diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 210071c1f..a23eb31fd 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -208,7 +208,6 @@ void clearcamera(player_struct* ps) ps->posz = ps->oposz; ps->angle.restore(); updatesector(ps->posx, ps->posy, &ps->cursectnum); - setpal(ps); DukeStatIterator it(STAT_ACTOR); while (auto k = it.Next()) diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 7d2087408..83580fb33 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -2150,8 +2150,6 @@ void movetransports_d(void) changespritesect(act2, Owner->s.sectnum); setsprite(ps[p].GetActor(), ps[p].posx, ps[p].posy, ps[p].posz + PHEIGHT); - setpal(&ps[p]); - if ((krand() & 255) < 32) spawn(act2, WATERSPLASH2); @@ -2474,7 +2472,6 @@ static void greenslime(DDukeActor *actor) ps[p].angle.restore(); updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum); - setpal(&ps[p]); DukeStatIterator it(STAT_ACTOR); while (auto ac = it.Next()) diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index af561f221..86ddadfcf 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1735,8 +1735,6 @@ void movetransports_r(void) changespritesect(act2, Owner->s.sectnum); - setpal(&ps[p]); - if ((krand() & 255) < 32) spawn(ps[p].GetActor(), WATERSPLASH2); } diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 2b26c17d2..6212c3aea 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -132,7 +132,7 @@ DDukeActor* aim(DDukeActor* s, int aang); void checkweapons(struct player_struct* const p); int findotherplayer(int p, int* d); void quickkill(struct player_struct* p); -void setpal(struct player_struct* p); +int setpal(struct player_struct* p); int madenoise(int playerNum); int haskey(int sect, int snum); void shootbloodsplat(DDukeActor* i, int p, int sx, int sy, int sz, int sa, int atwith, int BIGFORCE, int OOZFILTER, int NEWBEAST); diff --git a/source/games/duke/src/game.cpp b/source/games/duke/src/game.cpp index ea3b5efdd..efbd1425c 100644 --- a/source/games/duke/src/game.cpp +++ b/source/games/duke/src/game.cpp @@ -325,7 +325,6 @@ void GameInterface::app_init() registerosdcommands(); screenpeek = myconnectindex; - ps[myconnectindex].palette = BASEPAL; for (int j = numplayers; j < ud.multimode; j++) { diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 6c6800982..6e0b78491 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -586,7 +586,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang) if (j < 22000) j = 22000; else if (j > (65536 << 1)) j = (65536 << 1); - DrawTexture(twod, tileGetTexture(i), xdim / 2. + x1 / 4096., ydim / 2. + y1 / 4096., DTA_TranslationIndex, TRANSLATION(Translation_Remap + pp.palette, pspr->pal), DTA_CenterOffset, true, + DrawTexture(twod, tileGetTexture(i), xdim / 2. + x1 / 4096., ydim / 2. + y1 / 4096., DTA_TranslationIndex, TRANSLATION(Translation_Remap + setpal(&pp), pspr->pal), DTA_CenterOffset, true, DTA_Rotate, daang * (-360./2048), DTA_Color, shadeToLight(pspr->shade), DTA_ScaleX, j / 65536., DTA_ScaleY, j / 65536., TAG_DONE); } } diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 510f858d0..6de5f7600 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -2054,7 +2054,6 @@ int ParseState::parse(void) ps[g_p].posz = ps[g_p].oposz; ps[g_p].angle.restore(); updatesector(ps[g_p].posx,ps[g_p].posy,&ps[g_p].cursectnum); - setpal(&ps[g_p]); DukeStatIterator it(STAT_ACTOR); while (auto j = it.Next()) @@ -2273,7 +2272,6 @@ int ParseState::parse(void) resetinventory(g_p); resetweapons(g_p); } - setpal(&ps[g_p]); break; case concmd_ifcoop: parseifelse(ud.coop || numplayers > 2); diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 9fcd6a2f4..dfb074e84 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -136,7 +136,6 @@ void hud_input(int plnum) if (GetGameVarID(g_iReturnVarID, nullptr, plnum) == 0 && p->heat_amount > 0) { p->heat_on = !p->heat_on; - setpal(p); p->inven_icon = 5; S_PlayActorSound(NITEVISION_ONOFF, pact); FTA(106 + (!p->heat_on), p); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index a840e61e7..a391ea62b 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -125,7 +125,7 @@ void calcviewpitch(player_struct *p, double factor) // //--------------------------------------------------------------------------- -void setpal(struct player_struct* p) +int setpal(struct player_struct* p) { int palette; if (p->DrugMode) palette = DRUGPAL; @@ -134,7 +134,7 @@ void setpal(struct player_struct* p) else if (sector[p->cursectnum].ceilingpicnum >= TILE_FLOORSLIME && sector[p->cursectnum].ceilingpicnum <= TILE_FLOORSLIME + 2) palette = SLIMEPAL; else if (sector[p->cursectnum].lotag == ST_2_UNDERWATER) palette = WATERPAL; else palette = BASEPAL; - p->palette = palette; + return palette; } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 20ace7832..33ba5b10f 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1474,7 +1474,6 @@ int doincrements_d(struct player_struct* p) p->heat_on = 0; checkavailinven(p); S_PlayActorSound(NITEVISION_ONOFF, pact); - setpal(p); } } diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index f19955b37..934283b46 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -128,7 +128,6 @@ void resetplayerstats(int snum) p->random_club_frame= 0; p->on_warping_sector = 0; p->spritebridge = 0; - p->palette = 0; if(p->steroids_amount < 400 ) { @@ -166,7 +165,6 @@ void resetplayerstats(int snum) p->knuckle_incs = 1; p->fist_incs = 0; p->knee_incs = 0; - setpal(p); p->stairs = 0; p->noise_x = 0; p->noise_y = 0; @@ -962,7 +960,6 @@ void enterlevel(MapRecord *mi, int gamemode) } } resetmys(); - setpal(&ps[myconnectindex]); everyothertime = 0; global_random = 0; @@ -1063,7 +1060,6 @@ void exitlevel(MapRecord *nextlevel) { bool endofgame = nextlevel == nullptr; STAT_Update(endofgame); - setpal(&ps[myconnectindex]); StopCommentary(); dobonus(endofgame? -1 : 0, [=](bool) diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index ec42f7c5d..20c8d54a7 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -323,16 +323,13 @@ void setdrugmode(player_struct *p, int oyrepeat) var_8c = oyrepeat + p->drug_stat[1] * 5000; if (oyrepeat * 3 < var_8c) { - renderSetAspect(oyrepeat * 3, yxaspect); p->drug_aspect = oyrepeat * 3; p->drug_stat[0] = 2; } else { - renderSetAspect(var_8c, yxaspect); p->drug_aspect = var_8c; } - setpal(p); } else if (p->drug_stat[0] == 3) { @@ -340,7 +337,6 @@ void setdrugmode(player_struct *p, int oyrepeat) var_8c = oyrepeat + p->drug_stat[1] * 5000; if (var_8c < oyrepeat) { - renderSetAspect(oyrepeat, yxaspect); p->DrugMode = 0; p->drug_stat[0] = 0; p->drug_stat[2] = 0; @@ -348,10 +344,8 @@ void setdrugmode(player_struct *p, int oyrepeat) } else { - renderSetAspect(var_8c, yxaspect); p->drug_aspect = var_8c; } - setpal(p); } else if (p->drug_stat[0] == 2) { @@ -362,9 +356,7 @@ void setdrugmode(player_struct *p, int oyrepeat) else { p->drug_stat[2]++; - renderSetAspect(p->drug_stat[2] * 500 + oyrepeat * 3, yxaspect); p->drug_aspect = oyrepeat * 3 + p->drug_stat[2] * 500; - setpal(p); } } else @@ -379,17 +371,14 @@ void setdrugmode(player_struct *p, int oyrepeat) else { p->drug_stat[2]--; - renderSetAspect(p->drug_stat[2] * 500 + oyrepeat * 3, yxaspect); p->drug_aspect = oyrepeat * 3 + p->drug_stat[2] * 500; - setpal(p); } } } } - else if (p->DrugMode > 0) + if (p->DrugMode > 0) { renderSetAspect(p->drug_aspect, yxaspect); - setpal(p); } } @@ -514,7 +503,7 @@ void displayrooms(int snum, double smoothratio) // The camera texture must be rendered with the base palette, so this is the only place where the current global palette can be set. // The setting here will be carried over to the rendering of the weapon sprites, but other 2D content will always default to the main palette. - setgamepalette(p->palette); + setgamepalette(setpal(p)); if (ud.cameraactor) { spritetype* s; diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index 0cb9cfc67..74a9195dc 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -133,7 +133,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w, ("angle", w.angle) ("horizon", w.horizon) ("gotweapon", w.gotweapon) - ("palette", w.palette) ("pals", w.pals) ("fricx", w.fric.x) ("fricy", w.fric.y) @@ -476,7 +475,6 @@ void GameInterface::SerializeGameState(FSerializer& arc) cameraclock = 0; ps[myconnectindex].over_shoulder_on = 1; } - setpal(&ps[myconnectindex]); memset(gotpic, 0, sizeof(gotpic)); if (isRR()) cacheit_r(); else cacheit_d(); diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 57581882f..50b30ba21 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1458,7 +1458,6 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) ps[p].angle.restore(); updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum); - setpal(&ps[p]); DukeStatIterator it(STAT_ACTOR); while (auto j = it.Next()) @@ -1715,7 +1714,6 @@ void checksectors_d(int snum) j = p->cursectnum; p->cursectnum = spr->sectnum; - setpal(p); p->cursectnum = j; // parallaxtype = 2; @@ -1736,7 +1734,6 @@ void checksectors_d(int snum) p->newOwner = nullptr; updatesector(p->posx, p->posy, &p->cursectnum); - setpal(p); DukeStatIterator it(STAT_ACTOR); while (auto act = it.Next()) diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 59efe0cf9..5d1e0c0b0 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -2406,7 +2406,6 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) ps[p].posz = ps[p].oposz; updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum); - setpal(&ps[p]); DukeStatIterator it(STAT_EFFECTOR); while (auto act = it.Next()) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 524cc35e2..1a7dad66d 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -177,7 +177,6 @@ struct player_struct FixedBitArray gotweapon; // Palette management uses indices into the engine's palette table now. - unsigned int palette; PalEntry pals; // this was a global variable originally.