Browse Source

Convert SDL (mostly) to plStrings

Michael Hansen 12 years ago
parent
commit
49dfb4e546
  1. 28
      Sources/Plasma/CoreLib/plString.cpp
  2. 22
      Sources/Plasma/CoreLib/plString.h
  3. 22
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  4. 4
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp
  5. 8
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp
  6. 57
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp
  7. 28
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.h
  8. 29
      Sources/Plasma/FeatureLib/pfPython/pySDL.cpp
  9. 13
      Sources/Plasma/FeatureLib/pfPython/pySDL.h
  10. 11
      Sources/Plasma/FeatureLib/pfPython/pySDLGlue.cpp
  11. 12
      Sources/Plasma/FeatureLib/pfPython/pySpawnPointInfo.h
  12. 12
      Sources/Plasma/FeatureLib/pfPython/pySpawnPointInfoGlue.cpp
  13. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.cpp
  14. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.h
  15. 6
      Sources/Plasma/NucleusLib/pnMessage/plSDLModifierMsg.cpp
  16. 8
      Sources/Plasma/NucleusLib/pnMessage/plSDLModifierMsg.h
  17. 4
      Sources/Plasma/NucleusLib/pnMessage/plSDLNotificationMsg.h
  18. 5
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp
  19. 4
      Sources/Plasma/PubUtilLib/plAvatar/plClothingSDLModifier.cpp
  20. 2
      Sources/Plasma/PubUtilLib/plDrawable/plMorphSequenceSDLMod.cpp
  21. 4
      Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.cpp
  22. 2
      Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.h
  23. 6
      Sources/Plasma/PubUtilLib/plNetClient/plLinkEffectsMgr.cpp
  24. 4
      Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp
  25. 13
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
  26. 8
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.cpp
  27. 2
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp
  28. 9
      Sources/Plasma/PubUtilLib/plNetClientRecorder/plNetClientStatsRecorder.cpp
  29. 9
      Sources/Plasma/PubUtilLib/plNetClientRecorder/plNetClientStreamRecorder.cpp
  30. 10
      Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.cpp
  31. 10
      Sources/Plasma/PubUtilLib/plNetCommon/plSpawnPointInfo.cpp
  32. 23
      Sources/Plasma/PubUtilLib/plNetCommon/plSpawnPointInfo.h
  33. 34
      Sources/Plasma/PubUtilLib/plSDL/plSDL.h
  34. 41
      Sources/Plasma/PubUtilLib/plSDL/plSDLDescriptor.h
  35. 6
      Sources/Plasma/PubUtilLib/plSDL/plSDLMgr.cpp
  36. 58
      Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp
  37. 2
      Sources/Plasma/PubUtilLib/plSDL/plStateChangeNotifier.cpp
  38. 66
      Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp
  39. 8
      Sources/Plasma/PubUtilLib/plSDL/plStateDescriptor.cpp
  40. 130
      Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp
  41. 120
      Sources/Plasma/PubUtilLib/plSDL/plVarDescriptor.cpp
  42. 8
      Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp
  43. 46
      Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp
  44. 4
      Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.h
  45. 2
      Sources/Tools/MaxComponent/plAnimComponent.cpp

28
Sources/Plasma/CoreLib/plString.cpp

@ -709,7 +709,7 @@ static bool ch_in_set(char ch, const char *set)
return false; return false;
} }
std::vector<plString> plString::Tokenize(const char *delims) std::vector<plString> plString::Tokenize(const char *delims) const
{ {
std::vector<plString> result; std::vector<plString> result;
@ -733,7 +733,7 @@ std::vector<plString> plString::Tokenize(const char *delims)
} }
//TODO: Not binary safe //TODO: Not binary safe
std::vector<plString> plString::Split(const char *split, size_t maxSplits) std::vector<plString> plString::Split(const char *split, size_t maxSplits) const
{ {
std::vector<plString> result; std::vector<plString> result;
@ -765,6 +765,30 @@ plString operator+(const plString &left, const plString &right)
return cat; return cat;
} }
plString operator+(const plString &left, const char *right)
{
plString cat;
size_t rsize = strlen(right);
char *catstr = cat.fUtf8Buffer.CreateWritableBuffer(left.GetSize() + rsize);
memcpy(catstr, left.c_str(), left.GetSize());
memcpy(catstr + left.GetSize(), right, rsize);
catstr[cat.fUtf8Buffer.GetSize()] = 0;
return cat;
}
plString operator+(const char *left, const plString &right)
{
plString cat;
size_t lsize = strlen(left);
char *catstr = cat.fUtf8Buffer.CreateWritableBuffer(lsize + right.GetSize());
memcpy(catstr, left, lsize);
memcpy(catstr + lsize, right.c_str(), right.GetSize());
catstr[cat.fUtf8Buffer.GetSize()] = 0;
return cat;
}
plStringStream &plStringStream::append(const char *data, size_t length) plStringStream &plStringStream::append(const char *data, size_t length)
{ {
if (fLength + length > fBufSize) { if (fLength + length > fBufSize) {

22
Sources/Plasma/CoreLib/plString.h

@ -163,18 +163,15 @@ private:
public: public:
plString() { } plString() { }
#ifndef PLSTRING_POLLUTE_ASCII_CAST
plString(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); } plString(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); }
#endif
plString(const plString &copy) : fUtf8Buffer(copy.fUtf8Buffer) { } plString(const plString &copy) : fUtf8Buffer(copy.fUtf8Buffer) { }
plString(const plStringBuffer<char> &init) { operator=(init); } plString(const plStringBuffer<char> &init) { operator=(init); }
#ifndef PLSTRING_POLLUTE_ASCII_CAST
plString &operator=(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); return *this; } plString &operator=(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); return *this; }
#endif
plString &operator=(const plString &copy) { fUtf8Buffer = copy.fUtf8Buffer; return *this; } plString &operator=(const plString &copy) { fUtf8Buffer = copy.fUtf8Buffer; return *this; }
plString &operator=(const plStringBuffer<char> &init); plString &operator=(const plStringBuffer<char> &init);
plString &operator+=(const char *cstr) { return operator=(*this + cstr); }
plString &operator+=(const plString &str) { return operator=(*this + str); } plString &operator+=(const plString &str) { return operator=(*this + str); }
static inline plString FromUtf8(const char *utf8, size_t size = kSizeAuto) static inline plString FromUtf8(const char *utf8, size_t size = kSizeAuto)
@ -205,10 +202,8 @@ public:
return str; return str;
} }
#ifndef PLSTRING_POLLUTE_C_STR
const char *c_str(const char *substitute = "") const const char *c_str(const char *substitute = "") const
{ return IsEmpty() ? substitute : fUtf8Buffer.GetData(); } { return IsEmpty() ? substitute : fUtf8Buffer.GetData(); }
#endif
char CharAt(size_t position) const { return c_str()[position]; } char CharAt(size_t position) const { return c_str()[position]; }
@ -263,8 +258,15 @@ public:
: strnicmp(c_str(), str, count); : strnicmp(c_str(), str, count);
} }
int CompareI(const plString &str) const { return Compare(str, kCaseInsensitive); }
int CompareI(const char *str) const { return Compare(str, kCaseInsensitive); }
int CompareNI(const plString &str, size_t count) const { return CompareN(str, count, kCaseInsensitive); }
int CompareNI(const char *str, size_t count) const { return CompareN(str, count, kCaseInsensitive); }
bool operator<(const plString &other) const { return Compare(other) < 0; } bool operator<(const plString &other) const { return Compare(other) < 0; }
bool operator==(const char *other) const { return Compare(other) == 0; }
bool operator==(const plString &other) const { return Compare(other) == 0; } bool operator==(const plString &other) const { return Compare(other) == 0; }
bool operator!=(const char *other) const { return Compare(other) != 0; }
bool operator!=(const plString &other) const { return Compare(other) != 0; } bool operator!=(const plString &other) const { return Compare(other) != 0; }
int Find(char ch, CaseSensitivity sense = kCaseSensitive) const; int Find(char ch, CaseSensitivity sense = kCaseSensitive) const;
@ -291,8 +293,8 @@ public:
// and Tokenize is that Tokenize never returns a blank string (it strips // and Tokenize is that Tokenize never returns a blank string (it strips
// all delimiters and only returns the pieces left between them), whereas // all delimiters and only returns the pieces left between them), whereas
// Split will split on a full string, returning whatever is left between. // Split will split on a full string, returning whatever is left between.
std::vector<plString> Split(const char *split, size_t maxSplits = kSizeAuto); std::vector<plString> Split(const char *split, size_t maxSplits = kSizeAuto) const;
std::vector<plString> Tokenize(const char *delims = " \t\r\n\f\v"); std::vector<plString> Tokenize(const char *delims = " \t\r\n\f\v") const;
public: public:
struct less struct less
@ -423,9 +425,13 @@ public:
private: private:
friend plString operator+(const plString &left, const plString &right); friend plString operator+(const plString &left, const plString &right);
friend plString operator+(const plString &left, const char *right);
friend plString operator+(const char *left, const plString &right);
}; };
plString operator+(const plString &left, const plString &right); plString operator+(const plString &left, const plString &right);
plString operator+(const plString &left, const char *right);
plString operator+(const char *left, const plString &right);
class plStringStream class plStringStream

22
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp

