2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-13 18:17:49 -04:00

Merge pull request #275 from zrax/file-utils

Unify filesystem utilities
This commit is contained in:
2013-01-22 16:27:26 -08:00
148 changed files with 1545 additions and 4225 deletions

View File

@ -112,9 +112,9 @@ PF_CONSOLE_FILE_DUMMY(Avatar)
//
/////////////////////////////////////////////////////////////////
plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName,
plKey FindSceneObjectByName(const plString& name, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const plString& ageName,
char* statusStr, bool subString=false);
void PrintStringF(void pfun(const char *),const char * fmt, ...);
@ -361,7 +361,7 @@ PF_CONSOLE_CMD( Avatar_Turn, SetMouseTurnSensitivity, "float sensitivity", "Set
PF_CONSOLE_CMD( Avatar_Multistage, Trigger, "string multiComp", "Triggers the named Multistage Animation component")
{
char str[256];
plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plMultistageBehMod", nil, str, true);
plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plMultistageBehMod", "", str, true);
PrintString(str);
if (key)
@ -499,7 +499,7 @@ PF_CONSOLE_CMD( Avatar, SeekPoint, "string seekpoint", "Move to the given seekpo
if(avatar)
{
char buff[256];
plKey seekKey = FindSceneObjectByName(spName, nil, buff);
plKey seekKey = FindSceneObjectByName(spName, "", buff);
plSeekPointMod *mod = plAvatarMgr::GetInstance()->FindSeekPoint(spName);
if(mod)
@ -596,7 +596,7 @@ PF_CONSOLE_CMD( Avatar, FakeLinkToObj, "string objName", "Pseudo-Link the avatar
{
plString spName = plString::FromUtf8(params[0]);
char buff[256];
plKey seekKey = FindSceneObjectByName(spName, nil, buff);
plKey seekKey = FindSceneObjectByName(spName, "", buff);
if (!seekKey)
{
PrintString("Can't find object with that name, fake link failed.");

View File

@ -155,7 +155,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plUnifiedTime/plUnifiedTime.h"
//end for agedefn test
#include "plFile/hsFiles.h"
#include "pnSceneObject/plAudioInterface.h"
#include "plStatusLog/plStatusLog.h"
@ -263,9 +262,9 @@ PF_CONSOLE_FILE_DUMMY(Main)
// utility functions
//
//////////////////////////////////////////////////////////////////////////////
plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName,
plKey FindSceneObjectByName(const plString& name, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const plString& ageName,
char* statusStr, bool subString=false);
void PrintStringF(void pfun(const char *),const char * fmt, ...);
@ -273,7 +272,7 @@ void PrintStringF(void pfun(const char *),const char * fmt, ...);
// Find an object from name, type (int), and optionally age.
// Name can be an alias specified by saying $foo
//
plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString)
plKey FindObjectByName(const plString& name, int type, const plString& ageName, char* statusStr, bool subString)
{
if (name.IsNull())
{
@ -293,22 +292,22 @@ plKey FindObjectByName(const plString& name, int type, const char* ageName, char
// Try restricted to our age first, if we're not given an age name. This works
// around most of the problems associated with unused keys in pages causing the pages to be marked
// as not loaded and thus screwing up our searches
if( ageName == nil && plNetClientMgr::GetInstance() != nil )
if (ageName.IsNull() && plNetClientMgr::GetInstance() != nil)
{
const char *thisAge = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName();
if (thisAge != nil)
plString thisAge = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName();
if (!thisAge.IsNull())
{
key = plKeyFinder::Instance().StupidSearch(thisAge, nil, type, name, subString);
key = plKeyFinder::Instance().StupidSearch(thisAge, "", type, name, subString);
if (key != nil)
{
if (statusStr)
if (statusStr)
sprintf(statusStr, "Found Object");
return key;
}
}
}
// Fallback
key = plKeyFinder::Instance().StupidSearch(ageName,nil,type, name, subString);
key = plKeyFinder::Instance().StupidSearch(ageName, "", type, name, subString);
if (!key)
{
@ -334,7 +333,7 @@ plKey FindObjectByName(const plString& name, int type, const char* ageName, char
// Name can be an alias specified by saying $foo.
// Will load the object if necessary.
//
plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString)
plKey FindSceneObjectByName(const plString& name, const plString& ageName, char* statusStr, bool subString)
{
plKey key=FindObjectByName(name, plSceneObject::Index(), ageName, statusStr, subString);
@ -352,7 +351,7 @@ plKey FindSceneObjectByName(const plString& name, const char* ageName, char* sta
// Find an object from name, type (string) and optionally age.
// Name can be an alias specified by saying $foo
//
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName,
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const plString& ageName,
char* statusStr, bool subString)
{
if (!typeName)
@ -1579,8 +1578,8 @@ PF_CONSOLE_CMD( Graphics_Renderer, GrabCubeMap,
"Take cubemap from sceneObject's position and name it prefix_XX.jpg")
{
char str[512];
plString objName = plString::FromUtf8(params[0]);
plKey key = FindSceneObjectByName(objName, nil, str);
plString objName = static_cast<const char *>(params[0]);
plKey key = FindSceneObjectByName(objName, "", str);
PrintString( str );
if( !key )
return;
@ -1841,7 +1840,7 @@ PF_CONSOLE_CMD( Graphics_Show, SingleSound,
{
char str[ 512 ];
const char *ageName = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName();
plString ageName = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName();
plKey key = FindSceneObjectByName( plString::FromUtf8( params[ 0 ] ), ageName, str, true );
plSceneObject *obj = ( key != nil ) ? plSceneObject::ConvertNoRef( key->GetObjectPtr() ) : nil;
@ -2175,7 +2174,7 @@ PF_CONSOLE_CMD( App,
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), "", str);
plSceneObject* obj = plSceneObject::ConvertNoRef(key->GetObjectPtr());
if( !obj )
{
@ -2252,7 +2251,7 @@ PF_CONSOLE_CMD( App,
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), "", str);
plSceneObject* obj = plSceneObject::ConvertNoRef(key->GetObjectPtr());
if( !obj )
{
@ -2307,7 +2306,7 @@ PF_CONSOLE_CMD( App,
{
char str[256];
plString name = plString::FromUtf8(params[0]);
plKey key = FindSceneObjectByName(name, nil, str);
plKey key = FindSceneObjectByName(name, "", str);
if( !key )
{
sprintf(str, "%s - Not Found!", name.c_str());
@ -2773,7 +2772,7 @@ PF_CONSOLE_CMD( Registry, ListRefs, "string keyType, string keyName", "For the g
"the objects who currently have active refs on it." )
{
char result[ 256 ];
plKey obj = FindObjectByNameAndType( plString::FromUtf8( params[ 1 ] ), params[ 0 ], nil, result);
plKey obj = FindObjectByNameAndType( plString::FromUtf8( params[ 1 ] ), params[ 0 ], "", result);
if( obj == nil )
{
PrintString( result );
@ -2950,7 +2949,7 @@ PF_CONSOLE_CMD( Camera, SwitchTo, "string cameraName", "Switch to the named came
{
char str[256];
plString foo = plString::Format("%s_", (char*)params[0]);
plKey key = FindObjectByNameAndType(foo, "plCameraModifier1", nil, str, true);
plKey key = FindObjectByNameAndType(foo, "plCameraModifier1", "", str, true);
PrintString(str);
if (key)
@ -3076,7 +3075,7 @@ PF_CONSOLE_GROUP( Logic )
static plLogicModBase *FindLogicMod(const plString &name)
{
char str[256];
plKey key = FindObjectByNameAndType(name, "plLogicModifier", nil, str, true);
plKey key = FindObjectByNameAndType(name, "plLogicModifier", "", str, true);
pfConsole::AddLine(str);
if (key)
@ -3173,7 +3172,7 @@ PF_CONSOLE_CMD( Logic, TriggerResponderNum, "int responderNum, ...", "Triggers t
}
char str[256];
plKey key = FindObjectByNameAndType(responderNames[responderNum-1], "plResponderModifier", nil, str, true);
plKey key = FindObjectByNameAndType(responderNames[responderNum-1], "plResponderModifier", "", str, true);
PrintString(str);
if (key)
@ -3189,7 +3188,7 @@ PF_CONSOLE_CMD( Logic, TriggerResponder, "string responderComp, ...", "Triggers
}
char str[256];
plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plResponderModifier", nil, str, true);
plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plResponderModifier", "", str, true);
PrintString(str);
int responderState = -1;
@ -3211,7 +3210,7 @@ PF_CONSOLE_CMD( Logic, FastForwardResponder, "string responderComp, ...", "Fastf
}
char str[256];
plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plResponderModifier", nil, str, true);
plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plResponderModifier", "", str, true);
PrintString(str);
int responderState = -1;
@ -3522,7 +3521,7 @@ PF_CONSOLE_CMD( Audio, SetVolume,
"string obj, float vol", "Sets the volume on a given object. 1 is max volume, 0 is silence" )
{
char str[ 256 ];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[ 0 ]), nil, str);
plKey key = FindSceneObjectByName(plString::FromUtf8(params[ 0 ]), "", str);
if( key == nil )
return;
@ -3551,7 +3550,7 @@ PF_CONSOLE_CMD( Audio, IsolateSound,
plKey key;
plAudioSysMsg *asMsg;
key = FindSceneObjectByName( plString::FromUtf8( params[ 0 ] ), nil, str );
key = FindSceneObjectByName( plString::FromUtf8( params[ 0 ] ), "", str );
if( key == nil )
{
sprintf( str, "Cannot find sound %s", (char *)params[ 0 ] );
@ -3928,36 +3927,10 @@ PF_CONSOLE_CMD( Nav, PageInNode, // Group name, Function name
plSynchEnabler ps(false); // disable dirty tracking while paging in
plClientMsg* pMsg1 = new plClientMsg(plClientMsg::kLoadRoom);
pMsg1->AddReceiver( plClient::GetInstance()->GetKey() );
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation(nil, params[0]));
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation("", static_cast<const char *>(params[0])));
plgDispatch::MsgSend(pMsg1);
}
PF_CONSOLE_CMD( Nav, PageInNodeList, // Group name, Function name
"string roomNameBase", // Params
"Pages in all scene nodes that start with name." ) // Help string
{
/* This is really old and hasn't worked since 2002 anyways. */
#if HS_BUILD_FOR_WIN32
plSynchEnabler ps(false); // disable dirty tracking while paging in
std::string pageInNodesStr;
pageInNodesStr += "dat\\";
pageInNodesStr += (char*)params[0];
pageInNodesStr += "*.prx";
hsFolderIterator pageInNodesIter(pageInNodesStr.data(), true);
plClientMsg* pMsg1 = new plClientMsg(plClientMsg::kLoadRoom);
while (pageInNodesIter.NextFile())
{
char nodeName[255];
_splitpath(pageInNodesIter.GetFileName(), NULL, NULL, nodeName, NULL);
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation(nil, nodeName));
}
pMsg1->AddReceiver( plClient::GetInstance()->GetKey() );
plgDispatch::MsgSend(pMsg1);
#endif
}
#ifndef LIMIT_CONSOLE_COMMANDS
@ -3968,7 +3941,7 @@ PF_CONSOLE_CMD( Nav, PageOutNode, // Group name, Function name
plSynchEnabler ps(false); // disable dirty tracking while paging out
plClientMsg* pMsg1 = new plClientMsg(plClientMsg::kUnloadRoom);
pMsg1->AddReceiver( plClient::GetInstance()->GetKey() );
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation(nil, params[0]));
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation("", static_cast<const char *>(params[0])));
plgDispatch::MsgSend(pMsg1);
}
@ -3977,7 +3950,7 @@ PF_CONSOLE_CMD( Nav, UnloadPlayer, // Group name, Function name
"unloads a named player" ) // Help string
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), "", str);
PrintString("UnloadPlayer (console version) is currently broken. Hassle Matt.");
// plNetClientMgr::UnloadPlayer(key);
}
@ -3995,12 +3968,12 @@ PF_CONSOLE_CMD( Nav, MovePlayer, // Group name, Function name
"moves a player from one paging unit to another" ) // Help string
{
char str[256];
plKey playerKey = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey playerKey = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if( !playerKey )
return;
plKey nodeKey = FindObjectByName(plString::FromUtf8(params[1]), plSceneNode::Index(), nil, str);
plKey nodeKey = FindObjectByName(static_cast<const char *>(params[1]), plSceneNode::Index(), "", str);
PrintString(str);
if( !nodeKey )
return;
@ -4307,7 +4280,7 @@ PF_CONSOLE_CMD( Access,
char str[256];
char* preFix = params[0];
plString name = plString::Format("%s_plMorphSequence_0", preFix);
plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str);
plKey key = FindObjectByName(name, plMorphSequence::Index(), "", str);
PrintString(str);
if (!key)
return;
@ -4332,7 +4305,7 @@ PF_CONSOLE_CMD( Access,
char str[256];
char* preFix = params[0];
plString name = plString::Format("%s_plMorphSequence_2", preFix);
plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str);
plKey key = FindObjectByName(name, plMorphSequence::Index(), "", str);
PrintString(str);
if (!key)
return;
@ -4353,7 +4326,7 @@ PF_CONSOLE_CMD( Access,
char str[256];
char* preFix = params[0];
plString name = plString::Format("%s_plMorphSequence_2", preFix);
plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str);
plKey key = FindObjectByName(name, plMorphSequence::Index(), "", str);
PrintString(str);
if (!key)
return;
@ -4572,7 +4545,7 @@ PF_CONSOLE_CMD( Access,
"Test fading on visibility" )
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), "", str);
PrintString(str);
if( !key )
return;
@ -4604,7 +4577,7 @@ PF_CONSOLE_CMD( Access,
"Set the los test marker" )
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if( !key )
return;
@ -4618,7 +4591,7 @@ PF_CONSOLE_CMD( Access,
"Set the Los hack marker" )
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
plSceneObject* so = nil;
@ -4693,7 +4666,7 @@ PF_CONSOLE_CMD( Access,
"Fire shot along gun's z-axis, creating decal of radius <radius>, with optional max-range (def 1000)" )
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if( !key )
return;
@ -4774,7 +4747,7 @@ PF_CONSOLE_CMD( Access,
"Add particle system <psys> to bulletMgr <bull>")
{
char str[256];
plKey bullKey = FindObjectByName(plString::FromUtf8(params[0]), plDynaBulletMgr::Index(), nil, str, false);
plKey bullKey = FindObjectByName(static_cast<const char *>(params[0]), plDynaBulletMgr::Index(), "", str, false);
PrintString(str);
if( !(bullKey && bullKey->GetObjectPtr()) )
{
@ -4782,7 +4755,7 @@ PF_CONSOLE_CMD( Access,
return;
}
plKey sysKey = FindSceneObjectByName(plString::FromUtf8(params[1]), nil, str);
plKey sysKey = FindSceneObjectByName(static_cast<const char *>(params[1]), "", str);
if( !(sysKey && sysKey->GetObjectPtr()) )
{
PrintString("Psys not found");
@ -4982,7 +4955,7 @@ static void IDisplayWaveVal(PrintFunk PrintString, plWaveSet7* wave, plWaveCmd::
static plWaveSet7* IGetWaveSet(PrintFunk PrintString, const plString& name)
{
char str[256];
plKey waveKey = FindObjectByName(name, plWaveSet7::Index(), nil, str, false);
plKey waveKey = FindObjectByName(name, plWaveSet7::Index(), "", str, false);
PrintString(str);
if (!waveKey)
return nil;
@ -5463,7 +5436,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, Drawable, // Group name, Function name
"Enable or disable drawing of a sceneobject" ) // Help string
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if (!key)
return;
@ -5482,7 +5455,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, Physical, // Group name, Function name
"Enable or disable the physical of a sceneobject" ) // Help string
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if (!key)
return;
@ -5524,7 +5497,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, Audible, // Group name, Function name
"Enable or disable the audible of a sceneobject" ) // Help string
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if (!key)
return;
@ -5543,7 +5516,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, All, // Group name, Function name
"Enable or disable all fxns of a sceneobject" ) // Help string
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if (!key)
return;
@ -5563,10 +5536,10 @@ PF_CONSOLE_CMD( SceneObject, Attach, // Group name, Function name
{
char str[256];
plString childName = plString::FromUtf8(params[0]);
plString parentName = plString::FromUtf8(params[1]);
plString childName = static_cast<const char *>(params[0]);
plString parentName = static_cast<const char *>(params[1]);
plKey childKey = FindSceneObjectByName(childName, nil, str);
plKey childKey = FindSceneObjectByName(childName, "", str);
if( !childKey )
{
PrintString(str);
@ -5580,7 +5553,7 @@ PF_CONSOLE_CMD( SceneObject, Attach, // Group name, Function name
return;
}
plKey parentKey = FindSceneObjectByName(parentName, nil, str);
plKey parentKey = FindSceneObjectByName(parentName, "", str);
if( !parentKey )
{
PrintString(str);
@ -5601,9 +5574,9 @@ PF_CONSOLE_CMD( SceneObject, Detach, // Group name, Function name
{
char str[256];
plString childName = plString::FromUtf8(params[0]);
plString childName = static_cast<const char *>(params[0]);
plKey childKey = FindSceneObjectByName(childName, nil, str);
plKey childKey = FindSceneObjectByName(childName, "", str);
if( !childKey )
{
PrintString(str);
@ -6186,7 +6159,7 @@ PF_CONSOLE_GROUP( ParticleSystem ) // Defines a main command group
void UpdateParticleParam(const plString &objName, int32_t paramID, float value, void (*PrintString)(const char *))
{
char str[256];
plKey key = FindSceneObjectByName(objName, nil, str);
plKey key = FindSceneObjectByName(objName, "", str);
PrintString(str);
if (key == nil) return;
@ -6309,7 +6282,7 @@ PF_CONSOLE_CMD( ParticleSystem,
"Creates a system (if necessary) on the avatar, and transfers particles" )
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
if (key == nil)
return;
@ -6317,7 +6290,7 @@ PF_CONSOLE_CMD( ParticleSystem,
if (so == nil)
return;
plArmatureMod *avMod = plAvatarMgr::GetInstance()->GetLocalAvatar();
plArmatureMod *avMod = plAvatarMgr::GetInstance()->GetLocalAvatar();
if (avMod)
(new plParticleTransferMsg(nil, avMod->GetKey(), 0, so->GetKey(), (int)params[1]))->Send();
}
@ -6328,7 +6301,7 @@ PF_CONSOLE_CMD( ParticleSystem,
"Flag some particles for death." )
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
if (key == nil)
return;
@ -6350,7 +6323,7 @@ PF_CONSOLE_SUBGROUP( ParticleSystem, Flock )
static plParticleFlockEffect *FindFlock(const plString &objName)
{
char str[256];
plKey key = FindSceneObjectByName(objName, nil, str);
plKey key = FindSceneObjectByName(objName, "", str);
if (key == nil)
return nil;
@ -6528,7 +6501,7 @@ PF_CONSOLE_GROUP( Animation ) // Defines a main command group
void SendAnimCmdMsg(const plString &objName, plMessage *msg)
{
char str[256];
plKey key = FindSceneObjectByName(objName, nil, str);
plKey key = FindSceneObjectByName(objName, "", str);
if (key != nil)
{
msg->AddReceiver(key);

View File

@ -84,8 +84,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plUnifiedTime/plUnifiedTime.h"
//end for agedefn test
#include "plFile/hsFiles.h"
#include "plStatusLog/plStatusLog.h"
#include "hsTemplates.h"
@ -196,9 +194,9 @@ PF_CONSOLE_FILE_DUMMY(Net)
// utility functions
//
//////////////////////////////////////////////////////////////////////////////
plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName,
plKey FindSceneObjectByName(const plString& name, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const plString& ageName,
char* statusStr, bool subString=false);
void PrintStringF(void pfun(const char *),const char * fmt, ...);
@ -507,9 +505,9 @@ PF_CONSOLE_CMD( Net, // groupName
SetObjUpdateFreq, // fxnName
"string objName, float freqInSecs", // paramList
"Instructs the server to only send me updates about this object periodically" ) // helpString
{
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if (!key)
return;

View File

@ -49,75 +49,46 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsExceptions.h"
#ifdef HS_BUILD_FOR_WIN32
#include "hsWindows.h"
#include <sstream>
//// ParseDirectory //////////////////////////////////////////////////////////
bool pfConsoleDirSrc::ParseDirectory(const plFileName& path, const plString& mask /* = L"*.*" */)
bool pfConsoleDirSrc::ParseDirectory(const plFileName& path, const char* mask /* = L"*.*" */)
{
WIN32_FIND_DATAW findInfo;
HANDLE handle;
hsAssert( fEngine != nil, "Cannot do a dir execute without an engine!" );
handle = FindFirstFileW(plFileName::Join(path, mask).AsString().ToWchar(), &findInfo);
if (handle == INVALID_HANDLE_VALUE)
return false;
do
std::vector<plFileName> files = plFileSystem::ListDir(path, mask);
for (auto iter = files.begin(); iter != files.end(); ++iter)
{
if (!( findInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
plFileName name = iter->GetFileName();
if (AlreadyProcessedFile(path, name))
continue;
AddProcessedFile(path, name);
if (!fEngine->ExecuteFile(*iter))
{
plFileName name = plString::FromWchar(findInfo.cFileName);
plFileName fileAndPath = plFileName::Join(path, name);
if (AlreadyProcessedFile(path, name))
continue;
AddProcessedFile(path, name);
if (!fEngine->ExecuteFile(fileAndPath))
{
// Change the following line once we have a better way of reporting
// errors in the parsing
std::wstringstream error;
std::wstringstream caption;
wchar_t* errorMsg = hsStringToWString(fEngine->GetErrorMsg());
wchar_t* errorLine = hsStringToWString(fEngine->GetLastErrorLine());
// Change the following line once we have a better way of reporting
// errors in the parsing
plStringStream error, caption;
caption << L"Error parsing " << findInfo.cFileName;
error << errorMsg << L":\n\nCommand: '" << errorLine << L"'\n\nPress OK to continue parsing files.";
caption << "Error parsing " << name.AsString();
error << fEngine->GetErrorMsg() << ":\n\nCommand: '" << fEngine->GetLastErrorLine()
<< "'\n\nPress OK to continue parsing files.";
hsMessageBox(error.str().c_str(), caption.str().c_str(), hsMessageBoxNormal);
hsMessageBox(error.GetString().c_str(), caption.GetString().c_str(), hsMessageBoxNormal);
delete [] errorMsg;
delete [] errorLine;
FindClose(handle);
SetCheckProcessedFiles(true);
return false;
}
SetCheckProcessedFiles(true);
return false;
}
} while (FindNextFileW(handle, &findInfo) != 0);
}
FindClose(handle);
SetCheckProcessedFiles(true);
return true;
}
#else
#error This needs to be implemented for this platform!!!!
#endif
void pfConsoleDirSrc::ResetProcessedFiles()
{
int i;
for(i=0;i<fProcessedFiles.size(); i++)
delete fProcessedFiles[i];
fProcessedFiles.clear();
fProcessedFiles.clear();
}
//

View File

@ -71,14 +71,14 @@ class pfConsoleDirSrc
{
plFileName fPath;
plFileName fFile;
FileName() : fPath(""), fFile("") {}
FileName() {}
FileName(const plFileName& p, const plFileName& f) : fPath(p), fFile(f) {}
};
std::vector<FileName*> fProcessedFiles; // list of init files we've already executed
bool fCheckProcessedFiles; // set to check and skip files init files we've already executed
public:
pfConsoleDirSrc(pfConsoleEngine *engine) : fCheckProcessedFiles(false) { fEngine = engine; }
pfConsoleDirSrc(pfConsoleEngine *engine, const plFileName& path, const plString& mask = "*.ini")
pfConsoleDirSrc(pfConsoleEngine *engine, const plFileName& path, const char* mask = "*.ini")
: fCheckProcessedFiles(false)
{
fEngine = engine;
@ -88,7 +88,7 @@ class pfConsoleDirSrc
~pfConsoleDirSrc() { ResetProcessedFiles(); }
// Steps through the given directory and executes all files with the console engine
bool ParseDirectory(const plFileName& path, const plString& mask = "*.*");
bool ParseDirectory(const plFileName& path, const char* mask = "*.*");
void ResetProcessedFiles();
bool AlreadyProcessedFile(const plFileName& path, const plFileName& file);

View File

@ -305,7 +305,7 @@ static bool DumpSpecificMsgInfo(plMessage* msg, plString& info)
case plClientMsg::kLoadAgeKeys:
case plClientMsg::kReleaseAgeKeys:
info += plString::Format(" - Age: %s", clientMsg->GetAgeName());
info += plString::Format(" - Age: %s", clientMsg->GetAgeName().c_str());
break;
}
return true;