diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-04-02 22:10:00 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-04-07 15:28:25 +0200 |
commit | a5a4f737005258097fb46a7c746ac202575fd03e (patch) | |
tree | f10f14909a953c5fbbeb4730244525a7844092d8 | |
parent | 13543856597dc59f3cf8b7ecbf7d2e77e07c7f69 (diff) |
Lua: Move module initialization code to C
-rw-r--r-- | lib/mods/mods_aux.lua | 185 | ||||
-rw-r--r-- | lib/mods/modules.lua | 5 | ||||
-rw-r--r-- | lib/mods/theme/module.lua | 48 | ||||
-rw-r--r-- | lib/module.lua | 36 | ||||
-rw-r--r-- | src/birth.c | 26 | ||||
-rw-r--r-- | src/cmd4.c | 8 | ||||
-rw-r--r-- | src/defines.h | 5 | ||||
-rw-r--r-- | src/dungeon.c | 16 | ||||
-rw-r--r-- | src/externs.h | 7 | ||||
-rw-r--r-- | src/init2.c | 25 | ||||
-rw-r--r-- | src/loadsave.c | 2 | ||||
-rw-r--r-- | src/modules.c | 100 | ||||
-rw-r--r-- | src/skills.c | 2 | ||||
-rw-r--r-- | src/tables.c | 43 | ||||
-rw-r--r-- | src/types.h | 62 | ||||
-rw-r--r-- | src/variable.c | 5 | ||||
-rw-r--r-- | src/xtra2.c | 5 |
17 files changed, 195 insertions, 385 deletions
diff --git a/lib/mods/mods_aux.lua b/lib/mods/mods_aux.lua deleted file mode 100644 index 1562a566..00000000 --- a/lib/mods/mods_aux.lua +++ /dev/null @@ -1,185 +0,0 @@ --- Ok some functions that we dont need are dangerous ---[[ -execute = nil -getenv = nil -setlocale = nil -exit = nil -openfile = nil -writeto = nil -readfrom = nil -appendto = nil -remove = nil -rename = nil -tmpname = nil -]] -modules = {} - -current_module = nil - -function setup_module(mod) - -- For standart game, nothing needs to be done - if not mod.layout then return end - - for k, e in mod.layout do - module_reset_dir(k, e) - end -end - -function init_module(i) - setup_module(get_module(i)) -end - -function max_modules() - local i = 0 - for k, e in modules do - if type(k) == "number" and type(e) == "table" then - i = i + 1 - end - end - return i -end - -function get_module_name(j) - local i = 0 - for k, e in modules do - if type(k) == "number" and type(e) == "table" then - if i == j then return e.name end - i = i + 1 - end - end -end - -function get_module_desc(j) - local i = 0 - for k, e in modules do - if type(k) == "number" and type(e) == "table" then - if i == j then return e.desc end - i = i + 1 - end - end -end - -function get_module(j) - local i = 0 - for k, e in modules do - if type(k) == "number" and type(e) == "table" then - if i == j then return e end - i = i + 1 - end - end -end - -function find_module(name) - local i = 0 - for k, e in modules do - if type(k) == "number" and type(e) == "table" then - if name == e.name then return i end - i = i + 1 - end - end -end - -function assign_current_module(name) - current_module = get_module(find_module(name)) -end - -function get_module_info(type, subtype) - if subtype then - return current_module[type][subtype] - else - return current_module[type] - end -end - -function exec_module_info(type, ...) - return call(current_module[type], arg) -end - -function module_savefile_loadable(savefile_mod, savefile_death) - for _, e in current_module.mod_savefiles do - if e[1] == savefile_mod then - if e[2] == "all" then - return TRUE - elseif e[2] == "alive" and savefile_death == FALSE then - return TRUE - elseif e[2] == "dead" and savefile_death == TRUE then - return TRUE - end - end - end - return FALSE -end - -function scan_extra_modules() - scansubdir(ANGBAND_DIR_MODULES) - for i = 0, scansubdir_max - 1 do - if (scansubdir_result[i + 1] ~= ".") and (scansubdir_result[i + 1] ~= "..") then - local dir = path_build(ANGBAND_DIR_MODULES, scansubdir_result[i + 1]) - local file = path_build(dir, "module.lua") - if file_exist(file) == TRUE then - tome_dofile_anywhere(dir, "module.lua") - end - end - end -end - -function add_module(t) - assert(t.name, "No module name") - assert(type(t.version) == "table", "No module version") - assert(t.desc, "No module desc") - assert(t.author, "No module author") - assert(t.mod_savefiles, "No loadable savefiles module mark") - - for _, e in modules do - if type(e) == "table" and e.name == t.name then - error("Module name already defined: "..t.name) - end - end - - if type(t.author) == "string" then - t.author = { t.author, "unknown@unknown.net" } - end - - for k, e in t.mod_savefiles do - if type(e) == "string" then t.mod_savefiles[k] = { e, "all" } end - end - - if type(t.desc) == "table" then - local d = "" - for k, e in t.desc do - d = d .. e - if k < getn(t.desc) then - d = d .. "\n" - end - end - t.desc = d - end - - if not t.rand_quest then t.rand_quest = FALSE end - if not t.C_quest then t.C_quest = FALSE end - - if not t.base_dungeon then t.base_dungeon = 4 end - if not t.death_dungeon then t.death_dungeon = 28 end - - if not t.astral_dungeon then t.astral_dungeon = 8 end - if not t.astral_wild_x then t.astral_wild_x = 45 end - if not t.astral_wild_y then t.astral_wild_y = 19 end - - if not t.random_artifact_weapon_chance then - t.random_artifact_weapon_chance = 30 - end - if not t.random_artifact_armor_chance then - t.random_artifact_armor_chance = 20 - end - if not t.random_artifact_jewelry_chance then - t.random_artifact_jewelry_chance = 20 - end - - if not t.max_plev then t.max_plev = 50 end - if not t.max_skill_overage then t.max_skill_overage = 4 end - if not t.skill_per_level then t.skill_per_level = function() return 6 end end - - if not t.allow_birth then t.allow_birth = TRUE end - - tinsert(modules, t) -end diff --git a/lib/mods/modules.lua b/lib/mods/modules.lua deleted file mode 100644 index 5deddef7..00000000 --- a/lib/mods/modules.lua +++ /dev/null @@ -1,5 +0,0 @@ --- Load ToME -tome_dofile_anywhere(ANGBAND_DIR, "module.lua") - --- Look for more modules -scan_extra_modules() diff --git a/lib/mods/theme/module.lua b/lib/mods/theme/module.lua deleted file mode 100644 index cc0b6f08..00000000 --- a/lib/mods/theme/module.lua +++ /dev/null @@ -1,48 +0,0 @@ -add_module -{ - ["name"] = "Theme", - ["version"] = { 1, 2, 0 }, - ["author"] = { "furiosity", "furiosity@gmail.com" }, - ["desc"] = { - "A module that goes back to Tolkien roots, though by no means canonical.", - "A new wilderness map, new monsters, objects, artifacts, uniques, ego items,", - "terrain features, gods, races, subraces, and classes. Have fun. :-)", - }, - - ["rand_quest"] = TRUE, - ["C_quest"] = TRUE, - - ["base_dungeon"] = 4, - ["death_dungeon"] = 28, - - ["astral_dungeon"] = 8, - ["astral_wild_x"] = 45, - ["astral_wild_y"] = 19, - - ["random_artifact_weapon_chance"] = 30, - ["random_artifact_armor_chance"] = 30, - ["random_artifact_jewelry_chance"] = 30, - - ["max_plev"] = 50, - ["max_skill_overage"] = 5, - - ["mod_savefiles"]= - { - "Theme", - }, - ["layout"] = - { - ["apex"] = "theme", - ["core"] = "theme", - ["data"] = "theme", - ["dngn"] = "theme", - ["edit"] = "theme", - ["file"] = "theme", - ["help"] = "theme", - ["note"] = "theme", - ["save"] = "theme", - ["scpt"] = "theme", - ["user"] = "theme", - ["pref"] = "theme", - }, -}
\ No newline at end of file diff --git a/lib/module.lua b/lib/module.lua deleted file mode 100644 index edbaa34b..00000000 --- a/lib/module.lua +++ /dev/null @@ -1,36 +0,0 @@ -add_module -{ - ["name"] = "ToME", - ["version"] = { 2, 3, 9 }, - ["author"] = { "DarkGod", "darkgod@t-o-m-e.net" }, - ["desc"] = { - "The Tales of Middle-earth, the standard and official game.", - "You are set on a quest to investigate the old tower of Dol Guldur.", - "But who knows what will happen...", - }, - - ["rand_quest"] = TRUE, - ["C_quest"] = TRUE, - - ["base_dungeon"] = 4, - ["death_dungeon"] = 28, - - ["astral_dungeon"] = 8, - ["astral_wild_x"] = 45, - ["astral_wild_y"] = 19, - - ["random_artifact_weapon_chance"] = 30, - ["random_artifact_armor_chance"] = 20, - ["random_artifact_jewelry_chance"] = 20, - - ["max_plev"] = 50, - ["max_skill_overage"] = 4, - ["skill_per_level"] = function() - return 6 - end, - - ["mod_savefiles"]= - { - "ToME", - }, -} diff --git a/src/birth.c b/src/birth.c index f073b2f6..cbe87512 100644 --- a/src/birth.c +++ b/src/birth.c @@ -1615,8 +1615,6 @@ static bool_ player_birth_aux_ask() { int i, k, n, v, sel; - s32b tmp; - int racem[100], max_racem = 0; u32b restrictions[2]; @@ -1632,8 +1630,6 @@ static bool_ player_birth_aux_ask() s16b *class_types; - s32b allow_quest; - /*** Intro ***/ /* Clear screen */ @@ -2354,23 +2350,16 @@ static bool_ player_birth_aux_ask() /* Set the recall dungeon accordingly */ - call_lua("get_module_info", "(s)", "d", "base_dungeon", &tmp); - dungeon_type = tmp; + dungeon_type = DUNGEON_BASE; p_ptr->recall_dungeon = dungeon_type; max_dlv[dungeon_type] = d_info[dungeon_type].mindepth; if (p_ptr->astral) { - s32b x, y, astral_dun; - - call_lua("get_module_info", "(s)", "d", "astral_dungeon", &astral_dun); - dungeon_type = astral_dun; - /* Somewhere in the misty mountains */ - call_lua("get_module_info", "(s)", "d", "astral_wild_x", &x); - call_lua("get_module_info", "(s)", "d", "astral_wild_y", &y); - p_ptr->wilderness_x = x; - p_ptr->wilderness_y = y; + dungeon_type = DUNGEON_ASTRAL; + p_ptr->wilderness_x = DUNGEON_ASTRAL_WILD_X; + p_ptr->wilderness_y = DUNGEON_ASTRAL_WILD_Y; } /* Clean up */ @@ -2379,8 +2368,7 @@ static bool_ player_birth_aux_ask() /*** User enters number of quests ***/ /* Heino Vander Sanden and Jimmy De Laet */ - call_lua("get_module_info", "(s)", "d", "rand_quest", &allow_quest); - if (!ironman_rooms && allow_quest) + if (!ironman_rooms) { if (do_quick_start) { @@ -2445,8 +2433,6 @@ static bool_ player_birth_aux_ask() p_ptr->inside_quest = 0; /* Init the plots */ - call_lua("get_module_info", "(s)", "d", "C_quest", &allow_quest); - if (allow_quest) { plots[PLOT_MAIN] = QUEST_NECRO; quest[plots[PLOT_MAIN]].status = QUEST_STATUS_TAKEN; @@ -3694,7 +3680,7 @@ savefile_try_again: { s32b can_use; - call_lua("module_savefile_loadable", "(s)", "d", savefile_module[k], &can_use); + can_use = module_savefile_loadable(savefile_module[k]); if (can_use) { savefile_idx[m++] = k; @@ -2808,15 +2808,11 @@ void do_cmd_note(void) */ void do_cmd_version(void) { - cptr author, email; - - call_lua("get_module_info", "(s,d)", "s", "author", 1, &author); - call_lua("get_module_info", "(s,d)", "s", "author", 2, &email); - /* Silly message */ msg_format("You are playing %s made by %s (%s).", get_version_string(), - author, email); + modules[game_module_idx].meta.author.name, + modules[game_module_idx].meta.author.email); call_lua("patchs_display", "()", ""); } diff --git a/src/defines.h b/src/defines.h index bebe091c..344a171e 100644 --- a/src/defines.h +++ b/src/defines.h @@ -4418,6 +4418,11 @@ #define MAX_PLOTS 7 /* + * Modules + */ +#define MAX_MODULES 2 + +/* * Hooks */ #define HOOK_MONSTER_DEATH 0 diff --git a/src/dungeon.c b/src/dungeon.c index 6d732f00..9b384dce 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -5296,22 +5296,6 @@ void play_game(bool_ new_game) /* Roll new character */ if (new_game) { - s32b ret; - - /* Are we authorized to create new chars? */ - call_lua("get_module_info", "(s)", "d", "allow_birth", &ret); - - if (!ret) - { - msg_box("Sorry, this module does not allow character creation.", -1, -1); - - /* Close stuff */ - close_game(); - - /* Quit */ - quit(NULL); - } - process_hooks(HOOK_INIT, "()"); /* The dungeon is not ready */ diff --git a/src/externs.h b/src/externs.h index 197c1c8a..c671693d 100644 --- a/src/externs.h +++ b/src/externs.h @@ -97,6 +97,7 @@ extern int cli_total; extern quest_type quest_init_tome[MAX_Q_IDX_INIT]; extern int max_body_part[BODY_MAX]; extern gf_name_type gf_names[]; +extern module_type modules[MAX_MODULES]; /* variable.c */ @@ -588,11 +589,16 @@ extern bool_ automatizer_enabled; extern s16b last_teleportation_y; extern s16b last_teleportation_x; extern cptr game_module; +extern s32b game_module_idx; extern s32b VERSION_MAJOR; extern s32b VERSION_MINOR; extern s32b VERSION_PATCH; extern s32b max_plev; +extern s32b DUNGEON_BASE; extern s32b DUNGEON_DEATH; +extern s32b DUNGEON_ASTRAL; +extern s32b DUNGEON_ASTRAL_WILD_X; +extern s32b DUNGEON_ASTRAL_WILD_Y; extern deity_type *deity_info; extern s32b max_gods; extern timer_type *gl_timers; @@ -1758,6 +1764,7 @@ extern bool_ get_lua_var(cptr name, char type, void *arg); extern void module_reset_dir(cptr dir, cptr new_path); extern cptr force_module; extern bool_ select_module(void); +extern bool_ module_savefile_loadable(cptr savefile_mod); /* lua_bind.c */ diff --git a/src/init2.c b/src/init2.c index 5239426c..222293c4 100644 --- a/src/init2.c +++ b/src/init2.c @@ -1933,15 +1933,6 @@ static void init_basic() } } -/* - * Pseudo, dummy quest initializer, to actualy disable them - */ -static bool_ quest_disable_init_hook(int q_idx) -{ - q_idx = q_idx; - return FALSE; -} - /* * Initialise misc. values @@ -1951,8 +1942,6 @@ static errr init_misc(void) int xstart = 0; int ystart = 0; int i; - s32b allow_quest; - s32b allow_rquest; /*** Prepare the various "bizarre" arrays ***/ @@ -1977,26 +1966,12 @@ static errr init_misc(void) C_COPY(powers_type, powers_type_init, POWER_MAX_INIT, power_type); /* Prepare quests */ - call_lua("get_module_info", "(s)", "d", "C_quest", &allow_quest); - call_lua("get_module_info", "(s)", "d", "rand_quest", &allow_rquest); - quest = NULL; max_q_idx = MAX_Q_IDX_INIT; reinit_quests(max_q_idx); C_COPY(quest, quest_init_tome, MAX_Q_IDX_INIT, quest_type); - /* If we dont allow C quests, we dont let them init */ - if (!allow_quest) - { - for (i = 0; i < MAX_Q_IDX_INIT; i++) - { - if (allow_rquest && (i == QUEST_RANDOM)) - continue; - quest[i].init = quest_disable_init_hook; - } - } - /* Prepare gods */ deity_info = NULL; max_gods = MAX_GODS_INIT; diff --git a/src/loadsave.c b/src/loadsave.c index 6799a502..5d43d79a 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -692,7 +692,7 @@ static bool_ do_extra(int flag) { s32b ok; - call_lua("module_savefile_loadable", "(s,d)", "d", loaded_game_module, death, &ok); + ok = module_savefile_loadable(loaded_game_module); /* Argh bad game module! */ if (!ok) diff --git a/src/modules.c b/src/modules.c index 39b41d20..5f582d92 100644 --- a/src/modules.c +++ b/src/modules.c @@ -88,7 +88,6 @@ static void dump_modules(int sel, int max) int i; char buf[40], pre = ' ', post = ')'; - cptr name; char ind; @@ -109,13 +108,11 @@ static void dump_modules(int sel, int max) post = ')'; } - call_lua("get_module_name", "(d)", "s", i, &name); - strnfmt(buf, 40, "%c%c%c %s", pre, ind, post, name); + strnfmt(buf, 40, "%c%c%c %s", pre, ind, post, modules[i].meta.name); if (sel == i) { - call_lua("get_module_desc", "(d)", "s", i, &name); - print_desc_aux(name, 5, 0); + print_desc_aux(modules[i].meta.desc, 5, 0); c_put_str(TERM_L_BLUE, buf, 10 + (i / 4), 20 * (i % 4)); } @@ -124,22 +121,23 @@ static void dump_modules(int sel, int max) } } -static void activate_module() +static void activate_module(int module_idx) { + module_type *module_ptr = &modules[module_idx]; + /* Initialize the module table */ - call_lua("assign_current_module", "(s)", "", game_module); + game_module_idx = module_idx; /* Do misc inits */ - call_lua("get_module_info", "(s)", "d", "max_plev", &max_plev); - call_lua("get_module_info", "(s)", "d", "death_dungeon", &DUNGEON_DEATH); + max_plev = module_ptr->max_plev; - call_lua("get_module_info", "(s)", "d", "random_artifact_weapon_chance", &RANDART_WEAPON); - call_lua("get_module_info", "(s)", "d", "random_artifact_armor_chance", &RANDART_ARMOR); - call_lua("get_module_info", "(s)", "d", "random_artifact_jewelry_chance", &RANDART_JEWEL); + RANDART_WEAPON = module_ptr->randarts.weapon_chance; + RANDART_ARMOR = module_ptr->randarts.armor_chance; + RANDART_JEWEL = module_ptr->randarts.jewelry_chance; - call_lua("get_module_info", "(s,d)", "d", "version", 1, &VERSION_MAJOR); - call_lua("get_module_info", "(s,d)", "d", "version", 2, &VERSION_MINOR); - call_lua("get_module_info", "(s,d)", "d", "version", 3, &VERSION_PATCH); + VERSION_MAJOR = module_ptr->meta.version.major; + VERSION_MINOR = module_ptr->meta.version.minor; + VERSION_PATCH = module_ptr->meta.version.patch; version_major = VERSION_MAJOR; version_minor = VERSION_MINOR; version_patch = VERSION_PATCH; @@ -155,6 +153,31 @@ static void activate_module() process_player_base(); } +static void init_module(module_type *module_ptr) +{ + /* Set up module directories? */ + cptr dir = module_ptr->meta.module_dir; + if (dir) { + module_reset_dir("apex", dir); + module_reset_dir("core", dir); + module_reset_dir("data", dir); + module_reset_dir("dngn", dir); + module_reset_dir("edit", dir); + module_reset_dir("file", dir); + module_reset_dir("help", dir); + module_reset_dir("note", dir); + module_reset_dir("save", dir); + module_reset_dir("scpt", dir); + module_reset_dir("user", dir); + module_reset_dir("pref", dir); + } +} + +bool_ module_savefile_loadable(cptr savefile_mod) +{ + return (strcmp(savefile_mod, modules[game_module_idx].meta.save_file_tag) == 0); +} + /* Did the player force a module on command line */ cptr force_module = NULL; @@ -166,32 +189,35 @@ bool_ select_module() /* Init some lua */ init_lua(); - /* Some ports need to separate the module scripts from the installed mods, - so we need to check for these in two different places */ - if(!tome_dofile_anywhere(ANGBAND_DIR_CORE, "mods_aux.lua", FALSE)) - tome_dofile_anywhere(ANGBAND_DIR_MODULES, "mods_aux.lua", TRUE); - if(!tome_dofile_anywhere(ANGBAND_DIR_CORE, "modules.lua", FALSE)) - tome_dofile_anywhere(ANGBAND_DIR_MODULES, "modules.lua", TRUE); - - /* Grab the savefiles */ - call_lua("max_modules", "()", "d", &max); + /* How many modules? */ + max = MAX_MODULES; /* No need to bother the player if there is only one module */ sel = -1; - if (force_module) - call_lua("find_module", "(s)", "d", force_module, &sel); - if (max == 1) + if (force_module) { + /* Find module by name */ + int i=0; + for (i=0; i<MAX_MODULES; i++) { + if (strcmp(force_module, modules[i].meta.name) == 0) { + break; + } + } + if (i<MAX_MODULES) { + sel = i; + } + } + /* Only a single choice */ + if (max == 1) { sel = 0; + } + /* No module selected */ if (sel != -1) { - cptr tmp; - /* Process the module */ - call_lua("init_module", "(d)", "", sel); - call_lua("get_module_name", "(d)", "s", sel, &tmp); - game_module = string_make(tmp); + init_module(&modules[sel]); + game_module = string_make(modules[sel].meta.name); - activate_module(); + activate_module(sel); return FALSE; } @@ -251,7 +277,6 @@ bool_ select_module() { int x; - cptr tmp; if (islower(k)) x = A2I(k); else x = A2I(tolower(k)) + 26; @@ -259,11 +284,10 @@ bool_ select_module() if ((x < 0) || (x >= max)) continue; /* Process the module */ - call_lua("init_module", "(d)", "", x); - call_lua("get_module_name", "(d)", "s", x, &tmp); - game_module = string_make(tmp); + init_module(&modules[x]); + game_module = string_make(modules[x].meta.name); - activate_module(); + activate_module(x); return (FALSE); } diff --git a/src/skills.c b/src/skills.c index 36b4f585..9890e96d 100644 --- a/src/skills.c +++ b/src/skills.c @@ -31,7 +31,7 @@ void increase_skill(int i, s16b *invest) if (s_info[i].value >= SKILL_MAX) return; /* Cannot allocate more than player level + max_skill_overage levels */ - call_lua("get_module_info", "(s)", "d", "max_skill_overage", &max_skill_overage); + max_skill_overage = modules[game_module_idx].skills.max_skill_overage; if (((s_info[i].value + s_info[i].mod) / SKILL_STEP) >= (p_ptr->lev + max_skill_overage + 1)) { int hgt, wid; diff --git a/src/tables.c b/src/tables.c index e976e234..569acd93 100644 --- a/src/tables.c +++ b/src/tables.c @@ -4790,3 +4790,46 @@ gf_name_type gf_names[] = { GF_ATTACK, "projected melee attacks" }, { -1, NULL }, }; + +/** + * Modules + */ +module_type modules[MAX_MODULES] = +{ + { + { "ToME", + { 2, 3, 9 }, + { "DarkGod", "darkgod@t-o-m-e.net" }, + "The Tales of Middle-earth, the standard and official game.\n" + "You are set on a quest to investigate the old tower of Dol Guldur.\n" + "But who knows what will happen...", + "ToME", + NULL /* default dir */, + }, + /* Randarts: */ + { 30, 20, 20 }, + /* Max player level: */ + 50, + /* Skills: */ + { 6, 4, }, + }, + + { + { "Theme", + { 1, 2, 0 }, + { "furiosity", "furiosity@gmail.com" }, + "A module that goes back to Tolkien roots, though by no means canonical.\n" + "A new wilderness map, new monsters, objects, artifacts, uniques, ego items,\n" + "terrain features, gods, races, subraces, and classes. Have fun. :-)", + "Theme", + "theme", + }, + /* Randarts: */ + { 30, 30, 30 }, + /* Max player level: */ + 50, + /* Skill overage: */ + { 6, 5, }, + } + +}; diff --git a/src/types.h b/src/types.h index 49acb383..b5fab44e 100644 --- a/src/types.h +++ b/src/types.h @@ -2520,3 +2520,65 @@ struct ability_type s16b need_abilities[10]; /* List of prereq abilities(10 max) */ s16b forbid_abilities[10]; /* List of forbidden abilities(10 max) */ }; + +/** + * Module metadata + */ +typedef struct module_meta_type module_meta_type; +struct module_meta_type +{ + /* Module name */ + cptr name; + + /* Module version number */ + struct { + s32b major; + s32b minor; + s32b patch; + } version; + + /* Module author */ + struct { + cptr name; + cptr email; + } author; + + /* Module description */ + cptr desc; + + /* Save file tag */ + cptr save_file_tag; + + /* Module directory */ + cptr module_dir; +}; + +/** + * Modules + */ +typedef struct module_type module_type; +struct module_type +{ + /* Metadata about the module: author, description, etc. */ + module_meta_type meta; + + /* Random artifact generation chances */ + struct { + s32b weapon_chance; + s32b armor_chance; + s32b jewelry_chance; + } randarts; + + /* Max player level. */ + int max_plev; + + /* Skills */ + struct { + /* Skill points per level */ + s32b skill_per_level; + /* Maximum "overage" for skill points, i.e. how many skill + points you can go above your current level. */ + s32b max_skill_overage; + } skills; + +}; diff --git a/src/variable.c b/src/variable.c index 0eb0fadf..c00e1e42 100644 --- a/src/variable.c +++ b/src/variable.c @@ -1564,6 +1564,7 @@ s16b last_teleportation_x = -1; * The current game module */ cptr game_module; +s32b game_module_idx; s32b VERSION_MAJOR; s32b VERSION_MINOR; s32b VERSION_PATCH; @@ -1572,7 +1573,11 @@ s32b VERSION_PATCH; * Some module info */ s32b max_plev = 50; +s32b DUNGEON_BASE = 4; s32b DUNGEON_DEATH = 28; +s32b DUNGEON_ASTRAL = 8; +s32b DUNGEON_ASTRAL_WILD_X = 45; +s32b DUNGEON_ASTRAL_WILD_Y = 19; /* * Gods diff --git a/src/xtra2.c b/src/xtra2.c index 70978e47..45a0caec 100644 --- a/src/xtra2.c +++ b/src/xtra2.c @@ -2037,11 +2037,8 @@ void check_experience(void) if (p_ptr->skill_last_level < p_ptr->lev) { - s32b pts; - call_lua("exec_module_info", "(s)", "d", "skill_per_level", &pts); - p_ptr->skill_last_level = p_ptr->lev; - p_ptr->skill_points += pts; + p_ptr->skill_points += modules[game_module_idx].skills.skill_per_level; cmsg_format(TERM_L_GREEN, "You can increase %d more skills.", p_ptr->skill_points); p_ptr->redraw |= PR_STUDY; } |