Skip to content

Commit

Permalink
Fixed|Multiplayer|Hexen: Player's weapon after respawn
Browse files Browse the repository at this point in the history
In Hexen MP, players are given their old weapons and keys back, and
some mana. This commit fixes an issue where the client wasn't notified
that the readyweapon was changed by the server to the best owned one.

The amount of mana is now defined in Values.
  • Loading branch information
skyjake committed Mar 19, 2013
1 parent 5a8df81 commit bc61fbe
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion doomsday/plugins/common/include/p_start.h
Expand Up @@ -198,7 +198,7 @@ void P_SpawnPlayer(int plrNum, playerclass_t pClass, coord_t x, coord_t y, coord
angle_t angle, int spawnFlags, boolean makeCamera, boolean pickupItems);

void G_DeathMatchSpawnPlayer(int playernum);
void P_RebornPlayer(int plrNum);
void P_RebornPlayerInMultiplayer(int plrNum);

/**
* @return @c false if the player cannot be respawned at the
Expand Down
6 changes: 5 additions & 1 deletion doomsday/plugins/common/src/g_game.c
Expand Up @@ -2009,6 +2009,10 @@ void G_PlayerReborn(int player)
if(player < 0 || player >= MAXPLAYERS)
return; // Wha?

#ifdef _DEBUG
Con_Message("G_PlayerReborn: reseting player %i", player);
#endif

p = &players[player];

assert(sizeof(p->frags) == sizeof(frags));
Expand Down Expand Up @@ -2168,7 +2172,7 @@ void G_DoReborn(int plrNum)

if(IS_NETGAME)
{
P_RebornPlayer(plrNum);
P_RebornPlayerInMultiplayer(plrNum);
return;
}

Expand Down
31 changes: 17 additions & 14 deletions doomsday/plugins/common/src/p_start.c
Expand Up @@ -709,7 +709,7 @@ void P_SpawnClient(int plrNum)
/**
* Called by G_DoReborn if playing a net game.
*/
void P_RebornPlayer(int plrNum)
void P_RebornPlayerInMultiplayer(int plrNum)
{
#if __JHEXEN__
int oldKeys = 0, oldPieces = 0, bestWeapon;
Expand Down Expand Up @@ -772,12 +772,6 @@ void P_RebornPlayer(int plrNum)
{
P_SpawnClient(plrNum);
return;

// Anywhere will do for now.
//pos[VX] = pos[VY] = pos[VZ] = 0;
//angle = 0;
//spawnFlags = MSF_Z_FLOOR;
//makeCamera = true; // Clients spawn as spectators.
}
else
{
Expand Down Expand Up @@ -907,10 +901,11 @@ void P_RebornPlayer(int plrNum)
spawnPlayer(plrNum, pClass, pos[VX], pos[VY], pos[VZ], angle,
spawnFlags, makeCamera, true, true);

DENG_ASSERT(!IS_CLIENT);

// Restore player state?
if(!IS_CLIENT)
{
#if __JHEXEN__
{
int i;

// Restore keys and weapons
Expand All @@ -925,14 +920,22 @@ void P_RebornPlayer(int plrNum)
}
}

p->ammo[AT_BLUEMANA].owned = 25; //// @todo values.ded
p->ammo[AT_GREENMANA].owned = 25; //// @todo values.ded
GetDefInt("Multiplayer|Reborn|Blue mana", &p->ammo[AT_BLUEMANA].owned);
GetDefInt("Multiplayer|Reborn|Green mana", &p->ammo[AT_GREENMANA].owned);

#ifdef _DEBUG
Con_Message("P_RebornPlayer: Giving mana (b:%i g:%i) to player %i; also old weapons, "
"with best weapon %i", p->ammo[AT_BLUEMANA].owned, p->ammo[AT_GREENMANA].owned,
plrNum, bestWeapon);
#endif

if(bestWeapon)
{ // Bring up the best weapon.
p->pendingWeapon = bestWeapon;
{
// Bring up the best weapon.
p->readyWeapon = p->pendingWeapon = bestWeapon;
}
#endif
}
#endif
}

boolean P_CheckSpot(coord_t x, coord_t y)
Expand Down

0 comments on commit bc61fbe

Please sign in to comment.