2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 10:37:41 -04:00

Merged with master and plString

This commit is contained in:
NadnerbD
2012-02-12 01:57:16 -05:00
309 changed files with 3473 additions and 2575 deletions

View File

@ -175,7 +175,7 @@ plKey cyAvatar::IFindArmatureModKey(plKey avKey)
// PURPOSE : oneShot Avatar (must already be there)
//
void cyAvatar::OneShot(pyKey &seekKey, float duration, hsBool usePhysics,
const char *animName, hsBool drivable, hsBool reversible)
const plString &animName, hsBool drivable, hsBool reversible)
{
if ( fRecvr.Count() > 0 )
{
@ -186,7 +186,7 @@ void cyAvatar::OneShot(pyKey &seekKey, float duration, hsBool usePhysics,
seekKey.getKey(), // Mark D told me to do it ...paulg
duration,
usePhysics,
animName, // Constructor will do a copy. -mf- hsStrcpy(animName),
animName,
drivable,
reversible);
@ -1274,7 +1274,7 @@ PyObject* cyAvatar::GetTintClothingItemL(const char* clothing_name, uint8_t laye
}
char errmsg[256];
sprintf(errmsg,"Cannot find clothing item %d to find out what tint it is",clothing_name);
sprintf(errmsg,"Cannot find clothing item %s to find out what tint it is",clothing_name);
PyErr_SetString(PyExc_KeyError, errmsg);
// returning nil means an error occurred
return nil;
@ -1587,7 +1587,7 @@ void cyAvatar::ExitSubWorld()
//
// PURPOSE : Place the Avatar into the subworld of the sceneobject specified
//
void cyAvatar::PlaySimpleAnimation(const char* animName)
void cyAvatar::PlaySimpleAnimation(const plString& animName)
{
// make sure that there is atleast one avatar scene object attached (should be)
if ( fRecvr.Count() > 0)

View File

@ -103,7 +103,7 @@ public:
// oneShot Avatar (must already be there)
virtual void OneShot(pyKey &seekKey, float duration, hsBool usePhysics,
const char *animName, hsBool drivable, hsBool reversible);
const plString &animName, hsBool drivable, hsBool reversible);
// oneShot Avatar
virtual void RunBehavior(pyKey &behKey, hsBool netForce, hsBool netProp);
@ -412,7 +412,7 @@ public:
//
virtual void ExitSubWorld();
virtual void PlaySimpleAnimation(const char* animName);
virtual void PlaySimpleAnimation(const plString& animName);
/////////////////////////////////////////////////////////////////////////////
//

View File

@ -89,8 +89,7 @@ PYTHON_METHOD_DEFINITION(ptAvatar, oneShot, args)
}
pyKey* key = pyKey::ConvertFrom(keyObj);
std::string animNameStr = animName; // convert to string (for safety)
self->fThis->OneShot(*key, duration, usePhysics != 0, animNameStr.c_str(), drivable != 0, reversable != 0);
self->fThis->OneShot(*key, duration, usePhysics != 0, plString::FromUtf8(animName), drivable != 0, reversable != 0);
PYTHON_RETURN_NONE;
}
@ -592,8 +591,7 @@ PYTHON_METHOD_DEFINITION(ptAvatar, playSimpleAnimation, args)
PYTHON_RETURN_ERROR;
}
std::string animNameStr = animName; // convert to a string (for safety)
self->fThis->PlaySimpleAnimation(animNameStr.c_str());
self->fThis->PlaySimpleAnimation(plString::FromUtf8(animName));
PYTHON_RETURN_NONE;
}

View File