@ -6044,22 +6044,18 @@ PF_CONSOLE_CMD(Age, ShowSDL, "", "Prints the age SDL values")
return; return;
} }
char line[2048];
plStatusLog::AddLineS("ShowSDL.log", "-----------------------------------"); plStatusLog::AddLineS("ShowSDL.log", "-----------------------------------");
for (unsigned i = 0; i < rec->GetNumVars(); ++i) { for (unsigned i = 0; i < rec->GetNumVars(); ++i) {
plStateVariable * var = rec->GetVar(i); plStateVariable * var = rec->GetVar(i);
if (plSimpleStateVariable * simple = var->GetAsSimpleStateVar()) { if (plSimpleStateVariable * simple = var->GetAsSimpleStateVar()) {
const char * name = var->GetName(); plString line = var->GetName();
StrPrintf(line, arrsize(line), "%s=", name); line += "=";
for (unsigned j = 0; j < simple->GetCount(); ++j) { for (unsigned j = 0; j < simple->GetCount(); ++j) {
char * str = simple->GetAsString(j); line += simple->GetAsString(j);
StrPack(line, str, arrsize(line)); line += ",";
StrPack(line, ",", arrsize(line));
free(str);
} }
PrintString(line); PrintString(line.c_str());
plStatusLog::AddLineS("ShowSDL.log", "%s", line); plStatusLog::AddLineS("ShowSDL.log", "%s", line.c_str());
} }
} }
@ -6117,7 +6113,7 @@ PF_CONSOLE_CMD( Age, SetSDLFloat, "string varName, float value, int index", "Set
if (!sdlMod) if (!sdlMod)
return; return;
plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar(params[0]); plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar((const char *)params[0]);
if (!var) if (!var)
return; return;
@ -6141,7 +6137,7 @@ PF_CONSOLE_CMD( Age, SetSDLInt, "string varName, int value, int index", "Set the
if (!sdlMod) if (!sdlMod)
return; return;
plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar(params[0]); plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar((const char *)params[0]);
if (!var) if (!var)
return; return;
@ -6164,7 +6160,7 @@ PF_CONSOLE_CMD( Age, SetSDLBool, "string varName, bool value, int index", "Set t
if (!sdlMod) if (!sdlMod)
return; return;
plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar(params[0]); plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar((const char*)params[0]);
if (!var) if (!var)
return; return;

4
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp

@ -356,7 +356,7 @@ PF_CONSOLE_CMD( Net, // groupName
link.GetAgeInfo()->SetAgeFilename( params[0] ); link.GetAgeInfo()->SetAgeFilename( params[0] );
//link.GetAgeInfo()->SetAgeInstanceName( params[0] ); //link.GetAgeInfo()->SetAgeInstanceName( params[0] );
//link.GetAgeInfo()->SetAgeUserDefinedName( params[0] ); //link.GetAgeInfo()->SetAgeUserDefinedName( params[0] );
plUUID guid(params[1]); plUUID guid( (const char *)params[1] );
link.GetAgeInfo()->SetAgeInstanceGuid( &guid ); link.GetAgeInfo()->SetAgeInstanceGuid( &guid );
link.SetLinkingRules( plNetCommon::LinkingRules::kBasicLink ); link.SetLinkingRules( plNetCommon::LinkingRules::kBasicLink );
plNetLinkingMgr::GetInstance()->LinkToAge( &link ); plNetLinkingMgr::GetInstance()->LinkToAge( &link );
@ -379,7 +379,7 @@ PF_CONSOLE_CMD( Net,
{ {
plAgeLinkStruct link; plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] ); link.GetAgeInfo()->SetAgeFilename( params[0] );
link.SpawnPoint() = plSpawnPointInfo( params[1], params[1] ); link.SpawnPoint() = plSpawnPointInfo( (const char *)params[1], (const char *)params[1] );
link.SetLinkingRules( plNetCommon::LinkingRules::kOriginalBook ); link.SetLinkingRules( plNetCommon::LinkingRules::kOriginalBook );
plNetLinkingMgr::GetInstance()->LinkToAge( &link ); plNetLinkingMgr::GetInstance()->LinkToAge( &link );
PrintString("Linking to age with original book..."); PrintString("Linking to age with original book...");

8
Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp

@ -2300,16 +2300,14 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
plSDLNotificationMsg* sn = plSDLNotificationMsg::ConvertNoRef(msg); plSDLNotificationMsg* sn = plSDLNotificationMsg::ConvertNoRef(msg);
if (sn) if (sn)
{ {
const char* tag = sn->fHintString.c_str(); plString tag = sn->fHintString;
if (tag == nil)
tag = "";
// yes... then call it // yes... then call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod( PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_SDLNotify], fPyFunctionInstances[kfunc_SDLNotify],
(char*)fFunctionNames[kfunc_SDLNotify], (char*)fFunctionNames[kfunc_SDLNotify],
"ssls", sn->fVar->GetName(), sn->fSDLName.c_str(), "ssls", sn->fVar->GetName().c_str(), sn->fSDLName.c_str(),
sn->fPlayerID, tag); sn->fPlayerID, tag.c_str());
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE

57
Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp

@ -81,7 +81,7 @@ plPythonSDLModifier::plPythonSDLModifier(plPythonFileMod* owner) : fOwner(owner)
{ {
plVarDescriptor* var = desc->GetVar(i); plVarDescriptor* var = desc->GetVar(i);
const char* name = var->GetName(); plString name = var->GetName();
int count = var->GetCount(); int count = var->GetCount();
fMap[name] = SDLObj(nil, count, false); fMap[name] = SDLObj(nil, count, false);
@ -99,15 +99,14 @@ plPythonSDLModifier::~plPythonSDLModifier()
} }
} }
PyObject* plPythonSDLModifier::GetItem(const char* key) PyObject* plPythonSDLModifier::GetItem(const plString& key)
{ {
SDLMap::iterator it = fMap.find(key); SDLMap::iterator it = fMap.find(key);
if (it == fMap.end()) if (it == fMap.end())
{ {
char errmsg[256]; plString errmsg = plString::Format("SDL key %s not found", key.c_str());
sprintf(errmsg,"SDL key %s not found",key); PyErr_SetString(PyExc_KeyError, errmsg.c_str());
PyErr_SetString(PyExc_KeyError, errmsg);
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
@ -119,7 +118,7 @@ PyObject* plPythonSDLModifier::GetItem(const char* key)
return val; return val;
} }
void plPythonSDLModifier::ISetItem(const char* key, PyObject* value) void plPythonSDLModifier::ISetItem(const plString& key, PyObject* value)
{ {
if (!value || !PyTuple_Check(value)) if (!value || !PyTuple_Check(value))
{ {
@ -149,19 +148,19 @@ void plPythonSDLModifier::ISetItem(const char* key, PyObject* value)
oldObj.obj = value; oldObj.obj = value;
} }
void plPythonSDLModifier::SendToClients(const char* key) void plPythonSDLModifier::SendToClients(const plString& key)
{ {
SDLMap::iterator it = fMap.find(key); SDLMap::iterator it = fMap.find(key);
if (it != fMap.end()) if (it != fMap.end())
it->second.sendToClients = true; it->second.sendToClients = true;
} }
void plPythonSDLModifier::SetNotify(pyKey& selfkey, const char* key, float tolerance) void plPythonSDLModifier::SetNotify(pyKey& selfkey, const plString& key, float tolerance)
{ {
AddNotifyForVar(selfkey.getKey(), key, tolerance); AddNotifyForVar(selfkey.getKey(), key, tolerance);
} }
void plPythonSDLModifier::SetItem(const char* key, PyObject* value) void plPythonSDLModifier::SetItem(const plString& key, PyObject* value)
{ {
ISetItem(key, value); ISetItem(key, value);
IDirtySynchState(key); IDirtySynchState(key);
@ -169,7 +168,7 @@ void plPythonSDLModifier::SetItem(const char* key, PyObject* value)
void plPythonSDLModifier::SetItemFromSDLVar(plSimpleStateVariable* var) void plPythonSDLModifier::SetItemFromSDLVar(plSimpleStateVariable* var)
{ {
const char* name = var->GetName(); plString name = var->GetName();
// Get the SDL value in Python format // Get the SDL value in Python format
PyObject* pyVar = ISDLVarToPython(var); PyObject* pyVar = ISDLVarToPython(var);
@ -180,12 +179,12 @@ void plPythonSDLModifier::SetItemFromSDLVar(plSimpleStateVariable* var)
} }
void plPythonSDLModifier::SetDefault(const char* key, PyObject* value) void plPythonSDLModifier::SetDefault(const plString& key, PyObject* value)
{ {
ISetItem(key, value); ISetItem(key, value);
} }
void plPythonSDLModifier::SetItemIdx(const char* key, int idx, PyObject* value, bool sendImmediate) void plPythonSDLModifier::SetItemIdx(const plString& key, int idx, PyObject* value, bool sendImmediate)
{ {
if (!value) if (!value)
{ {
@ -269,7 +268,7 @@ const char* plPythonSDLModifier::GetSDLName() const
return fOwner->fPythonFile; return fOwner->fPythonFile;
} }
void plPythonSDLModifier::SetFlags(const char* name, bool sendImmediate, bool skipOwnershipCheck) void plPythonSDLModifier::SetFlags(const plString& name, bool sendImmediate, bool skipOwnershipCheck)
{ {
SDLMap::iterator it = fMap.find(name); SDLMap::iterator it = fMap.find(name);
if (it != fMap.end()) if (it != fMap.end())
@ -279,7 +278,7 @@ void plPythonSDLModifier::SetFlags(const char* name, bool sendImmediate, bool sk
} }
} }
void plPythonSDLModifier::SetTagString(const char* name, const char* tag) void plPythonSDLModifier::SetTagString(const plString& name, const plString& tag)
{ {
SDLMap::iterator it = fMap.find(name); SDLMap::iterator it = fMap.find(name);
if (it != fMap.end()) if (it != fMap.end())
@ -297,7 +296,7 @@ void plPythonSDLModifier::ISetCurrentStateFrom(const plStateDataRecord* srcState
{ {
plSimpleStateVariable* var = vars[i]; plSimpleStateVariable* var = vars[i];
const char* name = var->GetName(); plString name = var->GetName();
// Get the SDL value in Python format // Get the SDL value in Python format
PyObject* pyVar = ISDLVarToPython(var); PyObject* pyVar = ISDLVarToPython(var);
@ -334,11 +333,11 @@ void plPythonSDLModifier::IPutCurrentStateIn(plStateDataRecord* dstState)
SDLMap::iterator it = fMap.begin(); SDLMap::iterator it = fMap.begin();
for (; it != fMap.end(); it++) for (; it != fMap.end(); it++)
{ {
IPythonVarToSDL(dstState, it->first.c_str()); IPythonVarToSDL(dstState, it->first);
} }
} }
void plPythonSDLModifier::IDirtySynchState(const char* name, bool sendImmediate) void plPythonSDLModifier::IDirtySynchState(const plString& name, bool sendImmediate)
{ {
SDLMap::iterator it = fMap.find(name); SDLMap::iterator it = fMap.find(name);
if (it != fMap.end()) if (it != fMap.end())
@ -358,7 +357,7 @@ void plPythonSDLModifier::IDirtySynchState(const char* name, bool sendImmediate)
} }
bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int varIdx, int type, PyObject* pyVar, bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int varIdx, int type, PyObject* pyVar,
const char* hintstring) const plString& hintstring)
{ {
switch (type) switch (type)
{ {
@ -370,7 +369,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
int v = PyInt_AsLong(pyVar); int v = PyInt_AsLong(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -378,7 +377,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
int v = (int)PyLong_AsLong(pyVar); int v = (int)PyLong_AsLong(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -387,7 +386,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
int v = (int)PyFloat_AsDouble(pyVar); int v = (int)PyFloat_AsDouble(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -398,7 +397,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
float v = (float)PyFloat_AsDouble(pyVar); float v = (float)PyFloat_AsDouble(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -407,7 +406,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
float v = (float)PyInt_AsLong(pyVar); float v = (float)PyInt_AsLong(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -418,7 +417,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
char* v = PyString_AsString(pyVar); char* v = PyString_AsString(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
} }
break; break;
@ -428,7 +427,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
pyKey* key = PythonInterface::GetpyKeyFromPython(pyVar); pyKey* key = PythonInterface::GetpyKeyFromPython(pyVar);
if ( key ) if ( key )
var->Set(key->getKey(),varIdx); var->Set(key->getKey(),varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
} }
break; break;
@ -438,7 +437,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
double v = PyFloat_AsDouble(pyVar); double v = PyFloat_AsDouble(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -446,7 +445,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
double v = (double)PyInt_AsLong(pyVar); double v = (double)PyInt_AsLong(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -462,7 +461,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
return false; return false;
} }
void plPythonSDLModifier::IPythonVarToSDL(plStateDataRecord* state, const char* name) void plPythonSDLModifier::IPythonVarToSDL(plStateDataRecord* state, const plString& name)
{ {
plSimpleStateVariable* var = state->FindVar(name); plSimpleStateVariable* var = state->FindVar(name);
PyObject* pyVar = nil; PyObject* pyVar = nil;
@ -482,7 +481,7 @@ void plPythonSDLModifier::IPythonVarToSDL(plStateDataRecord* state, const char*
{ {
PyObject* pyVarItem = PyTuple_GetItem(pyVar, i); PyObject* pyVarItem = PyTuple_GetItem(pyVar, i);
if (pyVarItem) if (pyVarItem)
IPythonVarIdxToSDL(var, i, type, pyVarItem,it->second.hintString.c_str()); IPythonVarIdxToSDL(var, i, type, pyVarItem,it->second.hintString);
} }
} }
} }

28
Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.h

@ -70,11 +70,11 @@ protected:
bool sendToClients; bool sendToClients;
bool skipLocalCheck; bool skipLocalCheck;
bool sendImmediate; bool sendImmediate;
std::string hintString; plString hintString;
SDLObj() : obj(nil), size(-1), sendToClients(false) {} SDLObj() : obj(nil), size(-1), sendToClients(false) {}
SDLObj(PyObject* obj, int size, bool sendToClients) : obj(obj), size(size), sendToClients(sendToClients) {} SDLObj(PyObject* obj, int size, bool sendToClients) : obj(obj), size(size), sendToClients(sendToClients) {}
}; };
typedef std::map<std::string, SDLObj> SDLMap; typedef std::map<plString, SDLObj> SDLMap;
SDLMap fMap; SDLMap fMap;
plPythonFileMod* fOwner; plPythonFileMod* fOwner;
@ -83,11 +83,11 @@ protected:
PyObject* ISDLVarToPython(plSimpleStateVariable* var); PyObject* ISDLVarToPython(plSimpleStateVariable* var);
PyObject* ISDLVarIdxToPython(plSimpleStateVariable* var, int type, int idx); PyObject* ISDLVarIdxToPython(plSimpleStateVariable* var, int type, int idx);
void IPythonVarToSDL(plStateDataRecord* state, const char* name); void IPythonVarToSDL(plStateDataRecord* state, const plString& name);
bool IPythonVarIdxToSDL(plSimpleStateVariable* var, int varIdx, int type, PyObject* pyVar, const char* hintstring); bool IPythonVarIdxToSDL(plSimpleStateVariable* var, int varIdx, int type, PyObject* pyVar, const plString& hintstring);
void ISetItem(const char* key, PyObject* value); void ISetItem(const plString& key, PyObject* value);
void IDirtySynchState(const char* name, bool sendImmediate = false); void IDirtySynchState(const plString& name, bool sendImmediate = false);
void IPutCurrentStateIn(plStateDataRecord* dstState); void IPutCurrentStateIn(plStateDataRecord* dstState);
void ISetCurrentStateFrom(const plStateDataRecord* srcState); void ISetCurrentStateFrom(const plStateDataRecord* srcState);
@ -106,15 +106,15 @@ public:
static const plPythonSDLModifier* FindAgeSDL(); static const plPythonSDLModifier* FindAgeSDL();
static plKey FindAgeSDLTarget(); static plKey FindAgeSDLTarget();
void SetDefault(const char* key, PyObject* value); void SetDefault(const plString& key, PyObject* value);
void SendToClients(const char* key); void SendToClients(const plString& key);
void SetNotify(pyKey& selfkey, const char* key, float tolerance); void SetNotify(pyKey& selfkey, const plString& key, float tolerance);
PyObject* GetItem(const char* key); PyObject* GetItem(const plString& key);
void SetItem(const char* key, PyObject* value); void SetItem(const plString& key, PyObject* value);
void SetItemIdx(const char* key, int idx, PyObject* value, bool sendImmediate = false); void SetItemIdx(const plString& key, int idx, PyObject* value, bool sendImmediate = false);
void SetFlags(const char* name, bool sendImmediate, bool skipOwnershipCheck); void SetFlags(const plString& name, bool sendImmediate, bool skipOwnershipCheck);
void SetTagString(const char* name, const char* tag); void SetTagString(const plString& name, const plString& tag);
}; };
// A wrapper for plPythonSDLModifier that Python uses // A wrapper for plPythonSDLModifier that Python uses

29
Sources/Plasma/FeatureLib/pfPython/pySDL.cpp

@ -67,7 +67,7 @@ plStateDataRecord * pySDLStateDataRecord::GetRec() const
return fRec; return fRec;
} }
PyObject * pySDLStateDataRecord::FindVar( const char * name ) const PyObject * pySDLStateDataRecord::FindVar( const plString & name ) const
{ {
if ( !fRec ) if ( !fRec )
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
@ -79,17 +79,17 @@ PyObject * pySDLStateDataRecord::FindVar( const char * name ) const
return pySimpleStateVariable::New( var ); return pySimpleStateVariable::New( var );
} }
const char *pySDLStateDataRecord::GetName() const plString pySDLStateDataRecord::GetName() const
{ {
if (!fRec) if (!fRec)
return nil; return "";
const plStateDescriptor *stateDesc = fRec->GetDescriptor(); const plStateDescriptor *stateDesc = fRec->GetDescriptor();
return stateDesc->GetName(); return stateDesc->GetName();
} }
std::vector<std::string> pySDLStateDataRecord::GetVarList() std::vector<plString> pySDLStateDataRecord::GetVarList()
{ {
std::vector<std::string> retVal; std::vector<plString> retVal;
if (!fRec) if (!fRec)
return retVal; return retVal;
const plStateDescriptor *stateDesc = fRec->GetDescriptor(); const plStateDescriptor *stateDesc = fRec->GetDescriptor();
@ -225,16 +225,15 @@ bool pySimpleStateVariable::GetBool( int idx ) const
return v; return v;
} }
const char * pySimpleStateVariable::GetString( int idx ) const plString pySimpleStateVariable::GetString( int idx ) const
{ {
fString = "";
if ( fVar ) if ( fVar )
{ {
char v[256]; char v[256];
if ( fVar->Get( v, idx ) ) if ( fVar->Get( v, idx ) )
fString = v; return plString::FromUtf8(v);
} }
return fString.c_str(); return "";
} }
plKey pySimpleStateVariable::GetKey( int idx ) const plKey pySimpleStateVariable::GetKey( int idx ) const
@ -253,18 +252,18 @@ int pySimpleStateVariable::GetType() const
return varDesc->GetType(); return varDesc->GetType();
} }
const char *pySimpleStateVariable::GetDisplayOptions() const plString pySimpleStateVariable::GetDisplayOptions() const
{ {
if (!fVar) if (!fVar)
return nil; return "";
plVarDescriptor *varDesc = fVar->GetVarDescriptor(); plVarDescriptor *varDesc = fVar->GetVarDescriptor();
return varDesc->GetDisplayOptions(); return varDesc->GetDisplayOptions();
} }
const char *pySimpleStateVariable::GetDefault() const plString pySimpleStateVariable::GetDefault() const
{ {
if (!fVar) if (!fVar)
return nil; return "";
plVarDescriptor *varDesc = fVar->GetVarDescriptor(); plVarDescriptor *varDesc = fVar->GetVarDescriptor();
return varDesc->GetDefault(); return varDesc->GetDefault();
} }
@ -272,7 +271,7 @@ const char *pySimpleStateVariable::GetDefault() const
bool pySimpleStateVariable::IsInternal() const bool pySimpleStateVariable::IsInternal() const
{ {
if (!fVar) if (!fVar)
return nil; return false;
plVarDescriptor *varDesc = fVar->GetVarDescriptor(); plVarDescriptor *varDesc = fVar->GetVarDescriptor();
return varDesc->IsInternal(); return varDesc->IsInternal();
} }
@ -280,7 +279,7 @@ bool pySimpleStateVariable::IsInternal() const
bool pySimpleStateVariable::IsAlwaysNew() const bool pySimpleStateVariable::IsAlwaysNew() const
{ {
if (!fVar) if (!fVar)
return nil; return false;
plVarDescriptor *varDesc = fVar->GetVarDescriptor(); plVarDescriptor *varDesc = fVar->GetVarDescriptor();
return varDesc->IsAlwaysNew(); return varDesc->IsAlwaysNew();
} }

13
Sources/Plasma/FeatureLib/pfPython/pySDL.h

@ -90,9 +90,9 @@ public:
plStateDataRecord * GetRec() const; plStateDataRecord * GetRec() const;
///////////////////// /////////////////////
PyObject * FindVar( const char * name ) const; // returns pySimpleStateVariable PyObject * FindVar( const plString & name ) const; // returns pySimpleStateVariable
const char *GetName() const; plString GetName() const;
std::vector<std::string> GetVarList(); std::vector<plString> GetVarList();
void SetFromDefaults(bool timeStampNow); void SetFromDefaults(bool timeStampNow);
}; };
@ -101,7 +101,6 @@ class pySimpleStateVariable
{ {
private: private:
plSimpleStateVariable * fVar; plSimpleStateVariable * fVar;
mutable std::string fString; // for GetString()
protected: protected:
pySimpleStateVariable(); pySimpleStateVariable();
@ -133,12 +132,12 @@ public:
float GetFloat( int idx=0 ) const; float GetFloat( int idx=0 ) const;
double GetDouble( int idx=0 ) const; double GetDouble( int idx=0 ) const;
bool GetBool( int idx=0 ) const; bool GetBool( int idx=0 ) const;
const char * GetString( int idx=0 ) const; plString GetString( int idx=0 ) const;
plKey GetKey( int idx=0 ) const; plKey GetKey( int idx=0 ) const;
int GetType() const; int GetType() const;
const char *GetDisplayOptions() const; plString GetDisplayOptions() const;
const char *GetDefault() const; plString GetDefault() const;
bool IsAlwaysNew() const; bool IsAlwaysNew() const;
bool IsInternal() const; bool IsInternal() const;

11
Sources/Plasma/FeatureLib/pfPython/pySDLGlue.cpp

@ -104,12 +104,12 @@ PYTHON_METHOD_DEFINITION(ptSDLStateDataRecord, findVar, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSDLStateDataRecord, getName) PYTHON_METHOD_DEFINITION_NOARGS(ptSDLStateDataRecord, getName)
{ {
return PyString_FromString(self->fThis->GetName()); return PyString_FromString(self->fThis->GetName().c_str());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptSDLStateDataRecord, getVarList) PYTHON_METHOD_DEFINITION_NOARGS(ptSDLStateDataRecord, getVarList)
{ {
std::vector<std::string> vars = self->fThis->GetVarList(); std::vector<plString> vars = self->fThis->GetVarList();
PyObject* varList = PyList_New(vars.size()); PyObject* varList = PyList_New(vars.size());
for (int i = 0; i < vars.size(); i++) for (int i = 0; i < vars.size(); i++)
PyList_SetItem(varList, i, PyString_FromString(vars[i].c_str())); PyList_SetItem(varList, i, PyString_FromString(vars[i].c_str()));
@ -219,12 +219,13 @@ PYTHON_METHOD_DEFINITION(ptSimpleStateVariable, setBool, args)
PYTHON_RETURN_BOOL(self->fThis->SetBool(val != 0, idx)); PYTHON_RETURN_BOOL(self->fThis->SetBool(val != 0, idx));
} }
#define PyString_FromPlString(x) PyString_FromString((x).c_str())
STATEVAR_GET(getByte, GetByte, PyInt_FromLong) STATEVAR_GET(getByte, GetByte, PyInt_FromLong)
STATEVAR_GET(getShort, GetShort, PyInt_FromLong) STATEVAR_GET(getShort, GetShort, PyInt_FromLong)
STATEVAR_GET(getInt, GetInt, PyInt_FromLong) STATEVAR_GET(getInt, GetInt, PyInt_FromLong)
STATEVAR_GET(getFloat, GetFloat, PyFloat_FromDouble) STATEVAR_GET(getFloat, GetFloat, PyFloat_FromDouble)
STATEVAR_GET(getDouble, GetDouble, PyFloat_FromDouble) STATEVAR_GET(getDouble, GetDouble, PyFloat_FromDouble)
STATEVAR_GET(getString, GetString, PyString_FromString) STATEVAR_GET(getString, GetString, PyString_FromPlString)
STATEVAR_GET(getKey, GetKey, pyKey::New) STATEVAR_GET(getKey, GetKey, pyKey::New)
// getBool is special cause of the way python represents booleans // getBool is special cause of the way python represents booleans
@ -246,12 +247,12 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptSimpleStateVariable, getType)
PYTHON_METHOD_DEFINITION_NOARGS(ptSimpleStateVariable, getDisplayOptions) PYTHON_METHOD_DEFINITION_NOARGS(ptSimpleStateVariable, getDisplayOptions)
{ {
return PyString_FromString(self->fThis->GetDisplayOptions()); return PyString_FromString(self->fThis->GetDisplayOptions().c_str());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptSimpleStateVariable, getDefault) PYTHON_METHOD_DEFINITION_NOARGS(ptSimpleStateVariable, getDefault)
{ {
return PyString_FromString(self->fThis->GetDefault()); return PyString_FromString(self->fThis->GetDefault().c_str());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptSimpleStateVariable, isAlwaysNew) PYTHON_METHOD_DEFINITION_NOARGS(ptSimpleStateVariable, isAlwaysNew)

12
Sources/Plasma/FeatureLib/pfPython/pySpawnPointInfo.h

@ -74,11 +74,11 @@ public:
plSpawnPointInfo & SpawnPoint() { return fInfo; } plSpawnPointInfo & SpawnPoint() { return fInfo; }
void SetTitle( const char * v ) { fInfo.SetTitle( v ); } void SetTitle( const char * v ) { fInfo.SetTitle( v ); }
const char * GetTitle() const { return fInfo.GetTitle(); } plString GetTitle() const { return fInfo.GetTitle(); }
void SetName( const char * v ) { fInfo.SetName( v ); } void SetName( const char * v ) { fInfo.SetName( v ); }
const char * GetName() const { return fInfo.GetName(); } plString GetName() const { return fInfo.GetName(); }
void SetCameraStack(const char * v ) { fInfo.SetCameraStack( v ); } void SetCameraStack(const char * v ) { fInfo.SetCameraStack( v ); }
const char * GetCameraStack() const { return fInfo.GetCameraStack(); } plString GetCameraStack() const { return fInfo.GetCameraStack(); }
static PyObject* GetDefaultSpawnPoint(); static PyObject* GetDefaultSpawnPoint();
}; };
@ -105,11 +105,11 @@ public:
plSpawnPointInfo & SpawnPoint() { return fInfo; } plSpawnPointInfo & SpawnPoint() { return fInfo; }
void SetTitle( const char * v ) { fInfo.SetTitle( v ); } void SetTitle( const char * v ) { fInfo.SetTitle( v ); }
const char * GetTitle() const { return fInfo.GetTitle(); } plString GetTitle() const { return fInfo.GetTitle(); }
void SetName( const char * v ) { fInfo.SetName( v ); } void SetName( const char * v ) { fInfo.SetName( v ); }
const char * GetName() const { return fInfo.GetName(); } plString GetName() const { return fInfo.GetName(); }
void SetCameraStack(const char * v ) { fInfo.SetCameraStack( v ); } void SetCameraStack(const char * v ) { fInfo.SetCameraStack( v ); }
const char * GetCameraStack() const { return fInfo.GetCameraStack(); } plString GetCameraStack() const { return fInfo.GetCameraStack(); }
}; };
#endif // pySpawnPointInfo_h_inc #endif // pySpawnPointInfo_h_inc

12
Sources/Plasma/FeatureLib/pfPython/pySpawnPointInfoGlue.cpp

@ -78,7 +78,7 @@ PYTHON_INIT_DEFINITION(ptSpawnPointInfo, args, keywords)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfo, getTitle) PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfo, getTitle)
{ {
return PyString_FromString(self->fThis->GetTitle()); return PyString_FromString(self->fThis->GetTitle().c_str());
} }
PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setTitle, args) PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setTitle, args)
@ -95,7 +95,7 @@ PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setTitle, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfo, getName) PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfo, getName)
{ {
return PyString_FromString(self->fThis->GetName()); return PyString_FromString(self->fThis->GetName().c_str());
} }
PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setName, args) PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setName, args)
@ -112,7 +112,7 @@ PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfo, getCameraStack) PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfo, getCameraStack)
{ {
return PyString_FromString(self->fThis->GetCameraStack()); return PyString_FromString(self->fThis->GetCameraStack().c_str());
} }
PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setCameraStack, args) PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setCameraStack, args)
@ -191,7 +191,7 @@ PYTHON_NO_INIT_DEFINITION(ptSpawnPointInfoRef)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfoRef, getTitle) PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfoRef, getTitle)
{ {
return PyString_FromString(self->fThis->GetTitle()); return PyString_FromString(self->fThis->GetTitle().c_str());
} }
PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setTitle, args) PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setTitle, args)
@ -208,7 +208,7 @@ PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setTitle, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfoRef, getName) PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfoRef, getName)
{ {
return PyString_FromString(self->fThis->GetName()); return PyString_FromString(self->fThis->GetName().c_str());
} }
PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setName, args) PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setName, args)
@ -225,7 +225,7 @@ PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfoRef, getCameraStack) PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfoRef, getCameraStack)
{ {
return PyString_FromString(self->fThis->GetCameraStack()); return PyString_FromString(self->fThis->GetCameraStack().c_str());
} }
PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setCameraStack, args) PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setCameraStack, args)

