diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/char/char.cpp | 2 | ||||
-rw-r--r-- | src/conf/install.hpp.in (renamed from src/conf/install.hpp) | 7 | ||||
-rw-r--r-- | src/conf/version.hpp.in (renamed from src/conf/version.hpp) | 21 | ||||
-rw-r--r-- | src/main-gdb-head.py | 2 | ||||
-rw-r--r-- | src/map/clif.cpp | 2 | ||||
-rw-r--r-- | src/map/mob.cpp | 173 | ||||
-rw-r--r-- | src/map/npc-parse.cpp | 7 | ||||
-rw-r--r-- | src/map/script-fun.cpp | 241 | ||||
-rw-r--r-- | src/map/script-parse.py | 2 | ||||
-rw-r--r-- | src/mmo/version.cpp | 2 | ||||
-rw-r--r-- | src/shared/lib.cpp | 2 |
11 files changed, 209 insertions, 252 deletions
diff --git a/src/char/char.cpp b/src/char/char.cpp index 7ffdd0f..2194ef2 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -777,8 +777,8 @@ void create_online_files(void) stamp_time(timetemp); // write heading FPRINTF(fp2, "<HTML>\n"_fmt); - FPRINTF(fp2, " <META http-equiv=\"Refresh\" content=\"%d\">\n"_fmt, char_conf.online_refresh_html); // update on client explorer every x seconds FPRINTF(fp2, " <HEAD>\n"_fmt); + FPRINTF(fp2, " <META http-equiv=\"refresh\" content=\"%d\">\n"_fmt, char_conf.online_refresh_html); // update on client explorer every x seconds FPRINTF(fp2, " <TITLE>Online Players on %s</TITLE>\n"_fmt, char_conf.server_name); FPRINTF(fp2, " </HEAD>\n"_fmt); diff --git a/src/conf/install.hpp b/src/conf/install.hpp.in index 42fd125..e63164a 100644 --- a/src/conf/install.hpp +++ b/src/conf/install.hpp.in @@ -20,10 +20,9 @@ // just mention "fwd.hpp" to make formatter happy -#include "conf-raw/str-PACKAGESYSCONFDIR.h" -#include "conf-raw/str-PACKAGELOCALSTATEDIR.h" -#include "conf-raw/str-PACKAGEDATADIR.h" - +#define PACKAGESYSCONFDIR "@SYSCONFDIR@/tmwa"_s +#define PACKAGELOCALSTATEDIR "@LOCALSTATEDIR@/tmwa"_s +#define PACKAGEDATADIR "@PACKAGEDATADIR@"_s namespace tmwa { diff --git a/src/conf/version.hpp b/src/conf/version.hpp.in index df8a8b6..126fae2 100644 --- a/src/conf/version.hpp +++ b/src/conf/version.hpp.in @@ -20,20 +20,19 @@ // just mention "fwd.hpp" to make formatter happy -#include "conf-raw/str-VERSION_FULL.h" -#include "conf-raw/str-VERSION_HASH.h" +#define VERSION_FULL "@VERSION_FULL@"_s +#define VERSION_HASH "@VERSION_HASH@"_s -#include "conf-raw/int-VERSION_MAJOR.h" -#include "conf-raw/int-VERSION_MINOR.h" -#include "conf-raw/int-VERSION_PATCH.h" -#include "conf-raw/int-VERSION_DEVEL.h" +#define VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define VERSION_PATCH @PROJECT_VERSION_PATCH@ +#define VERSION_DEVEL @PROJECT_VERSION_TWEAK@ -#include "conf-raw/str-VENDOR_NAME.h" -#include "conf-raw/int-VENDOR_POINT.h" -#include "conf-raw/str-VENDOR_SOURCE.h" - -#include "conf-raw/str-VERSION_STRING.h" +#define VENDOR_NAME "@VENDOR_NAME@"_s +#define VENDOR_POINT @VENDOR_POINT@ +#define VENDOR_SOURCE "@VENDOR_SOURCE@"_s +#define VERSION_STRING "@VERSION_STRING@"_s namespace tmwa { diff --git a/src/main-gdb-head.py b/src/main-gdb-head.py index a465c97..09e22fe 100644 --- a/src/main-gdb-head.py +++ b/src/main-gdb-head.py @@ -5,7 +5,7 @@ # gdb sticks everything in one scope. # This lets us enumerate what *we* added. -initial_globals = {id(v):v for v in globals().values()} +initial_globals = {id(v):v for v in list(globals().values())} import re diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 4d36f17..1b77be6 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -4020,7 +4020,7 @@ RecvResult clif_parse_GetCharNameRequest(Session *s, dumb_ptr<map_session_data> dumb_ptr<mob_data> md = bl->is_mob(); nullpo_retr(rv, md); - if (md->name != MobName() && md->name != get_mob_db(md->mob_class).name && md->name.size() >= 4) + if (md->name.size() >= 4) fixed_95.char_name = stringish<CharName>(md->name); else fixed_95.char_name = stringish<CharName>(get_mob_db(md->mob_class).name); diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 996e2bb..fc41d19 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -355,24 +355,25 @@ void mob_init(dumb_ptr<mob_data> md) { int i; const Species mob_class = md->mob_class; - const int mutations_nr = get_mob_db(mob_class).mutations_nr; - const int mutation_power = get_mob_db(mob_class).mutation_power; - - md->stats[mob_stat::LV] = get_mob_db(mob_class).lv; - md->stats[mob_stat::MAX_HP] = get_mob_db(mob_class).max_hp; - md->stats[mob_stat::STR] = get_mob_db(mob_class).attrs[ATTR::STR]; - md->stats[mob_stat::AGI] = get_mob_db(mob_class).attrs[ATTR::AGI]; - md->stats[mob_stat::VIT] = get_mob_db(mob_class).attrs[ATTR::VIT]; - md->stats[mob_stat::INT] = get_mob_db(mob_class).attrs[ATTR::INT]; - md->stats[mob_stat::DEX] = get_mob_db(mob_class).attrs[ATTR::DEX]; - 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.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::CRITICAL_DEF] = get_mob_db(mob_class).critical_def; - md->stats[mob_stat::SPEED] = get_mob_db(mob_class).speed.count(); + const mob_db_& mob_info = get_mob_db(mob_class); + const int mutations_nr = mob_info.mutations_nr; + const int mutation_power = mob_info.mutation_power; + + md->stats[mob_stat::LV] = mob_info.lv; + md->stats[mob_stat::MAX_HP] = mob_info.max_hp; + md->stats[mob_stat::STR] = mob_info.attrs[ATTR::STR]; + md->stats[mob_stat::AGI] = mob_info.attrs[ATTR::AGI]; + md->stats[mob_stat::VIT] = mob_info.attrs[ATTR::VIT]; + md->stats[mob_stat::INT] = mob_info.attrs[ATTR::INT]; + md->stats[mob_stat::DEX] = mob_info.attrs[ATTR::DEX]; + md->stats[mob_stat::LUK] = mob_info.attrs[ATTR::LUK]; + md->stats[mob_stat::ATK1] = mob_info.atk1; + md->stats[mob_stat::ATK2] = mob_info.atk2; + md->stats[mob_stat::ADELAY] = mob_info.adelay.count(); + md->stats[mob_stat::DEF] = mob_info.def; + md->stats[mob_stat::MDEF] = mob_info.mdef; + md->stats[mob_stat::CRITICAL_DEF] = mob_info.critical_def; + md->stats[mob_stat::SPEED] = mob_info.speed.count(); md->stats[mob_stat::XP_BONUS] = MOB_XP_BONUS_BASE; for (i = 0; i < mutations_nr; i++) @@ -2596,6 +2597,7 @@ int mob_damage(dumb_ptr<block_list> src, dumb_ptr<mob_data> md, int damage, ); { + const mob_db_& mob_info = get_mob_db(md->mob_class); struct DmgLogParty { PartyPair p; @@ -2660,23 +2662,23 @@ int mob_damage(dumb_ptr<block_list> src, dumb_ptr<mob_data> md, int damage, per = 1; base_exp = - ((get_mob_db(md->mob_class).base_exp * + ((mob_info.base_exp * md->stats[mob_stat::XP_BONUS]) >> MOB_XP_BONUS_SHIFT) * per / 256; if (base_exp < 1) base_exp = 1; - if (sd && md && battle_config.pk_mode == 1 - && (get_mob_db(md->mob_class).lv - sd->status.base_level >= 20)) + if (sd && battle_config.pk_mode == 1 + && (mob_info.lv - sd->status.base_level >= 20)) { base_exp *= 1.15; // pk_mode additional exp if monster >20 levels [Valaris] } if (md->state.special_mob_ai >= 1 && battle_config.alchemist_summon_reward != 1) base_exp = 0; // Added [Valaris] - job_exp = get_mob_db(md->mob_class).job_exp * per / 256; + job_exp = mob_info.job_exp * per / 256; if (job_exp < 1) job_exp = 1; - if (sd && md && battle_config.pk_mode == 1 - && (get_mob_db(md->mob_class).lv - sd->status.base_level >= 20)) + if (sd && battle_config.pk_mode == 1 + && (mob_info.lv - sd->status.base_level >= 20)) { job_exp *= 1.15; // pk_mode additional exp if monster >20 levels [Valaris] } @@ -2730,13 +2732,14 @@ int mob_damage(dumb_ptr<block_list> src, dumb_ptr<mob_data> md, int damage, if (md->state.special_mob_ai >= 1 && battle_config.alchemist_summon_reward != 1) // Added [Valaris] break; // End - if (!get_mob_db(md->mob_class).dropitem[i].nameid) + const auto& drop_info = mob_info.dropitem[i]; + if (!drop_info.nameid) continue; - random_::Fixed<int, 10000> drop_rate = get_mob_db(md->mob_class).dropitem[i].p; - if (battle_config.drops_by_luk > 0 && sd && md) + random_::Fixed<int, 10000> drop_rate = drop_info.p; + if (sd && battle_config.drops_by_luk > 0) drop_rate.num += (sd->status.attrs[ATTR::LUK] * battle_config.drops_by_luk) / 100; // drops affected by luk [Valaris] - if (sd && md && battle_config.pk_mode == 1 - && (get_mob_db(md->mob_class).lv - sd->status.base_level >= 20)) + if (sd && battle_config.pk_mode == 1 + && (mob_info.lv - sd->status.base_level >= 20)) drop_rate.num *= 1.25; // pk_mode increase drops if 20 level difference [Valaris] // server-wide drop rate scaling @@ -2745,7 +2748,7 @@ int mob_damage(dumb_ptr<block_list> src, dumb_ptr<mob_data> md, int damage, continue; struct delay_item_drop ditem {}; - ditem.nameid = get_mob_db(md->mob_class).dropitem[i].nameid; + ditem.nameid = drop_info.nameid; ditem.amount = 1; ditem.m = md->bl_m; ditem.x = md->bl_x; @@ -2796,9 +2799,11 @@ int mob_damage(dumb_ptr<block_list> src, dumb_ptr<mob_data> md, int damage, npc_event(sd, md->npc_event, 0); // TODO: in the future, OnPCKillEvent, OnMobKillEvent and OnPCDieEvent should be combined - argrec_t arg[1] = + argrec_t arg[3] = { {"@mobID"_s, static_cast<int32_t>(unwrap<Species>(md->mob_class))}, + {"@mobX"_s, static_cast<int32_t>(md->bl_x)}, + {"@mobY"_s, static_cast<int32_t>(md->bl_y)}, }; npc_event_doall_l(stringish<ScriptLabel>("OnMobKillEvent"_s), sd->bl_id, arg); } @@ -3501,40 +3506,39 @@ int mobskill_event(dumb_ptr<mob_data> md, BF flag) static int mob_makedummymobdb(Species mob_class) { - int i; - - SNPRINTF(get_mob_db(mob_class).name, 24, "mob%d"_fmt, mob_class); - SNPRINTF(get_mob_db(mob_class).jname, 24, "mob%d"_fmt, mob_class); - get_mob_db(mob_class).lv = 1; - get_mob_db(mob_class).max_hp = 1000; - get_mob_db(mob_class).max_sp = 1; - get_mob_db(mob_class).base_exp = 2; - get_mob_db(mob_class).job_exp = 1; - get_mob_db(mob_class).range = 1; - get_mob_db(mob_class).atk1 = 7; - get_mob_db(mob_class).atk2 = 10; - get_mob_db(mob_class).def = 0; - get_mob_db(mob_class).mdef = 0; - get_mob_db(mob_class).attrs[ATTR::STR] = 1; - get_mob_db(mob_class).attrs[ATTR::AGI] = 1; - get_mob_db(mob_class).attrs[ATTR::VIT] = 1; - get_mob_db(mob_class).attrs[ATTR::INT] = 1; - get_mob_db(mob_class).attrs[ATTR::DEX] = 6; - get_mob_db(mob_class).attrs[ATTR::LUK] = 2; - get_mob_db(mob_class).range2 = 10; - get_mob_db(mob_class).range3 = 10; - get_mob_db(mob_class).size = 0; // 1 - 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_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 < MaxDrops; i++) - { - get_mob_db(mob_class).dropitem[i].nameid = ItemNameId(); - get_mob_db(mob_class).dropitem[i].p.num = 0; + mob_db_& mob_info = get_mob_db(mob_class); + SNPRINTF(mob_info.name, 24, "mob%d"_fmt, mob_class); + SNPRINTF(mob_info.jname, 24, "mob%d"_fmt, mob_class); + mob_info.lv = 1; + mob_info.max_hp = 1000; + mob_info.max_sp = 1; + mob_info.base_exp = 2; + mob_info.job_exp = 1; + mob_info.range = 1; + mob_info.atk1 = 7; + mob_info.atk2 = 10; + mob_info.def = 0; + mob_info.mdef = 0; + mob_info.attrs[ATTR::STR] = 1; + mob_info.attrs[ATTR::AGI] = 1; + mob_info.attrs[ATTR::VIT] = 1; + mob_info.attrs[ATTR::INT] = 1; + mob_info.attrs[ATTR::DEX] = 6; + mob_info.attrs[ATTR::LUK] = 2; + mob_info.range2 = 10; + mob_info.range3 = 10; + mob_info.size = 0; // 1 + mob_info.race = Race::formless; + mob_info.element = LevelElement{0, Element::neutral}; + mob_info.mode = MobMode::ZERO; + mob_info.speed = 300_ms; + mob_info.adelay = 1000_ms; + mob_info.amotion = 500_ms; + mob_info.dmotion = 500_ms; + for (int i = 0; i < MaxDrops; i++) + { + mob_info.dropitem[i].nameid = ItemNameId(); + mob_info.dropitem[i].p.num = 0; } return 0; } @@ -3654,56 +3658,55 @@ bool mob_readdb(ZString filename) continue; } - if (get_mob_db(mob_class).base_exp < 0) + if (mdbv.base_exp < 0) { PRINTF("bad mob line: Xp needs to be greater than 0. %s\n"_fmt, line); rv = false; continue; } - if (get_mob_db(mob_class).base_exp > 1000000000) + if (mdbv.base_exp > 1000000000) { PRINTF("bad mob line: Xp needs to be less than 1000000000. %s\n"_fmt, line); rv = false; continue; } - if (get_mob_db(mob_class).job_exp < 0) + if (mdbv.job_exp < 0) { PRINTF("bad mob line: Job Xp needs to be greater than 0. %s\n"_fmt, line); rv = false; continue; } - if (get_mob_db(mob_class).job_exp > 1000000000) + if (mdbv.job_exp > 1000000000) { PRINTF("bad mob line: Job Xp needs to be less than 1000000000. %s\n"_fmt, line); rv = false; continue; } - // TODO move this lower - get_mob_db(mob_class) = std::move(mdbv); - for (int i = 0; i < MaxDrops; i++) { - int rate = get_mob_db(mob_class).dropitem[i].p.num; + int rate = mdbv.dropitem[i].p.num; if (rate < 1) rate = 1; if (rate > 10000) rate = 10000; - get_mob_db(mob_class).dropitem[i].p.num = rate; + mdbv.dropitem[i].p.num = rate; } - get_mob_db(mob_class).skills.clear(); + mdbv.skills.clear(); + + mdbv.hair = 0; + mdbv.hair_color = 0; + mdbv.weapon = 0; + mdbv.shield = ItemNameId(); + mdbv.head_top = ItemNameId(); + mdbv.head_mid = ItemNameId(); + mdbv.head_buttom = ItemNameId(); + mdbv.clothes_color = 0; //Add for player monster dye - Valaris - get_mob_db(mob_class).hair = 0; - get_mob_db(mob_class).hair_color = 0; - get_mob_db(mob_class).weapon = 0; - get_mob_db(mob_class).shield = ItemNameId(); - get_mob_db(mob_class).head_top = ItemNameId(); - get_mob_db(mob_class).head_mid = ItemNameId(); - get_mob_db(mob_class).head_buttom = ItemNameId(); - get_mob_db(mob_class).clothes_color = 0; //Add for player monster dye - Valaris + if (mdbv.base_exp == 0) + mdbv.base_exp = mob_gen_exp(&mdbv); - if (get_mob_db(mob_class).base_exp == 0) - get_mob_db(mob_class).base_exp = mob_gen_exp(&get_mob_db(mob_class)); + get_mob_db(mob_class) = std::move(mdbv); } PRINTF("read %s done\n"_fmt, filename); } diff --git a/src/map/npc-parse.cpp b/src/map/npc-parse.cpp index df1a09a..8865ea6 100644 --- a/src/map/npc-parse.cpp +++ b/src/map/npc-parse.cpp @@ -273,15 +273,16 @@ bool npc_load_monster(ast::npc::Monster& monster) md->bl_m = m; md->bl_x = x; md->bl_y = y; - MobName expected = get_mob_db(mob_class).jname; + const mob_db_& mob_info = get_mob_db(mob_class); + MobName expected = mob_info.jname; if (monster.name.data != expected) { monster.name.span.warning(STRPRINTF("Visible label/jname should match: %s"_fmt, expected)); } if (monster.name.data == ENGLISH_NAME) - md->name = get_mob_db(mob_class).name; + md->name = mob_info.name; else if (monster.name.data == JAPANESE_NAME) - md->name = get_mob_db(mob_class).jname; + md->name = mob_info.jname; else md->name = monster.name.data; diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index fee39d6..c471da1 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -2683,6 +2683,22 @@ void builtin_getexp(ScriptState *st) *------------------------------------------ */ static +int get_mob_drop_nameid(Species mob_id, int index) +{ + return unwrap<ItemNameId>(get_mob_db(mob_id).dropitem[index].nameid); +} +static +int get_mob_drop_percent(Species mob_id, int index) +{ + return get_mob_db(mob_id).dropitem[index].p.num; +} +static +AString get_mob_drop_name(Species mob_id, int index) +{ + Option<P<struct item_data>> i_data = Some(itemdb_search(get_mob_db(mob_id).dropitem[index].nameid)); + return i_data.pmd_pget(&item_data::name).copy_or(stringish<ItemName>(""_s)); +} +static void builtin_mobinfo(ScriptState *st) { Species mob_id = wrap<Species>(conv_num(st, &AARG(0))); @@ -2697,6 +2713,19 @@ void builtin_mobinfo(ScriptState *st) return; } +#define CASE_MobInfo_DROPID(index) \ + MobInfo::DROPID##index: info = get_mob_drop_nameid(mob_id, index) + +#define CASE_MobInfo_DROPPERCENT(index) \ + MobInfo::DROPPERCENT##index: info = get_mob_drop_percent(mob_id, index) + +#define CASE_MobInfo_DROPNAME(index) \ + MobInfo::DROPNAME##index: \ + { \ + info_str = get_mob_drop_name(mob_id, index); \ + mode = 1; \ + } + switch (request) { case MobInfo::ID: @@ -2800,142 +2829,57 @@ void builtin_mobinfo(ScriptState *st) case MobInfo::MUTATION_POWER: info = get_mob_db(mob_id).mutation_power; break; - case MobInfo::DROPID0: - info = unwrap<ItemNameId>(get_mob_db(mob_id).dropitem[0].nameid); - break; - case MobInfo::DROPNAME0: - { - Option<P<struct item_data>> i_data = Some(itemdb_search(get_mob_db(mob_id).dropitem[0].nameid)); - info_str = i_data.pmd_pget(&item_data::name).copy_or(stringish<ItemName>(""_s)); - mode = 1; - } - break; - case MobInfo::DROPPERCENT0: - info = get_mob_db(mob_id).dropitem[0].p.num; - break; - case MobInfo::DROPID1: - info = unwrap<ItemNameId>(get_mob_db(mob_id).dropitem[0].nameid); - break; - case MobInfo::DROPNAME1: - { - Option<P<struct item_data>> i_data = Some(itemdb_search(get_mob_db(mob_id).dropitem[0].nameid)); - info_str = i_data.pmd_pget(&item_data::name).copy_or(stringish<ItemName>(""_s)); - mode = 1; - } - break; - case MobInfo::DROPPERCENT1: - info = get_mob_db(mob_id).dropitem[0].p.num; - break; - case MobInfo::DROPID2: - info = unwrap<ItemNameId>(get_mob_db(mob_id).dropitem[1].nameid); - break; - case MobInfo::DROPNAME2: - { - Option<P<struct item_data>> i_data = Some(itemdb_search(get_mob_db(mob_id).dropitem[1].nameid)); - info_str = i_data.pmd_pget(&item_data::name).copy_or(stringish<ItemName>(""_s)); - mode = 1; - } - break; - case MobInfo::DROPPERCENT2: - info = get_mob_db(mob_id).dropitem[1].p.num; - break; - case MobInfo::DROPID3: - info = unwrap<ItemNameId>(get_mob_db(mob_id).dropitem[2].nameid); - break; - case MobInfo::DROPNAME3: - { - Option<P<struct item_data>> i_data = Some(itemdb_search(get_mob_db(mob_id).dropitem[2].nameid)); - info_str = i_data.pmd_pget(&item_data::name).copy_or(stringish<ItemName>(""_s)); - mode = 1; - } - break; - case MobInfo::DROPPERCENT3: - info = get_mob_db(mob_id).dropitem[2].p.num; - break; - case MobInfo::DROPID4: - info = unwrap<ItemNameId>(get_mob_db(mob_id).dropitem[3].nameid); - break; - case MobInfo::DROPNAME4: - { - Option<P<struct item_data>> i_data = Some(itemdb_search(get_mob_db(mob_id).dropitem[3].nameid)); - info_str = i_data.pmd_pget(&item_data::name).copy_or(stringish<ItemName>(""_s)); - mode = 1; - } - break; - case MobInfo::DROPPERCENT4: - info = get_mob_db(mob_id).dropitem[3].p.num; - break; - case MobInfo::DROPID5: - info = unwrap<ItemNameId>(get_mob_db(mob_id).dropitem[4].nameid); - break; - case MobInfo::DROPNAME5: - { - Option<P<struct item_data>> i_data = Some(itemdb_search(get_mob_db(mob_id).dropitem[4].nameid)); - info_str = i_data.pmd_pget(&item_data::name).copy_or(stringish<ItemName>(""_s)); - mode = 1; - } - break; - case MobInfo::DROPPERCENT5: - info = get_mob_db(mob_id).dropitem[4].p.num; - break; - case MobInfo::DROPID6: - info = unwrap<ItemNameId>(get_mob_db(mob_id).dropitem[5].nameid); - break; - case MobInfo::DROPNAME6: - { - Option<P<struct item_data>> i_data = Some(itemdb_search(get_mob_db(mob_id).dropitem[5].nameid)); - info_str = i_data.pmd_pget(&item_data::name).copy_or(stringish<ItemName>(""_s)); - mode = 1; - } - break; - case MobInfo::DROPPERCENT6: - info = get_mob_db(mob_id).dropitem[5].p.num; - break; - case MobInfo::DROPID7: - info = unwrap<ItemNameId>(get_mob_db(mob_id).dropitem[6].nameid); - break; - case MobInfo::DROPNAME7: - { - Option<P<struct item_data>> i_data = Some(itemdb_search(get_mob_db(mob_id).dropitem[6].nameid)); - info_str = i_data.pmd_pget(&item_data::name).copy_or(stringish<ItemName>(""_s)); - mode = 1; - } - break; - case MobInfo::DROPPERCENT7: - info = get_mob_db(mob_id).dropitem[6].p.num; - break; - case MobInfo::DROPID8: - info = unwrap<ItemNameId>(get_mob_db(mob_id).dropitem[7].nameid); - break; - case MobInfo::DROPNAME8: - { - Option<P<struct item_data>> i_data = Some(itemdb_search(get_mob_db(mob_id).dropitem[7].nameid)); - info_str = i_data.pmd_pget(&item_data::name).copy_or(stringish<ItemName>(""_s)); - mode = 1; - } - break; - case MobInfo::DROPPERCENT8: - info = get_mob_db(mob_id).dropitem[7].p.num; - break; - case MobInfo::DROPID9: - info = unwrap<ItemNameId>(get_mob_db(mob_id).dropitem[7].nameid); - break; - case MobInfo::DROPNAME9: - { - Option<P<struct item_data>> i_data = Some(itemdb_search(get_mob_db(mob_id).dropitem[7].nameid)); - info_str = i_data.pmd_pget(&item_data::name).copy_or(stringish<ItemName>(""_s)); - mode = 1; - } - break; - case MobInfo::DROPPERCENT9: - info = get_mob_db(mob_id).dropitem[7].p.num; - break; + + case CASE_MobInfo_DROPID(0); break; + case CASE_MobInfo_DROPNAME(0); break; + case CASE_MobInfo_DROPPERCENT(0); break; + + case CASE_MobInfo_DROPID(1); break; + case CASE_MobInfo_DROPNAME(1); break; + case CASE_MobInfo_DROPPERCENT(1); break; + + case CASE_MobInfo_DROPID(2); break; + case CASE_MobInfo_DROPNAME(2); break; + case CASE_MobInfo_DROPPERCENT(2); break; + + case CASE_MobInfo_DROPID(3); break; + case CASE_MobInfo_DROPNAME(3); break; + case CASE_MobInfo_DROPPERCENT(3); break; + + case CASE_MobInfo_DROPID(4); break; + case CASE_MobInfo_DROPNAME(4); break; + case CASE_MobInfo_DROPPERCENT(4); break; + + case CASE_MobInfo_DROPID(5); break; + case CASE_MobInfo_DROPNAME(5); break; + case CASE_MobInfo_DROPPERCENT(5); break; + + case CASE_MobInfo_DROPID(6); break; + case CASE_MobInfo_DROPNAME(6); break; + case CASE_MobInfo_DROPPERCENT(6); break; + + case CASE_MobInfo_DROPID(7); break; + case CASE_MobInfo_DROPNAME(7); break; + case CASE_MobInfo_DROPPERCENT(7); break; + + case CASE_MobInfo_DROPID(8); break; + case CASE_MobInfo_DROPNAME(8); break; + case CASE_MobInfo_DROPPERCENT(8); break; + + case CASE_MobInfo_DROPID(9); break; + case CASE_MobInfo_DROPNAME(9); break; + case CASE_MobInfo_DROPPERCENT(9); break; + default: PRINTF("builtin_mobinfo: unknown request\n"_fmt); push_int<ScriptDataInt>(st->stack, -1); return; break; } +#undef CASE_MobInfo_DROPID +#undef CASE_MobInfo_DROPPERCENT +#undef CASE_MobInfo_DROPNAME + if (!mode) push_int<ScriptDataInt>(st->stack, info); else @@ -3022,7 +2966,9 @@ void builtin_mobinfo_droparrays(ScriptState *st) } for (int i = 0; i < MaxDrops; ++i) - if (get_mob_db(mob_id).dropitem[i].nameid) + { + auto& dropitem = get_mob_db(mob_id).dropitem[i]; + if (dropitem.nameid) { status = 1; switch (request) @@ -3030,15 +2976,15 @@ void builtin_mobinfo_droparrays(ScriptState *st) case MobInfo_DropArrays::IDS: if (name.startswith(".@"_s)) { - struct script_data vd = script_data(ScriptDataInt{unwrap<ItemNameId>(get_mob_db(mob_id).dropitem[i].nameid)}); + struct script_data vd = script_data(ScriptDataInt{unwrap<ItemNameId>(dropitem.nameid)}); set_scope_reg(st, reg.iplus(i), &vd); } else - set_reg(bl, VariableCode::VARIABLE, reg.iplus(i), unwrap<ItemNameId>(get_mob_db(mob_id).dropitem[i].nameid)); + set_reg(bl, VariableCode::VARIABLE, reg.iplus(i), unwrap<ItemNameId>(dropitem.nameid)); break; case MobInfo_DropArrays::NAMES: { - Option<P<struct item_data>> i_data = Some(itemdb_search(get_mob_db(mob_id).dropitem[i].nameid)); + Option<P<struct item_data>> i_data = Some(itemdb_search(dropitem.nameid)); RString item_name = i_data.pmd_pget(&item_data::name).copy_or(stringish<ItemName>(""_s)); if (name.startswith(".@"_s)) @@ -3053,11 +2999,11 @@ void builtin_mobinfo_droparrays(ScriptState *st) case MobInfo_DropArrays::PERCENTS: if (name.startswith(".@"_s)) { - struct script_data vd = script_data(ScriptDataInt{get_mob_db(mob_id).dropitem[i].p.num}); + struct script_data vd = script_data(ScriptDataInt{dropitem.p.num}); set_scope_reg(st, reg.iplus(i), &vd); } else - set_reg(bl, VariableCode::VARIABLE, reg.iplus(i), get_mob_db(mob_id).dropitem[i].p.num); + set_reg(bl, VariableCode::VARIABLE, reg.iplus(i), dropitem.p.num); break; } } @@ -3067,7 +3013,7 @@ void builtin_mobinfo_droparrays(ScriptState *st) status = 2; break; } - + } push_int<ScriptDataInt>(st->stack, status); } @@ -3097,16 +3043,19 @@ void builtin_getmobdrops(ScriptState *st) status = 1; + const mob_db_& mob_info = get_mob_db(mob_id); for (; i < MaxDrops; ++i) - if (get_mob_db(mob_id).dropitem[i].nameid) + { + auto& dropitem = mob_info.dropitem[i]; + if (dropitem.nameid) { - set_reg(bl, VariableCode::VARIABLE, SIR::from(variable_names.intern("$@MobDrop_item"_s), i), get_mob_db(mob_id).dropitem[i].p.num); + set_reg(bl, VariableCode::VARIABLE, SIR::from(variable_names.intern("$@MobDrop_item"_s), i), dropitem.p.num); - Option<P<struct item_data>> i_data = Some(itemdb_search(get_mob_db(mob_id).dropitem[i].nameid)); + Option<P<struct item_data>> i_data = Some(itemdb_search(dropitem.nameid)); RString item_name = i_data.pmd_pget(&item_data::name).copy_or(stringish<ItemName>(""_s)); set_reg(bl, VariableCode::VARIABLE, SIR::from(variable_names.intern("$@MobDrop_name$"_s), i), item_name); - set_reg(bl, VariableCode::VARIABLE, SIR::from(variable_names.intern("$@MobDrop_rate"_s), i), get_mob_db(mob_id).dropitem[i].p.num); + set_reg(bl, VariableCode::VARIABLE, SIR::from(variable_names.intern("$@MobDrop_rate"_s), i), dropitem.p.num); } else { @@ -3114,6 +3063,7 @@ void builtin_getmobdrops(ScriptState *st) status = 2; break; } + } if (status == 1) set_reg(bl, VariableCode::VARIABLE, SIR::from(variable_names.intern("$@MobDrop_count"_s), 0), i); @@ -4366,9 +4316,14 @@ void builtin_getitemlink(ScriptState *st) struct script_data *data; AString buf; data = &AARG(0); - ZString name = conv_str(st, data); + Option<P<struct item_data>> item_data_ = None; + + get_val(st, data); + if (data->is<ScriptDataStr>()) + item_data_ = itemdb_searchname(conv_str(st, data)); + else + item_data_ = itemdb_exists(wrap<ItemNameId>(conv_num(st, data))); - Option<P<struct item_data>> item_data_ = itemdb_searchname(name); OMATCH_BEGIN (item_data_) { OMATCH_CASE_SOME (item_data) diff --git a/src/map/script-parse.py b/src/map/script-parse.py index 199e348..3346b92 100644 --- a/src/map/script-parse.py +++ b/src/map/script-parse.py @@ -106,7 +106,7 @@ class ScriptBuffer(object): code_begin = code['_M_impl']['_M_start'] code_end = code['_M_impl']['_M_finish'] code_size = int(code_end - code_begin) - r = iter(range(code_size)) + r = iter(list(range(code_size))) for i in r: buf = [] for label in labels_dict.get(i, []): diff --git a/src/mmo/version.cpp b/src/mmo/version.cpp index f91b748..c75c25c 100644 --- a/src/mmo/version.cpp +++ b/src/mmo/version.cpp @@ -20,7 +20,7 @@ // 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 "../conf/version.hpp" +#include "src/conf/version.hpp" #include "../strings/xstring.hpp" diff --git a/src/shared/lib.cpp b/src/shared/lib.cpp index c0a4371..37b2e93 100644 --- a/src/shared/lib.cpp +++ b/src/shared/lib.cpp @@ -18,7 +18,7 @@ // 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 "../conf/install.hpp" +#include "src/conf/install.hpp" #include "../strings/literal.hpp" #include "../strings/astring.hpp" |