mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-17 13:38:18 +00:00
Merge pull request #9140 from Robyt3/Server-Demos-Filename-Fix
Fix server-side demos with maps in folders, make `CServer::GetMapName` function more efficient by caching
This commit is contained in:
commit
0d76b482ee
|
@ -246,6 +246,7 @@ CServer::CServer()
|
|||
m_SameMapReload = false;
|
||||
m_ReloadedWhenEmpty = false;
|
||||
m_aCurrentMap[0] = '\0';
|
||||
m_pCurrentMapName = m_aCurrentMap;
|
||||
|
||||
m_RconClientId = IServer::RCON_CID_SERV;
|
||||
m_RconAuthLevel = AUTHED_ADMIN;
|
||||
|
@ -2541,14 +2542,7 @@ void CServer::PumpNetwork(bool PacketWaiting)
|
|||
|
||||
const char *CServer::GetMapName() const
|
||||
{
|
||||
// get the name of the map without his path
|
||||
const char *pMapShortName = &Config()->m_SvMap[0];
|
||||
for(int i = 0; i < str_length(Config()->m_SvMap) - 1; i++)
|
||||
{
|
||||
if(Config()->m_SvMap[i] == '/' || Config()->m_SvMap[i] == '\\')
|
||||
pMapShortName = &Config()->m_SvMap[i + 1];
|
||||
}
|
||||
return pMapShortName;
|
||||
return m_pCurrentMapName;
|
||||
}
|
||||
|
||||
void CServer::ChangeMap(const char *pMap)
|
||||
|
@ -2587,6 +2581,7 @@ int CServer::LoadMap(const char *pMapName)
|
|||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBufMsg);
|
||||
|
||||
str_copy(m_aCurrentMap, pMapName);
|
||||
m_pCurrentMapName = fs_filename(m_aCurrentMap);
|
||||
|
||||
// load complete map into memory for download
|
||||
{
|
||||
|
@ -3398,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",
|
||||
|
@ -3428,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);
|
||||
}
|
||||
}
|
||||
|
@ -3438,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",
|
||||
|
@ -3506,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",
|
||||
|
|
|
@ -242,6 +242,7 @@ public:
|
|||
};
|
||||
|
||||
char m_aCurrentMap[IO_MAX_PATH_LENGTH];
|
||||
const char *m_pCurrentMapName;
|
||||
SHA256_DIGEST m_aCurrentMapSha256[NUM_MAP_TYPES];
|
||||
unsigned m_aCurrentMapCrc[NUM_MAP_TYPES];
|
||||
unsigned char *m_apCurrentMapData[NUM_MAP_TYPES];
|
||||
|
|
Loading…
Reference in a new issue