Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Server: Fixed weapon change mixup
The server should not redo the weapon change logic as
it already have been done by the client. Fixes the problem
where the client's DB Shotgun was performing like a normal
Shotgun (server had re-swapped it back to the other slot).
  • Loading branch information
skyjake committed Dec 23, 2011
1 parent 5469ba1 commit ffd0105
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions doomsday/plugins/common/include/common.h
Expand Up @@ -26,6 +26,8 @@

#define WEAPONBOTTOM (128) // from p_pspr.c

#define IS_NETWORK_SERVER (DD_GetInteger(DD_SERVER) && DD_GetInteger(DD_NETGAME))

#if __JDOOM__
# include "jdoom.h"
#elif __JDOOM64__
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/mobj.c
Expand Up @@ -126,7 +126,7 @@ void Mobj_XYMoveStopping(mobj_t* mo)

// Stop player walking animation (only real players).
if(!isVoodooDoll && player && belowStandSpeed && !isMovingPlayer &&
!(IS_NETGAME && IS_SERVER)) // Netgame servers use logic elsewhere for player animation.
!IS_NETWORK_SERVER) // Netgame servers use logic elsewhere for player animation.
{
// If in a walking frame, stop moving.
if(P_PlayerInWalkState(player))
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/p_player.c
Expand Up @@ -407,7 +407,7 @@ weapontype_t P_MaybeChangeWeapon(player_t *player, weapontype_t weapon,
weaponinfo_t *winf;
boolean found;

if(IS_NETGAME && IS_SERVER)
if(IS_NETWORK_SERVER)
{
// This is done on clientside.
NetSv_MaybeChangeWeapon(player - players, weapon, ammo, force);
Expand Down
19 changes: 16 additions & 3 deletions doomsday/plugins/common/src/p_user.c
Expand Up @@ -473,7 +473,7 @@ void P_MovePlayer(player_t *player)

if(!plrmo) return;

if(IS_NETGAME && IS_SERVER)
if(IS_NETWORK_SERVER)
{
// Server starts the walking animation for remote players.
if((!FEQUAL(dp->forwardMove, 0) || !FEQUAL(dp->sideMove, 0)) &&
Expand Down Expand Up @@ -1313,6 +1313,19 @@ void P_PlayerThinkWeapons(player_t* player)
weapontype_t oldweapon = player->pendingWeapon;
weapontype_t newweapon = WT_NOCHANGE;

if(IS_NETWORK_SERVER)
{
// Weapon change logic has already been done by the client.
newweapon = brain->changeWeapon;

if(!player->weapons[newweapon].owned)
{
Con_Message("P_PlayerThinkWeapons: Player %i tried to change to unowned weapon %i!\n",
(int)(player - players), newweapon);
newweapon = WT_NOCHANGE;
}
}
else
// Check for weapon change.
#if __JHERETIC__ || __JHEXEN__
if(brain->changeWeapon != WT_NOCHANGE && !player->morphTics)
Expand All @@ -1321,7 +1334,7 @@ void P_PlayerThinkWeapons(player_t* player)
#endif
{
// Direct slot selection.
weapontype_t cand, first;
weapontype_t cand, first;

// Is this a same-slot weapon cycle?
if(P_GetWeaponSlot(brain->changeWeapon) ==
Expand Down Expand Up @@ -1382,7 +1395,7 @@ void P_PlayerThinkWeapons(player_t* player)

void P_PlayerThinkUse(player_t *player)
{
if(IS_NETGAME && IS_SERVER && player != &players[CONSOLEPLAYER])
if(IS_NETWORK_SERVER && player != &players[CONSOLEPLAYER])
{
// Clients send use requests instead.
return;
Expand Down

0 comments on commit ffd0105

Please sign in to comment.