- did some cleanup on the global variables.

This commit is contained in:
Christoph Oelckers 2020-07-19 23:09:10 +02:00
parent 16efa87701
commit 06fa1391f5
11 changed files with 163 additions and 138 deletions

View file

@ -828,6 +828,7 @@ public:
void PrintKills(int totalclock)
{
char tempbuf[32];
GameText(10, 94 + 9, GStrings("TXT_EnemiesKilled"), 0);
GameText(10, 99 + 4 + 9, GStrings("TXT_EnemiesLeft"), 0);
@ -863,6 +864,7 @@ public:
void PrintSecrets(int totalclock)
{
char tempbuf[32];
GameText(10, 120 + 9, GStrings("TXT_SECFND"), 0);
GameText(10, 130 + 9, GStrings("TXT_SECMISS"), 0);
if (bonuscnt == 4) bonuscnt++;

View file

@ -416,6 +416,7 @@ public:
void PrintKills(int totalclock)
{
char tempbuf[32];
BigText(30, 112, GStrings("TXT_VarmintsKilled"), -1);
BigText(30, 128, GStrings("TXT_VarmintsLeft"), -1);
@ -448,6 +449,7 @@ public:
void PrintSecrets(int totalclock)
{
char tempbuf[32];
BigText(30, 144, GStrings("TXT_SECFND"), -1);
BigText(30, 160, GStrings("TXT_SECMISS"), -1);
if (bonuscnt == 4) bonuscnt++;

View file

@ -4432,17 +4432,17 @@ static int fallspecial(int g_i, int g_p)
addspritetodelete(g_i);
return 0;
}
if (g_sp->picnum != APLAYER && (badguy(g_sp) || g_sp->picnum == HEN || g_sp->picnum == COW || g_sp->picnum == PIG || g_sp->picnum == DOGRUN || g_sp->picnum == RABBIT) && (!isRRRA() || g_spriteExtra[g_i] < 128))
if (g_sp->picnum != APLAYER && (badguy(g_sp) || g_sp->picnum == HEN || g_sp->picnum == COW || g_sp->picnum == PIG || g_sp->picnum == DOGRUN || g_sp->picnum == RABBIT) && (!isRRRA() || spriteextra[g_i] < 128))
{
g_sp->z = hittype[g_i].floorz - FOURSLEIGHT;
g_sp->zvel = 8000;
g_sp->extra = 0;
g_spriteExtra[g_i]++;
spriteextra[g_i]++;
sphit = 1;
}
else if (g_sp->picnum != APLAYER)
{
if (!g_spriteExtra[g_i])
if (!spriteextra[g_i])
addspritetodelete(g_i);
return 0;
}
@ -4586,7 +4586,7 @@ void destroyit(int g_i)
sector[sectnum].floorxpanning = sector[js->sectnum].floorxpanning;
sector[sectnum].floorypanning = sector[js->sectnum].floorypanning;
sector[sectnum].visibility = sector[js->sectnum].visibility;
g_sectorExtra[sectnum] = g_sectorExtra[js->sectnum]; // TRANSITIONAL: at least rename this.
sectorextra[sectnum] = sectorextra[js->sectnum]; // TRANSITIONAL: at least rename this.
sector[sectnum].lotag = sector[js->sectnum].lotag;
sector[sectnum].hitag = sector[js->sectnum].hitag;
sector[sectnum].extra = sector[js->sectnum].extra;

View file

@ -567,10 +567,10 @@ int ParseState::parse(void)
break;
case concmd_iftipcow:
case concmd_ifhittruck: // both have the same code.
if (g_spriteExtra[g_i] == 1) // TRANSITIONAL 'filler' no longer exists
if (spriteextra[g_i] == 1) // TRANSITIONAL 'filler' no longer exists
{
j = 1;
g_spriteExtra[g_i]++;
spriteextra[g_i]++;
}
else
j = 0;
@ -631,7 +631,7 @@ int ParseState::parse(void)
insptr++;
if (isRR())
{
if (g_spriteExtra[g_i] < 1 || g_spriteExtra[g_i] == 128)
if (spriteextra[g_i] < 1 || spriteextra[g_i] == 128)
{
if (actorfella(g_i))
ps[g_p].actors_killed += *insptr;

View file

@ -35,6 +35,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_DUKE_NS
extern user_defs ud;
// Interpolation code is the same in all games with slightly different naming - this needs to be unified and cleaned up.
// Interpolations are reconstructed on load and do not need to be saved.
#define MAXINTERPOLATIONS MAXSPRITES
extern int numinterpolations;
extern int* curipos[MAXINTERPOLATIONS];
extern int bakipos[MAXINTERPOLATIONS];
// Variables that do not need to be saved.
extern int respawnactortime;
@ -49,6 +55,10 @@ extern int seenineblastradius;
extern int shrinkerblastradius;
extern int gc;
extern int tripbombblastradius;
extern int camerashitable;
extern int max_player_health;
extern int max_armour_amount;
extern int lasermode;
extern int cameraclock;
extern int cameradist;
@ -62,16 +72,18 @@ extern input_t sync[MAXPLAYERS];
extern int16_t max_ammo_amount[MAX_WEAPONS];
extern int16_t weaponsandammosprites[15];
extern int32_t PHEIGHT;
// Interpolation code is the same in all games with slightly different naming - this needs to be unified and cleaned up.
// Interpolations are reconstructed on load and do not need to be saved.
#define MAXINTERPOLATIONS MAXSPRITES
extern int numinterpolations;
extern int* curipos[MAXINTERPOLATIONS];
extern int bakipos[MAXINTERPOLATIONS];
extern int duke3d_globalflags;
extern bool synchronized_input;
extern uint8_t ready2send;
extern input_t loc;
extern int gamequit;
extern int playerswhenstarted;
extern int show_shareware;
extern int screenpeek;
extern ClockTicks ototalclock;
// Variables that must be saved
extern uint8_t spriteextra[MAXSPRITES], sectorextra[MAXSECTORS]; // these hold fields that were formerly in sprite and sector. Move these back into the base structs!
extern int rtsplaying;
extern int tempwallptr;
@ -83,120 +95,64 @@ extern player_struct ps[MAXPLAYERS];
extern int spriteqamount;
extern uint8_t shadedsector[MAXSECTORS];
extern int lastvisinc;
extern animwalltype animwall[MAXANIMWALLS];
extern int numanimwalls;
extern int animatecnt;
extern int numclouds;
extern int 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;
extern int16_t animatesect[MAXANIMATES];
extern int* animateptr[MAXANIMATES];
extern int animategoal[MAXANIMATES];
extern int animatevel[MAXANIMATES];
extern int16_t clouds[256];
extern int16_t cloudx;
extern int16_t cloudy;
extern ClockTicks cloudtotalclock;
// todo
extern int16_t spriteq[1024];
extern int16_t cyclers[MAXCYCLERS][6];
extern int16_t mirrorsector[64];
extern int16_t mirrorwall[64];
extern ClockTicks lockclock;
extern int wupass;
extern int chickenplant;
extern int thunderon;
extern int ufospawn;
extern int ufocnt;
extern int hulkspawn;
extern int lastlevel;
extern int geosectorwarp[MAXGEOSECTORS];
extern int geosectorwarp2[MAXGEOSECTORS];
extern int geosector[MAXGEOSECTORS];
extern int geox[MAXGEOSECTORS];
extern int geoy[MAXGEOSECTORS];
extern int geox2[MAXGEOSECTORS];
extern int geoy2[MAXGEOSECTORS];
extern int geocnt;
#ifdef global_c_
#define G_EXTERN
#else
#define G_EXTERN extern
#endif
G_EXTERN int duke3d_globalflags;
G_EXTERN animwalltype animwall[MAXANIMWALLS];
G_EXTERN bool synchronized_input;
G_EXTERN char ready2send;
G_EXTERN char tempbuf[MAXSECTORS<<1],buf[1024];
G_EXTERN input_t loc;
G_EXTERN int avgfvel, avgsvel, avgbits;
G_EXTERN fix16_t avgavel, avghorz;
G_EXTERN int8_t avgextbits;
G_EXTERN int movefifosendplc;
G_EXTERN int predictfifoplc;
G_EXTERN int g_networkBroadcastMode;
G_EXTERN int numanimwalls;
G_EXTERN int animatecnt;
G_EXTERN int numclouds;
G_EXTERN int camsprite;
G_EXTERN int numcyclers;
G_EXTERN int camerashitable;
G_EXTERN int earthquaketime;
G_EXTERN int freezerhurtowner;
G_EXTERN int gamequit;
G_EXTERN int global_random;
G_EXTERN int impact_damage;
G_EXTERN int mirrorcnt;
G_EXTERN int playerswhenstarted;
G_EXTERN int numplayersprites;
G_EXTERN int show_shareware;
G_EXTERN int spriteqloc;
G_EXTERN int max_player_health;
G_EXTERN int max_armour_amount;
G_EXTERN int lasermode;
G_EXTERN int screenpeek;
G_EXTERN int16_t animatesect[MAXANIMATES];
G_EXTERN int * animateptr[MAXANIMATES];
G_EXTERN int animategoal[MAXANIMATES];
G_EXTERN int animatevel[MAXANIMATES];
G_EXTERN int16_t clouds[256];
G_EXTERN int16_t cloudx;
G_EXTERN int16_t cloudy;
G_EXTERN ClockTicks cloudtotalclock;
G_EXTERN int16_t spriteq[1024];
G_EXTERN int16_t cyclers[MAXCYCLERS][6];
G_EXTERN int16_t mirrorsector[64];
G_EXTERN int16_t mirrorwall[64];
G_EXTERN ClockTicks lockclock;
G_EXTERN ClockTicks ototalclock;
G_EXTERN int wupass;
G_EXTERN int chickenplant;
G_EXTERN int thunderon;
G_EXTERN int ufospawn;
G_EXTERN int ufocnt;
G_EXTERN int hulkspawn;
G_EXTERN int lastlevel;
G_EXTERN int geosectorwarp[MAXGEOSECTORS];
G_EXTERN int geosectorwarp2[MAXGEOSECTORS];
G_EXTERN int geosector[MAXGEOSECTORS];
G_EXTERN int geox[MAXGEOSECTORS];
G_EXTERN int geoy[MAXGEOSECTORS];
G_EXTERN int geox2[MAXGEOSECTORS];
G_EXTERN int geoy2[MAXGEOSECTORS];
G_EXTERN uint32_t geocnt;
G_EXTERN int g_thunderFlash;
G_EXTERN int g_thunderTime;
G_EXTERN int g_winderFlash;
G_EXTERN int g_winderTime;
G_EXTERN int g_brightness;
G_EXTERN int16_t ambientlotag[64];
G_EXTERN int16_t ambienthitag[64];
G_EXTERN uint32_t ambientfx;
G_EXTERN int msx[MAXANIMPOINTS], msy[MAXANIMPOINTS];
G_EXTERN int WindTime, WindDir;
G_EXTERN int16_t fakebubba_spawn, mamaspawn_count, banjosound, BellTime, BellSprite /* word_119BE0*/;
G_EXTERN uint8_t g_spriteExtra[MAXSPRITES], g_sectorExtra[MAXSECTORS]; // move these back into the base structs!
G_EXTERN uint8_t enemysizecheat /*raat607*/, ufospawnsminion, pistonsound, chickenphase /* raat605*/, RRRA_ExitedLevel, fogactive;
G_EXTERN player_orig po[MAXPLAYERS];
G_EXTERN uint32_t everyothertime;
extern short ambientlotag[64];
extern short ambienthitag[64];
extern unsigned ambientfx;
extern int msx[MAXANIMPOINTS], msy[MAXANIMPOINTS];
extern int WindTime, WindDir;
extern short fakebubba_spawn, mamaspawn_count, banjosound;
extern short BellTime, BellSprite /* word_119BE0*/;
extern uint8_t enemysizecheat /*raat607*/, ufospawnsminion, pistonsound, chickenphase /* raat605*/, RRRA_ExitedLevel, fogactive;
extern uint32_t everyothertime;
extern player_orig po[MAXPLAYERS];
END_DUKE_NS

View file

@ -991,17 +991,17 @@ bool movementBlocked(int snum)
int haskey(int sect, int snum)
{
auto p = &ps[snum];
if (!g_sectorExtra[sect])
if (!sectorextra[sect])
return 1;
if (g_sectorExtra[sect] > 6)
if (sectorextra[sect] > 6)
return 1;
int wk = g_sectorExtra[sect];
int wk = sectorextra[sect];
if (wk > 3)
wk -= 3;
if (p->keys[wk] == 1)
{
g_sectorExtra[sect] = 0;
sectorextra[sect] = 0;
return 1;
}

View file

@ -698,8 +698,8 @@ void prelevel_common(int g)
resetprestat(0, g);
numclouds = 0;
memset(g_spriteExtra, 0, sizeof(g_spriteExtra));
memset(g_sectorExtra, 0, sizeof(g_sectorExtra));
memset(spriteextra, 0, sizeof(spriteextra));
memset(sectorextra, 0, sizeof(sectorextra));
memset(shadedsector, 0, sizeof(shadedsector));
memset(geosectorwarp, -1, sizeof(geosectorwarp));
memset(geosectorwarp2, -1, sizeof(geosectorwarp2));

View file

@ -681,7 +681,7 @@ void prelevel_r(int g)
deletesprite(i);
if (sprite[i].picnum == RRTILE34)
{
g_sectorExtra[sprite[i].sectnum] = sprite[i].lotag;
sectorextra[sprite[i].sectnum] = sprite[i].lotag;
deletesprite(i);
}
}

View file

@ -1081,8 +1081,8 @@ void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith)
if (s->lotag == 6)
{
for (j = 0; j < 16; j++) RANDOMSCRAP(s, -1);
g_spriteExtra[jj]++; // TRANSITIONAL move to sprite or actor
if (g_spriteExtra[jj] == 25)
spriteextra[jj]++; // TRANSITIONAL move to sprite or actor
if (spriteextra[jj] == 25)
{
startwall = sector[s->sectnum].wallptr;
endwall = startwall + sector[s->sectnum].wallnum;
@ -2576,7 +2576,7 @@ void checksectors_r(int snum)
case TOUGHGAL:
return;
case COW:
g_spriteExtra[neartagsprite] = 1; // TRANSITIONAL move to sprite or actor
spriteextra[neartagsprite] = 1; // TRANSITIONAL move to sprite or actor
return;
}
}
@ -2739,7 +2739,7 @@ void checksectors_r(int snum)
operatesectors(neartagsector, p->i);
else
{
if (g_spriteExtra[neartagsprite] > 3) // TRANSITIONAL move to sprite or actor
if (spriteextra[neartagsprite] > 3) // TRANSITIONAL move to sprite or actor
spritesound(99, p->i);
else
spritesound(419, p->i);
@ -2760,7 +2760,7 @@ void checksectors_r(int snum)
operatesectors(sprite[p->i].sectnum, p->i);
else
{
if (g_spriteExtra[neartagsprite] > 3) // TRANSITIONAL move to sprite or actor
if (spriteextra[neartagsprite] > 3) // TRANSITIONAL move to sprite or actor
spritesound(99, p->i);
else
spritesound(419, p->i);

View file

@ -21,7 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#define global_c_
#include "global.h"
#include "duke3d.h"
@ -42,6 +41,10 @@ int seenineblastradius = 2048;
int shrinkerblastradius = 650;
int gc = 176;
int tripbombblastradius = 3880;
int camerashitable;
int max_player_health;
int max_armour_amount;
int lasermode;
int cameradist = 0, cameraclock = 0;
int otherp;
@ -52,10 +55,21 @@ input_t sync[MAXPLAYERS];
int16_t max_ammo_amount[MAX_WEAPONS];
int16_t weaponsandammosprites[15];
int PHEIGHT = PHEIGHT_DUKE;
int duke3d_globalflags;
input_t loc;
bool synchronized_input;
uint8_t ready2send;
int gamequit;
int playerswhenstarted;
int show_shareware;
int screenpeek;
ClockTicks ototalclock;
// Variables that must be saved
uint8_t spriteextra[MAXSPRITES], sectorextra[MAXSECTORS]; // move these back into the base structs!
int rtsplaying;
int tempwallptr;
weaponhit hittype[MAXSPRITES];
@ -66,13 +80,64 @@ player_struct ps[MAXPLAYERS];
int spriteqamount = 64;
uint8_t shadedsector[MAXSECTORS];
int lastvisinc;
animwalltype animwall[MAXANIMWALLS];
int numanimwalls;
int animatecnt;
int numclouds;
int camsprite;
int numcyclers;
int earthquaketime;
int freezerhurtowner;
int global_random;
int impact_damage;
int mirrorcnt;
int numplayersprites;
int spriteqloc;
int16_t animatesect[MAXANIMATES];
int* animateptr[MAXANIMATES];
int animategoal[MAXANIMATES];
int animatevel[MAXANIMATES];
int16_t clouds[256];
int16_t cloudx;
int16_t cloudy;
ClockTicks cloudtotalclock;
int16_t spriteq[1024];
int16_t cyclers[MAXCYCLERS][6];
int16_t mirrorsector[64];
int16_t mirrorwall[64];
ClockTicks lockclock;
// Redneck Rampage
int wupass;
int chickenplant;
int thunderon;
int ufospawn;
int ufocnt;
int hulkspawn;
int lastlevel;
int geosectorwarp[MAXGEOSECTORS];
int geosectorwarp2[MAXGEOSECTORS];
int geosector[MAXGEOSECTORS];
int geox[MAXGEOSECTORS];
int geoy[MAXGEOSECTORS];
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, BellSprite /* word_119BE0*/;
uint8_t enemysizecheat /*raat607*/, ufospawnsminion, pistonsound, chickenphase /* raat605*/, RRRA_ExitedLevel, fogactive;
uint32_t everyothertime;
player_orig po[MAXPLAYERS];
END_DUKE_NS

View file

@ -628,8 +628,8 @@ static const dataspec_t svgm_anmisc[] =
{ 0, &g_earthquakeTime, sizeof(g_earthquakeTime), 1 },
// RR stuff
{ 0, &g_spriteExtra[0], sizeof(g_spriteExtra[0]), MAXSPRITES },
{ 0, &g_sectorExtra[0], sizeof(g_sectorExtra[0]), MAXSECTORS },
{ 0, &spriteextra[0], sizeof(spriteextra[0]), MAXSPRITES },
{ 0, &sectorextra[0], sizeof(sectorextra[0]), MAXSECTORS },
{ 0, &shadedsector[0], sizeof(shadedsector[0]), MAXSECTORS },