about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--datasrc/network.py9
-rw-r--r--src/game/client/components/controls.cpp17
-rw-r--r--src/game/client/components/players.cpp2
-rw-r--r--src/game/server/entities/character.cpp5
-rw-r--r--src/game/server/entities/character.h2
-rw-r--r--src/game/server/player.cpp11
-rw-r--r--src/game/server/player.h6
7 files changed, 31 insertions, 21 deletions
diff --git a/datasrc/network.py b/datasrc/network.py
index c80adc57..2489b131 100644
--- a/datasrc/network.py
+++ b/datasrc/network.py
@@ -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", [
diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp
index f7da46b6..479bba22 100644
--- a/src/game/client/components/controls.cpp
+++ b/src/game/client/components/controls.cpp
@@ -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;
diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp
index 40197e9f..cbbc8d99 100644
--- a/src/game/client/components/players.cpp
+++ b/src/game/client/components/players.cpp
@@ -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();
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp
index 1221d438..ddd416d1 100644
--- a/src/game/server/entities/character.cpp
+++ b/src/game/server/entities/character.cpp
@@ -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;
 }
diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h
index 6346570f..b874fd0c 100644
--- a/src/game/server/entities/character.h
+++ b/src/game/server/entities/character.h
@@ -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;
 	
diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp
index 32eec986..573d996d 100644
--- a/src/game/server/player.cpp
+++ b/src/game/server/player.cpp
@@ -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);
 
diff --git a/src/game/server/player.h b/src/game/server/player.h
index fbbf5567..f4d82d24 100644
--- a/src/game/server/player.h
+++ b/src/game/server/player.h
@@ -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;