/* * Hack -- main Angband initialization entry point * * Verify some files, display the "news.txt" file, create * the high score file, initialize all internal arrays, and * load the basic "user pref files". * * Be very careful to keep track of the order in which things * are initialized, in particular, the only thing *known* to * be available when this function is called is the "z-term.c" * package, and that may not be fully initialized until the * end of this function, when the default "user pref files" * are loaded and "Term_xtra(TERM_XTRA_REACT,0)" is called. * * Note that this function attempts to verify the "news" file, * and the game aborts (cleanly) on failure, since without the * "news" file, it is likely that the "lib" folder has not been * correctly located. Otherwise, the news file is displayed for * the user. * * Note that this function attempts to verify (or create) the * "high score" file, and the game aborts (cleanly) on failure, * since one of the most common "extraction" failures involves * failing to extract all sub-directories (even empty ones), such * as by failing to use the "-d" option of "pkunzip", or failing * to use the "save empty directories" option with "Compact Pro". * This error will often be caught by the "high score" creation * code below, since the "lib/apex" directory, being empty in the * standard distributions, is most likely to be "lost", making it * impossible to create the high score file. * * Note that various things are initialized by this function, * including everything that was once done by "init_some_arrays". * * This initialization involves the parsing of special files * in the "lib/edit" directories. * * Note that the "template" files are initialized first, since they * often contain errors. This means that macros and message recall * and things like that are not available until after they are done. * * We load the default "user pref files" here in case any "color" * changes are needed before character creation. * * Note that the "graf-xxx.prf" file must be loaded separately, * if needed, in the first (?) pass through "TERM_XTRA_REACT". */ public static bool init_angband() { Game_Event.signal(Game_Event.Event_Type.ENTER_INIT); /*** Initialize some arrays ***/ Init.arrays(); /*** Load default user pref files ***/ /* Initialize feature info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Loading basic user pref file..."); /* Process that file */ Prefs.process_pref_file("pref.prf", false, false); /* Done */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initialization complete"); /* Sneakily init command list */ Command.Init(); //#ifdef ALLOW_BORG /* apw */ // /* Allow the screensaver to do its work */ // if (screensaver) // { // event_signal(EVENT_LEAVE_INIT); // return !file_exists(savefile); // } //#endif /* ALLOW_BORG */ /* Ask for a "command" until we get one we like. */ while (true) { Game_Command command_req = new Game_Command(); if (Game_Command.get(cmd_context.CMD_INIT, ref command_req, true) == null) { continue; } else if (command_req.command == Command_Code.QUAFF) { Utilities.quit(); } else if (command_req.command == Command_Code.NEWGAME) { Game_Event.signal(Game_Event.Event_Type.LEAVE_INIT); return(true); } else if (command_req.command == Command_Code.LOADFILE) { Game_Event.signal(Game_Event.Event_Type.LEAVE_INIT); return(false); } } }
/* * Initialise just the internal arrays. * This should be callable by the test suite, without relying on input, or * anything to do with a user or savefiles. * * Assumption: Paths are set up correctly before calling this function. */ public static void arrays() { /* Initialize size info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing array sizes..."); if (z_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize sizes"); } /* Initialize feature info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (features)"); if (f_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize features"); } /* Initialize object base info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (object bases)"); if (kb_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize object bases"); } /* Initialize object info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (objects)"); if (k_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize objects"); } /* Initialize ego-item info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (ego-items)"); if (e_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize ego-items"); } /* Initialize artifact info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (artifacts)"); if (a_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize artifacts"); } /* Initialize monster pain messages */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (pain messages)"); if (mp_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize monster pain messages"); } /* Initialize monster-base info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (monster bases)"); if (rb_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize monster bases"); } /* Initialize monster info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (monsters)"); if (r_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize monsters"); } /* Initialize monster pits */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (monster pits)"); if (pit_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize monster pits"); } /* Initialize feature info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (vaults)"); if (v_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize vaults"); } /* Initialize history info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (histories)"); if (h_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize histories"); } /* Initialize race info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (races)"); if (p_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize races"); } /* Initialize class info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (classes)"); if (c_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize classes"); } /* Initialize flavor info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (flavors)"); if (flavor_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize flavors"); } /* Initialize spell info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (spells)"); if (s_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize spells"); } /* Initialize hint text */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (hints)"); if (hints_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Cannot initialize hints"); } /* Initialise store stocking data */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (store stocks)"); Store.Init(); /* Initialise random name data */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (random names)"); if (names_parser.run_parser() != Parser.Error.NONE) { Utilities.quit("Can't parse names"); } /* Initialize some other arrays */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (other)"); if (init_other() != Parser.Error.NONE) { Utilities.quit("Cannot initialize other stuff"); } /* Initialize some other arrays */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initializing arrays... (alloc)"); if (init_alloc() != Parser.Error.NONE) { Utilities.quit("Cannot initialize alloc stuff"); } }