From c06cfd144918a3087e434bdad847ab6681b8e7af Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sun, 10 Feb 2013 00:14:10 -0800 Subject: [PATCH] Fix some warnings and some errors. --- .../pfConsole/pfAvatarConsoleCommands.cpp | 2 +- .../pfConsole/pfConsoleCommands.cpp | 18 +++++++++++------- .../FeatureLib/pfConsoleCore/pfConsoleCmd.cpp | 9 +++++---- .../FeatureLib/pfConsoleCore/pfConsoleCmd.h | 12 ++++++------ .../pfConsoleCore/pfConsoleContext.cpp | 1 + .../pfConsoleCore/pfConsoleEngine.cpp | 19 ++++++++++--------- .../pfConsoleCore/pfConsoleEngine.h | 2 +- .../FeatureLib/pfPython/cyPythonInterface.cpp | 4 ++-- .../FeatureLib/pfPython/cyPythonInterface.h | 4 ++-- .../FeatureLib/pfPython/plPythonFileMod.cpp | 2 +- .../PubUtilLib/plAvatar/plAvatarMgr.cpp | 2 +- .../Plasma/PubUtilLib/plAvatar/plAvatarMgr.h | 2 +- .../PubUtilLib/plVault/plVaultNodeAccess.h | 2 +- 13 files changed, 43 insertions(+), 36 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp index e1693837..ba983660 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp @@ -677,7 +677,7 @@ PF_CONSOLE_CMD( Avatar_Anim, BlendAnimPri, "string Animation, float blendFactor, PF_CONSOLE_CMD( Avatar_Anim, PlaySimpleAnim, "string AvatarName, string Animation", "Play a simple (root not animated) one time animation on the avatar") { - plArmatureMod *avatar = plAvatarMgr::GetInstance()->FindAvatarByModelName(params[0]); + plArmatureMod *avatar = plAvatarMgr::GetInstance()->FindAvatarByModelName((char*)params[0]); if (avatar) avatar->PlaySimpleAnim(plString::FromUtf8(params[1])); } diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp index 2fbe3617..4f749eba 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp @@ -2003,10 +2003,13 @@ PF_CONSOLE_CMD( Graphics_Show, PhysicalsOnly, "", "Toggle only Physical geometry PF_CONSOLE_CMD( Graphics_Show, Normal, "", "Toggle normal geometry visible") { static bool on = true; - if( on = !on ) + + if (!on) { + on = !on; pfConsole::GetPipeline()->SetDrawableTypeMask(pfConsole::GetPipeline()->GetDrawableTypeMask() | plDrawableSpans::kNormal); - else + } else { pfConsole::GetPipeline()->SetDrawableTypeMask(pfConsole::GetPipeline()->GetDrawableTypeMask() & ~plDrawableSpans::kNormal); + } char str[ 256 ]; sprintf( str, "Normal geometry now %s", on ? "visible" : "invisible" ); @@ -2017,15 +2020,15 @@ PF_CONSOLE_CMD( Graphics_Show, NormalOnly, "", "Toggle only normal geometry visi { static bool on = false; static uint32_t oldMask = plDrawableSpans::kNormal; - if( on = !on ) - { + + if (!on) { + on = !on; oldMask = pfConsole::GetPipeline()->GetDrawableTypeMask(); pfConsole::GetPipeline()->SetDrawableTypeMask(plDrawableSpans::kNormal); - } - else - { + } else { pfConsole::GetPipeline()->SetDrawableTypeMask(oldMask); } + char str[ 256 ]; sprintf( str, on ? "Now showing only normal geometry" : "Restoring previous render state" ); PrintString( str ); @@ -3384,6 +3387,7 @@ Valid channels are: SoundFX, BgndMusic, Voice, GUI, NPCVoice and Ambience.") case plgAudioSys::kAmbience: sprintf( msg, "Setting Ambience master volume to %4.2f", vol ); break; case plgAudioSys::kGUI: sprintf( msg, "Setting GUI master volume to %4.2f", vol ); break; case plgAudioSys::kNPCVoice: sprintf( msg, "Setting NPC Voice master volume to %4.2f", vol ); break; + default: break; } PrintString( msg ); } diff --git a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp index d7949a9a..99589078 100644 --- a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp +++ b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp @@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // // ////////////////////////////////////////////////////////////////////////////// +#include "plString.h" #include "pfConsoleCmd.h" @@ -141,7 +142,7 @@ void pfConsoleCmdGroup::AddSubGroup( pfConsoleCmdGroup *group ) //// FindCommand ///////////////////////////////////////////////////////////// // No longer recursive. -pfConsoleCmd *pfConsoleCmdGroup::FindCommand( char *name ) +pfConsoleCmd *pfConsoleCmdGroup::FindCommand( const char *name ) { pfConsoleCmd *cmd; @@ -198,7 +199,7 @@ pfConsoleCmd *pfConsoleCmdGroup::FindNestedPartialCommand( char *name, uint32 //// FindSubGroup //////////////////////////////////////////////////////////// -pfConsoleCmdGroup *pfConsoleCmdGroup::FindSubGroup( char *name ) +pfConsoleCmdGroup *pfConsoleCmdGroup::FindSubGroup( const char *name ) { pfConsoleCmdGroup *group; @@ -249,7 +250,7 @@ pfConsoleCmdGroup *pfConsoleCmdGroup::FindSubGroupRecurse( const char *name ) //// FindCommandNoCase /////////////////////////////////////////////////////// // Case-insensitive version of FindCommand. -pfConsoleCmd *pfConsoleCmdGroup::FindCommandNoCase( char *name, uint8_t flags, pfConsoleCmd *start ) +pfConsoleCmd *pfConsoleCmdGroup::FindCommandNoCase( const char *name, uint8_t flags, pfConsoleCmd *start ) { pfConsoleCmd *cmd; @@ -284,7 +285,7 @@ pfConsoleCmd *pfConsoleCmdGroup::FindCommandNoCase( char *name, uint8_t flags //// FindSubGroupNoCase ////////////////////////////////////////////////////// -pfConsoleCmdGroup *pfConsoleCmdGroup::FindSubGroupNoCase( char *name, uint8_t flags, pfConsoleCmdGroup *start ) +pfConsoleCmdGroup *pfConsoleCmdGroup::FindSubGroupNoCase( const char *name, uint8_t flags, pfConsoleCmdGroup *start ) { pfConsoleCmdGroup *group; diff --git a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.h b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.h index 22c09b74..f3d4ea7e 100644 --- a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.h +++ b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.h @@ -96,12 +96,12 @@ class pfConsoleCmdGroup static pfConsoleCmdGroup *GetBaseGroup( void ); - pfConsoleCmd *FindCommand( char *name ); - pfConsoleCmd *FindCommandNoCase( char *name, uint8_t flags = 0, pfConsoleCmd *start = nil ); + pfConsoleCmd *FindCommand( const char *name ); + pfConsoleCmd *FindCommandNoCase( const char *name, uint8_t flags = 0, pfConsoleCmd *start = nil ); pfConsoleCmd *FindNestedPartialCommand( char *name, uint32_t *counter ); - pfConsoleCmdGroup *FindSubGroup( char *name ); - pfConsoleCmdGroup *FindSubGroupNoCase( char *name, uint8_t flags = 0, pfConsoleCmdGroup *start = nil ); + pfConsoleCmdGroup *FindSubGroup( const char *name ); + pfConsoleCmdGroup *FindSubGroupNoCase( const char *name, uint8_t flags = 0, pfConsoleCmdGroup *start = nil ); pfConsoleCmd *GetFirstCommand( void ) { return fCommands; } pfConsoleCmdGroup *GetFirstSubGroup( void ) { return fSubGroups; } @@ -120,7 +120,7 @@ class pfConsoleCmdParam uint8_t fType; - typedef char *CharPtr; + typedef char* CharPtr; union { @@ -153,7 +153,7 @@ class pfConsoleCmdParam operator int() const { return IToInt(); } operator float() const { return IToFloat(); } operator bool() const { return IToBool(); } - operator const CharPtr() const { return IToString(); } + operator CharPtr() const { return IToString(); } operator char() const { return IToChar(); } uint8_t GetType( void ) { return fType; } diff --git a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleContext.cpp b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleContext.cpp index 13e0b258..f5063e62 100644 --- a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleContext.cpp +++ b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleContext.cpp @@ -46,6 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com ////////////////////////////////////////////////////////////////////////////// #include "HeadSpin.h" +#include "plString.h" #include "pfConsoleContext.h" diff --git a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp index 9ef50326..e6039a43 100644 --- a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp +++ b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp @@ -58,7 +58,7 @@ static const char kTokenSeparators[] = " =\r\n\t,"; static const char kTokenGrpSeps[] = " =\r\n._\t,"; //WARNING: Potentially increments the pointer passed to it. -static char *console_strtok( char *&line, bool haveCommand ) +static const char *console_strtok( char *&line, bool haveCommand ) { char *begin = line; @@ -122,7 +122,7 @@ bool pfConsoleEngine::PrintCmdHelp( char *name, void (*PrintFn)( const char * { pfConsoleCmd *cmd; pfConsoleCmdGroup *group, *subGrp; - char *ptr; + const char *ptr; static char string[ 512 ]; static char tempString[ 512 ]; uint32_t i; @@ -203,7 +203,7 @@ const char *pfConsoleEngine::GetCmdSignature( char *name ) { pfConsoleCmd *cmd; pfConsoleCmdGroup *group, *subGrp; - char *ptr; + const char *ptr; static char string[ 512 ]; @@ -297,7 +297,7 @@ bool pfConsoleEngine::RunCommand( char *line, void (*PrintFn)( const char * ) pfConsoleCmdGroup *group, *subGrp; int32_t numParams, i, numQuotedParams = 0; pfConsoleCmdParam paramArray[ fMaxNumParams + 1 ]; - char *ptr; + const char *ptr; bool valid = true; @@ -395,9 +395,9 @@ bool pfConsoleEngine::RunCommand( char *line, void (*PrintFn)( const char * ) // Converts a null-terminated string representing a parameter to a // pfConsoleCmdParam argument. -bool pfConsoleEngine::IConvertToParam( uint8_t type, char *string, pfConsoleCmdParam *param ) +bool pfConsoleEngine::IConvertToParam( uint8_t type, const char *string, pfConsoleCmdParam *param ) { - char *c, expChars[] = "dDeE+-."; + const char *c, expChars[] = "dDeE+-."; bool hasDecimal = false, hasLetters = false; @@ -422,12 +422,12 @@ bool pfConsoleEngine::IConvertToParam( uint8_t type, char *string, pfConsoleC if( type == pfConsoleCmd::kAny ) { /// Want "any" - param->SetAny( string ); + param->SetAny( (char*)string ); } else if( type == pfConsoleCmd::kString ) { /// Want just a string - param->SetString( string ); + param->SetString( (char*)string ); } else if( type == pfConsoleCmd::kFloat ) { @@ -469,7 +469,8 @@ bool pfConsoleEngine::FindPartialCmd( char *line, bool findAgain, bool preser pfConsoleCmdGroup *group, *subGrp; bool foundMore = false; - static char *ptr = nil, *insertLoc = nil; + static const char *ptr = nil; + static char *insertLoc = nil; static pfConsoleCmd *lastCmd = nil; static pfConsoleCmdGroup *lastGroup = nil, *lastParentGroup = nil; static char newStr[ 256 ]; diff --git a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.h b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.h index e8de87cb..c12777f3 100644 --- a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.h +++ b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.h @@ -70,7 +70,7 @@ class pfConsoleEngine static const int32_t fMaxNumParams; - bool IConvertToParam( uint8_t type, char *string, pfConsoleCmdParam *param ); + bool IConvertToParam( uint8_t type, const char *string, pfConsoleCmdParam *param ); char fErrorMsg[ 128 ]; char fLastErrorLine[ 512 ]; diff --git a/Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.cpp b/Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.cpp index e77e3c39..a74996d2 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.cpp @@ -2195,7 +2195,7 @@ PyObject* PythonInterface::LoadObject(char* pickle, int32_t size) // // RETURNS : pointer to PyObject that is the result of the command // -bool PythonInterface::RunStringInteractive(char *command, PyObject* module) +bool PythonInterface::RunStringInteractive(const char *command, PyObject* module) { PyObject *d, *v; // make sure that we're given a good module... or at least one with an address @@ -2231,7 +2231,7 @@ bool PythonInterface::RunStringInteractive(char *command, PyObject* module) // // PURPOSE : run a python string in a specific module name // -bool PythonInterface::RunString(char *command, PyObject* module) +bool PythonInterface::RunString(const char *command, PyObject* module) { PyObject *d, *v; // make sure that we're given a good module... or at least one with an address diff --git a/Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.h b/Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.h index 686011a0..41ba6a66 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.h +++ b/Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.h @@ -199,7 +199,7 @@ public: // PURPOSE : run a python string in a specific module name // : Interactive mode (displays results) // - static bool RunStringInteractive(char *command, PyObject* module); + static bool RunStringInteractive(const char *command, PyObject* module); ///////////////////////////////////////////////////////////////////////////// @@ -210,7 +210,7 @@ public: // // PURPOSE : run a python string in a specific module name // - static bool RunString(char *command, PyObject* module); + static bool RunString(const char *command, PyObject* module); ///////////////////////////////////////////////////////////////////////////// diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp index 34005576..e1bcceac 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp @@ -2533,7 +2533,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg) PyObject* retVal = PyObject_CallMethod( fPyFunctionInstances[kfunc_OnMovieEvent], (char*)fFunctionNames[kfunc_OnMovieEvent], - "si", moviemsg->fMovieName, (uint32_t)moviemsg->fReason); + "si", moviemsg->fMovieName.AsString().c_str(), (uint32_t)moviemsg->fReason); if ( retVal == nil ) { #ifndef PLASMA_EXTERNAL_RELEASE diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp index a1b14e73..7498d31e 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp @@ -728,7 +728,7 @@ plArmatureMod* plAvatarMgr::FindAvatarByPlayerID(uint32_t pid) return nil; } -plArmatureMod *plAvatarMgr::FindAvatarByModelName(char *name) +plArmatureMod *plAvatarMgr::FindAvatarByModelName(const plString& name) { plAvatarVec::iterator it; for (it = fAvatars.begin(); it != fAvatars.end(); ++it) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.h b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.h index 1f5e8a49..5aed7bab 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.h @@ -140,7 +140,7 @@ public: plKey GetLocalAvatarKey(); static plArmatureMod *FindAvatar(plKey& avatarKey); // Key of the sceneObject plArmatureMod *FindAvatarByPlayerID(uint32_t pid); - plArmatureMod *FindAvatarByModelName(char *name); // Probably only useful for custom NPCs. All players are + plArmatureMod *FindAvatarByModelName(const plString& name); // Probably only useful for custom NPCs. All players are // either "Male" or "Female". void FindAllAvatarsByModelName(const char* name, plArmatureModPtrVec& outVec); plArmatureMod *GetFirstRemoteAvatar(); diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.h b/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.h index b6ad1675..12a226cb 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.h +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.h @@ -79,7 +79,7 @@ struct NetVaultNodeAccess { private: NetVaultNodeAccess (const NetVaultNodeAccess &) { } - const NetVaultNodeAccess & operator= (const NetVaultNodeAccess &) { } + void operator= (const NetVaultNodeAccess &) { } }; #define VNODE_ACCESSOR(type, name, basename) \