diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp index 69b5faeb..747a1b71 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp @@ -1097,6 +1097,39 @@ UInt32 cyMisc::SendRTChat(pyPlayer& from, const std::vector & tolist, return msgFlags; } +UInt32 cyMisc::SendRTChat(pyPlayer& from, const std::vector & 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 diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.h b/Sources/Plasma/FeatureLib/pfPython/cyMisc.h index fe2afa51..f0cb8207 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.h +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.h @@ -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 & tolist, const char* message, UInt32 flags); + static UInt32 SendRTChat(pyPlayer& from, const std::vector & tolist, const wchar_t* message, UInt32 flags); ///////////////////////////////////////////////////////////////////////////// // diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp index 2a2c842d..c8914d1d 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp @@ -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"