mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
reload the map on save just when the map name is equal
This commit is contained in:
parent
8351682edf
commit
ca80d2a347
|
@ -1850,22 +1850,6 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
|
|||
}
|
||||
}
|
||||
|
||||
static void ExtractName(const char *pFileName, char *pName, int BufferSize)
|
||||
{
|
||||
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 ? min(BufferSize, (int)(pEnd-pExtractedName+1)) : BufferSize;
|
||||
str_copy(pName, pExtractedName, Length);
|
||||
}
|
||||
|
||||
void CEditor::ReplaceImage(const char *pFileName, int StorageType, void *pUser)
|
||||
{
|
||||
CEditor *pEditor = (CEditor *)pUser;
|
||||
|
@ -1878,7 +1862,7 @@ void CEditor::ReplaceImage(const char *pFileName, int StorageType, void *pUser)
|
|||
pEditor->Graphics()->UnloadTexture(pImg->m_TexId);
|
||||
*pImg = ImgInfo;
|
||||
pImg->m_External = External;
|
||||
ExtractName(pFileName, pImg->m_aName, sizeof(pImg->m_aName));
|
||||
pEditor->ExtractName(pFileName, pImg->m_aName, sizeof(pImg->m_aName));
|
||||
pImg->m_TexId = pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, CImageInfo::FORMAT_AUTO, 0);
|
||||
pEditor->SortImages();
|
||||
for(int i = 0; i < pEditor->m_Map.m_lImages.size(); ++i)
|
||||
|
|
|
@ -680,6 +680,21 @@ public:
|
|||
|
||||
void AddFileDialogEntry(int Index, CUIRect *pView);
|
||||
void SortImages();
|
||||
static void ExtractName(const char *pFileName, char *pName, int BufferSize)
|
||||
{
|
||||
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 ? min(BufferSize, (int)(pEnd-pExtractedName+1)) : BufferSize;
|
||||
str_copy(pName, pExtractedName, Length);
|
||||
}
|
||||
};
|
||||
|
||||
// make sure to inline this function
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <engine/client.h>
|
||||
#include <engine/console.h>
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/serverbrowser.h>
|
||||
#include <engine/storage.h>
|
||||
#include <game/gamecore.h>
|
||||
#include "ed_editor.h"
|
||||
|
@ -361,7 +362,14 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
|
||||
// send rcon.. if we can
|
||||
if(m_pEditor->Client()->RconAuthed())
|
||||
{
|
||||
CServerInfo CurrentServerInfo;
|
||||
m_pEditor->Client()->GetServerInfo(&CurrentServerInfo);
|
||||
char aMapName[128];
|
||||
m_pEditor->ExtractName(pFileName, aMapName, sizeof(aMapName));
|
||||
if(!str_comp(aMapName, CurrentServerInfo.m_aMap))
|
||||
m_pEditor->Client()->Rcon("reload");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue