diff --git a/src/C4Group.cpp b/src/C4Group.cpp index 3655193f..0646b19d 100644 --- a/src/C4Group.cpp +++ b/src/C4Group.cpp @@ -1610,7 +1610,7 @@ bool C4Group::DeleteEntry(const char *szFilename, bool fRecycle) case GRPF_Folder: StdFile.Close(); char szPath[_MAX_FNAME + 1]; - FormatWithNull(szPath, "{}" DirSep "{}", FileName, szFilename); + FormatWithNull(szPath, "{}" DirSep "{}", +FileName, szFilename); if (fRecycle) { @@ -1781,7 +1781,7 @@ bool C4Group::ExtractEntry(const char *szFilename, const char *szExtractTo) break; case GRPF_Folder: // Copy item from folder to target char szPath[_MAX_FNAME + 1]; - FormatWithNull(szPath, "{}" DirSep "{}", FileName, szFilename); + FormatWithNull(szPath, "{}" DirSep "{}", +FileName, szFilename); if (!CopyItem(szPath, szTargetFName)) return Error("ExtractEntry: Cannot copy item"); break; @@ -2194,7 +2194,7 @@ uint32_t C4Group::EntryTime(const char *szFilename) break; case GRPF_Folder: char szPath[_MAX_FNAME + 1]; - FormatWithNull(szPath, "{}" DirSep "{}", FileName, szFilename); + FormatWithNull(szPath, "{}" DirSep "{}", +FileName, szFilename); iTime = FileTime(szPath); break; } @@ -2390,7 +2390,7 @@ bool C4Group::EnsureChildFilePtr(C4Group *pChild) // Open standard file is not the child file ...or StdFile ptr does not match pChild->FilePtr char szChildPath[_MAX_PATH + 1]; - FormatWithNull(szChildPath, "{}" DirSep "{}", FileName, GetFilename(pChild->FileName)); + FormatWithNull(szChildPath, "{}" DirSep "{}", +FileName, GetFilename(pChild->FileName)); if (!ItemIdentical(StdFile.Name, szChildPath)) { // Reopen correct child stdfile diff --git a/src/C4Language.cpp b/src/C4Language.cpp index ce66b919..be6bf39c 100644 --- a/src/C4Language.cpp +++ b/src/C4Language.cpp @@ -58,7 +58,7 @@ bool C4Language::Init() if (PackDirectory.Open(C4CFN_Languages)) while (PackDirectory.FindNextEntry("*.c4g", strEntry)) { - FormatWithNull(strPackFilename, "{}" DirSep "{}", C4CFN_Languages, strEntry); + FormatWithNull(strPackFilename, "{}" DirSep "{}", +C4CFN_Languages, +strEntry); pPack = new C4Group(); if (pPack->Open(strPackFilename)) { diff --git a/src/C4Network2.cpp b/src/C4Network2.cpp index 78095d4d..56734dd3 100644 --- a/src/C4Network2.cpp +++ b/src/C4Network2.cpp @@ -1951,7 +1951,7 @@ bool C4Network2::CreateDynamic(bool fInit) Log(C4ResStrTableKey::IDS_NET_SAVING); // compose file name char szDynamicBase[_MAX_PATH + 1], szDynamicFilename[_MAX_PATH + 1]; - FormatWithNull(szDynamicBase, "{}Dyn{}", Config.Network.WorkPath, GetFilename(Game.ScenarioFilename), _MAX_PATH); + FormatWithNull(szDynamicBase, "{}Dyn{}", +Config.Network.WorkPath, GetFilename(Game.ScenarioFilename), _MAX_PATH); if (!ResList.FindTempResFileName(szDynamicBase, szDynamicFilename)) Log(C4ResStrTableKey::IDS_NET_SAVE_ERR_CREATEDYNFILE); // save dynamic data diff --git a/src/C4ScriptHost.cpp b/src/C4ScriptHost.cpp index f4b66529..e5956620 100644 --- a/src/C4ScriptHost.cpp +++ b/src/C4ScriptHost.cpp @@ -194,10 +194,10 @@ void C4DefScriptHost::AfterLink() for (int32_t cnt = 0; cnt < Def->ActNum; cnt++) { C4ActionDef *pad = &Def->ActMap[cnt]; - FormatWithNull(WhereStr, "Action {}: StartCall", pad->Name); pad->StartCall = GetSFuncWarn(pad->SStartCall, CallAccess, WhereStr); - FormatWithNull(WhereStr, "Action {}: PhaseCall", pad->Name); pad->PhaseCall = GetSFuncWarn(pad->SPhaseCall, CallAccess, WhereStr); - FormatWithNull(WhereStr, "Action {}: EndCall", pad->Name); pad->EndCall = GetSFuncWarn(pad->SEndCall, CallAccess, WhereStr); - FormatWithNull(WhereStr, "Action {}: AbortCall", pad->Name); pad->AbortCall = GetSFuncWarn(pad->SAbortCall, CallAccess, WhereStr); + FormatWithNull(WhereStr, "Action {}: StartCall", +pad->Name); pad->StartCall = GetSFuncWarn(pad->SStartCall, CallAccess, WhereStr); + FormatWithNull(WhereStr, "Action {}: PhaseCall", +pad->Name); pad->PhaseCall = GetSFuncWarn(pad->SPhaseCall, CallAccess, WhereStr); + FormatWithNull(WhereStr, "Action {}: EndCall", +pad->Name); pad->EndCall = GetSFuncWarn(pad->SEndCall, CallAccess, WhereStr); + FormatWithNull(WhereStr, "Action {}: AbortCall", +pad->Name); pad->AbortCall = GetSFuncWarn(pad->SAbortCall, CallAccess, WhereStr); } Def->TimerCall = GetSFuncWarn(Def->STimerCall, CallAccess, "TimerCall"); } diff --git a/src/C4Strings.h b/src/C4Strings.h index fb3e1a33..3f16bf81 100644 --- a/src/C4Strings.h +++ b/src/C4Strings.h @@ -181,19 +181,19 @@ struct C4NullableBasicStringView using C4NullableStringView = C4NullableBasicStringView; -template +template requires (!std::disjunction_v>...>) void FormatWithNull(char(&buf)[N], const std::format_string fmt, Args&&...args) { *std::format_to_n(buf, N - 1, fmt, std::forward(args)...).out = '\0'; } -template +template requires (!std::disjunction_v>...>) void FormatWithNull(std::array &buf, const std::format_string fmt, Args&&...args) { *std::format_to_n(buf.begin(), N - 1, fmt, std::forward(args)...).out = '\0'; } -template +template requires (!std::disjunction_v>...>) void FormatWithNull(const std::span buf, const std::format_string fmt, Args &&...args) { *std::format_to_n(buf.begin(), buf.size() - 1, fmt, std::forward(args)...).out = '\0';