summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.cpp66
-rw-r--r--src/map/atcommand.hpp6
-rw-r--r--src/map/battle.cpp373
-rw-r--r--src/map/battle.hpp113
-rw-r--r--src/map/battle.t.hpp3
-rw-r--r--src/map/chrif.cpp68
-rw-r--r--src/map/chrif.hpp14
-rw-r--r--src/map/clif.cpp61
-rw-r--r--src/map/clif.hpp8
-rw-r--r--src/map/consts.hpp34
-rw-r--r--src/map/fwd.hpp17
-rw-r--r--src/map/globals.cpp147
-rw-r--r--src/map/globals.hpp108
-rw-r--r--src/map/grfio.cpp8
-rw-r--r--src/map/grfio.hpp3
-rw-r--r--src/map/intif.cpp5
-rw-r--r--src/map/intif.hpp3
-rw-r--r--src/map/itemdb.cpp7
-rw-r--r--src/map/itemdb.hpp3
-rw-r--r--src/map/magic-expr-eval.hpp3
-rw-r--r--src/map/magic-expr.cpp3
-rw-r--r--src/map/magic-expr.hpp3
-rw-r--r--src/map/magic-expr.py6
-rw-r--r--src/map/magic-interpreter-base.cpp7
-rw-r--r--src/map/magic-interpreter-base.hpp6
-rw-r--r--src/map/magic-interpreter.hpp3
-rw-r--r--src/map/magic-interpreter.py208
-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-stmt.py6
-rw-r--r--src/map/magic-v2.cpp9
-rw-r--r--src/map/magic-v2.hpp3
-rw-r--r--src/map/magic.cpp4
-rw-r--r--src/map/magic.hpp3
-rw-r--r--src/map/main.cpp3
-rw-r--r--src/map/map.cpp335
-rw-r--r--src/map/map.hpp25
-rw-r--r--src/map/map.py34
-rw-r--r--src/map/map.t.hpp3
-rw-r--r--src/map/mapflag.cpp3
-rw-r--r--src/map/mapflag.hpp3
-rw-r--r--src/map/mapflag.py10
-rw-r--r--src/map/mob.cpp25
-rw-r--r--src/map/mob.hpp5
-rw-r--r--src/map/mob.t.hpp3
-rw-r--r--src/map/npc-internal.hpp11
-rw-r--r--src/map/npc-parse.cpp11
-rw-r--r--src/map/npc-parse.hpp3
-rw-r--r--src/map/npc.cpp26
-rw-r--r--src/map/npc.hpp3
-rw-r--r--src/map/party.cpp8
-rw-r--r--src/map/party.hpp3
-rw-r--r--src/map/path.cpp3
-rw-r--r--src/map/path.hpp3
-rw-r--r--src/map/pc.cpp49
-rw-r--r--src/map/pc.hpp3
-rw-r--r--src/map/pc.t.hpp3
-rw-r--r--src/map/script-buffer.hpp9
-rw-r--r--src/map/script-call-internal.hpp3
-rw-r--r--src/map/script-call-internal.tcc3
-rw-r--r--src/map/script-call.cpp5
-rw-r--r--src/map/script-call.hpp3
-rw-r--r--src/map/script-call.t.hpp3
-rw-r--r--src/map/script-fun.cpp7
-rw-r--r--src/map/script-fun.hpp3
-rw-r--r--src/map/script-parse-internal.hpp8
-rw-r--r--src/map/script-parse.cpp32
-rw-r--r--src/map/script-parse.hpp10
-rw-r--r--src/map/script-parse.py18
-rw-r--r--src/map/script-persist.hpp5
-rw-r--r--src/map/script-persist.py38
-rw-r--r--src/map/script-startup-internal.hpp10
-rw-r--r--src/map/script-startup.cpp15
-rw-r--r--src/map/script-startup.hpp5
-rw-r--r--src/map/skill-pools.cpp19
-rw-r--r--src/map/skill-pools.hpp3
-rw-r--r--src/map/skill.cpp22
-rw-r--r--src/map/skill.hpp13
-rw-r--r--src/map/storage.cpp7
-rw-r--r--src/map/storage.hpp3
-rw-r--r--src/map/tmw.cpp27
-rw-r--r--src/map/tmw.hpp3
-rw-r--r--src/map/trade.cpp5
-rw-r--r--src/map/trade.hpp3
85 files changed, 934 insertions, 1243 deletions
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp
index 5853dc2..cd51b70 100644
--- a/src/map/atcommand.cpp
+++ b/src/map/atcommand.cpp
@@ -60,11 +60,14 @@
#include "../ast/npc.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "chrif.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "intif.hpp"
#include "itemdb.hpp"
#include "map.hpp"
+#include "map_conf.hpp"
#include "mob.hpp"
#include "npc.hpp"
#include "npc-parse.hpp"
@@ -80,6 +83,8 @@
namespace tmwa
{
+namespace map
+{
enum class ATCE
{
OKAY,
@@ -215,11 +220,9 @@ void log_atcommand(dumb_ptr<map_session_data> sd, ZString cmd)
cmd);
}
-AString gm_log;
-
io::AppendFile *get_gm_log()
{
- if (!gm_log)
+ if (!map_conf.gm_log)
return nullptr;
struct tm ctime = TimeT::now();
@@ -235,7 +238,7 @@ io::AppendFile *get_gm_log()
last_logfile_nr = logfile_nr;
AString fullname = STRPRINTF("%s.%04d-%02d"_fmt,
- gm_log, year, month);
+ map_conf.gm_log, year, month);
if (gm_logfile)
gm_logfile.reset();
@@ -245,7 +248,7 @@ io::AppendFile *get_gm_log()
if (!gm_logfile)
{
perror("GM log file");
- gm_log = AString();
+ map_conf.gm_log = AString();
}
return gm_logfile.get();
}
@@ -527,14 +530,14 @@ ATCE atcommand_charwarp(Session *s, dumb_ptr<map_session_data> sd,
{
Option<P<map_local>> m = map_mapname2mapid(map_name);
if (m.map([](P<map_local> m_){ return m_->flag.get(MapFlag::NOWARPTO); }).copy_or(false)
- && !pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level))))
+ && !pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level))
{
clif_displaymessage(s,
"You are not authorised to warp someone to this map."_s);
return ATCE::PERM;
}
if (pl_sd->bl_m->flag.get(MapFlag::NOWARP)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp this player from its actual map."_s);
@@ -596,14 +599,14 @@ ATCE atcommand_warp(Session *s, dumb_ptr<map_session_data> sd,
{
Option<P<map_local>> m = map_mapname2mapid(map_name);
if (m.map([](P<map_local> m_){ return m_->flag.get(MapFlag::NOWARPTO); }).copy_or(false)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp you to this map."_s);
return ATCE::PERM;
}
if (sd->bl_m->flag.get(MapFlag::NOWARP)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp you from your actual map."_s);
@@ -671,14 +674,14 @@ ATCE atcommand_goto(Session *s, dumb_ptr<map_session_data> sd,
if (pl_sd != nullptr)
{
if (pl_sd->bl_m->flag.get(MapFlag::NOWARPTO)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp you to the map of this player."_s);
return ATCE::PERM;
}
if (sd->bl_m->flag.get(MapFlag::NOWARP)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp you from your actual map."_s);
@@ -712,14 +715,14 @@ ATCE atcommand_jump(Session *s, dumb_ptr<map_session_data> sd,
if (x > 0 && x < 800 && y > 0 && y < 800)
{
if (sd->bl_m->flag.get(MapFlag::NOWARPTO)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp you to your actual map."_s);
return ATCE::PERM;
}
if (sd->bl_m->flag.get(MapFlag::NOWARP)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp you from your actual map."_s);
@@ -1064,14 +1067,14 @@ ATCE atcommand_load(Session *s, dumb_ptr<map_session_data> sd,
{
Option<P<map_local>> m = map_mapname2mapid(sd->status.save_point.map_);
if (m.map([](P<map_local> m_){ return m_->flag.get(MapFlag::NOWARPTO); }).copy_or(false)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp you to your save map."_s);
return ATCE::PERM;
}
if (sd->bl_m->flag.get(MapFlag::NOWARP)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp you from your actual map."_s);
@@ -1242,8 +1245,8 @@ ATCE atcommand_alive(Session *s, dumb_ptr<map_session_data> sd,
sd->status.hp = sd->status.max_hp;
sd->status.sp = sd->status.max_sp;
pc_setstand(sd);
- if (static_cast<interval_t>(battle_config.player_invincible_time) > interval_t::zero())
- pc_setinvincibletimer(sd, static_cast<interval_t>(battle_config.player_invincible_time));
+ if (battle_config.player_invincible_time > interval_t::zero())
+ pc_setinvincibletimer(sd, battle_config.player_invincible_time);
clif_updatestatus(sd, SP::HP);
clif_updatestatus(sd, SP::SP);
clif_resurrection(sd, 1);
@@ -2067,14 +2070,14 @@ ATCE atcommand_recall(Session *s, dumb_ptr<map_session_data> sd,
{
// you can recall only lower or same level
if (sd->bl_m->flag.get(MapFlag::NOWARPTO)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp somenone to your actual map."_s);
return ATCE::PERM;
}
if (pl_sd->bl_m->flag.get(MapFlag::NOWARP)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp this player from its actual map."_s);
@@ -2113,8 +2116,8 @@ ATCE atcommand_revive(Session *s, dumb_ptr<map_session_data> sd,
{
pl_sd->status.hp = pl_sd->status.max_hp;
pc_setstand(pl_sd);
- if (static_cast<interval_t>(battle_config.player_invincible_time) > interval_t::zero())
- pc_setinvincibletimer(sd, static_cast<interval_t>(battle_config.player_invincible_time));
+ if (battle_config.player_invincible_time > interval_t::zero())
+ pc_setinvincibletimer(sd, battle_config.player_invincible_time);
clif_updatestatus(pl_sd, SP::HP);
clif_updatestatus(pl_sd, SP::SP);
clif_resurrection(pl_sd, 1);
@@ -2397,7 +2400,7 @@ ATCE atcommand_character_save(Session *s, dumb_ptr<map_session_data> sd,
{
if (m->flag.get(MapFlag::NOWARPTO)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to set this map as a save map."_s);
@@ -3335,7 +3338,7 @@ ATCE atcommand_recallall(Session *s, dumb_ptr<map_session_data> sd,
int count;
if (sd->bl_m->flag.get(MapFlag::NOWARPTO)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp somenone to your actual map."_s);
@@ -3356,7 +3359,7 @@ ATCE atcommand_recallall(Session *s, dumb_ptr<map_session_data> sd,
{
// you can recall only lower or same level
if (pl_sd->bl_m->flag.get(MapFlag::NOWARP)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
count++;
else
pc_setpos(pl_sd, sd->mapname_, sd->bl_x, sd->bl_y, BeingRemoveWhy::QUIT);
@@ -3386,7 +3389,7 @@ ATCE atcommand_partyrecall(Session *s, dumb_ptr<map_session_data> sd,
return ATCE::USAGE;
if (sd->bl_m->flag.get(MapFlag::NOWARPTO)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp somenone to your actual map."_s);
@@ -3413,7 +3416,7 @@ ATCE atcommand_partyrecall(Session *s, dumb_ptr<map_session_data> sd,
&& pl_sd->status.party_id == p.party_id)
{
if (pl_sd->bl_m->flag.get(MapFlag::NOWARP)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
count++;
else
pc_setpos(pl_sd, sd->mapname_, sd->bl_x, sd->bl_y, BeingRemoveWhy::QUIT);
@@ -4661,14 +4664,14 @@ ATCE atcommand_jump_iterate(Session *s, dumb_ptr<map_session_data> sd,
}
if (pl_sd->bl_m->flag.get(MapFlag::NOWARPTO)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp you to the map of this player."_s);
return ATCE::PERM;
}
if (sd->bl_m->flag.get(MapFlag::NOWARP)
- && !(pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.any_warp_GM_min_level)))))
+ && !(pc_isGM(sd).satisfies(battle_config.any_warp_GM_min_level)))
{
clif_displaymessage(s,
"You are not authorised to warp you from your actual map."_s);
@@ -4739,11 +4742,11 @@ ATCE atcommand_skillpool_info(Session *s, dumb_ptr<map_session_data>,
clif_displaymessage(s, buf);
}
- buf = STRPRINTF("Learned skills out of %d for %s:"_fmt,
- skill_pool_skills_size, character);
+ buf = STRPRINTF("Learned skills out of %zu for %s:"_fmt,
+ skill_pool_skills.size(), character);
clif_displaymessage(s, buf);
- for (i = 0; i < skill_pool_skills_size; ++i)
+ for (i = 0; i < skill_pool_skills.size(); ++i)
{
const RString& name = skill_name(skill_pool_skills[i]);
int lvl = pl_sd->status.skill[skill_pool_skills[i]].lv;
@@ -5348,4 +5351,5 @@ Map<XString, AtCommandInfo> atcommand_info =
0, atcommand_source,
"Legal information about source code (must be a level 0 command!)"_s}},
};
+} // namespace map
} // namespace tmwa
diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp
index 745039d..4c0e421 100644
--- a/src/map/atcommand.hpp
+++ b/src/map/atcommand.hpp
@@ -25,6 +25,8 @@
namespace tmwa
{
+namespace map
+{
bool is_atcommand(Session *s, dumb_ptr<map_session_data> sd,
ZString message, GmLevel gmlvl);
@@ -32,8 +34,6 @@ bool atcommand_config_read(ZString cfgName);
void log_atcommand(dumb_ptr<map_session_data> sd, ZString cmd);
-// only used by map.cpp
-extern AString gm_log;
-
void atcommand_config_write(ZString cfgName);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/battle.cpp b/src/map/battle.cpp
index 983eac3..5b63acc 100644
--- a/src/map/battle.cpp
+++ b/src/map/battle.cpp
@@ -40,7 +40,9 @@
#include "../high/utils.hpp"
+#include "battle_conf.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "itemdb.hpp"
#include "map.hpp"
#include "mob.hpp"
@@ -53,13 +55,8 @@
namespace tmwa
{
-static Battle_Config init_battle_config();
-
-DIAG_PUSH();
-DIAG_I(shadow);
-struct Battle_Config battle_config = init_battle_config();
-DIAG_POP();
-
+namespace map
+{
/*==========================================
* 自分をロックしている対象の数を返す(汎用)
* 戻りは整数で0以上
@@ -729,7 +726,7 @@ interval_t battle_get_adelay(dumb_ptr<block_list> bl)
if (aspd_rate != 100)
adelay = adelay * aspd_rate / 100;
- return std::max(adelay, static_cast<interval_t>(battle_config.monster_max_aspd) * 2);
+ return std::max(adelay, battle_config.monster_max_aspd * 2);
}
}
@@ -744,7 +741,7 @@ interval_t battle_get_amotion(dumb_ptr<block_list> bl)
interval_t amotion = 2_s;
int aspd_rate = 100;
if (bl->bl_type == BL::MOB)
- amotion = static_cast<interval_t>(get_mob_db(bl->is_mob()->mob_class).amotion);
+ amotion = get_mob_db(bl->is_mob()->mob_class).amotion;
if (sc_data)
{
@@ -756,7 +753,7 @@ interval_t battle_get_amotion(dumb_ptr<block_list> bl)
if (aspd_rate != 100)
amotion = amotion * aspd_rate / 100;
- return std::max(amotion, static_cast<interval_t>(battle_config.monster_max_aspd));
+ return std::max(amotion, battle_config.monster_max_aspd);
}
}
@@ -765,7 +762,7 @@ interval_t battle_get_dmotion(dumb_ptr<block_list> bl)
nullpo_retr(interval_t::zero(), bl);
if (bl->bl_type == BL::MOB)
{
- return static_cast<interval_t>(get_mob_db(bl->is_mob()->mob_class).dmotion);
+ return get_mob_db(bl->is_mob()->mob_class).dmotion;
}
else if (bl->bl_type == BL::PC)
{
@@ -1064,7 +1061,7 @@ struct Damage battle_calc_mob_weapon_attack(dumb_ptr<block_list> src,
|| battle_config.vit_penaly_type > 0)
target_count +=
battle_counttargeted(target, src,
- ATK(battle_config.agi_penaly_count_lv)); // FIXME
+ battle_config.agi_penaly_count_lv);
if (battle_config.agi_penaly_type > 0)
{
if (target_count >= battle_config.agi_penaly_count)
@@ -1150,7 +1147,7 @@ struct Damage battle_calc_mob_weapon_attack(dumb_ptr<block_list> src,
int t_def;
target_count =
1 + battle_counttargeted(target, src,
- ATK(battle_config.vit_penaly_count_lv)); // FIXME
+ battle_config.vit_penaly_count_lv);
if (battle_config.vit_penaly_type > 0)
{
if (target_count >= battle_config.vit_penaly_count)
@@ -1342,7 +1339,7 @@ struct Damage battle_calc_pc_weapon_attack(dumb_ptr<block_list> src,
flee = battle_get_flee(target);
if (battle_config.agi_penaly_type > 0 || battle_config.vit_penaly_type > 0) //AGI、VITペナルティ設定が有効
target_count += battle_counttargeted(target, src,
- ATK(battle_config.agi_penaly_count_lv)); //対象の数を算出
+ battle_config.agi_penaly_count_lv); //対象の数を算出
if (battle_config.agi_penaly_type > 0)
{
if (target_count >= battle_config.agi_penaly_count)
@@ -1486,7 +1483,7 @@ struct Damage battle_calc_pc_weapon_attack(dumb_ptr<block_list> src,
int t_def;
target_count =
1 + battle_counttargeted(target, src,
- ATK(battle_config.vit_penaly_count_lv)); // FIXME
+ battle_config.vit_penaly_count_lv);
if (battle_config.vit_penaly_type > 0)
{
if (target_count >= battle_config.vit_penaly_count)
@@ -2168,349 +2165,5 @@ int battle_check_range(dumb_ptr<block_list> src, dumb_ptr<block_list> bl,
return (path_search(&wpd, src->bl_m, src->bl_x + dx, src->bl_y + dy,
bl->bl_x - dx, bl->bl_y - dy, 0x10001) != -1) ? 1 : 0;
}
-
-Battle_Config init_battle_config()
-{
- DIAG_PUSH();
- DIAG_I(shadow);
- Battle_Config battle_config;
- DIAG_POP();
- {
- battle_config.warp_point_debug = 0;
- battle_config.enemy_critical = 0;
- battle_config.enemy_critical_rate = 100;
- battle_config.enemy_str = 1;
- battle_config.enemy_perfect_flee = 0;
- battle_config.casting_rate = 100;
- battle_config.delay_rate = 100;
- battle_config.delay_dependon_dex = 0;
- battle_config.skill_delay_attack_enable = 0;
- battle_config.monster_skill_add_range = 0;
- battle_config.player_damage_delay = 1;
- battle_config.flooritem_lifetime = std::chrono::duration_cast<std::chrono::milliseconds>(LIFETIME_FLOORITEM).count();
- battle_config.item_auto_get = 0;
- battle_config.drop_pickup_safety_zone = 20;
- battle_config.item_first_get_time = 3000;
- battle_config.item_second_get_time = 1000;
- battle_config.item_third_get_time = 1000;
-
- battle_config.base_exp_rate = 100;
- battle_config.job_exp_rate = 100;
- battle_config.death_penalty_type = 0;
- battle_config.death_penalty_base = 0;
- battle_config.death_penalty_job = 0;
- battle_config.restart_hp_rate = 0;
- battle_config.restart_sp_rate = 0;
- battle_config.monster_hp_rate = 100;
- battle_config.monster_max_aspd = 199;
- battle_config.atcommand_gm_only = 0;
- battle_config.gm_all_equipment = 0;
- battle_config.monster_active_enable = 1;
- battle_config.mob_skill_use = 1;
- battle_config.mob_count_rate = 100;
- battle_config.basic_skill_check = 1;
- battle_config.player_invincible_time = 5000;
- battle_config.skill_min_damage = 0;
- battle_config.natural_healhp_interval = 6000;
- battle_config.natural_healsp_interval = 8000;
- battle_config.natural_heal_weight_rate = 50;
- battle_config.itemheal_regeneration_factor = 1;
- battle_config.arrow_decrement = 1;
- battle_config.max_aspd = 199;
- battle_config.max_hp = 32500;
- battle_config.max_sp = 32500;
- battle_config.max_lv = 99; // [MouseJstr]
- battle_config.max_parameter = 99;
- battle_config.monster_skill_log = 0;
- battle_config.battle_log = 0;
- battle_config.save_log = 0;
- battle_config.error_log = 1;
- battle_config.etc_log = 1;
- battle_config.save_clothcolor = 0;
- battle_config.undead_detect_type = 0;
- battle_config.agi_penaly_type = 0;
- battle_config.agi_penaly_count = 3;
- battle_config.agi_penaly_num = 0;
- battle_config.agi_penaly_count_lv = static_cast<int>(ATK::FLEE); // FIXME
- battle_config.vit_penaly_type = 0;
- battle_config.vit_penaly_count = 3;
- battle_config.vit_penaly_num = 0;
- battle_config.vit_penaly_count_lv = static_cast<int>(ATK::DEF); // FIXME
- battle_config.mob_changetarget_byskill = 0;
- battle_config.player_attack_direction_change = 1;
- battle_config.monster_attack_direction_change = 1;
- battle_config.display_delay_skill_fail = 1;
- battle_config.hide_GM_session = 0;
- battle_config.invite_request_check = 1;
- battle_config.disp_experience = 0;
- battle_config.prevent_logout = 1; // Added by RoVeRT
- battle_config.maximum_level = 255; // Added by Valaris
- battle_config.drops_by_luk = 0; // [Valaris]
- battle_config.pk_mode = 0; // [Valaris]
- battle_config.multi_level_up = 0; // [Valaris]
- battle_config.hack_info_GM_level = 60; // added by [Yor] (default: 60, GM level)
- battle_config.any_warp_GM_min_level = 20; // added by [Yor]
- battle_config.min_hair_style = 0;
- battle_config.max_hair_style = 20;
- battle_config.min_hair_color = 0;
- battle_config.max_hair_color = 9;
- battle_config.min_cloth_color = 0;
- battle_config.max_cloth_color = 4;
-
- battle_config.castrate_dex_scale = 150;
-
- battle_config.area_size = 14;
-
- battle_config.chat_lame_penalty = 2;
- battle_config.chat_spam_threshold = 10;
- battle_config.chat_spam_flood = 10;
- battle_config.chat_spam_ban = 1;
- battle_config.chat_spam_warn = 8;
- battle_config.chat_maxline = 255;
-
- battle_config.packet_spam_threshold = 2;
- battle_config.packet_spam_flood = 30;
- battle_config.packet_spam_kick = 1;
-
- battle_config.mask_ip_gms = 1;
-
- battle_config.mob_splash_radius = -1;
- }
- return battle_config;
-}
-
-static
-bool battle_config_(io::Spanned<XString> w1, io::Spanned<ZString> w2)
-{
- {
-#define BATTLE_CONFIG_VAR(name) {#name##_s, &battle_config.name}
- const struct
- {
- LString str;
- int *val;
- } data[] =
- {
- BATTLE_CONFIG_VAR(warp_point_debug),
- BATTLE_CONFIG_VAR(enemy_critical),
- BATTLE_CONFIG_VAR(enemy_critical_rate),
- BATTLE_CONFIG_VAR(enemy_str),
- BATTLE_CONFIG_VAR(enemy_perfect_flee),
- BATTLE_CONFIG_VAR(casting_rate),
- BATTLE_CONFIG_VAR(delay_rate),
- BATTLE_CONFIG_VAR(delay_dependon_dex),
- BATTLE_CONFIG_VAR(skill_delay_attack_enable),
- BATTLE_CONFIG_VAR(monster_skill_add_range),
- BATTLE_CONFIG_VAR(player_damage_delay),
- BATTLE_CONFIG_VAR(flooritem_lifetime),
- BATTLE_CONFIG_VAR(item_auto_get),
- BATTLE_CONFIG_VAR(drop_pickup_safety_zone),
- BATTLE_CONFIG_VAR(item_first_get_time),
- BATTLE_CONFIG_VAR(item_second_get_time),
- BATTLE_CONFIG_VAR(item_third_get_time),
- BATTLE_CONFIG_VAR(base_exp_rate),
- BATTLE_CONFIG_VAR(job_exp_rate),
- BATTLE_CONFIG_VAR(death_penalty_type),
- BATTLE_CONFIG_VAR(death_penalty_base),
- BATTLE_CONFIG_VAR(death_penalty_job),
- BATTLE_CONFIG_VAR(restart_hp_rate),
- BATTLE_CONFIG_VAR(restart_sp_rate),
- BATTLE_CONFIG_VAR(monster_hp_rate),
- BATTLE_CONFIG_VAR(monster_max_aspd),
- BATTLE_CONFIG_VAR(atcommand_gm_only),
- BATTLE_CONFIG_VAR(atcommand_spawn_quantity_limit),
- BATTLE_CONFIG_VAR(gm_all_equipment),
- BATTLE_CONFIG_VAR(monster_active_enable),
- BATTLE_CONFIG_VAR(mob_skill_use),
- BATTLE_CONFIG_VAR(mob_count_rate),
- BATTLE_CONFIG_VAR(basic_skill_check),
- BATTLE_CONFIG_VAR(player_invincible_time),
- BATTLE_CONFIG_VAR(skill_min_damage),
- BATTLE_CONFIG_VAR(natural_healhp_interval),
- BATTLE_CONFIG_VAR(natural_healsp_interval),
- BATTLE_CONFIG_VAR(natural_heal_weight_rate),
- BATTLE_CONFIG_VAR(itemheal_regeneration_factor),
- BATTLE_CONFIG_VAR(arrow_decrement),
- BATTLE_CONFIG_VAR(max_aspd),
- BATTLE_CONFIG_VAR(max_hp),
- BATTLE_CONFIG_VAR(max_sp),
- BATTLE_CONFIG_VAR(max_lv),
- BATTLE_CONFIG_VAR(max_parameter),
- BATTLE_CONFIG_VAR(monster_skill_log),
- BATTLE_CONFIG_VAR(battle_log),
- BATTLE_CONFIG_VAR(save_log),
- BATTLE_CONFIG_VAR(error_log),
- BATTLE_CONFIG_VAR(etc_log),
- BATTLE_CONFIG_VAR(save_clothcolor),
- BATTLE_CONFIG_VAR(undead_detect_type),
- BATTLE_CONFIG_VAR(agi_penaly_type),
- BATTLE_CONFIG_VAR(agi_penaly_count),
- BATTLE_CONFIG_VAR(agi_penaly_num),
- BATTLE_CONFIG_VAR(agi_penaly_count_lv),
- BATTLE_CONFIG_VAR(vit_penaly_type),
- BATTLE_CONFIG_VAR(vit_penaly_count),
- BATTLE_CONFIG_VAR(vit_penaly_num),
- BATTLE_CONFIG_VAR(vit_penaly_count_lv),
- BATTLE_CONFIG_VAR(mob_changetarget_byskill),
- BATTLE_CONFIG_VAR(player_attack_direction_change),
- BATTLE_CONFIG_VAR(monster_attack_direction_change),
- BATTLE_CONFIG_VAR(display_delay_skill_fail),
- BATTLE_CONFIG_VAR(hide_GM_session),
- BATTLE_CONFIG_VAR(invite_request_check),
- BATTLE_CONFIG_VAR(disp_experience),
- BATTLE_CONFIG_VAR(prevent_logout), // Added by RoVeRT
- BATTLE_CONFIG_VAR(alchemist_summon_reward), // [Valaris]
- BATTLE_CONFIG_VAR(maximum_level), // [Valaris]
- BATTLE_CONFIG_VAR(drops_by_luk), // [Valaris]
- BATTLE_CONFIG_VAR(monsters_ignore_gm), // [Valaris]
- BATTLE_CONFIG_VAR(pk_mode), // [Valaris]
- BATTLE_CONFIG_VAR(multi_level_up), // [Valaris]
- BATTLE_CONFIG_VAR(hack_info_GM_level), // added by [Yor]
- BATTLE_CONFIG_VAR(any_warp_GM_min_level), // added by [Yor]
- BATTLE_CONFIG_VAR(min_hair_style), // added by [MouseJstr]
- BATTLE_CONFIG_VAR(max_hair_style), // added by [MouseJstr]
- BATTLE_CONFIG_VAR(min_hair_color), // added by [MouseJstr]
- BATTLE_CONFIG_VAR(max_hair_color), // added by [MouseJstr]
- BATTLE_CONFIG_VAR(min_cloth_color), // added by [MouseJstr]
- BATTLE_CONFIG_VAR(max_cloth_color), // added by [MouseJstr]
- BATTLE_CONFIG_VAR(castrate_dex_scale), // added by [MouseJstr]
- BATTLE_CONFIG_VAR(area_size), // added by [MouseJstr]
- BATTLE_CONFIG_VAR(chat_lame_penalty),
- BATTLE_CONFIG_VAR(chat_spam_threshold),
- BATTLE_CONFIG_VAR(chat_spam_flood),
- BATTLE_CONFIG_VAR(chat_spam_ban),
- BATTLE_CONFIG_VAR(chat_spam_warn),
- BATTLE_CONFIG_VAR(chat_maxline),
- BATTLE_CONFIG_VAR(packet_spam_threshold),
- BATTLE_CONFIG_VAR(packet_spam_flood),
- BATTLE_CONFIG_VAR(packet_spam_kick),
- BATTLE_CONFIG_VAR(mask_ip_gms),
- BATTLE_CONFIG_VAR(mob_splash_radius),
- };
-
- for (auto datum : data)
- {
- if (w1.data == datum.str)
- {
- *datum.val = config_switch(w2.data);
- return true;
- }
- }
-
- PRINTF("WARNING: unknown battle conf key: %s\n"_fmt, AString(w1.data));
- return false;
-
- }
-}
-
-bool battle_config_read(ZString cfgName)
-{
- return load_config_file(cfgName, battle_config_);
-}
-
-void battle_config_check()
-{
- {
- if (static_cast<interval_t>(battle_config.flooritem_lifetime) < 1_s)
- battle_config.flooritem_lifetime = std::chrono::duration_cast<std::chrono::milliseconds>(LIFETIME_FLOORITEM).count();
- if (battle_config.restart_hp_rate < 0)
- battle_config.restart_hp_rate = 0;
- else if (battle_config.restart_hp_rate > 100)
- battle_config.restart_hp_rate = 100;
- if (battle_config.restart_sp_rate < 0)
- battle_config.restart_sp_rate = 0;
- else if (battle_config.restart_sp_rate > 100)
- battle_config.restart_sp_rate = 100;
- if (battle_config.natural_healhp_interval < NATURAL_HEAL_INTERVAL.count())
- battle_config.natural_healhp_interval = NATURAL_HEAL_INTERVAL.count();
- if (battle_config.natural_healsp_interval < NATURAL_HEAL_INTERVAL.count())
- battle_config.natural_healsp_interval = NATURAL_HEAL_INTERVAL.count();
- if (battle_config.natural_heal_weight_rate < 50)
- battle_config.natural_heal_weight_rate = 50;
- if (battle_config.natural_heal_weight_rate > 101)
- battle_config.natural_heal_weight_rate = 101;
- battle_config.monster_max_aspd =
- 2000 - battle_config.monster_max_aspd * 10;
- if (battle_config.monster_max_aspd < 10)
- battle_config.monster_max_aspd = 10;
- if (battle_config.monster_max_aspd > 1000)
- battle_config.monster_max_aspd = 1000;
- battle_config.max_aspd = 2000 - battle_config.max_aspd * 10;
- if (battle_config.max_aspd < 10)
- battle_config.max_aspd = 10;
- if (battle_config.max_aspd > 1000)
- battle_config.max_aspd = 1000;
- if (battle_config.max_hp > 1000000)
- battle_config.max_hp = 1000000;
- if (battle_config.max_hp < 100)
- battle_config.max_hp = 100;
- if (battle_config.max_sp > 1000000)
- battle_config.max_sp = 1000000;
- if (battle_config.max_sp < 100)
- battle_config.max_sp = 100;
- if (battle_config.max_parameter < 10)
- battle_config.max_parameter = 10;
- if (battle_config.max_parameter > 10000)
- battle_config.max_parameter = 10000;
-
- if (battle_config.agi_penaly_count < 2)
- battle_config.agi_penaly_count = 2;
- if (battle_config.vit_penaly_count < 2)
- battle_config.vit_penaly_count = 2;
-
- if (battle_config.hack_info_GM_level < 0) // added by [Yor]
- battle_config.hack_info_GM_level = 0;
- else if (battle_config.hack_info_GM_level > 100)
- battle_config.hack_info_GM_level = 100;
-
- if (battle_config.any_warp_GM_min_level < 0) // added by [Yor]
- battle_config.any_warp_GM_min_level = 0;
- else if (battle_config.any_warp_GM_min_level > 100)
- battle_config.any_warp_GM_min_level = 100;
-
- if (battle_config.chat_spam_ban < 0)
- battle_config.chat_spam_ban = 0;
- else if (battle_config.chat_spam_ban > 32767)
- battle_config.chat_spam_ban = 32767;
-
- if (battle_config.chat_spam_flood < 0)
- battle_config.chat_spam_flood = 0;
- else if (battle_config.chat_spam_flood > 32767)
- battle_config.chat_spam_flood = 32767;
-
- if (battle_config.chat_spam_warn < 0)
- battle_config.chat_spam_warn = 0;
- else if (battle_config.chat_spam_warn > 32767)
- battle_config.chat_spam_warn = 32767;
-
- if (battle_config.chat_spam_threshold < 0)
- battle_config.chat_spam_threshold = 0;
- else if (battle_config.chat_spam_threshold > 32767)
- battle_config.chat_spam_threshold = 32767;
-
- if (battle_config.chat_maxline < 1)
- battle_config.chat_maxline = 1;
- else if (battle_config.chat_maxline > 512)
- battle_config.chat_maxline = 512;
-
- if (battle_config.packet_spam_threshold < 0)
- battle_config.packet_spam_threshold = 0;
- else if (battle_config.packet_spam_threshold > 32767)
- battle_config.packet_spam_threshold = 32767;
-
- if (battle_config.packet_spam_flood < 0)
- battle_config.packet_spam_flood = 0;
- else if (battle_config.packet_spam_flood > 32767)
- battle_config.packet_spam_flood = 32767;
-
- if (battle_config.packet_spam_kick < 0)
- battle_config.packet_spam_kick = 0;
- else if (battle_config.packet_spam_kick > 1)
- battle_config.packet_spam_kick = 1;
-
- if (battle_config.mask_ip_gms < 0)
- battle_config.mask_ip_gms = 0;
- else if (battle_config.mask_ip_gms > 1)
- battle_config.mask_ip_gms = 1;
- }
-}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/battle.hpp b/src/map/battle.hpp
index 53782fa..1a13420 100644
--- a/src/map/battle.hpp
+++ b/src/map/battle.hpp
@@ -33,6 +33,8 @@
namespace tmwa
{
+namespace map
+{
// ダメージ
struct Damage
{
@@ -106,114 +108,5 @@ int battle_check_target(dumb_ptr<block_list> src, dumb_ptr<block_list> target,
BCT flag);
int battle_check_range(dumb_ptr<block_list> src, dumb_ptr<block_list> bl,
int range);
-
-extern struct Battle_Config
-{
- int warp_point_debug;
- int enemy_critical;
- int enemy_critical_rate;
- int enemy_str;
- int enemy_perfect_flee;
- int casting_rate, delay_rate, delay_dependon_dex;
- int skill_delay_attack_enable;
- int monster_skill_add_range;
- int player_damage_delay;
- int flooritem_lifetime;
- int item_auto_get;
- int item_first_get_time;
- int item_second_get_time;
- int item_third_get_time;
- int base_exp_rate, job_exp_rate;
- int death_penalty_type;
- int death_penalty_base, death_penalty_job;
- int restart_hp_rate;
- int restart_sp_rate;
- int monster_hp_rate;
- int monster_max_aspd;
- int atcommand_gm_only;
- int atcommand_spawn_quantity_limit;
- int gm_all_equipment;
- int monster_active_enable;
- int mob_skill_use;
- int mob_count_rate;
- int basic_skill_check;
- int player_invincible_time;
- int skill_min_damage;
- int natural_healhp_interval;
- int natural_healsp_interval;
- int natural_heal_weight_rate;
- int arrow_decrement;
- int max_aspd;
- int max_hp;
- int max_sp;
- int max_lv;
- int max_parameter;
- int monster_skill_log;
- int battle_log;
- int save_log;
- int error_log;
- int etc_log;
- int save_clothcolor;
- int undead_detect_type;
- int agi_penaly_type;
- int agi_penaly_count;
- int agi_penaly_num;
- int vit_penaly_type;
- int vit_penaly_count;
- int vit_penaly_num;
- int mob_changetarget_byskill;
- int player_attack_direction_change;
- int monster_attack_direction_change;
- int display_delay_skill_fail;
-
- int prevent_logout;
-
- int alchemist_summon_reward;
- int maximum_level;
- int drops_by_luk;
- int monsters_ignore_gm;
- int multi_level_up;
- int pk_mode;
-
- int agi_penaly_count_lv;
- int vit_penaly_count_lv;
-
- int hide_GM_session;
- int invite_request_check;
- int disp_experience;
-
- int hack_info_GM_level;
- int any_warp_GM_min_level;
-
- int min_hair_style;
- int max_hair_style;
- int min_hair_color;
- int max_hair_color;
- int min_cloth_color;
- int max_cloth_color;
-
- int castrate_dex_scale;
- int area_size;
-
- int chat_lame_penalty;
- int chat_spam_threshold;
- int chat_spam_flood;
- int chat_spam_ban;
- int chat_spam_warn;
- int chat_maxline;
-
- int packet_spam_threshold;
- int packet_spam_flood;
- int packet_spam_kick;
-
- int mask_ip_gms;
-
- int drop_pickup_safety_zone;
- int itemheal_regeneration_factor;
-
- int mob_splash_radius;
-} battle_config;
-
-bool battle_config_read(ZString cfgName);
-void battle_config_check();
+} // namespace map
} // namespace tmwa
diff --git a/src/map/battle.t.hpp b/src/map/battle.t.hpp
index 53c34ff..4759b68 100644
--- a/src/map/battle.t.hpp
+++ b/src/map/battle.t.hpp
@@ -29,6 +29,8 @@
namespace tmwa
{
+namespace map
+{
namespace e
{
enum class BF : uint16_t
@@ -241,4 +243,5 @@ earray<Races, Race, Race::COUNT> race_shift //=
Races::boss,
Races::other,
}};
+} // namespace map
} // namespace tmwa
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp
index 7d64098..bf4ae4e 100644
--- a/src/map/chrif.cpp
+++ b/src/map/chrif.cpp
@@ -41,10 +41,13 @@
#include "../wire/packets.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "intif.hpp"
#include "itemdb.hpp"
#include "map.hpp"
+#include "map_conf.hpp"
#include "npc.hpp"
#include "pc.hpp"
#include "storage.hpp"
@@ -54,60 +57,8 @@
namespace tmwa
{
-Session *char_session;
-static
-IP4Address char_ip;
-static
-int char_port = 6121;
-static
-AccountName userid;
-static
-AccountPass passwd;
-static
-int chrif_state;
-
-// 設定ファイル読み込み関係
-/*==========================================
- *
- *------------------------------------------
- */
-void chrif_setuserid(AccountName id)
-{
- userid = id;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void chrif_setpasswd(AccountPass pwd)
-{
- passwd = pwd;
-}
-
-AccountPass chrif_getpasswd(void)
-{
- return passwd;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void chrif_setip(IP4Address ip)
+namespace map
{
- char_ip = ip;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void chrif_setport(int port)
-{
- char_port = port;
-}
-
/*==========================================
*
*------------------------------------------
@@ -152,11 +103,11 @@ static
int chrif_connect(Session *s)
{
Packet_Fixed<0x2af8> fixed_f8;
- fixed_f8.account_name = userid;
- fixed_f8.account_pass = passwd;
+ fixed_f8.account_name = map_conf.userid;
+ fixed_f8.account_pass = map_conf.passwd;
fixed_f8.unused = 0;
- fixed_f8.ip = clif_getip();
- fixed_f8.port = clif_getport();
+ fixed_f8.ip = map_conf.map_ip;
+ fixed_f8.port = map_conf.map_port;
send_fpacket<0x2af8, 60>(s, fixed_f8);
return 0;
@@ -1169,7 +1120,7 @@ void check_connect_char_server(TimerData *, tick_t)
{
PRINTF("Attempt to connect to char-server...\n"_fmt);
chrif_state = 0;
- char_session = make_connection(char_ip, char_port,
+ char_session = make_connection(map_conf.char_ip, map_conf.char_port,
SessionParsers{.func_parse= chrif_parse, .func_delete= chrif_delete});
if (!char_session)
return;
@@ -1194,4 +1145,5 @@ void do_init_chrif(void)
5_s
).detach();
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/chrif.hpp b/src/map/chrif.hpp
index 59fb541..655103d 100644
--- a/src/map/chrif.hpp
+++ b/src/map/chrif.hpp
@@ -25,13 +25,8 @@
namespace tmwa
{
-void chrif_setuserid(AccountName);
-void chrif_setpasswd(AccountPass);
-AccountPass chrif_getpasswd(void);
-
-void chrif_setip(IP4Address);
-void chrif_setport(int);
-
+namespace map
+{
int chrif_isconnect(void);
int chrif_authreq(dumb_ptr<map_session_data>);
@@ -50,8 +45,5 @@ int chrif_saveaccountreg2(dumb_ptr<map_session_data> sd);
int chrif_send_divorce(CharId char_id);
void do_init_chrif(void);
-
-// only used by intif.cpp
-// and clif.cpp for the new on_delete stuff ...
-extern Session *char_session;
+} // namespace map
} // namespace tmwa
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index 1c6f403..577d7be 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -57,12 +57,15 @@
#include "atcommand.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "chrif.hpp"
+#include "globals.hpp"
#include "intif.hpp"
#include "itemdb.hpp"
#include "magic.hpp"
#include "magic-stmt.hpp"
#include "map.hpp"
+#include "map_conf.hpp"
#include "npc.hpp"
#include "party.hpp"
#include "pc.hpp"
@@ -76,6 +79,8 @@
namespace tmwa
{
+namespace map
+{
constexpr int EMOTE_IGNORED = 0x0e;
// functions list. Rate is how many milliseconds are required between
@@ -120,11 +125,6 @@ enum class SendWho
};
static
-IP4Address map_ip;
-static
-int map_port = 5121;
-
-static
int clif_changelook_towards(dumb_ptr<block_list> bl, LOOK type, int val,
dumb_ptr<map_session_data> dstsd);
static
@@ -152,42 +152,6 @@ void clif_delete(Session *s)
/*==========================================
- * map鯖のip設定
- *------------------------------------------
- */
-void clif_setip(IP4Address ip)
-{
- map_ip = ip;
-}
-
-/*==========================================
- * map鯖のport設定
- *------------------------------------------
- */
-void clif_setport(int port)
-{
- map_port = port;
-}
-
-/*==========================================
- * map鯖のip読み出し
- *------------------------------------------
- */
-IP4Address clif_getip(void)
-{
- return map_ip;
-}
-
-/*==========================================
- * map鯖のport読み出し
- *------------------------------------------
- */
-int clif_getport(void)
-{
- return map_port;
-}
-
-/*==========================================
*
*------------------------------------------
*/
@@ -3348,9 +3312,9 @@ RecvResult clif_parse_LoadEndAck(Session *s, dumb_ptr<map_session_data> sd)
// 119
// 78
- if (battle_config.player_invincible_time > 0)
+ if (battle_config.player_invincible_time > interval_t::zero())
{
- pc_setinvincibletimer(sd, static_cast<interval_t>(battle_config.player_invincible_time));
+ pc_setinvincibletimer(sd, battle_config.player_invincible_time);
}
map_addblock(sd); // ブロック登録
@@ -3574,7 +3538,7 @@ RecvResult clif_parse_GetCharNameRequest(Session *s, dumb_ptr<map_session_data>
send_fpacket<0x0195, 102>(s, fixed_195);
}
- if (pc_isGM(sd).satisfies(GmLevel::from(static_cast<uint32_t>(battle_config.hack_info_GM_level))))
+ if (pc_isGM(sd).satisfies(battle_config.hack_info_GM_level))
{
IP4Address ip = ssd->get_ip();
Packet_Fixed<0x020c> fixed_20c;
@@ -5322,12 +5286,10 @@ uint16_t clif_check_packet_flood(Session *s, int cmd)
// They are flooding
if (tick < sd->flood_rates[cmd] + rate)
{
- TimeT now = TimeT::now();
-
// If it's a nasty flood we log and possibly kick
- if (now > sd->packet_flood_reset_due)
+ if (tick > sd->packet_flood_reset_due)
{
- sd->packet_flood_reset_due = static_cast<time_t>(now) + battle_config.packet_spam_threshold;
+ sd->packet_flood_reset_due = tick + battle_config.packet_spam_threshold;
sd->packet_flood_in = 0;
}
@@ -5569,6 +5531,7 @@ unknown_packet:
void do_init_clif(void)
{
- make_listen_port(map_port, SessionParsers{.func_parse= clif_parse, .func_delete= clif_delete});
+ make_listen_port(map_conf.map_port, SessionParsers{.func_parse= clif_parse, .func_delete= clif_delete});
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/clif.hpp b/src/map/clif.hpp
index 2242949..153cc7c 100644
--- a/src/map/clif.hpp
+++ b/src/map/clif.hpp
@@ -38,11 +38,8 @@
namespace tmwa
{
-void clif_setip(IP4Address);
-void clif_setport(int);
-
-IP4Address clif_getip(void);
-int clif_getport(void);
+namespace map
+{
int clif_countusers(void);
void clif_setwaitclose(Session *);
@@ -179,4 +176,5 @@ int clif_GM_kick(dumb_ptr<map_session_data> sd, dumb_ptr<map_session_data> tsd,
int clif_foreachclient(std::function<void(dumb_ptr<map_session_data>)>);
void do_init_clif(void);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/consts.hpp b/src/map/consts.hpp
new file mode 100644
index 0000000..a68d8e3
--- /dev/null
+++ b/src/map/consts.hpp
@@ -0,0 +1,34 @@
+#pragma once
+// consts.hpp - Constants for tmwa-map.
+//
+// Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 "fwd.hpp"
+
+#include "../ints/udl.hpp"
+
+#include "../mmo/ids.hpp"
+
+
+namespace tmwa
+{
+namespace map
+{
+constexpr BlockId MAX_FLOORITEM = wrap<BlockId>(500000_u32);
+} // namespace map
+} // namespace tmwa
diff --git a/src/map/fwd.hpp b/src/map/fwd.hpp
index 0ab6128..1db4ed0 100644
--- a/src/map/fwd.hpp
+++ b/src/map/fwd.hpp
@@ -40,7 +40,18 @@
namespace tmwa
{
+namespace map
+{
// meh, add more when I feel like it
+struct BattleConf;
+struct MapConf;
+
+struct charid2nick;
+struct map_abstract;
+struct mob_db_;
+struct skill_db_;
+struct event_data;
+
struct block_list;
struct map_session_data;
struct npc_data;
@@ -55,9 +66,9 @@ class npc_data_message;
struct item_data;
-enum class SP : uint16_t;
-
struct ScriptState;
+struct str_data_t;
+class SIR;
namespace magic
{
@@ -74,5 +85,7 @@ struct env_t;
struct magic_conf_t;
struct component_t;
struct effect_set_t;
+struct proc_t;
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/globals.cpp b/src/map/globals.cpp
new file mode 100644
index 0000000..09ff157
--- /dev/null
+++ b/src/map/globals.cpp
@@ -0,0 +1,147 @@
+#include "globals.hpp"
+// globals.cpp - Evil global variables for tmwa-map.
+//
+// Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 "../generic/intern-pool.hpp"
+
+#include "../io/write.hpp"
+
+#include "../proto2/net-Storage.hpp"
+
+#include "battle_conf.hpp"
+#include "itemdb.hpp"
+#include "magic-interpreter.hpp"
+#include "map_conf.hpp"
+#include "mob.hpp"
+#include "npc-internal.hpp"
+#include "script-parse-internal.hpp"
+#include "skill.hpp"
+
+#include "../poison.hpp"
+
+
+namespace tmwa
+{
+ namespace map
+ {
+ BattleConf battle_config;
+ MapConf map_conf;
+
+ // only used by intif.cpp
+ // and clif.cpp for the new on_delete stuff ...
+ Session *char_session;
+ int chrif_state;
+ std::map<MapName, RString> resnametable;
+ Map<ItemNameId, item_data> item_db;
+ namespace magic
+ {
+ // Global magic conf
+ magic_conf_t magic_conf;
+ env_t magic_default_env = { &magic_conf, nullptr };
+ namespace magic_v2
+ {
+ std::map<RString, proc_t> procs;
+ std::map<RString, val_t> const_defm;
+ } // namespace magic_v2
+ } // namespace magic
+
+ DMap<BlockId, dumb_ptr<block_list>> id_db;
+ UPMap<MapName, map_abstract> maps_db;
+ DMap<CharName, dumb_ptr<map_session_data>> nick_db;
+ Map<CharId, charid2nick> charid_db;
+ int world_user_count = 0;
+ Array<dumb_ptr<block_list>, unwrap<BlockId>(MAX_FLOORITEM)> object;
+ BlockId first_free_object_id = BlockId();
+ int save_settings = 0xFFFF;
+ int block_free_lock = 0;
+ std::vector<dumb_ptr<block_list>> block_free;
+ /// This is a dummy entry that is shared by all the linked lists,
+ /// so that any entry can unlink itself without worrying about
+ /// whether it was the the head of the list.
+ block_list bl_head;
+ std::unique_ptr<io::AppendFile> map_logfile;
+ long map_logfile_index;
+ mob_db_ mob_db[2001];
+ std::list<AString> npc_srcs;
+ int npc_warp, npc_shop, npc_script, npc_mob;
+ BlockId npc_id = START_NPC_NUM;
+ Map<NpcEvent, struct event_data> ev_db;
+ DMap<NpcName, dumb_ptr<npc_data>> npcs_by_name;
+ // used for clock-based event triggers
+ // only tm_min, tm_hour, and tm_mday are used
+ tm ev_tm_b =
+ {
+ .tm_sec= 0,
+ .tm_min= -1,
+ .tm_hour= -1,
+ .tm_mday= -1,
+ .tm_mon= 0,
+ .tm_year= 0,
+ .tm_wday= 0,
+ .tm_yday= 0,
+ .tm_isdst= 0,
+ };
+ Map<PartyId, PartyMost> party_db;
+ std::map<AccountId, GmLevel> gm_accountm;
+ tick_t natural_heal_tick, natural_heal_prev_tick;
+ interval_t natural_heal_diff_tick;
+ int last_save_fd;
+ bool save_flag;
+ Map<AccountId, Storage> storage_db;
+
+ Map<RString, str_data_t> str_datam;
+ str_data_t LABEL_NEXTLINE_;
+ Map<ScriptLabel, int> scriptlabel_db;
+ std::set<ScriptLabel> probable_labels;
+ UPMap<RString, const ScriptBuffer> userfunc_db;
+ int parse_cmd_if = 0;
+ Option<Borrowed<str_data_t>> parse_cmdp = None;
+ InternPool variable_names;
+ // TODO: replace this whole mess with some sort of input stream that works
+ // a line at a time.
+ ZString startptr;
+ int startline;
+ int script_errors = 0;
+ DMap<SIR, int> mapreg_db;
+ Map<SIR, RString> mapregstr_db;
+ int mapreg_dirty = -1;
+
+ std::vector<SkillID> skill_pool_skills;
+ earray<skill_db_, SkillID, SkillID::MAX_SKILL_DB> skill_db;
+ // these variables are set in the 'else' branches,
+ // and used in the (recursive) 'if' branch
+ // TODO kill it, kill it with fire.
+ BlockId skill_area_temp_id;
+ int skill_area_temp_hp;
+
+ // Some other globals are not moved here, because they are
+ // large and initialized in-place and then *mostly* unmodified.
+ //
+ // src/map/atcommand.cpp:
+ // Map<XString, AtCommandInfo> atcommand_info;
+ // src/map/script-fun.cpp:
+ // BuiltinFunction builtin_functions[];
+ // src/map/clif.cpp:
+ // func_table clif_parse_func_table[0x0220];
+ // src/map/magic-expr.cpp:
+ // std::map<ZString, fun_t> functions;
+ // src/map/magic-stmt.cpp:
+ // std::map<ZString, op_t> operations;
+ } // namespace map
+} // namespace tmwa
diff --git a/src/map/globals.hpp b/src/map/globals.hpp
new file mode 100644
index 0000000..33cfec8
--- /dev/null
+++ b/src/map/globals.hpp
@@ -0,0 +1,108 @@
+#pragma once
+// globals.hpp - Evil global variables for tmwa-map.
+//
+// Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 "fwd.hpp"
+
+#include <ctime>
+
+#include <list>
+#include <map>
+#include <memory>
+#include <set>
+#include <vector>
+
+#include "../ints/wrap.hpp"
+
+#include "../net/timer.t.hpp"
+
+#include "../mmo/skill.t.hpp"
+
+#include "consts.hpp"
+#include "script-buffer.hpp"
+
+
+namespace tmwa
+{
+ namespace map
+ {
+ extern BattleConf battle_config;
+ extern MapConf map_conf;
+ extern Session *char_session;
+ extern int chrif_state;
+ extern std::map<MapName, RString> resnametable;
+ extern Map<ItemNameId, item_data> item_db;
+ namespace magic
+ {
+ // Global magic conf
+ extern magic_conf_t magic_conf;
+ extern env_t magic_default_env;
+ namespace magic_v2
+ {
+ extern std::map<RString, proc_t> procs;
+ extern std::map<RString, val_t> const_defm;
+ } // namespace magic_v2
+ } // namespace magic
+ extern DMap<BlockId, dumb_ptr<block_list>> id_db;
+ extern UPMap<MapName, map_abstract> maps_db;
+ extern DMap<CharName, dumb_ptr<map_session_data>> nick_db;
+ extern Map<CharId, charid2nick> charid_db;
+ extern int world_user_count;
+ extern Array<dumb_ptr<block_list>, unwrap<BlockId>(MAX_FLOORITEM)> object;
+ extern BlockId first_free_object_id;
+ extern int save_settings;
+ extern int block_free_lock;
+ extern std::vector<dumb_ptr<block_list>> block_free;
+ extern block_list bl_head;
+ extern std::unique_ptr<io::AppendFile> map_logfile;
+ extern long map_logfile_index;
+ extern mob_db_ mob_db[2001];
+ extern std::list<AString> npc_srcs;
+ extern int npc_warp, npc_shop, npc_script, npc_mob;
+ extern BlockId npc_id;
+ extern Map<NpcEvent, event_data> ev_db;
+ extern DMap<NpcName, dumb_ptr<npc_data>> npcs_by_name;
+ extern tm ev_tm_b;
+ extern Map<PartyId, PartyMost> party_db;
+ extern std::map<AccountId, GmLevel> gm_accountm;
+ extern tick_t natural_heal_tick, natural_heal_prev_tick;
+ extern interval_t natural_heal_diff_tick;
+ extern int last_save_fd;
+ extern bool save_flag;
+ extern Map<AccountId, Storage> storage_db;
+ extern Map<RString, str_data_t> str_datam;
+ extern str_data_t LABEL_NEXTLINE_;
+ extern Map<ScriptLabel, int> scriptlabel_db;
+ extern std::set<ScriptLabel> probable_labels;
+ extern UPMap<RString, const ScriptBuffer> userfunc_db;
+ extern int parse_cmd_if;
+ extern Option<Borrowed<str_data_t>> parse_cmdp;
+ extern InternPool variable_names;
+ extern ZString startptr;
+ extern int startline;
+ extern int script_errors;
+ extern DMap<SIR, int> mapreg_db;
+ extern Map<SIR, RString> mapregstr_db;
+ extern int mapreg_dirty;
+ extern std::vector<SkillID> skill_pool_skills;
+ extern earray<skill_db_, SkillID, SkillID::MAX_SKILL_DB> skill_db;
+ extern BlockId skill_area_temp_id;
+ extern int skill_area_temp_hp;
+ } // namespace map
+} // namespace tmwa
diff --git a/src/map/grfio.cpp b/src/map/grfio.cpp
index 8821374..3475108 100644
--- a/src/map/grfio.cpp
+++ b/src/map/grfio.cpp
@@ -39,14 +39,15 @@
#include "../high/extract_mmo.hpp"
#include "../high/mmo.hpp"
+#include "globals.hpp"
+
#include "../poison.hpp"
namespace tmwa
{
-static
-std::map<MapName, RString> resnametable;
-
+namespace map
+{
bool load_resnametable(ZString filename)
{
io::ReadFile in(filename);
@@ -107,4 +108,5 @@ std::vector<uint8_t> grfio_reads(MapName rname)
close(fd);
return buffer;
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/grfio.hpp b/src/map/grfio.hpp
index 4cd4092..25e27ef 100644
--- a/src/map/grfio.hpp
+++ b/src/map/grfio.hpp
@@ -29,10 +29,13 @@
namespace tmwa
{
+namespace map
+{
bool load_resnametable(ZString filename);
/// Load a resource into memory, subject to data/resnametable.txt.
/// Normally, resourcename is xxx-y.gat and the file is xxx-y.wlk.
/// Currently there is exactly one .wlk per .gat, but multiples are fine.
std::vector<uint8_t> grfio_reads(MapName resourcename);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/intif.cpp b/src/map/intif.cpp
index c6821b6..a5709ef 100644
--- a/src/map/intif.cpp
+++ b/src/map/intif.cpp
@@ -38,8 +38,10 @@
#include "../wire/packets.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "chrif.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "map.hpp"
#include "party.hpp"
#include "pc.hpp"
@@ -50,6 +52,8 @@
namespace tmwa
{
+namespace map
+{
//-----------------------------------------------------------------
// inter serverへの送信
@@ -694,4 +698,5 @@ RecvResult intif_parse(Session *s, uint16_t packet_id)
}
return rv;
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/intif.hpp b/src/map/intif.hpp
index d51ca11..ac68040 100644
--- a/src/map/intif.hpp
+++ b/src/map/intif.hpp
@@ -25,6 +25,8 @@
namespace tmwa
{
+namespace map
+{
RecvResult intif_parse(Session *, uint16_t packet_id);
void intif_GMmessage(XString mes);
@@ -47,4 +49,5 @@ void intif_party_leave(PartyId party_id, AccountId accound_id);
void intif_party_changemap(dumb_ptr<map_session_data> sd, int online);
void intif_party_message(PartyId party_id, AccountId account_id, XString mes);
void intif_party_checkconflict(PartyId party_id, AccountId account_id, CharName nick);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp
index c2fd0e2..7dd725e 100644
--- a/src/map/itemdb.cpp
+++ b/src/map/itemdb.cpp
@@ -37,6 +37,7 @@
#include "../ast/item.hpp"
+#include "globals.hpp"
#include "script-parse.hpp"
#include "../poison.hpp"
@@ -44,9 +45,8 @@
namespace tmwa
{
-static
-Map<ItemNameId, struct item_data> item_db;
-
+namespace map
+{
// Function declarations
/*==========================================
@@ -235,4 +235,5 @@ void do_final_itemdb(void)
itemdb_final(&pair.second);
item_db.clear();
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp
index fcc92c4..5e19c0b 100644
--- a/src/map/itemdb.hpp
+++ b/src/map/itemdb.hpp
@@ -31,6 +31,8 @@
namespace tmwa
{
+namespace map
+{
struct item_data
{
ItemNameId nameid;
@@ -104,4 +106,5 @@ void itemdb_reload(void);
void do_final_itemdb(void);
bool itemdb_readdb(ZString filename);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/magic-expr-eval.hpp b/src/map/magic-expr-eval.hpp
index 4529c04..e8ed4aa 100644
--- a/src/map/magic-expr-eval.hpp
+++ b/src/map/magic-expr-eval.hpp
@@ -28,6 +28,8 @@
namespace tmwa
{
+namespace map
+{
namespace magic
{
// TODO soon kill this unlike I killed VAR
@@ -48,4 +50,5 @@ namespace magic
#define ARG_MAY_BE_AREA(x) (args[x].is<ValArea>() || args[x].is<ValArea>())
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp
index f1f137d..197727e 100644
--- a/src/map/magic-expr.cpp
+++ b/src/map/magic-expr.cpp
@@ -50,6 +50,8 @@
namespace tmwa
{
+namespace map
+{
namespace magic
{
static
@@ -1868,4 +1870,5 @@ AString magic_eval_str(dumb_ptr<env_t> env, dumb_ptr<expr_t> expr)
return result.get_if<ValString>()->v_string;
}
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/magic-expr.hpp b/src/map/magic-expr.hpp
index 8b88142..055f37b 100644
--- a/src/map/magic-expr.hpp
+++ b/src/map/magic-expr.hpp
@@ -29,6 +29,8 @@
namespace tmwa
{
+namespace map
+{
namespace magic
{
/*
@@ -101,4 +103,5 @@ int magic_signature_check(ZString opname, ZString funname, ZString signature,
Borrowed<map_local> magic_area_rect(int *x, int *y, int *width, int *height,
area_t& area);
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/magic-expr.py b/src/map/magic-expr.py
index c48b79b..f53ddc8 100644
--- a/src/map/magic-expr.py
+++ b/src/map/magic-expr.py
@@ -1,7 +1,7 @@
class fun_t(object):
__slots__ = ('_value')
- name = 'tmwa::magic::fun_t'
+ name = 'tmwa::map::magic::fun_t'
depth = 1
enabled = True
@@ -31,8 +31,8 @@ class fun_t(object):
'''
tests = [
- ('static_cast<tmwa::magic::fun_t *>(nullptr)',
+ ('static_cast<tmwa::map::magic::fun_t *>(nullptr)',
'(fun_t *) nullptr'),
- ('new tmwa::magic::fun_t{"name"_s, "sig"_s, \'\\0\', nullptr}',
+ ('new tmwa::map::magic::fun_t{"name"_s, "sig"_s, \'\\0\', nullptr}',
'(fun_t *) = {->name = "name", ->signature = "sig", ->ret_ty = 0 \'\\000\', ->fun = nullptr}'),
]
diff --git a/src/map/magic-interpreter-base.cpp b/src/map/magic-interpreter-base.cpp
index e0392e4..c2be363 100644
--- a/src/map/magic-interpreter-base.cpp
+++ b/src/map/magic-interpreter-base.cpp
@@ -30,6 +30,7 @@
#include "../net/timer.hpp"
+#include "globals.hpp"
#include "magic.hpp"
#include "magic-expr.hpp"
#include "magic-interpreter.hpp"
@@ -40,6 +41,8 @@
namespace tmwa
{
+namespace map
+{
namespace magic
{
static
@@ -79,9 +82,6 @@ void set_spell(val_t *v, dumb_ptr<spell_t> x)
*v = ValSpell{x};
}
-magic_conf_t magic_conf; /* Global magic conf */
-env_t magic_default_env = { &magic_conf, nullptr };
-
AString magic_find_invocation(XString spellname)
{
auto it = magic_conf.spells_by_name.find(spellname);
@@ -549,4 +549,5 @@ int spell_unbind(dumb_ptr<map_session_data> subject, dumb_ptr<invocation> invoca
return 1;
}
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/magic-interpreter-base.hpp b/src/map/magic-interpreter-base.hpp
index 2557ecb..7c00db0 100644
--- a/src/map/magic-interpreter-base.hpp
+++ b/src/map/magic-interpreter-base.hpp
@@ -24,11 +24,10 @@
namespace tmwa
{
+namespace map
+{
namespace magic
{
-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 nullptr)
*/
@@ -81,4 +80,5 @@ dumb_ptr<spell_t> magic_find_spell(XString invocation);
void spell_update_location(dumb_ptr<invocation> invocation);
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/magic-interpreter.hpp b/src/map/magic-interpreter.hpp
index 547e294..cbd92a9 100644
--- a/src/map/magic-interpreter.hpp
+++ b/src/map/magic-interpreter.hpp
@@ -42,6 +42,8 @@
namespace tmwa
{
+namespace map
+{
namespace magic
{
struct location_t
@@ -624,4 +626,5 @@ struct proc_t
{}
};
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/magic-interpreter.py b/src/map/magic-interpreter.py
index 141cd22..520ab37 100644
--- a/src/map/magic-interpreter.py
+++ b/src/map/magic-interpreter.py
@@ -1,6 +1,6 @@
class AreaUnion(object):
__slots__ = ('_value')
- name = 'tmwa::magic::AreaUnion'
+ name = 'tmwa::map::magic::AreaUnion'
enabled = True
def __init__(self, value):
@@ -27,23 +27,23 @@ class area_t(object):
using tmwa::operator "" _s;
inline
- tmwa::Borrowed<tmwa::map_local> fake_map_local_x_dup_for_area_t(tmwa::ZString name)
+ tmwa::Borrowed<tmwa::map::map_local> fake_map_local_x_dup_for_area_t(tmwa::ZString name)
{
- auto *p = new tmwa::map_local{};
+ auto *p = new tmwa::map::map_local{};
p->name_ = tmwa::stringish<tmwa::MapName>(name);
return tmwa::borrow(*p);
}
'''
tests = [
- ('tmwa::magic::area_t(tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 123, 456})',
- '{<tmwa::sexpr::Variant<tmwa::magic::location_t, tmwa::magic::AreaUnion, tmwa::magic::AreaRect, tmwa::magic::AreaBar>> = {(tmwa::magic::location_t) = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 123, y = 456}}, size = 1}'),
- ('tmwa::magic::area_t(tmwa::magic::AreaUnion{{tmwa::dumb_ptr<tmwa::magic::area_t>::make(tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 123, 456}), tmwa::dumb_ptr<tmwa::magic::area_t>::make(tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 321, 654})}})',
- '{<tmwa::sexpr::Variant<tmwa::magic::location_t, tmwa::magic::AreaUnion, tmwa::magic::AreaRect, tmwa::magic::AreaBar>> = {(tmwa::magic::AreaUnion) = {{<tmwa::sexpr::Variant<tmwa::magic::location_t, tmwa::magic::AreaUnion, tmwa::magic::AreaRect, tmwa::magic::AreaBar>> = {(tmwa::magic::location_t) = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 123, y = 456}}, size = 1}, {<tmwa::sexpr::Variant<tmwa::magic::location_t, tmwa::magic::AreaUnion, tmwa::magic::AreaRect, tmwa::magic::AreaBar>> = {(tmwa::magic::location_t) = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 321, y = 654}}, size = 1}}}, size = 2}'),
- ('tmwa::magic::area_t(tmwa::magic::AreaRect{tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 123, 456}, 789, 102})',
- '{<tmwa::sexpr::Variant<tmwa::magic::location_t, tmwa::magic::AreaUnion, tmwa::magic::AreaRect, tmwa::magic::AreaBar>> = {(tmwa::magic::AreaRect) = {loc = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 123, y = 456}, width = 789, height = 102}}, size = 80478}'),
- ('tmwa::magic::area_t(tmwa::magic::AreaBar{tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 42, 43}, 123, 456, tmwa::DIR::NW})',
- '{<tmwa::sexpr::Variant<tmwa::magic::location_t, tmwa::magic::AreaUnion, tmwa::magic::AreaRect, tmwa::magic::AreaBar>> = {(tmwa::magic::AreaBar) = {loc = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 42, y = 43}, width = 123, depth = 456, dir = tmwa::DIR::NW}}, size = 112632}'),
+ ('tmwa::map::magic::area_t(tmwa::map::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 123, 456})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::location_t, tmwa::map::magic::AreaUnion, tmwa::map::magic::AreaRect, tmwa::map::magic::AreaBar>> = {(tmwa::map::magic::location_t) = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 123, y = 456}}, size = 1}'),
+ ('tmwa::map::magic::area_t(tmwa::map::magic::AreaUnion{{tmwa::dumb_ptr<tmwa::map::magic::area_t>::make(tmwa::map::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 123, 456}), tmwa::dumb_ptr<tmwa::map::magic::area_t>::make(tmwa::map::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 321, 654})}})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::location_t, tmwa::map::magic::AreaUnion, tmwa::map::magic::AreaRect, tmwa::map::magic::AreaBar>> = {(tmwa::map::magic::AreaUnion) = {{<tmwa::sexpr::Variant<tmwa::map::magic::location_t, tmwa::map::magic::AreaUnion, tmwa::map::magic::AreaRect, tmwa::map::magic::AreaBar>> = {(tmwa::map::magic::location_t) = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 123, y = 456}}, size = 1}, {<tmwa::sexpr::Variant<tmwa::map::magic::location_t, tmwa::map::magic::AreaUnion, tmwa::map::magic::AreaRect, tmwa::map::magic::AreaBar>> = {(tmwa::map::magic::location_t) = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 321, y = 654}}, size = 1}}}, size = 2}'),
+ ('tmwa::map::magic::area_t(tmwa::map::magic::AreaRect{tmwa::map::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 123, 456}, 789, 102})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::location_t, tmwa::map::magic::AreaUnion, tmwa::map::magic::AreaRect, tmwa::map::magic::AreaBar>> = {(tmwa::map::magic::AreaRect) = {loc = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 123, y = 456}, width = 789, height = 102}}, size = 80478}'),
+ ('tmwa::map::magic::area_t(tmwa::map::magic::AreaBar{tmwa::map::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 42, 43}, 123, 456, tmwa::DIR::NW})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::location_t, tmwa::map::magic::AreaUnion, tmwa::map::magic::AreaRect, tmwa::map::magic::AreaBar>> = {(tmwa::map::magic::AreaBar) = {loc = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 42, y = 43}, width = 123, depth = 456, dir = tmwa::DIR::NW}}, size = 112632}'),
]
@@ -55,47 +55,47 @@ class val_t(object):
using tmwa::operator "" _s;
inline
- tmwa::Borrowed<tmwa::map_local> fake_map_local_x_dup_for_val_t(tmwa::ZString name)
+ tmwa::Borrowed<tmwa::map::map_local> fake_map_local_x_dup_for_val_t(tmwa::ZString name)
{
- auto *p = new tmwa::map_local{};
+ auto *p = new tmwa::map::map_local{};
p->name_ = tmwa::stringish<tmwa::MapName>(name);
return tmwa::borrow(*p);
}
'''
tests = [
- ('tmwa::magic::val_t(tmwa::magic::ValUndef{})',
- '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValUndef) = {<No data fields>}}, <No data fields>}'),
- ('tmwa::magic::val_t(tmwa::magic::ValInt{42})',
- '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValInt) = {v_int = 42}}, <No data fields>}'),
- ('tmwa::magic::val_t(tmwa::magic::ValDir{tmwa::DIR::NW})',
- '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValDir) = {v_dir = tmwa::DIR::NW}}, <No data fields>}'),
- ('tmwa::magic::val_t(tmwa::magic::ValString{"Hello"_s})',
- '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValString) = {v_string = "Hello"}}, <No data fields>}'),
- ('tmwa::magic::val_t(tmwa::magic::ValEntityInt{tmwa::wrap<tmwa::BlockId>(123)})',
- '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValEntityInt) = {v_eid = 123}}, <No data fields>}'),
- ('tmwa::magic::val_t(tmwa::magic::ValEntityPtr{tmwa::dumb_ptr<tmwa::block_list>()})',
- '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValEntityPtr) = {v_entity = 0x0}}, <No data fields>}'),
- ('tmwa::magic::val_t(tmwa::magic::ValLocation{tmwa::magic::location_t{fake_map_local_x_dup_for_val_t("map"_s), 42, 123}})',
- '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValLocation) = {v_location = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 42, y = 123}}}, <No data fields>}'),
- ('tmwa::magic::val_t(tmwa::magic::ValArea{tmwa::dumb_ptr<tmwa::magic::area_t>()})',
- '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValArea) = {v_area = 0x0}}, <No data fields>}'),
- ('tmwa::magic::val_t(tmwa::magic::ValSpell{tmwa::dumb_ptr<tmwa::magic::spell_t>()})',
- '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValSpell) = {v_spell = 0x0}}, <No data fields>}'),
- ('tmwa::magic::val_t(tmwa::magic::ValInvocationInt{tmwa::wrap<tmwa::BlockId>(123)})',
- '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValInvocationInt) = {v_iid = 123}}, <No data fields>}'),
- ('tmwa::magic::val_t(tmwa::magic::ValInvocationPtr{})',
- '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValInvocationPtr) = {v_invocation = 0x0}}, <No data fields>}'),
- ('tmwa::magic::val_t(tmwa::magic::ValFail{})',
- '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValFail) = {<No data fields>}}, <No data fields>}'),
- ('tmwa::magic::val_t(tmwa::magic::ValNegative1{})',
- '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValNegative1) = {<No data fields>}}, <No data fields>}'),
+ ('tmwa::map::magic::val_t(tmwa::map::magic::ValUndef{})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValUndef) = {<No data fields>}}, <No data fields>}'),
+ ('tmwa::map::magic::val_t(tmwa::map::magic::ValInt{42})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValInt) = {v_int = 42}}, <No data fields>}'),
+ ('tmwa::map::magic::val_t(tmwa::map::magic::ValDir{tmwa::DIR::NW})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValDir) = {v_dir = tmwa::DIR::NW}}, <No data fields>}'),
+ ('tmwa::map::magic::val_t(tmwa::map::magic::ValString{"Hello"_s})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValString) = {v_string = "Hello"}}, <No data fields>}'),
+ ('tmwa::map::magic::val_t(tmwa::map::magic::ValEntityInt{tmwa::wrap<tmwa::BlockId>(123)})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValEntityInt) = {v_eid = 123}}, <No data fields>}'),
+ ('tmwa::map::magic::val_t(tmwa::map::magic::ValEntityPtr{tmwa::dumb_ptr<tmwa::map::block_list>()})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValEntityPtr) = {v_entity = 0x0}}, <No data fields>}'),
+ ('tmwa::map::magic::val_t(tmwa::map::magic::ValLocation{tmwa::map::magic::location_t{fake_map_local_x_dup_for_val_t("map"_s), 42, 123}})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValLocation) = {v_location = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 42, y = 123}}}, <No data fields>}'),
+ ('tmwa::map::magic::val_t(tmwa::map::magic::ValArea{tmwa::dumb_ptr<tmwa::map::magic::area_t>()})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValArea) = {v_area = 0x0}}, <No data fields>}'),
+ ('tmwa::map::magic::val_t(tmwa::map::magic::ValSpell{tmwa::dumb_ptr<tmwa::map::magic::spell_t>()})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValSpell) = {v_spell = 0x0}}, <No data fields>}'),
+ ('tmwa::map::magic::val_t(tmwa::map::magic::ValInvocationInt{tmwa::wrap<tmwa::BlockId>(123)})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValInvocationInt) = {v_iid = 123}}, <No data fields>}'),
+ ('tmwa::map::magic::val_t(tmwa::map::magic::ValInvocationPtr{})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValInvocationPtr) = {v_invocation = 0x0}}, <No data fields>}'),
+ ('tmwa::map::magic::val_t(tmwa::map::magic::ValFail{})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValFail) = {<No data fields>}}, <No data fields>}'),
+ ('tmwa::map::magic::val_t(tmwa::map::magic::ValNegative1{})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValNegative1) = {<No data fields>}}, <No data fields>}'),
]
class ExprAreaUnion(object):
__slots__ = ('_value')
- name = 'tmwa::magic::ExprAreaUnion'
+ name = 'tmwa::map::magic::ExprAreaUnion'
enabled = True
def __init__(self, value):
@@ -119,14 +119,14 @@ class e_area_t(object):
enabled = True
tests = [
- ('tmwa::magic::e_area_t(tmwa::magic::e_location_t())',
- '{<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}'),
- ('tmwa::magic::e_area_t(tmwa::magic::ExprAreaUnion{{tmwa::dumb_ptr<tmwa::magic::e_area_t>::make(tmwa::magic::e_location_t()), tmwa::dumb_ptr<tmwa::magic::e_area_t>::make(tmwa::magic::e_location_t())}})',
- '{<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::ExprAreaUnion) = {{<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}, {<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}}}, <No data fields>}'),
- ('tmwa::magic::e_area_t(tmwa::magic::ExprAreaRect{tmwa::magic::e_location_t(), tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::expr_t>()})',
- '{<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::ExprAreaRect) = {loc = {m = 0x0, x = 0x0, y = 0x0}, width = 0x0, height = 0x0}}, <No data fields>}'),
- ('tmwa::magic::e_area_t(tmwa::magic::ExprAreaBar{tmwa::magic::e_location_t(), tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::expr_t>()})',
- '{<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::ExprAreaBar) = {loc = {m = 0x0, x = 0x0, y = 0x0}, width = 0x0, depth = 0x0, dir = 0x0}}, <No data fields>}'),
+ ('tmwa::map::magic::e_area_t(tmwa::map::magic::e_location_t())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::e_location_t, tmwa::map::magic::ExprAreaUnion, tmwa::map::magic::ExprAreaRect, tmwa::map::magic::ExprAreaBar>> = {(tmwa::map::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}'),
+ ('tmwa::map::magic::e_area_t(tmwa::map::magic::ExprAreaUnion{{tmwa::dumb_ptr<tmwa::map::magic::e_area_t>::make(tmwa::map::magic::e_location_t()), tmwa::dumb_ptr<tmwa::map::magic::e_area_t>::make(tmwa::map::magic::e_location_t())}})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::e_location_t, tmwa::map::magic::ExprAreaUnion, tmwa::map::magic::ExprAreaRect, tmwa::map::magic::ExprAreaBar>> = {(tmwa::map::magic::ExprAreaUnion) = {{<tmwa::sexpr::Variant<tmwa::map::magic::e_location_t, tmwa::map::magic::ExprAreaUnion, tmwa::map::magic::ExprAreaRect, tmwa::map::magic::ExprAreaBar>> = {(tmwa::map::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}, {<tmwa::sexpr::Variant<tmwa::map::magic::e_location_t, tmwa::map::magic::ExprAreaUnion, tmwa::map::magic::ExprAreaRect, tmwa::map::magic::ExprAreaBar>> = {(tmwa::map::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}}}, <No data fields>}'),
+ ('tmwa::map::magic::e_area_t(tmwa::map::magic::ExprAreaRect{tmwa::map::magic::e_location_t(), tmwa::dumb_ptr<tmwa::map::magic::expr_t>(), tmwa::dumb_ptr<tmwa::map::magic::expr_t>()})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::e_location_t, tmwa::map::magic::ExprAreaUnion, tmwa::map::magic::ExprAreaRect, tmwa::map::magic::ExprAreaBar>> = {(tmwa::map::magic::ExprAreaRect) = {loc = {m = 0x0, x = 0x0, y = 0x0}, width = 0x0, height = 0x0}}, <No data fields>}'),
+ ('tmwa::map::magic::e_area_t(tmwa::map::magic::ExprAreaBar{tmwa::map::magic::e_location_t(), tmwa::dumb_ptr<tmwa::map::magic::expr_t>(), tmwa::dumb_ptr<tmwa::map::magic::expr_t>(), tmwa::dumb_ptr<tmwa::map::magic::expr_t>()})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::e_location_t, tmwa::map::magic::ExprAreaUnion, tmwa::map::magic::ExprAreaRect, tmwa::map::magic::ExprAreaBar>> = {(tmwa::map::magic::ExprAreaBar) = {loc = {m = 0x0, x = 0x0, y = 0x0}, width = 0x0, depth = 0x0, dir = 0x0}}, <No data fields>}'),
]
@@ -135,18 +135,18 @@ class expr_t(object):
enabled = True
tests = [
- ('tmwa::magic::expr_t(tmwa::magic::val_t(tmwa::magic::ValUndef()))',
- '{<tmwa::sexpr::Variant<tmwa::magic::val_t, tmwa::magic::e_location_t, tmwa::magic::e_area_t, tmwa::magic::ExprFunApp, tmwa::magic::ExprId, tmwa::magic::ExprField>> = {(tmwa::magic::val_t) = {<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValUndef) = {<No data fields>}}, <No data fields>}}, <No data fields>}'),
- ('tmwa::magic::expr_t(tmwa::magic::e_location_t())',
- '{<tmwa::sexpr::Variant<tmwa::magic::val_t, tmwa::magic::e_location_t, tmwa::magic::e_area_t, tmwa::magic::ExprFunApp, tmwa::magic::ExprId, tmwa::magic::ExprField>> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}'),
- ('tmwa::magic::expr_t(tmwa::magic::e_area_t(tmwa::magic::e_location_t()))',
- '{<tmwa::sexpr::Variant<tmwa::magic::val_t, tmwa::magic::e_location_t, tmwa::magic::e_area_t, tmwa::magic::ExprFunApp, tmwa::magic::ExprId, tmwa::magic::ExprField>> = {(tmwa::magic::e_area_t) = {<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}}, <No data fields>}'),
- ('tmwa::magic::expr_t(tmwa::magic::ExprFunApp())',
- '{<tmwa::sexpr::Variant<tmwa::magic::val_t, tmwa::magic::e_location_t, tmwa::magic::e_area_t, tmwa::magic::ExprFunApp, tmwa::magic::ExprId, tmwa::magic::ExprField>> = {(tmwa::magic::ExprFunApp) = {funp = (fun_t *) nullptr, line_nr = 0, column = 0, args_nr = 0, args = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}}, <No data fields>}'),
- ('tmwa::magic::expr_t(tmwa::magic::ExprId{123})',
- '{<tmwa::sexpr::Variant<tmwa::magic::val_t, tmwa::magic::e_location_t, tmwa::magic::e_area_t, tmwa::magic::ExprFunApp, tmwa::magic::ExprId, tmwa::magic::ExprField>> = {(tmwa::magic::ExprId) = {e_id = 123}}, <No data fields>}'),
- ('tmwa::magic::expr_t(tmwa::magic::ExprField{tmwa::dumb_ptr<tmwa::magic::expr_t>(), 42})',
- '{<tmwa::sexpr::Variant<tmwa::magic::val_t, tmwa::magic::e_location_t, tmwa::magic::e_area_t, tmwa::magic::ExprFunApp, tmwa::magic::ExprId, tmwa::magic::ExprField>> = {(tmwa::magic::ExprField) = {expr = 0x0, id = 42}}, <No data fields>}'),
+ ('tmwa::map::magic::expr_t(tmwa::map::magic::val_t(tmwa::map::magic::ValUndef()))',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::val_t, tmwa::map::magic::e_location_t, tmwa::map::magic::e_area_t, tmwa::map::magic::ExprFunApp, tmwa::map::magic::ExprId, tmwa::map::magic::ExprField>> = {(tmwa::map::magic::val_t) = {<tmwa::sexpr::Variant<tmwa::map::magic::ValUndef, tmwa::map::magic::ValInt, tmwa::map::magic::ValDir, tmwa::map::magic::ValString, tmwa::map::magic::ValEntityInt, tmwa::map::magic::ValEntityPtr, tmwa::map::magic::ValLocation, tmwa::map::magic::ValArea, tmwa::map::magic::ValSpell, tmwa::map::magic::ValInvocationInt, tmwa::map::magic::ValInvocationPtr, tmwa::map::magic::ValFail, tmwa::map::magic::ValNegative1>> = {(tmwa::map::magic::ValUndef) = {<No data fields>}}, <No data fields>}}, <No data fields>}'),
+ ('tmwa::map::magic::expr_t(tmwa::map::magic::e_location_t())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::val_t, tmwa::map::magic::e_location_t, tmwa::map::magic::e_area_t, tmwa::map::magic::ExprFunApp, tmwa::map::magic::ExprId, tmwa::map::magic::ExprField>> = {(tmwa::map::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}'),
+ ('tmwa::map::magic::expr_t(tmwa::map::magic::e_area_t(tmwa::map::magic::e_location_t()))',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::val_t, tmwa::map::magic::e_location_t, tmwa::map::magic::e_area_t, tmwa::map::magic::ExprFunApp, tmwa::map::magic::ExprId, tmwa::map::magic::ExprField>> = {(tmwa::map::magic::e_area_t) = {<tmwa::sexpr::Variant<tmwa::map::magic::e_location_t, tmwa::map::magic::ExprAreaUnion, tmwa::map::magic::ExprAreaRect, tmwa::map::magic::ExprAreaBar>> = {(tmwa::map::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}}, <No data fields>}'),
+ ('tmwa::map::magic::expr_t(tmwa::map::magic::ExprFunApp())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::val_t, tmwa::map::magic::e_location_t, tmwa::map::magic::e_area_t, tmwa::map::magic::ExprFunApp, tmwa::map::magic::ExprId, tmwa::map::magic::ExprField>> = {(tmwa::map::magic::ExprFunApp) = {funp = (fun_t *) nullptr, line_nr = 0, column = 0, args_nr = 0, args = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}}, <No data fields>}'),
+ ('tmwa::map::magic::expr_t(tmwa::map::magic::ExprId{123})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::val_t, tmwa::map::magic::e_location_t, tmwa::map::magic::e_area_t, tmwa::map::magic::ExprFunApp, tmwa::map::magic::ExprId, tmwa::map::magic::ExprField>> = {(tmwa::map::magic::ExprId) = {e_id = 123}}, <No data fields>}'),
+ ('tmwa::map::magic::expr_t(tmwa::map::magic::ExprField{tmwa::dumb_ptr<tmwa::map::magic::expr_t>(), 42})',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::val_t, tmwa::map::magic::e_location_t, tmwa::map::magic::e_area_t, tmwa::map::magic::ExprFunApp, tmwa::map::magic::ExprId, tmwa::map::magic::ExprField>> = {(tmwa::map::magic::ExprField) = {expr = 0x0, id = 42}}, <No data fields>}'),
]
@@ -154,30 +154,30 @@ class effect_t(object):
enabled = True
tests = [
- ('tmwa::magic::effect_t(tmwa::magic::EffectSkip{}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectSkip) = {<No data fields>}}, next = 0x0}'),
- ('tmwa::magic::effect_t(tmwa::magic::EffectAbort{}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectAbort) = {<No data fields>}}, next = 0x0}'),
- ('tmwa::magic::effect_t(tmwa::magic::EffectAssign{42, tmwa::dumb_ptr<tmwa::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectAssign) = {id = 42, expr = 0x0}}, next = 0x0}'),
- ('tmwa::magic::effect_t(tmwa::magic::EffectForEach{123, tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::effect_t>(), tmwa::magic::FOREACH_FILTER::PC}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectForEach) = {id = 123, area = 0x0, body = 0x0, filter = tmwa::magic::FOREACH_FILTER::PC}}, next = 0x0}'),
- ('tmwa::magic::effect_t(tmwa::magic::EffectFor{42, tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::effect_t>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectFor) = {id = 42, start = 0x0, stop = 0x0, body = 0x0}}, next = 0x0}'),
- ('tmwa::magic::effect_t(tmwa::magic::EffectIf{tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::effect_t>(), tmwa::dumb_ptr<tmwa::magic::effect_t>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectIf) = {cond = 0x0, true_branch = 0x0, false_branch = 0x0}}, next = 0x0}'),
- ('tmwa::magic::effect_t(tmwa::magic::EffectSleep{tmwa::dumb_ptr<tmwa::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectSleep) = {e_sleep = 0x0}}, next = 0x0}'),
- ('tmwa::magic::effect_t(tmwa::magic::EffectScript{tmwa::dumb_ptr<const tmwa::ScriptBuffer>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectScript) = {e_script = 0x0}}, next = 0x0}'),
- ('tmwa::magic::effect_t(tmwa::magic::EffectBreak{}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectBreak) = {<No data fields>}}, next = 0x0}'),
- ('tmwa::magic::effect_t(tmwa::magic::EffectOp(), tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectOp) = {opp = (op_t *) nullptr, args_nr = 0, line_nr = 0, column = 0, args = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}}, next = 0x0}'),
- ('tmwa::magic::effect_t(tmwa::magic::EffectEnd{}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectEnd) = {<No data fields>}}, next = 0x0}'),
- ('tmwa::magic::effect_t(tmwa::magic::EffectCall{nullptr, tmwa::dumb_ptr<std::vector<tmwa::dumb_ptr<tmwa::magic::expr_t>>>(), tmwa::dumb_ptr<tmwa::magic::effect_t>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectCall) = {formalv = nullptr, actualvp = 0x0, body = 0x0}}, next = 0x0}'),
+ ('tmwa::map::magic::effect_t(tmwa::map::magic::EffectSkip{}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::EffectSkip, tmwa::map::magic::EffectAbort, tmwa::map::magic::EffectAssign, tmwa::map::magic::EffectForEach, tmwa::map::magic::EffectFor, tmwa::map::magic::EffectIf, tmwa::map::magic::EffectSleep, tmwa::map::magic::EffectScript, tmwa::map::magic::EffectBreak, tmwa::map::magic::EffectOp, tmwa::map::magic::EffectEnd, tmwa::map::magic::EffectCall>> = {(tmwa::map::magic::EffectSkip) = {<No data fields>}}, next = 0x0}'),
+ ('tmwa::map::magic::effect_t(tmwa::map::magic::EffectAbort{}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::EffectSkip, tmwa::map::magic::EffectAbort, tmwa::map::magic::EffectAssign, tmwa::map::magic::EffectForEach, tmwa::map::magic::EffectFor, tmwa::map::magic::EffectIf, tmwa::map::magic::EffectSleep, tmwa::map::magic::EffectScript, tmwa::map::magic::EffectBreak, tmwa::map::magic::EffectOp, tmwa::map::magic::EffectEnd, tmwa::map::magic::EffectCall>> = {(tmwa::map::magic::EffectAbort) = {<No data fields>}}, next = 0x0}'),
+ ('tmwa::map::magic::effect_t(tmwa::map::magic::EffectAssign{42, tmwa::dumb_ptr<tmwa::map::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::EffectSkip, tmwa::map::magic::EffectAbort, tmwa::map::magic::EffectAssign, tmwa::map::magic::EffectForEach, tmwa::map::magic::EffectFor, tmwa::map::magic::EffectIf, tmwa::map::magic::EffectSleep, tmwa::map::magic::EffectScript, tmwa::map::magic::EffectBreak, tmwa::map::magic::EffectOp, tmwa::map::magic::EffectEnd, tmwa::map::magic::EffectCall>> = {(tmwa::map::magic::EffectAssign) = {id = 42, expr = 0x0}}, next = 0x0}'),
+ ('tmwa::map::magic::effect_t(tmwa::map::magic::EffectForEach{123, tmwa::dumb_ptr<tmwa::map::magic::expr_t>(), tmwa::dumb_ptr<tmwa::map::magic::effect_t>(), tmwa::map::magic::FOREACH_FILTER::PC}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::EffectSkip, tmwa::map::magic::EffectAbort, tmwa::map::magic::EffectAssign, tmwa::map::magic::EffectForEach, tmwa::map::magic::EffectFor, tmwa::map::magic::EffectIf, tmwa::map::magic::EffectSleep, tmwa::map::magic::EffectScript, tmwa::map::magic::EffectBreak, tmwa::map::magic::EffectOp, tmwa::map::magic::EffectEnd, tmwa::map::magic::EffectCall>> = {(tmwa::map::magic::EffectForEach) = {id = 123, area = 0x0, body = 0x0, filter = tmwa::map::magic::FOREACH_FILTER::PC}}, next = 0x0}'),
+ ('tmwa::map::magic::effect_t(tmwa::map::magic::EffectFor{42, tmwa::dumb_ptr<tmwa::map::magic::expr_t>(), tmwa::dumb_ptr<tmwa::map::magic::expr_t>(), tmwa::dumb_ptr<tmwa::map::magic::effect_t>()}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::EffectSkip, tmwa::map::magic::EffectAbort, tmwa::map::magic::EffectAssign, tmwa::map::magic::EffectForEach, tmwa::map::magic::EffectFor, tmwa::map::magic::EffectIf, tmwa::map::magic::EffectSleep, tmwa::map::magic::EffectScript, tmwa::map::magic::EffectBreak, tmwa::map::magic::EffectOp, tmwa::map::magic::EffectEnd, tmwa::map::magic::EffectCall>> = {(tmwa::map::magic::EffectFor) = {id = 42, start = 0x0, stop = 0x0, body = 0x0}}, next = 0x0}'),
+ ('tmwa::map::magic::effect_t(tmwa::map::magic::EffectIf{tmwa::dumb_ptr<tmwa::map::magic::expr_t>(), tmwa::dumb_ptr<tmwa::map::magic::effect_t>(), tmwa::dumb_ptr<tmwa::map::magic::effect_t>()}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::EffectSkip, tmwa::map::magic::EffectAbort, tmwa::map::magic::EffectAssign, tmwa::map::magic::EffectForEach, tmwa::map::magic::EffectFor, tmwa::map::magic::EffectIf, tmwa::map::magic::EffectSleep, tmwa::map::magic::EffectScript, tmwa::map::magic::EffectBreak, tmwa::map::magic::EffectOp, tmwa::map::magic::EffectEnd, tmwa::map::magic::EffectCall>> = {(tmwa::map::magic::EffectIf) = {cond = 0x0, true_branch = 0x0, false_branch = 0x0}}, next = 0x0}'),
+ ('tmwa::map::magic::effect_t(tmwa::map::magic::EffectSleep{tmwa::dumb_ptr<tmwa::map::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::EffectSkip, tmwa::map::magic::EffectAbort, tmwa::map::magic::EffectAssign, tmwa::map::magic::EffectForEach, tmwa::map::magic::EffectFor, tmwa::map::magic::EffectIf, tmwa::map::magic::EffectSleep, tmwa::map::magic::EffectScript, tmwa::map::magic::EffectBreak, tmwa::map::magic::EffectOp, tmwa::map::magic::EffectEnd, tmwa::map::magic::EffectCall>> = {(tmwa::map::magic::EffectSleep) = {e_sleep = 0x0}}, next = 0x0}'),
+ ('tmwa::map::magic::effect_t(tmwa::map::magic::EffectScript{tmwa::dumb_ptr<const tmwa::map::ScriptBuffer>()}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::EffectSkip, tmwa::map::magic::EffectAbort, tmwa::map::magic::EffectAssign, tmwa::map::magic::EffectForEach, tmwa::map::magic::EffectFor, tmwa::map::magic::EffectIf, tmwa::map::magic::EffectSleep, tmwa::map::magic::EffectScript, tmwa::map::magic::EffectBreak, tmwa::map::magic::EffectOp, tmwa::map::magic::EffectEnd, tmwa::map::magic::EffectCall>> = {(tmwa::map::magic::EffectScript) = {e_script = 0x0}}, next = 0x0}'),
+ ('tmwa::map::magic::effect_t(tmwa::map::magic::EffectBreak{}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::EffectSkip, tmwa::map::magic::EffectAbort, tmwa::map::magic::EffectAssign, tmwa::map::magic::EffectForEach, tmwa::map::magic::EffectFor, tmwa::map::magic::EffectIf, tmwa::map::magic::EffectSleep, tmwa::map::magic::EffectScript, tmwa::map::magic::EffectBreak, tmwa::map::magic::EffectOp, tmwa::map::magic::EffectEnd, tmwa::map::magic::EffectCall>> = {(tmwa::map::magic::EffectBreak) = {<No data fields>}}, next = 0x0}'),
+ ('tmwa::map::magic::effect_t(tmwa::map::magic::EffectOp(), tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::EffectSkip, tmwa::map::magic::EffectAbort, tmwa::map::magic::EffectAssign, tmwa::map::magic::EffectForEach, tmwa::map::magic::EffectFor, tmwa::map::magic::EffectIf, tmwa::map::magic::EffectSleep, tmwa::map::magic::EffectScript, tmwa::map::magic::EffectBreak, tmwa::map::magic::EffectOp, tmwa::map::magic::EffectEnd, tmwa::map::magic::EffectCall>> = {(tmwa::map::magic::EffectOp) = {opp = (op_t *) nullptr, args_nr = 0, line_nr = 0, column = 0, args = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}}, next = 0x0}'),
+ ('tmwa::map::magic::effect_t(tmwa::map::magic::EffectEnd{}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::EffectSkip, tmwa::map::magic::EffectAbort, tmwa::map::magic::EffectAssign, tmwa::map::magic::EffectForEach, tmwa::map::magic::EffectFor, tmwa::map::magic::EffectIf, tmwa::map::magic::EffectSleep, tmwa::map::magic::EffectScript, tmwa::map::magic::EffectBreak, tmwa::map::magic::EffectOp, tmwa::map::magic::EffectEnd, tmwa::map::magic::EffectCall>> = {(tmwa::map::magic::EffectEnd) = {<No data fields>}}, next = 0x0}'),
+ ('tmwa::map::magic::effect_t(tmwa::map::magic::EffectCall{nullptr, tmwa::dumb_ptr<std::vector<tmwa::dumb_ptr<tmwa::map::magic::expr_t>>>(), tmwa::dumb_ptr<tmwa::map::magic::effect_t>()}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::EffectSkip, tmwa::map::magic::EffectAbort, tmwa::map::magic::EffectAssign, tmwa::map::magic::EffectForEach, tmwa::map::magic::EffectFor, tmwa::map::magic::EffectIf, tmwa::map::magic::EffectSleep, tmwa::map::magic::EffectScript, tmwa::map::magic::EffectBreak, tmwa::map::magic::EffectOp, tmwa::map::magic::EffectEnd, tmwa::map::magic::EffectCall>> = {(tmwa::map::magic::EffectCall) = {formalv = nullptr, actualvp = 0x0, body = 0x0}}, next = 0x0}'),
]
@@ -185,20 +185,20 @@ class spellguard_t(object):
enabled = True
tests = [
- ('tmwa::magic::spellguard_t(tmwa::magic::GuardCondition{tmwa::dumb_ptr<tmwa::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::GuardCondition) = {s_condition = 0x0}}, next = 0x0}'),
- ('tmwa::magic::spellguard_t(tmwa::magic::GuardMana{tmwa::dumb_ptr<tmwa::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::GuardMana) = {s_mana = 0x0}}, next = 0x0}'),
- ('tmwa::magic::spellguard_t(tmwa::magic::GuardCastTime{tmwa::dumb_ptr<tmwa::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::GuardCastTime) = {s_casttime = 0x0}}, next = 0x0}'),
- ('tmwa::magic::spellguard_t(tmwa::magic::GuardComponents{tmwa::dumb_ptr<tmwa::magic::component_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::GuardComponents) = {s_components = 0x0}}, next = 0x0}'),
- ('tmwa::magic::spellguard_t(tmwa::magic::GuardCatalysts{tmwa::dumb_ptr<tmwa::magic::component_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::GuardCatalysts) = {s_catalysts = 0x0}}, next = 0x0}'),
- ('tmwa::magic::spellguard_t(tmwa::magic::GuardChoice{tmwa::dumb_ptr<tmwa::magic::spellguard_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::GuardChoice) = {s_alt = 0x0}}, next = 0x0}'),
- ('tmwa::magic::spellguard_t(tmwa::magic::effect_set_t{tmwa::dumb_ptr<tmwa::magic::effect_t>(), tmwa::dumb_ptr<tmwa::magic::effect_t>(), tmwa::dumb_ptr<tmwa::magic::effect_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::effect_set_t) = {effect = 0x0, at_trigger = 0x0, at_end = 0x0}}, next = 0x0}'),
+ ('tmwa::map::magic::spellguard_t(tmwa::map::magic::GuardCondition{tmwa::dumb_ptr<tmwa::map::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::map::magic::spellguard_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::GuardCondition, tmwa::map::magic::GuardMana, tmwa::map::magic::GuardCastTime, tmwa::map::magic::GuardComponents, tmwa::map::magic::GuardCatalysts, tmwa::map::magic::GuardChoice, tmwa::map::magic::effect_set_t>> = {(tmwa::map::magic::GuardCondition) = {s_condition = 0x0}}, next = 0x0}'),
+ ('tmwa::map::magic::spellguard_t(tmwa::map::magic::GuardMana{tmwa::dumb_ptr<tmwa::map::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::map::magic::spellguard_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::GuardCondition, tmwa::map::magic::GuardMana, tmwa::map::magic::GuardCastTime, tmwa::map::magic::GuardComponents, tmwa::map::magic::GuardCatalysts, tmwa::map::magic::GuardChoice, tmwa::map::magic::effect_set_t>> = {(tmwa::map::magic::GuardMana) = {s_mana = 0x0}}, next = 0x0}'),
+ ('tmwa::map::magic::spellguard_t(tmwa::map::magic::GuardCastTime{tmwa::dumb_ptr<tmwa::map::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::map::magic::spellguard_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::GuardCondition, tmwa::map::magic::GuardMana, tmwa::map::magic::GuardCastTime, tmwa::map::magic::GuardComponents, tmwa::map::magic::GuardCatalysts, tmwa::map::magic::GuardChoice, tmwa::map::magic::effect_set_t>> = {(tmwa::map::magic::GuardCastTime) = {s_casttime = 0x0}}, next = 0x0}'),
+ ('tmwa::map::magic::spellguard_t(tmwa::map::magic::GuardComponents{tmwa::dumb_ptr<tmwa::map::magic::component_t>()}, tmwa::dumb_ptr<tmwa::map::magic::spellguard_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::GuardCondition, tmwa::map::magic::GuardMana, tmwa::map::magic::GuardCastTime, tmwa::map::magic::GuardComponents, tmwa::map::magic::GuardCatalysts, tmwa::map::magic::GuardChoice, tmwa::map::magic::effect_set_t>> = {(tmwa::map::magic::GuardComponents) = {s_components = 0x0}}, next = 0x0}'),
+ ('tmwa::map::magic::spellguard_t(tmwa::map::magic::GuardCatalysts{tmwa::dumb_ptr<tmwa::map::magic::component_t>()}, tmwa::dumb_ptr<tmwa::map::magic::spellguard_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::GuardCondition, tmwa::map::magic::GuardMana, tmwa::map::magic::GuardCastTime, tmwa::map::magic::GuardComponents, tmwa::map::magic::GuardCatalysts, tmwa::map::magic::GuardChoice, tmwa::map::magic::effect_set_t>> = {(tmwa::map::magic::GuardCatalysts) = {s_catalysts = 0x0}}, next = 0x0}'),
+ ('tmwa::map::magic::spellguard_t(tmwa::map::magic::GuardChoice{tmwa::dumb_ptr<tmwa::map::magic::spellguard_t>()}, tmwa::dumb_ptr<tmwa::map::magic::spellguard_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::GuardCondition, tmwa::map::magic::GuardMana, tmwa::map::magic::GuardCastTime, tmwa::map::magic::GuardComponents, tmwa::map::magic::GuardCatalysts, tmwa::map::magic::GuardChoice, tmwa::map::magic::effect_set_t>> = {(tmwa::map::magic::GuardChoice) = {s_alt = 0x0}}, next = 0x0}'),
+ ('tmwa::map::magic::spellguard_t(tmwa::map::magic::effect_set_t{tmwa::dumb_ptr<tmwa::map::magic::effect_t>(), tmwa::dumb_ptr<tmwa::map::magic::effect_t>(), tmwa::dumb_ptr<tmwa::map::magic::effect_t>()}, tmwa::dumb_ptr<tmwa::map::magic::spellguard_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::GuardCondition, tmwa::map::magic::GuardMana, tmwa::map::magic::GuardCastTime, tmwa::map::magic::GuardComponents, tmwa::map::magic::GuardCatalysts, tmwa::map::magic::GuardChoice, tmwa::map::magic::effect_set_t>> = {(tmwa::map::magic::effect_set_t) = {effect = 0x0, at_trigger = 0x0, at_end = 0x0}}, next = 0x0}'),
]
@@ -206,10 +206,10 @@ class cont_activation_record_t(object):
enabled = True
tests = [
- ('tmwa::magic::cont_activation_record_t(tmwa::magic::CarForEach{42, true, tmwa::dumb_ptr<tmwa::magic::effect_t>(), tmwa::dumb_ptr<std::vector<tmwa::BlockId>>(), 123}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::CarForEach, tmwa::magic::CarFor, tmwa::magic::CarProc>> = {(tmwa::magic::CarForEach) = {id = 42, ty_is_spell_not_entity = true, body = 0x0, entities_vp = 0x0, index = 123}}, return_location = 0x0}'),
- ('tmwa::magic::cont_activation_record_t(tmwa::magic::CarFor{42, tmwa::dumb_ptr<tmwa::magic::effect_t>(), 123, 456}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::CarForEach, tmwa::magic::CarFor, tmwa::magic::CarProc>> = {(tmwa::magic::CarFor) = {id = 42, body = 0x0, current = 123, stop = 456}}, return_location = 0x0}'),
- ('tmwa::magic::cont_activation_record_t(tmwa::magic::CarProc{123, nullptr, tmwa::dumb_ptr<tmwa::magic::val_t[]>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())',
- '{<tmwa::sexpr::Variant<tmwa::magic::CarForEach, tmwa::magic::CarFor, tmwa::magic::CarProc>> = {(tmwa::magic::CarProc) = {args_nr = 123, formalap = nullptr, old_actualpa = 0x0 = {sz = 0}}}, return_location = 0x0}'),
+ ('tmwa::map::magic::cont_activation_record_t(tmwa::map::magic::CarForEach{42, true, tmwa::dumb_ptr<tmwa::map::magic::effect_t>(), tmwa::dumb_ptr<std::vector<tmwa::BlockId>>(), 123}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::CarForEach, tmwa::map::magic::CarFor, tmwa::map::magic::CarProc>> = {(tmwa::map::magic::CarForEach) = {id = 42, ty_is_spell_not_entity = true, body = 0x0, entities_vp = 0x0, index = 123}}, return_location = 0x0}'),
+ ('tmwa::map::magic::cont_activation_record_t(tmwa::map::magic::CarFor{42, tmwa::dumb_ptr<tmwa::map::magic::effect_t>(), 123, 456}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::CarForEach, tmwa::map::magic::CarFor, tmwa::map::magic::CarProc>> = {(tmwa::map::magic::CarFor) = {id = 42, body = 0x0, current = 123, stop = 456}}, return_location = 0x0}'),
+ ('tmwa::map::magic::cont_activation_record_t(tmwa::map::magic::CarProc{123, nullptr, tmwa::dumb_ptr<tmwa::map::magic::val_t[]>()}, tmwa::dumb_ptr<tmwa::map::magic::effect_t>())',
+ '{<tmwa::sexpr::Variant<tmwa::map::magic::CarForEach, tmwa::map::magic::CarFor, tmwa::map::magic::CarProc>> = {(tmwa::map::magic::CarProc) = {args_nr = 123, formalap = nullptr, old_actualpa = 0x0 = {sz = 0}}}, return_location = 0x0}'),
]
diff --git a/src/map/magic-interpreter.t.hpp b/src/map/magic-interpreter.t.hpp
index ab151fc..e302354 100644
--- a/src/map/magic-interpreter.t.hpp
+++ b/src/map/magic-interpreter.t.hpp
@@ -26,6 +26,8 @@
namespace tmwa
{
+namespace map
+{
namespace magic
{
enum class SPELLARG : uint8_t
@@ -79,4 +81,5 @@ ENUM_BITWISE_OPERATORS(INVOCATION_FLAG)
}
using e::INVOCATION_FLAG;
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp
index 39b47fc..c69dafa 100644
--- a/src/map/magic-stmt.cpp
+++ b/src/map/magic-stmt.cpp
@@ -53,6 +53,8 @@
namespace tmwa
{
+namespace map
+{
namespace magic
{
/* used for local spell effects */
@@ -1539,4 +1541,5 @@ int spell_attack(BlockId caster_id, BlockId target_id)
return 1;
}
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/magic-stmt.hpp b/src/map/magic-stmt.hpp
index cdbd40f..3b04fe3 100644
--- a/src/map/magic-stmt.hpp
+++ b/src/map/magic-stmt.hpp
@@ -28,6 +28,8 @@
namespace tmwa
{
+namespace map
+{
namespace magic
{
struct op_t
@@ -87,4 +89,5 @@ int spell_attack(BlockId caster, BlockId target);
void spell_free_invocation(dumb_ptr<invocation> invocation);
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/magic-stmt.py b/src/map/magic-stmt.py
index 65f44a7..7cc43d0 100644
--- a/src/map/magic-stmt.py
+++ b/src/map/magic-stmt.py
@@ -1,7 +1,7 @@
class op_t(object):
__slots__ = ('_value')
- name = 'tmwa::magic::op_t'
+ name = 'tmwa::map::magic::op_t'
depth = 1
enabled = True
@@ -30,8 +30,8 @@ class op_t(object):
'''
tests = [
- ('static_cast<tmwa::magic::op_t *>(nullptr)',
+ ('static_cast<tmwa::map::magic::op_t *>(nullptr)',
'(op_t *) nullptr'),
- ('new tmwa::magic::op_t{"name"_s, "sig"_s, nullptr}',
+ ('new tmwa::map::magic::op_t{"name"_s, "sig"_s, nullptr}',
'(op_t *) = {->name = "name", ->signature = "sig", ->op = nullptr}'),
]
diff --git a/src/map/magic-v2.cpp b/src/map/magic-v2.cpp
index 7dfae08..52b1b8f 100644
--- a/src/map/magic-v2.cpp
+++ b/src/map/magic-v2.cpp
@@ -38,6 +38,7 @@
#include "../ast/script.hpp"
+#include "globals.hpp"
#include "itemdb.hpp"
#include "magic-expr.hpp"
#include "magic-interpreter.hpp"
@@ -50,16 +51,13 @@
namespace tmwa
{
+namespace map
+{
namespace magic
{
namespace magic_v2
{
static
- std::map<RString, proc_t> procs;
- static
- std::map<RString, val_t> const_defm;
-
- static
size_t intern_id(ZString id_name)
{
// TODO use InternPool
@@ -1293,4 +1291,5 @@ bool load_magic_file_v2(ZString filename)
return rv;
}
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/magic-v2.hpp b/src/map/magic-v2.hpp
index 9ad44a9..fac2773 100644
--- a/src/map/magic-v2.hpp
+++ b/src/map/magic-v2.hpp
@@ -25,10 +25,13 @@
namespace tmwa
{
+namespace map
+{
namespace magic
{
bool magic_init0();
// must be called after itemdb initialization
bool load_magic_file_v2(ZString filename);
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/magic.cpp b/src/map/magic.cpp
index a6439a5..418312a 100644
--- a/src/map/magic.cpp
+++ b/src/map/magic.cpp
@@ -28,6 +28,7 @@
#include "../io/cxxstdio.hpp"
+#include "globals.hpp"
#include "magic-expr.hpp"
#include "magic-interpreter.hpp"
#include "magic-interpreter-base.hpp"
@@ -40,6 +41,8 @@
namespace tmwa
{
+namespace map
+{
namespace magic
{
/// Return a pair of strings, {spellname, parameter}
@@ -123,4 +126,5 @@ int magic_message(dumb_ptr<map_session_data> caster, XString source_invocation)
return 0; /* Not a spell */
}
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/magic.hpp b/src/map/magic.hpp
index 8c1ef84..70d40dc 100644
--- a/src/map/magic.hpp
+++ b/src/map/magic.hpp
@@ -27,6 +27,8 @@
namespace tmwa
{
+namespace map
+{
namespace magic
{
/**
@@ -42,4 +44,5 @@ namespace magic
*/
int magic_message(dumb_ptr<map_session_data> caster, XString source_invocation);
} // namespace magic
+} // namespace map
} // namespace tmwa
diff --git a/src/map/main.cpp b/src/map/main.cpp
index a54bb3f..f19272d 100644
--- a/src/map/main.cpp
+++ b/src/map/main.cpp
@@ -26,6 +26,9 @@
namespace tmwa
{
+namespace map
+{
+} // namespace map
} // namespace tmwa
int main(int argc, char **argv)
diff --git a/src/map/map.cpp b/src/map/map.cpp
index 25933a9..d502fbb 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -63,13 +63,16 @@
#include "atcommand.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "chrif.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "grfio.hpp"
#include "itemdb.hpp"
#include "magic-interpreter.hpp" // for is_spell inline body
#include "magic-stmt.hpp"
#include "magic-v2.hpp"
+#include "map_conf.hpp"
#include "mob.hpp"
#include "npc.hpp"
#include "npc-parse.hpp"
@@ -85,47 +88,16 @@
namespace tmwa
{
-DMap<BlockId, dumb_ptr<block_list>> id_db;
-
-UPMap<MapName, map_abstract> maps_db;
-
-static
-DMap<CharName, dumb_ptr<map_session_data>> nick_db;
-
-struct charid2nick
-{
- CharName nick;
- int req_id;
-};
-
-static
-Map<CharId, struct charid2nick> charid_db;
-
-static
-int users = 0;
-static
-Array<dumb_ptr<block_list>, unwrap<BlockId>(MAX_FLOORITEM)> object;
-static
-BlockId first_free_object_id = BlockId();
-
-interval_t autosave_time = DEFAULT_AUTOSAVE_INTERVAL;
-int save_settings = 0xFFFF;
-
-AString motd_txt = "conf/motd.txt"_s;
-
-const CharName WISP_SERVER_NAME = stringish<CharName>("Server"_s);
-
-map_local undefined_gat = [](){ map_local rv {}; rv.name_ = stringish<MapName>("undefined.gat"_s); return rv; }();
-
void SessionDeleter::operator()(SessionData *sd)
{
- really_delete1 static_cast<map_session_data *>(sd);
+ really_delete1 static_cast<map::map_session_data *>(sd);
}
-VString<49> convert_for_printf(NpcEvent ev)
+namespace map
{
- return STRNPRINTF(50, "%s::%s"_fmt, ev.npc, ev.label);
-}
+const CharName WISP_SERVER_NAME = stringish<CharName>("Server"_s);
+
+map_local undefined_gat = [](){ map_local rv {}; rv.name_ = stringish<MapName>("undefined.gat"_s); return rv; }();
/*==========================================
* 全map鯖総計での接続数設定
@@ -134,7 +106,7 @@ VString<49> convert_for_printf(NpcEvent ev)
*/
void map_setusers(int n)
{
- users = n;
+ world_user_count = n;
}
/*==========================================
@@ -143,14 +115,9 @@ void map_setusers(int n)
*/
int map_getusers(void)
{
- return users;
+ return world_user_count;
}
-static
-int block_free_lock = 0;
-static
-std::vector<dumb_ptr<block_list>> block_free;
-
void MapBlockLock::freeblock(dumb_ptr<block_list> bl)
{
if (block_free_lock == 0)
@@ -175,12 +142,6 @@ MapBlockLock::~MapBlockLock()
}
}
-/// This is a dummy entry that is shared by all the linked lists,
-/// so that any entry can unlink itself without worrying about
-/// whether it was the the head of the list.
-static
-struct block_list bl_head;
-
/*==========================================
* map[]のblock_listに追加
* mobは数が多いので別リスト
@@ -776,14 +737,14 @@ BlockId map_addflooritem(Item *item_data, int amount,
interval_t owner_protection[3];
{
- owner_protection[0] = static_cast<interval_t>(battle_config.item_first_get_time);
- owner_protection[1] = owner_protection[0] + static_cast<interval_t>(battle_config.item_second_get_time);
- owner_protection[2] = owner_protection[1] + static_cast<interval_t>(battle_config.item_third_get_time);
+ owner_protection[0] = battle_config.item_first_get_time;
+ owner_protection[1] = owner_protection[0] + battle_config.item_second_get_time;
+ owner_protection[2] = owner_protection[1] + battle_config.item_third_get_time;
}
return map_addflooritem_any(item_data, amount, m, x, y,
owners, owner_protection,
- static_cast<interval_t>(battle_config.flooritem_lifetime), 1);
+ battle_config.flooritem_lifetime, 1);
}
/*==========================================
@@ -1252,7 +1213,7 @@ int map_setipport(MapName name, IP4Address ip, int port)
if (md->gat)
{
// local -> check data
- if (ip != clif_getip() || port != clif_getport())
+ if (ip != map_conf.map_ip || port != map_conf.map_port)
{
PRINTF("from char server : %s -> %s:%d\n"_fmt,
name, ip, port);
@@ -1399,18 +1360,11 @@ void map_delmap(MapName mapname)
constexpr int LOGFILE_SECONDS_PER_CHUNK_SHIFT = 10;
static
-std::unique_ptr<io::AppendFile> map_logfile;
-static
-AString map_logfile_name;
-static
-long map_logfile_index;
-
-static
void map_close_logfile(void)
{
if (map_logfile)
{
- AString filename = STRPRINTF("%s.%ld"_fmt, map_logfile_name, map_logfile_index);
+ AString filename = STRPRINTF("%s.%ld"_fmt, map_conf.log_file, map_logfile_index);
const char *args[] =
{
"gzip",
@@ -1438,22 +1392,23 @@ void map_start_logfile(long index)
AString filename_buf = STRPRINTF(
"%s.%ld"_fmt,
- map_logfile_name,
+ map_conf.log_file,
map_logfile_index);
map_logfile = make_unique<io::AppendFile>(filename_buf);
if (!map_logfile->is_open())
{
map_logfile.reset();
- perror(map_logfile_name.c_str());
+ perror(map_conf.log_file.c_str());
}
}
static
-void map_set_logfile(AString filename)
+void map_set_logfile()
{
- struct timeval tv;
+ if (!map_conf.log_file)
+ return;
- map_logfile_name = std::move(filename);
+ struct timeval tv;
gettimeofday(&tv, nullptr);
map_start_logfile(tv.tv_sec >> LOGFILE_SECONDS_PER_CHUNK_SHIFT);
@@ -1479,127 +1434,6 @@ void map_log(XString line)
}
static
-bool map_config(io::Spanned<XString> w1, io::Spanned<ZString> w2)
-{
- struct hostent *h = nullptr;
-
- {
- if (w1.data == "userid"_s)
- {
- AccountName name = stringish<AccountName>(w2.data);
- chrif_setuserid(name);
- }
- else if (w1.data == "passwd"_s)
- {
- AccountPass pass = stringish<AccountPass>(w2.data);
- chrif_setpasswd(pass);
- }
- else if (w1.data == "char_ip"_s)
- {
- h = gethostbyname(w2.data.c_str());
- IP4Address w2ip;
- if (h != nullptr)
- {
- w2ip = IP4Address({
- static_cast<uint8_t>(h->h_addr[0]),
- static_cast<uint8_t>(h->h_addr[1]),
- static_cast<uint8_t>(h->h_addr[2]),
- static_cast<uint8_t>(h->h_addr[3]),
- });
- PRINTF("Character server IP address : %s -> %s\n"_fmt,
- w2.data, w2ip);
- }
- else
- {
- PRINTF("Bad IP value: %s\n"_fmt, w2.data);
- return false;
- }
- chrif_setip(w2ip);
- }
- else if (w1.data == "char_port"_s)
- {
- chrif_setport(atoi(w2.data.c_str()));
- }
- else if (w1.data == "map_ip"_s)
- {
- h = gethostbyname(w2.data.c_str());
- IP4Address w2ip;
- if (h != nullptr)
- {
- w2ip = IP4Address({
- static_cast<uint8_t>(h->h_addr[0]),
- static_cast<uint8_t>(h->h_addr[1]),
- static_cast<uint8_t>(h->h_addr[2]),
- static_cast<uint8_t>(h->h_addr[3]),
- });
- PRINTF("Map server IP address : %s -> %s\n"_fmt,
- w2.data, w2ip);
- }
- else
- {
- PRINTF("Bad IP value: %s\n"_fmt, w2.data);
- return false;
- }
- clif_setip(w2ip);
- }
- else if (w1.data == "map_port"_s)
- {
- clif_setport(atoi(w2.data.c_str()));
- }
- else if (w1.data == "map"_s)
- {
- MapName name = VString<15>(w2.data);
- map_addmap(name);
- }
- else if (w1.data == "delmap"_s)
- {
- MapName name = VString<15>(w2.data);
- map_delmap(name);
- }
- else if (w1.data == "npc"_s)
- {
- npc_addsrcfile(w2.data);
- }
- else if (w1.data == "delnpc"_s)
- {
- npc_delsrcfile(w2.data);
- }
- else if (w1.data == "autosave_time"_s)
- {
- autosave_time = std::chrono::seconds(atoi(w2.data.c_str()));
- if (autosave_time <= interval_t::zero())
- autosave_time = DEFAULT_AUTOSAVE_INTERVAL;
- }
- else if (w1.data == "motd_txt"_s)
- {
- motd_txt = w2.data;
- }
- else if (w1.data == "mapreg_txt"_s)
- {
- mapreg_txt = w2.data;
- }
- else if (w1.data == "gm_log"_s)
- {
- gm_log = std::move(w2.data);
- }
- else if (w1.data == "log_file"_s)
- {
- map_set_logfile(w2.data);
- }
- else if (w1.data == "import"_s)
- {
- return load_config_file(w2.data, map_config);
- }
- else
- {
- return false;
- }
- }
-
- return true;
-}
-
-static
void cleanup_sub(dumb_ptr<block_list> bl)
{
nullpo_retv(bl);
@@ -1624,42 +1458,21 @@ void cleanup_sub(dumb_ptr<block_list> bl)
}
}
-/*==========================================
- * map鯖終了時処理
- *------------------------------------------
- */
-void term_func(void)
+int compare_item(Item *a, Item *b)
{
- for (auto& mit : maps_db)
- {
- if (!mit.second->gat)
- continue;
- P<map_local> map_id = borrow(*mit.second).downcast_to<map_local>();
-
- map_foreachinarea(cleanup_sub,
- map_id,
- 0, 0,
- map_id->xs, map_id->ys,
- BL::NUL);
- }
-
- for (io::FD i : iter_fds())
- delete_session(get_session(i));
-
- map_removenpc();
-
- maps_db.clear();
-
- do_final_script();
- do_final_itemdb();
- do_final_storage();
+ return (a->nameid == b->nameid);
+}
- map_close_logfile();
+static
+bool map_config(io::Spanned<XString> key, io::Spanned<ZString> value)
+{
+ return parse_map_conf(map_conf, key, value);
}
-int compare_item(Item *a, Item *b)
+static
+bool battle_config_(io::Spanned<XString> key, io::Spanned<ZString> value)
{
- return (a->nameid == b->nameid);
+ return parse_battle_conf(battle_config, key, value);
}
static
@@ -1668,7 +1481,7 @@ bool map_confs(io::Spanned<XString> key, io::Spanned<ZString> value)
if (key.data == "map_conf"_s)
return load_config_file(value.data, map_config);
if (key.data == "battle_conf"_s)
- return battle_config_read(value.data);
+ return load_config_file(value.data, battle_config_);
if (key.data == "atcommand_conf"_s)
return atcommand_config_read(value.data);
@@ -1687,16 +1500,72 @@ bool map_confs(io::Spanned<XString> key, io::Spanned<ZString> value)
return load_resnametable(value.data);
if (key.data == "const_db"_s)
return read_constdb(value.data);
- PRINTF("unknown map conf key: %s\n"_fmt, AString(key.data));
+ key.span.error("Unknown meta-key for map server"_s);
return false;
}
+int map_scriptcont(dumb_ptr<map_session_data> sd, BlockId id)
+{
+ dumb_ptr<block_list> bl = map_id2bl(id);
+
+ if (!bl)
+ return 0;
+
+ switch (bl->bl_type)
+ {
+ case BL::NPC:
+ return npc_scriptcont(sd, id);
+ case BL::SPELL:
+ magic::spell_execute_script(bl->is_spell());
+ break;
+ }
+
+ return 0;
+}
+} // namespace map
+
+/*==========================================
+ * map鯖終了時処理
+ *------------------------------------------
+ */
+void term_func(void)
+{
+ using namespace tmwa::map;
+ for (auto& mit : maps_db)
+ {
+ if (!mit.second->gat)
+ continue;
+ P<map_local> map_id = borrow(*mit.second).downcast_to<map_local>();
+
+ map_foreachinarea(cleanup_sub,
+ map_id,
+ 0, 0,
+ map_id->xs, map_id->ys,
+ BL::NUL);
+ }
+
+ for (io::FD i : iter_fds())
+ delete_session(get_session(i));
+
+ map_removenpc();
+
+ maps_db.clear();
+
+ do_final_script();
+ do_final_itemdb();
+ do_final_storage();
+
+ map_close_logfile();
+}
+
/*======================================================
* Map-Server Init and Command-line Arguments [Valaris]
*------------------------------------------------------
*/
int do_init(Slice<ZString> argv)
{
+ using namespace tmwa::map;
+
ZString argv0 = argv.pop_front();
runflag &= magic::magic_init0();
@@ -1744,7 +1613,8 @@ int do_init(Slice<ZString> argv)
if (!loaded_config_yet)
runflag &= load_config_file("conf/tmwa-map.conf"_s, map_confs);
- battle_config_check();
+ map_set_logfile();
+
runflag &= map_readallmap();
do_init_chrif();
@@ -1762,26 +1632,7 @@ int do_init(Slice<ZString> argv)
PRINTF("The server is running in " SGR_BOLD SGR_RED "PK Mode" SGR_RESET "\n"_fmt);
PRINTF("The map-server is " SGR_BOLD SGR_GREEN "ready" SGR_RESET " (Server is listening on the port %d).\n\n"_fmt,
- clif_getport());
-
- return 0;
-}
-
-int map_scriptcont(dumb_ptr<map_session_data> sd, BlockId id)
-{
- dumb_ptr<block_list> bl = map_id2bl(id);
-
- if (!bl)
- return 0;
-
- switch (bl->bl_type)
- {
- case BL::NPC:
- return npc_scriptcont(sd, id);
- case BL::SPELL:
- magic::spell_execute_script(bl->is_spell());
- break;
- }
+ map_conf.map_port);
return 0;
}
diff --git a/src/map/map.hpp b/src/map/map.hpp
index 48bd997..3dd03e7 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -52,6 +52,8 @@
namespace tmwa
{
+namespace map
+{
constexpr int MAX_NPC_PER_MAP = 512;
constexpr int BLOCK_SIZE = 8;
#define AREA_SIZE battle_config.area_size
@@ -59,7 +61,6 @@ constexpr std::chrono::seconds LIFETIME_FLOORITEM = 1_min;
constexpr int MAX_SKILL_LEVEL = 100;
constexpr int MAX_EVENTTIMER = 32;
constexpr interval_t NATURAL_HEAL_INTERVAL = 500_ms;
-constexpr BlockId MAX_FLOORITEM = wrap<BlockId>(500000_u32);
constexpr int MAX_LEVEL = 255;
constexpr int MAX_WALKPATH = 48;
constexpr int MAX_DROP_PER_MAP = 48;
@@ -286,14 +287,14 @@ struct map_session_data : block_list, SessionData
unsigned in_progress:1;
} auto_ban_info;
- TimeT chat_reset_due;
- TimeT chat_repeat_reset_due;
+ tick_t chat_reset_due;
+ tick_t chat_repeat_reset_due;
int chat_lines_in;
int chat_total_repeats;
RString chat_lastmsg;
tick_t flood_rates[0x220];
- TimeT packet_flood_reset_due;
+ tick_t packet_flood_reset_due;
int packet_flood_in;
IP4Address get_ip()
@@ -492,8 +493,6 @@ struct map_abstract
map_abstract(map_abstract&&) = default;
virtual ~map_abstract() {}
};
-extern
-UPMap<MapName, map_abstract> maps_db;
struct map_local : map_abstract
{
@@ -530,11 +529,6 @@ struct flooritem_data : block_list
Item item_data;
};
-extern interval_t autosave_time;
-extern int save_settings;
-
-extern AString motd_txt;
-
extern const CharName WISP_SERVER_NAME;
// 鯖全体情報
@@ -607,8 +601,6 @@ BlockId map_addflooritem(Item *, int,
dumb_ptr<map_session_data>);
// キャラid=>キャラ名 変換関連
-extern
-DMap<BlockId, dumb_ptr<block_list>> id_db;
void map_addchariddb(CharId charid, CharName name);
CharName map_charid2nick(CharId);
@@ -701,4 +693,11 @@ inline dumb_ptr<npc_data_message> npc_data::is_message() { return npc_subtype ==
void map_addmap(MapName mapname);
void map_delmap(MapName mapname);
+
+struct charid2nick
+{
+ CharName nick;
+ int req_id;
+};
+} // namespace map
} // namespace tmwa
diff --git a/src/map/map.py b/src/map/map.py
index cb29d53..c7adf56 100644
--- a/src/map/map.py
+++ b/src/map/map.py
@@ -1,7 +1,7 @@
class map_local(object):
__slots__ = ('_value')
- name = 'tmwa::map_local'
+ name = 'tmwa::map::map_local'
depth = 1
enabled = True
@@ -26,14 +26,14 @@ class map_local(object):
yield '->ys', value['ys']
tests = [
- ('static_cast<tmwa::map_local *>(nullptr)', '(map_local *) nullptr'),
+ ('static_cast<tmwa::map::map_local *>(nullptr)', '(map_local *) nullptr'),
('fake_map_local("map"_s, 42, 404)', '(map_local *) = {->name = "map", ->xs = 42, ->ys = 404}'),
]
class map_remote(object):
__slots__ = ('_value')
- name = 'tmwa::map_remote'
+ name = 'tmwa::map::map_remote'
depth = 1
enabled = True
@@ -58,14 +58,14 @@ class map_remote(object):
yield '->port', value['port']
tests = [
- ('static_cast<tmwa::map_remote *>(nullptr)', '(map_remote *) nullptr'),
+ ('static_cast<tmwa::map::map_remote *>(nullptr)', '(map_remote *) nullptr'),
('fake_map_remote("map"_s, tmwa::IP4Address({8, 8, 8, 8}), 6667)', '(map_remote *) = {->name = "map", ->ip = 8.8.8.8, ->port = 6667}'),
]
class map_abstract(object):
__slots__ = ('_value')
- name = 'tmwa::map_abstract'
+ name = 'tmwa::map::map_abstract'
depth = 1
enabled = True
@@ -79,19 +79,19 @@ class map_abstract(object):
if value is None:
return '(map_abstract *) nullptr'
gat = value.dereference()['gat']
- gat = gat.address.cast(gdb.lookup_type('tmwa::map_abstract').pointer().pointer()).dereference()
+ gat = gat.address.cast(gdb.lookup_type('tmwa::map::map_abstract').pointer().pointer()).dereference()
if gat:
- return value.cast(gdb.lookup_type('tmwa::map_local').pointer())
+ return value.cast(gdb.lookup_type('tmwa::map::map_local').pointer())
else:
- return value.cast(gdb.lookup_type('tmwa::map_remote').pointer())
+ return value.cast(gdb.lookup_type('tmwa::map::map_remote').pointer())
tests = [
- ('static_cast<tmwa::map_abstract *>(nullptr)', '(map_abstract *) nullptr'),
+ ('static_cast<tmwa::map::map_abstract *>(nullptr)', '(map_abstract *) nullptr'),
] + [
- ('static_cast<tmwa::map_abstract *>(%s); value->gat.reset(new tmwa::MapCell[1])' % expr, expected)
+ ('static_cast<tmwa::map::map_abstract *>(%s); value->gat.reset(new tmwa::map::MapCell[1])' % expr, expected)
for (expr, expected) in map_local.tests[1:]
] + [
- ('static_cast<tmwa::map_abstract *>(%s)' % expr, expected)
+ ('static_cast<tmwa::map::map_abstract *>(%s)' % expr, expected)
for (expr, expected) in map_remote.tests[1:]
]
@@ -99,9 +99,9 @@ class map_abstract(object):
using tmwa::operator "" _s;
inline
- tmwa::map_local *fake_map_local(tmwa::ZString name, int xs, int ys)
+ tmwa::map::map_local *fake_map_local(tmwa::ZString name, int xs, int ys)
{
- auto *p = new tmwa::map_local{};
+ auto *p = new tmwa::map::map_local{};
p->name_ = tmwa::stringish<tmwa::MapName>(name);
p->xs = xs;
p->ys = ys;
@@ -109,17 +109,17 @@ class map_abstract(object):
}
inline
- tmwa::map_remote *fake_map_remote(tmwa::ZString name, tmwa::IP4Address ip, uint16_t port)
+ tmwa::map::map_remote *fake_map_remote(tmwa::ZString name, tmwa::IP4Address ip, uint16_t port)
{
- auto *p = new tmwa::map_remote{};
+ auto *p = new tmwa::map::map_remote{};
p->name_ = tmwa::stringish<tmwa::MapName>(name);
p->ip = ip;
p->port = port;
return p;
}
- void fake_delete(tmwa::map_abstract *);
- void fake_delete(tmwa::map_abstract *map)
+ void fake_delete(tmwa::map::map_abstract *);
+ void fake_delete(tmwa::map::map_abstract *map)
{
delete map;
}
diff --git a/src/map/map.t.hpp b/src/map/map.t.hpp
index e8a62bc..267c049 100644
--- a/src/map/map.t.hpp
+++ b/src/map/map.t.hpp
@@ -34,6 +34,8 @@
namespace tmwa
{
+namespace map
+{
enum class BL : uint8_t
{
NUL,
@@ -195,4 +197,5 @@ inline
BlockId account_to_block(AccountId a) { return wrap<BlockId>(unwrap<AccountId>(a)); }
inline
AccountId block_to_account(BlockId b) { return wrap<AccountId>(unwrap<BlockId>(b)); }
+} // namespace map
} // namespace tmwa
diff --git a/src/map/mapflag.cpp b/src/map/mapflag.cpp
index d5e78d8..9f3c9ab 100644
--- a/src/map/mapflag.cpp
+++ b/src/map/mapflag.cpp
@@ -25,6 +25,8 @@
namespace tmwa
{
+namespace map
+{
// because bitfields, that's why
bool MapFlags::get(MapFlag mf) const
@@ -93,4 +95,5 @@ MapFlag map_flag_from_int(int shift)
{
return static_cast<MapFlag>(1 << shift);
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/mapflag.hpp b/src/map/mapflag.hpp
index 5818697..3538c56 100644
--- a/src/map/mapflag.hpp
+++ b/src/map/mapflag.hpp
@@ -25,6 +25,8 @@
namespace tmwa
{
+namespace map
+{
// originally from script.cpp
// These are part of the script API, so they can't change ever,
// even though they are silly.
@@ -78,4 +80,5 @@ public:
bool impl_extract(XString str, MapFlag *mf);
MapFlag map_flag_from_int(int shift);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/mapflag.py b/src/map/mapflag.py
index fe5b016..b0a2f24 100644
--- a/src/map/mapflag.py
+++ b/src/map/mapflag.py
@@ -1,6 +1,6 @@
class MapFlags(object):
__slots__ = ('_value')
- name = 'tmwa::MapFlags'
+ name = 'tmwa::map::MapFlags'
enabled = True
def __init__(self, value):
@@ -52,12 +52,12 @@ class MapFlags(object):
('RESAVE', 30),
]
tests = [
- ('reinterpret_cast<const tmwa::MapFlags&>(static_cast<const unsigned int&>(0x80000000))', 'MapFlags(0x80000000)'),
- ('reinterpret_cast<const tmwa::MapFlags&>(static_cast<const unsigned int&>(0xf0000000))', 'MapFlags(TOWN | OUTSIDE | RESAVE | 0x80000000)'),
+ ('reinterpret_cast<const tmwa::map::MapFlags&>(static_cast<const unsigned int&>(0x80000000))', 'MapFlags(0x80000000)'),
+ ('reinterpret_cast<const tmwa::map::MapFlags&>(static_cast<const unsigned int&>(0xf0000000))', 'MapFlags(TOWN | OUTSIDE | RESAVE | 0x80000000)'),
] + [
- ('tmwa::MapFlags(); value.set(tmwa::MapFlag::%s, true)' % n, 'MapFlags(%s)' % n)
+ ('tmwa::map::MapFlags(); value.set(tmwa::map::MapFlag::%s, true)' % n, 'MapFlags(%s)' % n)
for (n, _) in junk
] + [
- ('reinterpret_cast<const tmwa::MapFlags&>(static_cast<const unsigned int&>(1 << %d))' % i, 'MapFlags(%s)' % n)
+ ('reinterpret_cast<const tmwa::map::MapFlags&>(static_cast<const unsigned int&>(1 << %d))' % i, 'MapFlags(%s)' % n)
for (n, i) in junk
]
diff --git a/src/map/mob.cpp b/src/map/mob.cpp
index c690ad0..cdb348c 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -47,7 +47,9 @@
#include "../mmo/extract_enums.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "itemdb.hpp"
#include "map.hpp"
#include "npc.hpp"
@@ -61,6 +63,8 @@
namespace tmwa
{
+namespace map
+{
constexpr interval_t MIN_MOBTHINKTIME = 100_ms;
// Move probability in the negligent mode MOB (rate of 1000 minute)
@@ -68,8 +72,6 @@ constexpr random_::Fraction MOB_LAZYMOVEPERC {50, 1000};
// Warp probability in the negligent mode MOB (rate of 1000 minute)
constexpr random_::Fraction MOB_LAZYWARPPERC {20, 1000};
-static
-struct mob_db_ mob_db[2001];
struct mob_db_& get_mob_db(Species s)
{
return mob_db[unwrap<Species>(s)];
@@ -318,12 +320,12 @@ int mob_gen_exp(mob_db_ *mob)
(2 * mob->attrs[ATTR::LUK] * mob->max_hp / mod_def);
double attack_factor =
(mob->atk1 + mob->atk2 + mob->attrs[ATTR::STR] / 3.0 + mob->attrs[ATTR::DEX] / 2.0 +
- mob->attrs[ATTR::LUK]) * (1872.0 / mob->adelay) / 4;
+ mob->attrs[ATTR::LUK]) * (1872.0 / mob->adelay.count()) / 4;
double dodge_factor =
pow(mob->lv + mob->attrs[ATTR::AGI] + mob->attrs[ATTR::LUK] / 2.0, 4.0 / 3.0);
// TODO s/persuit/pursuit/g sometime when I'm not worried about diffs
double persuit_factor =
- (3 + mob->range) * bool(mob->mode & MobMode::CAN_MOVE) * 1000 / mob->speed;
+ (3 + mob->range) * bool(mob->mode & MobMode::CAN_MOVE) * 1000 / mob->speed.count();
double aggression_factor =
bool(mob->mode & MobMode::AGGRESSIVE)
? 10.0 / 9.0
@@ -357,10 +359,10 @@ void mob_init(dumb_ptr<mob_data> md)
md->stats[mob_stat::LUK] = get_mob_db(mob_class).attrs[ATTR::LUK];
md->stats[mob_stat::ATK1] = get_mob_db(mob_class).atk1;
md->stats[mob_stat::ATK2] = get_mob_db(mob_class).atk2;
- md->stats[mob_stat::ADELAY] = get_mob_db(mob_class).adelay;
+ md->stats[mob_stat::ADELAY] = get_mob_db(mob_class).adelay.count();
md->stats[mob_stat::DEF] = get_mob_db(mob_class).def;
md->stats[mob_stat::MDEF] = get_mob_db(mob_class).mdef;
- md->stats[mob_stat::SPEED] = get_mob_db(mob_class).speed;
+ md->stats[mob_stat::SPEED] = get_mob_db(mob_class).speed.count();
md->stats[mob_stat::XP_BONUS] = MOB_XP_BONUS_BASE;
for (i = 0; i < mutations_nr; i++)
@@ -1148,7 +1150,7 @@ int mob_spawn(BlockId id)
mob_init(md);
if (!md->stats[mob_stat::SPEED])
- md->stats[mob_stat::SPEED] = get_mob_db(md->mob_class).speed;
+ md->stats[mob_stat::SPEED] = get_mob_db(md->mob_class).speed.count();
md->def_ele = get_mob_db(md->mob_class).element;
md->master_id = BlockId();
md->master_dist = 0;
@@ -3415,10 +3417,10 @@ int mob_makedummymobdb(Species mob_class)
get_mob_db(mob_class).race = Race::formless;
get_mob_db(mob_class).element = LevelElement{0, Element::neutral};
get_mob_db(mob_class).mode = MobMode::ZERO;
- get_mob_db(mob_class).speed = 300;
- get_mob_db(mob_class).adelay = 1000;
- get_mob_db(mob_class).amotion = 500;
- get_mob_db(mob_class).dmotion = 500;
+ get_mob_db(mob_class).speed = 300_ms;
+ get_mob_db(mob_class).adelay = 1000_ms;
+ get_mob_db(mob_class).amotion = 500_ms;
+ get_mob_db(mob_class).dmotion = 500_ms;
for (i = 0; i < 8; i++)
{
get_mob_db(mob_class).dropitem[i].nameid = ItemNameId();
@@ -3743,4 +3745,5 @@ void do_init_mob2(void)
MIN_MOBTHINKTIME * 10
).detach();
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/mob.hpp b/src/map/mob.hpp
index 6f6fb47..6d87228 100644
--- a/src/map/mob.hpp
+++ b/src/map/mob.hpp
@@ -37,6 +37,8 @@
namespace tmwa
{
+namespace map
+{
#define ENGLISH_NAME stringish<MobName>("--en--"_s)
#define JAPANESE_NAME stringish<MobName>("--ja--"_s)
#define MOB_THIS_MAP stringish<MapName>("this"_s)
@@ -71,7 +73,7 @@ struct mob_db_
Race race;
LevelElement element;
MobMode mode;
- int speed, adelay, amotion, dmotion;
+ interval_t speed, adelay, amotion, dmotion;
int mutations_nr, mutation_power;
struct
{
@@ -135,4 +137,5 @@ void mobskill_castend_pos(TimerData *tid, tick_t tick, BlockId id);
int mob_summonslave(dumb_ptr<mob_data> md2, int *value, int amount, int flag);
void mob_reload(void);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/mob.t.hpp b/src/map/mob.t.hpp
index 160a8a3..54e7ebe 100644
--- a/src/map/mob.t.hpp
+++ b/src/map/mob.t.hpp
@@ -27,6 +27,8 @@
namespace tmwa
{
+namespace map
+{
enum class MobSkillTarget
{
MST_TARGET = 0,
@@ -61,4 +63,5 @@ enum class MobSkillState : uint8_t
MSS_LOOT,
MSS_CHASE,
};
+} // namespace map
} // namespace tmwa
diff --git a/src/map/npc-internal.hpp b/src/map/npc-internal.hpp
index 4ddcc84..993263f 100644
--- a/src/map/npc-internal.hpp
+++ b/src/map/npc-internal.hpp
@@ -26,17 +26,12 @@
namespace tmwa
{
-extern
-BlockId npc_id;
-
+namespace map
+{
struct event_data
{
dumb_ptr<npc_data_script> nd;
int pos;
};
-
-extern
-Map<NpcEvent, struct event_data> ev_db;
-extern
-DMap<NpcName, dumb_ptr<npc_data>> npcs_by_name;
+} // namespace map
} // namespace tmwa
diff --git a/src/map/npc-parse.cpp b/src/map/npc-parse.cpp
index 3df54c7..bdb212c 100644
--- a/src/map/npc-parse.cpp
+++ b/src/map/npc-parse.cpp
@@ -41,7 +41,9 @@
#include "../ast/npc.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "itemdb.hpp"
#include "map.hpp"
#include "mob.hpp"
@@ -53,12 +55,8 @@
namespace tmwa
{
-static
-std::list<AString> npc_srcs;
-
-static
-int npc_warp, npc_shop, npc_script, npc_mob;
-
+namespace map
+{
static
void npc_clearsrcfile(void)
{
@@ -928,4 +926,5 @@ bool do_init_npc(void)
}
return rv;
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/npc-parse.hpp b/src/map/npc-parse.hpp
index 902a214..9bc3448 100644
--- a/src/map/npc-parse.hpp
+++ b/src/map/npc-parse.hpp
@@ -25,6 +25,8 @@
namespace tmwa
{
+namespace map
+{
bool npc_load_warp(ast::npc::Warp& warp);
/**
@@ -38,4 +40,5 @@ dumb_ptr<npc_data> npc_spawn_text(Borrowed<map_local> m, int x, int y,
void npc_addsrcfile(AString name);
void npc_delsrcfile(XString name);
bool do_init_npc(void);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index cd80cdf..3320039 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -45,7 +45,9 @@
#include "../proto2/map-user.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "itemdb.hpp"
#include "map.hpp"
#include "pc.hpp"
@@ -57,8 +59,8 @@
namespace tmwa
{
-BlockId npc_id = START_NPC_NUM;
-
+namespace map
+{
BlockId npc_get_new_npc_id(void)
{
BlockId rv = npc_id;
@@ -66,25 +68,6 @@ BlockId npc_get_new_npc_id(void)
return rv;
}
-Map<NpcEvent, struct event_data> ev_db;
-DMap<NpcName, dumb_ptr<npc_data>> npcs_by_name;
-
-// used for clock-based event triggers
-// only tm_min, tm_hour, and tm_mday are used
-static
-struct tm ev_tm_b =
-{
- .tm_sec= 0,
- .tm_min= -1,
- .tm_hour= -1,
- .tm_mday= -1,
- .tm_mon= 0,
- .tm_year= 0,
- .tm_wday= 0,
- .tm_yday= 0,
- .tm_isdst= 0,
-};
-
/*==========================================
* NPCの無効化/有効化
* npc_enable
@@ -936,4 +919,5 @@ void npc_free(dumb_ptr<npc_data> nd)
map_delblock(nd);
npc_free_internal(nd);
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/npc.hpp b/src/map/npc.hpp
index e62faf2..c856a8c 100644
--- a/src/map/npc.hpp
+++ b/src/map/npc.hpp
@@ -34,6 +34,8 @@
namespace tmwa
{
+namespace map
+{
constexpr BlockId START_NPC_NUM = wrap<BlockId>(110000000);
// TODO make these species, see npc_class in npc_data
@@ -82,4 +84,5 @@ void npc_timerevent_stop(dumb_ptr<npc_data_script> nd);
interval_t npc_gettimerevent_tick(dumb_ptr<npc_data_script> nd);
void npc_settimerevent_tick(dumb_ptr<npc_data_script> nd, interval_t newtimer);
int npc_delete(dumb_ptr<npc_data> nd);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/party.cpp b/src/map/party.cpp
index b05f4f1..ccbfd75 100644
--- a/src/map/party.cpp
+++ b/src/map/party.cpp
@@ -35,7 +35,9 @@
#include "../high/mmo.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "intif.hpp"
#include "map.hpp"
#include "pc.hpp"
@@ -45,13 +47,12 @@
namespace tmwa
{
+namespace map
+{
// 座標やHP送信の間隔
constexpr interval_t PARTY_SEND_XYHP_INVERVAL = 1_s;
static
-Map<PartyId, PartyMost> party_db;
-
-static
void party_check_conflict(dumb_ptr<map_session_data> sd);
static
void party_send_xyhp_timer(TimerData *tid, tick_t tick);
@@ -782,4 +783,5 @@ void party_foreachsamemap(std::function<void(dumb_ptr<block_list>)> func,
if (list[i]->bl_prev) // 有効かどうかチェック
func(list[i]);
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/party.hpp b/src/map/party.hpp
index a3f28e3..669857e 100644
--- a/src/map/party.hpp
+++ b/src/map/party.hpp
@@ -27,6 +27,8 @@
namespace tmwa
{
+namespace map
+{
void do_init_party(void);
Option<PartyPair> party_search(PartyId party_id);
Option<PartyPair> party_searchname(PartyName str);
@@ -63,4 +65,5 @@ int party_exp_share(PartyPair p, Borrowed<map_local> map, int base_exp, int job_
void party_foreachsamemap(std::function<void(dumb_ptr<block_list>)> func,
dumb_ptr<map_session_data> sd, int type);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/path.cpp b/src/map/path.cpp
index 3c05d52..52d20ad 100644
--- a/src/map/path.cpp
+++ b/src/map/path.cpp
@@ -39,6 +39,8 @@
namespace tmwa
{
+namespace map
+{
constexpr int MAX_HEAP = 150;
struct tmp_path
{
@@ -357,4 +359,5 @@ int path_search(struct walkpath_data *wpd, Borrowed<map_local> m, int x0, int y0
return -1;
}
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/path.hpp b/src/map/path.hpp
index 49dac7f..f16baaa 100644
--- a/src/map/path.hpp
+++ b/src/map/path.hpp
@@ -25,5 +25,8 @@
namespace tmwa
{
+namespace map
+{
int path_search(struct walkpath_data *, Borrowed<map_local>, int, int, int, int, int);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 33d77fd..7d04785 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -48,12 +48,15 @@
#include "atcommand.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "chrif.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "intif.hpp"
#include "itemdb.hpp"
#include "magic-stmt.hpp"
#include "map.hpp"
+#include "map_conf.hpp"
#include "npc.hpp"
#include "party.hpp"
#include "path.hpp"
@@ -67,6 +70,8 @@
namespace tmwa
{
+namespace map
+{
// PVP順位計算の間隔
constexpr std::chrono::milliseconds PVP_CALCRANK_INTERVAL =
1_s;
@@ -254,10 +259,6 @@ earray<EPOS, EQUIP, EQUIP::COUNT> equip_pos //=
EPOS::ARROW,
}};
-// TODO use DMap<>
-static
-std::map<AccountId, GmLevel> gm_accountm;
-
static
int pc_checkoverhp(dumb_ptr<map_session_data> sd);
static
@@ -597,7 +598,7 @@ int pc_isequip(dumb_ptr<map_session_data> sd, IOff0 n)
sc_data = battle_get_sc_data(sd);
- GmLevel gm_all_equipment = GmLevel::from(static_cast<uint32_t>(battle_config.gm_all_equipment));
+ GmLevel gm_all_equipment = battle_config.gm_all_equipment;
if (gm_all_equipment && pc_isGM(sd).satisfies(gm_all_equipment))
return 1;
@@ -759,14 +760,14 @@ int pc_authok(AccountId id, int login_id2,
sd->auto_ban_info.in_progress = 0;
// Initialize antispam vars
- sd->chat_reset_due = TimeT();
+ sd->chat_reset_due = tick_t();
sd->chat_lines_in = sd->chat_total_repeats = 0;
- sd->chat_repeat_reset_due = TimeT();
+ sd->chat_repeat_reset_due = tick_t();
sd->chat_lastmsg = RString();
for (tick_t& t : sd->flood_rates)
t = tick_t();
- sd->packet_flood_reset_due = TimeT();
+ sd->packet_flood_reset_due = tick_t();
sd->packet_flood_in = 0;
pc_calcstatus(sd, 1);
@@ -787,7 +788,7 @@ void pc_show_motd(dumb_ptr<map_session_data> sd)
clif_displaymessage(sd->sess, "This server is Free Software, for details type @source in chat or use the tmwa-source tool"_s);
sd->state.seen_motd = true;
- io::ReadFile in(motd_txt);
+ io::ReadFile in(map_conf.motd_txt);
if (in.is_open())
{
AString buf;
@@ -822,7 +823,8 @@ int pc_calc_skillpoint(dumb_ptr<map_session_data> sd)
nullpo_retz(sd);
- for (i = 0; i < skill_pool_skills_size; i++) {
+ for (i = 0; i < skill_pool_skills.size(); i++)
+ {
int lv = sd->status.skill[skill_pool_skills[i]].lv;
if (lv)
skill_points += ((lv * (lv - 1)) >> 1) - 1;
@@ -1320,7 +1322,7 @@ int pc_calcstatus(dumb_ptr<map_session_data> sd, int first)
if (sd->attack_spell_override)
sd->aspd = sd->attack_spell_delay;
- sd->aspd = std::max(sd->aspd, static_cast<interval_t>(battle_config.max_aspd));
+ sd->aspd = std::max(sd->aspd, battle_config.max_aspd);
sd->amotion = sd->aspd;
sd->dmotion = std::chrono::milliseconds(800 - sd->paramc[ATTR::AGI] * 4);
sd->dmotion = std::max(sd->dmotion, 400_ms);
@@ -2661,7 +2663,7 @@ void pc_attack_timer(TimerData *, tick_t tick, BlockId id)
sd->attackabletime = tick + (sd->aspd * 2);
}
if (sd->attackabletime <= tick)
- sd->attackabletime = tick + static_cast<interval_t>(battle_config.max_aspd) * 2;
+ sd->attackabletime = tick + battle_config.max_aspd * 2;
}
}
@@ -4591,10 +4593,6 @@ dumb_ptr<map_session_data> pc_get_partner(dumb_ptr<map_session_data> sd)
* SP回復量計算
*------------------------------------------
*/
-static
-tick_t natural_heal_tick, natural_heal_prev_tick;
-static
-interval_t natural_heal_diff_tick;
static
interval_t pc_spheal(dumb_ptr<map_session_data> sd)
@@ -4652,12 +4650,12 @@ int pc_natural_heal_hp(dumb_ptr<map_session_data> sd)
return 0;
}
- if (sd->hp_sub >= static_cast<interval_t>(battle_config.natural_healhp_interval))
+ if (sd->hp_sub >= battle_config.natural_healhp_interval)
{
bonus = sd->nhealhp;
- while (sd->hp_sub >= static_cast<interval_t>(battle_config.natural_healhp_interval))
+ while (sd->hp_sub >= battle_config.natural_healhp_interval)
{
- sd->hp_sub -= static_cast<interval_t>(battle_config.natural_healhp_interval);
+ sd->hp_sub -= battle_config.natural_healhp_interval;
if (sd->status.hp + bonus <= sd->status.max_hp)
sd->status.hp += bonus;
else
@@ -4698,12 +4696,12 @@ int pc_natural_heal_sp(dumb_ptr<map_session_data> sd)
else
sd->inchealsptick = interval_t::zero();
- if (sd->sp_sub >= static_cast<interval_t>(battle_config.natural_healsp_interval))
+ if (sd->sp_sub >= battle_config.natural_healsp_interval)
{
bonus = sd->nhealsp;
- while (sd->sp_sub >= static_cast<interval_t>(battle_config.natural_healsp_interval))
+ while (sd->sp_sub >= battle_config.natural_healsp_interval)
{
- sd->sp_sub -= static_cast<interval_t>(battle_config.natural_healsp_interval);
+ sd->sp_sub -= battle_config.natural_healsp_interval;
if (sd->status.sp + bonus <= sd->status.max_sp)
sd->status.sp += bonus;
else
@@ -4839,8 +4837,6 @@ void pc_setsavepoint(dumb_ptr<map_session_data> sd, MapName mapname, int x, int
*------------------------------------------
*/
static
-int last_save_fd, save_flag;
-static
void pc_autosave_sub(dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
@@ -4867,7 +4863,7 @@ void pc_autosave(TimerData *, tick_t)
if (save_flag == 0)
last_save_fd = -1;
- interval_t interval = autosave_time / (clif_countusers() + 1);
+ interval_t interval = map_conf.autosave_time / (clif_countusers() + 1);
if (interval <= interval_t::zero())
interval = 1_ms;
Timer(gettick() + interval,
@@ -4920,7 +4916,7 @@ void do_init_pc(void)
pc_natural_heal,
NATURAL_HEAL_INTERVAL
).detach();
- Timer(gettick() + autosave_time,
+ Timer(gettick() + map_conf.autosave_time,
pc_autosave
).detach();
}
@@ -4972,4 +4968,5 @@ int pc_logout(dumb_ptr<map_session_data> sd) // [fate] Player logs out
MAP_LOG_STATS(sd, "LOGOUT"_fmt);
return 0;
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/pc.hpp b/src/map/pc.hpp
index c889e44..ba0a46f 100644
--- a/src/map/pc.hpp
+++ b/src/map/pc.hpp
@@ -32,6 +32,8 @@
namespace tmwa
{
+namespace map
+{
inline
void pc_setsit(dumb_ptr<map_session_data> sd)
{
@@ -175,4 +177,5 @@ int pc_logout(dumb_ptr<map_session_data> sd); // [fate] Player logs out
void pc_show_motd(dumb_ptr<map_session_data> sd);
void do_init_pc(void);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/pc.t.hpp b/src/map/pc.t.hpp
index 427e8c3..c9235fa 100644
--- a/src/map/pc.t.hpp
+++ b/src/map/pc.t.hpp
@@ -28,6 +28,8 @@
namespace tmwa
{
+namespace map
+{
enum class PC_GAINEXP_REASON
{
KILLING = 0,
@@ -54,4 +56,5 @@ enum class CalcStatus
NOW,
LATER,
};
+} // namespace map
} // namespace tmwa
diff --git a/src/map/script-buffer.hpp b/src/map/script-buffer.hpp
index def23e2..e720044 100644
--- a/src/map/script-buffer.hpp
+++ b/src/map/script-buffer.hpp
@@ -27,16 +27,19 @@
namespace tmwa
{
+namespace map
+{
class ScriptBuffer;
+} // namespace map
} // namespace tmwa
namespace std
{
template<>
-struct default_delete<const tmwa::ScriptBuffer>
+struct default_delete<const tmwa::map::ScriptBuffer>
{
default_delete() {}
- default_delete(default_delete<tmwa::ScriptBuffer>) {}
- void operator()(const tmwa::ScriptBuffer *sd);
+ default_delete(default_delete<tmwa::map::ScriptBuffer>) {}
+ void operator()(const tmwa::map::ScriptBuffer *sd);
};
} // namespace std
diff --git a/src/map/script-call-internal.hpp b/src/map/script-call-internal.hpp
index e10a859..983b361 100644
--- a/src/map/script-call-internal.hpp
+++ b/src/map/script-call-internal.hpp
@@ -30,6 +30,8 @@
namespace tmwa
{
+namespace map
+{
enum class VariableCode : uint8_t
{
PARAM,
@@ -92,6 +94,7 @@ void push_str(struct script_stack *stack, RString str);
void push_copy(struct script_stack *stack, int pos_);
void pop_stack(struct script_stack *stack, int start, int end);
+} // namespace map
} // namespace tmwa
#include "script-call-internal.tcc"
diff --git a/src/map/script-call-internal.tcc b/src/map/script-call-internal.tcc
index d77d491..e10b69c 100644
--- a/src/map/script-call-internal.tcc
+++ b/src/map/script-call-internal.tcc
@@ -24,6 +24,8 @@
namespace tmwa
{
+namespace map
+{
template<class D>
bool first_type_is_any()
{
@@ -73,4 +75,5 @@ void push_str(struct script_stack *stack, RString str)
script_data nsd = T{.str= str};
stack->stack_datav.push_back(nsd);
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp
index 5ac45e5..b66af74 100644
--- a/src/map/script-call.cpp
+++ b/src/map/script-call.cpp
@@ -29,6 +29,8 @@
#include "../mmo/cxxstdio_enums.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
+#include "globals.hpp"
#include "map.hpp"
#include "npc.hpp"
#include "pc.hpp"
@@ -42,6 +44,8 @@
namespace tmwa
{
+namespace map
+{
constexpr bool DEBUG_RUN = false;
static
@@ -918,4 +922,5 @@ ZString get_script_var_s(dumb_ptr<map_session_data> sd, VarName var, int e)
PRINTF("Warning: you lied about the type and I can't fix it!"_fmt);
return ZString();
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/script-call.hpp b/src/map/script-call.hpp
index 0819ddd..d494326 100644
--- a/src/map/script-call.hpp
+++ b/src/map/script-call.hpp
@@ -31,6 +31,8 @@
namespace tmwa
{
+namespace map
+{
enum class ByteCode : uint8_t;
// implemented in script-parse.cpp because reasons
@@ -61,4 +63,5 @@ void set_script_var_s(dumb_ptr<map_session_data> sd, VarName var, int e, XString
int get_script_var_i(dumb_ptr<map_session_data> sd, VarName var, int e);
ZString get_script_var_s(dumb_ptr<map_session_data> sd, VarName var, int e);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/script-call.t.hpp b/src/map/script-call.t.hpp
index 04a6a80..5ef7de6 100644
--- a/src/map/script-call.t.hpp
+++ b/src/map/script-call.t.hpp
@@ -27,6 +27,8 @@
namespace tmwa
{
+namespace map
+{
struct argrec_t
{
ZString name;
@@ -42,4 +44,5 @@ struct argrec_t
argrec_t(ZString n, int i) : name(n), v(i) {}
argrec_t(ZString n, ZString z) : name(n), v(z) {}
};
+} // namespace map
} // namespace tmwa
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 12f8679..b9b581f 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -41,8 +41,10 @@
#include "atcommand.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "chrif.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "intif.hpp"
#include "itemdb.hpp"
#include "magic-interpreter-base.hpp"
@@ -62,6 +64,8 @@
namespace tmwa
{
+namespace map
+{
static
Array<LString, 11> pos_str //=
{{
@@ -2376,7 +2380,7 @@ void builtin_getunactivatedpoolskilllist(ScriptState *st)
if (!sd)
return;
- for (i = 0; i < skill_pool_skills_size; i++)
+ for (i = 0; i < skill_pool_skills.size(); i++)
{
SkillID skill_id = skill_pool_skills[i];
@@ -3093,4 +3097,5 @@ BuiltinFunction builtin_functions[] =
BUILTIN(mapexit, ""_s, '\0'),
{nullptr, ""_s, ""_s, '\0'},
};
+} // namespace map
} // namespace tmwa
diff --git a/src/map/script-fun.hpp b/src/map/script-fun.hpp
index e9f64f9..81d68fe 100644
--- a/src/map/script-fun.hpp
+++ b/src/map/script-fun.hpp
@@ -26,6 +26,8 @@
namespace tmwa
{
+namespace map
+{
struct BuiltinFunction
{
void (*func)(ScriptState *);
@@ -35,4 +37,5 @@ struct BuiltinFunction
};
extern BuiltinFunction builtin_functions[];
+} // namespace map
} // namespace tmwa
diff --git a/src/map/script-parse-internal.hpp b/src/map/script-parse-internal.hpp
index 89a35fd..ddaeef0 100644
--- a/src/map/script-parse-internal.hpp
+++ b/src/map/script-parse-internal.hpp
@@ -28,6 +28,8 @@
namespace tmwa
{
+namespace map
+{
enum class StringCode : uint8_t
{
NOP, POS, INT, PARAM, FUNC,
@@ -59,11 +61,7 @@ struct str_data_t
int val;
};
-extern
-Map<RString, str_data_t> str_datam;
-extern
-InternPool variable_names;
-
Option<Borrowed<str_data_t>> search_strp(XString p);
Borrowed<str_data_t> add_strp(XString p);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/script-parse.cpp b/src/map/script-parse.cpp
index 6b41225..fb306c5 100644
--- a/src/map/script-parse.cpp
+++ b/src/map/script-parse.cpp
@@ -36,6 +36,7 @@
#include "../ast/script.hpp"
+#include "globals.hpp"
#include "map.t.hpp"
#include "script-buffer.hpp"
#include "script-call.hpp"
@@ -46,6 +47,8 @@
namespace tmwa
{
+namespace map
+{
constexpr bool DEBUG_DISP = false;
class ScriptBuffer
@@ -77,15 +80,18 @@ public:
return ZString(strings::really_construct_from_a_pointer, reinterpret_cast<const char *>(&script_buf[i]), nullptr);
}
};
+} // namespace map
} // namespace tmwa
-void std::default_delete<const tmwa::ScriptBuffer>::operator()(const tmwa::ScriptBuffer *sd)
+void std::default_delete<const tmwa::map::ScriptBuffer>::operator()(const tmwa::map::ScriptBuffer *sd)
{
really_delete1 sd;
}
namespace tmwa
{
+namespace map
+{
// implemented for script-call.hpp because reasons
ByteCode ScriptPointer::peek() const { return (*TRY_UNWRAP(code, abort()))[pos]; }
ByteCode ScriptPointer::pop() { return (*TRY_UNWRAP(code, abort()))[pos++]; }
@@ -97,15 +103,6 @@ ZString ScriptPointer::pops()
return rv;
}
-Map<RString, str_data_t> str_datam;
-static
-str_data_t LABEL_NEXTLINE_;
-
-Map<ScriptLabel, int> scriptlabel_db;
-static
-std::set<ScriptLabel> probable_labels;
-UPMap<RString, const ScriptBuffer> userfunc_db;
-
static
struct ScriptConfigParse
{
@@ -119,12 +116,6 @@ struct ScriptConfigParse
int warn_cmd_mismatch_paramnum = 1;
} script_config;
-static
-int parse_cmd_if = 0;
-static
-Option<Borrowed<str_data_t>> parse_cmdp = None;
-
-InternPool variable_names;
Option<Borrowed<str_data_t>> search_strp(XString p)
{
@@ -307,14 +298,6 @@ ZString::iterator skip_word(ZString::iterator p)
return p;
}
-// TODO: replace this whole mess with some sort of input stream that works
-// a line at a time.
-static
-ZString startptr;
-static
-int startline;
-
-int script_errors = 0;
/*==========================================
* エラーメッセージ出力
*------------------------------------------
@@ -864,4 +847,5 @@ void ScriptBuffer::parse_script(ZString src, int line, bool implicit_end)
}
PRINTF("\n"_fmt);
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/script-parse.hpp b/src/map/script-parse.hpp
index 360711e..e08c470 100644
--- a/src/map/script-parse.hpp
+++ b/src/map/script-parse.hpp
@@ -29,12 +29,8 @@
namespace tmwa
{
+namespace map
+{
std::unique_ptr<const ScriptBuffer> compile_script(RString debug_name, const ast::script::ScriptBody& body, bool implicit_end);
-
-extern
-Map<ScriptLabel, int> scriptlabel_db;
-extern
-UPMap<RString, const ScriptBuffer> userfunc_db;
-
-extern int script_errors;
+} // namespace map
} // namespace tmwa
diff --git a/src/map/script-parse.py b/src/map/script-parse.py
index de27d57..0309f54 100644
--- a/src/map/script-parse.py
+++ b/src/map/script-parse.py
@@ -1,6 +1,6 @@
class ScriptBuffer(object):
__slots__ = ('_value')
- name = 'tmwa::ScriptBuffer'
+ name = 'tmwa::map::ScriptBuffer'
enabled = True
def __init__(self, value):
@@ -55,12 +55,12 @@ class ScriptBuffer(object):
global rstring_disable_children
rstring_disable_children = True
try:
- rv = 'VARIABLE %s' % gdb.parse_and_eval('tmwa::variable_names.names._M_impl._M_start[{ai}]'.format(ai=ai))
+ rv = 'VARIABLE %s' % gdb.parse_and_eval('tmwa::map::variable_names.names._M_impl._M_start[{ai}]'.format(ai=ai))
finally:
rstring_disable_children = False
return rv
elif cs == 'FUNC_REF':
- return 'FUNC_REF %s' % gdb.parse_and_eval('tmwa::builtin_functions[{ai}].name'.format(ai=ai))
+ return 'FUNC_REF %s' % gdb.parse_and_eval('tmwa::map::builtin_functions[{ai}].name'.format(ai=ai))
elif cs == 'PARAM':
# https://sourceware.org/bugzilla/show_bug.cgi?id=17568
try:
@@ -524,13 +524,13 @@ class ScriptBuffer(object):
using tmwa::operator "" _s;
static
- const tmwa::ScriptBuffer& test_script_buffer(tmwa::LString source)
+ const tmwa::map::ScriptBuffer& test_script_buffer(tmwa::LString source)
{
- auto p = tmwa::add_strp("TEST_FAKE_PARAM_BASELEVEL"_s);
- p->type = tmwa::StringCode::PARAM;
+ auto p = tmwa::map::add_strp("TEST_FAKE_PARAM_BASELEVEL"_s);
+ p->type = tmwa::map::StringCode::PARAM;
p->val = static_cast<uint16_t>(tmwa::SP::BASELEVEL);
- p = tmwa::add_strp("TEST_FAKE_CONSTANT"_s);
- p->type = tmwa::StringCode::INT;
+ p = tmwa::map::add_strp("TEST_FAKE_CONSTANT"_s);
+ p->type = tmwa::map::StringCode::INT;
p->val = 42;
tmwa::io::LineCharReader lr(tmwa::io::from_string, "<script debug print test>"_s, source);
@@ -539,7 +539,7 @@ class ScriptBuffer(object):
opt.implicit_end = true;
auto code_res = tmwa::ast::script::parse_script_body(lr, opt);
auto code = TRY_UNWRAP(code_res.get_success(), abort());
- auto ups = tmwa::compile_script("script debug print test"_s, code, opt.implicit_end);
+ auto ups = tmwa::map::compile_script("script debug print test"_s, code, opt.implicit_end);
assert(ups);
return *ups.release();
}
diff --git a/src/map/script-persist.hpp b/src/map/script-persist.hpp
index 044c567..45c2761 100644
--- a/src/map/script-persist.hpp
+++ b/src/map/script-persist.hpp
@@ -28,11 +28,15 @@
#include "../sexpr/variant.hpp"
+#include "../mmo/clif.t.hpp"
+
#include "script-buffer.hpp"
namespace tmwa
{
+namespace map
+{
class SIR
{
uint32_t impl;
@@ -120,4 +124,5 @@ struct script_data : ScriptDataVariantBase
script_data(ScriptDataRetInfo v) : ScriptDataVariantBase(std::move(v)) {}
script_data(ScriptDataFuncRef v) : ScriptDataVariantBase(std::move(v)) {}
};
+} // namespace map
} // namespace tmwa
diff --git a/src/map/script-persist.py b/src/map/script-persist.py
index a970cc5..3181344 100644
--- a/src/map/script-persist.py
+++ b/src/map/script-persist.py
@@ -8,30 +8,30 @@ class script_data(object):
#include "../map/script-parse-internal.hpp"
static
- tmwa::Borrowed<const tmwa::ScriptBuffer> fake_script()
+ tmwa::Borrowed<const tmwa::map::ScriptBuffer> fake_script()
{
static
- const std::vector<tmwa::ByteCode> buffer;
- return borrow(reinterpret_cast<const tmwa::ScriptBuffer&>(buffer));
+ const std::vector<tmwa::map::ByteCode> buffer;
+ return tmwa::borrow(reinterpret_cast<const tmwa::map::ScriptBuffer&>(buffer));
}
'''
tests = [
- ('tmwa::script_data(tmwa::ScriptDataPos{42})',
- '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataPos) = {numi = 42}}, <No data fields>}'),
- ('tmwa::script_data(tmwa::ScriptDataInt{123})',
- '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataInt) = {numi = 123}}, <No data fields>}'),
- ('tmwa::script_data(tmwa::ScriptDataParam{tmwa::SIR()})',
- '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataParam) = {reg = {impl = 0}}}, <No data fields>}'),
- ('tmwa::script_data(tmwa::ScriptDataStr{"Hello"_s})',
- '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataStr) = {str = "Hello"}}, <No data fields>}'),
- ('tmwa::script_data(tmwa::ScriptDataArg{0})',
- '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataArg) = {numi = 0}}, <No data fields>}'),
- ('tmwa::script_data(tmwa::ScriptDataVariable{tmwa::SIR()})',
- '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataVariable) = {reg = {impl = 0}}}, <No data fields>}'),
- ('tmwa::script_data(tmwa::ScriptDataRetInfo{fake_script()})',
- '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataRetInfo) = {script = <fake_script()::buffer>}}, <No data fields>}'),
- ('tmwa::script_data(tmwa::ScriptDataFuncRef{404})',
- '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataFuncRef) = {numi = 404}}, <No data fields>}'),
+ ('tmwa::map::script_data(tmwa::map::ScriptDataPos{42})',
+ '{<tmwa::sexpr::Variant<tmwa::map::ScriptDataPos, tmwa::map::ScriptDataInt, tmwa::map::ScriptDataParam, tmwa::map::ScriptDataStr, tmwa::map::ScriptDataArg, tmwa::map::ScriptDataVariable, tmwa::map::ScriptDataRetInfo, tmwa::map::ScriptDataFuncRef>> = {(tmwa::map::ScriptDataPos) = {numi = 42}}, <No data fields>}'),
+ ('tmwa::map::script_data(tmwa::map::ScriptDataInt{123})',
+ '{<tmwa::sexpr::Variant<tmwa::map::ScriptDataPos, tmwa::map::ScriptDataInt, tmwa::map::ScriptDataParam, tmwa::map::ScriptDataStr, tmwa::map::ScriptDataArg, tmwa::map::ScriptDataVariable, tmwa::map::ScriptDataRetInfo, tmwa::map::ScriptDataFuncRef>> = {(tmwa::map::ScriptDataInt) = {numi = 123}}, <No data fields>}'),
+ ('tmwa::map::script_data(tmwa::map::ScriptDataParam{tmwa::map::SIR()})',
+ '{<tmwa::sexpr::Variant<tmwa::map::ScriptDataPos, tmwa::map::ScriptDataInt, tmwa::map::ScriptDataParam, tmwa::map::ScriptDataStr, tmwa::map::ScriptDataArg, tmwa::map::ScriptDataVariable, tmwa::map::ScriptDataRetInfo, tmwa::map::ScriptDataFuncRef>> = {(tmwa::map::ScriptDataParam) = {reg = {impl = 0}}}, <No data fields>}'),
+ ('tmwa::map::script_data(tmwa::map::ScriptDataStr{"Hello"_s})',
+ '{<tmwa::sexpr::Variant<tmwa::map::ScriptDataPos, tmwa::map::ScriptDataInt, tmwa::map::ScriptDataParam, tmwa::map::ScriptDataStr, tmwa::map::ScriptDataArg, tmwa::map::ScriptDataVariable, tmwa::map::ScriptDataRetInfo, tmwa::map::ScriptDataFuncRef>> = {(tmwa::map::ScriptDataStr) = {str = "Hello"}}, <No data fields>}'),
+ ('tmwa::map::script_data(tmwa::map::ScriptDataArg{0})',
+ '{<tmwa::sexpr::Variant<tmwa::map::ScriptDataPos, tmwa::map::ScriptDataInt, tmwa::map::ScriptDataParam, tmwa::map::ScriptDataStr, tmwa::map::ScriptDataArg, tmwa::map::ScriptDataVariable, tmwa::map::ScriptDataRetInfo, tmwa::map::ScriptDataFuncRef>> = {(tmwa::map::ScriptDataArg) = {numi = 0}}, <No data fields>}'),
+ ('tmwa::map::script_data(tmwa::map::ScriptDataVariable{tmwa::map::SIR()})',
+ '{<tmwa::sexpr::Variant<tmwa::map::ScriptDataPos, tmwa::map::ScriptDataInt, tmwa::map::ScriptDataParam, tmwa::map::ScriptDataStr, tmwa::map::ScriptDataArg, tmwa::map::ScriptDataVariable, tmwa::map::ScriptDataRetInfo, tmwa::map::ScriptDataFuncRef>> = {(tmwa::map::ScriptDataVariable) = {reg = {impl = 0}}}, <No data fields>}'),
+ ('tmwa::map::script_data(tmwa::map::ScriptDataRetInfo{fake_script()})',
+ '{<tmwa::sexpr::Variant<tmwa::map::ScriptDataPos, tmwa::map::ScriptDataInt, tmwa::map::ScriptDataParam, tmwa::map::ScriptDataStr, tmwa::map::ScriptDataArg, tmwa::map::ScriptDataVariable, tmwa::map::ScriptDataRetInfo, tmwa::map::ScriptDataFuncRef>> = {(tmwa::map::ScriptDataRetInfo) = {script = <fake_script()::buffer>}}, <No data fields>}'),
+ ('tmwa::map::script_data(tmwa::map::ScriptDataFuncRef{404})',
+ '{<tmwa::sexpr::Variant<tmwa::map::ScriptDataPos, tmwa::map::ScriptDataInt, tmwa::map::ScriptDataParam, tmwa::map::ScriptDataStr, tmwa::map::ScriptDataArg, tmwa::map::ScriptDataVariable, tmwa::map::ScriptDataRetInfo, tmwa::map::ScriptDataFuncRef>> = {(tmwa::map::ScriptDataFuncRef) = {numi = 404}}, <No data fields>}'),
]
diff --git a/src/map/script-startup-internal.hpp b/src/map/script-startup-internal.hpp
index 0b2b0e1..91ce09b 100644
--- a/src/map/script-startup-internal.hpp
+++ b/src/map/script-startup-internal.hpp
@@ -28,13 +28,9 @@
namespace tmwa
{
-extern
-DMap<SIR, int> mapreg_db;
-extern
-Map<SIR, RString> mapregstr_db;
-extern
-int mapreg_dirty;
-
+namespace map
+{
void mapreg_setreg(SIR reg, int val);
void mapreg_setregstr(SIR reg, XString str);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/script-startup.cpp b/src/map/script-startup.cpp
index 7c77a27..ad809db 100644
--- a/src/map/script-startup.cpp
+++ b/src/map/script-startup.cpp
@@ -34,7 +34,9 @@
#include "../net/timer.hpp"
+#include "globals.hpp"
#include "map.hpp"
+#include "map_conf.hpp"
#include "script-parse-internal.hpp"
#include "script-persist.hpp"
@@ -43,10 +45,8 @@
namespace tmwa
{
-DMap<SIR, int> mapreg_db;
-Map<SIR, RString> mapregstr_db;
-int mapreg_dirty = -1;
-AString mapreg_txt = "save/mapreg.txt"_s;
+namespace map
+{
constexpr std::chrono::milliseconds MAPREG_AUTOSAVE_INTERVAL = 10_s;
bool read_constdb(ZString filename)
@@ -140,7 +140,7 @@ void mapreg_setregstr(SIR reg, XString str)
static
void script_load_mapreg(void)
{
- io::ReadFile in(mapreg_txt);
+ io::ReadFile in(map_conf.mapreg_txt);
if (!in.is_open())
return;
@@ -176,7 +176,7 @@ void script_load_mapreg(void)
else
{
borken:
- PRINTF("%s: %s broken data !\n"_fmt, mapreg_txt, AString(buf1));
+ PRINTF("%s: %s broken data !\n"_fmt, map_conf.mapreg_txt, AString(buf1));
continue;
}
}
@@ -218,7 +218,7 @@ void script_save_mapreg_strsub(SIR key, ZString data, io::WriteFile& fp)
static
void script_save_mapreg(void)
{
- io::WriteLock fp(mapreg_txt);
+ io::WriteLock fp(map_conf.mapreg_txt);
if (!fp.is_open())
return;
for (auto& pair : mapreg_db)
@@ -261,4 +261,5 @@ void do_init_script(void)
MAPREG_AUTOSAVE_INTERVAL
).detach();
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/script-startup.hpp b/src/map/script-startup.hpp
index 3894676..1691c94 100644
--- a/src/map/script-startup.hpp
+++ b/src/map/script-startup.hpp
@@ -24,10 +24,11 @@
namespace tmwa
{
+namespace map
+{
void do_init_script(void);
void do_final_script(void);
-extern AString mapreg_txt;
-
bool read_constdb(ZString filename);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/skill-pools.cpp b/src/map/skill-pools.cpp
index 8ed03b8..dfc70b0 100644
--- a/src/map/skill-pools.cpp
+++ b/src/map/skill-pools.cpp
@@ -25,6 +25,8 @@
#include "../mmo/cxxstdio_enums.hpp"
#include "battle.hpp"
+#include "consts.hpp"
+#include "globals.hpp"
#include "pc.hpp"
#include "../poison.hpp"
@@ -32,26 +34,18 @@
namespace tmwa
{
-Array<SkillID, MAX_POOL_SKILLS> skill_pool_skills;
-int skill_pool_skills_size = 0;
-
+namespace map
+{
void skill_pool_register(SkillID id)
{
- if (skill_pool_skills_size + 1 >= MAX_POOL_SKILLS)
- {
- FPRINTF(stderr,
- "Too many pool skills! Increase MAX_POOL_SKILLS and recompile."_fmt);
- return;
- }
-
- skill_pool_skills[skill_pool_skills_size++] = id;
+ skill_pool_skills.push_back(id);
}
int skill_pool(dumb_ptr<map_session_data> sd, SkillID *skills)
{
int i, count = 0;
- for (i = 0; count < MAX_SKILL_POOL && i < skill_pool_skills_size; i++)
+ for (i = 0; count < MAX_SKILL_POOL && i < skill_pool_skills.size(); i++)
{
SkillID skill_id = skill_pool_skills[i];
if (bool(sd->status.skill[skill_id].flags & SkillFlags::POOL_ACTIVATED))
@@ -148,4 +142,5 @@ int skill_power_bl(dumb_ptr<block_list> bl, SkillID skill)
else
return 0;
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/skill-pools.hpp b/src/map/skill-pools.hpp
index c8890e8..0f75e8e 100644
--- a/src/map/skill-pools.hpp
+++ b/src/map/skill-pools.hpp
@@ -23,4 +23,7 @@
namespace tmwa
{
+namespace map
+{
+} // namespace map
} // namespace tmwa
diff --git a/src/map/skill.cpp b/src/map/skill.cpp
index 4d70770..8a397a3 100644
--- a/src/map/skill.cpp
+++ b/src/map/skill.cpp
@@ -48,7 +48,9 @@
#include "../mmo/extract_enums.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "magic-stmt.hpp"
#include "mob.hpp"
#include "pc.hpp"
@@ -58,7 +60,10 @@
namespace tmwa
{
-struct skill_name_db skill_names[] =
+namespace map
+{
+static
+skill_name_db skill_names[] =
{
{SkillID::AC_OWL, "OWL"_s, "Owl's_Eye"_s},
@@ -90,9 +95,6 @@ struct skill_name_db skill_names[] =
{SkillID::ZERO, ""_s, ""_s}
};
-earray<skill_db_, SkillID, SkillID::MAX_SKILL_DB> skill_db;
-
-
static
int skill_attack(BF attack_type, dumb_ptr<block_list> src,
dumb_ptr<block_list> dsrc, dumb_ptr<block_list> bl,
@@ -378,17 +380,6 @@ void skill_area_sub(dumb_ptr<block_list> bl,
}
-/* 範囲スキル使用処理小分けここまで
- * -------------------------------------------------------------------------
- */
-
-// these variables are set in the 'else' branches,
-// and used in the (recursive) 'if' branch
-// TODO kill it, kill it with fire.
-static BlockId skill_area_temp_id;
-static int skill_area_temp_hp;
-
-
/*==========================================
* スキル使用(詠唱完了、ID指定攻撃系)
* (スパゲッティに向けて1歩前進!(ダメポ))
@@ -1289,4 +1280,5 @@ skill_name_db& skill_lookup_by_name(XString name)
return ner;
return skill_names[num_names - 1];
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/skill.hpp b/src/map/skill.hpp
index 4e6fff0..23881d4 100644
--- a/src/map/skill.hpp
+++ b/src/map/skill.hpp
@@ -36,6 +36,8 @@
namespace tmwa
{
+namespace map
+{
constexpr int MAX_SKILL_PRODUCE_DB = 150;
constexpr int MAX_SKILL_ARROW_DB = 150;
constexpr int MAX_SKILL_ABRA_DB = 350;
@@ -59,8 +61,6 @@ struct skill_db_
int weapon;
Array<int, MAX_SKILL_LEVEL> castnodex;
};
-extern
-earray<skill_db_, SkillID, SkillID::MAX_SKILL_DB> skill_db;
struct skill_name_db
{
@@ -74,9 +74,6 @@ struct skill_name_db
{}
};
-// used only by @skillid for iteration - should be depublicized
-extern struct skill_name_db skill_names[];
-
skill_name_db& skill_lookup_by_id(SkillID id);
skill_name_db& skill_lookup_by_name(XString name);
@@ -134,11 +131,6 @@ void skill_reload(void);
// Max. # of active entries in the skill pool
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 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.
int skill_pool(dumb_ptr<map_session_data> sd, SkillID *skills);
@@ -165,4 +157,5 @@ int skill_power_bl(dumb_ptr<block_list> bl, SkillID skill);
// [Fate] Remember that a certain skill ID belongs to a pool skill
void skill_pool_register(SkillID id);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/storage.cpp b/src/map/storage.cpp
index 1a98d5b..1327146 100644
--- a/src/map/storage.cpp
+++ b/src/map/storage.cpp
@@ -29,6 +29,7 @@
#include "chrif.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "intif.hpp"
#include "itemdb.hpp"
#include "map.hpp"
@@ -39,9 +40,8 @@
namespace tmwa
{
-static
-Map<AccountId, Storage> storage_db;
-
+namespace map
+{
void do_final_storage(void)
{
storage_db.clear();
@@ -311,4 +311,5 @@ int storage_storage_saved(AccountId account_id)
}
return 0;
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/storage.hpp b/src/map/storage.hpp
index 038df7d..5f118c3 100644
--- a/src/map/storage.hpp
+++ b/src/map/storage.hpp
@@ -29,6 +29,8 @@
namespace tmwa
{
+namespace map
+{
int storage_storageopen(dumb_ptr<map_session_data> sd);
int storage_storageadd(dumb_ptr<map_session_data> sd, IOff0 index, int amount);
int storage_storageget(dumb_ptr<map_session_data> sd, SOff0 index, int amount);
@@ -39,4 +41,5 @@ Option<Borrowed<Storage>> account2storage2(AccountId account_id);
int storage_storage_quit(dumb_ptr<map_session_data> sd);
int storage_storage_save(AccountId account_id, int final);
int storage_storage_saved(AccountId account_id);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/tmw.cpp b/src/map/tmw.cpp
index 4f29fab..3f6bb3a 100644
--- a/src/map/tmw.cpp
+++ b/src/map/tmw.cpp
@@ -28,12 +28,16 @@
#include "../io/cxxstdio.hpp"
+#include "../net/timer.hpp"
+
#include "../mmo/human_time_diff.hpp"
#include "atcommand.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "chrif.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "intif.hpp"
#include "map.hpp"
#include "pc.hpp"
@@ -43,8 +47,10 @@
namespace tmwa
{
+namespace map
+{
static
-void tmw_AutoBan(dumb_ptr<map_session_data> sd, ZString reason, int length);
+void tmw_AutoBan(dumb_ptr<map_session_data> sd, ZString reason, std::chrono::hours length);
static
bool tmw_CheckChatLameness(dumb_ptr<map_session_data> sd, XString message);
@@ -52,21 +58,21 @@ bool tmw_CheckChatLameness(dumb_ptr<map_session_data> sd, XString message);
int tmw_CheckChatSpam(dumb_ptr<map_session_data> sd, XString message)
{
nullpo_retr(1, sd);
- TimeT now = TimeT::now();
+ tick_t now = gettick();
if (pc_isGM(sd))
return 0;
if (now > sd->chat_reset_due)
{
- sd->chat_reset_due = static_cast<time_t>(now) + battle_config.chat_spam_threshold;
+ sd->chat_reset_due = now + battle_config.chat_spam_threshold;
sd->chat_lines_in = 0;
}
if (now > sd->chat_repeat_reset_due)
{
sd->chat_repeat_reset_due =
- static_cast<time_t>(now) + (battle_config.chat_spam_threshold * 60);
+ now + (battle_config.chat_spam_threshold * 60);
sd->chat_total_repeats = 0;
}
@@ -99,7 +105,7 @@ int tmw_CheckChatSpam(dumb_ptr<map_session_data> sd, XString message)
return 1;
}
- if (battle_config.chat_spam_ban &&
+ if (battle_config.chat_spam_ban != std::chrono::hours::zero() &&
(sd->chat_lines_in >= battle_config.chat_spam_warn
|| sd->chat_total_repeats >= battle_config.chat_spam_warn))
{
@@ -110,9 +116,9 @@ int tmw_CheckChatSpam(dumb_ptr<map_session_data> sd, XString message)
return 0;
}
-void tmw_AutoBan(dumb_ptr<map_session_data> sd, ZString reason, int length)
+void tmw_AutoBan(dumb_ptr<map_session_data> sd, ZString reason, std::chrono::hours length)
{
- if (length == 0 || sd->auto_ban_info.in_progress)
+ if (length == std::chrono::hours::zero() || sd->auto_ban_info.in_progress)
return;
sd->auto_ban_info.in_progress = 1;
@@ -123,7 +129,7 @@ void tmw_AutoBan(dumb_ptr<map_session_data> sd, ZString reason, int length)
tmw_GmHackMsg(hack_msg);
AString fake_command = STRPRINTF("@autoban %s %dh (%s spam)"_fmt,
- sd->status_key.name, length, reason);
+ sd->status_key.name, static_cast<uint16_t>(length.count()), reason);
log_atcommand(sd, fake_command);
AString anotherbuf = STRPRINTF("You have been banned for %s spamming. Please do not spam."_fmt,
@@ -132,7 +138,7 @@ void tmw_AutoBan(dumb_ptr<map_session_data> sd, ZString reason, int length)
clif_displaymessage(sd->sess, anotherbuf);
/* type: 2 - ban(year, month, day, hour, minute, second) */
HumanTimeDiff ban_len {};
- ban_len.hour = length;
+ ban_len.hour = length.count();
chrif_char_ask_name(AccountId(), sd->status_key.name, 2, ban_len);
clif_setwaitclose(sd->sess);
}
@@ -162,7 +168,8 @@ bool tmw_CheckChatLameness(dumb_ptr<map_session_data>, XString message)
void tmw_GmHackMsg(ZString line)
{
intif_wis_message_to_gm(WISP_SERVER_NAME,
- GmLevel::from(static_cast<uint32_t>(battle_config.hack_info_GM_level)),
+ battle_config.hack_info_GM_level,
line);
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/tmw.hpp b/src/map/tmw.hpp
index 7f0a57e..bc0043c 100644
--- a/src/map/tmw.hpp
+++ b/src/map/tmw.hpp
@@ -24,6 +24,9 @@
namespace tmwa
{
+namespace map
+{
int tmw_CheckChatSpam(dumb_ptr<map_session_data> sd, XString message);
void tmw_GmHackMsg(ZString line);
+} // namespace map
} // namespace tmwa
diff --git a/src/map/trade.cpp b/src/map/trade.cpp
index bc6e98f..c03609c 100644
--- a/src/map/trade.cpp
+++ b/src/map/trade.cpp
@@ -25,7 +25,9 @@
#include "../io/cxxstdio.hpp"
#include "battle.hpp"
+#include "battle_conf.hpp"
#include "clif.hpp"
+#include "globals.hpp"
#include "itemdb.hpp"
#include "map.hpp"
#include "npc.hpp"
@@ -37,6 +39,8 @@
namespace tmwa
{
+namespace map
+{
/*==========================================
* 取引要請を相手に送る
*------------------------------------------
@@ -473,4 +477,5 @@ void trade_verifyzeny(dumb_ptr<map_session_data> sd)
}
}
}
+} // namespace map
} // namespace tmwa
diff --git a/src/map/trade.hpp b/src/map/trade.hpp
index 86bfc96..569524b 100644
--- a/src/map/trade.hpp
+++ b/src/map/trade.hpp
@@ -27,6 +27,8 @@
namespace tmwa
{
+namespace map
+{
void trade_traderequest(dumb_ptr<map_session_data> sd, BlockId target_id);
void trade_tradeack(dumb_ptr<map_session_data> sd, int type);
void trade_tradeadditem(dumb_ptr<map_session_data> sd, IOff2 index, int amount);
@@ -34,4 +36,5 @@ void trade_tradeok(dumb_ptr<map_session_data> sd);
void trade_tradecancel(dumb_ptr<map_session_data> sd);
void trade_tradecommit(dumb_ptr<map_session_data> sd);
void trade_verifyzeny(dumb_ptr<map_session_data> sd);
+} // namespace map
} // namespace tmwa