4
Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.cpp

@ -166,7 +166,7 @@ void pyVaultAgeLinkNode::RemoveSpawnPointRef( pySpawnPointInfoRef & point )
access.RemoveSpawnPoint(point.GetName()); access.RemoveSpawnPoint(point.GetName());
} }
void pyVaultAgeLinkNode::RemoveSpawnPointByName( const char * spawnPtName ) void pyVaultAgeLinkNode::RemoveSpawnPointByName( const plString & spawnPtName )
{ {
if (!fNode) if (!fNode)
return; return;
@ -175,7 +175,7 @@ void pyVaultAgeLinkNode::RemoveSpawnPointByName( const char * spawnPtName )
access.RemoveSpawnPoint(spawnPtName); access.RemoveSpawnPoint(spawnPtName);
} }
bool pyVaultAgeLinkNode::HasSpawnPoint( const char * spawnPtName ) const bool pyVaultAgeLinkNode::HasSpawnPoint( const plString & spawnPtName ) const
{ {
if (!fNode) if (!fNode)
return false; return false;

4
Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.h

@ -100,8 +100,8 @@ public:
void AddSpawnPointRef( pySpawnPointInfoRef & point ); // will only add if not there already. void AddSpawnPointRef( pySpawnPointInfoRef & point ); // will only add if not there already.
void RemoveSpawnPoint( pySpawnPointInfo & point ); void RemoveSpawnPoint( pySpawnPointInfo & point );
void RemoveSpawnPointRef( pySpawnPointInfoRef & point ); void RemoveSpawnPointRef( pySpawnPointInfoRef & point );
void RemoveSpawnPointByName( const char * spawnPtName ); void RemoveSpawnPointByName( const plString & spawnPtName );
bool HasSpawnPoint( const char * spawnPtName ) const; bool HasSpawnPoint( const plString & spawnPtName ) const;
PyObject * GetSpawnPoints() const; // returns list of pySpawnPointInfo PyObject * GetSpawnPoints() const; // returns list of pySpawnPointInfo
PyObject * AsAgeLinkStruct() const; // returns pyAgeLinkStruct PyObject * AsAgeLinkStruct() const; // returns pyAgeLinkStruct

6
Sources/Plasma/NucleusLib/pnMessage/plSDLModifierMsg.cpp

@ -42,15 +42,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plSDLModifierMsg.h" #include "plSDLModifierMsg.h"
#include "plSDL/plSDL.h" // ugh. #include "plSDL/plSDL.h" // ugh.
plSDLModifierMsg::plSDLModifierMsg(const char* sdlName, Action a) : plSDLModifierMsg::plSDLModifierMsg(const plString& sdlName, Action a) :
fSDLName(nil), fSDLName(sdlName),
fAction(a), fAction(a),
fState(nil), fState(nil),
fPlayerID(0), fPlayerID(0),
fManageStateMem(false), fManageStateMem(false),
fFlags(0) fFlags(0)
{ {
SetSDLName(sdlName);
SetBCastFlag(plMessage::kPropagateToModifiers); SetBCastFlag(plMessage::kPropagateToModifiers);
} }
@ -58,5 +57,4 @@ plSDLModifierMsg::~plSDLModifierMsg()
{ {
if ( fManageStateMem ) if ( fManageStateMem )
delete fState; delete fState;
delete [] fSDLName;
} }

8
Sources/Plasma/NucleusLib/pnMessage/plSDLModifierMsg.h

@ -63,7 +63,7 @@ public:
}; };
protected: protected:
char* fSDLName; // the state descriptor name (ie. "physical") plString fSDLName; // the state descriptor name (ie. "physical")
Action fAction; Action fAction;
plStateDataRecord* fState; // for recving state plStateDataRecord* fState; // for recving state
bool fManageStateMem; // delete fState? bool fManageStateMem; // delete fState?
@ -71,7 +71,7 @@ protected:
uint32_t fFlags; uint32_t fFlags;
public: public:
plSDLModifierMsg(const char* sdlName=nil, Action a=kActionNone); plSDLModifierMsg(const plString& sdlName="", Action a=kActionNone);
~plSDLModifierMsg(); ~plSDLModifierMsg();
CLASSNAME_REGISTER( plSDLModifierMsg ); CLASSNAME_REGISTER( plSDLModifierMsg );
@ -86,8 +86,8 @@ public:
plStateDataRecord* GetState(bool unManageState=false) { if ( unManageState ) fManageStateMem=false; return fState; } plStateDataRecord* GetState(bool unManageState=false) { if ( unManageState ) fManageStateMem=false; return fState; }
void SetState(plStateDataRecord* s, bool manageState) { fState=s; fManageStateMem=manageState; } void SetState(plStateDataRecord* s, bool manageState) { fState=s; fManageStateMem=manageState; }
const char* GetSDLName() const { return fSDLName; } plString GetSDLName() const { return fSDLName; }
void SetSDLName(const char* s) { delete [] fSDLName; fSDLName=hsStrcpy(s); } void SetSDLName(const plString& s) { fSDLName=s; }
uint32_t GetPlayerID() const { return fPlayerID; } uint32_t GetPlayerID() const { return fPlayerID; }
void SetPlayerID(uint32_t p) { fPlayerID=p; } void SetPlayerID(uint32_t p) { fPlayerID=p; }

4
Sources/Plasma/NucleusLib/pnMessage/plSDLNotificationMsg.h

@ -50,9 +50,9 @@ class plSDLNotificationMsg : public plMessage
public: public:
float fDelta; // change threshold float fDelta; // change threshold
const plSimpleStateVariable* fVar; const plSimpleStateVariable* fVar;
std::string fSDLName; // name of state descriptor plString fSDLName; // name of state descriptor
int fPlayerID; // pid of the player who changed the data int fPlayerID; // pid of the player who changed the data
std::string fHintString; // hint from the player who changed the data plString fHintString; // hint from the player who changed the data
plSDLNotificationMsg() : fDelta(0), fVar(nil), fPlayerID(0) {} plSDLNotificationMsg() : fDelta(0), fVar(nil), fPlayerID(0) {}
~plSDLNotificationMsg() { } ~plSDLNotificationMsg() { }

5
Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp

@ -821,21 +821,20 @@ void plClothingOutfit::ReadFromVault()
ram.Write(sdl.sdlDataLen, sdl.sdlData); ram.Write(sdl.sdlDataLen, sdl.sdlData);
ram.Rewind(); ram.Rewind();
char * sdlRecName = nil; plString sdlRecName;
int sdlRecVersion; int sdlRecVersion;
plStateDataRecord::ReadStreamHeader(&ram, &sdlRecName, &sdlRecVersion); plStateDataRecord::ReadStreamHeader(&ram, &sdlRecName, &sdlRecVersion);
plStateDescriptor * desc = plSDLMgr::GetInstance()->FindDescriptor(sdlRecName, sdlRecVersion); plStateDescriptor * desc = plSDLMgr::GetInstance()->FindDescriptor(sdlRecName, sdlRecVersion);
if (desc) { if (desc) {
plStateDataRecord * sdlDataRec = new plStateDataRecord(desc); plStateDataRecord * sdlDataRec = new plStateDataRecord(desc);
if (sdlDataRec->Read(&ram, 0)) { if (sdlDataRec->Read(&ram, 0)) {
if (!strcmp(sdlRecName, kSDLMorphSequence)) if (sdlRecName == kSDLMorphSequence)
IHandleMorphSDR(sdlDataRec); IHandleMorphSDR(sdlDataRec);
else else
plClothingSDLModifier::HandleSingleSDR(sdlDataRec, this); plClothingSDLModifier::HandleSingleSDR(sdlDataRec, this);
} }
delete sdlDataRec; delete sdlDataRec;
} }
delete [] sdlRecName;
} }
nodes[i]->DecRef(); nodes[i]->DecRef();
} }

4
Sources/Plasma/PubUtilLib/plAvatar/plClothingSDLModifier.cpp

