fixed demo recording/playing, clientinfo for server dummies and wrong team colours in scoreboard

This commit is contained in:
oy 2012-08-04 12:50:45 +02:00
parent 525825c215
commit 4333f832f7
3 changed files with 45 additions and 19 deletions

View file

@ -221,7 +221,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
{
// make sure that we render the correct team
const CGameClient::CPlayerInfoItem *pInfo = &m_pClient->m_Snap.m_aInfoByScore[i];
if(!pInfo->m_pPlayerInfo || m_pClient->m_aClients[i].m_Team != Team || (!RenderDead && (pInfo->m_pPlayerInfo->m_PlayerFlags&PLAYERFLAG_DEAD)) ||
if(!pInfo->m_pPlayerInfo || m_pClient->m_aClients[pInfo->m_ClientID].m_Team != Team || (!RenderDead && (pInfo->m_pPlayerInfo->m_PlayerFlags&PLAYERFLAG_DEAD)) ||
(RenderDead && !(pInfo->m_pPlayerInfo->m_PlayerFlags&PLAYERFLAG_DEAD)))
continue;
@ -251,7 +251,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
Graphics()->QuadsBegin();
RenderTools()->SelectSprite(m_pClient->m_aClients[i].m_Team==TEAM_RED ? SPRITE_FLAG_BLUE : SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);
RenderTools()->SelectSprite(m_pClient->m_aClients[pInfo->m_ClientID].m_Team==TEAM_RED ? SPRITE_FLAG_BLUE : SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);
float Size = LineHeight;
IGraphics::CQuadItem QuadItem(TeeOffset+0.0f, y-5.0f-Spacing/2.0f, Size/2.0f, Size);

View file

@ -334,8 +334,7 @@ void CGameClient::OnReset()
m_All.m_paComponents[i]->OnReset();
m_LocalClientID = -1;
m_GameInfo.m_NumPlayers = 0;
m_GameInfo.m_aTeamSize[TEAM_RED] = m_GameInfo.m_aTeamSize[TEAM_BLUE] = 0;
mem_zero(&m_GameInfo, sizeof(m_GameInfo));
m_DemoSpecID = SPEC_FREEVIEW;
m_Tuning = CTuningParams();
}
@ -468,8 +467,9 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
return;
}
else if(MsgId == NETMSGTYPE_SV_TUNEPARAMS)
else if(MsgId == NETMSGTYPE_SV_TUNEPARAMS && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{
Client()->RecordGameMessage(false);
// unpack the new tuning
CTuningParams NewTuning;
int *pParams = (int *)&NewTuning;
@ -484,7 +484,6 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
// apply new tuning
m_Tuning = NewTuning;
Client()->RecordGameMessage(false);
return;
}
@ -501,10 +500,10 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
for(int i = 0; i < m_All.m_Num; i++)
m_All.m_paComponents[i]->OnMessage(MsgId, pRawMsg);
if(MsgId == NETMSGTYPE_SV_CLIENTINFO)
if(MsgId == NETMSGTYPE_SV_CLIENTINFO && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{
CNetMsg_Sv_ClientInfo *pMsg = (CNetMsg_Sv_ClientInfo *)pRawMsg;
Client()->RecordGameMessage(false);
CNetMsg_Sv_ClientInfo *pMsg = (CNetMsg_Sv_ClientInfo *)pRawMsg;
if(pMsg->m_Local)
{
@ -530,6 +529,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
char aBuf[128];
str_format(aBuf, sizeof(aBuf), Localize("'%s' entered and joined the %s"), pMsg->m_pName, GetTeamName(pMsg->m_Team, m_GameInfo.m_GameFlags&GAMEFLAG_TEAMS));
m_pChat->AddLine(-1, 0, aBuf);
//todo record msg
}
}
@ -555,8 +555,9 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
if(m_aClients[pMsg->m_ClientID].m_Team != TEAM_SPECTATORS)
m_GameInfo.m_aTeamSize[m_aClients[pMsg->m_ClientID].m_Team]++;
}
else if(MsgId == NETMSGTYPE_SV_CLIENTDROP)
else if(MsgId == NETMSGTYPE_SV_CLIENTDROP && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{
Client()->RecordGameMessage(false);
CNetMsg_Sv_ClientDrop *pMsg = (CNetMsg_Sv_ClientDrop *)pRawMsg;
if(m_LocalClientID == pMsg->m_ClientID || !m_aClients[pMsg->m_ClientID].m_Active)
@ -580,8 +581,9 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
m_aClients[pMsg->m_ClientID].Reset();
}
else if(MsgId == NETMSGTYPE_SV_GAMEINFO)
else if(MsgId == NETMSGTYPE_SV_GAMEINFO && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{
Client()->RecordGameMessage(false);
CNetMsg_Sv_GameInfo *pMsg = (CNetMsg_Sv_GameInfo *)pRawMsg;
m_GameInfo.m_GameFlags = pMsg->m_GameFlags;
@ -589,11 +591,10 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
m_GameInfo.m_TimeLimit = pMsg->m_TimeLimit;
m_GameInfo.m_MatchNum = pMsg->m_MatchNum;
m_GameInfo.m_MatchCurrent = pMsg->m_MatchCurrent;
Client()->RecordGameMessage(false);
}
else if(MsgId == NETMSGTYPE_SV_TEAM)
else if(MsgId == NETMSGTYPE_SV_TEAM && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{
Client()->RecordGameMessage(false);
CNetMsg_Sv_Team *pMsg = (CNetMsg_Sv_Team *)pRawMsg;
// calculate team-balance
if(m_aClients[pMsg->m_ClientID].m_Team != TEAM_SPECTATORS)
@ -609,8 +610,6 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
}
m_aClients[pMsg->m_ClientID].UpdateRenderInfo(false);
Client()->RecordGameMessage(false);
}
else if(MsgId == NETMSGTYPE_SV_READYTOENTER)
{
@ -766,6 +765,7 @@ void CGameClient::OnNewSnapshot()
if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
{
m_Tuning = StandardTuning;
mem_zero(&m_GameInfo, sizeof(m_GameInfo));
}
// go trough all the items in the snapshot and gather the info we want
@ -787,6 +787,7 @@ void CGameClient::OnNewSnapshot()
if(pInfo->m_Local)
m_LocalClientID = ClientID;
pClient->m_Active = true;
pClient->m_Team = pInfo->m_Team;
IntsToStr(pInfo->m_aName, 4, pClient->m_aName);
IntsToStr(pInfo->m_aClan, 3, pClient->m_aClan);
@ -799,7 +800,20 @@ void CGameClient::OnNewSnapshot()
pClient->m_aSkinPartColors[p] = pInfo->m_aSkinPartColors[p];
}
pClient->UpdateRenderInfo(true);
m_GameInfo.m_NumPlayers++;
// calculate team-balance
if(pClient->m_Team != TEAM_SPECTATORS)
m_GameInfo.m_aTeamSize[pClient->m_Team]++;
}
else if(Item.m_Type == NETOBJTYPE_DE_GAMEINFO)
{
const CNetObj_De_GameInfo *pInfo = (const CNetObj_De_GameInfo *)pData;
m_GameInfo.m_GameFlags = pInfo->m_GameFlags;
m_GameInfo.m_ScoreLimit = pInfo->m_ScoreLimit;
m_GameInfo.m_TimeLimit = pInfo->m_TimeLimit;
m_GameInfo.m_MatchNum = pInfo->m_MatchNum;
m_GameInfo.m_MatchCurrent = pInfo->m_MatchCurrent;
}
else if(Item.m_Type == NETOBJTYPE_DE_TUNEPARAMS)
{
@ -942,6 +956,15 @@ void CGameClient::OnNewSnapshot()
m_Snap.m_AliveCount[m_aClients[i].m_Team]++;
}
if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
{
for(int i = 0; i < MAX_CLIENTS; ++i)
{
if(m_aClients[i].m_Active)
m_aClients[i].UpdateRenderInfo(true);
}
}
CServerInfo CurrentServerInfo;
Client()->GetServerInfo(&CurrentServerInfo);
if(CurrentServerInfo.m_aGameType[0] != '0')
@ -968,6 +991,8 @@ void CGameClient::OnDemoRecSnap()
if(!pClientInfo)
return;
pClientInfo->m_Local = i==m_LocalClientID ? 1 : 0;
pClientInfo->m_Team = m_aClients[i].m_Team;
StrToInts(pClientInfo->m_aName, 4, m_aClients[i].m_aName);
StrToInts(pClientInfo->m_aClan, 3, m_aClients[i].m_aClan);
pClientInfo->m_Country = m_aClients[i].m_Country;

View file

@ -588,11 +588,12 @@ void CGameContext::OnClientEnter(int ClientID)
for(int i = 0; i < MAX_CLIENTS; ++i)
{
if(i == ClientID || !m_apPlayers[i] || !Server()->ClientIngame(i))
if(i == ClientID || !m_apPlayers[i] || (!Server()->ClientIngame(i) && !m_apPlayers[i]->IsDummy()))
continue;
// new info for others
Server()->SendPackMsg(&NewClientInfoMsg, MSGFLAG_VITAL|MSGFLAG_NORECORD, i);
if(Server()->ClientIngame(i))
Server()->SendPackMsg(&NewClientInfoMsg, MSGFLAG_VITAL|MSGFLAG_NORECORD, i);
// existing infos for new player
CNetMsg_Sv_ClientInfo ClientInfoMsg;
@ -650,7 +651,7 @@ void CGameContext::OnClientDrop(int ClientID, const char *pReason)
CNetMsg_Sv_ClientDrop Msg;
Msg.m_ClientID = ClientID;
Msg.m_pReason = pReason;
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1);
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_NORECORD, -1);
m_VoteUpdate = true;
}