summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.hpp2
-rw-r--r--src/map/battle.cpp44
-rw-r--r--src/map/battle.hpp2
-rw-r--r--src/map/clif.cpp6
-rw-r--r--src/map/clif.hpp2
-rw-r--r--src/map/intif.cpp1
-rw-r--r--src/map/intif.hpp2
-rw-r--r--src/map/magic-expr-eval.hpp4
-rw-r--r--src/map/magic-expr.cpp174
-rw-r--r--src/map/magic-expr.hpp8
-rw-r--r--src/map/magic-stmt.cpp54
-rw-r--r--src/map/magic-v2.cpp6
-rw-r--r--src/map/map.cpp31
-rw-r--r--src/map/map.hpp22
-rw-r--r--src/map/mapflag.cpp64
-rw-r--r--src/map/mob.cpp30
-rw-r--r--src/map/npc.cpp18
-rw-r--r--src/map/npc.hpp8
-rw-r--r--src/map/pc.cpp21
-rw-r--r--src/map/script.cpp40
-rw-r--r--src/map/script.hpp4
-rw-r--r--src/map/skill-pools.cpp2
-rw-r--r--src/map/skill.cpp16
-rw-r--r--src/map/skill.hpp15
-rw-r--r--src/map/tmw.hpp2
-rw-r--r--src/map/trade.cpp8
26 files changed, 294 insertions, 292 deletions
diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp
index 16d1efc..45759a6 100644
--- a/src/map/atcommand.hpp
+++ b/src/map/atcommand.hpp
@@ -3,8 +3,6 @@
# include "../strings/fwd.hpp"
-# include "../generic/const_array.hpp"
-
# include "map.hpp"
bool is_atcommand(Session *s, dumb_ptr<map_session_data> sd,
diff --git a/src/map/battle.cpp b/src/map/battle.cpp
index 7e563b8..49a0538 100644
--- a/src/map/battle.cpp
+++ b/src/map/battle.cpp
@@ -166,7 +166,7 @@ int battle_get_max_hp(dumb_ptr<block_list> bl)
int battle_get_str(dumb_ptr<block_list> bl)
{
int str = 0;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_ret(bl);
sc_data = battle_get_sc_data(bl);
@@ -189,7 +189,7 @@ int battle_get_str(dumb_ptr<block_list> bl)
int battle_get_agi(dumb_ptr<block_list> bl)
{
int agi = 0;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_ret(bl);
sc_data = battle_get_sc_data(bl);
@@ -211,7 +211,7 @@ int battle_get_agi(dumb_ptr<block_list> bl)
int battle_get_vit(dumb_ptr<block_list> bl)
{
int vit = 0;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_ret(bl);
sc_data = battle_get_sc_data(bl);
@@ -233,7 +233,7 @@ int battle_get_vit(dumb_ptr<block_list> bl)
int battle_get_int(dumb_ptr<block_list> bl)
{
int int_ = 0;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_ret(bl);
sc_data = battle_get_sc_data(bl);
@@ -255,7 +255,7 @@ int battle_get_int(dumb_ptr<block_list> bl)
int battle_get_dex(dumb_ptr<block_list> bl)
{
int dex = 0;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_ret(bl);
sc_data = battle_get_sc_data(bl);
@@ -277,7 +277,7 @@ int battle_get_dex(dumb_ptr<block_list> bl)
int battle_get_luk(dumb_ptr<block_list> bl)
{
int luk = 0;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_ret(bl);
sc_data = battle_get_sc_data(bl);
@@ -300,7 +300,7 @@ static
int battle_get_flee(dumb_ptr<block_list> bl)
{
int flee = 1;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_retr(1, bl);
sc_data = battle_get_sc_data(bl);
@@ -329,7 +329,7 @@ static
int battle_get_hit(dumb_ptr<block_list> bl)
{
int hit = 1;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_retr(1, bl);
sc_data = battle_get_sc_data(bl);
@@ -357,7 +357,7 @@ static
int battle_get_flee2(dumb_ptr<block_list> bl)
{
int flee2 = 1;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_retr(1, bl);
sc_data = battle_get_sc_data(bl);
@@ -389,7 +389,7 @@ static
int battle_get_critical(dumb_ptr<block_list> bl)
{
int critical = 1;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_retr(1, bl);
sc_data = battle_get_sc_data(bl);
@@ -415,7 +415,7 @@ int battle_get_critical(dumb_ptr<block_list> bl)
static
int battle_get_baseatk(dumb_ptr<block_list> bl)
{
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
int batk = 1;
nullpo_retr(1, bl);
@@ -442,7 +442,7 @@ int battle_get_baseatk(dumb_ptr<block_list> bl)
static
int battle_get_atk(dumb_ptr<block_list> bl)
{
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
int atk = 0;
nullpo_ret(bl);
@@ -518,7 +518,7 @@ int battle_get_atk_2(dumb_ptr<block_list> bl)
static
int battle_get_matk1(dumb_ptr<block_list> bl)
{
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_ret(bl);
sc_data = battle_get_sc_data(bl);
if (bl->bl_type == BL::MOB)
@@ -563,7 +563,7 @@ int battle_get_matk2(dumb_ptr<block_list> bl)
*/
int battle_get_def(dumb_ptr<block_list> bl)
{
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
int def = 0;
nullpo_ret(bl);
@@ -599,7 +599,7 @@ int battle_get_def(dumb_ptr<block_list> bl)
*/
int battle_get_mdef(dumb_ptr<block_list> bl)
{
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
int mdef = 0;
nullpo_ret(bl);
@@ -634,7 +634,7 @@ int battle_get_mdef(dumb_ptr<block_list> bl)
*/
int battle_get_def2(dumb_ptr<block_list> bl)
{
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
int def2 = 1;
nullpo_retr(1, bl);
@@ -715,7 +715,7 @@ interval_t battle_get_adelay(dumb_ptr<block_list> bl)
return bl->is_player()->aspd * 2;
else
{
- eptr<struct status_change, StatusChange> sc_data = battle_get_sc_data(bl);
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data = battle_get_sc_data(bl);
interval_t adelay = std::chrono::seconds(4);
int aspd_rate = 100;
if (bl->bl_type == BL::MOB)
@@ -743,7 +743,7 @@ interval_t battle_get_amotion(dumb_ptr<block_list> bl)
return bl->is_player()->amotion;
else
{
- eptr<struct status_change, StatusChange> sc_data = battle_get_sc_data(bl);
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data = battle_get_sc_data(bl);
interval_t amotion = std::chrono::seconds(2);
int aspd_rate = 100;
if (bl->bl_type == BL::MOB)
@@ -846,7 +846,7 @@ int battle_get_stat(SP stat_id, dumb_ptr<block_list> bl)
}
// StatusChange系の所得
-eptr<struct status_change, StatusChange> battle_get_sc_data(dumb_ptr<block_list> bl)
+eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> battle_get_sc_data(dumb_ptr<block_list> bl)
{
nullpo_retr(nullptr, bl);
@@ -1064,7 +1064,7 @@ struct Damage battle_calc_mob_weapon_attack(dumb_ptr<block_list> src,
BF flag;
int ac_flag = 0;
ATK dmg_lv = ATK::ZERO;
- eptr<struct status_change, StatusChange> sc_data, t_sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data, t_sc_data;
nullpo_retr(wd, src);
nullpo_retr(wd, target);
@@ -1337,7 +1337,7 @@ struct Damage battle_calc_pc_weapon_attack(dumb_ptr<block_list> src,
int div_;
BF flag;
ATK dmg_lv = ATK::ZERO;
- eptr<struct status_change, StatusChange> sc_data, t_sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data, t_sc_data;
int atkmax_ = 0, atkmin_ = 0; //二刀流用
int watk, watk_;
bool da = false;
@@ -1959,7 +1959,7 @@ ATK battle_weapon_attack(dumb_ptr<block_list> src, dumb_ptr<block_list> target,
tick_t tick)
{
dumb_ptr<map_session_data> sd = NULL;
- eptr<struct status_change, StatusChange> t_sc_data = battle_get_sc_data(target);
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> t_sc_data = battle_get_sc_data(target);
struct Damage wd;
nullpo_retr(ATK::ZERO, src);
diff --git a/src/map/battle.hpp b/src/map/battle.hpp
index fd452e8..5c62785 100644
--- a/src/map/battle.hpp
+++ b/src/map/battle.hpp
@@ -78,7 +78,7 @@ Race battle_get_race(dumb_ptr<block_list> bl);
MobMode battle_get_mode(dumb_ptr<block_list> bl);
int battle_get_stat(SP stat_id, dumb_ptr<block_list> bl);
-eptr<struct status_change, StatusChange> battle_get_sc_data(dumb_ptr<block_list> bl);
+eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> battle_get_sc_data(dumb_ptr<block_list> bl);
short *battle_get_sc_count(dumb_ptr<block_list> bl);
Opt1 *battle_get_opt1(dumb_ptr<block_list> bl);
Opt2 *battle_get_opt2(dumb_ptr<block_list> bl);
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index a5b02cd..3290013 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -2021,7 +2021,7 @@ int clif_misceffect(dumb_ptr<block_list> bl, int type)
int clif_changeoption(dumb_ptr<block_list> bl)
{
uint8_t buf[32];
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_ret(bl);
@@ -2435,7 +2435,7 @@ int clif_damage(dumb_ptr<block_list> src, dumb_ptr<block_list> dst,
int div, DamageType type, int damage2)
{
unsigned char buf[256];
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_ret(src);
nullpo_ret(dst);
@@ -2800,7 +2800,7 @@ int clif_skill_damage(dumb_ptr<block_list> src, dumb_ptr<block_list> dst,
int div, SkillID skill_id, int skill_lv, int type)
{
unsigned char buf[64];
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_ret(src);
nullpo_ret(dst);
diff --git a/src/map/clif.hpp b/src/map/clif.hpp
index c346f7d..571f68e 100644
--- a/src/map/clif.hpp
+++ b/src/map/clif.hpp
@@ -7,8 +7,6 @@
# include "../strings/fwd.hpp"
-# include "../generic/const_array.hpp"
-
# include "../mmo/ip.hpp"
# include "../mmo/timer.t.hpp"
diff --git a/src/map/intif.cpp b/src/map/intif.cpp
index 7f7be73..b2b95fe 100644
--- a/src/map/intif.cpp
+++ b/src/map/intif.cpp
@@ -104,6 +104,7 @@ void intif_saveaccountreg(dumb_ptr<map_session_data> sd)
int j, p;
nullpo_retv(sd);
+ assert (sd->status.account_reg_num < ACCOUNT_REG_NUM);
WFIFOW(char_session, 0) = 0x3004;
WFIFOL(char_session, 4) = sd->bl_id;
diff --git a/src/map/intif.hpp b/src/map/intif.hpp
index ac2740c..7028ed9 100644
--- a/src/map/intif.hpp
+++ b/src/map/intif.hpp
@@ -3,8 +3,6 @@
# include "../strings/fwd.hpp"
-# include "../generic/const_array.hpp"
-
# include "map.hpp"
int intif_parse(Session *);
diff --git a/src/map/magic-expr-eval.hpp b/src/map/magic-expr-eval.hpp
index 0783dc8..4de2f81 100644
--- a/src/map/magic-expr-eval.hpp
+++ b/src/map/magic-expr-eval.hpp
@@ -1,6 +1,8 @@
#ifndef TMWA_MAP_MAGIC_EXPR_EVAL_HPP
#define TMWA_MAP_MAGIC_EXPR_EVAL_HPP
+# include "../range/slice.hpp"
+
# include "../strings/zstring.hpp"
# include "magic-interpreter.hpp"
@@ -8,7 +10,7 @@
/* Helper definitions for dealing with functions and operations */
int magic_signature_check(ZString opname, ZString funname, ZString signature,
- int args_nr, val_t *args, int line, int column);
+ Slice<val_t> args, int line, int column);
void magic_area_rect(map_local **m, int *x, int *y, int *width, int *height,
area_t& area);
diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp
index 1be1b0b..1881afc 100644
--- a/src/map/magic-expr.cpp
+++ b/src/map/magic-expr.cpp
@@ -261,7 +261,7 @@ void make_spell(val_t *v)
}
static
-int fun_add(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_add(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ARG_TYPE(0) == TYPE::INT && ARG_TYPE(1) == TYPE::INT)
{
@@ -296,21 +296,21 @@ int fun_add(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_sub(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_sub(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = ARGINT(0) - ARGINT(1);
return 0;
}
static
-int fun_mul(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_mul(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = ARGINT(0) * ARGINT(1);
return 0;
}
static
-int fun_div(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_div(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (!ARGINT(1))
return 1; /* division by zero */
@@ -319,7 +319,7 @@ int fun_div(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_mod(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_mod(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (!ARGINT(1))
return 1; /* division by zero */
@@ -328,35 +328,35 @@ int fun_mod(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_or(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_or(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = ARGINT(0) || ARGINT(1);
return 0;
}
static
-int fun_and(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_and(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = ARGINT(0) && ARGINT(1);
return 0;
}
static
-int fun_not(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_not(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = !ARGINT(0);
return 0;
}
static
-int fun_neg(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_neg(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = ~ARGINT(0);
return 0;
}
static
-int fun_gte(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_gte(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ARG_TYPE(0) == TYPE::STRING || ARG_TYPE(1) == TYPE::STRING)
{
@@ -374,7 +374,7 @@ int fun_gte(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_lt(dumb_ptr<env_t> env, val_t *result, const_array<val_t> args)
+int fun_lt(dumb_ptr<env_t> env, val_t *result, Slice<val_t> args)
{
fun_gte(env, result, args);
RESULTINT = !RESULTINT;
@@ -382,7 +382,7 @@ int fun_lt(dumb_ptr<env_t> env, val_t *result, const_array<val_t> args)
}
static
-int fun_gt(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_gt(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ARG_TYPE(0) == TYPE::STRING || ARG_TYPE(1) == TYPE::STRING)
{
@@ -400,7 +400,7 @@ int fun_gt(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_lte(dumb_ptr<env_t> env, val_t *result, const_array<val_t> args)
+int fun_lte(dumb_ptr<env_t> env, val_t *result, Slice<val_t> args)
{
fun_gt(env, result, args);
RESULTINT = !RESULTINT;
@@ -408,7 +408,7 @@ int fun_lte(dumb_ptr<env_t> env, val_t *result, const_array<val_t> args)
}
static
-int fun_eq(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_eq(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ARG_TYPE(0) == TYPE::STRING || ARG_TYPE(1) == TYPE::STRING)
{
@@ -440,7 +440,7 @@ int fun_eq(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_ne(dumb_ptr<env_t> env, val_t *result, const_array<val_t> args)
+int fun_ne(dumb_ptr<env_t> env, val_t *result, Slice<val_t> args)
{
fun_eq(env, result, args);
RESULTINT = !RESULTINT;
@@ -448,56 +448,56 @@ int fun_ne(dumb_ptr<env_t> env, val_t *result, const_array<val_t> args)
}
static
-int fun_bitand(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_bitand(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = ARGINT(0) & ARGINT(1);
return 0;
}
static
-int fun_bitor(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_bitor(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = ARGINT(0) | ARGINT(1);
return 0;
}
static
-int fun_bitxor(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_bitxor(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = ARGINT(0) ^ ARGINT(1);
return 0;
}
static
-int fun_bitshl(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_bitshl(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = ARGINT(0) << ARGINT(1);
return 0;
}
static
-int fun_bitshr(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_bitshr(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = ARGINT(0) >> ARGINT(1);
return 0;
}
static
-int fun_max(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_max(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = max(ARGINT(0), ARGINT(1));
return 0;
}
static
-int fun_min(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_min(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = min(ARGINT(0), ARGINT(1));
return 0;
}
static
-int fun_if_then_else(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_if_then_else(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ARGINT(0))
magic_copy_var(result, &args[1]);
@@ -606,7 +606,7 @@ int magic_location_in_area(map_local *m, int x, int y, dumb_ptr<area_t> area)
}
static
-int fun_is_in(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_is_in(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = magic_location_in_area(ARGLOCATION(0).m,
ARGLOCATION(0).x,
@@ -615,7 +615,7 @@ int fun_is_in(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_skill(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_skill(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ENTITY_TYPE(0) != BL::PC
// don't convert to enum until after the range check
@@ -633,18 +633,18 @@ int fun_skill(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_his_shroud(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_his_shroud(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = (ENTITY_TYPE(0) == BL::PC && ARGPC(0)->state.shroud_active);
return 0;
}
-#define BATTLE_GETTER(name) \
-static \
-int fun_get_##name(dumb_ptr<env_t>, val_t *result, const_array<val_t> args) \
-{ \
- RESULTINT = battle_get_##name(ARGENTITY(0)); \
- return 0; \
+#define BATTLE_GETTER(name) \
+static \
+int fun_get_##name(dumb_ptr<env_t>, val_t *result, Slice<val_t> args) \
+{ \
+ RESULTINT = battle_get_##name(ARGENTITY(0)); \
+ return 0; \
}
BATTLE_GETTER(str)
@@ -659,28 +659,28 @@ BATTLE_GETTER(mdef)
BATTLE_GETTER(def)
BATTLE_GETTER(max_hp)
static
-int fun_get_dir(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_get_dir(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTDIR = battle_get_dir(ARGENTITY(0));
return 0;
}
-#define MMO_GETTER(name) \
-static \
-int fun_get_##name(dumb_ptr<env_t>, val_t *result, const_array<val_t> args) \
-{ \
- if (ENTITY_TYPE(0) == BL::PC) \
- RESULTINT = ARGPC(0)->status.name; \
- else \
- RESULTINT = 0; \
- return 0; \
+#define MMO_GETTER(name) \
+static \
+int fun_get_##name(dumb_ptr<env_t>, val_t *result, Slice<val_t> args) \
+{ \
+ if (ENTITY_TYPE(0) == BL::PC) \
+ RESULTINT = ARGPC(0)->status.name; \
+ else \
+ RESULTINT = 0; \
+ return 0; \
}
MMO_GETTER(sp)
MMO_GETTER(max_sp)
static
-int fun_name_of(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_name_of(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ARG_TYPE(0) == TYPE::ENTITY)
{
@@ -702,7 +702,7 @@ int fun_name_of(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
/* [Freeyorp] I'm putting this one in as name_of seems to have issues with summoned or spawned mobs. */
static
-int fun_mob_id(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_mob_id(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ENTITY_TYPE(0) != BL::MOB)
return 1;
@@ -727,14 +727,14 @@ void COPY_LOCATION(location_t& dest, block_list& src)
}
static
-int fun_location(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_location(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
COPY_LOCATION(RESULTLOCATION, *(ARGENTITY(0)));
return 0;
}
static
-int fun_random(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_random(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
int delta = ARGINT(0);
if (delta < 0)
@@ -752,7 +752,7 @@ int fun_random(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_random_dir(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_random_dir(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ARGINT(0))
RESULTDIR = random_::choice({DIR::S, DIR::SW, DIR::W, DIR::NW, DIR::N, DIR::NE, DIR::E, DIR::SE});
@@ -762,14 +762,14 @@ int fun_random_dir(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_hash_entity(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_hash_entity(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = ARGENTITY(0)->bl_id;
return 0;
}
int // ret -1: not a string, ret 1: no such item, ret 0: OK
-magic_find_item(const_array<val_t> args, int index, struct item *item_, int *stackable)
+magic_find_item(Slice<val_t> args, int index, struct item *item_, int *stackable)
{
struct item_data *item_data;
int must_add_sequentially;
@@ -801,7 +801,7 @@ magic_find_item(const_array<val_t> args, int index, struct item *item_, int *sta
}
static
-int fun_count_item(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_count_item(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
dumb_ptr<map_session_data> chr = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL;
int stackable;
@@ -817,7 +817,7 @@ int fun_count_item(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_is_equipped(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_is_equipped(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
dumb_ptr<map_session_data> chr = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL;
int stackable;
@@ -843,28 +843,28 @@ int fun_is_equipped(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_is_married(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_is_married(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = (ENTITY_TYPE(0) == BL::PC && ARGPC(0)->status.partner_id);
return 0;
}
static
-int fun_is_dead(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_is_dead(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = (ENTITY_TYPE(0) == BL::PC && pc_isdead(ARGPC(0)));
return 0;
}
static
-int fun_is_pc(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_is_pc(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = (ENTITY_TYPE(0) == BL::PC);
return 0;
}
static
-int fun_partner(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_partner(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ENTITY_TYPE(0) == BL::PC && ARGPC(0)->status.partner_id)
{
@@ -877,7 +877,7 @@ int fun_partner(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_awayfrom(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_awayfrom(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
location_t *loc = &ARGLOCATION(0);
int dx = dirx[ARGDIR(1)];
@@ -896,14 +896,14 @@ int fun_awayfrom(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_failed(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_failed(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = ARG_TYPE(0) == TYPE::FAIL;
return 0;
}
static
-int fun_npc(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_npc(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
NpcName name = stringish<NpcName>(ARGSTR(0));
RESULTENTITY = npc_name2id(name);
@@ -911,7 +911,7 @@ int fun_npc(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_pc(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_pc(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
CharName name = stringish<CharName>(ARGSTR(0));
RESULTENTITY = map_nick2sd(name);
@@ -919,7 +919,7 @@ int fun_pc(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_distance(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_distance(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ARGLOCATION(0).m != ARGLOCATION(1).m)
RESULTINT = 0x7fffffff;
@@ -930,7 +930,7 @@ int fun_distance(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_rdistance(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_rdistance(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ARGLOCATION(0).m != ARGLOCATION(1).m)
RESULTINT = 0x7fffffff;
@@ -944,7 +944,7 @@ int fun_rdistance(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_anchor(dumb_ptr<env_t> env, val_t *result, const_array<val_t> args)
+int fun_anchor(dumb_ptr<env_t> env, val_t *result, Slice<val_t> args)
{
dumb_ptr<teleport_anchor_t> anchor = magic_find_anchor(ARGSTR(0));
@@ -964,7 +964,7 @@ int fun_anchor(dumb_ptr<env_t> env, val_t *result, const_array<val_t> args)
}
static
-int fun_line_of_sight(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_line_of_sight(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
block_list e1, e2;
@@ -1020,14 +1020,14 @@ void magic_random_location(location_t *dest, dumb_ptr<area_t> area)
}
static
-int fun_pick_location(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_pick_location(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
magic_random_location(&result->v.v_location, ARGAREA(0));
return 0;
}
static
-int fun_read_script_int(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_read_script_int(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
dumb_ptr<block_list> subject_p = ARGENTITY(0);
VarName var_name = stringish<VarName>(ARGSTR(1));
@@ -1041,7 +1041,7 @@ int fun_read_script_int(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_read_script_str(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_read_script_str(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
dumb_ptr<block_list> subject_p = ARGENTITY(0);
VarName var_name = stringish<VarName>(ARGSTR(1));
@@ -1055,7 +1055,7 @@ int fun_read_script_str(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_rbox(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_rbox(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
location_t loc = ARGLOCATION(0);
int radius = ARGINT(1);
@@ -1071,7 +1071,7 @@ int fun_rbox(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_running_status_update(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_running_status_update(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ENTITY_TYPE(0) != BL::PC && ENTITY_TYPE(0) != BL::MOB)
return 1;
@@ -1082,28 +1082,28 @@ int fun_running_status_update(dumb_ptr<env_t>, val_t *result, const_array<val_t>
}
static
-int fun_status_option(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_status_option(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = (bool((ARGPC(0))->status.option & static_cast<Option>(ARGINT(1))));
return 0;
}
static
-int fun_element(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_element(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = static_cast<int>(battle_get_element(ARGENTITY(0)).element);
return 0;
}
static
-int fun_element_level(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_element_level(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = battle_get_element(ARGENTITY(0)).level;
return 0;
}
static
-int fun_is_exterior(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_is_exterior(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
#warning "Evil assumptions!"
RESULTINT = ARGLOCATION(0).m->name_[4] == '1';
@@ -1111,14 +1111,14 @@ int fun_is_exterior(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_contains_string(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_contains_string(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = NULL != strstr(ARGSTR(0).c_str(), ARGSTR(1).c_str());
return 0;
}
static
-int fun_strstr(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_strstr(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
const char *offset = strstr(ARGSTR(0).c_str(), ARGSTR(1).c_str());
RESULTINT = offset - ARGSTR(0).c_str();
@@ -1126,14 +1126,14 @@ int fun_strstr(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_strlen(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_strlen(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = strlen(ARGSTR(0).c_str());
return 0;
}
static
-int fun_substr(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_substr(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
const char *src = ARGSTR(0).c_str();
const int slen = strlen(src);
@@ -1159,14 +1159,14 @@ int fun_substr(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_sqrt(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_sqrt(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
RESULTINT = static_cast<int>(sqrt(ARGINT(0)));
return 0;
}
static
-int fun_map_level(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_map_level(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
#warning "Evil assumptions!"
RESULTINT = ARGLOCATION(0).m->name_[4] - '0';
@@ -1174,7 +1174,7 @@ int fun_map_level(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_map_nr(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_map_nr(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
#warning "Evil assumptions!"
MapName mapname = ARGLOCATION(0).m->name_;
@@ -1185,7 +1185,7 @@ int fun_map_nr(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_dir_towards(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_dir_towards(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
int dx;
int dy;
@@ -1251,7 +1251,7 @@ int fun_dir_towards(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
}
static
-int fun_extract_healer_xp(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
+int fun_extract_healer_xp(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
dumb_ptr<map_session_data> sd = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL;
@@ -1526,10 +1526,10 @@ TYPE type_key(char ty_key)
}
int magic_signature_check(ZString opname, ZString funname, ZString signature,
- int args_nr, val_t *args, int line, int column)
+ Slice<val_t> args, int line, int column)
{
int i;
- for (i = 0; i < args_nr; i++)
+ for (i = 0; i < args.size(); i++)
{
val_t *arg = &args[i];
char ty_key = signature[i];
@@ -1553,8 +1553,8 @@ int magic_signature_check(ZString opname, ZString funname, ZString signature,
if (!ty_key)
{
FPRINTF(stderr,
- "[magic-eval]: L%d:%d: Too many arguments (%d) to %s `%s'\n",
- line, column, args_nr, opname, funname);
+ "[magic-eval]: L%d:%d: Too many arguments (%zu) to %s `%s'\n",
+ line, column, args.size(), opname, funname);
return 1;
}
@@ -1640,9 +1640,9 @@ void magic_eval(dumb_ptr<env_t> env, val_t *dest, dumb_ptr<expr_t> expr)
for (i = 0; i < args_nr; ++i)
magic_eval(env, &arguments[i], expr->e.e_funapp.args[i]);
- if (magic_signature_check("function", f->name, f->signature, args_nr, arguments,
+ if (magic_signature_check("function", f->name, f->signature, Slice<val_t>(arguments, args_nr),
expr->e.e_funapp.line_nr, expr->e.e_funapp.column)
- || f->fun(env, dest, const_array<val_t>(arguments, args_nr)))
+ || f->fun(env, dest, Slice<val_t>(arguments, args_nr)))
dest->ty = TYPE::FAIL;
else
{
diff --git a/src/map/magic-expr.hpp b/src/map/magic-expr.hpp
index 79fdc3f..b2b0dd2 100644
--- a/src/map/magic-expr.hpp
+++ b/src/map/magic-expr.hpp
@@ -3,6 +3,8 @@
# include "magic-interpreter.hpp"
+# include "../range/slice.hpp"
+
# include "../strings/fwd.hpp"
# include "../strings/zstring.hpp"
@@ -24,14 +26,14 @@ struct fun_t
ZString name;
ZString signature;
char ret_ty;
- int (*fun)(dumb_ptr<env_t> env, val_t *result, const_array<val_t> arga);
+ int (*fun)(dumb_ptr<env_t> env, val_t *result, Slice<val_t> arga);
};
struct op_t
{
ZString name;
ZString signature;
- int (*op)(dumb_ptr<env_t> env, const_array<val_t> arga);
+ int (*op)(dumb_ptr<env_t> env, Slice<val_t> arga);
};
/**
@@ -72,7 +74,7 @@ void magic_copy_var(val_t *dest, val_t *src);
void magic_random_location(location_t *dest, dumb_ptr<area_t> area);
// ret -1: not a string, ret 1: no such item, ret 0: OK
-int magic_find_item(const_array<val_t> args, int index, struct item *item, int *stackable);
+int magic_find_item(Slice<val_t> args, int index, struct item *item, int *stackable);
# define GET_ARG_ITEM(index, dest, stackable) \
switch (magic_find_item(args, index, &dest, &stackable)) \
diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp
index 4063a68..081651c 100644
--- a/src/map/magic-stmt.cpp
+++ b/src/map/magic-stmt.cpp
@@ -298,7 +298,7 @@ dumb_ptr<npc_data> local_spell_effect(map_local *m, int x, int y, int effect,
}
static
-int op_sfx(dumb_ptr<env_t>, const_array<val_t> args)
+int op_sfx(dumb_ptr<env_t>, Slice<val_t> args)
{
interval_t delay = static_cast<interval_t>(ARGINT(2));
@@ -319,7 +319,7 @@ int op_sfx(dumb_ptr<env_t>, const_array<val_t> args)
}
static
-int op_instaheal(dumb_ptr<env_t> env, const_array<val_t> args)
+int op_instaheal(dumb_ptr<env_t> env, Slice<val_t> args)
{
dumb_ptr<block_list> caster = (env->VAR(VAR_CASTER).ty == TYPE::ENTITY)
? map_id2bl(env->VAR(VAR_CASTER).v.v_int) : NULL;
@@ -340,7 +340,7 @@ int op_instaheal(dumb_ptr<env_t> env, const_array<val_t> args)
}
static
-int op_itemheal(dumb_ptr<env_t> env, const_array<val_t> args)
+int op_itemheal(dumb_ptr<env_t> env, Slice<val_t> args)
{
dumb_ptr<block_list> subject = ARGENTITY(0);
if (subject->bl_type == BL::PC)
@@ -370,7 +370,7 @@ using e::Shroud;
#define ARGCHAR(n) (ARGENTITY(n)->is_player())
static
-int op_shroud(dumb_ptr<env_t>, const_array<val_t> args)
+int op_shroud(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<map_session_data> subject = ARGCHAR(0);
Shroud arg = static_cast<Shroud>(ARGINT(1));
@@ -389,7 +389,7 @@ int op_shroud(dumb_ptr<env_t>, const_array<val_t> args)
}
static
-int op_reveal(dumb_ptr<env_t>, const_array<val_t> args)
+int op_reveal(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<map_session_data> subject = ARGCHAR(0);
@@ -400,7 +400,7 @@ int op_reveal(dumb_ptr<env_t>, const_array<val_t> args)
}
static
-int op_message(dumb_ptr<env_t>, const_array<val_t> args)
+int op_message(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<map_session_data> subject = ARGCHAR(0);
@@ -419,7 +419,7 @@ void timer_callback_kill_npc(TimerData *, tick_t, int npc_id)
}
static
-int op_messenger_npc(dumb_ptr<env_t>, const_array<val_t> args)
+int op_messenger_npc(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<npc_data> npc;
location_t *loc = &ARGLOCATION(0);
@@ -476,7 +476,7 @@ void entity_warp(dumb_ptr<block_list> target, map_local *destm, int destx, int d
}
static
-int op_move(dumb_ptr<env_t>, const_array<val_t> args)
+int op_move(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<block_list> subject = ARGENTITY(0);
DIR dir = ARGDIR(1);
@@ -491,7 +491,7 @@ int op_move(dumb_ptr<env_t>, const_array<val_t> args)
}
static
-int op_warp(dumb_ptr<env_t>, const_array<val_t> args)
+int op_warp(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<block_list> subject = ARGENTITY(0);
location_t *loc = &ARGLOCATION(1);
@@ -502,7 +502,7 @@ int op_warp(dumb_ptr<env_t>, const_array<val_t> args)
}
static
-int op_banish(dumb_ptr<env_t>, const_array<val_t> args)
+int op_banish(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<block_list> subject = ARGENTITY(0);
@@ -529,7 +529,7 @@ void record_status_change(dumb_ptr<invocation> invocation_, int bl_id,
}
static
-int op_status_change(dumb_ptr<env_t> env, const_array<val_t> args)
+int op_status_change(dumb_ptr<env_t> env, Slice<val_t> args)
{
dumb_ptr<block_list> subject = ARGENTITY(0);
int invocation_id = env->VAR(VAR_INVOCATION).ty == TYPE::INVOCATION
@@ -550,7 +550,7 @@ int op_status_change(dumb_ptr<env_t> env, const_array<val_t> args)
}
static
-int op_stop_status_change(dumb_ptr<env_t>, const_array<val_t> args)
+int op_stop_status_change(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<block_list> subject = ARGENTITY(0);
@@ -561,7 +561,7 @@ int op_stop_status_change(dumb_ptr<env_t>, const_array<val_t> args)
}
static
-int op_override_attack(dumb_ptr<env_t> env, const_array<val_t> args)
+int op_override_attack(dumb_ptr<env_t> env, Slice<val_t> args)
{
dumb_ptr<block_list> psubject = ARGENTITY(0);
int charges = ARGINT(1);
@@ -602,7 +602,7 @@ int op_override_attack(dumb_ptr<env_t> env, const_array<val_t> args)
}
static
-int op_create_item(dumb_ptr<env_t>, const_array<val_t> args)
+int op_create_item(dumb_ptr<env_t>, Slice<val_t> args)
{
struct item item;
dumb_ptr<block_list> entity = ARGENTITY(0);
@@ -640,7 +640,7 @@ bool AGGRAVATION_MODE_MAKES_AGGRESSIVE(int n)
}
static
-int op_aggravate(dumb_ptr<env_t>, const_array<val_t> args)
+int op_aggravate(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<block_list> victim = ARGENTITY(2);
int mode = ARGINT(1);
@@ -675,7 +675,7 @@ enum class MonsterAttitude
};
static
-int op_spawn(dumb_ptr<env_t>, const_array<val_t> args)
+int op_spawn(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<area_t> area = ARGAREA(0);
dumb_ptr<block_list> owner_e = ARGENTITY(1);
@@ -766,7 +766,7 @@ const char *get_invocation_name(dumb_ptr<env_t> env)
}
static
-int op_injure(dumb_ptr<env_t> env, const_array<val_t> args)
+int op_injure(dumb_ptr<env_t> env, Slice<val_t> args)
{
dumb_ptr<block_list> caster = ARGENTITY(0);
dumb_ptr<block_list> target = ARGENTITY(1);
@@ -816,7 +816,7 @@ int op_injure(dumb_ptr<env_t> env, const_array<val_t> args)
}
static
-int op_emote(dumb_ptr<env_t>, const_array<val_t> args)
+int op_emote(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<block_list> victim = ARGENTITY(0);
int emotion = ARGINT(1);
@@ -826,7 +826,7 @@ int op_emote(dumb_ptr<env_t>, const_array<val_t> args)
}
static
-int op_set_script_variable(dumb_ptr<env_t>, const_array<val_t> args)
+int op_set_script_variable(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<map_session_data> c = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL;
VarName varname = stringish<VarName>(ARGSTR(1));
@@ -841,7 +841,7 @@ int op_set_script_variable(dumb_ptr<env_t>, const_array<val_t> args)
}
static
-int op_set_script_str(dumb_ptr<env_t>, const_array<val_t> args)
+int op_set_script_str(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<map_session_data> c = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL;
VarName varname = stringish<VarName>(ARGSTR(1));
@@ -856,7 +856,7 @@ int op_set_script_str(dumb_ptr<env_t>, const_array<val_t> args)
}
static
-int op_set_hair_colour(dumb_ptr<env_t>, const_array<val_t> args)
+int op_set_hair_colour(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<map_session_data> c = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL;
@@ -869,7 +869,7 @@ int op_set_hair_colour(dumb_ptr<env_t>, const_array<val_t> args)
}
static
-int op_set_hair_style(dumb_ptr<env_t>, const_array<val_t> args)
+int op_set_hair_style(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<map_session_data> c = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL;
@@ -882,7 +882,7 @@ int op_set_hair_style(dumb_ptr<env_t>, const_array<val_t> args)
}
static
-int op_drop_item_for (dumb_ptr<env_t>, const_array<val_t> args)
+int op_drop_item_for (dumb_ptr<env_t>, Slice<val_t> args)
{
struct item item;
int stackable;
@@ -908,7 +908,7 @@ int op_drop_item_for (dumb_ptr<env_t>, const_array<val_t> args)
}
static
-int op_gain_exp(dumb_ptr<env_t>, const_array<val_t> args)
+int op_gain_exp(dumb_ptr<env_t>, Slice<val_t> args)
{
dumb_ptr<map_session_data> c = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL;
@@ -1468,7 +1468,7 @@ interval_t spell_run(dumb_ptr<invocation> invocation_, int allow_delete)
int newpos = run_script_l(
ScriptPointer(&*e->e.e_script, invocation_->script_pos),
message_recipient, invocation_->bl_id,
- 3, arg);
+ arg);
/* Returns the new script position, or -1 once the script is finished */
if (newpos != -1)
{
@@ -1498,10 +1498,10 @@ interval_t spell_run(dumb_ptr<invocation> invocation_, int allow_delete)
magic_eval(invocation_->env, &args[i], e->e.e_op.args[i]);
if (!magic_signature_check("effect", op->name, op->signature,
- e->e.e_op.args_nr, args,
+ Slice<val_t>(args, e->e.e_op.args_nr),
e->e.e_op.line_nr,
e->e.e_op.column))
- op->op(invocation_->env, const_array<val_t>(args, e->e.e_op.args_nr));
+ op->op(invocation_->env, Slice<val_t>(args, e->e.e_op.args_nr));
for (i = 0; i < e->e.e_op.args_nr; i++)
magic_clear_var(&args[i]);
diff --git a/src/map/magic-v2.cpp b/src/map/magic-v2.cpp
index 1fad61d..41d29cd 100644
--- a/src/map/magic-v2.cpp
+++ b/src/map/magic-v2.cpp
@@ -254,7 +254,7 @@ namespace magic_v2
return true;
}
static
- bool op_effect(io::LineSpan span, ZString name, const_array<dumb_ptr<expr_t>> argv, dumb_ptr<effect_t>& effect)
+ bool op_effect(io::LineSpan span, ZString name, Slice<dumb_ptr<expr_t>> argv, dumb_ptr<effect_t>& effect)
{
op_t *op = magic_get_op(name);
if (!op)
@@ -290,7 +290,7 @@ namespace magic_v2
return retval;
}
static
- bool fun_expr(io::LineSpan span, ZString name, const_array<dumb_ptr<expr_t>> argv, dumb_ptr<expr_t>& expr)
+ bool fun_expr(io::LineSpan span, ZString name, Slice<dumb_ptr<expr_t>> argv, dumb_ptr<expr_t>& expr)
{
fun_t *fun = magic_get_fun(name);
if (!fun)
@@ -322,7 +322,7 @@ namespace magic_v2
e[0] = left;
e[1] = right;
dumb_ptr<expr_t> rv;
- if (!fun_expr(span, name, const_array<dumb_ptr<expr_t>>(e, 2), rv))
+ if (!fun_expr(span, name, e, rv))
abort();
return rv;
}
diff --git a/src/map/map.cpp b/src/map/map.cpp
index e5a3341..f701730 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -72,7 +72,7 @@ Map<int, struct charid2nick> charid_db;
static
int users = 0;
static
-dumb_ptr<block_list> object[MAX_FLOORITEM];
+Array<dumb_ptr<block_list>, MAX_FLOORITEM> object;
static
int first_free_object_id = 0, last_object_id = 0;
@@ -546,6 +546,7 @@ int map_addobject(dumb_ptr<block_list> bl)
*/
int map_delobjectnofree(int id, BL type)
{
+ assert (id < MAX_FLOORITEM);
if (!object[id])
return 0;
@@ -581,6 +582,7 @@ int map_delobjectnofree(int id, BL type)
*/
int map_delobject(int id, BL type)
{
+ assert (id < MAX_FLOORITEM);
dumb_ptr<block_list> obj = object[id];
if (obj == NULL)
@@ -603,6 +605,7 @@ int map_delobject(int id, BL type)
void map_foreachobject(std::function<void(dumb_ptr<block_list>)> func,
BL type)
{
+ assert (last_object_id < MAX_FLOORITEM);
std::vector<dumb_ptr<block_list>> bl_list;
for (int i = 2; i <= last_object_id; i++)
{
@@ -634,6 +637,7 @@ void map_foreachobject(std::function<void(dumb_ptr<block_list>)> func,
*/
void map_clearflooritem_timer(TimerData *tid, tick_t, int id)
{
+ assert (id < MAX_FLOORITEM);
dumb_ptr<block_list> obj = object[id];
assert (obj && obj->bl_type == BL::ITEM);
dumb_ptr<flooritem_data> fitem = obj->is_item();
@@ -1669,48 +1673,49 @@ bool map_confs(XString key, ZString value)
* Map-Server Init and Command-line Arguments [Valaris]
*------------------------------------------------------
*/
-int do_init(int argc, ZString *argv)
+int do_init(Slice<ZString> argv)
{
+ ZString argv0 = argv.pop_front();
runflag &= magic_init0();
bool loaded_config_yet = false;
- for (int i = 1; i < argc; ++i)
+ while (argv)
{
- if (argv[i].startswith('-'))
+ ZString argvi = argv.pop_front();
+ if (argvi.startswith('-'))
{
- if (argv[i] == "--help")
+ if (argvi == "--help")
{
PRINTF("Usage: %s [--help] [--version] [--write_atcommand_config outfile] [files...]\n",
- argv[0]);
+ argv0);
exit(0);
}
- else if (argv[i] == "--version")
+ else if (argvi == "--version")
{
PRINTF("%s\n", CURRENT_VERSION_STRING);
exit(0);
}
- else if (argv[i] == "--write-atcommand-config")
+ else if (argvi == "--write-atcommand-config")
{
- ++i;
- if (i == argc)
+ if (!argv)
{
PRINTF("Missing argument\n");
exit(1);
}
- ZString filename = argv[i];
+ ZString filename = argv.pop_front();
atcommand_config_write(filename);
exit(0);
}
else
{
- FPRINTF(stderr, "Unknown argument: %s\n", argv[i]);
+ FPRINTF(stderr, "Unknown argument: %s\n", argvi);
runflag = false;
}
}
else
{
loaded_config_yet = true;
- runflag &= load_config_file(argv[i], map_confs);
+ runflag &= load_config_file(argvi, map_confs);
}
}
diff --git a/src/map/map.hpp b/src/map/map.hpp
index 0f9f3d1..cb57c6b 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -113,7 +113,7 @@ public:
struct walkpath_data
{
unsigned char path_len, path_pos, path_half;
- DIR path[MAX_WALKPATH];
+ Array<DIR, MAX_WALKPATH> path;
};
struct status_change
{
@@ -173,7 +173,7 @@ struct map_session_data : block_list, SessionData
unsigned char tmw_version; // tmw client version
CharKey status_key;
CharData status;
- struct item_data *inventory_data[MAX_INVENTORY];
+ Array<struct item_data *, MAX_INVENTORY> inventory_data;
earray<short, EQUIP, EQUIP::COUNT> equip_index;
int weight, max_weight;
MapName mapname_;
@@ -275,8 +275,8 @@ struct map_session_data : block_list, SessionData
short sc_count;
int trade_partner;
- int deal_item_index[10];
- int deal_item_amount[10];
+ Array<int, TRADE_MAX> deal_item_index;
+ Array<int, TRADE_MAX> deal_item_amount;
int deal_zeny;
short deal_locked;
@@ -292,7 +292,7 @@ struct map_session_data : block_list, SessionData
int pvp_lastusers;
std::list<NpcEvent> eventqueuel;
- Timer eventtimer[MAX_EVENTTIMER];
+ Array<Timer, MAX_EVENTTIMER> eventtimer;
struct
{
@@ -349,7 +349,7 @@ struct npc_data : block_list
short flag;
std::list<RString> eventqueuel;
- Timer eventtimer[MAX_EVENTTIMER];
+ Array<Timer, MAX_EVENTTIMER> eventtimer;
short arenaflag;
private:
@@ -517,13 +517,7 @@ struct map_local : map_abstract
MapFlags flag;
struct point save;
struct point resave;
- dumb_ptr<npc_data> npc[MAX_NPC_PER_MAP];
- struct
- {
- int drop_id;
- int drop_type;
- int drop_per;
- } drop_list[MAX_DROP_PER_MAP];
+ Array<dumb_ptr<npc_data>, MAX_NPC_PER_MAP> npc;
};
struct map_remote : map_abstract
@@ -535,6 +529,8 @@ struct map_remote : map_abstract
inline
MapCell read_gatp(map_local *m, int x, int y)
{
+ assert (0 <= x && x < m->xs);
+ assert (0 <= y && y < m->ys);
return m->gat[x + y * m->xs];
}
diff --git a/src/map/mapflag.cpp b/src/map/mapflag.cpp
index 097f4d1..51af30a 100644
--- a/src/map/mapflag.cpp
+++ b/src/map/mapflag.cpp
@@ -40,41 +40,41 @@ bool extract<MapFlag, void, void>(XString str, MapFlag *mf)
{
const struct
{
- char str[32];
+ ZString str;
MapFlag id;
} flags[] =
{
- //{"alias", MapFlag::ALIAS},
- //{"nomemo", MapFlag::NOMEMO},
- {"noteleport", MapFlag::NOTELEPORT},
- {"noreturn", MapFlag::NORETURN},
- {"monster_noteleport", MapFlag::MONSTER_NOTELEPORT},
- {"nosave", MapFlag::NOSAVE},
- //{"nobranch", MapFlag::NOBRANCH},
- {"nopenalty", MapFlag::NOPENALTY},
- {"pvp", MapFlag::PVP},
- {"pvp_noparty", MapFlag::PVP_NOPARTY},
- //{"pvp_noguild", MapFlag::PVP_NOGUILD},
- //{"pvp_nightmaredrop", MapFlag::PVP_NIGHTMAREDROP},
- {"pvp_nocalcrank", MapFlag::PVP_NOCALCRANK},
- //{"gvg", MapFlag::GVG},
- //{"gvg_noparty", MapFlag::GVG_NOPARTY},
- //{"nozenypenalty", MapFlag::NOZENYPENALTY},
- //{"notrade", MapFlag::NOTRADE},
- //{"noskill", MapFlag::NOSKILL},
- {"nowarp", MapFlag::NOWARP},
- {"nowarpto", MapFlag::NOWARPTO},
- {"nopvp", MapFlag::NOPVP},
- //{"noicewall", MapFlag::NOICEWALL},
- {"snow", MapFlag::SNOW},
- {"fog", MapFlag::FOG},
- {"sakura", MapFlag::SAKURA},
- {"leaves", MapFlag::LEAVES},
- {"rain", MapFlag::RAIN},
- {"no_player_drops", MapFlag::NO_PLAYER_DROPS},
- {"town", MapFlag::TOWN},
- {"outside", MapFlag::OUTSIDE},
- {"resave", MapFlag::RESAVE},
+ //{ZString("alias"), MapFlag::ALIAS},
+ //{ZString("nomemo"), MapFlag::NOMEMO},
+ {ZString("noteleport"), MapFlag::NOTELEPORT},
+ {ZString("noreturn"), MapFlag::NORETURN},
+ {ZString("monster_noteleport"), MapFlag::MONSTER_NOTELEPORT},
+ {ZString("nosave"), MapFlag::NOSAVE},
+ //{ZString("nobranch"), MapFlag::NOBRANCH},
+ {ZString("nopenalty"), MapFlag::NOPENALTY},
+ {ZString("pvp"), MapFlag::PVP},
+ {ZString("pvp_noparty"), MapFlag::PVP_NOPARTY},
+ //{ZString("pvp_noguild"), MapFlag::PVP_NOGUILD},
+ //{ZString("pvp_nightmaredrop"), MapFlag::PVP_NIGHTMAREDROP},
+ {ZString("pvp_nocalcrank"), MapFlag::PVP_NOCALCRANK},
+ //{ZString("gvg"), MapFlag::GVG},
+ //{ZString("gvg_noparty"), MapFlag::GVG_NOPARTY},
+ //{ZString("nozenypenalty"), MapFlag::NOZENYPENALTY},
+ //{ZString("notrade"), MapFlag::NOTRADE},
+ //{ZString("noskill"), MapFlag::NOSKILL},
+ {ZString("nowarp"), MapFlag::NOWARP},
+ {ZString("nowarpto"), MapFlag::NOWARPTO},
+ {ZString("nopvp"), MapFlag::NOPVP},
+ //{ZString("noicewall"), MapFlag::NOICEWALL},
+ {ZString("snow"), MapFlag::SNOW},
+ {ZString("fog"), MapFlag::FOG},
+ {ZString("sakura"), MapFlag::SAKURA},
+ {ZString("leaves"), MapFlag::LEAVES},
+ {ZString("rain"), MapFlag::RAIN},
+ {ZString("no_player_drops"), MapFlag::NO_PLAYER_DROPS},
+ {ZString("town"), MapFlag::TOWN},
+ {ZString("outside"), MapFlag::OUTSIDE},
+ {ZString("resave"), MapFlag::RESAVE},
};
for (auto& pair : flags)
if (str == pair.str)
diff --git a/src/map/mob.cpp b/src/map/mob.cpp
index 61dcfb6..c4a4304 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -1305,7 +1305,7 @@ int mob_can_reach(dumb_ptr<mob_data> md, dumb_ptr<block_list> bl, int range)
int mob_target(dumb_ptr<mob_data> md, dumb_ptr<block_list> bl, int dist)
{
dumb_ptr<map_session_data> sd;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
MobMode mode;
nullpo_ret(md);
@@ -3560,15 +3560,15 @@ bool extract<MobSkillCondition, void, void>(XString str, MobSkillCondition *msc)
{
const struct
{
- char str[32];
+ ZString str;
MobSkillCondition id;
} cond1[] =
{
- {"always", MobSkillCondition::MSC_ALWAYS},
- {"myhpltmaxrate", MobSkillCondition::MSC_MYHPLTMAXRATE},
- {"notintown", MobSkillCondition::MSC_NOTINTOWN},
- {"slavelt", MobSkillCondition::MSC_SLAVELT},
- {"slavele", MobSkillCondition::MSC_SLAVELE},
+ {ZString("always"), MobSkillCondition::MSC_ALWAYS},
+ {ZString("myhpltmaxrate"), MobSkillCondition::MSC_MYHPLTMAXRATE},
+ {ZString("notintown"), MobSkillCondition::MSC_NOTINTOWN},
+ {ZString("slavelt"), MobSkillCondition::MSC_SLAVELT},
+ {ZString("slavele"), MobSkillCondition::MSC_SLAVELE},
};
for (auto& pair : cond1)
if (str == pair.str)
@@ -3584,14 +3584,14 @@ bool extract<MobSkillState, void, void>(XString str, MobSkillState *mss)
{
const struct
{
- char str[32];
+ ZString str;
MobSkillState id;
} state[] =
{
- {"any", MobSkillState::ANY},
- {"idle", MobSkillState::MSS_IDLE},
- {"walk", MobSkillState::MSS_WALK},
- {"attack", MobSkillState::MSS_ATTACK},
+ {ZString("any"), MobSkillState::ANY},
+ {ZString("idle"), MobSkillState::MSS_IDLE},
+ {ZString("walk"), MobSkillState::MSS_WALK},
+ {ZString("attack"), MobSkillState::MSS_ATTACK},
};
for (auto& pair : state)
if (str == pair.str)
@@ -3607,12 +3607,12 @@ bool extract<MobSkillTarget, void, void>(XString str, MobSkillTarget *mst)
{
const struct
{
- char str[32];
+ ZString str;
MobSkillTarget id;
} target[] =
{
- {"target", MobSkillTarget::MST_TARGET},
- {"self", MobSkillTarget::MST_SELF},
+ {ZString("target"), MobSkillTarget::MST_TARGET},
+ {ZString("self"), MobSkillTarget::MST_SELF},
};
for (auto& pair : target)
if (str == pair.str)
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index dd75691..514c042 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -200,7 +200,7 @@ void npc_timer_event(NpcEvent eventname)
*/
static
void npc_event_doall_sub(NpcEvent key, struct event_data *ev,
- int *c, ScriptLabel name, int rid, int argc, argrec_t *argv)
+ int *c, ScriptLabel name, int rid, Slice<argrec_t> argv)
{
ScriptLabel p = key.label;
@@ -209,45 +209,45 @@ void npc_event_doall_sub(NpcEvent key, struct event_data *ev,
if (name == p)
{
run_script_l(ScriptPointer(ev->nd->scr.script.get(), ev->pos), rid, ev->nd->bl_id,
- argc, argv);
+ argv);
(*c)++;
}
}
-int npc_event_doall_l(ScriptLabel name, int rid, int argc, argrec_t *args)
+int npc_event_doall_l(ScriptLabel name, int rid, Slice<argrec_t> args)
{
int c = 0;
for (auto& pair : ev_db)
- npc_event_doall_sub(pair.first, &pair.second, &c, name, rid, argc, args);
+ npc_event_doall_sub(pair.first, &pair.second, &c, name, rid, args);
return c;
}
static
void npc_event_do_sub(NpcEvent key, struct event_data *ev,
- int *c, NpcEvent name, int rid, int argc, argrec_t *argv)
+ int *c, NpcEvent name, int rid, Slice<argrec_t> argv)
{
nullpo_retv(ev);
if (name == key)
{
run_script_l(ScriptPointer(ev->nd->scr.script.get(), ev->pos), rid, ev->nd->bl_id,
- argc, argv);
+ argv);
(*c)++;
}
}
-int npc_event_do_l(NpcEvent name, int rid, int argc, argrec_t *args)
+int npc_event_do_l(NpcEvent name, int rid, Slice<argrec_t> args)
{
int c = 0;
if (!name.npc)
{
- return npc_event_doall_l(name.label, rid, argc, args);
+ return npc_event_doall_l(name.label, rid, args);
}
for (auto& pair : ev_db)
- npc_event_do_sub(pair.first, &pair.second, &c, name, rid, argc, args);
+ npc_event_do_sub(pair.first, &pair.second, &c, name, rid, args);
return c;
}
diff --git a/src/map/npc.hpp b/src/map/npc.hpp
index 93f2030..8d2dc5b 100644
--- a/src/map/npc.hpp
+++ b/src/map/npc.hpp
@@ -51,17 +51,17 @@ void npc_delsrcfile(XString);
bool do_init_npc(void);
int npc_event_do_oninit(void);
-int npc_event_doall_l(ScriptLabel name, int rid, int argc, struct argrec_t *argv);
-int npc_event_do_l(NpcEvent name, int rid, int argc, struct argrec_t *argv);
+int npc_event_doall_l(ScriptLabel name, int rid, Slice<argrec_t> argv);
+int npc_event_do_l(NpcEvent name, int rid, Slice<argrec_t> argv);
inline
int npc_event_doall(ScriptLabel name)
{
- return npc_event_doall_l(name, 0, 0, NULL);
+ return npc_event_doall_l(name, 0, nullptr);
}
inline
int npc_event_do(NpcEvent name)
{
- return npc_event_do_l(name, 0, 0, NULL);
+ return npc_event_do_l(name, 0, nullptr);
}
void npc_timerevent_start(dumb_ptr<npc_data_script> nd);
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 10c2b22..343e0fc 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -589,7 +589,7 @@ static
int pc_isequip(dumb_ptr<map_session_data> sd, int n)
{
struct item_data *item;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
//転生や養子の場合の元の職業を算出する
nullpo_ret(sd);
@@ -1074,7 +1074,7 @@ int pc_calcstatus(dumb_ptr<map_session_data> sd, int first)
};
run_script_l(ScriptPointer(sd->inventory_data[index]->equip_script.get(), 0),
sd->bl_id, 0,
- 2, arg);
+ arg);
}
sd->state.lr_flag = 0;
}
@@ -1091,7 +1091,7 @@ int pc_calcstatus(dumb_ptr<map_session_data> sd, int first)
sd->attackrange += sd->inventory_data[index]->range;
run_script_l(ScriptPointer(sd->inventory_data[index]->equip_script.get(), 0),
sd->bl_id, 0,
- 2, arg);
+ arg);
}
}
else if (sd->inventory_data[index]->type == ItemType::ARMOR)
@@ -1104,7 +1104,7 @@ int pc_calcstatus(dumb_ptr<map_session_data> sd, int first)
sd->watk += sd->inventory_data[index]->atk;
run_script_l(ScriptPointer(sd->inventory_data[index]->equip_script.get(), 0),
sd->bl_id, 0,
- 2, arg);
+ arg);
}
}
}
@@ -1130,7 +1130,7 @@ int pc_calcstatus(dumb_ptr<map_session_data> sd, int first)
sd->state.lr_flag = 2;
run_script_l(ScriptPointer(sd->inventory_data[index]->equip_script.get(), 0),
sd->bl_id, 0,
- 2, arg);
+ arg);
sd->state.lr_flag = 0;
sd->arrow_atk += sd->inventory_data[index]->atk;
}
@@ -2702,7 +2702,7 @@ void pc_attack_timer(TimerData *, tick_t tick, int id)
{
dumb_ptr<map_session_data> sd;
dumb_ptr<block_list> bl;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
int dist, range;
sd = map_id2sd(id);
@@ -3514,10 +3514,10 @@ int pc_damage(dumb_ptr<block_list> src, dumb_ptr<map_session_data> sd,
{"@victimrid", sd->bl_id},
{"@victimlvl", sd->status.base_level},
};
- npc_event_doall_l(stringish<ScriptLabel>("OnPCKilledEvent"), sd->bl_id, 3, arg);
- npc_event_doall_l(stringish<ScriptLabel>("OnPCKillEvent"), src->bl_id, 3, arg);
+ npc_event_doall_l(stringish<ScriptLabel>("OnPCKilledEvent"), sd->bl_id, arg);
+ npc_event_doall_l(stringish<ScriptLabel>("OnPCKillEvent"), src->bl_id, arg);
}
- npc_event_doall_l(stringish<ScriptLabel>("OnPCDieEvent"), sd->bl_id, 0, NULL);
+ npc_event_doall_l(stringish<ScriptLabel>("OnPCDieEvent"), sd->bl_id, nullptr);
return 0;
}
@@ -4084,6 +4084,7 @@ int pc_readglobalreg(dumb_ptr<map_session_data> sd, VarName reg)
nullpo_ret(sd);
+ assert (sd->status.global_reg_num < GLOBAL_REG_NUM);
for (i = 0; i < sd->status.global_reg_num; i++)
{
if (sd->status.global_reg[i].str == reg)
@@ -4109,6 +4110,7 @@ int pc_setglobalreg(dumb_ptr<map_session_data> sd, VarName reg, int val)
sd->die_counter = val;
pc_calcstatus(sd, 0);
}
+ assert (sd->status.global_reg_num < GLOBAL_REG_NUM);
if (val == 0)
{
for (i = 0; i < sd->status.global_reg_num; i++)
@@ -4155,6 +4157,7 @@ int pc_readaccountreg(dumb_ptr<map_session_data> sd, VarName reg)
nullpo_ret(sd);
+ assert (sd->status.account_reg_num < ACCOUNT_REG_NUM);
for (i = 0; i < sd->status.account_reg_num; i++)
{
if (sd->status.account_reg[i].str == reg)
diff --git a/src/map/script.cpp b/src/map/script.cpp
index cbb6d96..18055b8 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -78,20 +78,20 @@ Map<ScriptLabel, int> scriptlabel_db;
UPMap<RString, const ScriptBuffer> userfunc_db;
static
-const char *pos_str[11] =
-{
- "Head",
- "Body",
- "Left hand",
- "Right hand",
- "Robe",
- "Shoes",
- "Accessory 1",
- "Accessory 2",
- "Head 2",
- "Head 3",
- "Not Equipped",
-};
+Array<ZString, 11> pos_str //=
+{{
+ ZString("Head"),
+ ZString("Body"),
+ ZString("Left hand"),
+ ZString("Right hand"),
+ ZString("Robe"),
+ ZString("Shoes"),
+ ZString("Accessory 1"),
+ ZString("Accessory 2"),
+ ZString("Head 2"),
+ ZString("Head 3"),
+ ZString("Not Equipped"),
+}};
static
struct Script_Config
@@ -2202,8 +2202,8 @@ void builtin_strcharinfo(ScriptState *st)
// indexed by the equip_* in db/const.txt
// TODO change to use EQUIP
static
-EPOS equip[11] =
-{
+Array<EPOS, 11> equip //=
+{{
EPOS::HAT,
EPOS::MISC1,
EPOS::SHIELD,
@@ -2215,7 +2215,7 @@ EPOS equip[11] =
EPOS::TORSO,
EPOS::LEGS,
EPOS::ARROW,
-};
+}};
/*==========================================
* GetEquipID(Pos); Pos: 1-10
@@ -4693,11 +4693,11 @@ void run_script_main(ScriptState *st, const ScriptBuffer *rootscript)
*/
int run_script(ScriptPointer sp, int rid, int oid)
{
- return run_script_l(sp, rid, oid, 0, NULL);
+ return run_script_l(sp, rid, oid, nullptr);
}
int run_script_l(ScriptPointer sp, int rid, int oid,
- int args_nr, argrec_t *args)
+ Slice<argrec_t> args)
{
struct script_stack stack;
ScriptState st;
@@ -4717,7 +4717,7 @@ int run_script_l(ScriptPointer sp, int rid, int oid,
st.scriptp = sp;
st.rid = rid;
st.oid = oid;
- for (i = 0; i < args_nr; i++)
+ for (i = 0; i < args.size(); i++)
{
if (args[i].name.back() == '$')
pc_setregstr(sd, SIR::from(variable_names.intern(args[i].name)), args[i].v.s);
diff --git a/src/map/script.hpp b/src/map/script.hpp
index 8c072b3..ea087c2 100644
--- a/src/map/script.hpp
+++ b/src/map/script.hpp
@@ -6,6 +6,8 @@
# include <vector>
+# include "../range/slice.hpp"
+
# include "../strings/rstring.hpp"
# include "../strings/astring.hpp"
# include "../strings/zstring.hpp"
@@ -153,7 +155,7 @@ struct argrec_t
argrec_t(ZString n, int i) : name(n), v(i) {}
argrec_t(ZString n, ZString z) : name(n), v(z) {}
};
-int run_script_l(ScriptPointer, int, int, int, argrec_t *args);
+int run_script_l(ScriptPointer, int, int, Slice<argrec_t> args);
int run_script(ScriptPointer, int, int);
struct ScriptLabel;
diff --git a/src/map/skill-pools.cpp b/src/map/skill-pools.cpp
index 31998f8..2ac3a93 100644
--- a/src/map/skill-pools.cpp
+++ b/src/map/skill-pools.cpp
@@ -7,7 +7,7 @@
#include "../poison.hpp"
-SkillID skill_pool_skills[MAX_POOL_SKILLS];
+Array<SkillID, MAX_POOL_SKILLS> skill_pool_skills;
int skill_pool_skills_size = 0;
void skill_pool_register(SkillID id)
diff --git a/src/map/skill.cpp b/src/map/skill.cpp
index 72d7f7a..c29704a 100644
--- a/src/map/skill.cpp
+++ b/src/map/skill.cpp
@@ -232,7 +232,7 @@ int skill_attack(BF attack_type, dumb_ptr<block_list> src,
SkillID skillid, int skilllv, tick_t tick, BCT flag)
{
struct Damage dmg;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
int type, lv, damage;
nullpo_ret(src);
@@ -550,7 +550,7 @@ int skill_castend_nodamage_id(dumb_ptr<block_list> src, dumb_ptr<block_list> bl,
interval_t skill_castfix(dumb_ptr<block_list> bl, interval_t interval)
{
dumb_ptr<mob_data> md; // [Valaris]
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
int dex;
int castrate = 100;
SkillID skill;
@@ -601,7 +601,7 @@ interval_t skill_castfix(dumb_ptr<block_list> bl, interval_t interval)
*/
interval_t skill_delayfix(dumb_ptr<block_list> bl, interval_t interval)
{
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_retr(interval_t::zero(), bl);
@@ -663,7 +663,7 @@ int skill_castcancel(dumb_ptr<block_list> bl, int)
*/
int skill_status_change_active(dumb_ptr<block_list> bl, StatusChange type)
{
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
nullpo_ret(bl);
if (bl->bl_type != BL::PC && bl->bl_type != BL::MOB)
@@ -682,7 +682,7 @@ int skill_status_change_active(dumb_ptr<block_list> bl, StatusChange type)
void skill_status_change_end(dumb_ptr<block_list> bl, StatusChange type, TimerData *tid)
{
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
int opt_flag = 0, calc_flag = 0;
short *sc_count;
Option *option;
@@ -806,7 +806,7 @@ void skill_status_change_timer(TimerData *tid, tick_t tick, int id, StatusChange
{
dumb_ptr<block_list> bl;
dumb_ptr<map_session_data> sd = NULL;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
//short *sc_count; //使ってない?
if ((bl = map_id2bl(id)) == NULL)
@@ -907,7 +907,7 @@ int skill_status_effect(dumb_ptr<block_list> bl, StatusChange type,
interval_t tick, int spell_invocation)
{
dumb_ptr<map_session_data> sd = NULL;
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
short *sc_count;
Option *option;
Opt1 *opt1;
@@ -1081,7 +1081,7 @@ int skill_status_effect(dumb_ptr<block_list> bl, StatusChange type,
*/
int skill_status_change_clear(dumb_ptr<block_list> bl, int type)
{
- eptr<struct status_change, StatusChange> sc_data;
+ eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data;
short *sc_count;
Option *option;
Opt1 *opt1;
diff --git a/src/map/skill.hpp b/src/map/skill.hpp
index b612268..ece2ab5 100644
--- a/src/map/skill.hpp
+++ b/src/map/skill.hpp
@@ -22,17 +22,16 @@ struct skill_db_
SkillFlags poolflags;
int max_raise; // `max' is the global max, `max_raise' is the maximum attainable via skill-ups
int num_k;
- int cast[MAX_SKILL_LEVEL], delay[MAX_SKILL_LEVEL];
- int upkeep_time[MAX_SKILL_LEVEL], upkeep_time2[MAX_SKILL_LEVEL];
+ Array<int, MAX_SKILL_LEVEL> cast, delay;
+ Array<int, MAX_SKILL_LEVEL> upkeep_time, upkeep_time2;
bool castcancel;
int cast_def_rate;
int inf2, maxcount;
- int hp[MAX_SKILL_LEVEL], sp[MAX_SKILL_LEVEL], mhp[MAX_SKILL_LEVEL],
- hp_rate[MAX_SKILL_LEVEL], sp_rate[MAX_SKILL_LEVEL],
- zeny[MAX_SKILL_LEVEL];
+ Array<int, MAX_SKILL_LEVEL> hp, sp, mhp,
+ hprate, sp_rate,
+ zeny;
int weapon;
- int itemid[10], amount[10];
- int castnodex[MAX_SKILL_LEVEL];
+ Array<int, MAX_SKILL_LEVEL> castnodex;
};
extern
earray<skill_db_, SkillID, SkillID::MAX_SKILL_DB> skill_db;
@@ -115,7 +114,7 @@ constexpr int MAX_SKILL_POOL = 3;
// Max. # of skills that may be classified as pool skills in db/skill_db.txt
constexpr int MAX_POOL_SKILLS = 128;
-extern SkillID skill_pool_skills[MAX_POOL_SKILLS]; // All pool skills
+extern Array<SkillID, MAX_POOL_SKILLS> skill_pool_skills; // All pool skills
extern int skill_pool_skills_size; // Number of entries in skill_pool_skills
// Yields all active skills in the skill pool; no more than MAX_SKILL_POOL. Return is number of skills.
diff --git a/src/map/tmw.hpp b/src/map/tmw.hpp
index 65e71fb..65eb28a 100644
--- a/src/map/tmw.hpp
+++ b/src/map/tmw.hpp
@@ -3,8 +3,6 @@
# include "../strings/fwd.hpp"
-# include "../generic/const_array.hpp"
-
# include "../mmo/dumb_ptr.hpp"
# include "map.hpp"
diff --git a/src/map/trade.cpp b/src/map/trade.cpp
index e9c5fd4..bd6e2bf 100644
--- a/src/map/trade.cpp
+++ b/src/map/trade.cpp
@@ -137,7 +137,7 @@ void trade_tradeadditem(dumb_ptr<map_session_data> sd, int index, int amount)
&& target_sd->inventory_data[i] == NULL)
free_++;
}
- for (trade_i = 0; trade_i < 10; trade_i++)
+ for (trade_i = 0; trade_i < TRADE_MAX; trade_i++)
{
if (sd->deal_item_amount[trade_i] == 0)
{
@@ -238,7 +238,7 @@ void trade_tradeok(dumb_ptr<map_session_data> sd)
nullpo_retv(sd);
- for (trade_i = 0; trade_i < 10; trade_i++)
+ for (trade_i = 0; trade_i < TRADE_MAX; trade_i++)
{
if (sd->deal_item_amount[trade_i] >
sd->status.inventory[sd->deal_item_index[trade_i] - 2].amount
@@ -272,7 +272,7 @@ void trade_tradecancel(dumb_ptr<map_session_data> sd)
if ((target_sd = map_id2sd(sd->trade_partner)) != NULL)
{
- for (trade_i = 0; trade_i < 10; trade_i++)
+ for (trade_i = 0; trade_i < TRADE_MAX; trade_i++)
{ //give items back (only virtual)
if (sd->deal_item_amount[trade_i] != 0)
{
@@ -352,7 +352,7 @@ void trade_tradecommit(dumb_ptr<map_session_data> sd)
}
sd->trade_partner = 0;
target_sd->trade_partner = 0;
- for (trade_i = 0; trade_i < 10; trade_i++)
+ for (trade_i = 0; trade_i < TRADE_MAX; trade_i++)
{
if (sd->deal_item_amount[trade_i] != 0)
{