Browse Source

Merge pull request #318 from Hoikas/ccr-bcast

Global Chat Messages
Adam Johnson 12 years ago
parent
commit
99019becb0
  1. 4
      Sources/Plasma/FeatureLib/pfMessage/pfKIMsg.h
  2. 66
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  3. 3
      Sources/Plasma/FeatureLib/pfPython/cyMisc.h
  4. 63
      Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp
  5. 42
      Sources/Plasma/FeatureLib/pfPython/pyVault.cpp
  6. 28
      Sources/Plasma/FeatureLib/pfPython/pyVault.h
  7. 10
      Sources/Plasma/FeatureLib/pfPython/pyVaultGlue.cpp
  8. 17
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp

4
Sources/Plasma/FeatureLib/pfMessage/pfKIMsg.h

@ -160,8 +160,8 @@ class pfKIMsg : public plMessage
{
kPrivateMsg = 0x00000001,
kAdminMsg = 0x00000002,
kDead = 0x00000004,
kUNUSED1 = 0x00000008,
kGlobalMsg = 0x00000004,
kInterAgeMsg = 0x00000008,
kStatusMsg = 0x00000010,
kNeighborMsg = 0x00000020, // sending to all the neighbors
kChannelMask = 0x0000ff00

66
Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp

@ -1110,7 +1110,7 @@ float cyMisc::GetMaxListenDistSq()
//
// RETURNS : the flags that were sent with the message (may be modified)
//
uint32_t cyMisc::SendRTChat(pyPlayer& from, const std::vector<pyPlayer*> & tolist, const char* message, uint32_t flags)
uint32_t cyMisc::SendRTChat(const pyPlayer& from, const std::vector<pyPlayer*> & tolist, const plString& message, uint32_t flags)
{
// create the messge that will contain the chat message
pfKIMsg *msg = new pfKIMsg( pfKIMsg::kHACKChatMsg );
@ -1120,61 +1120,23 @@ uint32_t cyMisc::SendRTChat(pyPlayer& from, const std::vector<pyPlayer*> & tolis
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
int i;
for ( i=0 ; i<tolist.size() ; i++ )
{
if ( !VaultAmIgnoringPlayer( tolist[i]->GetPlayerID() ) )
msg->AddNetReceiver(tolist[i]->GetPlayerID());
}
}
uint32_t msgFlags = msg->GetFlags();
if (tolist.size() == 0 || (msg->GetNetReceivers() && msg->GetNetReceivers()->size() > 0))
msg->Send();
return msgFlags;
}
uint32_t cyMisc::SendRTChat(pyPlayer& from, const std::vector<pyPlayer*> & tolist, const wchar_t* message, uint32_t flags)
{
// create the messge that will contain the chat message
pfKIMsg *msg = new pfKIMsg( pfKIMsg::kHACKChatMsg );
msg->SetString( plString::FromWchar(message) );
msg->SetUser( from.GetPlayerName(), from.GetPlayerID() );
msg->SetFlags( flags );
msg->SetBCastFlag(plMessage::kNetPropagate | plMessage::kNetForce);
msg->SetBCastFlag(plMessage::kLocalPropagate, 0);
// this goes to everybody on the shard
if (flags & pfKIMsg::kGlobalMsg)
msg->SetBCastFlag(plMessage::kCCRSendToAllPlayers);
// allow inter-age routing of this msg
if (flags & pfKIMsg::kInterAgeMsg)
msg->SetBCastFlag( plMessage::kNetAllowInterAge );
if (tolist.size() > 0)
// add net rcvrs to msg
for ( auto it = tolist.begin(); it != tolist.end(); ++it )
{
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());
}
pyPlayer* to = *it;
if ( !VaultAmIgnoringPlayer( to->GetPlayerID() ) )
msg->AddNetReceiver(to->GetPlayerID());
}
uint32_t msgFlags = msg->GetFlags();
if (tolist.size() == 0 || (msg->GetNetReceivers() && msg->GetNetReceivers()->size() > 0))
msg->Send();
return msgFlags;
msg->Send();
return flags;
}
/////////////////////////////////////////////////////////////////////////////

3
Sources/Plasma/FeatureLib/pfPython/cyMisc.h

