diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index f4b71a4d5..b797d2ab2 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1009,7 +1009,7 @@ static void movefireext(DDukeActor* actor) auto spawned = CreateActor(actor->sector(), actor->spr.pos.plusZ(krandf(-48)), PClass::FindActor("DukeScrap"), -8, DVector2(0.75, 0.75), a, vel, zvel, actor, STAT_MISC); if (spawned) { - if (spawned) spawned->spriteextra = SCRAP3 - gs.firstdebris + krand() & 3; + if (spawned) spawned->spriteextra = Scrap3 + krand() & 3; spawned->spr.pal = 2; } } @@ -2146,7 +2146,7 @@ static void greenslime(DDukeActor *actor) auto spawned = CreateActor(actor->sector(), actor->spr.pos.plusZ(-8), PClass::FindActor("DukeScrap"), -8, DVector2(0.75, 0.75), a, vel, zvel, actor, STAT_MISC); if (spawned) { - if (spawned) spawned->spriteextra = SCRAP3 - gs.firstdebris + krand() & 3; + if (spawned) spawned->spriteextra = Scrap3 + krand() & 3; spawned->spr.pal = 6; } } @@ -2262,7 +2262,7 @@ static void greenslime(DDukeActor *actor) auto spawned = CreateActor(actor->sector(), actor->spr.pos.plusZ(-8), PClass::FindActor("DukeScrap"), -8, DVector2(0.75, 0.75), a, vel, zvel, actor, STAT_MISC); if (spawned) { - if (spawned) spawned->spriteextra = SCRAP3 - gs.firstdebris + krand() & 3; + if (spawned) spawned->spriteextra = Scrap3 + krand() & 3; spawned->spr.pal = 6; } } diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index 014c4ec74..533fc7279 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -30,6 +30,18 @@ enum }; +enum EScrap +{ + Scrap6 = 0, + Scrap1 = 10, + Scrap2 = 14, + Scrap3 = 18, + Scrap4 = 22, + Scrap5 = 26, + ScrapMax = 30 +}; + + // the available palettes. These are indices into the global table of translations. enum basepal_t { BASEPAL = 0, diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 4ab30e4f8..f36c3c2fd 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -2154,6 +2154,7 @@ int ParseState::parse(void) { insptr++; int dnum = *insptr - gs.firstdebris; + if (dnum < 0 || dnum >= ScrapMax) break; // this code only works with scrap and nothing else. insptr++; int count = *insptr; bool weap = fi.spawnweapondebris(g_ac->spr.picnum); diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 8049bdda7..9161bd44f 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1077,7 +1077,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) auto spawned = CreateActor(targ->sector(), targ->spr.pos.plusZ(-48), PClass::FindActor("DukeScrap"), -8, DVector2(0.75, 0.75), a, vel, zvel, targ, STAT_MISC); if (spawned) { - if (spawned) spawned->spriteextra = SCRAP3 - gs.firstdebris + krand() & 3; + if (spawned) spawned->spriteextra = Scrap3 + krand() & 3; spawned->spr.pal = 6; } } @@ -1096,7 +1096,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) auto vel = krandf(4) + 4; auto zvel = -krandf(16) - targ->vel.Z * 0.25; auto spawned = CreateActor(targ->sector(), targ->spr.pos.plusZ(-8), PClass::FindActor("DukeScrap"), -8, DVector2(0.75, 0.75), a, vel, zvel, targ, STAT_MISC); - if (spawned) spawned->spriteextra = SCRAP1 - gs.firstdebris + krand() & 15; + if (spawned) spawned->spriteextra = Scrap1 + krand() & 15; } S_PlayActorSound(GLASS_HEAVYBREAK, targ); deletesprite(targ); @@ -1126,7 +1126,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) auto zvel = -krandf(2) - 1; auto spawned = CreateActor(targ->sector(), DVector3(targ->spr.pos.XY(), targ->sector()->floorz - 12 - j * 2), PClass::FindActor("DukeScrap"), -8, DVector2(1, 1), a, vel, zvel, targ, 5); - if (spawned) spawned->spriteextra = SCRAP1 - gs.firstdebris + krand() & 15; + if (spawned) spawned->spriteextra = Scrap1 + krand() & 15; } spawn(targ, EXPLOSION2); diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 76a723489..c11f2c3b6 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -2151,7 +2151,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) auto spawned = CreateActor(targ->sector(), DVector3(targ->spr.pos.XY(), targ->sector()->floorz - 12 - j * 2), PClass::FindActor("DukeScrap"), -8, DVector2(1, 1), a, vel, zvel, targ, 5); - if (spawned) spawned->spriteextra = SCRAP1 - gs.firstdebris + krand() & 15; + if (spawned) spawned->spriteextra = Scrap1 + krand() & 15; } spawn(targ, EXPLOSION2); deletesprite(targ); diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index ecf8c6a2f..b85f70a51 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -631,7 +631,6 @@ DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, freezerhurtowner); DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, impact_damage); DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, playerheight); DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, displayflags); -DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, firstdebris); DEFINE_GLOBAL_UNSIZED(gs) diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index 05e70dd00..eee42a1c2 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -1268,6 +1268,5 @@ struct DukeGameInfo native readonly native int freezerhurtowner; readonly native int impact_damage; readonly native double playerheight; - readonly native int firstdebris; readonly native int displayflags; }