mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 10:37:41 -04:00
Deprecate and remove xtl::format in favor of plString::Format
This commit is contained in:
@ -48,6 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "hsStlUtils.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "plString.h"
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -214,6 +215,7 @@ void hsStatusMessageF(const char * fmt, ...)
|
||||
|
||||
#endif
|
||||
|
||||
// TODO: Deprecate these in favor of plString
|
||||
char * hsFormatStr(const char * fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
@ -225,8 +227,7 @@ char * hsFormatStr(const char * fmt, ...)
|
||||
|
||||
char * hsFormatStrV(const char * fmt, va_list args)
|
||||
{
|
||||
std::string buf;
|
||||
xtl::formatv(buf,fmt,args);
|
||||
plString buf = plString::IFormat(fmt, args);
|
||||
return hsStrcpy(buf.c_str());
|
||||
}
|
||||
|
||||
@ -460,6 +461,8 @@ char *hsWStringToString( const wchar_t *str )
|
||||
//
|
||||
char** DisplaySystemVersion()
|
||||
{
|
||||
// TODO: I so want to std::vector<plString> this, but that requires
|
||||
// including more headers in HeadSpin.h :(
|
||||
#if HS_BUILD_FOR_WIN32
|
||||
#ifndef VER_SUITE_PERSONAL
|
||||
#define VER_SUITE_PERSONAL 0x200
|
||||
@ -554,7 +557,7 @@ char** DisplaySystemVersion()
|
||||
|
||||
if ( osvi.dwMajorVersion <= 4 )
|
||||
{
|
||||
versionStrs.Append(hsStrcpy (xtl::format("version %d.%d %s (Build %d)\n",
|
||||
versionStrs.Append(hsStrcpy (plString::Format("version %d.%d %s (Build %d)\n",
|
||||
osvi.dwMajorVersion,
|
||||
osvi.dwMinorVersion,
|
||||
osvi.szCSDVersion,
|
||||
@ -562,7 +565,7 @@ char** DisplaySystemVersion()
|
||||
}
|
||||
else
|
||||
{
|
||||
versionStrs.Append(hsStrcpy (xtl::format("%s (Build %d)\n",
|
||||
versionStrs.Append(hsStrcpy (plString::Format("%s (Build %d)\n",
|
||||
osvi.szCSDVersion,
|
||||
osvi.dwBuildNumber & 0xFFFF).c_str()));
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ std::wstring & trimleft(std::wstring & s, const wchar_t * charset)
|
||||
|
||||
std::string & trimright(std::string & s, const char * charset)
|
||||
{
|
||||
int idx = s.find_last_not_of(charset);
|
||||
size_t idx = s.find_last_not_of(charset);
|
||||
|
||||
if (std::string::npos == idx)
|
||||
{
|
||||
@ -77,7 +77,7 @@ std::string & trimright(std::string & s, const char * charset)
|
||||
|
||||
std::wstring & trimright(std::wstring & s, const wchar_t * charset)
|
||||
{
|
||||
int idx = s.find_last_not_of(charset);
|
||||
size_t idx = s.find_last_not_of(charset);
|
||||
|
||||
if (std::wstring::npos == idx)
|
||||
{
|
||||
@ -107,197 +107,6 @@ std::wstring & trim(std::wstring & s, const wchar_t * charset)
|
||||
return s;
|
||||
}
|
||||
|
||||
// c-string
|
||||
std::string trim(const char * s, const char * charset)
|
||||
{
|
||||
std::string result = s;
|
||||
trimleft(result,charset);
|
||||
trimright(result,charset);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring trim(const wchar_t * s, const wchar_t * charset)
|
||||
{
|
||||
std::wstring result = s;
|
||||
trimleft(result,charset);
|
||||
trimright(result,charset);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// format
|
||||
std::string format(const char * fmt, ...)
|
||||
{
|
||||
std::string result;
|
||||
va_list args;
|
||||
va_start(args,fmt);
|
||||
formatv(result,fmt,args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring format(const wchar_t * fmt, ...)
|
||||
{
|
||||
std::wstring result;
|
||||
va_list args;
|
||||
va_start(args,fmt);
|
||||
formatv(result,fmt,args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string formatv(const char * fmt, va_list args)
|
||||
{
|
||||
std::string result;
|
||||
formatv( result, fmt, args );
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring formatv(const wchar_t * fmt, va_list args)
|
||||
{
|
||||
std::wstring result;
|
||||
formatv( result, fmt, args );
|
||||
return result;
|
||||
}
|
||||
|
||||
bool format(std::string & out, const char * fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args,fmt);
|
||||
bool r = formatv(out,fmt,args);
|
||||
va_end(args);
|
||||
return r;
|
||||
}
|
||||
|
||||
bool format(std::wstring & out, const wchar_t * fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args,fmt);
|
||||
bool r = formatv(out,fmt,args);
|
||||
va_end(args);
|
||||
return r;
|
||||
}
|
||||
|
||||
bool formatv(std::string & out, const char * fmt, va_list args)
|
||||
{
|
||||
#define kBufSz 2048
|
||||
|
||||
char buf[kBufSz];
|
||||
char * pbuf = buf;
|
||||
int len = 0;
|
||||
int attempts = 0;
|
||||
bool success = false;
|
||||
const int kMaxAttempts = 40;
|
||||
|
||||
do
|
||||
{
|
||||
int maxlen = kBufSz*attempts+kBufSz-1;
|
||||
len = hsVsnprintf(pbuf,maxlen,fmt,args);
|
||||
attempts++;
|
||||
success = (len>=0 && len<maxlen);
|
||||
if (!success)
|
||||
{
|
||||
if (pbuf!=buf)
|
||||
delete [] pbuf;
|
||||
pbuf = new char[kBufSz+kBufSz*attempts];
|
||||
}
|
||||
}
|
||||
while (!success && attempts<kMaxAttempts);
|
||||
|
||||
if (success)
|
||||
{
|
||||
pbuf[len] = '\0';
|
||||
out = pbuf;
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
pbuf[len] = '\0';
|
||||
out = pbuf;
|
||||
}
|
||||
else
|
||||
{
|
||||
out = "";
|
||||
if ( attempts==kMaxAttempts )
|
||||
{
|
||||
hsDebugMessage( "xtl::formatv - Max reallocs occurred while formatting string. Result is likely truncated!", 0 );
|
||||
}
|
||||
}
|
||||
|
||||
if (pbuf!=buf)
|
||||
delete [] pbuf;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool formatv(std::wstring & out, const wchar_t * fmt, va_list args)
|
||||
{
|
||||
#define kBufSz 2048
|
||||
|
||||
wchar_t buf[kBufSz];
|
||||
wchar_t * pbuf = buf;
|
||||
int len = 0;
|
||||
int attempts = 0;
|
||||
bool success = false;
|
||||
const int kMaxAttempts = 40;
|
||||
|
||||
do
|
||||
{
|
||||
int maxlen = kBufSz*attempts+kBufSz-1;
|
||||
len = hsVsnwprintf(pbuf,maxlen,fmt,args);
|
||||
attempts++;
|
||||
success = (len>=0 && len<maxlen);
|
||||
if (!success)
|
||||
{
|
||||
if (pbuf!=buf)
|
||||
delete [] pbuf;
|
||||
pbuf = new wchar_t[kBufSz+kBufSz*attempts];
|
||||
}
|
||||
}
|
||||
while (!success && attempts<kMaxAttempts);
|
||||
|
||||
if (success)
|
||||
{
|
||||
pbuf[len] = L'\0';
|
||||
out = pbuf;
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
pbuf[len] = L'\0';
|
||||
out = pbuf;
|
||||
}
|
||||
else
|
||||
{
|
||||
out = L"";
|
||||
if ( attempts==kMaxAttempts )
|
||||
{
|
||||
hsDebugMessage( "xtl::formatv - Max reallocs occurred while formatting wstring. Result is likely truncated!", 0 );
|
||||
}
|
||||
}
|
||||
|
||||
if (pbuf!=buf)
|
||||
delete [] pbuf;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/*
|
||||
typedef std::vector<std::string> StringVector;
|
||||
typedef std::vector<std::wstring> WStringVector;
|
||||
typedef std::list<std::string> StringList;
|
||||
typedef std::list<std::wstring> WStringList;
|
||||
typedef std::set<std::string> StringSet;
|
||||
typedef std::set<std::wstring> WStringSet;
|
||||
|
||||
template bool GetStringGroup<StringList>(const std::string& s, StringList& group, char sep);
|
||||
template bool GetStringGroup<WStringList>(const std::wstring& s, WStringList& group, wchar_t sep);
|
||||
template bool GetStringGroup<StringVector>(const std::string& s, StringVector& group, char sep);
|
||||
template bool GetStringGroup<WStringVector>(const std::wstring& s, WStringVector& group, wchar_t sep);
|
||||
template bool GetStringGroup<StringSet>(const std::string& s, StringSet& group, char sep);
|
||||
template bool GetStringGroup<WStringSet>(const std::wstring& s, WStringSet& group, wchar_t sep);
|
||||
*/
|
||||
|
||||
template <typename T> bool GetStringGroup(const std::string& s, T& group, char sep)
|
||||
{
|
||||
bool ret = false;
|
||||
@ -339,15 +148,6 @@ template <typename T> bool GetStringGroup(const std::wstring& s, T& group, wchar
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
template bool GetStringGroupAsString<StringList>(const StringList& group, std::string& s, char sep);
|
||||
template bool GetStringGroupAsString<WStringList>(const WStringList& group, std::wstring& s, wchar_t sep);
|
||||
template bool GetStringGroupAsString<StringVector>(const StringVector& group, std::string& s, char sep);
|
||||
template bool GetStringGroupAsString<WStringVector>(const WStringVector& group, std::wstring& s, wchar_t sep);
|
||||
template bool GetStringGroupAsString<StringSet>(const StringSet& group, std::string& s, char sep);
|
||||
template bool GetStringGroupAsString<WStringSet>(const WStringSet& group, std::wstring& s, wchar_t sep);
|
||||
*/
|
||||
|
||||
template <typename T> bool GetStringGroupAsString(const T& group, std::string& s, char sep)
|
||||
{
|
||||
typename T::const_iterator it = group.begin();
|
||||
|
@ -62,18 +62,6 @@ std::string & trimright(std::string & s, const char * charset=" \t\n\r");
|
||||
std::wstring & trimright(std::wstring & s, const wchar_t * charset=L" \t\n\r");
|
||||
std::string & trim(std::string & s, const char * charset=" \t\n\r");
|
||||
std::wstring & trim(std::wstring & s, const wchar_t * charset=L" \t\n\r");
|
||||
// c-string trim
|
||||
std::string trim(const char * s, const char * charset=" \t\n\r");
|
||||
std::wstring trim(const wchar_t * s, const wchar_t * charset=L" \t\n\r");
|
||||
// format
|
||||
std::string format(const char * fmt, ...);
|
||||
std::wstring format(const wchar_t * fmt, ...);
|
||||
std::string formatv(const char * fmt, va_list args);
|
||||
std::wstring formatv(const wchar_t * fmt, va_list args);
|
||||
bool format(std::string & out, const char * fmt, ...);
|
||||
bool format(std::wstring & out, const wchar_t * fmt, ...);
|
||||
bool formatv(std::string & out, const char * fmt, va_list args);
|
||||
bool formatv(std::wstring & out, const wchar_t * fmt, va_list args);
|
||||
|
||||
|
||||
template <typename T> bool GetStringGroup(const std::string& s, T& group, char sep = ',');
|
||||
|
@ -123,9 +123,8 @@ uint32_t hsStream::WriteFmt(const char * fmt, ...)
|
||||
|
||||
uint32_t hsStream::WriteFmtV(const char * fmt, va_list av)
|
||||
{
|
||||
std::string buf;
|
||||
xtl::formatv( buf, fmt, av );
|
||||
return Write( buf.length(), buf.data() );
|
||||
plString buf = plString::IFormat(fmt, av);
|
||||
return Write( buf.GetSize(), buf.c_str() );
|
||||
}
|
||||
|
||||
uint32_t hsStream::WriteSafeStringLong(const plString &string)
|
||||
|
@ -83,6 +83,9 @@ public:
|
||||
hsStream() : fBytesRead(0), fPosition(0) {}
|
||||
virtual ~hsStream() { }
|
||||
|
||||
// Pre-filename-stringification shortcut:
|
||||
bool Open_TEMP(const plString & filename, const char * mode = "rb") { return Open(filename.c_str(), mode); }
|
||||
|
||||
virtual bool Open(const char *, const char * = "rb")=0;
|
||||
virtual bool Open(const wchar_t *, const wchar_t * = L"rb")=0;
|
||||
virtual bool Close()=0;
|
||||
|
@ -750,6 +750,15 @@ std::vector<plString> plString::Split(const char *split, size_t maxSplits) const
|
||||
return result;
|
||||
}
|
||||
|
||||
plString plString::Fill(size_t count, char c)
|
||||
{
|
||||
plStringBuffer<char> buf;
|
||||
char *data = buf.CreateWritableBuffer(count + 1);
|
||||
memset(data, c, count);
|
||||
data[count] = 0;
|
||||
return buf;
|
||||
}
|
||||
|
||||
plString operator+(const plString &left, const plString &right)
|
||||
{
|
||||
plString cat;
|
||||
|
@ -299,6 +299,8 @@ public:
|
||||
std::vector<plString> Split(const char *split, size_t maxSplits = kSizeAuto) const;
|
||||
std::vector<plString> Tokenize(const char *delims = " \t\r\n\f\v") const;
|
||||
|
||||
static plString Fill(size_t count, char c);
|
||||
|
||||
public:
|
||||
struct less
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "pnKeyedObject/plKey.h"
|
||||
#include "plString.h"
|
||||
|
||||
static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info);
|
||||
static bool DumpSpecificMsgInfo(plMessage* msg, plString& info);
|
||||
|
||||
plDispatchLog::plDispatchLog() :
|
||||
fLog(nil),
|
||||
@ -101,7 +101,7 @@ void plDispatchLog::LogStatusBarChange(const char* name, const char* action)
|
||||
|
||||
void plDispatchLog::LogLongReceive(const char* keyname, const char* className, uint32_t clonePlayerID, plMessage* msg, float ms)
|
||||
{
|
||||
std::string info;
|
||||
plString info;
|
||||
if (DumpSpecificMsgInfo(msg, info))
|
||||
fLog->AddLineF("%-30s[%7u](%-20s) took %6.1f ms to receive %s[%s]\n", keyname, clonePlayerID, className, ms, msg->ClassName(), info.c_str());
|
||||
else
|
||||
@ -195,7 +195,7 @@ void plDispatchLog::RemoveFilterExactType(uint16_t type)
|
||||
#include "plResMgr/plKeyFinder.h"
|
||||
#include "plResMgr/plPageInfo.h"
|
||||
|
||||
static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info)
|
||||
static bool DumpSpecificMsgInfo(plMessage* msg, plString& info)
|
||||
{
|
||||
#ifndef PLASMA_EXTERNAL_RELEASE // Don't bloat up the external release with all these strings
|
||||
pfKIMsg* kiMsg = pfKIMsg::ConvertNoRef(msg);
|
||||
@ -257,7 +257,7 @@ static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info)
|
||||
PrintKIType(kGZFlashUpdate); // flash an update without saving (for animation of GZFill in)
|
||||
PrintKIType(kNoCommand);
|
||||
|
||||
info = xtl::format("Type: %s Str: %s User: %s(%d) Delay: %f Int: %d",
|
||||
info = plString::Format("Type: %s Str: %s User: %s(%d) Delay: %f Int: %d",
|
||||
typeName,
|
||||
kiMsg->GetString() != "" ? kiMsg->GetString().c_str() : "(nil)",
|
||||
kiMsg->GetUser() ? kiMsg->GetUser() : "(nil)",
|
||||
@ -298,14 +298,14 @@ static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info)
|
||||
const plPageInfo* pageInfo = plKeyFinder::Instance().GetLocationInfo(loc);
|
||||
|
||||
if (pageInfo)
|
||||
info += xtl::format("%s-%s ", pageInfo->GetAge(), pageInfo->GetPage());
|
||||
info += plString::Format("%s-%s ", pageInfo->GetAge(), pageInfo->GetPage());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case plClientMsg::kLoadAgeKeys:
|
||||
case plClientMsg::kReleaseAgeKeys:
|
||||
info += xtl::format(" - Age: %s", clientMsg->GetAgeName());
|
||||
info += plString::Format(" - Age: %s", clientMsg->GetAgeName());
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
@ -321,7 +321,7 @@ static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info)
|
||||
GetType(kOnRequest);
|
||||
GetType(kOnRemove);
|
||||
GetType(kOnReplace);
|
||||
xtl::format(info, "Obj: %s RefType: %s", refMsg->GetRef()->GetKeyName().c_str(), typeName);
|
||||
info = plString::Format("Obj: %s RefType: %s", refMsg->GetRef()->GetKeyName().c_str(), typeName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ PyObject* plPythonPack::OpenPacked(const char* fileName)
|
||||
{
|
||||
char *buf = new char[size];
|
||||
uint32_t readSize = fPackStream->Read(size, buf);
|
||||
hsAssert(readSize <= size, xtl::format("Python PackFile %s: Incorrect amount of data, read %d instead of %d",
|
||||
hsAssert(readSize <= size, plString::Format("Python PackFile %s: Incorrect amount of data, read %d instead of %d",
|
||||
fileName, readSize, size).c_str());
|
||||
|
||||
// let the python marshal make it back into a code object
|
||||
|
@ -331,7 +331,7 @@ void plDispatch::IMsgDispatch()
|
||||
if (plNetObjectDebuggerBase::GetInstance()->IsDebugObject(ko))
|
||||
{
|
||||
hsLogEntry(plNetObjectDebuggerBase::GetInstance()->LogMsg(
|
||||
xtl::format("<RCV> object:%s, GameMessage %s st=%.3f rt=%.3f",
|
||||
plString::Format("<RCV> object:%s, GameMessage %s st=%.3f rt=%.3f",
|
||||
ko->GetKeyName().c_str(), msg->ClassName(), hsTimer::GetSysSeconds(), hsTimer::GetSeconds()).c_str()));
|
||||
}
|
||||
}
|
||||
|
@ -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(xtl::format("Value: %s", stringref.data()).c_str());
|
||||
stream->LogStringString(plString::Format("Value: %s", stringref.data()).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(xtl::format("Value: %s", stringref.data()).c_str());
|
||||
stream->LogStringString(plString::Format("Value: %s", stringref.data()).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(xtl::format("Value: %s",str).c_str());
|
||||
stream->LogStringString(plString::Format("Value: %s",str).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -157,8 +157,8 @@ public:
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Helpers for reading/writing these types:
|
||||
// plString
|
||||
// std::string
|
||||
// xtl::istring
|
||||
// c strings (char *)
|
||||
// c arrays (type [])
|
||||
|
||||
|
@ -317,45 +317,28 @@ void plGenericType::SetVar(Types t, unsigned int size, void* val)
|
||||
}
|
||||
|
||||
|
||||
std::string plGenericType::GetAsStdString() const
|
||||
plString plGenericType::GetAsString() const
|
||||
{
|
||||
std::string s;
|
||||
|
||||
switch (fType)
|
||||
{
|
||||
case kInt :
|
||||
{
|
||||
xtl::format(s,"%d",fI);
|
||||
break;
|
||||
}
|
||||
return plString::Format("%d", fI);
|
||||
case kBool :
|
||||
case kUInt :
|
||||
{
|
||||
xtl::format(s,"%u",fType==kBool?fB:fU);
|
||||
break;
|
||||
}
|
||||
return plString::Format("%u", fType==kBool?fB:fU);
|
||||
case kFloat :
|
||||
case kDouble :
|
||||
{
|
||||
xtl::format(s,"%f",fType==kDouble?fD:fF);
|
||||
break;
|
||||
}
|
||||
return plString::Format("%f", fType==kDouble?fD:fF);
|
||||
case kChar :
|
||||
{
|
||||
xtl::format(s,"%c",fC);
|
||||
break;
|
||||
}
|
||||
return plString::Format("%c", fC);
|
||||
case kAny :
|
||||
case kString :
|
||||
{
|
||||
s = fS;
|
||||
break;
|
||||
}
|
||||
return fS;
|
||||
case kNone :
|
||||
break;
|
||||
default:
|
||||
hsAssert(false,"plGenericType::GetAsStdString unknown type");
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
return plString::Null;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public:
|
||||
void SetType(Types t) { fType=t; }
|
||||
uint8_t GetType( void ) const { return fType; }
|
||||
|
||||
std::string GetAsStdString() const;
|
||||
plString GetAsString() const;
|
||||
|
||||
// implicit set
|
||||
void Set( int32_t i ) { fI = i; fType = kInt; }
|
||||
|
@ -192,7 +192,7 @@ public:
|
||||
virtual int IsLocallyOwned(const plUoid&) const { hsAssert(false, "stub"); return 0; }
|
||||
virtual plNetGroupId GetEffectiveNetGroup(const plSynchedObject* obj) const { hsAssert(false, "stub"); return plNetGroup::kNetGroupUnknown; }
|
||||
virtual int Update(double secs) { return hsOK;}
|
||||
virtual const char* GetServerLogTimeAsString(std::string& ts) const { hsAssert(false, "stub"); return nil; }
|
||||
virtual const char* GetServerLogTimeAsString(plString& ts) const { hsAssert(false, "stub"); return nil; }
|
||||
virtual plUoid GetAgeSDLObjectUoid(const char* ageName) const { hsAssert(false, "stub"); return plUoid(); }
|
||||
virtual void StayAlive(double secs) {}
|
||||
virtual void QueueDisableNet( bool showDlg, const char msg[] ) {}
|
||||
|
@ -69,19 +69,19 @@ public:
|
||||
fIsZipped = wcscmp(plFileUtils::GetFileExt(reqFile), L"gz") == 0;
|
||||
}
|
||||
|
||||
~plResDownloadStream()
|
||||
virtual ~plResDownloadStream()
|
||||
{
|
||||
if (fFilename)
|
||||
delete[] fFilename;
|
||||
}
|
||||
|
||||
bool Open(const char* filename, const char* mode)
|
||||
virtual bool Open(const char* filename, const char* mode)
|
||||
{
|
||||
fFilename = hsStrcpy(filename);
|
||||
return plZlibStream::Open(filename, mode);
|
||||
}
|
||||
|
||||
uint32_t Write(uint32_t count, const void* buf)
|
||||
virtual uint32_t Write(uint32_t count, const void* buf)
|
||||
{
|
||||
fProgress->Increment((float)count);
|
||||
if (fIsZipped)
|
||||
@ -231,37 +231,34 @@ void plResPatcher::IssueRequest()
|
||||
Request req = fRequests.front();
|
||||
fRequests.pop();
|
||||
|
||||
std::wstring title;
|
||||
plString title;
|
||||
if (req.fType == kManifest)
|
||||
{
|
||||
char* eapSucksString = hsWStringToString(req.fFile.c_str());
|
||||
PatcherLog(kMajorStatus, " Downloading manifest... %s", eapSucksString);
|
||||
xtl::format(title, L"Checking %s for updates...", req.fFile.c_str());
|
||||
PatcherLog(kMajorStatus, " Downloading manifest... %S", req.fFile.c_str());
|
||||
title = plString::Format("Checking %S for updates...", req.fFile.c_str());
|
||||
NetCliFileManifestRequest(ManifestDownloaded, this, req.fFile.c_str());
|
||||
delete[] eapSucksString;
|
||||
} else if (req.fType == kFile) {
|
||||
char* eapSucksString = hsWStringToString(req.fFriendlyName.c_str());
|
||||
PatcherLog(kMajorStatus, " Downloading file... %s", eapSucksString);
|
||||
xtl::format(title, L"Downloading... %s", plFileUtils::GetFileName(req.fFriendlyName.c_str()));
|
||||
PatcherLog(kMajorStatus, " Downloading file... %S", req.fFriendlyName.c_str());
|
||||
title = plString::Format("Downloading... %S", plFileUtils::GetFileName(req.fFriendlyName.c_str()));
|
||||
|
||||
// If this is a PRP, we need to unload it from the ResManager
|
||||
if (stricmp(plFileUtils::GetFileExt(eapSucksString), "prp") == 0)
|
||||
((plResManager*)hsgResMgr::ResMgr())->RemoveSinglePage(eapSucksString);
|
||||
|
||||
plString filename = plString::FromWchar(req.fFriendlyName.c_str());
|
||||
if (stricmp(plFileUtils::GetFileExt(filename.c_str()), "prp") == 0)
|
||||
((plResManager*)hsgResMgr::ResMgr())->RemoveSinglePage(filename.c_str());
|
||||
|
||||
plFileUtils::EnsureFilePathExists(req.fFriendlyName.c_str());
|
||||
plResDownloadStream* stream = new plResDownloadStream(fProgress, req.fFile.c_str());
|
||||
if(stream->Open(eapSucksString, "wb"))
|
||||
uint32_t i = stream->ReadBE32();
|
||||
if (stream->Open_TEMP(filename, "wb"))
|
||||
NetCliFileDownloadRequest(req.fFile.c_str(), stream, FileDownloaded, this);
|
||||
else {
|
||||
PatcherLog(kError, " Unable to create file %s", eapSucksString);
|
||||
PatcherLog(kError, " Unable to create file %s", filename.c_str());
|
||||
Finish(false);
|
||||
}
|
||||
delete[] eapSucksString;
|
||||
}
|
||||
|
||||
char* hack = hsWStringToString(title.c_str());
|
||||
fProgress->SetTitle(hack);
|
||||
delete[] hack;
|
||||
fProgress->SetTitle(title.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -835,17 +835,16 @@ void plSceneInputInterface::ILinkOffereeToAge()
|
||||
// We must have an owned copy of the age before we can offer it, so make one now
|
||||
plUUID guid(GuidGenerate());
|
||||
info.SetAgeInstanceGuid(&guid);
|
||||
std::string title;
|
||||
std::string desc;
|
||||
plString title, desc;
|
||||
|
||||
unsigned nameLen = plNetClientMgr::GetInstance()->GetPlayerName().GetSize();
|
||||
if (plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 's' || plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 'S') {
|
||||
xtl::format( title, "%s'", plNetClientMgr::GetInstance()->GetPlayerName().c_str() );
|
||||
xtl::format( desc, "%s' %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() );
|
||||
title = plString::Format( "%s'", plNetClientMgr::GetInstance()->GetPlayerName().c_str() );
|
||||
desc = plString::Format( "%s' %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() );
|
||||
}
|
||||
else {
|
||||
xtl::format( title, "%s's", plNetClientMgr::GetInstance()->GetPlayerName().c_str() );
|
||||
xtl::format( desc, "%s's %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() );
|
||||
title = plString::Format( "%s's", plNetClientMgr::GetInstance()->GetPlayerName().c_str() );
|
||||
desc = plString::Format( "%s's %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() );
|
||||
}
|
||||
|
||||
info.SetAgeUserDefinedName( title.c_str() );
|
||||
|
@ -252,10 +252,10 @@ void plNetClientMgr::SetNullSend(bool on)
|
||||
//
|
||||
// returns server time in the form "[m/d/y h:m:s]"
|
||||
//
|
||||
const char* plNetClientMgr::GetServerLogTimeAsString(std::string& timestamp) const
|
||||
const char* plNetClientMgr::GetServerLogTimeAsString(plString& timestamp) const
|
||||
{
|
||||
const plUnifiedTime st=GetServerTime();
|
||||
xtl::format(timestamp, "{%02d/%02d %02d:%02d:%02d}",
|
||||
timestamp = plString::Format("{%02d/%02d %02d:%02d:%02d}",
|
||||
st.GetMonth(), st.GetDay(), st.GetHour(), st.GetMinute(), st.GetSecond());
|
||||
return timestamp.c_str();
|
||||
}
|
||||
@ -265,10 +265,10 @@ const char* plNetClientMgr::GetServerLogTimeAsString(std::string& timestamp) con
|
||||
//
|
||||
const char* ProcessTab(const char* fmt)
|
||||
{
|
||||
static std::string s;
|
||||
static plString s;
|
||||
if (fmt && *fmt=='\t')
|
||||
{
|
||||
s = xtl::format(" %s", fmt);
|
||||
s = plString::Format(" %s", fmt);
|
||||
return s.c_str();
|
||||
}
|
||||
return fmt;
|
||||
@ -283,7 +283,7 @@ bool plNetClientMgr::Log(const char* str) const
|
||||
return true;
|
||||
|
||||
// prepend raw time
|
||||
std::string buf2 = xtl::format("%.2f %s", hsTimer::GetSeconds(), ProcessTab(str));
|
||||
plString buf2 = plString::Format("%.2f %s", hsTimer::GetSeconds(), ProcessTab(str));
|
||||
|
||||
if ( GetConsoleOutput() )
|
||||
hsStatusMessage(buf2.c_str());
|
||||
|
@ -348,7 +348,7 @@ public:
|
||||
|
||||
// time converters
|
||||
plUnifiedTime GetServerTime() const;
|
||||
const char* GetServerLogTimeAsString(std::string& ts) const;
|
||||
const char* GetServerLogTimeAsString(plString& ts) const;
|
||||
double GetCurrentAgeElapsedSeconds() const;
|
||||
float GetCurrentAgeTimeOfDayPercent() const;
|
||||
|
||||
|
@ -437,7 +437,7 @@ int plNetClientMgr::SendMsg(plNetMessage* msg)
|
||||
if (plNetMsgGameMessage::ConvertNoRef(msg))
|
||||
SetFlagsBit(kSendingActions);
|
||||
|
||||
plCheckNetMgrResult_ValReturn(ret,(char*)xtl::format("Failed to send %s, NC ret=%d",
|
||||
plCheckNetMgrResult_ValReturn(ret, plString::Format("Failed to send %s, NC ret=%d",
|
||||
msg->ClassName(), ret).c_str());
|
||||
|
||||
return ret;
|
||||
|
@ -250,15 +250,15 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgSDLState)
|
||||
plStateDataRecord* sdRec = des ? new plStateDataRecord(des) : nil;
|
||||
if (!sdRec || sdRec->GetDescriptor()->GetVersion()!=ver)
|
||||
{
|
||||
std::string err;
|
||||
plString err;
|
||||
if (!sdRec)
|
||||
err = xtl::format( "SDL descriptor %s missing, v=%d", descName.c_str(), ver);
|
||||
err = plString::Format( "SDL descriptor %s missing, v=%d", descName.c_str(), ver);
|
||||
else
|
||||
err = xtl::format( "SDL descriptor %s, version mismatch, server v=%d, client v=%d",
|
||||
err = plString::Format( "SDL descriptor %s, version mismatch, server v=%d, client v=%d",
|
||||
descName.c_str(), ver, sdRec->GetDescriptor()->GetVersion());
|
||||
|
||||
hsAssert(false, err.c_str());
|
||||
nc->ErrorMsg(const_cast<char*>(err.c_str()));
|
||||
nc->ErrorMsg(err.c_str());
|
||||
|
||||
// Post Quit message
|
||||
nc->QueueDisableNet(true, "SDL Desc Problem");
|
||||
|
@ -358,9 +358,9 @@ const char * plAgeInfoStruct::GetDisplayName() const
|
||||
{
|
||||
int seq = GetAgeSequenceNumber();
|
||||
if ( seq>0 )
|
||||
xtl::format( fDisplayName, "%s(%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
|
||||
fDisplayName = plString::Format( "%s(%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
|
||||
else
|
||||
xtl::format( fDisplayName, "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
|
||||
fDisplayName = plString::Format( "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
|
||||
return fDisplayName.c_str();
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,8 @@ class plAgeInfoStruct : public plCreatable
|
||||
// The language of the client that created this age
|
||||
int32_t fAgeLanguage;
|
||||
|
||||
mutable std::string fDisplayName;
|
||||
// Evil (TODO: Nuke this)
|
||||
mutable plString fDisplayName;
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -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(xtl::format("ClassName: %s",this->ClassName()).c_str());
|
||||
readStream.LogStringString(plString::Format("ClassName: %s", this->ClassName()).c_str());
|
||||
int ret;
|
||||
if (peekOptions & kBaseClassOnly)
|
||||
{
|
||||
|
@ -646,13 +646,11 @@ public:
|
||||
bool GetRequestingState() const { return (fPageFlags & kRequestState) != 0; }
|
||||
|
||||
// debug
|
||||
std::string AsStdString() const
|
||||
plString AsString() const
|
||||
{
|
||||
std::string s;
|
||||
xtl::format(s,"pageFlags:%02X, paging %s, requestingState:%s, resetting=%d",fPageFlags,
|
||||
(fPageFlags&kPagingOut)?"out":"in", (fPageFlags&kRequestState)?"yes":"no",
|
||||
(fPageFlags & kResetList)!=0);
|
||||
return s;
|
||||
return plString::Format("pageFlags:%02X, paging %s, requestingState:%s, resetting=%d",
|
||||
fPageFlags, (fPageFlags&kPagingOut)?"out":"in",
|
||||
(fPageFlags&kRequestState)?"yes":"no", (fPageFlags & kResetList)!=0);
|
||||
}
|
||||
};
|
||||
|
||||
@ -755,11 +753,9 @@ public:
|
||||
void WriteVersion(hsStream* s, hsResMgr* mgr);
|
||||
|
||||
// debug
|
||||
std::string AsStdString() const
|
||||
plString AsString() const
|
||||
{
|
||||
std::string s;
|
||||
xtl::format(s,"len=%d",fVoiceData.size());
|
||||
return s;
|
||||
return plString::Format("len=%d",fVoiceData.size());
|
||||
}
|
||||
};
|
||||
|
||||
@ -795,7 +791,7 @@ public:
|
||||
void WriteVersion(hsStream* s, hsResMgr* mgr);
|
||||
|
||||
// debug
|
||||
plString AsStdString() const
|
||||
plString AsString() const
|
||||
{
|
||||
return plString::Format("lockReq=%d, %s",fLockRequest, plNetMsgStreamedObject::AsString().c_str());
|
||||
}
|
||||
@ -979,7 +975,7 @@ public:
|
||||
const hsBitVector& GetRegionsICareAbout() const { return fRegionsICareAbout; }
|
||||
const hsBitVector& GetRegionsImIn() const { return fRegionsImIn; }
|
||||
|
||||
plString AsStdString() const
|
||||
plString AsString() const
|
||||
{
|
||||
plString b1, b2;
|
||||
int i;
|
||||
|
@ -168,7 +168,7 @@ void plRegistryPageNode::LoadKeys()
|
||||
hsStream* stream = OpenStream();
|
||||
if (!stream)
|
||||
{
|
||||
hsAssert(0, xtl::format("plRegistryPageNode::LoadKeysFromSource - bad stream %s,%s",
|
||||
hsAssert(0, plString::Format("plRegistryPageNode::LoadKeysFromSource - bad stream %s,%s",
|
||||
GetPageInfo().GetAge(), GetPageInfo().GetPage()).c_str());
|
||||
return;
|
||||
}
|
||||
|
@ -1192,7 +1192,7 @@ void plResManager::PageInRoom(const plLocation& page, uint16_t objClassToRef, pl
|
||||
|
||||
kResMgrLog(1, ILog(1, "...IGNORING pageIn request; verification failed! (%s)", condStr.c_str()));
|
||||
|
||||
std::string msg = xtl::format("Data Problem: Age:%s Page:%s Error:%s",
|
||||
plString msg = plString::Format("Data Problem: Age:%s Page:%s Error:%s",
|
||||
pageNode->GetPageInfo().GetAge(), pageNode->GetPageInfo().GetPage(), condStr.c_str());
|
||||
hsMessageBox(msg.c_str(), "Error", hsMessageBoxNormal, hsMessageBoxIconError);
|
||||
|
||||
|
@ -70,7 +70,7 @@ void plSDLParser::DebugMsgV(const char* fmt, va_list args) const
|
||||
{
|
||||
if (strlen(fmt)==nil)
|
||||
return;
|
||||
hsStatusMessage(xtl::formatv(fmt,args).c_str());
|
||||
hsStatusMessage(plString::IFormat(fmt,args).c_str());
|
||||
}
|
||||
|
||||
//
|
||||
@ -109,7 +109,7 @@ bool plSDLParser::IParseStateDesc(const char* fileName, hsStream* stream, char t
|
||||
if (!strcmp(token, "VERSION"))
|
||||
{
|
||||
// read desc version
|
||||
hsAssert(curDesc, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
|
||||
hsAssert(curDesc, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
|
||||
if (stream->GetToken(token, kTokenLen))
|
||||
{
|
||||
int v=atoi(token);
|
||||
@ -119,14 +119,14 @@ bool plSDLParser::IParseStateDesc(const char* fileName, hsStream* stream, char t
|
||||
}
|
||||
else
|
||||
{
|
||||
hsAssert(false, xtl::format("Error parsing state desc, missing VERSION, fileName=%s",
|
||||
hsAssert(false, plString::Format("Error parsing state desc, missing VERSION, fileName=%s",
|
||||
fileName).c_str());
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hsAssert(false, xtl::format("Error parsing state desc, fileName=%s", fileName).c_str());
|
||||
hsAssert(false, plString::Format("Error parsing state desc, fileName=%s", fileName).c_str());
|
||||
ok = false;
|
||||
}
|
||||
|
||||
@ -135,7 +135,8 @@ bool plSDLParser::IParseStateDesc(const char* fileName, hsStream* stream, char t
|
||||
ok = ( plSDLMgr::GetInstance()->FindDescriptor(curDesc->GetName(), curDesc->GetVersion())==nil );
|
||||
if ( !ok )
|
||||
{
|
||||
std::string err = xtl::format( "Found duplicate SDL descriptor for %s version %d.\nFailed to parse file: %s", curDesc->GetName(), curDesc->GetVersion(), fileName );
|
||||
plString err = plString::Format( "Found duplicate SDL descriptor for %s version %d.\nFailed to parse file: %s",
|
||||
curDesc->GetName().c_str(), curDesc->GetVersion(), fileName );
|
||||
plNetApp::StaticErrorMsg( err.c_str() );
|
||||
hsAssert( false, err.c_str() );
|
||||
}
|
||||
|
@ -2683,8 +2683,8 @@ void plSDStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) const
|
||||
pad += " ";
|
||||
|
||||
int cnt = dirtyOnly ? GetDirtyCount() : GetUsedCount();
|
||||
dbg->LogMsg(xtl::format( "%sSDVar, name:%s dirtyOnly:%d count:%d",
|
||||
pad.c_str(), GetName(), dirtyOnly, cnt).c_str());
|
||||
dbg->LogMsg(plString::Format( "%sSDVar, name:%s dirtyOnly:%d count:%d",
|
||||
pad.c_str(), GetName().c_str(), dirtyOnly, cnt).c_str());
|
||||
|
||||
for(i=0;i<GetCount();i++)
|
||||
{
|
||||
@ -2704,8 +2704,8 @@ void plSDStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int level
|
||||
pad += " ";
|
||||
|
||||
int cnt = dirtyOnly ? GetDirtyCount() : GetUsedCount();
|
||||
stream->WriteString(xtl::format( "%sSDVar, name:%s dirtyOnly:%d count:%d",
|
||||
pad.c_str(), GetName(), dirtyOnly, cnt).c_str());
|
||||
stream->WriteString(plString::Format( "%sSDVar, name:%s dirtyOnly:%d count:%d",
|
||||
pad.c_str(), GetName().c_str(), dirtyOnly, cnt).c_str());
|
||||
|
||||
for(i=0;i<GetCount();i++)
|
||||
{
|
||||
|
@ -873,8 +873,7 @@ bool plStatusLog::IPrintLineToFile( const char *line, uint32_t count )
|
||||
{
|
||||
#if HS_BUILD_FOR_WIN32
|
||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
||||
std::string str;
|
||||
xtl::format( str, "%.*s\n", count, line );
|
||||
plString str = plString::Format( "%.*s\n", count, line );
|
||||
OutputDebugString( str.c_str() );
|
||||
#endif
|
||||
#else
|
||||
|
@ -310,8 +310,8 @@ const char* plUnifiedTime::Print() const
|
||||
// short year, month, day, hour, minute, second;
|
||||
// GetTime(year, month, day, hour, minute, second);
|
||||
//
|
||||
// xtl::format(s,"yr %d mo %d day %d hour %d min %d sec %d",
|
||||
// year, month, day, hour, minute, second);
|
||||
// s = plString::Format("yr %d mo %d day %d hour %d min %d sec %d",
|
||||
// year, month, day, hour, minute, second);
|
||||
|
||||
s = Format("%c");
|
||||
return s.c_str();
|
||||
@ -319,8 +319,8 @@ const char* plUnifiedTime::Print() const
|
||||
|
||||
const char* plUnifiedTime::PrintWMillis() const
|
||||
{
|
||||
static std::string s;
|
||||
xtl::format(s,"%s,s:%lu,ms:%d",
|
||||
static plString s;
|
||||
s = plString::Format("%s,s:%lu,ms:%d",
|
||||
Print(), (unsigned long)GetSecs(), GetMillis() );
|
||||
return s.c_str();
|
||||
}
|
||||
|
@ -91,11 +91,9 @@ void plDniCoordinateInfo::Write( hsStream* s, hsResMgr* mgr )
|
||||
s->WriteLE( fTorans );
|
||||
}
|
||||
|
||||
std::string plDniCoordinateInfo::AsStdString( int level ) const
|
||||
plString plDniCoordinateInfo::AsString( int level ) const
|
||||
{
|
||||
std::string result;
|
||||
std::string space( level, ' ' );
|
||||
xtl::format( result, "%sDniCoords[%d,%d,%d]", space.c_str(), fHSpans, fVSpans, fTorans );
|
||||
return result;
|
||||
plString space = plString::Fill( level, ' ' );
|
||||
return plString::Format( "%sDniCoords[%d,%d,%d]", space.c_str(), fHSpans, fVSpans, fTorans );
|
||||
}
|
||||
#endif // def CLIENT
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
void Write( hsStream* s, hsResMgr* mgr );
|
||||
|
||||
// debug
|
||||
std::string AsStdString( int level=0 ) const;
|
||||
plString AsString( int level=0 ) const;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user