Browse Source

Merge remote-tracking branch 'hoikas/morefun'

Merge boq's morefun branch to discourage people from releasing incorrect custom builds.
Adam Johnson 12 years ago
parent
commit
aefe778bb7
  1. 99
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  2. 15
      Sources/Plasma/FeatureLib/pfPython/cyMisc.h
  3. 27
      Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp
  4. 16
      Sources/Plasma/FeatureLib/pfPython/cyMiscGlue2.cpp
  5. 38
      Sources/Plasma/FeatureLib/pfPython/cyMiscGlue3.cpp
  6. 16
      Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp
  7. 23
      Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.cpp
  8. 8
      Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.h
  9. 10
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgScreener.cpp
  10. 28
      Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.cpp

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

@ -42,6 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <Python.h>
#include "plgDispatch.h"
#include "hsResMgr.h"
#include "pyKey.h"
#pragma hdrstop
@ -49,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plResMgr/plKeyFinder.h"
#include "pnKeyedObject/plKey.h"
#include "pnKeyedObject/plKeyImp.h"
#include "pnKeyedObject/plFixedKey.h"
#include "plMessage/plLinkToAgeMsg.h"
#include "plMessage/plConsoleMsg.h"
@ -220,6 +222,23 @@ PyObject* cyMisc::FindSceneObject(const plString& name, const char* ageName)
return pySceneObject::New(key);
}
PyObject* cyMisc::FindSceneObjects(const plString& name)
{
// assume that we won't find the sceneobject (key is equal to nil)
std::vector<plKey> keys;
if ( !name.IsNull() )
plKeyFinder::Instance().ReallyStupidSubstringSearch(name, plSceneObject::Index(), keys);
PyObject* result = PyList_New(keys.size());
for (size_t i=0; i < keys.size(); i++)
PyList_SET_ITEM(result, i, pySceneObject::New(keys[i]));
return result;
}
PyObject* cyMisc::FindActivator(const plString& name)
{
plKey key = nil;
@ -302,7 +321,7 @@ void cyMisc::ClearTimerCallbacks(pyKey& selfkey)
//
// PURPOSE : Attach an object to another object, knowing only their pyKeys
//
void cyMisc::AttachObject(pyKey& ckey, pyKey& pkey)
void cyMisc::AttachObject(pyKey& ckey, pyKey& pkey, bool netForce)
{
plKey childKey = ckey.getKey();
plKey parentKey = pkey.getKey();
@ -312,10 +331,16 @@ void cyMisc::AttachObject(pyKey& ckey, pyKey& pkey)
{
// create the attach message to attach the child
plAttachMsg* pMsg = new plAttachMsg(parentKey, childKey->GetObjectPtr(), plRefMsg::kOnRequest);
if (netForce) {
pMsg->SetBCastFlag(plMessage::kNetPropagate);
pMsg->SetBCastFlag(plMessage::kNetForce);
}
plgDispatch::MsgSend( pMsg );
}
}
void cyMisc::AttachObjectSO(pySceneObject& cobj, pySceneObject& pobj)
void cyMisc::AttachObjectSO(pySceneObject& cobj, pySceneObject& pobj, bool netForce)
{
plKey childKey = cobj.getObjKey();
plKey parentKey = pobj.getObjKey();
@ -325,6 +350,12 @@ void cyMisc::AttachObjectSO(pySceneObject& cobj, pySceneObject& pobj)
{
// create the attach message to attach the child
plAttachMsg* pMsg = new plAttachMsg(parentKey, childKey->GetObjectPtr(), plRefMsg::kOnRequest);
if (netForce) {
pMsg->SetBCastFlag(plMessage::kNetPropagate);
pMsg->SetBCastFlag(plMessage::kNetForce);
}
plgDispatch::MsgSend( pMsg );
}
}
@ -338,7 +369,7 @@ void cyMisc::AttachObjectSO(pySceneObject& cobj, pySceneObject& pobj)
//
// PURPOSE : Attach an object to another object, knowing only their pyKeys
//
void cyMisc::DetachObject(pyKey& ckey, pyKey& pkey)
void cyMisc::DetachObject(pyKey& ckey, pyKey& pkey, bool netForce)
{
plKey childKey = ckey.getKey();
plKey parentKey = pkey.getKey();
@ -348,10 +379,16 @@ void cyMisc::DetachObject(pyKey& ckey, pyKey& pkey)
{
// create the attach message to detach the child
plAttachMsg* pMsg = new plAttachMsg(parentKey, childKey->GetObjectPtr(), plRefMsg::kOnRemove);
if (netForce) {
pMsg->SetBCastFlag(plMessage::kNetPropagate);
pMsg->SetBCastFlag(plMessage::kNetForce);
}
plgDispatch::MsgSend( pMsg );
}
}
void cyMisc::DetachObjectSO(pySceneObject& cobj, pySceneObject& pobj)
void cyMisc::DetachObjectSO(pySceneObject& cobj, pySceneObject& pobj, bool netForce)
{
plKey childKey = cobj.getObjKey();
plKey parentKey = pobj.getObjKey();
@ -361,6 +398,12 @@ void cyMisc::DetachObjectSO(pySceneObject& cobj, pySceneObject& pobj)
{
// create the attach message to detach the child
plAttachMsg* pMsg = new plAttachMsg(parentKey, childKey->GetObjectPtr(), plRefMsg::kOnRemove);
if (netForce) {
pMsg->SetBCastFlag(plMessage::kNetPropagate);
pMsg->SetBCastFlag(plMessage::kNetForce);
}
plgDispatch::MsgSend( pMsg );
}
}
@ -1415,7 +1458,7 @@ int cyMisc::GetNumRemotePlayers()
// PURPOSE : page in, hold or out a particular node
//
void cyMisc::PageInNodes(const std::vector<std::string> & nodeNames, const char* age)
void cyMisc::PageInNodes(const std::vector<std::string> & nodeNames, const char* age, bool netForce)
{
if (hsgResMgr::ResMgr())
{
@ -1424,6 +1467,11 @@ void cyMisc::PageInNodes(const std::vector<std::string> & nodeNames, const char*
plKey clientKey = hsgResMgr::ResMgr()->FindKey(kClient_KEY);
msg->AddReceiver(clientKey);
if (netForce) {
msg->SetBCastFlag(plMessage::kNetPropagate);
msg->SetBCastFlag(plMessage::kNetForce);
}
int numNames = nodeNames.size();
for (int i = 0; i < numNames; i++)
msg->AddRoomLoc(plKeyFinder::Instance().FindLocation(age ? age : NetCommGetAge()->ageDatasetName, nodeNames[i].c_str()));
@ -1432,7 +1480,7 @@ void cyMisc::PageInNodes(const std::vector<std::string> & nodeNames, const char*
}
}
void cyMisc::PageOutNode(const char* nodeName)
void cyMisc::PageOutNode(const char* nodeName, bool netForce)
{
if ( hsgResMgr::ResMgr() )
{
@ -1441,6 +1489,11 @@ void cyMisc::PageOutNode(const char* nodeName)
plKey clientKey = hsgResMgr::ResMgr()->FindKey( kClient_KEY );
pMsg1->AddReceiver( clientKey );
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation("", nodeName));
if (netForce) {
pMsg1->SetBCastFlag(plMessage::kNetPropagate);
pMsg1->SetBCastFlag(plMessage::kNetForce);
}
plgDispatch::MsgSend(pMsg1);
}
}
@ -2866,3 +2919,37 @@ void cyMisc::VaultDownload(unsigned nodeId)
nil
);
}
PyObject* cyMisc::CloneKey(pyKey* object, bool loading) {
plKey obj = object->getKey();
plUoid uoid = obj->GetUoid();
plLoadCloneMsg* cloneMsg;
if (uoid.IsClone())
cloneMsg = new plLoadCloneMsg(obj, plNetClientMgr::GetInstance()->GetKey(), 0, loading);
else
cloneMsg = new plLoadCloneMsg(uoid, plNetClientMgr::GetInstance()->GetKey(), 0);
cloneMsg->SetBCastFlag(plMessage::kNetPropagate);
cloneMsg->SetBCastFlag(plMessage::kNetForce);
cloneMsg->Send();
return pyKey::New(cloneMsg->GetCloneKey());
}
PyObject* cyMisc::FindClones(pyKey* object) {
plKey obj = object->getKey();
plUoid uoid = obj->GetUoid();
plKeyImp* imp = ((plKeyImp*)obj);
uint32_t cloneNum = imp->GetNumClones();
PyObject* keyList = PyList_New(cloneNum);
for (int i=0; i < cloneNum; i++) {
PyObject* key = pyKey::New(imp->GetCloneByIdx(i));
PyList_SET_ITEM(keyList, i, key);
}
return keyList;
}

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

@ -147,6 +147,7 @@ public:
// optionally propagate over the net
//
static PyObject* FindSceneObject(const plString& name, const char* ageName); // returns pySceneObject
static PyObject* FindSceneObjects(const plString& name);
static PyObject* FindActivator(const plString& name); // returns pyKey
/////////////////////////////////////////////////////////////////////////////
@ -184,8 +185,8 @@ public:
//
// PURPOSE : Attach an object to another object, knowing only their pyKeys
//
static void AttachObject(pyKey& ckey, pyKey& pkey);
static void AttachObjectSO(pySceneObject& cobj, pySceneObject& pobj);
static void AttachObject(pyKey& ckey, pyKey& pkey, bool netForce);
static void AttachObjectSO(pySceneObject& cobj, pySceneObject& pobj, bool netForce);
/////////////////////////////////////////////////////////////////////////////
//
@ -195,8 +196,8 @@ public:
//
// PURPOSE : Attach an object to another object, knowing only their pyKeys
//
static void DetachObject(pyKey& ckey, pyKey& pkey);
static void DetachObjectSO(pySceneObject& cobj, pySceneObject& pobj);
static void DetachObject(pyKey& ckey, pyKey& pkey, bool netForce);
static void DetachObjectSO(pySceneObject& cobj, pySceneObject& pobj, bool netForce);
/////////////////////////////////////////////////////////////////////////////
//
@ -593,8 +594,8 @@ public:
//
// PURPOSE : page in, or out a paritcular node
//
static void PageInNodes(const std::vector<std::string> & nodeNames, const char* age);
static void PageOutNode(const char* nodeName);
static void PageInNodes(const std::vector<std::string> & nodeNames, const char* age, bool netForce);
static void PageOutNode(const char* nodeName, bool netForce);
/////////////////////////////////////////////////////////////////////////////
//
@ -954,6 +955,8 @@ public:
static PyObject* GetAIAvatarsByModelName(const char* name);
static void ForceVaultNodeUpdate(unsigned nodeId);
static void VaultDownload(unsigned nodeId);
static PyObject* CloneKey(pyKey* object, bool netForce);
static PyObject* FindClones(pyKey* object);
};
#endif // cyMisc_h

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

@ -484,6 +484,31 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtDumpLogs, args, "Params: folder\nDumps all cur
}
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtCloneKey, args, "Params: key, loading=false\nCreates clone of key")
{
PyObject* keyObj = NULL;
char loading = 0;
if (!PyArg_ParseTuple(args, "O|b", &keyObj, &loading) || !pyKey::Check(keyObj))
{
PyErr_SetString(PyExc_TypeError, "PtCloneKey expects a ptKey and bool");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(keyObj);
return cyMisc::CloneKey(key, loading);
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtFindClones, args, "Params: key\nFinds all clones")
{
PyObject* keyObj = NULL;
if (!PyArg_ParseTuple(args, "O", &keyObj) || !pyKey::Check(keyObj))
{
PyErr_SetString(PyExc_TypeError, "PtFindClones expects a ptKey");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(keyObj);
return cyMisc::FindClones(key);
}
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaMethods - the python method definitions
@ -530,6 +555,8 @@ void cyMisc::AddPlasmaMethods(std::vector<PyMethodDef> &methods)
PYTHON_GLOBAL_METHOD(methods, PtGetLocalizedString);
PYTHON_GLOBAL_METHOD(methods, PtDumpLogs);
PYTHON_GLOBAL_METHOD(methods, PtCloneKey);
PYTHON_GLOBAL_METHOD(methods, PtFindClones);
AddPlasmaMethods2(methods);
AddPlasmaMethods3(methods);

16
Sources/Plasma/FeatureLib/pfPython/cyMiscGlue2.cpp

@ -183,11 +183,12 @@ PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetFrameDeltaTime, "Returns the amount
return PyFloat_FromDouble(cyMisc::GetDelSysSeconds());
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtPageInNode, args, "Params: nodeName, ageName=\"\"\nPages in node, or a list of nodes")
PYTHON_GLOBAL_METHOD_DEFINITION(PtPageInNode, args, "Params: nodeName, netForce=false, ageName=\"\"\nPages in node, or a list of nodes")
{
PyObject* nodeNameObj = NULL;
char* ageName = NULL;
if (!PyArg_ParseTuple(args, "O|s", &nodeNameObj, &ageName))
char netForce = 0;
if (!PyArg_ParseTuple(args, "O|bs", &nodeNameObj, &netForce, &ageName))
{
PyErr_SetString(PyExc_TypeError, "PtPageInNode expects a string or list of strings, and optionally a string");
PYTHON_RETURN_ERROR;
@ -217,19 +218,20 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtPageInNode, args, "Params: nodeName, ageName=\
PYTHON_RETURN_ERROR;
}
cyMisc::PageInNodes(nodeNames, ageName);
cyMisc::PageInNodes(nodeNames, ageName, netForce);
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtPageOutNode, args, "Params: nodeName\nPages out a node")
PYTHON_GLOBAL_METHOD_DEFINITION(PtPageOutNode, args, "Params: nodeName, netForce = false\nPages out a node")
{
char* nodeName;
if (!PyArg_ParseTuple(args, "s", &nodeName))
char netForce = 0;
if (!PyArg_ParseTuple(args, "s|b", &nodeName, &netForce))
{
PyErr_SetString(PyExc_TypeError, "PtPageOutNode expects a string");
PyErr_SetString(PyExc_TypeError, "PtPageOutNode expects a string and bool");
PYTHON_RETURN_ERROR;
}
cyMisc::PageOutNode(nodeName);
cyMisc::PageOutNode(nodeName, netForce);
PYTHON_RETURN_NONE;
}

38
Sources/Plasma/FeatureLib/pfPython/cyMiscGlue3.cpp

@ -190,6 +190,17 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtFindSceneobject, args, "Params: name,ageName\n
return cyMisc::FindSceneObject(plString::FromUtf8(name), ageName);
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtFindSceneobjects, args, "Params: name\nThis will try to find a any sceneobject containing string in name")
{
char* name = NULL;
if (!PyArg_ParseTuple(args, "s", &name))
{
PyErr_SetString(PyExc_TypeError, "PtFindSceneobject expects string");
PYTHON_RETURN_ERROR;
}
return cyMisc::FindSceneObjects(plString::FromUtf8(name));
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtFindActivator, args, "Params: name\nThis will try to find an activator based on its name\n"
"- it will return a ptKey if found"
"- it will return None if not found")
@ -223,65 +234,67 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtWasLocallyNotified, args, "Params: selfKey\nRe
PYTHON_RETURN_BOOL(cyMisc::WasLocallyNotified(*key));
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtAttachObject, args, "Params: child,parent\nAttach child to parent based on ptKey or ptSceneobject\n"
PYTHON_GLOBAL_METHOD_DEFINITION(PtAttachObject, args, "Params: child,parent,netForce=false\nAttach child to parent based on ptKey or ptSceneobject\n"
"- childKey is the ptKey or ptSceneobject of the one being attached\n"
"- parentKey is the ptKey or ptSceneobject of the one being attached to\n"
"(both arguments must be ptKeys or ptSceneobjects, you cannot mix types)")
{
PyObject* childObj = NULL;
PyObject* parentObj = NULL;
if (!PyArg_ParseTuple(args, "OO", &childObj, &parentObj))
char netForce = 0;
if (!PyArg_ParseTuple(args, "OO|b", &childObj, &parentObj, &netForce))
{
PyErr_SetString(PyExc_TypeError, "PtAttachObject expects either two ptKeys or two ptSceneobjects");
PyErr_SetString(PyExc_TypeError, "PtAttachObject expects either two ptKeys or two ptSceneobjects and bool");
PYTHON_RETURN_ERROR;
}
if ((pyKey::Check(childObj)) && (pyKey::Check(parentObj)))
{
pyKey* child = pyKey::ConvertFrom(childObj);
pyKey* parent = pyKey::ConvertFrom(parentObj);
cyMisc::AttachObject(*child, *parent);
cyMisc::AttachObject(*child, *parent, netForce);
}
else if ((pySceneObject::Check(childObj)) && (pySceneObject::Check(parentObj)))
{
pySceneObject* child = pySceneObject::ConvertFrom(childObj);
pySceneObject* parent = pySceneObject::ConvertFrom(parentObj);
cyMisc::AttachObjectSO(*child, *parent);
cyMisc::AttachObjectSO(*child, *parent, netForce);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtAttachObject expects either two ptKeys or two ptSceneobjects");
PyErr_SetString(PyExc_TypeError, "PtAttachObject expects either two ptKeys or two ptSceneobjects and bool");
PYTHON_RETURN_ERROR;
}
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtDetachObject, args, "Params: child,parent\nDetach child from parent based on ptKey or ptSceneobject\n"
PYTHON_GLOBAL_METHOD_DEFINITION(PtDetachObject, args, "Params: child,parent,netForce=false\nDetach child from parent based on ptKey or ptSceneobject\n"
"- child is the ptKey or ptSceneobject of the one being detached\n"
"- parent is the ptKey or ptSceneobject of the one being detached from\n"
"(both arguments must be ptKeys or ptSceneobjects, you cannot mix types)")
{
PyObject* childObj = NULL;
PyObject* parentObj = NULL;
if (!PyArg_ParseTuple(args, "OO", &childObj, &parentObj))
char netForce = 0;
if (!PyArg_ParseTuple(args, "OO|b", &childObj, &parentObj, &netForce))
{
PyErr_SetString(PyExc_TypeError, "PtDetachObject expects either two ptKeys or two ptSceneobjects");
PyErr_SetString(PyExc_TypeError, "PtDetachObject expects either two ptKeys or two ptSceneobjects and bool");
PYTHON_RETURN_ERROR;
}
if ((pyKey::Check(childObj)) && (pyKey::Check(parentObj)))
{
pyKey* child = pyKey::ConvertFrom(childObj);
pyKey* parent = pyKey::ConvertFrom(parentObj);
cyMisc::DetachObject(*child, *parent);
cyMisc::DetachObject(*child, *parent, netForce);
}
else if ((pySceneObject::Check(childObj)) && (pySceneObject::Check(parentObj)))
{
pySceneObject* child = pySceneObject::ConvertFrom(childObj);
pySceneObject* parent = pySceneObject::ConvertFrom(parentObj);
cyMisc::DetachObjectSO(*child, *parent);
cyMisc::DetachObjectSO(*child, *parent, netForce);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtDetachObject expects either two ptKeys or two ptSceneobjects");
PyErr_SetString(PyExc_TypeError, "PtDetachObject expects either two ptKeys or two ptSceneobjects and bool");
PYTHON_RETURN_ERROR;
}
PYTHON_RETURN_NONE;
@ -698,6 +711,7 @@ void cyMisc::AddPlasmaMethods3(std::vector<PyMethodDef> &methods)
PYTHON_GLOBAL_METHOD(methods, PtClearTimerCallbacks);
PYTHON_GLOBAL_METHOD(methods, PtFindSceneobject);
PYTHON_GLOBAL_METHOD(methods, PtFindSceneobjects);
PYTHON_GLOBAL_METHOD(methods, PtFindActivator);
PYTHON_BASIC_GLOBAL_METHOD(methods, PtClearCameraStack);
PYTHON_GLOBAL_METHOD(methods, PtWasLocallyNotified);

16
Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp

@ -815,8 +815,8 @@ bool plDynamicTextMap::MsgReceive( plMessage *msg )
if( textMsg->fCmd & plDynamicTextMsg::kSetTextColor )
SetTextColor( textMsg->fColor, textMsg->fBlockRGB );
if( (textMsg->fCmd & plDynamicTextMsg::kSetFont ) && textMsg->fString)
SetFont( textMsg->fString, textMsg->fX, (uint8_t)(textMsg->fFlags) );
if( (textMsg->fCmd & plDynamicTextMsg::kSetFont ) && !textMsg->fString.IsNull())
SetFont( textMsg->fString.ToWchar(), textMsg->fX, (uint8_t)(textMsg->fFlags) );
if( textMsg->fCmd & plDynamicTextMsg::kSetLineSpacing )
SetLineSpacing( textMsg->fLineSpacing );
@ -832,16 +832,16 @@ bool plDynamicTextMap::MsgReceive( plMessage *msg )
FrameRect( textMsg->fLeft, textMsg->fTop, textMsg->fRight - textMsg->fLeft + 1,
textMsg->fBottom - textMsg->fTop + 1, textMsg->fColor );
if( (textMsg->fCmd & plDynamicTextMsg::kDrawString ) && textMsg->fString)
DrawString( textMsg->fX, textMsg->fY, textMsg->fString );
if( (textMsg->fCmd & plDynamicTextMsg::kDrawString ) && !textMsg->fString.IsNull())
DrawString( textMsg->fX, textMsg->fY, textMsg->fString.ToWchar() );
if( (textMsg->fCmd & plDynamicTextMsg::kDrawClippedString ) && textMsg->fString)
DrawClippedString( textMsg->fX, textMsg->fY, textMsg->fString,
if( (textMsg->fCmd & plDynamicTextMsg::kDrawClippedString ) && !textMsg->fString.IsNull())
DrawClippedString( textMsg->fX, textMsg->fY, textMsg->fString.ToWchar(),
textMsg->fLeft, textMsg->fTop, textMsg->fRight - textMsg->fLeft + 1,
textMsg->fBottom - textMsg->fTop + 1 );
if( (textMsg->fCmd & plDynamicTextMsg::kDrawWrappedString ) && textMsg->fString)
DrawWrappedString( textMsg->fX, textMsg->fY, textMsg->fString, textMsg->fRight, textMsg->fBottom );
if( (textMsg->fCmd & plDynamicTextMsg::kDrawWrappedString ) && !textMsg->fString.IsNull())
DrawWrappedString( textMsg->fX, textMsg->fY, textMsg->fString.ToWchar(), textMsg->fRight, textMsg->fBottom );
if( textMsg->fCmd & plDynamicTextMsg::kDrawImage )
{

23
Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.cpp

@ -65,7 +65,7 @@ void plDynamicTextMsg::SetFont( const char *face, int16_t size, bool isBold )
hsAssert( ( fCmd & ( kPosCmds | kStringCmds | kFlagCmds ) ) == 0, "Attempting to issue conflicting drawText commands" );
fCmd &= ~( kPosCmds | kStringCmds | kFlagCmds );
fCmd |= kSetFont;
fString = hsStringToWString( face );
fString = face;
fX = size;
fFlags = (uint32_t)isBold;
}
@ -123,9 +123,7 @@ void plDynamicTextMsg::DrawString( int16_t x, int16_t y, const wchar_t *text
fCmd &= ~( kStringCmds | kPosCmds );
fCmd |= kDrawString;
fString = new wchar_t[wcslen(text)+1];
wcscpy( fString, text );
fString[wcslen(text)] = L'\0';
fString = plString::FromWchar(text);
fX = x;
fY = y;
}
@ -143,9 +141,7 @@ void plDynamicTextMsg::DrawClippedString( int16_t x, int16_t y, uint16_t clip
fCmd &= ~( kStringCmds | kPosCmds | kRectCmds );
fCmd |= kDrawClippedString;
fString = new wchar_t[wcslen(text)+1];
wcscpy( fString, text );
fString[wcslen(text)] = L'\0';
fString = plString::FromWchar(text);
fX = x;
fY = y;
@ -168,9 +164,7 @@ void plDynamicTextMsg::DrawWrappedString( int16_t x, int16_t y, uint16_t wrap
fCmd &= ~( kStringCmds | kPosCmds | kRectCmds );
fCmd |= kDrawWrappedString;
fString = new wchar_t[wcslen(text)+1];
wcscpy( fString, text );
fString[wcslen(text)] = L'\0';
fString = plString::FromWchar(text);
fX = x;
fY = y;
@ -222,7 +216,7 @@ void plDynamicTextMsg::Read( hsStream *s, hsResMgr *mgr )
fClearColor.Read( s );
fColor.Read( s );
fString = s->ReadSafeWString();
fString = s->ReadSafeWString_TEMP();
fImageKey = mgr->ReadKey( s );
s->ReadLE( &fFlags );
@ -253,7 +247,8 @@ void plDynamicTextMsg::Write( hsStream *s, hsResMgr *mgr )
fClearColor.Write( s );
fColor.Write( s );
s->WriteSafeWString( plString::FromWchar(fString) );
s->WriteSafeWString(fString);
mgr->WriteKey( s, fImageKey );
s->WriteLE( fFlags );
@ -306,7 +301,7 @@ void plDynamicTextMsg::ReadVersion(hsStream* s, hsResMgr* mgr)
if (contentFlags.IsBitSet(kDynTextMsgColor))
fColor.Read( s );
if (contentFlags.IsBitSet(kDynTextMsgString))
fString = s->ReadSafeWString();
fString = s->ReadSafeWString_TEMP();
if (contentFlags.IsBitSet(kDynTextMsgImageKey))
fImageKey = mgr->ReadKey( s );
if (contentFlags.IsBitSet(kDynTextMsgFlags))
@ -360,7 +355,7 @@ void plDynamicTextMsg::WriteVersion(hsStream* s, hsResMgr* mgr)
fColor.Write( s );
// kDynTextMsgString
s->WriteSafeWString( plString::FromWchar(fString) );
s->WriteSafeWString( fString );
// kDynTextMsgImageKey
mgr->WriteKey( s, fImageKey );

8
Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.h

@ -72,7 +72,7 @@ protected:
hsColorRGBA fColor;
// String
wchar_t *fString;
plString fString;
// Mipmap
plKey fImageKey;
@ -84,8 +84,10 @@ protected:
int16_t fLineSpacing;
public:
plDynamicTextMsg() : plMessage( nil, nil, nil ) { fCmd = 0; fString = nil; fImageKey = nil; fFlags = 0; fBlockRGB = false; }
~plDynamicTextMsg() { delete [] fString; }
plDynamicTextMsg() :
plMessage(nullptr, nullptr, nullptr),
fCmd(0), fImageKey(nullptr), fFlags(0), fBlockRGB(false)
{ }
CLASSNAME_REGISTER( plDynamicTextMsg );
GETINTERFACE_ANY( plDynamicTextMsg, plMessage );

10
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgScreener.cpp

@ -144,13 +144,11 @@ bool plNetClientMsgScreener::AllowIncomingMessage(const plMessage* msg) const
bool plNetClientMsgScreener::IScreenIncoming(const plMessage* msg) const
{
// Why would you EVER send a RefMsg accross the network???
if (plFactory::DerivesFrom(CLASS_INDEX_SCOPED(plRefMsg), msg->ClassIndex()))
return false;
// Blacklist some obvious hacks here...
switch (msg->ClassIndex())
{
case CLASS_INDEX_SCOPED(plAttachMsg):
return true;
case CLASS_INDEX_SCOPED(plAudioSysMsg):
// This message has a flawed read/write
return false;
@ -170,4 +168,8 @@ bool plNetClientMsgScreener::IScreenIncoming(const plMessage* msg) const
// might break something that we really shouldn't...
return true;
}
// Toss non-attach plRefMsgs
if (plFactory::DerivesFrom(CLASS_INDEX_SCOPED(plRefMsg), msg->ClassIndex()))
return false;
}

28
Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.cpp

@ -90,18 +90,6 @@ void plNetMsgScreener::IRejectLogMsg(const plMessage* msg, const char* desc, con
//
plNetMsgScreener::Answer plNetMsgScreener::IAllowMessageType(int16_t classIndex, const plNetGameMember* gm) const
{
// Check based on baseclass
if (plFactory::DerivesFrom(plCCRMessage::Index(), classIndex))
{
ILogCCRMessage(classIndex, gm);
Answer ans=IIsSenderCCR(gm) ? kYes : kNo;
if (ans==kNo)
{
IRejectLogMsg(classIndex, "Not a CCR", gm);
}
return ans;
}
// Check based on exact type
switch(classIndex)
{
@ -128,20 +116,10 @@ plNetMsgScreener::Answer plNetMsgScreener::IAllowMessageType(int16_t classIndex,
case CLASS_INDEX_SCOPED(plEnableMsg):
case CLASS_INDEX_SCOPED(plLinkToAgeMsg):
case CLASS_INDEX_SCOPED(plSubWorldMsg):
case CLASS_INDEX_SCOPED(plDynamicTextMsg):
return kYes;
// definitely yes or no (based on whether sender is a CCR)
case CLASS_INDEX_SCOPED(plWarpMsg):
{
Answer ans=IIsSenderCCR(gm) ? kYes : kNo;
if (ans==kNo)
{
IRejectLogMsg(classIndex, "Not a CCR", gm);
}
return ans;
}
// conditionally yes, requires further validation of msg contents
// conditionally yes, requires further validation of msg contents
case CLASS_INDEX_SCOPED(plAnimCmdMsg):
case CLASS_INDEX_SCOPED(pfKIMsg):
case CLASS_INDEX_SCOPED(plAvTaskMsg):

Loading…
Cancel
Save