only update the ping if the scoreboard is active. Closes #27

This commit is contained in:
oy 2011-03-01 18:31:20 +01:00
parent 0bc13c91eb
commit 4bede550be
7 changed files with 31 additions and 21 deletions

View file

@ -1,7 +1,7 @@
from datatypes import *
Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"]
PlayerStates = ["UNKNOWN", "PLAYING", "IN_MENU", "CHATTING"]
PlayerFlags = ["PLAYING", "IN_MENU", "CHATTING", "SCOREBOARD"]
GameFlags = ["TEAMS", "FLAGS"]
Emoticons = [str(x) for x in range(0,16)]
@ -31,13 +31,13 @@ RawSource = '''
'''
Enums = [
Enum("PLAYERSTATE", PlayerStates),
Enum("EMOTE", Emotes),
Enum("POWERUP", Powerups),
Enum("EMOTICON", Emoticons)
]
Flags = [
Enum("PLAYERFLAG", PlayerFlags),
Flags("GAMEFLAG", GameFlags)
]
@ -52,7 +52,7 @@ Objects = [
NetIntAny("m_Fire"),
NetIntAny("m_Hook"),
NetIntRange("m_PlayerState", 0, len(PlayerStates)),
NetIntRange("m_PlayerFlags", 0, 256),
NetIntAny("m_WantedWeapon"),
NetIntAny("m_NextWeapon"),
@ -136,7 +136,7 @@ Objects = [
]),
NetObject("Character:CharacterCore", [
NetIntRange("m_PlayerState", 0, 'NUM_PLAYERSTATES-1'),
NetIntRange("m_PlayerFlags", 0, 256),
NetIntRange("m_Health", 0, 10),
NetIntRange("m_Armor", 0, 10),
NetIntRange("m_AmmoCount", 0, 10),
@ -152,7 +152,6 @@ Objects = [
NetIntAny("m_Score"),
NetIntAny("m_Latency"),
NetIntAny("m_LatencyFlux"),
]),
NetObject("ClientInfo", [

View file

@ -9,6 +9,7 @@
#include <game/client/component.h>
#include <game/client/components/chat.h>
#include <game/client/components/menus.h>
#include <game/client/components/scoreboard.h>
#include "controls.h"
@ -112,19 +113,22 @@ int CControls::SnapInput(int *pData)
// update player state
if(m_pClient->m_pChat->IsActive())
m_InputData.m_PlayerState = PLAYERSTATE_CHATTING;
m_InputData.m_PlayerFlags = PLAYERFLAG_CHATTING;
else if(m_pClient->m_pMenus->IsActive())
m_InputData.m_PlayerState = PLAYERSTATE_IN_MENU;
m_InputData.m_PlayerFlags = PLAYERFLAG_IN_MENU;
else
m_InputData.m_PlayerState = PLAYERSTATE_PLAYING;
m_InputData.m_PlayerFlags = PLAYERFLAG_PLAYING;
if(m_LastData.m_PlayerState != m_InputData.m_PlayerState)
if(m_pClient->m_pScoreboard->Active())
m_InputData.m_PlayerFlags |= PLAYERFLAG_SCOREBOARD;
if(m_LastData.m_PlayerFlags != m_InputData.m_PlayerFlags)
Send = true;
m_LastData.m_PlayerState = m_InputData.m_PlayerState;
m_LastData.m_PlayerFlags = m_InputData.m_PlayerFlags;
// we freeze the input if chat or menu is activated
if(m_InputData.m_PlayerState != PLAYERSTATE_PLAYING)
if(!(m_InputData.m_PlayerFlags&PLAYERFLAG_PLAYING))
{
OnReset();
@ -172,7 +176,6 @@ int CControls::SnapInput(int *pData)
else if(m_InputData.m_Jump != m_LastData.m_Jump) Send = true;
else if(m_InputData.m_Fire != m_LastData.m_Fire) Send = true;
else if(m_InputData.m_Hook != m_LastData.m_Hook) Send = true;
else if(m_InputData.m_PlayerState != m_LastData.m_PlayerState) Send = true;
else if(m_InputData.m_WantedWeapon != m_LastData.m_WantedWeapon) Send = true;
else if(m_InputData.m_NextWeapon != m_LastData.m_NextWeapon) Send = true;
else if(m_InputData.m_PrevWeapon != m_LastData.m_PrevWeapon) Send = true;

View file

@ -500,7 +500,7 @@ void CPlayers::RenderPlayer(
RenderInfo.m_ColorFeet.a = 1.0f;
RenderTools()->RenderTee(&State, &RenderInfo, Player.m_Emote, Direction, Position);
if(Player.m_PlayerState == PLAYERSTATE_CHATTING)
if(Player.m_PlayerFlags&PLAYERFLAG_CHATTING)
{
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_EMOTICONS].m_Id);
Graphics()->QuadsBegin();

View file

@ -54,7 +54,6 @@ void CCharacter::Reset()
bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
{
m_PlayerState = PLAYERSTATE_UNKNOWN;
m_EmoteStop = -1;
m_LastAction = -1;
m_ActiveWeapon = WEAPON_GUN;
@ -559,8 +558,6 @@ void CCharacter::Tick()
// handle Weapons
HandleWeapons();
m_PlayerState = m_Input.m_PlayerState;
// Previnput
m_PrevInput = m_Input;
return;
@ -839,5 +836,5 @@ void CCharacter::Snap(int SnappingClient)
pCharacter->m_Emote = EMOTE_BLINK;
}
pCharacter->m_PlayerState = m_PlayerState;
pCharacter->m_PlayerFlags = GetPlayer()->m_PlayerFlags;
}

View file

@ -120,8 +120,6 @@ private:
} m_Ninja;
int m_PlayerState;// if the client is chatting, accessing a menu or so
// the player core for the physics
CCharacterCore m_Core;

View file

@ -99,8 +99,13 @@ void CPlayer::Snap(int SnappingClient)
if(!pPlayerInfo)
return;
pPlayerInfo->m_Latency = m_Latency.m_Min;
pPlayerInfo->m_LatencyFlux = m_Latency.m_Max-m_Latency.m_Min;
// update latency value
if(SnappingClient != -1 && m_Team != -1 && GameServer()->m_apPlayers[SnappingClient]->m_PlayerFlags&PLAYERFLAG_SCOREBOARD)
{
GameServer()->m_apPlayers[SnappingClient]->m_aActLatency[m_ClientID] = m_Latency.m_Min;
}
pPlayerInfo->m_Latency = SnappingClient == -1 ? m_Latency.m_Min : GameServer()->m_apPlayers[SnappingClient]->m_aActLatency[m_ClientID];
pPlayerInfo->m_Local = 0;
pPlayerInfo->m_ClientID = m_ClientID;
pPlayerInfo->m_Score = m_Score;
@ -133,6 +138,8 @@ void CPlayer::OnPredictedInput(CNetObj_PlayerInput *NewInput)
void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput)
{
m_PlayerFlags = NewInput->m_PlayerFlags;
if(Character)
Character->OnDirectInput(NewInput);

View file

@ -37,6 +37,12 @@ public:
//---------------------------------------------------------
// this is used for snapping so we know how we can clip the view for the player
vec2 m_ViewPos;
// states if the client is chatting, accessing a menu etc.
int m_PlayerFlags;
// used for snapping to just update latency if the scoreboard is active
int m_aActLatency[MAX_CLIENTS];
//
int m_Vote;