-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameRoom_UpdatePVP.cpp
More file actions
106 lines (83 loc) · 4.19 KB
/
GameRoom_UpdatePVP.cpp
File metadata and controls
106 lines (83 loc) · 4.19 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "GameRoom_UpdatePVP.hpp"
#include "Client.hpp"
#include "GameRoom.hpp"
#include "Profile.hpp"
#include <sstream>
#include <iostream>
void AppendXmlFragmentv12(pugi::xml_node parent, const std::string& xml)
{
if (xml.empty())
return;
pugi::xml_document tmp;
pugi::xml_parse_result r = tmp.load_string(xml.c_str());
if (!r)
{
printf("XML parse error: %s\n", r.description());
return;
}
for (pugi::xml_node n : tmp.children())
{
parent.append_copy(n);
}
}
std::string NodeToString22(pugi::xml_node node)
{
if (!node || !node.parent())
return "";
std::ostringstream ss;
node.print(ss, "", pugi::format_raw);
return ss.str();
}
namespace GameRoomUpdatePVP {
void Init(Client* client, IqClass* iq) {
pugi::xml_document doc_Iq;
doc_Iq.load_string(client->Iq->data.c_str());
pugi::xml_node iqIn = doc_Iq.first_child();
//bool private_room = iqIn.attribute("private").as_bool();
//std::string mission_key = iqIn.attribute("mission_key").value();
//bool auto_team_balance = iqIn.attribute("auto_team_balance").as_bool();
//bool friendly_fire = iqIn.attribute("friendly_fire").as_bool();
//bool enemy_outlines = iqIn.attribute("enemy_outlines").as_bool();
//bool join_in_the_process = iqIn.attribute("join_in_the_process").as_bool();
//int max_players = iqIn.attribute("max_players").as_int();
//int inventory_slot = iqIn.attribute("inventory_slot").as_int();
//bool locked_spectator_camera = iqIn.attribute("locked_spectator_camera").as_bool();
//bool high_latency_autokick = iqIn.attribute("high_latency_autokick").as_bool();
/*
<iq to='masterserver@warface/pvp_pro_007_r1' id='uid00000047' type='get' from='1@warface/GameClient'
xmlns='jabber:client'>
<query
xmlns='urn:cryonline:k01' part_number='0' part_count='1' response_type='0'>
<gameroom_update_pvp by_mission_key='1' mission_key='309c5c0c-0ec2-438a-a18b-26efb45caf7e' private='0' friendly_fire='0' enemy_outlines='0' auto_team_balance='0' join_in_the_process='1' max_players='16' inventory_slot='8796059467775' locked_spectator_camera='0' high_latency_autokick='1'>
<class_rifleman enabled='0' class_id='0'/>
<class_heavy enabled='1' class_id='1'/>
<class_engineer enabled='0' class_id='4'/>
<class_medic enabled='0' class_id='3'/>
<class_sniper enabled='0' class_id='2'/>
</gameroom_update_pvp>
</query>
</iq>
*/
if (client->Player->Room->m_pGameRoomCore && client->Player->Room->m_pGameRoomCore->m_pCustomParams != NULL)
{
client->Player->Room->m_pGameRoomCore->mission = iqIn.attribute("mission_key").as_string();
client->Player->Room->m_pGameRoomCore->isPrivateRoom = iqIn.attribute("private").as_int();
client->Player->Room->m_pGameRoomCore->m_pCustomParams->class_restriction = 35;
client->Player->Room->m_pGameRoomCore->m_pCustomParams->inventory_slot = iqIn.attribute("inventory_slot").as_uint();
client->Player->Room->m_pGameRoomCore->m_pCustomParams->friendly_fire = iqIn.attribute("friendly_fire").as_int();
client->Player->Room->m_pGameRoomCore->m_pCustomParams->enemy_outlines = iqIn.attribute("enemy_outlines").as_int();
client->Player->Room->m_pGameRoomCore->m_pCustomParams->auto_team_balance = iqIn.attribute("auto_team_balance").as_int();
client->Player->Room->m_pGameRoomCore->m_pCustomParams->join_in_the_process = iqIn.attribute("join_in_the_process").as_int();
client->Player->Room->m_pGameRoomCore->m_pCustomParams->max_players = iqIn.attribute("max_players").as_int();
client->Player->Room->m_pGameRoomCore->m_pCustomParams->locked_spectator_camera = iqIn.attribute("locked_spectator_camera").as_int();
client->Player->Room->m_pGameRoomCore->m_pCustomParams->high_latency_autokick = iqIn.attribute("high_latency_autokick").as_int();
}
pugi::xml_node gameroom_open = client->Player->SerializeRoom(client, iq->LocalName.c_str());
if (!gameroom_open) return;
std::string result = client->Iq->PrepareData(client, NodeToString22(gameroom_open));
printf("%s\n", result.c_str());
client->sendPacket(client->clientSocket, std::vector<char>(result.begin(), result.end()));
//client->Player->SyncRoom(client, iq);
//client->Player->SyncRoom(client, iq);
}
}