diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-02-27 13:03:56 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-02-27 13:03:56 +0000 |
commit | 02294f67e4fc78d79d639d4c29aa72e22f93b06c (patch) | |
tree | 31a170cb7933750ed8b64cf8fd72dff373005ad7 /crawl-ref/source | |
parent | 7baa5392145a253c8f4744e12e90770c6147bd74 (diff) | |
download | crawl-ref-02294f67e4fc78d79d639d4c29aa72e22f93b06c.tar.gz crawl-ref-02294f67e4fc78d79d639d4c29aa72e22f93b06c.zip |
Apply Paul's patch 1901939: including files in init.txt
with some clean-up and fix in acr.cc to make the results
apply at once (instead of only after a screen redraw).
I've tested it and everything works fine. Recursive
inclusion, e.g. read_options('init.txt'), prints a stack
overflow error but doesn't crash the game, so I think
that's fine for now.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3469 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/acr.cc | 42 | ||||
-rw-r--r-- | crawl-ref/source/clua.cc | 22 |
2 files changed, 43 insertions, 21 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 09db1d0a7b..fbbcff2fa5 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -3764,18 +3764,32 @@ static bool initialise(void) burden_change(); make_hungry(0,true); - you.redraw_strength = true; + you.redraw_strength = true; you.redraw_intelligence = true; - you.redraw_dexterity = true; + you.redraw_dexterity = true; you.redraw_armour_class = true; - you.redraw_evasion = true; - you.redraw_experience = true; - you.redraw_gold = true; - you.wield_change = true; - you.quiver_change = true; + you.redraw_evasion = true; + you.redraw_experience = true; + you.redraw_gold = true; + you.wield_change = true; + you.quiver_change = true; you.start_time = time( NULL ); // start timer on session +#ifdef CLUA_BINDINGS + clua.runhook("chk_startgame", "b", newc); + std::string yname = you.your_name; + read_init_file(true); + Options.fixup_options(); + strncpy(you.your_name, yname.c_str(), kNameLen); + you.your_name[kNameLen - 1] = 0; + + // In case Lua changed the character set. + init_char_table(Options.char_set); + init_feature_table(); + init_monster_symbols(); +#endif + draw_border(); new_level(); update_turn_count(); @@ -3793,20 +3807,6 @@ static bool initialise(void) zap_los_monsters(); } -#ifdef CLUA_BINDINGS - clua.runhook("chk_startgame", "b", newc); - std::string yname = you.your_name; - read_init_file(true); - Options.fixup_options(); - strncpy(you.your_name, yname.c_str(), kNameLen); - you.your_name[kNameLen - 1] = 0; - - // In case Lua changed the character set. - init_char_table(Options.char_set); - init_feature_table(); - init_monster_symbols(); -#endif - set_cursor_enabled(false); viewwindow(1, false); // This just puts the view up for the first turn. diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index be10393602..85fca69605 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -1774,6 +1774,27 @@ static int crawl_setopt(lua_State *ls) return (0); } +static int crawl_read_options(lua_State *ls) +{ + if (!lua_isstring(ls, 1)) + return (0); + + const char* filename = lua_tostring(ls, 1); + FILE* f = fopen( filename, "r" ); + if (f) + { + FileLineInput fl(f); + Options.read_options(fl, true); + fclose(f); + } + else + { + mprf(MSGCH_WARN, "Warning: could not read options file '%s'", filename); + } + + return (0); +} + static int crawl_bindkey(lua_State *ls) { const char *s = NULL; @@ -2008,6 +2029,7 @@ static const struct luaL_reg crawl_lib[] = { "runmacro", crawl_runmacro }, { "bindkey", crawl_bindkey }, { "setopt", crawl_setopt }, + { "read_options", crawl_read_options }, { "msgch_num", crawl_msgch_num }, { "msgch_name", crawl_msgch_name }, |