Line data Source code
1 : /* Copyright (C) 2025 Wildfire Games. 2 : * This file is part of 0 A.D. 3 : * 4 : * 0 A.D. is free software: you can redistribute it and/or modify 5 : * it under the terms of the GNU General Public License as published by 6 : * the Free Software Foundation, either version 2 of the License, or 7 : * (at your option) any later version. 8 : * 9 : * 0 A.D. is distributed in the hope that it will be useful, 10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 : * GNU General Public License for more details. 13 : * 14 : * You should have received a copy of the GNU General Public License 15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 : */ 17 : 18 : #include "precompiled.h" 19 : 20 : #include "tools/atlas/GameInterface/CommandProc.h" 21 : #include "tools/atlas/GameInterface/Handlers/MessageHandler.h" 22 : #include "tools/atlas/GameInterface/Messages.h" 23 : 24 : #include <string> 25 : #include <utility> 26 : 27 : namespace AtlasMessage { struct IMessage; } 28 : 29 : // We want to include Messages.h again below, with some different definitions, 30 : // so cheat and undefine its include-guard 31 : #undef INCLUDED_MESSAGES 32 : 33 : namespace AtlasMessage 34 : { 35 : 36 : #define MESSAGE(name, vals) \ 37 : extern void f##name##_wrapper(AtlasMessage::IMessage*); \ 38 : AtlasMessage::GetMsgHandlers().insert(std::pair<std::string, AtlasMessage::msgHandler>(#name, &f##name##_wrapper)); 39 : 40 : #define QUERY(name, in_vals, out_vals) \ 41 : extern void f##name##_wrapper(AtlasMessage::IMessage*); \ 42 : AtlasMessage::GetMsgHandlers().insert(std::pair<std::string, AtlasMessage::msgHandler>(#name, &f##name##_wrapper)); 43 : 44 : #define COMMAND(name, merge, vals) \ 45 : extern cmdHandler c##name##_create(); \ 46 : GetCmdHandlers().insert(std::pair<std::string, cmdHandler>("c"#name, c##name##_create())); 47 : 48 : #undef SHAREABLE_STRUCT 49 : #define SHAREABLE_STRUCT(name) 50 : 51 0 : void RegisterHandlers() 52 : { 53 0 : MESSAGE(DoCommand, ); 54 0 : MESSAGE(UndoCommand, ); 55 0 : MESSAGE(RedoCommand, ); 56 0 : MESSAGE(MergeCommand, ); 57 : 58 : #define MESSAGES_SKIP_SETUP 59 : #include "Messages.h" 60 0 : } 61 : 62 : }