@ -231,7 +231,7 @@ void plClothingSDLModifier::HandleSingleSDR(const plStateDataRecord *sdr, plClot
int i; int i;
uint8_t tint[3]; uint8_t tint[3];
float tintScalar[3]; float tintScalar[3];
if (!strcmp(sdr->GetDescriptor()->GetName(), kStrClothingDescName)) if (sdr->GetDescriptor()->GetName() == kStrClothingDescName)
{ {
// get item from clothesItem // get item from clothesItem
plSimpleStateVariable* itemVar = sdr->FindVar(kStrItem); plSimpleStateVariable* itemVar = sdr->FindVar(kStrItem);
@ -284,7 +284,7 @@ void plClothingSDLModifier::HandleSingleSDR(const plStateDataRecord *sdr, plClot
} }
} }
} }
else if (!strcmp(sdr->GetDescriptor()->GetName(), kStrAppearanceDescName)) else if (sdr->GetDescriptor()->GetName() == kStrAppearanceDescName)
{ {
// skin tints // skin tints
plSimpleStateVariable* skinVar = sdr->FindVar(kStrSkinTint); plSimpleStateVariable* skinVar = sdr->FindVar(kStrSkinTint);

2
Sources/Plasma/PubUtilLib/plDrawable/plMorphSequenceSDLMod.cpp

@ -134,7 +134,7 @@ void plMorphSequenceSDLMod::ISetCurrentStateFrom(const plStateDataRecord* srcSta
plSceneObject* sobj=GetTarget(); plSceneObject* sobj=GetTarget();
hsAssert(sobj, "plMorphSequenceSDLMod, nil target"); hsAssert(sobj, "plMorphSequenceSDLMod, nil target");
if (strcmp(srcState->GetDescriptor()->GetName(), kSDLMorphSequence)) if (srcState->GetDescriptor()->GetName() != kSDLMorphSequence)
{ {
hsAssert(false, "Wrong type of state data record passed into plMorphSequenceSDLMod."); hsAssert(false, "Wrong type of state data record passed into plMorphSequenceSDLMod.");
return; return;

4
Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.cpp

@ -110,7 +110,7 @@ void plSDLModifier::ISendNetMsg(plStateDataRecord*& state, plKey senderKey, uint
bool plSDLModifier::MsgReceive(plMessage* msg) bool plSDLModifier::MsgReceive(plMessage* msg)
{ {
plSDLModifierMsg* sdlMsg = plSDLModifierMsg::ConvertNoRef(msg); plSDLModifierMsg* sdlMsg = plSDLModifierMsg::ConvertNoRef(msg);
if (sdlMsg && !stricmp(sdlMsg->GetSDLName(),GetSDLName())) if (sdlMsg && !sdlMsg->GetSDLName().CompareI(GetSDLName()))
{ {
uint32_t sendFlags = IApplyModFlags(sdlMsg->GetFlags()); uint32_t sendFlags = IApplyModFlags(sdlMsg->GetFlags());
@ -229,7 +229,7 @@ void plSDLModifier::ReceiveState(const plStateDataRecord* srcState)
plNetObjectDebugger::GetInstance()->SetDebugging(false); plNetObjectDebugger::GetInstance()->SetDebugging(false);
} }
void plSDLModifier::AddNotifyForVar(plKey key, const char* varName, float tolerance) const void plSDLModifier::AddNotifyForVar(plKey key, const plString& varName, float tolerance) const
{ {
// create a SDL notifier object // create a SDL notifier object
plStateChangeNotifier notifier(tolerance, key); plStateChangeNotifier notifier(tolerance, key);

2
Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.h

@ -80,7 +80,7 @@ public:
plStateDataRecord* GetStateCache() const { return fStateCache; } plStateDataRecord* GetStateCache() const { return fStateCache; }
virtual void AddTarget(plSceneObject* so); virtual void AddTarget(plSceneObject* so);
void AddNotifyForVar(plKey key, const char* varName, float tolerance) const; void AddNotifyForVar(plKey key, const plString& varName, float tolerance) const;
}; };
#endif // plSDLModifier_inc #endif // plSDLModifier_inc

6
Sources/Plasma/PubUtilLib/plNetClient/plLinkEffectsMgr.cpp

@ -386,12 +386,10 @@ bool plLinkEffectsMgr::MsgReceive(plMessage *msg)
bool linkToFissureDrop = lm && bool linkToFissureDrop = lm &&
lm->GetAgeLink()->HasSpawnPt() && lm->GetAgeLink()->HasSpawnPt() &&
lm->GetAgeLink()->SpawnPoint().GetName() && !lm->GetAgeLink()->SpawnPoint().GetName().CompareI(kCleftAgeLinkInPointFissureDrop);
!stricmp(lm->GetAgeLink()->SpawnPoint().GetName(), kCleftAgeLinkInPointFissureDrop);
bool linkToDsntFromShell = lm && bool linkToDsntFromShell = lm &&
lm->GetAgeLink()->HasSpawnPt() && lm->GetAgeLink()->HasSpawnPt() &&
lm->GetAgeLink()->SpawnPoint().GetTitle() && !lm->GetAgeLink()->SpawnPoint().GetTitle().CompareI(kDescentLinkFromShell);
!stricmp(lm->GetAgeLink()->SpawnPoint().GetTitle(), kDescentLinkFromShell);
if ( linkToACA || linkFromACA || linkToStartup || linkFromStartup || linkToFissureDrop || linkToDsntFromShell) if ( linkToACA || linkFromACA || linkToStartup || linkFromStartup || linkToFissureDrop || linkToDsntFromShell)
{ {
BCMsg->SetLinkFlag(plLinkEffectBCMsg::kMute); BCMsg->SetLinkFlag(plLinkEffectBCMsg::kMute);

4
Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp

@ -270,8 +270,8 @@ void plNCAgeJoiner::ExecNextOp () {
avatarName = "Male"; avatarName = "Male";
else else
avatarName = NetCommGetPlayer()->avatarDatasetName; avatarName = NetCommGetPlayer()->avatarDatasetName;
const char * linkInName = plNetLinkingMgr::GetInstance()->GetAgeLink()->SpawnPoint().GetName(); plString linkInName = plNetLinkingMgr::GetInstance()->GetAgeLink()->SpawnPoint().GetName();
am->LoadPlayer( avatarName, nil, linkInName ); am->LoadPlayer( avatarName, nil, linkInName.c_str() );
} }
else { else {
LogMsg(kLogPerf, L"AgeJoiner: Next:kPropagatePlayer"); LogMsg(kLogPerf, L"AgeJoiner: Next:kPropagatePlayer");

13
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp

@ -624,7 +624,7 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
// discard the state if object not found in dataset. // discard the state if object not found in dataset.
hsLogEntry( DebugMsg( "Failed to find object %s in dataset. Discarding pending state '%s'", hsLogEntry( DebugMsg( "Failed to find object %s in dataset. Discarding pending state '%s'",
tmpUoid.StringIze().c_str(), tmpUoid.StringIze().c_str(),
pl->fSDRec->GetDescriptor()->GetName() ) ); pl->fSDRec->GetDescriptor()->GetName().c_str() ) );
delete pl; delete pl;
it = fPendingLoads.erase(it); it = fPendingLoads.erase(it);
continue; continue;
@ -645,9 +645,10 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
#ifdef HS_DEBUGGING #ifdef HS_DEBUGGING
if (plNetObjectDebugger::GetInstance()->IsDebugObject(so)) if (plNetObjectDebugger::GetInstance()->IsDebugObject(so))
{ {
hsLogEntry( DebugMsg( "Delivering SDL state %s:%s", pl->fKey->GetName().c_str(), pl->fSDRec->GetDescriptor()->GetName() ) ); hsLogEntry( DebugMsg( "Delivering SDL state %s:%s", pl->fKey->GetName().c_str(),
// hsLogEntry(plNetObjectDebugger::GetInstance()->LogMsg(xtl::format("Dispatching SDL state, type %s to object:%s, locallyOwned=%d, st=%.3f rt=%.3f", pl->fSDRec->GetDescriptor()->GetName().c_str() ) );
// pl->fSDRec->GetDescriptor()->GetName(), pl->fKey->GetName(), // hsLogEntry(plNetObjectDebugger::GetInstance()->LogMsg(plString::Format("Dispatching SDL state, type %s to object:%s, locallyOwned=%d, st=%.3f rt=%.3f",
// pl->fSDRec->GetDescriptor()->GetName().c_str(), pl->fKey->GetName().c_str(),
// so->IsLocallyOwned()==plSynchedObject::kYes, secs, hsTimer::GetSeconds()).c_str())); // so->IsLocallyOwned()==plSynchedObject::kYes, secs, hsTimer::GetSeconds()).c_str()));
// hsLogEntry( pl->fSDRec->DumpToObjectDebugger( "Delivering SDL state", false, 0 ) ); // hsLogEntry( pl->fSDRec->DumpToObjectDebugger( "Delivering SDL state", false, 0 ) );
} }
@ -671,7 +672,7 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
// for around 5 minutes and its time to go // for around 5 minutes and its time to go
WarningMsg( "Pending state '%s' for object [uoid:%s,key:%s] has been queued for about %f secs. Removing...", WarningMsg( "Pending state '%s' for object [uoid:%s,key:%s] has been queued for about %f secs. Removing...",
pl->fSDRec && pl->fSDRec->GetDescriptor() ? pl->fSDRec->GetDescriptor()->GetName() : "?", pl->fSDRec && pl->fSDRec->GetDescriptor() ? pl->fSDRec->GetDescriptor()->GetName().c_str() : "?",
pl->fUoid.StringIze().c_str(), pl->fKey ? pl->fKey->GetUoid().StringIze().c_str() : "?", pl->fUoid.StringIze().c_str(), pl->fKey ? pl->fKey->GetUoid().StringIze().c_str() : "?",
( rawSecs - pl->fQueuedTime ) * pl->fQueueTimeResets); ( rawSecs - pl->fQueuedTime ) * pl->fQueueTimeResets);
@ -681,7 +682,7 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
} }
WarningMsg( "Pending state '%s' for object [uoid:%s,key:%s] has been queued for about %f secs. %s", WarningMsg( "Pending state '%s' for object [uoid:%s,key:%s] has been queued for about %f secs. %s",
pl->fSDRec && pl->fSDRec->GetDescriptor() ? pl->fSDRec->GetDescriptor()->GetName() : "?", pl->fSDRec && pl->fSDRec->GetDescriptor() ? pl->fSDRec->GetDescriptor()->GetName().c_str() : "?",
pl->fUoid.StringIze().c_str(), pl->fKey ? pl->fKey->GetUoid().StringIze().c_str() : "?", pl->fUoid.StringIze().c_str(), pl->fKey ? pl->fKey->GetUoid().StringIze().c_str() : "?",
( rawSecs - pl->fQueuedTime ) * pl->fQueueTimeResets, ( rawSecs - pl->fQueuedTime ) * pl->fQueueTimeResets,
so ? "(not loaded)" : "(not final)" ); so ? "(not loaded)" : "(not final)" );

8
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.cpp

@ -236,12 +236,12 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgSDLState)
// extract stateDataRecord from msg // extract stateDataRecord from msg
hsReadOnlyStream stream(m->StreamInfo()->GetStreamLen(), m->StreamInfo()->GetStreamBuf()); hsReadOnlyStream stream(m->StreamInfo()->GetStreamLen(), m->StreamInfo()->GetStreamBuf());
char* descName = nil; plString descName;
int ver; int ver;
plStateDataRecord::ReadStreamHeader(&stream, &descName, &ver); plStateDataRecord::ReadStreamHeader(&stream, &descName, &ver);
plStateDescriptor* des = plSDLMgr::GetInstance()->FindDescriptor(descName, ver); plStateDescriptor* des = plSDLMgr::GetInstance()->FindDescriptor(descName, ver);
if (stricmp(descName, kSDLAvatarPhysical) == 0) if (descName.CompareI(kSDLAvatarPhysical) == 0)
rwFlags |= plSDL::kKeepDirty; rwFlags |= plSDL::kKeepDirty;
// //
@ -287,13 +287,11 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgSDLState)
// queue up state // queue up state
nc->fPendingLoads.push_back(pl); nc->fPendingLoads.push_back(pl);
hsLogEntry( nc->DebugMsg( "Added pending SDL delivery for %s:%s", hsLogEntry( nc->DebugMsg( "Added pending SDL delivery for %s:%s",
m->ObjectInfo()->GetObjectName().c_str(), des->GetName() ) ); m->ObjectInfo()->GetObjectName().c_str(), des->GetName().c_str() ) );
} }
else else
delete sdRec; delete sdRec;
delete [] descName; // We've only used descName for a lookup (via SDR, and some error strings. Must delete now.
return hsOK; return hsOK;
} }

2
Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

@ -427,7 +427,7 @@ void plNetLinkingMgr::IDoLink(plLinkToAgeMsg* msg)
); );
StrCopy( StrCopy(
joinAgeOp->age.spawnPtName, joinAgeOp->age.spawnPtName,
GetAgeLink()->SpawnPoint().GetName(), GetAgeLink()->SpawnPoint().GetName().c_str(),
arrsize(joinAgeOp->age.spawnPtName) arrsize(joinAgeOp->age.spawnPtName)
); );
QueueOp(joinAgeOp); QueueOp(joinAgeOp);

9
Sources/Plasma/PubUtilLib/plNetClientRecorder/plNetClientStatsRecorder.cpp

@ -129,11 +129,11 @@ void plNetClientStatsRecorder::ILogMsg(plNetMessage* msg, const char* preText)
else if (plNetMsgSDLState* sdlMsg = plNetMsgSDLState::ConvertNoRef(msg)) else if (plNetMsgSDLState* sdlMsg = plNetMsgSDLState::ConvertNoRef(msg))
{ {
hsReadOnlyStream stream(sdlMsg->StreamInfo()->GetStreamLen(), sdlMsg->StreamInfo()->GetStreamBuf()); hsReadOnlyStream stream(sdlMsg->StreamInfo()->GetStreamLen(), sdlMsg->StreamInfo()->GetStreamBuf());
char* descName=nil; plString descName;
int ver; int ver;
if (plStateDataRecord::ReadStreamHeader(&stream, &descName, &ver)) if (plStateDataRecord::ReadStreamHeader(&stream, &descName, &ver))
{ {
fLog->AddLineF("%s%s(%s)", preText, msg->ClassName(), descName); fLog->AddLineF("%s%s(%s)", preText, msg->ClassName(), descName.c_str());
int i; int i;
@ -143,17 +143,16 @@ void plNetClientStatsRecorder::ILogMsg(plNetMessage* msg, const char* preText)
sdRec.GetDirtyVars(&vars); sdRec.GetDirtyVars(&vars);
for (i = 0; i < vars.size(); i++) for (i = 0; i < vars.size(); i++)
{ {
fLog->AddLineF("\t%s", vars[i]->GetVarDescriptor()->GetName()); fLog->AddLineF("\t%s", vars[i]->GetVarDescriptor()->GetName().c_str());
} }
plStateDataRecord::SDVarsList sdVars; plStateDataRecord::SDVarsList sdVars;
sdRec.GetDirtySDVars(&sdVars); sdRec.GetDirtySDVars(&sdVars);
for (i = 0; i < sdVars.size(); i++) for (i = 0; i < sdVars.size(); i++)
{ {
fLog->AddLineF("\t%s", sdVars[i]->GetSDVarDescriptor()->GetName()); fLog->AddLineF("\t%s", sdVars[i]->GetSDVarDescriptor()->GetName().c_str());
} }
} }
delete [] descName;
} }
else else
fLog->AddLineF("%s%s", preText, msg->ClassName()); fLog->AddLineF("%s%s", preText, msg->ClassName());

9
Sources/Plasma/PubUtilLib/plNetClientRecorder/plNetClientStreamRecorder.cpp

@ -334,11 +334,11 @@ void plNetClientStreamRecorder::ILogMsg(plNetMessage* msg, const char* preText)
else if (plNetMsgSDLState* sdlMsg = plNetMsgSDLState::ConvertNoRef(msg)) else if (plNetMsgSDLState* sdlMsg = plNetMsgSDLState::ConvertNoRef(msg))
{ {
hsReadOnlyStream stream(sdlMsg->StreamInfo()->GetStreamLen(), sdlMsg->StreamInfo()->GetStreamBuf()); hsReadOnlyStream stream(sdlMsg->StreamInfo()->GetStreamLen(), sdlMsg->StreamInfo()->GetStreamBuf());
char* descName=nil; plString descName;
int ver; int ver;
if (plStateDataRecord::ReadStreamHeader(&stream, &descName, &ver)) if (plStateDataRecord::ReadStreamHeader(&stream, &descName, &ver))
{ {
fLog->AddLineF("%s%s(%s)", preText, msg->ClassName(), descName); fLog->AddLineF("%s%s(%s)", preText, msg->ClassName(), descName.c_str());
int i; int i;
@ -348,17 +348,16 @@ void plNetClientStreamRecorder::ILogMsg(plNetMessage* msg, const char* preText)
sdRec.GetDirtyVars(&vars); sdRec.GetDirtyVars(&vars);
for (i = 0; i < vars.size(); i++) for (i = 0; i < vars.size(); i++)
{ {
fLog->AddLineF("\t%s", vars[i]->GetVarDescriptor()->GetName()); fLog->AddLineF("\t%s", vars[i]->GetVarDescriptor()->GetName().c_str());
} }
plStateDataRecord::SDVarsList sdVars; plStateDataRecord::SDVarsList sdVars;
sdRec.GetDirtySDVars(&sdVars); sdRec.GetDirtySDVars(&sdVars);
for (i = 0; i < sdVars.size(); i++) for (i = 0; i < sdVars.size(); i++)
{ {
fLog->AddLineF("\t%s", sdVars[i]->GetSDVarDescriptor()->GetName()); fLog->AddLineF("\t%s", sdVars[i]->GetSDVarDescriptor()->GetName().c_str());
} }
} }
delete [] descName;
} }
else else
fLog->AddLineF("%s%s", preText, msg->ClassName()); fLog->AddLineF("%s%s", preText, msg->ClassName());

10
Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.cpp

@ -387,14 +387,14 @@ void plAgeLinkStruct::Read( hsStream * s, hsResMgr* m)
s->LogReadLE( &fLinkingRules ,"LinkingRules"); s->LogReadLE( &fLinkingRules ,"LinkingRules");
if ( IsFlagSet( kHasSpawnPt_DEAD ) ) if ( IsFlagSet( kHasSpawnPt_DEAD ) )
{ {
std::string str; plString str;
s->LogSubStreamPushDesc("SpawnPt_DEAD"); s->LogSubStreamPushDesc("SpawnPt_DEAD");
plMsgStdStringHelper::Peek(str,s); plMsgStdStringHelper::Peek(str,s);
fSpawnPoint.SetName( str.c_str() ); fSpawnPoint.SetName( str );
if ( strcmp( fSpawnPoint.GetName(), kDefaultSpawnPtName )==0 ) if ( fSpawnPoint.GetName() == kDefaultSpawnPtName )
fSpawnPoint.SetTitle( kDefaultSpawnPtTitle ); fSpawnPoint.SetTitle( kDefaultSpawnPtTitle );
else else
fSpawnPoint.SetTitle( str.c_str() ); fSpawnPoint.SetTitle( str );
ClearFlag( kHasSpawnPt_DEAD ); ClearFlag( kHasSpawnPt_DEAD );
SetFlag( kHasSpawnPt ); SetFlag( kHasSpawnPt );
} }
@ -520,7 +520,7 @@ plString plAgeLinkStruct::AsString() const
{ {
ss << spacer ss << spacer
<< "Spwn:" << "Spwn:"
<< fSpawnPoint.AsStdString().c_str(); << fSpawnPoint.AsString();
spacer = kComma; spacer = kComma;
} }
if (HasAmCCR()) if (HasAmCCR())

10
Sources/Plasma/PubUtilLib/plNetCommon/plSpawnPointInfo.cpp

@ -120,10 +120,10 @@ void plSpawnPointInfo::Reset()
(*this)=kDefaultSpawnPoint; (*this)=kDefaultSpawnPoint;
} }
std::string plSpawnPointInfo::AsStdString() const plString plSpawnPointInfo::AsString() const
{ {
return xtl::format( "t:%s,n:%s,c:%s", return plString::Format( "t:%s,n:%s,c:%s",
fTitle.size()?fTitle.c_str():"(nil)", fTitle.c_str("(nil)"),
fSpawnPt.size()?fSpawnPt.c_str():"(nil)", fSpawnPt.c_str("(nil)"),
fCameraStack.size()?fCameraStack.c_str():"(nil)" ); fCameraStack.c_str("(nil)") );
} }

23
Sources/Plasma/PubUtilLib/plNetCommon/plSpawnPointInfo.h

@ -43,6 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plSpawnPointInfo_h_inc #define plSpawnPointInfo_h_inc
#include "hsStlUtils.h" #include "hsStlUtils.h"
#include "plString.h"
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
@ -55,24 +56,24 @@ class hsStream;
struct plSpawnPointInfo struct plSpawnPointInfo
{ {
std::string fTitle; // friendly title for GUIs plString fTitle; // friendly title for GUIs
std::string fSpawnPt; // name of spawn point in dataset plString fSpawnPt; // name of spawn point in dataset
std::string fCameraStack; plString fCameraStack;
plSpawnPointInfo(){} plSpawnPointInfo(){}
plSpawnPointInfo( const plSpawnPointInfo & other ) { (*this)=other; } plSpawnPointInfo( const plSpawnPointInfo & other ) { (*this)=other; }
plSpawnPointInfo( const char * title, const char * spawnPt ) plSpawnPointInfo( const plString & title, const plString & spawnPt )
: fTitle( title ), fSpawnPt( spawnPt ) {} : fTitle( title ), fSpawnPt( spawnPt ) {}
const char * GetTitle() const { return fTitle.c_str(); } plString GetTitle() const { return fTitle; }
void SetTitle( const char * v ) { fTitle=v; } void SetTitle( const plString & v ) { fTitle=v; }
const char * GetName() const { return fSpawnPt.c_str(); } plString GetName() const { return fSpawnPt; }
void SetName( const char * v ) { fSpawnPt = v; } void SetName( const plString & v ) { fSpawnPt = v; }
const char * GetCameraStack() const { return fCameraStack.c_str(); } plString GetCameraStack() const { return fCameraStack; }
void SetCameraStack( const char * v ) { fCameraStack=v; } void SetCameraStack( const plString & v ) { fCameraStack=v; }
void Reset(); void Reset();
void Read( hsStream * s ); void Read( hsStream * s );
void ReadOld( hsStream * s ); void ReadOld( hsStream * s );
void Write( hsStream * s ) const; void Write( hsStream * s ) const;
std::string AsStdString() const; plString AsString() const;
}; };
typedef std::vector<plSpawnPointInfo> plSpawnPointVec; typedef std::vector<plSpawnPointInfo> plSpawnPointVec;

34
Sources/Plasma/PubUtilLib/plSDL/plSDL.h

@ -107,10 +107,10 @@ namespace plSDL
class plStateVarNotificationInfo class plStateVarNotificationInfo
{ {
private: private:
std::string fHintString; plString fHintString;
public: public:
void SetHintString(const char* c) { fHintString=c; } void SetHintString(const plString& c) { fHintString=c; }
const char* GetHintString() const { return fHintString.c_str(); } plString GetHintString() const { return fHintString; }
void Read(hsStream* s, uint32_t readOptions); void Read(hsStream* s, uint32_t readOptions);
void Write(hsStream* s, uint32_t writeOptions) const; void Write(hsStream* s, uint32_t writeOptions) const;
@ -137,8 +137,8 @@ public:
plStateVariable() : fFlags(0) {} plStateVariable() : fFlags(0) {}
virtual ~plStateVariable() {} virtual ~plStateVariable() {}
const char* GetName() const { return GetVarDescriptor()->GetName(); } plString GetName() const { return GetVarDescriptor()->GetName(); }
bool IsNamed(const char* n) const { return (n && !stricmp(GetName(), n)); } bool IsNamed(const char* n) const { return (n && !GetName().CompareI(n)); }
virtual int GetCount() const = 0; virtual int GetCount() const = 0;
// conversion ops // conversion ops
@ -193,7 +193,7 @@ public:
int RemoveNotificationKey(plKey k); // returns number of keys left after removal int RemoveNotificationKey(plKey k); // returns number of keys left after removal
int RemoveNotificationKeys(KeyList keys); // returns number of keys left after removal int RemoveNotificationKeys(KeyList keys); // returns number of keys left after removal
void SendNotificationMsg(const plSimpleStateVariable* srcVar, const plSimpleStateVariable* dstVar, const char* sdlName); void SendNotificationMsg(const plSimpleStateVariable* srcVar, const plSimpleStateVariable* dstVar, const plString& sdlName);
bool GetValue(float* i) const; bool GetValue(float* i) const;
bool SetValue(float i); bool SetValue(float i);
@ -266,8 +266,8 @@ public:
void TimeStamp( const plUnifiedTime & ut=plUnifiedTime::GetCurrentTime() ); void TimeStamp( const plUnifiedTime & ut=plUnifiedTime::GetCurrentTime() );
void CopyFrom(plVarDescriptor* v); void CopyFrom(plVarDescriptor* v);
void CopyData(const plSimpleStateVariable* other, uint32_t writeOptions=0); void CopyData(const plSimpleStateVariable* other, uint32_t writeOptions=0);
bool SetFromString(const char* value, int idx, bool timeStampNow); // set value from string, type. return false on err bool SetFromString(const plString& value, int idx, bool timeStampNow); // set value from string, type. return false on err
char* GetAsString(int idx) const; plString GetAsString(int idx) const;
bool ConvertTo(plSimpleVarDescriptor* toVar, bool force=false); // return false on err bool ConvertTo(plSimpleVarDescriptor* toVar, bool force=false); // return false on err
void Alloc(int cnt=-1 /* -1 means don't change count */); // alloc memory after setting type void Alloc(int cnt=-1 /* -1 means don't change count */); // alloc memory after setting type
void Reset(); void Reset();
@ -315,7 +315,7 @@ public:
void AddStateChangeNotification(plStateChangeNotifier& n); void AddStateChangeNotification(plStateChangeNotifier& n);
void RemoveStateChangeNotification(plKey notificationObj); // remove all with this key void RemoveStateChangeNotification(plKey notificationObj); // remove all with this key
void RemoveStateChangeNotification(plStateChangeNotifier n); // remove ones which match void RemoveStateChangeNotification(plStateChangeNotifier n); // remove ones which match
void NotifyStateChange(const plSimpleStateVariable* other, const char* sdlName); // send notification msg if necessary, internal use void NotifyStateChange(const plSimpleStateVariable* other, const plString& sdlName); // send notification msg if necessary, internal use
void DumpToObjectDebugger(bool dirtyOnly, int level) const; void DumpToObjectDebugger(bool dirtyOnly, int level) const;
void DumpToStream(hsStream* stream, bool dirtyOnly, int level) const; void DumpToStream(hsStream* stream, bool dirtyOnly, int level) const;
@ -411,14 +411,14 @@ protected:
static const uint8_t kIOVersion; // I/O Version static const uint8_t kIOVersion; // I/O Version
void IDeleteVarsList(VarsList& vars); void IDeleteVarsList(VarsList& vars);
void IInitDescriptor(const char* name, int version); // or plSDL::kLatestVersion void IInitDescriptor(const plString& name, int version); // or plSDL::kLatestVersion
void IInitDescriptor(const plStateDescriptor* sd); void IInitDescriptor(const plStateDescriptor* sd);
void IReadHeader(hsStream* s); void IReadHeader(hsStream* s);
void IWriteHeader(hsStream* s) const; void IWriteHeader(hsStream* s) const;
bool IConvertVar(plSimpleStateVariable* fromVar, plSimpleStateVariable* toVar, bool force); bool IConvertVar(plSimpleStateVariable* fromVar, plSimpleStateVariable* toVar, bool force);
plStateVariable* IFindVar(const VarsList& vars, const char* name) const; plStateVariable* IFindVar(const VarsList& vars, const plString& name) const;
int IGetNumUsedVars(const VarsList& vars) const; int IGetNumUsedVars(const VarsList& vars) const;
int IGetUsedVars(const VarsList& varsOut, VarsList *varsIn) const; // build a list of vars that have data int IGetUsedVars(const VarsList& varsOut, VarsList *varsIn) const; // build a list of vars that have data
bool IHasUsedVars(const VarsList& vars) const; bool IHasUsedVars(const VarsList& vars) const;
@ -430,7 +430,7 @@ public:
CLASSNAME_REGISTER( plStateDataRecord ); CLASSNAME_REGISTER( plStateDataRecord );
GETINTERFACE_ANY( plStateDataRecord, plCreatable); GETINTERFACE_ANY( plStateDataRecord, plCreatable);
plStateDataRecord(const char* sdName, int version=plSDL::kLatestVersion); plStateDataRecord(const plString& sdName, int version=plSDL::kLatestVersion);
plStateDataRecord(plStateDescriptor* sd); plStateDataRecord(plStateDescriptor* sd);
plStateDataRecord(const plStateDataRecord &other, uint32_t writeOptions=0 ):fFlags(0) { CopyFrom(other, writeOptions); } plStateDataRecord(const plStateDataRecord &other, uint32_t writeOptions=0 ):fFlags(0) { CopyFrom(other, writeOptions); }
plStateDataRecord():fFlags(0) {} plStateDataRecord():fFlags(0) {}
@ -442,8 +442,8 @@ public:
uint32_t GetFlags() const { return fFlags; } uint32_t GetFlags() const { return fFlags; }
void SetFlags(uint32_t f) { fFlags =f; } void SetFlags(uint32_t f) { fFlags =f; }
plSimpleStateVariable* FindVar(const char* name) const { return (plSimpleStateVariable*)IFindVar(fVarsList, name); } plSimpleStateVariable* FindVar(const plString& name) const { return (plSimpleStateVariable*)IFindVar(fVarsList, name); }
plSDStateVariable* FindSDVar(const char* name) const { return (plSDStateVariable*)IFindVar(fSDVarsList, name); } plSDStateVariable* FindSDVar(const plString& name) const { return (plSDStateVariable*)IFindVar(fSDVarsList, name); }
plStateDataRecord& operator=(const plStateDataRecord& other) { CopyFrom(other); return *this; } plStateDataRecord& operator=(const plStateDataRecord& other) { CopyFrom(other); return *this; }
void CopyFrom(const plStateDataRecord& other, uint32_t writeOptions=0); void CopyFrom(const plStateDataRecord& other, uint32_t writeOptions=0);
@ -479,7 +479,7 @@ public:
bool HasDirtySDVars() const { return IHasDirtyVars(fSDVarsList); } bool HasDirtySDVars() const { return IHasDirtyVars(fSDVarsList); }
const plStateDescriptor* GetDescriptor() const { return fDescriptor; } const plStateDescriptor* GetDescriptor() const { return fDescriptor; }
void SetDescriptor(const char* sdName, int version); void SetDescriptor(const plString& sdName, int version);
plNetMsgSDLState* PrepNetMsg(float timeConvert, uint32_t writeOptions) const; // create/prep a net msg with this data plNetMsgSDLState* PrepNetMsg(float timeConvert, uint32_t writeOptions) const; // create/prep a net msg with this data
@ -498,7 +498,7 @@ public:
bool Read(hsStream* s, float timeConvert, uint32_t readOptions=0); bool Read(hsStream* s, float timeConvert, uint32_t readOptions=0);
void Write(hsStream* s, float timeConvert, uint32_t writeOptions=0) const; void Write(hsStream* s, float timeConvert, uint32_t writeOptions=0) const;
static bool ReadStreamHeader(hsStream* s, char** name, int* version, plUoid* objUoid=nil); static bool ReadStreamHeader(hsStream* s, plString* name, int* version, plUoid* objUoid=nil);
void WriteStreamHeader(hsStream* s, plUoid* objUoid=nil) const; void WriteStreamHeader(hsStream* s, plUoid* objUoid=nil) const;
}; };
@ -543,7 +543,7 @@ public:
~plSDLMgr(); ~plSDLMgr();
static plSDLMgr* GetInstance(); static plSDLMgr* GetInstance();
plStateDescriptor* FindDescriptor(const char* name, int version, const plSDL::DescriptorList * dl=nil) const; // version or kLatestVersion plStateDescriptor* FindDescriptor(const plString& name, int version, const plSDL::DescriptorList * dl=nil) const; // version or kLatestVersion
const plSDL::DescriptorList * GetDescriptors( void ) const { return &fDescriptors;} const plSDL::DescriptorList * GetDescriptors( void ) const { return &fDescriptors;}

41
Sources/Plasma/PubUtilLib/plSDL/plSDLDescriptor.h

@ -50,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h" #include "hsStlUtils.h"
#include "plString.h"
// //
// Describes a variable in a state descriptor. // Describes a variable in a state descriptor.
@ -99,16 +100,16 @@ public:
}; };
protected: protected:
static const uint8_t kVersion; // for Read/Write format static const uint8_t kVersion; // for Read/Write format
char* fDefault; // set by .sdl plString fDefault; // set by .sdl
char* fName; // set by .sdl plString fName; // set by .sdl
int fCount; // set by .sdl int fCount; // set by .sdl
Type fType; // set by .sdl Type fType; // set by .sdl
char* fTypeString; // string version of fType plString fTypeString; // string version of fType
uint32_t fFlags; uint32_t fFlags;
std::string fDisplayOptions; // set by .sdl plString fDisplayOptions; // set by .sdl
public: public:
plVarDescriptor(); plVarDescriptor() : fCount(1), fType(kNone), fFlags(0) { }
virtual ~plVarDescriptor(); virtual ~plVarDescriptor() { }
virtual void CopyFrom(const plVarDescriptor* v); virtual void CopyFrom(const plVarDescriptor* v);
@ -119,26 +120,26 @@ public:
virtual const plSDVarDescriptor* GetAsSDVarDescriptor() const = 0; virtual const plSDVarDescriptor* GetAsSDVarDescriptor() const = 0;
// getters // getters
const char* GetDefault() const { return fDefault; } plString GetDefault() const { return fDefault; }
const char* GetName() const { return fName; } plString GetName() const { return fName; }
Type GetType() const { return fType; } Type GetType() const { return fType; }
const char* GetTypeString() const { return fTypeString; } plString GetTypeString() const { return fTypeString; }
int GetCount() const { return fCount; } int GetCount() const { return fCount; }
bool IsInternal() const { return (fFlags & kInternal) != 0; } bool IsInternal() const { return (fFlags & kInternal) != 0; }
bool IsAlwaysNew() const { return (fFlags & kAlwaysNew) != 0; } bool IsAlwaysNew() const { return (fFlags & kAlwaysNew) != 0; }
bool IsVariableLength() const { return (fFlags & kVariableLength) != 0; } bool IsVariableLength() const { return (fFlags & kVariableLength) != 0; }
const char* GetDisplayOptions() const { return fDisplayOptions.c_str(); } plString GetDisplayOptions() const { return fDisplayOptions; }
// setters // setters
void SetDefault(const char* n) { delete [] fDefault; fDefault= hsStrcpy(n); } void SetDefault(const plString& n) { fDefault = n; }
void SetName(const char* n) { delete [] fName; fName = hsStrcpy(n); } void SetName(const plString& n) { fName = n; }
void SetCount(int c) { fCount=c; } void SetCount(int c) { fCount=c; }
virtual bool SetType(const char* type); virtual bool SetType(const plString& type);
void SetType(Type t) { fType=t; } void SetType(Type t) { fType=t; }
void SetInternal(bool d) { if (d) fFlags |= kInternal; else fFlags &= ~kInternal; } void SetInternal(bool d) { if (d) fFlags |= kInternal; else fFlags &= ~kInternal; }
void SetAlwaysNew(bool d) { if (d) fFlags |= kAlwaysNew; else fFlags &= ~kAlwaysNew; } void SetAlwaysNew(bool d) { if (d) fFlags |= kAlwaysNew; else fFlags &= ~kAlwaysNew; }
void SetVariableLength(bool d) { if (d) fFlags |= kVariableLength; else fFlags &= ~kVariableLength; } void SetVariableLength(bool d) { if (d) fFlags |= kVariableLength; else fFlags &= ~kVariableLength; }
void SetDisplayOptions(const char* s) { fDisplayOptions=s; } void SetDisplayOptions(const plString& s) { fDisplayOptions=s; }
// IO // IO
virtual bool Read(hsStream* s); virtual bool Read(hsStream* s);
@ -173,7 +174,7 @@ public:
int GetAtomicCount() const { return fAtomicCount; } int GetAtomicCount() const { return fAtomicCount; }
// setters // setters
bool SetType(const char* type); bool SetType(const plString& type);
void SetType(Type t) { plVarDescriptor::SetType(t); } // for lame compiler void SetType(Type t) { plVarDescriptor::SetType(t); } // for lame compiler
void SetAtomicType(Type t) { fAtomicType=t; } void SetAtomicType(Type t) { fAtomicType=t; }
@ -225,16 +226,16 @@ private:
typedef std::vector<plVarDescriptor*> VarsList; typedef std::vector<plVarDescriptor*> VarsList;
VarsList fVarsList; VarsList fVarsList;
int fVersion; int fVersion;
char* fName; plString fName;
std::string fFilename; // the filename this descriptor was read from std::string fFilename; // the filename this descriptor was read from
void IDeInit(); void IDeInit();
public: public:
plStateDescriptor() : fVersion(-1),fName(nil) {} plStateDescriptor() : fVersion(-1) {}
~plStateDescriptor(); ~plStateDescriptor();
// getters // getters
const char* GetName() const { return fName; } plString GetName() const { return fName; }
int GetNumVars() const { return fVarsList.size(); } int GetNumVars() const { return fVarsList.size(); }
plVarDescriptor* GetVar(int i) const { return fVarsList[i]; } plVarDescriptor* GetVar(int i) const { return fVarsList[i]; }
int GetVersion() const { return fVersion; } int GetVersion() const { return fVersion; }
@ -242,11 +243,11 @@ public:
// setters // setters
void SetVersion(int v) { fVersion=v; } void SetVersion(int v) { fVersion=v; }
void SetName(const char* n) { delete [] fName; fName=hsStrcpy(n); } void SetName(const plString& n) { fName=n; }
void AddVar(plVarDescriptor* v) { fVarsList.push_back(v); } void AddVar(plVarDescriptor* v) { fVarsList.push_back(v); }
void SetFilename( const char * n ) { fFilename=n;} void SetFilename( const char * n ) { fFilename=n;}
plVarDescriptor* FindVar(const char* name, int* idx=nil) const; plVarDescriptor* FindVar(const plString& name, int* idx=nil) const;
// IO // IO
bool Read(hsStream* s); bool Read(hsStream* s);

