From 9e08d81a6b72c266b2380975fd9863e919b3e51d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 21 May 2020 11:41:48 +0200 Subject: [PATCH] - prelevel --- source/games/duke/src/game.h | 5 - source/games/duke/src/global.h | 37 ++- source/games/duke/src/premap.cpp | 96 ++++++- source/games/duke/src/premap.h | 1 + source/games/duke/src/premap_d.cpp | 375 +++++++++++--------------- source/games/duke/src/premap_r.cpp | 308 +++++---------------- source/games/duke/src/zz_actors.cpp | 2 +- source/games/duke/src/zz_game.cpp | 99 ++++--- source/games/duke/src/zz_premap.cpp | 86 +++--- source/games/duke/src/zz_savegame.cpp | 30 +-- source/games/duke/src/zz_screens.cpp | 6 +- source/rr/src/actors.cpp | 2 +- source/rr/src/global.h | 2 +- source/rr/src/premap.cpp | 6 +- 14 files changed, 450 insertions(+), 605 deletions(-) diff --git a/source/games/duke/src/game.h b/source/games/duke/src/game.h index 45c46c957..4d49cca69 100644 --- a/source/games/duke/src/game.h +++ b/source/games/duke/src/game.h @@ -201,11 +201,6 @@ static inline int Menu_HaveUserMap(void) extern const char *defaultrtsfilename[GAMECOUNT]; extern const char *G_DefaultRtsFile(void); -#ifdef LEGACY_ROR -extern char ror_protectedsectors[MAXSECTORS]; -#endif - - extern int32_t g_Debug; extern int32_t g_Shareware; extern int32_t g_cameraClock; diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index 928e923aa..6192c32e6 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -108,7 +108,7 @@ G_EXTERN int32_t g_animWallCnt; #define numanimwalls g_animWallCnt G_EXTERN int32_t g_animateCnt; #define animatecnt g_animateCnt -G_EXTERN int32_t g_cloudCnt; +G_EXTERN int32_t numclouds; G_EXTERN int32_t g_curViewscreen; #define camsprite g_curViewscreen G_EXTERN int32_t g_frameRate; @@ -128,7 +128,7 @@ G_EXTERN int32_t g_globalRandom; G_EXTERN int32_t impact_damage; extern int32_t labelcnt; G_EXTERN int32_t g_maxPlayerHealth; -G_EXTERN int32_t g_mirrorCount; +G_EXTERN int32_t mirrorcnt; G_EXTERN int32_t g_mostConcurrentPlayers; G_EXTERN int32_t g_musicSize; G_EXTERN int32_t numplayersprites; @@ -149,7 +149,7 @@ G_EXTERN int32_t g_animateGoal[MAXANIMATES]; G_EXTERN int32_t g_animateVel[MAXANIMATES]; #define animatevel g_animateVel -G_EXTERN int16_t g_cloudSect[256]; +G_EXTERN int16_t clouds[256]; G_EXTERN int16_t g_cloudX; G_EXTERN int16_t g_cloudY; G_EXTERN ClockTicks g_cloudClock; @@ -157,8 +157,8 @@ G_EXTERN ClockTicks g_cloudClock; G_EXTERN int16_t SpriteDeletionQueue[1024]; G_EXTERN int16_t g_cyclers[MAXCYCLERS][6]; #define cyclers g_cyclers -G_EXTERN int16_t g_mirrorSector[64]; -G_EXTERN int16_t g_mirrorWall[64]; +G_EXTERN int16_t mirrorsector[64]; +G_EXTERN int16_t mirrorwall[64]; G_EXTERN int32_t *labelcode; #if 0 G_EXTERN int32_t *labeltype; @@ -167,9 +167,8 @@ G_EXTERN ClockTicks lockclock; G_EXTERN ClockTicks ototalclock; G_EXTERN int32_t wupass; -G_EXTERN int32_t g_chickenPlant; -#define chickenplant g_chickenPlant -G_EXTERN int32_t g_thunderOn; +G_EXTERN int32_t chickenplant; +G_EXTERN int32_t thunderon; G_EXTERN int32_t g_ufoSpawn; #define ufospawn g_ufoSpawn G_EXTERN int32_t g_ufoCnt; @@ -182,14 +181,14 @@ G_EXTERN int32_t g_lastLevel; G_EXTERN int32_t g_turdLevel; -G_EXTERN int32_t g_geoSectorWarp[MAXGEOSECTORS]; -G_EXTERN int32_t g_geoSectorWarp2[MAXGEOSECTORS]; -G_EXTERN int32_t g_geoSector[MAXGEOSECTORS]; -G_EXTERN int32_t g_geoSectorX[MAXGEOSECTORS]; -G_EXTERN int32_t g_geoSectorY[MAXGEOSECTORS]; -G_EXTERN int32_t g_geoSectorX2[MAXGEOSECTORS]; -G_EXTERN int32_t g_geoSectorY2[MAXGEOSECTORS]; -G_EXTERN uint32_t g_geoSectorCnt; +G_EXTERN int32_t geosectorwarp[MAXGEOSECTORS]; +G_EXTERN int32_t geosectorwarp2[MAXGEOSECTORS]; +G_EXTERN int32_t geosector[MAXGEOSECTORS]; +G_EXTERN int32_t geox[MAXGEOSECTORS]; +G_EXTERN int32_t geoy[MAXGEOSECTORS]; +G_EXTERN int32_t geox2[MAXGEOSECTORS]; +G_EXTERN int32_t geoy2[MAXGEOSECTORS]; +G_EXTERN uint32_t geocnt; G_EXTERN int32_t g_thunderFlash; G_EXTERN int32_t g_thunderTime; @@ -199,7 +198,7 @@ G_EXTERN int32_t g_brightness; G_EXTERN int16_t ambientlotag[64]; G_EXTERN int16_t ambienthitag[64]; -G_EXTERN uint32_t g_ambientCnt; +G_EXTERN uint32_t ambientfx; inline int32_t G_HaveActor(int spriteNum) { @@ -227,9 +226,9 @@ G_EXTERN msx_ msx; G_EXTERN msy_ msy; G_EXTERN int32_t WindTime, WindDir; -G_EXTERN int16_t fakebubba_spawn, mamaspawn_count, banjosound, g_bellTime, g_bellSprite; +G_EXTERN int16_t fakebubba_spawn, mamaspawn_count, banjosound, g_bellTime, BellSprite; #define BellTime g_bellTime -#define word_119BE0 g_bellSprite +#define word_119BE0 BellSprite G_EXTERN uint8_t g_spriteExtra[MAXSPRITES], g_sectorExtra[MAXSECTORS]; // move these back into the base structs! G_EXTERN uint8_t enemysizecheat, ufospawnsminion, pistonsound, chickenphase, RRRA_ExitedLevel, RRRA_EndEpisode, fogactive; G_EXTERN int32_t g_cdTrack; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 238ee4b2f..ed1412ac7 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -27,6 +27,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #include "ns.h" #include "global.h" +#include "premap.h" BEGIN_DUKE_NS @@ -426,7 +427,7 @@ void resetprestat(int snum,int g) fakebubba_spawn = 0; RRRA_ExitedLevel = 0; BellTime = 0; - g_bellSprite = 0; + BellSprite = 0; numinterpolations = 0; //startofdynamicinterpolations = 0; @@ -651,5 +652,98 @@ void resetpspritevars(int g) } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- +void lava_cleararrays(); + +void prelevel_common(int g) +{ + int i; + + auto p = &ps[screenpeek]; + p->sea_sick_stat = 0; + ufospawnsminion = 0; + pistonsound = 0; + p->SlotWin = 0; + enemysizecheat = 0; + p->MamaEnd = 0; + mamaspawn_count = 15; + banjosound = 0; + RRRA_ExitedLevel = 0; + + lava_cleararrays(); + geocnt = 0; + ambientfx = 0; + thunderon = 0; + chickenplant = 0; + WindTime = 0; + WindDir = 0; + fakebubba_spawn = 0; + RRRA_ExitedLevel = 0; + mamaspawn_count = 15; + BellTime = 0; + BellSprite = 0; + + // RRRA E2L1 fog handling. + setmapfog(0); + fogactive = 0; + + show2dsector.Zero(); + memset(show2dwall, 0, sizeof(show2dwall)); + memset(show2dsprite, 0, sizeof(show2dsprite)); + + resetprestat(0, g); + numclouds = 0; + + memset(g_spriteExtra, 0, sizeof(g_spriteExtra)); + memset(g_sectorExtra, 0, sizeof(g_sectorExtra)); + memset(shadedsector, 0, sizeof(shadedsector)); + memset(geosectorwarp, -1, sizeof(geosectorwarp)); + memset(geosectorwarp2, -1, sizeof(geosectorwarp2)); + memset(ambienthitag, -1, sizeof(ambienthitag)); + memset(ambientlotag, -1, sizeof(ambientlotag)); + + for (i = 0; i < numsectors; i++) + { + sector[i].extra = 256; + + switch (sector[i].lotag) + { + case 20: + case 22: + if (sector[i].floorz > sector[i].ceilingz) + sector[i].lotag |= 32768; + continue; + } + + if (sector[i].ceilingstat & 1) + { + //setupbackdrop(sector[i].ceilingpicnum); + + if (sector[i].ceilingpicnum == TILE_CLOUDYSKIES && numclouds < 127) + clouds[numclouds++] = i; + + if (ps[0].one_parallax_sectnum == -1) + ps[0].one_parallax_sectnum = i; + } + + if (sector[i].lotag == 32767) //Found a secret room + { + ps[0].max_secret_rooms++; + continue; + } + + if (sector[i].lotag == -1) + { + ps[0].exitx = wall[sector[i].wallptr].x; + ps[0].exity = wall[sector[i].wallptr].y; + continue; + } + } +} + END_DUKE_NS \ No newline at end of file diff --git a/source/games/duke/src/premap.h b/source/games/duke/src/premap.h index fe1c0e332..4802706de 100644 --- a/source/games/duke/src/premap.h +++ b/source/games/duke/src/premap.h @@ -46,6 +46,7 @@ void G_ResetInterpolations(void); extern int32_t fragbarheight(void); void setmapfog(int fogtype); void G_InitRRRASkies(void); +void prelevel_common(int g); END_DUKE_NS diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index e48f3c98f..9cf927c1e 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -264,190 +264,127 @@ void cacheit_d(void) precacheMarkedTiles(); } -#if 0 - //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- -void prelevel(int g) +void prelevel_d(int g) { short i, nexti, j, startwall, endwall, lotaglist; short lotags[65]; - - show2dsector.Zero(); - memset(show2dwall,0, sizeof(show2dwall)); - memset(show2dsprite,0, sizeof(show2dsprite)); - - resetprestat(0,g); - numclouds = 0; - - for(i=0;i sector[i].ceilingz) - sector[i].lotag |= 32768; - continue; - } - - if(sector[i].ceilingstat&1) - { - setupbackdrop(sector[i].ceilingpicnum); - - if(sector[i].ceilingpicnum == CLOUDYSKIES && numclouds < 127) - clouds[numclouds++] = i; - - if(ps[0].one_parallax_sectnum == -1) - ps[0].one_parallax_sectnum = i; - } - - if(sector[i].lotag == 32767) //Found a secret room - { - ps[0].max_secret_rooms++; - continue; - } - - if(sector[i].lotag == -1) - { - ps[0].exitx = wall[sector[i].wallptr].x; - ps[0].exity = wall[sector[i].wallptr].y; - continue; - } - } + prelevel_common(g); i = headspritestat[0]; - while(i >= 0) + while (i >= 0) { nexti = nextspritestat[i]; - LoadActor(i, -1, -1); - - if(sprite[i].lotag == -1 && (sprite[i].cstat&16) ) + if (sprite[i].lotag == -1 && (sprite[i].cstat & 16)) { - ps[0].exitx = SX; - ps[0].exity = SY; + ps[0].exitx = sprite[i].x; + ps[0].exity = sprite[i].y; } - else switch(PN) + else switch (sprite[i].picnum) { - case GPSPEED: - sector[SECT].extra = SLT; - deletesprite(i); - break; + case GPSPEED: + sector[sprite[i].sectnum].extra = sprite[i].lotag; + deletesprite(i); + break; - case CYCLER: - if(numcyclers >= MAXCYCLERS) - gameexit("\nToo many cycling sectors."); - cyclers[numcyclers][0] = SECT; - cyclers[numcyclers][1] = SLT; - cyclers[numcyclers][2] = SS; - cyclers[numcyclers][3] = sector[SECT].floorshade; - cyclers[numcyclers][4] = SHT; - cyclers[numcyclers][5] = (SA == 1536); - numcyclers++; - deletesprite(i); - break; + case CYCLER: + if (numcyclers >= MAXCYCLERS) + I_Error("Too many cycling sectors."); + cyclers[numcyclers][0] = sprite[i].sectnum; + cyclers[numcyclers][1] = sprite[i].lotag; + cyclers[numcyclers][2] = sprite[i].shade; + cyclers[numcyclers][3] = sector[sprite[i].sectnum].floorshade; + cyclers[numcyclers][4] = sprite[i].hitag; + cyclers[numcyclers][5] = (sprite[i].ang == 1536); + numcyclers++; + deletesprite(i); + break; } i = nexti; } - for(i=0;i < MAXSPRITES;i++) + for (i = 0; i < MAXSPRITES; i++) { - if(sprite[i].statnum < MAXSTATUS) + if (sprite[i].statnum < MAXSTATUS) { - if(PN == SECTOREFFECTOR && SLT == 14) + if (sprite[i].picnum == SECTOREFFECTOR && sprite[i].lotag == 14) continue; - spawn(-1,i); + fi.spawn(-1, i); } } - for(i=0;i < MAXSPRITES;i++) - if(sprite[i].statnum < MAXSTATUS) + for (i = 0; i < MAXSPRITES; i++) + if (sprite[i].statnum < MAXSTATUS) { - if( PN == SECTOREFFECTOR && SLT == 14 ) - spawn(-1,i); + if (sprite[i].picnum == SECTOREFFECTOR && sprite[i].lotag == 14) + fi.spawn(-1, i); } lotaglist = 0; i = headspritestat[0]; - while(i >= 0) + while (i >= 0) { - switch(PN) + switch (sprite[i].picnum) { - case DIPSWITCH: - case DIPSWITCH2: - case ACCESSSWITCH: - case PULLSWITCH: - case HANDSWITCH: - case SLOTDOOR: - case LIGHTSWITCH: - case SPACELIGHTSWITCH: - case SPACEDOORSWITCH: - case FRANKENSTINESWITCH: - case LIGHTSWITCH2: - case POWERSWITCH1: - case LOCKSWITCH1: - case POWERSWITCH2: - break; - case DIPSWITCH+1: - case DIPSWITCH2+1: - case PULLSWITCH+1: - case HANDSWITCH+1: - case SLOTDOOR+1: - case LIGHTSWITCH+1: - case SPACELIGHTSWITCH+1: - case SPACEDOORSWITCH+1: - case FRANKENSTINESWITCH+1: - case LIGHTSWITCH2+1: - case POWERSWITCH1+1: - case LOCKSWITCH1+1: - case POWERSWITCH2+1: - for(j=0;j 64) + I_Error("Too many switches (64 max)."); + + j = headspritestat[3]; + while (j >= 0) { - lotags[lotaglist] = SLT; - lotaglist++; - if(lotaglist > 64) - gameexit("\nToo many switches (64 max)."); - - j = headspritestat[3]; - while(j >= 0) - { - if(sprite[j].lotag == 12 && sprite[j].hitag == SLT) - hittype[j].temp_data[0] = 1; - j = nextspritestat[j]; - } + if (sprite[j].lotag == 12 && sprite[j].hitag == sprite[i].lotag) + hittype[j].temp_data[0] = 1; + j = nextspritestat[j]; } - break; + } + break; } i = nextspritestat[i]; } mirrorcnt = 0; - for( i = 0; i < numwalls; i++ ) + for (i = 0; i < numwalls; i++) { - walltype *wal; + walltype* wal; wal = &wall[i]; - if(wal->overpicnum == MIRROR && (wal->cstat&32) != 0) + if (wal->overpicnum == MIRROR && (wal->cstat & 32) != 0) { j = wal->nextsector; - if(mirrorcnt > 63) - gameexit("\nToo many mirrors (64 max.)"); - if ( (j >= 0) && sector[j].ceilingpicnum != MIRROR ) + if (mirrorcnt > 63) + I_Error("Too many mirrors (64 max.)"); + if ((j >= 0) && sector[j].ceilingpicnum != MIRROR) { sector[j].ceilingpicnum = MIRROR; sector[j].floorpicnum = MIRROR; @@ -458,127 +395,112 @@ void prelevel(int g) } } - if(numanimwalls >= MAXANIMWALLS) - gameexit("\nToo many 'anim' walls (max 512.)"); + if (numanimwalls >= MAXANIMWALLS) + I_Error("Too many 'anim' walls (max 512.)"); animwall[numanimwalls].tag = 0; animwall[numanimwalls].wallnum = 0; - switch(wal->overpicnum) + switch (wal->overpicnum) { - case FANSHADOW: - case FANSPRITE: - wall->cstat |= 65; - animwall[numanimwalls].wallnum = i; - numanimwalls++; - break; + case FANSHADOW: + case FANSPRITE: + wall->cstat |= 65; + animwall[numanimwalls].wallnum = i; + numanimwalls++; + break; - case W_FORCEFIELD: - if(waloff[W_FORCEFIELD] == 0) - for(j=0;j<3;j++) - tloadtile(W_FORCEFIELD+j); - case W_FORCEFIELD+1: - case W_FORCEFIELD+2: - if(wal->shade > 31) - wal->cstat = 0; - else wal->cstat |= 85+256; + case W_FORCEFIELD: + for (j = 0; j < 3; j++) + tloadtile(W_FORCEFIELD + j); + case W_FORCEFIELD + 1: + case W_FORCEFIELD + 2: + if (wal->shade > 31) + wal->cstat = 0; + else wal->cstat |= 85 + 256; + if (wal->lotag && wal->nextwall >= 0) + wall[wal->nextwall].lotag = wal->lotag; - if(wal->lotag && wal->nextwall >= 0) - wall[wal->nextwall].lotag = - wal->lotag; + case BIGFORCE: - case BIGFORCE: + animwall[numanimwalls].wallnum = i; + numanimwalls++; - animwall[numanimwalls].wallnum = i; - numanimwalls++; - - continue; + continue; } wal->extra = -1; - switch(wal->picnum) + switch (wal->picnum) { - case WATERTILE2: - for(j=0;j<3;j++) - if(waloff[wal->picnum+j] == 0) - tloadtile(wal->picnum+j); - break; + case W_TECHWALL1: + case W_TECHWALL2: + case W_TECHWALL3: + case W_TECHWALL4: + animwall[numanimwalls].wallnum = i; + // animwall[numanimwalls].tag = -1; + numanimwalls++; + break; + case SCREENBREAK6: + case SCREENBREAK7: + case SCREENBREAK8: + for (j = SCREENBREAK6; j < SCREENBREAK9; j++) + tloadtile(j); + animwall[numanimwalls].wallnum = i; + animwall[numanimwalls].tag = -1; + numanimwalls++; + break; - case TECHLIGHT2: - case TECHLIGHT4: - if(waloff[wal->picnum] == 0) - tloadtile(wal->picnum); - break; - case W_TECHWALL1: - case W_TECHWALL2: - case W_TECHWALL3: - case W_TECHWALL4: - animwall[numanimwalls].wallnum = i; -// animwall[numanimwalls].tag = -1; - numanimwalls++; - break; - case SCREENBREAK6: - case SCREENBREAK7: - case SCREENBREAK8: - if(waloff[SCREENBREAK6] == 0) - for(j=SCREENBREAK6;jextra = wal->picnum; + animwall[numanimwalls].tag = -1; + if (ud.lockout) + { + if (wal->picnum == FEMPIC1) + wal->picnum = BLANKSCREEN; + else wal->picnum = SCREENBREAK6; + } - wal->extra = wal->picnum; - animwall[numanimwalls].tag = -1; - if(ud.lockout) - { - if(wal->picnum == FEMPIC1) - wal->picnum = BLANKSCREEN; - else wal->picnum = SCREENBREAK6; - } + animwall[numanimwalls].wallnum = i; + animwall[numanimwalls].tag = wal->picnum; + numanimwalls++; + break; - animwall[numanimwalls].wallnum = i; - animwall[numanimwalls].tag = wal->picnum; - numanimwalls++; - break; + case SCREENBREAK1: + case SCREENBREAK2: + case SCREENBREAK3: + case SCREENBREAK4: + case SCREENBREAK5: - case SCREENBREAK1: - case SCREENBREAK2: - case SCREENBREAK3: - case SCREENBREAK4: - case SCREENBREAK5: + case SCREENBREAK9: + case SCREENBREAK10: + case SCREENBREAK11: + case SCREENBREAK12: + case SCREENBREAK13: + case SCREENBREAK14: + case SCREENBREAK15: + case SCREENBREAK16: + case SCREENBREAK17: + case SCREENBREAK18: + case SCREENBREAK19: - case SCREENBREAK9: - case SCREENBREAK10: - case SCREENBREAK11: - case SCREENBREAK12: - case SCREENBREAK13: - case SCREENBREAK14: - case SCREENBREAK15: - case SCREENBREAK16: - case SCREENBREAK17: - case SCREENBREAK18: - case SCREENBREAK19: - - animwall[numanimwalls].wallnum = i; - animwall[numanimwalls].tag = wal->picnum; - numanimwalls++; - break; + animwall[numanimwalls].wallnum = i; + animwall[numanimwalls].tag = wal->picnum; + numanimwalls++; + break; } } //Invalidate textures in sector behind mirror - for(i=0;ifogtype = 0; - p->raat5dd = 0; - p->raat5fd = 0; - p->raat601 = 0; - p->SlotWin = 0; - p->raat607 = 0; - p->raat609 = 0; - mamaspawn_count = 15; - word_119BDC = 0; - word_119BE2 = 0; - if (ud.level_number == 3 && ud.volume_number == 0) - mamaspawn_count = 5; - else if (ud.level_number == 2 && ud.volume_number == 1) - mamaspawn_count = 10; - else if (ud.level_number == 6 && ud.volume_number == 1) - mamaspawn_count = 15; - else if (ud.level_number == 4 && ud.volume_number == 1) - ps[myconnectindex].steroids_amount = 0; -#endif - - clearbufbyte(show2dsector, sizeof(show2dsector), 0L); - clearbufbyte(show2dwall, sizeof(show2dwall), 0L); - clearbufbyte(show2dsprite, sizeof(show2dsprite), 0L); - - for (i = 0; i < MAXSECTORS; i++) - shadedsector[i] = 0; - - for (i = 0; i < 64; i++) + if (isRRRA()) { - geosectorwarp[i] = -1; - geosectorwarp2[i] = -1; - } + if (ud.level_number == 4 && ud.volume_number == 1) + ps[myconnectindex].steroids_amount = 0; - for (i = 0; i < 64; i++) - { - ambienthitag[i] = -1; - ambientlotag[i] = -1; - ambientsprite[i] = -1; - } - - resetprestat(0, g); - lightnincnt = 0; - torchcnt = 0; - geocnt = 0; - jaildoorcnt = 0; - minecartcnt = 0; - ambientfx = 0; - crashcnt = 0; - thunderon = 0; - chickenplant = 0; -#ifdef RRRA - WindTime = 0; - WindDir = 0; - fakebubba_spawn = 0; - word_119BE2 = 0; - mamaspawn_count = 15; - BellTime = 0; - word_119BE0 = 0; - - for (j = 0; j < MAXSPRITES; j++) - { - if (sprite[j].pal == 100) + for (j = 0; j < MAXSPRITES; j++) { - if (numplayers > 1) - deletesprite(j); - else + if (sprite[j].pal == 100) + { + if (numplayers > 1) + deletesprite(j); + else + sprite[j].pal = 0; + } + else if (sprite[j].pal == 101) + { + sprite[j].extra = 0; + sprite[j].hitag = 1; sprite[j].pal = 0; - } - else if (sprite[j].pal == 101) - { - sprite[j].extra = 0; - sprite[j].hitag = 1; - sprite[j].pal = 0; - changespritestat(j, 118); + changespritestat(j, 118); + } } } -#endif for (i = 0; i < numsectors; i++) { if (sector[i].ceilingpicnum == RRTILE2577) thunderon = 1; - sector[i].extra = 256; switch (sector[i].lotag) { @@ -568,23 +517,14 @@ void prelevel(char g) { if (sector[i].hitag == sector[j].hitag && j != i) { - if (jaildoorcnt > 32) - gameexit("\nToo many jaildoor sectors"); - jaildoordist[jaildoorcnt] = dist; - jaildoorspeed[jaildoorcnt] = speed; - jaildoorsecthtag[jaildoorcnt] = sector[i].hitag; - jaildoorsect[jaildoorcnt] = j; - jaildoordrag[jaildoorcnt] = 0; - jaildooropen[jaildoorcnt] = 0; - jaildoordir[jaildoorcnt] = sector[j].lotag; - jaildoorsound[jaildoorcnt] = sound; - jaildoorcnt++; + addjaildoor(dist, speed, sector[i].hitag, sector[j].lotag, sound, j); } } break; case 42: { short ii; + int childsectnum = -1; k = headspritesect[i]; while (k != -1) { @@ -598,7 +538,7 @@ void prelevel(char g) if (sprite[ii].picnum == RRTILE66) if (sprite[ii].lotag == sprite[k].sectnum) { - minecartchildsect[minecartcnt] = sprite[ii].sectnum; + childsectnum = sprite[ii].sectnum; deletesprite(ii); } } @@ -611,51 +551,9 @@ void prelevel(char g) } k = nexti; } - if (minecartcnt > 16) - gameexit("\nToo many minecart sectors"); - minecartdist[minecartcnt] = dist; - minecartspeed[minecartcnt] = speed; - minecartsect[minecartcnt] = i; - minecartdir[minecartcnt] = sector[i].hitag; - minecartdrag[minecartcnt] = dist; - minecartopen[minecartcnt] = 1; - minecartsound[minecartcnt] = sound; - minecartcnt++; + addminecart(dist, speed, i, sector[i].hitag, sound, childsectnum); break; } - case 20: - case 22: - if (sector[i].floorz > sector[i].ceilingz) - sector[i].lotag |= 32768; - continue; - } - - if (sector[i].ceilingstat & 1) - { - if (waloff[sector[i].ceilingpicnum] == 0) - { - if (sector[i].ceilingpicnum == LA) - for (j = 0; j < 5; j++) - if (waloff[sector[i].ceilingpicnum + j] == 0) - tloadtile(sector[i].ceilingpicnum + j); - } - setupbackdrop(sector[i].ceilingpicnum); - - if (ps[0].one_parallax_sectnum == -1) - ps[0].one_parallax_sectnum = i; - } - - if (sector[i].lotag == 32767) //Found a secret room - { - ps[0].max_secret_rooms++; - continue; - } - - if (sector[i].lotag == -1) - { - ps[0].exitx = wall[sector[i].wallptr].x; - ps[0].exity = wall[sector[i].wallptr].y; - continue; } } @@ -666,8 +564,8 @@ void prelevel(char g) if (sprite[i].lotag == -1 && (sprite[i].cstat & 16)) { - ps[0].exitx = SX; - ps[0].exity = SY; + ps[0].exitx = sprite[i].x; + ps[0].exity = sprite[i].y; } else switch (sprite[i].picnum) { @@ -676,44 +574,35 @@ void prelevel(char g) break; case GPSPEED: - sector[SECT].extra = SLT; + sector[sprite[i].sectnum].extra = sprite[i].lotag; deletesprite(i); break; case CYCLER: if (numcyclers >= MAXCYCLERS) - gameexit("\nToo many cycling sectors."); - cyclers[numcyclers][0] = SECT; - cyclers[numcyclers][1] = SLT; - cyclers[numcyclers][2] = SS; - cyclers[numcyclers][3] = sector[SECT].floorshade; - cyclers[numcyclers][4] = SHT; - cyclers[numcyclers][5] = (SA == 1536); + I_Error("Too many cycling sectors."); + cyclers[numcyclers][0] = sprite[i].sectnum; + cyclers[numcyclers][1] = sprite[i].lotag; + cyclers[numcyclers][2] = sprite[i].shade; + cyclers[numcyclers][3] = sector[sprite[i].sectnum].floorshade; + cyclers[numcyclers][4] = sprite[i].hitag; + cyclers[numcyclers][5] = (sprite[i].ang == 1536); numcyclers++; deletesprite(i); break; case RRTILE18: - if (torchcnt > 64) - gameexit("\nToo many torch effects"); - torchsector[torchcnt] = SECT; - torchsectorshade[torchcnt] = sector[SECT].floorshade; - torchtype[torchcnt] = SLT; - torchcnt++; + addtorch(i); deletesprite(i); break; case RRTILE35: - if (lightnincnt > 64) - gameexit("\nToo many lightnin effects"); - lightninsector[lightnincnt] = SECT; - lightninsectorshade[lightnincnt] = sector[SECT].floorshade; - lightnincnt++; + addlightning(i); deletesprite(i); break; case RRTILE68: - shadedsector[SECT] = 1; + shadedsector[sprite[i].sectnum] = 1; deletesprite(i); break; @@ -723,12 +612,11 @@ void prelevel(char g) case SOUNDFX: if (ambientfx >= 64) - gameexit("\nToo many ambient effects"); + I_Error("Too many ambient effects"); else { - ambienthitag[ambientfx] = SHT; - ambientlotag[ambientfx] = SLT; - ambientsprite[ambientfx] = i; + ambienthitag[ambientfx] = sprite[i].hitag; + ambientlotag[ambientfx] = sprite[i].lotag; sprite[i].ang = ambientfx; ambientfx++; sprite[i].lotag = 0; @@ -744,7 +632,7 @@ void prelevel(char g) if (sprite[i].picnum == RRTILE19) { if (geocnt > 64) - gameexit("\nToo many geometry effects"); + I_Error("Too many geometry effects"); if (sprite[i].hitag == 0) { geosector[geocnt] = sprite[i].sectnum; @@ -757,14 +645,14 @@ void prelevel(char g) geosectorwarp[geocnt] = sprite[j].sectnum; geox[geocnt] = sprite[i].x - sprite[j].x; geoy[geocnt] = sprite[i].y - sprite[j].y; - geoz[geocnt] = sprite[i].z - sprite[j].z; + //geoz[geocnt] = sprite[i].z - sprite[j].z; } if (sprite[j].hitag == 2) { geosectorwarp2[geocnt] = sprite[j].sectnum; geox2[geocnt] = sprite[i].x - sprite[j].x; geoy2[geocnt] = sprite[i].y - sprite[j].y; - geoz2[geocnt] = sprite[i].z - sprite[j].z; + //geoz2[geocnt] = sprite[i].z - sprite[j].z; } } } @@ -777,9 +665,9 @@ void prelevel(char g) { if (sprite[i].statnum < MAXSTATUS) { - if (sprite[i].picnum == SECTOREFFECTOR && SLT == 14) + if (sprite[i].picnum == SECTOREFFECTOR && sprite[i].lotag == 14) continue; - spawn(-1, i); + fi.spawn(-1, i); } } @@ -787,14 +675,14 @@ void prelevel(char g) { if (sprite[i].statnum < MAXSTATUS) { - if (sprite[i].picnum == SECTOREFFECTOR && SLT == 14) - spawn(-1, i); + if (sprite[i].picnum == SECTOREFFECTOR && sprite[i].lotag == 14) + fi.spawn(-1, i); } if (sprite[i].picnum == RRTILE19) deletesprite(i); if (sprite[i].picnum == RRTILE34) { - sector[sprite[i].sectnum].filler = sprite[i].lotag; + g_sectorExtra[sprite[i].sectnum] = sprite[i].lotag; deletesprite(i); } } @@ -806,24 +694,8 @@ void prelevel(char g) { switch (sprite[i].picnum) { - case DIPSWITCH: - case DIPSWITCH2: - case ACCESSSWITCH: - case PULLSWITCH: - case HANDSWITCH: - case SLOTDOOR: - case LIGHTSWITCH: - case SPACELIGHTSWITCH: - case SPACEDOORSWITCH: - case FRANKENSTINESWITCH: - case LIGHTSWITCH2: - case POWERSWITCH1: - case LOCKSWITCH1: - case POWERSWITCH2: -#ifdef RRRA - case RRTILE8464: -#endif - break; + case RRTILE8464 + 1: + if (!isRRRA()) break; case DIPSWITCH + 1: case DIPSWITCH2 + 1: case PULLSWITCH + 1: @@ -839,24 +711,22 @@ void prelevel(char g) case POWERSWITCH2 + 1: case NUKEBUTTON: case NUKEBUTTON + 1: -#ifdef RRRA - case RRTILE8464 + 1: -#endif + for (j = 0; j < lotaglist; j++) - if (SLT == lotags[j]) + if (sprite[i].lotag == lotags[j]) break; if (j == lotaglist) { - lotags[lotaglist] = SLT; + lotags[lotaglist] = sprite[i].lotag; lotaglist++; if (lotaglist > 64) - gameexit("\nToo many switches (64 max)."); + I_Error("Too many switches (64 max)."); j = headspritestat[3]; while (j >= 0) { - if (sprite[j].lotag == 12 && sprite[j].hitag == SLT) + if (sprite[j].lotag == 12 && sprite[j].hitag == sprite[i].lotag) hittype[j].temp_data[0] = 1; j = nextspritestat[j]; } @@ -878,7 +748,7 @@ void prelevel(char g) j = wal->nextsector; if (mirrorcnt > 63) - gameexit("\nToo many mirrors (64 max.)"); + I_Error("Too many mirrors (64 max.)"); if ((j >= 0) && sector[j].ceilingpicnum != MIRROR) { sector[j].ceilingpicnum = MIRROR; @@ -891,7 +761,7 @@ void prelevel(char g) } if (numanimwalls >= MAXANIMWALLS) - gameexit("\nToo many 'anim' walls (max 512.)"); + I_Error("Too many 'anim' walls (max 512.)"); animwall[numanimwalls].tag = 0; animwall[numanimwalls].wallnum = 0; @@ -913,47 +783,11 @@ void prelevel(char g) switch (wal->picnum) { - case WATERTILE2: - for (j = 0; j < 3; j++) - if (waloff[wal->picnum + j] == 0) - tloadtile(wal->picnum + j); - break; - - case RRTILE1814: - case RRTILE1817: - if (waloff[wal->picnum] == 0) - tloadtile(wal->picnum); - break; - case RRTILE1939: - case RRTILE1986: - case RRTILE1987: - case RRTILE1988: - case RRTILE2004: - case RRTILE2005: - case RRTILE2123: - case RRTILE2124: - case RRTILE2125: - case RRTILE2126: - case RRTILE2636: - case RRTILE2637: - case RRTILE2878: - case RRTILE2879: - case RRTILE2898: - case RRTILE2899: - if (waloff[wal->picnum] == 0) - tloadtile(wal->picnum); - break; - case TECHLIGHT2: - case TECHLIGHT4: - if (waloff[wal->picnum] == 0) - tloadtile(wal->picnum); - break; case SCREENBREAK6: case SCREENBREAK7: case SCREENBREAK8: - if (waloff[SCREENBREAK6] == 0) - for (j = SCREENBREAK6; j <= SCREENBREAK8; j++) - tloadtile(j, pal); + for (j = SCREENBREAK6; j <= SCREENBREAK8; j++) + tloadtile(j); animwall[numanimwalls].wallnum = i; animwall[numanimwalls].tag = -1; numanimwalls++; @@ -972,18 +806,20 @@ void prelevel(char g) wall[j].overpicnum = MIRROR; } } + videoSetBrightness(0); if (!thunderon) { - char brightness = ud.brightness >> 2; - setbrightness(brightness, palette); - visibility = p->visibility; + g_visibility = p->visibility; } - tilesizx[0] = tilesizy[0] = 0; -} + } +#if 0 + + + #if 0 void enterlevel(char g) { @@ -1172,4 +1008,4 @@ void loadlevel(const char *filename) -END_DUKE_NS \ No newline at end of file +END_DUKE_NS diff --git a/source/games/duke/src/zz_actors.cpp b/source/games/duke/src/zz_actors.cpp index 174626c30..6eb9661dd 100644 --- a/source/games/duke/src/zz_actors.cpp +++ b/source/games/duke/src/zz_actors.cpp @@ -223,7 +223,7 @@ void G_MoveWorld_r(void) if (!DEER) movefx(); //ST 11 - if (numplayers < 2 && g_thunderOn) + if (numplayers < 2 && thunderon) thunder(); g_moveWorldTime = (1 - 0.033) * g_moveWorldTime + 0.033 * (timerGetHiTicks() - worldTime); diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index aada66ae9..041d9c0d9 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -568,7 +568,6 @@ void G_SE150(int32_t x, int32_t y, int32_t z, int32_t a, int32_t h, int32_t smoo } #ifdef LEGACY_ROR -char ror_protectedsectors[MAXSECTORS]; static int32_t drawing_ror = 0; static int32_t ror_sprite = -1; @@ -651,7 +650,7 @@ static void G_SE40(int32_t smoothratio) { SE40backupStat[i] = sector[i].ceilingstat; SE40backupZ[i] = sector[i].ceilingz; - if (!ror_protectedsectors[i] || sp->lotag == 41) + if (sp->lotag == 41) { sector[i].ceilingstat = 1; sector[i].ceilingz += newz; @@ -673,7 +672,7 @@ static void G_SE40(int32_t smoothratio) { SE40backupStat[i] = sector[i].floorstat; SE40backupZ[i] = sector[i].floorz; - if (!ror_protectedsectors[i] || sp->lotag == 41) + if (sp->lotag == 41) { sector[i].floorstat = 1; sector[i].floorz = +newz; @@ -727,9 +726,9 @@ void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t q16horiz #endif ) { - if (g_mirrorCount == 0) + if (mirrorcnt == 0) { - // NOTE: We can have g_mirrorCount==0 but gotpic'd TILE_MIRROR, + // NOTE: We can have mirrorcnt==0 but gotpic'd TILE_MIRROR, // for example in LNGA2. gotpic[TILE_MIRROR>>3] &= ~(1<<(TILE_MIRROR&7)); return; @@ -737,48 +736,48 @@ void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t q16horiz int32_t i = 0, dst = INT32_MAX; - for (bssize_t k=g_mirrorCount-1; k>=0; k--) + for (bssize_t k=mirrorcnt-1; k>=0; k--) { - if (!wallvisible(x, y, g_mirrorWall[k])) + if (!wallvisible(x, y, mirrorwall[k])) continue; const int32_t j = - klabs(wall[g_mirrorWall[k]].x - x) + - klabs(wall[g_mirrorWall[k]].y - y); + klabs(wall[mirrorwall[k]].x - x) + + klabs(wall[mirrorwall[k]].y - y); if (j < dst) dst = j, i = k; } - if (wall[g_mirrorWall[i]].overpicnum != TILE_MIRROR) + if (wall[mirrorwall[i]].overpicnum != TILE_MIRROR) { // Try to find a new mirror wall in case the original one was broken. - int32_t startwall = sector[g_mirrorSector[i]].wallptr; - int32_t endwall = startwall + sector[g_mirrorSector[i]].wallnum; + int32_t startwall = sector[mirrorsector[i]].wallptr; + int32_t endwall = startwall + sector[mirrorsector[i]].wallnum; for (bssize_t k=startwall; k= 0 && (wall[j].cstat&32) && wall[j].overpicnum==TILE_MIRROR) // cmp. premap.c { - g_mirrorWall[i] = j; + mirrorwall[i] = j; break; } } } - if (wall[g_mirrorWall[i]].overpicnum == TILE_MIRROR) + if (wall[mirrorwall[i]].overpicnum == TILE_MIRROR) { int32_t tposx, tposy; fix16_t tang; - renderPrepareMirror(x, y, z, a, q16horiz, g_mirrorWall[i], &tposx, &tposy, &tang); + renderPrepareMirror(x, y, z, a, q16horiz, mirrorwall[i], &tposx, &tposy, &tang); int32_t j = g_visibility; g_visibility = (j>>1) + (j>>2); - renderDrawRoomsQ16(tposx,tposy,z,tang,q16horiz,g_mirrorSector[i]+MAXSECTORS); + renderDrawRoomsQ16(tposx,tposy,z,tang,q16horiz,mirrorsector[i]+MAXSECTORS); display_mirror = 1; G_DoSpriteAnimations(tposx,tposy,z,fix16_to_int(tang),smoothratio); display_mirror = 0; @@ -1133,39 +1132,39 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) int geoSector = 0; - for (bsize_t gs = 0; gs < g_geoSectorCnt; gs++) + for (bsize_t gs = 0; gs < geocnt; gs++) { - int spriteNum = headspritesect[g_geoSector[gs]]; + int spriteNum = headspritesect[geosector[gs]]; while (spriteNum != -1) { int spriteNext = nextspritesect[spriteNum]; - changespritesect(spriteNum, g_geoSectorWarp[gs]); - sprite[spriteNum].x -= g_geoSectorX[gs]; - sprite[spriteNum].y -= g_geoSectorY[gs]; + changespritesect(spriteNum, geosectorwarp[gs]); + sprite[spriteNum].x -= geox[gs]; + sprite[spriteNum].y -= geoy[gs]; setsprite(spriteNum, (vec3_t*)&sprite[spriteNum]); spriteNum = spriteNext; } - if (CAMERA(sect) == g_geoSector[gs]) + if (CAMERA(sect) == geosector[gs]) geoSector = gs; } - CAMERA(pos.x) -= g_geoSectorX[geoSector]; - CAMERA(pos.y) -= g_geoSectorY[geoSector]; + CAMERA(pos.x) -= geox[geoSector]; + CAMERA(pos.y) -= geoy[geoSector]; yax_preparedrawrooms(); - renderDrawRoomsQ16(CAMERA(pos.x),CAMERA(pos.y),CAMERA(pos.z),CAMERA(q16ang),CAMERA(q16horiz),g_geoSectorWarp[geoSector]); - yax_drawrooms(G_DoSpriteAnimations, g_geoSectorWarp[geoSector], 0, smoothRatio); - CAMERA(pos.x) += g_geoSectorX[geoSector]; - CAMERA(pos.y) += g_geoSectorY[geoSector]; + renderDrawRoomsQ16(CAMERA(pos.x),CAMERA(pos.y),CAMERA(pos.z),CAMERA(q16ang),CAMERA(q16horiz),geosectorwarp[geoSector]); + yax_drawrooms(G_DoSpriteAnimations, geosectorwarp[geoSector], 0, smoothRatio); + CAMERA(pos.x) += geox[geoSector]; + CAMERA(pos.y) += geoy[geoSector]; - for (bsize_t gs = 0; gs < g_geoSectorCnt; gs++) + for (bsize_t gs = 0; gs < geocnt; gs++) { - int spriteNum = headspritesect[g_geoSectorWarp[gs]]; + int spriteNum = headspritesect[geosectorwarp[gs]]; while (spriteNum != -1) { int spriteNext = nextspritesect[spriteNum]; - changespritesect(spriteNum, g_geoSector[gs]); - sprite[spriteNum].x += g_geoSectorX[gs]; - sprite[spriteNum].y += g_geoSectorY[gs]; + changespritesect(spriteNum, geosector[gs]); + sprite[spriteNum].x += geox[gs]; + sprite[spriteNum].y += geoy[gs]; setsprite(spriteNum, (vec3_t*)&sprite[spriteNum]); spriteNum = spriteNext; } @@ -1175,39 +1174,39 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) renderDrawMasks(); - for (bsize_t gs = 0; gs < g_geoSectorCnt; gs++) + for (bsize_t gs = 0; gs < geocnt; gs++) { - int spriteNum = headspritesect[g_geoSector[gs]]; + int spriteNum = headspritesect[geosector[gs]]; while (spriteNum != -1) { int spriteNext = nextspritesect[spriteNum]; - changespritesect(spriteNum, g_geoSectorWarp2[gs]); - sprite[spriteNum].x -= g_geoSectorX2[gs]; - sprite[spriteNum].y -= g_geoSectorY2[gs]; + changespritesect(spriteNum, geosectorwarp2[gs]); + sprite[spriteNum].x -= geox2[gs]; + sprite[spriteNum].y -= geoy2[gs]; setsprite(spriteNum, (vec3_t*)&sprite[spriteNum]); spriteNum = spriteNext; } - if (CAMERA(sect) == g_geoSector[gs]) + if (CAMERA(sect) == geosector[gs]) geoSector = gs; } - CAMERA(pos.x) -= g_geoSectorX2[geoSector]; - CAMERA(pos.y) -= g_geoSectorY2[geoSector]; + CAMERA(pos.x) -= geox2[geoSector]; + CAMERA(pos.y) -= geoy2[geoSector]; yax_preparedrawrooms(); - renderDrawRoomsQ16(CAMERA(pos.x),CAMERA(pos.y),CAMERA(pos.z),CAMERA(q16ang),CAMERA(q16horiz),g_geoSectorWarp2[geoSector]); - yax_drawrooms(G_DoSpriteAnimations, g_geoSectorWarp2[geoSector], 0, smoothRatio); - CAMERA(pos.x) += g_geoSectorX2[geoSector]; - CAMERA(pos.y) += g_geoSectorY2[geoSector]; + renderDrawRoomsQ16(CAMERA(pos.x),CAMERA(pos.y),CAMERA(pos.z),CAMERA(q16ang),CAMERA(q16horiz),geosectorwarp2[geoSector]); + yax_drawrooms(G_DoSpriteAnimations, geosectorwarp2[geoSector], 0, smoothRatio); + CAMERA(pos.x) += geox2[geoSector]; + CAMERA(pos.y) += geoy2[geoSector]; - for (bsize_t gs = 0; gs < g_geoSectorCnt; gs++) + for (bsize_t gs = 0; gs < geocnt; gs++) { - int spriteNum = headspritesect[g_geoSectorWarp2[gs]]; + int spriteNum = headspritesect[geosectorwarp2[gs]]; while (spriteNum != -1) { int spriteNext = nextspritesect[spriteNum]; - changespritesect(spriteNum, g_geoSector[gs]); - sprite[spriteNum].x += g_geoSectorX2[gs]; - sprite[spriteNum].y += g_geoSectorY2[gs]; + changespritesect(spriteNum, geosector[gs]); + sprite[spriteNum].x += geox2[gs]; + sprite[spriteNum].y += geoy2[gs]; setsprite(spriteNum, (vec3_t*)&sprite[spriteNum]); spriteNum = spriteNext; } diff --git a/source/games/duke/src/zz_premap.cpp b/source/games/duke/src/zz_premap.cpp index b4e10163b..c209df281 100644 --- a/source/games/duke/src/zz_premap.cpp +++ b/source/games/duke/src/zz_premap.cpp @@ -199,12 +199,6 @@ void G_UpdateScreenArea(void) pus = NUMPAGES; } -static inline void P_ResetTintFade(DukePlayer_t *const pPlayer) -{ - pPlayer->pals.f = 0; -} - - static inline int G_CheckExitSprite(int spriteNum) { return ((uint16_t)sprite[spriteNum].lotag == UINT16_MAX && (sprite[spriteNum].cstat & 16)); } void G_InitRRRASkies(void) @@ -236,6 +230,10 @@ void G_InitRRRASkies(void) } } +void prelevel_d(int g); +void prelevel_r(int g); + +#if 0 static void prelevel(char g) { uint8_t *tagbitmap = (uint8_t *)Xcalloc(65536>>3, 1); @@ -275,22 +273,19 @@ static void prelevel(char g) Bmemset(g_spriteExtra, 0, sizeof(g_spriteExtra)); Bmemset(g_sectorExtra, 0, sizeof(g_sectorExtra)); Bmemset(shadedsector, 0, sizeof(shadedsector)); - Bmemset(g_geoSectorWarp, -1, sizeof(g_geoSectorWarp)); - Bmemset(g_geoSectorWarp2, -1, sizeof(g_geoSectorWarp2)); + Bmemset(geosectorwarp, -1, sizeof(geosectorwarp)); + Bmemset(geosectorwarp2, -1, sizeof(geosectorwarp2)); Bmemset(ambienthitag, -1, sizeof(ambienthitag)); Bmemset(ambientlotag, -1, sizeof(ambientlotag)); show2dsector.Zero(); -#ifdef LEGACY_ROR - Bmemset(ror_protectedsectors, 0, MAXSECTORS); -#endif resetprestat(0,g); if (RR) { lava_cleararrays(); - g_geoSectorCnt = 0; - g_ambientCnt = 0; - g_thunderOn = 0; - g_chickenPlant = 0; + geocnt = 0; + ambientfx = 0; + thunderon = 0; + chickenplant = 0; if (RRRA) { WindTime = 0; @@ -299,7 +294,7 @@ static void prelevel(char g) RRRA_ExitedLevel = 0; mamaspawn_count = 15; // ??? g_bellTime = 0; - g_bellSprite = 0; + BellSprite = 0; for (bssize_t spriteNum = 0; spriteNum < MAXSPRITES; spriteNum++) { @@ -320,7 +315,7 @@ static void prelevel(char g) } } } - g_cloudCnt = 0; + numclouds = 0; int missedCloudSectors = 0; @@ -328,7 +323,7 @@ static void prelevel(char g) for (bssize_t i=0; i= 64) + if (ambientfx >= 64) G_GameExit("\nToo many ambient effects"); else { - ambienthitag[g_ambientCnt] = SHT(i); - ambientlotag[g_ambientCnt] = SLT(i); - sprite[i].ang = g_ambientCnt++; + ambienthitag[ambientfx] = SHT(i); + ambientlotag[ambientfx] = SLT(i); + sprite[i].ang = ambientfx++; sprite[i].lotag = 0; sprite[i].hitag = 0; } @@ -524,28 +519,28 @@ static void prelevel(char g) { if (sprite[i].hitag == 0) { - if (g_geoSectorCnt >= MAXGEOSECTORS) + if (geocnt >= MAXGEOSECTORS) G_GameExit("\nToo many geometry effects"); - g_geoSector[g_geoSectorCnt] = sprite[i].sectnum; + geosector[geocnt] = sprite[i].sectnum; for (bssize_t j = 0; j < MAXSPRITES; j++) { if (sprite[i].lotag == sprite[j].lotag && i != j && sprite[j].picnum == TILE_RRTILE19) { if (sprite[j].hitag == 1) { - g_geoSectorWarp[g_geoSectorCnt] = sprite[j].sectnum; - g_geoSectorX[g_geoSectorCnt] = sprite[i].x - sprite[j].x; - g_geoSectorY[g_geoSectorCnt] = sprite[i].y - sprite[j].y; + geosectorwarp[geocnt] = sprite[j].sectnum; + geox[geocnt] = sprite[i].x - sprite[j].x; + geoy[geocnt] = sprite[i].y - sprite[j].y; } if (sprite[j].hitag == 2) { - g_geoSectorWarp2[g_geoSectorCnt] = sprite[j].sectnum; - g_geoSectorX2[g_geoSectorCnt] = sprite[i].x - sprite[j].x; - g_geoSectorY2[g_geoSectorCnt] = sprite[i].y - sprite[j].y; + geosectorwarp2[geocnt] = sprite[j].sectnum; + geox2[geocnt] = sprite[i].x - sprite[j].x; + geoy2[geocnt] = sprite[i].y - sprite[j].y; } } } - g_geoSectorCnt++; + geocnt++; } } } @@ -622,7 +617,7 @@ static void prelevel(char g) Xfree(tagbitmap); - g_mirrorCount = 0; + mirrorcnt = 0; for (bssize_t i = 0; i < numwalls; i++) { @@ -634,16 +629,16 @@ static void prelevel(char g) if ((nextSectnum >= 0) && sector[nextSectnum].ceilingpicnum != TILE_MIRROR) { - if (g_mirrorCount > 63) + if (mirrorcnt > 63) { G_GameExit("\nToo many mirrors (64 max.)"); } sector[nextSectnum].ceilingpicnum = TILE_MIRROR; sector[nextSectnum].floorpicnum = TILE_MIRROR; - g_mirrorWall[g_mirrorCount] = i; - g_mirrorSector[g_mirrorCount] = nextSectnum; - g_mirrorCount++; + mirrorwall[mirrorcnt] = i; + mirrorsector[mirrorcnt] = nextSectnum; + mirrorcnt++; continue; } } @@ -789,10 +784,10 @@ static void prelevel(char g) } //Invalidate textures in sector behind mirror - for (bssize_t i=0; ivisibility; @@ -814,7 +809,7 @@ static void prelevel(char g) G_SetupGlobalPsky(); } - +#endif void G_NewGame(int volumeNum, int levelNum, int skillNum) { @@ -1117,7 +1112,8 @@ int G_EnterLevel(int gameMode) Bmemset(gotpic, 0, sizeof(gotpic)); Bmemset(precachehightile, 0, sizeof(precachehightile)); - prelevel(gameMode); + if (isRR()) prelevel_r(gameMode); + else prelevel_d(gameMode); G_InitRRRASkies(); diff --git a/source/games/duke/src/zz_savegame.cpp b/source/games/duke/src/zz_savegame.cpp index 2c5181570..1a9ca7f74 100644 --- a/source/games/duke/src/zz_savegame.cpp +++ b/source/games/duke/src/zz_savegame.cpp @@ -827,9 +827,9 @@ static const dataspec_t svgm_secwsp[] = { DS_CNT(g_cyclerCnt), &g_cyclers[0][0], sizeof(g_cyclers[0]), (intptr_t)&g_cyclerCnt }, { DS_NOCHK, &g_animWallCnt, sizeof(g_animWallCnt), 1 }, { DS_CNT(g_animWallCnt), &animwall, sizeof(animwall[0]), (intptr_t)&g_animWallCnt }, - { DS_NOCHK, &g_mirrorCount, sizeof(g_mirrorCount), 1 }, - { DS_NOCHK, &g_mirrorWall[0], sizeof(g_mirrorWall[0]), ARRAY_SIZE(g_mirrorWall) }, - { DS_NOCHK, &g_mirrorSector[0], sizeof(g_mirrorSector[0]), ARRAY_SIZE(g_mirrorSector) }, + { DS_NOCHK, &mirrorcnt, sizeof(mirrorcnt), 1 }, + { DS_NOCHK, &mirrorwall[0], sizeof(mirrorwall[0]), ARRAY_SIZE(mirrorwall) }, + { DS_NOCHK, &mirrorsector[0], sizeof(mirrorsector[0]), ARRAY_SIZE(mirrorsector) }, { 0, &everyothertime, sizeof(everyothertime), 1 }, { DS_END, 0, 0, 0 } }; @@ -861,8 +861,8 @@ static const dataspec_t svgm_anmisc[] = { 0, &g_spriteDeleteQueuePos, sizeof(g_spriteDeleteQueuePos), 1 }, { DS_NOCHK, &g_deleteQueueSize, sizeof(g_deleteQueueSize), 1 }, { DS_CNT(g_deleteQueueSize), &SpriteDeletionQueue[0], sizeof(int16_t), (intptr_t)&g_deleteQueueSize }, - { DS_NOCHK, &g_cloudCnt, sizeof(g_cloudCnt), 1 }, - { 0, &g_cloudSect[0], sizeof(g_cloudSect), 1 }, + { DS_NOCHK, &numclouds, sizeof(numclouds), 1 }, + { 0, &clouds[0], sizeof(clouds), 1 }, { 0, &g_cloudX, sizeof(g_cloudX), 1 }, { 0, &g_cloudY, sizeof(g_cloudY), 1 }, { 0, &g_pskyidx, sizeof(g_pskyidx), 1 }, // DS_NOCHK? @@ -874,7 +874,7 @@ static const dataspec_t svgm_anmisc[] = { 0, &shadedsector[0], sizeof(shadedsector[0]), MAXSECTORS }, - { 0, &g_ambientCnt, sizeof(g_ambientCnt), 1 }, + { 0, &ambientfx, sizeof(ambientfx), 1 }, { 0, &ambienthitag[0], sizeof(ambienthitag[0]), ARRAY_SIZE(ambienthitag) }, { 0, &ambientlotag[0], sizeof(ambientlotag[0]), ARRAY_SIZE(ambientlotag) }, @@ -883,14 +883,14 @@ static const dataspec_t svgm_anmisc[] = { 0, &g_hulkSpawn, sizeof(g_hulkSpawn), 1 }, { 0, &g_lastLevel, sizeof(g_lastLevel), 1 }, - { 0, &g_geoSector[0], sizeof(g_geoSector[0]), ARRAY_SIZE(g_geoSector) }, - { 0, &g_geoSectorWarp[0], sizeof(g_geoSectorWarp[0]), ARRAY_SIZE(g_geoSectorWarp) }, - { 0, &g_geoSectorX[0], sizeof(g_geoSectorX[0]), ARRAY_SIZE(g_geoSectorX) }, - { 0, &g_geoSectorY[0], sizeof(g_geoSectorY[0]), ARRAY_SIZE(g_geoSectorY) }, - { 0, &g_geoSectorWarp2[0], sizeof(g_geoSectorWarp2[0]), ARRAY_SIZE(g_geoSectorWarp2) }, - { 0, &g_geoSectorX2[0], sizeof(g_geoSectorX2[0]), ARRAY_SIZE(g_geoSectorX2) }, - { 0, &g_geoSectorY2[0], sizeof(g_geoSectorY2[0]), ARRAY_SIZE(g_geoSectorY2) }, - { 0, &g_geoSectorCnt, sizeof(g_geoSectorCnt), 1 }, + { 0, &geosector[0], sizeof(geosector[0]), ARRAY_SIZE(geosector) }, + { 0, &geosectorwarp[0], sizeof(geosectorwarp[0]), ARRAY_SIZE(geosectorwarp) }, + { 0, &geox[0], sizeof(geox[0]), ARRAY_SIZE(geox) }, + { 0, &geoy[0], sizeof(geoy[0]), ARRAY_SIZE(geoy) }, + { 0, &geosectorwarp2[0], sizeof(geosectorwarp2[0]), ARRAY_SIZE(geosectorwarp2) }, + { 0, &geox2[0], sizeof(geox2[0]), ARRAY_SIZE(geox2) }, + { 0, &geoy2[0], sizeof(geoy2[0]), ARRAY_SIZE(geoy2) }, + { 0, &geocnt, sizeof(geocnt), 1 }, { 0, &WindTime, sizeof(WindTime), 1 }, { 0, &WindDir, sizeof(WindDir), 1 }, @@ -898,7 +898,7 @@ static const dataspec_t svgm_anmisc[] = { 0, &mamaspawn_count, sizeof(mamaspawn_count), 1 }, { 0, &banjosound, sizeof(banjosound), 1 }, { 0, &g_bellTime, sizeof(g_bellTime), 1 }, - { 0, &g_bellSprite, sizeof(g_bellSprite), 1 }, + { 0, &BellSprite, sizeof(BellSprite), 1 }, { 0, &enemysizecheat, sizeof(enemysizecheat), 1 }, { 0, &ufospawnsminion, sizeof(ufospawnsminion), 1 }, diff --git a/source/games/duke/src/zz_screens.cpp b/source/games/duke/src/zz_screens.cpp index d6e7c48bf..408930ee7 100644 --- a/source/games/duke/src/zz_screens.cpp +++ b/source/games/duke/src/zz_screens.cpp @@ -219,10 +219,10 @@ static inline void G_MoveClouds(void) g_cloudX += sintable[(fix16_to_int(g_player[screenpeek].ps->q16ang)+512)&2047]>>9; g_cloudY += sintable[fix16_to_int(g_player[screenpeek].ps->q16ang)&2047]>>9; - for (i=g_cloudCnt-1; i>=0; i--) + for (i=numclouds-1; i>=0; i--) { - sector[g_cloudSect[i]].ceilingxpanning = g_cloudX>>6; - sector[g_cloudSect[i]].ceilingypanning = g_cloudY>>6; + sector[clouds[i]].ceilingxpanning = g_cloudX>>6; + sector[clouds[i]].ceilingypanning = g_cloudY>>6; } } diff --git a/source/rr/src/actors.cpp b/source/rr/src/actors.cpp index 8a0ae2fbf..2fac447dc 100644 --- a/source/rr/src/actors.cpp +++ b/source/rr/src/actors.cpp @@ -9759,7 +9759,7 @@ void G_MoveWorld(void) if (!DEER) G_MoveFX(); //ST 11 - if (RR && numplayers < 2 && g_thunderOn) + if (RR && numplayers < 2 && thunderon) G_Thunder(); g_moveWorldTime = (1-0.033)*g_moveWorldTime + 0.033*(timerGetHiTicks()-worldTime); diff --git a/source/rr/src/global.h b/source/rr/src/global.h index 21cd0cd46..f2e2339e3 100644 --- a/source/rr/src/global.h +++ b/source/rr/src/global.h @@ -159,7 +159,7 @@ G_EXTERN ClockTicks ototalclock; G_EXTERN int32_t g_wupass; G_EXTERN int32_t g_chickenPlant; -G_EXTERN int32_t g_thunderOn; +G_EXTERN int32_t thunderon; G_EXTERN int32_t g_ufoSpawn; G_EXTERN int32_t g_ufoCnt; G_EXTERN int32_t g_hulkSpawn; diff --git a/source/rr/src/premap.cpp b/source/rr/src/premap.cpp index 18b9cdb08..8b3ecd96d 100644 --- a/source/rr/src/premap.cpp +++ b/source/rr/src/premap.cpp @@ -1320,7 +1320,7 @@ static void prelevel(char g) g_jailDoorCnt = 0; g_mineCartCnt = 0; g_ambientCnt = 0; - g_thunderOn = 0; + thunderon = 0; g_chickenPlant = 0; if (RRRA) { @@ -1359,7 +1359,7 @@ static void prelevel(char g) for (bssize_t i=0; ivisibility;