mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Convert username in pyPlayer and pfKIMsg to a plString
This commit is contained in:
@ -259,8 +259,8 @@ static bool DumpSpecificMsgInfo(plMessage* msg, plString& info)
|
||||
|
||||
info = plString::Format("Type: %s Str: %s User: %s(%d) Delay: %f Int: %d",
|
||||
typeName,
|
||||
kiMsg->GetString() != "" ? kiMsg->GetString().c_str() : "(nil)",
|
||||
kiMsg->GetUser() ? kiMsg->GetUser() : "(nil)",
|
||||
kiMsg->GetString().c_str("(nil)"),
|
||||
kiMsg->GetUser().c_str("(nil)"),
|
||||
kiMsg->GetPlayerID(),
|
||||
kiMsg->GetDelay(),
|
||||
kiMsg->GetIntValue());
|
||||
|
@ -64,7 +64,7 @@ class pfKIMsg : public plMessage
|
||||
uint32_t fFlags;
|
||||
|
||||
// for the hack chat message thingy
|
||||
char *fUser;
|
||||
plString fUser;
|
||||
uint32_t fPlayerID;
|
||||
plString fString;
|
||||
|
||||
@ -77,8 +77,8 @@ class pfKIMsg : public plMessage
|
||||
void IInit()
|
||||
{
|
||||
fCommand = kNoCommand;
|
||||
fString = "";
|
||||
fUser = nil;
|
||||
fString = plString::Null;
|
||||
fUser = plString::Null;
|
||||
fPlayerID = 0;
|
||||
fFlags = 0;
|
||||
fDelay = 0.0;
|
||||
@ -180,7 +180,6 @@ class pfKIMsg : public plMessage
|
||||
pfKIMsg() : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); IInit(); }
|
||||
pfKIMsg( uint8_t command ) : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); IInit(); fCommand = command; }
|
||||
pfKIMsg( plKey &receiver, uint8_t command ) : plMessage( nil, nil, nil ) { AddReceiver( receiver ); IInit(); fCommand = command; }
|
||||
~pfKIMsg() { delete [] fUser; }
|
||||
|
||||
CLASSNAME_REGISTER( pfKIMsg );
|
||||
GETINTERFACE_ANY( pfKIMsg, plMessage );
|
||||
@ -189,7 +188,7 @@ class pfKIMsg : public plMessage
|
||||
{
|
||||
plMessage::IMsgRead( s, mgr );
|
||||
s->ReadLE( &fCommand );
|
||||
fUser = s->ReadSafeString();
|
||||
fUser = s->ReadSafeString_TEMP();
|
||||
fPlayerID = s->ReadLE32();
|
||||
fString = s->ReadSafeWString_TEMP();
|
||||
fFlags = s->ReadLE32();
|
||||
@ -214,9 +213,9 @@ class pfKIMsg : public plMessage
|
||||
void SetString( const plString &str ) { fString = str; }
|
||||
plString GetString( void ) { return fString; }
|
||||
|
||||
void SetUser( const char *str, uint32_t pid=0 ) { fUser = hsStrcpy( str ); fPlayerID = pid; }
|
||||
const char *GetUser( void ) { return fUser; }
|
||||
uint32_t GetPlayerID( void ) { return fPlayerID; }
|
||||
void SetUser(const plString &str, uint32_t pid=0) { fUser = str; fPlayerID = pid; }
|
||||
plString GetUser() const { return fUser; }
|
||||
uint32_t GetPlayerID() const { return fPlayerID; }
|
||||
|
||||
void SetFlags( uint32_t flags ) { fFlags = flags; }
|
||||
uint32_t GetFlags( void ) const { return fFlags; }
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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; }
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user