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 "lib/debug.h" 21 : #include "tools/atlas/GameInterface/CommandProc.h" 22 : #include "tools/atlas/GameInterface/Handlers/MessageHandler.h" 23 : #include "tools/atlas/GameInterface/Messages.h" 24 : #include "tools/atlas/GameInterface/Shareable.h" 25 : 26 : #include <cstddef> 27 : #include <map> 28 : #include <string> 29 : #include <utility> 30 : 31 : namespace AtlasMessage { 32 : 33 : 34 0 : MESSAGEHANDLER(DoCommand) 35 : { 36 0 : Command* c = NULL; 37 0 : cmdHandlers::const_iterator it = GetCmdHandlers().find("c" + *msg->name); 38 0 : if (it != GetCmdHandlers().end()) 39 : { 40 0 : c = (it->second)(msg->data); 41 : } 42 : else 43 : { 44 0 : debug_warn(L"Unrecognized command"); 45 0 : return; 46 : } 47 : 48 0 : GetCommandProc().Submit(c); 49 : } 50 : 51 0 : MESSAGEHANDLER(UndoCommand) 52 : { 53 0 : GetCommandProc().Undo(); 54 0 : } 55 : 56 0 : MESSAGEHANDLER(RedoCommand) 57 : { 58 0 : GetCommandProc().Redo(); 59 0 : } 60 : 61 0 : MESSAGEHANDLER(MergeCommand) 62 : { 63 0 : GetCommandProc().Merge(); 64 0 : } 65 : 66 : 67 : }