void xmpp_iq_join_channel(const char *channel, f_join_channel_cb f, void *args) { int is_switch = session.status >= STATUS_LOBBY; struct cb_args *a = calloc(1, sizeof (struct cb_args)); a->cb = f; a->args = args; if (channel == NULL) channel = session.channel; if (channel) a->channel = strdup(channel); else a->channel = NULL; t_uid id; idh_generate_unique_id(&id); idh_register(&id, 0, xmpp_iq_join_channel_cb, a); /* Join CryOnline channel */ send_stream_format(session.wfs, "<iq id='%s' to='k01.warface' type='get'>" "<query xmlns='urn:cryonline:k01'>" "<%s_channel version='%s' token='%s' region_id='global'" " profile_id='%s' user_id='%s' resource='%s'" " user_data='' hw_id='' build_type='--release'/>" "</query>" "</iq>", &id, is_switch ? "switch" : "join", game_version_get(), session.active_token, session.profile_id, session.online_id, a->channel); }
void xmpp_iq_gameroom_open ( const char *mission_key, enum e_room_type type, f_gameroom_open_cb fun, void *args ) { struct cb_args *a = calloc ( 1, sizeof ( struct cb_args ) ); a->fun = fun; a->args = args; t_uid id; idh_generate_unique_id ( &id ); idh_register ( &id, 0, xmpp_iq_gameroom_open_cb, a ); /* Open the game room */ send_stream_format ( session.wfs, "<iq id='%s' to='masterserver@warface/%s' type='get'>" " <query xmlns='urn:cryonline:k01'>" " <gameroom_open" " room_name='Room' team_id='%d' status='1'" " class_id='1' room_type='%d' private='1'" " mission='%s' inventory_slot='0'>" " </gameroom_open>" " </query>" "</iq>", &id, session.online.channel, type ^ ROOM_PVE_PRIVATE ? 1 : 0, type, mission_key ); }
static void xmpp_iq_gameroom_sync_cb(const char *msg_id, const char *msg, void *args) { char *data = wf_get_query_content(msg); int room_status = get_info_int(data, "status='", "'", NULL); if (room_status == 2) { t_uid id; idh_generate_unique_id(&id); idh_register(&id, 0, xmpp_iq_session_join_cb, NULL); send_stream_format(session.wfs, "<iq id='%s' to='masterserver@warface/%s' type='get'>" " <query xmlns='urn:cryonline:k01'>" " <session_join/>" " </query>" "</iq>", &id, session.channel); char *sessionid = get_info(data, "session id='", "'", NULL); if (sessionid != NULL && sessionid[0]) printf("Session id: %s\n", sessionid); free(sessionid); } free(data); }
void *thread_buyboxes ( void *args ) { signal ( SIGINT, sigint_handler__ ); struct cmd_randombox_args_cb_t *randombox_args = ( struct cmd_randombox_args_cb_t* ) args; char *offers = NULL; unsigned int i = 0; for ( ; i < 5; ++i ) { char *s; FORMAT ( s, "%s<offer id='%d'/>", offers ? offers : "", randombox_args->rid + i ); free ( offers ); offers = s; } t_uid id; idh_generate_unique_id ( &id ); idh_register ( &id, 0, _randombox_cb, randombox_args ); send_stream_format ( session.wfs, "<iq id='%s' to='masterserver@warface/%s' type='get'>" "<query xmlns='urn:cryonline:k01'>" "<shop_buy_multiple_offer supplier_id='1'>" "%s" "</shop_buy_multiple_offer>" "</query>" "</iq>", &id, session.online.channel, offers ); free ( offers ); pthread_exit ( NULL ); }
void xmpp_iq_ping(void) { t_uid id; idh_generate_unique_id(&id); idh_register(&id, 0, xmpp_iq_ping_cb, NULL); send_stream_format(session.wfs, "<iq id='%s' from='%s' to='warface' type='get'>" " <ping xmlns='urn:xmpp:ping'/>" "</iq>", &id, session.jid); }
void xmpp_print_number_of_occupants ( int wfs, char *room ) { t_uid id; idh_generate_unique_id ( &id ); idh_register ( &id, 0, xmpp_print_number_of_occupants_cb, NULL ); send_stream_format ( wfs, "<iq to='%s' type='get' id='%s'>" " <query xmlns='http://jabber.org/protocol/disco#info'/>" "</iq>", room, &id ); }
void xmpp_iq_get_account_profiles(void) { t_uid id; idh_generate_unique_id(&id); idh_register(&id, 0, xmpp_iq_get_account_profiles_cb, NULL); /* Get CryOnline profile */ send_stream_format(session.wfs, "<iq id='%s' to='ms.warface' type='get'>" " <query xmlns='urn:cryonline:k01'>" " <get_account_profiles version='%s'" " user_id='%s' token='%s'/>" " </query>" "</iq>", &id, game_version_get(), session.online_id, session.active_token); }
void cmd_stats(f_cmd_stats_cb cb, void *args) { t_uid id; struct cb_args *a = calloc(1, sizeof (struct cb_args)); a->cb = cb; a->args = args; idh_generate_unique_id(&id); idh_register(&id, 1, cmd_stats_cb, a); send_stream_format(session.wfs, "<iq to='k01.warface' type='get' id='%s'>" "<query xmlns='urn:cryonline:k01'>" "<get_master_servers/>" "</query>" "</iq>", &id); }
static void xmpp_iq_gameroom_join_(void *args) { struct cb_args *a = (struct cb_args *) args; t_uid id; idh_generate_unique_id(&id); idh_register(&id, 0, xmpp_iq_gameroom_join_cb, args); /* Open the game room */ send_stream_format(session.wfs, "<iq id='%s' to='masterserver@warface/%s' type='get'>" " <query xmlns='urn:cryonline:k01'>" " <gameroom_join room_id='%s' team_id='0'" " status='1' class_id='1' join_reason='0'/>" " </query>" "</iq>", &id, session.channel, a->room_id); }
void xmpp_iq_gameroom_setname ( const char *room_name, f_id_callback cb, void *args ) { t_uid id; idh_generate_unique_id ( &id ); idh_register ( &id, 0, cb, args ); char *serialized = xml_serialize ( room_name ); send_stream_format ( session.wfs, "<iq id='%s' to='masterserver@warface/%s' type='get'>" " <query xmlns='urn:cryonline:k01'>" " <gameroom_setname room_name='%s'/>" " </query>" "</iq>", &id, session.online.channel, serialized ); free ( serialized ); }
void xmpp_iq_peer_player_info(const char *online_id, f_peer_player_info_cb f, void *args) { struct cb_args *a = calloc(1, sizeof (struct cb_args)); a->cb = f; a->args = args; t_uid id; idh_generate_unique_id(&id); idh_register(&id, 0, xmpp_iq_peer_player_info_cb, a); send_stream_format(session.wfs, "<iq to='%s' type='get' id='%s'>" "<query xmlns='urn:cryonline:k01'>" "<peer_player_info/>" "</query>" "</iq>", online_id, &id); }
void xmpp_iq_profile_info_get_status(const char *nickname, const char *nick_to, const char *jid_to) { struct cb_args *a = calloc(1, sizeof (struct cb_args)); a->nick_to = strdup(nick_to); a->jid_to = strdup(jid_to); t_uid id; idh_generate_unique_id(&id); idh_register(&id, 0, xmpp_iq_profile_info_get_status_cb, a); send_stream_format(session.wfs, "<iq to='k01.warface' type='get' id='%s'>" "<query xmlns='urn:cryonline:k01'>" "<profile_info_get_status nickname='%s'/>" "</query>" "</iq>", &id, nickname); }
static void _randombox_cb ( const char *msg, enum xmpp_msg_type type, void *args ) { /* Answer : <iq to='masterserver@warface/pve_2' type='get'> <query xmlns='urn:cryonline:k01'> <shop_buy_multiple_offer error_status="0"> <purchased_item> <exp name="exp_item_01" added="50" total="40014" offerId="9870"/> <profile_item name="flashbang" profile_item_id="xxxxx" offerId="9870" added_expiration="1 day" added_quantity="0" error_status="0"> <item id="xxxxx" name="flashbang" attached_to="0" config="dm=0;material=;pocket_index=3246082" slot="0" equipped="0" default="0" permanent="0" expired_confirmed="0" buy_time_utc="1429646487" expiration_time_utc="1449778407" seconds_left="172628"/> </profile_item> <exp name="exp_item_01" added="50" total="40064" offerId="9871"/> ... </purchased_item> <money game_money="AAA" cry_money="BBB" crown_money="CCC"/> </shop_buy_multiple_offer> </query> </iq> */ struct cmd_randombox_args_cb_t *randombox_args = (struct cmd_randombox_args_cb_t*) args; if ( type & XMPP_TYPE_ERROR ) { LOGPRINT ( KRED BOLD "Error while purchasing items\n" ); return; } char *data = wf_get_query_content ( msg ); if ( data != NULL ) { //printf ( "Answer: \n---------\n%s\n--------\n\n", data ); unsigned int error_code = get_info_int ( data, "error_status='", "'", NULL ); unsigned int money_left = get_info_int ( data, "game_money='", "'", NULL ); const char *m = strstr ( data, "<shop_buy_multiple_offer" ); if ( m != NULL && ( error_code == 1 || error_code == 0 ) ) { unsigned total_xp = 0; m += sizeof ( "<shop_buy_multiple_offer" ); do { const char *exp_s = strstr ( m, "<exp" ); const char *profile_item_s = strstr ( m, "<profile_item" ); if ( exp_s != NULL && ( profile_item_s == NULL || exp_s < profile_item_s ) ) { m = exp_s + sizeof ( "<exp" ); total_xp += get_info_int ( m, "added='", "'", NULL ); } else if ( profile_item_s != NULL ) { m = profile_item_s + sizeof ( "<profile_item" ); char *name = get_info ( m, "name='", "'", NULL ); char *expir = get_info ( m, "added_expiration='", "'", NULL ); char *quant = get_info ( m, "added_quantity='", "'", NULL ); LOGPRINT ( "%-20s %-10s %s\n", "ITEM", expir && expir[ 0 ] != '0' ? expir : quant, name ); if ( randombox_args->needed && strstr ( name, randombox_args->needed ) ) { LOGPRINT ( KGRN BOLD "%-20s %s\a\n" KRST KWHT, "GOT ITEM", name ); randombox_args->gotNeeded = 1; } free ( quant ); free ( expir ); free ( name ); } else { break; } } while ( 1 ); randombox_args->moneyLeft = money_left; randombox_args->xp += total_xp; LOGPRINT ( "%-20s " BOLD "%d\n", "MONEY LEFT", money_left ); if ( randombox_args->moneyLeft < randombox_args->stopMoney || randombox_args->gotNeeded ) { session.profile.money.game = randombox_args->moneyLeft; session.profile.experience += randombox_args->xp; LOGPRINT ( "%-20s " BOLD "%d\n", "TOTAL XP EARNED", randombox_args->xp ); free ( randombox_args->needed ); free ( randombox_args ); return; } char *offers = NULL; unsigned int i = 0; for ( ; i < 5; ++i ) { char *s; FORMAT ( s, "%s<offer id='%d'/>", offers ? offers : "", randombox_args->rid + i ); free ( offers ); offers = s; } t_uid id; idh_generate_unique_id ( &id ); idh_register ( &id, 0, _randombox_cb, randombox_args ); send_stream_format ( session.wfs, "<iq id='%s' to='masterserver@warface/%s' type='get'>" "<query xmlns='urn:cryonline:k01'>" "<shop_buy_multiple_offer supplier_id='1'>" "%s" "</shop_buy_multiple_offer>" "</query>" "</iq>", &id, session.online.channel, offers ); free ( offers ); } else { switch ( error_code ) { case 2: LOGPRINT ( KRED BOLD "Restricted purchase\n" ); break; default: break; } session.profile.money.game = randombox_args->moneyLeft; session.profile.experience += randombox_args->xp; LOGPRINT ( "%-20s " BOLD "%d\n", "TOTAL XP EARNED", randombox_args->xp ); free ( randombox_args->needed ); free ( randombox_args ); } } free ( data ); return; }