6
Sources/Plasma/PubUtilLib/plSDL/plSDLMgr.cpp

@ -101,9 +101,9 @@ plSDLMgr* plSDLMgr::GetInstance()
// search latest and legacy descriptors for one that matches. // search latest and legacy descriptors for one that matches.
// if version is -1, search for latest descriptor with matching name // if version is -1, search for latest descriptor with matching name
// //
plStateDescriptor* plSDLMgr::FindDescriptor(const char* name, int version, const plSDL::DescriptorList * dl) const plStateDescriptor* plSDLMgr::FindDescriptor(const plString& name, int version, const plSDL::DescriptorList * dl) const
{ {
if (!name) if (name.IsNull())
return nil; return nil;
if ( !dl ) if ( !dl )
@ -116,7 +116,7 @@ plStateDescriptor* plSDLMgr::FindDescriptor(const char* name, int version, const
int highestFound = -1; int highestFound = -1;
for(it=(*dl).begin(); it!= (*dl).end(); it++) for(it=(*dl).begin(); it!= (*dl).end(); it++)
{ {
if (!stricmp((*it)->GetName(), name) ) if (!(*it)->GetName().CompareI(name) )
{ {
if ( (*it)->GetVersion()==version ) if ( (*it)->GetVersion()==version )
{ {

58
Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp

@ -162,12 +162,12 @@ bool plSDLParser::IParseStateDesc(const char* fileName, hsStream* stream, char t
bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char token[], plStateDescriptor*& curDesc, bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char token[], plStateDescriptor*& curDesc,
plVarDescriptor*& curVar) const plVarDescriptor*& curVar) const
{ {
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 ( !curDesc ) if ( !curDesc )
return false; return false;
bool skipNext=false; bool skipNext=false;
std::string dbgStr; plString dbgStr;
static char seps[] = "( ,)[]"; static char seps[] = "( ,)[]";
// read type, name, cnt, [default] // read type, name, cnt, [default]
@ -180,7 +180,7 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
// nested sdls // nested sdls
char* sdlName = token+1; char* sdlName = token+1;
plStateDescriptor* stateDesc = plSDLMgr::GetInstance()->FindDescriptor(sdlName, plSDL::kLatestVersion); plStateDescriptor* stateDesc = plSDLMgr::GetInstance()->FindDescriptor(sdlName, plSDL::kLatestVersion);
hsAssert(stateDesc, xtl::format("can't find nested state desc reference %s, fileName=%s", hsAssert(stateDesc, plString::Format("can't find nested state desc reference %s, fileName=%s",
sdlName, fileName).c_str()); sdlName, fileName).c_str());
curVar = new plSDVarDescriptor(stateDesc); curVar = new plSDVarDescriptor(stateDesc);
} }
@ -189,19 +189,19 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
curDesc->AddVar(curVar); curDesc->AddVar(curVar);
bool ok=curVar->SetType(token); bool ok=curVar->SetType(token);
hsAssert(ok, xtl::format("Variable 'type' syntax problem with .sdl file, type=%s, fileName=%s", token, fileName).c_str()); hsAssert(ok, plString::Format("Variable 'type' syntax problem with .sdl file, type=%s, fileName=%s", token, fileName).c_str());
dbgStr = xtl::format("\tVAR Type=%s ", token).c_str(); dbgStr = plString::Format("\tVAR Type=%s ", token);
// //
// NAME (foo[1]) // NAME (foo[1])
// //
if (stream->GetToken(token, kTokenLen)) if (stream->GetToken(token, kTokenLen))
{ {
hsAssert(strstr(token, "[") && strstr(token, "]"), xtl::format("invalid var syntax, missing [x], fileName=%s", hsAssert(strstr(token, "[") && strstr(token, "]"), plString::Format("invalid var syntax, missing [x], fileName=%s",
fileName).c_str()); fileName).c_str());
char* ptr = strtok( token, seps ); // skip [ char* ptr = strtok( token, seps ); // skip [
hsAssert(curVar, xtl::format("Missing current var. Syntax problem with .sdl file, fileName=%s", fileName).c_str()); hsAssert(curVar, plString::Format("Missing current var. Syntax problem with .sdl file, fileName=%s", fileName).c_str());
curVar->SetName(token); curVar->SetName(token);
// //
// COUNT // COUNT
@ -211,7 +211,7 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
curVar->SetCount(cnt); curVar->SetCount(cnt);
if (cnt==0) if (cnt==0)
curVar->SetVariableLength(true); curVar->SetVariableLength(true);
dbgStr += xtl::format("Name=%s[%d]", curVar->GetName(), cnt).c_str(); dbgStr += plString::Format("Name=%s[%d]", curVar->GetName().c_str(), cnt);
} }
// //
@ -221,10 +221,10 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
{ {
if (!strcmp(token, "DEFAULT")) if (!strcmp(token, "DEFAULT"))
{ {
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str()); hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
// read state var type // read state var type
std::string defaultStr; plString defaultStr;
plSimpleVarDescriptor* sVar=(plSimpleVarDescriptor*)curVar; plSimpleVarDescriptor* sVar=(plSimpleVarDescriptor*)curVar;
if (sVar) if (sVar)
{ {
@ -239,51 +239,51 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
} }
} }
} }
if (defaultStr.size()) if (!defaultStr.IsEmpty())
{ {
curVar->SetDefault(defaultStr.c_str()); curVar->SetDefault(defaultStr);
dbgStr += std::string(" DEFAULT=") + defaultStr; dbgStr += " DEFAULT=" + defaultStr;
} }
} }
else else
if (!strcmp(token, "DISPLAYOPTION")) if (!strcmp(token, "DISPLAYOPTION"))
{ {
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str()); hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
dbgStr += std::string(" ") + token; dbgStr += plString(" ") + token;
bool read=stream->GetToken(token, kTokenLen); bool read=stream->GetToken(token, kTokenLen);
if (read) if (read)
{ {
std::string oldOptions=curVar->GetDisplayOptions(); plString oldOptions=curVar->GetDisplayOptions();
if (oldOptions.size()) if (!oldOptions.IsEmpty())
oldOptions += std::string(","); oldOptions += ",";
oldOptions += token; oldOptions += token;
curVar->SetDisplayOptions(oldOptions.c_str()); curVar->SetDisplayOptions(oldOptions);
dbgStr += std::string("=") + token; dbgStr += plString("=") + token;
if (!stricmp(token, "hidden")) if (!stricmp(token, "hidden"))
curVar->SetInternal(true); curVar->SetInternal(true);
} }
else else
{ {
hsAssert(false, xtl::format("missing displayOption string, fileName=%s", fileName).c_str()); hsAssert(false, plString::Format("missing displayOption string, fileName=%s", fileName).c_str());
} }
} }
else else
if (!strcmp(token, "DEFAULTOPTION")) if (!strcmp(token, "DEFAULTOPTION"))
{ {
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str()); hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
dbgStr += std::string(" ") + token; dbgStr += plString(" ") + token;
bool read=stream->GetToken(token, kTokenLen); bool read=stream->GetToken(token, kTokenLen);
if (read) if (read)
{ {
dbgStr += std::string("=") + token; dbgStr += plString("=") + token;
if (!stricmp(token, "vault")) if (!stricmp(token, "vault"))
curVar->SetAlwaysNew(true); curVar->SetAlwaysNew(true);
} }
else else
{ {
hsAssert(false, xtl::format("missing defaultOption string, fileName=%s", fileName).c_str()); hsAssert(false, plString::Format("missing defaultOption string, fileName=%s", fileName).c_str());
} }
} }
@ -291,16 +291,16 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
else else
if (!strcmp(token, "INTERNAL")) if (!strcmp(token, "INTERNAL"))
{ {
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str()); hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
curVar->SetInternal(true); curVar->SetInternal(true);
dbgStr += std::string(" ") + token; dbgStr += plString(" ") + token;
} }
else else
if (!strcmp(token, "PHASED")) if (!strcmp(token, "PHASED"))
{ {
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str()); hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
curVar->SetAlwaysNew(true); curVar->SetAlwaysNew(true);
dbgStr += std::string(" ") + token; dbgStr += plString(" ") + token;
} }
#endif #endif
else else

2
Sources/Plasma/PubUtilLib/plSDL/plStateChangeNotifier.cpp

@ -121,7 +121,7 @@ bool plStateChangeNotifier::operator==(const plStateChangeNotifier &other) const
// send notification msg to all registered recipients // send notification msg to all registered recipients
// //
void plStateChangeNotifier::SendNotificationMsg(const plSimpleStateVariable* srcVar, const plSimpleStateVariable* dstVar, void plStateChangeNotifier::SendNotificationMsg(const plSimpleStateVariable* srcVar, const plSimpleStateVariable* dstVar,
const char* sdlName) const plString& sdlName)
{ {
plSDLNotificationMsg* m = new plSDLNotificationMsg; plSDLNotificationMsg* m = new plSDLNotificationMsg;

66
Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp

@ -95,7 +95,7 @@ void plSDL::VariableLengthWrite(hsStream* s, int size, int val)
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// State Data // State Data
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
plStateDataRecord::plStateDataRecord(const char* name, int version) : fFlags(0) plStateDataRecord::plStateDataRecord(const plString& name, int version) : fFlags(0)
, fDescriptor( nil ) , fDescriptor( nil )
{ {
SetDescriptor(name, version); SetDescriptor(name, version);
@ -113,7 +113,7 @@ plStateDataRecord::~plStateDataRecord()
IDeleteVarsList(fSDVarsList); IDeleteVarsList(fSDVarsList);
} }
void plStateDataRecord::SetDescriptor(const char* name, int version) void plStateDataRecord::SetDescriptor(const plString& name, int version)
{ {
IInitDescriptor(name, version); IInitDescriptor(name, version);
} }
@ -125,10 +125,10 @@ void plStateDataRecord::IDeleteVarsList(VarsList& vars)
vars.clear(); vars.clear();
} }
void plStateDataRecord::IInitDescriptor(const char* name, int version) void plStateDataRecord::IInitDescriptor(const plString& name, int version)
{ {
plStateDescriptor* sd = plSDLMgr::GetInstance()->FindDescriptor(name, version); plStateDescriptor* sd = plSDLMgr::GetInstance()->FindDescriptor(name, version);
//hsAssert( sd, xtl::format("Failed to find sdl descriptor: %s,%d. Missing legacy descriptor?", name, version ).c_str() ); //hsAssert( sd, plString::Format("Failed to find sdl descriptor: %s,%d. Missing legacy descriptor?", name.c_str(), version ).c_str() );
if (sd) if (sd)
IInitDescriptor(sd); IInitDescriptor(sd);
} }
@ -268,7 +268,7 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
{ {
if (plSDLMgr::GetInstance()->GetNetApp()) if (plSDLMgr::GetInstance()->GetNetApp())
plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed reading SDL, desc %s", plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed reading SDL, desc %s",
fDescriptor && fDescriptor->GetName() ? fDescriptor->GetName() : "?"); fDescriptor ? fDescriptor->GetName().c_str("?") : "?");
return false; return false;
} }
} }
@ -276,8 +276,8 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
catch(...) catch(...)
{ {
hsAssert( false, hsAssert( false,
xtl::format("Something bad happened while reading simple var data, desc:%s", plString::Format("Something bad happened while reading simple var data, desc:%s",
fDescriptor && fDescriptor->GetName() ? fDescriptor->GetName() : "?").c_str()); fDescriptor ? fDescriptor->GetName().c_str("?") : "?").c_str());
return false; return false;
} }
@ -302,7 +302,7 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
{ {
if (plSDLMgr::GetInstance()->GetNetApp()) if (plSDLMgr::GetInstance()->GetNetApp())
plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed reading nested SDL, desc %s", plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed reading nested SDL, desc %s",
fDescriptor && fDescriptor->GetName() ? fDescriptor->GetName() : "?"); fDescriptor ? fDescriptor->GetName().c_str("?") : "?");
return false; return false;
} }
} }
@ -310,15 +310,15 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
catch(...) catch(...)
{ {
hsAssert( false, hsAssert( false,
xtl::format("Something bad happened while reading nested var data, desc:%s", plString::Format("Something bad happened while reading nested var data, desc:%s",
fDescriptor && fDescriptor->GetName() ? fDescriptor->GetName() : "?").c_str()); fDescriptor ? fDescriptor->GetName().c_str("?") : "?").c_str());
return false; return false;
} }
// convert to latest descriptor // convert to latest descriptor
// Only really need to do this the first time this descriptor is read... // Only really need to do this the first time this descriptor is read...
plStateDescriptor* latestDesc=plSDLMgr::GetInstance()->FindDescriptor(fDescriptor->GetName(), plSDL::kLatestVersion); plStateDescriptor* latestDesc=plSDLMgr::GetInstance()->FindDescriptor(fDescriptor->GetName(), plSDL::kLatestVersion);
hsAssert( latestDesc, xtl::format("Failed to find latest sdl descriptor for: %s", fDescriptor->GetName() ).c_str() ); hsAssert( latestDesc, plString::Format("Failed to find latest sdl descriptor for: %s", fDescriptor->GetName().c_str() ).c_str() );
bool forceConvert = (readOptions&plSDL::kForceConvert)!=0; bool forceConvert = (readOptions&plSDL::kForceConvert)!=0;
if ( latestDesc && ( forceConvert || ( fDescriptor->GetVersion()!=latestDesc->GetVersion() ) ) ) if ( latestDesc && ( forceConvert || ( fDescriptor->GetVersion()!=latestDesc->GetVersion() ) ) )
{ {
@ -392,17 +392,17 @@ void plStateDataRecord::Write(hsStream* s, float timeConvert, uint32_t writeOpti
// //
// STATIC - read prefix header. returns true on success // STATIC - read prefix header. returns true on success
// //
bool plStateDataRecord::ReadStreamHeader(hsStream* s, char** name, int* version, plUoid* objUoid) bool plStateDataRecord::ReadStreamHeader(hsStream* s, plString* name, int* version, plUoid* objUoid)
{ {
uint16_t savFlags; uint16_t savFlags;
s->ReadLE(&savFlags); s->ReadLE(&savFlags);
if (!(savFlags & plSDL::kAddedVarLengthIO)) // using to establish a new version in the header, can delete in 8/03 if (!(savFlags & plSDL::kAddedVarLengthIO)) // using to establish a new version in the header, can delete in 8/03
{ {
*name = nil; *name = "";
return false; // bad version return false; // bad version
} }
*name = s->ReadSafeString(); *name = s->ReadSafeString_TEMP();
*version = s->ReadLE16(); *version = s->ReadLE16();
if (objUoid) if (objUoid)
@ -492,13 +492,14 @@ void plStateDataRecord::UpdateFrom(const plStateDataRecord& other, uint32_t writ
if ( GetDescriptor()->GetVersion()!=other.GetDescriptor()->GetVersion() ) if ( GetDescriptor()->GetVersion()!=other.GetDescriptor()->GetVersion() )
{ {
plStateDescriptor* sd=plSDLMgr::GetInstance()->FindDescriptor( other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion() ); plStateDescriptor* sd=plSDLMgr::GetInstance()->FindDescriptor( other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion() );
hsAssert( sd, xtl::format( "Failed to find sdl descriptor %s,%d. Missing legacy descriptor?", other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion() ).c_str() ); hsAssert( sd, plString::Format( "Failed to find sdl descriptor %s,%d. Missing legacy descriptor?",
other.GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetVersion() ).c_str() );
ConvertTo( sd ); ConvertTo( sd );
} }
hsAssert(other.GetDescriptor()==fDescriptor, hsAssert(other.GetDescriptor()==fDescriptor,
xtl::format("descriptor mismatch in UpdateFromDirty, SDL=%s,%s version %d %d", plString::Format("descriptor mismatch in UpdateFromDirty, SDL=%s,%s version %d %d",
GetDescriptor()->GetName(), other.GetDescriptor()->GetName(), GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetName().c_str(),
GetDescriptor()->GetVersion(), other.GetDescriptor()->GetVersion()).c_str()); GetDescriptor()->GetVersion(), other.GetDescriptor()->GetVersion()).c_str());
bool dirtyOnly = (writeOptions & plSDL::kDirtyOnly); bool dirtyOnly = (writeOptions & plSDL::kDirtyOnly);
@ -543,9 +544,9 @@ void plStateDataRecord::FlagDifferentState(const plStateDataRecord& other)
} }
else else
{ {
hsAssert(false, xtl::format("descriptor mismatch in FlagDifferentState, mine %s %d, other %s %d", hsAssert(false, plString::Format("descriptor mismatch in FlagDifferentState, mine %s %d, other %s %d",
fDescriptor->GetName(), fDescriptor->GetVersion(), fDescriptor->GetName().c_str(), fDescriptor->GetVersion(),
other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion()).c_str()); other.GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetVersion()).c_str());
} }
} }
@ -597,9 +598,9 @@ void plStateDataRecord::FlagNewerState(const plStateDataRecord& other, bool resp
} }
else else
{ {
hsAssert(false, xtl::format("descriptor mismatch in FlagNewerState, mine %s %d, other %s %d", hsAssert(false, plString::Format("descriptor mismatch in FlagNewerState, mine %s %d, other %s %d",
fDescriptor->GetName(), fDescriptor->GetVersion(), fDescriptor->GetName().c_str(), fDescriptor->GetVersion(),
other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion()).c_str()); other.GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetVersion()).c_str());
} }
} }
@ -651,16 +652,16 @@ bool plStateDataRecord::IConvertVar(plSimpleStateVariable* fromVar, plSimpleStat
return true; // ok return true; // ok
} }
plStateVariable* plStateDataRecord::IFindVar(const VarsList& vars, const char* name) const plStateVariable* plStateDataRecord::IFindVar(const VarsList& vars, const plString& name) const
{ {
for (int i = 0; i < vars.size(); i++) for (int i = 0; i < vars.size(); i++)
{ {
if (!stricmp(vars[i]->GetVarDescriptor()->GetName(), name)) if (!vars[i]->GetVarDescriptor()->GetName().CompareI(name))
return vars[i]; return vars[i];
} }
if (plSDLMgr::GetInstance()->GetNetApp()) if (plSDLMgr::GetInstance()->GetNetApp())
plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed to find SDL var %s", name); plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed to find SDL var %s", name.c_str());
return nil; return nil;
} }
@ -674,7 +675,7 @@ bool plStateDataRecord::ConvertTo( plStateDescriptor* other, bool force )
if (!other && !force) if (!other && !force)
return false; // err return false; // err
hsAssert(!stricmp(fDescriptor->GetName(), other->GetName()), "descriptor mismatch"); hsAssert(!fDescriptor->GetName().CompareI(other->GetName()), "descriptor mismatch");
if ( !force && (other == fDescriptor || other->GetVersion()==fDescriptor->GetVersion())) if ( !force && (other == fDescriptor || other->GetVersion()==fDescriptor->GetVersion()))
return true; // ok, nothing to do return true; // ok, nothing to do
@ -682,7 +683,7 @@ bool plStateDataRecord::ConvertTo( plStateDescriptor* other, bool force )
hsAssert(other->GetVersion()>=fDescriptor->GetVersion(), "converting to an older state descriptor version?"); hsAssert(other->GetVersion()>=fDescriptor->GetVersion(), "converting to an older state descriptor version?");
hsLogEntry( plNetApp::StaticDebugMsg( "SDR(%p) converting sdl record %s from version %d to %d (force:%d)", hsLogEntry( plNetApp::StaticDebugMsg( "SDR(%p) converting sdl record %s from version %d to %d (force:%d)",
this, fDescriptor->GetName(), fDescriptor->GetVersion(), other->GetVersion(), force ) ); this, fDescriptor->GetName().c_str(), fDescriptor->GetVersion(), other->GetVersion(), force ) );
// make other StateData to represent other descriptor, // make other StateData to represent other descriptor,
// this will be the destination for the convert operation // this will be the destination for the convert operation
@ -696,7 +697,7 @@ bool plStateDataRecord::ConvertTo( plStateDescriptor* other, bool force )
{ {
// get other var info // get other var info
plSimpleStateVariable* otherVar = otherStateData.GetVar(i); plSimpleStateVariable* otherVar = otherStateData.GetVar(i);
const char* otherVarName = otherVar->GetVarDescriptor()->GetName(); plString otherVarName = otherVar->GetVarDescriptor()->GetName();
// find corresponding var in my data // find corresponding var in my data
plSimpleStateVariable* myVar=FindVar(otherVarName); plSimpleStateVariable* myVar=FindVar(otherVarName);
@ -708,7 +709,7 @@ bool plStateDataRecord::ConvertTo( plStateDescriptor* other, bool force )
for(i=0;i<otherStateData.GetNumSDVars(); i++) for(i=0;i<otherStateData.GetNumSDVars(); i++)
{ {
plSDStateVariable* otherSDVar = otherStateData.GetSDVar(i); plSDStateVariable* otherSDVar = otherStateData.GetSDVar(i);
const char* otherSDVarName = otherSDVar->GetVarDescriptor()->GetName(); plString otherSDVarName = otherSDVar->GetVarDescriptor()->GetName();
// find corresponding var in my data // find corresponding var in my data
plSDStateVariable* mySDVar=FindSDVar(otherSDVarName); plSDStateVariable* mySDVar=FindSDVar(otherSDVarName);
@ -747,7 +748,7 @@ void plStateDataRecord::DumpToObjectDebugger(const char* msg, bool dirtyOnly, in
dbg->LogMsg(plString::Format("%s%s", pad.c_str(),msg).c_str()); dbg->LogMsg(plString::Format("%s%s", pad.c_str(),msg).c_str());
dbg->LogMsg(plString::Format("%sSDR(%p), desc=%s, showDirty=%d, numVars=%d, vol=%d", dbg->LogMsg(plString::Format("%sSDR(%p), desc=%s, showDirty=%d, numVars=%d, vol=%d",
pad.c_str(), this, fDescriptor->GetName(), dirtyOnly, numVars+numSDVars, fFlags&kVolatile).c_str()); pad.c_str(), this, fDescriptor->GetName().c_str(), dirtyOnly, numVars+numSDVars, fFlags&kVolatile).c_str());
// dump simple vars // dump simple vars
for(i=0;i<fVarsList.size(); i++) for(i=0;i<fVarsList.size(); i++)
@ -787,7 +788,8 @@ void plStateDataRecord::DumpToStream(hsStream* stream, const char* msg, bool dir
stream->Write(logStr.GetSize(), logStr.c_str()); 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(), dirtyOnly, numVars+numSDVars, fFlags&kVolatile); 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);
stream->Write(logStr.GetSize(), logStr.c_str()); stream->Write(logStr.GetSize(), logStr.c_str());
// dump simple vars // dump simple vars

8
Sources/Plasma/PubUtilLib/plSDL/plStateDescriptor.cpp

@ -56,19 +56,18 @@ plStateDescriptor::~plStateDescriptor()
void plStateDescriptor::IDeInit() void plStateDescriptor::IDeInit()
{ {
delete [] fName;
int i; int i;
for(i=0;i<fVarsList.size();i++) for(i=0;i<fVarsList.size();i++)
delete fVarsList[i]; delete fVarsList[i];
fVarsList.clear(); fVarsList.clear();
} }
plVarDescriptor* plStateDescriptor::FindVar(const char* name, int* idx) const plVarDescriptor* plStateDescriptor::FindVar(const plString& name, int* idx) const
{ {
VarsList::const_iterator it; VarsList::const_iterator it;
for(it=fVarsList.begin(); it != fVarsList.end(); it++) for(it=fVarsList.begin(); it != fVarsList.end(); it++)
{ {
if (!stricmp((*it)->GetName(), name)) if (!(*it)->GetName().CompareI(name))
{ {
if (idx) if (idx)
*idx = it-fVarsList.begin(); *idx = it-fVarsList.begin();
@ -95,8 +94,7 @@ bool plStateDescriptor::Read(hsStream* s)
IDeInit(); IDeInit();
delete [] fName; fName = s->ReadSafeString_TEMP();
fName = s->ReadSafeString();
uint16_t version=s->ReadLE16(); uint16_t version=s->ReadLE16();
fVersion=version; fVersion=version;

130
Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp

@ -108,11 +108,9 @@ public:
void plStateVarNotificationInfo::Read(hsStream* s, uint32_t readOptions) void plStateVarNotificationInfo::Read(hsStream* s, uint32_t readOptions)
{ {
uint8_t saveFlags=s->ReadByte(); // unused uint8_t saveFlags=s->ReadByte(); // unused
char* hint=s->ReadSafeString(); plString hint=s->ReadSafeString_TEMP();
if (hint && !(readOptions & plSDL::kSkipNotificationInfo)) if (!hint.IsNull() && !(readOptions & plSDL::kSkipNotificationInfo))
fHintString = (const char*)hint; fHintString = hint;
// we're done with it...
delete[] hint;
} }
void plStateVarNotificationInfo::Write(hsStream* s, uint32_t writeOptions) const void plStateVarNotificationInfo::Write(hsStream* s, uint32_t writeOptions) const
@ -212,8 +210,8 @@ void plSimpleStateVariable::IDeAlloc()
} }
break; break;
default: default:
hsAssert(false, xtl::format("undefined atomic type:%d var:%s cnt:%d", hsAssert(false, plString::Format("undefined atomic type:%d var:%s cnt:%d",
type, GetName() ? GetName() : "?", GetCount()).c_str()); type, GetName().c_str("?"), GetCount()).c_str());
break; break;
}; };
@ -328,12 +326,11 @@ void plSimpleStateVariable::TimeStamp( const plUnifiedTime & ut/*=plUnifiedTime:
// //
// Set value from string. Used to set default values which are specified as strings. // Set value from string. Used to set default values which are specified as strings.
// //
bool plSimpleStateVariable::SetFromString(const char* valueConst, int idx, bool timeStampNow) bool plSimpleStateVariable::SetFromString(const plString& value, int idx, bool timeStampNow)
{ {
if (!valueConst) if (value.IsNull())
return false; return false;
std::string value = valueConst;
plVarDescriptor::Type type=fVar.GetAtomicType(); plVarDescriptor::Type type=fVar.GetAtomicType();
switch(type) switch(type)
{ {
@ -346,54 +343,47 @@ bool plSimpleStateVariable::SetFromString(const char* valueConst, int idx, bool
case plVarDescriptor::kByte: case plVarDescriptor::kByte:
{ {
// handles value in the form "(i,j,k)" for vectors // handles value in the form "(i,j,k)" for vectors
static char seps[] = "( ,)"; std::vector<plString> bits = value.Tokenize("( ,)");
char* ptr = strtok( (char*)value.c_str(), seps );
int i=idx*fVar.GetAtomicCount(); int i=idx*fVar.GetAtomicCount();
while (ptr) for (std::vector<plString>::iterator ptr = bits.begin(); ptr != bits.end(); ++ptr)
{ {
if ((type==plVarDescriptor::kInt) && fI) if ((type==plVarDescriptor::kInt) && fI)
fI[i++] = atoi(ptr); fI[i++] = ptr->ToInt();
else if (type==plVarDescriptor::kShort && fS) else if (type==plVarDescriptor::kShort && fS)
fS[i++] = (short)atoi(ptr); fS[i++] = static_cast<short>(ptr->ToInt());
else if (type==plVarDescriptor::kByte && fBy) else if (type==plVarDescriptor::kByte && fBy)
fBy[i++] = (uint8_t)atoi(ptr); fBy[i++] = static_cast<uint8_t>(ptr->ToInt());
else if ( (type==plVarDescriptor::kFloat || type==plVarDescriptor::kAgeTimeOfDay) && fF) else if ( (type==plVarDescriptor::kFloat || type==plVarDescriptor::kAgeTimeOfDay) && fF)
fF[i++] = (float)atof(ptr); fF[i++] = static_cast<float>(ptr->ToFloat());
else if ( (type==plVarDescriptor::kDouble || type==plVarDescriptor::kTime) && fD) else if ( (type==plVarDescriptor::kDouble || type==plVarDescriptor::kTime) && fD)
fD[i++] = atof(ptr); fD[i++] = ptr->ToDouble();
ptr = strtok(nil, seps);
} }
} }
break; break;
case plVarDescriptor::kBool: case plVarDescriptor::kBool:
{ {
// handles value in the form "(i,j,k)" for things like vectors // handles value in the form "(i,j,k)" for things like vectors
static char seps[] = "( ,)"; std::vector<plString> bits = value.Tokenize("( ,)");
char* ptr = strtok( (char*)value.c_str(), seps );
int i=idx*fVar.GetAtomicCount(); int i=idx*fVar.GetAtomicCount();
while (ptr) for (std::vector<plString>::iterator ptr = bits.begin(); ptr != bits.end(); ++ptr)
{ {
if (!stricmp(ptr, "true")) if (!ptr->CompareI("true"))
fB[i++]=true; fB[i++]=true;
else else if (!ptr->CompareI("false"))
if (!stricmp(ptr, "false"))
fB[i++]=false; fB[i++]=false;
else else
fB[i++] = (atoi(ptr) != 0); fB[i++] = (ptr->ToInt() != 0);
ptr = strtok(nil, seps);
} }
} }
break; break;
case plVarDescriptor::kString32: case plVarDescriptor::kString32:
{ {
// handles value in the form "(i,j,k)" for things like vectors // handles value in the form "(i,j,k)" for things like vectors
static char seps[] = "( ,)"; std::vector<plString> bits = value.Tokenize("( ,)");
char* ptr = strtok( (char*)value.c_str(), seps );
int i=idx*fVar.GetAtomicCount(); int i=idx*fVar.GetAtomicCount();
while (ptr) for (std::vector<plString>::iterator ptr = bits.begin(); ptr != bits.end(); ++ptr)
{ {
hsStrncpy(fS32[i++], ptr, 32); hsStrncpy(fS32[i++], ptr->c_str(), 32);
ptr = strtok(nil, seps);
} }
} }
break; break;
@ -419,12 +409,12 @@ void plSimpleStateVariable::IVarSet(bool timeStampNow/*=true*/)
// //
// Get value as string. // Get value as string.
// //
char* plSimpleStateVariable::GetAsString(int idx) const plString plSimpleStateVariable::GetAsString(int idx) const
{ {
int j; int j;
std::string str; plString str;
if (fVar.GetAtomicCount()>1) if (fVar.GetAtomicCount()>1)
str = str + "("; str += "(";
plVarDescriptor::Type type=fVar.GetAtomicType(); plVarDescriptor::Type type=fVar.GetAtomicType();
switch(type) switch(type)
@ -442,20 +432,20 @@ char* plSimpleStateVariable::GetAsString(int idx) const
for(j=0;j<fVar.GetAtomicCount();j++) for(j=0;j<fVar.GetAtomicCount();j++)
{ {
if (type==plVarDescriptor::kInt) if (type==plVarDescriptor::kInt)
str.append( xtl::format( "%d", fI[i++]) ); str += plString::Format( "%d", fI[i++]);
else if (type==plVarDescriptor::kShort) else if (type==plVarDescriptor::kShort)
str.append( xtl::format( "%d", fS[i++]) ); str += plString::Format( "%d", fS[i++]);
else if (type==plVarDescriptor::kByte) else if (type==plVarDescriptor::kByte)
str.append( xtl::format( "%d", fBy[i++]) ); str += plString::Format( "%d", fBy[i++]);
else if (type==plVarDescriptor::kFloat || type==plVarDescriptor::kAgeTimeOfDay) else if (type==plVarDescriptor::kFloat || type==plVarDescriptor::kAgeTimeOfDay)
str.append( xtl::format( "%.3f", fF[i++]) ); str += plString::Format( "%.3f", fF[i++]);
else if (type==plVarDescriptor::kDouble) else if (type==plVarDescriptor::kDouble)
str.append( xtl::format( "%.3f", fD[i++]) ); str += plString::Format( "%.3f", fD[i++]);
else if (type==plVarDescriptor::kTime) else if (type==plVarDescriptor::kTime)
{ {
double tmp; double tmp;
Get(&tmp, i++); Get(&tmp, i++);
str.append( xtl::format( "%.3f", tmp) ); str += plString::Format( "%.3f", tmp);
} }
if (j==fVar.GetAtomicCount()-1) if (j==fVar.GetAtomicCount()-1)
@ -474,7 +464,7 @@ char* plSimpleStateVariable::GetAsString(int idx) const
int i=idx*fVar.GetAtomicCount(); int i=idx*fVar.GetAtomicCount();
for(j=0;j<fVar.GetAtomicCount();j++) for(j=0;j<fVar.GetAtomicCount();j++)
{ {
str.append( xtl::format( "%s", fB[i++] ? "true" : "false") ); str += plString::Format( "%s", fB[i++] ? "true" : "false");
if (j==fVar.GetAtomicCount()-1) if (j==fVar.GetAtomicCount()-1)
{ {
@ -492,7 +482,7 @@ char* plSimpleStateVariable::GetAsString(int idx) const
int i=idx*fVar.GetAtomicCount(); int i=idx*fVar.GetAtomicCount();
for(j=0;j<fVar.GetAtomicCount();j++) for(j=0;j<fVar.GetAtomicCount();j++)
{ {
str.append( xtl::format( "%s", fS32[i++]) ); str += plString::Format( "%s", fS32[i++]);
if (j==fVar.GetAtomicCount()-1) if (j==fVar.GetAtomicCount()-1)
{ {
@ -510,7 +500,7 @@ char* plSimpleStateVariable::GetAsString(int idx) const
int i=idx*fVar.GetAtomicCount(); int i=idx*fVar.GetAtomicCount();
for(j=0;j<fVar.GetAtomicCount();j++) for(j=0;j<fVar.GetAtomicCount();j++)
{ {
str.append( xtl::format( "%s", "other") ); str += "other";
if (j==fVar.GetAtomicCount()-1) if (j==fVar.GetAtomicCount()-1)
{ {
@ -524,7 +514,7 @@ char* plSimpleStateVariable::GetAsString(int idx) const
break; break;
} }
return hsStrcpy(str.c_str()); return str;
} }
// //
@ -2131,7 +2121,7 @@ case type: \
} \ } \
break; break;
void plSimpleStateVariable::NotifyStateChange(const plSimpleStateVariable* other, const char* sdlName) void plSimpleStateVariable::NotifyStateChange(const plSimpleStateVariable* other, const plString& sdlName)
{ {
if (fChangeNotifiers.size()==0) if (fChangeNotifiers.size()==0)
return; return;
@ -2174,8 +2164,8 @@ void plSimpleStateVariable::NotifyStateChange(const plSimpleStateVariable* other
if (plNetObjectDebuggerBase::GetInstance() && plNetObjectDebuggerBase::GetInstance()->GetDebugging()) if (plNetObjectDebuggerBase::GetInstance() && plNetObjectDebuggerBase::GetInstance()->GetDebugging())
{ {
plNetObjectDebuggerBase::GetInstance()->LogMsg( plNetObjectDebuggerBase::GetInstance()->LogMsg(
xtl::format("Var %s did %s send notification difference. Has %d notifiers with %d recipients.", plString::Format("Var %s did %s send notification difference. Has %d notifiers with %d recipients.",
GetName(), !notify ? "NOT" : "", fChangeNotifiers.size(), numNotifiers).c_str()); GetName().c_str(), !notify ? "NOT" : "", fChangeNotifiers.size(), numNotifiers).c_str());
} }
} }
@ -2290,12 +2280,12 @@ void plSimpleStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) cons
if (!dbg) if (!dbg)
return; return;
std::string pad; plString pad;
int i; int i;
for(i=0;i<level; i++) for(i=0;i<level; i++)
pad += " "; pad += " ";
std::string logMsg = xtl::format( "%sSimpleVar, name:%s[%d]", pad.c_str(), GetName(), GetCount()); plString logMsg = plString::Format( "%sSimpleVar, name:%s[%d]", pad.c_str(), GetName().c_str(), GetCount());
if (GetCount()>1) if (GetCount()>1)
{ {
dbg->LogMsg(logMsg.c_str()); // it's going to be a long msg, so print it on its own line dbg->LogMsg(logMsg.c_str()); // it's going to be a long msg, so print it on its own line
@ -2305,22 +2295,21 @@ void plSimpleStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) cons
pad += "\t"; pad += "\t";
for(i=0;i<GetCount(); i++) for(i=0;i<GetCount(); i++)
{ {
char* s=GetAsString(i); plString s=GetAsString(i);
if (fVar.GetAtomicType() == plVarDescriptor::kTime) if (fVar.GetAtomicType() == plVarDescriptor::kTime)
{ {
const char* p=fT[i].PrintWMillis(); const char* p=fT[i].PrintWMillis();
logMsg += xtl::format( "%sVar:%d gameTime:%s pst:%s ts:%s", logMsg += plString::Format( "%sVar:%d gameTime:%s pst:%s ts:%s",
pad.c_str(), i, s ? s : "?", p, fTimeStamp.Format("%c").c_str() ); pad.c_str(), i, s.c_str("?"), p, fTimeStamp.Format("%c").c_str() );
} }
else else
{ {
logMsg +=xtl::format( "%sVar:%d value:%s ts:%s", logMsg += plString::Format( "%sVar:%d value:%s ts:%s",
pad.c_str(), i, s ? s : "?", fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() ); pad.c_str(), i, s.c_str("?"), fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() );
} }
delete [] s;
if ( !dirtyOnly ) if ( !dirtyOnly )
logMsg += xtl::format( " dirty:%d", IsDirty() ); logMsg += plString::Format( " dirty:%d", IsDirty() );
dbg->LogMsg(logMsg.c_str()); dbg->LogMsg(logMsg.c_str());
logMsg = ""; logMsg = "";
@ -2329,12 +2318,12 @@ void plSimpleStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) cons
void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int level) const void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int level) const
{ {
std::string pad; plString pad;
int i; int i;
for(i=0;i<level; i++) for(i=0;i<level; i++)
pad += " "; pad += " ";
std::string logMsg = xtl::format( "%sSimpleVar, name:%s[%d]", pad.c_str(), GetName(), GetCount()); plString logMsg = plString::Format( "%sSimpleVar, name:%s[%d]", pad.c_str(), GetName().c_str(), GetCount());
if (GetCount()>1) if (GetCount()>1)
{ {
stream->WriteString(logMsg.c_str()); // it's going to be a long msg, so print it on its own line stream->WriteString(logMsg.c_str()); // it's going to be a long msg, so print it on its own line
@ -2344,22 +2333,21 @@ void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int l
pad += "\t"; pad += "\t";
for(i=0;i<GetCount(); i++) for(i=0;i<GetCount(); i++)
{ {
char* s=GetAsString(i); plString s=GetAsString(i);
if (fVar.GetAtomicType() == plVarDescriptor::kTime) if (fVar.GetAtomicType() == plVarDescriptor::kTime)
{ {
const char* p=fT[i].PrintWMillis(); const char* p=fT[i].PrintWMillis();
logMsg += xtl::format( "%sVar:%d gameTime:%s pst:%s ts:%s", logMsg += plString::Format( "%sVar:%d gameTime:%s pst:%s ts:%s",
pad.c_str(), i, s ? s : "?", p, fTimeStamp.Format("%c").c_str() ); pad.c_str(), i, s.c_str("?"), p, fTimeStamp.Format("%c").c_str() );
} }
else else
{ {
logMsg +=xtl::format( "%sVar:%d value:%s ts:%s", logMsg += plString::Format( "%sVar:%d value:%s ts:%s",
pad.c_str(), i, s ? s : "?", fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() ); pad.c_str(), i, s.c_str("?"), fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() );
} }
delete [] s;
if ( !dirtyOnly ) if ( !dirtyOnly )
logMsg += xtl::format( " dirty:%d", IsDirty() ); logMsg += plString::Format( " dirty:%d", IsDirty() );
stream->WriteString(logMsg.c_str()); stream->WriteString(logMsg.c_str());
logMsg = ""; logMsg = "";
@ -2497,9 +2485,9 @@ void plSDStateVariable::CopyFrom(plSDStateVariable* other, uint32_t writeOptions
// //
void plSDStateVariable::UpdateFrom(plSDStateVariable* other, uint32_t writeOptions/*=0*/) void plSDStateVariable::UpdateFrom(plSDStateVariable* other, uint32_t writeOptions/*=0*/)
{ {
hsAssert(!stricmp(other->GetSDVarDescriptor()->GetName(), fVarDescriptor->GetName()), hsAssert(!other->GetSDVarDescriptor()->GetName().CompareI(fVarDescriptor->GetName()),
xtl::format("var descriptor mismatch in UpdateFrom, name %s,%s ver %d,%d", plString::Format("var descriptor mismatch in UpdateFrom, name %s,%s ver %d,%d",
GetName(), other->GetName()).c_str()); GetName().c_str(), other->GetName().c_str()).c_str());
Resize(other->GetCount()); // make sure sizes match Resize(other->GetCount()); // make sure sizes match
bool dirtyOnly = (writeOptions & plSDL::kDirtyOnly); bool dirtyOnly = (writeOptions & plSDL::kDirtyOnly);
@ -2521,8 +2509,8 @@ void plSDStateVariable::ConvertTo(plSDStateVariable* otherSDVar, bool force )
plStateDescriptor* otherSD=otherSDVar->GetSDVarDescriptor()->GetStateDescriptor(); plStateDescriptor* otherSD=otherSDVar->GetSDVarDescriptor()->GetStateDescriptor();
hsLogEntry( plNetApp::StaticDebugMsg( "SDSV(%p) converting %s from %s to %s (force:%d)", hsLogEntry( plNetApp::StaticDebugMsg( "SDSV(%p) converting %s from %s to %s (force:%d)",
this, fVarDescriptor->GetName(), fVarDescriptor->GetTypeString(), this, fVarDescriptor->GetName().c_str(), fVarDescriptor->GetTypeString().c_str(),
otherSDVar->GetSDVarDescriptor()->GetTypeString(), force ) ); otherSDVar->GetSDVarDescriptor()->GetTypeString().c_str(), force ) );
int j; int j;
for(j=0;j<GetCount(); j++) for(j=0;j<GetCount(); j++)

120
Sources/Plasma/PubUtilLib/plSDL/plVarDescriptor.cpp

@ -55,96 +55,77 @@ const uint8_t plVarDescriptor::kVersion=3; // for Read/Write format
// State Var // State Var
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
plVarDescriptor::plVarDescriptor() :
fName(nil),
fCount(1),
fType(kNone),
fTypeString(nil),
fDefault(nil),
fFlags(0)
{
}
plVarDescriptor::~plVarDescriptor()
{
delete [] fName;
delete [] fDefault;
delete [] fTypeString;
}
// //
// Set type from a string. Return false on err. // Set type from a string. Return false on err.
// //
bool plVarDescriptor::SetType(const char* type) bool plVarDescriptor::SetType(const plString& type)
{ {
if (!type) if (type.IsNull())
return false; return false;
if (!stricmp(type, "vector3")) if (!type.CompareI("vector3"))
fType=kVector3; fType=kVector3;
else else
if (!stricmp(type, "point3")) if (!type.CompareI("point3"))
fType=kPoint3; fType=kPoint3;
else else
if (!stricmp(type, "rgb")) if (!type.CompareI("rgb"))
fType=kRGB; fType=kRGB;
else else
if (!stricmp(type, "rgba")) if (!type.CompareI("rgba"))
fType=kRGBA; fType=kRGBA;
else else
if (!stricmp(type, "rgb8")) if (!type.CompareI("rgb8"))
fType=kRGB8; fType=kRGB8;
else else
if (!stricmp(type, "rgba8")) if (!type.CompareI("rgba8"))
fType=kRGBA8; fType=kRGBA8;
else else
if (!strnicmp(type, "quat",4)) if (!type.CompareNI("quat", 4))
fType=kQuaternion; fType=kQuaternion;
else else
if (!stricmp(type, "rgba")) if (!type.CompareI("rgba"))
fType=kRGBA; fType=kRGBA;
else else
if (!stricmp(type, "int")) if (!type.CompareI("int"))
fType=kInt; fType=kInt;
else else
if (!stricmp(type, "byte")) if (!type.CompareI("byte"))
fType=kByte; fType=kByte;
else else
if (!stricmp(type, "short")) if (!type.CompareI("short"))
fType=kShort; fType=kShort;
else else
if (!stricmp(type, "float")) if (!type.CompareI("float"))
fType=kFloat; fType=kFloat;
else else
if (!stricmp(type, "double")) if (!type.CompareI("double"))
fType=kDouble; fType=kDouble;
else else
if (!stricmp(type, "time")) if (!type.CompareI("time"))
fType=kTime; fType=kTime;
else else
if (!stricmp(type, "ageTimeOfDay")) if (!type.CompareI("ageTimeOfDay"))
fType=kAgeTimeOfDay; fType=kAgeTimeOfDay;
else else
if (!stricmp(type, "bool")) if (!type.CompareI("bool"))
fType=kBool; fType=kBool;
else else
if (!stricmp(type, "string32")) if (!type.CompareI("string32"))
fType=kString32; fType=kString32;
else else
if (!stricmp(type, "plKey")) if (!type.CompareI("plKey"))
fType=kKey; fType=kKey;
else else
if (!stricmp(type, "message") || !stricmp(type, "creatable") ) if (!type.CompareI("message") || !type.CompareI("creatable") )
fType=kCreatable; fType=kCreatable;
else else
if (*type=='$') if (type.CharAt(0)=='$')
fType=kStateDescriptor; fType=kStateDescriptor;
else else
return false; // err return false; // err
delete [] fTypeString; fTypeString = type;
fTypeString = hsStrcpy(type);
return true; // ok return true; // ok
} }
@ -156,8 +137,7 @@ void plVarDescriptor::CopyFrom(const plVarDescriptor* other)
SetCount(other->GetCount()); SetCount(other->GetCount());
SetDisplayOptions(other->GetDisplayOptions()); SetDisplayOptions(other->GetDisplayOptions());
delete [] fTypeString; fTypeString=other->GetTypeString();
fTypeString=hsStrcpy(other->GetTypeString());
fType = other->GetType(); fType = other->GetType();
fFlags = other->fFlags; fFlags = other->fFlags;
@ -178,8 +158,7 @@ bool plVarDescriptor::Read(hsStream* s)
return false; return false;
} }
delete [] fName; fName=s->ReadSafeString_TEMP();
fName=s->ReadSafeString();
plMsgStdStringHelper::Peek(fDisplayOptions, s); plMsgStdStringHelper::Peek(fDisplayOptions, s);
@ -187,8 +166,7 @@ bool plVarDescriptor::Read(hsStream* s)
fType=(Type)s->ReadByte(); fType=(Type)s->ReadByte();
delete [] fDefault; fDefault = s->ReadSafeString_TEMP();
fDefault = s->ReadSafeString();
fFlags = s->ReadLE32(); fFlags = s->ReadLE32();
return true; return true;
@ -259,87 +237,84 @@ int plSimpleVarDescriptor::GetSize() const
// Set type from a string. Return false on err. // Set type from a string. Return false on err.
// Sets atomicCount and atomicType // Sets atomicCount and atomicType
// //
bool plSimpleVarDescriptor::SetType(const char* type) bool plSimpleVarDescriptor::SetType(const plString& type)
{ {
if (!type)
return false;
if (!plVarDescriptor::SetType(type)) if (!plVarDescriptor::SetType(type))
return false; return false;
if (!stricmp(type, "vector3")) if (!type.CompareI("vector3"))
{ {
fAtomicCount = 3; fAtomicCount = 3;
fAtomicType=kFloat; fAtomicType=kFloat;
} }
else else
if (!stricmp(type, "point3")) if (!type.CompareI("point3"))
{ {
fAtomicCount = 3; fAtomicCount = 3;
fAtomicType=kFloat; fAtomicType=kFloat;
} }
else else
if (!stricmp(type, "rgb")) if (!type.CompareI("rgb"))
{ {
fAtomicCount = 3; fAtomicCount = 3;
fAtomicType=kFloat; fAtomicType=kFloat;
} }
else else
if (!stricmp(type, "rgba")) if (!type.CompareI("rgba"))
{ {
fAtomicCount = 4; fAtomicCount = 4;
fAtomicType=kFloat; fAtomicType=kFloat;
} }
else else
if (!stricmp(type, "rgb8")) if (!type.CompareI("rgb8"))
{ {
fAtomicCount = 3; fAtomicCount = 3;
fAtomicType=kByte; fAtomicType=kByte;
} }
else else
if (!stricmp(type, "rgba8")) if (!type.CompareI("rgba8"))
{ {
fAtomicCount = 4; fAtomicCount = 4;
fAtomicType=kByte; fAtomicType=kByte;
} }
else else
if (!strnicmp(type, "quat",4)) if (!type.CompareNI("quat", 4))
{ {
fAtomicCount = 4; fAtomicCount = 4;
fAtomicType=kFloat; fAtomicType=kFloat;
} }
else else
if (!stricmp(type, "int")) if (!type.CompareI("int"))
fAtomicType=kInt; fAtomicType=kInt;
else else
if (!stricmp(type, "byte")) if (!type.CompareI("byte"))
fAtomicType=kByte; fAtomicType=kByte;
else else
if (!stricmp(type, "short")) if (!type.CompareI("short"))
fAtomicType=kShort; fAtomicType=kShort;
else else
if (!stricmp(type, "float")) if (!type.CompareI("float"))
fAtomicType=kFloat; fAtomicType=kFloat;
else else
if (!stricmp(type, "double")) if (!type.CompareI("double"))
fAtomicType=kDouble; fAtomicType=kDouble;
else else
if (!stricmp(type, "time")) if (!type.CompareI("time"))
fAtomicType=kTime; fAtomicType=kTime;
else else
if (!stricmp(type, "ageTimeOfDay")) if (!type.CompareI("ageTimeOfDay"))
fAtomicType=kAgeTimeOfDay; fAtomicType=kAgeTimeOfDay;
else else
if (!stricmp(type, "bool")) if (!type.CompareI("bool"))
fAtomicType=kBool; fAtomicType=kBool;
else else
if (!stricmp(type, "string32")) if (!type.CompareI("string32"))
fAtomicType=kString32; fAtomicType=kString32;
else else
if (!stricmp(type, "plKey")) if (!type.CompareI("plKey"))
fAtomicType=kKey; fAtomicType=kKey;
else else
if (!stricmp(type, "message") || !stricmp(type, "creatable")) if (!type.CompareI("message") || !type.CompareI("creatable"))
fAtomicType=kCreatable; fAtomicType=kCreatable;
else else
return false; // err return false; // err
@ -398,12 +373,11 @@ bool plSDVarDescriptor::Read(hsStream* s)
if (!plVarDescriptor::Read(s)) if (!plVarDescriptor::Read(s))
return false; return false;
char* sdName=s->ReadSafeString(); plString sdName=s->ReadSafeString_TEMP();
uint16_t version = s->ReadLE16(); uint16_t version = s->ReadLE16();
plStateDescriptor* sd=plSDLMgr::GetInstance()->FindDescriptor(sdName, version); plStateDescriptor* sd=plSDLMgr::GetInstance()->FindDescriptor(sdName, version);
hsAssert( sd, xtl::format("Failed to find sdl descriptor: %s,%d. Missing legacy descriptor?", sdName, version ).c_str() ); hsAssert( sd, plString::Format("Failed to find sdl descriptor: %s,%d. Missing legacy descriptor?", sdName.c_str(), version ).c_str() );
SetStateDesc(sd); SetStateDesc(sd);
delete [] sdName;
return true; return true;
} }

8
Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp

@ -2424,13 +2424,9 @@ bool VaultAddOwnedAgeSpawnPoint (const Uuid & ageInstId, const plSpawnPointInfo
RelVaultNode * link = nil; RelVaultNode * link = nil;
for (;;) { for (;;) {
if (!spawnPt.GetName()) if (spawnPt.GetName().IsEmpty())
break; break;
if (!spawnPt.GetTitle()) if (spawnPt.GetTitle().IsEmpty())
break;
if (!StrLen(spawnPt.GetName()))
break;
if (!StrLen(spawnPt.GetTitle()))
break; break;
fldr = VaultGetAgesIOwnFolderIncRef(); fldr = VaultGetAgesIOwnFolderIncRef();

46
Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp

@ -534,13 +534,12 @@ bool VaultSDLNode::GetStateDataRecord (plStateDataRecord * rec, unsigned readOpt
ram.Write(sdlDataLen, sdlData); ram.Write(sdlDataLen, sdlData);
ram.Rewind(); ram.Rewind();
char * sdlRecName = nil; plString sdlRecName;
int sdlRecVersion; int sdlRecVersion;
if (!plStateDataRecord::ReadStreamHeader(&ram, &sdlRecName, &sdlRecVersion)) if (!plStateDataRecord::ReadStreamHeader(&ram, &sdlRecName, &sdlRecVersion))
return false; return false;
rec->SetDescriptor(sdlRecName, sdlRecVersion); rec->SetDescriptor(sdlRecName, sdlRecVersion);
free(sdlRecName);
// Note: Setting from default here results in a bug causing age SDL to // Note: Setting from default here results in a bug causing age SDL to
// be incorrectly shown when immediately linking back to an age you linked // be incorrectly shown when immediately linking back to an age you linked
@ -698,14 +697,14 @@ bool VaultImageNode::ExtractImage (plMipmap ** dst) {
#ifdef CLIENT #ifdef CLIENT
struct MatchesSpawnPointTitle struct MatchesSpawnPointTitle
{ {
std::string fTitle; plString fTitle;
MatchesSpawnPointTitle( const char * title ):fTitle( title ){} MatchesSpawnPointTitle( const plString & title ):fTitle( title ){}
bool operator ()( const plSpawnPointInfo & p ) const { return ( p.fTitle==fTitle ); } bool operator ()( const plSpawnPointInfo & p ) const { return ( p.fTitle==fTitle ); }
}; };
struct MatchesSpawnPointName struct MatchesSpawnPointName
{ {
std::string fName; plString fName;
MatchesSpawnPointName( const char * name ):fName( name ){} MatchesSpawnPointName( const plString & name ):fName( name ){}
bool operator ()( const plSpawnPointInfo & p ) const { return ( p.fSpawnPt==fName ); } bool operator ()( const plSpawnPointInfo & p ) const { return ( p.fSpawnPt==fName ); }
}; };
#endif #endif
@ -768,7 +767,7 @@ void VaultAgeLinkNode::AddSpawnPoint (const plSpawnPointInfo & point) {
//============================================================================ //============================================================================
#ifdef CLIENT #ifdef CLIENT
void VaultAgeLinkNode::RemoveSpawnPoint (const char spawnPtName[]) { void VaultAgeLinkNode::RemoveSpawnPoint (const plString & spawnPtName) {
plSpawnPointVec points; plSpawnPointVec points;
GetSpawnPoints( &points ); GetSpawnPoints( &points );
@ -784,7 +783,7 @@ void VaultAgeLinkNode::RemoveSpawnPoint (const char spawnPtName[]) {
//============================================================================ //============================================================================
#ifdef CLIENT #ifdef CLIENT
bool VaultAgeLinkNode::HasSpawnPoint (const char spawnPtName[]) const { bool VaultAgeLinkNode::HasSpawnPoint (const plString & spawnPtName) const {
plSpawnPointVec points; plSpawnPointVec points;
GetSpawnPoints( &points ); GetSpawnPoints( &points );
@ -804,23 +803,18 @@ bool VaultAgeLinkNode::HasSpawnPoint (const plSpawnPointInfo & point) const {
#ifdef CLIENT #ifdef CLIENT
void VaultAgeLinkNode::GetSpawnPoints (plSpawnPointVec * out) const { void VaultAgeLinkNode::GetSpawnPoints (plSpawnPointVec * out) const {
char str[2048]; plString str = plString::FromUtf8(reinterpret_cast<const char*>(spawnPoints), spawnPointsLen);
memset(&str, 0, sizeof(str)); std::vector<plString> izer = str.Tokenize(";");
memcpy(str, spawnPoints, min(spawnPointsLen, arrsize(str) - 1)); for (auto token1 = izer.begin(); token1 != izer.end(); ++token1)
char token1[ 1024 ];
hsStringTokenizer izer1( str, ";" );
while ( izer1.Next( token1, sizeof( token1 ) ) )
{ {
plSpawnPointInfo point; plSpawnPointInfo point;
char token2[ 1024 ]; std::vector<plString> izer2 = token1->Tokenize(":");
hsStringTokenizer izer2( token1, ":" ); if ( izer2.size() > 0)
if ( izer2.Next( token2, sizeof( token2 ) ) ) point.fTitle = izer2[0];
point.fTitle = token2; if ( izer2.size() > 1)
if ( izer2.Next( token2, sizeof( token2 ) ) ) point.fSpawnPt = izer2[1];
point.fSpawnPt = token2; if ( izer2.size() > 2)
if ( izer2.Next( token2, sizeof( token2 ) ) ) point.fSpawnPt = izer2[2];
point.fCameraStack = token2;
out->push_back(point); out->push_back(point);
} }
@ -831,7 +825,7 @@ void VaultAgeLinkNode::GetSpawnPoints (plSpawnPointVec * out) const {
#ifdef CLIENT #ifdef CLIENT
void VaultAgeLinkNode::SetSpawnPoints (const plSpawnPointVec & in) { void VaultAgeLinkNode::SetSpawnPoints (const plSpawnPointVec & in) {
std::stringstream ss; plStringStream ss;
for ( unsigned i=0; i<in.size(); i++ ) { for ( unsigned i=0; i<in.size(); i++ ) {
ss ss
<< in[i].fTitle << ":" << in[i].fTitle << ":"
@ -843,8 +837,8 @@ void VaultAgeLinkNode::SetSpawnPoints (const plSpawnPointVec & in) {
base, base,
&spawnPoints, &spawnPoints,
&spawnPointsLen, &spawnPointsLen,
(const uint8_t *)ss.str().c_str(), (const uint8_t *)ss.GetString().c_str(),
ss.str().size() ss.GetLength()
); );
} }
#endif #endif

4
Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.h

@ -277,8 +277,8 @@ struct VaultAgeLinkNode : NetVaultNodeAccess {
#ifdef CLIENT #ifdef CLIENT
bool CopyTo (plAgeLinkStruct * link); bool CopyTo (plAgeLinkStruct * link);
void AddSpawnPoint (const plSpawnPointInfo & point); // will only add if not there already. void AddSpawnPoint (const plSpawnPointInfo & point); // will only add if not there already.
void RemoveSpawnPoint (const char spawnPtName[]); void RemoveSpawnPoint (const plString & spawnPtName);
bool HasSpawnPoint (const char spawnPtName[]) const; bool HasSpawnPoint (const plString & spawnPtName) const;
bool HasSpawnPoint (const plSpawnPointInfo & point) const; // compares spawn name only, not title. bool HasSpawnPoint (const plSpawnPointInfo & point) const; // compares spawn name only, not title.
void GetSpawnPoints (plSpawnPointVec * out) const; void GetSpawnPoints (plSpawnPointVec * out) const;
void SetSpawnPoints (const plSpawnPointVec & in); void SetSpawnPoints (const plSpawnPointVec & in);

2
Sources/Tools/MaxComponent/plAnimComponent.cpp

@ -178,7 +178,7 @@ void plAnimComponentProc::FillAgeGlobalComboBox(HWND box, const char *varName)
var->GetType() == plVarDescriptor::kTime || var->GetType() == plVarDescriptor::kTime ||
var->GetType() == plVarDescriptor::kAgeTimeOfDay) var->GetType() == plVarDescriptor::kAgeTimeOfDay)
{ {
ComboBox_AddString(box, var->GetName()); ComboBox_AddString(box, var->GetName().c_str());
} }
} }
} }

Loading…
Cancel
Save