From 711680d652a8db17c1b91428b6d6835f30dfb4fd Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Wed, 19 Nov 2014 17:44:13 -0800 Subject: Magically allow "break" within WITH_VAR --- src/map/atcommand.cpp | 10 +++++----- src/map/battle.cpp | 4 ++-- src/map/chrif.cpp | 2 +- src/map/clif.cpp | 12 +++++++----- src/map/itemdb.cpp | 2 +- src/map/map.cpp | 2 +- src/map/mob.cpp | 2 +- src/map/party.cpp | 4 ++-- src/map/pc.cpp | 20 ++++++++++---------- src/map/script-call.cpp | 2 +- src/map/script-fun.cpp | 24 ++++++++++++------------ src/map/script-parse.cpp | 2 +- src/map/trade.cpp | 4 ++-- 13 files changed, 46 insertions(+), 44 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 0b23ddd..bd1690d 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -375,7 +375,7 @@ bool atcommand_config_read(ZString cfgName) continue; } Option> p_ = get_atcommandinfo_byname(w1); - if OPTION_IS_SOME(p, p_) + if OPTION_IS_SOME_NOLOOP(p, p_) { p->level = GmLevel::from(static_cast(atoi(w2.c_str()))); } @@ -3406,7 +3406,7 @@ ATCE atcommand_partyrecall(Session *s, dumb_ptr sd, Option p_ = party_searchname(party_name); if (p_.is_none()) p_ = party_search(wrap(static_cast(atoi(message.c_str())))); - if OPTION_IS_SOME(p, p_) + if OPTION_IS_SOME_NOLOOP(p, p_) { count = 0; for (io::FD i : iter_fds()) @@ -3588,7 +3588,7 @@ ATCE atcommand_partyspy(Session *s, dumb_ptr sd, Option p_ = party_searchname(party_name); if (p_.is_none()) p_ = party_search(wrap(static_cast(atoi(message.c_str())))); - if OPTION_IS_SOME(p, p_) + if OPTION_IS_SOME_NOLOOP(p, p_) { if (sd->partyspy == p.party_id) { @@ -3962,7 +3962,7 @@ ATCE atcommand_character_storage_list(Session *s, dumb_ptr sd, { // you can look items only lower or same level Option> stor_ = account2storage2(pl_sd->status_key.account_id); - if OPTION_IS_SOME(stor, stor_) + if OPTION_IS_SOME_NOLOOP(stor, stor_) { counter = 0; count = 0; @@ -4426,7 +4426,7 @@ ATCE atcommand_adjcmdlvl(Session *s, dumb_ptr, Option> it_ = atcommand_info.search(cmd); { - if OPTION_IS_SOME(it, it_) + if OPTION_IS_SOME_NOLOOP(it, it_) { it->level = newlev; clif_displaymessage(s, "@command level changed."_s); diff --git a/src/map/battle.cpp b/src/map/battle.cpp index f852265..28c9d5f 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -1411,7 +1411,7 @@ struct Damage battle_calc_pc_weapon_attack(dumb_ptr src, if (widx.ok()) { - if OPTION_IS_SOME(sdidw, sd->inventory_data[widx]) + if OPTION_IS_SOME_NOLOOP(sdidw, sd->inventory_data[widx]) atkmin = atkmin * (80 + sdidw->wlv * 20) / 100; } if (sd->status.weapon == ItemLook::BOW) @@ -1932,7 +1932,7 @@ ATK battle_weapon_attack(dumb_ptr src, dumb_ptr target, ItemNameId weapon; if (weapon_index.ok()) { - if OPTION_IS_SOME(sdidw, sd->inventory_data[weapon_index]) + if OPTION_IS_SOME_NOLOOP(sdidw, sd->inventory_data[weapon_index]) { if (bool(sd->status.inventory[weapon_index].equip & EPOS::WEAPON)) { diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index dbdd401..7119ee8 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -967,7 +967,7 @@ void ladmin_itemfrob_c2(dumb_ptr bl, ItemNameId source_id, ItemNameI IFIX(pc->status.head_bottom); Option> stor_ = account2storage2(pc->status_key.account_id); - if OPTION_IS_SOME(stor, stor_) + if OPTION_IS_SOME_NOLOOP(stor, stor_) { for (SOff0 j : SOff0::iter()) FIX(stor->storage_[j]); diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 430d928..3a84e03 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -401,7 +401,7 @@ int clif_send(const Buffer& buf, dumb_ptr bl, SendWho type) p_ = party_search(sd->status.party_id); } } - if OPTION_IS_SOME(p, p_) + if OPTION_IS_SOME_NOLOOP(p, p_) { for (int i = 0; i < MAX_PARTY; i++) { @@ -1262,17 +1262,19 @@ int clif_selllist(dumb_ptr sd) { if (!sd->status.inventory[i].nameid) continue; - if OPTION_IS_SOME(sdidi, sd->inventory_data[i]) + if OPTION_IS_SOME_NOLOOP(sdidi, sd->inventory_data[i]) { int val = sdidi->value_sell; if (val < 0) - continue; + goto continue_outer; Packet_Repeat<0x00c7> info; info.ioff2 = i.shift(); info.base_price = val; info.actual_price = val; repeat_c7.push_back(info); } + continue_outer: + ; } send_packet_repeatonly<0x00c7, 4, 10>(s, repeat_c7); @@ -3636,7 +3638,7 @@ RecvResult clif_parse_GetCharNameRequest(Session *s, dumb_ptr { Option p_ = party_search(ssd->status.party_id); - if OPTION_IS_SOME(p, p_) + if OPTION_IS_SOME_NOLOOP(p, p_) { party_name = p->name; send = 1; @@ -4188,7 +4190,7 @@ RecvResult clif_parse_EquipItem(Session *s, dumb_ptr sd) if (sd->npc_id) return rv; - if OPTION_IS_SOME(sdidi, sd->inventory_data[index]) + if OPTION_IS_SOME_NOLOOP(sdidi, sd->inventory_data[index]) { EPOS epos = fixed.epos_ignored; if (sdidi->type == ItemType::ARROW) diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp index 2f7ed30..dbe2dd6 100644 --- a/src/map/itemdb.cpp +++ b/src/map/itemdb.cpp @@ -92,7 +92,7 @@ Option> itemdb_exists(ItemNameId nameid) Borrowed itemdb_search(ItemNameId nameid) { Option> id_ = item_db.search(nameid); - if OPTION_IS_SOME(id, id_) + if OPTION_IS_SOME_NOLOOP(id, id_) return id; P id = item_db.init(nameid); diff --git a/src/map/map.cpp b/src/map/map.cpp index b5f08ea..784319f 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -1247,7 +1247,7 @@ void map_setcell(Borrowed m, int x, int y, MapCell t) int map_setipport(MapName name, IP4Address ip, int port) { Option> md_ = maps_db.get(name); - if OPTION_IS_SOME(md, md_) + if OPTION_IS_SOME_NOLOOP(md, md_) { if (md->gat) { diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 044d0b6..63db442 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -2591,7 +2591,7 @@ int mob_damage(dumb_ptr src, dumb_ptr md, int damage, if (it == ptv.end()) { Option p_ = party_search(pid); - if OPTION_IS_SOME(p, p_) + if OPTION_IS_SOME_NOLOOP(p, p_) { if (p->exp != 0) { diff --git a/src/map/party.cpp b/src/map/party.cpp index 8150743..0a9d2c5 100644 --- a/src/map/party.cpp +++ b/src/map/party.cpp @@ -213,7 +213,7 @@ static PartyPair handle_info(const PartyPair sp) { Option p_ = party_search(sp.party_id); - if OPTION_IS_SOME(p, p_) + if OPTION_IS_SOME_NOLOOP(p, p_) { *p.party_most = *sp.party_most; return p; @@ -459,7 +459,7 @@ int party_member_leaved(PartyId party_id, AccountId account_id, CharName name) { dumb_ptr sd = map_id2sd(account_to_block(account_id)); Option p_ = party_search(party_id); - if OPTION_IS_SOME(p, p_) + if OPTION_IS_SOME_NOLOOP(p, p_) { int i; for (i = 0; i < MAX_PARTY; i++) diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 95bdb8d..55e430a 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -555,14 +555,14 @@ int pc_setequipindex(dumb_ptr sd) sd->equip_index_maybe[j] = i; if (bool(sd->status.inventory[i].equip & EPOS::WEAPON)) { - if OPTION_IS_SOME(sdidi, sd->inventory_data[i]) + if OPTION_IS_SOME_NOLOOP(sdidi, sd->inventory_data[i]) sd->weapontype1 = sdidi->look; else sd->weapontype1 = ItemLook::NONE; } if (bool(sd->status.inventory[i].equip & EPOS::SHIELD)) { - if OPTION_IS_SOME(sdidi, sd->inventory_data[i]) + if OPTION_IS_SOME_NOLOOP(sdidi, sd->inventory_data[i]) { if (sdidi->type == ItemType::WEAPON) { @@ -1007,7 +1007,7 @@ int pc_calcstatus(dumb_ptr sd, int first) || sd->equip_index_maybe[EQUIP::LEGS] == index)) continue; - if OPTION_IS_SOME(sdidi, sd->inventory_data[index]) + if OPTION_IS_SOME_NOLOOP(sdidi, sd->inventory_data[index]) { sd->spellpower_bonus_target += sdidi->magic_bonus; @@ -1042,7 +1042,7 @@ int pc_calcstatus(dumb_ptr sd, int first) && (sd->equip_index_maybe[EQUIP::TORSO] == index || sd->equip_index_maybe[EQUIP::LEGS] == index)) continue; - if OPTION_IS_SOME(sdidi, sd->inventory_data[index]) + if OPTION_IS_SOME_NOLOOP(sdidi, sd->inventory_data[index]) { sd->def += sdidi->def; if (sdidi->type == ItemType::WEAPON) @@ -1093,7 +1093,7 @@ int pc_calcstatus(dumb_ptr sd, int first) if (aidx.ok()) { IOff0 index = aidx; - if OPTION_IS_SOME(sdidi, sd->inventory_data[index]) + if OPTION_IS_SOME_NOLOOP(sdidi, sd->inventory_data[index]) { //まだ属性が入っていない argrec_t arg[2] = { @@ -2120,7 +2120,7 @@ int pc_useitem(dumb_ptr sd, IOff0 n) if (!n.ok()) return 0; - if OPTION_IS_SOME(sdidn, sd->inventory_data[n]) + if OPTION_IS_SOME_NOLOOP(sdidn, sd->inventory_data[n]) { amount = sd->status.inventory[n].amount; if (!sd->status.inventory[n].nameid @@ -3335,7 +3335,7 @@ int pc_damage(dumb_ptr src, dumb_ptr sd, if (sd->status.party_id) { // on-the-fly party hp updates [Valaris] Option p_ = party_search(sd->status.party_id); - if OPTION_IS_SOME(p, p_) + if OPTION_IS_SOME_NOLOOP(p, p_) clif_party_hp(p, sd); } // end addition [Valaris] @@ -3703,7 +3703,7 @@ int pc_heal(dumb_ptr sd, int hp, int sp) if (sd->status.party_id) { // on-the-fly party hp updates [Valaris] Option p_ = party_search(sd->status.party_id); - if OPTION_IS_SOME(p, p_) + if OPTION_IS_SOME_NOLOOP(p, p_) clif_party_hp(p, sd); } // end addition [Valaris] @@ -4369,7 +4369,7 @@ int pc_equipitem(dumb_ptr sd, IOff0 n, EPOS) ItemNameId view_i; ItemLook view_l = ItemLook::NONE; // TODO: This is ugly. - if OPTION_IS_SOME(sdidn, sd->inventory_data[n]) + if OPTION_IS_SOME_NOLOOP(sdidn, sd->inventory_data[n]) { bool look_not_weapon = sdidn->look == ItemLook::NONE; bool equip_is_weapon = bool(sd->status.inventory[n].equip & EPOS::WEAPON); @@ -4389,7 +4389,7 @@ int pc_equipitem(dumb_ptr sd, IOff0 n, EPOS) } if (bool(sd->status.inventory[n].equip & EPOS::SHIELD)) { - if OPTION_IS_SOME(sdidn, sd->inventory_data[n]) + if OPTION_IS_SOME_NOLOOP(sdidn, sd->inventory_data[n]) { if (sdidn->type == ItemType::WEAPON) { diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp index 212e0e3..abab24d 100644 --- a/src/map/script-call.cpp +++ b/src/map/script-call.cpp @@ -108,7 +108,7 @@ void get_val(dumb_ptr sd, struct script_data *data) else if (prefix == '$') { Option> s_ = mapregstr_db.search(u.reg); - if OPTION_IS_SOME(s, s_) + if OPTION_IS_SOME_NOLOOP(s, s_) str = *s; } else diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index c38f498..a291a11 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -122,7 +122,7 @@ void builtin_callfunc(ScriptState *st) RString str = conv_str(st, &AARG(0)); Option> scr_ = userfunc_db.get(str); - if OPTION_IS_SOME(scr, scr_) + if OPTION_IS_SOME_NOLOOP(scr, scr_) { int j = 0; assert (st->start + 3 == st->end); @@ -720,7 +720,7 @@ void builtin_countitem(ScriptState *st) { ZString name = ZString(conv_str(st, data)); Option> item_data_ = itemdb_searchname(name); - if OPTION_IS_SOME(item_data, item_data_) + if OPTION_IS_SOME_NOLOOP(item_data, item_data_) nameid = item_data->nameid; } else @@ -763,7 +763,7 @@ void builtin_checkweight(ScriptState *st) { ZString name = ZString(conv_str(st, data)); Option> item_data_ = itemdb_searchname(name); - if OPTION_IS_SOME(item_data, item_data_) + if OPTION_IS_SOME_NOLOOP(item_data, item_data_) nameid = item_data->nameid; } else @@ -808,7 +808,7 @@ void builtin_getitem(ScriptState *st) { ZString name = ZString(conv_str(st, data)); Option> item_data_ = itemdb_searchname(name); - if OPTION_IS_SOME(item_data, item_data_) + if OPTION_IS_SOME_NOLOOP(item_data, item_data_) nameid = item_data->nameid; } else @@ -861,7 +861,7 @@ void builtin_makeitem(ScriptState *st) { ZString name = ZString(conv_str(st, data)); Option> item_data_ = itemdb_searchname(name); - if OPTION_IS_SOME(item_data, item_data_) + if OPTION_IS_SOME_NOLOOP(item_data, item_data_) nameid = item_data->nameid; } else @@ -905,7 +905,7 @@ void builtin_delitem(ScriptState *st) { ZString name = ZString(conv_str(st, data)); Option> item_data_ = itemdb_searchname(name); - if OPTION_IS_SOME(item_data, item_data_) + if OPTION_IS_SOME_NOLOOP(item_data, item_data_) nameid = item_data->nameid; } else @@ -1080,7 +1080,7 @@ void builtin_getequipid(ScriptState *st) if (i.ok()) { Option> item_ = sd->inventory_data[i]; - if OPTION_IS_SOME(item, item_) + if OPTION_IS_SOME_NOLOOP(item, item_) push_int(st->stack, unwrap(item->nameid)); else push_int(st->stack, 0); @@ -1109,7 +1109,7 @@ void builtin_getequipname(ScriptState *st) if (i.ok()) { Option> item_ = sd->inventory_data[i]; - if OPTION_IS_SOME(item, item_) + if OPTION_IS_SOME_NOLOOP(item, item_) buf = STRPRINTF("%s-[%s]"_fmt, pos_str[num - 1], item->jname); else buf = STRPRINTF("%s-[%s]"_fmt, pos_str[num - 1], pos_str[10]); @@ -1832,7 +1832,7 @@ void builtin_getareadropitem(ScriptState *st) { ZString name = ZString(conv_str(st, data)); Option> item_data_ = itemdb_searchname(name); - if OPTION_IS_SOME(item_data, item_data_) + if OPTION_IS_SOME_NOLOOP(item_data, item_data_) item = item_data->nameid; } else @@ -2013,7 +2013,7 @@ void builtin_setmapflag(ScriptState *st) int i = conv_num(st, &AARG(1)); MapFlag mf = map_flag_from_int(i); Option> m_ = map_mapname2mapid(str); - if OPTION_IS_SOME(m, m_) + if OPTION_IS_SOME_NOLOOP(m, m_) { m->flag.set(mf, 1); } @@ -2026,7 +2026,7 @@ void builtin_removemapflag(ScriptState *st) int i = conv_num(st, &AARG(1)); MapFlag mf = map_flag_from_int(i); Option> m_ = map_mapname2mapid(str); - if OPTION_IS_SOME(m, m_) + if OPTION_IS_SOME_NOLOOP(m, m_) { m->flag.set(mf, 0); } @@ -2041,7 +2041,7 @@ void builtin_getmapflag(ScriptState *st) int i = conv_num(st, &AARG(1)); MapFlag mf = map_flag_from_int(i); Option> m_ = map_mapname2mapid(str); - if OPTION_IS_SOME(m, m_) + if OPTION_IS_SOME_NOLOOP(m, m_) { r = m->flag.get(mf); } diff --git a/src/map/script-parse.cpp b/src/map/script-parse.cpp index 878397f..47e0def 100644 --- a/src/map/script-parse.cpp +++ b/src/map/script-parse.cpp @@ -134,7 +134,7 @@ Option> search_strp(XString p) Borrowed add_strp(XString p) { Option> rv_ = search_strp(p); - if OPTION_IS_SOME(rv, rv_) + if OPTION_IS_SOME_NOLOOP(rv, rv_) return rv; RString p2 = p; diff --git a/src/map/trade.cpp b/src/map/trade.cpp index b5e19be..5ec63c9 100644 --- a/src/map/trade.cpp +++ b/src/map/trade.cpp @@ -174,7 +174,7 @@ void trade_tradeadditem(dumb_ptr sd, IOff2 index, int amount) sd->status.inventory[index.unshift()].nameid) continue; - if OPTION_IS_SOME(id, target_sd->inventory_data[i]) + if OPTION_IS_SOME_INLOOP(id, target_sd->inventory_data[i]) { if (id->type != ItemType::WEAPON && id->type != ItemType::ARMOR @@ -231,7 +231,7 @@ void trade_tradeadditem(dumb_ptr sd, IOff2 index, int amount) sd->status. inventory[sd->deal_item_index[trade_i].unshift()].nameid) continue; - if OPTION_IS_SOME(id, target_sd->inventory_data[i]) + if OPTION_IS_SOME_INLOOP(id, target_sd->inventory_data[i]) { if (id->type != ItemType::WEAPON && id->type != ItemType::ARMOR -- cgit v1.2.3-60-g2f50