-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameRoom_SetPlayer.cpp
More file actions
43 lines (34 loc) · 1.23 KB
/
GameRoom_SetPlayer.cpp
File metadata and controls
43 lines (34 loc) · 1.23 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
#include "GameRoom_SetPlayer.hpp"
#include "Client.hpp"
#include "GameRoom.hpp"
#include <sstream>
std::string NodeToString13(pugi::xml_node node)
{
if (!node || !node.parent())
return "";
std::ostringstream ss;
node.print(ss, "", pugi::format_raw);
return ss.str();
}
/*
*/
namespace GameRoom_SetPlayer {
void Init(Client* client, IqClass* iq) {
if (client->Player->Room == NULL || !client->Player->Room)
return;
pugi::xml_document doc_Iq;
doc_Iq.load_string(client->Iq->data.c_str());
pugi::xml_node iqIn = doc_Iq.first_child();
WARFACE_TEAMS team_id = (WARFACE_TEAMS)iqIn.attribute("team_id").as_int();
int status = iqIn.attribute("status").as_int();
int class_id = iqIn.attribute("class_id").as_int();
client->Player->class_preserence = class_id;
client->Player->Team = team_id;
pugi::xml_node gameroom_setplayer = client->Player->SerializeRoom(client, iq->LocalName.c_str());
if (!gameroom_setplayer) return;
std::string result = client->Iq->PrepareData(client, NodeToString13(gameroom_setplayer));
printf("%s\n", result.c_str());
client->sendPacket(client->clientSocket, std::vector<char>(result.begin(), result.end()));
client->Player->SyncRoom(client, iq);
}
}