Browse Source

String fixes for the Console stuff.

Darryl Pogue 13 years ago
parent
commit
fd71861316
  1. 14
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  2. 15
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp
  3. 12
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.h
  4. 6
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp
  5. 2
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.h

14
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp

@ -841,7 +841,7 @@ PF_CONSOLE_CMD( Console, SetVar, "string name, string value",
hsBool oldF = ctx.GetAddWhenNotFound(); hsBool oldF = ctx.GetAddWhenNotFound();
ctx.SetAddWhenNotFound( true ); ctx.SetAddWhenNotFound( true );
ctx.SetVar( params[ 0 ], params[ 1 ] ); ctx.SetVar((char*)params[ 0 ], (char*)params[ 1 ] );
ctx.SetAddWhenNotFound( oldF ); ctx.SetAddWhenNotFound( oldF );
} }
@ -2251,17 +2251,17 @@ PF_CONSOLE_CMD( App,
char* eventStr = params[1]; char* eventStr = params[1];
CallbackEvent event; CallbackEvent event;
if( !_stricmp(eventStr, "Start") ) if( !stricmp(eventStr, "Start") )
{ {
event = kStart; event = kStart;
} }
else else
if( !_stricmp(eventStr, "Stop") ) if( !stricmp(eventStr, "Stop") )
{ {
event = kStop; event = kStop;
} }
else else
if( !_stricmp(eventStr, "Time") ) if( !stricmp(eventStr, "Time") )
{ {
event = kTime; event = kTime;
secs = params[2]; secs = params[2];
@ -2306,17 +2306,17 @@ PF_CONSOLE_CMD( App,
char* eventStr = params[1]; char* eventStr = params[1];
CallbackEvent event; CallbackEvent event;
if( !_stricmp(eventStr, "Start") ) if( !stricmp(eventStr, "Start") )
{ {
event = kStart; event = kStart;
} }
else else
if( !_stricmp(eventStr, "Stop") ) if( !stricmp(eventStr, "Stop") )
{ {
event = kStop; event = kStop;
} }
else else
if( !_stricmp(eventStr, "Time") ) if( !stricmp(eventStr, "Time") )
{ {
event = kTime; event = kTime;
secs = params[2]; secs = params[2];

15
Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp

@ -43,7 +43,7 @@ UInt32 pfConsoleCmdGroup::fBaseCmdGroupRef = 0;
//// Constructor & Destructor //////////////////////////////////////////////// //// Constructor & Destructor ////////////////////////////////////////////////
pfConsoleCmdGroup::pfConsoleCmdGroup( char *name, char *parent ) pfConsoleCmdGroup::pfConsoleCmdGroup(const char *name, const char *parent )
{ {
fNext = nil; fNext = nil;
fPrevPtr = nil; fPrevPtr = nil;
@ -160,7 +160,7 @@ pfConsoleCmd *pfConsoleCmdGroup::FindNestedPartialCommand( char *name, UInt32
// Try us // Try us
for( cmd = fCommands; cmd != nil; cmd = cmd->GetNext() ) for( cmd = fCommands; cmd != nil; cmd = cmd->GetNext() )
{ {
if( _strnicmp( cmd->GetName(), name, strlen( name ) ) == 0 ) if(strnicmp( cmd->GetName(), name, strlen( name ) ) == 0 )
{ {
if( *counter == 0 ) if( *counter == 0 )
return cmd; return cmd;
@ -250,7 +250,7 @@ pfConsoleCmd *pfConsoleCmdGroup::FindCommandNoCase( char *name, UInt8 flags,
{ {
for( cmd = start; cmd != nil; cmd = cmd->GetNext() ) for( cmd = start; cmd != nil; cmd = cmd->GetNext() )
{ {
if( _strnicmp( cmd->GetName(), name, strlen( name ) ) == 0 ) if(strnicmp( cmd->GetName(), name, strlen( name ) ) == 0 )
return cmd; return cmd;
} }
} }
@ -285,7 +285,7 @@ pfConsoleCmdGroup *pfConsoleCmdGroup::FindSubGroupNoCase( char *name, UInt8 fl
{ {
for( group = start; group != nil; group = group->GetNext() ) for( group = start; group != nil; group = group->GetNext() )
{ {
if( _strnicmp( group->GetName(), name, strlen( name ) ) == 0 ) if(strnicmp( group->GetName(), name, strlen( name ) ) == 0 )
return group; return group;
} }
} }
@ -355,7 +355,8 @@ int pfConsoleCmdGroup::IterateCommands(pfConsoleCmdIterator* t, int depth)
char pfConsoleCmd::fSigTypes[ kNumTypes ][ 8 ] = { "int", "float", "bool", "string", "char", "void", "..." }; char pfConsoleCmd::fSigTypes[ kNumTypes ][ 8 ] = { "int", "float", "bool", "string", "char", "void", "..." };
pfConsoleCmd::pfConsoleCmd( char *group, char *name, char *paramList, char *help, pfConsoleCmd::pfConsoleCmd(const char *group, const char *name,
const char *paramList, const char *help,
pfConsoleCmdPtr func, hsBool localOnly ) pfConsoleCmdPtr func, hsBool localOnly )
{ {
fNext = nil; fNext = nil;
@ -390,7 +391,7 @@ pfConsoleCmd::~pfConsoleCmd()
//// ICreateSignature //////////////////////////////////////////////////////// //// ICreateSignature ////////////////////////////////////////////////////////
// Creates the signature and sig labels based on the given string. // Creates the signature and sig labels based on the given string.
void pfConsoleCmd::ICreateSignature( char *paramList ) void pfConsoleCmd::ICreateSignature(const char *paramList )
{ {
static char seps[] = " :-"; static char seps[] = " :-";
@ -461,7 +462,7 @@ void pfConsoleCmd::ICreateSignature( char *paramList )
// Finds the group this command should be in and registers it with that // Finds the group this command should be in and registers it with that
// group. // group.
void pfConsoleCmd::Register( char *group, char *name ) void pfConsoleCmd::Register(const char *group, const char *name )
{ {
pfConsoleCmdGroup *g; pfConsoleCmdGroup *g;

12
Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.h

@ -65,7 +65,7 @@ class pfConsoleCmdGroup
kFindPartial = 0x01 kFindPartial = 0x01
}; };
pfConsoleCmdGroup( char *name, char *parent ); pfConsoleCmdGroup(const char *name, const char *parent );
~pfConsoleCmdGroup(); ~pfConsoleCmdGroup();
void AddCommand( pfConsoleCmd *cmd ); void AddCommand( pfConsoleCmd *cmd );
@ -159,7 +159,7 @@ class pfConsoleCmd
{ {
protected: protected:
char fName[ 128 ]; char fName[ 128 ];
char *fHelpString; const char* fHelpString;
pfConsoleCmdPtr fFunction; pfConsoleCmdPtr fFunction;
hsBool fLocalOnly; hsBool fLocalOnly;
@ -172,7 +172,7 @@ class pfConsoleCmd
hsExpander<UInt8> fSignature; hsExpander<UInt8> fSignature;
hsExpander<char *> fSigLabels; hsExpander<char *> fSigLabels;
void ICreateSignature( char *paramList ); void ICreateSignature(const char *paramList );
public: public:
@ -192,10 +192,10 @@ class pfConsoleCmd
static char fSigTypes[ kNumTypes ][ 8 ]; static char fSigTypes[ kNumTypes ][ 8 ];
pfConsoleCmd( char *group, char *name, char *paramList, char *help, pfConsoleCmdPtr func, hsBool localOnly = false ); pfConsoleCmd(const char *group, const char *name, const char *paramList, const char *help, pfConsoleCmdPtr func, hsBool localOnly = false );
~pfConsoleCmd(); ~pfConsoleCmd();
void Register( char *group, char *name ); void Register(const char *group, const char *name );
void Unregister(); void Unregister();
void Execute( Int32 numParams, pfConsoleCmdParam *params, void (*PrintFn)( const char * ) = nil ); void Execute( Int32 numParams, pfConsoleCmdParam *params, void (*PrintFn)( const char * ) = nil );
@ -204,7 +204,7 @@ class pfConsoleCmd
pfConsoleCmd *GetNext( void ) { return fNext; } pfConsoleCmd *GetNext( void ) { return fNext; }
char *GetName( void ) { return fName; } char *GetName( void ) { return fName; }
char *GetHelp( void ) { return fHelpString; } const char *GetHelp( void ) { return fHelpString; }
const char *GetSignature( void ); const char *GetSignature( void );
pfConsoleCmdGroup *GetParent( void ) { return fParentGroup; } pfConsoleCmdGroup *GetParent( void ) { return fParentGroup; }

6
Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp

@ -149,8 +149,10 @@ hsBool pfConsoleEngine::PrintCmdHelp( char *name, void (*PrintFn)( const char *
PrintFn( " Commands:" ); PrintFn( " Commands:" );
for( cmd = group->GetFirstCommand(); cmd != nil; cmd = cmd->GetNext() ) for( cmd = group->GetFirstCommand(); cmd != nil; cmd = cmd->GetNext() )
{ {
for( ptr = cmd->GetHelp(), i = 0; ptr[ i ] != 0 && ptr[ i ] != '\n'; i++ ) const char* p = cmd->GetHelp();
tempString[ i ] = ptr[ i ]; for(i = 0; p[ i ] != 0 && p[ i ] != '\n'; i++) {
tempString[ i ] = p[ i ];
}
tempString[ i ] = 0; tempString[ i ] = 0;
sprintf( string, " %s: %s", cmd->GetName(), tempString ); sprintf( string, " %s: %s", cmd->GetName(), tempString );

2
Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.h

@ -58,7 +58,7 @@ class pfConsoleEngine
char fErrorMsg[ 128 ]; char fErrorMsg[ 128 ];
char fLastErrorLine[ 512 ]; char fLastErrorLine[ 512 ];
void ISetErrorMsg( char *msg ) { hsStrncpy( fErrorMsg, msg, sizeof( fErrorMsg ) ); } void ISetErrorMsg(const char *msg ) { hsStrncpy( fErrorMsg, msg, sizeof( fErrorMsg ) ); }
// Recursive function to build a string of the groups a command is in // Recursive function to build a string of the groups a command is in
void IBuildCmdNameRecurse( pfConsoleCmdGroup *group, char *string ); void IBuildCmdNameRecurse( pfConsoleCmdGroup *group, char *string );

Loading…
Cancel
Save