From 92bf1232da4c6eaae7b57b77ed71fa1c5d4b4eac Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 29 Nov 2020 15:09:23 +0100 Subject: [PATCH] - Duke: documented global variables for eventual scriptification. Most are only needed internally or for very special uses and do not need any scripting consideration. --- source/games/duke/src/actors.cpp | 8 +- source/games/duke/src/gamedef.cpp | 4 +- source/games/duke/src/global.cpp | 131 ++++++++++++++++------------ source/games/duke/src/global.h | 5 +- source/games/duke/src/savegame.cpp | 4 +- source/games/duke/src/sectors_d.cpp | 2 +- source/games/duke/src/sectors_r.cpp | 2 +- source/games/duke/src/spawn.cpp | 4 +- source/games/duke/src/spawn_d.cpp | 6 +- source/games/duke/src/spawn_r.cpp | 2 +- 10 files changed, 93 insertions(+), 75 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 6eb58de4a..ba4f491a1 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1935,10 +1935,10 @@ void reactor(DDukeActor* actor, int REACTOR, int REACTOR2, int REACTORBURNT, int { //Turn on all of those flashing sectoreffector. fi.hitradius(actor, 4096, - impact_damage << 2, - impact_damage << 2, - impact_damage << 2, - impact_damage << 2); + gs.impact_damage << 2, + gs.impact_damage << 2, + gs.impact_damage << 2, + gs.impact_damage << 2); DukeStatIterator it(STAT_STANDABLE); while (auto act2 = it.Next()) { diff --git a/source/games/duke/src/gamedef.cpp b/source/games/duke/src/gamedef.cpp index afb245364..289adb70f 100644 --- a/source/games/duke/src/gamedef.cpp +++ b/source/games/duke/src/gamedef.cpp @@ -1887,7 +1887,7 @@ int ConCompiler::parsecommand() auto parseone = [&]() { return params[pget++]; }; ud.const_visibility = parseone(); - impact_damage = parseone(); + gs.impact_damage = parseone(); gs.max_player_health = parseone(); gs.max_armour_amount = parseone(); gs.respawnactortime = parseone(); @@ -1915,7 +1915,7 @@ int ConCompiler::parsecommand() if (isRR()) gs.max_ammo_amount[12] = parseone(); gs.camerashitable = parseone(); gs.numfreezebounces = parseone(); - freezerhurtowner = parseone(); + gs.freezerhurtowner = parseone(); if (isPlutoPak() || isRR()) { spriteqamount = clamp(parseone(), 0, 1024); diff --git a/source/games/duke/src/global.cpp b/source/games/duke/src/global.cpp index 482e0b18d..718357188 100644 --- a/source/games/duke/src/global.cpp +++ b/source/games/duke/src/global.cpp @@ -33,71 +33,99 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms BEGIN_DUKE_NS -user_defs ud; +//------------------------------------------------------------------------- +// +// variables that need a script export +// +//------------------------------------------------------------------------- +user_defs ud; // partially serialized + +// not serialized - read only DukeGameInfo gs; - -int cameradist = 0, cameraclock = 0; -int otherp; -int actor_tog; -int playerswhenstarted; -int show_shareware; int screenpeek; - - -// Variables that must be saved -uint8_t sectorextra[MAXSECTORS]; // move these back into the base structs! - -int rtsplaying; -int tempwallptr; -weaponhit hittype[MAXSPRITES+1]; // +1 to have a blank entry for serialization. -bool sound445done; // this was local state inside a function, but this must be maintained globally and serialized +// serialized player_struct ps[MAXPLAYERS]; -int spriteqamount = 64; -uint8_t shadedsector[MAXSECTORS]; -int lastvisinc; -animwalltype animwall[MAXANIMWALLS]; -int numanimwalls; -int animatecnt; -int numclouds; -DDukeActor* camsprite; -int numcyclers; -int earthquaketime; -int freezerhurtowner; -int global_random; -int impact_damage; -int mirrorcnt; -int numplayersprites; -int spriteqloc; -int thunder_brightness; +//------------------------------------------------------------------------- +// +// variables that only need an export if the entire game logic gets scriptified. +// Otherwise all code referencing these variables should remain native. +// +//------------------------------------------------------------------------- + +int lastvisinc; // weapon flash +DDukeActor* camsprite; // active camera +int earthquaketime; +int global_random; // readonly - one single global per-frame random value. Ugh... + +// Redneck Rampage +int chickenplant; // readonly - used to trigger some special behavior if a special item is found in a map. +int thunderon; // readonly - enables thunder effect in RR if true. +int ufospawn; // UFO spawn flag +int ufocnt; // UFO spawn count +int hulkspawn; // Spawn a hulk? +int lastlevel; // Set at the end of RRRA's E2L7. +short fakebubba_spawn, mamaspawn_count, banjosound; // RRRA special effects +short BellTime; +DDukeActor* BellSprite /* word_119BE0*/; +int WindTime, WindDir; +uint8_t enemysizecheat /*raat607*/, ufospawnsminion, pistonsound, chickenphase /* raat605*/, RRRA_ExitedLevel, fogactive; + +//------------------------------------------------------------------------- +// +// variables that do not need a script export. +// +//------------------------------------------------------------------------- + +// not serialized +int cameradist = 0, cameraclock = 0; // only for 3rd person view +int otherp; // internal helper +int actor_tog; // cheat helper +int playerswhenstarted; // why is this needed? +int show_shareware; // display only. +int rtsplaying; // RTS playback state +int tempwallptr; // msx/y index. +int msx[MAXANIMPOINTS], msy[MAXANIMPOINTS]; +bool sound445done; // used in checksectors_r. This was local state inside a function, but this must be maintained globally and serialized + +// serialized +uint8_t sectorextra[MAXSECTORS]; // something about keys, all access through the haskey function. +weaponhit hittype[MAXSPRITES + 1]; // +1 to have a blank entry for serialization, all access in game code through the iterators. +int spriteqamount = 64; // internal sprite queue +int spriteqloc; +DDukeActor* spriteq[1024]; +uint8_t shadedsector[MAXSECTORS]; // display hackiness +animwalltype animwall[MAXANIMWALLS]; // animated walls +int numanimwalls; +int animatecnt; // sector plane movement int16_t animatesect[MAXANIMATES]; int8_t animatetype[MAXANIMATES]; int16_t animatetarget[MAXANIMATES]; int animategoal[MAXANIMATES]; int animatevel[MAXANIMATES]; - +int numclouds; // cloudy skies int16_t clouds[256]; int16_t cloudx; int16_t cloudy; int cloudclock; - -DDukeActor *spriteq[1024]; +int numcyclers; // sector lighting effects int16_t cyclers[MAXCYCLERS][6]; -int16_t mirrorsector[64]; +int mirrorcnt; +int16_t mirrorsector[64]; // mirrors int16_t mirrorwall[64]; +int numplayersprites; // player management for some SEs. +player_orig po[MAXPLAYERS]; +unsigned ambientfx; // used by soundtag and soundtagonce script commands. If exported, export the commands, not the data! +short ambientlotag[64]; +short ambienthitag[64]; +uint32_t everyothertime; // Global animation ticker helper. // Redneck Rampage -int wupass; -int chickenplant; -int thunderon; -int ufospawn; -int ufocnt; -int hulkspawn; -int lastlevel; - -int geosectorwarp[MAXGEOSECTORS]; +int thunder_brightness; +int wupass; // used to play the level entry sound only once. +int geosectorwarp[MAXGEOSECTORS]; // geometry render hack (overlay a secondary scene) int geosectorwarp2[MAXGEOSECTORS]; int geosector[MAXGEOSECTORS]; int geox[MAXGEOSECTORS]; @@ -106,16 +134,5 @@ int geox2[MAXGEOSECTORS]; int geoy2[MAXGEOSECTORS]; int geocnt; -short ambientlotag[64]; -short ambienthitag[64]; -unsigned ambientfx; -int msx[MAXANIMPOINTS], msy[MAXANIMPOINTS]; -int WindTime, WindDir; -short fakebubba_spawn, mamaspawn_count, banjosound; -short BellTime; -DDukeActor* BellSprite /* word_119BE0*/; -uint8_t enemysizecheat /*raat607*/, ufospawnsminion, pistonsound, chickenphase /* raat605*/, RRRA_ExitedLevel, fogactive; -uint32_t everyothertime; -player_orig po[MAXPLAYERS]; END_DUKE_NS diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index d92e73470..1e5eb961a 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -33,6 +33,9 @@ struct DukeGameInfo int max_player_health = 0; int max_armour_amount = 0; int lasermode = 0; + int freezerhurtowner = 0; + int impact_damage = 0; + TileInfo tileinfo[MAXTILES] = {}; // This is not from EDuke32. ActorInfo actorinfo[MAXTILES] = {}; int16_t max_ammo_amount[MAX_WEAPONS] = {}; @@ -71,9 +74,7 @@ extern int numclouds; extern DDukeActor* camsprite; extern int numcyclers; extern int earthquaketime; -extern int freezerhurtowner; extern int global_random; -extern int impact_damage; extern int mirrorcnt; extern int numplayersprites; extern int spriteqloc; diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index 7a6885821..fabdbb89b 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -347,9 +347,9 @@ void GameInterface::SerializeGameState(FSerializer& arc) .Array("animwall", animwall, numanimwalls) ("camsprite", camsprite) ("earthquaketime", earthquaketime) - ("freezerhurtowner", freezerhurtowner) + ("gs.freezerhurtowner", gs.freezerhurtowner) ("global_random", global_random) - ("impact_damage", impact_damage) + ("gs.impact_damage", gs.impact_damage) ("numplayersprites", numplayersprites) ("spriteqloc", spriteqloc) ("animatecnt", animatecnt) diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index c48ec807d..aa317aa51 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1424,7 +1424,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) if (s->statnum != 2) { - if (pspr->picnum == FREEZEBLAST && ((s->picnum == APLAYER && s->pal == 1) || (freezerhurtowner == 0 && proj->GetOwner() == targ))) + if (pspr->picnum == FREEZEBLAST && ((s->picnum == APLAYER && s->pal == 1) || (gs.freezerhurtowner == 0 && proj->GetOwner() == targ))) return; diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index cd2f433ef..d81241a10 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -2385,7 +2385,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) if (s->statnum != 2) { - if (pspr->picnum == FREEZEBLAST && ((s->picnum == APLAYER && s->pal == 1) || (freezerhurtowner == 0 && proj->GetOwner() == targ))) + if (pspr->picnum == FREEZEBLAST && ((s->picnum == APLAYER && s->pal == 1) || (gs.freezerhurtowner == 0 && proj->GetOwner() == targ))) return; targ->picnum = pspr->picnum; diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index eecca054c..bc2301f39 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -207,7 +207,7 @@ int initspriteforspawn(DDukeActor* actj, int pn, const std::initializer_listcstat |= 257; - sp->extra = impact_damage; + sp->extra = gs.impact_damage; return i; } } @@ -600,7 +600,7 @@ int initreactor(DDukeActor* actj, DDukeActor* actor, bool isrecon) sp->extra = 130; } else - sp->extra = impact_damage; + sp->extra = gs.impact_damage; sp->cstat |= 257; // Make it hitable diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index 4ac72f3e5..e9bdd497d 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -1057,7 +1057,7 @@ int spawn_d(int j, int pn) sp->cstat |= 1+256; //Make it hitable sp->xrepeat = sp->yrepeat = 24; sp->shade = -127; - sp->extra = impact_damage<<2; + sp->extra = gs.impact_damage<<2; changespritestat(act, STAT_ZOMBIEACTOR); break; @@ -1114,7 +1114,7 @@ int spawn_d(int j, int pn) sp->xrepeat=sp->yrepeat=0; } else sp->cstat = 1+256; - sp->extra = impact_damage<<2; + sp->extra = gs.impact_damage<<2; act->SetOwner(act); changespritestat(act, STAT_STANDABLE); break; @@ -1127,7 +1127,7 @@ int spawn_d(int j, int pn) if(sp->picnum == FIREEXT) { sp->cstat = 257; - sp->extra = impact_damage<<2; + sp->extra = gs.impact_damage<<2; } else { diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index 5c88fd6ac..9848000b3 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -1374,7 +1374,7 @@ int spawn_r(int j, int pn) sp->xrepeat=sp->yrepeat=0; } else sp->cstat = 1+256; - sp->extra = impact_damage<<2; + sp->extra = gs.impact_damage<<2; act->SetOwner(act); changespritestat(act, STAT_STANDABLE); break;