mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Record player name in Teehistorian files
This commit is contained in:
parent
2e211c9a31
commit
783f4e3093
|
@ -356,6 +356,7 @@ public:
|
|||
virtual void TeehistorianRecordPlayerJoin(int ClientId, bool Sixup) = 0;
|
||||
virtual void TeehistorianRecordPlayerDrop(int ClientId, const char *pReason) = 0;
|
||||
virtual void TeehistorianRecordPlayerRejoin(int ClientId) = 0;
|
||||
virtual void TeehistorianRecordPlayerName(int ClientId, const char *pName) = 0;
|
||||
|
||||
virtual void FillAntibot(CAntibotRoundData *pData) = 0;
|
||||
|
||||
|
|
|
@ -354,10 +354,11 @@ bool CServer::SetClientNameImpl(int ClientId, const char *pNameRequest, bool Set
|
|||
|
||||
bool Changed = str_comp(m_aClients[ClientId].m_aName, aNameTry) != 0;
|
||||
|
||||
if(Set)
|
||||
if(Set && Changed)
|
||||
{
|
||||
// set the client name
|
||||
str_copy(m_aClients[ClientId].m_aName, aNameTry);
|
||||
GameServer()->TeehistorianRecordPlayerName(ClientId, m_aClients[ClientId].m_aName);
|
||||
}
|
||||
|
||||
return Changed;
|
||||
|
|
|
@ -18,3 +18,4 @@ UUID(TEEHISTORIAN_TEAM_PRACTICE, "teehistorian-team-practice@ddnet.tw")
|
|||
UUID(TEEHISTORIAN_PLAYER_READY, "teehistorian-player-ready@ddnet.tw")
|
||||
UUID(TEEHISTORIAN_PLAYER_REJOIN, "teehistorian-rejoinver6@ddnet.org")
|
||||
UUID(TEEHISTORIAN_ANTIBOT, "teehistorian-antibot@ddnet.org")
|
||||
UUID(TEEHISTORIAN_PLAYER_NAME, "teehistorian-player-name@ddnet.org")
|
||||
|
|
|
@ -1767,6 +1767,14 @@ void CGameContext::TeehistorianRecordPlayerRejoin(int ClientId)
|
|||
}
|
||||
}
|
||||
|
||||
void CGameContext::TeehistorianRecordPlayerName(int ClientId, const char *pName)
|
||||
{
|
||||
if(m_TeeHistorianActive)
|
||||
{
|
||||
m_TeeHistorian.RecordPlayerName(ClientId, pName);
|
||||
}
|
||||
}
|
||||
|
||||
bool CGameContext::OnClientDDNetVersionKnown(int ClientId)
|
||||
{
|
||||
IServer::CClientInfo Info;
|
||||
|
|
|
@ -328,6 +328,7 @@ public:
|
|||
void TeehistorianRecordPlayerJoin(int ClientId, bool Sixup) override;
|
||||
void TeehistorianRecordPlayerDrop(int ClientId, const char *pReason) override;
|
||||
void TeehistorianRecordPlayerRejoin(int ClientId) override;
|
||||
void TeehistorianRecordPlayerName(int ClientId, const char *pName) override;
|
||||
|
||||
bool IsClientReady(int ClientId) const override;
|
||||
bool IsClientPlayer(int ClientId) const override;
|
||||
|
|
|
@ -573,6 +573,23 @@ void CTeeHistorian::RecordPlayerDrop(int ClientId, const char *pReason)
|
|||
Write(Buffer.Data(), Buffer.Size());
|
||||
}
|
||||
|
||||
void CTeeHistorian::RecordPlayerName(int ClientId, const char *pName)
|
||||
{
|
||||
EnsureTickWritten();
|
||||
|
||||
CPacker Buffer;
|
||||
Buffer.Reset();
|
||||
Buffer.AddInt(ClientId);
|
||||
Buffer.AddString(pName, 0);
|
||||
|
||||
if(m_Debug)
|
||||
{
|
||||
dbg_msg("teehistorian", "drop cid=%d reason='%s'", ClientId, pName);
|
||||
}
|
||||
|
||||
WriteExtra(UUID_TEEHISTORIAN_PLAYER_NAME, Buffer.Data(), Buffer.Size());
|
||||
}
|
||||
|
||||
void CTeeHistorian::RecordConsoleCommand(int ClientId, int FlagMask, const char *pCmd, IConsole::IResult *pResult)
|
||||
{
|
||||
EnsureTickWritten();
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
void RecordPlayerRejoin(int ClientId);
|
||||
void RecordPlayerReady(int ClientId);
|
||||
void RecordPlayerDrop(int ClientId, const char *pReason);
|
||||
void RecordPlayerName(int ClientId, const char *pName);
|
||||
void RecordConsoleCommand(int ClientId, int FlagMask, const char *pCmd, IConsole::IResult *pResult);
|
||||
void RecordTestExtra();
|
||||
void RecordPlayerSwap(int ClientId1, int ClientId2);
|
||||
|
|
|
@ -838,6 +838,24 @@ TEST_F(TeeHistorian, AntibotEmptyMessage)
|
|||
Expect(EXPECTED, sizeof(EXPECTED));
|
||||
}
|
||||
|
||||
TEST_F(TeeHistorian, PlayerName)
|
||||
{
|
||||
const unsigned char EXPECTED[] = {
|
||||
// EX uuid=d016f9b9-4151-3b87-87e5-3a6087eb5f26 datalen=4
|
||||
0x4a,
|
||||
0xd0, 0x16, 0xf9, 0xb9, 0x41, 0x51, 0x3b, 0x87,
|
||||
0x87, 0xe5, 0x3a, 0x60, 0x87, 0xeb, 0x5f, 0x26,
|
||||
0x0e,
|
||||
// (PLAYER_NAME) id=21 name="nameless tee"
|
||||
0x15,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x6c, 0x65, 0x73, 0x73,
|
||||
0x20, 0x74, 0x65, 0x65
|
||||
};
|
||||
|
||||
m_TH.RecordPlayerName(21, "nameless tee");
|
||||
Expect(EXPECTED, sizeof(EXPECTED));
|
||||
}
|
||||
|
||||
TEST_F(TeeHistorian, PrevGameUuid)
|
||||
{
|
||||
m_GameInfo.m_HavePrevGameUuid = true;
|
||||
|
|
Loading…
Reference in a new issue