Skip to content

Commit

Permalink
Fixed: "HeXen inventory not saved between maps" (see here http://sour…
Browse files Browse the repository at this point in the history
  • Loading branch information
danij committed May 2, 2009
1 parent 0f13631 commit 27bfc2d
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion doomsday/plugins/common/src/p_saveg.c
Expand Up @@ -5378,9 +5378,10 @@ static void SV_HxLoadMap(void)
void SV_MapTeleport(int map, int position)
{
int i;
int j;
char fileName[100];
player_t playerBackup[MAXPLAYERS];
uint numInventoryItems[MAXPLAYERS][NUM_INVENTORYITEM_TYPES];
inventoryitemtype_t readyItem[MAXPLAYERS];
mobj_t *targetPlayerMobj;
boolean rClass;
boolean playerWasReborn;
Expand Down Expand Up @@ -5421,7 +5422,13 @@ void SV_MapTeleport(int map, int position)
randomClassParm = false;
for(i = 0; i < MAXPLAYERS; ++i)
{
uint j;

memcpy(&playerBackup[i], &players[i], sizeof(player_t));

for(j = 0; j < NUM_INVENTORYITEM_TYPES; ++j)
numInventoryItems[i][j] = P_InventoryCount(i, j);
readyItem[i] = P_InventoryReadyItem(i);
}

// Only SV_HxLoadMap() uses targetPlayerAddrs, so it's NULLed here
Expand Down Expand Up @@ -5454,11 +5461,27 @@ void SV_MapTeleport(int map, int position)
targetPlayerMobj = NULL;
for(i = 0; i < MAXPLAYERS; ++i)
{
uint j;

if(!players[i].plr->inGame)
{
continue;
}

memcpy(&players[i], &playerBackup[i], sizeof(player_t));
for(j = 0; j < NUM_INVENTORYITEM_TYPES; ++j)
{
uint k;

// Don't give back the wings of wrath if reborn.
if(j == IIT_FLY && players[i].playerState == PST_REBORN)
continue;

for(k = 0; k < numInventoryItems[i][j]; ++k)
P_InventoryGive(i, j, true);
}
P_InventorySetReadyItem(i, readyItem[i]);

HUMsg_ClearMessages(i);
players[i].attacker = NULL;
players[i].poisoner = NULL;
Expand Down

0 comments on commit 27bfc2d

Please sign in to comment.