1 #ifndef __LOBBY_2_MESSAGE_STEAM_H
2 #define __LOBBY_2_MESSAGE_STEAM_H
3 
4 #include "Lobby2Message.h"
5 #include "DS_Multilist.h"
6 #include "Lobby2Client_Steam.h"
7 #include "steam_api.h"
8 
9 namespace RakNet
10 {
11 
12 #define __L2_MSG_DB_HEADER(__NAME__,__DB__) \
13 	struct __NAME__##_##__DB__ : public __NAME__
14 
__L2_MSG_DB_HEADER(Client_Login,Steam)15 	__L2_MSG_DB_HEADER(Client_Login, Steam)
16 	{
17 		virtual bool ClientImpl( Lobby2Client *client);
18 
19 		virtual void DebugMsg(RakNet::RakString &out) const
20 		{
21 			if (resultCode!=L2RC_SUCCESS)
22 			{
23 				Client_Login::DebugMsg(out);
24 				return;
25 			}
26 			out.Set("Login success");
27 		}
28 	};
29 
__L2_MSG_DB_HEADER(Client_Logoff,Steam)30 	__L2_MSG_DB_HEADER(Client_Logoff, Steam)
31 	{
32 		virtual bool ClientImpl( Lobby2Client *client);
33 
34 		virtual void DebugMsg(RakNet::RakString &out) const
35 		{
36 			if (resultCode!=L2RC_SUCCESS)
37 			{
38 				Client_Logoff::DebugMsg(out);
39 				return;
40 			}
41 			out.Set("Logoff success");
42 		}
43 	};
44 
__L2_MSG_DB_HEADER(Console_SearchRooms,Steam)45 	__L2_MSG_DB_HEADER(Console_SearchRooms, Steam)
46 	{
47 		virtual bool ClientImpl( Lobby2Client *client);
48 
49 		virtual void DebugMsg(RakNet::RakString &out) const
50 		{
51 			if (resultCode!=L2RC_SUCCESS)
52 			{
53 				Console_SearchRooms::DebugMsg(out);
54 				return;
55 			}
56 			out.Set("%i rooms found", roomNames.GetSize());
57 			for (DataStructures::DefaultIndexType i=0; i < roomNames.GetSize(); i++)
58 			{
59 				out += RakNet::RakString("\n%i. %s. ID=%"PRINTF_64_BIT_MODIFIER"u", i+1, roomNames[i].C_String(), roomIds[i].ConvertToUint64());
60 			}
61 		}
62 
63 		// Output
64 		// Use CConsoleCommand_GetRoomDetails to get room names for unknown rooms, which will have blank names
65 		DataStructures::Multilist<ML_UNORDERED_LIST, RakNet::RakString> roomNames;
66 		DataStructures::Multilist<ML_UNORDERED_LIST, CSteamID> roomIds;
67 
68 		/// \internal
69 		CCallResult<Lobby2Client_Steam, LobbyMatchList_t> m_SteamCallResultLobbyMatchList;
70 	};
71 
__L2_MSG_DB_HEADER(Console_GetRoomDetails,Steam)72 	__L2_MSG_DB_HEADER(Console_GetRoomDetails, Steam)
73 	{
74 		virtual bool ClientImpl( Lobby2Client *client);
75 
76 		virtual void DebugMsg(RakNet::RakString &out) const
77 		{
78 			if (resultCode!=L2RC_SUCCESS)
79 			{
80 				Console_GetRoomDetails::DebugMsg(out);
81 				return;
82 			}
83 			out.Set("GetRoomDetails: roomName=%s for id %"PRINTF_64_BIT_MODIFIER"u", roomName.C_String(), roomId.ConvertToUint64());
84 		}
85 
86 		/// Input
87 		CSteamID roomId;
88 
89 		/// Output
90 		RakNet::RakString roomName;
91 	};
92 
__L2_MSG_DB_HEADER(Console_CreateRoom,Steam)93 	__L2_MSG_DB_HEADER(Console_CreateRoom, Steam)
94 	{
95 		virtual bool ClientImpl( Lobby2Client *client);
96 
97 		virtual void DebugMsg(RakNet::RakString &out) const
98 		{
99 			if (resultCode!=L2RC_SUCCESS)
100 			{
101 				Console_CreateRoom::DebugMsg(out);
102 				return;
103 			}
104 			out.Set("Console_CreateRoom: roomName %s created for id %"PRINTF_64_BIT_MODIFIER"u", roomName.C_String(), roomId);
105 		}
106 
107 		/// Input
108 		/// If public, anyone can join. Else friends only
109 		bool roomIsPublic;
110 		RakNet::RakString roomName;
111 
112 		/// Output
113 		uint64 roomId;
114 
115 		/// \internal
116 		CCallResult<Lobby2Client_Steam, LobbyCreated_t> m_SteamCallResultLobbyCreated;
117 	};
118 
__L2_MSG_DB_HEADER(Console_JoinRoom,Steam)119 	__L2_MSG_DB_HEADER(Console_JoinRoom, Steam)
120 	{
121 		virtual bool ClientImpl( Lobby2Client *client);
122 
123 		virtual void DebugMsg(RakNet::RakString &out) const
124 		{
125 			if (resultCode!=L2RC_SUCCESS)
126 			{
127 				Console_JoinRoom::DebugMsg(out);
128 				return;
129 			}
130 			out.Set("Console_JoinRoom: Joined id %"PRINTF_64_BIT_MODIFIER"u", roomId);
131 		}
132 
133 		/// Input
134 		uint64 roomId;
135 
136 		/// \internal
137 		CCallResult<Lobby2Client_Steam, LobbyEnter_t> m_SteamCallResultLobbyEntered;
138 	};
139 
__L2_MSG_DB_HEADER(Console_LeaveRoom,Steam)140 	__L2_MSG_DB_HEADER(Console_LeaveRoom, Steam)
141 	{
142 		virtual bool ClientImpl( Lobby2Client *client);
143 
144 		virtual void DebugMsg(RakNet::RakString &out) const
145 		{
146 			if (resultCode!=L2RC_SUCCESS)
147 			{
148 				Console_LeaveRoom::DebugMsg(out);
149 				return;
150 			}
151 			out.Set("Left room %"PRINTF_64_BIT_MODIFIER"u", roomId);
152 		}
153 
154 		/// Input
155 		uint64 roomId;
156 	};
157 
__L2_MSG_DB_HEADER(Console_SendRoomChatMessage,Steam)158 	__L2_MSG_DB_HEADER(Console_SendRoomChatMessage, Steam)
159 	{
160 		virtual bool ClientImpl( Lobby2Client *client);
161 
162 		virtual void DebugMsg(RakNet::RakString &out) const
163 		{
164 			if (resultCode!=L2RC_SUCCESS)
165 			{
166 				Console_SendRoomChatMessage::DebugMsg(out);
167 				return;
168 			}
169 			out.Set("Sent %s to room %"PRINTF_64_BIT_MODIFIER"u", message.C_String(), roomId);
170 		}
171 
172 		/// Input
173 		uint64 roomId;
174 		RakNet::RakString message;
175 	};
176 
177 
__L2_MSG_DB_HEADER(Notification_Friends_StatusChange,Steam)178 	__L2_MSG_DB_HEADER(Notification_Friends_StatusChange, Steam)
179 	{
180 		uint64_t friendId;
181 		RakNet::RakString friendNewName;
182 
183 		virtual void DebugMsg(RakNet::RakString &out) const
184 		{
185 			if (resultCode!=L2RC_SUCCESS)
186 			{
187 				Notification_Friends_StatusChange::DebugMsg(out);
188 				return;
189 			}
190 			out.Set("Friend renamed to %s with ID %"PRINTF_64_BIT_MODIFIER"u", friendNewName.C_String(), friendId);
191 		}
192 	};
193 
__L2_MSG_DB_HEADER(Notification_Console_UpdateRoomParameters,Steam)194 	__L2_MSG_DB_HEADER(Notification_Console_UpdateRoomParameters, Steam)
195 	{
196 		uint64_t roomId;
197 		RakNet::RakString roomNewName;
198 
199 		virtual void DebugMsg(RakNet::RakString &out) const
200 		{
201 			if (resultCode!=L2RC_SUCCESS)
202 			{
203 				Notification_Console_UpdateRoomParameters::DebugMsg(out);
204 				return;
205 			}
206 			out.Set("RoomStateChanged: Room named %s with ID %"PRINTF_64_BIT_MODIFIER"u", roomNewName.C_String(), roomId);
207 		}
208 	};
209 
__L2_MSG_DB_HEADER(Notification_Console_MemberJoinedRoom,Steam)210 	__L2_MSG_DB_HEADER(Notification_Console_MemberJoinedRoom, Steam)
211 	{
212 		uint64_t roomId;
213 		uint64_t srcMemberId;
214 		RakNet::RakString memberName;
215 
216 		virtual void DebugMsg(RakNet::RakString &out) const
217 		{
218 			if (resultCode!=L2RC_SUCCESS)
219 			{
220 				Notification_Console_MemberJoinedRoom::DebugMsg(out);
221 				return;
222 			}
223 			out.Set("MemberJoinedRoom: Member named %s and ID %"PRINTF_64_BIT_MODIFIER"u joined room with ID %"PRINTF_64_BIT_MODIFIER"u", memberName.C_String(), srcMemberId, roomId);
224 		}
225 	};
226 
__L2_MSG_DB_HEADER(Notification_Console_MemberLeftRoom,Steam)227 	__L2_MSG_DB_HEADER(Notification_Console_MemberLeftRoom, Steam)
228 	{
229 		uint64_t roomId;
230 		uint64_t srcMemberId;
231 		RakNet::RakString memberName;
232 
233 		virtual void DebugMsg(RakNet::RakString &out) const
234 		{
235 			if (resultCode!=L2RC_SUCCESS)
236 			{
237 				Notification_Console_MemberLeftRoom::DebugMsg(out);
238 				return;
239 			}
240 			out.Set("MemberLeftRoom: Member named %s and ID %"PRINTF_64_BIT_MODIFIER"u left room with ID %"PRINTF_64_BIT_MODIFIER"u", memberName.C_String(), srcMemberId, roomId);
241 		}
242 	};
243 
__L2_MSG_DB_HEADER(Notification_Console_RoomChatMessage,Steam)244 	__L2_MSG_DB_HEADER(Notification_Console_RoomChatMessage, Steam)
245 	{
246 		RakNet::RakString message;
247 
248 		virtual void DebugMsg(RakNet::RakString &out) const
249 		{
250 			if (resultCode!=L2RC_SUCCESS)
251 			{
252 				Notification_Console_RoomChatMessage::DebugMsg(out);
253 				return;
254 			}
255 			out=message;
256 		}
257 	};
258 
__L2_MSG_DB_HEADER(Notification_Console_RoomMemberConnectivityUpdate,Steam)259 	__L2_MSG_DB_HEADER(Notification_Console_RoomMemberConnectivityUpdate, Steam)
260 	{
261 		bool succeeded;
262 		SystemAddress remoteSystem;
263 
264 		virtual void DebugMsg(RakNet::RakString &out) const
265 		{
266 			if (resultCode!=L2RC_SUCCESS)
267 			{
268 				Notification_Console_RoomMemberConnectivityUpdate::DebugMsg(out);
269 				return;
270 			}
271 			if (succeeded)
272 			{
273 				out.Set("Signaling to %s succeeded.", remoteSystem.ToString(true));
274 			}
275 			else
276 			{
277 				out.Set("Signaling to %s failed.", remoteSystem.ToString(true));
278 			}
279 		}
280 	};
281 
282 // --------------------------------------------- Database specific factory class for all messages --------------------------------------------
283 
284 #define __L2_MSG_FACTORY_IMPL(__NAME__,__DB__) {case L2MID_##__NAME__ : Lobby2Message *m = RakNet::OP_NEW< __NAME__##_##__DB__ >(__FILE__, __LINE__) ; return m;}
285 
286 	struct Lobby2MessageFactory_Steam : public Lobby2MessageFactory
287 	{
Lobby2MessageFactory_SteamLobby2MessageFactory_Steam288 		Lobby2MessageFactory_Steam() {}
~Lobby2MessageFactory_SteamLobby2MessageFactory_Steam289 		virtual ~Lobby2MessageFactory_Steam() {}
AllocLobby2MessageFactory_Steam290 		virtual Lobby2Message *Alloc(Lobby2MessageID id)
291 		{
292 			switch (id)
293 			{
294 				__L2_MSG_FACTORY_IMPL(Client_Login, Steam);
295 				__L2_MSG_FACTORY_IMPL(Client_Logoff, Steam);
296 				__L2_MSG_FACTORY_IMPL(Console_SearchRooms, Steam);
297 				__L2_MSG_FACTORY_IMPL(Console_GetRoomDetails, Steam);
298 				__L2_MSG_FACTORY_IMPL(Console_CreateRoom, Steam);
299 				__L2_MSG_FACTORY_IMPL(Console_JoinRoom, Steam);
300 				__L2_MSG_FACTORY_IMPL(Console_LeaveRoom, Steam);
301 				__L2_MSG_FACTORY_IMPL(Console_SendRoomChatMessage, Steam);
302 				__L2_MSG_FACTORY_IMPL(Notification_Friends_StatusChange, Steam);
303 				__L2_MSG_FACTORY_IMPL(Notification_Console_UpdateRoomParameters, Steam);
304 				__L2_MSG_FACTORY_IMPL(Notification_Console_MemberJoinedRoom, Steam);
305 				__L2_MSG_FACTORY_IMPL(Notification_Console_MemberLeftRoom, Steam);
306 				__L2_MSG_FACTORY_IMPL(Notification_Console_RoomChatMessage, Steam);
307 				__L2_MSG_FACTORY_IMPL(Notification_Console_RoomMemberConnectivityUpdate, Steam);
308 
309 				default:
310 
311 				return Lobby2MessageFactory::Alloc(id);
312 			};
313 		};
314 	};
315 }; // namespace RakNet
316 
317 #endif
318