summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/io/cxxstdio_enums.hpp39
-rw-r--r--src/map/clif.cpp4
-rw-r--r--src/map/fwd.hpp6
-rw-r--r--src/map/magic-expr-eval.cpp3
-rw-r--r--src/map/magic-expr-eval.hpp5
-rw-r--r--src/map/magic-expr.cpp3
-rw-r--r--src/map/magic-expr.hpp3
-rw-r--r--src/map/magic-interpreter-base.cpp3
-rw-r--r--src/map/magic-interpreter-base.hpp3
-rw-r--r--src/map/magic-interpreter.cpp3
-rw-r--r--src/map/magic-interpreter.hpp10
-rw-r--r--src/map/magic-interpreter.t.hpp3
-rw-r--r--src/map/magic-stmt.cpp3
-rw-r--r--src/map/magic-stmt.hpp3
-rw-r--r--src/map/magic-v2.cpp3
-rw-r--r--src/map/magic-v2.hpp3
-rw-r--r--src/map/magic.cpp3
-rw-r--r--src/map/magic.hpp3
-rw-r--r--src/map/map.cpp8
-rw-r--r--src/map/map.hpp8
-rw-r--r--src/map/pc.cpp6
-rw-r--r--src/map/script.cpp2
-rw-r--r--src/map/skill.cpp4
-rw-r--r--src/sexpr/variant.hpp1
24 files changed, 94 insertions, 38 deletions
diff --git a/src/io/cxxstdio_enums.hpp b/src/io/cxxstdio_enums.hpp
index 3a11dde..5424518 100644
--- a/src/io/cxxstdio_enums.hpp
+++ b/src/io/cxxstdio_enums.hpp
@@ -44,44 +44,49 @@ inline
auto decay_for_printf(Option v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
}
+namespace magic
+{
enum class AREA : uint8_t;
-enum class BL : uint8_t;
-enum class ByteCode : uint8_t;
enum class EFFECT : uint8_t;
enum class EXPR : uint8_t;
-enum class ItemLook : uint16_t;
-enum class MS : uint8_t;
-enum class SP : uint16_t;
enum class SPELLARG : uint8_t;
enum class SPELLGUARD : uint8_t;
-enum class SkillID : uint16_t;
-enum class StatusChange : uint16_t;
enum class TYPE : uint8_t;
inline
auto decay_for_printf(AREA v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
inline
-auto decay_for_printf(BL v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
-inline
-auto decay_for_printf(ByteCode v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
-inline
auto decay_for_printf(EFFECT v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
inline
auto decay_for_printf(EXPR v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
inline
+auto decay_for_printf(SPELLARG v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
+inline
+auto decay_for_printf(SPELLGUARD v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
+inline
+auto decay_for_printf(TYPE v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
+}
+
+enum class BL : uint8_t;
+enum class ByteCode : uint8_t;
+enum class ItemLook : uint16_t;
+enum class MS : uint8_t;
+enum class SP : uint16_t;
+enum class SkillID : uint16_t;
+enum class StatusChange : uint16_t;
+
+inline
+auto decay_for_printf(BL v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
+inline
+auto decay_for_printf(ByteCode v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
+inline
auto decay_for_printf(ItemLook v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
inline
auto decay_for_printf(MS v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
inline
auto decay_for_printf(SP v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
inline
-auto decay_for_printf(SPELLARG v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
-inline
-auto decay_for_printf(SPELLGUARD v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
-inline
auto decay_for_printf(SkillID v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
inline
auto decay_for_printf(StatusChange v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
-inline
-auto decay_for_printf(TYPE v) -> typename remove_enum<decltype(v)>::type { return typename remove_enum<decltype(v)>::type(v); }
} // namespace tmwa
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index bb21ca9..fb4041c 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -3732,7 +3732,7 @@ RecvResult clif_parse_GlobalMessage(Session *s, dumb_ptr<map_session_data> sd)
if (is_atcommand(s, sd, mbuf, GmLevel()))
return rv;
- if (!magic_message(sd, mbuf))
+ if (!magic::magic_message(sd, mbuf))
{
/* Don't send chat that results in an automatic ban. */
if (tmw_CheckChatSpam(sd, mbuf))
@@ -4096,7 +4096,7 @@ RecvResult clif_parse_TakeItem(Session *s, dumb_ptr<map_session_data> sd)
return rv; // too far away to pick up
if (sd->state.shroud_active && sd->state.shroud_disappears_on_pickup)
- magic_unshroud(sd);
+ magic::magic_unshroud(sd);
pc_takeitem(sd, fitem);
diff --git a/src/map/fwd.hpp b/src/map/fwd.hpp
index fe66b15..79bbbcd 100644
--- a/src/map/fwd.hpp
+++ b/src/map/fwd.hpp
@@ -30,7 +30,7 @@ struct map_session_data;
struct npc_data;
struct mob_data;
struct flooritem_data;
-struct invocation;
+//struct magic::invocation;
struct map_local;
class npc_data_script;
class npc_data_shop;
@@ -40,7 +40,8 @@ struct NpcEvent;
struct item_data;
-// magic
+namespace magic
+{
struct fun_t;
struct op_t;
struct expr_t;
@@ -54,4 +55,5 @@ struct env_t;
struct magic_conf_t;
struct component_t;
struct effect_set_t;
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic-expr-eval.cpp b/src/map/magic-expr-eval.cpp
index 0283b8d..9903600 100644
--- a/src/map/magic-expr-eval.cpp
+++ b/src/map/magic-expr-eval.cpp
@@ -23,4 +23,7 @@
namespace tmwa
{
+namespace magic
+{
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic-expr-eval.hpp b/src/map/magic-expr-eval.hpp
index a291fcd..3cbc8f5 100644
--- a/src/map/magic-expr-eval.hpp
+++ b/src/map/magic-expr-eval.hpp
@@ -28,7 +28,9 @@
namespace tmwa
{
-// TODO kill this like I killed VAR
+namespace magic
+{
+// TODO soon kill this unlike I killed VAR
#define ARGINT(x) args[x].v.v_int
#define ARGDIR(x) args[x].v.v_dir
#define ARGSTR(x) ZString(args[x].v.v_string)
@@ -55,4 +57,5 @@ namespace tmwa
#define ARGMOB(x) (ARGENTITY(x)->is_mob())
#define ARG_MAY_BE_AREA(x) (ARG_TYPE(x) == TYPE::AREA || ARG_TYPE(x) == TYPE::LOCATION)
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp
index 2d2eba9..c0551d2 100644
--- a/src/map/magic-expr.cpp
+++ b/src/map/magic-expr.cpp
@@ -48,6 +48,8 @@
namespace tmwa
{
+namespace magic
+{
template<class T>
bool CHECK_TYPE(T *v, TYPE t)
{
@@ -1772,4 +1774,5 @@ dumb_ptr<expr_t> magic_new_expr(EXPR ty)
expr->ty = ty;
return expr;
}
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic-expr.hpp b/src/map/magic-expr.hpp
index e582a66..4c1efe2 100644
--- a/src/map/magic-expr.hpp
+++ b/src/map/magic-expr.hpp
@@ -35,6 +35,8 @@
namespace tmwa
{
+namespace magic
+{
/*
* Argument types:
* i : int
@@ -106,4 +108,5 @@ int magic_signature_check(ZString opname, ZString funname, ZString signature,
void magic_area_rect(map_local **m, int *x, int *y, int *width, int *height,
area_t& area);
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic-interpreter-base.cpp b/src/map/magic-interpreter-base.cpp
index e628719..cc09ed9 100644
--- a/src/map/magic-interpreter-base.cpp
+++ b/src/map/magic-interpreter-base.cpp
@@ -39,6 +39,8 @@
namespace tmwa
{
+namespace magic
+{
static
void set_int_p(val_t *v, int i, TYPE t)
{
@@ -559,4 +561,5 @@ int spell_unbind(dumb_ptr<map_session_data> subject, dumb_ptr<invocation> invoca
return 1;
}
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic-interpreter-base.hpp b/src/map/magic-interpreter-base.hpp
index 57dde85..8c05df0 100644
--- a/src/map/magic-interpreter-base.hpp
+++ b/src/map/magic-interpreter-base.hpp
@@ -30,6 +30,8 @@
namespace tmwa
{
+namespace magic
+{
extern magic_conf_t magic_conf; /* Global magic conf */
extern env_t magic_default_env; /* Fake default environment */
@@ -84,4 +86,5 @@ dumb_ptr<invocation> spell_clone_effect(dumb_ptr<invocation> source);
dumb_ptr<spell_t> magic_find_spell(XString invocation);
void spell_update_location(dumb_ptr<invocation> invocation);
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic-interpreter.cpp b/src/map/magic-interpreter.cpp
index 87ac23e..389a821 100644
--- a/src/map/magic-interpreter.cpp
+++ b/src/map/magic-interpreter.cpp
@@ -23,4 +23,7 @@
namespace tmwa
{
+namespace magic
+{
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic-interpreter.hpp b/src/map/magic-interpreter.hpp
index c9b6c97..62ab504 100644
--- a/src/map/magic-interpreter.hpp
+++ b/src/map/magic-interpreter.hpp
@@ -44,6 +44,8 @@
namespace tmwa
{
+namespace magic
+{
struct location_t
{
map_local *m;
@@ -403,11 +405,14 @@ struct invocation : block_list
std::vector<status_change_ref_t> status_change_refv;
};
+} // namespace magic
// inlines for map.hpp
-inline dumb_ptr<invocation> block_list::as_spell() { return dumb_ptr<invocation>(static_cast<invocation *>(this)); }
-inline dumb_ptr<invocation> block_list::is_spell() { return bl_type == BL::SPELL ? as_spell() : nullptr; }
+inline dumb_ptr<magic::invocation> block_list::as_spell() { return dumb_ptr<magic::invocation>(static_cast<magic::invocation *>(this)); }
+inline dumb_ptr<magic::invocation> block_list::is_spell() { return bl_type == BL::SPELL ? as_spell() : nullptr; }
+namespace magic
+{
/* The following is used only by the parser: */
struct args_rec_t
{
@@ -426,4 +431,5 @@ struct proc_t
, body()
{}
};
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic-interpreter.t.hpp b/src/map/magic-interpreter.t.hpp
index 6c7ff81..095922a 100644
--- a/src/map/magic-interpreter.t.hpp
+++ b/src/map/magic-interpreter.t.hpp
@@ -26,6 +26,8 @@
namespace tmwa
{
+namespace magic
+{
enum class SPELLARG : uint8_t
{
NONE,
@@ -146,4 +148,5 @@ enum class INVOCATION_FLAG : uint8_t
ENUM_BITWISE_OPERATORS(INVOCATION_FLAG)
}
using e::INVOCATION_FLAG;
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp
index f8f3b03..28bcbe8 100644
--- a/src/map/magic-stmt.cpp
+++ b/src/map/magic-stmt.cpp
@@ -50,6 +50,8 @@
namespace tmwa
{
+namespace magic
+{
/* used for local spell effects */
constexpr Species INVISIBLE_NPC = wrap<Species>(127);
@@ -1643,4 +1645,5 @@ int spell_attack(BlockId caster_id, BlockId target_id)
return 1;
}
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic-stmt.hpp b/src/map/magic-stmt.hpp
index 729562e..28af140 100644
--- a/src/map/magic-stmt.hpp
+++ b/src/map/magic-stmt.hpp
@@ -32,6 +32,8 @@
namespace tmwa
{
+namespace magic
+{
struct op_t
{
ZString name;
@@ -88,4 +90,5 @@ void magic_stop_completely(dumb_ptr<map_session_data> c);
int spell_attack(BlockId caster, BlockId target);
void spell_free_invocation(dumb_ptr<invocation> invocation);
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic-v2.cpp b/src/map/magic-v2.cpp
index a671dea..fe135ea 100644
--- a/src/map/magic-v2.cpp
+++ b/src/map/magic-v2.cpp
@@ -45,6 +45,8 @@
namespace tmwa
{
+namespace magic
+{
namespace magic_v2
{
static
@@ -1263,4 +1265,5 @@ bool load_magic_file_v2(ZString filename)
}
return rv;
}
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic-v2.hpp b/src/map/magic-v2.hpp
index 07d467e..9ad44a9 100644
--- a/src/map/magic-v2.hpp
+++ b/src/map/magic-v2.hpp
@@ -25,7 +25,10 @@
namespace tmwa
{
+namespace magic
+{
bool magic_init0();
// must be called after itemdb initialization
bool load_magic_file_v2(ZString filename);
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic.cpp b/src/map/magic.cpp
index b899a5e..bc46f86 100644
--- a/src/map/magic.cpp
+++ b/src/map/magic.cpp
@@ -40,6 +40,8 @@
namespace tmwa
{
+namespace magic
+{
#undef DEBUG
/// Return a pair of strings, {spellname, parameter}
@@ -127,4 +129,5 @@ int magic_message(dumb_ptr<map_session_data> caster, XString source_invocation)
return 0; /* Not a spell */
}
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/magic.hpp b/src/map/magic.hpp
index e06e913..a420872 100644
--- a/src/map/magic.hpp
+++ b/src/map/magic.hpp
@@ -31,6 +31,8 @@
namespace tmwa
{
+namespace magic
+{
/**
* Try to cast magic.
*
@@ -43,4 +45,5 @@ namespace tmwa
* message should not be repeated.
*/
int magic_message(dumb_ptr<map_session_data> caster, XString source_invocation);
+} // namespace magic
} // namespace tmwa
diff --git a/src/map/map.cpp b/src/map/map.cpp
index 832e6aa..4a25029 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -1624,7 +1624,7 @@ void cleanup_sub(dumb_ptr<block_list> bl)
map_clearflooritem(bl->bl_id);
break;
case BL::SPELL:
- spell_free_invocation(bl->is_spell());
+ magic::spell_free_invocation(bl->is_spell());
break;
}
}
@@ -1686,7 +1686,7 @@ bool map_confs(XString key, ZString value)
if (key == "skill_db"_s)
return skill_readdb(value);
if (key == "magic_conf"_s)
- return load_magic_file_v2(value);
+ return magic::load_magic_file_v2(value);
if (key == "resnametable"_s)
return load_resnametable(value);
@@ -1703,7 +1703,7 @@ bool map_confs(XString key, ZString value)
int do_init(Slice<ZString> argv)
{
ZString argv0 = argv.pop_front();
- runflag &= magic_init0();
+ runflag &= magic::magic_init0();
bool loaded_config_yet = false;
while (argv)
@@ -1784,7 +1784,7 @@ int map_scriptcont(dumb_ptr<map_session_data> sd, BlockId id)
case BL::NPC:
return npc_scriptcont(sd, id);
case BL::SPELL:
- spell_execute_script(bl->is_spell());
+ magic::spell_execute_script(bl->is_spell());
break;
}
diff --git a/src/map/map.hpp b/src/map/map.hpp
index 0e4815c..55f4823 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -117,13 +117,13 @@ private:
dumb_ptr<npc_data> as_npc();
dumb_ptr<mob_data> as_mob();
dumb_ptr<flooritem_data> as_item();
- dumb_ptr<invocation> as_spell();
+ dumb_ptr<magic::invocation> as_spell();
public:
dumb_ptr<map_session_data> is_player();
dumb_ptr<npc_data> is_npc();
dumb_ptr<mob_data> is_mob();
dumb_ptr<flooritem_data> is_item();
- dumb_ptr<invocation> is_spell();
+ dumb_ptr<magic::invocation> is_spell();
};
struct walkpath_data
@@ -223,7 +223,7 @@ struct map_session_data : block_list, SessionData
BlockId followtarget;
tick_t cast_tick; // [Fate] Next tick at which spellcasting is allowed
- dumb_ptr<invocation> active_spells; // [Fate] Singly-linked list of active spells linked to this PC
+ dumb_ptr<magic::invocation> active_spells; // [Fate] Singly-linked list of active spells linked to this PC
BlockId attack_spell_override; // [Fate] When an attack spell is active for this player, they trigger it
// like a weapon. Check pc_attack_timer() for details.
// Weapon equipment slot (slot 4) item override
@@ -664,7 +664,7 @@ dumb_ptr<flooritem_data> map_id_is_item(BlockId id)
return bl ? bl->is_item() : nullptr;
}
inline
-dumb_ptr<invocation> map_id_is_spell(BlockId id)
+dumb_ptr<magic::invocation> map_id_is_spell(BlockId id)
{
dumb_ptr<block_list> bl = map_id2bl(id);
return bl ? bl->is_spell() : nullptr;
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 0cb8382..2fa8bb7 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -2782,7 +2782,7 @@ void pc_attack_timer(TimerData *, tick_t tick, BlockId id)
interval_t attack_spell_delay = sd->attack_spell_delay;
if (sd->attack_spell_override // [Fate] If we have an active attack spell, use that
- && spell_attack(id, sd->attacktarget))
+ && magic::spell_attack(id, sd->attacktarget))
{
// Return if the spell succeeded. If the spell had disspiated, spell_attack() may fail.
sd->attackabletime = tick + attack_spell_delay;
@@ -3464,7 +3464,7 @@ int pc_damage(dumb_ptr<block_list> src, dumb_ptr<map_session_data> sd,
pc_calcstatus(sd, 0);
// [Fate] Reset magic
sd->cast_tick = gettick();
- magic_stop_completely(sd);
+ magic::magic_stop_completely(sd);
if (battle_config.death_penalty_type > 0 && sd->status.base_level >= 20)
{
@@ -5234,7 +5234,7 @@ void do_init_pc(void)
void pc_cleanup(dumb_ptr<map_session_data> sd)
{
- magic_stop_completely(sd);
+ magic::magic_stop_completely(sd);
}
void pc_invisibility(dumb_ptr<map_session_data> sd, int enabled)
diff --git a/src/map/script.cpp b/src/map/script.cpp
index 22fcb41..329b47f 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -3497,7 +3497,7 @@ void builtin_getspellinvocation(ScriptState *st)
{
dumb_string name = conv_str(st, &AARGO2(2));
- AString invocation = magic_find_invocation(name.str());
+ AString invocation = magic::magic_find_invocation(name.str());
if (!invocation)
invocation = "..."_s;
diff --git a/src/map/skill.cpp b/src/map/skill.cpp
index 20dcb1a..add6a42 100644
--- a/src/map/skill.cpp
+++ b/src/map/skill.cpp
@@ -851,7 +851,7 @@ void skill_status_change_timer(TimerData *tid, tick_t tick, BlockId id, StatusCh
if (sc_data[type].spell_invocation)
{ // Must report termination
- spell_effect_report_termination(sc_data[type].spell_invocation,
+ magic::spell_effect_report_termination(sc_data[type].spell_invocation,
bl->bl_id, type, 0);
sc_data[type].spell_invocation = BlockId();
}
@@ -1084,7 +1084,7 @@ int skill_status_effect(dumb_ptr<block_list> bl, StatusChange type,
sc_data[type].val1 = val1;
if (sc_data[type].spell_invocation) // Supplant by newer spell
- spell_effect_report_termination(sc_data[type].spell_invocation,
+ magic::spell_effect_report_termination(sc_data[type].spell_invocation,
bl->bl_id, type, 1);
sc_data[type].spell_invocation = spell_invocation;
diff --git a/src/sexpr/variant.hpp b/src/sexpr/variant.hpp
index 04f35dc..50ee77f 100644
--- a/src/sexpr/variant.hpp
+++ b/src/sexpr/variant.hpp
@@ -111,6 +111,7 @@ namespace sexpr
template<class F, class... V>
void apply(Void&& r, F&& f, V&&... v);
} // namespace sexpr
+using sexpr::Variant;
} // namespace tmwa
#include "variant.tcc"