@ -462,8 +462,7 @@ public:
//
// RETURNS : the flags that were sent with the message (may be modified)
//
static uint32_t SendRTChat(pyPlayer& from, const std::vector<pyPlayer*> & tolist, const char* message, uint32_t flags);
static uint32_t SendRTChat(pyPlayer& from, const std::vector<pyPlayer*> & tolist, const wchar_t* message, uint32_t flags);
static uint32_t SendRTChat(const pyPlayer& from, const std::vector<pyPlayer*> & tolist, const plString& message, uint32_t flags);
/////////////////////////////////////////////////////////////////////////////
//

63
Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp

@ -233,60 +233,47 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtSendRTChat, args, "Params: fromPlayer,toPlayer
PyObject* fromPlayerObj = NULL;
PyObject* toPlayerListObj = NULL;
PyObject* message = NULL;
unsigned long msgFlags;
if (!PyArg_ParseTuple(args, "OOOl", &fromPlayerObj, &toPlayerListObj, &message, &msgFlags))
uint32_t msgFlags = 0;
const char* err = "PtSendRTChat expects a ptPlayer, a sequence of ptPlayers, a string, and an optional long";
if (!PyArg_ParseTuple(args, "OOO|l", &fromPlayerObj, &toPlayerListObj, &message, &msgFlags))
{
PyErr_SetString(PyExc_TypeError, "PtSendRTChat expects a ptPlayer, a list of ptPlayers, a string, and a long");
PyErr_SetString(PyExc_TypeError, err);
PYTHON_RETURN_ERROR;
}
if (!pyPlayer::Check(fromPlayerObj))
{
PyErr_SetString(PyExc_TypeError, "PtSendRTChat expects a ptPlayer, a list of ptPlayers, a string, and a long");
PyErr_SetString(PyExc_TypeError, err);
PYTHON_RETURN_ERROR;
}
pyPlayer* sender = pyPlayer::ConvertFrom(fromPlayerObj);
pyPlayer* fromPlayer = pyPlayer::ConvertFrom(fromPlayerObj);
std::vector<pyPlayer*> toPlayerList;
if (PyList_Check(toPlayerListObj))
{
int listSize = PyList_Size(toPlayerListObj);
for (int i = 0; i < listSize; i++)
{
PyObject* listItem = PyList_GetItem(toPlayerListObj, i);
if (!pyPlayer::Check(listItem))
{
PyErr_SetString(PyExc_TypeError, "PtSendRTChat expects a ptPlayer, a list of ptPlayers, a string, and a long");
PYTHON_RETURN_ERROR;
}
toPlayerList.push_back(pyPlayer::ConvertFrom(listItem));
}
}
else
if (!PySequence_Check(toPlayerListObj))
{
PyErr_SetString(PyExc_TypeError, "PtSendRTChat expects a ptPlayer, a list of ptPlayers, a string, and a long");
PyErr_SetString(PyExc_TypeError, err);
PYTHON_RETURN_ERROR;
}
if (PyString_Check(message))
{
char* msg = PyString_AsString(message);
return PyLong_FromUnsignedLong(cyMisc::SendRTChat(*fromPlayer, toPlayerList, msg, msgFlags));
}
else if (PyUnicode_Check(message))
std::vector<pyPlayer*> toPlayers;
toPlayers.reserve(PySequence_Size(toPlayerListObj));
for (Py_ssize_t i = 0; i < PySequence_Size(toPlayerListObj); ++i)
{
int size = PyUnicode_GetSize(message);
wchar_t* msg = new wchar_t[size + 1]; msg[size] = 0;
PyUnicode_AsWideChar((PyUnicodeObject*)message, msg, size);
uint32_t retval = cyMisc::SendRTChat(*fromPlayer, toPlayerList, msg, msgFlags);
delete msg;
return PyLong_FromUnsignedLong(retval);
PyObject* item = PySequence_GetItem(toPlayerListObj, i);
if (!pyPlayer::Check(item))
{
PyErr_SetString(PyExc_TypeError, err);
PYTHON_RETURN_ERROR;
}
toPlayers.push_back(pyPlayer::ConvertFrom(item));
}
else
if (!PyString_CheckEx(message))
{
PyErr_SetString(PyExc_TypeError, "PtSendRTChat expects a ptPlayer, a list of ptPlayers, a string, and a long");
PyErr_SetString(PyExc_TypeError, err);
PYTHON_RETURN_ERROR;
}
plString chatmsg = PyString_AsStringEx(message);
return PyLong_FromUnsignedLong(cyMisc::SendRTChat(*sender, toPlayers, chatmsg, msgFlags));
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtSendKIMessage, args, "Params: command,value\nSends a command message to the KI frontend.\n"

