Record tee position at the end of the tick

priviously spawning players were recorded one tick too late
and add teehistorian minor version for the validator to recognize the
change
This commit is contained in:
Zwelf 2021-08-14 12:40:11 +02:00
parent 1ee4f0117c
commit 6c452c15cf
3 changed files with 41 additions and 21 deletions

View file

@ -793,25 +793,6 @@ void CGameContext::OnTick()
//if(world.paused) // make sure that the game object always updates
m_pController->Tick();
if(m_TeeHistorianActive)
{
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(m_apPlayers[i] && m_apPlayers[i]->GetCharacter())
{
CNetObj_CharacterCore Char;
m_apPlayers[i]->GetCharacter()->GetCore().Write(&Char);
m_TeeHistorian.RecordPlayer(i, &Char);
}
else
{
m_TeeHistorian.RecordDeadPlayer(i);
}
}
m_TeeHistorian.EndPlayers();
m_TeeHistorian.BeginInputs();
}
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(m_apPlayers[i])
@ -1072,6 +1053,27 @@ void CGameContext::OnTick()
}
}
#endif
// Record player position at the end of the tick
if(m_TeeHistorianActive)
{
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(m_apPlayers[i] && m_apPlayers[i]->GetCharacter())
{
CNetObj_CharacterCore Char;
m_apPlayers[i]->GetCharacter()->GetCore().Write(&Char);
m_TeeHistorian.RecordPlayer(i, &Char);
}
else
{
m_TeeHistorian.RecordDeadPlayer(i);
}
}
m_TeeHistorian.EndPlayers();
m_TeeHistorian.BeginInputs();
}
// Warning: do not put code in this function directly above or below this comment
}
// Server hooks

View file

@ -8,6 +8,7 @@
static const char TEEHISTORIAN_NAME[] = "teehistorian@ddnet.tw";
static const CUuid TEEHISTORIAN_UUID = CalculateUuid(TEEHISTORIAN_NAME);
static const char TEEHISTORIAN_VERSION[] = "2";
static const char TEEHISTORIAN_VERSION_MINOR[] = "2";
#define UUID(id, name) static const CUuid UUID_##id = CalculateUuid(name);
#include <engine/shared/teehistorian_ex_chunks.h>
@ -86,9 +87,26 @@ void CTeeHistorian::WriteHeader(const CGameInfo *pGameInfo)
#define E(buf, str) EscapeJson(buf, sizeof(buf), str)
str_format(aJson, sizeof(aJson), "{\"comment\":\"%s\",\"version\":\"%s\",\"game_uuid\":\"%s\",\"server_version\":\"%s\",\"start_time\":\"%s\",\"server_name\":\"%s\",\"server_port\":\"%d\",\"game_type\":\"%s\",\"map_name\":\"%s\",\"map_size\":\"%d\",\"map_sha256\":\"%s\",\"map_crc\":\"%08x\",\"prng_description\":\"%s\",\"config\":{",
str_format(aJson, sizeof(aJson),
"{"
"\"comment\":\"%s\","
"\"version\":\"%s\","
"\"minor_version\":\"%s\","
"\"game_uuid\":\"%s\","
"\"server_version\":\"%s\","
"\"start_time\":\"%s\","
"\"server_name\":\"%s\","
"\"server_port\":\"%d\","
"\"game_type\":\"%s\","
"\"map_name\":\"%s\","
"\"map_size\":\"%d\","
"\"map_sha256\":\"%s\","
"\"map_crc\":\"%08x\","
"\"prng_description\":\"%s\","
"\"config\":{",
E(aCommentBuffer, TEEHISTORIAN_NAME),
TEEHISTORIAN_VERSION,
TEEHISTORIAN_VERSION_MINOR,
aGameUuid,
E(aServerVersionBuffer, pGameInfo->m_pServerVersion),
E(aStartTimeBuffer, aStartTime),

View file

@ -89,7 +89,7 @@ protected:
void Expect(const unsigned char *pOutput, int OutputSize)
{
static CUuid TEEHISTORIAN_UUID = CalculateUuid("teehistorian@ddnet.tw");
static const char PREFIX1[] = "{\"comment\":\"teehistorian@ddnet.tw\",\"version\":\"2\",\"game_uuid\":\"a1eb7182-796e-3b3e-941d-38ca71b2a4a8\",\"server_version\":\"DDNet test\",\"start_time\":\"";
static const char PREFIX1[] = "{\"comment\":\"teehistorian@ddnet.tw\",\"version\":\"2\",\"minor_version\":\"2\",\"game_uuid\":\"a1eb7182-796e-3b3e-941d-38ca71b2a4a8\",\"server_version\":\"DDNet test\",\"start_time\":\"";
static const char PREFIX2[] = "\",\"server_name\":\"server name\",\"server_port\":\"8303\",\"game_type\":\"game type\",\"map_name\":\"Kobra 3 Solo\",\"map_size\":\"903514\",\"map_sha256\":\"0123456789012345678901234567890123456789012345678901234567890123\",\"map_crc\":\"eceaf25c\",\"prng_description\":\"test-prng:02468ace\",\"config\":{},\"tuning\":{},\"uuids\":[";
static const char PREFIX3[] = "]}";