1 /*! 2 * Copyright (C) 2011-2016 OpenDungeons Team 3 * 4 * This program 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 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "ClientNotification.h" 19 #include "utils/LogManager.h" 20 #include "utils/Helper.h" 21 ClientNotification(ClientNotificationType type)22ClientNotification::ClientNotification(ClientNotificationType type): 23 mType(type) 24 { 25 mPacket << type; 26 } 27 typeString(ClientNotificationType type)28std::string ClientNotification::typeString(ClientNotificationType type) 29 { 30 switch(type) 31 { 32 case ClientNotificationType::hello: 33 return "hello"; 34 case ClientNotificationType::levelOK: 35 return "levelOK"; 36 case ClientNotificationType::setNick: 37 return "setNick"; 38 case ClientNotificationType::chat: 39 return "chat"; 40 case ClientNotificationType::readyForSeatConfiguration: 41 return "readyForSeatConfiguration"; 42 case ClientNotificationType::seatConfigurationSet: 43 return "seatConfigurationSet"; 44 case ClientNotificationType::seatConfigurationRefresh: 45 return "seatConfigurationRefresh"; 46 case ClientNotificationType::askEntityPickUp: 47 return "askEntityPickUp"; 48 case ClientNotificationType::askHandDrop: 49 return "askHandDrop"; 50 case ClientNotificationType::askMarkTiles: 51 return "askMarkTiles"; 52 case ClientNotificationType::askBuildRoom: 53 return "askBuildRoom"; 54 case ClientNotificationType::askSellRoomTiles: 55 return "askSellRoomTiles"; 56 case ClientNotificationType::editorAskDestroyRoomTiles: 57 return "editorAskDestroyRoomTiles"; 58 case ClientNotificationType::askBuildTrap: 59 return "askBuildTrap"; 60 case ClientNotificationType::askSellTrapTiles: 61 return "askSellTrapTiles"; 62 case ClientNotificationType::editorAskDestroyTrapTiles: 63 return "editorAskDestroyTrapTiles"; 64 case ClientNotificationType::ackNewTurn: 65 return "ackNewTurn"; 66 case ClientNotificationType::askCreatureInfos: 67 return "askCreatureInfos"; 68 case ClientNotificationType::askPickupWorker: 69 return "askPickupWorker"; 70 case ClientNotificationType::askPickupFighter: 71 return "askPickupFighter"; 72 case ClientNotificationType::askSlapEntity: 73 return "askSlapEntity"; 74 case ClientNotificationType::askCastSpell: 75 return "askCastSpell"; 76 case ClientNotificationType::askSetSkillTree: 77 return "askSetSkillTree"; 78 case ClientNotificationType::askSetPlayerSettings: 79 return "askSetPlayerSettings"; 80 case ClientNotificationType::askSaveMap: 81 return "askSaveMap"; 82 case ClientNotificationType::askExecuteConsoleCommand: 83 return "askExecuteConsoleCommand"; 84 case ClientNotificationType::editorAskChangeTiles: 85 return "editorAskChangeTiles"; 86 case ClientNotificationType::editorAskBuildRoom: 87 return "editorAskBuildRoom"; 88 case ClientNotificationType::editorAskBuildTrap: 89 return "editorAskBuildTrap"; 90 case ClientNotificationType::editorCreateWorker: 91 return "editorCreateWorker"; 92 case ClientNotificationType::editorCreateFighter: 93 return "editorCreateFighter"; 94 case ClientNotificationType::editorAskCreateMapLight: 95 return "editorAskCreateMapLight"; 96 default: 97 OD_LOG_ERR("Unknown enum for ClientNotificationType=" 98 + Helper::toString(static_cast<int>(type))); 99 } 100 return ""; 101 } 102 operator <<(ODPacket & os,const ClientNotificationType & nt)103ODPacket& operator<<(ODPacket& os, const ClientNotificationType& nt) 104 { 105 os << static_cast<int32_t>(nt); 106 return os; 107 } 108 operator >>(ODPacket & is,ClientNotificationType & nt)109ODPacket& operator>>(ODPacket& is, ClientNotificationType& nt) 110 { 111 int32_t tmp; 112 is >> tmp; 113 nt = static_cast<ClientNotificationType>(tmp); 114 return is; 115 } 116