Skip to content

Commit 1f10a85

Browse files
author
G_Moris
committed
Fixed part 1
1 parent 4d49b80 commit 1f10a85

File tree

14 files changed

+37
-42
lines changed

14 files changed

+37
-42
lines changed

Client/core/CVersionUpdater.Util.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ namespace
391391
SString GetAttribute(const SString& strName) const
392392
{
393393
const SString* pValue = MapFind(attributeMap, strName);
394-
return pValue ? (*pValue).c_str() : "";
394+
return pValue ? *pValue : SStringX("");
395395
}
396396
void SetAttribute(const SString& strName, const SString& strValue) { MapSet(attributeMap, strName, strValue); }
397397
};
@@ -606,7 +606,7 @@ namespace
606606
SaveReportSettings();
607607
}
608608

609-
SString GetFilter() const { return strFilter != "" ? strFilter.c_str() : "+all"; }
609+
SString GetFilter() const { return !strFilter.empty() ? strFilter : SStringX("+all"); }
610610

611611
int GetMinSize() const { return iMinSize; }
612612

Client/loader/Install.Manifest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static void ParseManifestVersion1(std::ifstream& manifest, std::vector<ManifestF
6363
{
6464
uint32_t checksum{};
6565

66-
if (auto[ptr, ec] = std::from_chars(line.data(), line.data() + space, checksum, 16); ec == std::errc{})
66+
if (const auto& [ptr, ec] = std::from_chars(line.data(), line.data() + space, checksum, 16); ec == std::errc{})
6767
{
6868
ManifestFile file{};
6969
file.relativePath = line.substr(space + 1);

Client/loader/Utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ ePathResult GetGamePath(SString& strOutResult, bool bFindIfMissing)
572572
if (strlen(pathList[0].c_str()))
573573
{
574574
// Check for replacement characters (?), to see if there are any (unsupported) unicode characters
575-
if (reinterpret_cast<int>(strchr(pathList[0].c_str(), '?')) > 0)
575+
if (strchr(pathList[0].c_str(), '?') != nullptr)
576576
return GAME_PATH_UNICODE_CHARS;
577577
}
578578

Client/mods/deathmatch/logic/CAntiCheat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ SString CAntiCheat::GetInfo(const SString& acInfo, const SString& sdInfo)
100100

101101
SString strAllowedFiles = "None";
102102
SString strVerifyFiles = acInfo.SplitLeft(",");
103-
SString strEnabledSD = sdInfo == "" ? "None" : sdInfo.c_str();
103+
SString strEnabledSD = sdInfo.empty() ? SStringX("None") : sdInfo;
104104
SString strDisabledAC = acInfo.SplitRight(",");
105-
strDisabledAC = strDisabledAC == "" ? "None" : strDisabledAC.c_str();
105+
strDisabledAC = strDisabledAC.empty() ? SStringX("None") : strDisabledAC;
106106

107107
int iVerifyFiles = atoi(strVerifyFiles);
108108
if (iVerifyFiles == 0)

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,8 @@ void CClientGame::DoPulsePostFrame()
10191019
bool useZoneName = true;
10201020

10211021
const eClientVehicleType vehicleType = (pVehicle) ? CClientVehicleManager::GetVehicleType(pVehicle->GetModel()) : CLIENTVEHICLE_NONE;
1022-
std::string discordState = (pVehicle) ? g_vehicleTypePrefixes.at(vehicleType).c_str() : _("Walking around ").c_str();
1022+
1023+
std::string discordState = pVehicle ? g_vehicleTypePrefixes.at(vehicleType) : _("Walking around ");
10231024

10241025
if (task && task->IsValid())
10251026
{

Client/mods/deathmatch/logic/CClientPerfStat.LuaMemory.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,15 @@ void CClientPerfStatLuaMemoryImpl::GetLuaMemoryStats(CClientPerfStatResult* pRes
297297
int WebBrowserCount = g_pClientGame->GetManager()->GetRenderElementManager()->GetWebBrowserCount();
298298
int VectorGraphicCount = g_pClientGame->GetManager()->GetRenderElementManager()->GetVectorGraphicCount();
299299
TextItemCount = std::max(TextItemCount - 4, 0); // Remove count for radar items
300-
row[c++] = !TextItemCount ? "-" : SString("%d", TextItemCount).c_str();
301-
row[c++] = !DxFontCount ? "-" : SString("%d", DxFontCount).c_str();
302-
row[c++] = !GuiFontCount ? "-" : SString("%d", GuiFontCount).c_str();
303-
row[c++] = !TextureCount ? "-" : SString("%d", TextureCount).c_str();
304-
row[c++] = !ShaderCount ? "-" : SString("%d", ShaderCount).c_str();
305-
row[c++] = !RenderTargetCount ? "-" : SString("%d", RenderTargetCount).c_str();
306-
row[c++] = !ScreenSourceCount ? "-" : SString("%d", ScreenSourceCount).c_str();
307-
row[c++] = !WebBrowserCount ? "-" : SString("%d", WebBrowserCount).c_str();
308-
row[c++] = !VectorGraphicCount ? "-" : SString("%d", VectorGraphicCount).c_str();
300+
row[c++] = !TextItemCount ? "-" : std::to_string(TextItemCount);
301+
row[c++] = !DxFontCount ? "-" : std::to_string(DxFontCount);
302+
row[c++] = !GuiFontCount ? "-" : std::to_string(GuiFontCount);
303+
row[c++] = !TextureCount ? "-" : std::to_string(TextureCount);
304+
row[c++] = !ShaderCount ? "-" : std::to_string(ShaderCount);
305+
row[c++] = !RenderTargetCount ? "-" : std::to_string(RenderTargetCount);
306+
row[c++] = !ScreenSourceCount ? "-" : std::to_string(ScreenSourceCount);
307+
row[c++] = !WebBrowserCount ? "-" : std::to_string(WebBrowserCount);
308+
row[c++] = !VectorGraphicCount ? "-" : std::to_string(VectorGraphicCount);
309309
}
310310

311311
// For each VM
@@ -333,9 +333,9 @@ void CClientPerfStatLuaMemoryImpl::GetLuaMemoryStats(CClientPerfStatResult* pRes
333333

334334
row[c++] = SString("%d KB", LuaMainMemory.Current);
335335
row[c++] = SString("%d KB", LuaMainMemory.Max);
336-
row[c++] = !LuaMainMemory.OpenXMLFiles ? "-" : SString("%d", LuaMainMemory.OpenXMLFiles).c_str();
337-
row[c++] = !LuaMainMemory.Refs ? "-" : SString("%d", LuaMainMemory.Refs).c_str();
338-
row[c++] = !LuaMainMemory.TimerCount ? "-" : SString("%d", LuaMainMemory.TimerCount).c_str();
339-
row[c++] = !LuaMainMemory.ElementCount ? "-" : SString("%d", LuaMainMemory.ElementCount).c_str();
336+
row[c++] = !LuaMainMemory.OpenXMLFiles ? "-" : std::to_string(LuaMainMemory.OpenXMLFiles);
337+
row[c++] = !LuaMainMemory.Refs ? "-" : std::to_string(LuaMainMemory.Refs);
338+
row[c++] = !LuaMainMemory.TimerCount ? "-" : std::to_string(LuaMainMemory.TimerCount);
339+
row[c++] = !LuaMainMemory.ElementCount ? "-" : std::to_string(LuaMainMemory.ElementCount);
340340
}
341341
}

Client/mods/deathmatch/logic/CClientPerfStat.LuaTiming.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,9 @@ void CClientPerfStatLuaTimingImpl::OutputTimingBlock(CClientPerfStatResult* pRes
430430

431431
double total_p = total_s / double(threshList[i]) * 100;
432432

433-
row[c++] = total_p > 0.005 ? SString("%2.2f%%", total_p).c_str() : "-";
434-
row[c++] = total_s > 0.0005 ? SString("%2.3f", total_s).c_str() : "-";
435-
row[c++] = p->prev.calls > 0 ? SString("%d", p->prev.calls).c_str() : "";
433+
row[c++] = total_p > 0.005 ? SString("%2.2f%%", total_p) : SStringX("-");
434+
row[c++] = total_s > 0.0005 ? SString("%2.3f", total_s) : SStringX("-");
435+
row[c++] = p->prev.calls > 0 ? SString("%d", p->prev.calls) : SStringX("");
436436
row[c++] = avg_s > 0.0005 ? SString("%2.3f", avg_s).c_str() : bSubBlock ? "-" : "";
437437
row[c++] = max_s > 0.0005 ? SString("%2.3f", max_s).c_str() : bSubBlock ? "-" : "";
438438
}

Client/mods/deathmatch/logic/CServerIdManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class CServerIdManagerImpl : public CServerIdManager
7070
bool m_bClearedDefaultDirectory;
7171
std::map<CServerIdKey, CServerIdInfo> m_ServerIdMap;
7272
SString m_strServerIdLookupBaseDir;
73-
SString m_strTempErrorDir;
73+
std::string m_strTempErrorDir;
7474
};
7575

7676
///////////////////////////////////////////////////////////////
@@ -266,7 +266,7 @@ SString CServerIdManagerImpl::GetConnectionPrivateDirectory(bool bPreviousVer)
266266

267267
// If ServerId is invalid, use the temp dir
268268
if (strServerId.length() < 10)
269-
return bPreviousVer ? "" : m_strTempErrorDir.c_str();
269+
return bPreviousVer ? "" : m_strTempErrorDir;
270270

271271
// Otherwise fetch the server unique dir
272272
const CServerIdInfo& info = GetServerIdInfo(strServerId);

Client/mods/deathmatch/logic/luadefs/CLuaDrawingDefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ int CLuaDrawingDefs::DxCreateShader(lua_State* luaVM)
11951195
// Replace any path in the error message with our own one
11961196
SString strRootPathWithoutResource = strRootPath.Left(strRootPath.TrimEnd("\\").length() - SStringX(pFileResource->GetName()).length());
11971197
strStatus = strStatus.ReplaceI(strRootPathWithoutResource, "");
1198-
argStream.SetCustomError(bIsRawData ? "raw data" : strFile.c_str(), strStatus);
1198+
argStream.SetCustomError(bIsRawData ? SStringX("raw data") : strFile, strStatus);
11991199
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
12001200
lua_pushboolean(luaVM, false);
12011201
return 1;

Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ int CLuaEngineDefs::EngineLoadCOL(lua_State* luaVM)
320320
{
321321
// Delete it again. We failed
322322
delete pCol;
323-
argStream.SetCustomError(bIsRawData ? "raw data" : input.c_str(), "Error loading COL");
323+
argStream.SetCustomError(bIsRawData ? SStringX("raw data") : input, "Error loading COL");
324324
}
325325
}
326326
else
327327
{
328-
argStream.SetCustomError(bIsRawData ? "raw data" : input.c_str(), "Bad file path");
328+
argStream.SetCustomError(bIsRawData ? SStringX("raw data") : input, "Bad file path");
329329
}
330330
}
331331
}
@@ -392,12 +392,12 @@ int CLuaEngineDefs::EngineLoadDFF(lua_State* luaVM)
392392
{
393393
// Delete it again
394394
delete pDFF;
395-
argStream.SetCustomError(bIsRawData ? "raw data" : input.c_str(), "Error loading DFF");
395+
argStream.SetCustomError(bIsRawData ? SStringX("raw data") : input, "Error loading DFF");
396396
}
397397
}
398398
else
399399
{
400-
argStream.SetCustomError(bIsRawData ? "raw data" : input.c_str(), "Bad file path");
400+
argStream.SetCustomError(bIsRawData ? SStringX("raw data") : input, "Bad file path");
401401
}
402402
}
403403
}
@@ -466,11 +466,11 @@ int CLuaEngineDefs::EngineLoadTXD(lua_State* luaVM)
466466
{
467467
// Delete it again
468468
delete pTXD;
469-
argStream.SetCustomError(bIsRawData ? "raw data" : input.c_str(), "Error loading TXD");
469+
argStream.SetCustomError(bIsRawData ? SStringX("raw data") : input, "Error loading TXD");
470470
}
471471
}
472472
else
473-
argStream.SetCustomError(bIsRawData ? "raw data" : input.c_str(), "Bad file path");
473+
argStream.SetCustomError(bIsRawData ? SStringX("raw data") : input, "Bad file path");
474474
}
475475
}
476476
}
@@ -531,12 +531,12 @@ int CLuaEngineDefs::EngineLoadIFP(lua_State* luaVM)
531531
}
532532
else
533533
{
534-
argStream.SetCustomError(bIsRawData ? "raw data" : input.c_str(), "Error loading IFP");
534+
argStream.SetCustomError(bIsRawData ? SStringX("raw data") : input, "Error loading IFP");
535535
}
536536
}
537537
else
538538
{
539-
argStream.SetCustomError(bIsRawData ? "raw data" : input.c_str(), "Bad file path");
539+
argStream.SetCustomError(bIsRawData ? SStringX("raw data") : input, "Bad file path");
540540
}
541541
}
542542
}

0 commit comments

Comments
 (0)