mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 10:37:41 -04:00
PtSendRTChat now accepts a unicode object
This commit is contained in:
@ -1097,6 +1097,39 @@ UInt32 cyMisc::SendRTChat(pyPlayer& from, const std::vector<pyPlayer*> & tolist,
|
||||
return msgFlags;
|
||||
}
|
||||
|
||||
UInt32 cyMisc::SendRTChat(pyPlayer& from, const std::vector<pyPlayer*> & tolist, const wchar_t* message, UInt32 flags)
|
||||
{
|
||||
// create the messge that will contain the chat message
|
||||
pfKIMsg *msg = TRACKED_NEW pfKIMsg( pfKIMsg::kHACKChatMsg );
|
||||
msg->SetString( message );
|
||||
msg->SetUser( from.GetPlayerName(), from.GetPlayerID() );
|
||||
msg->SetFlags( flags );
|
||||
msg->SetBCastFlag(plMessage::kNetPropagate | plMessage::kNetForce);
|
||||
msg->SetBCastFlag(plMessage::kLocalPropagate, 0);
|
||||
|
||||
if (tolist.size() > 0)
|
||||
{
|
||||
if (flags & 8/* kRTChatInterAge in PlasmaKITypes.py */)
|
||||
{
|
||||
// allow inter-age routing of this msg
|
||||
msg->SetBCastFlag( plMessage::kNetAllowInterAge );
|
||||
}
|
||||
// add net rcvrs to msg
|
||||
for ( int i = 0 ; i < tolist.size() ; i++ )
|
||||
{
|
||||
if ( !VaultAmIgnoringPlayer( tolist[i]->GetPlayerID() ) )
|
||||
msg->AddNetReceiver(tolist[i]->GetPlayerID());
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 msgFlags = msg->GetFlags();
|
||||
|
||||
if (tolist.size() == 0 || (msg->GetNetReceivers() && msg->GetNetReceivers()->size() > 0))
|
||||
msg->Send();
|
||||
|
||||
return msgFlags;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Function : SendKIMessage
|
||||
|
@ -424,6 +424,7 @@ public:
|
||||
// RETURNS : the flags that were sent with the message (may be modified)
|
||||
//
|
||||
static UInt32 SendRTChat(pyPlayer& from, const std::vector<pyPlayer*> & tolist, const char* message, UInt32 flags);
|
||||
static UInt32 SendRTChat(pyPlayer& from, const std::vector<pyPlayer*> & tolist, const wchar_t* message, UInt32 flags);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -196,9 +196,9 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtSendRTChat, args, "Params: fromPlayer,toPlayer
|
||||
{
|
||||
PyObject* fromPlayerObj = NULL;
|
||||
PyObject* toPlayerListObj = NULL;
|
||||
char* message = NULL;
|
||||
PyObject* message = NULL;
|
||||
unsigned long msgFlags;
|
||||
if (!PyArg_ParseTuple(args, "OOsl", &fromPlayerObj, &toPlayerListObj, &message, &msgFlags))
|
||||
if (!PyArg_ParseTuple(args, "OOOl", &fromPlayerObj, &toPlayerListObj, &message, &msgFlags))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtSendRTChat expects a ptPlayer, a list of ptPlayers, a string, and a long");
|
||||
PYTHON_RETURN_ERROR;
|
||||
@ -232,7 +232,25 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtSendRTChat, args, "Params: fromPlayer,toPlayer
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
return PyLong_FromUnsignedLong(cyMisc::SendRTChat(*fromPlayer, toPlayerList, message, msgFlags));
|
||||
if (PyString_Check(message))
|
||||
{
|
||||
char* msg = PyString_AsString(message);
|
||||
return PyLong_FromUnsignedLong(cyMisc::SendRTChat(*fromPlayer, toPlayerList, msg, msgFlags));
|
||||
}
|
||||
else if (PyUnicode_Check(message))
|
||||
{
|
||||
Py_ssize_t size = PyUnicode_GetSize(message);
|
||||
wchar_t* msg = TRACKED_NEW wchar_t[size];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)message, msg, size);
|
||||
UInt32 retval = cyMisc::SendRTChat(*fromPlayer, toPlayerList, msg, msgFlags);
|
||||
DEL(msg);
|
||||
return PyLong_FromUnsignedLong(retval);
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtSendRTChat expects a ptPlayer, a list of ptPlayers, a string, and a long");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtSendKIMessage, args, "Params: command,value\nSends a command message to the KI frontend.\n"
|
||||
|
Reference in New Issue
Block a user