1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 19:29:09 +00:00

Convert many of the now-deprecated plString::Format calls to plFormat

This commit is contained in:
2014-05-24 23:46:54 -07:00
parent 89a9bbb3c4
commit 1debf8180b
98 changed files with 404 additions and 413 deletions

View File

@ -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;
}

View File

@ -319,7 +319,7 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
// 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());
}
}
@ -744,9 +744,9 @@ void plStateDataRecord::DumpToObjectDebugger(const char* msg, bool dirtyOnly, in
int numVars = dirtyOnly ? GetNumDirtyVars() : GetNumUsedVars();
int numSDVars = dirtyOnly ? GetNumDirtySDVars() : GetNumUsedSDVars();
dbg->LogMsg(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());
@ -780,12 +780,12 @@ void plStateDataRecord::DumpToStream(hsStream* stream, const char* msg, bool dir
int numVars = dirtyOnly ? GetNumDirtyVars() : GetNumUsedVars();
int numSDVars = dirtyOnly ? GetNumDirtySDVars() : GetNumUsedSDVars();
plString logStr = plString::Format("%s", fAssocObject.IsValid() ? fAssocObject.GetObjectName().c_str() : " ");
plString logStr = fAssocObject.IsValid() ? fAssocObject.GetObjectName() : " ";
stream->Write(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());
}

View File

@ -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;j<fVar.GetAtomicCount();j++)
{
if (type==plVarDescriptor::kInt)
str += plString::Format( "%d", fI[i++]);
str << fI[i++];
else if (type==plVarDescriptor::kShort)
str += plString::Format( "%d", fS[i++]);
str << fS[i++];
else if (type==plVarDescriptor::kByte)
str += plString::Format( "%d", fBy[i++]);
str << fBy[i++];
else if (type==plVarDescriptor::kFloat || type==plVarDescriptor::kAgeTimeOfDay)
str += plString::Format( "%.3f", fF[i++]);
str << plString::Format( "%.3f", fF[i++]);
else if (type==plVarDescriptor::kDouble)
str += plString::Format( "%.3f", fD[i++]);
str << plString::Format( "%.3f", fD[i++]);
else if (type==plVarDescriptor::kTime)
{
double tmp;
Get(&tmp, i++);
str += plString::Format( "%.3f", tmp);
str << plString::Format( "%.3f", tmp);
}
if (j==fVar.GetAtomicCount()-1)
{
if (j)
str += ")";
str << ')';
}
else
str += ",";
str << ',';
}
}
break;
@ -463,15 +463,15 @@ plString plSimpleStateVariable::GetAsString(int idx) const
int i=idx*fVar.GetAtomicCount();
for(j=0;j<fVar.GetAtomicCount();j++)
{
str += plString::Format( "%s", fB[i++] ? "true" : "false");
str << (fB[i++] ? "true" : "false");
if (j==fVar.GetAtomicCount()-1)
{
if (j)
str += ")";
str << ')';
}
else
str += ",";
str << ',';
}
}
break;
@ -481,15 +481,15 @@ plString plSimpleStateVariable::GetAsString(int idx) const
int i=idx*fVar.GetAtomicCount();
for(j=0;j<fVar.GetAtomicCount();j++)
{
str += plString::Format( "%s", fS32[i++]);
str << fS32[i++];
if (j==fVar.GetAtomicCount()-1)
{
if (j)
str += ")";
str << ')';
}
else
str += ",";
str << ',';
}
}
break;
@ -499,21 +499,21 @@ plString plSimpleStateVariable::GetAsString(int idx) const
int i=idx*fVar.GetAtomicCount();
for(j=0;j<fVar.GetAtomicCount();j++)
{
str += "other";
str << "other";
if (j==fVar.GetAtomicCount()-1)
{
if (j)
str += ")";
str << ')';
}
else
str += ",";
str << ',';
}
}
break;
}
}
return str;
return str.GetString();
}
//
@ -2163,8 +2163,8 @@ void plSimpleStateVariable::NotifyStateChange(const plSimpleStateVariable* other
if (plNetObjectDebuggerBase::GetInstance() && plNetObjectDebuggerBase::GetInstance()->GetDebugging())
{
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());
}
}
@ -2284,7 +2284,7 @@ void plSimpleStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) cons
for(i=0;i<level; i++)
pad += " ";
plString logMsg = plString::Format( "%sSimpleVar, name:%s[%d]", pad.c_str(), GetName().c_str(), GetCount());
plString logMsg = plFormat("{}SimpleVar, name:{}[{}]", pad, GetName(), GetCount());
if (GetCount()>1)
{
dbg->LogMsg(logMsg.c_str()); // it's going to be a long msg, so print it on its own line
@ -2298,13 +2298,13 @@ void plSimpleStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) cons
if (fVar.GetAtomicType() == plVarDescriptor::kTime)
{
const char* p=fT[i].PrintWMillis();
logMsg += plString::Format( "%sVar:%d gameTime:%s pst:%s ts:%s",
pad.c_str(), i, s.c_str("?"), p, fTimeStamp.Format("%c").c_str() );
logMsg += plFormat("{}Var:{} gameTime:{} pst:{} ts:{}",
pad, i, s, p, fTimeStamp.Format("%c"));
}
else
{
logMsg += plString::Format( "%sVar:%d value:%s ts:%s",
pad.c_str(), i, s.c_str("?"), fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() );
logMsg += plFormat("{}Var:{} value:{} ts:{}",
pad, i, s, fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c"));
}
if ( !dirtyOnly )
@ -2322,7 +2322,7 @@ void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int l
for(i=0;i<level; i++)
pad += " ";
plString logMsg = plString::Format( "%sSimpleVar, name:%s[%d]", pad.c_str(), GetName().c_str(), GetCount());
plString logMsg = plFormat("{}SimpleVar, name:{}[{}]", pad, GetName(), GetCount());
if (GetCount()>1)
{
stream->WriteString(logMsg); // it's going to be a long msg, so print it on its own line
@ -2336,13 +2336,13 @@ void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int l
if (fVar.GetAtomicType() == plVarDescriptor::kTime)
{
const char* p=fT[i].PrintWMillis();
logMsg += plString::Format( "%sVar:%d gameTime:%s pst:%s ts:%s",
pad.c_str(), i, s.c_str("?"), p, fTimeStamp.Format("%c").c_str() );
logMsg += plFormat("{}Var:{} gameTime:{} pst:{} ts:{}",
pad, i, s, p, fTimeStamp.Format("%c"));
}
else
{
logMsg += plString::Format( "%sVar:%d value:%s ts:%s",
pad.c_str(), i, s.c_str("?"), fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() );
logMsg += plFormat("{}Var:{} value:{} ts:{}",
pad, i, s, fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c"));
}
if ( !dirtyOnly )

View File

@ -375,7 +375,7 @@ bool plSDVarDescriptor::Read(hsStream* s)
plString sdName=s->ReadSafeString();
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;
}