42
Sources/Plasma/FeatureLib/pfPython/pyVault.cpp

@ -121,7 +121,7 @@ static PyObject * GetAgeInfoList (unsigned folderType) {
}
//////////////////////////////////////////////////
PyObject* pyVault::GetPlayerInfo( void )
PyObject* pyVault::GetPlayerInfo()
{
PyObject * result = nil;
if (RelVaultNode * rvnPlr = VaultGetPlayerNodeIncRef()) {
@ -140,7 +140,7 @@ PyObject* pyVault::GetPlayerInfo( void )
}
PyObject* pyVault::GetAvatarOutfitFolder( void )
PyObject* pyVault::GetAvatarOutfitFolder()
{
PyObject * result = GetFolder(plVault::kAvatarOutfitFolder);
@ -152,7 +152,7 @@ PyObject* pyVault::GetAvatarOutfitFolder( void )
PYTHON_RETURN_NONE;
}
PyObject* pyVault::GetAvatarClosetFolder( void )
PyObject* pyVault::GetAvatarClosetFolder()
{
PyObject * result = GetFolder(plVault::kAvatarClosetFolder);
@ -164,7 +164,7 @@ PyObject* pyVault::GetAvatarClosetFolder( void )
PYTHON_RETURN_NONE;
}
PyObject* pyVault::GetChronicleFolder( void )
PyObject* pyVault::GetChronicleFolder()
{
PyObject * result = GetFolder(plVault::kChronicleFolder);
@ -176,7 +176,7 @@ PyObject* pyVault::GetChronicleFolder( void )
PYTHON_RETURN_NONE;
}
PyObject* pyVault::GetInbox( void )
PyObject* pyVault::GetInbox()
{
PyObject * result = GetFolder(plVault::kInboxFolder);
@ -188,7 +188,7 @@ PyObject* pyVault::GetInbox( void )
PYTHON_RETURN_NONE;
}
PyObject* pyVault::GetAgeJournalsFolder( void )
PyObject* pyVault::GetAgeJournalsFolder()
{
PyObject * result = GetFolder(plVault::kAgeJournalsFolder);
@ -249,8 +249,18 @@ PyObject* pyVault::GetKIUsage(void)
return retVal;
}
PyObject* pyVault::GetAllPlayersFolder()
{
#ifndef PLASMA_EXTERNAL_RELEASE
PyObject* result = GetPlayerInfoList(plVault::kAllPlayersFolder);
if (result)
return result;
#endif
PyObject* pyVault::GetIgnoreListFolder( void )
PYTHON_RETURN_NONE;
}
PyObject* pyVault::GetIgnoreListFolder()
{
PyObject * result = GetPlayerInfoList(plVault::kIgnoreListFolder);
@ -262,7 +272,7 @@ PyObject* pyVault::GetIgnoreListFolder( void )
PYTHON_RETURN_NONE;
}
PyObject* pyVault::GetBuddyListFolder( void )
PyObject* pyVault::GetBuddyListFolder()
{
PyObject * result = GetPlayerInfoList(plVault::kBuddyListFolder);
@ -274,7 +284,7 @@ PyObject* pyVault::GetBuddyListFolder( void )
PYTHON_RETURN_NONE;
}
PyObject* pyVault::GetPeopleIKnowAboutFolder( void )
PyObject* pyVault::GetPeopleIKnowAboutFolder()
{
PyObject * result = GetPlayerInfoList(plVault::kPeopleIKnowAboutFolder);
@ -389,7 +399,7 @@ void pyVault::SendToDevice( pyVaultNode& node, const char * deviceName )
}
PyObject* pyVault::GetAgesICanVisitFolder(void)
PyObject* pyVault::GetAgesICanVisitFolder()
{
PyObject * result = GetAgeInfoList(plVault::kAgesICanVisitFolder);
@ -402,7 +412,7 @@ PyObject* pyVault::GetAgesICanVisitFolder(void)
}
PyObject* pyVault::GetAgesIOwnFolder(void)
PyObject* pyVault::GetAgesIOwnFolder()
{
PyObject * result = GetAgeInfoList(plVault::kAgesIOwnFolder);
@ -415,7 +425,7 @@ PyObject* pyVault::GetAgesIOwnFolder(void)
}
PyObject* pyVault::GetInviteFolder(void)
PyObject* pyVault::GetInviteFolder()
{
PyObject * result = GetFolder(plVault::kPlayerInviteFolder);
@ -506,12 +516,12 @@ void pyVault::UpdatePsnlAgeSDL( pySDLStateDataRecord & pyrec )
templateNode->DecRef();
}
bool pyVault::InMyPersonalAge( void ) const
bool pyVault::InMyPersonalAge() const
{
return VaultAmInMyPersonalAge();
}
bool pyVault::InMyNeighborhoodAge( void ) const
bool pyVault::InMyNeighborhoodAge() const
{
return VaultAmInMyNeighborhoodAge();
}
@ -684,7 +694,7 @@ bool pyVault::SetAgePublic( const pyAgeInfoStruct * ageInfo, bool makePublic )
}
PyObject* pyVault::GetGlobalInbox( void )
PyObject* pyVault::GetGlobalInbox()
{
PyObject * result = nil;
if (RelVaultNode * rvnGlobalInbox = VaultGetGlobalInboxIncRef()) {
@ -725,5 +735,3 @@ PyObject* pyVault::FindNode( pyVaultNode* templateNode ) const
PYTHON_RETURN_NONE;
}

28
Sources/Plasma/FeatureLib/pfPython/pyVault.h

@ -103,16 +103,17 @@ public:
#ifndef BUILDING_PYPLASMA
//////////////////////////////////////////////////
PyObject* GetPlayerInfo( void ); // returns pyVaultNode
PyObject* GetKIUsage(void);
PyObject* GetAvatarOutfitFolder( void ); // returns pyVaultFolderNode
PyObject* GetAvatarClosetFolder( void ); // returns pyVaultFolderNode
PyObject* GetInbox( void ); // returns pyVaultFolderNode
PyObject* GetChronicleFolder( void ); // returns pyVaultFolderNode
PyObject* GetAgeJournalsFolder( void ); // returns pyVaultFolderNode
PyObject* GetIgnoreListFolder( void ); // returns pyVaultPlayerInfoListNode
PyObject* GetBuddyListFolder( void ); // returns pyVaultPlayerInfoListNode
PyObject* GetPeopleIKnowAboutFolder( void ); // returns pyVaultPlayerInfoListNode
PyObject* GetPlayerInfo(); // returns pyVaultNode
PyObject* GetKIUsage();
PyObject* GetAvatarOutfitFolder(); // returns pyVaultFolderNode
PyObject* GetAvatarClosetFolder(); // returns pyVaultFolderNode
PyObject* GetInbox(); // returns pyVaultFolderNode
PyObject* GetChronicleFolder(); // returns pyVaultFolderNode
PyObject* GetAgeJournalsFolder(); // returns pyVaultFolderNode
PyObject* GetAllPlayersFolder();
PyObject* GetIgnoreListFolder(); // returns pyVaultPlayerInfoListNode
PyObject* GetBuddyListFolder(); // returns pyVaultPlayerInfoListNode
PyObject* GetPeopleIKnowAboutFolder(); // returns pyVaultPlayerInfoListNode
PyObject* GetAgesICanVisitFolder(); // returns pyVaultFolderNode
PyObject* GetAgesIOwnFolder(); // returns pyVaultFolderNode
PyObject* GetInviteFolder(); // returns pyVaultFolderNode
@ -139,9 +140,9 @@ public:
///////////////
// true if we are joined to our personal age.
bool InMyPersonalAge( void ) const;
bool InMyPersonalAge() const;
// true if we are joined to our neighborhood age.
bool InMyNeighborhoodAge( void ) const;
bool InMyNeighborhoodAge() const;
// true if we own the age we are in
bool AmOwnerOfCurrentAge() const;
// true if we are czar of the age we are in
@ -175,9 +176,6 @@ public:
bool SetAgePublic( const pyAgeInfoStruct * ageInfo, bool makePublic );
PyObject* GetGlobalInbox( void ); // returns pyVaultFolderNode
#ifdef GlobalInboxTestCode
void CreateGlobalInbox( void );
#endif
// find matching node
PyObject* FindNode( pyVaultNode* templateNode ) const; // returns pyVaultNode

10
Sources/Plasma/FeatureLib/pfPython/pyVaultGlue.cpp

@ -101,6 +101,11 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVault, getAgeJournalsFolder)
return self->fThis->GetAgeJournalsFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVault, getAllPlayersFolder)
{
return self->fThis->GetAllPlayersFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVault, getIgnoreListFolder)
{
return self->fThis->GetIgnoreListFolder();
@ -205,10 +210,6 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVault, getGlobalInbox)
return self->fThis->GetGlobalInbox();
}
#ifdef GlobalInboxTestCode
PYTHON_BASIC_METHOD_DEFINITION(ptVault, createGlobalInbox, CreateGlobalInbox)
#endif
PYTHON_METHOD_DEFINITION(ptVault, findNode, args)
{
PyObject* templateNodeObj = NULL;
@ -476,6 +477,7 @@ PYTHON_START_METHODS_TABLE(ptVault)
"Returns a ptVaultFolderNode of the avatars outfit in their closet."),
PYTHON_METHOD_NOARGS(ptVault, getChronicleFolder, "Returns a ptVaultFolderNode of the current player's chronicle folder."),
PYTHON_METHOD_NOARGS(ptVault, getAgeJournalsFolder, "Returns a ptVaultFolderNode of the current player's age journals folder."),
PYTHON_METHOD_NOARGS(ptVault, getAllPlayersFolder, "Returns a ptVaultPlayerInfoListNode of the all players folder."),
PYTHON_METHOD_NOARGS(ptVault, getIgnoreListFolder, "Returns a ptVaultPlayerInfoListNode of the current player's ignore list folder."),
PYTHON_METHOD_NOARGS(ptVault, getBuddyListFolder, "Returns a ptVaultPlayerInfoListNode of the current player's buddy list folder."),
PYTHON_METHOD_NOARGS(ptVault, getPeopleIKnowAboutFolder, "Returns a ptVaultPlayerInfoListNode of the current player's people I know about (Recent) list folder."),

