mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Record player switch in teehistorian
This commit is contained in:
parent
416af01e0a
commit
86f57289c6
|
@ -8,6 +8,7 @@ UUID(TEEHISTORIAN_AUTH_LOGIN, "teehistorian-auth-login@ddnet.tw")
|
|||
UUID(TEEHISTORIAN_AUTH_LOGOUT, "teehistorian-auth-logout@ddnet.tw")
|
||||
UUID(TEEHISTORIAN_JOINVER6, "teehistorian-joinver6@ddnet.tw")
|
||||
UUID(TEEHISTORIAN_JOINVER7, "teehistorian-joinver7@ddnet.tw")
|
||||
UUID(TEEHISTORIAN_PLAYER_SWITCH, "teehistorian-player-swap@ddnet.tw")
|
||||
UUID(TEEHISTORIAN_SAVE_SUCCESS, "teehistorian-save-success@ddnet.tw")
|
||||
UUID(TEEHISTORIAN_SAVE_FAILURE, "teehistorian-save-failure@ddnet.tw")
|
||||
UUID(TEEHISTORIAN_LOAD_SUCCESS, "teehistorian-load-success@ddnet.tw")
|
||||
|
|
|
@ -908,6 +908,8 @@ void CGameTeams::SwapTeamCharacters(CPlayer *pPlayer, CPlayer *pTargetPlayer, in
|
|||
|
||||
GameServer()->m_World.SwapClients(pPlayer->GetCID(), pTargetPlayer->GetCID());
|
||||
|
||||
GameServer()->TeeHistorian()->RecordPlayerSwap(pPlayer->GetCID(), pTargetPlayer->GetCID());
|
||||
|
||||
str_format(aBuf, sizeof(aBuf),
|
||||
"%s has swapped with %s.",
|
||||
Server()->ClientName(pPlayer->GetCID()), Server()->ClientName(pTargetPlayer->GetCID()));
|
||||
|
|
|
@ -576,6 +576,18 @@ void CTeeHistorian::RecordTestExtra()
|
|||
WriteExtra(UUID_TEEHISTORIAN_TEST, "", 0);
|
||||
}
|
||||
|
||||
void CTeeHistorian::RecordPlayerSwap(int ClientID1, int ClientID2)
|
||||
{
|
||||
EnsureTickWritten();
|
||||
|
||||
CPacker Buffer;
|
||||
Buffer.Reset();
|
||||
Buffer.AddInt(ClientID1);
|
||||
Buffer.AddInt(ClientID2);
|
||||
|
||||
WriteExtra(UUID_TEEHISTORIAN_PLAYER_SWITCH, Buffer.Data(), Buffer.Size());
|
||||
}
|
||||
|
||||
void CTeeHistorian::RecordTeamSaveSuccess(int Team, CUuid SaveID, const char *pTeamSave)
|
||||
{
|
||||
EnsureTickWritten();
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
void RecordPlayerDrop(int ClientID, const char *pReason);
|
||||
void RecordConsoleCommand(int ClientID, int FlagMask, const char *pCmd, IConsole::IResult *pResult);
|
||||
void RecordTestExtra();
|
||||
void RecordPlayerSwap(int ClientID1, int ClientID2);
|
||||
void RecordTeamSaveSuccess(int Team, CUuid SaveID, const char *pTeamSave);
|
||||
void RecordTeamSaveFailure(int Team);
|
||||
void RecordTeamLoadSuccess(int Team, CUuid SaveID, const char *pTeamSave);
|
||||
|
|
|
@ -592,6 +592,29 @@ TEST_F(TeeHistorian, LoadFailed)
|
|||
Expect(EXPECTED, sizeof(EXPECTED));
|
||||
}
|
||||
|
||||
TEST_F(TeeHistorian, PlayerSwap)
|
||||
{
|
||||
const unsigned char EXPECTED[] = {
|
||||
// TICK_SKIP dt=0
|
||||
0x41, 0x00,
|
||||
// EX uuid=5de9b633-49cf-3e99-9a25-d4a78e9717d7 datalen=2
|
||||
0x4a,
|
||||
0x5d, 0xe9, 0xb6, 0x33, 0x49, 0xcf, 0x3e, 0x99,
|
||||
0x9a, 0x25, 0xd4, 0xa7, 0x8e, 0x97, 0x17, 0xd7,
|
||||
0x02,
|
||||
// playerId1=11
|
||||
0x0b,
|
||||
// playerId2=21
|
||||
0x15,
|
||||
// FINISH
|
||||
0x40};
|
||||
Tick(1);
|
||||
m_TH.RecordPlayerSwap(11, 21);
|
||||
Finish();
|
||||
|
||||
Expect(EXPECTED, sizeof(EXPECTED));
|
||||
}
|
||||
|
||||
TEST_F(TeeHistorian, PlayerTeam)
|
||||
{
|
||||
const unsigned char EXPECTED[] = {
|
||||
|
|
Loading…
Reference in a new issue