From 08809eeb1db043ac72ca8a64f74e9f5ed6a54631 Mon Sep 17 00:00:00 2001 From: mekolat Date: Fri, 22 May 2015 13:09:14 -0400 Subject: add map mask support --- src/map/clif.cpp | 16 ++++++++++++++++ src/map/clif.hpp | 1 + src/map/map.hpp | 1 + src/map/mapflag.cpp | 2 +- src/map/mapflag.hpp | 2 +- src/map/mapflag.py | 2 +- src/map/npc-parse.cpp | 15 ++++++++++++++- src/map/pc.cpp | 3 +++ src/map/script-fun.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 84 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/map/clif.cpp b/src/map/clif.cpp index db5ecd2..35cc463 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -1155,6 +1155,9 @@ void clif_changemap(dumb_ptr sd, MapName mapname, int x, int y fixed_91.x = x; fixed_91.y = y; send_fpacket<0x0091, 22>(s, fixed_91); + + if(sd->bl_m->mask > 0) + clif_send_mask(sd, sd->bl_m->mask); } /*========================================== @@ -3873,6 +3876,19 @@ void clif_message(dumb_ptr bl, XString msg) clif_send(buf, bl, SendWho::AREA, MIN_CLIENT_VERSION); } +void clif_send_mask(dumb_ptr sd, int map_mask) +{ + nullpo_retv(sd); + if(sd->client_version < 2) + return; + + Packet_Fixed<0x0226> fixed_226; + fixed_226.mask = map_mask; + + Buffer buf = create_fpacket<0x0226, 10>(fixed_226); + send_buffer(sd->sess, buf); +} + /*========================================== * *------------------------------------------ diff --git a/src/map/clif.hpp b/src/map/clif.hpp index cd499de..28f58a9 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -107,6 +107,7 @@ void clif_setnpcdirection_towards(dumb_ptr sd, dumb_ptr sd, XString music); void clif_npc_action(dumb_ptr, BlockId, short, int, short, short); +void clif_send_mask(dumb_ptr, int); // trade void clif_traderequest(dumb_ptr sd, CharName name); diff --git a/src/map/map.hpp b/src/map/map.hpp index 2b638d4..aea35b7 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -505,6 +505,7 @@ struct map_local : map_abstract MapFlags flag; Point save; Point resave; + int mask; Array, MAX_NPC_PER_MAP> npc; }; diff --git a/src/map/mapflag.cpp b/src/map/mapflag.cpp index 9f3c9ab..22c4878 100644 --- a/src/map/mapflag.cpp +++ b/src/map/mapflag.cpp @@ -71,7 +71,7 @@ bool impl_extract(XString str, MapFlag *mf) {"nowarp"_s, MapFlag::NOWARP}, {"nowarpto"_s, MapFlag::NOWARPTO}, {"nopvp"_s, MapFlag::NOPVP}, - //{"noicewall"_s, MapFlag::NOICEWALL}, + {"mask"_s, MapFlag::MASK}, {"snow"_s, MapFlag::SNOW}, {"fog"_s, MapFlag::FOG}, {"sakura"_s, MapFlag::SAKURA}, diff --git a/src/map/mapflag.hpp b/src/map/mapflag.hpp index 3538c56..9223d70 100644 --- a/src/map/mapflag.hpp +++ b/src/map/mapflag.hpp @@ -54,7 +54,7 @@ enum class MapFlag NOWARP = 1 << 13, NOWARPTO = 1 << 26, NOPVP = 1 << 14, - //NOICEWALL = 1 << 15, + MASK = 1 << 15, SNOW = 1 << 16, FOG = 1 << 17, SAKURA = 1 << 18, diff --git a/src/map/mapflag.py b/src/map/mapflag.py index b0a2f24..728aa81 100644 --- a/src/map/mapflag.py +++ b/src/map/mapflag.py @@ -40,7 +40,7 @@ class MapFlags(object): ('NOWARP', 13), ('NOWARPTO', 26), ('NOPVP', 14), - #('NOICEWALL', 15), + ('MASK', 15), ('SNOW', 16), ('FOG', 17), ('SAKURA', 18), diff --git a/src/map/npc-parse.cpp b/src/map/npc-parse.cpp index 0a0d682..9ee84d2 100644 --- a/src/map/npc-parse.cpp +++ b/src/map/npc-parse.cpp @@ -354,7 +354,7 @@ bool npc_load_mapflag(ast::npc::MapFlag& mapflag) } MapName savemap; - int savex, savey; + int savex, savey, mask; if (mf == MapFlag::NOSAVE) { @@ -392,6 +392,19 @@ bool npc_load_mapflag(ast::npc::MapFlag& mapflag) return false; } } + else if (mf == MapFlag::MASK) + { + if (mapflag.vec_extra.data.size() == 1 + && extract(mapflag.vec_extra.data[0].data, &mask)) + { + m->mask = mask; + } + else + { + mapflag.vec_extra.span.error("Unable to extract map mask"_s); + return false; + } + } else { if (mapflag.vec_extra.data.size()) diff --git a/src/map/pc.cpp b/src/map/pc.cpp index ca636b4..96233e1 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -796,6 +796,9 @@ int pc_authok(AccountId id, int login_id2, pc_calcstatus(sd, 1); + if(sd->bl_m->mask > 0) + clif_send_mask(sd, sd->bl_m->mask); + // Init Quest Log clif_sendallquest(sd); return 0; diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 2b72fc4..2822550 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -2704,6 +2704,50 @@ void builtin_music(ScriptState *st) clif_change_music(sd, msg); } +static +void builtin_mapmask(ScriptState *st) +{ + dumb_ptr nd; + dumb_ptr sd; + int map_mask = conv_num(st, &AARG(0)); + + if(st->oid) + nd = map_id_is_npc(st->oid); + if(st->rid) + sd = script_rid2sd(st); + + if(HARG(1) && sd != nullptr) + sd->bl_m->mask = map_mask; + else if(HARG(1) && nd) + nd->bl_m->mask = map_mask; + + if (sd == nullptr) + return; + clif_send_mask(sd, map_mask); +} + +static +void builtin_getmask(ScriptState *st) +{ + dumb_ptr nd; + dumb_ptr sd; + int map_mask; + + if(st->oid) + nd = map_id_is_npc(st->oid); + if(st->rid) + sd = script_rid2sd(st); + + if(sd != nullptr) + map_mask = sd->bl_m->mask; + else if(nd) + map_mask = nd->bl_m->mask; + else + map_mask = -1; + + push_int(st->stack, map_mask); +} + /*========================================== * npctalk (sends message to surrounding * area) [Valaris] @@ -3188,6 +3232,8 @@ BuiltinFunction builtin_functions[] = BUILTIN(npctalk, "ss?"_s, '\0'), BUILTIN(title, "s"_s, '\0'), BUILTIN(music, "s"_s, '\0'), + BUILTIN(mapmask, "i?"_s, '\0'), + BUILTIN(getmask, ""_s, 'i'), BUILTIN(getlook, "i"_s, 'i'), BUILTIN(getsavepoint, "i"_s, '.'), BUILTIN(areatimer, "MxyxytE"_s, '\0'), -- cgit v1.2.3-60-g2f50