From a6600c200f95821a691df470985156f51740a793 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 30 Dec 2022 21:45:31 +0100 Subject: [PATCH] - a lot of simple picnum or TILE_* replacements. --- source/games/duke/src/actors_r.cpp | 2 +- source/games/duke/src/classnames.h | 9 ++++++++ source/games/duke/src/dukeactor.h | 1 - source/games/duke/src/gameexec.cpp | 6 ++--- source/games/duke/src/player_d.cpp | 2 +- source/games/duke/src/player_r.cpp | 22 +++++++++---------- source/games/duke/src/player_w.cpp | 2 +- source/games/duke/src/sectors_d.cpp | 3 +-- source/games/duke/src/sectors_r.cpp | 3 +-- source/games/duke/src/spawn.cpp | 14 ------------ source/games/duke/src/vmexports.cpp | 7 +++--- .../filter/redneck/rmapinfo.spawnclasses | 1 + .../zscript/games/duke/actors/redneckmisc.zs | 8 +++++++ 13 files changed, 41 insertions(+), 39 deletions(-) diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 67a0a966c..f3f053309 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -553,7 +553,7 @@ void handle_se06_r(DDukeActor *actor) ns->spr.pal = 7; ns->spr.scale = DVector2(1.25, 3.984375); } - ns = spawn(actor, 296); + ns = spawn(actor, RedneckTeleportClass); if (ns) { ns->spr.cstat = 0; diff --git a/source/games/duke/src/classnames.h b/source/games/duke/src/classnames.h index d55e1ce46..e0189d1e5 100644 --- a/source/games/duke/src/classnames.h +++ b/source/games/duke/src/classnames.h @@ -120,3 +120,12 @@ xx(RedneckRock) xx(RedneckRock2) xx(RedneckDestroyTags) xx(RedneckDestructo) +xx(RedneckDynamite) +xx(RedneckWaterSurface) +xx(RedneckLadder) +xx(RedneckTeleport) +xx(RedneckRevolver) +xx(RedneckShotgun) +xx(RedneckRipsaw) +xx(RedneckBlaster) +xx(RedneckPowderKeg) diff --git a/source/games/duke/src/dukeactor.h b/source/games/duke/src/dukeactor.h index d8228c304..4193d9d0b 100644 --- a/source/games/duke/src/dukeactor.h +++ b/source/games/duke/src/dukeactor.h @@ -19,7 +19,6 @@ inline int player_struct::GetPlayerNum() return actor->PlayerIndex(); } -DDukeActor* spawn(DDukeActor* spawner, int type); DDukeActor* spawn(DDukeActor* spawner, PClassActor* pname); // return type is int for scripting - the value must still be true or false! diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index e9ab3ceae..af5f91e53 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1894,7 +1894,7 @@ int ParseState::parse(void) case concmd_spawn: insptr++; if(g_ac->insector()) - spawn(g_ac,*insptr); + spawn(g_ac, GetSpawnType(*insptr)); insptr++; break; case concmd_ifwasweapon: @@ -2388,7 +2388,7 @@ int ParseState::parse(void) lIn = *insptr++; lIn = GetGameVarID(lIn, g_ac, g_p).safeValue(); if(g_ac->insector()) - lReturn = spawn(g_ac, lIn); + lReturn = spawn(g_ac, GetSpawnType(lIn)); SetGameVarID(g_iReturnVarID, (lReturn), g_ac, g_p); break; @@ -2398,7 +2398,7 @@ int ParseState::parse(void) DDukeActor* lReturn = nullptr; insptr++; if(g_ac->insector()) - lReturn = spawn(g_ac, *insptr); + lReturn = spawn(g_ac, GetSpawnType(*insptr)); insptr++; SetGameVarID(g_iReturnVarID, (lReturn), g_ac, g_p); break; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index d262118ed..eca753a98 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -221,7 +221,7 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum DukeStatIterator it(STAT_ACTOR); while (auto act = it.Next()) { - if (act->spr.picnum == DTILE_HEAVYHBOMB && act->GetOwner() == p->GetActor()) + if (act->GetClass() == DukePipeBombClass && act->GetOwner() == p->GetActor()) { p->gotweapon[HANDBOMB_WEAPON] = true; j = HANDREMOTE_WEAPON; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index bc95ddbb0..5e6ecffab 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -194,7 +194,7 @@ void selectweapon_r(int snum, int weap) DukeStatIterator it(STAT_ACTOR); while (auto act = it.Next()) { - if (act->spr.picnum == RTILE_DYNAMITE && act->GetOwner() == p->GetActor()) + if (act->GetClass() == RedneckDynamiteClass && act->GetOwner() == p->GetActor()) { p->gotweapon[DYNAMITE_WEAPON] = true; j = THROWINGDYNAMITE_WEAPON; @@ -600,15 +600,15 @@ int doincrements_r(player_struct* p) void checkweapons_r(player_struct* p) { - static const uint16_t weapon_sprites[MAX_WEAPONS] = { RTILE_KNEE, RTILE_FIRSTGUNSPRITE, RTILE_SHOTGUNSPRITE, - RTILE_RIFLEGUNSPRITE, RTILE_DYNAMITE, RTILE_CROSSBOWSPRITE, RTILE_RIPSAWSPRITE, RTILE_ALIENBLASTERSPRITE, - RTILE_POWDERKEG, RTILE_BOWLINGBALLSPRITE, RTILE_TITSPRITE, RTILE_DYNAMITE }; + static PClassActor* const* const weapon_sprites[MAX_WEAPONS] = { &DukeMeleeAttackClass, &RedneckRevolverClass, &RedneckShotgunClass, + &RedneckRiflegunClass, &RedneckDynamiteClass, &RedneckCrossbowClass, &RedneckRipsawClass, &RedneckBlasterClass, + &RedneckPowderKegClass, &RedneckBowlingBallClass, &RedneckTitgunClass, &RedneckDynamiteClass }; if (isRRRA()) { if (p->OnMotorcycle && numplayers > 1) { - auto j = spawn(p->GetActor(), 7220); + auto j = spawn(p->GetActor(), RedneckEmptyBikeClass); if (j) { j->spr.Angles.Yaw = p->GetActor()->spr.Angles.Yaw; @@ -627,7 +627,7 @@ void checkweapons_r(player_struct* p) } else if (p->OnBoat && numplayers > 1) { - auto j = spawn(p->GetActor(), 7233); + auto j = spawn(p->GetActor(), RedneckEmptyBoatClass); if (j) { j->spr.Angles.Yaw = p->GetActor()->spr.Angles.Yaw; @@ -649,7 +649,7 @@ void checkweapons_r(player_struct* p) if (p->curr_weapon > 0) { if (krand() & 1) - spawn(p->GetActor(), weapon_sprites[p->curr_weapon]); + spawn(p->GetActor(), *weapon_sprites[p->curr_weapon]); else switch (p->curr_weapon) { case CHICKEN_WEAPON: @@ -1966,7 +1966,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) if ((p->kickback_pic % 3) == 0) { - auto j = spawn(pact, RTILE_SHELL); + auto j = spawn(pact, DukeShellClass); if (j) { @@ -2369,7 +2369,7 @@ void processinput_r(int snum) DukeSectIterator it(psectp); while (auto act2 = it.Next()) { - if (act2->spr.picnum == RTILE_WATERSURFACE) + if (act2->GetClass() == RedneckWaterSurfaceClass) if (act2->spr.pos.Z - 8 < p->GetActor()->getOffsetZ()) psectlotag = ST_2_UNDERWATER; } @@ -2418,7 +2418,7 @@ void processinput_r(int snum) chz.setNone(); ceilingz = p->truecz; } - else if (chz.actor()->spr.picnum == RTILE_LADDER) + else if (chz.actor()->GetClass() == RedneckLadderClass) { if (!p->stairs) { @@ -2463,7 +2463,7 @@ void processinput_r(int snum) auto ang = (clz.actor()->spr.pos.XY() - p->GetActor()->spr.pos.XY()).Angle(); p->vel.XY() -= ang.ToVector(); } - if (clz.actor()->spr.picnum == RTILE_LADDER) + if (clz.actor()->GetClass() == RedneckLadderClass) { if (!p->stairs) { diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index 55041299a..669669107 100644 --- a/source/games/duke/src/player_w.cpp +++ b/source/games/duke/src/player_w.cpp @@ -111,7 +111,7 @@ void DoSpawn(player_struct *p, int snum) if(!aplWeaponSpawn(p->curr_weapon, snum)) return; - auto j = spawn(p->GetActor(), aplWeaponSpawn(p->curr_weapon, snum)); + auto j = spawn(p->GetActor(), GetSpawnType(aplWeaponSpawn(p->curr_weapon, snum))); if (!j) return; if((aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_SPAWNTYPE2 ) ) diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 9b38b5c66..3c187e8d5 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -175,7 +175,6 @@ void checkhitdefault_d(DDukeActor* targ, DDukeActor* proj) if ((targ->spr.picnum != DTILE_DRONE) && (targ->spr.picnum != DTILE_ROTATEGUN) && (targ->spr.picnum != DTILE_COMMANDER) && targ->spr.picnum != DTILE_GREENSLIME) if (proj->spr.picnum != DTILE_FREEZEBLAST) - //if (actortype[targ->spr.picnum] == 0) //TRANSITIONAL. { auto spawned = spawn(proj, DukeJibs6Class); if (spawned) @@ -260,7 +259,7 @@ void checkhitdefault_d(DDukeActor* targ, DDukeActor* proj) } } - if (targ->spr.scale.X < 0.375 && proj->spr.picnum == DTILE_SHRINKSPARK) + if (targ->spr.scale.X < 0.375 && proj->GetClass() == DukeShrinkSparkClass) return; auto hitowner = targ->GetHitOwner(); diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index d9afc8b4d..3bb27e1ff 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -173,7 +173,6 @@ void checkhitdefault_r(DDukeActor* targ, DDukeActor* proj) if ((targ->spr.picnum != RTILE_DRONE)) if (proj->spr.picnum != RTILE_FREEZEBLAST) - //if (actortype[targ->spr.picnum] == 0) { auto spawned = spawn(proj, DukeJibs6Class); if (spawned) @@ -622,7 +621,7 @@ void tearitup(sectortype* sect) DukeSectIterator it(sect); while (auto act = it.Next()) { - if (act->spr.picnum == RTILE_DESTRUCTO) + if (act->GetClass() == RedneckDestructoClass) { act->attackertype = DukeShotSparkClass; act->hitextra = 1; diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 323cc728c..88f82c677 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -260,20 +260,6 @@ bool initspriteforspawn(DDukeActor* act) // //--------------------------------------------------------------------------- -DDukeActor* spawn(DDukeActor* actj, int pn) -{ - if (actj) - { - auto spawned = CreateActor(actj->sector(), actj->spr.pos, pn, 0, DVector2(0, 0), nullAngle, 0., 0., actj, 0); - if (spawned) - { - spawned->attackertype = static_cast(actj->GetClass()); - return spawninit(actj, spawned, nullptr); - } - } - return nullptr; -} - DDukeActor* spawn(DDukeActor* actj, PClassActor * cls) { if (actj && cls) diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index e86e1daa6..098157883 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -491,11 +491,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, movesprite_ex, DukeActor_movesprite_ex ACTION_RETURN_INT(DukeActor_movesprite_ex(self, velx, vely, velz, clipmask, coll)); } -DDukeActor* DukeActor_Spawnsprite(DDukeActor* origin, int picnum) +DDukeActor* DukeActor_Spawnsprite(DDukeActor* origin, int typeId) { - if (picnum >= 0 && picnum < MAXTILES) + auto st = GetSpawnType(typeId); + if (st) { - return spawn(origin, picnum); + return spawn(origin, st); } return nullptr; } diff --git a/wadsrc/static/filter/redneck/rmapinfo.spawnclasses b/wadsrc/static/filter/redneck/rmapinfo.spawnclasses index a3c3c0772..dbb008c97 100644 --- a/wadsrc/static/filter/redneck/rmapinfo.spawnclasses +++ b/wadsrc/static/filter/redneck/rmapinfo.spawnclasses @@ -371,5 +371,6 @@ spawnclasses 1990 = RedneckTikilamp 3845 = DukePlayerPawn, noskill + 380 = RedneckWaterSurface, noskill } diff --git a/wadsrc/static/zscript/games/duke/actors/redneckmisc.zs b/wadsrc/static/zscript/games/duke/actors/redneckmisc.zs index 077cfe28d..10ce011dc 100644 --- a/wadsrc/static/zscript/games/duke/actors/redneckmisc.zs +++ b/wadsrc/static/zscript/games/duke/actors/redneckmisc.zs @@ -164,3 +164,11 @@ class RedneckTikiLamp : DukeItemBase +FULLBRIGHT } } + +class RedneckWaterSurface : DukeActor +{ + default + { + pic "WATERSURFACE"; + } +} \ No newline at end of file