diff options
Diffstat (limited to 'src/map/clif.cpp')
-rw-r--r-- | src/map/clif.cpp | 399 |
1 files changed, 147 insertions, 252 deletions
diff --git a/src/map/clif.cpp b/src/map/clif.cpp index b47bf28..243ffaf 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -36,30 +36,36 @@ #include "../strings/xstring.hpp" #include "../io/cxxstdio.hpp" -#include "../io/cxxstdio_enums.hpp" +#include "../io/extract.hpp" #include "../io/write.hpp" #include "../net/ip.hpp" -#include "../net/packets.hpp" #include "../net/socket.hpp" #include "../net/timer.hpp" +#include "../net/timestamp-utils.hpp" #include "../proto2/any-user.hpp" #include "../proto2/char-map.hpp" #include "../proto2/map-user.hpp" -#include "../mmo/md5more.hpp" -#include "../mmo/utils.hpp" +#include "../mmo/cxxstdio_enums.hpp" #include "../mmo/version.hpp" +#include "../high/md5more.hpp" + +#include "../wire/packets.hpp" + #include "atcommand.hpp" #include "battle.hpp" +#include "battle_conf.hpp" #include "chrif.hpp" +#include "globals.hpp" #include "intif.hpp" #include "itemdb.hpp" #include "magic.hpp" #include "magic-stmt.hpp" #include "map.hpp" +#include "map_conf.hpp" #include "npc.hpp" #include "party.hpp" #include "pc.hpp" @@ -73,6 +79,8 @@ namespace tmwa { +namespace map +{ constexpr int EMOTE_IGNORED = 0x0e; // functions list. Rate is how many milliseconds are required between @@ -117,11 +125,6 @@ enum class SendWho }; static -IP4Address map_ip; -static -int map_port = 5121; - -static int clif_changelook_towards(dumb_ptr<block_list> bl, LOOK type, int val, dumb_ptr<map_session_data> dstsd); static @@ -149,42 +152,6 @@ void clif_delete(Session *s) /*========================================== - * map鯖のip設定 - *------------------------------------------ - */ -void clif_setip(IP4Address ip) -{ - map_ip = ip; -} - -/*========================================== - * map鯖のport設定 - *------------------------------------------ - */ -void clif_setport(int port) -{ - map_port = port; -} - -/*========================================== - * map鯖のip読み出し - *------------------------------------------ - */ -IP4Address clif_getip(void) -{ - return map_ip; -} - -/*========================================== - * map鯖のport読み出し - *------------------------------------------ - */ -int clif_getport(void) -{ - return map_port; -} - -/*========================================== * *------------------------------------------ */ @@ -231,11 +198,6 @@ int is_deaf(dumb_ptr<block_list> bl) return sd->special_state.deaf; } -static -void clif_emotion_towards(dumb_ptr<block_list> bl, - dumb_ptr<block_list> target, int type); - - enum class ChatType { Party, @@ -295,7 +257,6 @@ void clif_send_sub(dumb_ptr<block_list> bl, const Buffer& buf, static int clif_send(const Buffer& buf, dumb_ptr<block_list> bl, SendWho type) { - PartyPair p; int x0 = 0, x1 = 0, y0 = 0, y1 = 0; if (type != SendWho::ALL_CLIENT) @@ -305,7 +266,7 @@ int clif_send(const Buffer& buf, dumb_ptr<block_list> bl, SendWho type) if (bl->bl_type == BL::PC) { dumb_ptr<map_session_data> sd2 = bl->is_player(); - if (bool(sd2->status.option & Option::INVISIBILITY)) + if (bool(sd2->status.option & Opt0::INVISIBILITY)) { // Obscure hidden GMs @@ -384,20 +345,22 @@ int clif_send(const Buffer& buf, dumb_ptr<block_list> bl, SendWho type) case SendWho::PARTY_WOS: // 自分以外の全パーティーメンバに送信 case SendWho::PARTY_SAMEMAP: // 同じマップの全パーティーメンバに送信 case SendWho::PARTY_SAMEMAP_WOS: // 自分以外の同じマップの全パーティーメンバに送信 + { + Option<PartyPair> p_ = None; if (bl->bl_type == BL::PC) { dumb_ptr<map_session_data> sd = bl->is_player(); if (sd->partyspy) { - p = party_search(sd->partyspy); + p_ = party_search(sd->partyspy); } else { if (sd->status.party_id) - p = party_search(sd->status.party_id); + p_ = party_search(sd->status.party_id); } } - if (p) + OMATCH_BEGIN_SOME (p, p_) { for (int i = 0; i < MAX_PARTY; i++) { @@ -436,6 +399,8 @@ int clif_send(const Buffer& buf, dumb_ptr<block_list> bl, SendWho type) } } } + OMATCH_END (); + } break; case SendWho::SELF: { @@ -617,37 +582,6 @@ int clif_clearchar(dumb_ptr<block_list> bl, BeingRemoveWhy type) return 0; } -static -void clif_clearchar_delay_sub(TimerData *, tick_t, - dumb_ptr<block_list> bl, BeingRemoveWhy type) -{ - clif_clearchar(bl, type); - MapBlockLock::freeblock(bl); -} - -int clif_clearchar_delay(tick_t tick, - dumb_ptr<block_list> bl, BeingRemoveWhy type) -{ - dumb_ptr<block_list> tmpbl; - tmpbl.new_(); - - // yikes! - tmpbl->bl_next = bl->bl_next; - tmpbl->bl_prev = bl->bl_prev; - tmpbl->bl_id = bl->bl_id; - tmpbl->bl_m = bl->bl_m; - tmpbl->bl_x = bl->bl_x; - tmpbl->bl_y = bl->bl_y; - tmpbl->bl_type = bl->bl_type; - - Timer(tick, - std::bind(clif_clearchar_delay_sub, ph::_1, ph::_2, - tmpbl, type) - ).detach(); - - return 0; -} - /*========================================== * *------------------------------------------ @@ -684,14 +618,14 @@ void clif_set0078_main_1d8(dumb_ptr<map_session_data> sd, Buffer& buf) fixed_1d8.weapon = sd->attack_spell_look_override; else { - if (widx.ok() && sd->inventory_data[widx]) + if (widx.ok() && sd->inventory_data[widx].is_some()) { fixed_1d8.weapon = sd->status.inventory[widx].nameid; } else fixed_1d8.weapon = ItemNameId(); } - if (sidx.ok() && sidx != widx && sd->inventory_data[sidx]) + if (sidx.ok() && sidx != widx && sd->inventory_data[sidx].is_some()) { fixed_1d8.shield = sd->status.inventory[sidx].nameid; } @@ -738,14 +672,14 @@ void clif_set0078_alt_1d9(dumb_ptr<map_session_data> sd, Buffer& buf) fixed_1d8.weapon = sd->attack_spell_look_override; else { - if (widx.ok() && sd->inventory_data[widx]) + if (widx.ok() && sd->inventory_data[widx].is_some()) { fixed_1d8.weapon = sd->status.inventory[widx].nameid; } else fixed_1d8.weapon = ItemNameId(); } - if (sidx.ok() && sidx != widx && sd->inventory_data[sidx]) + if (sidx.ok() && sidx != widx && sd->inventory_data[sidx].is_some()) { fixed_1d8.shield = sd->status.inventory[sidx].nameid; } @@ -791,13 +725,13 @@ void clif_set007b(dumb_ptr<map_session_data> sd, Buffer& buf) fixed_1da.hair_style = sd->status.hair; IOff0 widx = sd->equip_index_maybe[EQUIP::WEAPON]; IOff0 sidx = sd->equip_index_maybe[EQUIP::SHIELD]; - if (widx.ok() && sd->inventory_data[widx]) + if (widx.ok() && sd->inventory_data[widx].is_some()) { fixed_1da.weapon = sd->status.inventory[widx].nameid; } else fixed_1da.weapon = ItemNameId(); - if (sidx.ok() && sidx != widx && sd->inventory_data[sidx]) + if (sidx.ok() && sidx != widx && sd->inventory_data[sidx].is_some()) { fixed_1da.shield = sd->status.inventory[sidx].nameid; } @@ -969,7 +903,7 @@ int clif_spawnnpc(dumb_ptr<npc_data> nd) { nullpo_retz(nd); - if (nd->npc_class == NEGATIVE_SPECIES || nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS) + if (nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS) return 0; Packet_Fixed<0x007c> fixed_7c; @@ -1002,7 +936,7 @@ int clif_spawn_fake_npc_for_player(dumb_ptr<map_session_data> sd, BlockId fake_n fixed_7c.speed = interval_t(); fixed_7c.opt1 = Opt1::ZERO; fixed_7c.opt2 = Opt2::ZERO; - fixed_7c.option = Option::ZERO; + fixed_7c.option = Opt0::ZERO; fixed_7c.species = FAKE_NPC_CLASS; fixed_7c.pos.x = sd->bl_x; fixed_7c.pos.y = sd->bl_y; @@ -1013,7 +947,7 @@ int clif_spawn_fake_npc_for_player(dumb_ptr<map_session_data> sd, BlockId fake_n fixed_78.speed = interval_t(); fixed_78.opt1 = Opt1::ZERO; fixed_78.opt2 = Opt2::ZERO; - fixed_78.option = Option::ZERO; + fixed_78.option = Opt0::ZERO; fixed_78.species = FAKE_NPC_CLASS; fixed_78.unused_head_bottom_or_species_again = unwrap<Species>(FAKE_NPC_CLASS); fixed_78.pos.x = sd->bl_x; @@ -1224,7 +1158,6 @@ int clif_npcbuysell(dumb_ptr<map_session_data> sd, BlockId id) */ int clif_buylist(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data_shop> nd) { - struct item_data *id; int i, val; nullpo_retz(sd); @@ -1234,7 +1167,7 @@ int clif_buylist(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data_shop> nd) std::vector<Packet_Repeat<0x00c6>> repeat_c6(nd->shop_items.size()); for (i = 0; i < nd->shop_items.size(); i++) { - id = itemdb_search(nd->shop_items[i].nameid); + P<struct item_data> id = itemdb_search(nd->shop_items[i].nameid); val = nd->shop_items[i].value; repeat_c6[i].base_price = val; // base price repeat_c6[i].actual_price = val; // actual price @@ -1258,9 +1191,11 @@ int clif_selllist(dumb_ptr<map_session_data> sd) std::vector<Packet_Repeat<0x00c7>> repeat_c7; for (IOff0 i : IOff0::iter()) { - if (sd->status.inventory[i].nameid && sd->inventory_data[i]) + if (!sd->status.inventory[i].nameid) + continue; + OMATCH_BEGIN_SOME (sdidi, sd->inventory_data[i]) { - int val = sd->inventory_data[i]->value_sell; + int val = sdidi->value_sell; if (val < 0) continue; Packet_Repeat<0x00c7> info; @@ -1269,6 +1204,7 @@ int clif_selllist(dumb_ptr<map_session_data> sd) info.actual_price = val; repeat_c7.push_back(info); } + OMATCH_END (); } send_packet_repeatonly<0x00c7, 4, 10>(s, repeat_c7); @@ -1379,9 +1315,9 @@ int clif_additem(dumb_ptr<map_session_data> sd, IOff0 n, int amount, PickupFail } else { - if (!n.ok() || !sd->status.inventory[n].nameid - || sd->inventory_data[n] == nullptr) + if (!n.ok() || !sd->status.inventory[n].nameid) return 1; + auto sdidn = TRY_UNWRAP(sd->inventory_data[n], return 1); fixed_a0.ioff2 = n.shift(); fixed_a0.amount = amount; @@ -1396,9 +1332,9 @@ int clif_additem(dumb_ptr<map_session_data> sd, IOff0 n, int amount, PickupFail fixed_a0.card3 = 0; } fixed_a0.epos = pc_equippoint(sd, n); - fixed_a0.item_type = (sd->inventory_data[n]->type == ItemType::_7 + fixed_a0.item_type = (sdidn->type == ItemType::_7 ? ItemType::WEAPON - : sd->inventory_data[n]->type); + : sdidn->type); fixed_a0.pickup_fail = fail; } @@ -1435,17 +1371,18 @@ void clif_itemlist(dumb_ptr<map_session_data> sd) std::vector<Packet_Repeat<0x01ee>> repeat_1ee; for (IOff0 i : IOff0::iter()) { - if (!sd->status.inventory[i].nameid - || sd->inventory_data[i] == nullptr - || itemdb_isequip2(sd->inventory_data[i])) + if (!sd->status.inventory[i].nameid) + continue; + auto sdidi = TRY_UNWRAP(sd->inventory_data[i], continue); + if (itemdb_isequip2(sdidi)) continue; Packet_Repeat<0x01ee> info; info.ioff2 = i.shift(); info.name_id = sd->status.inventory[i].nameid; - info.item_type = sd->inventory_data[i]->type; + info.item_type = sdidi->type; info.identify = 1; info.amount = sd->status.inventory[i].amount; - if (sd->inventory_data[i]->equip == EPOS::ARROW) + if (sdidi->equip == EPOS::ARROW) { info.epos = EPOS::ARROW; if (bool(sd->status.inventory[i].equip)) @@ -1479,17 +1416,18 @@ void clif_equiplist(dumb_ptr<map_session_data> sd) std::vector<Packet_Repeat<0x00a4>> repeat_a4; for (IOff0 i : IOff0::iter()) { - if (!sd->status.inventory[i].nameid - || sd->inventory_data[i] == nullptr - || !itemdb_isequip2(sd->inventory_data[i])) + if (!sd->status.inventory[i].nameid) + continue; + P<struct item_data> sdidi = TRY_UNWRAP(sd->inventory_data[i], continue); + if (!itemdb_isequip2(sdidi)) continue; Packet_Repeat<0x00a4> info; info.ioff2 = i.shift(); info.name_id = sd->status.inventory[i].nameid; info.item_type = ( - sd->inventory_data[i]->type == ItemType::_7 + sdidi->type == ItemType::_7 ? ItemType::WEAPON - : sd->inventory_data[i]->type); + : sdidi->type); info.identify = 0; info.epos_pc = pc_equippoint(sd, i); info.epos_inv = sd->status.inventory[i].equip; @@ -1513,10 +1451,9 @@ void clif_equiplist(dumb_ptr<map_session_data> sd) * カプラさんに預けてある消耗品&収集品リスト *------------------------------------------ */ -int clif_storageitemlist(dumb_ptr<map_session_data> sd, Storage *stor) +int clif_storageitemlist(dumb_ptr<map_session_data> sd, Borrowed<Storage> stor) { nullpo_retz(sd); - nullpo_retz(stor); Session *s = sd->sess; std::vector<Packet_Repeat<0x01f0>> repeat_1f0; @@ -1525,9 +1462,7 @@ int clif_storageitemlist(dumb_ptr<map_session_data> sd, Storage *stor) if (!stor->storage_[i].nameid) continue; - struct item_data *id; - id = itemdb_search(stor->storage_[i].nameid); - nullpo_retz(id); + P<struct item_data> id = itemdb_search(stor->storage_[i].nameid); if (itemdb_isequip2(id)) continue; @@ -1555,10 +1490,9 @@ int clif_storageitemlist(dumb_ptr<map_session_data> sd, Storage *stor) * カプラさんに預けてある装備リスト *------------------------------------------ */ -int clif_storageequiplist(dumb_ptr<map_session_data> sd, Storage *stor) +int clif_storageequiplist(dumb_ptr<map_session_data> sd, Borrowed<Storage> stor) { nullpo_retz(sd); - nullpo_retz(stor); Session *s = sd->sess; std::vector<Packet_Repeat<0x00a6>> repeat_a6; @@ -1567,9 +1501,7 @@ int clif_storageequiplist(dumb_ptr<map_session_data> sd, Storage *stor) if (!stor->storage_[i].nameid) continue; - struct item_data *id; - id = itemdb_search(stor->storage_[i].nameid); - nullpo_retz(id); + P<struct item_data> id = itemdb_search(stor->storage_[i].nameid); if (!itemdb_isequip2(id)) continue; Packet_Repeat<0x00a6> info; @@ -1831,7 +1763,7 @@ int clif_changelook_towards(dumb_ptr<block_list> bl, LOOK type, int val, if (bl->bl_type == BL::PC) sd = bl->is_player(); - if (sd && bool(sd->status.option & Option::INVISIBILITY)) + if (sd && bool(sd->status.option & Opt0::INVISIBILITY)) return 0; if (sd @@ -1845,7 +1777,7 @@ int clif_changelook_towards(dumb_ptr<block_list> bl, LOOK type, int val, fixed_1d7.look_type = type; IOff0 idx = sd->equip_index_maybe[equip_point]; - if (idx.ok() && sd->inventory_data[idx]) + if (idx.ok() && sd->inventory_data[idx].is_some()) { fixed_1d7.weapon_or_name_id_or_value = unwrap<ItemNameId>(sd->status.inventory[idx].nameid); } @@ -1862,14 +1794,14 @@ int clif_changelook_towards(dumb_ptr<block_list> bl, LOOK type, int val, fixed_1d7.weapon_or_name_id_or_value = unwrap<ItemNameId>(sd->attack_spell_look_override); else { - if (widx.ok() && sd->inventory_data[widx]) + if (widx.ok() && sd->inventory_data[widx].is_some()) { fixed_1d7.weapon_or_name_id_or_value = unwrap<ItemNameId>(sd->status.inventory[widx].nameid); } else fixed_1d7.weapon_or_name_id_or_value = unwrap<ItemNameId>(ItemNameId()); } - if (sidx.ok() && sidx != widx && sd->inventory_data[sidx]) + if (sidx.ok() && sidx != widx && sd->inventory_data[sidx].is_some()) { fixed_1d7.shield = sd->status.inventory[sidx].nameid; } @@ -2074,7 +2006,7 @@ int clif_changeoption(dumb_ptr<block_list> bl) nullpo_retz(bl); - Option option = *battle_get_option(bl); + Opt0 option = *battle_get_option(bl); sc_data = battle_get_sc_data(bl); Packet_Fixed<0x0119> fixed_119; @@ -2263,10 +2195,9 @@ int clif_tradecompleted(dumb_ptr<map_session_data> sd, int fail) *------------------------------------------ */ int clif_updatestorageamount(dumb_ptr<map_session_data> sd, - Storage *stor) + Borrowed<Storage> stor) { nullpo_retz(sd); - nullpo_retz(stor); Session *s = sd->sess; Packet_Fixed<0x00f2> fixed_f2; @@ -2281,11 +2212,10 @@ int clif_updatestorageamount(dumb_ptr<map_session_data> sd, * カプラ倉庫にアイテムを追加する *------------------------------------------ */ -int clif_storageitemadded(dumb_ptr<map_session_data> sd, Storage *stor, +int clif_storageitemadded(dumb_ptr<map_session_data> sd, Borrowed<Storage> stor, SOff0 index, int amount) { nullpo_retz(sd); - nullpo_retz(stor); Session *s = sd->sess; Packet_Fixed<0x00f4> fixed_f4; @@ -2357,7 +2287,7 @@ static void clif_getareachar_pc(dumb_ptr<map_session_data> sd, dumb_ptr<map_session_data> dstsd) { - if (bool(dstsd->status.option & Option::INVISIBILITY)) + if (bool(dstsd->status.option & Opt0::INVISIBILITY)) return; nullpo_retv(sd); @@ -2392,7 +2322,7 @@ void clif_getareachar_npc(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data> nd) nullpo_retv(sd); nullpo_retv(nd); - if (nd->npc_class == NEGATIVE_SPECIES || nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS) + if (nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS) return; Buffer buf; @@ -2470,7 +2400,7 @@ int clif_fixpcpos(dumb_ptr<map_session_data> sd) */ int clif_damage(dumb_ptr<block_list> src, dumb_ptr<block_list> dst, tick_t tick, interval_t sdelay, interval_t ddelay, int damage, - int div, DamageType type, int damage2) + int div, DamageType type) { eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data; @@ -2488,7 +2418,7 @@ int clif_damage(dumb_ptr<block_list> src, dumb_ptr<block_list> dst, fixed_8a.damage = (damage > 0x7fff) ? 0x7fff : damage; fixed_8a.div = div; fixed_8a.damage_type = type; - fixed_8a.damage2 = damage2; + fixed_8a.damage2 = 0; Buffer buf = create_fpacket<0x008a, 29>(fixed_8a); clif_send(buf, src, SendWho::AREA); @@ -2686,43 +2616,6 @@ void clif_mobinsight(dumb_ptr<block_list> bl, dumb_ptr<mob_data> md) } /*========================================== - * - *------------------------------------------ - */ -int clif_skillinfo(dumb_ptr<map_session_data> sd, SkillID skillid, int type, - int range) -{ - nullpo_retz(sd); - - Session *s = sd->sess; - if (!sd->status.skill[skillid].lv) - return 0; - Packet_Fixed<0x0147> fixed_147; - fixed_147.info.skill_id = skillid; - if (type < 0) - fixed_147.info.type_or_inf = skill_get_inf(skillid); - else - fixed_147.info.type_or_inf = type; - fixed_147.info.flags = SkillFlags::ZERO; - fixed_147.info.level = sd->status.skill[skillid].lv; - fixed_147.info.sp = skill_get_sp(skillid, sd->status.skill[skillid].lv); - if (range < 0) - { - range = skill_get_range(skillid, sd->status.skill[skillid].lv); - if (range < 0) - range = battle_get_range(sd) - (range + 1); - fixed_147.info.range = range; - } - else - fixed_147.info.range = range; - fixed_147.info.unused = ""_s; - fixed_147.info.can_raise = sd->status.skill[skillid].lv < skill_get_max_raise(skillid); - send_fpacket<0x0147, 39>(s, fixed_147); - - return 0; -} - -/*========================================== * スキルリストを送信する *------------------------------------------ */ @@ -2971,8 +2864,6 @@ int clif_party_info(PartyPair p, Session *s) int i; dumb_ptr<map_session_data> sd = nullptr; - nullpo_retz(p); - Packet_Head<0x00fb> head_fb; std::vector<Packet_Repeat<0x00fb>> repeat_fb; head_fb.party_name = p->name; @@ -3018,15 +2909,12 @@ int clif_party_info(PartyPair p, Session *s) void clif_party_invite(dumb_ptr<map_session_data> sd, dumb_ptr<map_session_data> tsd) { - PartyPair p; - nullpo_retv(sd); nullpo_retv(tsd); Session *s = tsd->sess; - if (!(p = party_search(sd->status.party_id))) - return; + PartyPair p = TRY_UNWRAP(party_search(sd->status.party_id), return); Packet_Fixed<0x00fe> fixed_fe; fixed_fe.account_id = sd->status_key.account_id; @@ -3068,8 +2956,6 @@ void clif_party_inviteack(dumb_ptr<map_session_data> sd, CharName nick, int flag */ void clif_party_option(PartyPair p, dumb_ptr<map_session_data> sd, int flag) { - nullpo_retv(p); - if (sd == nullptr && flag == 0) { int i; @@ -3102,8 +2988,6 @@ void clif_party_leaved(PartyPair p, dumb_ptr<map_session_data> sd, { int i; - nullpo_retv(p); - Packet_Fixed<0x0105> fixed_105; fixed_105.account_id = account_id; fixed_105.char_name = name; @@ -3140,8 +3024,6 @@ void clif_party_message(PartyPair p, AccountId account_id, XString mes) dumb_ptr<map_session_data> sd = nullptr; int i; - nullpo_retv(p); - for (i = 0; i < MAX_PARTY; i++) { sd = dumb_ptr<map_session_data>(p->member[i].sd); @@ -3214,21 +3096,6 @@ int clif_movetoattack(dumb_ptr<map_session_data> sd, dumb_ptr<block_list> bl) } /*========================================== - * MVPエフェクト - *------------------------------------------ - */ -int clif_mvp_effect(dumb_ptr<map_session_data> sd) -{ - nullpo_retz(sd); - - Packet_Fixed<0x010c> fixed_10c; - fixed_10c.block_id = sd->bl_id; - Buffer buf = create_fpacket<0x010c, 6>(fixed_10c); - clif_send(buf, sd, SendWho::AREA); - return 0; -} - -/*========================================== * エモーション *------------------------------------------ */ @@ -3243,7 +3110,6 @@ void clif_emotion(dumb_ptr<block_list> bl, int type) clif_send(buf, bl, SendWho::AREA); } -static void clif_emotion_towards(dumb_ptr<block_list> bl, dumb_ptr<block_list> target, int type) { @@ -3442,9 +3308,9 @@ RecvResult clif_parse_LoadEndAck(Session *s, dumb_ptr<map_session_data> sd) // 119 // 78 - if (battle_config.player_invincible_time > 0) + if (battle_config.player_invincible_time > interval_t::zero()) { - pc_setinvincibletimer(sd, static_cast<interval_t>(battle_config.player_invincible_time)); + pc_setinvincibletimer(sd, battle_config.player_invincible_time); } map_addblock(sd); // ブロック登録 @@ -3467,7 +3333,6 @@ RecvResult clif_parse_LoadEndAck(Session *s, dumb_ptr<map_session_data> sd) std::bind(pc_calc_pvprank_timer, ph::_1, ph::_2, sd->bl_id)); sd->pvp_rank = 0; - sd->pvp_lastusers = 0; sd->pvp_point = 5; } } @@ -3642,16 +3507,20 @@ RecvResult clif_parse_GetCharNameRequest(Session *s, dumb_ptr<map_session_data> fixed_95.char_name = ssd->status_key.name; send_fpacket<0x0095, 30>(s, fixed_95); - PartyPair p; - PartyName party_name; int send = 0; - if (ssd->status.party_id && (p = party_search(ssd->status.party_id))) + if (ssd->status.party_id) { - party_name = p->name; - send = 1; + Option<PartyPair> p_ = party_search(ssd->status.party_id); + + OMATCH_BEGIN_SOME (p, p_) + { + party_name = p->name; + send = 1; + } + OMATCH_END (); } if (send) @@ -3665,7 +3534,7 @@ RecvResult clif_parse_GetCharNameRequest(Session *s, dumb_ptr<map_session_data> send_fpacket<0x0195, 102>(s, fixed_195); } - if (pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.hack_info_GM_level)))) + if (pc_isGM(sd).satisfies(battle_config.hack_info_GM_level)) { IP4Address ip = ssd->get_ip(); Packet_Fixed<0x020c> fixed_20c; @@ -3853,25 +3722,6 @@ RecvResult clif_parse_Emotion(Session *s, dumb_ptr<map_session_data> sd) *------------------------------------------ */ static -RecvResult clif_parse_HowManyConnections(Session *s, dumb_ptr<map_session_data>) -{ - Packet_Fixed<0x00c1> fixed; - RecvResult rv = recv_fpacket<0x00c1, 2>(s, fixed); - if (rv != RecvResult::Complete) - return rv; - - Packet_Fixed<0x00c2> fixed_c2; - fixed_c2.users = map_getusers(); - send_fpacket<0x00c2, 6>(s, fixed_c2); - - return rv; -} - -/*========================================== - * - *------------------------------------------ - */ -static RecvResult clif_parse_ActionRequest(Session *s, dumb_ptr<map_session_data> sd) { Packet_Fixed<0x0089> fixed; @@ -3904,7 +3754,7 @@ RecvResult clif_parse_ActionRequest(Session *s, dumb_ptr<map_session_data> sd) { case DamageType::NORMAL: case DamageType::CONTINUOUS: - if (bool(sd->status.option & Option::HIDE)) + if (bool(sd->status.option & Opt0::HIDE)) return rv; if (!battle_config.skill_delay_attack_enable) { @@ -4046,7 +3896,7 @@ RecvResult clif_parse_Wis(Session *s, dumb_ptr<map_session_data> sd) if (dstsd->sess == s) { ZString mes = "You cannot page yourself."_s; - clif_wis_message(s, wisp_server_name, mes); + clif_wis_message(s, WISP_SERVER_NAME, mes); } else { @@ -4199,15 +4049,16 @@ RecvResult clif_parse_EquipItem(Session *s, dumb_ptr<map_session_data> sd) if (sd->npc_id) return rv; - if (sd->inventory_data[index]) + OMATCH_BEGIN_SOME (sdidi, sd->inventory_data[index]) { EPOS epos = fixed.epos_ignored; - if (sd->inventory_data[index]->type == ItemType::ARROW) + if (sdidi->type == ItemType::ARROW) epos = EPOS::ARROW; // Note: the EPOS argument to pc_equipitem is actually ignored pc_equipitem(sd, index, epos); } + OMATCH_END (); return rv; } @@ -4816,6 +4667,60 @@ RecvResult clif_parse_PartyMessage(Session *s, dumb_ptr<map_session_data> sd) return rv; } +void clif_sendallquest(dumb_ptr<map_session_data> sd) +{ + int i; + QuestId questid; + if (!sd) + return; + + if (!sd->sess) + return; + + Session *s = sd->sess; + Packet_Head<0x0215> head_215; + std::vector<Packet_Repeat<0x0215>> repeat_215; + + assert (sd->status.global_reg_num < GLOBAL_REG_NUM); + for (QuestId q = wrap<QuestId>(0); q < wrap<QuestId>(-1); q = next(q)) + { + P<struct quest_data> quest_data_ = TRY_UNWRAP(questdb_exists(q), continue); + for (i = 0; i < sd->status.global_reg_num; i++) + { + if (sd->status.global_reg[i].str == quest_data_->quest_vr) + { + int val = ((sd->status.global_reg[i].value & (((1 << quest_data_->quest_mask) - 1) << (quest_data_->quest_shift * quest_data_->quest_mask))) >> (quest_data_->quest_shift * quest_data_->quest_mask)); + Packet_Repeat<0x0215> info; + info.variable = unwrap<QuestId>(quest_data_->questid); + info.value = val; + repeat_215.push_back(info); + break; + } + } + } + + send_vpacket<0x0215, 4, 6>(s, head_215, repeat_215); + return; +} + +void clif_sendquest(dumb_ptr<map_session_data> sd, QuestId questid, int value) +{ + if (!sd) + return; + + if (!sd->sess) + return; + + Session *s = sd->sess; + + Packet_Fixed<0x0214> fixed; + fixed.variable = unwrap<QuestId>(questid); + fixed.value = value; + send_fpacket<0x0214, 8>(s, fixed); + return; +} + + func_table clif_parse_func_table[0x0220] = { {0, 10, nullptr, }, // 0x0000 @@ -5011,7 +4916,7 @@ func_table clif_parse_func_table[0x0220] = {0, 5, nullptr, }, // 0x00be {1000, 3, clif_parse_Emotion, }, // 0x00bf {0, 7, nullptr, }, // 0x00c0 - {0, 2, clif_parse_HowManyConnections, }, // 0x00c1 + {0, 2, nullptr, }, // 0x00c1 {0, 6, nullptr, }, // 0x00c2 {0, 8, nullptr, }, // 0x00c3 {0, 6, nullptr, }, // 0x00c4 @@ -5431,12 +5336,10 @@ uint16_t clif_check_packet_flood(Session *s, int cmd) // They are flooding if (tick < sd->flood_rates[cmd] + rate) { - TimeT now = TimeT::now(); - // If it's a nasty flood we log and possibly kick - if (now > sd->packet_flood_reset_due) + if (tick > sd->packet_flood_reset_due) { - sd->packet_flood_reset_due = static_cast<time_t>(now) + battle_config.packet_spam_threshold; + sd->packet_flood_reset_due = tick + battle_config.packet_spam_threshold; sd->packet_flood_in = 0; } @@ -5638,7 +5541,6 @@ unknown_packet: PRINTF("\nclif_parse: session #%d, packet 0x%x, lenght %zu\n"_fmt, s, packet_id, packet_avail(s)); { - ZString packet_txt = "save/packet.txt"_s; if (sd && sd->state.auth) { PRINTF("Unknown packet: Account ID %d, character ID %d, player name %s.\n"_fmt, @@ -5650,35 +5552,27 @@ unknown_packet: else PRINTF("Unknown packet (unknown)\n"_fmt); - io::AppendFile fp(packet_txt); - if (!fp.is_open()) - { - PRINTF("clif.c: cant write [%s] !!! data is lost !!!\n"_fmt, - packet_txt); - return; - } - else { timestamp_seconds_buffer now; stamp_time(now); if (sd && sd->state.auth) { - FPRINTF(fp, + FPRINTF(stderr, "%s\nPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n"_fmt, now, sd->status_key.account_id, sd->status_key.char_id, sd->status_key.name); } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified) - FPRINTF(fp, + FPRINTF(stderr, "%s\nUnauthenticated player with account ID %d sent wrong packet:\n"_fmt, now, sd->bl_id); else - FPRINTF(fp, + FPRINTF(stderr, "%s\nUnknown connection sent wrong packet:\n"_fmt, now); - packet_dump(fp, s); + packet_dump(s); } } } @@ -5687,6 +5581,7 @@ unknown_packet: void do_init_clif(void) { - make_listen_port(map_port, SessionParsers{.func_parse= clif_parse, .func_delete= clif_delete}); + make_listen_port(map_conf.map_port, SessionParsers{.func_parse= clif_parse, .func_delete= clif_delete}); } +} // namespace map } // namespace tmwa |