17
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp

@ -359,12 +359,9 @@ int plNetClientMgr::ISendGameMessage(plMessage* msg)
//
bool ccrSendToAllPlayers = false;
#ifndef PLASMA_EXTERNAL_RELEASE
if ( AmCCR() )
{
ccrSendToAllPlayers = msg->HasBCastFlag( plMessage::kCCRSendToAllPlayers );
if ( ccrSendToAllPlayers )
netMsgWrap->SetBit( plNetMessage::kRouteToAllPlayers );
}
ccrSendToAllPlayers = msg->HasBCastFlag( plMessage::kCCRSendToAllPlayers );
if ( ccrSendToAllPlayers )
netMsgWrap->SetBit( plNetMessage::kRouteToAllPlayers );
#endif
//
@ -382,13 +379,13 @@ int plNetClientMgr::ISendGameMessage(plMessage* msg)
if (msg->HasBCastFlag(plMessage::kNetSendUnreliable) &&
!(synchedObj && (synchedObj->GetSynchFlags() & plSynchedObject::kSendReliably)) )
netMsgWrap->SetBit(plNetMessage::kNeedsReliableSend, 0); // clear reliable net send bit
#ifdef HS_DEBUGGING
int16_t type=*(int16_t*)netMsgWrap->StreamInfo()->GetStreamBuf();
hsAssert(type>=0 && type<plCreatableIndex::plNumClassIndices, "garbage type out");
#endif
netMsgWrap->SetPlayerID(GetPlayerID());
netMsgWrap->SetPlayerID(GetPlayerID());
netMsgWrap->SetNetProtocol(kNetProtocolCli2Game);
int ret = SendMsg(netMsgWrap);
@ -403,7 +400,7 @@ int plNetClientMgr::ISendGameMessage(plMessage* msg)
#endif
}
delete netMsgWrap;
delete netMsgWrap;
return ret;
}

Loading…
Cancel
Save