summaryrefslogtreecommitdiff
path: root/src/map/magic-interpreter.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/magic-interpreter.hpp')
-rw-r--r--src/map/magic-interpreter.hpp122
1 files changed, 40 insertions, 82 deletions
diff --git a/src/map/magic-interpreter.hpp b/src/map/magic-interpreter.hpp
index 7d529ee..c9b6c97 100644
--- a/src/map/magic-interpreter.hpp
+++ b/src/map/magic-interpreter.hpp
@@ -1,5 +1,4 @@
-#ifndef TMWA_MAP_MAGIC_INTERPRETER_HPP
-#define TMWA_MAP_MAGIC_INTERPRETER_HPP
+#pragma once
// magic-interpreter.hpp - Old magic.
//
// Copyright © 2004-2011 The Mana World Development Team
@@ -20,29 +19,31 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-# include "../sanity.hpp"
+#include "fwd.hpp"
-# include "magic-interpreter.t.hpp"
+#include "magic-interpreter.t.hpp"
-# include <cassert>
+#include <cassert>
-# include "../strings/fwd.hpp"
-# include "../strings/rstring.hpp"
+#include <memory>
-# include "magic.hpp"
-# include "map.hpp"
-# include "script.hpp"
-# include "skill.t.hpp"
+#include "../strings/fwd.hpp"
+#include "../strings/rstring.hpp"
-struct fun_t;
-struct op_t;
-struct expr_t;
-struct val_t;
-struct location_t;
-struct area_t;
-struct spell_t;
-struct invocation;
+#include "../generic/fwd.hpp"
+#include "../net/timer.t.hpp"
+
+#include "../mmo/ids.hpp"
+#include "../mmo/utils.hpp"
+
+#include "map.hpp"
+#include "script.hpp"
+#include "skill.t.hpp"
+
+
+namespace tmwa
+{
struct location_t
{
map_local *m;
@@ -103,7 +104,7 @@ struct val_t
/* Expressions */
/* ----------- */
-# define MAX_ARGS 7 /* Max. # of args used in builtin primitive functions */
+#define MAX_ARGS 7 /* Max. # of args used in builtin primitive functions */
struct e_location_t
{
@@ -223,7 +224,7 @@ struct effect_t
struct component_t
{
dumb_ptr<component_t> next;
- int item_id;
+ ItemNameId item_id;
int count;
};
@@ -309,17 +310,15 @@ struct magic_conf_t
/* Execution environment */
// these are not an enum they're a nasty intern hack
-# define VAR_MIN_CASTTIME 0
-# define VAR_OBSCURE_CHANCE 1
-# define VAR_CASTER 2
-# define VAR_SPELLPOWER 3
-# define VAR_SPELL 4
-# define VAR_INVOCATION 5
-# define VAR_TARGET 6
-# define VAR_SCRIPTTARGET 7
-# define VAR_LOCATION 8
-
-struct magic_config;
+#define VAR_MIN_CASTTIME 0
+#define VAR_OBSCURE_CHANCE 1
+#define VAR_CASTER 2
+#define VAR_SPELLPOWER 3
+#define VAR_SPELL 4
+#define VAR_INVOCATION 5
+#define VAR_TARGET 6
+#define VAR_SCRIPTTARGET 7
+#define VAR_LOCATION 8
struct env_t
{
@@ -337,7 +336,7 @@ struct env_t
};
-# define MAX_STACK_SIZE 32
+#define MAX_STACK_SIZE 32
struct cont_activation_record_t
{
@@ -349,7 +348,7 @@ struct cont_activation_record_t
int id;
TYPE ty;
dumb_ptr<effect_t> body;
- dumb_ptr<std::vector<int>> entities_vp;
+ dumb_ptr<std::vector<BlockId>> entities_vp;
int index;
} c_foreach;
struct
@@ -377,7 +376,7 @@ struct cont_activation_record_t
struct status_change_ref_t
{
StatusChange sc_type;
- int bl_id;
+ BlockId bl_id;
};
struct invocation : block_list
@@ -387,8 +386,8 @@ struct invocation : block_list
dumb_ptr<env_t> env;
dumb_ptr<spell_t> spell;
- int caster; /* this is the person who originally invoked the spell */
- int subject; /* when this person dies, the spell dies with it */
+ BlockId caster; /* this is the person who originally invoked the spell */
+ BlockId subject; /* when this person dies, the spell dies with it */
Timer timer; /* spell timer, if any */
@@ -397,56 +396,18 @@ struct invocation : block_list
int script_pos; /* Script position; if nonzero, resume the script we were running. */
dumb_ptr<effect_t> current_effect;
- dumb_ptr<effect_t> trigger_effect; /* If non-NULL, this is used to spawn a cloned effect based on the same environment */
- dumb_ptr<effect_t> end_effect; /* If non-NULL, this is executed when the spell terminates naturally, e.g. when all status changes have run out or all delays are over. */
+ dumb_ptr<effect_t> trigger_effect; /* If non-nullptr, this is used to spawn a cloned effect based on the same environment */
+ dumb_ptr<effect_t> end_effect; /* If non-nullptr, this is executed when the spell terminates naturally, e.g. when all status changes have run out or all delays are over. */
/* Status change references: for status change updates, keep track of whom we updated where */
std::vector<status_change_ref_t> status_change_refv;
};
+// 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; }
-extern magic_conf_t magic_conf; /* Global magic conf */
-extern env_t magic_default_env; /* Fake default environment */
-
-/**
- * Adds a component selection to a component holder (which may initially be NULL)
- */
-void magic_add_component(dumb_ptr<component_t> *component_holder, int id, int count);
-
-dumb_ptr<teleport_anchor_t> magic_find_anchor(XString name);
-
-dumb_ptr<env_t> spell_create_env(magic_conf_t *conf, dumb_ptr<spell_t> spell,
- dumb_ptr<map_session_data> caster, int spellpower, XString param);
-
-void magic_free_env(dumb_ptr<env_t> env);
-
-/**
- * near_miss is set to nonzero iff the spell only failed due to ephemereal issues (spell delay in effect, out of mana, out of components)
- */
-effect_set_t *spell_trigger(dumb_ptr<spell_t> spell,
- dumb_ptr<map_session_data> caster,
- dumb_ptr<env_t> env, int *near_miss);
-
-dumb_ptr<invocation> spell_instantiate(effect_set_t *effect, dumb_ptr<env_t> env);
-
-/**
- * Bind a spell to a subject (this is a no-op for `local' spells).
- */
-void spell_bind(dumb_ptr<map_session_data> subject, dumb_ptr<invocation> invocation);
-
-// 1 on failure
-int spell_unbind(dumb_ptr<map_session_data> subject, dumb_ptr<invocation> invocation);
-
-/**
- * Clones a spell to run the at_effect field
- */
-dumb_ptr<invocation> spell_clone_effect(dumb_ptr<invocation> source);
-
-dumb_ptr<spell_t> magic_find_spell(XString invocation);
-
/* The following is used only by the parser: */
struct args_rec_t
{
@@ -465,7 +426,4 @@ struct proc_t
, body()
{}
};
-
-void spell_update_location(dumb_ptr<invocation> invocation);
-
-#endif // TMWA_MAP_MAGIC_INTERPRETER_HPP
+} // namespace tmwa