diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main-gdb-head.py | 9 | ||||
-rw-r--r-- | src/map/atcommand.cpp | 80 | ||||
-rw-r--r-- | src/map/battle.cpp | 4 | ||||
-rw-r--r-- | src/map/clif.cpp | 14 | ||||
-rw-r--r-- | src/map/magic-stmt.cpp | 4 | ||||
-rw-r--r-- | src/map/map.cpp | 2 | ||||
-rw-r--r-- | src/map/mapflag.cpp | 110 | ||||
-rw-r--r-- | src/map/mapflag.hpp | 85 | ||||
-rw-r--r-- | src/map/mapflag.py | 51 | ||||
-rw-r--r-- | src/map/mob.cpp | 6 | ||||
-rw-r--r-- | src/map/npc.cpp | 4 | ||||
-rw-r--r-- | src/map/pc.cpp | 12 | ||||
-rw-r--r-- | src/map/script.cpp | 26 |
13 files changed, 173 insertions, 234 deletions
diff --git a/src/main-gdb-head.py b/src/main-gdb-head.py index 75e43bf..8c6fe08 100644 --- a/src/main-gdb-head.py +++ b/src/main-gdb-head.py @@ -5,7 +5,7 @@ # gdb sticks everything in one scope. # This lets us enumerate what *we* added. -initial_globals = set(globals()) +initial_globals = {id(v):v for v in globals().itervalues()} import re @@ -32,15 +32,16 @@ def get_basic_type(type_): def finish(): global finish, initial_globals, FastPrinters - diff = set(globals()) - initial_globals \ + final_globals = {id(v):v for v in globals().itervalues()} + diff = final_globals.viewkeys() - initial_globals.viewkeys() \ - {'finish', 'initial_globals', 'FastPrinters'} fp = FastPrinters() # After this, don't access any more globals in this function. del finish, initial_globals, FastPrinters - for k in diff: - v = globals()[k] + for i in diff: + v = final_globals[i] if hasattr(v, 'children') or hasattr(v, 'to_string'): fp.add_printer(v) diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index ef94963..6cb1425 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -492,14 +492,14 @@ ATCE atcommand_charwarp(Session *s, dumb_ptr<map_session_data> sd, if (x > 0 && x < 800 && y > 0 && y < 800) { map_local *m = map_mapname2mapid(map_name); - if (m != nullptr && m->flag.nowarpto + if (m != nullptr && m->flag.get(MapFlag::NOWARPTO) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, "You are not authorised to warp someone to this map."); return ATCE::PERM; } - if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarp + if (pl_sd->bl_m && pl_sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, @@ -561,14 +561,14 @@ ATCE atcommand_warp(Session *s, dumb_ptr<map_session_data> sd, if (x > 0 && x < 800 && y > 0 && y < 800) { map_local *m = map_mapname2mapid(map_name); - if (m != nullptr && m->flag.nowarpto + if (m != nullptr && m->flag.get(MapFlag::NOWARPTO) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, "You are not authorised to warp you to this map."); return ATCE::PERM; } - if (sd->bl_m && sd->bl_m->flag.nowarp + if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, @@ -636,14 +636,14 @@ ATCE atcommand_goto(Session *s, dumb_ptr<map_session_data> sd, dumb_ptr<map_session_data> pl_sd = map_nick2sd(character); if (pl_sd != NULL) { - if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarpto + if (pl_sd->bl_m && pl_sd->bl_m->flag.get(MapFlag::NOWARPTO) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, "You are not authorised to warp you to the map of this player."); return ATCE::PERM; } - if (sd->bl_m && sd->bl_m->flag.nowarp + if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, @@ -677,14 +677,14 @@ ATCE atcommand_jump(Session *s, dumb_ptr<map_session_data> sd, y = random_::in(1, 399); if (x > 0 && x < 800 && y > 0 && y < 800) { - if (sd->bl_m && sd->bl_m->flag.nowarpto + if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARPTO) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, "You are not authorised to warp you to your actual map."); return ATCE::PERM; } - if (sd->bl_m && sd->bl_m->flag.nowarp + if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, @@ -1039,14 +1039,14 @@ ATCE atcommand_load(Session *s, dumb_ptr<map_session_data> sd, ZString) { map_local *m = map_mapname2mapid(sd->status.save_point.map_); - if (m != nullptr && m->flag.nowarpto + if (m != nullptr && m->flag.get(MapFlag::NOWARPTO) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, "You are not authorised to warp you to your save map."); return ATCE::PERM; } - if (sd->bl_m && sd->bl_m->flag.nowarp + if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, @@ -1519,9 +1519,9 @@ ATCE atcommand_pvpoff(Session *s, dumb_ptr<map_session_data> sd, return ATCE::EXIST; } - if (sd->bl_m->flag.pvp) + if (sd->bl_m->flag.get(MapFlag::PVP)) { - sd->bl_m->flag.pvp = 0; + sd->bl_m->flag.set(MapFlag::PVP, 0); for (io::FD i : iter_fds()) { Session *s2 = get_session(i); @@ -1558,9 +1558,9 @@ ATCE atcommand_pvpon(Session *s, dumb_ptr<map_session_data> sd, return ATCE::EXIST; } - if (!sd->bl_m->flag.pvp && !sd->bl_m->flag.nopvp) + if (!sd->bl_m->flag.get(MapFlag::PVP) && !sd->bl_m->flag.get(MapFlag::NOPVP)) { - sd->bl_m->flag.pvp = 1; + sd->bl_m->flag.set(MapFlag::PVP, 1); for (io::FD i : iter_fds()) { Session *s2 = get_session(i); @@ -2034,14 +2034,14 @@ ATCE atcommand_recall(Session *s, dumb_ptr<map_session_data> sd, if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level - if (sd->bl_m && sd->bl_m->flag.nowarpto + if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARPTO) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, "You are not authorised to warp somenone to your actual map."); return ATCE::PERM; } - if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarp + if (pl_sd->bl_m && pl_sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, @@ -2365,7 +2365,7 @@ ATCE atcommand_character_save(Session *s, dumb_ptr<map_session_data> sd, } else { - if (m != nullptr && m->flag.nowarpto + if (m != nullptr && m->flag.get(MapFlag::NOWARPTO) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, @@ -3309,7 +3309,7 @@ ATCE atcommand_recallall(Session *s, dumb_ptr<map_session_data> sd, { int count; - if (sd->bl_m && sd->bl_m->flag.nowarpto + if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARPTO) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, @@ -3330,7 +3330,7 @@ ATCE atcommand_recallall(Session *s, dumb_ptr<map_session_data> sd, && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level - if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarp + if (pl_sd->bl_m && pl_sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) count++; else @@ -3361,7 +3361,7 @@ ATCE atcommand_partyrecall(Session *s, dumb_ptr<map_session_data> sd, if (!extract(message, &party_name) || !party_name) return ATCE::USAGE; - if (sd->bl_m && sd->bl_m->flag.nowarpto + if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARPTO) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, @@ -3384,7 +3384,7 @@ ATCE atcommand_partyrecall(Session *s, dumb_ptr<map_session_data> sd, && sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party_id) { - if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarp + if (pl_sd->bl_m && pl_sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) count++; else @@ -3440,23 +3440,23 @@ ATCE atcommand_mapinfo(Session *s, dumb_ptr<map_session_data> sd, clif_displaymessage(s, output); clif_displaymessage(s, "------ Map Flags ------"); output = STRPRINTF("Player vs Player: %s | No Party: %s", - (m_id->flag.pvp) ? "True" : "False", - (m_id->flag.pvp_noparty) ? "True" : "False"); + (m_id->flag.get(MapFlag::PVP)) ? "True" : "False", + (m_id->flag.get(MapFlag::PVP_NOPARTY)) ? "True" : "False"); clif_displaymessage(s, output); output = STRPRINTF("No Penalty: %s", - (m_id->flag.nopenalty) ? "True" : "False"); + (m_id->flag.get(MapFlag::NOPENALTY)) ? "True" : "False"); clif_displaymessage(s, output); output = STRPRINTF("No Return: %s", - (m_id->flag.noreturn) ? "True" : "False"); + (m_id->flag.get(MapFlag::NORETURN)) ? "True" : "False"); clif_displaymessage(s, output); output = STRPRINTF("No Save: %s", - (m_id->flag.nosave) ? "True" : "False"); + (m_id->flag.get(MapFlag::NOSAVE)) ? "True" : "False"); clif_displaymessage(s, output); output = STRPRINTF("No Teleport: %s", - (m_id->flag.noteleport) ? "True" : "False"); + (m_id->flag.get(MapFlag::NOTELEPORT)) ? "True" : "False"); clif_displaymessage(s, output); output = STRPRINTF("No Monster Teleport: %s", - (m_id->flag.monster_noteleport) ? "True" : "False"); + (m_id->flag.get(MapFlag::MONSTER_NOTELEPORT)) ? "True" : "False"); clif_displaymessage(s, output); switch (list) @@ -4470,10 +4470,10 @@ ATCE atcommand_rain(Session *, dumb_ptr<map_session_data> sd, { int effno = 0; effno = 161; - if (effno < 0 || sd->bl_m->flag.rain) + if (effno < 0 || sd->bl_m->flag.get(MapFlag::RAIN)) return ATCE::EXIST; - sd->bl_m->flag.rain = 1; + sd->bl_m->flag.set(MapFlag::RAIN, 1); clif_specialeffect(sd, effno, 2); return ATCE::OKAY; } @@ -4484,10 +4484,10 @@ ATCE atcommand_snow(Session *, dumb_ptr<map_session_data> sd, { int effno = 0; effno = 162; - if (effno < 0 || sd->bl_m->flag.snow) + if (effno < 0 || sd->bl_m->flag.get(MapFlag::SNOW)) return ATCE::EXIST; - sd->bl_m->flag.snow = 1; + sd->bl_m->flag.set(MapFlag::SNOW, 1); clif_specialeffect(sd, effno, 2); return ATCE::OKAY; } @@ -4498,10 +4498,10 @@ ATCE atcommand_sakura(Session *, dumb_ptr<map_session_data> sd, { int effno = 0; effno = 163; - if (effno < 0 || sd->bl_m->flag.sakura) + if (effno < 0 || sd->bl_m->flag.get(MapFlag::SAKURA)) return ATCE::EXIST; - sd->bl_m->flag.sakura = 1; + sd->bl_m->flag.set(MapFlag::SAKURA, 1); clif_specialeffect(sd, effno, 2); return ATCE::OKAY; } @@ -4512,10 +4512,10 @@ ATCE atcommand_fog(Session *, dumb_ptr<map_session_data> sd, { int effno = 0; effno = 233; - if (effno < 0 || sd->bl_m->flag.fog) + if (effno < 0 || sd->bl_m->flag.get(MapFlag::FOG)) return ATCE::EXIST; - sd->bl_m->flag.fog = 1; + sd->bl_m->flag.set(MapFlag::FOG, 1); clif_specialeffect(sd, effno, 2); return ATCE::OKAY; @@ -4527,10 +4527,10 @@ ATCE atcommand_leaves(Session *, dumb_ptr<map_session_data> sd, { int effno = 0; effno = 333; - if (effno < 0 || sd->bl_m->flag.leaves) + if (effno < 0 || sd->bl_m->flag.get(MapFlag::LEAVES)) return ATCE::EXIST; - sd->bl_m->flag.leaves = 1; + sd->bl_m->flag.set(MapFlag::LEAVES, 1); clif_specialeffect(sd, effno, 2); return ATCE::OKAY; } @@ -4821,14 +4821,14 @@ ATCE atcommand_jump_iterate(Session *s, dumb_ptr<map_session_data> sd, pl_sd = get_start(); } - if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarpto + if (pl_sd->bl_m && pl_sd->bl_m->flag.get(MapFlag::NOWARPTO) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, "You are not authorised to warp you to the map of this player."); return ATCE::PERM; } - if (sd->bl_m && sd->bl_m->flag.nowarp + if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, diff --git a/src/map/battle.cpp b/src/map/battle.cpp index d1e79ef..3830c0f 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -2236,12 +2236,12 @@ int battle_check_target(dumb_ptr<block_list> src, dumb_ptr<block_list> target, if (ss->bl_type == BL::PC && target->bl_type == BL::PC) { // 両方PVPモードなら否定(敵) - if (ss->bl_m->flag.pvp + if (ss->bl_m->flag.get(MapFlag::PVP) || pc_iskiller(ss->is_player(), target->is_player())) { // [MouseJstr] if (battle_config.pk_mode) return 1; // prevent novice engagement in pk_mode [Valaris] - else if (ss->bl_m->flag.pvp_noparty && s_p > 0 && t_p > 0 + else if (ss->bl_m->flag.get(MapFlag::PVP_NOPARTY) && s_p > 0 && t_p > 0 && s_p == t_p) return 1; return 0; diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 3fc716d..5355192 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -887,15 +887,15 @@ int clif_spawnpc(dumb_ptr<map_session_data> sd) WBUFW(buf, 51) = 0; clif_send(buf, clif_parse_func_table[0x1d9].len, sd, SendWho::AREA_WOS); - if (sd->bl_m->flag.snow) + if (sd->bl_m->flag.get(MapFlag::SNOW)) clif_specialeffect(sd, 162, 1); - if (sd->bl_m->flag.fog) + if (sd->bl_m->flag.get(MapFlag::FOG)) clif_specialeffect(sd, 233, 1); - if (sd->bl_m->flag.sakura) + if (sd->bl_m->flag.get(MapFlag::SAKURA)) clif_specialeffect(sd, 163, 1); - if (sd->bl_m->flag.leaves) + if (sd->bl_m->flag.get(MapFlag::LEAVES)) clif_specialeffect(sd, 333, 1); - if (sd->bl_m->flag.rain) + if (sd->bl_m->flag.get(MapFlag::RAIN)) clif_specialeffect(sd, 161, 1); // clif_changelook_accessories(sd, NULL); @@ -3512,7 +3512,7 @@ void clif_parse_LoadEndAck(Session *, dumb_ptr<map_session_data> sd) if (!battle_config.pk_mode) sd->pvp_timer.cancel(); - if (sd->bl_m->flag.pvp) + if (sd->bl_m->flag.get(MapFlag::PVP)) { if (!battle_config.pk_mode) { @@ -4122,7 +4122,7 @@ void clif_parse_DropItem(Session *s, dumb_ptr<map_session_data> sd) clif_clearchar(sd, BeingRemoveWhy::DEAD); return; } - if (sd->bl_m->flag.no_player_drops) + if (sd->bl_m->flag.get(MapFlag::NO_PLAYER_DROPS)) { clif_displaymessage(sd->sess, "Can't drop items here."); return; diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp index 945faa9..1905871 100644 --- a/src/map/magic-stmt.cpp +++ b/src/map/magic-stmt.cpp @@ -772,7 +772,7 @@ int op_injure(dumb_ptr<env_t> env, const_array<val_t> args) int mdef = battle_get_mdef(target); if (target->bl_type == BL::PC - && !target->bl_m->flag.pvp + && !target->bl_m->flag.get(MapFlag::PVP) && !target->is_player()->special_state.killable && (caster->bl_type != BL::PC || !caster->is_player()->special_state.killer)) return 0; /* Cannot damage other players outside of pvp */ @@ -1088,7 +1088,7 @@ void find_entities_in_area_c(dumb_ptr<block_list> target, if (filter == FOREACH_FILTER::PC || filter == FOREACH_FILTER::ENTITY || (filter == FOREACH_FILTER::TARGET - && target->bl_m->flag.pvp)) + && target->bl_m->flag.get(MapFlag::PVP))) break; else if (filter == FOREACH_FILTER::SPELL) { /* Check all spells bound to the caster */ diff --git a/src/map/map.cpp b/src/map/map.cpp index caab5b4..a063d2b 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -1258,7 +1258,7 @@ bool map_readmap(map_local *m, size_t num, MapName fn) m->users = 0; really_memzero_this(&m->flag); if (battle_config.pk_mode) - m->flag.pvp = 1; // make all maps pvp for pk_mode [Valaris] + m->flag.set(MapFlag::PVP, 1); MapCell *gat_m = reinterpret_cast<MapCell *>(&gat_v[4]); std::copy(gat_m, gat_m + s, &m->gat[0]); diff --git a/src/map/mapflag.cpp b/src/map/mapflag.cpp index 4b7b305..73d46f1 100644 --- a/src/map/mapflag.cpp +++ b/src/map/mapflag.cpp @@ -24,110 +24,15 @@ bool MapFlags::get(MapFlag mf) const { - switch (mf) - { - case MapFlag::NOTELEPORT: - return noteleport; - case MapFlag::NORETURN: - return noreturn; - case MapFlag::MONSTER_NOTELEPORT: - return monster_noteleport; - case MapFlag::NOSAVE: - return nosave; - case MapFlag::NOPENALTY: - return nopenalty; - case MapFlag::PVP: - return pvp; - case MapFlag::PVP_NOPARTY: - return pvp_noparty; - case MapFlag::PVP_NOCALCRANK: - return pvp_nocalcrank; - case MapFlag::NOWARP: - return nowarp; - case MapFlag::NOWARPTO: - return nowarpto; - case MapFlag::NOPVP: - return nopvp; - case MapFlag::SNOW: - return snow; - case MapFlag::FOG: - return fog; - case MapFlag::SAKURA: - return sakura; - case MapFlag::LEAVES: - return leaves; - case MapFlag::RAIN: - return rain; - case MapFlag::NO_PLAYER_DROPS: - return no_player_drops; - case MapFlag::TOWN: - return town; - default: - return false; - } + return flags & static_cast<unsigned>(mf); } void MapFlags::set(MapFlag mf, bool val) { - switch (mf) - { - case MapFlag::NOTELEPORT: - noteleport = val; - break; - case MapFlag::NORETURN: - noreturn = val; - break; - case MapFlag::MONSTER_NOTELEPORT: - monster_noteleport = val; - break; - case MapFlag::NOSAVE: - nosave = val; - break; - case MapFlag::NOPENALTY: - nopenalty = val; - break; - case MapFlag::PVP: - pvp = val; - break; - case MapFlag::PVP_NOPARTY: - pvp_noparty = val; - break; - case MapFlag::PVP_NOCALCRANK: - pvp_nocalcrank = val; - break; - case MapFlag::NOWARP: - nowarp = val; - break; - case MapFlag::NOWARPTO: - nowarpto = val; - break; - case MapFlag::NOPVP: - nopvp = val; - break; - case MapFlag::SNOW: - snow = val; - break; - case MapFlag::FOG: - fog = val; - break; - case MapFlag::SAKURA: - sakura = val; - break; - case MapFlag::LEAVES: - leaves = val; - break; - case MapFlag::RAIN: - rain = val; - break; - case MapFlag::NO_PLAYER_DROPS: - no_player_drops = val; - break; - case MapFlag::TOWN: - town = val; - break; - default: - break; - } + if (val) + flags |= static_cast<unsigned>(mf); + else + flags &=~ static_cast<unsigned>(mf); } template<> @@ -177,3 +82,8 @@ bool extract<MapFlag, void, void>(XString str, MapFlag *mf) } return false; } + +MapFlag map_flag_from_int(int shift) +{ + return static_cast<MapFlag>(1 << shift); +} diff --git a/src/map/mapflag.hpp b/src/map/mapflag.hpp index 0905492..8e9749c 100644 --- a/src/map/mapflag.hpp +++ b/src/map/mapflag.hpp @@ -31,61 +31,45 @@ // Hm, I guess if I did them builtin instead of loading from const.txt ... enum class MapFlag { - //ALIAS = 21, - //NOMEMO = 0, - NOTELEPORT = 1, - NORETURN = 22, - MONSTER_NOTELEPORT = 23, - NOSAVE = 2, - //NOBRANCH = 3, - NOPENALTY = 4, - PVP = 6, - PVP_NOPARTY = 7, - //PVP_NOGUILD = 8, - //PVP_NIGHTMAREDROP = 24, - PVP_NOCALCRANK = 25, - //GVG = 9, - //GVG_NOPARTY = 10, - //NOZENYPENALTY = 5, - //NOTRADE = 11, - //NOSKILL = 12, - NOWARP = 13, - NOWARPTO = 26, - NOPVP = 14, - //NOICEWALL = 15, - SNOW = 16, - FOG = 17, - SAKURA = 18, - LEAVES = 19, - RAIN = 20, - NO_PLAYER_DROPS = 27, - TOWN = 28, + //ALIAS = 1 << 21, + //NOMEMO = 1 << 0, + NOTELEPORT = 1 << 1, + NORETURN = 1 << 22, + MONSTER_NOTELEPORT = 1 << 23, + NOSAVE = 1 << 2, + //NOBRANCH = 1 << 3, + NOPENALTY = 1 << 4, + PVP = 1 << 6, + PVP_NOPARTY = 1 << 7, + //PVP_NOGUILD = 1 << 8, + //PVP_NIGHTMAREDROP = 1 << 24, + PVP_NOCALCRANK = 1 << 25, + //GVG = 1 << 9, + //GVG_NOPARTY = 1 << 10, + //NOZENYPENALTY = 1 << 5, + //NOTRADE = 1 << 11, + //NOSKILL = 1 << 12, + NOWARP = 1 << 13, + NOWARPTO = 1 << 26, + NOPVP = 1 << 14, + //NOICEWALL = 1 << 15, + SNOW = 1 << 16, + FOG = 1 << 17, + SAKURA = 1 << 18, + LEAVES = 1 << 19, + RAIN = 1 << 20, + NO_PLAYER_DROPS = 1 << 27, + TOWN = 1 << 28, - COUNT = 29, + //UNUSED1 = 1 << 29, + //UNUSED2 = 1 << 30, + //UNUSED3 = 1 << 31, }; class MapFlags { -public: - unsigned noteleport:1; - unsigned noreturn:1; - unsigned monster_noteleport:1; - unsigned nosave:1; - unsigned nopenalty:1; - unsigned pvp:1; - unsigned pvp_noparty:1; - unsigned pvp_nocalcrank:1; - unsigned nowarp:1; - unsigned nowarpto:1; - unsigned nopvp:1; // [Valaris] - unsigned snow:1; // [Valaris] - unsigned fog:1; // [Valaris] - unsigned sakura:1; // [Valaris] - unsigned leaves:1; // [Valaris] - unsigned rain:1; // [Valaris] - unsigned no_player_drops:1; // [Jaxad0127] - unsigned town:1; // [remoitnane] + uint32_t flags; public: bool get(MapFlag) const; void set(MapFlag, bool); @@ -94,5 +78,6 @@ public: template<> bool extract<MapFlag, void, void>(XString str, MapFlag *mf); -#endif // TMWA_MAP_MAPFLAG_HPP +MapFlag map_flag_from_int(int shift); +#endif // TMWA_MAP_MAPFLAG_HPP diff --git a/src/map/mapflag.py b/src/map/mapflag.py new file mode 100644 index 0000000..181476c --- /dev/null +++ b/src/map/mapflag.py @@ -0,0 +1,51 @@ +class MapFlags(object): + ''' print a set of map flags + ''' + __slots__ = ('_value') + name = 'MapFlags' + enabled = True + + def __init__(self, value): + self._value = value['flags'] + + def to_string(self): + i = int(self._value) + s = [] + for n, v in [ + ('ALIAS', 21), + ('NOMEMO', 0), + ('NOTELEPORT', 1), + ('NORETURN', 22), + ('MONSTER_NOTELEPORT', 23), + ('NOSAVE', 2), + ('NOBRANCH', 3), + ('NOPENALTY', 4), + ('PVP', 6), + ('PVP_NOPARTY', 7), + ('PVP_NOGUILD', 8), + ('PVP_NIGHTMAREDROP', 24), + ('PVP_NOCALCRANK', 25), + ('GVG', 9), + ('GVG_NOPARTY', 10), + ('NOZENYPENALTY', 5), + ('NOTRADE', 11), + ('NOSKILL', 12), + ('NOWARP', 13), + ('NOWARPTO', 26), + ('NOPVP', 14), + ('NOICEWALL', 15), + ('SNOW', 16), + ('FOG', 17), + ('SAKURA', 18), + ('LEAVES', 19), + ('RAIN', 20), + ('NO_PLAYER_DROPS', 27), + ('TOWN', 28), + ]: + v = 1 << v + if i & v: + i -= v + s.append(n) + if i or not s: + s.append('%#08x' % i) + return 'MapFlags(%s)' % (' | '.join(s)) diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 2a06cf7..c67dbc4 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -788,7 +788,7 @@ int mob_attack(dumb_ptr<mob_data> md, tick_t tick) // If you are reading this, please note: // it is highly platform-specific that this even works at all. int radius = battle_config.mob_splash_radius; - if (radius >= 0 && tbl->bl_type == BL::PC && !tbl->bl_m->flag.town) + if (radius >= 0 && tbl->bl_type == BL::PC && !tbl->bl_m->flag.get(MapFlag::TOWN)) map_foreachinarea(std::bind(mob_ancillary_attack, ph::_1, md, tbl, tick), tbl->bl_m, tbl->bl_x - radius, tbl->bl_y - radius, @@ -2747,7 +2747,7 @@ int mob_warp(dumb_ptr<mob_data> md, map_local *m, int x, int y, BeingRemoveWhy t if (type != BeingRemoveWhy::NEGATIVE1) { - if (md->bl_m->flag.monster_noteleport) + if (md->bl_m->flag.get(MapFlag::MONSTER_NOTELEPORT)) return 0; clif_clearchar(md, type); } @@ -3272,7 +3272,7 @@ int mobskill_use(dumb_ptr<mob_data> md, tick_t tick, flag = (md->hp < max_hp * msii.cond2i / 100); break; case MobSkillCondition::MSC_NOTINTOWN: // Only outside of towns. - flag = !md->bl_m->flag.town; + flag = !md->bl_m->flag.get(MapFlag::TOWN); break; case MobSkillCondition::MSC_SLAVELT: // slave < num flag = (mob_countslave(md) < msii.cond2i); diff --git a/src/map/npc.cpp b/src/map/npc.cpp index a939c74..43926e0 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -1532,8 +1532,8 @@ int npc_parse_mapflag(XString w1, XString, XString w3, ZString w4) if (battle_config.pk_mode && mf == MapFlag::NOPVP) { - m->flag.nopvp = 1; - m->flag.pvp = 0; + m->flag.set(MapFlag::NOPVP, 1); + m->flag.set(MapFlag::PVP, 0); return 0; } diff --git a/src/map/pc.cpp b/src/map/pc.cpp index c9588bb..f8f9dc8 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -422,7 +422,7 @@ void pc_makesavestatus(dumb_ptr<map_session_data> sd) } // セーブ禁止マップだったので指定位置に移動 - if (sd->bl_m->flag.nosave) + if (sd->bl_m->flag.get(MapFlag::NOSAVE)) { map_local *m = sd->bl_m; if (m->save.map_ == "SavePoint") @@ -2402,7 +2402,7 @@ int pc_randomwarp(dumb_ptr<map_session_data> sd, BeingRemoveWhy type) map_local *m = sd->bl_m; - if (sd->bl_m->flag.noteleport) // テレポート禁止 + if (sd->bl_m->flag.get(MapFlag::NOTELEPORT)) // テレポート禁止 return 0; do @@ -3503,7 +3503,7 @@ int pc_damage(dumb_ptr<block_list> src, dumb_ptr<map_session_data> sd, if (battle_config.death_penalty_type > 0 && sd->status.base_level >= 20) { // changed penalty options, added death by player if pk_mode [Valaris] - if (!sd->bl_m->flag.nopenalty) + if (!sd->bl_m->flag.get(MapFlag::NOPENALTY)) { if (battle_config.death_penalty_type == 1 && battle_config.death_penalty_base > 0) @@ -3558,10 +3558,10 @@ int pc_damage(dumb_ptr<block_list> src, dumb_ptr<map_session_data> sd, } // pvp - if (sd->bl_m->flag.pvp && !battle_config.pk_mode) + if (sd->bl_m->flag.get(MapFlag::PVP) && !battle_config.pk_mode) { // disable certain pvp functions on pk_mode [Valaris] //ランキング計算 - if (!sd->bl_m->flag.pvp_nocalcrank) + if (!sd->bl_m->flag.get(MapFlag::PVP_NOCALCRANK)) { sd->pvp_point -= 5; if (src && src->bl_type == BL::PC) @@ -4782,7 +4782,7 @@ int pc_calc_pvprank(dumb_ptr<map_session_data> sd) map_local *m = sd->bl_m; nullpo_ret(m); - if (!(m->flag.pvp)) + if (!(m->flag.get(MapFlag::PVP))) return 0; sd->pvp_rank = 1; map_foreachinarea(std::bind(pc_calc_pvprank_sub, ph::_1, sd), diff --git a/src/map/script.cpp b/src/map/script.cpp index 74f437a..5889d22 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -1451,17 +1451,9 @@ void builtin_warp(ScriptState *st) y = conv_num(st, &AARGO2(4)); if (str == "Random") pc_randomwarp(sd, BeingRemoveWhy::WARPED); - else if (str == "SavePoint") + else if (str == "SavePoint" or str == "Save") { - if (sd->bl_m->flag.noreturn) // 蝶禁止 - return; - - pc_setpos(sd, sd->status.save_point.map_, sd->status.save_point.x, sd->status.save_point.y, - BeingRemoveWhy::WARPED); - } - else if (str == "Save") - { - if (sd->bl_m->flag.noreturn) // 蝶禁止 + if (sd->bl_m->flag.get(MapFlag::NORETURN)) return; pc_setpos(sd, sd->status.save_point.map_, sd->status.save_point.x, sd->status.save_point.y, @@ -3150,7 +3142,7 @@ void builtin_setmapflag(ScriptState *st) { MapName str = stringish<MapName>(ZString(conv_str(st, &AARGO2(2)))); int i = conv_num(st, &AARGO2(3)); - MapFlag mf = static_cast<MapFlag>(i); + MapFlag mf = map_flag_from_int(i); map_local *m = map_mapname2mapid(str); if (m != nullptr) { @@ -3163,7 +3155,7 @@ void builtin_removemapflag(ScriptState *st) { MapName str = stringish<MapName>(ZString(conv_str(st, &AARGO2(2)))); int i = conv_num(st, &AARGO2(3)); - MapFlag mf = static_cast<MapFlag>(i); + MapFlag mf = map_flag_from_int(i); map_local *m = map_mapname2mapid(str); if (m != nullptr) { @@ -3178,7 +3170,7 @@ void builtin_getmapflag(ScriptState *st) MapName str = stringish<MapName>(ZString(conv_str(st, &AARGO2(2)))); int i = conv_num(st, &AARGO2(3)); - MapFlag mf = static_cast<MapFlag>(i); + MapFlag mf = map_flag_from_int(i); map_local *m = map_mapname2mapid(str); if (m != nullptr) { @@ -3193,9 +3185,9 @@ void builtin_pvpon(ScriptState *st) { MapName str = stringish<MapName>(ZString(conv_str(st, &AARGO2(2)))); map_local *m = map_mapname2mapid(str); - if (m != nullptr && !m->flag.pvp && !m->flag.nopvp) + if (m != nullptr && !m->flag.get(MapFlag::PVP) && !m->flag.get(MapFlag::NOPVP)) { - m->flag.pvp = 1; + m->flag.set(MapFlag::PVP, 1); if (battle_config.pk_mode) // disable ranking functions if pk_mode is on [Valaris] return; @@ -3228,9 +3220,9 @@ void builtin_pvpoff(ScriptState *st) { MapName str = stringish<MapName>(ZString(conv_str(st, &AARGO2(2)))); map_local *m = map_mapname2mapid(str); - if (m != nullptr && m->flag.pvp && m->flag.nopvp) + if (m != nullptr && m->flag.get(MapFlag::PVP) && m->flag.get(MapFlag::NOPVP)) { - m->flag.pvp = 0; + m->flag.set(MapFlag::PVP, 0); if (battle_config.pk_mode) // disable ranking options if pk_mode is on [Valaris] return; |