@ -194,12 +194,12 @@ void cyMisc::ConsoleNet(const char* command, hsBool netForce)
// PURPOSE : Execute a console command from a python script,
// optionally propagate over the net
//
PyObject* cyMisc::FindSceneObject(const char* name, const char* ageName)
PyObject* cyMisc::FindSceneObject(const plString& name, const char* ageName)
{
// assume that we won't find the sceneobject (key is equal to nil)
plKey key=nil;
if ( name || name[0] != 0)
if ( !name.IsEmpty() )
{
const char* theAge = ageName;
if ( ageName[0] == 0 )
@ -209,18 +209,17 @@ PyObject* cyMisc::FindSceneObject(const char* name, const char* ageName)
if ( key == nil )
{
char errmsg[256];
sprintf(errmsg,"Sceneobject %s not found",name);
PyErr_SetString(PyExc_NameError, errmsg);
plString errmsg = plString::Format("Sceneobject %s not found",name.c_str());
PyErr_SetString(PyExc_NameError, errmsg.c_str());
return nil; // return nil cause we errored
}
return pySceneObject::New(key);
}
PyObject* cyMisc::FindActivator(const char* name)
PyObject* cyMisc::FindActivator(const plString& name)
{
plKey key = nil;
if (name && strlen(name) > 0)
if (!name.IsEmpty())
{
std::vector<plKey> keylist;
plKeyFinder::Instance().ReallyStupidActivatorSearch(name, keylist);
@ -453,10 +452,9 @@ hsBool cyMisc::WasLocallyNotified(pyKey &selfkey)
// PURPOSE : Return the net client (account) name of the player whose avatar
// key is provided.
//
const char* cyMisc::GetClientName(pyKey &avKey)
plString cyMisc::GetClientName(pyKey &avKey)
{
const char* ret=plNetClientMgr::GetInstance()->GetPlayerName(avKey.getKey());
return (ret==nil) ? "" : ret;
return plNetClientMgr::GetInstance()->GetPlayerName(avKey.getKey());
}
PyObject* cyMisc::GetAvatarKeyFromClientID(int clientID)
@ -547,7 +545,7 @@ hsBool cyMisc::ValidateKey(pyKey& key)
//
// PURPOSE : Return the local net client (account) name
//
const char* cyMisc::GetLocalClientName()
plString cyMisc::GetLocalClientName()
{
return plNetClientMgr::GetInstance()->GetPlayerName();
}
@ -946,7 +944,7 @@ PyObject* cyMisc::GetLocalAvatar()
PyObject* cyMisc::GetLocalPlayer()
{
return pyPlayer::New(plNetClientMgr::GetInstance()->GetLocalPlayerKey(),
plNetClientMgr::GetInstance()->GetPlayerName(),
plNetClientMgr::GetInstance()->GetPlayerName().c_str(),
plNetClientMgr::GetInstance()->GetPlayerID(),
0.0 );
}
@ -1003,7 +1001,7 @@ std::vector<PyObject*> cyMisc::GetPlayerList()
// only non-ignored people in list and not in ignore list
if ( !VaultAmIgnoringPlayer ( mbr->GetPlayerID()) )
{
PyObject* playerObj = pyPlayer::New(avkey, mbr->GetPlayerName(), mbr->GetPlayerID(), mbr->GetDistSq());
PyObject* playerObj = pyPlayer::New(avkey, mbr->GetPlayerName().c_str(), mbr->GetPlayerID(), mbr->GetDistSq());
pyPlayer* player = pyPlayer::ConvertFrom(playerObj); // accesses internal pyPlayer object
// modifies playerObj
@ -1038,7 +1036,7 @@ std::vector<PyObject*> cyMisc::GetPlayerListDistanceSorted()
// only non-ignored people in list and not in ignore list
if ( !VaultAmIgnoringPlayer ( mbr->GetPlayerID()) )
{
PyObject* playerObj = pyPlayer::New(avkey, mbr->GetPlayerName(), mbr->GetPlayerID(), mbr->GetDistSq());
PyObject* playerObj = pyPlayer::New(avkey, mbr->GetPlayerName().c_str(), mbr->GetPlayerID(), mbr->GetDistSq());
pyPlayer* player = pyPlayer::ConvertFrom(playerObj); // accesses internal pyPlayer object
// modifies playerObj
@ -1916,7 +1914,7 @@ int cyMisc::GetNumParticles(pyKey& host)
}
void cyMisc::SetLightColorValue(pyKey& light, std::string lightName, float r, float g, float b, float a)
void cyMisc::SetLightColorValue(pyKey& light, const plString& lightName, float r, float g, float b, float a)
{
// lightName is the name of the light object attached to the light that we want to talk to
// for the bug lights, this would be "RTOmni-BugLightTest"
@ -1964,7 +1962,7 @@ void cyMisc::SetLightColorValue(pyKey& light, std::string lightName, float r, fl
}
#include "pnMessage/plEnableMsg.h"
void cyMisc::SetLightAnimationOn(pyKey& light, std::string lightName, hsBool start)
void cyMisc::SetLightAnimationOn(pyKey& light, const plString& lightName, hsBool start)
{
// lightName is the name of the light object attached to the light that we want to talk to
// for the bug lights, this would be "RTOmni-BugLightTest"
@ -2364,7 +2362,7 @@ public:
if ( guid )
{
PyObject* retVal = PyObject_CallMethod(fPyObject, "publicAgeRemoved", "s", guid->AsString());
PyObject* retVal = PyObject_CallMethod(fPyObject, "publicAgeRemoved", "s", guid->AsString().c_str());
Py_XDECREF(retVal);
}
}
@ -2455,28 +2453,25 @@ const char* cyMisc::GetCameraNumber(int number)
plCameraModifier1* pCam = plVirtualCam1::Instance()->GetCameraNumber(number-1);
if (pCam->GetTarget())
{
const char* ret = pCam->GetTarget()->GetKeyName();
(ret==nil) ? "empty" : ret;
char str[256];
sprintf(str, "saving camera named %s to chronicle\n",ret);
plVirtualCam1::Instance()->AddMsgToLog(str);
const char* ret = pCam->GetTarget()->GetKeyName().c_str();
plString str = plString::Format("saving camera named %s to chronicle\n",ret);
plVirtualCam1::Instance()->AddMsgToLog(str.c_str());
return ret;
}
plVirtualCam1::Instance()->AddMsgToLog("sending empty to camera chronicle\n");
return "empty";
}
void cyMisc::RebuildCameraStack(const char* name, const char* ageName)
void cyMisc::RebuildCameraStack(const plString& name, const char* ageName)
{
plKey key=nil;
char str[256];
sprintf(str, "attempting to restore camera named %s from chronicle\n",name);
plVirtualCam1::Instance()->AddMsgToLog(str);
if (strcmp(name, "empty") == 0)
plString str = plString::Format("attempting to restore camera named %s from chronicle\n",name.c_str());
plVirtualCam1::Instance()->AddMsgToLog(str.c_str());
if (name.Compare("empty") == 0)
return;
if ( name || name[0] != 0)
if ( !name.IsEmpty() )
{
key=plKeyFinder::Instance().StupidSearch(nil,nil,plSceneObject::Index(), name, false);
}
@ -2487,9 +2482,8 @@ void cyMisc::RebuildCameraStack(const char* name, const char* ageName)
{
// give up and force built in 3rd person
plVirtualCam1::Instance()->PushThirdPerson();
char errmsg[256];
sprintf(errmsg,"Sceneobject %s not found",name);
PyErr_SetString(PyExc_NameError, errmsg);
plString errmsg = plString::Format("Sceneobject %s not found",name.c_str());
PyErr_SetString(PyExc_NameError, errmsg.c_str());
}
}
else
@ -2512,9 +2506,8 @@ void cyMisc::RebuildCameraStack(const char* name, const char* ageName)
}
}
plVirtualCam1::Instance()->PushThirdPerson();
char errmsg[256];
sprintf(errmsg,"Sceneobject %s has no camera modifier",name);
PyErr_SetString(PyExc_NameError, errmsg);
plString errmsg = plString::Format("Sceneobject %s has no camera modifier",name.c_str());
PyErr_SetString(PyExc_NameError, errmsg.c_str());
}
}
@ -2676,10 +2669,10 @@ void cyMisc::FakeLinkToObject(pyKey& avatar, pyKey& object)
plgDispatch::MsgSend(msg);
}
void cyMisc::FakeLinkToObjectNamed(const char* name)
void cyMisc::FakeLinkToObjectNamed(const plString& name)
{
plKey key = nil;
if ( name || name[0] != 0)
if ( !name.IsEmpty() )
{
key = plKeyFinder::Instance().StupidSearch(nil,nil,plSceneObject::Index(), name, false);
}

View File

@ -142,8 +142,8 @@ public:
// PURPOSE : Execute a console command from a python script,
// optionally propagate over the net
//
static PyObject* FindSceneObject(const char* name, const char* ageName); // returns pySceneObject
static PyObject* FindActivator(const char* name); // returns pyKey
static PyObject* FindSceneObject(const plString& name, const char* ageName); // returns pySceneObject
static PyObject* FindActivator(const plString& name); // returns pyKey
/////////////////////////////////////////////////////////////////////////////
//
@ -252,7 +252,7 @@ public:
// PURPOSE : Return the net client (account) name of the player whose avatar
// key is provided.
//
static const char* GetClientName(pyKey &avKey);
static plString GetClientName(pyKey &avKey);
static PyObject* GetAvatarKeyFromClientID(int clientID); // returns pyKey
static int GetLocalClientID();
@ -268,7 +268,7 @@ public:
//
// PURPOSE : Return the local net client (account) name
//
static const char* GetLocalClientName();
static plString GetLocalClientName();
//
@ -697,8 +697,8 @@ public:
static void SetParticleOffset(float x, float y, float z, pyKey& particles);
static void KillParticles(float time, float pct, pyKey& particles);
static int GetNumParticles(pyKey& host);
static void SetLightColorValue(pyKey& light, std::string lightName, float r, float g, float b, float a);
static void SetLightAnimationOn(pyKey& light, std::string lightName, hsBool start);
static void SetLightColorValue(pyKey& light, const plString& lightName, float r, float g, float b, float a);
static void SetLightAnimationOn(pyKey& light, const plString& lightName, hsBool start);
//////////////////////////////////////////////////////////////////////////////
//
// Function : RegisterForControlEventMessages
@ -799,7 +799,7 @@ public:
static int GetNumCameras();
static const char* GetCameraNumber(int number);
static void RebuildCameraStack(const char* name, const char* ageName);
static void RebuildCameraStack(const plString& name, const char* ageName);
static void PyClearCameraStack();
static void RecenterCamera();
static bool IsFirstPerson();
@ -877,8 +877,8 @@ public:
// PURPOSE : takes an avatar key and an object key and fake-links the avatar
// to that object's position. appears to be a link to other players
//
static void FakeLinkToObject(pyKey& avatar, pyKey& object);
static void FakeLinkToObjectNamed(const char* name);
static void FakeLinkToObject(pyKey& avatar, pyKey& object);
static void FakeLinkToObjectNamed(const plString& name);
//////////////////////////////////////////////////////////////////////////////
//

View File

@ -112,10 +112,10 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtGetClientName, args, "Params: avatarKey=None\n
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(keyObj);
return PyString_FromString(cyMisc::GetClientName(*key));
return PyString_FromString(cyMisc::GetClientName(*key).s_str());
}
else
return PyString_FromString(cyMisc::GetLocalClientName());
return PyString_FromString(cyMisc::GetLocalClientName().c_str());
}
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetLocalAvatar, "This will return a ptSceneobject of the local avatar\n"

