return a pointer from Actor::GetCommand, so the command not existing

isn't fatal
This commit is contained in:
Glenn Maynard
2006-03-26 05:53:20 +00:00
parent 458b31b7db
commit ab08e39204
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -1240,11 +1240,12 @@ bool Actor::HasCommand( const RString &sCmdName )
return it != m_mapNameToCommands.end();
}
const apActorCommands& Actor::GetCommand( const RString &sCommandName ) const
const apActorCommands *Actor::GetCommand( const RString &sCommandName ) const
{
map<RString, apActorCommands>::const_iterator it = m_mapNameToCommands.find( sCommandName );
ASSERT( it != m_mapNameToCommands.end() );
return it->second;
if( it == m_mapNameToCommands.end() )
return NULL;
return &it->second;
}
void Actor::PlayCommand( const RString &sCommandName, Actor *pParent )
+1 -1
View File
@@ -332,7 +332,7 @@ public:
//
void AddCommand( const RString &sCmdName, apActorCommands apac );
bool HasCommand( const RString &sCmdName );
const apActorCommands& GetCommand( const RString &sCommandName ) const;
const apActorCommands *GetCommand( const RString &sCommandName ) const;
virtual void PlayCommand( const RString &sCommandName, Actor *pParent = NULL );
virtual void RunCommands( const LuaReference& cmds, Actor *pParent = NULL );
void RunCommands( const apActorCommands& cmds, Actor *pParent = NULL ) { this->RunCommands( *cmds, pParent ); } // convenience