diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h b/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h index fed637c54ca..1bfc1a9ea2b 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h @@ -391,9 +391,11 @@ class MetaMap : public SubsystemInterface static void parseMetaMap(INI* ini); - // TheSuperHackers @info Function to generate default key mappings + // TheSuperHackers @feature Function to generate default key mappings // for actions that were not found in a CommandMap.ini - static void generateMetaMap(); + void generateMetaMap(); + + void verifyMetaMap(); const MetaMapRec *getFirstMetaMapRec() const { return m_metaMaps; } }; diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp index 60a2beccb4b..62270b81ae1 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp @@ -627,8 +627,6 @@ void GameEngine::init() fname.format("Data\\%s\\CommandMap", GetRegistryLanguage().str()); initSubsystem(TheMetaMap,"TheMetaMap", MSGNEW("GameEngineSubsystem") MetaMap(), nullptr, fname.str(), "Data\\INI\\CommandMap"); - TheMetaMap->generateMetaMap(); - #if defined(RTS_DEBUG) ini.loadFileDirectory("Data\\INI\\CommandMapDebug", INI_LOAD_MULTIFILE, nullptr); #endif @@ -637,6 +635,9 @@ void GameEngine::init() ini.loadFileDirectory("Data\\INI\\CommandMapDemo", INI_LOAD_MULTIFILE, nullptr); #endif + TheMetaMap->generateMetaMap(); + TheMetaMap->verifyMetaMap(); + initSubsystem(TheActionManager,"TheActionManager", MSGNEW("GameEngineSubsystem") ActionManager(), nullptr); //initSubsystem((CComObject *)TheWebBrowser,"(CComObject *)TheWebBrowser", (CComObject *)createWebBrowser(), nullptr); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp index 9d9df747c00..9d5f504dfd9 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp @@ -466,9 +466,6 @@ GameMessageDisposition MetaEventTranslator::translateGameMessage(const GameMessa for (const MetaMapRec *map = TheMetaMap->getFirstMetaMapRec(); map; map = map->m_next) { - DEBUG_ASSERTCRASH(map->m_meta > GameMessage::MSG_BEGIN_META_MESSAGES && - map->m_meta < GameMessage::MSG_END_META_MESSAGES, ("hmm, expected only meta-msgs here")); - if (!isMessageUsable(map->m_usableIn)) continue; @@ -725,14 +722,14 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } //------------------------------------------------------------------------------------------------- -/*static */ void MetaMap::generateMetaMap() +void MetaMap::generateMetaMap() { // TheSuperHackers @info A default mapping for MSG_META_SELECT_ALL_AIRCRAFT would be useful for Generals // but is not recommended, because it will cause key mapping conflicts with original game languages. { // Is useful for Generals and Zero Hour. - MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_INCREASE_MAX_RENDER_FPS); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_INCREASE_MAX_RENDER_FPS); if (map->m_key == MK_NONE) { map->m_key = MK_KPPLUS; @@ -743,7 +740,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } { // Is useful for Generals and Zero Hour. - MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_DECREASE_MAX_RENDER_FPS); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_DECREASE_MAX_RENDER_FPS); if (map->m_key == MK_NONE) { map->m_key = MK_KPMINUS; @@ -754,7 +751,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } { // Is useful for Generals and Zero Hour. - MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_INCREASE_LOGIC_TIME_SCALE); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_INCREASE_LOGIC_TIME_SCALE); if (map->m_key == MK_NONE) { map->m_key = MK_KPPLUS; @@ -765,7 +762,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } { // Is useful for Generals and Zero Hour. - MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_DECREASE_LOGIC_TIME_SCALE); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_DECREASE_LOGIC_TIME_SCALE); if (map->m_key == MK_NONE) { map->m_key = MK_KPMINUS; @@ -776,7 +773,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } { // Is useful for Generals and Zero Hour. - MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_TOGGLE_PLAYER_OBSERVER); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_TOGGLE_PLAYER_OBSERVER); if (map->m_key == MK_NONE) { map->m_key = MK_M; @@ -787,7 +784,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } { // Is mostly useful for Generals. - MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_TOGGLE_FAST_FORWARD_REPLAY); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_TOGGLE_FAST_FORWARD_REPLAY); if (map->m_key == MK_NONE) { map->m_key = MK_F; @@ -798,7 +795,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } { // Is useful for Generals and Zero Hour. - MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_TOGGLE_PAUSE); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_TOGGLE_PAUSE); if (map->m_key == MK_NONE) { map->m_key = MK_P; @@ -809,7 +806,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } { // Is useful for Generals and Zero Hour. - MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_TOGGLE_PAUSE_ALT); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_TOGGLE_PAUSE_ALT); if (map->m_key == MK_NONE) { map->m_key = MK_P; @@ -820,7 +817,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } { // Is useful for Generals and Zero Hour. - MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_STEP_FRAME); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_STEP_FRAME); if (map->m_key == MK_NONE) { map->m_key = MK_O; @@ -831,7 +828,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } { // Is useful for Generals and Zero Hour. - MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_STEP_FRAME_ALT); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_STEP_FRAME_ALT); if (map->m_key == MK_NONE) { map->m_key = MK_O; @@ -842,7 +839,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } { // Is useful for Generals and Zero Hour. - MetaMapRec* map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_SELECT_NEXT_IDLE_WORKER); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_SELECT_NEXT_IDLE_WORKER); if (map->m_key == MK_NONE) { map->m_key = MK_I; map->m_transition = DOWN; @@ -854,7 +851,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } } { - MetaMapRec* map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_ALT_CAMERA_ROTATE_LEFT); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_ALT_CAMERA_ROTATE_LEFT); if (map->m_key == MK_NONE) { map->m_key = MK_KP4; map->m_transition = DOWN; @@ -863,7 +860,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } } { - MetaMapRec* map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_ALT_CAMERA_ROTATE_RIGHT); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_ALT_CAMERA_ROTATE_RIGHT); if (map->m_key == MK_NONE) { map->m_key = MK_KP6; map->m_transition = DOWN; @@ -875,7 +872,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) #if defined(RTS_DEBUG) { // Is useful for Generals and Zero Hour. - MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_DEMO_REMOVE_PREREQ); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_DEMO_REMOVE_PREREQ); if (map->m_key == MK_NONE) { map->m_key = MK_P; @@ -886,7 +883,7 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) } { // Is useful for Generals and Zero Hour. - MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_DEMO_FREE_BUILD); + MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_DEMO_FREE_BUILD); if (map->m_key == MK_NONE) { map->m_key = MK_B; @@ -898,6 +895,20 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t) #endif // defined(RTS_DEBUG) } +//------------------------------------------------------------------------------------------------- +void MetaMap::verifyMetaMap() +{ +#ifdef DEBUG_CRASHING + for (const MetaMapRec *map = getFirstMetaMapRec(); map; map = map->m_next) + { + DEBUG_ASSERTCRASH( + map->m_meta > GameMessage::MSG_BEGIN_META_MESSAGES && + map->m_meta < GameMessage::MSG_END_META_MESSAGES, + ("hmm, expected only meta-msgs here")); + } +#endif +} + //------------------------------------------------------------------------------------------------- /*static*/ void INI::parseMetaMapDefinition( INI* ini ) {