mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Use str_startswith
, str_endswith
, str_truncate
Use this instead of ad-hoc implementations which are a bit more error-prone.
This commit is contained in:
parent
11862b495f
commit
b3df4ffc08
|
@ -239,7 +239,7 @@ void CSmoothTime::Update(CGraph *pGraph, int64 Target, int TimeLeft, int AdjustD
|
||||||
UpdateInt(Target);
|
UpdateInt(Target);
|
||||||
}
|
}
|
||||||
|
|
||||||
CClient::CClient() : m_DemoPlayer(&m_SnapshotDelta), m_DemoRecorder(&m_SnapshotDelta), m_pConLinkIdentifier("teeworlds:")
|
CClient::CClient() : m_DemoPlayer(&m_SnapshotDelta), m_DemoRecorder(&m_SnapshotDelta)
|
||||||
{
|
{
|
||||||
m_pEditor = 0;
|
m_pEditor = 0;
|
||||||
m_pInput = 0;
|
m_pInput = 0;
|
||||||
|
@ -2419,9 +2419,9 @@ static CClient *CreateClient()
|
||||||
return new(pClient) CClient;
|
return new(pClient) CClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClient::HandleTeeworldsConnectLink(const char *pConLink)
|
void CClient::ConnectOnStart(const char *pAddress)
|
||||||
{
|
{
|
||||||
str_copy(m_aCmdConnect, pConLink, sizeof(m_aCmdConnect));
|
str_copy(m_aCmdConnect, pAddress, sizeof(m_aCmdConnect));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2555,23 +2555,20 @@ int main(int argc, const char **argv) // ignore_convention
|
||||||
// parse the command line arguments
|
// parse the command line arguments
|
||||||
if(argc > 1) // ignore_convention
|
if(argc > 1) // ignore_convention
|
||||||
{
|
{
|
||||||
switch(argc) // ignore_convention
|
const char *pAddress = 0;
|
||||||
|
if(argc == 2)
|
||||||
{
|
{
|
||||||
case 2:
|
pAddress = str_startswith(argv[1], "teeworlds:");
|
||||||
|
}
|
||||||
|
if(pAddress)
|
||||||
{
|
{
|
||||||
// handle Teeworlds connect link
|
pClient->ConnectOnStart(pAddress);
|
||||||
const int Length = str_length(pClient->m_pConLinkIdentifier);
|
}
|
||||||
if(str_comp_num(pClient->m_pConLinkIdentifier, argv[1], Length) == 0) // ignore_convention
|
else
|
||||||
{
|
{
|
||||||
pClient->HandleTeeworldsConnectLink(argv[1] + Length); // ignore_convention
|
pConsole->ParseArguments(argc - 1, &argv[1]);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
pConsole->ParseArguments(argc - 1, &argv[1]); // ignore_convention
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore empty config strings to their defaults
|
// restore empty config strings to their defaults
|
||||||
|
|
|
@ -278,6 +278,7 @@ public:
|
||||||
bool LimitFps();
|
bool LimitFps();
|
||||||
void Run();
|
void Run();
|
||||||
|
|
||||||
|
void ConnectOnStart(const char *pAddress);
|
||||||
|
|
||||||
static void Con_Connect(IConsole::IResult *pResult, void *pUserData);
|
static void Con_Connect(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void Con_Disconnect(IConsole::IResult *pResult, void *pUserData);
|
static void Con_Disconnect(IConsole::IResult *pResult, void *pUserData);
|
||||||
|
@ -318,9 +319,5 @@ public:
|
||||||
void ToggleFullscreen();
|
void ToggleFullscreen();
|
||||||
void ToggleWindowBordered();
|
void ToggleWindowBordered();
|
||||||
void ToggleWindowVSync();
|
void ToggleWindowVSync();
|
||||||
|
|
||||||
// Teeworlds connect link
|
|
||||||
const char * const m_pConLinkIdentifier;
|
|
||||||
void HandleTeeworldsConnectLink(const char *pConLink);
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -84,7 +84,7 @@ bool CMapChecker::ReadAndValidateMap(IStorage *pStorage, const char *pFilename,
|
||||||
int Length = (int)(pEnd - pExtractedName);
|
int Length = (int)(pEnd - pExtractedName);
|
||||||
if(Length <= 0 || Length >= MAX_MAP_LENGTH)
|
if(Length <= 0 || Length >= MAX_MAP_LENGTH)
|
||||||
return true;
|
return true;
|
||||||
str_copy(aMapName, pExtractedName, min((int)MAX_MAP_LENGTH, (int)(pEnd-pExtractedName+1)));
|
str_truncate(aMapName, MAX_MAP_LENGTH, pExtractedName, pEnd - pExtractedName);
|
||||||
str_format(aMapNameExt, sizeof(aMapNameExt), "%s.map", aMapName);
|
str_format(aMapNameExt, sizeof(aMapNameExt), "%s.map", aMapName);
|
||||||
|
|
||||||
// check for valid map
|
// check for valid map
|
||||||
|
|
|
@ -111,8 +111,11 @@ public:
|
||||||
|
|
||||||
while((pLine = LineReader.Get()))
|
while((pLine = LineReader.Get()))
|
||||||
{
|
{
|
||||||
if(str_length(pLine) > 9 && !str_comp_num(pLine, "add_path ", 9))
|
const char *pLineWithoutPrefix = str_startswith(pLine, "add_path ");
|
||||||
AddPath(pLine+9);
|
if(pLineWithoutPrefix)
|
||||||
|
{
|
||||||
|
AddPath(pLineWithoutPrefix);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
io_close(File);
|
io_close(File);
|
||||||
|
|
|
@ -222,7 +222,7 @@ bool CChat::OnInput(IInput::CEvent Event)
|
||||||
for(m_PlaceholderLength = 0; *pCursor && *pCursor != ' '; ++pCursor)
|
for(m_PlaceholderLength = 0; *pCursor && *pCursor != ' '; ++pCursor)
|
||||||
++m_PlaceholderLength;
|
++m_PlaceholderLength;
|
||||||
|
|
||||||
str_copy(m_aCompletionBuffer, m_Input.GetString()+m_PlaceholderOffset, min(static_cast<int>(sizeof(m_aCompletionBuffer)), m_PlaceholderLength+1));
|
str_truncate(m_aCompletionBuffer, sizeof(m_aCompletionBuffer), m_Input.GetString()+m_PlaceholderOffset, m_PlaceholderLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
// find next possible name
|
// find next possible name
|
||||||
|
@ -280,7 +280,7 @@ bool CChat::OnInput(IInput::CEvent Event)
|
||||||
{
|
{
|
||||||
char aBuf[256];
|
char aBuf[256];
|
||||||
// add part before the name
|
// add part before the name
|
||||||
str_copy(aBuf, m_Input.GetString(), min(static_cast<int>(sizeof(aBuf)), m_PlaceholderOffset+1));
|
str_truncate(aBuf, sizeof(aBuf), m_Input.GetString(), m_PlaceholderOffset);
|
||||||
|
|
||||||
// add the name
|
// add the name
|
||||||
str_append(aBuf, pCompletionString, sizeof(aBuf));
|
str_append(aBuf, pCompletionString, sizeof(aBuf));
|
||||||
|
|
|
@ -1403,8 +1403,7 @@ void CMenus::RenderBackButton(CUIRect MainView)
|
||||||
int CMenus::MenuImageScan(const char *pName, int IsDir, int DirType, void *pUser)
|
int CMenus::MenuImageScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||||
{
|
{
|
||||||
CMenus *pSelf = (CMenus *)pUser;
|
CMenus *pSelf = (CMenus *)pUser;
|
||||||
int l = str_length(pName);
|
if(IsDir || !str_endswith(pName, ".png"))
|
||||||
if(l < 4 || IsDir || str_comp(pName+l-4, ".png") != 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
char aBuf[512];
|
char aBuf[512];
|
||||||
|
@ -1475,7 +1474,7 @@ int CMenus::MenuImageScan(const char *pName, int IsDir, int DirType, void *pUser
|
||||||
mem_free(Info.m_pData);
|
mem_free(Info.m_pData);
|
||||||
|
|
||||||
// set menu image data
|
// set menu image data
|
||||||
str_copy(MenuImage.m_aName, pName, min((int)sizeof(MenuImage.m_aName),l-3));
|
str_truncate(MenuImage.m_aName, sizeof(MenuImage.m_aName), pName, str_length(pName) - 4);
|
||||||
str_format(aBuf, sizeof(aBuf), "load menu image %s", MenuImage.m_aName);
|
str_format(aBuf, sizeof(aBuf), "load menu image %s", MenuImage.m_aName);
|
||||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf);
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf);
|
||||||
pSelf->m_lMenuImages.add(MenuImage);
|
pSelf->m_lMenuImages.add(MenuImage);
|
||||||
|
|
|
@ -2170,12 +2170,13 @@ void CMenus::DoGameIcon(const char *pName, const CUIRect *pRect, int Type)
|
||||||
int CMenus::GameIconScan(const char *pName, int IsDir, int DirType, void *pUser)
|
int CMenus::GameIconScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||||
{
|
{
|
||||||
CMenus *pSelf = (CMenus *)pUser;
|
CMenus *pSelf = (CMenus *)pUser;
|
||||||
int l = str_length(pName);
|
const char *pSuffix = str_endswith(pName, ".png");
|
||||||
if(l < 5 || IsDir || str_comp(pName + l - 4, ".png") != 0)
|
if(IsDir || !pSuffix)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
char aGameIconName[128] = { 0 };
|
char aGameIconName[128];
|
||||||
str_copy(aGameIconName, pName, min((int)sizeof(aGameIconName), l - 3));
|
str_truncate(aGameIconName, sizeof(aGameIconName), pName, pSuffix - pName);
|
||||||
|
|
||||||
// add new game icon
|
// add new game icon
|
||||||
char aBuf[512];
|
char aBuf[512];
|
||||||
|
|
|
@ -269,11 +269,12 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
int CMenus::DemolistFetchCallback(const char *pName, int IsDir, int StorageType, void *pUser)
|
int CMenus::DemolistFetchCallback(const char *pName, int IsDir, int StorageType, void *pUser)
|
||||||
{
|
{
|
||||||
CMenus *pSelf = (CMenus *)pUser;
|
CMenus *pSelf = (CMenus *)pUser;
|
||||||
int Length = str_length(pName);
|
if(str_comp(pName, ".") == 0
|
||||||
if((pName[0] == '.' && (pName[1] == 0 ||
|
|| (str_comp(pName, "..") == 0 && str_comp(pSelf->m_aCurrentDemoFolder, "demos") == 0)
|
||||||
(pName[1] == '.' && pName[2] == 0 && !str_comp(pSelf->m_aCurrentDemoFolder, "demos")))) ||
|
|| (!IsDir && str_endswith(pName, ".demo")))
|
||||||
(!IsDir && (Length < 5 || str_comp(pName+Length-5, ".demo"))))
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
CDemoItem Item;
|
CDemoItem Item;
|
||||||
str_copy(Item.m_aFilename, pName, sizeof(Item.m_aFilename));
|
str_copy(Item.m_aFilename, pName, sizeof(Item.m_aFilename));
|
||||||
|
@ -284,7 +285,7 @@ int CMenus::DemolistFetchCallback(const char *pName, int IsDir, int StorageType,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
str_copy(Item.m_aName, pName, min(static_cast<int>(sizeof(Item.m_aName)), Length-4));
|
str_truncate(Item.m_aName, sizeof(Item.m_aName), pName, str_length(pName) - 5);
|
||||||
Item.m_InfosLoaded = false;
|
Item.m_InfosLoaded = false;
|
||||||
}
|
}
|
||||||
Item.m_IsDir = IsDir != 0;
|
Item.m_IsDir = IsDir != 0;
|
||||||
|
|
|
@ -582,26 +582,24 @@ public:
|
||||||
int CMenus::ThemeScan(const char *pName, int IsDir, int DirType, void *pUser)
|
int CMenus::ThemeScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||||
{
|
{
|
||||||
CMenus *pSelf = (CMenus *)pUser;
|
CMenus *pSelf = (CMenus *)pUser;
|
||||||
int l = str_length(pName);
|
const char *pSuffix = str_endswith(pName, ".map");
|
||||||
|
if(IsDir || !pSuffix)
|
||||||
if(l < 5 || IsDir || str_comp(pName+l-4, ".map") != 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
char aFullName[128];
|
char aFullName[128];
|
||||||
char aThemeName[128];
|
char aThemeName[128];
|
||||||
str_copy(aFullName, pName, min((int)sizeof(aFullName),l-3));
|
str_truncate(aFullName, sizeof(aFullName), pName, pSuffix - pName);
|
||||||
|
|
||||||
l = str_length(aFullName);
|
bool IsDay = false;
|
||||||
bool isDay = false;
|
bool IsNight = false;
|
||||||
bool isNight = false;
|
if((pSuffix = str_endswith(aFullName, "_day")))
|
||||||
if(l > 4 && str_comp(aFullName+l-4, "_day") == 0)
|
|
||||||
{
|
{
|
||||||
str_copy(aThemeName, pName, min((int)sizeof(aThemeName),l-3));
|
str_truncate(aThemeName, sizeof(aThemeName), pName, pSuffix - aThemeName);
|
||||||
isDay = true;
|
IsDay = true;
|
||||||
}
|
}
|
||||||
else if(l > 6 && str_comp(aFullName+l-6, "_night") == 0)
|
else if((pSuffix = str_endswith(aFullName, "_night")))
|
||||||
{
|
{
|
||||||
str_copy(aThemeName, pName, min((int)sizeof(aThemeName),l-5));
|
str_truncate(aThemeName, sizeof(aThemeName), pName, pSuffix - aThemeName);
|
||||||
isNight = true;
|
IsNight = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
str_copy(aThemeName, aFullName, sizeof(aThemeName));
|
str_copy(aThemeName, aFullName, sizeof(aThemeName));
|
||||||
|
@ -614,16 +612,16 @@ int CMenus::ThemeScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||||
{
|
{
|
||||||
if(str_comp(pSelf->m_lThemes[i].m_Name, aThemeName) == 0)
|
if(str_comp(pSelf->m_lThemes[i].m_Name, aThemeName) == 0)
|
||||||
{
|
{
|
||||||
if(isDay)
|
if(IsDay)
|
||||||
pSelf->m_lThemes[i].m_HasDay = true;
|
pSelf->m_lThemes[i].m_HasDay = true;
|
||||||
if(isNight)
|
if(IsNight)
|
||||||
pSelf->m_lThemes[i].m_HasNight = true;
|
pSelf->m_lThemes[i].m_HasNight = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make new theme
|
// make new theme
|
||||||
CTheme Theme(aThemeName, isDay, isNight);
|
CTheme Theme(aThemeName, IsDay, IsNight);
|
||||||
char aBuf[512];
|
char aBuf[512];
|
||||||
str_format(aBuf, sizeof(aBuf), "added theme %s from ui/themes/%s", aThemeName, pName);
|
str_format(aBuf, sizeof(aBuf), "added theme %s from ui/themes/%s", aThemeName, pName);
|
||||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf);
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf);
|
||||||
|
@ -634,12 +632,12 @@ int CMenus::ThemeScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||||
int CMenus::ThemeIconScan(const char *pName, int IsDir, int DirType, void *pUser)
|
int CMenus::ThemeIconScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||||
{
|
{
|
||||||
CMenus *pSelf = (CMenus *)pUser;
|
CMenus *pSelf = (CMenus *)pUser;
|
||||||
int l = str_length(pName);
|
const char *pSuffix = str_endswith(pName, ".png");
|
||||||
|
if(IsDir || !pSuffix)
|
||||||
if(l < 4 || IsDir || str_comp(pName+l-4, ".png") != 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
char aThemeName[128];
|
char aThemeName[128];
|
||||||
str_copy(aThemeName, pName, min((int)sizeof(aThemeName),l-3));
|
str_truncate(aThemeName, sizeof(aThemeName), pName, pSuffix - pName);
|
||||||
|
|
||||||
// save icon for an existing theme
|
// save icon for an existing theme
|
||||||
for(sorted_array<CTheme>::range r = pSelf->m_lThemes.all(); !r.empty(); r.pop_front()) // bit slow but whatever
|
for(sorted_array<CTheme>::range r = pSelf->m_lThemes.all(); !r.empty(); r.pop_front()) // bit slow but whatever
|
||||||
|
|
|
@ -28,8 +28,7 @@ int *const CSkins::ms_apColorVariables[NUM_SKINPARTS] = {&g_Config.m_PlayerColor
|
||||||
int CSkins::SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser)
|
int CSkins::SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||||
{
|
{
|
||||||
CSkins *pSelf = (CSkins *)pUser;
|
CSkins *pSelf = (CSkins *)pUser;
|
||||||
int l = str_length(pName);
|
if(IsDir || !str_endswith(pName, ".png"))
|
||||||
if(l < 4 || IsDir || str_comp(pName+l-4, ".png") != 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
char aBuf[512];
|
char aBuf[512];
|
||||||
|
@ -93,7 +92,7 @@ int CSkins::SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||||
Part.m_Flags |= SKINFLAG_SPECIAL;
|
Part.m_Flags |= SKINFLAG_SPECIAL;
|
||||||
if(DirType != IStorage::TYPE_SAVE)
|
if(DirType != IStorage::TYPE_SAVE)
|
||||||
Part.m_Flags |= SKINFLAG_STANDARD;
|
Part.m_Flags |= SKINFLAG_STANDARD;
|
||||||
str_copy(Part.m_aName, pName, min((int)sizeof(Part.m_aName),l-3));
|
str_truncate(Part.m_aName, sizeof(Part.m_aName), pName, str_length(pName) - 4);
|
||||||
if(g_Config.m_Debug)
|
if(g_Config.m_Debug)
|
||||||
{
|
{
|
||||||
str_format(aBuf, sizeof(aBuf), "load skin part %s", Part.m_aName);
|
str_format(aBuf, sizeof(aBuf), "load skin part %s", Part.m_aName);
|
||||||
|
@ -106,8 +105,7 @@ int CSkins::SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||||
|
|
||||||
int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
|
int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||||
{
|
{
|
||||||
int l = str_length(pName);
|
if(IsDir || !str_endswith(pName, ".json"))
|
||||||
if(l < 5 || IsDir || str_comp(pName+l-5, ".json") != 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CSkins *pSelf = (CSkins *)pUser;
|
CSkins *pSelf = (CSkins *)pUser;
|
||||||
|
@ -125,7 +123,7 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||||
|
|
||||||
// init
|
// init
|
||||||
CSkin Skin = pSelf->m_DummySkin;
|
CSkin Skin = pSelf->m_DummySkin;
|
||||||
str_copy(Skin.m_aName, pName, min((int)sizeof(Skin.m_aName),l-4));
|
str_truncate(Skin.m_aName, sizeof(Skin.m_aName), pName, str_length(pName) - 5);
|
||||||
if(pSelf->Find(Skin.m_aName, true) != -1)
|
if(pSelf->Find(Skin.m_aName, true) != -1)
|
||||||
return 0;
|
return 0;
|
||||||
bool SpecialSkin = pName[0] == 'x' && pName[1] == '_';
|
bool SpecialSkin = pName[0] == 'x' && pName[1] == '_';
|
||||||
|
|
|
@ -814,9 +814,8 @@ void CEditor::CallbackSaveMap(const char *pFileName, int StorageType, void *pUse
|
||||||
{
|
{
|
||||||
CEditor *pEditor = static_cast<CEditor*>(pUser);
|
CEditor *pEditor = static_cast<CEditor*>(pUser);
|
||||||
char aBuf[1024];
|
char aBuf[1024];
|
||||||
const int Length = str_length(pFileName);
|
|
||||||
// add map extension
|
// add map extension
|
||||||
if(Length <= 4 || pFileName[Length-4] != '.' || str_comp_nocase(pFileName+Length-3, "map"))
|
if(!str_endswith(pFileName, ".map"))
|
||||||
{
|
{
|
||||||
str_format(aBuf, sizeof(aBuf), "%s.map", pFileName);
|
str_format(aBuf, sizeof(aBuf), "%s.map", pFileName);
|
||||||
pFileName = aBuf;
|
pFileName = aBuf;
|
||||||
|
@ -3024,19 +3023,25 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
|
||||||
static int EditorListdirCallback(const char *pName, int IsDir, int StorageType, void *pUser)
|
static int EditorListdirCallback(const char *pName, int IsDir, int StorageType, void *pUser)
|
||||||
{
|
{
|
||||||
CEditor *pEditor = (CEditor*)pUser;
|
CEditor *pEditor = (CEditor*)pUser;
|
||||||
int Length = str_length(pName);
|
const char *pExt = 0;
|
||||||
if((pName[0] == '.' && (pName[1] == 0 ||
|
switch(pEditor->m_FileDialogFileType)
|
||||||
(pName[1] == '.' && pName[2] == 0 && (!str_comp(pEditor->m_pFileDialogPath, "maps") || !str_comp(pEditor->m_pFileDialogPath, "mapres"))))) ||
|
{
|
||||||
(!IsDir && ((pEditor->m_FileDialogFileType == CEditor::FILETYPE_MAP && (Length < 4 || str_comp(pName+Length-4, ".map"))) ||
|
case CEditor::FILETYPE_MAP: pExt = ".map"; break;
|
||||||
(pEditor->m_FileDialogFileType == CEditor::FILETYPE_IMG && (Length < 4 || str_comp(pName+Length-4, ".png"))))))
|
case CEditor::FILETYPE_IMG: pExt = ".png"; break;
|
||||||
|
}
|
||||||
|
if(str_comp(pName, ".") == 0
|
||||||
|
|| (str_comp(pName, "..") == 0 && (str_comp(pEditor->m_pFileDialogPath, "maps") == 0 || str_comp(pEditor->m_pFileDialogPath, "mapres") == 0))
|
||||||
|
|| (pExt && !IsDir && str_endswith(pName, pExt)))
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
CEditor::CFilelistItem Item;
|
CEditor::CFilelistItem Item;
|
||||||
str_copy(Item.m_aFilename, pName, sizeof(Item.m_aFilename));
|
str_copy(Item.m_aFilename, pName, sizeof(Item.m_aFilename));
|
||||||
if(IsDir)
|
if(IsDir)
|
||||||
str_format(Item.m_aName, sizeof(Item.m_aName), "%s/", pName);
|
str_format(Item.m_aName, sizeof(Item.m_aName), "%s/", pName);
|
||||||
else
|
else
|
||||||
str_copy(Item.m_aName, pName, min(static_cast<int>(sizeof(Item.m_aName)), Length-3));
|
str_truncate(Item.m_aName, sizeof(Item.m_aName), pName, str_length(pName) - 4);
|
||||||
Item.m_IsDir = IsDir != 0;
|
Item.m_IsDir = IsDir != 0;
|
||||||
Item.m_IsLink = false;
|
Item.m_IsLink = false;
|
||||||
Item.m_StorageType = StorageType;
|
Item.m_StorageType = StorageType;
|
||||||
|
|
|
@ -390,14 +390,14 @@ void CGameContext::SendVoteStatus(int ClientID, int Total, int Yes, int No)
|
||||||
|
|
||||||
void CGameContext::AbortVoteOnDisconnect(int ClientID)
|
void CGameContext::AbortVoteOnDisconnect(int ClientID)
|
||||||
{
|
{
|
||||||
if(m_VoteCloseTime && ClientID == m_VoteClientID && (!str_comp_num(m_aVoteCommand, "kick ", 5) ||
|
if(m_VoteCloseTime && ClientID == m_VoteClientID && (str_startswith(m_aVoteCommand, "kick ") ||
|
||||||
!str_comp_num(m_aVoteCommand, "set_team ", 9) || (!str_comp_num(m_aVoteCommand, "ban ", 4) && Server()->IsBanned(ClientID))))
|
str_startswith(m_aVoteCommand, "set_team ") || (str_startswith(m_aVoteCommand, "ban ") && Server()->IsBanned(ClientID))))
|
||||||
m_VoteCloseTime = -1;
|
m_VoteCloseTime = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::AbortVoteOnTeamChange(int ClientID)
|
void CGameContext::AbortVoteOnTeamChange(int ClientID)
|
||||||
{
|
{
|
||||||
if(m_VoteCloseTime && ClientID == m_VoteClientID && !str_comp_num(m_aVoteCommand, "set_team ", 9))
|
if(m_VoteCloseTime && ClientID == m_VoteClientID && str_startswith(m_aVoteCommand, "set_team "))
|
||||||
m_VoteCloseTime = -1;
|
m_VoteCloseTime = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue