mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Refactor GetDemoName
using IStorage::StripPathAndExtension
The functions were effectively identical already.
This commit is contained in:
parent
c3b8c94212
commit
82d94faf28
|
@ -106,7 +106,7 @@ public:
|
|||
virtual void Unpause() = 0;
|
||||
virtual bool IsPlaying() const = 0;
|
||||
virtual const CInfo *BaseInfo() const = 0;
|
||||
virtual void GetDemoName(char *pBuffer, int BufferSize) const = 0;
|
||||
virtual void GetDemoName(char *pBuffer, size_t BufferSize) const = 0;
|
||||
virtual bool GetDemoInfo(class IStorage *pStorage, const char *pFilename, int StorageType, CDemoHeader *pDemoHeader, CTimelineMarkers *pTimelineMarkers, CMapInfo *pMapInfo) const = 0;
|
||||
virtual int GetDemoType() const = 0;
|
||||
};
|
||||
|
|
|
@ -1064,21 +1064,9 @@ int CDemoPlayer::Stop()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void CDemoPlayer::GetDemoName(char *pBuffer, int BufferSize) const
|
||||
void CDemoPlayer::GetDemoName(char *pBuffer, size_t BufferSize) const
|
||||
{
|
||||
const char *pFileName = m_aFilename;
|
||||
const char *pExtractedName = pFileName;
|
||||
const char *pEnd = 0;
|
||||
for(; *pFileName; ++pFileName)
|
||||
{
|
||||
if(*pFileName == '/' || *pFileName == '\\')
|
||||
pExtractedName = pFileName + 1;
|
||||
else if(*pFileName == '.')
|
||||
pEnd = pFileName;
|
||||
}
|
||||
|
||||
int Length = pEnd > pExtractedName ? minimum(BufferSize, (int)(pEnd - pExtractedName + 1)) : BufferSize;
|
||||
str_copy(pBuffer, pExtractedName, Length);
|
||||
IStorage::StripPathAndExtension(m_aFilename, pBuffer, BufferSize);
|
||||
}
|
||||
|
||||
bool CDemoPlayer::GetDemoInfo(class IStorage *pStorage, const char *pFilename, int StorageType, CDemoHeader *pDemoHeader, CTimelineMarkers *pTimelineMarkers, CMapInfo *pMapInfo) const
|
||||
|
|
|
@ -154,7 +154,7 @@ public:
|
|||
int SeekTick(ETickOffset TickOffset) override;
|
||||
int SetPos(int WantedTick) override;
|
||||
const CInfo *BaseInfo() const override { return &m_Info.m_Info; }
|
||||
void GetDemoName(char *pBuffer, int BufferSize) const override;
|
||||
void GetDemoName(char *pBuffer, size_t BufferSize) const override;
|
||||
bool GetDemoInfo(class IStorage *pStorage, const char *pFilename, int StorageType, CDemoHeader *pDemoHeader, CTimelineMarkers *pTimelineMarkers, CMapInfo *pMapInfo) const override;
|
||||
const char *GetDemoFileName() { return m_aFilename; }
|
||||
int GetDemoType() const override;
|
||||
|
|
Loading…
Reference in a new issue