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

Convert username in pyPlayer and pfKIMsg to a plString

This commit is contained in:
2014-01-09 18:58:49 -08:00
parent 71a36424de
commit a931c7ca33
6 changed files with 33 additions and 34 deletions

View File

@ -647,7 +647,7 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
// if it wasn't a named string then must be normal string type
if ( isNamedAttr == 0 )
if ( !parameter.fString.IsNull() )
value = PyString_FromString(parameter.fString.c_str());
value = PyString_FromPlString(parameter.fString);
break;
case plPythonParameter::kSceneObject:
case plPythonParameter::kSceneObjectList:
@ -1882,7 +1882,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
case pfKIMsg::kRateIt:
value = PyTuple_New(3);
str = pkimsg->GetString().ToWchar();
PyTuple_SetItem(value,0,PyString_FromString(pkimsg->GetUser()));
PyTuple_SetItem(value,0,PyString_FromPlString(pkimsg->GetUser()));
PyTuple_SetItem(value,1,PyUnicode_FromWideChar(str, str.GetSize()));
PyTuple_SetItem(value,2,PyLong_FromLong(pkimsg->GetIntValue()));
break;
@ -1999,7 +1999,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
if ( mbrIndex != -1 )
{
plNetTransportMember *mbr = plNetClientMgr::GetInstance()->TransportMgr().GetMember( mbrIndex );
player = pyPlayer::New(mbr->GetAvatarKey(), mbr->GetPlayerName().c_str(), mbr->GetPlayerID(), mbr->GetDistSq());
player = pyPlayer::New(mbr->GetAvatarKey(), mbr->GetPlayerName(), mbr->GetPlayerID(), mbr->GetDistSq());
}
else
{
@ -2155,8 +2155,8 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
else
{
// else if we could not find the player in our list, then just return a string of the user's name
const char * fromName = pkimsg->GetUser();
if (!fromName)
plString fromName = pkimsg->GetUser();
if (fromName.IsEmpty())
fromName = "Anonymous Coward";
player = pyPlayer::New(plNetClientMgr::GetInstance()->GetLocalPlayerKey(), fromName, pkimsg->GetPlayerID(), 0.0);
}

View File

@ -48,14 +48,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
pyPlayer::pyPlayer() // only used by python glue, do NOT call
{
fAvatarKey = nil;
fPlayerName = "";
fPlayerName = plString::Null;
fPlayerID = 0;
fDistSq = -1;
fIsCCR = false;
fIsServer = false;
}
pyPlayer::pyPlayer(pyKey& avKey, const char* pname, uint32_t pid, float distsq)
pyPlayer::pyPlayer(pyKey& avKey, const plString& pname, uint32_t pid, float distsq)
{
fAvatarKey = avKey.getKey();
fPlayerName = pname;
@ -65,7 +65,7 @@ pyPlayer::pyPlayer(pyKey& avKey, const char* pname, uint32_t pid, float distsq)
fIsServer = false;
}
pyPlayer::pyPlayer(plKey avKey, const char* pname, uint32_t pid, float distsq)
pyPlayer::pyPlayer(plKey avKey, const plString& pname, uint32_t pid, float distsq)
{
fAvatarKey = avKey;
fPlayerName = pname;
@ -76,7 +76,7 @@ pyPlayer::pyPlayer(plKey avKey, const char* pname, uint32_t pid, float distsq)
}
// another way to create a player with just a name and number
pyPlayer::pyPlayer(const char* pname, uint32_t pid)
pyPlayer::pyPlayer(const plString& pname, uint32_t pid)
{
fAvatarKey = nil;
fPlayerName = pname;
@ -86,7 +86,7 @@ pyPlayer::pyPlayer(const char* pname, uint32_t pid)
fIsServer = false;
}
void pyPlayer::Init(plKey avKey, const char* pname, uint32_t pid, float distsq) // used by python glue, do NOT call
void pyPlayer::Init(plKey avKey, const plString& pname, uint32_t pid, float distsq) // used by python glue, do NOT call
{
fAvatarKey = avKey;
fPlayerName = pname;

View File

@ -51,31 +51,31 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGlueHelpers.h"
#include "pnKeyedObject/plKey.h"
#include <string>
#include "plString.h"
class pyPlayer
{
protected:
plKey fAvatarKey;
std::string fPlayerName;
plString fPlayerName;
uint32_t fPlayerID;
float fDistSq; // from local player, temp
bool fIsCCR;
bool fIsServer;
pyPlayer(); // only used by python glue, do NOT call
pyPlayer(pyKey& avKey, const char* pname, uint32_t pid, float distsq);
pyPlayer(plKey avKey, const char* pname, uint32_t pid, float distsq);
pyPlayer(pyKey& avKey, const plString& pname, uint32_t pid, float distsq);
pyPlayer(plKey avKey, const plString& pname, uint32_t pid, float distsq);
// another way to create a player with just a name and number
pyPlayer(const char* pname, uint32_t pid);
pyPlayer(const plString& pname, uint32_t pid);
public:
void Init(plKey avKey, const char* pname, uint32_t pid, float distsq); // used by python glue, do NOT call
void Init(plKey avKey, const plString& pname, uint32_t pid, float distsq); // used by python glue, do NOT call
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptPlayer);
static PyObject *New(pyKey& avKey, const char* pname, uint32_t pid, float distsq);
static PyObject *New(plKey avKey, const char* pname, uint32_t pid, float distsq);
static PyObject *New(const char* pname, uint32_t pid);
static PyObject *New(pyKey& avKey, const plString& pname, uint32_t pid, float distsq);
static PyObject *New(plKey avKey, const plString& pname, uint32_t pid, float distsq);
static PyObject *New(const plString& pname, uint32_t pid);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyPlayer object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyPlayer); // converts a PyObject to a pyPlayer (throws error if not correct type)
@ -96,7 +96,7 @@ public:
plKey GetKey() const { return fAvatarKey; }
// for python access
const char * GetPlayerName() const { return fPlayerName.c_str();}
plString GetPlayerName() const { return fPlayerName; }
uint32_t GetPlayerID() const { return fPlayerID; }
float GetDistSq() const { return fDistSq; }

View File

@ -137,7 +137,7 @@ PYTHON_RICH_COMPARE_DEFINITION(ptPlayer, obj1, obj2, compareType)
PYTHON_METHOD_DEFINITION_NOARGS(ptPlayer, getPlayerName)
{
return PyString_FromString(self->fThis->GetPlayerName());
return PyString_FromPlString(self->fThis->GetPlayerName());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptPlayer, getPlayerID)
@ -180,21 +180,21 @@ PYTHON_END_METHODS_TABLE;
PLASMA_CUSTOM_TYPE(ptPlayer, "Params: avkey,name,playerID,distanceSq\nAnd optionally __init__(name,playerID)");
// required functions for PyObject interoperability
PyObject *pyPlayer::New(pyKey& avKey, const char* pname, uint32_t pid, float distsq)
PyObject *pyPlayer::New(pyKey& avKey, const plString& pname, uint32_t pid, float distsq)
{
ptPlayer *newObj = (ptPlayer*)ptPlayer_type.tp_new(&ptPlayer_type, NULL, NULL);
newObj->fThis->Init(avKey.getKey(), pname, pid, distsq);
return (PyObject*)newObj;
}
PyObject *pyPlayer::New(plKey avKey, const char* pname, uint32_t pid, float distsq)
PyObject *pyPlayer::New(plKey avKey, const plString& pname, uint32_t pid, float distsq)
{
ptPlayer *newObj = (ptPlayer*)ptPlayer_type.tp_new(&ptPlayer_type, NULL, NULL);
newObj->fThis->Init(avKey, pname, pid, distsq);
return (PyObject*)newObj;
}
PyObject *pyPlayer::New(const char* pname, uint32_t pid)
PyObject *pyPlayer::New(const plString& pname, uint32_t pid)
{
ptPlayer *newObj = (ptPlayer*)ptPlayer_type.tp_new(&ptPlayer_type, NULL, NULL);
newObj->fThis->Init(nil, pname, pid, -1);