diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index 3f78bf39e..14f182f39 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -382,12 +382,12 @@ inline int PlayerInputBits(int pl, int bits) return (g_player[pl].input->bits & bits); } -inline bool PlayerInputSideVel(int pl) +inline int PlayerInputSideVel(int pl) { return g_player[pl].input->svel; } -inline bool PlayerInputForwardVel(int pl) +inline int PlayerInputForwardVel(int pl) { return g_player[pl].input->fvel; } diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 9e7974f7a..4d3d1789a 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -40,18 +40,21 @@ BEGIN_DUKE_NS //--------------------------------------------------------------------------- // -// setpal +// why is this such a mess? // //--------------------------------------------------------------------------- -void setpal_(struct player_struct* p) // cannot be activated yet. +void setpal(struct player_struct* p) { - int palette;; + int palette; + restorepalette = 1; if (p->DrugMode) palette = DRUGPAL; - else if (p->heat_on || (sector[p->cursectnum].ceilingpicnum >= TILE_FLOORSLIME && sector[p->cursectnum].ceilingpicnum <= TILE_FLOORSLIME+2)) palette = SLIMEPAL; - else if (sector[p->cursectnum].lotag == 2) palette = WATERPAL; + else if (p->heat_on) palette = SLIMEPAL; + else if (p->cursectnum < 0) palette = BASEPAL; // don't crash if out of range. + else if (sector[p->cursectnum].ceilingpicnum >= TILE_FLOORSLIME && sector[p->cursectnum].ceilingpicnum <= TILE_FLOORSLIME + 2) palette = SLIMEPAL, ++restorepalette; + else if (sector[p->cursectnum].lotag == ST_2_UNDERWATER) palette = WATERPAL, ++restorepalette; else palette = BASEPAL; - videoSetPalette(palette, 0); + p->palette = palette; } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/player.h b/source/games/duke/src/player.h index e60ec4dc9..4253d037c 100644 --- a/source/games/duke/src/player.h +++ b/source/games/duke/src/player.h @@ -413,12 +413,7 @@ void P_UpdatePosWhenViewingCam(DukePlayer_t *pPlayer); void P_ProcessInput(int playerNum); void P_DHProcessInput(int playerNum); void quickkill(DukePlayer_t* pPlayer); -void P_UpdateScreenPal(DukePlayer_t *pPlayer); -inline void setpal(DukePlayer_t* pPlayer) -{ - P_UpdateScreenPal(pPlayer); -} - +void setpal(DukePlayer_t* pPlayer); void P_EndLevel(void); void P_CheckWeaponI(int playerNum); int P_GetOverheadPal(const DukePlayer_t *pPlayer); diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 137f22b3b..013f2ed85 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1541,6 +1541,7 @@ void checksectors_d(int snum) if (p->newowner >= 0) { + Printf("%d, %d\n", PlayerInputSideVel(snum), PlayerInputForwardVel(snum)); if (abs(PlayerInputSideVel(snum)) > 768 || abs(PlayerInputForwardVel(snum)) > 768) { i = -1; diff --git a/source/games/duke/src/zz_demo.cpp b/source/games/duke/src/zz_demo.cpp index 900ce5a49..f2a44f98c 100644 --- a/source/games/duke/src/zz_demo.cpp +++ b/source/games/duke/src/zz_demo.cpp @@ -76,7 +76,6 @@ RECHECK: ud.recstat = 0; //fadepal(0,0,0, 0,252,28); - P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0); // JBF 20040308 drawbackground(); //M_DisplayMenus(); videoNextPage(); diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index 00a6de5b3..fe4cc57a8 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -748,7 +748,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) { pPlayer->drug_aspect = aspect; } - P_UpdateScreenPal(pPlayer); + setpal(pPlayer); } else if (pPlayer->drug_stat[0] == 3) { @@ -766,7 +766,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) { pPlayer->drug_aspect = aspect; } - P_UpdateScreenPal(pPlayer); + setpal(pPlayer); } else if (pPlayer->drug_stat[0] == 2) { @@ -779,7 +779,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) pPlayer->drug_stat[2]++; aspect = pPlayer->drug_stat[2] * 500 + viewingRange * 3; pPlayer->drug_aspect = aspect; - P_UpdateScreenPal(pPlayer); + setpal(pPlayer); } } else @@ -796,7 +796,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) pPlayer->drug_stat[2]--; aspect = pPlayer->drug_stat[2] * 500 + viewingRange * 3; pPlayer->drug_aspect = aspect; - P_UpdateScreenPal(pPlayer); + setpal(pPlayer); } } @@ -811,7 +811,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) renderSetAspect(mulscale16(viewingRange, viewingrange), yxaspect); } - P_UpdateScreenPal(pPlayer); + setpal(pPlayer); } if (pPlayer->newowner < 0) @@ -1621,7 +1621,7 @@ static int G_EndOfLevel(void) { STAT_Update(ud.eog || (currentLevel->flags & MI_FORCEEOG)); P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0); - P_UpdateScreenPal(g_player[myconnectindex].ps); + setpal(g_player[myconnectindex].ps); if (g_player[myconnectindex].ps->gm&MODE_EOL) { diff --git a/source/games/duke/src/zz_player.cpp b/source/games/duke/src/zz_player.cpp index 578325484..c46e1ef29 100644 --- a/source/games/duke/src/zz_player.cpp +++ b/source/games/duke/src/zz_player.cpp @@ -45,32 +45,6 @@ void P_AddKills(DukePlayer_t * const pPlayer, uint16_t kills) pPlayer->actors_killed += kills; } -void P_UpdateScreenPal(DukePlayer_t * const pPlayer) -{ - int inWater = 0; - int const playerSectnum = pPlayer->cursectnum; - - if (pPlayer->DrugMode) - pPlayer->palette = DRUGPAL; - else if (pPlayer->heat_on) - pPlayer->palette = SLIMEPAL; - else if (playerSectnum < 0) - pPlayer->palette = BASEPAL; - else if (sector[playerSectnum].ceilingpicnum >= TILE_FLOORSLIME && sector[playerSectnum].ceilingpicnum <= TILE_FLOORSLIME + 2) - { - pPlayer->palette = SLIMEPAL; - inWater = 1; - } - else - { - pPlayer->palette = (sector[pPlayer->cursectnum].lotag == ST_2_UNDERWATER) ? WATERPAL : BASEPAL; - inWater = 1; - } - - restorepalette = 1+inWater; -} - - int P_GetOverheadPal(DukePlayer_t const * pPlayer) { return sprite[pPlayer->i].pal; diff --git a/source/games/duke/src/zz_premap.cpp b/source/games/duke/src/zz_premap.cpp index d8241c8ce..b500f84d0 100644 --- a/source/games/duke/src/zz_premap.cpp +++ b/source/games/duke/src/zz_premap.cpp @@ -510,7 +510,7 @@ int G_EnterLevel(int gameMode) //g_player[myconnectindex].ps->palette = palette; P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0); // JBF 20040308 - P_UpdateScreenPal(g_player[myconnectindex].ps); + setpal(g_player[myconnectindex].ps); renderFlushPerms(); everyothertime = 0; diff --git a/source/games/duke/src/zz_savegame.cpp b/source/games/duke/src/zz_savegame.cpp index 93e87f689..fb5f0b6f7 100644 --- a/source/games/duke/src/zz_savegame.cpp +++ b/source/games/duke/src/zz_savegame.cpp @@ -1417,7 +1417,7 @@ static void postloadplayer(int32_t savegamep) } //3 - P_UpdateScreenPal(g_player[myconnectindex].ps); + setpal(g_player[myconnectindex].ps); restorepalette = -1; //4