From 42bbc1e6ce0f2b35c337cd980351e4a010bda325 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 20 May 2020 23:39:54 +0200 Subject: [PATCH] resetprestat --- source/games/duke/src/global.h | 2 +- source/games/duke/src/premap.cpp | 10 +- source/games/duke/src/premap.h | 1 + source/games/duke/src/zz_interpolate.cpp | 28 +++--- source/games/duke/src/zz_premap.cpp | 118 +---------------------- source/games/duke/src/zz_savegame.cpp | 4 +- 6 files changed, 23 insertions(+), 140 deletions(-) diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index 2b98b426a..928e923aa 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -313,7 +313,7 @@ enum }; // Interpolation code is the same in all games with slightly different naming - this needs to be unified and cleaned up. -extern int32_t g_interpolationCnt; +extern int32_t numinterpolations; extern int32_t* curipos[MAXINTERPOLATIONS]; extern int32_t bakipos[MAXINTERPOLATIONS]; void G_UpdateInterpolations(void); diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index b965985b4..ec7b8cdae 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -377,7 +377,7 @@ void resetinventory(int snum) // //--------------------------------------------------------------------------- -void resetprestat(short snum,char g) +void resetprestat(int snum,int g) { struct player_struct *p; short i; @@ -427,7 +427,7 @@ void resetprestat(short snum,char g) BellTime = 0; g_bellSprite = 0; - //numinterpolations = 0; + numinterpolations = 0; //startofdynamicinterpolations = 0; if( ( (g&MODE_EOL) != MODE_EOL && numplayers < 2) || (ud.coop != 1 && numplayers > 1) ) @@ -451,7 +451,7 @@ void resetprestat(short snum,char g) p->make_noise = 0; p->noise_radius = 0; - if (ud.multimode > 1 && ud.coop != 1) + if (isRR() && ud.multimode > 1 && ud.coop != 1) { p->keys[0] = 1; p->keys[1] = 1; @@ -484,9 +484,7 @@ void resetprestat(short snum,char g) if (numplayers < 2) { - ufospawn = ud.m_player_skill*4+1; - if (ufospawn > 32) - ufospawn = 32; + ufospawn = std::min(ud.m_player_skill*4+1, 32); ufocnt = 0; hulkspawn = ud.m_player_skill + 1; } diff --git a/source/games/duke/src/premap.h b/source/games/duke/src/premap.h index 2c5a2ec1f..d1c5ead83 100644 --- a/source/games/duke/src/premap.h +++ b/source/games/duke/src/premap.h @@ -40,6 +40,7 @@ void resetinventory(int playerNum); void P_ResetPlayer(int playerNum); void resetplayerstats(int playerNum); void resetweapons(int playerNum); +void resetprestat(int snum, int g); void G_ClearFIFO(void); void G_ResetInterpolations(void); extern int32_t fragbarheight(void); diff --git a/source/games/duke/src/zz_interpolate.cpp b/source/games/duke/src/zz_interpolate.cpp index 6886e1102..91a80242c 100644 --- a/source/games/duke/src/zz_interpolate.cpp +++ b/source/games/duke/src/zz_interpolate.cpp @@ -28,7 +28,7 @@ BEGIN_DUKE_NS #define MAXINTERPOLATIONS MAXSPRITES -int32_t g_interpolationCnt; +int32_t numinterpolations; int32_t g_interpolationLock; int32_t oldipos[MAXINTERPOLATIONS]; int32_t *curipos[MAXINTERPOLATIONS]; @@ -36,28 +36,28 @@ int32_t bakipos[MAXINTERPOLATIONS]; int G_SetInterpolation(int32_t *const posptr) { - if (g_interpolationCnt >= MAXINTERPOLATIONS) + if (numinterpolations >= MAXINTERPOLATIONS) return 1; - for (bssize_t i = 0; i < g_interpolationCnt; ++i) + for (bssize_t i = 0; i < numinterpolations; ++i) if (curipos[i] == posptr) return 0; - curipos[g_interpolationCnt] = posptr; - oldipos[g_interpolationCnt] = *posptr; - g_interpolationCnt++; + curipos[numinterpolations] = posptr; + oldipos[numinterpolations] = *posptr; + numinterpolations++; return 0; } void G_StopInterpolation(const int32_t * const posptr) { - for (bssize_t i = 0; i < g_interpolationCnt; ++i) + for (bssize_t i = 0; i < numinterpolations; ++i) if (curipos[i] == posptr) { - g_interpolationCnt--; - oldipos[i] = oldipos[g_interpolationCnt]; - bakipos[i] = bakipos[g_interpolationCnt]; - curipos[i] = curipos[g_interpolationCnt]; + numinterpolations--; + oldipos[i] = oldipos[numinterpolations]; + bakipos[i] = bakipos[numinterpolations]; + curipos[i] = curipos[numinterpolations]; } } @@ -68,7 +68,7 @@ void G_DoInterpolations(int smoothRatio) int32_t ndelta = 0; - for (bssize_t i = 0, j = 0; i < g_interpolationCnt; ++i) + for (bssize_t i = 0, j = 0; i < numinterpolations; ++i) { int32_t const odelta = ndelta; bakipos[i] = *curipos[i]; @@ -82,12 +82,12 @@ void G_DoInterpolations(int smoothRatio) void G_UpdateInterpolations(void) //Stick at beginning of G_DoMoveThings { - for (bssize_t i=g_interpolationCnt-1; i>=0; i--) oldipos[i] = *curipos[i]; + for (bssize_t i=numinterpolations-1; i>=0; i--) oldipos[i] = *curipos[i]; } void G_RestoreInterpolations(void) //Stick at end of drawscreen { - int32_t i=g_interpolationCnt-1; + int32_t i=numinterpolations-1; if (--g_interpolationLock) return; diff --git a/source/games/duke/src/zz_premap.cpp b/source/games/duke/src/zz_premap.cpp index cb8d86d7e..392618464 100644 --- a/source/games/duke/src/zz_premap.cpp +++ b/source/games/duke/src/zz_premap.cpp @@ -311,122 +311,6 @@ void P_ResetPlayer(int playerNum) } -static void resetprestat(int playerNum, int gameMode) -{ - DukePlayer_t *const pPlayer = g_player[playerNum].ps; - - g_spriteDeleteQueuePos = 0; - for (bssize_t i = 0; i < g_deleteQueueSize; i++) SpriteDeletionQueue[i] = -1; - - pPlayer->hbomb_on = 0; - pPlayer->cheat_phase = 0; - pPlayer->toggle_key_flag = 0; - pPlayer->secret_rooms = 0; - pPlayer->max_secret_rooms = 0; - pPlayer->actors_killed = 0; - pPlayer->max_actors_killed = 0; - pPlayer->lastrandomspot = 0; - pPlayer->weapon_pos = WEAPON_POS_START; - - P_ResetTintFade(pPlayer); - - pPlayer->kickback_pic = 5; - - pPlayer->last_weapon = -1; - pPlayer->weapreccnt = 0; - pPlayer->interface_toggle_flag = 0; - pPlayer->show_empty_weapon = 0; - pPlayer->holster_weapon = 0; - pPlayer->last_pissed_time = 0; - pPlayer->one_parallax_sectnum = -1; - pPlayer->visibility = ud.const_visibility; - - screenpeek = myconnectindex; - g_animWallCnt = 0; - g_cyclerCnt = 0; - g_animateCnt = 0; - parallaxtype = 0; - randomseed = 17; - ud.pause_on = 0; - ud.camerasprite = -1; - ud.eog = 0; - tempwallptr = 0; - g_curViewscreen = -1; - g_earthquakeTime = 0; - g_interpolationCnt = 0; - - if (RRRA) - { - WindTime = 0; - WindDir = 0; - fakebubba_spawn = 0; - RRRA_ExitedLevel = 0; - g_bellTime = 0; - g_bellSprite = 0; - } - - if (((gameMode & MODE_EOL) != MODE_EOL && numplayers < 2 && !g_netServer) - || (!(g_gametypeFlags[ud.coop] & GAMETYPE_PRESERVEINVENTORYDEATH) && numplayers > 1)) - { - resetweapons(playerNum); - resetinventory(playerNum); - } - else if (pPlayer->curr_weapon == HANDREMOTE_WEAPON && !isRR()) - { - pPlayer->ammo_amount[HANDBOMB_WEAPON]++; - pPlayer->curr_weapon = HANDBOMB_WEAPON; - } - - pPlayer->timebeforeexit = 0; - pPlayer->customexitsound = 0; - - if (RR) - { - pPlayer->stairs = 0; - pPlayer->noise_x = 131072; - pPlayer->noise_y = 131072; - pPlayer->make_noise = 0; - pPlayer->noise_radius = 0; - if ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop] & GAMETYPE_ACCESSATSTART)) - { - pPlayer->keys[0] = 1; - pPlayer->keys[1] = 1; - pPlayer->keys[2] = 1; - pPlayer->keys[3] = 1; - pPlayer->keys[4] = 1; - } - else - { - pPlayer->keys[0] = 0; - pPlayer->keys[1] = 0; - pPlayer->keys[2] = 0; - pPlayer->keys[3] = 0; - pPlayer->keys[4] = 0; - } - - pPlayer->drunkang = pPlayer->eatang = 1647; - pPlayer->drink_amt = pPlayer->eat = 0; - pPlayer->drink_timer = pPlayer->eat_timer = 4096; - pPlayer->shotgun_state[0] = pPlayer->shotgun_state[1] = 0; - pPlayer->detonate_time = 0; - pPlayer->detonate_count = 0; - pPlayer->recoil = 0; - pPlayer->yehaa_timer = 0; - resetlanepics(); - if (!g_netServer && numplayers < 2) - { - g_ufoSpawn = min(ud.m_player_skill*4+1, 32); - g_ufoCnt = 0; - g_hulkSpawn = ud.m_player_skill + 1; - } - else - { - g_ufoSpawn = 32; - g_ufoCnt = 0; - g_hulkSpawn = 2; - } - } -} static inline int G_CheckExitSprite(int spriteNum) { return ((uint16_t)sprite[spriteNum].lotag == UINT16_MAX && (sprite[spriteNum].cstat & 16)); } @@ -1594,7 +1478,7 @@ int G_EnterLevel(int gameMode) G_ClearFIFO(); - for (i=g_interpolationCnt-1; i>=0; i--) bakipos[i] = *curipos[i]; + for (i=numinterpolations-1; i>=0; i--) bakipos[i] = *curipos[i]; g_player[myconnectindex].ps->over_shoulder_on = 0; diff --git a/source/games/duke/src/zz_savegame.cpp b/source/games/duke/src/zz_savegame.cpp index a83fb3201..2c5181570 100644 --- a/source/games/duke/src/zz_savegame.cpp +++ b/source/games/duke/src/zz_savegame.cpp @@ -71,7 +71,7 @@ void G_ResetInterpolations(void) { int32_t k, i; - g_interpolationCnt = 0; + numinterpolations = 0; k = headspritestat[STAT_EFFECTOR]; while (k >= 0) @@ -105,7 +105,7 @@ void G_ResetInterpolations(void) k = nextspritestat[k]; } - for (i=g_interpolationCnt-1; i>=0; i--) bakipos[i] = *curipos[i]; + for (i=numinterpolations-1; i>=0; i--) bakipos[i] = *curipos[i]; for (i = g_animateCnt-1; i>=0; i--) G_SetInterpolation(g_animatePtr[i]); }