-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameRoom.cpp
More file actions
73 lines (55 loc) · 1.91 KB
/
GameRoom.cpp
File metadata and controls
73 lines (55 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "GameRoom.hpp"
#include "Profile.hpp"
#include "Client.hpp"
#include <sstream>
void GameRoom::Get() {
}
void GameRoom::Leave(Client* client) {
if (client->Player->Room == NULL)
return;
auto it = std::find(m_GameRoomsPlayers.begin(), m_GameRoomsPlayers.end(), client->Player);
auto it1 = std::find(Roomed::m_GameRooms.begin(), Roomed::m_GameRooms.end(), client->Player->Room);
if (it1 != Roomed::m_GameRooms.end()) {
Roomed::m_GameRooms.erase(it1);
}
if (m_GameRoomsPlayers.size() == 1) {
m_GameRoomsPlayers.clear();
}
else {
if (it != m_GameRoomsPlayers.end()) {
m_GameRoomsPlayers.erase(it);
}
}
client->Player->Room->m_pGameRoomCore->m_pCustomParams = NULL;
client->Player->Room->m_pGameRoomCore = NULL;
client->Player->Room = NULL;
}
pugi::xml_node GameRoom::Serialize(Client* client) {
}
std::string NodeToString23(pugi::xml_node node)
{
if (!node || !node.parent())
return "";
std::ostringstream ss;
node.print(ss, "", pugi::format_raw);
return ss.str();
}
void GameRoom::Sync(Client* client, IqClass* iq) {
try {
pugi::xml_node gameroom_open = client->Player->SerializeRoom(client, "gameroom_sync");
std::string GET_RoomSync = iq->PrepareDataGet(client, NodeToString23(gameroom_open), "gameroom_sync");
printf("string get packet %s\n", GET_RoomSync.c_str());
client->sendPacket(client->clientSocket, std::vector<char>(GET_RoomSync.begin(), GET_RoomSync.end()));
}
catch (std::exception& e){
printf("[GameRoom] not critical error, but it warning-error: < %s >\n", e.what());
}
}
void GameRoom::Create(Player* player, std::string room_name) {
//Player obj = *player;
player->Room->m_GameRoomsPlayers.push_back(player);
Roomed::m_GameRooms.push_back(player->Room);
this->RoomID = static_cast<int>(Roomed::m_GameRooms.size()) + 1;
this->m_pGameRoomCore->room_name = room_name;
RoomMaster = player;
}