mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Don't open map file again if we have it open already
This commit is contained in:
parent
42b07441a5
commit
35dcb4d6cf
|
@ -3250,7 +3250,7 @@ void CClient::DemoRecorder_Start(const char *pFilename, bool WithTimestamp, int
|
|||
}
|
||||
else
|
||||
str_format(aFilename, sizeof(aFilename), "demos/%s.demo", pFilename);
|
||||
m_DemoRecorder[Recorder].Start(Storage(), m_pConsole, aFilename, GameClient()->NetVersion(), m_aCurrentMap, m_pMap->Crc(), "client", m_pMap->MapSize(), NULL);
|
||||
m_DemoRecorder[Recorder].Start(Storage(), m_pConsole, aFilename, GameClient()->NetVersion(), m_aCurrentMap, m_pMap->Crc(), "client", m_pMap->MapSize(), 0, m_pMap->File());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3660,7 +3660,7 @@ const char* CClient::RaceRecordStart(const char *pFilename)
|
|||
if(State() != STATE_ONLINE)
|
||||
dbg_msg("demorec/record", "client is not online");
|
||||
else
|
||||
m_DemoRecorder[RECORDER_RACE].Start(Storage(), m_pConsole, aFilename, GameClient()->NetVersion(), m_aCurrentMap, m_pMap->Crc(), "client", m_pMap->MapSize(), NULL);
|
||||
m_DemoRecorder[RECORDER_RACE].Start(Storage(), m_pConsole, aFilename, GameClient()->NetVersion(), m_aCurrentMap, m_pMap->Crc(), "client", m_pMap->MapSize(), 0, m_pMap->File());
|
||||
|
||||
return m_aCurrentMap;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
virtual void Unload() = 0;
|
||||
virtual unsigned Crc() = 0;
|
||||
virtual int MapSize() = 0;
|
||||
virtual IOHANDLE File() = 0;
|
||||
};
|
||||
|
||||
extern IEngineMap *CreateEngineMap();
|
||||
|
|
|
@ -443,6 +443,12 @@ int CDataFileReader::MapSize()
|
|||
return m_pDataFile->m_Header.m_Size + 16;
|
||||
}
|
||||
|
||||
IOHANDLE CDataFileReader::File()
|
||||
{
|
||||
if(!m_pDataFile) return 0;
|
||||
return m_pDataFile->m_File;
|
||||
}
|
||||
|
||||
|
||||
CDataFileWriter::CDataFileWriter()
|
||||
{
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
|
||||
unsigned Crc();
|
||||
int MapSize();
|
||||
IOHANDLE File();
|
||||
};
|
||||
|
||||
// write access
|
||||
|
|
|
@ -33,7 +33,7 @@ CDemoRecorder::CDemoRecorder(class CSnapshotDelta *pSnapshotDelta, bool NoMapDat
|
|||
}
|
||||
|
||||
// Record
|
||||
int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename, const char *pNetVersion, const char *pMap, unsigned Crc, const char *pType, unsigned int MapSize, unsigned char *pMapData, DEMOFUNC_FILTER pfnFilter, void *pUser)
|
||||
int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename, const char *pNetVersion, const char *pMap, unsigned Crc, const char *pType, unsigned int MapSize, unsigned char *pMapData, IOHANDLE MapFile, DEMOFUNC_FILTER pfnFilter, void *pUser)
|
||||
{
|
||||
m_pfnFilter = pfnFilter;
|
||||
m_pUser = pUser;
|
||||
|
@ -59,9 +59,12 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con
|
|||
|
||||
m_pConsole = pConsole;
|
||||
|
||||
IOHANDLE MapFile = NULL;
|
||||
bool CloseMapFile = false;
|
||||
|
||||
if(!pMapData)
|
||||
if(MapFile)
|
||||
io_seek(MapFile, 0, IOSEEK_START);
|
||||
|
||||
if(!pMapData && !MapFile)
|
||||
{
|
||||
// open mapfile
|
||||
char aMapFilename[128];
|
||||
|
@ -89,6 +92,8 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con
|
|||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", aBuf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
CloseMapFile = true;
|
||||
}
|
||||
|
||||
// write header
|
||||
|
@ -129,7 +134,10 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con
|
|||
break;
|
||||
io_write(DemoFile, &aChunk, Bytes);
|
||||
}
|
||||
io_close(MapFile);
|
||||
if(CloseMapFile)
|
||||
io_close(MapFile);
|
||||
else
|
||||
io_seek(MapFile, 0, IOSEEK_START);
|
||||
}
|
||||
|
||||
m_LastKeyFrame = -1;
|
||||
|
@ -950,7 +958,7 @@ void CDemoEditor::Slice(const char *pDemo, const char *pDst, int StartTick, int
|
|||
return;
|
||||
|
||||
const CDemoPlayer::CMapInfo *pMapInfo = m_pDemoPlayer->GetMapInfo();
|
||||
if (m_pDemoRecorder->Start(m_pStorage, m_pConsole, pDst, m_pNetVersion, pMapInfo->m_aName, pMapInfo->m_Crc, "client", 0, 0, pfnFilter, pUser) == -1)
|
||||
if (m_pDemoRecorder->Start(m_pStorage, m_pConsole, pDst, m_pNetVersion, pMapInfo->m_aName, pMapInfo->m_Crc, "client", 0, 0, 0, pfnFilter, pUser) == -1)
|
||||
return;
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
CDemoRecorder(class CSnapshotDelta *pSnapshotDelta, bool NoMapData = false);
|
||||
CDemoRecorder() {}
|
||||
|
||||
int Start(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename, const char *pNetversion, const char *pMap, unsigned MapCrc, const char *pType, unsigned int MapSize, unsigned char *pMapData, DEMOFUNC_FILTER pfnFilter = 0, void *pUser = 0);
|
||||
int Start(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename, const char *pNetversion, const char *pMap, unsigned MapCrc, const char *pType, unsigned int MapSize, unsigned char *pMapData, IOHANDLE MapFile = 0, DEMOFUNC_FILTER pfnFilter = 0, void *pUser = 0);
|
||||
int Stop();
|
||||
void AddDemoMarker();
|
||||
|
||||
|
|
|
@ -48,6 +48,11 @@ public:
|
|||
{
|
||||
return m_DataFile.MapSize();
|
||||
}
|
||||
|
||||
virtual IOHANDLE File()
|
||||
{
|
||||
return m_DataFile.File();
|
||||
}
|
||||
};
|
||||
|
||||
extern IEngineMap *CreateEngineMap() { return new CMap; }
|
||||
|
|
Loading…
Reference in a new issue