mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
General cleanup
Use c++ methods, remove unnecessary casts, unnecessary use of auto, etc..
This commit is contained in:
parent
0b4eb06dd2
commit
e92b5d1300
@ -41,16 +41,16 @@ void MOD_GetAllInstalledMaps()
|
||||
|
||||
for (const fs::directory_entry& dEntry : fs::directory_iterator("vpk"))
|
||||
{
|
||||
std::string svFileName = dEntry.path().string();
|
||||
std::string svFileName = dEntry.path().u8string();
|
||||
std::regex_search(svFileName, smRegexMatches, rgArchiveRegex);
|
||||
|
||||
if (smRegexMatches.size() > 0)
|
||||
{
|
||||
if (strcmp(smRegexMatches[1].str().c_str(), "frontend") == 0)
|
||||
if (smRegexMatches[1].str().compare("frontend") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (strcmp(smRegexMatches[1].str().c_str(), "mp_common") == 0)
|
||||
else if (smRegexMatches[1].str().compare("mp_common") == 0)
|
||||
{
|
||||
if (std::find(g_vAllMaps.begin(), g_vAllMaps.end(), "mp_lobby") == g_vAllMaps.end())
|
||||
g_vAllMaps.push_back("mp_lobby");
|
||||
@ -354,7 +354,7 @@ void MOD_PreloadPakFile(const string& svLevelName)
|
||||
nlohmann::json jsIn;
|
||||
try
|
||||
{
|
||||
ifstream iPakLoadDefFile(fsPath.string().c_str(), std::ios::binary); // Load prerequisites file.
|
||||
ifstream iPakLoadDefFile(fsPath.u8string(), std::ios::binary); // Load prerequisites file.
|
||||
|
||||
jsIn = nlohmann::json::parse(iPakLoadDefFile);
|
||||
iPakLoadDefFile.close();
|
||||
|
@ -125,7 +125,7 @@ void NET_PrintFunc(const char* fmt, ...)
|
||||
|
||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
va_end(args);
|
||||
|
||||
DevMsg(eDLL_T::CLIENT, "%s", buf);
|
||||
|
@ -35,7 +35,7 @@ void HSys_Error(char* fmt, ...)
|
||||
buf[sizeof(buf) -1] = 0;
|
||||
va_end(args);
|
||||
|
||||
Error(eDLL_T::ENGINE, "%s\n", buf);
|
||||
Error(eDLL_T::ENGINE, "%s", buf);
|
||||
return v_Sys_Error(buf);
|
||||
}
|
||||
|
||||
@ -54,11 +54,11 @@ void* HSys_Warning(int level, char* fmt, ...)
|
||||
|
||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
va_end(args);
|
||||
}/////////////////////////////
|
||||
|
||||
Warning(eDLL_T::COMMON, "Warning(%d):%s\n", level, buf);
|
||||
Warning(eDLL_T::COMMON, "Warning(%d):%s", level, buf);
|
||||
return v_Sys_Warning(level, buf);
|
||||
}
|
||||
|
||||
@ -107,11 +107,12 @@ void HCon_NPrintf(int pos, const char* fmt, ...)
|
||||
|
||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
va_end(args);
|
||||
}/////////////////////////////
|
||||
|
||||
snprintf((char*)g_pLogSystem.m_pszCon_NPrintf_Buf, 4096, buf);
|
||||
snprintf(g_pLogSystem.m_pszCon_NPrintf_Buf,
|
||||
sizeof(g_pLogSystem.m_pszCon_NPrintf_Buf), buf);
|
||||
}
|
||||
}
|
||||
#endif // !DEDICATED
|
||||
|
@ -111,7 +111,7 @@ FileHandle_t CBaseFileSystem::VReadFromVPK(CBaseFileSystem* pFileSystem, FileHan
|
||||
{
|
||||
std::string svFilePath = ConvertToWinPath(pszFilePath);
|
||||
|
||||
if (strstr(svFilePath.c_str(), "\\\*\\"))
|
||||
if (svFilePath.find("\\\*\\") != string::npos)
|
||||
{
|
||||
// Erase '//*/'.
|
||||
svFilePath.erase(0, 4);
|
||||
@ -139,7 +139,7 @@ bool CBaseFileSystem::VReadFromCache(CBaseFileSystem* pFileSystem, char* pszFile
|
||||
{
|
||||
std::string svFilePath = ConvertToWinPath(pszFilePath);
|
||||
|
||||
if (strstr(svFilePath.c_str(), "\\\*\\"))
|
||||
if (svFilePath.find("\\\*\\") != string::npos)
|
||||
{
|
||||
// Erase '//*/'.
|
||||
svFilePath.erase(0, 4);
|
||||
|
@ -31,7 +31,7 @@ void CAI_Network::DebugConnectMsg(int node1, int node2, const char* pszFormat, .
|
||||
|
||||
vsnprintf(buf, sizeof(buf), pszFormat, args);
|
||||
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
va_end(args);
|
||||
}/////////////////////////////
|
||||
|
||||
|
@ -312,12 +312,12 @@ void CAI_NetworkManager::LoadNetworkGraph(CAI_NetworkManager* pAINetworkManager,
|
||||
if (nAiNetVersion > AINET_VERSION_NUMBER)
|
||||
{
|
||||
Warning(eDLL_T::SERVER, "AI node graph '%s' deviates expectations (net version: '%d' expected: '%d')\n",
|
||||
fsGraphPath.string().c_str(), nAiNetVersion, AINET_VERSION_NUMBER);
|
||||
fsGraphPath.relative_path().u8string().c_str(), nAiNetVersion, AINET_VERSION_NUMBER);
|
||||
}
|
||||
else if (nAiMapVersion != g_ServerGlobalVariables->m_nMapVersion)
|
||||
{
|
||||
Warning(eDLL_T::SERVER, "AI node graph '%s' is out of date (map version: '%d' expected: '%d')\n",
|
||||
fsGraphPath.string().c_str(), nAiMapVersion, g_ServerGlobalVariables->m_nMapVersion);
|
||||
fsGraphPath.relative_path().u8string().c_str(), nAiMapVersion, g_ServerGlobalVariables->m_nMapVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -336,7 +336,7 @@ void CAI_NetworkManager::LoadNetworkGraph(CAI_NetworkManager* pAINetworkManager,
|
||||
if (nNavMeshHash != nAiGraphHash)
|
||||
{
|
||||
Warning(eDLL_T::SERVER, "AI node graph '%s' is out of date (checksum: '0x%X' expected: '0x%X')\n",
|
||||
fsGraphPath.string().c_str(), nNavMeshHash, nAiGraphHash);
|
||||
fsGraphPath.relative_path().u8string().c_str(), nNavMeshHash, nAiGraphHash);
|
||||
}
|
||||
|
||||
iNavMesh.close();
|
||||
|
@ -535,7 +535,7 @@ void CConsole::ProcessCommand(const char* pszCommand)
|
||||
t.detach(); // Detatch from render thread.
|
||||
|
||||
m_nHistoryPos = -1;
|
||||
for (ssize_t i = static_cast<ssize_t>(m_vHistory.size()) - 1; i >= 0; i--)
|
||||
for (size_t i = m_vHistory.size(); i-- > 0; )
|
||||
{
|
||||
if (m_vHistory[i].compare(pszCommand) == 0)
|
||||
{
|
||||
|
@ -105,10 +105,10 @@ void buildLinkTable(dtNavMesh* mesh, LinkTableData& data)
|
||||
{
|
||||
dtMeshTile* tile = mesh->getTile(i);
|
||||
if (!tile || !tile->header || !tile->dataSize) continue;
|
||||
auto pcount = tile->header->polyCount;
|
||||
int pcount = tile->header->polyCount;
|
||||
for (int j = 0; j < pcount; j++)
|
||||
{
|
||||
auto& poly = tile->polys[j];
|
||||
dtPoly& poly = tile->polys[j];
|
||||
poly.disjointSetId = -1;
|
||||
}
|
||||
}
|
||||
@ -118,14 +118,14 @@ void buildLinkTable(dtNavMesh* mesh, LinkTableData& data)
|
||||
{
|
||||
dtMeshTile* tile = mesh->getTile(i);
|
||||
if (!tile || !tile->header || !tile->dataSize) continue;
|
||||
auto pcount = tile->header->polyCount;
|
||||
int pcount = tile->header->polyCount;
|
||||
for (int j = 0; j < pcount; j++)
|
||||
{
|
||||
auto& poly = tile->polys[j];
|
||||
auto plink = poly.firstLink;
|
||||
dtPoly& poly = tile->polys[j];
|
||||
unsigned int plink = poly.firstLink;
|
||||
while (plink != DT_NULL_LINK)
|
||||
{
|
||||
auto l = tile->links[plink];
|
||||
const dtLink l = tile->links[plink];
|
||||
const dtMeshTile* t;
|
||||
const dtPoly* p;
|
||||
mesh->getTileAndPolyByRefUnsafe(l.ref, &t, &p);
|
||||
@ -153,11 +153,11 @@ void buildLinkTable(dtNavMesh* mesh, LinkTableData& data)
|
||||
{
|
||||
dtMeshTile* tile = mesh->getTile(i);
|
||||
if (!tile || !tile->header || !tile->dataSize) continue;
|
||||
auto pcount = tile->header->polyCount;
|
||||
int pcount = tile->header->polyCount;
|
||||
for (int j = 0; j < pcount; j++)
|
||||
{
|
||||
auto& poly = tile->polys[j];
|
||||
auto id = data.find(poly.disjointSetId);
|
||||
dtPoly& poly = tile->polys[j];
|
||||
int id = data.find(poly.disjointSetId);
|
||||
poly.disjointSetId = id;
|
||||
}
|
||||
}
|
||||
|
@ -784,7 +784,7 @@ void Sample_TileMesh::removeAllTiles()
|
||||
|
||||
void Sample_TileMesh::buildAllHulls()
|
||||
{
|
||||
for (auto& h : hulls)
|
||||
for (const hulldef& h : hulls)
|
||||
{
|
||||
m_agentRadius = h.radius;
|
||||
m_agentMaxClimb = h.climb_height;
|
||||
|
@ -550,18 +550,18 @@ void CUIBaseSurface::ParseMaps()
|
||||
{
|
||||
std::regex rgArchiveRegex{ R"([^_]*_(.*)(.bsp.pak000_dir).*)" };
|
||||
std::smatch smRegexMatches;
|
||||
for (const auto& dEntry : fs::directory_iterator("vpk"))
|
||||
for (const fs::directory_entry& dEntry : fs::directory_iterator("vpk"))
|
||||
{
|
||||
std::string svFileName = dEntry.path().string();
|
||||
std::regex_search(svFileName, smRegexMatches, rgArchiveRegex);
|
||||
|
||||
if (smRegexMatches.size() > 0)
|
||||
{
|
||||
if (strcmp(smRegexMatches[1].str().c_str(), "frontend") == 0)
|
||||
if (smRegexMatches[1].str().compare("frontend") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (strcmp(smRegexMatches[1].str().c_str(), "mp_common") == 0)
|
||||
else if (smRegexMatches[1].str().compare("mp_common") == 0)
|
||||
{
|
||||
if (!this->m_MapCombo->Items.Contains("mp_lobby"))
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
||||
|
||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
va_end(args);
|
||||
}/////////////////////////////
|
||||
|
||||
|
4
r5dev/thirdparty/imgui/src/imgui_utility.cpp
vendored
4
r5dev/thirdparty/imgui/src/imgui_utility.cpp
vendored
@ -45,7 +45,7 @@ void Strtrim(char* s)
|
||||
void ImGuiConfig::Load()
|
||||
{
|
||||
fs::path fsPath = "platform\\imgui.json";
|
||||
DevMsg(eDLL_T::MS, "Loading ImGui config file '%s'\n", fsPath.relative_path().string().c_str());
|
||||
DevMsg(eDLL_T::MS, "Loading ImGui config file '%s'\n", fsPath.relative_path().u8string().c_str());
|
||||
|
||||
if (fs::exists(fsPath))
|
||||
{
|
||||
@ -93,7 +93,7 @@ void ImGuiConfig::Save()
|
||||
|
||||
fs::path fsPath = "platform\\imgui.json";
|
||||
|
||||
DevMsg(eDLL_T::MS, "Saving ImGui config file '%s'\n", fsPath.string().c_str());
|
||||
DevMsg(eDLL_T::MS, "Saving ImGui config file '%s'\n", fsPath.relative_path().u8string().c_str());
|
||||
std::ofstream outFile(fsPath, std::ios::out | std::ios::trunc); // Write config file.
|
||||
|
||||
outFile << jsOut.dump(4); // Dump it into config file.
|
||||
|
@ -62,12 +62,12 @@ void CNetAdr2::SetPort(const string& svInPort)
|
||||
void CNetAdr2::SetIPAndPort(string svInAdr)
|
||||
{
|
||||
SetType(netadrtype_t::NA_IP);
|
||||
if (strstr(svInAdr.c_str(), "loopback") || strstr(svInAdr.c_str(), "::1"))
|
||||
if (svInAdr.find("loopback") != string::npos || svInAdr.find("::1") != string::npos)
|
||||
{
|
||||
SetType(netadrtype_t::NA_LOOPBACK);
|
||||
svInAdr = "[127.0.0.1]:" + GetPort(svInAdr);
|
||||
}
|
||||
else if (strstr(svInAdr.c_str(), "localhost"))
|
||||
else if (svInAdr.find("localhost") != string::npos)
|
||||
{
|
||||
svInAdr = "[127.0.0.1]:" + GetPort(svInAdr);
|
||||
}
|
||||
@ -102,7 +102,7 @@ void CNetAdr2::SetIPAndPort(string svInAdr, string svInPort)
|
||||
svInAdr = "127.0.0.1";
|
||||
}
|
||||
|
||||
if (strstr(svInAdr.c_str(), "[") || strstr(svInAdr.c_str(), "]"))
|
||||
if (svInAdr.find("[") != string::npos || svInAdr.find("]") != string::npos)
|
||||
{
|
||||
svInAdr = GetBase(svInAdr);
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ void CLogSystem::DrawHostStats(void) const
|
||||
nHeight = g_nWindowHeight - nHeight;
|
||||
}
|
||||
|
||||
CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, v_Rui_GetFontFace(), m_nFontHeight, nWidth, nHeight, c.r(), c.g(), c.b(), c.a(), (char*)m_pszCon_NPrintf_Buf);
|
||||
CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, v_Rui_GetFontFace(), m_nFontHeight, nWidth, nHeight, c.r(), c.g(), c.b(), c.a(), m_pszCon_NPrintf_Buf);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -37,6 +37,12 @@ struct LogMsg_t
|
||||
class CLogSystem
|
||||
{
|
||||
public:
|
||||
CLogSystem()
|
||||
{
|
||||
m_nFontHeight = 16;
|
||||
memset(m_pszCon_NPrintf_Buf, '\0', sizeof(m_pszCon_NPrintf_Buf));
|
||||
}
|
||||
|
||||
void Update(void);
|
||||
void AddLog(LogType_t type, string svText);
|
||||
void DrawLog(void);
|
||||
@ -48,11 +54,11 @@ public:
|
||||
|
||||
private:
|
||||
Color GetLogColorForType(LogType_t type) const;
|
||||
vector<LogMsg_t> m_vLogs{};
|
||||
int m_nFontHeight = 16;
|
||||
vector<LogMsg_t> m_vLogs;
|
||||
int m_nFontHeight;
|
||||
|
||||
public:
|
||||
char* m_pszCon_NPrintf_Buf[4096]{};
|
||||
char m_pszCon_NPrintf_Buf[4096]{};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -74,7 +74,7 @@ void CFactory::GetFactoriesFromRegister(void)
|
||||
//---------------------------------------------------------------------------------
|
||||
CMemory CFactory::GetFactoryPtr(const string& svFactoryName, bool bVersionLess) const
|
||||
{
|
||||
for (auto& it : m_vFactories) // Loop through the whole vector.
|
||||
for (const FactoryInfo& it : m_vFactories) // Loop through the whole vector.
|
||||
{
|
||||
if (bVersionLess)
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ int HQHull_PrintFunc(const char* fmt, ...)
|
||||
|
||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
va_end(args);
|
||||
}/////////////////////////////
|
||||
|
||||
|
@ -55,14 +55,14 @@ VPKDir_t CPackedStore::GetDirectoryFile(string svPackDirFile) const
|
||||
|
||||
for (size_t i = 0; i < DIR_LOCALE.size(); i++)
|
||||
{
|
||||
if (strstr(svPackDirFile.c_str(), DIR_CONTEXT[i].c_str()))
|
||||
if (svPackDirFile.find(DIR_CONTEXT[i]) != string::npos)
|
||||
{
|
||||
for (size_t j = 0; j < DIR_CONTEXT.size(); j++)
|
||||
{
|
||||
if (strstr(svPackDirFile.c_str(), DIR_CONTEXT[j].c_str()))
|
||||
if (svPackDirFile.find(DIR_CONTEXT[j]) != string::npos)
|
||||
{
|
||||
string svPackDirPrefix = DIR_LOCALE[i] + DIR_LOCALE[i];
|
||||
StringReplace(svPackDirFile, DIR_LOCALE[i].c_str(), svPackDirPrefix.c_str());
|
||||
StringReplace(svPackDirFile, DIR_LOCALE[i], svPackDirPrefix);
|
||||
goto escape;
|
||||
}
|
||||
}
|
||||
@ -234,7 +234,7 @@ nlohmann::json CPackedStore::GetManifest(const string& svWorkSpace, const string
|
||||
{
|
||||
try
|
||||
{
|
||||
ifstream iManifest(fsPath.string().c_str(), std::ios::binary);
|
||||
ifstream iManifest(fsPath.u8string(), std::ios::binary);
|
||||
jsOut = nlohmann::json::parse(iManifest);
|
||||
|
||||
return jsOut;
|
||||
@ -306,9 +306,9 @@ string CPackedStore::StripLocalePrefix(const string& svDirectoryFile) const
|
||||
|
||||
for (size_t i = 0; i < DIR_LOCALE.size(); i++)
|
||||
{
|
||||
if (strstr(svFileName.c_str(), DIR_LOCALE[i].c_str()))
|
||||
if (svFileName.find(DIR_LOCALE[i]) != string::npos)
|
||||
{
|
||||
StringReplace(svFileName, DIR_LOCALE[i].c_str(), "");
|
||||
StringReplace(svFileName, DIR_LOCALE[i], "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user