summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp94
1 files changed, 45 insertions, 49 deletions
diff --git a/src/main.cpp b/src/main.cpp
index a73e04a8..8721da19 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -88,6 +88,7 @@ unsigned short x, y;
unsigned char direction;
//unsigned short job, hair, hair_color;
unsigned char stretch_mode, screen_mode;
+char *dir;
// new sound-engine /- kth5
TmwSound sound;
@@ -125,7 +126,7 @@ void init_engine() {
init_log();
set_close_button_callback(request_exit);
- char *dir = new char[400];
+ dir = new char[400];
strcpy(dir, "");
#ifndef __USE_UNIX98
@@ -200,20 +201,17 @@ void init_engine() {
config.setValue("remember", 1);
config.setValue("username", "Player");
- config.Write(dir);
+ config.write(dir);
}
}
- //set_config_file(dir);
- config.Init(dir);
+ config.init(dir);
#ifdef WIN32
if(code) {
set_config_string("system", "keyboard", code);
}
#endif
- delete dir; dir = 0;
-
// set_config_file("tmw.ini");
#ifdef MACOSX
set_color_depth(32);
@@ -269,6 +267,8 @@ void init_engine() {
/** Clear the engine */
void exit_engine() {
+ config.write(dir);
+ delete dir;
gui_exit();
destroy_bitmap(buffer);
allegro_exit();
@@ -276,49 +276,45 @@ void exit_engine() {
/** Main */
int main() {
- init_engine();
- // initialize sound-engine and start playing intro-theme /-kth5
- try{
- if(config.getValue("sound", 0)==1)
- sound.Init(32,20); // inits the sound-subsystem w/ 32 voices / 20 for mod
- sound.SetVol(128,128,128); // sets intial volume parameters
- //#ifdef WIN32
- //sound.StartMIDI("Sound/Midis/city.mid",-1); // play a midi file
- //#endif
- //sound.LoadItem("test.wav", TMWSOUND_SFX);
- }catch(const char * err){ // catch errors and show appropriate messages on-screen (elven plz... ^^)
- ok("Sound Engine", err);
- warning(err);
- }
-
- while(state!=EXIT) {
- switch(state) {
- case LOGIN:
- status("LOGIN");
- login();
- break;
- case CHAR_SERVER:
- status("CHAR_SERVER");
- char_server();
- break;
- case CHAR_SELECT:
- status("CHAR_SELECT");
- charSelect();
- break;
- case GAME:
- sound.StopBGM();
- status("GAME");
- map_start();
- if( state==GAME )
- game();
- break;
- default:
- state = EXIT;
- break;
+ init_engine();
+ // initialize sound-engine and start playing intro-theme /-kth5
+ try{
+ if(config.getValue("sound", 0)==1)
+ sound.Init(32,20);
+ sound.SetVol(128,128,128);
+ }catch(const char * err){
+ ok("Sound Engine", err);
+ warning(err);
+ }
+
+ while(state!=EXIT) {
+ switch(state) {
+ case LOGIN:
+ status("LOGIN");
+ login();
+ break;
+ case CHAR_SERVER:
+ status("CHAR_SERVER");
+ char_server();
+ break;
+ case CHAR_SELECT:
+ status("CHAR_SELECT");
+ charSelect();
+ break;
+ case GAME:
+ sound.StopBGM();
+ status("GAME");
+ map_start();
+ if( state==GAME )
+ game();
+ break;
+ default:
+ state = EXIT;
+ break;
+ }
}
- }
- status("EXIT");
- exit_engine();
- return 0;
+ status("EXIT");
+ exit_engine();
+ return 0;
}
END_OF_MAIN();