diff --git a/Sources/Plasma/Apps/plClient/plClient.cpp b/Sources/Plasma/Apps/plClient/plClient.cpp index bdc5528d..11c01a74 100644 --- a/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/Sources/Plasma/Apps/plClient/plClient.cpp @@ -774,8 +774,8 @@ bool plClient::MsgReceive(plMessage* msg) plEventCallbackMsg* callback = plEventCallbackMsg::ConvertNoRef(msg); if( callback ) { - plString str = plString::Format("Callback event from %s\n", callback->GetSender() - ? callback->GetSender()->GetName().c_str() + plString str = plFormat("Callback event from {}\n", callback->GetSender() + ? callback->GetSender()->GetName() : "Unknown"); hsStatusMessage(str.c_str()); static int gotten = 0; diff --git a/Sources/Plasma/Apps/plFileEncrypt/main.cpp b/Sources/Plasma/Apps/plFileEncrypt/main.cpp index 502119f2..3e0885be 100644 --- a/Sources/Plasma/Apps/plFileEncrypt/main.cpp +++ b/Sources/Plasma/Apps/plFileEncrypt/main.cpp @@ -108,12 +108,12 @@ void EncryptFiles(const plFileName& dir, const char* ext, bool encrypt) { if (encrypt) { - printf("encrypting: %s\n", iter->GetFileName().c_str()); + plPrintf("encrypting: {}\n", iter->GetFileName()); plEncryptedStream::FileEncrypt(*iter); } else - { - printf("decrypting: %s\n", iter->GetFileName().c_str()); + { + plPrintf("decrypting: {}\n", iter->GetFileName()); plEncryptedStream::FileDecrypt(*iter); } } diff --git a/Sources/Plasma/Apps/plFileSecure/main.cpp b/Sources/Plasma/Apps/plFileSecure/main.cpp index 5210bae4..ee69b5aa 100644 --- a/Sources/Plasma/Apps/plFileSecure/main.cpp +++ b/Sources/Plasma/Apps/plFileSecure/main.cpp @@ -110,7 +110,7 @@ void SecureFiles(const plFileName& dir, const plString& ext, uint32_t* key) std::vector files = plFileSystem::ListDir(dir, ext.c_str()); for (auto iter = files.begin(); iter != files.end(); ++iter) { - printf("securing: %s\n", iter->GetFileName().c_str()); + plPrintf("securing: {}\n", iter->GetFileName()); plSecureStream::FileEncrypt(*iter, key); } } diff --git a/Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp b/Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp index 1ceb4e46..b4a73fee 100644 --- a/Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp +++ b/Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp @@ -240,7 +240,7 @@ public: const plPageInfo& info = page->GetPageInfo(); plFileName fileName = plFileName::Join(fOutputDir, - plString::Format("%s_%s.csv", info.GetAge().c_str(), info.GetPage().c_str())); + plFormat("{}_{}.csv", info.GetAge(), info.GetPage())); fStream.Open(fileName, "wt"); page->LoadKeys(); diff --git a/Sources/Plasma/Apps/plPageOptimizer/main.cpp b/Sources/Plasma/Apps/plPageOptimizer/main.cpp index 4aa284b4..11d794d2 100644 --- a/Sources/Plasma/Apps/plPageOptimizer/main.cpp +++ b/Sources/Plasma/Apps/plPageOptimizer/main.cpp @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) } plFileName filename = argv[1]; - printf("Optimizing %s...", filename.GetFileName().c_str()); + plPrintf("Optimizing {}...", filename); #ifndef _DEBUG try { diff --git a/Sources/Plasma/Apps/plPythonPack/main.cpp b/Sources/Plasma/Apps/plPythonPack/main.cpp index eede46de..9a836ab2 100644 --- a/Sources/Plasma/Apps/plPythonPack/main.cpp +++ b/Sources/Plasma/Apps/plPythonPack/main.cpp @@ -84,11 +84,11 @@ void WritePythonFile(const plFileName &fileName, const plFileName &path, hsStrea if (!pyStream.Open(filePath) || !glueStream.Open(glueFile)) { - printf("Unable to open path %s, ", filePath.AsString().c_str()); + plPrintf("Unable to open path {}, ", filePath); return; } - printf("==Packing %s, ", fileName.AsString().c_str()); + plPrintf("==Packing {}, ", fileName); pyStream.FastFwd(); uint32_t pyFileSize = pyStream.GetPosition(); @@ -168,20 +168,20 @@ void WritePythonFile(const plFileName &fileName, const plFileName &path, hsStrea } pythonCode = PythonInterface::CompileString(code, fileName); hsAssert(pythonCode,"Not sure why this didn't compile the second time???"); - printf("an import file "); + fputs("an import file ", stdout); } else - printf("a PythonFile modifier(tm) "); + fputs("a PythonFile modifier(tm) ", stdout); } else { - printf("......blast! Error during run-code!\n"); + fputs("......blast! Error during run-code!\n", stdout); char* errmsg; int chars_read = PythonInterface::getOutputAndReset(&errmsg); if (chars_read > 0) { - printf("%s\n", errmsg); + plPrintf("{}\n", errmsg); } } } @@ -193,20 +193,20 @@ void WritePythonFile(const plFileName &fileName, const plFileName &path, hsStrea char* pycode; PythonInterface::DumpObject(pythonCode,&pycode,&size); - printf("\n"); + fputc('\n', stdout); // print any message after each module char* errmsg; int chars_read = PythonInterface::getOutputAndReset(&errmsg); if (chars_read > 0) { - printf("%s\n", errmsg); + plPrintf("{}\n", errmsg); } s->WriteLE32(size); s->Write(size, pycode); } else { - printf("......blast! Compile error!\n"); + fputs("......blast! Compile error!\n", stdout); s->WriteLE32(0); PyErr_Print(); @@ -216,7 +216,7 @@ void WritePythonFile(const plFileName &fileName, const plFileName &path, hsStrea int chars_read = PythonInterface::getOutputAndReset(&errmsg); if (chars_read > 0) { - printf("%s\n", errmsg); + plPrintf("{}\n", errmsg); } } @@ -353,16 +353,16 @@ void FindPackages(std::vector& fileNames, std::vector& p void PackDirectory(const plFileName& dir, const plFileName& rootPath, const plFileName& pakName, std::vector& extraDirs, bool packSysAndPlasma = false) { - printf("\nCreating %s using the contents of %s\n", pakName.AsString().c_str(), dir.AsString().c_str()); - printf("Changing working directory to %s\n", rootPath.AsString().c_str()); + plPrintf("\nCreating {} using the contents of {}\n", pakName, dir); + plPrintf("Changing working directory to {}\n", rootPath); if (!plFileSystem::SetCWD(rootPath)) { - printf("ERROR: Directory change to %s failed for some reason\n", rootPath.AsString().c_str()); - printf("Unable to continue with the packing of this directory, aborting...\n"); + plPrintf("ERROR: Directory change to {} failed for some reason\n", rootPath); + fputs("Unable to continue with the packing of this directory, aborting...\n", stdout); return; } else - printf("Directory changed to %s\n", rootPath.AsString().c_str()); + plPrintf("Directory changed to {}\n", rootPath); std::vector fileNames; std::vector pathNames; @@ -371,7 +371,7 @@ void PackDirectory(const plFileName& dir, const plFileName& rootPath, const plFi FindPackages(fileNames, pathNames, dir); if (packSysAndPlasma) { - printf("Adding the system and plasma directories to this pack file\n"); + fputs("Adding the system and plasma directories to this pack file\n", stdout); plFileName tempPath; tempPath = plFileName::Join(dir, "system"); FindFiles(fileNames, pathNames, tempPath); @@ -431,15 +431,15 @@ void PackDirectory(const plFileName& dir, const plFileName& rootPath, const plFi void PrintUsage() { - printf("Usage:\n"); - printf("plPythonPack [directory to pack...]\n"); - printf("NOTE: the directory to pack must have full system and plasma dirs and\n"); - printf(" must be a relative path to the current working directory\n"); + fputs("Usage:\n", stdout); + fputs("plPythonPack [directory to pack...]\n", stdout); + fputs("NOTE: the directory to pack must have full system and plasma dirs and\n", stdout); + fputs(" must be a relative path to the current working directory\n", stdout); } int main(int argc, char *argv[]) { - printf("The Python Pack Utility\n"); + fputs("The Python Pack Utility\n", stdout); plFileName baseWorkingDir = plFileSystem::GetCWD(); diff --git a/Sources/Plasma/CoreLib/plFormat.cpp b/Sources/Plasma/CoreLib/plFormat.cpp index 8122166f..61d919d6 100644 --- a/Sources/Plasma/CoreLib/plFormat.cpp +++ b/Sources/Plasma/CoreLib/plFormat.cpp @@ -449,7 +449,7 @@ PL_FORMAT_IMPL(double) PL_FORMAT_IMPL(char) { /* Note: The use of unsigned here is not a typo -- we only format decimal - values with a sign, so we can convert everything else to unsigned. */ + values with a sign, so we can convert everything else to unsigned. */ switch (format.fDigitClass) { case plFormat_Private::kDigitBin: return _formatNumeric(format, value, 2); diff --git a/Sources/Plasma/CoreLib/plFormat.h b/Sources/Plasma/CoreLib/plFormat.h index add69600..ba632045 100644 --- a/Sources/Plasma/CoreLib/plFormat.h +++ b/Sources/Plasma/CoreLib/plFormat.h @@ -251,4 +251,17 @@ plString plFormat(const char *fmt_str, _Type value, _Args... args) return plFormat_Private::_IFormat(data, args...); } +template +void plPrintf(FILE *fd, const char *fmt_str, _Type value, _Args... args) +{ + plString output = plFormat(fmt_str, value, args...); + fwrite(output.c_str(), sizeof(char), output.GetSize(), fd); +} + +template +void plPrintf(const char *fmt_str, _Type value, _Args... args) +{ + plPrintf(stdout, fmt_str, value, args...); +} + #endif // plFormat_Defined diff --git a/Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.cpp b/Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.cpp index cc1fa04b..2d965a03 100644 --- a/Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.cpp +++ b/Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.cpp @@ -123,10 +123,10 @@ void plAnimDebugList::ShowReport() plLayerAnimation *layerAnim = plLayerAnimation::ConvertNoRef(layer); if (layerAnim) { - str = plString::Format("%s: %s %.3f (%.3f)", mat->GetKeyName().c_str(), layerAnim->GetKeyName().c_str(), + str = plFormat("{}: {} {.3f} ({.3f})", mat->GetKeyName(), layerAnim->GetKeyName(), layerAnim->GetTimeConvert().CurrentAnimTime(), layerAnim->GetTimeConvert().WorldToAnimTimeNoUpdate(hsTimer::GetSysSeconds())); - txt.DrawString(x, y, str.c_str()); + txt.DrawString(x, y, str); y += yOff; } layer = layer->GetOverLay(); @@ -147,17 +147,17 @@ void plAnimDebugList::ShowReport() if (!mod) continue; - str = plString::Format(" %s", so->GetKeyName().c_str()); - txt.DrawString(x, y, str.c_str()); + str = plFormat(" {}", so->GetKeyName()); + txt.DrawString(x, y, str); y += yOff; for (j = 0; j < mod->GetNumATCAnimations(); j++) { plAGAnimInstance *anim = mod->GetATCAnimInstance(j); - str = plString::Format(" %s: %.3f (%.3f)", anim->GetAnimation()->GetName().c_str(), + str = plFormat(" {}: {.3f} ({.3f})", anim->GetAnimation()->GetName(), anim->GetTimeConvert()->CurrentAnimTime(), anim->GetTimeConvert()->WorldToAnimTimeNoUpdate(hsTimer::GetSysSeconds())); - txt.DrawString(x, y, str.c_str()); + txt.DrawString(x, y, str); y += yOff; } } diff --git a/Sources/Plasma/FeatureLib/pfAudio/plListener.cpp b/Sources/Plasma/FeatureLib/pfAudio/plListener.cpp index d893d216..e8081859 100644 --- a/Sources/Plasma/FeatureLib/pfAudio/plListener.cpp +++ b/Sources/Plasma/FeatureLib/pfAudio/plListener.cpp @@ -183,19 +183,23 @@ bool plListener::IEval(double secs, float del, uint32_t dirty) if( fPrintDbgInfo ) { plString str; - str = plString::Format( "Direction: (%3.2f,%3.2f,%3.2f) from %s", dir.fX, dir.fY, dir.fZ, ( facingType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName().c_str() : "VCam" ); + str = plFormat("Direction: ({3.2f},{3.2f},{3.2f}) from {}", dir.fX, dir.fY, dir.fZ, + (facingType == kObject) ? pRefObject->GetKeyName() : "VCam"); plDebugText::Instance().DrawString( x, y, str.c_str(), (uint32_t)0xffffffff ); y += 12; - str = plString::Format( "Up: (%3.2f,%3.2f,%3.2f) from %s", up.fX, up.fY, up.fZ, ( facingType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName().c_str() : "VCam" ); + str = plFormat("Up: ({3.2f},{3.2f},{3.2f}) from {}", up.fX, up.fY, up.fZ, + (facingType == kObject) ? pRefObject->GetKeyName() : "VCam"); plDebugText::Instance().DrawString( x, y, str.c_str(), (uint32_t)0xffffffff ); y += 12; - str = plString::Format( "Position: (%3.2f,%3.2f,%3.2f) from %s", position.fX, position.fY, position.fZ, ( posType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName().c_str() : "VCam" ); + str = plFormat("Position: ({3.2f},{3.2f},{3.2f}) from {}", position.fX, position.fY, position.fZ, + (posType == kObject) ? pRefObject->GetKeyName() : "VCam"); plDebugText::Instance().DrawString( x, y, str.c_str(), (uint32_t)0xffffffff ); y += 12; - str = plString::Format( "Velocity: (%3.2f,%3.2f,%3.2f) from %s", velocity.fX, velocity.fY, velocity.fZ, ( velType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName().c_str() : "VCam" ); + str = plFormat("Velocity: ({3.2f},{3.2f},{3.2f}) from {}", velocity.fX, velocity.fY, velocity.fZ, + (velType == kObject) ? pRefObject->GetKeyName() : "VCam"); plDebugText::Instance().DrawString( x, y, str.c_str(), (uint32_t)0xffffffff ); y += 12; } diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsole.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsole.cpp index 71d46461..bad5b98a 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsole.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsole.cpp @@ -280,7 +280,7 @@ bool pfConsole::MsgReceive( plMessage *msg ) plString prefix = plProduct::ShortName(); // List all of the PNG indices we have taken up already... - plString pattern = plString::Format("%s*.png", prefix.c_str()); + plString pattern = plFormat("{}*.png", prefix); std::vector images = plFileSystem::ListDir(screenshots, pattern.c_str()); std::set indices; std::for_each(images.begin(), images.end(), @@ -298,7 +298,7 @@ bool pfConsole::MsgReceive( plMessage *msg ) } // Got our num, save the screenshot. - plFileName fn = plString::Format("%s%04d.png", prefix.c_str(), num); + plFileName fn = plFormat("{}{_04}.png", prefix, num); plPNG::Instance().WriteToFile(plFileName::Join(screenshots, fn), capMsg->GetMipmap()); AddLineF("Saved screenshot as '%s'", fn.AsString().c_str()); @@ -325,8 +325,8 @@ bool pfConsole::MsgReceive( plMessage *msg ) { // Change the following line once we have a better way of reporting // errors in the parsing - plString str = plString::Format("Error parsing %s", cmd->GetString()); - plString msg = plString::Format("%s:\n\nCommand: '%s'\n%s", fEngine->GetErrorMsg(), fEngine->GetLastErrorLine(), + plString str = plFormat("Error parsing {}", cmd->GetString()); + plString msg = plFormat("{}:\n\nCommand: '{}'\n{}", fEngine->GetErrorMsg(), fEngine->GetLastErrorLine(), #ifdef HS_DEBUGGING "" ); diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp index 496a0e95..5e66a96a 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp @@ -2872,7 +2872,7 @@ PF_CONSOLE_CMD( Camera, // groupName PF_CONSOLE_CMD( Camera, SwitchTo, "string cameraName", "Switch to the named camera") { char str[256]; - plString foo = plString::Format("%s_", (char*)params[0]); + plString foo = plFormat("{}_", (char*)params[0]); plKey key = FindObjectByNameAndType(foo, "plCameraModifier1", "", str, true); PrintString(str); @@ -4204,7 +4204,7 @@ PF_CONSOLE_CMD( Access, { char str[256]; char* preFix = params[0]; - plString name = plString::Format("%s_plMorphSequence_0", preFix); + plString name = plFormat("{}_plMorphSequence_0", preFix); plKey key = FindObjectByName(name, plMorphSequence::Index(), "", str); PrintString(str); if (!key) @@ -4229,7 +4229,7 @@ PF_CONSOLE_CMD( Access, { char str[256]; char* preFix = params[0]; - plString name = plString::Format("%s_plMorphSequence_2", preFix); + plString name = plFormat("{}_plMorphSequence_2", preFix); plKey key = FindObjectByName(name, plMorphSequence::Index(), "", str); PrintString(str); if (!key) @@ -4250,7 +4250,7 @@ PF_CONSOLE_CMD( Access, { char str[256]; char* preFix = params[0]; - plString name = plString::Format("%s_plMorphSequence_2", preFix); + plString name = plFormat("{}_plMorphSequence_2", preFix); plKey key = FindObjectByName(name, plMorphSequence::Index(), "", str); PrintString(str); if (!key) @@ -4405,7 +4405,7 @@ PF_CONSOLE_CMD( Access, seq->Activate(); - PrintString(plString::Format("%s Active\n", seq->GetKey()->GetName().c_str()).c_str()); + PrintString(plFormat("{} Active\n", seq->GetKey()->GetName()).c_str()); } PF_CONSOLE_CMD( Access, @@ -4422,7 +4422,7 @@ PF_CONSOLE_CMD( Access, seq->DeActivate(); - PrintString(plString::Format("%s Unactive\n", seq->GetKey()->GetName().c_str()).c_str()); + PrintString(plFormat("{} Unactive\n", seq->GetKey()->GetName()).c_str()); } PF_CONSOLE_CMD( Access, @@ -4444,8 +4444,7 @@ PF_CONSOLE_CMD( Access, seq->SetUseSharedMesh(true); seq->AddSharedMesh(item->fMeshes[plClothingItem::kLODHigh]); - PrintString(plString::Format("%s on item %s\n", seq->GetKey()->GetName().c_str(), - (char *)params[0]).c_str()); + PrintString(plFormat("{} on item {}\n", seq->GetKey()->GetName(), (char *)params[0]).c_str()); } #include "pfSurface/plFadeOpacityMod.h" @@ -6869,8 +6868,7 @@ PF_CONSOLE_CMD( Python, plString args; if (numParams > 1) { - const char* tmp = params[1]; - args = plString::Format("(%s,)", tmp); + args = plFormat("({},)", (char*)params[1]); } else args = "()"; diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp index 0517fe9c..23232190 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp @@ -298,14 +298,14 @@ static bool DumpSpecificMsgInfo(plMessage* msg, plString& info) const plPageInfo* pageInfo = plKeyFinder::Instance().GetLocationInfo(loc); if (pageInfo) - info += plString::Format("%s-%s ", pageInfo->GetAge().c_str(), pageInfo->GetPage().c_str()); + info += plFormat("{}-{} ", pageInfo->GetAge(), pageInfo->GetPage()); } } break; case plClientMsg::kLoadAgeKeys: case plClientMsg::kReleaseAgeKeys: - info += plString::Format(" - Age: %s", clientMsg->GetAgeName().c_str()); + info += plFormat(" - Age: {}", clientMsg->GetAgeName()); break; } return true; @@ -321,7 +321,7 @@ static bool DumpSpecificMsgInfo(plMessage* msg, plString& info) GetType(kOnRequest); GetType(kOnRemove); GetType(kOnReplace); - info = plString::Format("Obj: %s RefType: %s", refMsg->GetRef()->GetKeyName().c_str(), typeName); + info = plFormat("Obj: {} RefType: {}", refMsg->GetRef()->GetKeyName(), typeName); return true; } diff --git a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp index c4565874..f7f3bd41 100644 --- a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp +++ b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp @@ -152,11 +152,11 @@ bool pfConsoleEngine::PrintCmdHelp( char *name, void (*PrintFn)( const char * if( group == pfConsoleCmdGroup::GetBaseGroup() ) PrintFn("Base commands and groups:"); else - PrintFn(plString::Format("Group %s:", group->GetName()).c_str()); + PrintFn(plFormat("Group {}:", group->GetName()).c_str()); PrintFn(" Subgroups:"); for( subGrp = group->GetFirstSubGroup(); subGrp != nil; subGrp = subGrp->GetNext() ) { - PrintFn(plString::Format(" %s", subGrp->GetName()).c_str()); + PrintFn(plFormat(" {}", subGrp->GetName()).c_str()); } PrintFn(" Commands:"); for( cmd = group->GetFirstCommand(); cmd != nil; cmd = cmd->GetNext() ) @@ -167,7 +167,7 @@ bool pfConsoleEngine::PrintCmdHelp( char *name, void (*PrintFn)( const char * } tempString[ i ] = 0; - PrintFn(plString::Format(" %s: %s", cmd->GetName(), tempString).c_str()); + PrintFn(plFormat(" {}: {}", cmd->GetName(), tempString).c_str()); } return true; @@ -182,9 +182,9 @@ bool pfConsoleEngine::PrintCmdHelp( char *name, void (*PrintFn)( const char * } /// That's it! - PrintFn(plString::Format("\nHelp for the command %s:", cmd->GetName()).c_str()); - PrintFn(plString::Format("\\i%s", cmd->GetHelp()).c_str()); - PrintFn(plString::Format("\\iUsage: %s", cmd->GetSignature()).c_str()); + PrintFn(plFormat("\nHelp for the command {}:", cmd->GetName()).c_str()); + PrintFn(plFormat("\\i{}", cmd->GetHelp()).c_str()); + PrintFn(plFormat("\\iUsage: {}", cmd->GetSignature()).c_str()); return true; } @@ -368,12 +368,9 @@ bool pfConsoleEngine::RunCommand( char *line, void (*PrintFn)( const char * ) cmd->GetSigEntry( (uint8_t)numParams ) != pfConsoleCmd::kNone ) ) { // Print help string and return - static char string[ 512 ]; - ISetErrorMsg( "" ); // Printed on next line - PrintFn( "Invalid parameters to command" ); - sprintf( string, "Usage: %s", cmd->GetSignature() ); - PrintFn( string ); + PrintFn("Invalid parameters to command"); + PrintFn(plFormat("Usage: {}", cmd->GetSignature()).c_str()); return false; } diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.cpp index 54883305..0386eeeb 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.cpp @@ -126,7 +126,7 @@ plString pfGUICtrlGenerator::IGetNextKeyName( const char *prefix ) { static uint32_t keyCount = 0; - return plString::Format( "%s%d", prefix, keyCount++ ); + return plFormat("{}{}", prefix, keyCount++); } //// IAddKey ///////////////////////////////////////////////////////////////// diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.cpp index f229e227..2c1737e1 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.cpp @@ -184,7 +184,7 @@ pfGUIListPicture::pfGUIListPicture( plKey mipKey, bool respectAlpha ) : pfGUILis { // Gotta make and grab an uncompressed one plMipmap *uncompBuffer = hsCodecManager::Instance().CreateUncompressedMipmap( mip, hsCodecManager::k32BitDepth ); - plString str = plString::Format( "%s_uncomp", mip->GetKeyName().c_str() ); + plString str = plFormat("{}_uncomp", mip->GetKeyName()); fMipmapKey = hsgResMgr::ResMgr()->NewKey( str, uncompBuffer, fMipmapKey->GetUoid().GetLocation() ); fMipmapKey->RefObject(); } diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.cpp index 380ace2b..a6608d83 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.cpp @@ -97,7 +97,7 @@ class pfPopUpKeyGenerator plKey CreateKey( hsKeyedObject *ko ) { - plString name = plString::Format( "%s-%d", fPrefix, fKeyCount++ ); + plString name = plFormat("{}-{}", fPrefix, fKeyCount++); return hsgResMgr::ResMgr()->NewKey( name, ko, fLoc ); } diff --git a/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp b/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp index 13b45121..0b2a2506 100644 --- a/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp +++ b/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp @@ -3036,11 +3036,11 @@ plLayerBink *pfJournalBook::IMakeMovieLayer(pfEsHTMLChunk *chunk, uint16_t x, ui static int uniqueSuffix = 0; plString buff; - buff = plString::Format("%s_%d_ml", GetKey()->GetName().c_str(), uniqueSuffix); + buff = plFormat("{}_{}_ml", GetKey()->GetName(), uniqueSuffix); layer = new plLayer; hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); - buff = plString::Format("%s_%d_m", GetKey()->GetName().c_str(), uniqueSuffix++); + buff = plFormat("{}_{}_m", GetKey()->GetName(), uniqueSuffix++); movieLayer = new plLayerBink; hsgResMgr::ResMgr()->NewKey(buff, movieLayer, GetKey()->GetUoid().GetLocation()); movieLayer->GetKey()->RefObject(); // we want to own a ref so we can nuke it at will @@ -3183,7 +3183,7 @@ plLayerInterface *pfJournalBook::IMakeBaseLayer(plMipmap *image) // We'll need a unique name. This is a hack, but an effective hack. static int uniqueSuffix = 0; - plString buff = plString::Format("%s_%d", GetKey()->GetName().c_str(), uniqueSuffix++); + plString buff = plFormat("{}_{}", GetKey()->GetName(), uniqueSuffix++); plLayer* layer = new plLayer; hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); @@ -3237,7 +3237,7 @@ plLayerInterface *pfJournalBook::IMakeDecalLayer(pfEsHTMLChunk *decalChunk, plMi // We'll need a unique name. This is a hack, but an effective hack. static int uniqueSuffix = 0; - plString buff = plString::Format("%s_%d_d", GetKey()->GetName().c_str(), uniqueSuffix++); + plString buff = plFormat("{}_{}_d", GetKey()->GetName(), uniqueSuffix++); plLayer* layer = new plLayer; hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); diff --git a/Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp b/Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp index c9811f23..f74d8788 100644 --- a/Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp +++ b/Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp @@ -203,7 +203,7 @@ void XMLCALL LocalizationXMLFile::StartTag(void *userData, const XML_Char *eleme else if (wElement == "translation") file->IHandleTranslationTag(parentTag, newTag); else - file->AddError(plString::Format("Unknown tag %s found", wElement.c_str())); + file->AddError(plFormat("Unknown tag {} found", wElement)); } void XMLCALL LocalizationXMLFile::EndTag(void *userData, const XML_Char *element) @@ -496,7 +496,7 @@ LocalizationXMLFile::set LocalizationDatabase::IMergeSetData(LocalizationXMLFile firstSet[curElement->first] = curElement->second; else // merge the element in firstSet[curElement->first] = IMergeElementData(firstSet[curElement->first], curElement->second, fileName, - plString::Format("%s.%s", path.c_str(), curElement->first.c_str())); + plFormat("{}.{}", path, curElement->first)); } return firstSet; @@ -515,7 +515,7 @@ LocalizationXMLFile::age LocalizationDatabase::IMergeAgeData(LocalizationXMLFile firstAge[curSet->first] = curSet->second; else // merge the data in firstAge[curSet->first] = IMergeSetData(firstAge[curSet->first], curSet->second, fileName, - plString::Format("%s.%s", path.c_str(), curSet->first.c_str())); + plFormat("{}.{}", path, curSet->first)); } return firstAge; @@ -919,7 +919,7 @@ void pfLocalizationDataMgr::IConvertSet(LocSetInfo *setInfo, const plString & cu LocElementInfo elementInfo; elementInfo.fElement = curElement->second; - IConvertElement(&elementInfo, plString::Format("%s.%s", curPath.c_str(), curElement->first.c_str())); + IConvertElement(&elementInfo, plFormat("{}.{}", curPath, curElement->first)); } } @@ -933,7 +933,7 @@ void pfLocalizationDataMgr::IConvertAge(LocAgeInfo *ageInfo, const plString & cu LocSetInfo setInfo; setInfo.fSet = curSet->second; - IConvertSet(&setInfo, plString::Format("%s.%s", curPath.c_str(), curSet->first.c_str())); + IConvertSet(&setInfo, plFormat("{}.{}", curPath, curSet->first)); } } @@ -948,26 +948,26 @@ void pfLocalizationDataMgr::IWriteText(const plFileName & filename, const plStri plStringStream fileData; fileData << "\n"; fileData << "\n"; - fileData << plString::Format("\t\n", ageName.c_str()); + fileData << "\t\n"; std::vector setNames = GetSetList(ageName); for (int curSet = 0; curSet < setNames.size(); curSet++) { setEmpty = true; // so far, this set is empty plStringStream setCode; - setCode << plString::Format("\t\t\n", setNames[curSet].c_str()); + setCode << "\t\t\n"; std::vector elementNames = GetElementList(ageName, setNames[curSet]); for (int curElement = 0; curElement < elementNames.size(); curElement++) { - setCode << plString::Format("\t\t\t\n", elementNames[curElement].c_str()); - plString key = plString::Format("%s.%s.%s", ageName.c_str(), setNames[curSet].c_str(), elementNames[curElement].c_str()); + setCode << "\t\t\t\n"; + plString key = plFormat("{}.{}.{}", ageName, setNames[curSet], elementNames[curElement]); if (fLocalizedElements[key].find(languageName) != fLocalizedElements[key].end()) { weWroteData = true; setEmpty = false; - setCode << plString::Format("\t\t\t\t", languageName.c_str()); + setCode << "\t\t\t\t"; setCode << fLocalizedElements[key][languageName].ToXML(); setCode << "\n"; } @@ -1093,7 +1093,7 @@ pfLocalizedString pfLocalizationDataMgr::GetSpecificElement(const plString & nam std::vector pfLocalizationDataMgr::GetLanguages(const plString & ageName, const plString & setName, const plString & elementName) { std::vector retVal; - plString key = plString::Format("%s.%s.%s", ageName.c_str(), setName.c_str(), elementName.c_str()); + plString key = plFormat("{}.{}.{}", ageName, setName, elementName); if (fLocalizedElements.exists(key)) { // age, set, and element exists @@ -1209,8 +1209,8 @@ void pfLocalizationDataMgr::WriteDatabaseToDisk(const plFileName & path) { for (int curLanguage = 0; curLanguage < languageNames.size(); curLanguage++) { - plFileName locPath = plFileName::Join(path, plString::Format("%s%s.loc", - ageNames[curAge].c_str(), languageNames[curLanguage].c_str())); + plFileName locPath = plFileName::Join(path, plFormat("{}{}.loc", + ageNames[curAge], languageNames[curLanguage])); IWriteText(locPath, ageNames[curAge], languageNames[curLanguage]); } } diff --git a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp index 72194979..7d4bcea6 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp @@ -1272,7 +1272,7 @@ PyObject* cyAvatar::GetTintClothingItemL(const plString& clothing_name, uint8_t } } - plString errmsg = plString::Format("Cannot find clothing item %s to find out what tint it is", clothing_name.c_str()); + plString errmsg = plFormat("Cannot find clothing item {} to find out what tint it is", clothing_name); PyErr_SetString(PyExc_KeyError, errmsg.c_str()); // returning nil means an error occurred return nil; diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp index 021ed081..cc7eaebc 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp @@ -215,7 +215,7 @@ PyObject* cyMisc::FindSceneObject(const plString& name, const char* ageName) if ( key == nil ) { - plString errmsg = plString::Format("Sceneobject %s not found",name.c_str()); + plString errmsg = plFormat("Sceneobject {} not found", name); PyErr_SetString(PyExc_NameError, errmsg.c_str()); return nil; // return nil cause we errored } @@ -935,7 +935,7 @@ PyObject* cyMisc::GetDialogFromTagID(uint32_t tag) return pyGUIDialog::New(pdialog->GetKey()); } - plString errmsg = plString::Format("GUIDialog TagID %d not found", tag); + plString errmsg = plFormat("GUIDialog TagID {} not found", tag); PyErr_SetString(PyExc_KeyError, errmsg.c_str()); return nil; // return nil, cause we threw an error } @@ -951,7 +951,7 @@ PyObject* cyMisc::GetDialogFromString(const char* name) return pyGUIDialog::New(pdialog->GetKey()); } - plString errmsg = plString::Format("GUIDialog %s not found", name); + plString errmsg = plFormat("GUIDialog {} not found", name); PyErr_SetString(PyExc_KeyError, errmsg.c_str()); return nil; // return nil, cause we threw an error } @@ -2497,7 +2497,7 @@ plString cyMisc::GetCameraNumber(int number) if (pCam && pCam->GetTarget()) { plString ret = pCam->GetTarget()->GetKeyName(); - plString log = plString::Format("saving camera named %s to chronicle\n", ret.c_str()); + plString log = plFormat("saving camera named {} to chronicle\n", ret); plVirtualCam1::Instance()->AddMsgToLog(log.c_str()); return ret; } @@ -2508,7 +2508,7 @@ plString cyMisc::GetCameraNumber(int number) void cyMisc::RebuildCameraStack(const plString& name, const char* ageName) { plKey key=nil; - plString str = plString::Format("attempting to restore camera named %s from chronicle\n",name.c_str()); + plString str = plFormat("attempting to restore camera named {} from chronicle\n", name); plVirtualCam1::Instance()->AddMsgToLog(str.c_str()); if (name.Compare("empty") == 0) @@ -2525,7 +2525,7 @@ void cyMisc::RebuildCameraStack(const plString& name, const char* ageName) { // give up and force built in 3rd person plVirtualCam1::Instance()->PushThirdPerson(); - plString errmsg = plString::Format("Sceneobject %s not found",name.c_str()); + plString errmsg = plFormat("Sceneobject {} not found", name); PyErr_SetString(PyExc_NameError, errmsg.c_str()); } } @@ -2549,7 +2549,7 @@ void cyMisc::RebuildCameraStack(const plString& name, const char* ageName) } } plVirtualCam1::Instance()->PushThirdPerson(); - plString errmsg = plString::Format("Sceneobject %s has no camera modifier",name.c_str()); + plString errmsg = plFormat("Sceneobject {} has no camera modifier", name); PyErr_SetString(PyExc_NameError, errmsg.c_str()); } diff --git a/Sources/Plasma/FeatureLib/pfPython/cyPhysics.cpp b/Sources/Plasma/FeatureLib/pfPython/cyPhysics.cpp index 549f30fe..221f25ca 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyPhysics.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyPhysics.cpp @@ -322,8 +322,8 @@ void cyPhysics::Move(pyVector3& direction, float distance) } else { - plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.", - obj->GetKeyName().c_str()); + plString errmsg = plFormat("Sceneobject {} does not have a coordinate interface.", + obj->GetKeyName()); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str()); } } @@ -392,8 +392,8 @@ void cyPhysics::Rotate(float rad, pyVector3& axis) } else { - plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.", - obj->GetKeyName().c_str()); + plString errmsg = plFormat("Sceneobject {} does not have a coordinate interface.", + obj->GetKeyName()); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str()); } } diff --git a/Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.cpp b/Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.cpp index 26349ea7..9f8e75c4 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.cpp @@ -2003,7 +2003,7 @@ PyObject* PythonInterface::CreateModule(const char* module) if ((m = PyDict_GetItemString(modules, module)) != NULL && PyModule_Check(m)) { // clear it - hsAssert(false, plString::Format("ERROR! Creating a python module of the same name - %s", module).c_str()); + hsAssert(false, plFormat("ERROR! Creating a python module of the same name - {}", module).c_str()); _PyModule_Clear(m); } diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp index 0c9ab7f0..609744b4 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp @@ -431,7 +431,7 @@ bool plPythonFileMod::ILoadPythonCode() #ifndef PLASMA_EXTERNAL_RELEASE // get code from file and execute in module // see if the file exists first before trying to import it - plFileName pyfile = plFileName::Join(".", "python", plString::Format("%s.py", fPythonFile.c_str())); + plFileName pyfile = plFileName::Join(".", "python", plFormat("{}.py", fPythonFile)); if (plFileInfo(pyfile).Exists()) { char fromLoad[256]; @@ -1002,7 +1002,8 @@ plString plPythonFileMod::IMakeModuleName(plSceneObject* sobj) } modulename[k] = '\0'; - plString name = plString::FromUtf8(modulename); + plStringStream name; + name << modulename; // check to see if we are attaching to a clone? plKeyImp* pKeyImp = (plKeyImp*)(sKey); @@ -1012,7 +1013,7 @@ plString plPythonFileMod::IMakeModuleName(plSceneObject* sobj) // add the cloneID to the end of the module name // and set the fIAmAClone flag uint32_t cloneID = pKeyImp->GetUoid().GetCloneID(); - name += plString::Format("%d", cloneID); + name << cloneID; fAmIAttachedToClone = true; } @@ -1021,10 +1022,10 @@ plString plPythonFileMod::IMakeModuleName(plSceneObject* sobj) { // if not unique then add the sequence number to the end of the modulename uint32_t seqID = pKeyImp->GetUoid().GetLocation().GetSequenceNumber(); - name += plString::Format("%d", seqID); + name << seqID; } - return name; + return name.GetString(); } ///////////////////////////////////////////////////////////////////////////// diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonPack.cpp b/Sources/Plasma/FeatureLib/pfPython/plPythonPack.cpp index 4b3fdf53..42a85a43 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonPack.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonPack.cpp @@ -209,8 +209,8 @@ PyObject* plPythonPack::OpenPacked(const plString& fileName) { char *buf = new char[size]; uint32_t readSize = fPackStream->Read(size, buf); - hsAssert(readSize <= size, plString::Format("Python PackFile %s: Incorrect amount of data, read %d instead of %d", - fileName.c_str(), readSize, size).c_str()); + hsAssert(readSize <= size, plFormat("Python PackFile {}: Incorrect amount of data, read {} instead of {}", + fileName, readSize, size).c_str()); // let the python marshal make it back into a code object PyObject *pythonCode = PyMarshal_ReadObjectFromString(buf, size); diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp b/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp index 17b8e002..5cab4804 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp @@ -105,7 +105,7 @@ PyObject* plPythonSDLModifier::GetItem(const plString& key) if (it == fMap.end()) { - plString errmsg = plString::Format("SDL key %s not found", key.c_str()); + plString errmsg = plFormat("SDL key {} not found", key); PyErr_SetString(PyExc_KeyError, errmsg.c_str()); PYTHON_RETURN_ERROR; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.cpp b/Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.cpp index 5d9f1440..4ac43f4a 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.cpp @@ -190,9 +190,9 @@ plString pyAgeInfoStruct::GetDisplayName() const { int32_t seq = GetAgeSequenceNumber(); if (seq > 0) - return plString::Format("%s (%d) %s", user.c_str(), seq, instance.c_str()); + return plFormat("{} ({}) {}", user, seq, instance); else - return plString::Format("%s %s", user.c_str(), instance.c_str()); + return plFormat("{} {}", user, instance); } } @@ -275,8 +275,8 @@ plString pyAgeInfoStructRef::GetDisplayName() const { int32_t seq = GetAgeSequenceNumber(); if (seq > 0) - return plString::Format("%s (%d) %s", user.c_str(), seq, instance.c_str()); + return plFormat("{} ({}) {}", user, seq, instance); else - return plString::Format("%s %s", user.c_str(), instance.c_str()); + return plFormat("{} {}", user, instance); } } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyImage.cpp b/Sources/Plasma/FeatureLib/pfPython/pyImage.cpp index 62fb68b4..2ec3e02c 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyImage.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyImage.cpp @@ -210,7 +210,7 @@ PyObject* pyImage::LoadJPEGFromDisk(const plFileName& filename, uint16_t width, } // let's create a nice name for this thing based on the filename - plString name = plString::Format("PtImageFromDisk_%s", filename.AsString().c_str()); + plString name = plFormat("PtImageFromDisk_{}", filename); hsgResMgr::ResMgr()->NewKey(name, theMipmap, plLocation::kGlobalFixedLoc); @@ -235,7 +235,7 @@ PyObject* pyImage::LoadPNGFromDisk(const plFileName& filename, uint16_t width, u } // let's create a nice name for this thing based on the filename - plString name = plString::Format("PtImageFromDisk_%s", filename.AsString().c_str()); + plString name = plFormat("PtImageFromDisk_{}", filename); hsgResMgr::ResMgr()->NewKey(name, theMipmap, plLocation::kGlobalFixedLoc); diff --git a/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.cpp b/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.cpp index 4ef89b6c..0c87ab6b 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.cpp @@ -62,7 +62,7 @@ uint32_t pyJournalBook::fNextKeyID = 0; void pyJournalBook::IMakeNewKey( void ) { - plString name = plString::Format( "pyJournalBook-%d", fNextKeyID++ ); + plString name = plFormat("pyJournalBook-{}", fNextKeyID++); hsgResMgr::ResMgr()->NewKey( name, fBook, plLocation::kGlobalFixedLoc ); fBook->GetKey()->RefObject(); diff --git a/Sources/Plasma/FeatureLib/pfPython/pySceneObject.cpp b/Sources/Plasma/FeatureLib/pfPython/pySceneObject.cpp index 0347e458..b0e7537c 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pySceneObject.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pySceneObject.cpp @@ -293,8 +293,8 @@ PyObject* pySceneObject::GetLocalToWorld() return pyMatrix44::New((hsMatrix44)ci->GetLocalToWorld()); else { - plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.", - obj->GetKeyName().c_str()); + plString errmsg = plFormat("Sceneobject {} does not have a coordinate interface.", + obj->GetKeyName()); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str()); return nil; // return nil to tell python we errored } @@ -322,8 +322,8 @@ PyObject* pySceneObject::GetWorldToLocal() return pyMatrix44::New((hsMatrix44)ci->GetWorldToLocal()); else { - plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.", - obj->GetKeyName().c_str()); + plString errmsg = plFormat("Sceneobject {} does not have a coordinate interface.", + obj->GetKeyName()); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str()); return nil; // return nil to tell python we errored } @@ -351,8 +351,8 @@ PyObject* pySceneObject::GetLocalToParent() return pyMatrix44::New((hsMatrix44)ci->GetLocalToParent()); else { - plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.", - obj->GetKeyName().c_str()); + plString errmsg = plFormat("Sceneobject {} does not have a coordinate interface.", + obj->GetKeyName()); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str()); return nil; // return nil to tell python we errored } @@ -380,8 +380,8 @@ PyObject* pySceneObject::GetParentToLocal() return pyMatrix44::New((hsMatrix44)ci->GetParentToLocal()); else { - plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.", - obj->GetKeyName().c_str()); + plString errmsg = plFormat("Sceneobject {} does not have a coordinate interface.", + obj->GetKeyName()); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str()); return nil; // return nil to tell python we errored } @@ -425,8 +425,8 @@ PyObject* pySceneObject::GetWorldPosition() return pyPoint3::New((hsPoint3)ci->GetWorldPos()); else { - plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.", - obj->GetKeyName().c_str()); + plString errmsg = plFormat("Sceneobject {} does not have a coordinate interface.", + obj->GetKeyName()); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str()); return nil; // return nil to tell python we errored } @@ -454,8 +454,8 @@ PyObject* pySceneObject::GetViewVector() return pyVector3::New(ci->GetLocalToWorld().GetAxis(hsMatrix44::kView)); else { - plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.", - obj->GetKeyName().c_str()); + plString errmsg = plFormat("Sceneobject {} does not have a coordinate interface.", + obj->GetKeyName()); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str()); return nil; // return nil to tell python we errored } @@ -483,8 +483,8 @@ PyObject* pySceneObject::GetUpVector() return pyVector3::New(ci->GetLocalToWorld().GetAxis(hsMatrix44::kUp)); else { - plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.", - obj->GetKeyName().c_str()); + plString errmsg = plFormat("Sceneobject {} does not have a coordinate interface.", + obj->GetKeyName()); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str()); return nil; // return nil to tell python we errored } @@ -512,8 +512,8 @@ PyObject* pySceneObject::GetRightVector() return pyVector3::New(ci->GetLocalToWorld().GetAxis(hsMatrix44::kRight)); else { - plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.", - obj->GetKeyName().c_str()); + plString errmsg = plFormat("Sceneobject {} does not have a coordinate interface.", + obj->GetKeyName()); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str()); return nil; // return nil to tell python we errored } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp index acc7d5ca..f46103c8 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp @@ -670,13 +670,13 @@ void pyVault::CreateNeighborhood() unsigned nameLen = nc->GetPlayerName().GetSize(); if (nc->GetPlayerName().CharAt(nameLen - 1) == 's' || nc->GetPlayerName().CharAt(nameLen - 1) == 'S') { - title = plString::Format( "%s'", nc->GetPlayerName().c_str() ); - desc = plString::Format( "%s' %s", nc->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName().c_str() ); + title = plFormat("{}'", nc->GetPlayerName()); + desc = plFormat("{}' {}", nc->GetPlayerName(), link.GetAgeInfo()->GetAgeInstanceName()); } else { - title = plString::Format( "%s's", nc->GetPlayerName().c_str() ); - desc = plString::Format( "%s's %s", nc->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName().c_str() ); + title = plFormat("{}'s", nc->GetPlayerName()); + desc = plFormat("{}'s {}", nc->GetPlayerName(), link.GetAgeInfo()->GetAgeInstanceName()); } plUUID guid = plUUID::Generate(); diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp index 8e282840..355d3171 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp @@ -68,7 +68,7 @@ static unsigned s_keyseq; //============================================================================ static plKey CreateAndRefImageKey (unsigned nodeId, plMipmap * mipmap) { - plString keyName = plString::Format("VaultImg_%u_%u", nodeId, s_keyseq++); + plString keyName = plFormat("VaultImg_{}_{}", nodeId, s_keyseq++); plKey key = hsgResMgr::ResMgr()->NewKey(keyName, mipmap, plLocation::kGlobalFixedLoc); diff --git a/Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp b/Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp index f44048e6..a5a4d00a 100644 --- a/Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp +++ b/Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp @@ -112,7 +112,7 @@ bool plLayerMovie::ISetupBitmap() memset(b->GetImage(), 0x10, b->GetHeight() * b->GetRowBytes() ); b->SetFlags( b->GetFlags() | plMipmap::kDontThrowAwayImage ); - plString name = plString::Format( "%s_BMap", fMovieName.AsString().c_str() ); + plString name = plFormat("{}_BMap", fMovieName); hsgResMgr::ResMgr()->NewKey( name, b, plLocation::kGlobalFixedLoc ); *fTexture = (plBitmap *)b; diff --git a/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp b/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp index 79401720..e865a09b 100644 --- a/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp +++ b/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp @@ -335,8 +335,9 @@ void plDispatch::IMsgDispatch() if (plNetObjectDebuggerBase::GetInstance()->IsDebugObject(ko)) { hsLogEntry(plNetObjectDebuggerBase::GetInstance()->LogMsg( - plString::Format(" object:%s, GameMessage %s st=%.3f rt=%.3f", - ko->GetKeyName().c_str(), msg->ClassName(), hsTimer::GetSysSeconds(), hsTimer::GetSeconds()).c_str())); + plFormat(" object:{}, GameMessage {} st={.3f} rt={.3f}", + ko->GetKeyName(), msg->ClassName(), hsTimer::GetSysSeconds(), + hsTimer::GetSeconds()).c_str())); } } } diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.cpp b/Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.cpp index 5ee68acb..cfdba773 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.cpp +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.cpp @@ -148,8 +148,8 @@ void hsKeyedObject::UnRegisterAsManual(plUoid& inUoid) { #if !HS_BUILD_FOR_UNIX // disable for unix servers hsAssert(false, - plString::Format("Request to Unregister wrong FixedKey, keyName=%s, inUoid=%s, myUoid=%s", - fpKey->GetName().c_str("?"), inUoid.StringIze().c_str(), myUoid.StringIze().c_str()).c_str()); + plFormat("Request to Unregister wrong FixedKey, keyName={}, inUoid={}, myUoid={}", + fpKey->GetName(), inUoid, myUoid).c_str()); #endif } ((plKeyImp*)fpKey)->UnRegister(); diff --git a/Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp b/Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp index 8706b4a8..f2918da7 100644 --- a/Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp +++ b/Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp @@ -280,7 +280,7 @@ int plMsgStdStringHelper::Peek(std::string & stringref, hsStream* stream, const stringref.resize(strlen); if (strlen){ stream->LogRead(strlen,(void*)stringref.data(),"StdString"); - stream->LogStringString(plString::Format("Value: %s", stringref.data()).c_str()); + stream->LogStringString(plFormat("Value: {}", stringref).c_str()); } } else @@ -302,7 +302,7 @@ int plMsgStdStringHelper::PeekBig(std::string & stringref, hsStream* stream, co stringref.resize(bufsz); if (bufsz){ stream->LogRead(bufsz,(void*)stringref.data(),"StdString"); - stream->LogStringString(plString::Format("Value: %s", stringref.data()).c_str()); + stream->LogStringString(plFormat("Value: {}", stringref).c_str()); } } else @@ -357,7 +357,7 @@ int plMsgCStringHelper::Peek(char *& str, hsStream* stream, const uint32_t peekO str[strlen] = '\0'; if (strlen) { stream->LogRead(strlen,str,"CString"); - stream->LogStringString(plString::Format("Value: %s",str).c_str()); + stream->LogStringString(plFormat("Value: {}", str).c_str()); } } } diff --git a/Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.cpp b/Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.cpp index fd7e16ff..422978c5 100644 --- a/Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.cpp +++ b/Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.cpp @@ -237,15 +237,16 @@ plString plGenericType::GetAsString() const switch (fType) { case kInt : - return plString::Format("%d", fI); + return plFormat("{}", fI); case kBool : - case kUInt : - return plString::Format("%u", fType==kBool?fB:fU); + return plFormat("{}", fB ? 1 : 0); + case kUInt: + return plFormat("{}", fU); case kFloat : case kDouble : - return plString::Format("%f", fType==kDouble?fD:fF); + return plFormat("{f}", fType==kDouble ? fD : fF); case kChar : - return plString::Format("%c", fC); + return plFormat("{}", fC); case kAny : case kString : return fS; diff --git a/Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.cpp b/Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.cpp index 4b9215a5..eccc9f49 100644 --- a/Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.cpp +++ b/Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.cpp @@ -63,7 +63,7 @@ plString GetTextAddr(uint32_t binAddr) { in_addr in; memcpy(&in, &binAddr, sizeof(binAddr)); - return plString::Format("%s", inet_ntoa(in)); + return plString::FromUtf8(inet_ntoa(in)); } // NOTE: On Win32, WSAStartup() must be called before GetBinAddr() will work. diff --git a/Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp b/Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp index d8278073..6563c373 100644 --- a/Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp +++ b/Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp @@ -118,9 +118,9 @@ bool plAgePage::SetFromString( const plString &stringIn ) plString plAgePage::GetAsString( void ) const { if (fFlags) - return plString::Format("%s,%d,%d", fName.c_str(), fSeqSuffix, fFlags); + return plFormat("{},{},{}", fName, fSeqSuffix, fFlags); - return plString::Format("%s,%d", fName.c_str(), fSeqSuffix); + return plFormat("{},{}", fName, fSeqSuffix); } diff --git a/Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp b/Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp index b3366867..8fc2715c 100644 --- a/Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp +++ b/Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp @@ -78,13 +78,13 @@ void plResPatcher::OnCompletion(ENetError result, const plString& status) { plString error = plString::Null; if (IS_NET_ERROR(result)) - error = plString::Format("Update Failed: %S\n%s", NetErrorAsString(result), status.c_str()); + error = plFormat("Update Failed: {}\n{}", NetErrorAsString(result), status); plgDispatch::Dispatch()->MsgQueue(new plResPatcherMsg(IS_NET_SUCCESS(result), error)); } void plResPatcher::OnFileDownloadBegin(const plFileName& file) { - fProgress->SetTitle(plString::Format("Downloading %s...", file.GetFileName().c_str())); + fProgress->SetTitle(plFormat("Downloading {}...", file.GetFileName())); if (file.GetFileExt().CompareI("prp") == 0) { plResManager* mgr = static_cast(hsgResMgr::ResMgr()); @@ -124,9 +124,9 @@ void plResPatcher::OnProgressTick(uint64_t dl, uint64_t total, const plString& m fProgress->SetHowMuch(dl); } - plString status = plString::Format("%s / %s", - plFileSystem::ConvertFileSize(dl).c_str(), - plFileSystem::ConvertFileSize(total).c_str() + plString status = plFormat("%s / %s", + plFileSystem::ConvertFileSize(dl), + plFileSystem::ConvertFileSize(total) ); fProgress->SetStatusText(status); diff --git a/Sources/Plasma/PubUtilLib/plAudible/plWinAudible.cpp b/Sources/Plasma/PubUtilLib/plAudible/plWinAudible.cpp index c329ec71..601de2dd 100644 --- a/Sources/Plasma/PubUtilLib/plAudible/plWinAudible.cpp +++ b/Sources/Plasma/PubUtilLib/plAudible/plWinAudible.cpp @@ -474,7 +474,7 @@ void plWinAudible::Read(hsStream* s, hsResMgr* mgr) void plWinAudible::IAssignSoundKey( plSound *sound, const char *name, uint32_t i ) { - plString keyName = plString::Format( "%s_%d", name, i ); + plString keyName = plFormat("{}_{}", name, i); hsgResMgr::ResMgr()->NewKey( keyName, sound, GetKey() ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); } diff --git a/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp b/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp index c93f3bae..efb86ff3 100644 --- a/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp +++ b/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp @@ -411,7 +411,7 @@ plVoiceSound::plVoiceSound() fEAXSettings.SetRoomParams(-1200, -100, 0, 0); fLastUpdate = 0; - plString keyName = plString::Format("VoiceSound_%d", fCount); + plString keyName = plFormat("VoiceSound_{}", fCount); fCount++; hsgResMgr::ResMgr()->NewKey(keyName, this, plLocation::kGlobalFixedLoc); } diff --git a/Sources/Plasma/PubUtilLib/plAudio/plWin32GroupedSound.cpp b/Sources/Plasma/PubUtilLib/plAudio/plWin32GroupedSound.cpp index 49495816..be6e28af 100644 --- a/Sources/Plasma/PubUtilLib/plAudio/plWin32GroupedSound.cpp +++ b/Sources/Plasma/PubUtilLib/plAudio/plWin32GroupedSound.cpp @@ -160,7 +160,7 @@ bool plWin32GroupedSound::LoadSound( bool is3D ) // We need it to be resident to read in if( retVal == plSoundBuffer::kError) { - plString str = plString::Format("Unable to open .wav file %s", fDataBufferKey ? fDataBufferKey->GetName().c_str() : "nil"); + plString str = plFormat("Unable to open .wav file {}", fDataBufferKey ? fDataBufferKey->GetName() : "nil"); IPrintDbgMessage( str.c_str(), true ); fFailed = true; return false; @@ -211,9 +211,10 @@ bool plWin32GroupedSound::LoadSound( bool is3D ) fDSoundBuffer = new plDSoundBuffer( bufferSize, header, is3D, IsPropertySet( kPropLooping ), true ); if( !fDSoundBuffer->IsValid() ) { - char str[256]; - sprintf(str, "Can't create sound buffer for %s.wav. This could happen if the wav file is a stereo file. Stereo files are not supported on 3D sounds. If the file is not stereo then please report this error.", GetFileName().AsString().c_str()); - IPrintDbgMessage( str, true ); + plString str = plFormat("Can't create sound buffer for {}.wav. This could happen if the wav file is a stereo file." + " Stereo files are not supported on 3D sounds. If the file is not stereo then please report this error.", + GetFileName()); + IPrintDbgMessage(str.c_str(), true); fFailed = true; delete fDSoundBuffer; @@ -228,14 +229,14 @@ bool plWin32GroupedSound::LoadSound( bool is3D ) IFillCurrentSound( 0 ); // Logging - plString str = plString::Format(" Grouped %s %s allocated (%d msec).", buffer->GetFileName().IsValid() ? "file" : "buffer", - buffer->GetFileName().IsValid() ? buffer->GetFileName().AsString().c_str() : buffer->GetKey()->GetUoid().GetObjectName().c_str(), - //fDSoundBuffer->IsHardwareAccelerated() ? "hardware" : "software", - //fDSoundBuffer->IsStaticVoice() ? "static" : "dynamic", + plString str = plFormat(" Grouped {} {} allocated ({} msec).", buffer->GetFileName().IsValid() ? "file" : "buffer", + buffer->GetFileName().IsValid() ? buffer->GetFileName() : buffer->GetKeyName(), + //fDSoundBuffer->IsHardwareAccelerated() ? "hardware" : "software", + //fDSoundBuffer->IsStaticVoice() ? "static" : "dynamic", #ifdef PL_PROFILE_ENABLED - gProfileVarStaticSndShoveTime.GetValue() ); + gProfileVarStaticSndShoveTime.GetValue()); #else - 0 ); + 0); #endif IPrintDbgMessage( str.c_str() ); if( GetKey() != nil && GetKeyName().Find( "Footstep" ) >= 0 ) diff --git a/Sources/Plasma/PubUtilLib/plAudio/plWin32StaticSound.cpp b/Sources/Plasma/PubUtilLib/plAudio/plWin32StaticSound.cpp index bbcbb006..6fc54391 100644 --- a/Sources/Plasma/PubUtilLib/plAudio/plWin32StaticSound.cpp +++ b/Sources/Plasma/PubUtilLib/plAudio/plWin32StaticSound.cpp @@ -115,7 +115,7 @@ bool plWin32StaticSound::LoadSound( bool is3D ) if( retVal == plSoundBuffer::kError ) { - plString str = plString::Format( "Unable to open .wav file %s", fDataBufferKey ? fDataBufferKey->GetName().c_str() : "nil"); + plString str = plFormat("Unable to open .wav file {}", fDataBufferKey ? fDataBufferKey->GetName() : "nil"); IPrintDbgMessage( str.c_str(), true ); fFailed = true; return false; @@ -143,9 +143,10 @@ bool plWin32StaticSound::LoadSound( bool is3D ) fDSoundBuffer = new plDSoundBuffer( bufferSize, header, is3D, IsPropertySet( kPropLooping ), tryStatic ); if( !fDSoundBuffer->IsValid() ) { - char str[256]; - sprintf(str, "Can't create sound buffer for %s.wav. This could happen if the wav file is a stereo file. Stereo files are not supported on 3D sounds. If the file is not stereo then please report this error.", GetFileName().AsString().c_str()); - IPrintDbgMessage( str, true ); + plString str = plFormat("Can't create sound buffer for {}.wav. This could happen if the wav file is a stereo file." + " Stereo files are not supported on 3D sounds. If the file is not stereo then please report this error.", + GetFileName()); + IPrintDbgMessage(str.c_str(), true); fFailed = true; delete fDSoundBuffer; diff --git a/Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.cpp b/Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.cpp index 2e8895f4..b0bc4ac4 100644 --- a/Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.cpp +++ b/Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.cpp @@ -195,7 +195,7 @@ plSoundBuffer::ELoadReturnVal plWin32StreamingSound::IPreLoadBuffer( bool playWh return plSoundBuffer::kError; } - IPrintDbgMessage(plString::Format(" Readied file %s for streaming", fSrcFilename.AsString().c_str()).c_str()); + IPrintDbgMessage(plFormat(" Readied file {} for streaming", fSrcFilename).c_str()); // dont free sound data until we have a chance to use it in load sound @@ -251,8 +251,8 @@ bool plWin32StreamingSound::LoadSound( bool is3D ) if( retVal == plSoundBuffer::kError ) { - plString str = plString::Format( "Unable to open streaming source %s", - fDataBufferKey->GetName().c_str() ); + plString str = plFormat("Unable to open streaming source {}", + fDataBufferKey->GetName()); IPrintDbgMessage( str.c_str(), true ); fFailed = true; return false; @@ -282,9 +282,9 @@ bool plWin32StreamingSound::LoadSound( bool is3D ) delete fDSoundBuffer; fDSoundBuffer = nil; - plString str = plString::Format("Can't create sound buffer for %s.wav. This could happen if the wav file is a stereo file." - " Stereo files are not supported on 3D sounds. If the file is not stereo then please report this error.", - GetFileName().AsString().c_str()); + plString str = plFormat("Can't create sound buffer for {}.wav. This could happen if the wav file is a stereo file." + " Stereo files are not supported on 3D sounds. If the file is not stereo then please report this error.", + GetFileName()); IPrintDbgMessage(str.c_str(), true); fFailed = true; return false; @@ -337,7 +337,7 @@ bool plWin32StreamingSound::LoadSound( bool is3D ) IRefreshEAXSettings( true ); // Debug info - plString dbg = plString::Format(" Streaming %s.", fSrcFilename.AsString().c_str()); + plString dbg = plFormat(" Streaming {}.", fSrcFilename); IPrintDbgMessage(dbg.c_str()); plStatusLog::AddLineS( "audioTimes.log", 0xffffffff, "Streaming %4.2f secs of %s", diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp index 90f5ca13..46a25ea1 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp @@ -724,16 +724,16 @@ void plAnimStage::DumpDebug(bool active, int &x, int &y, int lineHeight, plDebug str << " "; if(fLoops) - str << plString::Format("loop(%d/%d)", fCurLoop, fLoops); + str << "loop(" << fCurLoop << '/' << fLoops << ')'; - str << plString::Format("time: (%f/%f)", fLocalTime, fLength); + str << "time: (" << fLocalTime << '/' << fLength << ')'; if(active) - debugTxt.DrawString(x, y, str.GetString().c_str(), 0, 255, 0); + debugTxt.DrawString(x, y, str.GetString(), 0, 255, 0); else if(fAnimInstance) - debugTxt.DrawString(x, y, str.GetString().c_str()); + debugTxt.DrawString(x, y, str.GetString()); else - debugTxt.DrawString(x, y, str.GetString().c_str(), 255, 255, 0); + debugTxt.DrawString(x, y, str.GetString(), 255, 255, 0); y += lineHeight; } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp index cb1a607f..1cfff012 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp @@ -2654,7 +2654,7 @@ int plArmatureMod::RefreshDebugDisplay() void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt) { - debugTxt.DrawString(x, y, plString::Format("Armature <%s>:", fRootName.c_str()), 255, 128, 128); + debugTxt.DrawString(x, y, plFormat("Armature <{}>:", fRootName), 255, 128, 128); y += lineHeight; plSceneObject * SO = GetTarget(0); @@ -2664,9 +2664,8 @@ void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugTe hsMatrix44 l2w = SO->GetLocalToWorld(); hsPoint3 worldPos = l2w.GetTranslate(); - const char *opaque = IsOpaque() ? "yes" : "no"; - debugTxt.DrawString(x, y, plString::Format("position(world): %.2f, %.2f, %.2f Opaque: %3s", - worldPos.fX, worldPos.fY, worldPos.fZ, opaque)); + debugTxt.DrawString(x, y, plFormat("position(world): {.2f}, {.2f}, {.2f} Opaque: {>3}", + worldPos.fX, worldPos.fY, worldPos.fZ, IsOpaque() ? "yes" : "no")); y += lineHeight; const char* frozen = "n.a."; @@ -2677,8 +2676,8 @@ void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugTe plKey world = nil; if (fController) world = fController->GetSubworld(); - debugTxt.DrawString(x, y, plString::Format("In world: %s Frozen: %s", - world ? world->GetName().c_str() : "nil", frozen)); + debugTxt.DrawString(x, y, plFormat("In world: {} Frozen: {}", + world ? world->GetName() : "nil", frozen)); y+= lineHeight; plString details; @@ -2687,8 +2686,8 @@ void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugTe hsPoint3 physPos; GetPositionAndRotationSim(&physPos, nil); const hsVector3& vel = fController->GetLinearVelocity(); - details = plString::Format("position(physical): <%.2f, %.2f, %.2f> velocity: <%5.2f, %5.2f, %5.2f>", - physPos.fX, physPos.fY, physPos.fZ, vel.fX, vel.fY, vel.fZ); + details = plFormat("position(physical): <{.2f}, {.2f}, {.2f}> velocity: <{5.2f}, {5.2f}, {5.2f}>", + physPos.fX, physPos.fY, physPos.fZ, vel.fX, vel.fY, vel.fZ); } else { @@ -2747,11 +2746,11 @@ void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugTe debugTxt.DrawString(x, y, "Relevance Regions:"); y += lineHeight; - debugTxt.DrawString(x, y, plString::Format(" In: %s", - plRelevanceMgr::Instance()->GetRegionNames(fRegionsImIn).c_str())); + debugTxt.DrawString(x, y, plFormat(" In: {}", + plRelevanceMgr::Instance()->GetRegionNames(fRegionsImIn))); y += lineHeight; - debugTxt.DrawString(x, y, plString::Format(" Care about: %s", - plRelevanceMgr::Instance()->GetRegionNames(fRegionsICareAbout).c_str())); + debugTxt.DrawString(x, y, plFormat(" Care about: %s", + plRelevanceMgr::Instance()->GetRegionNames(fRegionsICareAbout))); y += lineHeight; } } @@ -2792,11 +2791,11 @@ void plAvBoneMap::AddBoneMapping(uint32_t boneID, const plSceneObject *SO) void plArmatureMod::DebugDumpMoveKeys(int &x, int &y, int lineHeight, plDebugText &debugTxt) { - debugTxt.DrawString(x, y, plString::Format("Mouse Input Map: %s", + debugTxt.DrawString(x, y, plFormat("Mouse Input Map: {}", plAvatarInputInterface::GetInstance()->GetInputMapName())); y += lineHeight; - debugTxt.DrawString(x, y, plString::Format("Turn strength: %.2f (key: %.2f, analog: %.2f)", + debugTxt.DrawString(x, y, plFormat("Turn strength: {.2f} (key: {.2f}, analog: {.2f})", GetTurnStrength(), GetKeyTurnStrength(), GetAnalogTurnStrength())); y += lineHeight; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp index efb78727..bb78bf1c 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp @@ -105,19 +105,18 @@ void plArmatureBehavior::DumpDebug(int &x, int &y, int lineHeight, plDebugText & { float strength = GetStrength(); const char *onOff = strength > 0 ? "on" : "off"; - char blendBar[11] = "||||||||||"; + char blendBar[] = "||||||||||"; int bars = (int)min(10 * strength, 10); blendBar[bars] = '\0'; plString details; if (fAnim) { - plString animName = fAnim->GetName(); float time = fAnim->GetTimeConvert()->CurrentAnimTime(); - details = plString::Format("%20s %3s time: %5.2f %s", animName.c_str(), onOff, time, blendBar); + details = plFormat("{>20} {>3} time: {5.2f} {}", fAnim->GetName(), onOff, time, blendBar); } else - details = plString::Format(" Behavior %2d %3s %s", fIndex, onOff, blendBar); + details = plFormat(" Behavior {2} {>3} {}", fIndex, onOff, blendBar); debugTxt.DrawString(x, y, details); y += lineHeight; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp index ea3def0b..14603d77 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp @@ -443,7 +443,7 @@ void plAvBrainCritter::DumpToDebugDisplay(int& x, int& y, int lineHeight, plDebu // extract the name from the behavior running plString mode = "Mode: Unknown"; if (fBehaviors[fCurMode]) - mode = plString::Format("Mode: %s", ((CritterBehavior*)(fBehaviors[fCurMode]))->Name().c_str()); + mode = plFormat("Mode: {}", ((CritterBehavior*)(fBehaviors[fCurMode]))->Name()); // draw it debugTxt.DrawString(x, y, mode); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp index d7957df1..0e3a0f09 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp @@ -903,7 +903,7 @@ void plAvBrainHuman::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugT const char *grounded = fWalkingStrategy->IsOnGround() ? "yes" : "no"; const char *pushing = (fWalkingStrategy->GetPushingPhysical() ? (fWalkingStrategy->GetFacingPushingPhysical() ? "facing" : "behind") : "none"); - debugTxt.DrawString(x, y, plString::Format("Ground: %3s, AirTime: %5.2f (Peak: %5.2f), PushingPhys: %6s", + debugTxt.DrawString(x, y, plFormat("Ground: {>3}, AirTime: {5.2f} (Peak: {5.2f}), PushingPhys: {>6}", grounded, fWalkingStrategy->GetAirTime(), fWalkingStrategy->GetImpactTime(), pushing)); y += lineHeight; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp index 18c8bbe6..94b7b77a 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp @@ -619,11 +619,11 @@ void plAvBrainSwim::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugTe y += lineHeight; float buoy = fSwimStrategy ? fSwimStrategy->GetBuoyancy() : 0.0f; - debugTxt.DrawString(x, y, plString::Format("Distance to surface: %f Buoyancy: %f", fSurfaceDistance, buoy)); + debugTxt.DrawString(x, y, plFormat("Distance to surface: {f} Buoyancy: {f}", fSurfaceDistance, buoy)); y += lineHeight; hsVector3 linV = fAvMod->GetController()->GetAchievedLinearVelocity(); - debugTxt.DrawString(x, y, plString::Format("Linear Velocity: (%5.2f, %5.2f, %5.2f)", linV.fX, linV.fY, linV.fZ)); + debugTxt.DrawString(x, y, plFormat("Linear Velocity: ({5.2f}, {5.2f}, {5.2f})", linV.fX, linV.fY, linV.fZ)); y += lineHeight; int i; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp index ca9c203b..253d1d15 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp @@ -267,11 +267,11 @@ void plClothingItem::Write(hsStream *s, hsResMgr *mgr) plKey accessoryKey = nil; if (!fAccessoryName.IsEmpty()) { - plString strBuf = plString::Format("CItm_%s", fAccessoryName.c_str()); + plString strBuf = plFormat("CItm_{}", fAccessoryName); accessoryKey = plKeyFinder::Instance().StupidSearch("GlobalClothing", "", plClothingItem::Index(), strBuf); if (accessoryKey == nil) { - strBuf = plString::Format("Couldn't find accessory \"%s\". It won't show at runtime.", fAccessoryName.c_str()); + strBuf = plFormat("Couldn't find accessory \"{}\". It won't show at runtime.", fAccessoryName); hsMessageBox(strBuf.c_str(), GetKeyName().c_str(), hsMessageBoxNormal); } } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp index a05276fb..bfff143c 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp @@ -636,7 +636,7 @@ bool plAvOneShotTask::Start(plArmatureMod *avatar, plArmatureBrain *brain, doubl } else { - plString buf = plString::Format("Oneshot: Can't find animation <%s>; all bets are off.", fAnimName.c_str()); + plString buf = plFormat("Oneshot: Can't find animation <{}>; all bets are off.", fAnimName); hsAssert(false, buf.c_str()); result = true; } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp index c1c8b402..df825a3e 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp @@ -116,7 +116,7 @@ plCoopCoordinator::plCoopCoordinator(plKey host, plKey guest, serial = serial % 999; - plString newName = plString::Format("%s%s%3i\x000", host->GetName().c_str(), guest->GetName().c_str(), serial++); + plString newName = plFormat("{}{}{3}\x000", host->GetName(), guest->GetName(), serial++); plKey newKey = hsgResMgr::ResMgr()->NewKey(newName, this, host->GetUoid().GetLocation()); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp index afbc1f6d..318a12a7 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp @@ -290,7 +290,7 @@ bool IIsClosestAnim(const char *animName, hsMatrix44 &sitGoal, float &closestDis return true; } } else { - hsAssert(false, plString::Format("Missing sit animation: %s", animName).c_str()); + hsAssert(false, plFormat("Missing sit animation: {}", animName).c_str()); } return false; } diff --git a/Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.h b/Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.h index 9391baa1..71c7778c 100644 --- a/Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.h +++ b/Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.h @@ -142,11 +142,17 @@ public: plConfigInfo* GetConfigInfo() { return &fConfigInfo; } plConfigInfo* GetConfigInfoLog() { return &fLog; } - bool GetValue(plString& retval, const plString & section, const plString & key, const plString & desc, const plString& defval = ""); - bool GetValue(int& retval, const plString & section, const plString & key, const plString & desc, int defval); - bool GetValue(bool& retval, const plString & section, const plString & key, const plString & desc, bool defval); - bool GetValue(float& retval, const plString & section, const plString & key, const plString & desc, float defval); - bool GetValue(double& retval, const plString & section, const plString & key, const plString & desc, double defval); + template + bool GetValue(_Type& retval, const plString & section, const plString & key, const plString & desc, const _Type& defval = _Type()) + { + plString descwdef = plFormat("{} # {}", defval, desc); + fLog.AddValue(section, key, descwdef, kReplaceIfExists); + + bool found; + retval = fConfigInfo.GetValue(section, key, defval, &found); + return found; + } + bool GetAllValues(std::vector& values, const plString & section, const plString & key, const plString & desc); #if USE_MULT_SECTIONS diff --git a/Sources/Plasma/PubUtilLib/plContainer/plConfigInfoLogging.cpp b/Sources/Plasma/PubUtilLib/plContainer/plConfigInfoLogging.cpp index 6ec622d4..d8394d6f 100644 --- a/Sources/Plasma/PubUtilLib/plContainer/plConfigInfoLogging.cpp +++ b/Sources/Plasma/PubUtilLib/plContainer/plConfigInfoLogging.cpp @@ -49,60 +49,9 @@ plConfigInfoLogging::~plConfigInfoLogging() { } -bool plConfigInfoLogging::GetValue(plString& retval, const plString & section, const plString & key, const plString & desc, const plString& defval) -{ - plString descwdef = plString::Format("%s # %s",defval.c_str(),desc.c_str()); - fLog.AddValue(section,key,descwdef,kReplaceIfExists); - - bool found; - retval = fConfigInfo.GetValue(section,key,defval,&found); - return found; -} - -bool plConfigInfoLogging::GetValue(int& retval, const plString & section, const plString & key, const plString & desc, int defval) -{ - plString descwdef = plString::Format("%d # %s",defval,desc.c_str()); - fLog.AddValue(section,key,descwdef,kReplaceIfExists); - - bool found; - retval = fConfigInfo.GetValue(section,key,defval,&found); - return found; -} - -bool plConfigInfoLogging::GetValue(bool& retval, const plString & section, const plString & key, const plString & desc, bool defval) -{ - plString descwdef = plString::Format("%d # %s",defval,desc.c_str()); - fLog.AddValue(section,key,descwdef,kReplaceIfExists); - - bool found; - retval = ( fConfigInfo.GetValue(section,key,(int)defval,&found)!=0 ); - return found; -} - -bool plConfigInfoLogging::GetValue(float& retval, const plString & section, const plString & key, const plString & desc, float defval) -{ - plString descwdef = plString::Format("%f # %s",defval,desc.c_str()); - fLog.AddValue(section,key,descwdef,kReplaceIfExists); - - bool found; - double retvald = fConfigInfo.GetValue(section,key,defval,&found); - retval = (float)retvald; - return found; -} - -bool plConfigInfoLogging::GetValue(double& retval, const plString & section, const plString & key, const plString & desc, double defval) -{ - plString descwdef = plString::Format("%f # %s",defval,desc.c_str()); - fLog.AddValue(section,key,descwdef,kReplaceIfExists); - - bool found; - retval = fConfigInfo.GetValue(section,key,defval,&found); - return found; -} - bool plConfigInfoLogging::GetAllValues(std::vector& values, const plString & section, const plString & key, const plString & desc) { - plString descwdef = plString::Format("%s # %s","\"Multiple Entries\"",desc.c_str()); + plString descwdef = plFormat("\"Multiple Entries\" # {}", desc); fLog.AddValue(section,key,descwdef,kReplaceIfExists); values = fConfigInfo.GetAllValues(section,key); diff --git a/Sources/Plasma/PubUtilLib/plContainer/plKeysAndValues.cpp b/Sources/Plasma/PubUtilLib/plContainer/plKeysAndValues.cpp index 913141e5..fad2ac09 100644 --- a/Sources/Plasma/PubUtilLib/plContainer/plKeysAndValues.cpp +++ b/Sources/Plasma/PubUtilLib/plContainer/plKeysAndValues.cpp @@ -87,12 +87,12 @@ bool plKeysAndValues::KeyHasValue(const plString & key, const plString & value) bool plKeysAndValues::KeyHasValue(const plString & key, int value) { - return KeyHasValue(key, plString::Format("%d", value)); + return KeyHasValue(key, plFormat("{}", value)); } bool plKeysAndValues::KeyHasValue(const plString & key, double value) { - return KeyHasValue(key, plString::Format("%f", value)); + return KeyHasValue(key, plFormat("{f}", value)); } bool plKeysAndValues::AddValue(const plString & key, const plString & value, KAddValueMode mode) @@ -116,12 +116,12 @@ bool plKeysAndValues::AddValue(const plString & key, const plString & value, KAd bool plKeysAndValues::AddValue(const plString & key, int value, KAddValueMode mode) { - return AddValue(key, plString::Format("%d", value), mode); + return AddValue(key, plFormat("{}", value), mode); } bool plKeysAndValues::AddValue(const plString & key, double value, KAddValueMode mode) { - return AddValue(key, plString::Format("%f", value), mode); + return AddValue(key, plFormat("{f}", value), mode); } bool plKeysAndValues::AddValues(const plString & key, const std::vector & values, KAddValueMode mode) @@ -139,12 +139,12 @@ bool plKeysAndValues::SetValue(const plString & key, const plString & value) bool plKeysAndValues::SetValue(const plString & key, int value) { - return SetValue(key, plString::Format("%d", value)); + return SetValue(key, plFormat("{}", value)); } bool plKeysAndValues::SetValue(const plString & key, double value) { - return SetValue(key, plString::Format("%f", value)); + return SetValue(key, plFormat("{f}", value)); } plString plKeysAndValues::GetValue(const plString & key, const plString & defval, bool * outFound) const @@ -160,17 +160,17 @@ plString plKeysAndValues::GetValue(const plString & key, const plString & defval uint32_t plKeysAndValues::GetValue(const plString & key, uint32_t defval, bool * outFound) const { - return strtoul(GetValue(key, plString::Format("%ul", defval), outFound).c_str(), nil, 0); + return GetValue(key, plFormat("{}", defval), outFound).ToUInt(); } int plKeysAndValues::GetValue(const plString & key, int defval, bool * outFound) const { - return atol(GetValue(key, plString::Format("%d", defval), outFound).c_str()); + return GetValue(key, plFormat("{}", defval), outFound).ToInt(); } double plKeysAndValues::GetValue(const plString & key, double defval, bool * outFound) const { - return atof(GetValue(key, plString::Format("%f", defval), outFound).c_str()); + return GetValue(key, plFormat("{f}", defval), outFound).ToDouble(); } std::vector plKeysAndValues::GetAllValues(const plString & key) diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableGenerator.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableGenerator.cpp index 23671816..2912c5d1 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableGenerator.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableGenerator.cpp @@ -259,7 +259,7 @@ plDrawableSpans *plDrawableGenerator::GenerateDrawable( uint32_t vertCount, hsPo } static int nameIdx = 0; - plString buff = plString::Format( "GenDrawable_%d", nameIdx++ ); + plString buff = plFormat("GenDrawable_{}", nameIdx++); hsgResMgr::ResMgr()->NewKey( buff, newDraw, plLocation::kGlobalFixedLoc ); } diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp index bd94e798..f4c5a4b9 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp @@ -1578,20 +1578,20 @@ hsGMaterial* plDynaDecalMgr::IConvertToEnvMap(hsGMaterial* mat, plBitmap* envMap oldMip->SetCurrLevel(0); hsGMaterial* newMat = new hsGMaterial; - plString buff = plString::Format("%s_EnvMat", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_EnvMat", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, newMat, GetKey()->GetUoid().GetLocation()); static plTweak kSmooth(1.f); plMipmap* bumpMap = plBumpMapGen::QikNormalMap(nil, oldMip, 0xffffffff, plBumpMapGen::kBubbleTest, kSmooth); // plMipmap* bumpMap = plBumpMapGen::QikNormalMap(nil, oldMip, 0xffffffff, plBumpMapGen::kNormalize, kSmooth); // plMipmap* bumpMap = plBumpMapGen::QikNormalMap(nil, oldMip, 0xffffffff, 0, 0); - buff = plString::Format("%s_BumpMap", GetKey()->GetName().c_str()); + buff = plFormat("{}_BumpMap", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, bumpMap, GetKey()->GetUoid().GetLocation()); bumpMap->SetFlags(bumpMap->GetFlags() | plMipmap::kBumpEnvMap | plMipmap::kForceNonCompressed); plLayer* bumpLay = new plLayer; - buff = plString::Format("%s_BumpMap_0", GetKey()->GetName().c_str()); + buff = plFormat("{}_BumpMap_0", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, bumpLay, GetKey()->GetUoid().GetLocation()); bumpLay->SetState(oldLay->GetState()); @@ -1613,7 +1613,7 @@ hsGMaterial* plDynaDecalMgr::IConvertToEnvMap(hsGMaterial* mat, plBitmap* envMap newMat->AddLayerViaNotify(bumpLay); plLayer* envLay = new plLayer; - buff = plString::Format("%s_EnvMap_0", GetKey()->GetName().c_str()); + buff = plFormat("{}_EnvMap_0", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, envLay, GetKey()->GetUoid().GetLocation()); envLay->SetBlendFlags(hsGMatState::kBlendMult); diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp index 53624dcf..703933a5 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp @@ -84,12 +84,14 @@ void plProxyGen::Init(const hsKeyedObject* owner) plLocation loc; if( owner->GetKey() ) { - buff = plString::Format("%s_ProxyGen_%d_%d", owner->GetKey()->GetName().c_str(), owner->GetKey()->GetUoid().GetClonePlayerID(), fProxyKeyCounter++); + buff = plFormat("{}_ProxyGen_{}_{}", owner->GetKey()->GetName(), + owner->GetKey()->GetUoid().GetClonePlayerID(), + fProxyKeyCounter++); loc = owner->GetKey()->GetUoid().GetLocation(); } else { - buff = plString::Format( "ProxyGen%d", fProxyKeyCounter++ ); + buff = plFormat("ProxyGen{}", fProxyKeyCounter++); loc = plLocation::kGlobalFixedLoc; } @@ -159,7 +161,7 @@ hsGMaterial* plProxyGen::IMakeProxyMaterial() const plString buff; if( !GetKeyName().IsNull() ) - buff = plString::Format("%s_Material", GetKeyName().c_str()); + buff = plFormat("{}_Material", GetKeyName()); else buff = "ProxyMaterial"; hsgResMgr::ResMgr()->NewKey( buff, retVal, GetKey() ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); @@ -234,7 +236,7 @@ void plProxyGen::IGenerateProxy() { plString buff; if( !GetKeyName().IsNull() ) - buff = plString::Format("%s_ProxyDrawable", GetKeyName().c_str()); + buff = plFormat("{}_ProxyDrawable", GetKeyName()); else buff = "ProxyDrawable"; diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plWaveSet7.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plWaveSet7.cpp index b1668904..109a678b 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plWaveSet7.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plWaveSet7.cpp @@ -1616,7 +1616,7 @@ plMipmap* plWaveSet7::ICreateBiasNoiseMap() plMipmap::kUncompressed, plMipmap::UncompressedInfo::kRGB8888); - plString buff = plString::Format("%s_BiasBitPS", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_BiasBitPS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, mipMap, GetKey()->GetUoid().GetLocation()); int i; @@ -1661,7 +1661,7 @@ plMipmap* plWaveSet7::ICreateBumpMipmapPS() plMipmap::kUncompressed, plMipmap::UncompressedInfo::kRGB8888); - plString buff = plString::Format("%s_BumpBitPS", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_BumpBitPS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, mipMap, GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->SendRef(mipMap->GetKey(), new plGenRefMsg(GetKey(), plRefMsg::kOnRequest, 0, kRefCosineLUT), plRefFlags::kActiveRef); @@ -1713,7 +1713,7 @@ void plWaveSet7::IAddBumpBiasLayer(hsGMaterial* mat) for( i = 0; i < 2; i++ ) { plLayer* layer = new plLayer; - plString buff = plString::Format("%s_Bias_%d", GetKey()->GetName().c_str(), i); + plString buff = plFormat("{}_Bias_{}", GetKey()->GetName(), i); hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); layer->SetBlendFlags(hsGMatState::kBlendAdd); @@ -1748,7 +1748,7 @@ void plWaveSet7::IAddBumpBiasLayer(hsGMaterial* mat) plLayer* plWaveSet7::ICreateBumpLayerPS(plMipmap* mipMap, hsGMaterial* bumpMat, int which) { plLayer* layer = new plLayer; - plString buff = plString::Format("%s_BumpLayerPS_%d", GetKey()->GetName().c_str(), which); + plString buff = plFormat("{}_BumpLayerPS_{}", GetKey()->GetName(), which); hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); layer->SetBlendFlags(which ? hsGMatState::kBlendAdd : 0); @@ -1805,7 +1805,7 @@ hsGMaterial* plWaveSet7::ICreateBumpLayersPS() // Create a blank material hsGMaterial* bumpMat = new hsGMaterial; - plString buff = plString::Format("%s_BumpMatPS", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_BumpMatPS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, bumpMat, GetKey()->GetUoid().GetLocation()); plMipmap* mipMap = ICreateBumpMipmapPS(); @@ -1846,7 +1846,7 @@ void plWaveSet7::IAddBumpBiasShaders(plLayer* layer) { plShader* vShader = new plShader; - plString buff = plString::Format("%s_BiasVS", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_BiasVS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -1909,7 +1909,7 @@ void plWaveSet7::IAddBumpBiasShaders(plLayer* layer) { plShader* pShader = new plShader; - plString buff = plString::Format("%s_BiasPS", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_BiasPS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -1942,7 +1942,7 @@ void plWaveSet7::IAddBumpVertexShader(hsGMaterial* mat, int iShader, int iFirst, int iShader = iBase / kBumpPerPass; plShader* vShader = new plShader; - plString buff = plString::Format("%s_BumpVS_%d", GetKey()->GetName().c_str(), iShader); + plString buff = plFormat("{}_BumpVS_{}", GetKey()->GetName(), iShader); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -1987,7 +1987,7 @@ void plWaveSet7::IAddBumpPixelShader(hsGMaterial* mat, int iShader, int iFirst, int iShader = iBase / kBumpPerPass; plShader* pShader = new plShader; - plString buff = plString::Format("%s_BumpPS_%d", GetKey()->GetName().c_str(), iShader); + plString buff = plFormat("{}_BumpPS_{}", GetKey()->GetName(), iShader); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -2029,7 +2029,7 @@ void plWaveSet7::IAddBumpPixelShader(hsGMaterial* mat, int iShader, int iFirst, plDrawableSpans* plWaveSet7::ICreateBumpDrawable() { fBumpDraw = new plDrawableSpans; - plString buff = plString::Format("%s_BumpDraw", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_BumpDraw", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, fBumpDraw, GetKey()->GetUoid().GetLocation()); ICreateClearDrawable(fBumpDraw, fBumpMat); @@ -2144,7 +2144,7 @@ plRenderTarget* plWaveSet7::ICreateTransferRenderTarget(const char* name, int si plRenderTarget* rt = new plRenderTarget(flags, size, size, bitDepth, zDepth, stencilDepth); - plString buff = plString::Format("%s_%s", GetKey()->GetName().c_str(), name); + plString buff = plFormat("{}_{}", GetKey()->GetName(), name); hsgResMgr::ResMgr()->NewKey(buff, rt, GetKey()->GetUoid().GetLocation()); return rt; @@ -2156,7 +2156,7 @@ plLayer* plWaveSet7::ICreateTotalLayer(plBitmap* bm, hsGMaterial* mat, int which if( !layer ) { layer = new plLayer; - plString buff = plString::Format("%s_%sLayerPS_%d", GetKey()->GetName().c_str(), suff, which); + plString buff = plFormat("{}_{}LayerPS_{}", GetKey()->GetName(), suff, which); hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); layer->SetAmbientColor(hsColorRGBA().Set(0.f, 0.f, 0.f, 1.f)); @@ -2190,7 +2190,7 @@ plLayer* plWaveSet7::ICreateTotalLayer(plBitmap* bm, hsGMaterial* mat, int which plLayer* plWaveSet7::ICreateTotalEnvLayer(plBitmap* envMap, hsGMaterial* mat, int which, const char* pref) { plLayer* layer = new plLayer; - plString buff = plString::Format("%s_%s_EnvLayerPS_%d", GetKey()->GetName().c_str(), pref, which); + plString buff = plFormat("{}_{}_EnvLayerPS_{}", GetKey()->GetName(), pref, which); hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); layer->SetBlendFlags(which ? hsGMatState::kBlendAddSigned : 0); @@ -2290,7 +2290,7 @@ void plWaveSet7::IAddShoreVertexShader(hsGMaterial* mat) plShader* vShader = new plShader; - plString buff = plString::Format("%s_ShoreVS", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_ShoreVS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -2343,7 +2343,7 @@ void plWaveSet7::IAddShorePixelShader(hsGMaterial* mat) { plShader* pShader = new plShader; - plString buff = plString::Format("%s_ShorePS", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_ShorePS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -2366,7 +2366,7 @@ void plWaveSet7::IAddFixedVertexShader(hsGMaterial* mat, const int numUVWs) plShader* vShader = new plShader; - plString buff = plString::Format("%s_FixedVS", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_FixedVS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -2435,7 +2435,7 @@ void plWaveSet7::IAddFixedPixelShader(hsGMaterial* mat) if( !fFixedPShader ) { plShader* pShader = new plShader; - plString buff = plString::Format("%s_FixedPS", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_FixedPS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -2463,7 +2463,7 @@ void plWaveSet7::IAddRipVertexShader(hsGMaterial* mat, const plRipVSConsts& ripC if( !fRipVShader ) { plShader* vShader = new plShader; - plString buff = plString::Format("%s_RipVS", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_RipVS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -2548,7 +2548,7 @@ void plWaveSet7::IAddRipPixelShader(hsGMaterial* mat, const plRipVSConsts& ripCo if( !fRipPShader ) { plShader* pShader = new plShader; - plString buff = plString::Format("%s_RipPS", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_RipPS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -2607,7 +2607,7 @@ plShader* plWaveSet7::ICreateDecalVShader(DecalVType t) plShader* vShader = new plShader; - plString buff = plString::Format("%s_%s", GetKey()->GetName().c_str(), fname[t]); + plString buff = plFormat("{}_{}", GetKey()->GetName(), fname[t]); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -2735,7 +2735,7 @@ plShader* plWaveSet7::ICreateDecalPShader(DecalPType t) plShader* pShader = new plShader; - plString buff = plString::Format("%s_%s", GetKey()->GetName().c_str(), fname[t]); + plString buff = plFormat("{}_{}", GetKey()->GetName(), fname[t]); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -3676,7 +3676,7 @@ plDrawableSpans* plWaveSet7::ICreateGraphDrawable(plDrawableSpans* drawable, hsG plDrawableSpans* plWaveSet7::ICreateEmptyGraphDrawable(const char* name, uint32_t ref, int which) { plDrawableSpans* drawable = new plDrawableSpans; - plString buff = plString::Format("%s_%s_%d", GetKey()->GetName().c_str(), name, which); + plString buff = plFormat("{}_{}_{}", GetKey()->GetName(), name, which); hsgResMgr::ResMgr()->NewKey(buff, drawable, GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->SendRef(drawable->GetKey(), new plGenRefMsg(GetKey(), plRefMsg::kOnRequest, which, (int8_t)ref), plRefFlags::kActiveRef); @@ -3688,7 +3688,7 @@ hsGMaterial* plWaveSet7::ICreateEmptyMaterial(const char* name, uint32_t ref, in { hsGMaterial* mat = new hsGMaterial; - plString buff = plString::Format("%s_%s_%d", GetKey()->GetName().c_str(), name, which); + plString buff = plFormat("{}_{}_{}", GetKey()->GetName(), name, which); hsgResMgr::ResMgr()->NewKey(buff, mat, GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->SendRef(mat->GetKey(), new plGenRefMsg(GetKey(), plRefMsg::kOnRequest, which, (int8_t)ref), plRefFlags::kActiveRef); @@ -3699,7 +3699,7 @@ hsGMaterial* plWaveSet7::ICreateEmptyMaterial(const char* name, uint32_t ref, in plLayer* plWaveSet7::ICreateBlankLayer(const char* name, int suff) { plLayer* lay = new plLayer; - plString buff = plString::Format("%s_%s_%d", GetKey()->GetName().c_str(), name, suff); + plString buff = plFormat("{}_{}_{}", GetKey()->GetName(), name, suff); hsgResMgr::ResMgr()->NewKey(buff, lay, GetKey()->GetUoid().GetLocation()); return lay; @@ -3714,7 +3714,7 @@ plMipmap* plWaveSet7::ICreateBlankTex(const char* name, int width, int height, u plMipmap::kUncompressed, plMipmap::UncompressedInfo::kRGB8888); - plString buff = plString::Format("%s_%s", GetKey()->GetName().c_str(), name); + plString buff = plFormat("{}_{}", GetKey()->GetName(), name); hsgResMgr::ResMgr()->NewKey(buff, mipMap, GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->SendRef(mipMap->GetKey(), new plGenRefMsg(GetKey(), plRefMsg::kOnRequest, 0, (int8_t)ref), plRefFlags::kActiveRef); @@ -4120,7 +4120,7 @@ void plWaveSet7::IAddGraphVShader(hsGMaterial* mat, int iPass) if( !fGraphVShader[iPass] ) { plShader* vShader = new plShader; - plString buff = plString::Format("%s_GraphVS_%d", GetKey()->GetName().c_str(), iPass); + plString buff = plFormat("{}_GraphVS_{}", GetKey()->GetName(), iPass); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -4154,7 +4154,7 @@ void plWaveSet7::IAddGraphPShader(hsGMaterial* mat, int iPass) if( !fGraphPShader[iPass] ) { plShader* pShader = new plShader; - plString buff = plString::Format("%s_GraphPS_%d", GetKey()->GetName().c_str(), iPass); + plString buff = plFormat("{}_GraphPS_{}", GetKey()->GetName(), iPass); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -4228,7 +4228,7 @@ void plWaveSet7::IMakeShoreLayer(hsGMaterial* mat, int which) if( which >= mat->GetNumLayers() ) { plLayer* lay = new plLayer; - name = plString::Format("%s_lay_%d", mat->GetKey()->GetName().c_str(), which); + name = plFormat("{}_lay_{}", mat->GetKey()->GetName(), which); hsgResMgr::ResMgr()->NewKey(name, lay, GetKey()->GetUoid().GetLocation()); lay->SetAmbientColor(hsColorRGBA().Set(0.f, 0.f, 0.f, 1.f)); diff --git a/Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp b/Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp index 124fc406..80ae0250 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp +++ b/Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp @@ -163,7 +163,7 @@ void plFontCache::ILoadCustomFonts( void ) plString keyName; if (font->GetKey() == nil) { - keyName = plString::Format( "%s-%d", font->GetFace().c_str(), font->GetSize() ); + keyName = plFormat("{}-{}", font->GetFace(), font->GetSize()); hsgResMgr::ResMgr()->NewKey( keyName, font, plLocation::kGlobalFixedLoc ); } diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp index 563c3a66..b171a784 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp @@ -837,13 +837,16 @@ void plSceneInputInterface::ILinkOffereeToAge() plString title, desc; unsigned nameLen = plNetClientMgr::GetInstance()->GetPlayerName().GetSize(); - if (plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 's' || plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 'S') { - title = plString::Format( "%s'", plNetClientMgr::GetInstance()->GetPlayerName().c_str() ); - desc = plString::Format( "%s' %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName().c_str() ); + if (plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 's' + || plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 'S') { + title = plFormat("{}'", plNetClientMgr::GetInstance()->GetPlayerName()); + desc = plFormat("{}' {}", plNetClientMgr::GetInstance()->GetPlayerName(), + link.GetAgeInfo()->GetAgeInstanceName()); } else { - title = plString::Format( "%s's", plNetClientMgr::GetInstance()->GetPlayerName().c_str() ); - desc = plString::Format( "%s's %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName().c_str() ); + title = plFormat("{}'s", plNetClientMgr::GetInstance()->GetPlayerName()); + desc = plFormat("{}'s {}", plNetClientMgr::GetInstance()->GetPlayerName(), + link.GetAgeInfo()->GetAgeInstanceName()); } info.SetAgeUserDefinedName( title.c_str() ); diff --git a/Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.cpp b/Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.cpp index 7d338684..ba65e3a0 100644 --- a/Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.cpp @@ -178,8 +178,8 @@ void plSDLModifier::SendState(uint32_t sendFlags) { gMooseDump=true; plNetObjectDebugger::GetInstance()->SetDebugging(true); - curState->DumpToObjectDebugger(plString::Format("Object %s SENDS SDL state", - GetStateOwnerKey()->GetName().c_str(), dirtyOnly).c_str()); + curState->DumpToObjectDebugger(plFormat("Object {} SENDS SDL state", + GetStateOwnerKey()->GetName()).c_str(), dirtyOnly); gMooseDump=false; } @@ -203,8 +203,8 @@ void plSDLModifier::ReceiveState(const plStateDataRecord* srcState) { gMooseDump=true; plNetObjectDebugger::GetInstance()->SetDebugging(true); - srcState->DumpToObjectDebugger(plString::Format("Object %s RECVS SDL state", - GetStateOwnerKey()->GetName().c_str()).c_str()); + srcState->DumpToObjectDebugger(plFormat("Object {} RECVS SDL state", + GetStateOwnerKey()->GetName()).c_str()); gMooseDump=false; } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp index e37f4468..58425280 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp @@ -261,7 +261,7 @@ void plNCAgeJoiner::ExecNextOp () { // Start progress bar plString str; #ifndef PLASMA_EXTERNAL_RELEASE - str = plString::Format("Loading age... %s", age.ageDatasetName); + str = plFormat("Loading age... {}", age.ageDatasetName); #endif progressBar = plProgressMgr::GetInstance()->RegisterOperation(0, str.c_str(), plProgressMgr::kNone, false, true); plDispatch::SetMsgRecieveCallback(IDispatchMsgReceiveCallback); diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp index e24982a7..9631cae8 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp @@ -279,7 +279,7 @@ bool plNetClientMgr::Log(const char* str) const return true; // prepend raw time - plString buf2 = plString::Format("%.2f %s", hsTimer::GetSeconds(), ProcessTab(str)); + plString buf2 = plFormat("{.2f} {}", hsTimer::GetSeconds(), ProcessTab(str)); if ( GetConsoleOutput() ) hsStatusMessage(buf2.c_str()); diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp index da9a8008..b5758393 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp @@ -393,10 +393,10 @@ int plNetClientMgr::ISendGameMessage(plMessage* msg) { #if 0 hsLogEntry(plNetObjectDebugger::GetInstance()->LogMsg( - plString::Format(" object:%s, rcvr %s %s", - msg->GetSender().GetKeyName().c_str(), - msg->GetNumReceivers() ? msg->GetReceiver(0)->GetName().c_str() : "?", - netMsgWrap->AsStdString().c_str()).c_str())); + plFormat(" object:{}, rcvr {} {}", + msg->GetSender().GetKeyName(), + msg->GetNumReceivers() ? msg->GetReceiver(0)->GetName() : "?", + netMsgWrap->AsStdString()).c_str())); #endif } @@ -434,7 +434,7 @@ int plNetClientMgr::SendMsg(plNetMessage* msg) if (plNetMsgGameMessage::ConvertNoRef(msg)) SetFlagsBit(kSendingActions); - plCheckNetMgrResult_ValReturn(ret, plString::Format("Failed to send %s, NC ret=%d", + plCheckNetMgrResult_ValReturn(ret, plFormat("Failed to send {}, NC ret={}", msg->ClassName(), ret).c_str()); return ret; diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.cpp index bb8444f2..3a55638d 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.cpp @@ -252,10 +252,10 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgSDLState) { plString err; if (!sdRec) - err = plString::Format( "SDL descriptor %s missing, v=%d", descName.c_str(), ver); + err = plFormat("SDL descriptor {} missing, v={}", descName, ver); else - err = plString::Format( "SDL descriptor %s, version mismatch, server v=%d, client v=%d", - descName.c_str(), ver, sdRec->GetDescriptor()->GetVersion()); + err = plFormat("SDL descriptor {}, version mismatch, server v={}, client v={}", + descName, ver, sdRec->GetDescriptor()->GetVersion()); hsAssert(false, err.c_str()); nc->ErrorMsg(err.c_str()); diff --git a/Sources/Plasma/PubUtilLib/plNetCommon/plSpawnPointInfo.cpp b/Sources/Plasma/PubUtilLib/plNetCommon/plSpawnPointInfo.cpp index 49a0f83a..0bb3f1e0 100644 --- a/Sources/Plasma/PubUtilLib/plNetCommon/plSpawnPointInfo.cpp +++ b/Sources/Plasma/PubUtilLib/plNetCommon/plSpawnPointInfo.cpp @@ -122,8 +122,5 @@ void plSpawnPointInfo::Reset() plString plSpawnPointInfo::AsString() const { - return plString::Format( "t:%s,n:%s,c:%s", - fTitle.c_str("(nil)"), - fSpawnPt.c_str("(nil)"), - fCameraStack.c_str("(nil)") ); + return plFormat("t:{},n:{},c:{}", fTitle, fSpawnPt, fCameraStack); } diff --git a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.cpp b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.cpp index bcf26c87..27c11713 100644 --- a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.cpp +++ b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.cpp @@ -226,7 +226,7 @@ int plNetMessage::PeekBuffer(const char* bufIn, int bufLen, uint32_t peekOptions readStream.LogSetList(el); readStream.Init(bufLen, bufIn); readStream.LogSubStreamStart("plNetMessage"); - readStream.LogStringString(plString::Format("ClassName: %s", this->ClassName()).c_str()); + readStream.LogStringString(plFormat("ClassName: {}", this->ClassName()).c_str()); int ret; if (peekOptions & kBaseClassOnly) { @@ -704,8 +704,8 @@ plString plNetMsgSDLState::AsString() const { ISetDescName(); // set desc name for debug if necessary - return plString::Format("object:%s, initial:%d, %s", - ObjectInfo()->GetObjectName().c_str(), fIsInitialState, plNetMsgStreamedObject::AsString().c_str() ); + return plFormat("object:{}, initial:{}, {}", + ObjectInfo()->GetObjectName(), fIsInitialState, plNetMsgStreamedObject::AsString()); } // diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp index d052c5b1..50da61ea 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp @@ -857,8 +857,8 @@ void plPXPhysicalControllerCore::IDrawDebugDisplay(int controllerIdx) if (controllerIdx == 0) { y = 10; - debugString = plString::Format("Controller Count: %d", gControllers.size()); - debugTxt.DrawString(x, y, debugString.c_str()); + debugString = plFormat("Controller Count: {}", gControllers.size()); + debugTxt.DrawString(x, y, debugString); y += lineHeight; } @@ -866,9 +866,9 @@ void plPXPhysicalControllerCore::IDrawDebugDisplay(int controllerIdx) int collisionCount = fDbgCollisionInfo.GetCount(); if (collisionCount > 0) { - debugString = plString::Format("Controller #%d (%s) Collisions:", - controllerIdx + 1, gControllers[controllerIdx]->fOwner->GetName().c_str()); - debugTxt.DrawString(x, y, debugString.c_str()); + debugString = plFormat("Controller #{} ({}) Collisions:", + controllerIdx + 1, gControllers[controllerIdx]->fOwner->GetName()); + debugTxt.DrawString(x, y, debugString); y += lineHeight; for (int i = 0; i < collisionCount; i++) @@ -876,11 +876,11 @@ void plPXPhysicalControllerCore::IDrawDebugDisplay(int controllerIdx) hsVector3 normal = fDbgCollisionInfo[i].fNormal; const char* overlapStr = fDbgCollisionInfo[i].fOverlap ? "yes" : "no"; float angle = hsRadiansToDegrees(acos(normal * hsVector3(0, 0, 1))); - debugString = plString::Format("\tObj: %s, Normal: (%.2f, %.2f, %.2f), Angle(%.1f), Overlap(%s)", - fDbgCollisionInfo[i].fSO->GetKeyName().c_str(), + debugString = plFormat("\tObj: {}, Normal: ({.2f}, {.2f}, {.2f}), Angle({.1f}), Overlap({})", + fDbgCollisionInfo[i].fSO->GetKeyName(), normal.fX, normal.fY, normal.fZ, angle, overlapStr); - debugTxt.DrawString(x, y, debugString.c_str()); + debugTxt.DrawString(x, y, debugString); y += lineHeight; } } diff --git a/Sources/Plasma/PubUtilLib/plPhysical/plPhysicalSDLModifier.cpp b/Sources/Plasma/PubUtilLib/plPhysical/plPhysicalSDLModifier.cpp index 41d32caa..004424d2 100644 --- a/Sources/Plasma/PubUtilLib/plPhysical/plPhysicalSDLModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysical/plPhysicalSDLModifier.cpp @@ -215,29 +215,30 @@ void plPhysicalSDLModifier::ILogState(const plStateDataRecord* state, bool useDi plPhysical* phys = IGetPhysical(); - plString log = plString::Format("%s: %s", phys->GetKeyName().c_str(), prefix); + plStringStream log; + log << phys->GetKeyName() << ": " << prefix; if (isPosSet) - log += plString::Format(" Pos=%.1f %.1f %.1f", pos.fX, pos.fY, pos.fZ); + log << plFormat(" Pos={.1f} {.1f} {.1f}", pos.fX, pos.fY, pos.fZ); else - log += " Pos=None"; + log << " Pos=None"; if (isLinVSet) - log += plString::Format(" LinV=%.1f %.1f %.1f", linV.fX, linV.fY, linV.fZ); + log << plFormat(" LinV={.1f} {.1f} {.1f}", linV.fX, linV.fY, linV.fZ); else - log += " LinV=None"; + log << " LinV=None"; if (isAngVSet) - log += plString::Format(" AngV=%.1f %.1f %.1f", angV.fX, angV.fY, angV.fZ); + log << plFormat(" AngV={.1f} {.1f} {.1f}", angV.fX, angV.fY, angV.fZ); else - log += " AngV=None"; + log << " AngV=None"; if (isRotSet) - log += plString::Format(" Rot=%.1f %.1f %.1f %.1f", rot.fX, rot.fY, rot.fZ, rot.fW); + log << plFormat(" Rot={.1f} {.1f} {.1f} {.1f}", rot.fX, rot.fY, rot.fZ, rot.fW); else - log += " Rot=None"; + log << " Rot=None"; - IGetLog()->AddLine(log.c_str(), color); + IGetLog()->AddLine(log.GetString().c_str(), color); } plStatusLog* plPhysicalSDLModifier::IGetLog() diff --git a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXEnumerate.cpp b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXEnumerate.cpp index d7c296c6..a38acf40 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXEnumerate.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXEnumerate.cpp @@ -43,6 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plDXEnumerate.h" #include "plPipeline/hsG3DDeviceSelector.h" #include "hsGDirect3D.h" +#include "plFormat.h" //// Local Typedefs /////////////////////////////////////////////////////////// @@ -84,12 +85,12 @@ HRESULT hsGDirect3DTnLEnumerate::SelectFromDevMode(const hsG3DDeviceRecord* devR } } } - plString errStr = plString::Format("Can't find requested device - %s:%s:%s:%s:%s", + plString errStr = plFormat("Can't find requested device - {}:{}:{}:{}:{}", devRec->GetG3DDeviceTypeName(), - devRec->GetDriverDesc().c_str(), - devRec->GetDriverName().c_str(), - devRec->GetDriverVersion().c_str(), - devRec->GetDeviceDesc().c_str()); + devRec->GetDriverDesc(), + devRec->GetDriverName(), + devRec->GetDriverVersion(), + devRec->GetDeviceDesc()); DWORD enumFlags = 0; int width = devMode->GetWidth(); diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.cpp index a449c863..01c0a7fc 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.cpp @@ -141,7 +141,7 @@ bool plCaptureRender::Capture(const plKey& ack, uint16_t width, uint16_t height) plRenderTarget* rt = new plRenderTarget(flags, width, height, bitDepth, zDepth, stencilDepth); static int idx=0; - plString buff = plString::Format("tRT%d", idx++); + plString buff = plFormat("tRT{}", idx++); hsgResMgr::ResMgr()->NewKey(buff, rt, ack->GetUoid().GetLocation()); @@ -183,7 +183,7 @@ bool plCaptureRender::IProcess(plPipeline* pipe, const plKey& ack, plRenderTarge static int currentCapIndex = 0; // Mipmap isn't created with a key so let's give it one now - plString buff = plString::Format("CaptureRender_%d", currentCapIndex++); + plString buff = plFormat("CaptureRender_{}", currentCapIndex++); hsgResMgr::ResMgr()->NewKey(buff, mipMap, plLocation::kGlobalFixedLoc); mipMap->Ref(); diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp index 83fae06d..3eb283b4 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp @@ -160,7 +160,7 @@ void plPlate::SetTexture(plBitmap *texture) plString keyName; material = new hsGMaterial(); - keyName = plString::Format( "PlateBlank#%d", fMagicUniqueKeyInt++ ); + keyName = plFormat("PlateBlank#{}", fMagicUniqueKeyInt++); hsgResMgr::ResMgr()->NewKey( keyName, material, plLocation::kGlobalFixedLoc ); layer = material->MakeBaseLayer(); layer->SetShadeFlags( layer->GetShadeFlags() | hsGMatState::kShadeNoShade | hsGMatState::kShadeWhite | hsGMatState::kShadeReallyNoFog ); @@ -207,14 +207,14 @@ plMipmap *plPlate::CreateMaterial( uint32_t width, uint32_t height, bool with /// Create a new bitmap fMipmap = new plMipmap( width, height, withAlpha ? plMipmap::kARGB32Config : plMipmap::kRGB32Config, 1 ); memset( fMipmap->GetImage(), 0xff, height * fMipmap->GetRowBytes() ); - keyName = plString::Format( "PlateBitmap#%d", fMagicUniqueKeyInt++ ); + keyName = plFormat("PlateBitmap#{}", fMagicUniqueKeyInt++); hsgResMgr::ResMgr()->NewKey( keyName, fMipmap, plLocation::kGlobalFixedLoc ); fMipmap->SetFlags( fMipmap->GetFlags() | plMipmap::kDontThrowAwayImage ); } /// NOW create a layer wrapper and a material for that layer material = new hsGMaterial(); - keyName = plString::Format( "PlateBlank#%d", fMagicUniqueKeyInt++ ); + keyName = plFormat("PlateBlank#{}", fMagicUniqueKeyInt++); hsgResMgr::ResMgr()->NewKey( keyName, material, plLocation::kGlobalFixedLoc ); layer = material->MakeBaseLayer(); layer->SetShadeFlags( layer->GetShadeFlags() | hsGMatState::kShadeNoShade | hsGMatState::kShadeWhite | hsGMatState::kShadeReallyNoFog ); @@ -245,7 +245,7 @@ void plPlate::CreateFromResource(const plString& resName) plMipmap* resTexture = new plMipmap; resTexture->CopyFrom(plClientResMgr::Instance().getResource(resName)); - plString keyName = plString::Format( "PlateResource#%d", fMagicUniqueKeyInt++ ); + plString keyName = plFormat("PlateResource#{}", fMagicUniqueKeyInt++); hsgResMgr::ResMgr()->NewKey(keyName, resTexture, plLocation::kGlobalFixedLoc); CreateMaterial(resTexture->GetWidth(), resTexture->GetHeight(), true, resTexture); } diff --git a/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp b/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp index beea394d..3e339a4a 100644 --- a/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp @@ -62,7 +62,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com plProgressMgr* plProgressMgr::fManager = nullptr; -#define LOADING_RES "xLoading_Linking.%02d.png" #define LOADING_RES_COUNT 18 plString plProgressMgr::fImageRotation[LOADING_RES_COUNT]; @@ -83,7 +82,7 @@ plProgressMgr::plProgressMgr() // Fill array with pre-computed loading frame IDs for (int i=0; i < LOADING_RES_COUNT; i++) - fImageRotation[i] = plString::Format(LOADING_RES, i); + fImageRotation[i] = plFormat("xLoading_Linking.{_02}.png", i); } plProgressMgr::~plProgressMgr() diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp index 4f9fae2a..69f31245 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp @@ -368,7 +368,7 @@ class plPageFinder : public plRegistryPageIterator } // Try for full location - if (plString::Format("%s_%s", info.GetAge().c_str(), info.GetPage().c_str()).CompareI(fFindString) == 0) + if (plFormat("{}_{}", info.GetAge(), info.GetPage()).CompareI(fFindString) == 0) { *fPagePtr = node; return false; diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp index fc2291d4..74e9121d 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp @@ -78,8 +78,8 @@ plRegistryPageNode::plRegistryPageNode(const plLocation& location, const plStrin // Time to construct our actual file name. For now, we'll use the same old format // of age_page.extension - fPath = plFileName::Join(dataPath, plString::Format("%s_District_%s.prp", - fPageInfo.GetAge().c_str(), fPageInfo.GetPage().c_str())); + fPath = plFileName::Join(dataPath, plFormat("{}_District_{}.prp", + fPageInfo.GetAge(), fPageInfo.GetPage())); } plRegistryPageNode::~plRegistryPageNode() @@ -152,8 +152,8 @@ void plRegistryPageNode::LoadKeys() hsStream* stream = OpenStream(); if (!stream) { - hsAssert(0, plString::Format("plRegistryPageNode::LoadKeysFromSource - bad stream %s,%s", - GetPageInfo().GetAge().c_str(), GetPageInfo().GetPage().c_str()).c_str()); + hsAssert(0, plFormat("plRegistryPageNode::LoadKeysFromSource - bad stream {},{}", + GetPageInfo().GetAge(), GetPageInfo().GetPage()).c_str()); return; } @@ -331,7 +331,7 @@ void plRegistryPageNode::AddKey(plKeyImp* key) // Attempt recovery for (int i = 0; i < 500; i++) { - plString tempName = plString::Format("%s%d", key->GetUoid().GetObjectName().c_str(), i); + plString tempName = plFormat("{}{}", key->GetUoid().GetObjectName(), i); if (keys->FindKey(tempName) == nil) { plUoid uoid(key->GetUoid().GetLocation(), key->GetUoid().GetClassType(), tempName, key->GetUoid().GetLoadMask()); diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp index fa0dba8f..4892b8e0 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp @@ -1162,8 +1162,8 @@ void plResManager::PageInRoom(const plLocation& page, uint16_t objClassToRef, pl kResMgrLog(1, ILog(1, "...IGNORING pageIn request; verification failed! (%s)", condStr.c_str())); - plString msg = plString::Format("Data Problem: Age:%s Page:%s Error:%s", - pageNode->GetPageInfo().GetAge().c_str(), pageNode->GetPageInfo().GetPage().c_str(), condStr.c_str()); + plString msg = plFormat("Data Problem: Age:{} Page:{} Error:{}", + pageNode->GetPageInfo().GetAge(), pageNode->GetPageInfo().GetPage(), condStr); hsMessageBox(msg.c_str(), "Error", hsMessageBoxNormal, hsMessageBoxIconError); hsRefCnt_SafeUnRef(refMsg); diff --git a/Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp b/Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp index 296a8c65..373d80ed 100644 --- a/Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp +++ b/Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp @@ -108,8 +108,7 @@ bool plSDLParser::IParseStateDesc(const plFileName& fileName, hsStream* stream, if (!strcmp(token, "VERSION")) { // read desc version - hsAssert(curDesc, plString::Format("Syntax problem with .sdl file, fileName=%s", - fileName.AsString().c_str()).c_str()); + hsAssert(curDesc, plFormat("Syntax problem with .sdl file, fileName={}", fileName).c_str()); if (stream->GetToken(token, kTokenLen)) { int v=atoi(token); @@ -119,15 +118,13 @@ bool plSDLParser::IParseStateDesc(const plFileName& fileName, hsStream* stream, } else { - hsAssert(false, plString::Format("Error parsing state desc, missing VERSION, fileName=%s", - fileName.AsString().c_str()).c_str()); + hsAssert(false, plFormat("Error parsing state desc, missing VERSION, fileName={}", fileName).c_str()); ok = false; } } else { - hsAssert(false, plString::Format("Error parsing state desc, fileName=%s", - fileName.AsString().c_str()).c_str()); + hsAssert(false, plFormat("Error parsing state desc, fileName={}", fileName).c_str()); ok = false; } @@ -136,8 +133,8 @@ bool plSDLParser::IParseStateDesc(const plFileName& fileName, hsStream* stream, ok = ( plSDLMgr::GetInstance()->FindDescriptor(curDesc->GetName(), curDesc->GetVersion())==nil ); if ( !ok ) { - plString err = plString::Format("Found duplicate SDL descriptor for %s version %d.\nFailed to parse file: %s", - curDesc->GetName().c_str(), curDesc->GetVersion(), fileName.AsString().c_str()); + plString err = plFormat("Found duplicate SDL descriptor for {} version {}.\nFailed to parse file: {}", + curDesc->GetName(), curDesc->GetVersion(), fileName); plNetApp::StaticErrorMsg( err.c_str() ); hsAssert( false, err.c_str() ); } @@ -164,8 +161,7 @@ bool plSDLParser::IParseStateDesc(const plFileName& fileName, hsStream* stream, bool plSDLParser::IParseVarDesc(const plFileName& fileName, hsStream* stream, char token[], plStateDescriptor*& curDesc, plVarDescriptor*& curVar) const { - hsAssert(curDesc, plString::Format("Syntax problem with .sdl file, fileName=%s", - fileName.AsString().c_str()).c_str()); + hsAssert(curDesc, plFormat("Syntax problem with .sdl file, fileName={}", fileName).c_str()); if ( !curDesc ) return false; @@ -183,8 +179,8 @@ bool plSDLParser::IParseVarDesc(const plFileName& fileName, hsStream* stream, ch // nested sdls char* sdlName = token+1; plStateDescriptor* stateDesc = plSDLMgr::GetInstance()->FindDescriptor(sdlName, plSDL::kLatestVersion); - hsAssert(stateDesc, plString::Format("can't find nested state desc reference %s, fileName=%s", - sdlName, fileName.AsString().c_str()).c_str()); + hsAssert(stateDesc, plFormat("can't find nested state desc reference {}, fileName={}", + sdlName, fileName).c_str()); curVar = new plSDVarDescriptor(stateDesc); } else @@ -192,21 +188,20 @@ bool plSDLParser::IParseVarDesc(const plFileName& fileName, hsStream* stream, ch curDesc->AddVar(curVar); bool ok=curVar->SetType(token); - hsAssert(ok, plString::Format("Variable 'type' syntax problem with .sdl file, type=%s, fileName=%s", - token, fileName.AsString().c_str()).c_str()); - dbgStr = plString::Format("\tVAR Type=%s ", token); + hsAssert(ok, plFormat("Variable 'type' syntax problem with .sdl file, type={}, fileName={}", + token, fileName).c_str()); + dbgStr = plFormat("\tVAR Type={} ", token); // // NAME (foo[1]) // if (stream->GetToken(token, kTokenLen)) { - hsAssert(strstr(token, "[") && strstr(token, "]"), plString::Format("invalid var syntax, missing [x], fileName=%s", - fileName.AsString().c_str()).c_str()); + hsAssert(strstr(token, "[") != nullptr && strstr(token, "]") != nullptr, + plFormat("invalid var syntax, missing [x], fileName={}", fileName).c_str()); char* ptr = strtok( token, seps ); // skip [ - hsAssert(curVar, plString::Format("Missing current var. Syntax problem with .sdl file, fileName=%s", - fileName.AsString().c_str()).c_str()); + hsAssert(curVar, plFormat("Missing current var. Syntax problem with .sdl file, fileName={}", fileName).c_str()); curVar->SetName(token); // // COUNT @@ -216,7 +211,7 @@ bool plSDLParser::IParseVarDesc(const plFileName& fileName, hsStream* stream, ch curVar->SetCount(cnt); if (cnt==0) curVar->SetVariableLength(true); - dbgStr += plString::Format("Name=%s[%d]", curVar->GetName().c_str(), cnt); + dbgStr += plFormat("Name={}[{}]", curVar->GetName(), cnt); } // @@ -226,8 +221,7 @@ bool plSDLParser::IParseVarDesc(const plFileName& fileName, hsStream* stream, ch { if (!strcmp(token, "DEFAULT")) { - hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", - fileName.AsString().c_str()).c_str()); + hsAssert(curVar, plFormat("Syntax problem with .sdl file, fileName={}", fileName).c_str()); // read state var type plString defaultStr; @@ -254,8 +248,7 @@ bool plSDLParser::IParseVarDesc(const plFileName& fileName, hsStream* stream, ch else if (!strcmp(token, "DISPLAYOPTION")) { - hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", - fileName.AsString().c_str()).c_str()); + hsAssert(curVar, plFormat("Syntax problem with .sdl file, fileName={}", fileName).c_str()); dbgStr += plString(" ") + token; bool read=stream->GetToken(token, kTokenLen); @@ -272,15 +265,13 @@ bool plSDLParser::IParseVarDesc(const plFileName& fileName, hsStream* stream, ch } else { - hsAssert(false, plString::Format("missing displayOption string, fileName=%s", - fileName.AsString().c_str()).c_str()); + hsAssert(false, plFormat("missing displayOption string, fileName={}", fileName).c_str()); } } else if (!strcmp(token, "DEFAULTOPTION")) { - hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", - fileName.AsString().c_str()).c_str()); + hsAssert(curVar, plFormat("Syntax problem with .sdl file, fileName={}", fileName).c_str()); dbgStr += plString(" ") + token; bool read=stream->GetToken(token, kTokenLen); @@ -292,8 +283,7 @@ bool plSDLParser::IParseVarDesc(const plFileName& fileName, hsStream* stream, ch } else { - hsAssert(false, plString::Format("missing defaultOption string, fileName=%s", - fileName.AsString().c_str()).c_str()); + hsAssert(false, plFormat("missing defaultOption string, fileName={}", fileName).c_str()); } } @@ -301,16 +291,14 @@ bool plSDLParser::IParseVarDesc(const plFileName& fileName, hsStream* stream, ch else if (!strcmp(token, "INTERNAL")) { - hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", - fileName.AsString().c_str()).c_str()); + hsAssert(curVar, plFormat("Syntax problem with .sdl file, fileName={}", fileName).c_str()); curVar->SetInternal(true); dbgStr += plString(" ") + token; } else if (!strcmp(token, "PHASED")) { - hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", - fileName.AsString().c_str()).c_str()); + hsAssert(curVar, plFormat("Syntax problem with .sdl file, fileName={}", fileName).c_str()); curVar->SetAlwaysNew(true); dbgStr += plString(" ") + token; } diff --git a/Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp b/Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp index d42bc664..8684c418 100644 --- a/Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp +++ b/Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp @@ -277,8 +277,8 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption catch(...) { hsAssert( false, - plString::Format("Something bad happened while reading simple var data, desc:%s", - fDescriptor ? fDescriptor->GetName().c_str("?") : "?").c_str()); + plFormat("Something bad happened while reading simple var data, desc:{}", + fDescriptor ? fDescriptor->GetName() : "?").c_str()); return false; } @@ -311,15 +311,15 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption catch(...) { hsAssert( false, - plString::Format("Something bad happened while reading nested var data, desc:%s", - fDescriptor ? fDescriptor->GetName().c_str("?") : "?").c_str()); + plFormat("Something bad happened while reading nested var data, desc:{}", + fDescriptor ? fDescriptor->GetName() : "?").c_str()); return false; } // convert to latest descriptor // Only really need to do this the first time this descriptor is read... plStateDescriptor* latestDesc=plSDLMgr::GetInstance()->FindDescriptor(fDescriptor->GetName(), plSDL::kLatestVersion); - hsAssert( latestDesc, plString::Format("Failed to find latest sdl descriptor for: %s", fDescriptor->GetName().c_str() ).c_str() ); + hsAssert(latestDesc, plFormat("Failed to find latest sdl descriptor for: {}", fDescriptor->GetName()).c_str()); bool forceConvert = (readOptions&plSDL::kForceConvert)!=0; if ( latestDesc && ( forceConvert || ( fDescriptor->GetVersion()!=latestDesc->GetVersion() ) ) ) { @@ -493,14 +493,14 @@ void plStateDataRecord::UpdateFrom(const plStateDataRecord& other, uint32_t writ if ( GetDescriptor()->GetVersion()!=other.GetDescriptor()->GetVersion() ) { plStateDescriptor* sd=plSDLMgr::GetInstance()->FindDescriptor( other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion() ); - hsAssert( sd, plString::Format( "Failed to find sdl descriptor %s,%d. Missing legacy descriptor?", - other.GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetVersion() ).c_str() ); + hsAssert(sd, plFormat("Failed to find sdl descriptor {},{}. Missing legacy descriptor?", + other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion()).c_str()); ConvertTo( sd ); } hsAssert(other.GetDescriptor()==fDescriptor, - plString::Format("descriptor mismatch in UpdateFromDirty, SDL=%s,%s version %d %d", - GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetName().c_str(), + plFormat("descriptor mismatch in UpdateFromDirty, SDL={},{} version {} {}", + GetDescriptor()->GetName(), other.GetDescriptor()->GetName(), GetDescriptor()->GetVersion(), other.GetDescriptor()->GetVersion()).c_str()); bool dirtyOnly = (writeOptions & plSDL::kDirtyOnly); @@ -545,9 +545,9 @@ void plStateDataRecord::FlagDifferentState(const plStateDataRecord& other) } else { - hsAssert(false, plString::Format("descriptor mismatch in FlagDifferentState, mine %s %d, other %s %d", - fDescriptor->GetName().c_str(), fDescriptor->GetVersion(), - other.GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetVersion()).c_str()); + hsAssert(false, plFormat("descriptor mismatch in FlagDifferentState, mine {} {}, other {} {}", + fDescriptor->GetName(), fDescriptor->GetVersion(), + other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion()).c_str()); } } @@ -599,9 +599,9 @@ void plStateDataRecord::FlagNewerState(const plStateDataRecord& other, bool resp } else { - hsAssert(false, plString::Format("descriptor mismatch in FlagNewerState, mine %s %d, other %s %d", - fDescriptor->GetName().c_str(), fDescriptor->GetVersion(), - other.GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetVersion()).c_str()); + hsAssert(false, plFormat("descriptor mismatch in FlagNewerState, mine {} {}, other {} {}", + fDescriptor->GetName(), fDescriptor->GetVersion(), + other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion()).c_str()); } } @@ -736,23 +736,20 @@ void plStateDataRecord::DumpToObjectDebugger(const char* msg, bool dirtyOnly, in if (!dbg) return; - plString pad; - int i; - for(i=0;iLogMsg(plString::Format("%s", fAssocObject.IsValid() ? fAssocObject.GetObjectName().c_str() : " ").c_str()); + dbg->LogMsg(fAssocObject.IsValid() ? fAssocObject.GetObjectName().c_str() : " "); if (msg) - dbg->LogMsg(plString::Format("%s%s", pad.c_str(),msg).c_str()); + dbg->LogMsg(plFormat("{}{}", pad, msg).c_str()); - dbg->LogMsg(plString::Format("%sSDR(%p), desc=%s, showDirty=%d, numVars=%d, vol=%d", - pad.c_str(), this, fDescriptor->GetName().c_str(), dirtyOnly, numVars+numSDVars, fFlags&kVolatile).c_str()); + dbg->LogMsg(plFormat("{}SDR(0x{x}), desc={}, showDirty={}, numVars={}, vol={}", + pad, (uintptr_t)this, fDescriptor->GetName(), dirtyOnly, numVars+numSDVars, fFlags&kVolatile).c_str()); // dump simple vars - for(i=0;iIsDirty()) || (!dirtyOnly && fVarsList[i]->IsUsed()) ) { @@ -761,7 +758,7 @@ void plStateDataRecord::DumpToObjectDebugger(const char* msg, bool dirtyOnly, in } // dump nested vars - for(i=0;iIsDirty()) || (!dirtyOnly && fSDVarsList[i]->IsUsed()) ) { @@ -772,29 +769,26 @@ void plStateDataRecord::DumpToObjectDebugger(const char* msg, bool dirtyOnly, in void plStateDataRecord::DumpToStream(hsStream* stream, const char* msg, bool dirtyOnly, int level) const { - std::string pad; - int i; - for(i=0;iWrite(logStr.GetSize(), logStr.c_str()); if (msg) { - logStr = plString::Format("%s%s", pad.c_str(),msg); + logStr = plFormat("{}{}", pad, msg); stream->Write(logStr.GetSize(), logStr.c_str()); } - logStr = plString::Format("%sSDR(%p), desc=%s, showDirty=%d, numVars=%d, vol=%d", - pad.c_str(), this, fDescriptor->GetName().c_str(), dirtyOnly, numVars+numSDVars, fFlags&kVolatile); + logStr = plFormat("{}SDR(0x{x}), desc={}, showDirty={}, numVars={}, vol={}", + pad, (uintptr_t)this, fDescriptor->GetName(), dirtyOnly, numVars+numSDVars, fFlags&kVolatile); stream->Write(logStr.GetSize(), logStr.c_str()); // dump simple vars - for(i=0;iIsDirty()) || (!dirtyOnly && fVarsList[i]->IsUsed()) ) { @@ -802,8 +796,8 @@ void plStateDataRecord::DumpToStream(hsStream* stream, const char* msg, bool dir } } - // dump nested vars - for(i=0;iIsDirty()) || (!dirtyOnly && fSDVarsList[i]->IsUsed()) ) { diff --git a/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp b/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp index e4796954..ef01995f 100644 --- a/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp +++ b/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp @@ -209,8 +209,8 @@ void plSimpleStateVariable::IDeAlloc() } break; default: - hsAssert(false, plString::Format("undefined atomic type:%d var:%s cnt:%d", - type, GetName().c_str("?"), GetCount()).c_str()); + hsAssert(false, plFormat("undefined atomic type:{} var:{} cnt:{}", + type, GetName(), GetCount()).c_str()); break; }; @@ -411,9 +411,9 @@ void plSimpleStateVariable::IVarSet(bool timeStampNow/*=true*/) plString plSimpleStateVariable::GetAsString(int idx) const { int j; - plString str; + plStringStream str; if (fVar.GetAtomicCount()>1) - str += "("; + str << '('; plVarDescriptor::Type type=fVar.GetAtomicType(); switch(type) @@ -431,29 +431,29 @@ plString plSimpleStateVariable::GetAsString(int idx) const for(j=0;jGetDebugging()) { plNetObjectDebuggerBase::GetInstance()->LogMsg( - plString::Format("Var %s did %s send notification difference. Has %d notifiers with %d recipients.", - GetName().c_str(), !notify ? "NOT" : "", fChangeNotifiers.size(), numNotifiers).c_str()); + plFormat("Var {} did {} send notification difference. Has {} notifiers with {} recipients.", + GetName(), !notify ? "NOT" : "", fChangeNotifiers.size(), numNotifiers).c_str()); } } @@ -2279,77 +2279,87 @@ void plSimpleStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) cons if (!dbg) return; - plString pad; - int i; - for(i=0;i1) { - dbg->LogMsg(logMsg.c_str()); // it's going to be a long msg, so print it on its own line - logMsg = ""; + dbg->LogMsg(logMsg.GetString().c_str()); // it's going to be a long msg, so print it on its own line + logMsg.Truncate(); } - + pad += "\t"; - for(i=0;iLogMsg(logMsg.c_str()); - logMsg = ""; + dbg->LogMsg(logMsg.GetString().c_str()); + logMsg.Truncate(); } } void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int level) const { - plString pad; - int i; - for(i=0;i1) { - stream->WriteString(logMsg); // it's going to be a long msg, so print it on its own line - logMsg = ""; + stream->WriteString(logMsg.GetString()); // it's going to be a long msg, so print it on its own line + logMsg.Truncate(); } - + pad += "\t"; - for(i=0;iWriteString(logMsg); - logMsg = ""; + stream->WriteString(logMsg.GetString()); + logMsg.Truncate(); } } @@ -2485,8 +2495,8 @@ void plSDStateVariable::CopyFrom(plSDStateVariable* other, uint32_t writeOptions void plSDStateVariable::UpdateFrom(plSDStateVariable* other, uint32_t writeOptions/*=0*/) { hsAssert(!other->GetSDVarDescriptor()->GetName().CompareI(fVarDescriptor->GetName()), - plString::Format("var descriptor mismatch in UpdateFrom, name %s,%s ver %d,%d", - GetName().c_str(), other->GetName().c_str()).c_str()); + plFormat("var descriptor mismatch in UpdateFrom, name {},{}", + GetName(), other->GetName()).c_str()); Resize(other->GetCount()); // make sure sizes match bool dirtyOnly = (writeOptions & plSDL::kDirtyOnly); @@ -2676,16 +2686,13 @@ void plSDStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) const if (!dbg) return; - std::string pad; - int i; - for(i=0;iLogMsg(plString::Format( "%sSDVar, name:%s dirtyOnly:%d count:%d", - pad.c_str(), GetName().c_str(), dirtyOnly, cnt).c_str()); + dbg->LogMsg(plFormat("{}SDVar, name:{} dirtyOnly:{} count:{}", + pad, GetName(), dirtyOnly, cnt).c_str()); - for(i=0;iIsDirty()) || (!dirtyOnly && fDataRecList[i]->IsUsed()) ) @@ -2703,8 +2710,8 @@ void plSDStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int level pad += " "; int cnt = dirtyOnly ? GetDirtyCount() : GetUsedCount(); - stream->WriteString(plString::Format( "%sSDVar, name:%s dirtyOnly:%d count:%d", - pad.c_str(), GetName().c_str(), dirtyOnly, cnt)); + stream->WriteString(plFormat("{}SDVar, name:{} dirtyOnly:{} count:{}", + pad, GetName(), dirtyOnly, cnt)); for(i=0;iReadSafeString(); uint16_t version = s->ReadLE16(); plStateDescriptor* sd=plSDLMgr::GetInstance()->FindDescriptor(sdName, version); - hsAssert( sd, plString::Format("Failed to find sdl descriptor: %s,%d. Missing legacy descriptor?", sdName.c_str(), version ).c_str() ); + hsAssert(sd, plFormat("Failed to find sdl descriptor: {},{}. Missing legacy descriptor?", sdName, version).c_str()); SetStateDesc(sd); return true; } diff --git a/Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp b/Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp index f4710555..cb6ca038 100644 --- a/Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp +++ b/Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp @@ -216,9 +216,9 @@ void plAutoProfileImp::INextProfile() plMipmap mipmap; if (plClient::GetInstance()->GetPipeline()->CaptureScreen(&mipmap)) { - plString fileName = plString::Format("%s\\%s_%s.jpg", - plProfileManagerFull::Instance().GetProfilePath().AsString().c_str(), - ageName, fLastSpawnPointName.c_str()); + plString fileName = plFormat("{}\\{}_{}.jpg", + plProfileManagerFull::Instance().GetProfilePath(), + ageName, fLastSpawnPointName); plJPEG::Instance().SetWriteQuality(100); plJPEG::Instance().WriteToFile(fileName.c_str(), &mipmap); diff --git a/Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp b/Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp index 8bb74a15..004c7807 100644 --- a/Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp +++ b/Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp @@ -433,10 +433,10 @@ plFileName plProfileManagerFull::GetProfilePath() plUnifiedTime curTime = plUnifiedTime::GetCurrent(plUnifiedTime::kLocal); profilePath = plFileName::Join(plFileSystem::GetUserDataPath(), "Profile", - plString::Format("%02d-%02d-%04d_%02d-%02d", - curTime.GetMonth(), curTime.GetDay(), - curTime.GetYear(), curTime.GetHour(), - curTime.GetMinute())); + plFormat("{_02}-{_02}-{_04}_{_02}-{_02}", + curTime.GetMonth(), curTime.GetDay(), + curTime.GetYear(), curTime.GetHour(), + curTime.GetMinute())); plFileSystem::CreateDir(profilePath, true); } diff --git a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp index 39a91819..02fad6b6 100644 --- a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp +++ b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp @@ -330,15 +330,15 @@ bool plStatusLog::IReOpen( void ) plFileName fileNoExt; plString ext; IParseFileName(fileNoExt, ext); - plFileName fileToOpen = plString::Format("%s.0.%s", fileNoExt.AsString().c_str(), ext.c_str()); + plFileName fileToOpen = plFormat("{}.0.{}", fileNoExt, ext); if (!(fFlags & kDontRotateLogs)) { plFileName work, work2; - work = plString::Format("%s.3.%s", fileNoExt.AsString().c_str(), ext.c_str()); + work = plFormat("{}.3.{}", fileNoExt, ext); plFileSystem::Unlink(work); - work2 = plString::Format("%s.2.%s", fileNoExt.AsString().c_str(), ext.c_str()); + work2 = plFormat("{}.2.{}", fileNoExt, ext); plFileSystem::Move(work2, work); - work = plString::Format("%s.1.%s", fileNoExt.AsString().c_str(), ext.c_str()); + work = plFormat("{}.1.{}", fileNoExt, ext); plFileSystem::Move(work, work2); plFileSystem::Move(fileToOpen, work); } @@ -715,21 +715,22 @@ bool plStatusLog::IPrintLineToFile( const char *line, uint32_t count ) } - if ( fFlags & kDebugOutput ) + plString out_str = plString::FromUtf8(line, count) + "\n"; + if (fFlags & kDebugOutput) { + #if HS_BUILD_FOR_WIN32 #ifndef PLASMA_EXTERNAL_RELEASE - plString str = plString::Format( "%.*s\n", count, line ); - OutputDebugString( str.c_str() ); + OutputDebugString(out_str.c_str()); #endif #else - fprintf( stderr, "%.*s\n", count, line ); + fputs(str.c_str(), str); #endif } - if ( fFlags & kStdout ) + if (fFlags & kStdout) { - fprintf( stdout, "%.*s\n", count, line ); + fputs(out_str.c_str(), stdout); } return ret; diff --git a/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp b/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp index d3c097de..db4f7e36 100644 --- a/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp +++ b/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp @@ -134,7 +134,7 @@ plLayer* hsGMaterial::MakeBaseLayer() plString buff; if( !GetKeyName().IsNull() ) - buff = plString::Format("%s_Layer", GetKeyName().c_str()); + buff = plFormat("{}_Layer", GetKeyName()); else buff = "Layer"; hsgResMgr::ResMgr()->NewKey( buff, newLay, GetKey() != nil ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); diff --git a/Sources/Plasma/PubUtilLib/plSurface/plGrassShaderMod.cpp b/Sources/Plasma/PubUtilLib/plSurface/plGrassShaderMod.cpp index 8a73529a..de02eda0 100644 --- a/Sources/Plasma/PubUtilLib/plSurface/plGrassShaderMod.cpp +++ b/Sources/Plasma/PubUtilLib/plSurface/plGrassShaderMod.cpp @@ -226,7 +226,7 @@ void plGrassShaderMod::ISetupShaders() if (!fVShader) { plShader* vShader = new plShader; - plString buff = plString::Format("%s_GrassVS", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_GrassVS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); vShader->SetInputFormat(1); @@ -249,7 +249,7 @@ void plGrassShaderMod::ISetupShaders() if (!fPShader) { plShader* pShader = new plShader; - plString buff = plString::Format("%s_GrassPS", GetKey()->GetName().c_str()); + plString buff = plFormat("{}_GrassPS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); pShader->SetNumConsts(0); diff --git a/Sources/Plasma/PubUtilLib/plVault/plDniCoordinateInfo.cpp b/Sources/Plasma/PubUtilLib/plVault/plDniCoordinateInfo.cpp index d33910a1..60bb0c79 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plDniCoordinateInfo.cpp +++ b/Sources/Plasma/PubUtilLib/plVault/plDniCoordinateInfo.cpp @@ -94,6 +94,6 @@ void plDniCoordinateInfo::Write( hsStream* s, hsResMgr* mgr ) plString plDniCoordinateInfo::AsString( int level ) const { plString space = plString::Fill( level, ' ' ); - return plString::Format( "%sDniCoords[%d,%d,%d]", space.c_str(), fHSpans, fVSpans, fTorans ); + return plFormat("{}DniCoords[{},{},{}]", space, fHSpans, fVSpans, fTorans); } #endif // def CLIENT diff --git a/Sources/Tools/MaxComponent/Pch.h b/Sources/Tools/MaxComponent/Pch.h index 9de18dd7..b321c3aa 100644 --- a/Sources/Tools/MaxComponent/Pch.h +++ b/Sources/Tools/MaxComponent/Pch.h @@ -72,6 +72,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsTemplates.h" #include "hsThread.h" #include "plTweak.h" +#include "plFormat.h" // Windows #include "hsWindows.h" diff --git a/Sources/Tools/MaxComponent/plAnimComponent.cpp b/Sources/Tools/MaxComponent/plAnimComponent.cpp index 28b5b585..52a06005 100644 --- a/Sources/Tools/MaxComponent/plAnimComponent.cpp +++ b/Sources/Tools/MaxComponent/plAnimComponent.cpp @@ -890,7 +890,7 @@ bool plAnimComponentBase::IMakePersistent(plMaxNode *node, plAGAnim *anim, plErr plAGMasterMod *mod = plAGMasterMod::ConvertNoRef(fMods[node]); hsAssert(mod != nil, "No MasterMod to make animation persistent!"); - plString buffer = plString::Format("%s_%s_anim_%d", node->GetName(), anim->GetName().c_str(), mod->GetNumPrivateAnimations()); + plString buffer = plFormat("{}_{}_anim_{}", node->GetName(), anim->GetName(), mod->GetNumPrivateAnimations()); plLocation nodeLoc = node->GetLocation(); plKey animKey = hsgResMgr::ResMgr()->NewKey(buffer, anim, nodeLoc); diff --git a/Sources/Tools/MaxComponent/plAudioComponents.cpp b/Sources/Tools/MaxComponent/plAudioComponents.cpp index da85365f..6cd71a5d 100644 --- a/Sources/Tools/MaxComponent/plAudioComponents.cpp +++ b/Sources/Tools/MaxComponent/plAudioComponents.cpp @@ -2317,7 +2317,7 @@ bool plSound3DEmitterComponent::ConvertGrouped( plMaxNode *baseNode, hsTArray if( fIndices.find( baseNode ) != fIndices.end() ) index = fIndices[ baseNode ]; - keyName = plString::Format( "%s_MergedSound", GetINode()->GetName() ); + keyName = plFormat("{}_MergedSound", GetINode()->GetName()); plKey buffKey = baseNode->FindPageKey( plSoundBuffer::Index(), keyName ); if( buffKey != nil ) @@ -2485,7 +2485,7 @@ bool plBackgroundMusicComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) if( srcBuffer == nil ) return false; - plString keyName = plString::Format( "%s_Win32BgndSnd", GetINode()->GetName() ); + plString keyName = plFormat("{}_Win32BgndSnd", GetINode()->GetName()); plWin32Sound *sound = nil; if( srcBuffer->GetDataLengthInSecs() > 4.f ) @@ -2643,7 +2643,7 @@ bool plGUISoundComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) return false; } - plString keyName = plString::Format( "%s_Win32GUISound", GetINode()->GetName() ); + plString keyName = plFormat("{}_Win32GUISound", GetINode()->GetName()); plWin32StaticSound *sound = new plWin32StaticSound; hsgResMgr::ResMgr()->NewKey(keyName, sound, node->GetLocation(), node->GetLoadMask()); diff --git a/Sources/Tools/MaxComponent/plAvatarComponent.cpp b/Sources/Tools/MaxComponent/plAvatarComponent.cpp index afff8249..095d3dc0 100644 --- a/Sources/Tools/MaxComponent/plAvatarComponent.cpp +++ b/Sources/Tools/MaxComponent/plAvatarComponent.cpp @@ -509,11 +509,11 @@ void AddClothingToMod(plMaxNode *node, plArmatureMod *mod, int group, hsGMateria } else base->SetLayoutName("BasicHuman"); - keyName = plString::Format("%s_ClothingBase", node->GetName()); + keyName = plFormat("{}_ClothingBase", node->GetName()); hsgResMgr::ResMgr()->NewKey(keyName, base, node->GetLocation()); plClothingOutfit *outfit = new plClothingOutfit(); outfit->fGroup = group; - keyName = plString::Format("%s_outfit", mod->GetKey()->GetName().c_str()); + keyName = plFormat("{}_outfit", mod->GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(keyName, outfit, node->GetLocation()); msg = new plGenRefMsg(outfit->GetKey(), plRefMsg::kOnCreate, -1, -1); diff --git a/Sources/Tools/MaxComponent/plComponentBase.cpp b/Sources/Tools/MaxComponent/plComponentBase.cpp index e0ba8151..f6fdf991 100644 --- a/Sources/Tools/MaxComponent/plComponentBase.cpp +++ b/Sources/Tools/MaxComponent/plComponentBase.cpp @@ -41,6 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ #include "HeadSpin.h" +#include "plFormat.h" #include "plComponentBase.h" #include "plComponentReg.h" @@ -309,7 +310,7 @@ plString plComponentBase::IGetUniqueName(plMaxNodeBase* target) hsAssert(thisTargIdx != -1, "Bad target for IGetUniqueName"); if (numUsedTargs > 1) - return plString::Format("%s_%d", GetINode()->GetName(), thisTargIdx); + return plFormat("{}_{}", GetINode()->GetName(), thisTargIdx); else return plString::FromUtf8(GetINode()->GetName()); } diff --git a/Sources/Tools/MaxComponent/plInventoryObjComponent.cpp b/Sources/Tools/MaxComponent/plInventoryObjComponent.cpp index 84bb8a55..75fd35a1 100644 --- a/Sources/Tools/MaxComponent/plInventoryObjComponent.cpp +++ b/Sources/Tools/MaxComponent/plInventoryObjComponent.cpp @@ -193,7 +193,7 @@ bool plInventoryObjComponent::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) // Create and register the ClickDrag's logic component plLogicModifier *logic = new plLogicModifier; - plString tmpName = plString::Format("%s_%s_LogicModifier", obj->GetKeyName().c_str(), GetINode()->GetName()); + plString tmpName = plFormat("{}_{}_LogicModifier", obj->GetKeyName(), GetINode()->GetName()); plKey logicKey = hsgResMgr::ResMgr()->NewKey(tmpName, logic, node->GetLocation()); hsgResMgr::ResMgr()->AddViaNotify(logicKey, new plObjRefMsg(obj->GetKey(), plRefMsg::kOnCreate, -1, plObjRefMsg::kModifier), plRefFlags::kActiveRef); diff --git a/Sources/Tools/MaxComponent/plMiscComponents.cpp b/Sources/Tools/MaxComponent/plMiscComponents.cpp index c138df01..0f014ba6 100644 --- a/Sources/Tools/MaxComponent/plMiscComponents.cpp +++ b/Sources/Tools/MaxComponent/plMiscComponents.cpp @@ -648,7 +648,7 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg ) fCompPB->SetValue( kInfoSeqSuffix, 0, 0 ); return; } - plFileName path = plFileName::Join(ageFolder, plString::Format("%s.age", curAge)); + plFileName path = plFileName::Join(ageFolder, plFormat("{}.age", curAge)); IVerifyLatestAgeAsset( curAge, path, errMsg ); std::unique_ptr aged(plPageInfoUtils::GetAgeDesc(curAge)); diff --git a/Sources/Tools/MaxComponent/plMultistageBehComponent.cpp b/Sources/Tools/MaxComponent/plMultistageBehComponent.cpp index 74dbd6bf..15214095 100644 --- a/Sources/Tools/MaxComponent/plMultistageBehComponent.cpp +++ b/Sources/Tools/MaxComponent/plMultistageBehComponent.cpp @@ -333,7 +333,7 @@ void plMultistageBehComponent::FixStageNames() for (int i = 0; i < fStages.size(); i++) { plBaseStage* stage = fStages[i]; - stage->SetName(plString::Format("Stage %d", i)); + stage->SetName(plFormat("Stage {}", i)); } } } diff --git a/Sources/Tools/MaxComponent/plVolumeGadgetComponent.cpp b/Sources/Tools/MaxComponent/plVolumeGadgetComponent.cpp index 6c81a3f9..a2d673b7 100644 --- a/Sources/Tools/MaxComponent/plVolumeGadgetComponent.cpp +++ b/Sources/Tools/MaxComponent/plVolumeGadgetComponent.cpp @@ -335,7 +335,7 @@ bool plVolumeGadgetComponent::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) if(fCompPB->GetInt(kVolumeGadgetEnter) || fCompPB->GetInt(kVolumeTriggerOnFacing)) { plLogicModifier *logic = new plLogicModifier; - plString tmpName = plString::Format("%s_Enter", IGetUniqueName(node).c_str()); + plString tmpName = plFormat("{}_Enter", IGetUniqueName(node)); plKey logicKey = hsgResMgr::ResMgr()->NewKey(tmpName, logic, node->GetLocation()); hsgResMgr::ResMgr()->AddViaNotify(logicKey, new plObjRefMsg(obj->GetKey(), plRefMsg::kOnCreate, -1, plObjRefMsg::kModifier), plRefFlags::kActiveRef); @@ -349,7 +349,7 @@ bool plVolumeGadgetComponent::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) if(fCompPB->GetInt(kVolumeGadgetExit)) { plLogicModifier *logic = new plLogicModifier; - plString tmpName = plString::Format("%s_Exit", IGetUniqueName(node).c_str()); + plString tmpName = plFormat("{}_Exit", IGetUniqueName(node)); plKey logicKey = hsgResMgr::ResMgr()->NewKey(tmpName, logic, node->GetLocation()); hsgResMgr::ResMgr()->AddViaNotify(logicKey, new plObjRefMsg(obj->GetKey(), plRefMsg::kOnCreate, -1, plObjRefMsg::kModifier), plRefFlags::kActiveRef); @@ -407,7 +407,7 @@ void plVolumeGadgetComponent::ICreateConditions(plMaxNode* node, plErrorMsg* err prefix = "Enter"; // Register the detector - plString tmpName = plString::Format("%s_%s", IGetUniqueName(node).c_str(), prefix); + plString tmpName = plFormat("{}_{}", IGetUniqueName(node), prefix); plKey detectorKey = hsgResMgr::ResMgr()->NewKey(tmpName, detector, loc); hsgResMgr::ResMgr()->AddViaNotify(detectorKey, new plObjRefMsg(obj->GetKey(), plRefMsg::kOnCreate, -1, plObjRefMsg::kModifier), plRefFlags::kActiveRef); plVolumeSensorConditionalObject* boxCond=nil; @@ -419,7 +419,7 @@ void plVolumeGadgetComponent::ICreateConditions(plMaxNode* node, plErrorMsg* err { boxCond = new plVolumeSensorConditionalObjectNoArbitration; } - tmpName = plString::Format("%s_%s", IGetUniqueName(node).c_str(), prefix); + tmpName = plFormat("{}_{}", IGetUniqueName(node), prefix); plKey boxKey = hsgResMgr::ResMgr()->NewKey(tmpName, boxCond, loc); if (enter) diff --git a/Sources/Tools/MaxConvert/hsConverterUtils.cpp b/Sources/Tools/MaxConvert/hsConverterUtils.cpp index 249ed920..4ecdb8ce 100644 --- a/Sources/Tools/MaxConvert/hsConverterUtils.cpp +++ b/Sources/Tools/MaxConvert/hsConverterUtils.cpp @@ -239,7 +239,7 @@ char *hsConverterUtils::MangleReference(char *mangName, const char *nodeName, co // Default is to make it global, but you can set another default (like same // room as referencer) with defRoom. - plString tempName = plString::Format("%s..%s", defRoom, nodeName); + plString tempName = plFormat("{}..{}", defRoom, nodeName); return hsStrcpy(mangName, tempName.c_str()); } @@ -278,9 +278,9 @@ char *hsConverterUtils::MangleReference(char *mangName, INode *node, const char* ) tempName = nodeName; else if (roomName && *roomName) - tempName = plString::Format("%s..%s", roomName, nodeName); + tempName = plFormat("{}..{}", roomName, nodeName); else - tempName = plString::Format("%s..%s", defRoom, nodeName); + tempName = plFormat("{}..{}", defRoom, nodeName); return hsStrcpy(mangName, tempName.c_str()); diff --git a/Sources/Tools/MaxConvert/hsMaterialConverter.cpp b/Sources/Tools/MaxConvert/hsMaterialConverter.cpp index e1bf0180..ac94080b 100644 --- a/Sources/Tools/MaxConvert/hsMaterialConverter.cpp +++ b/Sources/Tools/MaxConvert/hsMaterialConverter.cpp @@ -311,7 +311,7 @@ void AttachLinkMtlAnims(plMaxNode *node, hsGMaterial *mat) animLayer = new plLayerLinkAnimation; animLayer->SetLinkKey(node->GetAvatarSO()->GetKey()); //animLayer->fLeavingAge = leaving[x]; - plString fullAnimName = plString::Format("%s_%s_%s", oldLayer->GetKeyName().c_str(), animName, suff); + plString fullAnimName = plFormat("{}_{}_{}", oldLayer->GetKeyName(), animName, suff); hsgResMgr::ResMgr()->NewKey(fullAnimName, animLayer, node->GetLocation()); animLayer->SetOpacityCtl(opaCtl); animLayer->GetTimeConvert().SetBegin(times[0]); @@ -908,7 +908,7 @@ hsGMaterial* hsMaterialConverter::NonAlphaHackPrint(plMaxNode* node, Texmap* bas if( !(baseTex && node) ) return nil; - plString name = plString::Format("%s_%s_%d", node->GetName(), baseTex->GetName(), 0); + plString name = plFormat("{}_{}_0", node->GetName(), baseTex->GetName()); // Search done materials for it @@ -950,7 +950,7 @@ hsGMaterial* hsMaterialConverter::AlphaHackPrint(plMaxNode* node, Texmap* baseTe if( !(baseTex && node) ) return nil; - plString name = plString::Format("%s_%s_%d_AH", node->GetName(), baseTex->GetName(), 0); + plString name = plFormat("{}_{}_0_AH", node->GetName(), baseTex->GetName()); // Search done materials for it @@ -999,7 +999,7 @@ hsGMaterial* hsMaterialConverter::NonAlphaHackVersion(plMaxNode* node, Mtl* mtl, return nil; } - plString name = plString::Format("%s_%s_%d", node->GetName(), mtl->GetName(), subIndex); + plString name = plFormat("{}_{}_{}", node->GetName(), mtl->GetName(), subIndex); return ICreateMaterial(mtl, node, name, subIndex, 1, false); } @@ -1014,7 +1014,7 @@ hsGMaterial* hsMaterialConverter::AlphaHackVersion(plMaxNode* node, Mtl* mtl, in return nil; } - plString name = plString::Format("%s_%s_%d_AH", node->GetName(), mtl->GetName(), subIndex); + plString name = plFormat("{}_{}_{}_AH", node->GetName(), mtl->GetName(), subIndex); return ICreateMaterial(mtl, node, name, subIndex, 1, true); } @@ -1334,7 +1334,7 @@ hsGMaterial *hsMaterialConverter::IAddDefaultMaterial(plMaxNode *node) plLocation loc = node->GetLocation(); hsGMaterial *hMat = new hsGMaterial; - hsgResMgr::ResMgr()->NewKey(plString::Format("%s_DefMat", node->GetName()), hMat, loc); + hsgResMgr::ResMgr()->NewKey(plFormat("{}_DefMat", node->GetName()), hMat, loc); plLayer *layer = new plLayer; layer->InitToDefault(); @@ -1575,7 +1575,7 @@ hsGMaterial *hsMaterialConverter::IProcessCompositeMtl(Mtl *mtl, plMaxNode *node uint32_t *layerCounts = new uint32_t[mtl->NumSubMtls()]; IParamBlock2 *pb = mtl->GetParamBlockByID(plCompositeMtl::kBlkPasses); hsGMaterial *mat = new hsGMaterial; - hsgResMgr::ResMgr()->NewKey(plString::Format("%s_%d", name.c_str(), subMtlFlags), mat, node->GetLocation()); + hsgResMgr::ResMgr()->NewKey(plFormat("{}_{}", name, subMtlFlags), mat, node->GetLocation()); int multiIndex = IFindSubIndex(node, mtl); bool needAlphaHack = node->AlphaHackLayersNeeded(multiIndex) > 0; @@ -1589,7 +1589,7 @@ hsGMaterial *hsMaterialConverter::IProcessCompositeMtl(Mtl *mtl, plMaxNode *node bool usingSubMtl = (i == 0 || pb->GetInt(kCompOn, 0, i - 1)); if ((bitMask & subMtlFlags) != 0 && usingSubMtl) { - plString pref = plString::Format("%s_%d", mat->GetKey()->GetName().c_str(), i); + plString pref = plFormat("{}_{}", mat->GetKeyName(), i); subMtl = mtl->GetSubMtl(i); if (subMtl != nil && subMtl->ClassID() == PASS_MTL_CLASS_ID) @@ -1685,7 +1685,7 @@ hsGMaterial *hsMaterialConverter::IProcessMultipassMtl(Mtl *mtl, plMaxNode *node if ( ( subMtl->ClassID() == PASS_MTL_CLASS_ID || subMtl->ClassID() == BUMP_MTL_CLASS_ID ) && check != 0) { - IProcessPlasmaMaterial(subMtl, node, mat, mat->GetKey()->GetName()); + IProcessPlasmaMaterial(subMtl, node, mat, mat->GetKeyName()); } layerCounts[i] = mat->GetNumLayers(); } @@ -1822,7 +1822,7 @@ plLayerAnimation *IConvertNoteTrackAnims(plLayerAnimation *animLayer, SegmentMap if (spec->fType == SegmentSpec::kAnim) { plLayerAnimation *noteAnim = new plLayerAnimation; - plString animName = plString::Format("%s_anim_%s", name.c_str(), spec->fName); + plString animName = plFormat("{}_anim_{}", name, spec->fName); hsgResMgr::ResMgr()->NewKey(animName, noteAnim, node->GetLocation()); if (animLayer->GetPreshadeColorCtl()) @@ -2049,7 +2049,7 @@ plLayerInterface* IProcessLayerAnimation(plPassMtlBase* mtl, plLayerTex* layTex, if( mtl->GetUseGlobal() ) { plLayerSDLAnimation *SDLLayer = new plLayerSDLAnimation; - plString animName = plString::Format("%s_anim_%s", name.c_str(), mtl->GetGlobalVarName()); + plString animName = plFormat("{}_anim_{}", name, mtl->GetGlobalVarName()); hsgResMgr::ResMgr()->NewKey(animName, SDLLayer, node->GetLocation()); SDLLayer->SetVarName((char*)mtl->GetGlobalVarName()); @@ -2150,7 +2150,7 @@ plLayerInterface* IProcessAnimation(plPassMtlBase *mtl, plMaxNode *node, const p // return layerIFace; plLayerSDLAnimation *SDLLayer = new plLayerSDLAnimation; - plString animName = plString::Format("%s_anim_%s", name.c_str(), mtl->GetGlobalVarName()); + plString animName = plFormat("{}_anim_{}", name, mtl->GetGlobalVarName()); hsgResMgr::ResMgr()->NewKey(animName, SDLLayer, node->GetLocation()); SDLLayer->SetVarName((char*)mtl->GetGlobalVarName()); @@ -3084,7 +3084,7 @@ void hsMaterialConverter::IAppendFunkyLayer(plMaxNode* node, Texmap* texMap, hsG plBitmap* funkRamp = IGetFunkyRamp(node, funkyType); - plString name = plString::Format("%s_funkRamp", prevLay->GetKey()->GetName().c_str()); + plString name = plFormat("{}_funkRamp", prevLay->GetKeyName()); plLayer* layer = new plLayer; layer->InitToDefault(); @@ -3223,7 +3223,7 @@ void hsMaterialConverter::IAppendWetLayer(plMaxNode* node, hsGMaterial* mat) uvwXfm.fMap[1][2] = -1.f / (tr - op); uvwXfm.fMap[1][3] = uvwXfm.fMap[1][2] * -tr; - plString name = plString::Format("%s_funkRamp", prevLay->GetKey()->GetName().c_str()); + plString name = plFormat("{}_funkRamp", prevLay->GetKeyName()); plLayer* layer = nil; plKey key = node->FindPageKey( plLayer::Index(), name ); @@ -3695,13 +3695,13 @@ plLayer* hsMaterialConverter::IMakeBumpLayer(plMaxNode* node, const plString& na switch( miscFlag & hsGMatState::kMiscBumpChans ) { case hsGMatState::kMiscBumpDu: - name = plString::Format("%s_DU_BumpLut", nameBase.c_str()); + name = plFormat("{}_DU_BumpLut", nameBase); break; case hsGMatState::kMiscBumpDv: - name = plString::Format("%s_DV_BumpLut", nameBase.c_str()); + name = plFormat("{}_DV_BumpLut", nameBase); break; case hsGMatState::kMiscBumpDw: - name = plString::Format("%s_DW_BumpLut", nameBase.c_str()); + name = plFormat("{}_DW_BumpLut", nameBase); break; default: hsAssert(false, "Bogus flag input to MakeBumpLayer"); @@ -3779,7 +3779,7 @@ void hsMaterialConverter::IInsertBumpLayers(plMaxNode* node, hsGMaterial* mat, i (bumpLay->GetBlendFlags() & ~hsGMatState::kBlendMask) | hsGMatState::kBlendDot3); - plString name = mat->GetLayer(bumpLayerIdx)->GetKey()->GetName(); + plString name = mat->GetLayer(bumpLayerIdx)->GetKeyName(); plLayer* layerDu = IMakeBumpLayer(node, name, mat, hsGMatState::kMiscBumpDu); plLayer* layerDv = IMakeBumpLayer(node, name, mat, hsGMatState::kMiscBumpDv); @@ -4542,7 +4542,7 @@ plClothingItem *hsMaterialConverter::GenerateClothingItem(plClothingMtl *mtl, co cloth->fDefaultTint2[1] = (uint8_t)(tint2.g * 255.f); cloth->fDefaultTint2[2] = (uint8_t)(tint2.b * 255.f); - clothKeyName = plString::Format("CItm_%s", cloth->fName.c_str()); + clothKeyName = plFormat("CItm_{}", cloth->fName); hsgResMgr::ResMgr()->NewKey(clothKeyName, cloth, loc); plNodeRefMsg* nodeRefMsg = new plNodeRefMsg(plKeyFinder::Instance().FindSceneNodeKey(loc), @@ -4621,7 +4621,7 @@ static int ICompareBaseLayerTexture(const hsMaterialConverter::DoneMaterialData* if( !oneTex && twoTex ) return -1; - return oneTex->GetKey()->GetName().Compare(twoTex->GetKey()->GetName(), plString::kCaseInsensitive); + return oneTex->GetKeyName().Compare(twoTex->GetKeyName(), plString::kCaseInsensitive); } static int IIsAnimatedLayer(const plLayerInterface* lay) @@ -4678,7 +4678,7 @@ static int ICompareDoneLayers(const plLayerInterface* one, const plLayerInterfac if( one->GetTexture() && two->GetTexture() ) { - retVal = one->GetTexture()->GetKey()->GetName().Compare(two->GetTexture()->GetKey()->GetName(), plString::kCaseInsensitive); + retVal = one->GetTexture()->GetKeyName().Compare(two->GetTexture()->GetKeyName(), plString::kCaseInsensitive); if( retVal < 0 ) return -1; else if( retVal > 0 ) @@ -5132,7 +5132,7 @@ hsMaterialConverter::DoneMaterialData* hsMaterialConverter::IFindDoneMaterial(Do plMipmap *hsMaterialConverter::GetStaticColorTexture(Color c, plLocation &loc) { uint32_t colorHex = MakeUInt32Color(c.r, c.g, c.b, 1.f); - plString texName = plString::Format("StaticColorTex_4x4_%X", colorHex); + plString texName = plFormat("StaticColorTex_4x4_{X}", colorHex); int w = 4; int h = 4; diff --git a/Sources/Tools/MaxConvert/plBitmapCreator.cpp b/Sources/Tools/MaxConvert/plBitmapCreator.cpp index e9b119e1..1503acdb 100644 --- a/Sources/Tools/MaxConvert/plBitmapCreator.cpp +++ b/Sources/Tools/MaxConvert/plBitmapCreator.cpp @@ -538,18 +538,18 @@ plBitmap *plBitmapCreator::ICreateTexture( plBitmapData *bd, const plLocation &l { // Mangle of the form: name@dropStart&dropStop&max&min if( clipID != -1 ) - name = plString::Format( "%s*%x#%d@%s&%3.2f&%3.2f&%3.2f&%3.2f", temp.c_str(), bd->texFlags, clipID, + name = plFormat("{}*{x}#{}@{}&{3.2f}&{3.2f}&{3.2f}&{3.2f}", temp, bd->texFlags, clipID, bd->createFlags & plMipmap::kCreateDetailAlpha ? "al" : ( bd->createFlags & plMipmap::kCreateDetailAdd ? "ad" : "mu" ), bd->detailDropoffStart, bd->detailDropoffStop, bd->detailMax, bd->detailMin ); else - name = plString::Format( "%s*%x@%s&%3.2f&%3.2f&%3.2f&%3.2f", temp.c_str(), bd->texFlags, + name = plFormat("{}*{x}@{}&{3.2f}&{3.2f}&{3.2f}&{3.2f}", temp, bd->texFlags, bd->createFlags & plMipmap::kCreateDetailAlpha ? "al" : ( bd->createFlags == plMipmap::kCreateDetailAdd ? "ad" : "mu" ), bd->detailDropoffStart, bd->detailDropoffStop, bd->detailMax, bd->detailMin ); } else if( clipID != -1 ) - name = plString::Format( "%s*%x#%d", temp.c_str(), bd->texFlags, clipID ); + name = plFormat("{}*{x}#{}", temp, bd->texFlags, clipID); else - name = plString::Format( "%s*%x", temp.c_str(), bd->texFlags ); + name = plFormat("{}*{x}", temp, bd->texFlags); if( bd->invertAlpha ) name += "_inva"; name += ".hsm"; diff --git a/Sources/Tools/MaxConvert/plClusterUtil.cpp b/Sources/Tools/MaxConvert/plClusterUtil.cpp index 8ffc3435..09618995 100644 --- a/Sources/Tools/MaxConvert/plClusterUtil.cpp +++ b/Sources/Tools/MaxConvert/plClusterUtil.cpp @@ -105,7 +105,7 @@ plClusterGroup* plClusterUtil::CreateGroup(plMaxNode* templNode, const char* nam { plClusterGroup* retVal = new plClusterGroup; - plString buff = plString::Format("%s_%s_%d", name, templNode->GetName(), fIdx++); + plString buff = plFormat("{}_{}_{}", name, templNode->GetName(), fIdx++); hsgResMgr::ResMgr()->NewKey(buff, retVal, templNode->GetLocation(), templNode->GetLoadMask()); plKey sceneNode = templNode->GetRoomKey(); diff --git a/Sources/Tools/MaxConvert/plLayerConverter.cpp b/Sources/Tools/MaxConvert/plLayerConverter.cpp index 701a9c3d..ee26da7c 100644 --- a/Sources/Tools/MaxConvert/plLayerConverter.cpp +++ b/Sources/Tools/MaxConvert/plLayerConverter.cpp @@ -570,10 +570,10 @@ plLayerInterface *plLayerConverter::IConvertDynamicEnvLayer( plPlasmaMAXLayer if( anchor == maxNode ) { // Self-anchoring material, make sure the name is unique via the nodeName - texName = plString::Format( "%s_cubicRT@%s", plasmaLayer->GetKeyName().c_str(), maxNode->GetName() ); + texName = plFormat("{}_cubicRT@{}", plasmaLayer->GetKeyName(), maxNode->GetName()); } else - texName = plString::Format( "%s_cubicRT", plasmaLayer->GetKeyName().c_str() ); + texName = plFormat("{}_cubicRT", plasmaLayer->GetKeyName()); plBitmap *texture = (plBitmap *)IMakeCubicRenderTarget( texName, maxNode, anchor ); if( texture ) @@ -776,10 +776,8 @@ static uint32_t MakeUInt32Color(float r, float g, float b, float a) plBitmap* plLayerConverter::IGetAttenRamp(plMaxNode *node, BOOL isAdd, int loClamp, int hiClamp) { - plString funkName = plString::Format("%s_%d_%d", - isAdd ? "AttenRampAdd" : "AttenRampMult", - loClamp, - hiClamp); + plString funkName = plFormat("{}_{}_{}", isAdd ? "AttenRampAdd" : "AttenRampMult", + loClamp, hiClamp); float range = float(hiClamp - loClamp) * 1.e-2f; float lowest = float(loClamp) * 1.e-2f; @@ -1003,7 +1001,7 @@ plDynamicTextMap *plLayerConverter::ICreateDynTextMap( const plString &layerN // Need a unique key name for every layer that uses one. We could also key // off of width and height, but layerName should be more than plenty - plString texName = plString::Format( "%s_dynText", layerName.c_str() ); + plString texName = plFormat("{}_dynText", layerName); // Does it already exist? key = node->FindPageKey( plDynamicTextMap::Index(), texName ); @@ -1124,7 +1122,7 @@ plCubicRenderTarget *plLayerConverter::IMakeCubicRenderTarget( const plString &n /// Now make a modifier plCubicRenderTargetModifier *mod = new plCubicRenderTargetModifier(); - plString modName = plString::Format( "%s_mod", name.c_str() ); + plString modName = plFormat("{}_mod", name); hsgResMgr::ResMgr()->NewKey( modName, mod, node->GetLocation() ); hsgResMgr::ResMgr()->AddViaNotify( cubic->GetKey(), new plGenRefMsg( mod->GetKey(), plRefMsg::kOnCreate, 0, 0 ), plRefFlags::kPassiveRef ); diff --git a/Sources/Tools/MaxConvert/plLightMapGen.cpp b/Sources/Tools/MaxConvert/plLightMapGen.cpp index 93867ec1..205a4663 100644 --- a/Sources/Tools/MaxConvert/plLightMapGen.cpp +++ b/Sources/Tools/MaxConvert/plLightMapGen.cpp @@ -369,7 +369,7 @@ bool plLightMapGen::ICompressLightMaps() { const plLocation &textureLoc = plPluginResManager::ResMgr()->GetCommonPage(orig->GetKey()->GetUoid().GetLocation(), plAgeDescription::kTextures ); - plString name = plString::Format("%s_DX", orig->GetKey()->GetName().c_str()); + plString name = plFormat("{}_DX", orig->GetKey()->GetName()); plKey compKey = hsgResMgr::ResMgr()->FindKey(plUoid(textureLoc, plMipmap::Index(), name)); if( compKey ) @@ -1255,7 +1255,7 @@ plLayerInterface* plLightMapGen::IMakeLightMapLayer(plMaxNode* node, plGeometryS return mat->GetPiggyBack(i); } - plString newMatName = plString::Format("%s_%s_LIGHTMAPGEN", mat->GetKey()->GetName().c_str(), node->GetName()); + plString newMatName = plFormat("{}_{}_LIGHTMAPGEN", mat->GetKey()->GetName(), node->GetName()); plLocation nodeLoc = node->GetLocation(); plKey matKey = hsgResMgr::ResMgr()->FindKey(plUoid(nodeLoc, hsGMaterial::Index(), newMatName)); @@ -1293,7 +1293,7 @@ plLayerInterface* plLightMapGen::IMakeLightMapLayer(plMaxNode* node, plGeometryS // Make sure layer (and mip) name are unique across pages by putting the page name in const plPageInfo* pageInfo = plKeyFinder::Instance().GetLocationInfo(node->GetLocation()); - plString layName = plString::Format("%s_%s_LIGHTMAPGEN", pageInfo->GetPage().c_str(), node->GetName()); + plString layName = plFormat("{}_{}_LIGHTMAPGEN", pageInfo->GetPage(), node->GetName()); plKey layKey = node->FindPageKey(plLayer::Index(), layName); @@ -1310,7 +1310,7 @@ plLayerInterface* plLightMapGen::IMakeLightMapLayer(plMaxNode* node, plGeometryS } else { - plString mipmapName = plString::Format( "%s_mip", layName.c_str() ); + plString mipmapName = plFormat("{}_mip", layName); // Deleted the NOTE here because it was incorrect in every meaningful sense of the word. - mf @@ -1320,7 +1320,7 @@ plLayerInterface* plLightMapGen::IMakeLightMapLayer(plMaxNode* node, plGeometryS if( !mipKey && !fRecalcLightMaps ) { - plString compressedName = plString::Format("%s_DX", mipmapName.c_str()); + plString compressedName = plFormat("{}_DX", mipmapName); plKey compKey = hsgResMgr::ResMgr()->FindKey(plUoid(textureLoc, plMipmap::Index(), compressedName)); diff --git a/Sources/Tools/MaxConvert/plMeshConverter.cpp b/Sources/Tools/MaxConvert/plMeshConverter.cpp index d0375131..abd503cd 100644 --- a/Sources/Tools/MaxConvert/plMeshConverter.cpp +++ b/Sources/Tools/MaxConvert/plMeshConverter.cpp @@ -494,7 +494,7 @@ bool plMeshConverter::IValidateUVs(plMaxNode* node) if (uvsAreBad) { - plFileName logfile = plString::Format("UV_%s.log", GetCOREInterface()->GetCurFileName().data()); + plFileName logfile = plFormat("UV_{}.log", GetCOREInterface()->GetCurFileName().data()); plStatusLog::AddLineS(logfile, "%s has suspicious UVs", node->GetName()); if (fWarnSuspiciousUVs) diff --git a/Sources/Tools/MaxMain/plMaxNode.cpp b/Sources/Tools/MaxMain/plMaxNode.cpp index e6983855..fc576665 100644 --- a/Sources/Tools/MaxMain/plMaxNode.cpp +++ b/Sources/Tools/MaxMain/plMaxNode.cpp @@ -1443,7 +1443,7 @@ bool plMaxNode::MakeMesh(plErrorMsg *pErrMsg, plConvertSettings *settings) for (i = 0; i < spanArray.GetCount(); i++) swapSpans->Append(spanArray.Get(i)); - plString tmpName = plString::Format("%s_SMsh", GetName()); + plString tmpName = plFormat("{}_SMsh", GetName()); hsgResMgr::ResMgr()->NewKey(tmpName, GetSwappableGeom(), GetLocation(), GetLoadMask()); return true; @@ -2255,12 +2255,12 @@ bool plMaxNode::ConvertToOccluder(plErrorMsg* pErrMsg, bool twoSided, bool isHol plString tmpName; if( GetKey() && !GetKey()->GetName().IsEmpty() ) { - tmpName = plString::Format("%s_Occluder", GetKey()->GetName().c_str()); + tmpName = plFormat("{}_Occluder", GetKey()->GetName()); } else { static int numOcc = 0; - tmpName = plString::Format("Occluder_%4.4d", numOcc); + tmpName = plFormat("Occluder_{_04d}", numOcc); } plKey key = hsgResMgr::ResMgr()->NewKey( tmpName, occ, nodeLoc, GetLoadMask() ); @@ -3341,13 +3341,13 @@ plDrawableSpans *plMaxNode::IGetSceneNodeSpans( plSceneNode *node, bool needBlen { /// Blending (deferred) spans spans->SetCriteria( crit ); - tmpName = plString::Format( "%s_%8.8x_%xBlendSpans", node->GetKeyName().c_str(), crit.fLevel.fLevel, crit.fCriteria); + tmpName = plFormat("{}_{_08x}_{x}BlendSpans", node->GetKeyName(), crit.fLevel.fLevel, crit.fCriteria); } else { /// Normal spans spans->SetCriteria( crit ); - tmpName = plString::Format( "%s_%8.8x_%xSpans", node->GetKeyName().c_str(), crit.fLevel.fLevel, crit.fCriteria); + tmpName = plFormat("{}_{_08x}_{x}Spans", node->GetKeyName(), crit.fLevel.fLevel, crit.fCriteria); } if (GetSwappableGeomTarget() != (uint32_t)-1 || GetSwappableGeom()) // We intend to swap geometry with this node... flag the drawable as volatile diff --git a/Sources/Tools/MaxMain/plPluginResManager.cpp b/Sources/Tools/MaxMain/plPluginResManager.cpp index 12e89fea..b39c9f4a 100644 --- a/Sources/Tools/MaxMain/plPluginResManager.cpp +++ b/Sources/Tools/MaxMain/plPluginResManager.cpp @@ -65,7 +65,7 @@ plKey plPluginResManager::NameToLoc(const plString& age, const plString& page, i hsAssert(pageNode != nil, "No page returned from INameToPage(), shouldn't be possible"); // Go find the sceneNode now, since we know the page exists (go through our normal channels, though) - plString keyName = plString::Format("%s_%s", age.c_str(), page.c_str()); + plString keyName = plFormat("{}_{}", age, page); plUoid nodeUoid(pageNode->GetPageInfo().GetLocation(), plSceneNode::Index(), keyName); diff --git a/Sources/Tools/MaxPlasmaMtls/Layers/plPlasmaMAXLayer.cpp b/Sources/Tools/MaxPlasmaMtls/Layers/plPlasmaMAXLayer.cpp index 9a885ef2..011eac7e 100644 --- a/Sources/Tools/MaxPlasmaMtls/Layers/plPlasmaMAXLayer.cpp +++ b/Sources/Tools/MaxPlasmaMtls/Layers/plPlasmaMAXLayer.cpp @@ -157,7 +157,7 @@ class plLayerTargetContainer : public hsKeyedObject plLayerTargetContainer() { - plString str = plString::Format( "plLayerTargetContainer-%d", fKeyCount++ ); + plString str = plFormat("plLayerTargetContainer-{}", fKeyCount++); hsgResMgr::ResMgr()->NewKey( str, this, plLocation::kGlobalFixedLoc ); } }; diff --git a/Sources/Tools/plFontConverter/plFontConverter.cpp b/Sources/Tools/plFontConverter/plFontConverter.cpp index a44ef519..8dec0c85 100644 --- a/Sources/Tools/plFontConverter/plFontConverter.cpp +++ b/Sources/Tools/plFontConverter/plFontConverter.cpp @@ -570,7 +570,7 @@ void plFontConverter::IBatchFreeType(const plFileName &path, void *init) fFont->SetFace(fontName); plFileName fileName = plFileName::Join(destPath, - plString::Format("%s-%d.p2f", fFont->GetFace().c_str(), fFont->GetSize())); + plFormat("{}-{}.p2f", fFont->GetFace(), fFont->GetSize())); hsUNIXStream stream; if (!stream.Open(fileName, "wb")) QMessageBox::critical(this, tr("ERROR"), tr("Can't open file for writing")); diff --git a/Sources/Tools/plLocalizationEditor/plAddDlgs.h b/Sources/Tools/plLocalizationEditor/plAddDlgs.h index 027dc12e..61c7438d 100644 --- a/Sources/Tools/plLocalizationEditor/plAddDlgs.h +++ b/Sources/Tools/plLocalizationEditor/plAddDlgs.h @@ -44,7 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #define __plAddDlgs_h__ #include -#include "plString.h" +#include "plFormat.h" class plAddElementDlg : public QDialog { @@ -57,7 +57,7 @@ public: bool DoPick(); // returns true if [Ok] clicked, false otherwise. plString GetValue() const { - return plString::Format("%s.%s.%s", fAgeName.c_str(), fSetName.c_str(), fElementName.c_str()); + return plFormat("{}.{}.{}", fAgeName, fSetName, fElementName); } private slots: diff --git a/Sources/Tools/plLocalizationEditor/plEditDlg.cpp b/Sources/Tools/plLocalizationEditor/plEditDlg.cpp index 1dde33bc..ac34cbe4 100644 --- a/Sources/Tools/plLocalizationEditor/plEditDlg.cpp +++ b/Sources/Tools/plLocalizationEditor/plEditDlg.cpp @@ -117,7 +117,7 @@ void EditDialog::SaveLocalizationText() if (ageName.IsEmpty() || setName.IsEmpty() || elementName.IsEmpty() || elementLanguage.IsEmpty()) return; - plString name = plString::Format("%s.%s.%s", ageName.c_str(), setName.c_str(), elementName.c_str()); + plString name = plFormat("{}.{}.{}", ageName, setName, elementName); pfLocalizationDataMgr::Instance().SetElementPlainTextData(name, elementLanguage, text); } @@ -138,7 +138,7 @@ void EditDialog::LoadLocalization(const plString &locPath) else { EnableEdit(true); - plString key = plString::Format("%s.%s.%s", ageName.c_str(), setName.c_str(), elementName.c_str()); + plString key = plFormat("{}.{}.{}", ageName, setName, elementName); plString elementText = pfLocalizationDataMgr::Instance().GetElementPlainTextData(key, elementLanguage); fUI->fLocalizationText->setPlainText(elementText.c_str()); } @@ -306,12 +306,12 @@ void EditDialog::AddClicked() plString newLanguage = dlg.GetValue(); plString ageName, setName, elementName, elementLanguage; SplitLocalizationPath(fCurrentLocPath, ageName, setName, elementName, elementLanguage); - plString key = plString::Format("%s.%s.%s", ageName.c_str(), setName.c_str(), elementName.c_str()); + plString key = plFormat("{}.{}.{}", ageName, setName, elementName); if (!pfLocalizationDataMgr::Instance().AddLocalization(key, newLanguage)) QMessageBox::critical(this, tr("Error"), tr("Couldn't add additional localization!")); else { - plString path = plString::Format("%s.%s", key.c_str(), newLanguage.c_str()); + plString path = plFormat("{}.{}", key, newLanguage); fCurrentLocPath = ""; fUI->fLocalizationTree->clear(); fUI->fLocalizationTree->LoadData(path); @@ -347,7 +347,7 @@ void EditDialog::DeleteClicked() { plString ageName, setName, elementName, elementLanguage; SplitLocalizationPath(fCurrentLocPath, ageName, setName, elementName, elementLanguage); - plString key = plString::Format("%s.%s.%s", ageName.c_str(), setName.c_str(), elementName.c_str()); + plString key = plFormat("{}.{}.{}", ageName, setName, elementName); if (!pfLocalizationDataMgr::Instance().DeleteLocalization(key, elementLanguage)) QMessageBox::critical(this, tr("Error"), tr("Couldn't delete localization!")); else diff --git a/Sources/Tools/plShaderAssembler/main.cpp b/Sources/Tools/plShaderAssembler/main.cpp index 4b10dab0..3e6454ab 100644 --- a/Sources/Tools/plShaderAssembler/main.cpp +++ b/Sources/Tools/plShaderAssembler/main.cpp @@ -6,99 +6,55 @@ #include #include -void ICreateHeader(const char* const varName, const char* const fileName, FILE* fp, LPD3DXBUFFER shader) +void ICreateHeader(const plString& varName, const plFileName& fileName, FILE* fp, LPD3DXBUFFER shader) { - fprintf(fp, "\n\n\n"); + fputs("\n\n\n", fp); int byteLen = shader->GetBufferSize(); int quadLen = byteLen >> 2; unsigned char* codes = (unsigned char*)shader->GetBufferPointer(); - fprintf(fp, "static const uint32_t %sbyteLen = %d;\n\n", varName, byteLen); - fprintf(fp, "static const uint8_t %sCodes[] = {\n", varName); + plPrintf(fp, "static const uint32_t {}byteLen = {};\n\n", varName, byteLen); + plPrintf(fp, "static const uint8_t {}Codes[] = {\n", varName); int i; for( i = 0; i < quadLen-1; i++ ) { - fprintf(fp, "\t0x%x,", *codes++); - fprintf(fp, "\t0x%x,", *codes++); - fprintf(fp, "\t0x%x,", *codes++); - fprintf(fp, "\t0x%x,\n", *codes++); + plPrintf(fp, "\t0x{x},", *codes++); + plPrintf(fp, "\t0x{x},", *codes++); + plPrintf(fp, "\t0x{x},", *codes++); + plPrintf(fp, "\t0x{x},\n", *codes++); } - fprintf(fp, "\t0x%x,", *codes++); - fprintf(fp, "\t0x%x,", *codes++); - fprintf(fp, "\t0x%x,", *codes++); - fprintf(fp, "\t0x%x\n", *codes++); - fprintf(fp, "\t};"); - fprintf(fp, "\n\n"); - - fprintf(fp, "static const plShaderDecl %sDecl(\"%s\", %s, %sbyteLen, %sCodes);\n\n", varName, fileName, varName, varName, varName); - fprintf(fp, "static const plShaderRegister %sRegister(&%sDecl);\n\n", varName, varName); + plPrintf(fp, "\t0x{x},", *codes++); + plPrintf(fp, "\t0x{x},", *codes++); + plPrintf(fp, "\t0x{x},", *codes++); + plPrintf(fp, "\t0x{x}\n", *codes++); + fputs("\t};", fp); + fputs("\n\n", fp); + + plPrintf(fp, "static const plShaderDecl {}Decl(\"{}\", {}, {}byteLen, {}Codes);\n\n", + varName, fileName, varName, varName, varName); + plPrintf(fp, "static const plShaderRegister {}Register(&{}Decl);\n\n", varName, varName); } int main(int argc, char* argv[]) { if( argc < 2 ) { - printf("%s ...\n", argv[0]); + plPrintf("{} ...\n", argv[0]); return 0; } - const char* const * nameList = 0L; + + const char* const * nameList = nullptr; int numNames = 0; - if( !_stricmp(argv[1], "all") ) + if (stricmp(argv[1], "all") == 0) { - // Cut and paste enum and add kNumEnumNames to end - // so you don't have to count. - enum { - vs_WaveFixedFin6, - ps_WaveFixed, - vs_CompCosines, - ps_CompCosines, - vs_ShoreLeave6, - ps_ShoreLeave6, - vs_WaveRip, - ps_WaveRip, - vs_WaveDec1Lay, - vs_WaveDec2Lay11, - vs_WaveDec2Lay12, - vs_WaveDecEnv, - ps_CbaseAbase, - ps_CalphaAbase, - ps_CalphaAMult, - ps_CalphaAadd, - ps_CaddAbase, - ps_CaddAMult, - ps_CaddAAdd, - ps_CmultAbase, - ps_CmultAMult, - ps_CmultAAdd, - ps_WaveDecEnv, - vs_WaveGraph2, - ps_WaveGraph, - vs_WaveGridFin, - ps_WaveGrid, - vs_BiasNormals, - ps_BiasNormals, - vs_ShoreLeave7, - vs_WaveRip7, - ps_MoreCosines, - vs_WaveDec1Lay_7, - vs_WaveDec2Lay11_7, - vs_WaveDec2Lay12_7, - vs_WaveDecEnv_7, - vs_WaveFixedFin7, - vs_GrassShader, - ps_GrassShader, - - kNumEnumNames - }; - // Just copy in the enum and use Replace on // vs_ => "vs_ // ps_ => "ps_ // , => ", - const char* kEnumNames[kNumEnumNames] = { + const char* kEnumNames[] = { "vs_WaveFixedFin6", "ps_WaveFixed", "vs_CompCosines", @@ -141,62 +97,54 @@ int main(int argc, char* argv[]) }; nameList = kEnumNames; - numNames = kNumEnumNames; + numNames = arrsize(kEnumNames); } else { nameList = argv+1; numNames = argc-1; } - int i; - for( i = 0; i < numNames; i++ ) + + for (int i = 0; i < numNames; i++ ) { const char* name = nameList[i]; + plString varName = plFileName(name).StripFileExt().AsString(); - char varName[512]; - strcpy(varName, name); - char* p = strrchr(varName, '.'); - if( p ) - *p = 0; - - char inFile[512]; - sprintf(inFile, "%s.inl", varName); - - char outFile[512]; - sprintf(outFile, "%s.h", varName); + plFileName inFile = plFormat("{}.inl", varName); + plFileName outFile = plFormat("{}.h", varName); - printf("Processing %s into %s\n", name, outFile); - FILE* fp = fopen(outFile, "w"); - if( !fp ) + plPrintf("Processing {} into {}\n", name, outFile); + FILE* fp = fopen(outFile.AsString().c_str(), "w"); + if (!fp) { - printf("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"); - printf("Error opening file %s for output\n"); - printf("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"); + fputs("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stdout); + plPrintf("Error opening file %s for output\n", outFile); + fputs("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stdout); continue; } - LPD3DXBUFFER compiledShader = 0L; - LPD3DXBUFFER compilationErrors = 0L; + LPD3DXBUFFER compiledShader = nullptr; + LPD3DXBUFFER compilationErrors = nullptr; DWORD flags = 0; - LPD3DXINCLUDE include = 0L; + LPD3DXINCLUDE include = nullptr; HRESULT hr = D3DXAssembleShaderFromFile( - inFile, - 0L, + inFile.AsString().c_str(), + nullptr, include, flags, &compiledShader, &compilationErrors); - if( FAILED(hr) ) + if (FAILED(hr)) { - printf("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"); - printf(compilationErrors ? (char*)compilationErrors->GetBufferPointer() : "File not found"); + fputs("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stdout); + fputs(compilationErrors ? (const char*)compilationErrors->GetBufferPointer() + : "File not found", stdout); continue; } - sprintf(inFile, "sha/%s.inl", varName); - ICreateHeader(varName, inFile, fp, compiledShader); + ICreateHeader(varName, plFormat("sha/{}.inl", varName), fp, compiledShader); fclose(fp);