From f794849eadd7ec64d6fb5639002e2f0ab5096aa4 Mon Sep 17 00:00:00 2001 From: danij Date: Sat, 30 Sep 2006 23:19:56 +0000 Subject: [PATCH] Updated jHeretic and jHexen to use per-player inventory cursor vars (added to player_t). Done in preparation for multiple local player support. --- doomsday/plugins/common/include/p_inventory.h | 3 +- doomsday/plugins/common/src/g_controls.c | 12 +- doomsday/plugins/common/src/g_game.c | 5 +- doomsday/plugins/common/src/p_inventory.c | 143 ++++++++------- doomsday/plugins/common/src/p_user.c | 4 +- doomsday/plugins/jheretic/include/h_player.h | 4 +- doomsday/plugins/jheretic/include/p_local.h | 2 - doomsday/plugins/jheretic/src/st_stuff.c | 35 ++-- doomsday/plugins/jhexen/include/h2def.h | 4 +- doomsday/plugins/jhexen/include/p_local.h | 2 - doomsday/plugins/jhexen/include/x_player.h | 4 +- doomsday/plugins/jhexen/src/st_stuff.c | 164 +++++++++--------- doomsday/plugins/jhexen/src/sv_save.c | 30 +--- 13 files changed, 210 insertions(+), 202 deletions(-) diff --git a/doomsday/plugins/common/include/p_inventory.h b/doomsday/plugins/common/include/p_inventory.h index b3e0f3d629..8e4f7dafe4 100644 --- a/doomsday/plugins/common/include/p_inventory.h +++ b/doomsday/plugins/common/include/p_inventory.h @@ -54,10 +54,11 @@ extern boolean artiskip; extern boolean usearti; -extern int inv_ptr; boolean P_GiveArtifact(player_t *player, artitype_e arti, mobj_t *mo); +void P_InventoryResetCursor(player_t *player); + void P_InventoryRemoveArtifact(player_t *player, int slot); boolean P_InventoryUseArtifact(player_t *player, artitype_e arti); void P_InventoryNextArtifact(player_t *player); diff --git a/doomsday/plugins/common/src/g_controls.c b/doomsday/plugins/common/src/g_controls.c index 105c7da58a..fc84e44388 100644 --- a/doomsday/plugins/common/src/g_controls.c +++ b/doomsday/plugins/common/src/g_controls.c @@ -610,7 +610,7 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, float elapsedTime) { if(actions[A_SPEED].on && artiskip) { - if(players[consoleplayer].inventory[inv_ptr].type != arti_none) + if(cplr->inventory[cplr->inv_ptr].type != arti_none) { actions[A_USEARTIFACT].on = false; @@ -621,14 +621,12 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, float elapsedTime) { if(ST_IsInventoryVisible()) { - players[consoleplayer].readyArtifact = - players[consoleplayer].inventory[inv_ptr].type; + cplr->readyArtifact = cplr->inventory[cplr->inv_ptr].type; ST_Inventory(false); // close the inventory if(cfg.chooseAndUse) - cmd->arti = - players[consoleplayer].inventory[inv_ptr].type; + cmd->arti = cplr->inventory[cplr->inv_ptr].type; else cmd->arti = 0; @@ -636,7 +634,7 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, float elapsedTime) } else if(usearti) { - cmd->arti = players[consoleplayer].inventory[inv_ptr].type; + cmd->arti = cplr->inventory[cplr->inv_ptr].type; usearti = false; } } @@ -870,7 +868,7 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, float elapsedTime) else if(mousex) { // Mouse angle changes are immediate. - if(!pausestate && players[consoleplayer].plr->mo && + if(!pausestate && players[consoleplayer].plr->mo && players[consoleplayer].playerstate != PST_DEAD) { players[consoleplayer].plr->mo->angle += FLT2FIX(mousex * -8); //G_AdjustAngle(cplr, mousex * -8, 1); diff --git a/doomsday/plugins/common/src/g_game.c b/doomsday/plugins/common/src/g_game.c index 4507e0d639..9720090b3f 100644 --- a/doomsday/plugins/common/src/g_game.c +++ b/doomsday/plugins/common/src/g_game.c @@ -633,7 +633,7 @@ boolean G_Responder(event_t *ev) { // flag to denote that it's okay to use an artifact if(!ST_IsInventoryVisible()) { - plr->readyArtifact = plr->inventory[inv_ptr].type; + plr->readyArtifact = plr->inventory[plr->inv_ptr].type; } usearti = true; } @@ -1157,13 +1157,12 @@ void G_PlayerReborn(int player) #endif #if !__JDOOM__ + P_InventoryResetCursor(p); if(p == &players[consoleplayer]) { # if __JHEXEN__ || __JSTRIFE__ SB_state = -1; // refresh the status bar # endif - inv_ptr = 0; // reset the inventory pointer - curpos = 0; } #endif diff --git a/doomsday/plugins/common/src/p_inventory.c b/doomsday/plugins/common/src/p_inventory.c index a9acbdab7e..e0358fe680 100644 --- a/doomsday/plugins/common/src/p_inventory.c +++ b/doomsday/plugins/common/src/p_inventory.c @@ -76,7 +76,6 @@ boolean P_UsePuzzleItem(player_t *player, int itemType); // PUBLIC DATA DEFINITIONS ------------------------------------------------- -int inv_ptr; boolean usearti = true; // PRIVATE DATA DEFINITIONS ------------------------------------------------ @@ -150,13 +149,13 @@ boolean P_GiveArtifact(player_t *player, artitype_e arti, mobj_t *mo) player->readyArtifact = arti; } #if __JHEXEN__ - else if(player == &players[consoleplayer] && slidePointer && i <= inv_ptr) + else if(slidePointer && i <= player->inv_ptr) { - inv_ptr++; - curpos++; - if(curpos > 6) + player->inv_ptr++; + player->curpos++; + if(player->curpos > 6) { - curpos = 6; + player->curpos = 6; } } #else @@ -174,30 +173,30 @@ boolean P_GiveArtifact(player_t *player, artitype_e arti, mobj_t *mo) # if __JHERETIC__ void P_InventoryCheckReadyArtifact(player_t *player) { - if(!player || player != &players[consoleplayer]) + if(!player) return; - if(!player->inventory[inv_ptr].count) + if(!player->inventory[player->inv_ptr].count) { // Set position markers and get next readyArtifact - inv_ptr--; - if(inv_ptr < 6) + player->inv_ptr--; + if(player->inv_ptr < 6) { - curpos--; - if(curpos < 0) + player->curpos--; + if(player->curpos < 0) { - curpos = 0; + player->curpos = 0; } } - if(inv_ptr >= player->inventorySlotNum) + if(player->inv_ptr >= player->inventorySlotNum) { - inv_ptr = player->inventorySlotNum - 1; + player->inv_ptr = player->inventorySlotNum - 1; } - if(inv_ptr < 0) + if(player->inv_ptr < 0) { - inv_ptr = 0; + player->inv_ptr = 0; } - player->readyArtifact = player->inventory[inv_ptr].type; + player->readyArtifact = player->inventory[player->inv_ptr].type; if(!player->inventorySlotNum) player->readyArtifact = arti_none; @@ -207,31 +206,31 @@ void P_InventoryCheckReadyArtifact(player_t *player) void P_InventoryNextArtifact(player_t *player) { - if(!player || player != &players[consoleplayer]) + if(!player) return; - inv_ptr--; - if(inv_ptr < 6) + player->inv_ptr--; + if(player->inv_ptr < 6) { - curpos--; - if(curpos < 0) + player->curpos--; + if(player->curpos < 0) { - curpos = 0; + player->curpos = 0; } } - if(inv_ptr < 0) + if(player->inv_ptr < 0) { - inv_ptr = player->inventorySlotNum - 1; - if(inv_ptr < 6) + player->inv_ptr = player->inventorySlotNum - 1; + if(player->inv_ptr < 6) { - curpos = inv_ptr; + player->curpos = player->inv_ptr; } else { - curpos = 6; + player->curpos = 6; } } - player->readyArtifact = player->inventory[inv_ptr].type; + player->readyArtifact = player->inventory[player->inv_ptr].type; } void P_InventoryRemoveArtifact(player_t *player, int slot) @@ -257,24 +256,22 @@ void P_InventoryRemoveArtifact(player_t *player, int slot) player->inventorySlotNum--; - if(player == &players[consoleplayer]) - { // Set position markers and get next readyArtifact - inv_ptr--; - if(inv_ptr < 6) - { - curpos--; - if(curpos < 0) - curpos = 0; - } + // Set position markers and get next readyArtifact + player->inv_ptr--; + if(player->inv_ptr < 6) + { + player->curpos--; + if(player->curpos < 0) + player->curpos = 0; + } - if(inv_ptr >= player->inventorySlotNum) - inv_ptr = player->inventorySlotNum - 1; + if(player->inv_ptr >= player->inventorySlotNum) + player->inv_ptr = player->inventorySlotNum - 1; - if(inv_ptr < 0) - inv_ptr = 0; + if(player->inv_ptr < 0) + player->inv_ptr = 0; - player->readyArtifact = player->inventory[inv_ptr].type; - } + player->readyArtifact = player->inventory[player->inv_ptr].type; } } @@ -332,6 +329,15 @@ boolean P_InventoryUseArtifact(player_t *player, artitype_e arti) return success; } +void P_InventoryResetCursor(player_t *player) +{ + if(!player) + return; + + player->inv_ptr = 0; + player->curpos = 0; +} + /* * Returns true if the artifact was used. */ @@ -607,35 +613,35 @@ static boolean P_InventoryMove(player_t *plr, int dir) if(dir == 0) { - inv_ptr--; - if(inv_ptr < 0) + plr->inv_ptr--; + if(plr->inv_ptr < 0) { - inv_ptr = 0; + plr->inv_ptr = 0; } else { - curpos--; - if(curpos < 0) + plr->curpos--; + if(plr->curpos < 0) { - curpos = 0; + plr->curpos = 0; } } } else { - inv_ptr++; - if(inv_ptr >= plr->inventorySlotNum) + plr->inv_ptr++; + if(plr->inv_ptr >= plr->inventorySlotNum) { - inv_ptr--; - if(inv_ptr < 0) - inv_ptr = 0; + plr->inv_ptr--; + if(plr->inv_ptr < 0) + plr->inv_ptr = 0; } else { - curpos++; - if(curpos > 6) + plr->curpos++; + if(plr->curpos > 6) { - curpos = 6; + plr->curpos = 6; } } } @@ -647,7 +653,24 @@ static boolean P_InventoryMove(player_t *plr, int dir) */ DEFCC(CCmdInventory) { - P_InventoryMove(players + consoleplayer, !stricmp(argv[0], "invright")); + int player = consoleplayer; + + if(argc > 2) + { + Con_Printf("Usage: %s (player)\n", argv[0]); + Con_Printf("If player is not specified, will default to consoleplayer.\n"); + return true; + } + + if(argc == 2) + player = strtol(argv[1], NULL, 0); + + if(player < 0) + player = 0; + if(player > MAXPLAYERS -1) + player = MAXPLAYERS -1; + + P_InventoryMove(&players[player], !stricmp(argv[0], "invright")); return true; } #endif diff --git a/doomsday/plugins/common/src/p_user.c b/doomsday/plugins/common/src/p_user.c index b75cb8bcbe..1713d84191 100644 --- a/doomsday/plugins/common/src/p_user.c +++ b/doomsday/plugins/common/src/p_user.c @@ -571,10 +571,10 @@ void P_RaiseDeadPlayer(player_t *player) { player->playerstate = PST_REBORN; #if __JHERETIC__ || __JHEXEN__ + P_InventoryResetCursor(player); + if(player == &players[consoleplayer]) { - inv_ptr = 0; - curpos = 0; R_SetFilter(0); } diff --git a/doomsday/plugins/jheretic/include/h_player.h b/doomsday/plugins/jheretic/include/h_player.h index 8c9b8f0aea..15edbf66ca 100644 --- a/doomsday/plugins/jheretic/include/h_player.h +++ b/doomsday/plugins/jheretic/include/h_player.h @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, + * Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * * In addition, as a special exception, we, the authors of deng @@ -162,6 +162,8 @@ typedef struct player_s { // DJS - Here follows Heretic specific player_t properties // inventory_t inventory[NUMINVENTORYSLOTS]; + int inv_ptr; + int curpos; artitype_e readyArtifact; int artifactCount; int inventorySlotNum; diff --git a/doomsday/plugins/jheretic/include/p_local.h b/doomsday/plugins/jheretic/include/p_local.h index c43ef764e8..8066396fa8 100644 --- a/doomsday/plugins/jheretic/include/p_local.h +++ b/doomsday/plugins/jheretic/include/p_local.h @@ -288,8 +288,6 @@ void Draw_EndZoom(void); // ***** ST_STUFF ***** -extern int curpos; - void ST_Inventory(boolean show); boolean ST_IsInventoryVisible(void); diff --git a/doomsday/plugins/jheretic/src/st_stuff.c b/doomsday/plugins/jheretic/src/st_stuff.c index ed38d76113..b6a4846e50 100644 --- a/doomsday/plugins/jheretic/src/st_stuff.c +++ b/doomsday/plugins/jheretic/src/st_stuff.c @@ -146,7 +146,6 @@ extern boolean hu_showallfrags; // in hu_stuff.c currently // PUBLIC DATA DEFINITIONS ------------------------------------------------- -int curpos; int inventoryTics; boolean inventory = false; @@ -559,7 +558,7 @@ void ST_updateWidgets(void) oldarti = -1; // so that the correct artifact fills in after the flash } else if(oldarti != plr->readyArtifact || - oldartiCount != plr->inventory[inv_ptr].count) + oldartiCount != plr->inventory[plr->inv_ptr].count) { if(plr->readyArtifact > 0) @@ -568,11 +567,11 @@ void ST_updateWidgets(void) } oldarti = plr->readyArtifact; - oldartiCount = plr->inventory[inv_ptr].count; + oldartiCount = plr->inventory[plr->inv_ptr].count; } // update the inventory - x = inv_ptr - curpos; + x = plr->inv_ptr - plr->curpos; for(i = 0; i < NUMVISINVSLOTS; i++) { st_invslot[i] = plr->inventory[x + i].type +5; // plus 5 for useartifact patches @@ -725,6 +724,7 @@ void ST_Ticker(void) int delta; int curHealth; static int tomePlay = 0; + player_t *plyr = &players[consoleplayer]; ST_updateWidgets(); @@ -732,7 +732,7 @@ void ST_Ticker(void) { ChainWiggle = P_Random() & 1; } - curHealth = players[consoleplayer].plr->mo->health; + curHealth = plyr->plr->mo->health; if(curHealth < 0) { curHealth = 0; @@ -764,10 +764,10 @@ void ST_Ticker(void) HealthMarker += delta; } // Tome of Power countdown sound. - if(players[consoleplayer].powers[pw_weaponlevel2] && - players[consoleplayer].powers[pw_weaponlevel2] < cfg.tomeSound * 35) + if(plyr->powers[pw_weaponlevel2] && + plyr->powers[pw_weaponlevel2] < cfg.tomeSound * 35) { - int timeleft = players[consoleplayer].powers[pw_weaponlevel2] / 35; + int timeleft = plyr->powers[pw_weaponlevel2] / 35; if(tomePlay != timeleft) { @@ -779,8 +779,7 @@ void ST_Ticker(void) // turn inventory off after a certain amount of time if(inventory && !(--inventoryTics)) { - players[consoleplayer].readyArtifact = - players[consoleplayer].inventory[inv_ptr].type; + plyr->readyArtifact = plyr->inventory[plyr->inv_ptr].type; inventory = false; } } @@ -1323,14 +1322,14 @@ void ST_drawWidgets(boolean refresh) if(plyr->readyArtifact > 0) { STlib_updateMultIcon(&w_artici, refresh); - if(!ArtifactFlash && plyr->inventory[inv_ptr].count > 1) + if(!ArtifactFlash && plyr->inventory[plyr->inv_ptr].count > 1) STlib_updateNum(&w_articount, refresh); } } else { // Draw Inventory - x = inv_ptr - curpos; + x = plyr->inv_ptr - plyr->curpos; for(i = 0; i < NUMVISINVSLOTS; i++){ if( plyr->inventory[x + i].type != arti_none) @@ -1343,7 +1342,7 @@ void ST_drawWidgets(boolean refresh) } // Draw selector box - GL_DrawPatch(ST_INVENTORYX + curpos * 31, 189, PatchSELECTBOX.lump); + GL_DrawPatch(ST_INVENTORYX + plyr->curpos * 31, 189, PatchSELECTBOX.lump); // Draw more left indicator if(x != 0) @@ -1461,7 +1460,7 @@ void ST_doFullscreenStuff(void) GL_DrawPatchLitAlpha(286, 166, 1, iconalpha/2, W_GetNumForName("ARTIBOX")); GL_DrawPatchLitAlpha(286, 166, 1, iconalpha, W_GetNumForName(artifactlist[plyr->readyArtifact + 5])); //plus 5 for useartifact flashes - DrSmallNumber(plyr->inventory[inv_ptr].count, 307, 188, 1, 1, 1, textalpha); + DrSmallNumber(plyr->inventory[plyr->inv_ptr].count, 307, 188, 1, 1, 1, textalpha); Draw_EndZoom(); } } @@ -1472,20 +1471,20 @@ void ST_doFullscreenStuff(void) invScale = MINMAX_OF(0.25f, cfg.hudScale - 0.25f, 0.8f); Draw_BeginZoom(invScale, 160, 198); - x = inv_ptr - curpos; + x = plyr->inv_ptr - plyr->curpos; for(i = 0; i < 7; i++) { GL_DrawPatchLitAlpha(50 + i * 31, 168, 1, iconalpha/2, W_GetNumForName("ARTIBOX")); if(plyr->inventorySlotNum > x + i && plyr->inventory[x + i].type != arti_none) { - GL_DrawPatchLitAlpha(50 + i * 31, 168, 1, i==curpos? hudalpha : iconalpha, + GL_DrawPatchLitAlpha(50 + i * 31, 168, 1, i==plyr->curpos? hudalpha : iconalpha, W_GetNumForName(artifactlist[plyr->inventory[x + i]. type +5])); //plus 5 for useartifact flashes - DrSmallNumber(plyr->inventory[x + i].count, 69 + i * 31, 190, 1, 1, 1, i==curpos? hudalpha : textalpha/2); + DrSmallNumber(plyr->inventory[x + i].count, 69 + i * 31, 190, 1, 1, 1, i==plyr->curpos? hudalpha : textalpha/2); } } - GL_DrawPatchLitAlpha(50 + curpos * 31, 197, 1, hudalpha, PatchSELECTBOX.lump); + GL_DrawPatchLitAlpha(50 + plyr->curpos * 31, 197, 1, hudalpha, PatchSELECTBOX.lump); if(x != 0) { GL_DrawPatchLitAlpha(38, 167, 1, iconalpha, diff --git a/doomsday/plugins/jhexen/include/h2def.h b/doomsday/plugins/jhexen/include/h2def.h index 56a1541c8b..f848e05c10 100644 --- a/doomsday/plugins/jhexen/include/h2def.h +++ b/doomsday/plugins/jhexen/include/h2def.h @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, + * Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * * In addition, as a special exception, we, the authors of deng @@ -966,8 +966,6 @@ void F_StartFinale(void); // STATUS BAR (SB_bar.c) //---------------------- -extern int inv_ptr; -extern int curpos; extern int SB_state; void SB_Init(void); void SB_SetClassData(void); diff --git a/doomsday/plugins/jhexen/include/p_local.h b/doomsday/plugins/jhexen/include/p_local.h index 83ccd50307..bc6cd5b58d 100644 --- a/doomsday/plugins/jhexen/include/p_local.h +++ b/doomsday/plugins/jhexen/include/p_local.h @@ -252,8 +252,6 @@ void C_DECL A_BridgeRemove(mobj_t *actor); // ***** ST_STUFF ***** -extern int curpos; - void ST_Inventory(boolean show); boolean ST_IsInventoryVisible(void); diff --git a/doomsday/plugins/jhexen/include/x_player.h b/doomsday/plugins/jhexen/include/x_player.h index ccf7d3be63..7742579840 100644 --- a/doomsday/plugins/jhexen/include/x_player.h +++ b/doomsday/plugins/jhexen/include/x_player.h @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, + * Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * * In addition, as a special exception, we, the authors of deng @@ -109,6 +109,8 @@ typedef struct player_s { int armorpoints[NUMARMOR]; inventory_t inventory[NUMINVENTORYSLOTS]; + int inv_ptr; + int curpos; artitype_e readyArtifact; int artifactCount; int inventorySlotNum; diff --git a/doomsday/plugins/jhexen/src/st_stuff.c b/doomsday/plugins/jhexen/src/st_stuff.c index fab5833d43..cac8fa4f2a 100644 --- a/doomsday/plugins/jhexen/src/st_stuff.c +++ b/doomsday/plugins/jhexen/src/st_stuff.c @@ -141,7 +141,6 @@ extern boolean hu_showallfrags; // in hu_stuff.c currently // PUBLIC DATA DECLARATIONS ------------------------------------------------ -int curpos; int inventoryTics; boolean inventory = false; @@ -265,8 +264,6 @@ static boolean st_fragson; static boolean st_blended = false; static int HealthMarker; -static player_t *CPlayer; - static int FontBNumBase; int lu_palette; @@ -723,14 +720,14 @@ void ST_updateWidgets(void) oldarti = -1; // so that the correct artifact fills in after the flash } else if(oldarti != plr->readyArtifact || - oldartiCount != plr->inventory[inv_ptr].count) + oldartiCount != plr->inventory[plr->inv_ptr].count) { if(plr->readyArtifact > 0) { st_artici = plr->readyArtifact + 5; } oldarti = plr->readyArtifact; - oldartiCount = plr->inventory[inv_ptr].count; + oldartiCount = plr->inventory[plr->inv_ptr].count; } // Armor @@ -809,7 +806,7 @@ void ST_updateWidgets(void) // update the inventory - x = inv_ptr - curpos; + x = plr->inv_ptr - plr->curpos; for(i = 0; i < NUMVISINVSLOTS; i++) { @@ -835,13 +832,14 @@ void ST_Ticker(void) { int delta; int curHealth; + player_t *plr = &players[consoleplayer]; - if(!players[consoleplayer].plr->mo) + if(!plr->plr->mo) return; ST_updateWidgets(); - curHealth = players[consoleplayer].plr->mo->health; + curHealth = plr->plr->mo->health; if(curHealth < 0) { curHealth = 0; @@ -876,8 +874,7 @@ void ST_Ticker(void) // turn inventory off after a certain amount of time if(inventory && !(--inventoryTics)) { - players[consoleplayer].readyArtifact = - players[consoleplayer].inventory[inv_ptr].type; + plr->readyArtifact = plr->inventory[plr->inv_ptr].type; inventory = false; } } @@ -1144,6 +1141,7 @@ void ST_refreshBackground(void) { int x, y, w, h; float cw, cw2, ch; + player_t *plyr = &players[consoleplayer]; if(st_blended && ((cfg.statusbarAlpha < 1.0f) && (cfg.statusbarAlpha > 0.0f))) { @@ -1318,7 +1316,7 @@ void ST_refreshBackground(void) { GL_DrawPatch(38, 162, PatchNumSTATBAR.lump); - if(CPlayer->pieces == 7) + if(plyr->pieces == 7) { GL_DrawPatch(190, 162, PatchNumWEAPONFULL.lump); @@ -1379,9 +1377,9 @@ void ST_doRefresh(void) void ST_Drawer(int fullscreenmode, boolean refresh ) { st_firsttime = st_firsttime || refresh; - st_statusbaron = (fullscreenmode < 2) || ( automapactive && (cfg.automapHudDisplay == 0 || cfg.automapHudDisplay == 2) ); - - CPlayer = &players[consoleplayer]; + st_statusbaron = (fullscreenmode < 2) || + (automapactive && + (cfg.automapHudDisplay == 0 || cfg.automapHudDisplay == 2) ); // Do palette shifts ST_doPaletteStuff(false); @@ -1444,6 +1442,7 @@ static void DrawAnimatedIcons(void) int frame; static boolean hitCenterFrame; float iconalpha = (st_statusbaron? 1: hudalpha) - ( 1 - cfg.hudIconAlpha); + player_t *plyr = &players[consoleplayer]; // extern int screenblocks; @@ -1455,13 +1454,13 @@ static void DrawAnimatedIcons(void) Draw_BeginZoom(cfg.hudScale, 2, 2); // Wings of wrath - if(CPlayer->powers[pw_flight]) + if(plyr->powers[pw_flight]) { - if(CPlayer->powers[pw_flight] > BLINKTHRESHOLD || - !(CPlayer->powers[pw_flight] & 16)) + if(plyr->powers[pw_flight] > BLINKTHRESHOLD || + !(plyr->powers[pw_flight] & 16)) { frame = (leveltime / 3) & 15; - if(CPlayer->plr->mo->flags2 & MF2_FLY) + if(plyr->plr->mo->flags2 & MF2_FLY) { if(hitCenterFrame && (frame != 15 && frame != 0)) { @@ -1491,10 +1490,10 @@ static void DrawAnimatedIcons(void) } // Speed Boots - if(CPlayer->powers[pw_speed]) + if(plyr->powers[pw_speed]) { - if(CPlayer->powers[pw_speed] > BLINKTHRESHOLD || - !(CPlayer->powers[pw_speed] & 16)) + if(plyr->powers[pw_speed] > BLINKTHRESHOLD || + !(plyr->powers[pw_speed] & 16)) { frame = (leveltime / 3) & 15; GL_DrawPatchLitAlpha(60 + leftoff, 19, 1, iconalpha, SpinSpeedLump.lump + frame); @@ -1507,10 +1506,10 @@ static void DrawAnimatedIcons(void) Draw_BeginZoom(cfg.hudScale, 318, 2); // Defensive power - if(CPlayer->powers[pw_invulnerability]) + if(plyr->powers[pw_invulnerability]) { - if(CPlayer->powers[pw_invulnerability] > BLINKTHRESHOLD || - !(CPlayer->powers[pw_invulnerability] & 16)) + if(plyr->powers[pw_invulnerability] > BLINKTHRESHOLD || + !(plyr->powers[pw_invulnerability] & 16)) { frame = (leveltime / 3) & 15; GL_DrawPatchLitAlpha(260, 19, 1, iconalpha, SpinDefenseLump.lump + frame); @@ -1519,10 +1518,10 @@ static void DrawAnimatedIcons(void) } // Minotaur Active - if(CPlayer->powers[pw_minotaur]) + if(plyr->powers[pw_minotaur]) { - if(CPlayer->powers[pw_minotaur] > BLINKTHRESHOLD || - !(CPlayer->powers[pw_minotaur] & 16)) + if(plyr->powers[pw_minotaur] > BLINKTHRESHOLD || + !(plyr->powers[pw_minotaur] & 16)) { frame = (leveltime / 3) & 15; GL_DrawPatchLitAlpha(300, 19, 1, iconalpha, SpinMinotaurLump.lump + frame); @@ -1546,6 +1545,7 @@ void ST_doPaletteStuff(boolean forceChange) { static int sb_palette = 0; int palette; + player_t *plyr = &players[consoleplayer]; if(forceChange) { @@ -1553,36 +1553,36 @@ void ST_doPaletteStuff(boolean forceChange) } if(gamestate == GS_LEVEL) { - CPlayer = &players[consoleplayer]; - if(CPlayer->poisoncount) + plyr = &players[consoleplayer]; + if(plyr->poisoncount) { palette = 0; - palette = (CPlayer->poisoncount + 7) >> 3; + palette = (plyr->poisoncount + 7) >> 3; if(palette >= NUMPOISONPALS) { palette = NUMPOISONPALS - 1; } palette += STARTPOISONPALS; } - else if(CPlayer->damagecount) + else if(plyr->damagecount) { - palette = (CPlayer->damagecount + 7) >> 3; + palette = (plyr->damagecount + 7) >> 3; if(palette >= NUMREDPALS) { palette = NUMREDPALS - 1; } palette += STARTREDPALS; } - else if(CPlayer->bonuscount) + else if(plyr->bonuscount) { - palette = (CPlayer->bonuscount + 7) >> 3; + palette = (plyr->bonuscount + 7) >> 3; if(palette >= NUMBONUSPALS) { palette = NUMBONUSPALS - 1; } palette += STARTBONUSPALS; } - else if(CPlayer->plr->mo->flags2 & MF2_ICEDAMAGE) + else if(plyr->plr->mo->flags2 & MF2_ICEDAMAGE) { // Frozen player palette = STARTICEPAL; } @@ -1599,7 +1599,7 @@ void ST_doPaletteStuff(boolean forceChange) { sb_palette = palette; // $democam - CPlayer->plr->filter = R_GetFilterColor(palette); + plyr->plr->filter = R_GetFilterColor(palette); } } @@ -1746,9 +1746,9 @@ void ST_drawWidgets(boolean refresh) STlib_updateNum(&w_armor, refresh); // current artifact - if(CPlayer->readyArtifact > 0){ + if(plyr->readyArtifact > 0){ STlib_updateMultIcon(&w_artici, refresh); - if(!ArtifactFlash && CPlayer->inventory[inv_ptr].count > 1) + if(!ArtifactFlash && plyr->inventory[plyr->inv_ptr].count > 1) STlib_updateNum(&w_articount, refresh); } @@ -1774,8 +1774,8 @@ void ST_drawWidgets(boolean refresh) // Draw the mana bars GL_SetNoTexture(); - GL_DrawRect(95, 165, 3, 22 - (22 * CPlayer->ammo[0]) / MAX_MANA, 0, 0, 0, cfg.statusbarAlpha); - GL_DrawRect(103, 165, 3, 22 - (22 * CPlayer->ammo[1]) / MAX_MANA, 0, 0, 0, cfg.statusbarAlpha); + GL_DrawRect(95, 165, 3, 22 - (22 * plyr->ammo[0]) / MAX_MANA, 0, 0, 0, cfg.statusbarAlpha); + GL_DrawRect(103, 165, 3, 22 - (22 * plyr->ammo[1]) / MAX_MANA, 0, 0, 0, cfg.statusbarAlpha); } else { DrawKeyBar(); @@ -1785,7 +1785,7 @@ void ST_drawWidgets(boolean refresh) else { // Draw Inventory - x = inv_ptr - curpos; + x = plyr->inv_ptr - plyr->curpos; for(i = 0; i < NUMVISINVSLOTS; i++){ if( plyr->inventory[x + i].type != arti_none) @@ -1798,14 +1798,14 @@ void ST_drawWidgets(boolean refresh) } // Draw selector box - GL_DrawPatch(ST_INVENTORYX + curpos * 31, 163, PatchNumSELECTBOX.lump); + GL_DrawPatch(ST_INVENTORYX + plyr->curpos * 31, 163, PatchNumSELECTBOX.lump); // Draw more left indicator if(x != 0) GL_DrawPatchLitAlpha(42, 163, 1, cfg.statusbarCounterAlpha, !(leveltime & 4) ? PatchNumINVLFGEM1.lump : PatchNumINVLFGEM2.lump); // Draw more right indicator - if(CPlayer->inventorySlotNum - x > 7) + if(plyr->inventorySlotNum - x > 7) GL_DrawPatchLitAlpha(269, 163, 1, cfg.statusbarCounterAlpha, !(leveltime & 4) ? PatchNumINVRTGEM1.lump : PatchNumINVRTGEM2.lump); } } @@ -1821,34 +1821,35 @@ void DrawKeyBar(void) int i; int xPosition; int temp; + player_t *plyr = &players[consoleplayer]; xPosition = 46; for(i = 0; i < NUMKEYS && xPosition <= 126; i++) { - if(CPlayer->keys & (1 << i)) + if(plyr->keys & (1 << i)) { GL_DrawPatchLitAlpha(xPosition, 163, 1, cfg.statusbarCounterAlpha, W_GetNumForName("keyslot1") + i); xPosition += 20; } } temp = - PCLASS_INFO(CPlayer->class)->autoarmorsave + CPlayer->armorpoints[ARMOR_ARMOR] + - CPlayer->armorpoints[ARMOR_SHIELD] + - CPlayer->armorpoints[ARMOR_HELMET] + - CPlayer->armorpoints[ARMOR_AMULET]; + PCLASS_INFO(plyr->class)->autoarmorsave + plyr->armorpoints[ARMOR_ARMOR] + + plyr->armorpoints[ARMOR_SHIELD] + + plyr->armorpoints[ARMOR_HELMET] + + plyr->armorpoints[ARMOR_AMULET]; for(i = 0; i < NUMARMOR; i++) { - if(!CPlayer->armorpoints[i]) + if(!plyr->armorpoints[i]) { continue; } - if(CPlayer->armorpoints[i] <= (PCLASS_INFO(CPlayer->class)->armorincrement[i] >> 2)) + if(plyr->armorpoints[i] <= (PCLASS_INFO(plyr->class)->armorincrement[i] >> 2)) { GL_DrawPatchLitAlpha(150 + 31 * i, 164, 1, cfg.statusbarCounterAlpha * 0.3, W_GetNumForName("armslot1") + i); } - else if(CPlayer->armorpoints[i] <= - (PCLASS_INFO(CPlayer->class)->armorincrement[i] >> 1)) + else if(plyr->armorpoints[i] <= + (PCLASS_INFO(plyr->class)->armorincrement[i] >> 1)) { GL_DrawPatchLitAlpha(150 + 31 * i, 164, 1, cfg.statusbarCounterAlpha * 0.6, W_GetNumForName("armslot1") + i); @@ -1875,17 +1876,17 @@ static void DrawWeaponPieces(void) GL_DrawPatchLitAlpha(190, 162, 1, cfg.statusbarCounterAlpha, PatchNumWEAPONFULL.lump); else { - if(CPlayer->pieces & WPIECE1) + if(plyr->pieces & WPIECE1) { GL_DrawPatchLitAlpha(PCLASS_INFO(cfg.PlayerClass[consoleplayer])->piecex[0], 162, 1, cfg.statusbarCounterAlpha, PatchNumPIECE1.lump); } - if(CPlayer->pieces & WPIECE2) + if(plyr->pieces & WPIECE2) { GL_DrawPatchLitAlpha(PCLASS_INFO(cfg.PlayerClass[consoleplayer])->piecex[1], 162, 1, cfg.statusbarCounterAlpha, PatchNumPIECE2.lump); } - if(CPlayer->pieces & WPIECE3) + if(plyr->pieces & WPIECE3) { GL_DrawPatchLitAlpha(PCLASS_INFO(cfg.PlayerClass[consoleplayer])->piecex[2], 162, 1, cfg.statusbarCounterAlpha, PatchNumPIECE3.lump); @@ -1906,6 +1907,7 @@ void ST_doFullscreenStuff(void) int temp; float textalpha = hudalpha - ( 1 - cfg.hudColor[3]); float iconalpha = hudalpha - ( 1 - cfg.hudIconAlpha); + player_t *plyr = &players[consoleplayer]; #ifdef DEMOCAM if(demoplayback && democam.mode) @@ -1915,14 +1917,15 @@ void ST_doFullscreenStuff(void) if(cfg.hudShown[HUD_HEALTH]) { Draw_BeginZoom(cfg.hudScale, 5, 198); - if(CPlayer->plr->mo->health > 0) + if(plyr->plr->mo->health > 0) { - DrBNumber(CPlayer->plr->mo->health, 5, 180, - cfg.hudColor[0], cfg.hudColor[1], cfg.hudColor[2], textalpha); + DrBNumber(plyr->plr->mo->health, 5, 180, + cfg.hudColor[0], cfg.hudColor[1], cfg.hudColor[2], textalpha); } else { - DrBNumber(0, 5, 180, cfg.hudColor[0], cfg.hudColor[1], cfg.hudColor[2], textalpha); + DrBNumber(0, 5, 180, cfg.hudColor[0], cfg.hudColor[1], cfg.hudColor[2], + textalpha); } Draw_EndZoom(); } @@ -1935,26 +1938,26 @@ void ST_doFullscreenStuff(void) int ypos = cfg.hudShown[HUD_MANA] == 2 ? 152 : 2; for(i = 0; i < 2; i++) - if(CPlayer->ammo[i] == 0) + if(plyr->ammo[i] == 0) patches[i] = dim[i]; - if(CPlayer->readyweapon == WP_FIRST) + if(plyr->readyweapon == WP_FIRST) { for(i = 0; i < 2; i++) patches[i] = dim[i]; } - if(CPlayer->readyweapon == WP_SECOND) + if(plyr->readyweapon == WP_SECOND) { if(!patches[0]) patches[0] = bright[0]; patches[1] = dim[1]; } - if(CPlayer->readyweapon == WP_THIRD) + if(plyr->readyweapon == WP_THIRD) { patches[0] = dim[0]; if(!patches[1]) patches[1] = bright[1]; } - if(CPlayer->readyweapon == WP_FOURTH) + if(plyr->readyweapon == WP_FOURTH) { for(i = 0; i < 2; i++) if(!patches[i]) @@ -1964,7 +1967,7 @@ void ST_doFullscreenStuff(void) for(i = 0; i < 2; i++) { GL_DrawPatchLitAlpha(2, ypos + i * 13, 1, iconalpha, patches[i]); - DrINumber(CPlayer->ammo[i], 18, ypos + i * 13, 1, 1, 1, textalpha); + DrINumber(plyr->ammo[i], 18, ypos + i * 13, 1, 1, 1, textalpha); } Draw_EndZoom(); } @@ -1976,7 +1979,7 @@ void ST_doFullscreenStuff(void) { if(players[i].plr->ingame) { - temp += CPlayer->frags[i]; + temp += plyr->frags[i]; } } Draw_BeginZoom(cfg.hudScale, 2, 198); @@ -1986,15 +1989,16 @@ void ST_doFullscreenStuff(void) if(!inventory) { if(cfg.hudShown[HUD_ARTI]){ - if(CPlayer->readyArtifact > 0) + if(plyr->readyArtifact > 0) { Draw_BeginZoom(cfg.hudScale, 318, 198); GL_DrawPatchLitAlpha(286, 170, 1, iconalpha/2, W_GetNumForName("ARTIBOX")); GL_DrawPatchLitAlpha(284, 169, 1, iconalpha, - W_GetNumForName(artifactlist[CPlayer->readyArtifact+5])); - if(CPlayer->inventory[inv_ptr].count > 1) + W_GetNumForName(artifactlist[plyr->readyArtifact+5])); + if(plyr->inventory[plyr->inv_ptr].count > 1) { - DrSmallNumber(CPlayer->inventory[inv_ptr].count, 302, 192, 1, 1, 1, textalpha); + DrSmallNumber(plyr->inventory[plyr->inv_ptr].count, + 302, 192, 1, 1, 1, textalpha); } Draw_EndZoom(); } @@ -2007,32 +2011,32 @@ void ST_doFullscreenStuff(void) invScale = MINMAX_OF(0.25f, cfg.hudScale - 0.25f, 0.8f); Draw_BeginZoom(invScale, 160, 198); - x = inv_ptr - curpos; + x = plyr->inv_ptr - plyr->curpos; for(i = 0; i < 7; i++) { GL_DrawPatchLitAlpha(50 + i * 31, 168, 1, iconalpha/2, W_GetNumForName("ARTIBOX")); - if(CPlayer->inventorySlotNum > x + i && - CPlayer->inventory[x + i].type != arti_none) + if(plyr->inventorySlotNum > x + i && + plyr->inventory[x + i].type != arti_none) { - GL_DrawPatchLitAlpha(49 + i * 31, 167, 1, i==curpos? hudalpha : iconalpha, - W_GetNumForName(artifactlist[CPlayer->inventory + GL_DrawPatchLitAlpha(49 + i * 31, 167, 1, i==plyr->curpos? hudalpha : iconalpha, + W_GetNumForName(artifactlist[plyr->inventory [x + i].type+5])); - if(CPlayer->inventory[x + i].count > 1) + if(plyr->inventory[x + i].count > 1) { - DrSmallNumber(CPlayer->inventory[x + i].count, 66 + i * 31, - 188,1, 1, 1, i==curpos? hudalpha : textalpha/2); + DrSmallNumber(plyr->inventory[x + i].count, 66 + i * 31, + 188,1, 1, 1, i==plyr->curpos? hudalpha : textalpha/2); } } } - GL_DrawPatchLitAlpha(50 + curpos * 31, 167, 1, hudalpha,PatchNumSELECTBOX.lump); + GL_DrawPatchLitAlpha(50 + plyr->curpos * 31, 167, 1, hudalpha,PatchNumSELECTBOX.lump); if(x != 0) { GL_DrawPatchLitAlpha(40, 167, 1, iconalpha, !(leveltime & 4) ? PatchNumINVLFGEM1.lump : PatchNumINVLFGEM2.lump); } - if(CPlayer->inventorySlotNum - x > 7) + if(plyr->inventorySlotNum - x > 7) { GL_DrawPatchLitAlpha(268, 167, 1, iconalpha, !(leveltime & 4) ? PatchNumINVRTGEM1.lump : diff --git a/doomsday/plugins/jhexen/src/sv_save.c b/doomsday/plugins/jhexen/src/sv_save.c index b394a60b56..68d8ec3a8c 100644 --- a/doomsday/plugins/jhexen/src/sv_save.c +++ b/doomsday/plugins/jhexen/src/sv_save.c @@ -52,6 +52,7 @@ #include "p_mapsetup.h" #include "p_player.h" #include "p_map.h" +#include "p_inventory.h" // MACROS ------------------------------------------------------------------ @@ -536,23 +537,20 @@ void SV_HxLoadGame(int slot) Z_Free(TargetPlayerAddrs); // Restore player structs - inv_ptr = 0; - curpos = 0; - for(i = 0; i < MAXPLAYERS; i++) + for(i = 0; i < MAXPLAYERS; ++i) { mobj = players[i].plr->mo; players[i] = playerBackup[i]; players[i].plr->mo = mobj; - if(i == consoleplayer) - { - players[i].readyArtifact = players[i].inventory[inv_ptr].type; - } + players[i].readyArtifact = players[i].inventory[players[i].inv_ptr].type; + + P_InventoryResetCursor(&players[i]); } //Con_Printf("SaveToReal: "); // Kick out players who do not belong here. - for(i = 0; i < MAXPLAYERS; i++) + for(i = 0; i < MAXPLAYERS; ++i) { if(!players[i].plr->ingame) continue; @@ -626,10 +624,6 @@ void SV_HxMapTeleport(int map, int position) char fileName[100]; player_t playerBackup[MAXPLAYERS]; mobj_t *targetPlayerMobj; - - // mobj_t *mobj; - int inventoryPtr; - int currentInvPos; boolean rClass; boolean playerWasReborn; boolean oldWeaponowned[NUMWEAPONS]; @@ -654,13 +648,9 @@ void SV_HxMapTeleport(int map, int position) randomclass = false; for(i = 0; i < MAXPLAYERS; i++) { - playerBackup[i] = players[i]; + memcpy(&playerBackup[i], &players[i], sizeof(player_t)); } - // Save some globals that get trashed during the load - inventoryPtr = inv_ptr; - currentInvPos = curpos; - // Only SV_HxLoadMap() uses TargetPlayerAddrs, so it's NULLed here // for the following check (player mobj redirection) TargetPlayerAddrs = NULL; @@ -695,7 +685,7 @@ void SV_HxMapTeleport(int map, int position) { continue; } - players[i] = playerBackup[i]; + memcpy(&players[i], &playerBackup[i], sizeof(player_t)); P_ClearMessage(&players[i]); players[i].attacker = NULL; players[i].poisoner = NULL; @@ -780,10 +770,6 @@ void SV_HxMapTeleport(int map, int position) } } - // Restore trashed globals - inv_ptr = inventoryPtr; - curpos = currentInvPos; - // Launch waiting scripts if(!deathmatch) {