/* * Copyright (C) 2002-2007 The Warp Rogue Team * Part of the Warp Rogue Project * * This software is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License. * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY. * * See the license.txt file for more details. */ /* * Module Name: ProgramManager * Description: Program init/shutdown/abort functions */ #include #define Uses_Ui #define Uses_Log #define Uses_Options #define Uses_Npc #define Uses_Career #define Uses_Object #define Uses_Macro #define Uses_Random #define Uses_Area #define Uses_Sector #define Uses_World #define Uses_Pathfinder #define Uses_Terrain #define Uses_Party #define Uses_Util #define Uses_DataFile #define Uses_Quest #define Uses_Script #include "mheader.h" #include "prgman.h" #include "cellpnt.h" #include "cellcave.h" #include "rdb.h" /* * initializes the program */ void program_init(void) { log_erase(); random_init(); cpn_set_rng(random_int); ccd_set_rng(random_int); rdb_set_error_handler(die); load_options(); load_keybindings(); ui_init(); world_init(); area_init(); terrain_init(); object_init(); npc_init(); career_init(); party_init(); sector_init(); quest_init(); script_init(); load_scenario_files(); pathfinder_init(); macro_init(); } /* * program shutdown */ void program_shutdown(void) { pathfinder_clean_up(); party_clean_up(); career_clean_up(); npc_clean_up(); object_clean_up(); terrain_clean_up(); script_clean_up(); quest_clean_up(); area_clean_up(); world_clean_up(); ui_clean_up(); random_clean_up(); exit(EXIT_SUCCESS); } /* * aborts the game in case of an internal program error */ void die(const char *fmt, ...) { va_list vl; static char buffer[STRING_BUFFER_SIZE]; va_start(vl, fmt); vsprintf(buffer, fmt, vl); va_end(vl); log_output(buffer); exit(EXIT_FAILURE); } /* * aborts the game in case of an internal program error * (no data path version) */ void die_no_data_path(const char *fmt, ...) { va_list vl; static char buffer[STRING_BUFFER_SIZE]; va_start(vl, fmt); vsprintf(buffer, fmt, vl); va_end(vl); fprintf(stderr, buffer); exit(EXIT_FAILURE); }