From a62decbc919f2e13e5f6142e574a0d2bc41e25dc Mon Sep 17 00:00:00 2001 From: btd Date: Sun, 24 Oct 2010 14:47:25 +0400 Subject: [PATCH] Show others for ddrace clients. Need to fix entities now. Signed-off-by: btd --- datasrc/datatypes.py | 1 + datasrc/network.py | 2 +- src/engine/shared/config_variables.h | 2 +- src/engine/shared/network_conn.cpp | 6 +++--- src/game/client/gameclient.cpp | 29 +++++++++++++++++++++++++- src/game/gamecore.cpp | 10 ++++----- src/game/server/entities/character.cpp | 22 +++++++------------ src/game/server/gamecontext.cpp | 7 +++++-- src/game/server/teams.cpp | 26 +++++++++++++++++++++++ src/game/server/teams.h | 2 ++ 10 files changed, 79 insertions(+), 28 deletions(-) diff --git a/datasrc/datatypes.py b/datasrc/datatypes.py index 4e293ab14..fafabe62b 100644 --- a/datasrc/datatypes.py +++ b/datasrc/datatypes.py @@ -309,6 +309,7 @@ class NetIntAny(NetVariable): return ["pMsg->%s = pUnpacker->GetInt();" % self.name] def emit_pack(self): return ["pPacker->AddInt(%s);" % self.name] + class NetIntRange(NetIntAny): def __init__(self, name, min, max): diff --git a/datasrc/network.py b/datasrc/network.py index 89ad7563c..de6f7b19e 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -296,7 +296,7 @@ Messages = [ NetMessage("Cl_IsRace", []), - NetMessage("Cl_Team", [ + NetMessage("Cl_TeamsState", [ NetIntAny("m_Tee0"), NetIntAny("m_Tee1"), NetIntAny("m_Tee2"), diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 31d2291e6..f55ab2e0c 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -147,5 +147,5 @@ MACRO_CONFIG_STR(SvRulesLine10, sv_rules_line10, 40, "", CFGFLAG_SERVER, "Rules MACRO_CONFIG_INT(SvTeam, sv_team, 0, -1, 1, CFGFLAG_SERVER, "Teams configuration", 4) MACRO_CONFIG_INT(SvTeamStrict, sv_team_strict, 0, 0, 1, CFGFLAG_SERVER, "Kill or not all team if someone left game in team", 4) -MACRO_CONFIG_INT(SvConnTimeout, sv_conn_timeout, 10, 5, 100, CFGFLAG_CLIENT|CFGFLAG_SERVER, "Network timeout for init", 4) +MACRO_CONFIG_INT(ConnTimeout, conn_timeout, 15, 5, 100, CFGFLAG_CLIENT|CFGFLAG_SERVER, "Network timeout", 4) #endif diff --git a/src/engine/shared/network_conn.cpp b/src/engine/shared/network_conn.cpp index bc6b4628d..f47191276 100644 --- a/src/engine/shared/network_conn.cpp +++ b/src/engine/shared/network_conn.cpp @@ -301,7 +301,7 @@ int CNetConnection::Update() // check for timeout if(State() != NET_CONNSTATE_OFFLINE && State() != NET_CONNSTATE_CONNECT && - (Now-m_LastRecvTime) > time_freq()*g_Config.m_SvConnTimeout) + (Now-m_LastRecvTime) > time_freq()*g_Config.m_ConnTimeout) { m_State = NET_CONNSTATE_ERROR; SetError("Timeout"); @@ -313,11 +313,11 @@ int CNetConnection::Update() CNetChunkResend *pResend = m_Buffer.First(); // check if we have some really old stuff laying around and abort if not acked - if(Now-pResend->m_FirstSendTime > time_freq()*g_Config.m_SvConnTimeout) + if(Now-pResend->m_FirstSendTime > time_freq()*g_Config.m_ConnTimeout) { m_State = NET_CONNSTATE_ERROR; char aBuf[512]; - str_format(aBuf, sizeof(aBuf), "Too weak connection (not acked for %d seconds)", g_Config.m_SvConnTimeout); + str_format(aBuf, sizeof(aBuf), "Too weak connection (not acked for %d seconds)", g_Config.m_ConnTimeout); SetError(aBuf); } else diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 0d0a029c2..864d74bc5 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -395,6 +395,8 @@ void CGameClient::OnReset() m_Teams.Reset(); Layers()->Dest(); Collision()->Dest(); + + m_RaceMsgSent = false; } @@ -579,6 +581,31 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker) else g_GameClient.m_pSounds->Play(CSounds::CHN_GLOBAL, pMsg->m_Soundid, 1.0f, vec2(0,0)); } + else if(MsgId == NETMSGTYPE_CL_TEAMSSTATE) { + CNetMsg_Cl_TeamsState *pMsg = (CNetMsg_Cl_TeamsState *)pRawMsg; + m_Teams.Team(0, pMsg->m_Tee0); + m_Teams.Team(1, pMsg->m_Tee1); + m_Teams.Team(2, pMsg->m_Tee2); + m_Teams.Team(3, pMsg->m_Tee3); + m_Teams.Team(4, pMsg->m_Tee4); + m_Teams.Team(5, pMsg->m_Tee5); + m_Teams.Team(6, pMsg->m_Tee6); + m_Teams.Team(7, pMsg->m_Tee7); + m_Teams.Team(8, pMsg->m_Tee8); + m_Teams.Team(9, pMsg->m_Tee9); + m_Teams.Team(10, pMsg->m_Tee10); + m_Teams.Team(11, pMsg->m_Tee11); + m_Teams.Team(12, pMsg->m_Tee12); + m_Teams.Team(13, pMsg->m_Tee13); + m_Teams.Team(14, pMsg->m_Tee14); + m_Teams.Team(15, pMsg->m_Tee15); + for(int i = 0; i < MAX_CLIENTS; i++) + { + char aBuf[512]; + str_format(aBuf, sizeof(aBuf), "Team = %d", m_Teams.Team(i)); + dbg_msg("Teams", aBuf); + } + } } void CGameClient::OnStateChange(int NewState, int OldState) @@ -859,7 +886,7 @@ void CGameClient::OnPredict() g_GameClient.m_aClients[i].m_Predicted.Init(&World, Collision(), &m_Teams); World.m_apCharacters[i] = &g_GameClient.m_aClients[i].m_Predicted; - World.m_apCharacters[i]->m_Id = m_Snap.m_LocalCid; + World.m_apCharacters[i]->m_Id = m_Snap.m_paPlayerInfos[i]->m_ClientId; g_GameClient.m_aClients[i].m_Predicted.Read(&m_Snap.m_aCharacters[i].m_Cur); } diff --git a/src/game/gamecore.cpp b/src/game/gamecore.cpp index 2adf56201..dfefca4e9 100644 --- a/src/game/gamecore.cpp +++ b/src/game/gamecore.cpp @@ -242,13 +242,13 @@ void CCharacterCore::Tick(bool UseInput) for(int i = 0; i < MAX_CLIENTS; i++) { CCharacterCore *p = m_pWorld->m_apCharacters[i]; - - + char aBuf[512]; + str_format(aBuf, sizeof(aBuf), "ThisId = %d Id = %d Team = %d", m_Id, i, m_pTeams->Team(i)); + dbg_msg("GameCore", aBuf); if(!p || p == this || !m_pTeams->CanCollide(i, m_Id)) continue; - //char aBuf[512]; - //str_format(aBuf, sizeof(aBuf), "ThisId = %d Id = %d TheSameTeam? = %d", ThisId, i, m_pTeams->SameTeam(i, ThisId)); - //dbg_msg("GameCore", aBuf); + + vec2 ClosestPoint = closest_point_on_line(m_HookPos, NewPos, p->m_Pos); if(distance(p->m_Pos, ClosestPoint) < PhysSize+2.0f) { diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 91213ccaf..3eeeaeaac 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1279,21 +1279,13 @@ void CCharacter::Snap(int SnappingClient) return; CCharacter* SnapChar = GameServer()->GetPlayerChar(SnappingClient); - if - ( - SnapChar && - !SnapChar->m_Super && - ( - GameServer()->m_apPlayers[SnappingClient]->GetTeam() != -1 && - SnapChar->Team() != Team() && - Team() != TEAM_SUPER - ) || - ( - GetPlayer()->m_Invisible && - GetPlayer()->GetCID() != SnappingClient && - GameServer()->m_apPlayers[SnappingClient]->m_Authed < GetPlayer()->m_Authed - ) - ) + if(SnapChar && !SnapChar->m_Super && + GameServer()->m_apPlayers[SnappingClient]->GetTeam() != -1 && + !CanCollide(SnappingClient) && !GameServer()->m_apPlayers[SnappingClient]->m_IsUsingRaceClient) return; + if(GetPlayer()->m_Invisible && + GetPlayer()->GetCID() != SnappingClient && + GameServer()->m_apPlayers[SnappingClient]->m_Authed < GetPlayer()->m_Authed + ) return; CNetObj_Character *Character = static_cast(Server()->SnapNewItem(NETOBJTYPE_CHARACTER, m_pPlayer->GetCID(), sizeof(CNetObj_Character))); diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 4b92c795f..db0c13f49 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -604,7 +604,7 @@ void CGameContext::OnClientEnter(int ClientId) SendChatTarget(ClientId, "Note This is an Alpha release, just for testing, your feedback is important!!"); if(g_Config.m_SvWelcome[0]!=0) SendChatTarget(ClientId,g_Config.m_SvWelcome); - str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' team=%d", ClientId, Server()->ClientName(ClientId), m_apPlayers[ClientId]->GetTeam()); + //str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' team=%d", ClientId, Server()->ClientName(ClientId), m_apPlayers[ClientId]->GetTeam()); Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); @@ -961,7 +961,10 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) else if (MsgId == NETMSGTYPE_CL_ISRACE) { pPlayer->m_IsUsingRaceClient = true; - + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "%d use DDRace Client", pPlayer->GetCID()); + dbg_msg("DDRace", aBuf); + ((CGameControllerDDRace*)m_pController)->m_Teams.SendTeamsState(ClientId); } else if(MsgId == NETMSGTYPE_CL_CHANGEINFO || MsgId == NETMSGTYPE_CL_STARTINFO) { diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index ab5d5d89f..87284f3e4 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -90,6 +90,9 @@ bool CGameTeams::SetCharacterTeam(int id, int Team) { char aBuf[512]; str_format(aBuf, sizeof(aBuf), "Id = %d Team = %d", id, Team); dbg_msg("Teams", aBuf); + if(Character(id) && Character(id)->GetPlayer()->m_IsUsingRaceClient) { + SendTeamsState(id); + } //GameServer()->CreatePlayerSpawn(Character(id)->m_Core.m_Pos, TeamMask()); return true; } @@ -141,3 +144,26 @@ int CGameTeams::TeamMask(int Team) { } return Mask; } + +void CGameTeams::SendTeamsState(int Cid) { + CNetMsg_Cl_TeamsState Msg; + Msg.m_Tee0 = m_Core.Team(0); + Msg.m_Tee1 = m_Core.Team(1); + Msg.m_Tee2 = m_Core.Team(2); + Msg.m_Tee3 = m_Core.Team(3); + Msg.m_Tee4 = m_Core.Team(4); + Msg.m_Tee5 = m_Core.Team(5); + Msg.m_Tee6 = m_Core.Team(6); + Msg.m_Tee7 = m_Core.Team(7); + Msg.m_Tee8 = m_Core.Team(8); + Msg.m_Tee9 = m_Core.Team(9); + Msg.m_Tee10 = m_Core.Team(10); + Msg.m_Tee11 = m_Core.Team(11); + Msg.m_Tee12 = m_Core.Team(12); + Msg.m_Tee13 = m_Core.Team(13); + Msg.m_Tee14 = m_Core.Team(14); + Msg.m_Tee15 = m_Core.Team(15); + + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, Cid); + +} diff --git a/src/game/server/teams.h b/src/game/server/teams.h index 0395d9954..8b6e5d742 100644 --- a/src/game/server/teams.h +++ b/src/game/server/teams.h @@ -44,6 +44,8 @@ public: void SetForceCharacterTeam(int id, int Team); void Reset(); + + void SendTeamsState(int Cid); }; #endif