diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 655402825..8aab2a8ea 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -61,7 +61,7 @@ void RANDOMSCRAP(DDukeActor* origin) { int r1 = krand(), r2 = krand(), r3 = krand(), r4 = krand(), r5 = krand(), r6 = krand(), r7 = krand(); int v = isRR() ? 16 : 48; - EGS(origin->s->sectnum, + EGS(origin->s->sector(), origin->s->x + (r7 & 255) - 128, origin->s->y + (r6 & 255) - 128, origin->s->z - (8 << 8) - (r5 & 8191), TILE_SCRAP6 + (r4 & 15), -8, v, v, r3 & 2047, (r2 & 63) + 64, -512 - (r1 & 2047), origin, 5); } @@ -268,7 +268,7 @@ void lotsofstuff(DDukeActor* actor, int n, int spawntype) for (int i = n; i > 0; i--) { int r1 = krand(), r2 = krand(); // using the RANDCORRECT version from RR. - auto j = EGS(s->sectnum, s->x, s->y, s->z - (r2 % (47 << 8)), spawntype, -32, 8, 8, r1 & 2047, 0, 0, actor, 5); + auto j = EGS(s->sector(), s->x, s->y, s->z - (r2 % (47 << 8)), spawntype, -32, 8, 8, r1 & 2047, 0, 0, actor, 5); j->s->cstat = krand() & 12; } } @@ -1358,7 +1358,7 @@ void movetongue(DDukeActor *actor, int tongue, int jaw) s->z = Owner->s->z - (34 << 8); for (int k = 0; k < actor->temp_data[0]; k++) { - auto q = EGS(s->sectnum, + auto q = EGS(s->sector(), s->x + MulScale(k, bcos(s->ang), 9), s->y + MulScale(k, bsin(s->ang), 9), s->z + ((k * Sgn(s->zvel)) * abs(s->zvel / 12)), tongue, -40 + (k << 1), @@ -1370,7 +1370,7 @@ void movetongue(DDukeActor *actor, int tongue, int jaw) } } int k = actor->temp_data[0]; // do not depend on the above loop counter. - auto spawned = EGS(s->sectnum, + auto spawned = EGS(s->sector(), s->x + MulScale(k, bcos(s->ang), 9), s->y + MulScale(k, bsin(s->ang), 9), s->z + ((k * Sgn(s->zvel)) * abs(s->zvel / 12)), jaw, -40, @@ -2620,7 +2620,7 @@ void gutsdir(DDukeActor* actor, int gtype, int n, int p) int r1 = krand(); int r2 = krand(); // TRANSITIONAL: owned by a player??? - EGS(actor->s->sectnum, actor->s->x, actor->s->y, gutz, gtype, -32, sx, sy, a, 256 + (r2 & 127), -512 - (r1 & 2047), ps[p].GetActor(), 5); + EGS(actor->s->sector(), actor->s->x, actor->s->y, gutz, gtype, -32, sx, sy, a, 256 + (r2 & 127), -512 - (r1 & 2047), ps[p].GetActor(), 5); } } diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index ca4539d5c..90744a7aa 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -669,7 +669,7 @@ void guts_d(DDukeActor* actor, int gtype, int n, int p) int r4 = krand(); int r5 = krand(); // TRANSITIONAL: owned by a player??? - auto spawned = EGS(s->sectnum, s->x + (r5 & 255) - 128, s->y + (r4 & 255) - 128, gutz - (r3 & 8191), gtype, -32, sx, sy, a, 48 + (r2 & 31), -512 - (r1 & 2047), ps[p].GetActor(), 5); + auto spawned = EGS(s->sector(), s->x + (r5 & 255) - 128, s->y + (r4 & 255) - 128, gutz - (r3 & 8191), gtype, -32, sx, sy, a, 48 + (r2 & 31), -512 - (r1 & 2047), ps[p].GetActor(), 5); if (spawned->s->picnum == JIBS2) { spawned->s->xrepeat >>= 2; @@ -1229,7 +1229,7 @@ static void movefireext(DDukeActor* actor) for (int k = 0; k < 16; k++) { - auto spawned = EGS(actor->s->sectnum, actor->s->x, actor->s->y, actor->s->z - (krand() % (48 << 8)), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (actor->s->zvel >> 2), actor, 5); + auto spawned = EGS(actor->s->sector(), actor->s->x, actor->s->y, actor->s->z - (krand() % (48 << 8)), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (actor->s->zvel >> 2), actor, 5); spawned->s->pal = 2; } @@ -1804,7 +1804,7 @@ static void weaponcommon_d(DDukeActor* proj) { for (k = -3; k < 2; k++) { - auto spawned = EGS(s->sectnum, + auto spawned = EGS(s->sector(), s->x + MulScale(k, bcos(s->ang), 9), s->y + MulScale(k, bsin(s->ang), 9), s->z + ((k * Sgn(s->zvel)) * abs(s->zvel / 24)), FIRELASER, -40 + (k << 2), @@ -2353,7 +2353,7 @@ static void greenslime(DDukeActor *actor) return; for (j = 16; j >= 0; j--) { - auto k = EGS(s->sectnum, s->x, s->y, s->z, GLASSPIECES + (j % 3), -32, 36, 36, krand() & 2047, 32 + (krand() & 63), 1024 - (krand() & 1023), actor, 5); + auto k = EGS(s->sector(), s->x, s->y, s->z, GLASSPIECES + (j % 3), -32, 36, 36, krand() & 2047, 32 + (krand() & 63), 1024 - (krand() & 1023), actor, 5); k->s->pal = 1; } ps[p].actors_killed++; @@ -2391,7 +2391,7 @@ static void greenslime(DDukeActor *actor) { for (x = 0; x < 8; x++) { - auto j = EGS(s->sectnum, s->x, s->y, s->z - (8 << 8), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), actor, 5); + auto j = EGS(s->sector(), s->x, s->y, s->z - (8 << 8), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), actor, 5); j->s->pal = 6; } @@ -2506,7 +2506,7 @@ static void greenslime(DDukeActor *actor) for (x = 0; x < 8; x++) { - auto j = EGS(s->sectnum, s->x, s->y, s->z - (8 << 8), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), actor, 5); + auto j = EGS(s->sector(), s->x, s->y, s->z - (8 << 8), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), actor, 5); j->s->pal = 6; } t[0] = -3; diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index ec9eaf701..450be26df 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -495,7 +495,7 @@ void guts_r(DDukeActor* actor, int gtype, int n, int p) int r4 = krand(); int r5 = krand(); // TRANSITIONAL: owned by a player??? - auto spawned = EGS(s->sectnum, s->x + (r5 & 255) - 128, s->y + (r4 & 255) - 128, gutz - (r3 & 8191), gtype, -32, sx >> 1, sy >> 1, a, 48 + (r2 & 31), -512 - (r1 & 2047), ps[p].GetActor(), 5); + auto spawned = EGS(s->sector(), s->x + (r5 & 255) - 128, s->y + (r4 & 255) - 128, gutz - (r3 & 8191), gtype, -32, sx >> 1, sy >> 1, a, 48 + (r2 & 31), -512 - (r1 & 2047), ps[p].GetActor(), 5); if (pal != 0) spawned->s->pal = pal; } @@ -1426,7 +1426,7 @@ static void weaponcommon_r(DDukeActor *proj) { for (k = -3; k < 2; k++) { - auto x = EGS(s->sectnum, + auto x = EGS(s->sector(), s->x + MulScale(k, bcos(s->ang), 9), s->y + MulScale(k, bsin(s->ang), 9), s->z + ((k * Sgn(s->zvel)) * abs(s->zvel / 24)), FIRELASER, -40 + (k << 2), @@ -3359,7 +3359,7 @@ void handle_se06_r(DDukeActor *actor) ns->s->pal = 33; if (!hulkspawn) { - ns = EGS(s->sectnum, s->x, s->y, s->sector()->ceilingz + 119428, 3677, -8, 16, 16, 0, 0, 0, actor, 5); + ns = EGS(s->sector(), s->x, s->y, s->sector()->ceilingz + 119428, 3677, -8, 16, 16, 0, 0, 0, actor, 5); ns->s->cstat = 514; ns->s->pal = 7; ns->s->xrepeat = 80; diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 1c68272a6..cd7c34b40 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -2162,7 +2162,7 @@ int ParseState::parse(void) s = 0; else s = (krand()%3); - auto l = EGS(g_sp->sectnum, + auto l = EGS(g_sp->sector(), g_sp->x + (krand() & 255) - 128, g_sp->y + (krand() & 255) - 128, g_sp->z - (8 << 8) - (krand() & 8191), dnum + s, g_sp->shade, 32 + (krand() & 15), 32 + (krand() & 15), krand() & 2047, (krand() & 127) + 32, -(krand() & 2047), g_ac, 5); diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 0a7399b6a..3de4e16b6 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -281,7 +281,7 @@ void hud_input(int plnum) p->inven_icon = 3; auto pactor = - EGS(p->cursectnum, + EGS(p->cursector(), p->pos.x, p->pos.y, p->pos.z + (30 << 8), TILE_APLAYER, -64, 0, 0, p->angle.ang.asbuild(), 0, 0, nullptr, 10); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 10e7d0e4a..670b324a7 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -134,7 +134,7 @@ void forceplayerangle(int snum) void tracers(int x1, int y1, int z1, int x2, int y2, int z2, int n) { int i, xv, yv, zv; - int sect = -1; + sectortype* sect = nullptr; i = n + 1; xv = (x2 - x1) / i; @@ -150,9 +150,9 @@ void tracers(int x1, int y1, int z1, int x2, int y2, int z2, int n) y1 += yv; z1 += zv; updatesector(x1, y1, §); - if (sect >= 0) + if (sect) { - if (sector[sect].lotag == 2) + if (sect->lotag == 2) EGS(sect, x1, y1, z1, TILE_WATERBUBBLE, -32, 4 + (krand() & 3), 4 + (krand() & 3), krand() & 2047, 0, 0, ps[0].GetActor(), 5); else EGS(sect, x1, y1, z1, TILE_SMALLSMOKE, -32, 14, 14, 0, 0, 0, ps[0].GetActor(), 5); diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 5a2f19c1e..8d30b38f9 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -126,7 +126,7 @@ static void shootfireball(DDukeActor *actor, int p, int sx, int sy, int sz, int sizy = 7; } - auto spawned = EGS(s->sectnum, sx, sy, sz, FIREBALL, -127, sizx, sizy, sa, vel, zvel, actor, (short)4); + auto spawned = EGS(s->sector(), sx, sy, sz, FIREBALL, -127, sizx, sizy, sa, vel, zvel, actor, (short)4); auto spr = spawned->s; spr->extra += (krand() & 7); if (s->picnum == BOSS5 || p >= 0) @@ -263,7 +263,7 @@ static void shootknee(DDukeActor* actor, int p, int sx, int sy, int sz, int sa) { if (hitwallp || hitsprt) { - auto knee = EGS(sectnum(hitsectp), hitx, hity, hitz, KNEE, -15, 0, 0, sa, 32, 0, actor, 4); + auto knee = EGS(hitsectp, hitx, hity, hitz, KNEE, -15, 0, 0, sa, 32, 0, actor, 4); knee->s->extra += (krand() & 7); if (p >= 0) { @@ -421,7 +421,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa DDukeActor* spark; if (p >= 0) { - spark = EGS(sectnum(hitsectp), hitx, hity, hitz, SHOTSPARK1, -15, 10, 10, sa, 0, 0, actor, 4); + spark = EGS(hitsectp, hitx, hity, hitz, SHOTSPARK1, -15, 10, 10, sa, 0, 0, actor, 4); spark->s->extra = ScriptCode[gs.actorinfo[atwith].scriptaddress]; spark->s->extra += (krand() % 6); @@ -535,7 +535,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa } else { - spark = EGS(sectnum(hitsectp), hitx, hity, hitz, SHOTSPARK1, -15, 24, 24, sa, 0, 0, actor, 4); + spark = EGS(hitsectp, hitx, hity, hitz, SHOTSPARK1, -15, 24, 24, sa, 0, 0, actor, 4); spark->s->extra = ScriptCode[gs.actorinfo[atwith].scriptaddress]; if (hitact) @@ -565,7 +565,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa static void shootstuff(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, int atwith) { spritetype* const s = actor->s; - int sect = s->sectnum; + sectortype* sect = s->sector(); int vel, zvel; int l, scount; @@ -676,7 +676,7 @@ static void shootstuff(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, static void shootrpg(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, int atwith) { auto s = actor->s; - int sect = s->sectnum; + auto sect = s->sector(); int vel, zvel; int l, scount; @@ -877,7 +877,7 @@ static void shootlaser(DDukeActor* actor, int p, int sx, int sy, int sz, int sa) if (j == 1) { - auto bomb = EGS(sectnum(hitsectp), hitx, hity, hitz, TRIPBOMB, -16, 4, 5, sa, 0, 0, actor, 6); + auto bomb = EGS(hitsectp, hitx, hity, hitz, TRIPBOMB, -16, 4, 5, sa, 0, 0, actor, 6); if (isWW2GI()) { int lTripBombControl = GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, nullptr, -1); @@ -918,7 +918,7 @@ static void shootlaser(DDukeActor* actor, int p, int sx, int sy, int sz, int sa) static void shootgrowspark(DDukeActor* actor, int p, int sx, int sy, int sz, int sa) { auto s = actor->s; - int sect = s->sectnum; + auto sect = s->sector(); int zvel; int k; int hitx, hity, hitz; @@ -973,7 +973,7 @@ static void shootgrowspark(DDukeActor* actor, int p, int sx, int sy, int sz, int //RESHOOTGROW: s->cstat &= ~257; - hitscan(sx, sy, sz, sect, bcos(sa), bsin(sa), + hitscan(sx, sy, sz, sectnum(sect), bcos(sa), bsin(sa), zvel << 6, &hitsectp, &wal, &hitsprt, &hitx, &hity, &hitz, CLIPMASK1); s->cstat |= 257; @@ -1009,7 +1009,7 @@ void shoot_d(DDukeActor* actor, int atwith) { spritetype* const s = actor->s; - int sect, l, j; + int l, j; int sx, sy, sz, sa, p, vel, zvel, x, dal; if (s->picnum == TILE_APLAYER) { @@ -1029,7 +1029,7 @@ void shoot_d(DDukeActor* actor, int atwith) } - sect = s->sectnum; + auto sect = s->sector(); zvel = 0; if (s->picnum == TILE_APLAYER) @@ -1074,7 +1074,7 @@ void shoot_d(DDukeActor* actor, int atwith) case FIREFLY: // BOSS5 shot { auto k = spawn(actor, atwith); - k->s->sectnum = sect; + k->s->sectnum = sectnum(sect); k->s->x = sx; k->s->y = sy; k->s->z = sz; @@ -2213,7 +2213,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect) i = -512 - MulScale(p->horizon.sum().asq16(), 20, 16); } - auto spawned = EGS(p->cursectnum, + auto spawned = EGS(p->cursector(), p->pos.x + p->angle.ang.bcos(-6), p->pos.y + p->angle.ang.bsin(-6), p->pos.z, HEAVYHBOMB, -16, 9, 9, diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index c4609b307..e428a1f81 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -148,12 +148,12 @@ static void shootmelee(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, DDukeActor* wpn; if (isRRRA() && atwith == SLINGBLADE) { - wpn = EGS(sectnum(hitsectp), hitx, hity, hitz, SLINGBLADE, -15, 0, 0, sa, 32, 0, actor, 4); + wpn = EGS(hitsectp, hitx, hity, hitz, SLINGBLADE, -15, 0, 0, sa, 32, 0, actor, 4); wpn->s->extra += 50; } else { - wpn = EGS(sectnum(hitsectp), hitx, hity, hitz, KNEE, -15, 0, 0, sa, 32, 0, actor, 4); + wpn = EGS(hitsectp, hitx, hity, hitz, KNEE, -15, 0, 0, sa, 32, 0, actor, 4); wpn->s->extra += (krand() & 7); } if (p >= 0) @@ -311,7 +311,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa DDukeActor* spark; if (p >= 0) { - spark = EGS(sectnum(hitsectp), hitx, hity, hitz, SHOTSPARK1, -15, 10, 10, sa, 0, 0, actor, 4); + spark = EGS(hitsectp, hitx, hity, hitz, SHOTSPARK1, -15, 10, 10, sa, 0, 0, actor, 4); spark->s->extra = ScriptCode[gs.actorinfo[atwith].scriptaddress]; spark->s->extra += (krand() % 6); @@ -431,7 +431,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa } else { - spark = EGS(sectnum(hitsectp), hitx, hity, hitz, SHOTSPARK1, -15, 24, 24, sa, 0, 0, actor, 4); + spark = EGS(hitsectp, hitx, hity, hitz, SHOTSPARK1, -15, 24, 24, sa, 0, 0, actor, 4); spark->s->extra = ScriptCode[gs.actorinfo[atwith].scriptaddress]; if (hitsprt) @@ -461,7 +461,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa static void shootstuff(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, int atwith) { auto s = actor->s; - int sect = s->sectnum; + auto sect = s->sector(); int vel = 0, zvel; int scount; @@ -601,7 +601,7 @@ static void shootstuff(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, static void shootrpg(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, int atwith) { auto s = actor->s; - int sect = s->sectnum; + auto sect = s->sector(); int vel, zvel; int l, scount; @@ -753,7 +753,7 @@ static void shootrpg(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, i static void shootwhip(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, int atwith) { auto s = actor->s; - int sect = s->sectnum; + auto sect = s->sector(); int vel = 0, zvel; int scount; @@ -829,11 +829,11 @@ void shoot_r(DDukeActor* actor, int atwith) { spritetype* const s = actor->s; - int sect, sa, p; + int sa, p; int sx, sy, sz, vel, zvel, x; - sect = s->sectnum; + auto const sect = s->sector(); zvel = 0; if (s->picnum == TILE_APLAYER) @@ -2736,7 +2736,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect) i = -512 - MulScale(p->horizon.sum().asq16(), 20, 16); } - auto spawned = EGS(p->cursectnum, + auto spawned = EGS(p->cursector(), p->pos.x + p->angle.ang.bcos(-6), p->pos.y + p->angle.ang.bsin(-6), p->pos.z, HEAVYHBOMB, -16, 9, 9, @@ -3146,7 +3146,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect) i = -512 - MulScale(p->horizon.sum().asq16(), 20, 16); } - EGS(p->cursectnum, + EGS(p->cursector(), p->pos.x + p->angle.ang.bcos(-6), p->pos.y + p->angle.ang.bsin(-6), p->pos.z, TRIPBOMBSPRITE, -16, 9, 9, diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index 2318b508e..36dd6c8b2 100644 --- a/source/games/duke/src/player_w.cpp +++ b/source/games/duke/src/player_w.cpp @@ -340,7 +340,7 @@ void operateweapon_ww(int snum, ESyncBits actions, int psect) i = -512 - MulScale(p->horizon.sum().asq16(), 20, 16); } - auto j = EGS(p->cursectnum, + auto j = EGS(p->cursector(), p->pos.x + p->angle.ang.bcos(-6), p->pos.y + p->angle.ang.bsin(-6), p->pos.z, HEAVYHBOMB, -16, 9, 9, diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index a1c2ec6b2..a0c097161 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -508,7 +508,7 @@ void resetpspritevars(int g) int aimmode[MAXPLAYERS]; STATUSBARTYPE tsbar[MAXPLAYERS]; - EGS(ps[0].cursectnum, ps[0].pos.x, ps[0].pos.y, ps[0].pos.z, + EGS(ps[0].cursector(), ps[0].pos.x, ps[0].pos.y, ps[0].pos.z, TILE_APLAYER, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, nullptr, 10); if (ud.recstat != 2) for (i = 0; i < MAXPLAYERS; i++) diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 463c715fe..24938b89e 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -674,16 +674,17 @@ void checkhitwall_d(DDukeActor* spr, walltype* wal, int x, int y, int z, int atw [[fallthrough]]; case BIGFORCE: { - updatesector(x, y, &sn); - if (sn < 0) return; + sectortype* sptr = nullptr; + updatesector(x, y, &sptr); + if (sptr == nullptr) return; DDukeActor* spawned; if (atwith == -1) - spawned = EGS(sn, x, y, z, FORCERIPPLE, -127, 8, 8, 0, 0, 0, spr, 5); + spawned = EGS(sptr, x, y, z, FORCERIPPLE, -127, 8, 8, 0, 0, 0, spr, 5); else { if (atwith == CHAINGUN) - spawned = EGS(sn, x, y, z, FORCERIPPLE, -127, 16 + spr->s->xrepeat, 16 + spr->s->yrepeat, 0, 0, 0, spr, 5); - else spawned = EGS(sn, x, y, z, FORCERIPPLE, -127, 32, 32, 0, 0, 0, spr, 5); + spawned = EGS(sptr, x, y, z, FORCERIPPLE, -127, 16 + spr->s->xrepeat, 16 + spr->s->yrepeat, 0, 0, 0, spr, 5); + else spawned = EGS(sptr, x, y, z, FORCERIPPLE, -127, 32, 32, 0, 0, 0, spr, 5); } spawned->s->cstat |= 18 + 128; @@ -708,7 +709,9 @@ void checkhitwall_d(DDukeActor* spr, walltype* wal, int x, int y, int z, int atw case GLASS: { - updatesector(x, y, &sn); if (sn < 0) return; + sectortype* sptr = nullptr; + updatesector(x, y, &sptr); + if (sptr == nullptr) return; wal->overpicnum = GLASS2; lotsofglass(spr, wal, 10); wal->cstat = 0; @@ -716,7 +719,7 @@ void checkhitwall_d(DDukeActor* spr, walltype* wal, int x, int y, int z, int atw if (wal->nextwall >= 0) wal->nextWall()->cstat = 0; - auto spawned = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, spr, 3); + auto spawned = EGS(sptr, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, spr, 3); spawned->s->lotag = 128; spawned->temp_data[1] = 5; spawned->temp_walls[0] = wal; @@ -724,7 +727,9 @@ void checkhitwall_d(DDukeActor* spr, walltype* wal, int x, int y, int z, int atw return; } case STAINGLASS1: - updatesector(x, y, &sn); if (sn < 0) return; + sectortype* sptr = nullptr; + updatesector(x, y, &sptr); + if (sptr == nullptr) return; lotsofcolourglass(spr, wal, 80); wal->cstat = 0; if (wal->nextwall >= 0) @@ -1101,7 +1106,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) case HEAVYHBOMB: for (k = 0; k < 64; k++) { - auto j = EGS(s->sectnum, s->x, s->y, s->z - (krand() % (48 << 8)), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), targ, 5); + auto j = EGS(s->sector(), s->x, s->y, s->z - (krand() % (48 << 8)), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), targ, 5); j->s->pal = 8; } @@ -1116,7 +1121,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) case HANGLIGHT: case GENERICPOLE2: for (k = 0; k < 6; k++) - EGS(s->sectnum, s->x, s->y, s->z - (8 << 8), SCRAP1 + (krand() & 15), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), targ, 5); + EGS(s->sector(), s->x, s->y, s->z - (8 << 8), SCRAP1 + (krand() & 15), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), targ, 5); S_PlayActorSound(GLASS_HEAVYBREAK, targ); deletesprite(targ); break; @@ -1146,7 +1151,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) if (gs.actorinfo[SHOTSPARK1].scriptaddress && pspr->extra != ScriptCode[gs.actorinfo[SHOTSPARK1].scriptaddress]) { for (j = 0; j < 15; j++) - EGS(s->sectnum, s->x, s->y, s->sector()->floorz - (12 << 8) - (j << 9), SCRAP1 + (krand() & 15), -8, 64, 64, + EGS(s->sector(), s->x, s->y, s->sector()->floorz - (12 << 8) - (j << 9), SCRAP1 + (krand() & 15), -8, 64, 64, krand() & 2047, (krand() & 127) + 64, -(krand() & 511) - 256, targ, 5); spawn(targ, EXPLOSION2); deletesprite(targ); diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 724915ec1..0817288d1 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -936,7 +936,7 @@ static void lotsofpopcorn(DDukeActor *actor, walltype* wal, int n) for (j = n - 1; j >= 0; j--) { a = sp->ang - 256 + (krand() & 511) + 1024; - EGS(sp->sectnum, sp->x, sp->y, sp->z, POPCORN, -32, 36, 36, a, 32 + (krand() & 63), 1024 - (krand() & 1023), actor, 5); + EGS(sp->sector(), sp->x, sp->y, sp->z, POPCORN, -32, 36, 36, a, 32 + (krand() & 63), 1024 - (krand() & 1023), actor, 5); } return; } @@ -966,7 +966,7 @@ static void lotsofpopcorn(DDukeActor *actor, walltype* wal, int n) if (z < -(32 << 8) || z >(32 << 8)) z = sp->z - (32 << 8) + (krand() & ((64 << 8) - 1)); a = sp->ang - 1024; - EGS(sp->sectnum, x1, y1, z, POPCORN, -32, 36, 36, a, 32 + (krand() & 63), -(krand() & 1023), actor, 5); + EGS(sp->sector(), x1, y1, z, POPCORN, -32, 36, 36, a, 32 + (krand() & 63), -(krand() & 1023), actor, 5); } } } @@ -1025,7 +1025,9 @@ void checkhitwall_r(DDukeActor* spr, walltype* wal, int x, int y, int z, int atw case RRTILE1973: { - updatesector(x, y, &sn); if (sn < 0) return; + sectortype* sptr = nullptr; + updatesector(x, y, &sptr); + if (sptr == nullptr) return; wal->overpicnum = GLASS2; lotsofpopcorn(spr, wal, 64); wal->cstat = 0; @@ -1033,7 +1035,7 @@ void checkhitwall_r(DDukeActor* spr, walltype* wal, int x, int y, int z, int atw if (wal->nextwall >= 0) wal->nextWall()->cstat = 0; - auto spawned = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, spr, 3); + auto spawned = EGS(sptr, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, spr, 3); spawned->s->lotag = SE_128_GLASS_BREAKING; spawned->temp_data[1] = 2; spawned->temp_walls[0] = wal; @@ -1042,7 +1044,9 @@ void checkhitwall_r(DDukeActor* spr, walltype* wal, int x, int y, int z, int atw } case GLASS: { - updatesector(x, y, &sn); if (sn < 0) return; + sectortype* sptr = nullptr; + updatesector(x, y, &sptr); + if (sptr == nullptr) return; wal->overpicnum = GLASS2; lotsofglass(spr, wal, 10); wal->cstat = 0; @@ -1050,7 +1054,7 @@ void checkhitwall_r(DDukeActor* spr, walltype* wal, int x, int y, int z, int atw if (wal->nextwall >= 0) wal->nextWall()->cstat = 0; - auto spawned = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, spr, 3); + auto spawned = EGS(sptr, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, spr, 3); spawned->s->lotag = SE_128_GLASS_BREAKING; spawned->temp_data[1] = 2; spawned->temp_walls[0] = wal; @@ -2068,7 +2072,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) lotsofglass(targ, nullptr, 10); s->picnum++; for (k = 0; k < 6; k++) - EGS(s->sectnum, s->x, s->y, s->z - (8 << 8), SCRAP6 + (krand() & 15), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), targ, 5); + EGS(s->sector(), s->x, s->y, s->z - (8 << 8), SCRAP6 + (krand() & 15), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), targ, 5); break; case BOWLINGBALL: pspr->xvel = (s->xvel >> 1) + (s->xvel >> 2); @@ -2160,7 +2164,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) case UWHIP: for (k = 0; k < 64; k++) { - auto j = EGS(s->sectnum, s->x, s->y, s->z - (krand() % (48 << 8)), SCRAP6 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), targ, 5); + auto j = EGS(s->sector(), s->x, s->y, s->z - (krand() % (48 << 8)), SCRAP6 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), targ, 5); j->s->pal = 8; } @@ -2193,7 +2197,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) if (gs.actorinfo[SHOTSPARK1].scriptaddress && pspr->extra != ScriptCode[gs.actorinfo[SHOTSPARK1].scriptaddress]) { for (j = 0; j < 15; j++) - EGS(s->sectnum, s->x, s->y, s->sector()->floorz - (12 << 8) - (j << 9), SCRAP1 + (krand() & 15), -8, 64, 64, + EGS(s->sector(), s->x, s->y, s->sector()->floorz - (12 << 8) - (j << 9), SCRAP1 + (krand() & 15), -8, 64, 64, krand() & 2047, (krand() & 127) + 64, -(krand() & 511) - 256, targ, 5); spawn(targ, EXPLOSION2); deletesprite(targ); diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index bed187773..3c8ef7ef7 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -143,7 +143,7 @@ int initspriteforspawn(DDukeActor* actj, int pn, const std::initializer_lists->sectnum, actj->s->x, actj->s->y, actj->s->z, pn, 0, 0, 0, 0, 0, 0, actj, 0); + auto spawned = EGS(actj->s->sector(), actj->s->x, actj->s->y, actj->s->z, pn, 0, 0, 0, 0, 0, 0, actj, 0); spawned->picnum = actj->s->picnum; sp = spawned->s; t = spawned->temp_data; @@ -1093,7 +1093,7 @@ void lotsofglass(DDukeActor *actor, walltype* wal, int n) for (j = n - 1; j >= 0; j--) { a = sp->ang - 256 + (krand() & 511) + 1024; - EGS(sp->sectnum, sp->x, sp->y, sp->z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), 1024 - (krand() & 1023), &hittype[j], 5); + EGS(sp->sector(), sp->x, sp->y, sp->z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), 1024 - (krand() & 1023), &hittype[j], 5); } return; } @@ -1118,7 +1118,7 @@ void lotsofglass(DDukeActor *actor, walltype* wal, int n) if (z < -(32 << 8) || z >(32 << 8)) z = sp->z - (32 << 8) + (krand() & ((64 << 8) - 1)); a = sp->ang - 1024; - EGS(sp->sectnum, x1, y1, z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), -(krand() & 1023), actor, 5); + EGS(sp->sector(), x1, y1, z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), -(krand() & 1023), actor, 5); } } } @@ -1137,7 +1137,7 @@ void spriteglass(DDukeActor* actor, int n) { int a = krand() & 2047; int z = sp->z - ((krand() & 16) << 8); - auto k = EGS(sp->sectnum, sp->x, sp->y, z, TILE_GLASSPIECES + (j % 3), krand() & 15, 36, 36, a, 32 + (krand() & 63), -512 - (krand() & 2047), actor, 5); + auto k = EGS(sp->sector(), sp->x, sp->y, z, TILE_GLASSPIECES + (j % 3), krand() & 15, 36, 36, a, 32 + (krand() & 63), -512 - (krand() & 2047), actor, 5); k->s->pal = sp->pal; } } @@ -1189,7 +1189,7 @@ void lotsofcolourglass(DDukeActor* actor, walltype* wal, int n) for (j = n - 1; j >= 0; j--) { a = krand() & 2047; - auto k = EGS(sp->sectnum, sp->x, sp->y, sp->z - (krand() & (63 << 8)), TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), 1024 - (krand() & 2047), actor, 5); + auto k = EGS(sp->sector(), sp->x, sp->y, sp->z - (krand() & (63 << 8)), TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), 1024 - (krand() & 2047), actor, 5); k->s->pal = krand() & 15; } return; @@ -1210,7 +1210,7 @@ void lotsofcolourglass(DDukeActor* actor, walltype* wal, int n) if (z < -(32 << 8) || z >(32 << 8)) z = sp->z - (32 << 8) + (krand() & ((64 << 8) - 1)); a = sp->ang - 1024; - auto k = EGS(sp->sectnum, x1, y1, z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), -(krand() & 2047), actor, 5); + auto k = EGS(sp->sector(), x1, y1, z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), -(krand() & 2047), actor, 5); k->s->pal = krand() & 7; } }