mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 10:37:41 -04:00
Split out minimal core console functionality from the pfConsole module
--HG-- rename : Sources/Plasma/FeatureLib/pfConsole/pfConsoleCmd.cpp => Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp rename : Sources/Plasma/FeatureLib/pfConsole/pfConsoleCmd.h => Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.h rename : Sources/Plasma/FeatureLib/pfConsole/pfConsoleContext.cpp => Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleContext.cpp rename : Sources/Plasma/FeatureLib/pfConsole/pfConsoleContext.h => Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleContext.h rename : Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.cpp => Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp
This commit is contained in:
@ -12,23 +12,17 @@ set(pfConsole_SOURCES
|
||||
pfAvatarConsoleCommands.cpp
|
||||
pfCCRConsoleCommands.cpp
|
||||
pfConsole.cpp
|
||||
pfConsoleCmd.cpp
|
||||
pfConsoleCommands.cpp
|
||||
pfConsoleCommandsNet.cpp
|
||||
pfConsoleContext.cpp
|
||||
pfConsoleDirSrc.cpp
|
||||
pfConsoleEngine.cpp
|
||||
pfDispatchLog.cpp
|
||||
pfGameConsoleCommands.cpp
|
||||
)
|
||||
|
||||
set(pfConsole_HEADERS
|
||||
pfConsole.h
|
||||
pfConsoleCmd.h
|
||||
pfConsoleContext.h
|
||||
pfConsoleCreatable.h
|
||||
pfConsoleDirSrc.h
|
||||
pfConsoleEngine.h
|
||||
pfDispatchLog.h
|
||||
)
|
||||
|
||||
|
@ -33,7 +33,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#define LIMIT_CONSOLE_COMMANDS 1
|
||||
#endif
|
||||
|
||||
#include "pfConsoleCmd.h"
|
||||
#include "pfConsoleCore/pfConsoleCmd.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "pfConsole.h"
|
||||
#include "hsResMgr.h"
|
||||
@ -76,10 +76,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#define PF_SANITY_CHECK( cond, msg ) { if( !( cond ) ) { PrintString( msg ); return; } }
|
||||
|
||||
//// DO NOT REMOVE!!!!
|
||||
//// This is here so Microsoft VC won't decide to "optimize" this file out
|
||||
void pfConsoleCmdGroup::DummyAvatar( void )
|
||||
{
|
||||
}
|
||||
PF_CONSOLE_FILE_DUMMY(Avatar)
|
||||
//// DO NOT REMOVE!!!!
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -36,16 +36,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
// Only calls to the CCRMgr interface are allowed here
|
||||
// See me if you need to include any other files...
|
||||
//
|
||||
#include "pfConsoleCmd.h"
|
||||
#include "pfConsoleCore/pfConsoleCmd.h"
|
||||
#include "pfConsole.h"
|
||||
#include "pfCCR/plCCRMgr.h"
|
||||
#include "plNetClient/plNetClientMgr.h"
|
||||
|
||||
//// DO NOT REMOVE!!!!
|
||||
//// This is here so Microsoft VC won't decide to "optimize" this file out
|
||||
// YOU ALSO NEED TO CALL THIS FXN
|
||||
void pfConsoleCmdGroup::DummyCCR( void )
|
||||
{
|
||||
}
|
||||
PF_CONSOLE_FILE_DUMMY(CCR)
|
||||
//// DO NOT REMOVE!!!!
|
||||
|
||||
void PrintStringF(void pfun(const char *),const char * fmt, ...);
|
||||
|
||||
|
@ -30,7 +30,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pfConsole.h"
|
||||
#include "pfConsoleEngine.h"
|
||||
#include "pfConsoleCore/pfConsoleEngine.h"
|
||||
#include "plPipeline/plDebugText.h"
|
||||
#include "plInputCore/plInputDevice.h"
|
||||
#include "plInputCore/plInputInterface.h"
|
||||
|
@ -1,657 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// pfConsoleCmd Functions //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pfConsoleCmd.h"
|
||||
#include "hsUtils.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// pfConsoleCmdGroup Stuff /////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pfConsoleCmdGroup *pfConsoleCmdGroup::fBaseCmdGroup = nil;
|
||||
UInt32 pfConsoleCmdGroup::fBaseCmdGroupRef = 0;
|
||||
|
||||
|
||||
//// Constructor & Destructor ////////////////////////////////////////////////
|
||||
|
||||
pfConsoleCmdGroup::pfConsoleCmdGroup( char *name, char *parent )
|
||||
{
|
||||
Dummy();
|
||||
DummyJunior();
|
||||
DummyNet();
|
||||
DummyAvatar();
|
||||
DummyCCR();
|
||||
|
||||
fNext = nil;
|
||||
fPrevPtr = nil;
|
||||
fCommands = nil;
|
||||
fSubGroups = nil;
|
||||
|
||||
if( name == nil )
|
||||
{
|
||||
/// Create base
|
||||
hsStrncpy( fName, "base", sizeof( fName ) );
|
||||
fParentGroup = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
pfConsoleCmdGroup *group = GetBaseGroup();
|
||||
|
||||
if( parent != nil && parent[ 0 ] != 0 )
|
||||
{
|
||||
group = group->FindSubGroupRecurse( parent );
|
||||
hsAssert( group != nil, "Trying to register group under nonexistant group!" );
|
||||
}
|
||||
|
||||
hsStrncpy( fName, name, sizeof( fName ) );
|
||||
group->AddSubGroup( this );
|
||||
fParentGroup = group;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pfConsoleCmdGroup::~pfConsoleCmdGroup()
|
||||
{
|
||||
if( this != fBaseCmdGroup )
|
||||
{
|
||||
Unlink();
|
||||
|
||||
DecBaseCmdGroupRef();
|
||||
}
|
||||
}
|
||||
|
||||
//// GetBaseGroup ////////////////////////////////////////////////////////////
|
||||
|
||||
pfConsoleCmdGroup *pfConsoleCmdGroup::GetBaseGroup( void )
|
||||
{
|
||||
if( fBaseCmdGroup == nil )
|
||||
{
|
||||
/// Initialize base group
|
||||
fBaseCmdGroup = TRACKED_NEW pfConsoleCmdGroup( nil, nil );
|
||||
}
|
||||
|
||||
return fBaseCmdGroup;
|
||||
}
|
||||
|
||||
//// DecBaseCmdGroupRef //////////////////////////////////////////////////////
|
||||
|
||||
void pfConsoleCmdGroup::DecBaseCmdGroupRef( void )
|
||||
{
|
||||
fBaseCmdGroupRef--;
|
||||
if( fBaseCmdGroupRef == 0 )
|
||||
{
|
||||
delete fBaseCmdGroup;
|
||||
fBaseCmdGroup = nil;
|
||||
}
|
||||
}
|
||||
|
||||
//// Add Functions ///////////////////////////////////////////////////////////
|
||||
|
||||
void pfConsoleCmdGroup::AddCommand( pfConsoleCmd *cmd )
|
||||
{
|
||||
cmd->Link( &fCommands );
|
||||
fBaseCmdGroupRef++;
|
||||
}
|
||||
|
||||
void pfConsoleCmdGroup::AddSubGroup( pfConsoleCmdGroup *group )
|
||||
{
|
||||
group->Link( &fSubGroups );
|
||||
fBaseCmdGroupRef++;
|
||||
}
|
||||
|
||||
//// FindCommand /////////////////////////////////////////////////////////////
|
||||
// No longer recursive.
|
||||
|
||||
pfConsoleCmd *pfConsoleCmdGroup::FindCommand( char *name )
|
||||
{
|
||||
pfConsoleCmd *cmd;
|
||||
|
||||
|
||||
hsAssert( name != nil, "nil name passed to FindCommand()" );
|
||||
|
||||
/// Only search locally
|
||||
for( cmd = fCommands; cmd != nil; cmd = cmd->GetNext() )
|
||||
{
|
||||
if( strcmp( cmd->GetName(), name ) == 0 )
|
||||
return cmd;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
//// FindNestedPartialCommand ////////////////////////////////////////////////
|
||||
// Okay. YAFF. This one searches through the group and its children looking
|
||||
// for a partial command based on the string given. The counter determines
|
||||
// how many matches it skips before returning a match. (That way you can
|
||||
// cycle through matches by sending 1 + the last counter every time).
|
||||
|
||||
pfConsoleCmd *pfConsoleCmdGroup::FindNestedPartialCommand( char *name, UInt32 *counter )
|
||||
{
|
||||
pfConsoleCmd *cmd;
|
||||
pfConsoleCmdGroup *group;
|
||||
|
||||
|
||||
hsAssert( name != nil, "nil name passed to FindNestedPartialCommand()" );
|
||||
hsAssert( counter != nil, "nil counter passed to FindNestedPartialCommand()" );
|
||||
|
||||
// Try us
|
||||
for( cmd = fCommands; cmd != nil; cmd = cmd->GetNext() )
|
||||
{
|
||||
if( _strnicmp( cmd->GetName(), name, strlen( name ) ) == 0 )
|
||||
{
|
||||
if( *counter == 0 )
|
||||
return cmd;
|
||||
|
||||
(*counter)--;
|
||||
}
|
||||
}
|
||||
|
||||
// Try children
|
||||
for( group = fSubGroups; group != nil; group = group->GetNext() )
|
||||
{
|
||||
cmd = group->FindNestedPartialCommand( name, counter );
|
||||
if( cmd != nil )
|
||||
return cmd;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
//// FindSubGroup ////////////////////////////////////////////////////////////
|
||||
|
||||
pfConsoleCmdGroup *pfConsoleCmdGroup::FindSubGroup( char *name )
|
||||
{
|
||||
pfConsoleCmdGroup *group;
|
||||
|
||||
|
||||
hsAssert( name != nil, "nil name passed to FindSubGroup()" );
|
||||
|
||||
/// Only search locally
|
||||
for( group = fSubGroups; group != nil; group = group->GetNext() )
|
||||
{
|
||||
if( strcmp( group->GetName(), name ) == 0 )
|
||||
return group;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
//// FindSubGroupRecurse /////////////////////////////////////////////////////
|
||||
// Resurces through a string, finding the final subgroup that the string
|
||||
// represents. Parses with spaces, _ or . as the separators. Copies string.
|
||||
|
||||
pfConsoleCmdGroup *pfConsoleCmdGroup::FindSubGroupRecurse( const char *name )
|
||||
{
|
||||
char *ptr, *string;
|
||||
pfConsoleCmdGroup *group;
|
||||
static char seps[] = " ._";
|
||||
|
||||
|
||||
string = TRACKED_NEW char[ strlen( name ) + 1 ];
|
||||
hsAssert( string != nil, "Cannot allocate string in FindSubGroupRecurse()" );
|
||||
strcpy( string, name );
|
||||
|
||||
/// Scan for subgroups
|
||||
group = pfConsoleCmdGroup::GetBaseGroup();
|
||||
ptr = strtok( string, seps );
|
||||
while( ptr != nil )
|
||||
{
|
||||
// Take this token and check to see if it's a group
|
||||
group = group->FindSubGroup( ptr );
|
||||
hsAssert( group != nil, "Invalid group name to FindSubGroupRecurse()" );
|
||||
|
||||
ptr = strtok( nil, seps );
|
||||
}
|
||||
|
||||
delete [] string;
|
||||
return group;
|
||||
}
|
||||
|
||||
//// FindCommandNoCase ///////////////////////////////////////////////////////
|
||||
// Case-insensitive version of FindCommand.
|
||||
|
||||
pfConsoleCmd *pfConsoleCmdGroup::FindCommandNoCase( char *name, UInt8 flags, pfConsoleCmd *start )
|
||||
{
|
||||
pfConsoleCmd *cmd;
|
||||
|
||||
|
||||
hsAssert( name != nil, "nil name passed to FindCommandNoCase()" );
|
||||
|
||||
/// Only search locally
|
||||
if( start == nil )
|
||||
start = fCommands;
|
||||
else
|
||||
start = start->GetNext();
|
||||
|
||||
if( flags & kFindPartial )
|
||||
{
|
||||
for( cmd = start; cmd != nil; cmd = cmd->GetNext() )
|
||||
{
|
||||
if( _strnicmp( cmd->GetName(), name, strlen( name ) ) == 0 )
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( cmd = start; cmd != nil; cmd = cmd->GetNext() )
|
||||
{
|
||||
if( stricmp( cmd->GetName(), name ) == 0 )
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
//// FindSubGroupNoCase //////////////////////////////////////////////////////
|
||||
|
||||
pfConsoleCmdGroup *pfConsoleCmdGroup::FindSubGroupNoCase( char *name, UInt8 flags, pfConsoleCmdGroup *start )
|
||||
{
|
||||
pfConsoleCmdGroup *group;
|
||||
|
||||
|
||||
hsAssert( name != nil, "nil name passed to FindSubGroupNoCase()" );
|
||||
|
||||
/// Only search locally
|
||||
if( start == nil )
|
||||
start = fSubGroups;
|
||||
else
|
||||
start = start->GetNext();
|
||||
|
||||
if( flags & kFindPartial )
|
||||
{
|
||||
for( group = start; group != nil; group = group->GetNext() )
|
||||
{
|
||||
if( _strnicmp( group->GetName(), name, strlen( name ) ) == 0 )
|
||||
return group;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( group = start; group != nil; group = group->GetNext() )
|
||||
{
|
||||
if( stricmp( group->GetName(), name ) == 0 )
|
||||
return group;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
//// Link & Unlink ///////////////////////////////////////////////////////////
|
||||
|
||||
void pfConsoleCmdGroup::Link( pfConsoleCmdGroup **prevPtr )
|
||||
{
|
||||
hsAssert( fNext == nil && fPrevPtr == nil, "Trying to link console group that's already linked!" );
|
||||
|
||||
fNext = *prevPtr;
|
||||
if( *prevPtr )
|
||||
(*prevPtr)->fPrevPtr = &fNext;
|
||||
fPrevPtr = prevPtr;
|
||||
*fPrevPtr = this;
|
||||
}
|
||||
|
||||
void pfConsoleCmdGroup::Unlink( void )
|
||||
{
|
||||
hsAssert( fNext != nil || fPrevPtr != nil, "Trying to unlink console group that isn't linked!" );
|
||||
|
||||
if( fNext )
|
||||
fNext->fPrevPtr = fPrevPtr;
|
||||
*fPrevPtr = fNext;
|
||||
}
|
||||
|
||||
|
||||
int pfConsoleCmdGroup::IterateCommands(pfConsoleCmdIterator* t, int depth)
|
||||
{
|
||||
pfConsoleCmd *cmd;
|
||||
|
||||
cmd = this->GetFirstCommand();
|
||||
while(cmd)
|
||||
{
|
||||
t->ProcessCmd(cmd,depth);
|
||||
cmd = cmd->GetNext();
|
||||
}
|
||||
|
||||
pfConsoleCmdGroup *grp;
|
||||
|
||||
grp = this->GetFirstSubGroup();
|
||||
while(grp)
|
||||
{
|
||||
if(t->ProcessGroup(grp, depth))
|
||||
grp->IterateCommands(t, depth+1);
|
||||
grp = grp->GetNext();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// pfConsoleCmd Functions //////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char pfConsoleCmd::fSigTypes[ kNumTypes ][ 8 ] = { "int", "float", "bool", "string", "char", "void", "..." };
|
||||
|
||||
pfConsoleCmd::pfConsoleCmd( char *group, char *name, char *paramList, char *help,
|
||||
pfConsoleCmdPtr func, hsBool localOnly )
|
||||
{
|
||||
fNext = nil;
|
||||
fPrevPtr = nil;
|
||||
|
||||
fFunction = func;
|
||||
fLocalOnly = localOnly;
|
||||
|
||||
hsStrncpy( fName, name, sizeof( fName ) );
|
||||
fHelpString = help;
|
||||
|
||||
ICreateSignature( paramList );
|
||||
Register( group, name );
|
||||
}
|
||||
|
||||
pfConsoleCmd::~pfConsoleCmd()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for( i = 0; i < fSigLabels.GetCount(); i++ )
|
||||
{
|
||||
if( fSigLabels[ i ] != nil )
|
||||
delete [] fSigLabels[ i ];
|
||||
}
|
||||
Unregister();
|
||||
|
||||
fSignature.Reset();
|
||||
fSigLabels.Reset();
|
||||
}
|
||||
|
||||
//// ICreateSignature ////////////////////////////////////////////////////////
|
||||
// Creates the signature and sig labels based on the given string.
|
||||
|
||||
void pfConsoleCmd::ICreateSignature( char *paramList )
|
||||
{
|
||||
static char seps[] = " :-";
|
||||
|
||||
char params[ 256 ];
|
||||
char *ptr, *nextPtr, *tok, *tok2;
|
||||
int i;
|
||||
|
||||
|
||||
/// Simple check
|
||||
if( paramList == nil )
|
||||
{
|
||||
fSignature.Push( kAny );
|
||||
fSigLabels.Push( (char *)nil );
|
||||
return;
|
||||
}
|
||||
|
||||
/// So we can do stuff to it
|
||||
hsAssert( strlen( paramList ) < sizeof( params ), "Make the (#*$& params string larger!" );
|
||||
hsStrcpy( params, paramList );
|
||||
|
||||
fSignature.Empty();
|
||||
fSigLabels.Empty();
|
||||
|
||||
/// Loop through all the types given in the list
|
||||
ptr = params;
|
||||
do
|
||||
{
|
||||
/// Find break
|
||||
nextPtr = strchr( ptr, ',' );
|
||||
if( nextPtr != nil )
|
||||
{
|
||||
*nextPtr = 0;
|
||||
nextPtr++;
|
||||
}
|
||||
|
||||
/// Do this param
|
||||
tok = strtok( ptr, seps );
|
||||
if( tok == nil && ptr == params )
|
||||
break;
|
||||
|
||||
hsAssert( tok != nil, "Bad parameter list for console command!" );
|
||||
tok2 = strtok( nil, seps );
|
||||
|
||||
if( tok2 != nil )
|
||||
{
|
||||
// Type and label: assume label second
|
||||
fSigLabels.Push( hsStrcpy( tok2 ) );
|
||||
}
|
||||
else
|
||||
fSigLabels.Push( (char *)nil );
|
||||
|
||||
// Find type
|
||||
for( i = 0; i < kNumTypes; i++ )
|
||||
{
|
||||
if( strcmp( fSigTypes[ i ], tok ) == 0 )
|
||||
{
|
||||
fSignature.Push( (UInt8)i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
hsAssert( i < kNumTypes, "Bad parameter type in console command parameter list!" );
|
||||
|
||||
} while( ( ptr = nextPtr ) != nil );
|
||||
}
|
||||
|
||||
//// Register ////////////////////////////////////////////////////////////////
|
||||
// Finds the group this command should be in and registers it with that
|
||||
// group.
|
||||
|
||||
void pfConsoleCmd::Register( char *group, char *name )
|
||||
{
|
||||
pfConsoleCmdGroup *g;
|
||||
|
||||
|
||||
if( group == nil || group[ 0 ] == 0 )
|
||||
{
|
||||
g = pfConsoleCmdGroup::GetBaseGroup();
|
||||
g->AddCommand( this );
|
||||
}
|
||||
else
|
||||
{
|
||||
g = pfConsoleCmdGroup::FindSubGroupRecurse( group );
|
||||
hsAssert( g != nil, "Trying to register command under nonexistant group!" );
|
||||
g->AddCommand( this );
|
||||
}
|
||||
|
||||
fParentGroup = g;
|
||||
}
|
||||
|
||||
//// Unregister //////////////////////////////////////////////////////////////
|
||||
|
||||
void pfConsoleCmd::Unregister( void )
|
||||
{
|
||||
Unlink();
|
||||
pfConsoleCmdGroup::DecBaseCmdGroupRef();
|
||||
}
|
||||
|
||||
//// Execute /////////////////////////////////////////////////////////////////
|
||||
// Run da thing!
|
||||
|
||||
void pfConsoleCmd::Execute( Int32 numParams, pfConsoleCmdParam *params, void (*PrintFn)( const char * ) )
|
||||
{
|
||||
fFunction( numParams, params, PrintFn );
|
||||
}
|
||||
|
||||
//// Link & Unlink ///////////////////////////////////////////////////////////
|
||||
|
||||
void pfConsoleCmd::Link( pfConsoleCmd **prevPtr )
|
||||
{
|
||||
hsAssert( fNext == nil && fPrevPtr == nil, "Trying to link console command that's already linked!" );
|
||||
|
||||
fNext = *prevPtr;
|
||||
if( *prevPtr )
|
||||
(*prevPtr)->fPrevPtr = &fNext;
|
||||
fPrevPtr = prevPtr;
|
||||
*fPrevPtr = this;
|
||||
}
|
||||
|
||||
void pfConsoleCmd::Unlink( void )
|
||||
{
|
||||
hsAssert( fNext != nil || fPrevPtr != nil, "Trying to unlink console command that isn't linked!" );
|
||||
|
||||
if( fNext )
|
||||
fNext->fPrevPtr = fPrevPtr;
|
||||
*fPrevPtr = fNext;
|
||||
}
|
||||
|
||||
//// GetSigEntry /////////////////////////////////////////////////////////////
|
||||
|
||||
UInt8 pfConsoleCmd::GetSigEntry( UInt8 i )
|
||||
{
|
||||
if( fSignature.GetCount() == 0 )
|
||||
return kNone;
|
||||
|
||||
if( i < fSignature.GetCount() )
|
||||
{
|
||||
if( fSignature[ i ] == kEtc )
|
||||
return kAny;
|
||||
|
||||
return fSignature[ i ];
|
||||
}
|
||||
|
||||
if( fSignature[ fSignature.GetCount() - 1 ] == kEtc )
|
||||
return kAny;
|
||||
|
||||
return kNone;
|
||||
}
|
||||
|
||||
//// GetSignature ////////////////////////////////////////////////////////////
|
||||
// Gets the signature of the command as a string. Format is:
|
||||
// name [ type param [, type param ... ] ]
|
||||
// WARNING: uses a static buffer, so don't rely on the contents if you call
|
||||
// it more than once! (You shouldn't need to, though)
|
||||
|
||||
const char *pfConsoleCmd::GetSignature( void )
|
||||
{
|
||||
static char string[ 256 ];
|
||||
|
||||
int i;
|
||||
char pStr[ 128 ];
|
||||
|
||||
|
||||
strcpy( string, fName );
|
||||
for( i = 0; i < fSignature.GetCount(); i++ )
|
||||
{
|
||||
if( fSigLabels[ i ] == nil )
|
||||
sprintf( pStr, "%s", fSigTypes[ fSignature[ i ] ] );
|
||||
else
|
||||
sprintf( pStr, "%s %s", fSigTypes[ fSignature[ i ] ], fSigLabels[ i ] );
|
||||
|
||||
hsAssert( strlen( string ) + strlen( pStr ) + 2 < sizeof( string ), "Not enough room for signature string" );
|
||||
strcat( string, ( i > 0 ) ? ", " : " " );
|
||||
|
||||
strcat( string, pStr );
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// pfConsoleCmdParam Functions /////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//// Conversion Functions ////////////////////////////////////////////////////
|
||||
|
||||
const int & pfConsoleCmdParam::IToInt( void ) const
|
||||
{
|
||||
hsAssert( fType == kInt || fType == kAny, "Trying to use a non-int parameter as an int!" );
|
||||
|
||||
static int i;
|
||||
if( fType == kAny )
|
||||
{
|
||||
hsAssert( fValue.s != nil, "Weird parameter during conversion" );
|
||||
i = atoi( fValue.s );
|
||||
return i;
|
||||
}
|
||||
|
||||
return fValue.i;
|
||||
}
|
||||
|
||||
const float & pfConsoleCmdParam::IToFloat( void ) const
|
||||
{
|
||||
hsAssert( fType == kFloat || fType == kAny, "Trying to use a non-float parameter as a float!" );
|
||||
|
||||
static float f;
|
||||
if( fType == kAny )
|
||||
{
|
||||
hsAssert( fValue.s != nil, "Weird parameter during conversion" );
|
||||
f = (float)atof( fValue.s );
|
||||
return f;
|
||||
}
|
||||
|
||||
return fValue.f;
|
||||
}
|
||||
|
||||
const bool & pfConsoleCmdParam::IToBool( void ) const
|
||||
{
|
||||
hsAssert( fType == kBool || fType == kAny, "Trying to use a non-bool parameter as a bool!" );
|
||||
|
||||
static bool b;
|
||||
if( fType == kAny )
|
||||
{
|
||||
hsAssert( fValue.s != nil, "Weird parameter during conversion" );
|
||||
if( atoi( fValue.s ) > 0 || stricmp( fValue.s, "true" ) == 0 )
|
||||
b = true;
|
||||
else
|
||||
b = false;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
return fValue.b;
|
||||
}
|
||||
|
||||
const pfConsoleCmdParam::CharPtr & pfConsoleCmdParam::IToString( void ) const
|
||||
{
|
||||
hsAssert( fType == kString || fType == kAny, "Trying to use a non-string parameter as a string!" );
|
||||
|
||||
return fValue.s;
|
||||
}
|
||||
|
||||
const char & pfConsoleCmdParam::IToChar( void ) const
|
||||
{
|
||||
hsAssert( fType == kChar || fType == kAny, "Trying to use a non-char parameter as a char!" );
|
||||
|
||||
static char c;
|
||||
if( fType == kAny )
|
||||
{
|
||||
hsAssert( fValue.s != nil, "Weird parameter during conversion" );
|
||||
c = fValue.s[ 0 ];
|
||||
return c;
|
||||
}
|
||||
|
||||
return fValue.c;
|
||||
}
|
||||
|
@ -1,272 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// pfConsoleCmd Header //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _pfConsoleCmd_h
|
||||
#define _pfConsoleCmd_h
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsBiExpander.h"
|
||||
|
||||
|
||||
//// pfConsoleCmdGroup Class Definition //////////////////////////////////////
|
||||
|
||||
class pfConsoleCmd;
|
||||
class pfConsoleCmdIterator;
|
||||
|
||||
|
||||
class pfConsoleCmdGroup
|
||||
{
|
||||
protected:
|
||||
|
||||
static pfConsoleCmdGroup *fBaseCmdGroup;
|
||||
static UInt32 fBaseCmdGroupRef;
|
||||
|
||||
char fName[ 128 ];
|
||||
|
||||
pfConsoleCmdGroup *fNext;
|
||||
pfConsoleCmdGroup **fPrevPtr;
|
||||
|
||||
pfConsoleCmdGroup *fSubGroups;
|
||||
pfConsoleCmd *fCommands;
|
||||
|
||||
pfConsoleCmdGroup *fParentGroup;
|
||||
|
||||
public:
|
||||
|
||||
enum FindFlags {
|
||||
kFindPartial = 0x01
|
||||
};
|
||||
|
||||
pfConsoleCmdGroup( char *name, char *parent );
|
||||
~pfConsoleCmdGroup();
|
||||
|
||||
void AddCommand( pfConsoleCmd *cmd );
|
||||
void AddSubGroup( pfConsoleCmdGroup *group );
|
||||
|
||||
void Link( pfConsoleCmdGroup **prevPtr );
|
||||
void Unlink( void );
|
||||
|
||||
pfConsoleCmdGroup *GetNext( void ) { return fNext; }
|
||||
char *GetName( void ) { return fName; }
|
||||
pfConsoleCmdGroup *GetParent( void ) { return fParentGroup; }
|
||||
|
||||
static pfConsoleCmdGroup *GetBaseGroup( void );
|
||||
|
||||
pfConsoleCmd *FindCommand( char *name );
|
||||
pfConsoleCmd *FindCommandNoCase( char *name, UInt8 flags = 0, pfConsoleCmd *start = nil );
|
||||
pfConsoleCmd *FindNestedPartialCommand( char *name, UInt32 *counter );
|
||||
|
||||
pfConsoleCmdGroup *FindSubGroup( char *name );
|
||||
pfConsoleCmdGroup *FindSubGroupNoCase( char *name, UInt8 flags = 0, pfConsoleCmdGroup *start = nil );
|
||||
|
||||
pfConsoleCmd *GetFirstCommand( void ) { return fCommands; }
|
||||
pfConsoleCmdGroup *GetFirstSubGroup( void ) { return fSubGroups; }
|
||||
|
||||
int IterateCommands(pfConsoleCmdIterator*, int depth=0);
|
||||
|
||||
static pfConsoleCmdGroup *FindSubGroupRecurse( const char *name );
|
||||
static void DecBaseCmdGroupRef( void );
|
||||
|
||||
static void Dummy( void );
|
||||
static void DummyJunior( void );
|
||||
static void DummyNet( void );
|
||||
static void DummyAvatar( void );
|
||||
static void DummyCCR( void );
|
||||
};
|
||||
|
||||
//// pfConsoleCmdParam Class Definition //////////////////////////////////////
|
||||
|
||||
class pfConsoleCmdParam
|
||||
{
|
||||
protected:
|
||||
|
||||
UInt8 fType;
|
||||
|
||||
typedef char *CharPtr;
|
||||
|
||||
union
|
||||
{
|
||||
int i;
|
||||
float f;
|
||||
bool b;
|
||||
CharPtr s;
|
||||
char c;
|
||||
} fValue;
|
||||
|
||||
const int &IToInt( void ) const;
|
||||
const float &IToFloat( void ) const;
|
||||
const bool &IToBool( void ) const;
|
||||
const CharPtr &IToString( void ) const;
|
||||
const char &IToChar( void ) const;
|
||||
|
||||
public:
|
||||
|
||||
enum Types
|
||||
{
|
||||
kInt = 0,
|
||||
kFloat,
|
||||
kBool,
|
||||
kString,
|
||||
kChar,
|
||||
kAny,
|
||||
kNone = 0xff
|
||||
};
|
||||
|
||||
operator int() const { return IToInt(); }
|
||||
operator float() const { return IToFloat(); }
|
||||
operator bool() const { return IToBool(); }
|
||||
operator const CharPtr() const { return IToString(); }
|
||||
operator char() const { return IToChar(); }
|
||||
|
||||
UInt8 GetType( void ) { return fType; }
|
||||
|
||||
void SetInt( int i ) { fValue.i = i; fType = kInt; }
|
||||
void SetFloat( float f ) { fValue.f = f; fType = kFloat; }
|
||||
void SetBool( bool b ) { fValue.b = b; fType = kBool; }
|
||||
void SetString( CharPtr s ) { fValue.s = s; fType = kString; }
|
||||
void SetChar( char c ) { fValue.c = c; fType = kChar; }
|
||||
void SetAny( CharPtr s ) { fValue.s = s; fType = kAny; }
|
||||
void SetNone( void ) { fType = kNone; }
|
||||
};
|
||||
|
||||
//// pfConsoleCmd Class Definition ///////////////////////////////////////////
|
||||
|
||||
typedef void (*pfConsoleCmdPtr)( Int32 numParams, pfConsoleCmdParam *params, void (*PrintString)( const char * ) );
|
||||
|
||||
class pfConsoleCmd
|
||||
{
|
||||
protected:
|
||||
char fName[ 128 ];
|
||||
char *fHelpString;
|
||||
|
||||
pfConsoleCmdPtr fFunction;
|
||||
hsBool fLocalOnly;
|
||||
|
||||
pfConsoleCmd *fNext;
|
||||
pfConsoleCmd **fPrevPtr;
|
||||
|
||||
pfConsoleCmdGroup *fParentGroup;
|
||||
|
||||
hsExpander<UInt8> fSignature;
|
||||
hsExpander<char *> fSigLabels;
|
||||
|
||||
void ICreateSignature( char *paramList );
|
||||
|
||||
public:
|
||||
|
||||
enum ParamTypes
|
||||
{
|
||||
kInt = 0,
|
||||
kFloat,
|
||||
kBool,
|
||||
kString,
|
||||
kChar,
|
||||
kAny,
|
||||
kEtc,
|
||||
kNumTypes,
|
||||
kNone = 0xff
|
||||
};
|
||||
|
||||
static char fSigTypes[ kNumTypes ][ 8 ];
|
||||
|
||||
|
||||
pfConsoleCmd( char *group, char *name, char *paramList, char *help, pfConsoleCmdPtr func, hsBool localOnly = false );
|
||||
~pfConsoleCmd();
|
||||
|
||||
void Register( char *group, char *name );
|
||||
void Unregister();
|
||||
void Execute( Int32 numParams, pfConsoleCmdParam *params, void (*PrintFn)( const char * ) = nil );
|
||||
|
||||
void Link( pfConsoleCmd **prevPtr );
|
||||
void Unlink( void );
|
||||
|
||||
pfConsoleCmd *GetNext( void ) { return fNext; }
|
||||
char *GetName( void ) { return fName; }
|
||||
char *GetHelp( void ) { return fHelpString; }
|
||||
const char *GetSignature( void );
|
||||
|
||||
pfConsoleCmdGroup *GetParent( void ) { return fParentGroup; }
|
||||
|
||||
UInt8 GetSigEntry( UInt8 i );
|
||||
};
|
||||
|
||||
|
||||
|
||||
class pfConsoleCmdIterator
|
||||
{
|
||||
public:
|
||||
virtual void ProcessCmd(pfConsoleCmd*, int ) {}
|
||||
virtual bool ProcessGroup(pfConsoleCmdGroup *, int) {return true;}
|
||||
};
|
||||
|
||||
|
||||
//// pfConsoleCmd Creation Macro /////////////////////////////////////////////
|
||||
//
|
||||
// This expands into 3 things:
|
||||
// - A prototype for the function.
|
||||
// - A declaration of a pfConsoleCmd object, which takes in that function
|
||||
// as a parameter
|
||||
// - The start of the function itself, so that the {} after the macro
|
||||
// define the body of that function.
|
||||
//
|
||||
// PF_LOCAL_CONSOLE_CMD is identical, only it passes true for the localOnly flag.
|
||||
// This isn't used currently and is here only for legacy.
|
||||
|
||||
// PF_CONSOLE_BASE_CMD doesn't belong to a group; it creates a global console function.
|
||||
|
||||
|
||||
#define PF_CONSOLE_BASE_CMD( name, p, help ) \
|
||||
void pfConsoleCmd_##name##_proc( Int32 numParams, pfConsoleCmdParam *params, void (*PrintString)( const char * ) ); \
|
||||
pfConsoleCmd conCmd_##name( nil, #name, p, help, pfConsoleCmd_##name##_proc ); \
|
||||
void pfConsoleCmd_##name##_proc( Int32 numParams, pfConsoleCmdParam *params, void (*PrintString)( const char * ) )
|
||||
|
||||
#define PF_CONSOLE_CMD( grp, name, p, help ) \
|
||||
void pfConsoleCmd_##grp##_##name##_proc( Int32 numParams, pfConsoleCmdParam *params, void (*PrintString)( const char * ) ); \
|
||||
pfConsoleCmd conCmd_##grp##_##name( #grp, #name, p, help, pfConsoleCmd_##grp##_##name##_proc ); \
|
||||
void pfConsoleCmd_##grp##_##name##_proc( Int32 numParams, pfConsoleCmdParam *params, void (*PrintString)( const char * ) )
|
||||
|
||||
#define PF_LOCAL_CONSOLE_CMD( grp, name, p, help ) \
|
||||
void pfConsoleCmd_##grp##_##name##_proc( Int32 numParams, pfConsoleCmdParam *params, void (*PrintString)( const char * ) ); \
|
||||
pfConsoleCmd conCmd_##grp##_##name( #grp, #name, p, help, pfConsoleCmd_##grp##_##name##_proc, true ); \
|
||||
void pfConsoleCmd_##grp##_##name##_proc( Int32 numParams, pfConsoleCmdParam *params, void (*PrintString)( const char * ) )
|
||||
|
||||
//// pfConsoleCmdGroup Creation Macro ////////////////////////////////////////
|
||||
|
||||
#define PF_CONSOLE_GROUP( name ) \
|
||||
pfConsoleCmdGroup conGroup_##name( #name, nil );
|
||||
|
||||
#define PF_CONSOLE_SUBGROUP( parent, name ) \
|
||||
pfConsoleCmdGroup conGroup_##parent##_##name( #name, #parent );
|
||||
|
||||
|
||||
|
||||
#endif //_pfConsoleCmd_h
|
||||
|
@ -34,7 +34,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#endif
|
||||
|
||||
|
||||
#include "pfConsoleCmd.h"
|
||||
#include "pfConsoleCore/pfConsoleCmd.h"
|
||||
#include "plgDispatch.h"
|
||||
|
||||
#include "plAgeLoader/plAgeLoader.h"
|
||||
@ -75,7 +75,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plVault/plVault.h"
|
||||
#include "../../Apps/plClient/plClient.h"
|
||||
#include "pfConsole.h"
|
||||
#include "pfConsoleContext.h"
|
||||
#include "pfConsoleCore/pfConsoleContext.h"
|
||||
#include "plResMgr/plKeyFinder.h"
|
||||
#include "plModifier/plSimpleModifier.h"
|
||||
#include "plAvatar/plAvatarMgr.h"
|
||||
@ -160,10 +160,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
//// DO NOT REMOVE!!!!
|
||||
//// This is here so Microsoft VC won't decide to "optimize" this file out
|
||||
//// DO NOT REMOVE!!!!
|
||||
void pfConsoleCmdGroup::Dummy( void )
|
||||
{
|
||||
}
|
||||
PF_CONSOLE_FILE_DUMMY(Main)
|
||||
//// DO NOT REMOVE!!!!
|
||||
|
||||
//// Defining Console Commands ///////////////////////////////////////////////
|
||||
@ -258,6 +255,7 @@ plKey FindSceneObjectByName(const char* name, const char* ageName, char* statusS
|
||||
plKey FindObjectByName(const char* name, int type, const char* ageName, char* statusStr, bool subString=false);
|
||||
plKey FindObjectByNameAndType(const char* name, const char* typeName, const char* ageName,
|
||||
char* statusStr, bool subString=false);
|
||||
void PrintStringF(void pfun(const char *),const char * fmt, ...);
|
||||
|
||||
//
|
||||
// Find an object from name, type (int), and optionally age.
|
||||
@ -355,17 +353,6 @@ plKey FindObjectByNameAndType(const char* name, const char* typeName, const char
|
||||
return FindObjectByName(name, plFactory::FindClassIndex(typeName), ageName, statusStr, subString);
|
||||
}
|
||||
|
||||
void PrintStringF(void pfun(const char *),const char * fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
char buffy[512];
|
||||
va_start(args, fmt);
|
||||
vsprintf(buffy, fmt, args);
|
||||
va_end(args);
|
||||
pfun(buffy);
|
||||
}
|
||||
|
||||
//// plDoesFileExist //////////////////////////////////////////////////////////
|
||||
// Utility function to determine whether the given file exists
|
||||
|
||||
|
@ -34,7 +34,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#endif
|
||||
|
||||
|
||||
#include "pfConsoleCmd.h"
|
||||
#include "pfConsoleCore/pfConsoleCmd.h"
|
||||
#include "plgDispatch.h"
|
||||
|
||||
#include "plAgeLoader/plAgeLoader.h"
|
||||
@ -89,10 +89,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
//// DO NOT REMOVE!!!!
|
||||
//// This is here so Microsoft VC won't decide to "optimize" this file out
|
||||
//// DO NOT REMOVE!!!!
|
||||
void pfConsoleCmdGroup::DummyNet( void )
|
||||
{
|
||||
}
|
||||
PF_CONSOLE_FILE_DUMMY(Net)
|
||||
//// DO NOT REMOVE!!!!
|
||||
|
||||
//// Defining Console Commands ///////////////////////////////////////////////
|
||||
@ -1053,284 +1050,3 @@ PF_CONSOLE_CMD(
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Server
|
||||
*
|
||||
***/
|
||||
|
||||
//TODO: Fix Plasma to use OpenSSL's byte order (or better yet, to use OpenSSL),
|
||||
// so this hack isn't needed
|
||||
static void swap_key_bytes(byte keyData[])
|
||||
{
|
||||
for (size_t i = 0; i < (kNetDiffieHellmanKeyBits / 16); ++i)
|
||||
std::swap(keyData[i], keyData[ (kNetDiffieHellmanKeyBits / 8) - i - 1 ]);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
// Server group
|
||||
PF_CONSOLE_GROUP(Server)
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server,
|
||||
Status,
|
||||
"string url",
|
||||
"Set the server's status URL"
|
||||
) {
|
||||
wchar_t *wurl = hsStringToWString((const char *)params[0]);
|
||||
SetServerStatusUrl(wurl);
|
||||
delete [] wurl;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server,
|
||||
Signup,
|
||||
"string url",
|
||||
"Set the server's new user sign-up URL"
|
||||
) {
|
||||
wchar_t *wurl = hsStringToWString((const char *)params[0]);
|
||||
SetServerSignupUrl(wurl);
|
||||
delete [] wurl;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server,
|
||||
DispName,
|
||||
"string name",
|
||||
"Set the displayable server name"
|
||||
) {
|
||||
wchar_t *wname = hsStringToWString((const char *)params[0]);
|
||||
SetServerDisplayName(wname);
|
||||
delete [] wname;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
// Server.File group
|
||||
PF_CONSOLE_SUBGROUP(Server, File)
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server_File,
|
||||
Host,
|
||||
"string address",
|
||||
"Set the File Server address"
|
||||
) {
|
||||
wchar_t *wHost = hsStringToWString((const char *)params[0]);
|
||||
SetFileSrvHostname(wHost);
|
||||
delete [] wHost;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
// Server.Auth group
|
||||
PF_CONSOLE_SUBGROUP(Server, Auth)
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server_Auth,
|
||||
Host,
|
||||
"string address",
|
||||
"Set the Auth Server address"
|
||||
) {
|
||||
wchar_t *wHost = hsStringToWString((const char *)params[0]);
|
||||
SetAuthSrvHostname(wHost);
|
||||
delete [] wHost;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server_Auth,
|
||||
N,
|
||||
"string base64Key",
|
||||
"Set the Auth Server N key"
|
||||
) {
|
||||
int baseLength = hsStrlen((const char *)params[0]);
|
||||
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
|
||||
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
|
||||
kNetDiffieHellmanKeyBits / 8);
|
||||
return;
|
||||
}
|
||||
|
||||
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
|
||||
kNetDiffieHellmanKeyBits / 8, kAuthDhNData);
|
||||
swap_key_bytes(kAuthDhNData);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server_Auth,
|
||||
X,
|
||||
"string base64Key",
|
||||
"Set the Auth Server X key"
|
||||
) {
|
||||
int baseLength = hsStrlen((const char *)params[0]);
|
||||
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
|
||||
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
|
||||
kNetDiffieHellmanKeyBits / 8);
|
||||
return;
|
||||
}
|
||||
|
||||
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
|
||||
kNetDiffieHellmanKeyBits / 8, kAuthDhXData);
|
||||
swap_key_bytes(kAuthDhXData);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
// Server.Csr group
|
||||
PF_CONSOLE_SUBGROUP(Server, Csr)
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server_Csr,
|
||||
Host,
|
||||
"string address",
|
||||
"Set the Csr Server address"
|
||||
) {
|
||||
wchar_t *wHost = hsStringToWString((const char *)params[0]);
|
||||
SetCsrSrvHostname(wHost);
|
||||
delete [] wHost;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server_Csr,
|
||||
N,
|
||||
"string base64Key",
|
||||
"Set the Csr Server N key"
|
||||
) {
|
||||
int baseLength = hsStrlen((const char *)params[0]);
|
||||
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
|
||||
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
|
||||
kNetDiffieHellmanKeyBits / 8);
|
||||
return;
|
||||
}
|
||||
|
||||
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
|
||||
kNetDiffieHellmanKeyBits / 8, kCsrDhNData);
|
||||
swap_key_bytes(kCsrDhNData);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server_Csr,
|
||||
X,
|
||||
"string base64Key",
|
||||
"Set the Csr Server X key"
|
||||
) {
|
||||
int baseLength = hsStrlen((const char *)params[0]);
|
||||
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
|
||||
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
|
||||
kNetDiffieHellmanKeyBits / 8);
|
||||
return;
|
||||
}
|
||||
|
||||
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
|
||||
kNetDiffieHellmanKeyBits / 8, kCsrDhXData);
|
||||
swap_key_bytes(kCsrDhXData);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
// Server.Game group
|
||||
PF_CONSOLE_SUBGROUP(Server, Game)
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server_Game,
|
||||
N,
|
||||
"string base64Key",
|
||||
"Set the Game Server N key"
|
||||
) {
|
||||
int baseLength = hsStrlen((const char *)params[0]);
|
||||
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
|
||||
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
|
||||
kNetDiffieHellmanKeyBits / 8);
|
||||
return;
|
||||
}
|
||||
|
||||
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
|
||||
kNetDiffieHellmanKeyBits / 8, kGameDhNData);
|
||||
swap_key_bytes(kGameDhNData);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server_Game,
|
||||
X,
|
||||
"string base64Key",
|
||||
"Set the Game Server X key"
|
||||
) {
|
||||
int baseLength = hsStrlen((const char *)params[0]);
|
||||
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
|
||||
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
|
||||
kNetDiffieHellmanKeyBits / 8);
|
||||
return;
|
||||
}
|
||||
|
||||
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
|
||||
kNetDiffieHellmanKeyBits / 8, kGameDhXData);
|
||||
swap_key_bytes(kGameDhXData);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
// Server.Gate group
|
||||
PF_CONSOLE_SUBGROUP(Server, Gate)
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server_Gate,
|
||||
Host,
|
||||
"string address",
|
||||
"Set the GateKeeper Server address"
|
||||
) {
|
||||
wchar_t *wHost = hsStringToWString((const char *)params[0]);
|
||||
SetGateKeeperSrvHostname(wHost);
|
||||
delete [] wHost;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server_Gate,
|
||||
N,
|
||||
"string base64Key",
|
||||
"Set the GateKeeper Server N key"
|
||||
) {
|
||||
int baseLength = hsStrlen((const char *)params[0]);
|
||||
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
|
||||
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
|
||||
kNetDiffieHellmanKeyBits / 8);
|
||||
return;
|
||||
}
|
||||
|
||||
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
|
||||
kNetDiffieHellmanKeyBits / 8, kGateKeeperDhNData);
|
||||
swap_key_bytes(kGateKeeperDhNData);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
PF_CONSOLE_CMD(
|
||||
Server_Gate,
|
||||
X,
|
||||
"string base64Key",
|
||||
"Set the GateKeeper Server X key"
|
||||
) {
|
||||
int baseLength = hsStrlen((const char *)params[0]);
|
||||
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
|
||||
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
|
||||
kNetDiffieHellmanKeyBits / 8);
|
||||
return;
|
||||
}
|
||||
|
||||
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
|
||||
kNetDiffieHellmanKeyBits / 8, kGateKeeperDhXData);
|
||||
swap_key_bytes(kGateKeeperDhXData);
|
||||
}
|
||||
|
@ -1,276 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// pfConsoleContext //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "pfConsoleContext.h"
|
||||
|
||||
|
||||
//// Static Root Context /////////////////////////////////////////////////////
|
||||
|
||||
pfConsoleContext pfConsoleContext::fRootContext( "global" );
|
||||
|
||||
pfConsoleContext &pfConsoleContext::GetRootContext( void )
|
||||
{
|
||||
return fRootContext;
|
||||
}
|
||||
|
||||
//// Constructor/Destructor //////////////////////////////////////////////////
|
||||
|
||||
pfConsoleContext::pfConsoleContext( const char *name )
|
||||
{
|
||||
fName = ( name != nil ) ? hsStrcpy( name ) : nil;
|
||||
fAddWhenNotFound = true;
|
||||
}
|
||||
|
||||
pfConsoleContext::~pfConsoleContext()
|
||||
{
|
||||
Clear();
|
||||
delete [] fName;
|
||||
}
|
||||
|
||||
//// Clear ///////////////////////////////////////////////////////////////////
|
||||
|
||||
void pfConsoleContext::Clear( void )
|
||||
{
|
||||
Int32 idx;
|
||||
|
||||
|
||||
for( idx = fVarValues.GetCount() - 1; idx >= 0; idx-- )
|
||||
RemoveVar( idx );
|
||||
}
|
||||
|
||||
//// Getters /////////////////////////////////////////////////////////////////
|
||||
|
||||
UInt32 pfConsoleContext::GetNumVars( void ) const
|
||||
{
|
||||
hsAssert( fVarValues.GetCount() == fVarNames.GetCount(), "Mismatch in console var context arrays" );
|
||||
return fVarValues.GetCount();
|
||||
}
|
||||
|
||||
const char *pfConsoleContext::GetVarName( UInt32 idx ) const
|
||||
{
|
||||
hsAssert( fVarValues.GetCount() == fVarNames.GetCount(), "Mismatch in console var context arrays" );
|
||||
|
||||
if( idx >= fVarNames.GetCount() )
|
||||
{
|
||||
hsAssert( false, "GetVarName() index out of range for console context" );
|
||||
return nil;
|
||||
}
|
||||
|
||||
return fVarNames[ idx ];
|
||||
}
|
||||
|
||||
pfConsoleCmdParam &pfConsoleContext::GetVarValue( UInt32 idx ) const
|
||||
{
|
||||
hsAssert( fVarValues.GetCount() == fVarNames.GetCount(), "Mismatch in console var context arrays" );
|
||||
hsAssert( idx < fVarValues.GetCount(), "GetVarValue() index out of range for console context" );
|
||||
|
||||
return fVarValues[ idx ];
|
||||
}
|
||||
|
||||
|
||||
//// FindVar /////////////////////////////////////////////////////////////////
|
||||
|
||||
Int32 pfConsoleContext::FindVar( const char *name ) const
|
||||
{
|
||||
UInt32 idx;
|
||||
|
||||
|
||||
hsAssert( fVarValues.GetCount() == fVarNames.GetCount(), "Mismatch in console var context arrays" );
|
||||
|
||||
for( idx = 0; idx < fVarNames.GetCount(); idx++ )
|
||||
{
|
||||
if( stricmp( name, fVarNames[ idx ] ) == 0 )
|
||||
{
|
||||
return (Int32)idx;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//// RemoveVar ///////////////////////////////////////////////////////////////
|
||||
|
||||
void pfConsoleContext::RemoveVar( UInt32 idx )
|
||||
{
|
||||
hsAssert( fVarValues.GetCount() == fVarNames.GetCount(), "Mismatch in console var context arrays" );
|
||||
|
||||
if( idx >= fVarValues.GetCount() )
|
||||
{
|
||||
hsAssert( false, "RemoveVar() index out of range for console context" );
|
||||
return;
|
||||
}
|
||||
|
||||
delete [] fVarNames[ idx ];
|
||||
if( fVarValues[ idx ].GetType() == pfConsoleCmdParam::kString )
|
||||
// Necessary because the params won't delete the data themselves
|
||||
delete [] ( (char *)fVarValues[ idx ] );
|
||||
|
||||
fVarNames.Remove( idx );
|
||||
fVarValues.Remove( idx );
|
||||
}
|
||||
|
||||
//// AddVar Variants /////////////////////////////////////////////////////////
|
||||
|
||||
void pfConsoleContext::IAddVar( const char *name, const pfConsoleCmdParam &value )
|
||||
{
|
||||
fVarNames.Append( hsStrcpy( name ) );
|
||||
fVarValues.Append( value );
|
||||
|
||||
// Remember, params won't know any better, since by default they don't own a copy of their string
|
||||
UInt32 idx = fVarValues.GetCount() - 1;
|
||||
if( fVarValues[ idx ].GetType() == pfConsoleCmdParam::kString )
|
||||
fVarValues[ idx ].SetString( hsStrcpy( fVarValues[ idx ] ) );
|
||||
}
|
||||
|
||||
void pfConsoleContext::AddVar( const char *name, const pfConsoleCmdParam &value )
|
||||
{
|
||||
Int32 idx = FindVar( name );
|
||||
if( idx != -1 )
|
||||
{
|
||||
hsAssert( false, "AddVar() failed because variable already in console context" );
|
||||
return;
|
||||
}
|
||||
|
||||
IAddVar( name, value );
|
||||
}
|
||||
|
||||
void pfConsoleContext::AddVar( const char *name, int value )
|
||||
{
|
||||
pfConsoleCmdParam param;
|
||||
param.SetInt( value );
|
||||
AddVar( name, param );
|
||||
}
|
||||
|
||||
void pfConsoleContext::AddVar( const char *name, float value )
|
||||
{
|
||||
pfConsoleCmdParam param;
|
||||
param.SetFloat( value );
|
||||
AddVar( name, param );
|
||||
}
|
||||
|
||||
void pfConsoleContext::AddVar( const char *name, const char *value )
|
||||
{
|
||||
pfConsoleCmdParam param;
|
||||
param.SetString( (char *)value ); // It's ok, we'll be copying it soon 'nuf
|
||||
AddVar( name, param );
|
||||
}
|
||||
|
||||
void pfConsoleContext::AddVar( const char *name, char value )
|
||||
{
|
||||
pfConsoleCmdParam param;
|
||||
param.SetChar( value );
|
||||
AddVar( name, param );
|
||||
}
|
||||
|
||||
void pfConsoleContext::AddVar( const char *name, bool value )
|
||||
{
|
||||
pfConsoleCmdParam param;
|
||||
param.SetBool( value );
|
||||
AddVar( name, param );
|
||||
}
|
||||
|
||||
//// SetVar Variants /////////////////////////////////////////////////////////
|
||||
|
||||
hsBool pfConsoleContext::SetVar( UInt32 idx, const pfConsoleCmdParam &value )
|
||||
{
|
||||
hsAssert( fVarValues.GetCount() == fVarNames.GetCount(), "Mismatch in console var context arrays" );
|
||||
if( idx >= fVarValues.GetCount() )
|
||||
{
|
||||
hsAssert( false, "SetVar() index out of range for console context" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( fVarValues[ idx ].GetType() == pfConsoleCmdParam::kString )
|
||||
{
|
||||
// Remember, params won't know any better, since by default they don't own a copy of their string
|
||||
delete [] ( (char *)fVarValues[ idx ] );
|
||||
}
|
||||
|
||||
fVarValues[ idx ] = value;
|
||||
if( fVarValues[ idx ].GetType() == pfConsoleCmdParam::kString )
|
||||
fVarValues[ idx ].SetString( hsStrcpy( fVarValues[ idx ] ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
hsBool pfConsoleContext::SetVar( const char *name, const pfConsoleCmdParam &value )
|
||||
{
|
||||
Int32 idx = FindVar( name );
|
||||
if( idx == -1 )
|
||||
{
|
||||
if( fAddWhenNotFound )
|
||||
{
|
||||
// Don't panic, just add
|
||||
IAddVar( name, value );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return SetVar( idx, value );
|
||||
}
|
||||
|
||||
hsBool pfConsoleContext::SetVar( const char *name, int value )
|
||||
{
|
||||
pfConsoleCmdParam param;
|
||||
param.SetInt( value );
|
||||
return SetVar( name, param );
|
||||
}
|
||||
|
||||
hsBool pfConsoleContext::SetVar( const char *name, float value )
|
||||
{
|
||||
pfConsoleCmdParam param;
|
||||
param.SetFloat( value );
|
||||
return SetVar( name, param );
|
||||
}
|
||||
|
||||
hsBool pfConsoleContext::SetVar( const char *name, const char *value )
|
||||
{
|
||||
pfConsoleCmdParam param;
|
||||
param.SetString( (char *)value ); // Don't worry, we'll be copying it soon 'nuf
|
||||
return SetVar( name, param );
|
||||
}
|
||||
|
||||
hsBool pfConsoleContext::SetVar( const char *name, char value )
|
||||
{
|
||||
pfConsoleCmdParam param;
|
||||
param.SetChar( value );
|
||||
return SetVar( name, param );
|
||||
}
|
||||
|
||||
hsBool pfConsoleContext::SetVar( const char *name, bool value )
|
||||
{
|
||||
pfConsoleCmdParam param;
|
||||
param.SetBool( value );
|
||||
return SetVar( name, param );
|
||||
}
|
||||
|
@ -1,95 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// pfConsoleContext Header //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _pfConsoleContext_h
|
||||
#define _pfConsoleContext_h
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "pfConsoleCmd.h"
|
||||
|
||||
|
||||
//// Class Definition ////////////////////////////////////////////////////////
|
||||
|
||||
class pfConsoleContext
|
||||
{
|
||||
protected:
|
||||
|
||||
hsBool fAddWhenNotFound; // Controls whether we add variables on Set() calls if they're not found
|
||||
|
||||
char *fName;
|
||||
|
||||
hsTArray<char *> fVarNames;
|
||||
hsTArray<pfConsoleCmdParam> fVarValues;
|
||||
|
||||
void IAddVar( const char *name, const pfConsoleCmdParam &value );
|
||||
|
||||
static pfConsoleContext fRootContext;
|
||||
|
||||
public:
|
||||
|
||||
pfConsoleContext( const char *name );
|
||||
virtual ~pfConsoleContext();
|
||||
|
||||
void Clear( void );
|
||||
|
||||
UInt32 GetNumVars( void ) const;
|
||||
const char *GetVarName( UInt32 idx ) const;
|
||||
pfConsoleCmdParam &GetVarValue( UInt32 idx ) const;
|
||||
|
||||
Int32 FindVar( const char *name ) const;
|
||||
void RemoveVar( UInt32 idx );
|
||||
|
||||
void AddVar( const char *name, const pfConsoleCmdParam &value );
|
||||
void AddVar( const char *name, int value );
|
||||
void AddVar( const char *name, float value );
|
||||
void AddVar( const char *name, const char *value );
|
||||
void AddVar( const char *name, char value );
|
||||
void AddVar( const char *name, bool value );
|
||||
|
||||
hsBool SetVar( UInt32 idx, const pfConsoleCmdParam &value );
|
||||
|
||||
hsBool SetVar( const char *name, const pfConsoleCmdParam &value );
|
||||
hsBool SetVar( const char *name, int value );
|
||||
hsBool SetVar( const char *name, float value );
|
||||
hsBool SetVar( const char *name, const char *value );
|
||||
hsBool SetVar( const char *name, char value );
|
||||
hsBool SetVar( const char *name, bool value );
|
||||
|
||||
// Decide whether Sets() on nonexistant variables will fail or add a new variable
|
||||
void SetAddWhenNotFound( hsBool f ) { fAddWhenNotFound = f; }
|
||||
hsBool GetAddWhenNotFound( void ) const { return fAddWhenNotFound; }
|
||||
|
||||
static pfConsoleContext &GetRootContext( void );
|
||||
};
|
||||
|
||||
|
||||
#endif //_pfConsoleContext_h
|
||||
|
@ -41,7 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "pfConsoleEngine.h"
|
||||
#include "pfConsoleCore/pfConsoleEngine.h"
|
||||
|
||||
//// pfConsoleDirSrc Class Definition ////////////////////////////////////////
|
||||
|
||||
|
@ -1,581 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// pfConsoleEngine Functions //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pfConsoleEngine.h"
|
||||
#include "pfConsoleCmd.h"
|
||||
#include "pfConsoleContext.h"
|
||||
|
||||
#include "plFile/plEncryptedStream.h"
|
||||
|
||||
|
||||
const Int32 pfConsoleEngine::fMaxNumParams = 16;
|
||||
|
||||
static const char kTokenSeparators[] = " =\r\n\t,";
|
||||
static const char kTokenGrpSeps[] = " =\r\n._\t,";
|
||||
|
||||
static char *console_strtok( char *&line, hsBool haveCommand )
|
||||
{
|
||||
char *begin = line;
|
||||
|
||||
while (*begin && isspace(*begin))
|
||||
++begin;
|
||||
|
||||
for (line = begin; *line; ++line) {
|
||||
if (!haveCommand) {
|
||||
for (const char *sep = kTokenGrpSeps; *sep; ++sep) {
|
||||
if (*line == *sep) {
|
||||
*line = 0;
|
||||
while (*++line && (*line == *sep))
|
||||
/* skip duplicate delimiters */;
|
||||
return begin;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (*begin == '"' || *begin == '\'') {
|
||||
// Handle strings as a single token
|
||||
char *endptr = strchr(line + 1, *line);
|
||||
if (endptr == nil) {
|
||||
// Bad string token sentry
|
||||
return "\xFF";
|
||||
}
|
||||
*endptr = 0;
|
||||
line = endptr + 1;
|
||||
return begin + 1;
|
||||
}
|
||||
for (const char *sep = kTokenSeparators; *sep; ++sep) {
|
||||
if (*line == *sep) {
|
||||
*line = 0;
|
||||
while (*++line && (*line == *sep))
|
||||
/* skip duplicate delimiters */;
|
||||
return begin;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (begin == line)
|
||||
return nil;
|
||||
|
||||
line = line + strlen(line);
|
||||
return begin;
|
||||
}
|
||||
|
||||
|
||||
//// Constructor & Destructor ////////////////////////////////////////////////
|
||||
|
||||
pfConsoleEngine::pfConsoleEngine()
|
||||
{
|
||||
}
|
||||
|
||||
pfConsoleEngine::~pfConsoleEngine()
|
||||
{
|
||||
}
|
||||
|
||||
//// PrintCmdHelp ////////////////////////////////////////////////////////////
|
||||
|
||||
hsBool pfConsoleEngine::PrintCmdHelp( char *name, void (*PrintFn)( const char * ) )
|
||||
{
|
||||
pfConsoleCmd *cmd;
|
||||
pfConsoleCmdGroup *group, *subGrp;
|
||||
char *ptr;
|
||||
static char string[ 512 ];
|
||||
static char tempString[ 512 ];
|
||||
UInt32 i;
|
||||
|
||||
|
||||
/// Scan for subgroups. This can be an empty loop
|
||||
group = pfConsoleCmdGroup::GetBaseGroup();
|
||||
ptr = console_strtok( name, false );
|
||||
while( ptr != nil )
|
||||
{
|
||||
// Take this token and check to see if it's a group
|
||||
if( ( subGrp = group->FindSubGroupNoCase( ptr ) ) != nil )
|
||||
group = subGrp;
|
||||
else
|
||||
break;
|
||||
|
||||
ptr = console_strtok( name, false );
|
||||
}
|
||||
|
||||
if( ptr == nil )
|
||||
{
|
||||
if( group == nil )
|
||||
{
|
||||
ISetErrorMsg( "Invalid command syntax" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Print help for this group
|
||||
if( group == pfConsoleCmdGroup::GetBaseGroup() )
|
||||
strcpy( string, "Base commands and groups:" );
|
||||
else
|
||||
sprintf( string, "Group %s:", group->GetName() );
|
||||
PrintFn( string );
|
||||
PrintFn( " Subgroups:" );
|
||||
for( subGrp = group->GetFirstSubGroup(); subGrp != nil; subGrp = subGrp->GetNext() )
|
||||
{
|
||||
sprintf( string, " %s", subGrp->GetName() );
|
||||
PrintFn( string );
|
||||
}
|
||||
PrintFn( " Commands:" );
|
||||
for( cmd = group->GetFirstCommand(); cmd != nil; cmd = cmd->GetNext() )
|
||||
{
|
||||
for( ptr = cmd->GetHelp(), i = 0; ptr[ i ] != 0 && ptr[ i ] != '\n'; i++ )
|
||||
tempString[ i ] = ptr[ i ];
|
||||
tempString[ i ] = 0;
|
||||
|
||||
sprintf( string, " %s: %s", cmd->GetName(), tempString );
|
||||
PrintFn( string );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// OK, so what we found wasn't a group. Which means we need a command...
|
||||
cmd = group->FindCommandNoCase( ptr );
|
||||
if( cmd == nil )
|
||||
{
|
||||
ISetErrorMsg( "Invalid syntax: command not found" );
|
||||
return false;
|
||||
}
|
||||
|
||||
/// That's it!
|
||||
sprintf( string, "\nHelp for the command %s:", cmd->GetName() );
|
||||
PrintFn( string );
|
||||
sprintf( string, "\\i%s", cmd->GetHelp() );
|
||||
PrintFn( string );
|
||||
sprintf( string, "\\iUsage: %s", cmd->GetSignature() );
|
||||
PrintFn( string );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//// GetCmdSignature /////////////////////////////////////////////////////////
|
||||
|
||||
const char *pfConsoleEngine::GetCmdSignature( char *name )
|
||||
{
|
||||
pfConsoleCmd *cmd;
|
||||
pfConsoleCmdGroup *group, *subGrp;
|
||||
char *ptr;
|
||||
static char string[ 512 ];
|
||||
|
||||
|
||||
/// Scan for subgroups. This can be an empty loop
|
||||
group = pfConsoleCmdGroup::GetBaseGroup();
|
||||
ptr = console_strtok( name, false );
|
||||
while( ptr != nil )
|
||||
{
|
||||
// Take this token and check to see if it's a group
|
||||
if( ( subGrp = group->FindSubGroupNoCase( ptr ) ) != nil )
|
||||
group = subGrp;
|
||||
else
|
||||
break;
|
||||
|
||||
ptr = console_strtok( name, false );
|
||||
}
|
||||
|
||||
if( ptr == nil )
|
||||
{
|
||||
ISetErrorMsg( "Invalid command syntax" );
|
||||
return nil;
|
||||
}
|
||||
|
||||
/// OK, so what we found wasn't a group. Which means we need a command...
|
||||
cmd = group->FindCommandNoCase( ptr );
|
||||
if( cmd == nil )
|
||||
{
|
||||
ISetErrorMsg( "Invalid syntax: command not found" );
|
||||
return nil;
|
||||
}
|
||||
|
||||
/// That's it!
|
||||
return (char *)cmd->GetSignature();
|
||||
}
|
||||
|
||||
//// Dummy Local Function ////////////////////////////////////////////////////
|
||||
|
||||
void DummyPrintFn( const char *line )
|
||||
{
|
||||
}
|
||||
|
||||
//// ExecuteFile /////////////////////////////////////////////////////////////
|
||||
|
||||
hsBool pfConsoleEngine::ExecuteFile( const char *fileName )
|
||||
{
|
||||
wchar* wFilename = hsStringToWString(fileName);
|
||||
hsBool ret = ExecuteFile(wFilename);
|
||||
delete [] wFilename;
|
||||
return ret;
|
||||
}
|
||||
|
||||
hsBool pfConsoleEngine::ExecuteFile( const wchar *fileName )
|
||||
{
|
||||
char string[ 512 ];
|
||||
int line;
|
||||
|
||||
hsStream* stream = plEncryptedStream::OpenEncryptedFile(fileName);
|
||||
|
||||
if( !stream )
|
||||
{
|
||||
ISetErrorMsg( "Cannot open given file" );
|
||||
// return false;
|
||||
/// THIS IS BAD: because of the asserts we throw after this if we return false, a missing
|
||||
/// file will throw an assert. This is all well and good except for the age-specific .fni files,
|
||||
/// which aren't required to be there and rely on this functionality to test whether the file is
|
||||
/// present. Once age-specific .fni's are gone, reinstate the return false here. -mcn
|
||||
return true;
|
||||
}
|
||||
|
||||
for( line = 1; stream->ReadLn( string, sizeof( string ) ); line++ )
|
||||
{
|
||||
strncpy( fLastErrorLine, string, sizeof( fLastErrorLine ) );
|
||||
|
||||
if( !RunCommand( string, DummyPrintFn ) )
|
||||
{
|
||||
sprintf( string, "Error in console file %s, command line %d: %s", fileName, line, fErrorMsg );
|
||||
ISetErrorMsg( string );
|
||||
stream->Close();
|
||||
delete stream;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
stream->Close();
|
||||
delete stream;
|
||||
fLastErrorLine[ 0 ] = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//// RunCommand //////////////////////////////////////////////////////////////
|
||||
// Updated 2.14.2001 mcn to support spaces, _ or . as group separators. This
|
||||
// requires tokenizing the entire line and searching the tokens one by one,
|
||||
// parsing them first as groups, then commands and then params.
|
||||
|
||||
hsBool pfConsoleEngine::RunCommand( char *line, void (*PrintFn)( const char * ) )
|
||||
{
|
||||
pfConsoleCmd *cmd;
|
||||
pfConsoleCmdGroup *group, *subGrp;
|
||||
Int32 numParams, i, numQuotedParams = 0;
|
||||
pfConsoleCmdParam paramArray[ fMaxNumParams + 1 ];
|
||||
char *ptr;
|
||||
hsBool valid = true;
|
||||
|
||||
|
||||
hsAssert( line != nil, "Bad parameter to RunCommand()" );
|
||||
|
||||
/// Loop #1: Scan for subgroups. This can be an empty loop
|
||||
group = pfConsoleCmdGroup::GetBaseGroup();
|
||||
ptr = console_strtok( line, false );
|
||||
while( ptr != nil )
|
||||
{
|
||||
// Take this token and check to see if it's a group
|
||||
if( ( subGrp = group->FindSubGroupNoCase( ptr ) ) != nil )
|
||||
group = subGrp;
|
||||
else
|
||||
break;
|
||||
|
||||
ptr = console_strtok( line, false );
|
||||
}
|
||||
|
||||
if( ptr == nil )
|
||||
{
|
||||
ISetErrorMsg( "Invalid command syntax" );
|
||||
return false;
|
||||
}
|
||||
|
||||
/// OK, so what we found wasn't a group. Which means we need a command next
|
||||
cmd = group->FindCommandNoCase( ptr );
|
||||
if( cmd == nil )
|
||||
{
|
||||
ISetErrorMsg( "Invalid syntax: command not found" );
|
||||
return false;
|
||||
}
|
||||
|
||||
/// We have the group, we have the command from that group. So continue
|
||||
/// tokenizing (with the new separators now, mind you) and turn them into
|
||||
/// params
|
||||
|
||||
for( numParams = numQuotedParams = 0; numParams < fMaxNumParams
|
||||
&& ( ptr = console_strtok( line, true ) ) != nil
|
||||
&& valid; numParams++ )
|
||||
{
|
||||
if( ptr[ 0 ] == '\xFF' )
|
||||
{
|
||||
ISetErrorMsg( "Invalid syntax: unterminated quoted parameter" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Special case for context variables--if we're specifying one, we want to just grab
|
||||
// the value of it and return that instead
|
||||
valid = false;
|
||||
if( ptr[ 0 ] == '$' )
|
||||
{
|
||||
pfConsoleContext &context = pfConsoleContext::GetRootContext();
|
||||
|
||||
// Potential variable, see if we can find it
|
||||
Int32 idx = context.FindVar( ptr + 1 );
|
||||
if( idx == -1 )
|
||||
{
|
||||
ISetErrorMsg( "Invalid console variable name" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just copy. Note that this will copy string pointers, but so long as the variable in
|
||||
// question doesn't change, we'll be OK...
|
||||
paramArray[ numParams ] = context.GetVarValue( idx );
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( !valid )
|
||||
valid = IConvertToParam( cmd->GetSigEntry( (UInt8)numParams ), ptr, ¶mArray[ numParams ] );
|
||||
}
|
||||
for( i = numParams; i < fMaxNumParams + 1; i++ )
|
||||
paramArray[ i ].SetNone();
|
||||
|
||||
if( !valid || ( cmd->GetSigEntry( (UInt8)numParams ) != pfConsoleCmd::kAny &&
|
||||
cmd->GetSigEntry( (UInt8)numParams ) != pfConsoleCmd::kNone ) )
|
||||
{
|
||||
// Print help string and return
|
||||
static char string[ 512 ];
|
||||
|
||||
ISetErrorMsg( "" ); // Printed on next line
|
||||
PrintFn( "Invalid parameters to command" );
|
||||
sprintf( string, "Usage: %s", cmd->GetSignature() );
|
||||
PrintFn( string );
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Execute it and return
|
||||
cmd->Execute( numParams, paramArray, PrintFn );
|
||||
return true;
|
||||
}
|
||||
|
||||
//// IConvertToParam /////////////////////////////////////////////////////////
|
||||
// Converts a null-terminated string representing a parameter to a
|
||||
// pfConsoleCmdParam argument.
|
||||
|
||||
hsBool pfConsoleEngine::IConvertToParam( UInt8 type, char *string, pfConsoleCmdParam *param )
|
||||
{
|
||||
char *c, expChars[] = "dDeE+-.";
|
||||
hsBool hasDecimal = false, hasLetters = false;
|
||||
|
||||
|
||||
if( type == pfConsoleCmd::kNone )
|
||||
return false;
|
||||
|
||||
for( c = string; *c != 0; c++ )
|
||||
{
|
||||
if( !isdigit( *c ) )
|
||||
{
|
||||
if( c == string && ( *c == '-' || *c == '+' ) )
|
||||
{
|
||||
// Do nothing--perfectly legal to have these at the beginning of an int
|
||||
}
|
||||
else if( strchr( expChars, *c ) != nil )
|
||||
hasDecimal = true;
|
||||
else
|
||||
hasLetters = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( type == pfConsoleCmd::kAny )
|
||||
{
|
||||
/// Want "any"
|
||||
param->SetAny( string );
|
||||
}
|
||||
else if( type == pfConsoleCmd::kString )
|
||||
{
|
||||
/// Want just a string
|
||||
param->SetString( string );
|
||||
}
|
||||
else if( type == pfConsoleCmd::kFloat )
|
||||
{
|
||||
if( hasLetters )
|
||||
return false;
|
||||
|
||||
param->SetFloat( (float)atof( string ) );
|
||||
}
|
||||
else if( type == pfConsoleCmd::kInt )
|
||||
{
|
||||
if( hasLetters || hasDecimal )
|
||||
return false;
|
||||
|
||||
param->SetInt( atoi( string ) );
|
||||
}
|
||||
else if( type == pfConsoleCmd::kBool )
|
||||
{
|
||||
if( stricmp( string, "true" ) == 0 || stricmp( string, "t" ) == 0 )
|
||||
param->SetBool( true );
|
||||
else if( stricmp( string, "false" ) == 0 || stricmp( string, "f" ) == 0 )
|
||||
param->SetBool( false );
|
||||
else if( atoi( string ) == 0 )
|
||||
param->SetBool( false );
|
||||
else
|
||||
param->SetBool( true );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//// FindPartialCmd //////////////////////////////////////////////////////////
|
||||
// Given a string which is the beginning of a console command, modifies the
|
||||
// string to represent the best match of command (or group) for that string.
|
||||
// WARNING: modifies the string passed to it.
|
||||
|
||||
hsBool pfConsoleEngine::FindPartialCmd( char *line, hsBool findAgain, hsBool preserveParams )
|
||||
{
|
||||
pfConsoleCmd *cmd = nil;
|
||||
pfConsoleCmdGroup *group, *subGrp;
|
||||
hsBool foundMore = false;
|
||||
|
||||
static char *ptr = nil, *insertLoc = nil;
|
||||
static pfConsoleCmd *lastCmd = nil;
|
||||
static pfConsoleCmdGroup *lastGroup = nil, *lastParentGroup = nil;
|
||||
static char newStr[ 256 ];
|
||||
|
||||
|
||||
/// Repeat search
|
||||
if( !findAgain )
|
||||
{
|
||||
lastCmd = nil;
|
||||
lastGroup = nil;
|
||||
}
|
||||
|
||||
/// New search
|
||||
if( strlen( line ) > sizeof( newStr ) )
|
||||
return false;
|
||||
|
||||
newStr[ 0 ] = 0;
|
||||
insertLoc = newStr;
|
||||
|
||||
/// Loop #1: Scan for subgroups. This can be an empty loop
|
||||
lastParentGroup = group = pfConsoleCmdGroup::GetBaseGroup();
|
||||
ptr = console_strtok( line, false );
|
||||
while( ptr != nil )
|
||||
{
|
||||
// Take this token and check to see if it's a group
|
||||
if( ( subGrp = group->FindSubGroupNoCase( ptr, 0/*pfConsoleCmdGroup::kFindPartial*/
|
||||
, /*lastGroup*/nil ) ) != nil )
|
||||
{
|
||||
lastParentGroup = group;
|
||||
group = subGrp;
|
||||
strcat( newStr, group->GetName() );
|
||||
insertLoc += strlen( group->GetName() );
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
ptr = console_strtok( line, false );
|
||||
strcat( newStr, "." );
|
||||
insertLoc++;
|
||||
}
|
||||
|
||||
if( ptr != nil )
|
||||
{
|
||||
// Still got at least one token left. Try to match to either
|
||||
// a partial group or a partial command
|
||||
if( ( subGrp = group->FindSubGroupNoCase( ptr, pfConsoleCmdGroup::kFindPartial, lastGroup ) ) != nil )
|
||||
{
|
||||
lastParentGroup = group;
|
||||
lastGroup = group = subGrp;
|
||||
strcat( newStr, group->GetName() );
|
||||
strcat( newStr, "." );
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = group->FindCommandNoCase( ptr, pfConsoleCmdGroup::kFindPartial, lastCmd );
|
||||
if( cmd == nil )
|
||||
return false;
|
||||
|
||||
strcat( newStr, cmd->GetName() );
|
||||
strcat( newStr, " " );
|
||||
lastCmd = cmd;
|
||||
}
|
||||
}
|
||||
|
||||
if( preserveParams )
|
||||
{
|
||||
/// Preserve the rest of the string after the matched command
|
||||
ptr = strtok( nil, "\0" );
|
||||
if( ptr != nil )
|
||||
strcat( newStr, ptr );
|
||||
}
|
||||
|
||||
// Copy back!
|
||||
strcpy( line, newStr );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//// FindNestedPartialCmd ////////////////////////////////////////////////////
|
||||
// Same as FindPartialCmd, only starts from the global group and searches
|
||||
// everything. The string passed should only be a partial command sans
|
||||
// groups. numToSkip specifies how many matches to skip before returning one
|
||||
// (so if numToSkip = 1, then this will return the second match found).
|
||||
|
||||
hsBool pfConsoleEngine::FindNestedPartialCmd( char *line, UInt32 numToSkip, hsBool preserveParams )
|
||||
{
|
||||
pfConsoleCmd *cmd;
|
||||
|
||||
|
||||
/// Somewhat easier than FindPartialCmd...
|
||||
cmd = pfConsoleCmdGroup::GetBaseGroup()->FindNestedPartialCommand( line, &numToSkip );
|
||||
if( cmd == nil )
|
||||
return false;
|
||||
|
||||
/// Recurse back up and get the group hierarchy
|
||||
line[ 0 ] = 0;
|
||||
IBuildCmdNameRecurse( cmd->GetParent(), line );
|
||||
strcat( line, cmd->GetName() );
|
||||
strcat( line, " " );
|
||||
|
||||
if( preserveParams )
|
||||
{
|
||||
/// Preserve the rest of the string after the matched command
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//// IBuildCmdNameRecurse ////////////////////////////////////////////////////
|
||||
|
||||
void pfConsoleEngine::IBuildCmdNameRecurse( pfConsoleCmdGroup *group, char *string )
|
||||
{
|
||||
if( group == nil || group == pfConsoleCmdGroup::GetBaseGroup() )
|
||||
return;
|
||||
|
||||
|
||||
IBuildCmdNameRecurse( group->GetParent(), string );
|
||||
|
||||
strcat( string, group->GetName() );
|
||||
strcat( string, "." );
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// pfConsoleEngine Header //
|
||||
// //
|
||||
//// Description /////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// The engine is where parsing and execution of console commands takes //
|
||||
// place. It takes place independently of the interface, so that the //
|
||||
// execution can happen from an INI file, from a screen-based console or //
|
||||
// even a GUI interface. //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _pfConsoleEngine_h
|
||||
#define _pfConsoleEngine_h
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsUtils.h"
|
||||
|
||||
|
||||
//// pfConsoleEngine Class Definition ////////////////////////////////////////
|
||||
|
||||
class pfConsoleCmdParam;
|
||||
class pfConsoleCmdGroup;
|
||||
class pfConsoleEngine
|
||||
{
|
||||
private:
|
||||
|
||||
static const Int32 fMaxNumParams;
|
||||
|
||||
hsBool IConvertToParam( UInt8 type, char *string, pfConsoleCmdParam *param );
|
||||
|
||||
char fErrorMsg[ 128 ];
|
||||
char fLastErrorLine[ 512 ];
|
||||
|
||||
void ISetErrorMsg( char *msg ) { hsStrncpy( fErrorMsg, msg, sizeof( fErrorMsg ) ); }
|
||||
|
||||
// Recursive function to build a string of the groups a command is in
|
||||
void IBuildCmdNameRecurse( pfConsoleCmdGroup *group, char *string );
|
||||
|
||||
public:
|
||||
|
||||
pfConsoleEngine();
|
||||
~pfConsoleEngine();
|
||||
|
||||
// Gets the signature for the command given (NO groups!)
|
||||
const char *GetCmdSignature( char *name );
|
||||
|
||||
// Prints out the help for a given command (or group)
|
||||
hsBool PrintCmdHelp( char *name, void (*PrintFn)( const char * ) );
|
||||
|
||||
// Breaks the given line into a command and parameters and runs the command
|
||||
hsBool RunCommand( char *line, void (*PrintFn)( const char * ) );
|
||||
|
||||
// Executes the given file as a sequence of console commands
|
||||
hsBool ExecuteFile( const char *fileName );
|
||||
hsBool ExecuteFile( const wchar *fileName );
|
||||
|
||||
// Get the last reported error
|
||||
const char *GetErrorMsg( void ) { return fErrorMsg; }
|
||||
|
||||
// Get the line for which the last reported error was for
|
||||
const char *GetLastErrorLine( void ) { return fLastErrorLine; }
|
||||
|
||||
// Does command completion on a partially-complete console line
|
||||
hsBool FindPartialCmd( char *line, hsBool findAgain = false, hsBool perserveParams = false );
|
||||
|
||||
// Does command completion without restrictions to any group, skipping the number of matches given
|
||||
hsBool FindNestedPartialCmd( char *line, UInt32 numToSkip, hsBool perserveParams = false );
|
||||
};
|
||||
|
||||
|
||||
#endif //_pfConsoleEngine_h
|
@ -53,7 +53,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#endif
|
||||
|
||||
|
||||
#include "pfConsoleCmd.h"
|
||||
#include "pfConsoleCore/pfConsoleCmd.h"
|
||||
#include "pfConsole.h"
|
||||
|
||||
#include "plPipeline.h"
|
||||
@ -75,12 +75,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
//// DO NOT REMOVE!!!!
|
||||
//// This is here so Microsoft VC won't decide to "optimize" this file out
|
||||
PF_CONSOLE_FILE_DUMMY(Game)
|
||||
//// DO NOT REMOVE!!!!
|
||||
void pfConsoleCmdGroup::DummyJunior( void )
|
||||
{
|
||||
}
|
||||
//// DO NOT REMOVE!!!!
|
||||
|
||||
|
||||
//// plDoesFileExist //////////////////////////////////////////////////////////
|
||||
// Utility function to determine whether the given file exists
|
||||
|
Reference in New Issue
Block a user