diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index deba25c28..22e9d4b18 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -178,7 +178,7 @@ 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 spriteglass(DDukeActor* snum, int cnt); -void lotsofcolourglass(int snum, int wallNum, int cnt); +void lotsofcolourglass(DDukeActor* snum, int wallNum, int cnt); void lotsofglass(int snum, int wallnum, int cnt); void checkplayerhurt_d(struct player_struct* p, const Collision& coll); void checkplayerhurt_r(struct player_struct* p, const Collision& coll); diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index d5ab4766b..ca62a25a7 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -727,7 +727,7 @@ void checkhitwall_d(DDukeActor* spr, int dawallnum, int x, int y, int z, int atw } case STAINGLASS1: updatesector(x, y, &sn); if (sn < 0) return; - lotsofcolourglass(spr->GetIndex(), dawallnum, 80); + lotsofcolourglass(spr, dawallnum, 80); wal->cstat = 0; if (wal->nextwall >= 0) wall[wal->nextwall].cstat = 0; @@ -1188,7 +1188,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) fi.lotsofmoney(targ, 4 + (krand() & 3)); else if (s->picnum == STATUE || s->picnum == STATUEFLASH) { - lotsofcolourglass(targ->GetIndex(), -1, 40); + lotsofcolourglass(targ, -1, 40); S_PlayActorSound(GLASS_HEAVYBREAK, targ); } else if (s->picnum == VASE) diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index a772aa962..ee47d979f 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -918,20 +918,20 @@ void activatebysector_r(int sect, DDukeActor* activator) // //--------------------------------------------------------------------------- -static void lotsofpopcorn(short i, short wallnum, short n) +static void lotsofpopcorn(DDukeActor *actor, short wallnum, short n) { int j, xv, yv, z, x1, y1; short sect, a; sect = -1; - auto sp = &sprite[i]; + auto sp = &actor->s; if (wallnum < 0) { 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), i, 5); + EGS(sp->sectnum, sp->x, sp->y, sp->z, POPCORN, -32, 36, 36, a, 32 + (krand() & 63), 1024 - (krand() & 1023), actor, 5); } return; } @@ -962,7 +962,7 @@ static void lotsofpopcorn(short i, short wallnum, short 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), i, 5); + EGS(sp->sectnum, x1, y1, z, POPCORN, -32, 36, 36, a, 32 + (krand() & 63), -(krand() & 1023), actor, 5); } } } @@ -1023,7 +1023,7 @@ void checkhitwall_r(DDukeActor* spr, int dawallnum, int x, int y, int z, int atw { updatesector(x, y, &sn); if (sn < 0) return; wal->overpicnum = GLASS2; - lotsofpopcorn(spr->GetIndex(), dawallnum, 64); + lotsofpopcorn(spr, dawallnum, 64); wal->cstat = 0; if (wal->nextwall >= 0) @@ -1055,7 +1055,7 @@ void checkhitwall_r(DDukeActor* spr, int dawallnum, int x, int y, int z, int atw } case STAINGLASS1: updatesector(x, y, &sn); if (sn < 0) return; - lotsofcolourglass(spr->GetIndex(), dawallnum, 80); + lotsofcolourglass(spr, dawallnum, 80); wal->cstat = 0; if (wal->nextwall >= 0) wall[wal->nextwall].cstat = 0; @@ -2229,7 +2229,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) fi.lotsofmoney(targ, 4 + (krand() & 3)); else if (s->picnum == STATUE || s->picnum == STATUEFLASH) { - lotsofcolourglass(targ->GetIndex(), -1, 40); + lotsofcolourglass(targ, -1, 40); S_PlayActorSound(GLASS_HEAVYBREAK, targ); } else if (s->picnum == VASE) @@ -2354,13 +2354,13 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) if (pspr->picnum != FREEZEBLAST) //if (actortype[s->picnum] == 0) //TRANSITIONAL. Cannot be done right with EDuke mess backing the engine. { - j = fi.spawn(proj->GetIndex(), JIBS6); + auto spawned = spawn(proj, JIBS6); if (pspr->pal == 6) - sprite[j].pal = 6; - sprite[j].z += (4 << 8); - sprite[j].xvel = 16; - sprite[j].xrepeat = sprite[j].yrepeat = 24; - sprite[j].ang += 32 - (krand() & 63); + spawned->s.pal = 6; + spawned->s.z += (4 << 8); + spawned->s.xvel = 16; + spawned->s.xrepeat = spawned->s.yrepeat = 24; + spawned->s.ang += 32 - (krand() & 63); } j = pspr->owner; diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 2e4e1b8ff..f0ea4755e 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -1202,20 +1202,20 @@ void ceilingglass(int i, int sectnum, int n) // //--------------------------------------------------------------------------- -void lotsofcolourglass(int i, int wallnum, int n) +void lotsofcolourglass(DDukeActor* actor, int wallnum, int n) { int j, xv, yv, z, x1, y1; short sect = -1; - int a, k; - auto sp = &sprite[i]; + int a;; + auto sp = &actor->s; if (wallnum < 0) { for (j = n - 1; j >= 0; j--) { a = krand() & 2047; - 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), i, 5); - sprite[k].pal = krand() & 15; + 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); + k->s.pal = krand() & 15; } return; } @@ -1237,8 +1237,8 @@ void lotsofcolourglass(int i, int wallnum, int n) if (z < -(32 << 8) || z >(32 << 8)) z = sp->z - (32 << 8) + (krand() & ((64 << 8) - 1)); a = sp->ang - 1024; - k = EGS(sp->sectnum, x1, y1, z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), -(krand() & 2047), i, 5); - sprite[k].pal = krand() & 7; + auto k = EGS(sp->sectnum, x1, y1, z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), -(krand() & 2047), actor, 5); + k->s.pal = krand() & 7; } }