From 2ba204444cd11ae678abcb7472d601f76f902614 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 15 Dec 2022 10:46:41 +0100 Subject: [PATCH] - merged the spawn init code now that all differences are externalized --- source/CMakeLists.txt | 2 - source/games/duke/all_d.cpp | 1 - source/games/duke/all_r.cpp | 1 - source/games/duke/src/dispatch.cpp | 2 - source/games/duke/src/duke3d.h | 1 - source/games/duke/src/funct.h | 6 +- source/games/duke/src/premap_d.cpp | 10 +- source/games/duke/src/premap_r.cpp | 11 +-- source/games/duke/src/spawn.cpp | 61 ++++++++++++- source/games/duke/src/spawn_d.cpp | 91 ------------------- source/games/duke/src/spawn_r.cpp | 79 ---------------- .../zscript/games/duke/actors/dukedecos.zs | 2 +- 12 files changed, 63 insertions(+), 204 deletions(-) delete mode 100644 source/games/duke/src/spawn_d.cpp delete mode 100644 source/games/duke/src/spawn_r.cpp diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index cae0ff9d7..8395d9945 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -738,8 +738,6 @@ set( NOT_COMPILED_SOURCE_FILES games/duke/src/sectors_r.cpp games/duke/src/sounds.cpp games/duke/src/spawn.cpp - games/duke/src/spawn_d.cpp - games/duke/src/spawn_r.cpp games/duke/src/vmexports.cpp # Shadow Warrior diff --git a/source/games/duke/all_d.cpp b/source/games/duke/all_d.cpp index d2373164f..7e08114b2 100644 --- a/source/games/duke/all_d.cpp +++ b/source/games/duke/all_d.cpp @@ -6,7 +6,6 @@ #include "src/player_w.cpp" #include "src/premap_d.cpp" #include "src/sectors_d.cpp" -#include "src/spawn_d.cpp" // These global files include names_d.h! #include "src/sounds.cpp" diff --git a/source/games/duke/all_r.cpp b/source/games/duke/all_r.cpp index e874f9a3a..09b4cb3e2 100644 --- a/source/games/duke/all_r.cpp +++ b/source/games/duke/all_r.cpp @@ -7,4 +7,3 @@ #include "src/player_r.cpp" #include "src/premap_r.cpp" #include "src/sectors_r.cpp" -#include "src/spawn_r.cpp" diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index 32a1c9d76..4fd785c65 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -100,7 +100,6 @@ void SetDispatcher() checkhitsprite_d, checkhitdefault_d, checksectors_d, - spawninit_d, addweapon_d, hitradius_d, @@ -134,7 +133,6 @@ void SetDispatcher() checkhitsprite_r, checkhitdefault_r, checksectors_r, - spawninit_r, addweapon_r, hitradius_r, diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 3fd861ddb..2139ca674 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -79,7 +79,6 @@ struct Dispatcher void (*checkhitsprite)(DDukeActor* i, DDukeActor* sn); void (*checkhitdefault)(DDukeActor* i, DDukeActor* sn); void (*checksectors)(int low); - DDukeActor* (*spawninit)(DDukeActor* actj, DDukeActor* act, TArray* actors); void (*addweapon)(player_struct *p, int weapon, bool wswitch); void (*hitradius)(DDukeActor* i, int r, int hp1, int hp2, int hp3, int hp4); diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 8d01be3ff..62b599995 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -165,10 +165,8 @@ void checkplayerhurt_d(player_struct* p, const Collision& coll); void checkplayerhurt_r(player_struct* p, const Collision& coll); DDukeActor* dospawnsprite(DDukeActor* actj, int pn); -void spriteinit_d(DDukeActor*); -void spriteinit_r(DDukeActor*); -DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* actors); -DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* actors); +void spriteinit(DDukeActor*, TArray& actors); +DDukeActor* spawninit(DDukeActor* actj, DDukeActor* act, TArray* actors); void addspritetodelete(int spnum=0); void checkavailinven(player_struct* p); diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index 9f629f3f1..9f4603b07 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -234,12 +234,6 @@ void cacheit_d(void) // // //--------------------------------------------------------------------------- -void spriteinit_d(DDukeActor* actor, TArray& actors) -{ - actor->mapSpawned = true; - bool res = initspriteforspawn(actor); - if (res) spawninit_d(nullptr, actor, &actors); -} void prelevel_d(int g, TArray& actors) { @@ -268,7 +262,7 @@ void prelevel_d(int g, TArray& actors) { if (iseffector(actor) && actor->spr.lotag == SE_14_SUBWAY_CAR) continue; - spriteinit_d(actor, actors); + spriteinit(actor, actors); } } @@ -277,7 +271,7 @@ void prelevel_d(int g, TArray& actors) if (actor->exists()) { if (iseffector(actor) && actor->spr.lotag == SE_14_SUBWAY_CAR) - spriteinit_d(actor, actors); + spriteinit(actor, actors); } } lotaglist = 0; diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 81c8c2014..a92e3a503 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -367,13 +367,6 @@ void cacheit_r(void) // //--------------------------------------------------------------------------- -void spriteinit_r(DDukeActor* actor, TArray& actors) -{ - actor->mapSpawned = true; - bool res = initspriteforspawn(actor); - if (res) spawninit_r(nullptr, actor, &actors); -} - void prelevel_r(int g, TArray& actors) { player_struct* p; @@ -549,7 +542,7 @@ void prelevel_r(int g, TArray& actors) { if (iseffector(actor) && actor->spr.lotag == SE_14_SUBWAY_CAR) continue; - spriteinit_r(actor, actors); + spriteinit(actor, actors); } } @@ -558,7 +551,7 @@ void prelevel_r(int g, TArray& actors) if (actor->exists()) { if (iseffector(actor) && actor->spr.lotag == SE_14_SUBWAY_CAR) - spriteinit_r(actor, actors); + spriteinit(actor, actors); if (actor->GetClass()->TypeName == NAME_RedneckGeometryEffect) actor->Destroy(); if (actor->GetClass()->TypeName == NAME_RedneckKeyinfoSetter) diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 870611abd..f74184ab8 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -158,7 +158,7 @@ DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, PClassActor* DDukeActor* SpawnActor(sectortype* whatsectp, const DVector3& pos, PClassActor* cls, int8_t s_shd, const DVector2& scale, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat) { auto actor = CreateActor(whatsectp, pos, cls, s_shd, scale, s_ang, s_vel, s_zvel, s_ow, s_stat); - if (actor) fi.spawninit(s_ow, actor, nullptr); + if (actor) spawninit(s_ow, actor, nullptr); return actor; } @@ -272,7 +272,7 @@ DDukeActor* spawn(DDukeActor* actj, int pn) if (spawned) { spawned->attackertype = actj->spr.picnum; - return fi.spawninit(actj, spawned, nullptr); + return spawninit(actj, spawned, nullptr); } } return nullptr; @@ -286,7 +286,7 @@ DDukeActor* spawn(DDukeActor* actj, PClassActor * cls) if (spawned) { spawned->attackertype = actj->spr.picnum; - return fi.spawninit(actj, spawned, nullptr); + return spawninit(actj, spawned, nullptr); } } return nullptr; @@ -819,6 +819,59 @@ void spawneffector(DDukeActor* actor, TArray* actors) } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +DDukeActor* spawninit(DDukeActor* actj, DDukeActor* act, TArray* actors) +{ + if (actorflag(act, SFLAG2_TRIGGERRESPAWN)) + { + act->spr.yint = act->spr.hitag; + act->spr.hitag = -1; + } + + if (iseffector(act)) + { + // for in-game spawned SE's the init code must not run. The only type ever being spawned that way is SE128 - + // but we cannot check that here as the number has not been set yet. + if (actj == 0) spawneffector(act, actors); + } + else if (!act->isPlayer()) + { + if (!badguy(act) || commonEnemySetup(act, actj)) + CallInitialize(act); + } + else + { + act->spr.scale = DVector2(0, 0); + int j = ud.coop; + if (j == 2) j = 0; + + if (ud.multimode < 2 || (ud.multimode > 1 && j != act->spr.lotag)) + ChangeActorStat(act, STAT_MISC); + else + ChangeActorStat(act, STAT_PLAYER); + CallInitialize(act); + } + return act; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void spriteinit(DDukeActor* actor, TArray& actors) +{ + actor->mapSpawned = true; + bool res = initspriteforspawn(actor); + if (res) spawninit(nullptr, actor, &actors); +} + //--------------------------------------------------------------------------- // // @@ -976,6 +1029,4 @@ void lotsofcolourglass(DDukeActor* actor, walltype* wal, int n) } } - - END_DUKE_NS diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp deleted file mode 100644 index a243b5910..000000000 --- a/source/games/duke/src/spawn_d.cpp +++ /dev/null @@ -1,91 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 1996, 2003 - 3D Realms Entertainment -Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) -Copyright (C) 2020 - Christoph Oelckers - -This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition - -Duke Nukem 3D is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Original Source: 1996 - Todd Replogle -Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms - -EDuke enhancements integrated: 04/13/2003 - Matt Saettler - -Note: EDuke source was in transition. Changes are in-progress in the -source as it is released. - -*/ -//------------------------------------------------------------------------- -#include -#include "ns.h" -#include "global.h" -#include "sounds.h" -#include "names_d.h" -#include "dukeactor.h" - -BEGIN_DUKE_NS - - -DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* actors) -{ - if (actorflag(act, SFLAG2_TRIGGERRESPAWN)) - { - act->spr.yint = act->spr.hitag; - act->spr.hitag = -1; - } - - if (iseffector(act)) - { - // for in-game spawned SE's the init code must not run. The only type ever being spawned that way is SE128 - - // but we cannot check that here as the number has not been set yet. - if (actj == 0) spawneffector(act, actors); - return act; - } - - if (act->GetClass() != RUNTIME_CLASS(DDukeActor)) - { - if (!badguy(act) || commonEnemySetup(act, actj)) - CallInitialize(act); - return act; - } - auto sectp = act->sector(); - - - switch (act->spr.picnum) - { - default: - if (!badguy(act) || commonEnemySetup(act, actj)) - CallInitialize(act); - break; - case DTILE_APLAYER: - { - act->spr.scale = DVector2(0, 0); - int j = ud.coop; - if (j == 2) j = 0; - - if (ud.multimode < 2 || (ud.multimode > 1 && j != act->spr.lotag)) - ChangeActorStat(act, STAT_MISC); - else - ChangeActorStat(act, STAT_PLAYER); - break; - } - } - return act; -} - -END_DUKE_NS diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp deleted file mode 100644 index a02a58ebd..000000000 --- a/source/games/duke/src/spawn_r.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 1996, 2003 - 3D Realms Entertainment -Copyright (C) 2017-2019 Nuke.YKT -Copyright (C) 2020 - Christoph Oelckers - -This file is part of Duke Nukem 3D version 1.5 - Atomic Edition - -Duke Nukem 3D is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Original Source: 1996 - Todd Replogle -Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms -*/ -//------------------------------------------------------------------------- - -#include -#include "ns.h" -#include "global.h" -#include "sounds.h" -#include "names_r.h" -#include "dukeactor.h" - -BEGIN_DUKE_NS - -DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* actors) -{ - if (actorflag(act, SFLAG2_TRIGGERRESPAWN)) - { - act->spr.yint = act->spr.hitag; - act->spr.hitag = -1; - } - - if (iseffector(act)) - { - spawneffector(act, actors); - return act; - } - - if (act->GetClass() != RUNTIME_CLASS(DDukeActor)) - { - if (!badguy(act) || commonEnemySetup(act, actj)) - CallInitialize(act); - return act; - } - auto sectp = act->sector(); - - if (!act->isPlayer()) - { - if (!badguy(act) || commonEnemySetup(act, actj)) - CallInitialize(act); - } - else - { - act->spr.scale = DVector2(0, 0); - int j = ud.coop; - if (j == 2) j = 0; - - if (ud.multimode < 2 || (ud.multimode > 1 && j != act->spr.lotag)) - ChangeActorStat(act, STAT_MISC); - else - ChangeActorStat(act, STAT_PLAYER); - } - return act; -} - -END_DUKE_NS diff --git a/wadsrc/static/zscript/games/duke/actors/dukedecos.zs b/wadsrc/static/zscript/games/duke/actors/dukedecos.zs index 0b772b74f..85148dfbf 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukedecos.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukedecos.zs @@ -56,7 +56,7 @@ class DukeNukeBarrelLeaked : DukeExplodingBarrel { default { - pic "DTILE_NUKEBARRELLEAKED"; + pic "NUKEBARRELLEAKED"; } } class DukeWoodenHorse : DukeExplodingBarrel