From 7c19bf4b6bd544b0ed3619fa8a8d1aaa2859fe9f Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 10 Jan 2004 20:43:56 +0000 Subject: [PATCH] add missing files --- stepmania/src/ActorCommands.cpp | 72 +++++++++++++++++++++++++++ stepmania/src/ActorCommands.h | 86 +++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 stepmania/src/ActorCommands.cpp create mode 100644 stepmania/src/ActorCommands.h diff --git a/stepmania/src/ActorCommands.cpp b/stepmania/src/ActorCommands.cpp new file mode 100644 index 0000000000..16b5bb9d2f --- /dev/null +++ b/stepmania/src/ActorCommands.cpp @@ -0,0 +1,72 @@ +#include "global.h" // testing updates + +/* +----------------------------------------------------------------------------- + Class: ActorCommands + + Desc: See header. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "ActorCommands.h" +#include "RageUtil.h" +#include "RageLog.h" +#include "arch/ArchHooks/ArchHooks.h" + +void IncorrectActorParametersWarning( const ParsedCommand &command, int iMaxIndexAccessed ) +{ + const CString sError = ssprintf( "Actor::HandleCommand: Wrong number of parameters in command '%s'. Expected %d but there are %u.", + command.GetOriginalCommandString().c_str(), iMaxIndexAccessed+1, command.vTokens.size() ); + LOG->Warn( sError ); + HOOKS->MessageBoxOK( sError ); +} + +void ParsedCommandToken::Set( const CString &sToken ) +{ + s = sToken; + f = atof( sToken ); + i = atoi( sToken ); + b = i != 0; + bColorIsValid = c.FromString( sToken ); +} + +void ParsedCommand::Set( const CString &sCommand ) +{ + CStringArray vsTokens; + split( sCommand, ",", vsTokens, false ); // don't ignore empty + + vTokens.resize( vsTokens.size() ); + + for( int j=0; j &vCommandsOut ) +{ + vCommandsOut.clear(); + CStringArray vsCommands; + split( sCommands, ";", vsCommands, true ); // do ignore empty + + vCommandsOut.resize( vsCommands.size() ); + + for( int i=0; i vTokens; + + CString GetOriginalCommandString() const; // for when reporting an error in number of params +}; + +// Take a command list string and return pointers to each of the tokens in the +// string. sCommand list is a list of commands separated by ';'. +void ParseCommands( const CString &sCommands, vector &vCommandsOut ); + + +#define HandleParams int iMaxIndexAccessed = 0; +#define sParam(i) (GetParam(command,i,iMaxIndexAccessed)) +#define fParam(i) (GetParam(command,i,iMaxIndexAccessed)) +#define iParam(i) (GetParam(command,i,iMaxIndexAccessed)) +#define bParam(i) (GetParam(command,i,iMaxIndexAccessed)) +#define cParam(i) (ColorParam(command,i,iMaxIndexAccessed)) +#define CheckHandledParams if( iMaxIndexAccessed != (int)command.vTokens.size()-1 ) { IncorrectActorParametersWarning( command, iMaxIndexAccessed ); } +void IncorrectActorParametersWarning( const ParsedCommand& command, int iMaxIndexAccessed ); + +template +inline T GetParam( const ParsedCommand& command, int iIndex, int& iMaxIndexAccessedOut ) +{ + iMaxIndexAccessedOut = max( iIndex, iMaxIndexAccessedOut ); + if( iIndex < int(command.vTokens.size()) ) + { + return (T)command.vTokens[iIndex]; + } + else + { + ParsedCommandToken pct; + pct.Set( "" ); + return (T)pct; + } +} + +inline RageColor ColorParam( const ParsedCommand& command, int iIndex, int& iMaxIndexAccessed ) +{ + if( command.vTokens[iIndex].bColorIsValid ) + return GetParam(command,iIndex,iMaxIndexAccessed); + else + return RageColor( fParam(iIndex+0),fParam(iIndex+1),fParam(iIndex+2),fParam(iIndex+3) ); +} + + + + + + +#endif