View File

@ -183,7 +183,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtFindSceneobject, args, "Params: name,ageName\n
PyErr_SetString(PyExc_TypeError, "PtFindSceneobject expects two strings");
PYTHON_RETURN_ERROR;
}
return cyMisc::FindSceneObject(name, ageName);
return cyMisc::FindSceneObject(plString::FromUtf8(name), ageName);
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtFindActivator, args, "Params: name\nThis will try to find an activator based on its name\n"
@ -197,7 +197,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtFindActivator, args, "Params: name\nThis will
PYTHON_RETURN_ERROR;
}
return cyMisc::FindActivator(name);
return cyMisc::FindActivator(plString::FromUtf8(name));
}
PYTHON_BASIC_GLOBAL_METHOD_DEFINITION(PtClearCameraStack, cyMisc::ClearCameraStack, "Clears the camera stack")

View File

@ -141,23 +141,17 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtSetLightValue, args, "Params: key,name,r,g,b,a
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(keyObj);
std::string name = "";
plString name;
if (PyUnicode_Check(nameObj))
{
int strLen = PyUnicode_GetSize(nameObj);
wchar_t* text = new wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)nameObj, text, strLen);
text[strLen] = L'\0';
char* cText = hsWStringToString(text);
name = cText;
delete [] cText;
delete [] text;
PyObject* utf8 = PyUnicode_AsUTF8String(nameObj);
name = plString::FromUtf8(PyString_AsString(utf8));
Py_DECREF(utf8);
}
else if (PyString_Check(nameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(nameObj);
name = text;
name = plString::FromUtf8(PyString_AsString(nameObj));
}
else
{
@ -184,23 +178,17 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtSetLightAnimStart, args, "Params: key,name,sta
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(keyObj);
std::string name = "";
plString name;
if (PyUnicode_Check(nameObj))
{
int strLen = PyUnicode_GetSize(nameObj);
wchar_t* text = new wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)nameObj, text, strLen);
text[strLen] = L'\0';
char* cText = hsWStringToString(text);
name = cText;
delete [] cText;
delete [] text;
PyObject* utf8 = PyUnicode_AsUTF8String(nameObj);
name = plString::FromUtf8(PyString_AsString(utf8));
Py_DECREF(utf8);
}
else if (PyString_Check(nameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(nameObj);
name = text;
name = plString::FromUtf8(PyString_AsString(nameObj));
}
else
{
@ -363,7 +351,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtRebuildCameraStack, args, "Params: name,ageNam
PyErr_SetString(PyExc_TypeError, "PtRebuildCameraStack expects two strings");
PYTHON_RETURN_ERROR;
}
cyMisc::RebuildCameraStack(name, ageName);
cyMisc::RebuildCameraStack(plString::FromUtf8(name), ageName);
PYTHON_RETURN_NONE;
}

View File

@ -334,9 +334,9 @@ void cyPhysics::Move(pyVector3& direction, float distance)
}
else
{
char errmsg[256];
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName());
PyErr_SetString(PyExc_RuntimeError, errmsg);
plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
}
}
}
@ -404,9 +404,9 @@ void cyPhysics::Rotate(float rad, pyVector3& axis)
}
else
{
char errmsg[256];
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName());
PyErr_SetString(PyExc_RuntimeError, errmsg);
plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
}
}
}

View File

