Skip to content

Commit

Permalink
Fix server-side demos with maps in folders
Browse files Browse the repository at this point in the history
When maps are loaded from folders on the server, the same folders were used for demos but recording would usually fail due to the folders not existing in the demos folder.

Furthermore, the map name being written in the demo header also included the folder names, which causes the client to not find the map unless it also exists at that location.

Closes ddnet#9033.
  • Loading branch information
Robyt3 committed Oct 11, 2024
1 parent e24b87a commit ab60d0b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/engine/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3393,13 +3393,13 @@ void CServer::DemoRecorder_HandleAutoStart()
char aTimestamp[20];
str_timestamp(aTimestamp, sizeof(aTimestamp));
char aFilename[IO_MAX_PATH_LENGTH];
str_format(aFilename, sizeof(aFilename), "demos/auto/server/%s_%s.demo", m_aCurrentMap, aTimestamp);
str_format(aFilename, sizeof(aFilename), "demos/auto/server/%s_%s.demo", GetMapName(), aTimestamp);
m_aDemoRecorder[RECORDER_AUTO].Start(
Storage(),
m_pConsole,
aFilename,
GameServer()->NetVersion(),
m_aCurrentMap,
GetMapName(),
m_aCurrentMapSha256[MAP_TYPE_SIX],
m_aCurrentMapCrc[MAP_TYPE_SIX],
"server",
Expand All @@ -3423,7 +3423,7 @@ void CServer::SaveDemo(int ClientId, float Time)
if(IsRecording(ClientId))
{
char aNewFilename[IO_MAX_PATH_LENGTH];
str_format(aNewFilename, sizeof(aNewFilename), "demos/%s_%s_%05.2f.demo", m_aCurrentMap, m_aClients[ClientId].m_aName, Time);
str_format(aNewFilename, sizeof(aNewFilename), "demos/%s_%s_%05.2f.demo", GetMapName(), m_aClients[ClientId].m_aName, Time);
m_aDemoRecorder[ClientId].Stop(IDemoRecorder::EStopMode::KEEP_FILE, aNewFilename);
}
}
Expand All @@ -3433,13 +3433,13 @@ void CServer::StartRecord(int ClientId)
if(Config()->m_SvPlayerDemoRecord)
{
char aFilename[IO_MAX_PATH_LENGTH];
str_format(aFilename, sizeof(aFilename), "demos/%s_%d_%d_tmp.demo", m_aCurrentMap, m_NetServer.Address().port, ClientId);
str_format(aFilename, sizeof(aFilename), "demos/%s_%d_%d_tmp.demo", GetMapName(), m_NetServer.Address().port, ClientId);
m_aDemoRecorder[ClientId].Start(
Storage(),
Console(),
aFilename,
GameServer()->NetVersion(),
m_aCurrentMap,
GetMapName(),
m_aCurrentMapSha256[MAP_TYPE_SIX],
m_aCurrentMapCrc[MAP_TYPE_SIX],
"server",
Expand Down Expand Up @@ -3501,7 +3501,7 @@ void CServer::ConRecord(IConsole::IResult *pResult, void *pUser)
pServer->Console(),
aFilename,
pServer->GameServer()->NetVersion(),
pServer->m_aCurrentMap,
pServer->GetMapName(),
pServer->m_aCurrentMapSha256[MAP_TYPE_SIX],
pServer->m_aCurrentMapCrc[MAP_TYPE_SIX],
"server",
Expand Down

0 comments on commit ab60d0b

Please sign in to comment.