Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Heretic: Fixing chicken morph
Located a few issues with the code (such as using __JHERETIC
instead of __JHERETIC__) that were messing things up.
Currently the client is getting the message about morphing,
but the server seems to switch the mobj to the wrong attack
state when the chicken attacks. I suppose the player class
has something to do with this.
  • Loading branch information
skyjake committed May 24, 2011
1 parent 0996f74 commit 5eef324
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 26 deletions.
21 changes: 15 additions & 6 deletions doomsday/plugins/common/src/d_netcl.c
Expand Up @@ -90,6 +90,12 @@ short NetCl_ReadShort(void)
return SHORT( *(short*) (readbuffer - 2) );
}

unsigned short NetCl_ReadUShort(void)
{
readbuffer += 2;
return SHORT( *(unsigned short*) (readbuffer - 2) );
}

int NetCl_ReadLong(void)
{
readbuffer += 4;
Expand Down Expand Up @@ -357,16 +363,16 @@ void NetCl_UpdatePlayerState2(byte *data, int plrNum)

void NetCl_UpdatePlayerState(byte *data, int plrNum)
{
int i;
player_t *pl = &players[plrNum];
byte b;
unsigned short flags, s;
int i;
player_t* pl = &players[plrNum];
byte b;
int flags, s;

if(!Get(DD_GAME_READY))
return;

NetCl_SetReadBuffer(data);
flags = NetCl_ReadShort();
flags = NetCl_ReadUShort();

#ifdef _DEBUG
Con_Message("NetCl_UpdatePlayerState: fl=%x\n", flags);
Expand Down Expand Up @@ -605,10 +611,13 @@ void NetCl_UpdatePlayerState(byte *data, int plrNum)
pl->viewHeight = (float) NetCl_ReadByte();
}

#if __JHERETIC || __JHEXEN__ || __JSTRIFE__
#if __JHERETIC__ || __JHEXEN__ || __JSTRIFE__
if(flags & PSF_MORPH_TIME)
{
pl->morphTics = NetCl_ReadByte() * 35;
#ifdef _DEBUG
Con_Message("NetCl_UpdatePlayerState: Player %i morphtics = %i\n", plrNum, pl->morphTics);
#endif
}
#endif

Expand Down
6 changes: 4 additions & 2 deletions doomsday/plugins/common/src/d_netsv.c
Expand Up @@ -1207,6 +1207,9 @@ void NetSv_SendPlayerState(int srcPlrNum, int destPlrNum, int flags,
#if __JHERETIC__ || __JHEXEN__ || __JSTRIFE__
if(flags & PSF_MORPH_TIME)
{
#ifdef _DEBUG
Con_Message("NetSv_SendPlayerState: Player %i, sending morph tics as %i seconds.\n", srcPlrNum, (pl->morphTics + 34) / 35);
#endif
// Send as seconds.
*ptr++ = (pl->morphTics + 34) / 35;
}
Expand All @@ -1221,8 +1224,7 @@ void NetSv_SendPlayerState(int srcPlrNum, int destPlrNum, int flags,
#endif

// Finally, send the packet.
Net_SendPacket(destPlrNum | (reliable ? DDSP_ORDERED : 0), pType, buffer,
ptr - buffer);
Net_SendPacket(destPlrNum | (reliable ? DDSP_ORDERED : 0), pType, buffer, ptr - buffer);
}

void NetSv_SendPlayerInfo(int whose, int to_whom)
Expand Down
36 changes: 20 additions & 16 deletions doomsday/plugins/common/src/p_user.c
Expand Up @@ -697,21 +697,27 @@ void P_MorphThink(player_t *player)
player->chickenPeck -= 3;
}

if(IS_CLIENT || player->morphTics & 15)
if(/*IS_CLIENT || */ player->morphTics & 15)
return;

pmo = player->plr->mo;
//// \fixme: Replace equality to zero checks with mom in-range.
if(pmo->mom[MX] == 0 && pmo->mom[MY] == 0 && P_Random() < 160)
{ // Twitch view angle
pmo->angle += (P_Random() - P_Random()) << 19;
}

if(pmo->pos[VZ] <= pmo->floorZ && (P_Random() < 32))
{ // Jump and noise
pmo->mom[MZ] += 1;
P_MobjChangeState(pmo, S_CHICPLAY_PAIN);
return;
if(!IS_NETGAME || IS_CLIENT)
{
//// \fixme: Replace equality to zero checks with mom in-range.
if(pmo->mom[MX] == 0 && pmo->mom[MY] == 0 && P_Random() < 160)
{ // Twitch view angle
pmo->angle += (P_Random() - P_Random()) << 19;
}
/* }
if(!IS_NETGAME || !IS_CLIENT)
{*/
if(pmo->pos[VZ] <= pmo->floorZ && (P_Random() < 32))
{ // Jump and noise
pmo->mom[MZ] += 1;
P_MobjChangeState(pmo, S_CHICPLAY_PAIN);
return;
}
}

if(P_Random() < 48)
Expand All @@ -734,6 +740,8 @@ boolean P_UndoPlayerMorph(player_t *player)
weapontype_t weapon;
int oldFlags, oldFlags2, oldBeast;

if(IS_CLIENT) return false;

# if __JHEXEN__
player->update |= PSF_MORPH_TIME | PSF_POWERS | PSF_HEALTH;
# endif
Expand Down Expand Up @@ -1840,11 +1848,7 @@ void P_PlayerThink(player_t *player, timespan_t ticLength)
if(P_PlayerThinkDeath(player))
return; // I'm dead!

if(!IS_CLIENT) // Locally only.
{
P_PlayerThinkMorph(player);
}

P_PlayerThinkMorph(player);
P_PlayerThinkAttackLunge(player);
P_PlayerThinkMove(player);
P_PlayerThinkFly(player);
Expand Down
7 changes: 5 additions & 2 deletions doomsday/plugins/jheretic/src/p_inter.c
Expand Up @@ -990,6 +990,10 @@ boolean P_MorphPlayer(player_t* player)
angle_t angle;
int oldFlags2;

#ifdef _DEBUG
Con_Message("P_MorphPlayer: Player %i.\n", player - players);
#endif

if(player->morphTics)
{
if((player->morphTics < CHICKENTICS - TICSPERSEC) &&
Expand Down Expand Up @@ -1034,8 +1038,7 @@ boolean P_MorphPlayer(player_t* player)

player->morphTics = CHICKENTICS;
player->plr->flags |= DDPF_FIXPOS | DDPF_FIXMOM;
player->update |=
PSF_MORPH_TIME | PSF_HEALTH | PSF_POWERS | PSF_ARMOR_POINTS;
player->update |= PSF_MORPH_TIME | PSF_HEALTH | PSF_POWERS | PSF_ARMOR_POINTS;

P_ActivateMorphWeapon(player);
return true;
Expand Down

0 comments on commit 5eef324

Please sign in to comment.