bool item_t::decode_addon() { if ( encoded_addon_str == "none" ) return true; if ( encoded_addon_str == "synapse_springs" ) { unique_addon = true; return true; } std::string use_str; if ( unique_gear_t::get_use_encoding( use_str, encoded_addon_str, heroic(), lfr(), player -> dbc.ptr ) ) { unique_addon = true; use.name_str = encoded_addon_str; return decode_special( use, use_str ); } std::string equip_str; if ( unique_gear_t::get_equip_encoding( equip_str, encoded_addon_str, heroic(), lfr(), player -> dbc.ptr ) ) { unique_addon = true; addon.name_str = encoded_addon_str; return decode_special( addon, equip_str ); } std::vector<token_t> tokens; int num_tokens = parse_tokens( tokens, encoded_addon_str ); for ( int i=0; i < num_tokens; i++ ) { token_t& t = tokens[ i ]; int s; if ( ( s = util_t::parse_stat_type( t.name ) ) != STAT_NONE ) { stats.add_stat( s, t.value ); } else { sim -> errorf( "Player %s has unknown 'addon=' token '%s' at slot %s\n", player -> name(), t.full.c_str(), slot_name() ); return false; } } return true; }
void Ororok::lastfm::Auth::lastfmQueryFinished() { Ororok::lastfm::Response lfr(Ororok::lastfm::parseReply(p->lastfmReply)); if (lfr.error()) { // cleanup username and session data reset(); emit failed(lfr.error(), lfr.errorText()); return; } ::lastfm::XmlQuery lfm; lfm.parse(lfr.data); // replace username, just in case ::lastfm::ws::Username = lfm["session"]["name"].text(); // remember session key, it's important to re-use it in the // future, we don't want to login every time when application // starts ::lastfm::ws::SessionKey = lfm["session"]["key"].text(); emit success(::lastfm::ws::Username, ::lastfm::ws::SessionKey); }
void item_t::encode_options() { // Re-build options_str for use in saved profiles std::string& o = options_str; o = encoded_name_str; if ( heroic() ) { o += ",heroic=1"; } if ( lfr() ) { o += ",lfr=1"; } if ( armor_type() ) { o += ",type="; o += encoded_armor_type_str; } if ( ! encoded_ilevel_str.empty() ) { o += ",ilevel="; o += encoded_ilevel_str; } if ( ! encoded_quality_str.empty() ) { o += ",quality="; o += encoded_quality_str; } if ( ! encoded_stats_str.empty() ) { o += ",stats="; o += encoded_stats_str; } if ( ! encoded_reforge_str.empty() ) { o += ",reforge="; o += encoded_reforge_str; } if ( ! encoded_gems_str.empty() ) { o += ",gems="; o += encoded_gems_str; } if ( ! encoded_enchant_str.empty() ) { o += ",enchant="; o += encoded_enchant_str; } if ( ! encoded_addon_str.empty() ) { o += ",addon="; o += encoded_addon_str; } if ( ! encoded_equip_str.empty() ) { o += ",equip="; o += encoded_equip_str; } if ( ! encoded_use_str.empty() ) { o += ",use="; o += encoded_use_str; } if ( ! encoded_weapon_str.empty() ) { o += ",weapon="; o += encoded_weapon_str; } if ( ! encoded_random_suffix_str.empty() ) { o += ",suffix="; o += encoded_random_suffix_str; } }
bool item_t::decode_enchant() { if ( encoded_enchant_str == "none" ) return true; if ( encoded_enchant_str == "berserking" || encoded_enchant_str == "executioner" || encoded_enchant_str == "mongoose" || encoded_enchant_str == "avalanche" || encoded_enchant_str == "elemental_slayer" || encoded_enchant_str == "hurricane" || encoded_enchant_str == "landslide" || encoded_enchant_str == "power_torrent" || encoded_enchant_str == "windwalk" || encoded_enchant_str == "spellsurge" || encoded_enchant_str == "synapse_springs" || encoded_enchant_str == "gnomish_xray" ) { unique_enchant = true; return true; } if ( encoded_enchant_str == "lightweave_embroidery" || encoded_enchant_str == "lightweave_embroidery_old" || encoded_enchant_str == "lightweave" || encoded_enchant_str == "lightweave_old" || encoded_enchant_str == "swordguard_embroidery" || encoded_enchant_str == "swordguard_embroidery_old" || encoded_enchant_str == "darkglow_embroidery" || encoded_enchant_str == "darkglow_embroidery_old" ) { stats.add_stat( STAT_SPIRIT, 1 ); } std::string use_str; if ( unique_gear_t::get_use_encoding( use_str, encoded_enchant_str, heroic(), lfr(), player -> dbc.ptr ) ) { unique_enchant = true; use.name_str = encoded_enchant_str; return decode_special( use, use_str ); } std::string equip_str; if ( unique_gear_t::get_equip_encoding( equip_str, encoded_enchant_str, heroic(), lfr(), player -> dbc.ptr ) ) { unique_enchant = true; enchant.name_str = encoded_enchant_str; return decode_special( enchant, equip_str ); } std::vector<token_t> tokens; int num_tokens = parse_tokens( tokens, encoded_enchant_str ); for ( int i=0; i < num_tokens; i++ ) { token_t& t = tokens[ i ]; int s; if ( ( s = util_t::parse_stat_type( t.name ) ) != STAT_NONE ) { stats.add_stat( s, t.value ); } else { sim -> errorf( "Player %s has unknown 'enchant=' token '%s' at slot %s\n", player -> name(), t.full.c_str(), slot_name() ); continue; } } return true; }
bool item_t::init() { parse_options(); encoded_name_str = armory_name_str; if ( ! option_name_str.empty() ) encoded_name_str = option_name_str; if ( ! option_id_str.empty() ) { if ( ! item_t::download_item( *this, option_id_str ) ) { return false; } if ( encoded_name_str != armory_name_str ) { sim -> errorf( "Player %s at slot %s has inconsistency between name '%s' and '%s' for id '%s'\n", player -> name(), slot_name(), option_name_str.c_str(), armory_name_str.c_str(), option_id_str.c_str() ); encoded_name_str = armory_name_str; } } if ( encoded_name_str != "empty" && encoded_name_str != "none" ) { id_str = armory_id_str; encoded_stats_str = armory_stats_str; encoded_reforge_str = armory_reforge_str; encoded_gems_str = armory_gems_str; encoded_enchant_str = armory_enchant_str; encoded_addon_str = armory_addon_str; encoded_weapon_str = armory_weapon_str; encoded_heroic_str = armory_heroic_str; encoded_lfr_str = armory_lfr_str; encoded_armor_type_str = armory_armor_type_str; encoded_ilevel_str = armory_ilevel_str; encoded_quality_str = armory_quality_str; encoded_random_suffix_str = armory_random_suffix_str; } if ( ! option_heroic_str.empty() ) encoded_heroic_str = option_heroic_str; if ( ! decode_heroic() ) return false; if ( ! option_lfr_str.empty() ) encoded_lfr_str = option_lfr_str; if ( ! decode_lfr() ) return false; if ( ! option_armor_type_str.empty() ) encoded_armor_type_str = option_armor_type_str; if ( ! decode_armor_type() ) return false; if ( ! option_ilevel_str.empty() ) encoded_ilevel_str = option_ilevel_str; if ( ! decode_ilevel() ) return false; if ( ! option_quality_str.empty() ) encoded_quality_str = option_quality_str; if ( ! decode_quality() ) return false; unique_gear_t::get_equip_encoding( encoded_equip_str, encoded_name_str, heroic(), lfr(), player -> dbc.ptr, id_str ); unique_gear_t::get_use_encoding ( encoded_use_str, encoded_name_str, heroic(), lfr(), player -> dbc.ptr, id_str ); if ( ! option_stats_str.empty() ) encoded_stats_str = option_stats_str; if ( ! option_reforge_str.empty() ) encoded_reforge_str = option_reforge_str; if ( ! option_gems_str.empty() ) encoded_gems_str = option_gems_str; if ( ! option_enchant_str.empty() ) { if ( ( slot == SLOT_FINGER_1 || slot == SLOT_FINGER_2 ) && ! ( player -> profession[ PROF_ENCHANTING ] > 0 ) ) { sim -> errorf( "Player %s's ring at slot %s has a ring enchant without the enchanting profession\n", player -> name(), slot_name() ); } else { encoded_enchant_str = option_enchant_str; } } if ( ! option_addon_str.empty() ) encoded_addon_str = option_addon_str; if ( ! option_weapon_str.empty() ) encoded_weapon_str = option_weapon_str; if ( ! option_random_suffix_str.empty() ) encoded_random_suffix_str = option_random_suffix_str; if ( ! decode_stats() ) return false; if ( ! decode_gems() ) return false; if ( ! decode_enchant() ) return false; if ( ! decode_addon() ) return false; if ( ! decode_weapon() ) return false; if ( ! decode_random_suffix() ) return false; if ( ! decode_reforge() ) return false; if ( ! option_equip_str.empty() ) encoded_equip_str = option_equip_str; if ( ! option_use_str.empty() ) encoded_use_str = option_use_str; if ( ! decode_special( use, encoded_use_str ) ) return false; if ( ! decode_special( equip, encoded_equip_str ) ) return false; encode_options(); return true; }