@ -331,7 +331,6 @@ hsBool plPythonFileMod::fAtConvertTime = false;
plPythonFileMod::plPythonFileMod()
{
fPythonFile = nil;
fModuleName = nil;
fModule = nil;
fLocalNotify= true;
fIsFirstTimeEval = true;
@ -404,26 +403,25 @@ plPythonFileMod::~plPythonFileMod()
}
// then get rid of this module
// NOTE: fModule shouldn't be made in the plugin, only at runtime
if ( fModuleName && fModule )
if ( !fModuleName.IsNull() && fModule )
{
//_PyModule_Clear(fModule);
PyObject *m;
PyObject *modules = PyImport_GetModuleDict();
if( modules && (m = PyDict_GetItemString(modules, fModuleName)) && PyModule_Check(m))
if( modules && (m = PyDict_GetItemString(modules, fModuleName.c_str())) && PyModule_Check(m))
{
hsStatusMessageF("Module %s removed from python dictionary",fModuleName);
PyDict_DelItemString(modules, fModuleName);
hsStatusMessageF("Module %s removed from python dictionary",fModuleName.c_str());
PyDict_DelItemString(modules, fModuleName.c_str());
}
else
{
hsStatusMessageF("Module %s not found in python dictionary. Already removed?",fModuleName);
hsStatusMessageF("Module %s not found in python dictionary. Already removed?",fModuleName.c_str());
}
// the above code should have unloaded the module from python, so it will delete itself, therefore
// we need to set our pointer to nil to make sure we don't try to use it
fModule = nil;
}
delete [] fModuleName;
fModuleName = nil;
fModuleName = plString::Null;
}
#include "plPythonPack.h"
@ -510,11 +508,8 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
{
plKey pkey = sobj->GetKey();
// nope, must be the first object. Then use it as the basis for the module
char modulename[256];
IMakeModuleName(modulename,sobj);
delete [] fModuleName;
fModuleName = StrDup(modulename);
fModule = PythonInterface::CreateModule(modulename);
fModuleName = IMakeModuleName(sobj);
fModule = PythonInterface::CreateModule(fModuleName.c_str());
// if we can't create the instance then there is nothing to do here
if (!ILoadPythonCode())
@ -634,24 +629,23 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
NamedComponent comp;
comp.isActivator = (isNamedAttr == 1);
comp.id = parameter.fID;
comp.name = new char[strlen(parameter.datarecord.fString) + 1];
strcpy(comp.name, parameter.datarecord.fString);
comp.name = parameter.fString;
fNamedCompQueue.Append(comp);
}
else
{
if (isNamedAttr == 1)
IFindActivatorAndAdd(parameter.datarecord.fString, parameter.fID);
IFindActivatorAndAdd(parameter.fString, parameter.fID);
else
IFindResponderAndAdd(parameter.datarecord.fString, parameter.fID);
IFindResponderAndAdd(parameter.fString, parameter.fID);
}
}
}
// if it wasn't a named string then must be normal string type
if ( isNamedAttr == 0 )
if ( parameter.datarecord.fString != nil )
value = PyString_FromString(parameter.datarecord.fString);
if ( !parameter.fString.IsNull() )
value = PyString_FromString(parameter.fString.c_str());
break;
case plPythonParameter::kSceneObject:
case plPythonParameter::kSceneObjectList:
@ -951,7 +945,7 @@ void plPythonFileMod::HandleDiscardedKey( plKeyEventMsg *msg )
//
// NOTE: This modifier wasn't intended to have multiple targets
//
void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj)
plString plPythonFileMod::IMakeModuleName(plSceneObject* sobj)
{
// Forgive my general crapulance...
// This strips underscores out of module names
@ -960,13 +954,14 @@ void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj)
plKey pKey = GetKey();
plKey sKey = sobj->GetKey();
const char* pKeyName = pKey->GetName();
const char* pSobjName = sKey->GetName();
const char* pKeyName = pKey->GetName().c_str();
const char* pSobjName = sKey->GetName().c_str();
uint16_t len = hsStrlen(pKeyName);
uint16_t slen = hsStrlen(pSobjName);
uint16_t len = pKey->GetName().GetSize();
uint16_t slen = sKey->GetName().GetSize();
hsAssert(len+slen < 256, "Warning: String length exceeds 256 characters.");
char modulename[256];
int i, k = 0;
for(i = 0; i < slen; i++)
@ -983,6 +978,7 @@ void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj)
}
modulename[k] = '\0';
plString name = plString::FromUtf8(modulename);
// check to see if we are attaching to a clone?
plKeyImp* pKeyImp = (plKeyImp*)(sKey);
@ -992,7 +988,7 @@ void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj)
// add the cloneID to the end of the module name
// and set the fIAmAClone flag
uint32_t cloneID = pKeyImp->GetUoid().GetCloneID();
sprintf(modulename,"%s%d",modulename,cloneID);
name += plString::Format("%d", cloneID);
fAmIAttachedToClone = true;
}
@ -1001,8 +997,10 @@ void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj)
{
// if not unique then add the sequence number to the end of the modulename
uint32_t seqID = pKeyImp->GetUoid().GetLocation().GetSequenceNumber();
sprintf(modulename,"%s%d",modulename,seqID);
name += plString::Format("%d", seqID);
}
return name;
}
/////////////////////////////////////////////////////////////////////////////
@ -1047,9 +1045,9 @@ void plPythonFileMod::ISetKeyValue(const plKey& key, int32_t id)
// PURPOSE : find a responder by name in all age and page locations
// : and add to the Parameter list
//
void plPythonFileMod::IFindResponderAndAdd(const char *responderName, int32_t id)
void plPythonFileMod::IFindResponderAndAdd(const plString &responderName, int32_t id)
{
if ( responderName != nil )
if ( !responderName.IsNull() )
{
std::vector<plKey> keylist;
const plLocation &loc = GetKey()->GetUoid().GetLocation();
@ -1075,9 +1073,9 @@ void plPythonFileMod::IFindResponderAndAdd(const char *responderName, int32_t id
// PURPOSE : find a responder by name in all age and page locations
// : and add to the Parameter list
//
void plPythonFileMod::IFindActivatorAndAdd(const char *activatorName, int32_t id)
void plPythonFileMod::IFindActivatorAndAdd(const plString &activatorName, int32_t id)
{
if ( activatorName != nil )
if ( !activatorName.IsNull() )
{
std::vector<plKey> keylist;
const plLocation &loc = GetKey()->GetUoid().GetLocation();
@ -1236,8 +1234,6 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
IFindActivatorAndAdd(comp.name, comp.id);
else
IFindResponderAndAdd(comp.name, comp.id);
delete [] comp.name;
}
fNamedCompQueue.Reset();
@ -1756,9 +1752,9 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
{
// yes...
// call it
char* roomname = "";
const char* roomname = "";
if ( pRLNMsg->GetRoom() != nil )
roomname = (char*)pRLNMsg->GetRoom()->GetName();
roomname = pRLNMsg->GetRoom()->GetName().c_str();
plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(
@ -1965,7 +1961,7 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
if ( mbrIndex != -1 )
{
plNetTransportMember *mbr = plNetClientMgr::GetInstance()->TransportMgr().GetMember( mbrIndex );
player = pyPlayer::New(mbr->GetAvatarKey(), mbr->GetPlayerName(), mbr->GetPlayerID(), mbr->GetDistSq());
player = pyPlayer::New(mbr->GetAvatarKey(), mbr->GetPlayerName().c_str(), mbr->GetPlayerID(), mbr->GetDistSq());
}
else
{
@ -2837,11 +2833,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
//
void plPythonFileMod::ReportError()
{
char objectName[128];
StrCopy(objectName, this->GetKeyName(), arrsize(objectName));
StrPack(objectName, " - ", arrsize(objectName));
plString objectName = this->GetKeyName();
objectName += _TEMP_CONVERT_FROM_LITERAL(" - ");
PythonInterface::WriteToStdErr(objectName);
PythonInterface::WriteToStdErr(objectName.c_str());
PyErr_Print(); // make sure the error is printed
PyErr_Clear(); // clear the error
@ -2984,4 +2979,4 @@ void plPythonFileMod::Write(hsStream* stream, hsResMgr* mgr)
//// kGlobalNameKonstant /////////////////////////////////////////////////
// My continued attempt to spread the CORRECT way to spell konstant. -mcn
char plPythonFileMod::kGlobalNameKonstant[] = "VeryVerySpecialPythonFileMod";
plString plPythonFileMod::kGlobalNameKonstant = _TEMP_CONVERT_FROM_LITERAL("VeryVerySpecialPythonFileMod");

View File

@ -74,10 +74,10 @@ protected:
hsBool IEval(double secs, float del, uint32_t dirty);
void IMakeModuleName(char* modulename,plSceneObject* sobj);
plString IMakeModuleName(plSceneObject* sobj);
char* fPythonFile;
char* fModuleName;
plString fModuleName;
// the list of receivers that want to be notified
hsTArray<plKey> fReceivers;
@ -104,15 +104,15 @@ protected:
struct NamedComponent
{
char* name;
int32_t id;
bool isActivator;
plString name;
int32_t id;
bool isActivator;
};
hsTArray<NamedComponent> fNamedCompQueue;
virtual void IFindResponderAndAdd(const char *responderName, int32_t id);
virtual void IFindActivatorAndAdd(const char *activatorName, int32_t id);
virtual void IFindResponderAndAdd(const plString &responderName, int32_t id);
virtual void IFindActivatorAndAdd(const plString &activatorName, int32_t id);
void ISetKeyValue(const plKey& key, int32_t id);
bool ILoadPythonCode();
@ -210,7 +210,7 @@ public:
static const char* fFunctionNames[];
// The konstant hard-coded name to be used for all global pythonFileMods
static char kGlobalNameKonstant[];
static plString kGlobalNameKonstant;
// API for processing discarded keys as the deafult key catcher
void HandleDiscardedKey( plKeyEventMsg *msg );

View File

@ -94,17 +94,16 @@ public:
// the data of the value
union
{
int32_t fIntNumber;
int32_t fIntNumber;
float fFloatNumber;
float fFloatNumber;
hsBool fBool;
char* fString;
} datarecord;
plKey fObjectKey; // the plKey of the scene object (should be part of the union, but unions don't allow complex types)
plString fString;
plPythonParameter()
@ -147,7 +146,7 @@ public:
SetTobool(other.datarecord.fBool);
break;
case kString:
SetToString(other.datarecord.fString);
SetToString(other.fString);
break;
case kSceneObject:
SetToSceneObject(other.fObjectKey);
@ -174,7 +173,7 @@ public:
SetToAnimation(other.fObjectKey);
break;
case kAnimationName:
SetToAnimationName(other.datarecord.fString);
SetToAnimationName(other.fString);
break;
case kBehavior:
SetToBehavior(other.fObjectKey);
@ -214,10 +213,6 @@ public:
void SetToNone()
{
// remove the string if one was created
if ( fValueType == kString || fValueType == kAnimationName )
delete [] datarecord.fString;
fValueType = kNone;
}
@ -239,11 +234,11 @@ public:
fValueType = kbool;
datarecord.fBool = state;
}
void SetToString(const char* string)
void SetToString(const plString& string)
{
SetToNone();
fValueType = kString;
datarecord.fString = hsStrcpy(string);
fString = string;
}
void SetToSceneObject(plKey key, hsBool list=false)
{
@ -302,11 +297,11 @@ public:
fValueType = kAnimation;
fObjectKey = key;
}
void SetToAnimationName(const char* string)
void SetToAnimationName(const plString& string)
{
SetToNone();
fValueType = kAnimationName;
datarecord.fString = hsStrcpy(string);
fString = string;
}
void SetToBehavior(plKey key)
{
@ -380,11 +375,13 @@ public:
count = stream->ReadLE32();
if ( count != 0 )
{
datarecord.fString = new char[count+1];
stream->ReadLE(count,datarecord.fString);
char *buffer = new char[count];
stream->ReadLE(count, buffer);
buffer[count-1] = 0;
fString = plString::Steal(buffer, count);
}
else
datarecord.fString = nil;
fString = plString::Null;
break;
case kSceneObject:
@ -430,13 +427,13 @@ public:
case kString:
case kAnimationName:
if ( datarecord.fString != nil )
count = hsStrlen(datarecord.fString)+1;
if ( !fString.IsNull() )
count = fString.GetSize()+1;
else
count = 0;
stream->WriteLE(count);
if ( count != 0 )
stream->WriteLE(count,datarecord.fString);
stream->WriteLE(count, fString.c_str());
break;
case kSceneObject:

View File

@ -604,21 +604,20 @@ const plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL()
return sdlMod;
plNetClientApp::StaticErrorMsg("pfmod %s has a nil python SDL modifier for age sdl %s",
pfmod->GetKeyName() ? pfmod->GetKeyName() : "?", ageName);
pfmod->GetKeyName().s_str("?"), ageName);
}
else
{
char str[256];
if (!key)
plNetClientApp::StaticErrorMsg("nil key %s for age sdl %s", ageName, oid.StringIze(str));
plNetClientApp::StaticErrorMsg("nil key %s for age sdl %s", ageName, oid.StringIze().c_str());
else
if (!key->ObjectIsLoaded())
plNetClientApp::StaticErrorMsg("key %s not loaded for age sdl %s",
key->GetName() ? key->GetName() : "?", ageName);
key->GetName().s_str("?"), ageName);
else
if (!plPythonFileMod::ConvertNoRef(key->ObjectIsLoaded()))
plNetClientApp::StaticErrorMsg("key %s is not a python file mod for age sdl %s",
key->GetName() ? key->GetName() : "?", ageName);
key->GetName().s_str("?"), ageName);
}
}
else

View File

@ -118,7 +118,7 @@ void pyAgeInfoStruct::SetAgeDescription( const char * v )
const char * pyAgeInfoStruct::GetAgeInstanceGuid() const
{
fAgeInstanceGuidStr = fAgeInfo.GetAgeInstanceGuid()->AsStdString();
fAgeInstanceGuidStr = fAgeInfo.GetAgeInstanceGuid()->AsString();
return fAgeInstanceGuidStr.c_str();
}
@ -164,9 +164,9 @@ const char * pyAgeInfoStruct::GetDisplayName() const
{
int32_t seq = GetAgeSequenceNumber();
if ( seq>0 )
xtl::format( fDisplayName, "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
fDisplayName = plString::Format( "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
else
xtl::format( fDisplayName, "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
fDisplayName = plString::Format( "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
return fDisplayName.c_str();
}
@ -217,7 +217,7 @@ void pyAgeInfoStructRef::SetAgeUserDefinedName( const char * v )
const char * pyAgeInfoStructRef::GetAgeInstanceGuid() const
{
fAgeInstanceGuidStr = fAgeInfo.GetAgeInstanceGuid()->AsStdString();
fAgeInstanceGuidStr = fAgeInfo.GetAgeInstanceGuid()->AsString();
return fAgeInstanceGuidStr.c_str();
}
@ -241,8 +241,8 @@ const char * pyAgeInfoStructRef::GetDisplayName() const
{
int32_t seq = GetAgeSequenceNumber();
if ( seq>0 )
xtl::format( fDisplayName, "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
fDisplayName = plString::Format( "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
else
xtl::format( fDisplayName, "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
fDisplayName = plString::Format( "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
return fDisplayName.c_str();
}

View File

@ -57,14 +57,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class pyVaultAgeInfoNode;
class pyAgeInfoStructRef;
class plString;
class pyAgeInfoStruct
{
private:
plAgeInfoStruct fAgeInfo;
mutable std::string fAgeInstanceGuidStr; // for getting Age Instance GUID
mutable std::string fDisplayName; // used by GetDisplayName()
mutable plString fAgeInstanceGuidStr; // for getting Age Instance GUID
mutable plString fDisplayName; // used by GetDisplayName()
protected:
pyAgeInfoStruct();
@ -112,8 +113,8 @@ private:
static plAgeInfoStruct fDefaultAgeInfo; // created so a default constructor could be made for python. Do NOT use
plAgeInfoStruct & fAgeInfo;
mutable std::string fAgeInstanceGuidStr; // for getting Age Instance GUID
mutable std::string fDisplayName; // used by GetDisplayName()
mutable plString fAgeInstanceGuidStr; // for getting Age Instance GUID
mutable plString fDisplayName; // used by GetDisplayName()
protected:
pyAgeInfoStructRef(): fAgeInfo( fDefaultAgeInfo ) {} // only here for the python glue... do NOT call directly

View File

@ -105,42 +105,42 @@ bool pyCritterBrain::RunningBehavior(const std::string& behaviorName) const
std::string pyCritterBrain::BehaviorName(int behavior) const
{
if (!fBrain)
return false;
return nil;
return fBrain->BehaviorName(behavior);
}
std::string pyCritterBrain::AnimationName(int behavior) const
plString pyCritterBrain::AnimationName(int behavior) const
{
if (!fBrain)
return false;
return plString::Null;
return fBrain->AnimationName(behavior);
}
int pyCritterBrain::CurBehavior() const
{
if (!fBrain)
return false;
return 0;
return fBrain->CurBehavior();
}
int pyCritterBrain::NextBehavior() const
{
if (!fBrain)
return false;
return 0;
return fBrain->NextBehavior();
}
std::string pyCritterBrain::IdleBehaviorName() const
{
if (!fBrain)
return false;
return nil;
return fBrain->IdleBehaviorName();
}
std::string pyCritterBrain::RunBehaviorName() const
{
if (!fBrain)
return false;
return nil;
return fBrain->RunBehaviorName();
}

View File

@ -92,7 +92,7 @@ public:
bool RunningBehavior(const std::string& behaviorName) const;
std::string BehaviorName(int behavior) const;
std::string AnimationName(int behavior) const;
plString AnimationName(int behavior) const;
int CurBehavior() const;
int NextBehavior() const;

View File

@ -200,7 +200,7 @@ PyObject* pyImage::LoadJPEGFromDisk(const wchar_t* filename, uint16_t width, uin
}
// let's create a nice name for this thing based on the filename
std::string name = "PtImageFromDisk_";
plString name = _TEMP_CONVERT_FROM_LITERAL("PtImageFromDisk_");
char* filetext = hsWStringToString(filename);
name = name + filetext;
delete[] filetext;
@ -227,13 +227,9 @@ PyObject* pyImage::LoadPNGFromDisk(const wchar_t* filename, uint16_t width, uint
}
}
// let's create a nice name for this thing based on the filename
std::string name = "PtImageFromDisk_";
char* filetext = hsWStringToString(filename);
name = name + filetext;
delete[] filetext;
name += plString::FromWchar(i);
hsgResMgr::ResMgr()->NewKey(name.c_str(), theMipmap, plLocation::kGlobalFixedLoc);
hsgResMgr::ResMgr()->NewKey(name, theMipmap, plLocation::kGlobalFixedLoc);
return pyImage::New( theMipmap );
}

View File

@ -58,8 +58,7 @@ uint32_t pyJournalBook::fNextKeyID = 0;
void pyJournalBook::IMakeNewKey( void )
{
char name[ 128 ];
sprintf( name, "pyJournalBook-%d", fNextKeyID++ );
plString name = plString::Format( "pyJournalBook-%d", fNextKeyID++ );
hsgResMgr::ResMgr()->NewKey( name, fBook, plLocation::kGlobalFixedLoc );
fBook->GetKey()->RefObject();
@ -96,14 +95,14 @@ pyJournalBook::pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, py
IMakeNewKey();
}
pyJournalBook::pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey, const char *guiName )
pyJournalBook::pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey, const plString &guiName )
{
fBook = new pfJournalBook( esHTMLSource, coverImage.GetKey(), callbackKey.getKey(),
callbackKey.getKey() != nil ? callbackKey.getKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc, guiName );
IMakeNewKey();
}
pyJournalBook::pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey, const char *guiName )
pyJournalBook::pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey, const plString &guiName )
{
fBook = new pfJournalBook( esHTMLSource.c_str(), coverImage.GetKey(), callbackKey.getKey(),
callbackKey.getKey() != nil ? callbackKey.getKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc, guiName );
@ -135,7 +134,7 @@ pyJournalBook::~pyJournalBook()
}
}
void pyJournalBook::MakeBook(std::string esHTMLSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, std::string guiName /* = "" */)
void pyJournalBook::MakeBook(std::string esHTMLSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, plString guiName /* = "" */)
{
if (fBook)
fBook->GetKey()->UnRefObject();
@ -144,11 +143,11 @@ void pyJournalBook::MakeBook(std::string esHTMLSource, plKey coverImageKey /* =
if (callbackKey != nil)
loc = callbackKey->GetUoid().GetLocation();
fBook = new pfJournalBook(esHTMLSource.c_str(), coverImageKey, callbackKey, loc, guiName.c_str());
fBook = new pfJournalBook(esHTMLSource.c_str(), coverImageKey, callbackKey, loc, guiName);
IMakeNewKey();
}
void pyJournalBook::MakeBook(std::wstring esHTMLSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, std::string guiName /* = "" */)
void pyJournalBook::MakeBook(std::wstring esHTMLSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, plString guiName /* = "" */)
{
if (fBook)
fBook->GetKey()->UnRefObject();
@ -157,7 +156,7 @@ void pyJournalBook::MakeBook(std::wstring esHTMLSource, plKey coverImageKey /* =
if (callbackKey != nil)
loc = callbackKey->GetUoid().GetLocation();
fBook = new pfJournalBook(esHTMLSource.c_str(), coverImageKey, callbackKey, loc, guiName.c_str());
fBook = new pfJournalBook(esHTMLSource.c_str(), coverImageKey, callbackKey, loc, guiName);
IMakeNewKey();
}
@ -235,18 +234,18 @@ void pyJournalBook::AllowPageTurning( bool allow )
fBook->AllowPageTurning(allow);
}
void pyJournalBook::SetGUI( const char *guiName )
void pyJournalBook::SetGUI( const plString &guiName )
{
if (fBook != nil)
fBook->SetGUI(guiName);
}
void pyJournalBook::LoadGUI( const char *guiName )
void pyJournalBook::LoadGUI( const plString &guiName )
{
pfJournalBook::LoadGUI(guiName);
}
void pyJournalBook::UnloadGUI( const char *guiName )
void pyJournalBook::UnloadGUI( const plString &guiName )
{
pfJournalBook::UnloadGUI(guiName);
}

View File

@ -78,8 +78,8 @@ protected:
pyJournalBook( std::wstring esHTMLSource, pyKey callbackKey );
pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey );
pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey );
pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey, const char *guiName );
pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey, const char *guiName );
pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey, const plString &guiName );
pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey, const plString &guiName );
public:
virtual ~pyJournalBook();
@ -88,8 +88,8 @@ public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBook);
static PyObject *New(std::string htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, std::string guiName = "");
static PyObject *New(std::wstring htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, std::string guiName = "");
static PyObject *New(std::string htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL(""));
static PyObject *New(std::wstring htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL(""));
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyJournalBook object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyJournalBook); // converts a PyObject to a pyJournalBook (throws error if not correct type)
@ -98,8 +98,8 @@ public:
static void AddPlasmaConstantsClasses(PyObject *m);
// Deletes the existing book and re-creates it, for use by the python glue
void MakeBook(std::string esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, std::string guiName = "");
void MakeBook(std::wstring esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, std::string guiName = "");
void MakeBook(std::string esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL(""));
void MakeBook(std::wstring esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL(""));
// Interface functions per book
virtual void Show( hsBool startOpened );
@ -117,10 +117,10 @@ public:
virtual void SetSize( float width, float height );
virtual void SetGUI( const char *guiName );
virtual void SetGUI( const plString &guiName );
static void LoadGUI( const char *guiName );
static void UnloadGUI( const char *guiName );
static void LoadGUI( const plString &guiName );
static void UnloadGUI( const plString &guiName );
static void UnloadAllGUIs();
virtual PyObject *GetMovie( uint8_t index ); // returns cyAnimation

View File

@ -101,9 +101,9 @@ PYTHON_INIT_DEFINITION(ptBook, args, keywords)
callbackKey = pyKey::ConvertFrom(callbackObj)->getKey();
}
std::string guiNameStr = "";
plString guiNameStr;
if (guiName)
guiNameStr = guiName;
guiNameStr = plString::FromUtf8(guiName);
// convert the sourcecode object
if (PyUnicode_Check(sourceObj))
@ -225,7 +225,7 @@ PYTHON_METHOD_DEFINITION(ptBook, setGUI, args)
PyErr_SetString(PyExc_TypeError, "setGUI expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetGUI(guiName);
self->fThis->SetGUI(plString::FromUtf8(guiName));
PYTHON_RETURN_NONE;
}
@ -293,14 +293,14 @@ PYTHON_END_METHODS_TABLE;
PLASMA_DEFAULT_TYPE(ptBook, "Params: esHTMLSource,coverImage=None,callbackKey=None,guiName=''\nCreates a new book");
// required functions for PyObject interoperability
PyObject *pyJournalBook::New(std::string htmlSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, std::string guiName /* = "" */)
PyObject *pyJournalBook::New(std::string htmlSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, plString guiName /* = "" */)
{
ptBook *newObj = (ptBook*)ptBook_type.tp_new(&ptBook_type, NULL, NULL);
newObj->fThis->MakeBook(htmlSource, coverImageKey, callbackKey, guiName);
return (PyObject*)newObj;
}
PyObject *pyJournalBook::New(std::wstring htmlSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, std::string guiName /* = "" */)
PyObject *pyJournalBook::New(std::wstring htmlSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, plString guiName /* = "" */)
{
ptBook *newObj = (ptBook*)ptBook_type.tp_new(&ptBook_type, NULL, NULL);
newObj->fThis->MakeBook(htmlSource, coverImageKey, callbackKey, guiName);
@ -329,7 +329,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtLoadBookGUI, args, "Params: guiName\nLoads the
PyErr_SetString(PyExc_TypeError, "PtLoadBookGUI expects a string");
PYTHON_RETURN_ERROR;
}
pyJournalBook::LoadGUI(guiName);
pyJournalBook::LoadGUI(plString::FromUtf8(guiName));
PYTHON_RETURN_NONE;
}
@ -341,7 +341,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtUnloadBookGUI, args, "Params: guiName\nUnloads
PyErr_SetString(PyExc_TypeError, "PtUnloadBookGUI expects a string");
PYTHON_RETURN_ERROR;
}
pyJournalBook::UnloadGUI(guiName);
pyJournalBook::UnloadGUI(plString::FromUtf8(guiName));
PYTHON_RETURN_NONE;
}

View File

@ -52,6 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/plKey.h"
#include "pyGlueHelpers.h"
#include "plString.h"
class plPythonFileMod;
class pySceneObject;
@ -98,7 +99,7 @@ public:
// getter and setters
virtual plKey getKey() { return fKey; }
virtual void setKey(plKey key) { fKey=key; }
virtual const char* getName() const { return fKey ? fKey->GetName() : "nil"; }
virtual const char* getName() const { return fKey ? fKey->GetName().c_str() : "nil"; }
#ifndef BUILDING_PYPLASMA
PyObject* GetPySceneObject();

View File

@ -89,10 +89,10 @@ public:
bool HasServerPort() const { return fInfo.HasServerPort(); }
bool HasServerGuid() const { return fInfo.HasServerGuid(); }
const char * GetServerName() const { return fInfo.GetServerName(); }
uint8_t GetServerType() const { return fInfo.GetServerType(); }
uint8_t GetServerType() const { return fInfo.GetServerType(); }
const char * GetServerAddr() const { return fInfo.GetServerAddr(); }
uint16_t GetServerPort() const { return fInfo.GetServerPort(); }
const char * GetServerGuid() const { fServerGuid.CopyFrom( fInfo.GetServerGuid() ); return fServerGuid.AsString(); }
uint16_t GetServerPort() const { return fInfo.GetServerPort(); }
const char * GetServerGuid() const { fServerGuid.CopyFrom( fInfo.GetServerGuid() ); return fServerGuid.AsString().c_str(); }
};
@ -129,10 +129,10 @@ public:
bool HasServerPort() const { return fInfo.HasServerPort(); }
bool HasServerGuid() const { return fInfo.HasServerGuid(); }
const char * GetServerName() const { return fInfo.GetServerName(); }
uint8_t GetServerType() const { return fInfo.GetServerType(); }
uint8_t GetServerType() const { return fInfo.GetServerType(); }
const char * GetServerAddr() const { return fInfo.GetServerAddr(); }
uint16_t GetServerPort() const { return fInfo.GetServerPort(); }
const char * GetServerGuid() const { fServerGuid.CopyFrom( fInfo.GetServerGuid() ); return fServerGuid.AsString(); }
uint16_t GetServerPort() const { return fInfo.GetServerPort(); }
const char * GetServerGuid() const { fServerGuid.CopyFrom( fInfo.GetServerGuid() ); return fServerGuid.AsString().c_str(); }
};

View File

@ -210,21 +210,21 @@ void pySceneObject::SetNetForce(hsBool state)
}
const char* pySceneObject::GetName()
plString pySceneObject::GetName()
{
if ( fSceneObjects.Count() > 0 )
return fSceneObjects[0]->GetName();
return "";
return _TEMP_CONVERT_FROM_LITERAL("");
}
PyObject* pySceneObject::findObj(const char* name)
PyObject* pySceneObject::findObj(const plString& name)
{
PyObject* pSobj = nil;
// search through the plKeys that we have looking for this name
int i;
for ( i=0; i<fSceneObjects.Count(); i++ )
{
if ( hsStrEQ(name,fSceneObjects[i]->GetName()) )
if ( name == fSceneObjects[i]->GetName() )
{
pSobj = pySceneObject::New(fSceneObjects[i],fPyMod);
break;
@ -235,7 +235,7 @@ PyObject* pySceneObject::findObj(const char* name)
if ( pSobj == nil )
{
// throw a Python error, so the coder knows it didn't work
PyErr_SetString(PyExc_KeyError, name);
PyErr_SetString(PyExc_KeyError, name.c_str());
}
return pSobj;
@ -284,9 +284,9 @@ PyObject* pySceneObject::GetLocalToWorld()
return pyMatrix44::New((hsMatrix44)ci->GetLocalToWorld());
else
{
char errmsg[256];
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName());
PyErr_SetString(PyExc_RuntimeError, errmsg);
plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored
}
}
@ -313,9 +313,9 @@ PyObject* pySceneObject::GetWorldToLocal()
return pyMatrix44::New((hsMatrix44)ci->GetWorldToLocal());
else
{
char errmsg[256];
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName());
PyErr_SetString(PyExc_RuntimeError, errmsg);
plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored
}
}
@ -342,9 +342,9 @@ PyObject* pySceneObject::GetLocalToParent()
return pyMatrix44::New((hsMatrix44)ci->GetLocalToParent());
else
{
char errmsg[256];
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName());
PyErr_SetString(PyExc_RuntimeError, errmsg);
plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored
}
}
@ -371,9 +371,9 @@ PyObject* pySceneObject::GetParentToLocal()
return pyMatrix44::New((hsMatrix44)ci->GetParentToLocal());
else
{
char errmsg[256];
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName());
PyErr_SetString(PyExc_RuntimeError, errmsg);
plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored
}
}
@ -416,9 +416,9 @@ PyObject* pySceneObject::GetWorldPosition()
return pyPoint3::New((hsPoint3)ci->GetWorldPos());
else
{
char errmsg[256];
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName());
PyErr_SetString(PyExc_RuntimeError, errmsg);
plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored
}
}
@ -445,9 +445,9 @@ PyObject* pySceneObject::GetViewVector()
return pyVector3::New(ci->GetLocalToWorld().GetAxis(hsMatrix44::kView));
else
{
char errmsg[256];
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName());
PyErr_SetString(PyExc_RuntimeError, errmsg);
plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored
}
}
@ -474,9 +474,9 @@ PyObject* pySceneObject::GetUpVector()
return pyVector3::New(ci->GetLocalToWorld().GetAxis(hsMatrix44::kUp));
else
{
char errmsg[256];
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName());
PyErr_SetString(PyExc_RuntimeError, errmsg);
plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored
}
}
@ -503,9 +503,9 @@ PyObject* pySceneObject::GetRightVector()
return pyVector3::New(ci->GetLocalToWorld().GetAxis(hsMatrix44::kRight));
else
{
char errmsg[256];
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName());
PyErr_SetString(PyExc_RuntimeError, errmsg);
plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored
}
}

