-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJoinChannel.cpp
More file actions
118 lines (93 loc) · 13 KB
/
JoinChannel.cpp
File metadata and controls
118 lines (93 loc) · 13 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
107
108
109
110
111
112
113
114
115
116
117
118
#include "JoinChannel.hpp"
#include "Client.hpp"
#include <sstream>
namespace JoinChannel {
std::string GetItems(Client* client)
{
if (!client || !client->Player ||
client->Player->profile_id == 0)
return {};
pugi::xml_document doc;
pugi::xml_node itemsNode = doc.append_child("items");
itemsNode.append_attribute("current_preset_id") = 0;
for (const ItemsPlayer& item : client->Player->items_list)
{
item.Serialize(itemsNode);
}
std::ostringstream ss;
doc.save(ss, "", pugi::format_raw);
return ss.str();
}
void AppendXmlFragment(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 NodeToString(pugi::xml_node node)
{
if (!node || !node.parent())
return "";
std::ostringstream ss;
node.print(ss, "", pugi::format_raw);
return ss.str();
}
std::string Cp1251ToUtf8(const std::string& cp1251)
{
// CP1251 -> UTF-16
int wideLen = MultiByteToWideChar(1251, 0, cp1251.c_str(), -1, nullptr, 0);
if (wideLen == 0)
return {};
std::wstring wide(wideLen, L'\0');
MultiByteToWideChar(1251, 0, cp1251.c_str(), -1, &wide[0], wideLen);
// UTF-16 -> UTF-8
int utf8Len = WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1, nullptr, 0, nullptr, nullptr);
if (utf8Len == 0)
return {};
std::string utf8(utf8Len, '\0');
WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1, &utf8[0], utf8Len, nullptr, nullptr);
utf8.pop_back(); // óáðàòü \0
return utf8;
}
//TODO: âõîä íà êÀíàë
void Init(Client* client, IqClass* IQ) {
pugi::xml_document doc;
pugi::xml_node join = doc.append_child("join_channel");
pugi::xml_node character = join.append_child("character");
character.append_attribute("nick") = u8"ïðèâ";
character.append_attribute("gender") = "male";
character.append_attribute("height") = "1";
character.append_attribute("fatness") = "0";
character.append_attribute("head") = "default_head_22";
character.append_attribute("current_class") = "2";
character.append_attribute("experience") = "107132";
character.append_attribute("rank_id") = "3";
character.append_attribute("banner_badge") = "0";
character.append_attribute("banner_mark") = "0";
character.append_attribute("banner_stripe") = "0";
character.append_attribute("ranked_points") = "0";
character.append_attribute("game_money") = "0";
character.append_attribute("cry_money") = "0";
character.append_attribute("crown_money") = "0";
character.append_attribute("armory_tokens") = "0";
character.append_attribute("prev_last_seen") = "1765484884";
pugi::xml_document itemsDoc;
itemsDoc.load_string(GetItems(client).c_str());
character.append_copy(itemsDoc.first_child());
AppendXmlFragment(character, "<profile_progression_state profile_id='50416994' mission_unlocked='none,trainingmission,whitesharkeasy,zombieeasy,zombienormal,zombiehard,snowfortressmarathonhard,snowfortress1hard,snowfortress2hard,snowfortress3hard,volcanoeasy,volcanonormal,volcanohard,anubiseasy,anubisnormal,anubishard,zombietowereasy,zombietowernormal,zombietowerhard,icebreakereasy,icebreakernormal,icebreakerhard,anubiseasy2,anubisnormal2,anubishard2,chernobyleasy,chernobylnormal,chernobylhard,japaneasy,japannormal,japanhard,marseasy,marsnormal,marshard,pve_arenahard,blackwoodhard,swarmhard,solomission,volcanomarathonnormal,volcanomarathonhard,volcanoact1easy,volcanoact1normal,volcanoact1hard,volcanoact2easy,volcanoact2normal,volcanoact2hard,volcanoact3easy,volcanoact3normal,volcanoact3hard,marsmarathoneasy,marsmarathonnormal,marsmarathonhard,marsact1easy,marsact1normal,marsact1hard,chernobylmarathoneasy,chernobylmarathonnormal,volcanomarathoneasy,heisthard,labirinthsurvival,nemesissurvival,endorsurvival,endorfinal,midgardsurvival,midgardeasy,midgardnormal,midgardhard,swarmeasy,swarmnormal,pve_arenaeasy,pve_arenanormal,heisteasy,heistnormal,blackwoodeasy,blackwoodnormal,asgardeasy,asgardnormal,asgardhard,whitesharknormal,whitesharkhard,snowfortress1easy,snowfortress1normal,snowfortress2easy,snowfortress2normal,snowfortress3easy,snowfortress3normal,snowfortressmarathoneasy,snowfortressmarathonnormal,anubisstory,swarmstory,asgardstory,chernobylstory,whitesharkstory,zombietowerstory,zombiestory,anubisstory2,icebreakerstory,japanstory,marsstory,pve_arenastory,blackwoodstory,heiststory,nemesisstory,midgardstory,volcanostory,snowfortressstory,endorstory,endorstory2,aresstory,all' tutorial_unlocked='7' tutorial_passed='7' class_unlocked='31' gamemodes_unlocked='4063'/>");
AppendXmlFragment(character, "<variables><item key='chat.enable_reference' value='1'/><item key='clans.clan_item' value='clan_creation_item_01'/><item key='clans.enable_chat' value='1'/><item key='clans.max_name_size' value='16'/><item key='clans.min_name_size' value='4'/><item key='cvar:cc_cache' value='1'/><item key='cvar:cl_autostart_pve_room' value='1'/><item key='cvar:cl_autostart_room' value='1'/><item key='cvar:cl_card_progressions_enabled' value='0'/><item key='cvar:cl_charms_enabled' value='1'/><item key='cvar:cl_enable_personalized_offers' value='1'/><item key='cvar:cl_quickplay_gamemode_based' value='0'/><item key='cvar:cl_send_fps_stats' value='0'/><item key='cvar:cl_shop_skin_validation_enabled' value='0'/><item key='cvar:cl_statistic_flush_period' value='120'/><item key='cvar:cl_teams_states_pannel_enabled' value='1'/><item key='cvar:e_ParticlesUpdateAsync' value='0'/><item key='cvar:g_aprils_fool_enabled' value='1'/><item key='cvar:g_aprils_fool_items' value='pt25_mvt24fool04 pt25_mvt24fool04skin_shop'/><item key='cvar:g_battle_pass_enabled' value='1'/><item key='cvar:g_character_manager_early_preload' value='1'/><item key='cvar:g_chat_language_separated' value='0'/><item key='cvar:g_clientDfConeAngle' value='70'/><item key='cvar:g_enable_flashbang_mechanic' value='1'/><item key='cvar:g_enable_function_time_collector' value='1'/><item key='cvar:g_enable_headshot_effect' value='1'/><item key='cvar:g_event_enabled' value='1'/><item key='cvar:g_event_hiw_enabled' value='1'/><item key='cvar:g_heavy_class_enabled' value='1'/><item key='cvar:g_ingame_fps_indicator_show_threshold' value='30.0'/><item key='cvar:g_ingame_indicators_update_rate' value='3.0'/><item key='cvar:g_ingame_packetloss_indicator_show_threshold' value='20.0'/><item key='cvar:g_ingame_ping_indicator_show_threshold' value='200.0'/><item key='cvar:g_item_progression_enabled' value='1'/><item key='cvar:g_lobbylevel' value='hideout_ares_2025'/><item key='cvar:g_matchmaking_region_switching_dialog' value='1'/><item key='cvar:g_material_effects_early_preload' value='1'/><item key='cvar:g_notifications_clan_invite_ttl_seconds' value='86400'/><item key='cvar:g_perks_enabled' value='1'/><item key='cvar:g_preinvite_ping_timeout' value='20'/><item key='cvar:g_pve_mission_access_limitation_enabled' value='0'/><item key='cvar:g_ranked_leaderboard_enabled' value='1'/><item key='cvar:g_rating_game_restricted_equipment_verification_enabled' value='1'/><item key='cvar:g_reconnect_to_game_enabled' value='1'/><item key='cvar:g_sm_coop_assist_threshold' value='25'/><item key='cvar:g_tournament_enabled' value='0'/><item key='cvar:g_validInternalProtocols' value='mailrugames;https;http'/><item key='cvar:g_zoom_speed_multiplier' value='0.6'/><item key='cvar:hud_for_observer_enabled' value='1'/><item key='cvar:online_enable_clan_broadcast' value='1'/><item key='cvar:online_enable_friend_broadcast' value='1'/><item key='cvar:online_newbie_rank' value='5'/><item key='cvar:pl_inertia_haste_enabled' value='1'/><item key='cvar:r_MultiThreaded' value='2'/><item key='cvar:r_NewBrightness' value='1'/><item key='cvar:r_OitEnabled' value='1'/><item key='cvar:r_ShadersSendMisses' value='0'/><item key='cvar:r_TexAsyncPreloading' value='0'/><item key='cvar:r_TexturesStreaming' value='1'/><item key='cvar:r_shadersnocompile' value='0'/><item key='cvar:s_OGGStreaming' value='1'/><item key='cvar:s_SoundMoods' value='1'/><item key='cvar:sys_crash_force_send' value='1'/><item key='cvar:sys_crash_use_put' value='1'/><item key='cvar:sys_crashserver_project' value='wf'/><item key='cvar:sys_crashserver_url' value='crashreport-1-awpc.ext.terrhq.ru:8080/reports/crashparser'/><item key='cvar:sys_use_anzu' value='0'/><item key='cvar:ui_cacheValidTime' value='15'/><item key='cvar:ui_currency_bonus_enabled' value='1'/><item key='cvar:ui_hidden_smg' value='nemesissurvival'/><item key='cvar:ui_kick_vote_enabled' value='1'/><item key='cvar:ui_lobby_rating_tab_min_rank' value='26'/><item key='cvar:ui_mastery_boost_enabled' value='1'/><item key='cvar:ui_money_refill_min_rank' value='1'/><item key='cvar:ui_money_refill_min_repair_percent' value='70'/><item key='cvar:ui_multiply_offer_buy_number' value='5'/><item key='cvar:ui_music_files' value='main_theme_23:music/winterevent2023/wf_winter_hideout_2023.ogg;main_theme_23_light:music/winterevent2023/wf_winter_hideout_2023.ogg;'/><item key='cvar:ui_play_again_button_enabled' value='0'/><item key='cvar:ui_play_again_callout_enabled' value='0'/><item key='cvar:ui_progressive_event_store' value='1'/><item key='cvar:ui_randombox_choice_limitation_enabled' value='1'/><item key='cvar:ui_restore_enabled' value='1'/><item key='cvar:ui_surrender_vote_enabled' value='1'/><item key='cvar:ui_weapon_collection_enabled' value='0'/><item key='dailycompetition.rewardPlayersCount' value='1000'/><item key='discord.application_id' value='554573575047348225'/><item key='discord.game_launch_url' value='gameklauncher://open'/><item key='discord.localize' value='1'/><item key='friends.limit' value='150'/><item key='max_gm_boost_effect' value='2.55'/><item key='max_ic_boost_effect' value='1'/><item key='max_ip_boost_effect' value='5'/><item key='max_newbie' value='10'/><item key='max_skilled' value='25'/><item key='max_vp_boost_effect' value='1.95'/><item key='max_xp_boost_effect' value='2.95'/><item key='min_online_users' value='0'/><item key='mission_generation' value='1'/><item key='quickplay.is_light_mode_filter' value='0'/><item key='quickplay.newbie_channel_conf' value='quickplay_default'/><item key='quickplay.pro_channel_conf' value='quickplay_default'/><item key='quickplay.skilled_channel_conf' value='quickplay_default'/><item key='randombox.offers_count' value='2'/><item key='randombox_choice_limitation.max_amount' value='1'/><item key='room.server_allocation_timeout' value='10'/><item key='shop.maxbatchsize' value='5'/><item key='url.charge_account' value='mailrugames://demandgamingform/0.1177'/><item key='url.online_help' value='https://wf.mail.ru/wiki/index.php'/><item key='url.services' value='mailrugames://demandbrowserform/0.1177/?url=https://ru.warface.com/dynamic/user/mccode.php?forward=https%3A%2F%2Fru.warface.com%2Fminigames%2Fbpservices%3Fclient%3D1'/><item key='url.promo' value='mailrugames://demandbrowserform/0.1177/?url=https://ru.warface.com/dynamic/user/mccode.php?forward=https%3A%2F%2Fru.warface.com%2Fpromo%2Fsave_wharton%2F%3Fis_client%3D1%26from%3D%26auth_code%3D%25auth_code%25'/><item key='cvar:cl_quickplay_gamemode_based_newbie' value='0'/><item key='cvar:cl_quickplay_gamemode_based_newbie_abtest' value='0'/><item key='cvar:net_traceroute_enabled' value='1'/><item key='cvar:g_traceroute_send_enabled' value='1'/><item key='cvar:g_traceroute_send_url' value='https://traceapi.warface.ru/wf_pc'/><item key='cvar:ui_story_mode_enable' value='1'/><item key='cvar:ui_player_profile_update' value='1'/><item key='cvar:ui_enable_player_statistic' value='0'/><item key='cvar:ui_player_profile_menu_button_enabled' value='0'/><item key='cvar:g_use_spotting_system_for_rating' value='1'/><item key='cvar:sv_attack_pos_validator_failed_logs' value='0'/><item key='cvar:hud_new_tutorial_hints' value='0'/><item key='cvar:ui_allow_latin' value='0'/><item key='cvar:g_paid_subscription_features_mask' value='23'/><item key='cvar:hud_card_award_start_delay' value='3'/><item key='cvar:unilog_enabled' value='0'/><item key='cvar:unilog_stat_enabled' value='0'/><item key='cvar:g_anti_wallhack_enabled' value='0'/><item key='cvar:g_ingame_afk_notification_timeout' value='0'/><item key='cvar:g_activate_improved_afk' value='0'/><item key='cvar:ui_new_pvp_room_settings_enabled' value='0'/><item key='cvar:ui_new_pvp_room_enabled' value='0'/><item key='cvar:ui_new_pve_room_enabled' value='0'/></variables>");
std::string result = IQ->PrepareData(client, NodeToString(join));
printf("%s\n", result.c_str());
client->sendPacket(client->clientSocket, std::vector<char>(result.begin(), result.end()));
}
}