Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "audio.h"
00026 #include "event_handler.h"
00027 #include "game.h"
00028 #include "gamedata.h"
00029 #include "gametime.h"
00030 #include "input.h"
00031 #include "nls.h"
00032 #include "python_class.h"
00033 #include "screen.h"
00034 #include "yarg.h"
00035 #include "win_manager.h"
00036
00037 #ifdef MEMORY_LEAKS
00038 #include <mcheck.h>
00039 #endif
00040
00041 using namespace std;
00042
00043
00044
00045
00046 extern "C"
00047 {
00048
00049
00050
00051
00052 void init_adonthell (void);
00053 }
00054
00055 bool init_python()
00056 {
00057
00058
00059 string t;
00060 t = game::global_data_dir() + "/modules";
00061 python::insert_path ((char *) t.c_str());
00062
00063
00064 t = game::game_data_dir () + "/scripts/modules";
00065 python::insert_path ((char *) t.c_str ());
00066 t = game::game_data_dir () + "/scripts";
00067 python::insert_path ((char *) t.c_str ());
00068
00069
00070
00071 init_adonthell ();
00072
00073 python::module = python::import_module ("adonthell");
00074 if (!python::module) return false;
00075
00076 data::globals = PyModule_GetDict (python::module);
00077
00078 return true;
00079 }
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 extern "C"
00094 int main(int argc, char * argv[])
00095 {
00096 config myconfig;
00097
00098 #ifdef MEMORY_LEAKS
00099
00100
00101 mtrace ();
00102 #endif
00103
00104
00105 #if !defined (SINGLE_DIR_INST)
00106 game::init (DATA_DIR);
00107 #else
00108
00109 if (argc && argv[0])
00110 {
00111 char *str = argv[0];
00112 do if (*str == '\\') *str = '/';
00113 while (*(str++));
00114
00115 str = strrchr (argv[0], '/');
00116 *(str + 1) = 0;
00117 chdir (argv[0]);
00118
00119
00120 myconfig.gamedir = string (argv[0]) + "/games/wastesedge";
00121
00122 *(str + 1) = '/';
00123 }
00124
00125
00126 char buf[500];
00127 getcwd (buf, sizeof (buf));
00128
00129 char *str = buf;
00130 do if (*str == '\\') *str = '/';
00131 while (*(str++));
00132
00133 game::init (buf);
00134 #endif
00135
00136
00137
00138 myconfig.read_adonthellrc ();
00139 myconfig.parse_arguments (argc, argv);
00140
00141
00142 nls::init (myconfig);
00143
00144 game::set_game_data_dir(myconfig.gamedir);
00145
00146
00147 gamedata::init (game::user_data_dir(), game::game_data_dir(),
00148 myconfig.game_name, myconfig.quick_load);
00149
00150
00151 screen::set_video_mode (320, 240, 0, myconfig.double_screen, myconfig.screen_mode);
00152
00153 #ifdef DEBUG
00154 printf("%s\n", screen::info().c_str());
00155 #endif
00156
00157
00158 if (myconfig.audio_volume > 0)
00159 audio::init (&myconfig);
00160
00161
00162 input::init ();
00163
00164
00165 python::init ();
00166 init_python();
00167
00168
00169 data::engine = new adonthell;
00170 data::the_player = NULL;
00171
00172
00173 win_manager::init (myconfig.font);
00174
00175
00176 event_handler::init ();
00177
00178
00179
00180 gametime::init (180);
00181
00182
00183 yarg::init (myconfig.game_name);
00184 yarg::randomize ();
00185
00186
00187 python::exec_file ("init");
00188
00189
00190
00191 win_manager::cleanup ();
00192
00193
00194 input::shutdown ();
00195
00196
00197 audio::cleanup ();
00198
00199
00200 gamedata::cleanup ();
00201
00202
00203 delete data::engine;
00204 if (data::the_player)
00205 delete data::the_player;
00206
00207
00208 event_handler::cleanup ();
00209
00210
00211 python::cleanup ();
00212
00213
00214 SDL_Quit ();
00215
00216 return 0;
00217 }