teehistorian: Test statefulness of PLAYER_TEAM and TEAM_PRACTICE

This commit is contained in:
heinrich5991 2021-10-06 18:06:19 +02:00
parent fbb98c8801
commit 1bffc6ebfc
2 changed files with 54 additions and 10 deletions

View file

@ -332,7 +332,7 @@ void CTeeHistorian::RecordPlayerTeam(int ClientID, int Team)
if(m_Debug)
{
dbg_msg("teehistorian", "team_change cid=%d team=%d", ClientID, Team);
dbg_msg("teehistorian", "player_team cid=%d team=%d", ClientID, Team);
}
WriteExtra(UUID_TEEHISTORIAN_PLAYER_TEAM, Buffer.Data(), Buffer.Size());
@ -354,7 +354,7 @@ void CTeeHistorian::RecordTeamPractice(int Team, bool Practice)
if(m_Debug)
{
dbg_msg("teehistorian", "team_rescue team=%d practice=%d", Team, Practice);
dbg_msg("teehistorian", "team_practice team=%d practice=%d", Team, Practice);
}
WriteExtra(UUID_TEEHISTORIAN_TEAM_PRACTICE, Buffer.Data(), Buffer.Size());

View file

@ -536,20 +536,42 @@ TEST_F(TeeHistorian, LoadFailed)
TEST_F(TeeHistorian, PlayerTeam)
{
const unsigned char EXPECTED[] = {
// TICK_SKIP dt=0
0x41, 0x00,
// EX uuid=a111c04e-1ea8-38e0-90b1-d7f993ca0da9 datalen=2
0x4a,
0xa1, 0x11, 0xc0, 0x4e, 0x1e, 0xa8, 0x38, 0xe0,
0x90, 0xb1, 0xd7, 0xf9, 0x93, 0xca, 0x0d, 0xa9,
0x02,
// player_id=33
0x21,
// team=54
0x36,
// (PLAYER_TEAM) cid=33 team=54
0x21, 0x36,
// TICK_SKIP dt=0
0x41, 0x00,
// EX uuid=a111c04e-1ea8-38e0-90b1-d7f993ca0da9 datalen=2
0x4a,
0xa1, 0x11, 0xc0, 0x4e, 0x1e, 0xa8, 0x38, 0xe0,
0x90, 0xb1, 0xd7, 0xf9, 0x93, 0xca, 0x0d, 0xa9,
0x02,
// (PLAYER_TEAM) cid=3 team=12
0x03, 0x0c,
// EX uuid=a111c04e-1ea8-38e0-90b1-d7f993ca0da9 datalen=2
0x4a,
0xa1, 0x11, 0xc0, 0x4e, 0x1e, 0xa8, 0x38, 0xe0,
0x90, 0xb1, 0xd7, 0xf9, 0x93, 0xca, 0x0d, 0xa9,
0x02,
// (PLAYER_TEAM) cid=33 team=0
0x21, 0x00,
// FINISH
0x40};
Tick(1);
m_TH.RecordPlayerTeam(3, 0);
m_TH.RecordPlayerTeam(33, 54);
m_TH.RecordPlayerTeam(45, 0);
Tick(2);
m_TH.RecordPlayerTeam(3, 12);
m_TH.RecordPlayerTeam(33, 0);
m_TH.RecordPlayerTeam(45, 0);
Finish();
Expect(EXPECTED, sizeof(EXPECTED));
}
@ -557,20 +579,42 @@ TEST_F(TeeHistorian, PlayerTeam)
TEST_F(TeeHistorian, TeamPractice)
{
const unsigned char EXPECTED[] = {
// TICK_SKIP dt=0
0x41, 0x00,
// EX uuid=5792834e-81d1-34c9-a29b-b5ff25dac3bc datalen=2
0x4a,
0x57, 0x92, 0x83, 0x4e, 0x81, 0xd1, 0x34, 0xc9,
0xa2, 0x9b, 0xb5, 0xff, 0x25, 0xda, 0xc3, 0xbc,
0x02,
// team=23
0x17,
// practice=1
0x01,
// (TEAM_PRACTICE) team=23 practice=1
0x17, 0x01,
// TICK_SKIP dt=0
0x41, 0x00,
// EX uuid=5792834e-81d1-34c9-a29b-b5ff25dac3bc datalen=2
0x4a,
0x57, 0x92, 0x83, 0x4e, 0x81, 0xd1, 0x34, 0xc9,
0xa2, 0x9b, 0xb5, 0xff, 0x25, 0xda, 0xc3, 0xbc,
0x02,
// (TEAM_PRACTICE) team=1 practice=1
0x01, 0x01,
// EX uuid=5792834e-81d1-34c9-a29b-b5ff25dac3bc datalen=2
0x4a,
0x57, 0x92, 0x83, 0x4e, 0x81, 0xd1, 0x34, 0xc9,
0xa2, 0x9b, 0xb5, 0xff, 0x25, 0xda, 0xc3, 0xbc,
0x02,
// (TEAM_PRACTICE) team=23 practice=0
0x17, 0x00,
// FINISH
0x40};
Tick(1);
m_TH.RecordTeamPractice(1, 0);
m_TH.RecordTeamPractice(16, 0);
m_TH.RecordTeamPractice(23, 1);
Tick(2);
m_TH.RecordTeamPractice(1, 1);
m_TH.RecordTeamPractice(16, 0);
m_TH.RecordTeamPractice(23, 0);
Finish();
Expect(EXPECTED, sizeof(EXPECTED));
}