mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Use CUtlVector for map list
This commit is contained in:
parent
a994da728d
commit
bc59f1349d
@ -27,7 +27,7 @@ int _Host_Map_f_CompletionFunc(char const* cmdname, char const* partial, char co
|
||||
substring = (char*)partial + strlen(cmdname);
|
||||
}
|
||||
|
||||
const int mapcount = (int)g_InstalledMaps.size();
|
||||
const int mapcount = g_InstalledMaps.Count();
|
||||
const int longest = COMMAND_COMPLETION_ITEM_LENGTH;
|
||||
const int count = MIN(mapcount, COMMAND_COMPLETION_MAXITEMS);
|
||||
|
||||
@ -36,9 +36,9 @@ int _Host_Map_f_CompletionFunc(char const* cmdname, char const* partial, char co
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (strstr(g_InstalledMaps[i].c_str(), substring))
|
||||
if (strstr(g_InstalledMaps[i].String(), substring))
|
||||
{
|
||||
strncpy(commands[filtered_count], g_InstalledMaps[i].c_str(), longest);
|
||||
strncpy(commands[filtered_count], g_InstalledMaps[i].String(), longest);
|
||||
|
||||
char old[COMMAND_COMPLETION_ITEM_LENGTH];
|
||||
strncpy(old, commands[filtered_count], sizeof(old));
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "client/clientstate.h"
|
||||
#endif // !DEDICATED
|
||||
|
||||
vector<string> g_InstalledMaps;
|
||||
CUtlVector<CUtlString> g_InstalledMaps;
|
||||
string s_LevelName;
|
||||
|
||||
std::regex s_ArchiveRegex{ R"([^_]*_(.*)(.bsp.pak000_dir).*)" };
|
||||
@ -52,7 +52,7 @@ void Mod_GetAllInstalledMaps()
|
||||
std::cmatch regexMatches;
|
||||
std::lock_guard<std::mutex> l(g_InstalledMapsMutex);
|
||||
|
||||
g_InstalledMaps.clear(); // Clear current list.
|
||||
g_InstalledMaps.Purge(); // Clear current list.
|
||||
|
||||
FOR_EACH_VEC(fileList, i)
|
||||
{
|
||||
@ -67,18 +67,20 @@ void Mod_GetAllInstalledMaps()
|
||||
|
||||
if (!regexMatches.empty())
|
||||
{
|
||||
if (regexMatches[1].str().compare("frontend") == 0)
|
||||
const string match = regexMatches[1].str();
|
||||
|
||||
if (match.compare("frontend") == 0)
|
||||
continue; // Frontend contains no BSP's.
|
||||
|
||||
else if (regexMatches[1].str().compare("mp_common") == 0)
|
||||
else if (match.compare("mp_common") == 0)
|
||||
{
|
||||
if (std::find(g_InstalledMaps.begin(), g_InstalledMaps.end(), "mp_lobby") == g_InstalledMaps.end())
|
||||
g_InstalledMaps.push_back("mp_lobby");
|
||||
if (!g_InstalledMaps.HasElement("mp_lobby"))
|
||||
g_InstalledMaps.AddToTail("mp_lobby");
|
||||
|
||||
continue; // Common contains mp_lobby.
|
||||
}
|
||||
|
||||
if (std::find(g_InstalledMaps.begin(), g_InstalledMaps.end(), regexMatches[1].str()) == g_InstalledMaps.end())
|
||||
g_InstalledMaps.push_back(regexMatches[1].str());
|
||||
else if (!g_InstalledMaps.HasElement(match.c_str()))
|
||||
g_InstalledMaps.AddToTail(match.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ inline __int64(*sub_14045A1D0)(unsigned __int8(__fastcall* a1)(_QWORD), JobFifoL
|
||||
inline void(*sub_140441220)(__int64 a1, __int64 a2);
|
||||
|
||||
extern bool s_bBasePaksInitialized;
|
||||
extern vector<string> g_InstalledMaps;
|
||||
extern CUtlVector<CUtlString> g_InstalledMaps;
|
||||
|
||||
bool Mod_LevelHasChanged(const char* pszLevelName);
|
||||
void Mod_GetAllInstalledMaps();
|
||||
|
@ -38,13 +38,16 @@ namespace VScriptCode
|
||||
{
|
||||
std::lock_guard<std::mutex> l(g_InstalledMapsMutex);
|
||||
|
||||
if (g_InstalledMaps.empty())
|
||||
if (g_InstalledMaps.IsEmpty())
|
||||
return SQ_OK;
|
||||
|
||||
sq_newarray(v, 0);
|
||||
for (const string& it : g_InstalledMaps)
|
||||
|
||||
FOR_EACH_VEC(g_InstalledMaps, i)
|
||||
{
|
||||
sq_pushstring(v, it.c_str(), -1);
|
||||
const CUtlString& mapName = g_InstalledMaps[i];
|
||||
|
||||
sq_pushstring(v, mapName.String(), -1);
|
||||
sq_arrayappend(v, -2);
|
||||
}
|
||||
|
||||
|
@ -519,11 +519,15 @@ void CBrowser::HostPanel(void)
|
||||
if (ImGui::BeginCombo("Map", g_pServerListManager->m_Server.m_svHostMap.c_str()))
|
||||
{
|
||||
g_InstalledMapsMutex.lock();
|
||||
for (const string& svMap : g_InstalledMaps)
|
||||
|
||||
FOR_EACH_VEC(g_InstalledMaps, i)
|
||||
{
|
||||
if (ImGui::Selectable(svMap.c_str(), svMap == g_pServerListManager->m_Server.m_svHostMap))
|
||||
const CUtlString& mapName = g_InstalledMaps[i];
|
||||
|
||||
if (ImGui::Selectable(mapName.String(),
|
||||
mapName.IsEqual_CaseInsensitive(g_pServerListManager->m_Server.m_svHostMap.c_str())))
|
||||
{
|
||||
g_pServerListManager->m_Server.m_svHostMap = svMap;
|
||||
g_pServerListManager->m_Server.m_svHostMap = mapName.String();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user