X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fmain.c;h=457143847899e17e4257b68843a108fd3cdd5f3b;hb=52f02f0f8614afa7d4776e90d955eff9c3659f80;hp=adf093f0e44dfc64a8bc13dd102754cd4c907981;hpb=4b5302fe73b9aa08819ff740bbf8286352a990fb;p=plomrogue diff --git a/src/main.c b/src/main.c index adf093f..4571438 100644 --- a/src/main.c +++ b/src/main.c @@ -20,15 +20,15 @@ #include "map.h" /* for struct Map, init_map() */ #include "misc.h" /* for update_log(), find_passable_pos(), save_game(), * try_calloc(), check_tempfile(), check_xor_files(), - * load_interface_conf(), load_game() + * load_interface_conf(), load_game(), rrand() */ #include "wincontrol.h" /* get_win_by_id(), get_winconf_by_win() */ -#include "rrand.h" /* for rrand(), rrand_seed() */ #include "rexit.h" /* for exit_game(), exit_err() */ #include "command_db.h" /* for init_command_db(), is_command_id_shortdsc() */ #include "control.h" /* for control_by_id(), player_control(), * get_available_keycode_to_action() */ +#include "map_object_actions.h" /* for init_map_object_actions() */ @@ -37,8 +37,11 @@ int main(int argc, char *argv[]) char * f_name = "main()"; world.turn = 0; /* Turns to 1 when map and objects are initalized. */ + /* Initialize commands and map object actions. */ init_command_db(); set_cleanup_flag(CLEANUP_COMMAND_DB); + init_map_object_actions(); + set_cleanup_flag(CLEANUP_MAPOBJACTS); /* Check for corrupted savefile / recordfile savings. */ char * recordfile = "record"; @@ -123,12 +126,14 @@ int main(int argc, char *argv[]) exit_err(write_uint32_bigendian(world.seed, file), err_w); try_fclose_unlink_rename(file, recordfile_tmp, recordfile, f_name); } + world.mapseed = world.seed; } /* Generate map from seed and, if newly generated world, start positions of * actors. */ - rrand_seed(world.seed); + uint32_t restore_seed = world.seed; + world.seed = world.mapseed; struct Map map = init_map(); world.map = ↦ set_cleanup_flag(CLEANUP_MAP); @@ -144,20 +149,17 @@ int main(int argc, char *argv[]) set_cleanup_flag(CLEANUP_MAP_OBJECTS); world.turn = 1; } + world.seed = restore_seed; /* Initialize window system and windows. */ - WINDOW * screen = initscr(); + init_win_meta(); set_cleanup_flag(CLEANUP_NCURSES); noecho(); curs_set(0); - keypad(screen, TRUE); + keypad(world.wmeta->screen, TRUE); raw(); - char * err_winmem = "Trouble with init_win_meta() in main ()."; - exit_err(init_win_meta(screen, &world.wmeta), err_winmem); - set_cleanup_flag(CLEANUP_WIN_META); - load_interface_conf(/*&world*/); - set_cleanup_flag(CLEANUP_INTERFACE_CONF); - err_winmem = "Trouble with draw_all_wins() in main()."; + load_interface_conf(); + set_cleanup_flag(CLEANUP_INTERFACE); /* Focus map on player. */ struct MapObj * player = get_player(); @@ -182,7 +184,8 @@ int main(int argc, char *argv[]) { break; } - if (is_command_id_shortdsc(action, "drop")) + if ( is_command_id_shortdsc(action, "drop") + || is_command_id_shortdsc(action, "use")) { world.inventory_select = getc(file); } @@ -191,7 +194,7 @@ int main(int argc, char *argv[]) } while (1) { - draw_all_wins(world.wmeta); + draw_all_wins(); key = getch(); wc = get_winconf_by_win(world.wmeta->active); if ( (1 == wc->view && wingeom_control(key)) @@ -205,7 +208,8 @@ int main(int argc, char *argv[]) action = getc(file); if (EOF != action) { - if (is_command_id_shortdsc(action, "drop")) + if ( is_command_id_shortdsc(action, "drop") + || is_command_id_shortdsc(action, "use")) { world.inventory_select = getc(file); } @@ -226,7 +230,7 @@ int main(int argc, char *argv[]) while (1) { save_game(); - draw_all_wins(world.wmeta); + draw_all_wins(); key = getch(); wc = get_winconf_by_win(world.wmeta->active); if ( (1 == wc->view && wingeom_control(key))