diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 22e9d4b18..fd4d589d2 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -176,7 +176,7 @@ void getglobalz(DDukeActor* s); void OnEvent(int id, int pnum = -1, DDukeActor* snum = nullptr, int dist = -1); short EGS(short whatsect, int s_x, int s_y, int s_z, short s_pn, signed char s_s, signed char s_xr, signed char s_yr, short s_a, short s_ve, int s_zv, short s_ow, signed char s_ss); -void ceilingglass(int snum, int sectnum, int cnt); +void ceilingglass(DDukeActor* snum, int sectnum, int cnt); void spriteglass(DDukeActor* snum, int cnt); void lotsofcolourglass(DDukeActor* snum, int wallNum, int cnt); void lotsofglass(int snum, int wallnum, int cnt); diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index ca62a25a7..3560ad414 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -599,7 +599,7 @@ bool checkhitswitch_d(int snum, int ww, DDukeActor *act) if (act && (flags & SF_TALK) == 0) S_PlaySound3D(hitag, act, &v); else - S_PlayActorSound(hitag, ps[snum].i); + S_PlayActorSound(hitag, ps[snum].GetActor()); } return 1; @@ -961,8 +961,8 @@ bool checkhitceiling_d(int sn) case TECHLIGHT2: case TECHLIGHT4: - ceilingglass(ps[myconnectindex].i, sn, 10); - S_PlayActorSound(GLASS_BREAKING, ps[screenpeek].i); + ceilingglass(ps[myconnectindex].GetActor(), sn, 10); + S_PlayActorSound(GLASS_BREAKING, ps[screenpeek].GetActor()); if (sector[sn].ceilingpicnum == WALLLIGHT1) sector[sn].ceilingpicnum = WALLLIGHTBUST1; @@ -1499,6 +1499,7 @@ void checksectors_d(int snum) int neartaghitdist; p = &ps[snum]; + auto pact = p->GetActor(); switch (sector[p->cursectnum].lotag) { @@ -1521,7 +1522,7 @@ void checksectors_d(int snum) if (sector[p->cursectnum].lotag >= 10000 && sector[p->cursectnum].lotag < 16383) { if (snum == screenpeek || ud.coop == 1) - S_PlayActorSound(sector[p->cursectnum].lotag - 10000, p->i); + S_PlayActorSound(sector[p->cursectnum].lotag - 10000, pact); sector[p->cursectnum].lotag = 0; } break; @@ -1569,7 +1570,7 @@ void checksectors_d(int snum) if (i < 1280 && hitscanwall >= 0 && wall[hitscanwall].overpicnum == MIRROR) if (wall[hitscanwall].lotag > 0 && S_CheckSoundPlaying(wall[hitscanwall].lotag) == 0 && snum == screenpeek) { - S_PlayActorSound(wall[hitscanwall].lotag, p->i); + S_PlayActorSound(wall[hitscanwall].lotag, pact); return; } @@ -1693,7 +1694,7 @@ void checksectors_d(int snum) } return; case PLUG: - S_PlayActorSound(SHORT_CIRCUIT, p->i); + S_PlayActorSound(SHORT_CIRCUIT, pact); p->GetActor()->s.extra -= 2 + (krand() & 3); SetPlayerPal(p, PalEntry(32, 48, 48, 64)); break; @@ -1758,8 +1759,8 @@ void checksectors_d(int snum) if (abs(hits(p->GetActor())) < 512) { if ((krand() & 255) < 16) - S_PlayActorSound(DUKE_SEARCH2, p->i); - else S_PlayActorSound(DUKE_SEARCH, p->i); + S_PlayActorSound(DUKE_SEARCH2, pact); + else S_PlayActorSound(DUKE_SEARCH, pact); return; } diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index ee47d979f..431db9847 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -1399,7 +1399,7 @@ void checkplayerhurt_r(struct player_struct* p, const Collision &coll) p->GetActor()->s.extra -= 5; p->hurt_delay = 16; SetPlayerPal(p, PalEntry(32, 32, 0, 0)); - S_PlayActorSound(DUKE_LONGTERM_PAIN, p->i); + S_PlayActorSound(DUKE_LONGTERM_PAIN, p->GetActor()); } break; } @@ -1449,8 +1449,8 @@ bool checkhitceiling_r(int sn) case RRTILE2898: - ceilingglass(ps[myconnectindex].i, sn, 10); - S_PlayActorSound(GLASS_BREAKING, ps[screenpeek].i); + ceilingglass(ps[myconnectindex].GetActor(), sn, 10); + S_PlayActorSound(GLASS_BREAKING, ps[screenpeek].GetActor()); if (sector[sn].ceilingpicnum == WALLLIGHT1) sector[sn].ceilingpicnum = WALLLIGHTBUST1; @@ -2439,6 +2439,7 @@ void checksectors_r(int snum) int neartaghitdist; p = &ps[snum]; + auto pact = p->GetActor(); switch (sector[p->cursectnum].lotag) { @@ -2465,7 +2466,7 @@ void checksectors_r(int snum) if (sector[p->cursectnum].lotag >= 10000) { if (snum == screenpeek || ud.coop == 1) - S_PlayActorSound(sector[p->cursectnum].lotag - 10000, p->i); + S_PlayActorSound(sector[p->cursectnum].lotag - 10000, pact); sector[p->cursectnum].lotag = 0; } break; @@ -2496,20 +2497,20 @@ void checksectors_r(int snum) if (hitscanwall >= 0 && wall[hitscanwall].overpicnum == MIRROR && snum == screenpeek) if (numplayers == 1) { - if (S_CheckActorSoundPlaying(p->i, 27) == 0 && S_CheckActorSoundPlaying(p->i, 28) == 0 && S_CheckActorSoundPlaying(p->i, 29) == 0 - && S_CheckActorSoundPlaying(p->i, 257) == 0 && S_CheckActorSoundPlaying(p->i, 258) == 0) + if (S_CheckActorSoundPlaying(pact, 27) == 0 && S_CheckActorSoundPlaying(pact, 28) == 0 && S_CheckActorSoundPlaying(pact, 29) == 0 + && S_CheckActorSoundPlaying(pact, 257) == 0 && S_CheckActorSoundPlaying(pact, 258) == 0) { short snd = krand() % 5; if (snd == 0) - S_PlayActorSound(27, p->i); + S_PlayActorSound(27, pact); else if (snd == 1) - S_PlayActorSound(28, p->i); + S_PlayActorSound(28, pact); else if (snd == 2) - S_PlayActorSound(29, p->i); + S_PlayActorSound(29, pact); else if (snd == 3) - S_PlayActorSound(257, p->i); + S_PlayActorSound(257, pact); else if (snd == 4) - S_PlayActorSound(258, p->i); + S_PlayActorSound(258, pact); } return; } @@ -2517,9 +2518,9 @@ void checksectors_r(int snum) else { if (hitscanwall >= 0 && wall[hitscanwall].overpicnum == MIRROR) - if (wall[hitscanwall].lotag > 0 && S_CheckActorSoundPlaying(p->i, wall[hitscanwall].lotag) == 0 && snum == screenpeek) + if (wall[hitscanwall].lotag > 0 && S_CheckActorSoundPlaying(pact, wall[hitscanwall].lotag) == 0 && snum == screenpeek) { - S_PlayActorSound(wall[hitscanwall].lotag, p->i); + S_PlayActorSound(wall[hitscanwall].lotag, pact); return; } } @@ -2663,7 +2664,7 @@ void checksectors_r(int snum) case RRTILE2122: if (p->last_pissed_time == 0) { - S_PlayActorSound(435, p->i); + S_PlayActorSound(435, pact); p->last_pissed_time = 26 * 220; p->transporter_hold = 29 * 2; @@ -2680,8 +2681,8 @@ void checksectors_r(int snum) else if (p->GetActor()->s.extra < max_player_health) p->GetActor()->s.extra = max_player_health; } - else if (S_CheckActorSoundPlaying(p->i, DUKE_GRUNT) == 0) - S_PlayActorSound(DUKE_GRUNT, p->i); + else if (S_CheckActorSoundPlaying(pact, DUKE_GRUNT) == 0) + S_PlayActorSound(DUKE_GRUNT, pact); return; case WATERFOUNTAIN: if (neartagsprite->temp_data[0] != 1) @@ -2692,12 +2693,12 @@ void checksectors_r(int snum) if (p->GetActor()->s.extra < max_player_health) { p->GetActor()->s.extra++; - S_PlayActorSound(DUKE_DRINKING, p->i); + S_PlayActorSound(DUKE_DRINKING, pact); } } return; case PLUG: - S_PlayActorSound(SHORT_CIRCUIT, p->i); + S_PlayActorSound(SHORT_CIRCUIT, pact); p->GetActor()->s.extra -= 2 + (krand() & 3); SetPlayerPal(p, PalEntry(32, 48, 48, 64)); break; @@ -2710,8 +2711,8 @@ void checksectors_r(int snum) if (abs(hits(p->GetActor())) < 512) { if ((krand() & 255) < 16) - S_PlayActorSound(DUKE_SEARCH2, p->i); - else S_PlayActorSound(DUKE_SEARCH, p->i); + S_PlayActorSound(DUKE_SEARCH2, pact); + else S_PlayActorSound(DUKE_SEARCH, pact); return; } @@ -2739,9 +2740,9 @@ void checksectors_r(int snum) else { if (neartagsprite->spriteextra > 3) - S_PlayActorSound(99, p->i); + S_PlayActorSound(99, pact); else - S_PlayActorSound(419, p->i); + S_PlayActorSound(419, pact); FTA(41, p); } } @@ -2759,9 +2760,9 @@ void checksectors_r(int snum) else { if (neartagsprite->spriteextra > 3) - S_PlayActorSound(99, p->i); + S_PlayActorSound(99, pact); else - S_PlayActorSound(419, p->i); + S_PlayActorSound(419, pact); FTA(41, p); } } @@ -2832,8 +2833,8 @@ void dofurniture(int wl, int sect, int snum) var_C = 0; if (var_C) { - if (S_CheckActorSoundPlaying(ps[snum].i, 389) == 0) - S_PlayActorSound(389, ps[snum].i); + if (S_CheckActorSoundPlaying(ps[snum].GetActor(), 389) == 0) + S_PlayActorSound(389, ps[snum].GetActor()); for (i = startwall; i < endwall; i++) { x = wall[i].x; diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index f0ea4755e..9373d8c02 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -1168,11 +1168,11 @@ void spriteglass(DDukeActor* actor, int n) // //--------------------------------------------------------------------------- -void ceilingglass(int i, int sectnum, int n) +void ceilingglass(DDukeActor* actor, int sectnum, int n) { int j, xv, yv, z, x1, y1; int a, s, startwall, endwall; - auto sp = &sprite[i]; + auto sp = &actor->s; startwall = sector[sectnum].wallptr; endwall = startwall + sector[sectnum].wallnum; @@ -1191,7 +1191,7 @@ void ceilingglass(int i, int sectnum, int n) y1 += yv; a = krand() & 2047; z = sector[sectnum].ceilingz + ((krand() & 15) << 8); - EGS(sectnum, x1, y1, z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, (krand() & 31), 0, i, 5); + EGS(sectnum, x1, y1, z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, (krand() & 31), 0, actor, 5); } } }