don't keep "Message" in command name

fixes ScoreDisplayCalories
This commit is contained in:
Chris Danford
2005-03-08 16:54:48 +00:00
parent 0be0cb5ab5
commit 7ab74cdd24
2 changed files with 13 additions and 9 deletions
+12 -9
View File
@@ -90,13 +90,9 @@ static bool GetMessageNameFromCommandName( const CString &sCommandName, CString
void Actor::UnsubcribeAndClearCommands()
{
FOREACHM_CONST( CString, apActorCommands, m_mapNameToCommands, e )
{
CString sMessage;
if( GetMessageNameFromCommandName(e->first, sMessage) )
MESSAGEMAN->Unsubscribe( this, sMessage );
}
m_mapNameToCommands.clear();
FOREACH_CONST( CString, m_vsSubscribedTo, s )
MESSAGEMAN->Unsubscribe( this, *s );
m_vsSubscribedTo.clear();
}
Actor::~Actor()
@@ -1049,10 +1045,17 @@ void Actor::QueueMessage( const CString& sMessageName )
void Actor::AddCommand( const CString &sCmdName, apActorCommands apac )
{
m_mapNameToCommands[sCmdName] = apac;
CString sMessage;
if( GetMessageNameFromCommandName(sCmdName, sMessage) )
{
MESSAGEMAN->Subscribe( this, sMessage );
m_vsSubscribedTo.push_back( sMessage );
m_mapNameToCommands[sMessage] = apac; // sCmdName w/o "Message" at the end
}
else
{
m_mapNameToCommands[sCmdName] = apac;
}
}
void Actor::PlayCommand( const CString &sCommandName )
@@ -1073,7 +1076,7 @@ void Actor::PlayCommand2( const CString &sCommandName, Actor *pParent )
void Actor::HandleMessage( const CString& sMessage )
{
PlayCommand( sMessage + "Message" );
PlayCommand( sMessage );
}
+1
View File
@@ -437,6 +437,7 @@ protected:
// commands
//
map<CString, apActorCommands> m_mapNameToCommands;
vector<CString> m_vsSubscribedTo;
};
template<class T>