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 #ifndef SERVERNOTIFICATION_H
19 #define SERVERNOTIFICATION_H
20 
21 #include "network/ODPacket.h"
22 
23 #include <deque>
24 #include <string>
25 #include <OgreVector3.h>
26 
27 class Tile;
28 class Creature;
29 class MovableGameEntity;
30 class Player;
31 
32 enum class ServerNotificationType
33 {
34     // Negotiation for multiplayer
35     loadLevel, // Tells the client to load the level: + string LevelFilename
36     pickNick,
37     addPlayers,
38     removePlayers,
39     startGameMode,
40     newMap,
41     addClass,
42     clientAccepted,
43     clientRejected,
44     seatConfigurationRefresh,
45 
46     playerConfigChange,
47 
48     chat,
49     chatServer,
50 
51     turnStarted,
52 
53     animatedObjectSetWalkPath,
54     setObjectAnimationState,
55     entityPickedUp,
56     entityDropped,
57     entitySlapped,
58 
59     playerFighting, // Tells the player he is under attack or attacking
60     playerNoMoreFighting, // Tells the player he is no longer under attack or attacking
61 
62     addEntity,
63     removeEntity,
64     entitiesRefresh,
65     refreshPlayerSeat,
66     setEntityOpacity,
67     notifyCreatureInfo,
68     refreshCreatureVisDebug,
69 
70     refreshSeatVisDebug,
71 
72     playSpatialSound, // Makes the client play a sound at tile coordinates.
73     playRelativeSound, // Makes the client play a sound.
74 
75     markTiles,
76     refreshTiles,
77     refreshVisibleTiles,
78     carryEntity,
79     releaseCarriedEntity,
80 
81     skillTree,
82     skillsDone,
83 
84     setPlayerSettings,
85 
86     setSpellCooldown,
87 
88     playerEvents,
89 
90     exit
91 };
92 
93 ODPacket& operator<<(ODPacket& os, const ServerNotificationType& nt);
94 ODPacket& operator>>(ODPacket& is, ServerNotificationType& nt);
95 
96 //! \brief A data structure used to send messages to the clients
97 class ServerNotification
98 {
99     friend class ODServer;
100 
101     public:
102         /*! \brief Creates a message to be sent to concernedPlayer. If concernedPlayer is null, the message will be sent to
103          *         every connected player.
104          */
105         ServerNotification(ServerNotificationType type, Player* concernedPlayer);
~ServerNotification()106         virtual ~ServerNotification()
107         {}
108 
109         ODPacket mPacket;
110 
111         static std::string typeString(ServerNotificationType type);
112 
113     private:
114         ServerNotificationType mType;
115         Player *mConcernedPlayer;
116 };
117 
118 #endif // SERVERNOTIFICATION_H
119