View File

@ -114,9 +114,9 @@ public:
virtual void SetNetForce(hsBool state);
virtual PyObject* findObj(const char* name); // pySceneObject
virtual PyObject* findObj(const plString& name); // pySceneObject
virtual const char* GetName();
virtual plString GetName();
virtual std::vector<PyObject*> GetResponders(); // pyKey list
virtual std::vector<PyObject*> GetPythonMods(); // pyKey list
//

View File

@ -151,12 +151,12 @@ PYTHON_METHOD_DEFINITION(ptSceneobject, findObject, args)
PyErr_SetString(PyExc_TypeError, "findObject expects a string");
PYTHON_RETURN_ERROR;
}
return self->fThis->findObj(name);
return self->fThis->findObj(plString::FromUtf8(name));
}
PYTHON_METHOD_DEFINITION_NOARGS(ptSceneobject, getName)
{
return PyString_FromString(self->fThis->GetName());
return PyString_FromString(self->fThis->GetName().c_str());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptSceneobject, getResponders)

View File

@ -654,25 +654,25 @@ void pyVault::CreateNeighborhood()
link.GetAgeInfo()->SetAgeFilename(kNeighborhoodAgeFilename);
link.GetAgeInfo()->SetAgeInstanceName(kNeighborhoodAgeInstanceName);
std::string title;
std::string desc;
plString title;
plString desc;
unsigned nameLen = StrLen(nc->GetPlayerName());
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S')
unsigned nameLen = nc->GetPlayerName().GetSize();
if (nc->GetPlayerName().CharAt(nameLen - 1) == 's' || nc->GetPlayerName().CharAt(nameLen - 1) == 'S')
{
xtl::format( title, "%s'", nc->GetPlayerName() );
xtl::format( desc, "%s' %s", nc->GetPlayerName(), link.GetAgeInfo()->GetAgeInstanceName() );
title = plString::Format( "%s'", nc->GetPlayerName().c_str() );
desc = plString::Format( "%s' %s", nc->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() );
}
else
{
xtl::format( title, "%s's", nc->GetPlayerName() );
xtl::format( desc, "%s's %s", nc->GetPlayerName(), link.GetAgeInfo()->GetAgeInstanceName() );
title = plString::Format( "%s's", nc->GetPlayerName().c_str() );
desc = plString::Format( "%s's %s", nc->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() );
}
plUUID guid(GuidGenerate());
link.GetAgeInfo()->SetAgeInstanceGuid(&guid);
link.GetAgeInfo()->SetAgeUserDefinedName( title.c_str() );
link.GetAgeInfo()->SetAgeDescription( desc.c_str() );
link.GetAgeInfo()->SetAgeUserDefinedName( _TEMP_CONVERT_TO_CONST_CHAR(title) );
link.GetAgeInfo()->SetAgeDescription( _TEMP_CONVERT_TO_CONST_CHAR(desc) );
VaultRegisterOwnedAge(&link);
}

View File

@ -64,8 +64,7 @@ static unsigned s_keyseq;
//============================================================================
static plKey CreateAndRefImageKey (unsigned nodeId, plMipmap * mipmap) {
char keyName[MAX_PATH];
StrPrintf(keyName, arrsize(keyName), "VaultImg_%u_%u", nodeId, s_keyseq++);
plString keyName = plString::Format("VaultImg_%u_%u", nodeId, s_keyseq++);
plKey key = hsgResMgr::ResMgr()->NewKey(keyName, mipmap, plLocation::kGlobalFixedLoc);