From 4e5fa4db0b325e1f0f3a0e07549e26b5ef77dc2f Mon Sep 17 00:00:00 2001 From: Jakob Fries Date: Fri, 1 Jun 2007 11:17:10 +0000 Subject: [PATCH] --- default.bam | 2 +- src/engine/client/client.cpp | 4 ++-- src/engine/config.cpp | 15 +++++++++------ src/engine/config.h | 9 +++++---- src/game/client/menu.cpp | 16 ++++++++-------- src/main.cpp | 36 ------------------------------------ 6 files changed, 25 insertions(+), 57 deletions(-) delete mode 100644 src/main.cpp diff --git a/default.bam b/default.bam index 449a8e307..01128ae2e 100644 --- a/default.bam +++ b/default.bam @@ -47,7 +47,7 @@ settings.cc.flags = "-Wall" settings.cc.includes:add("src") settings.cc.includes:add("../baselib/src/external/zlib") -engine = Compile(settings, Collect("src/engine/*.cpp", "src/engine/config/*.cpp")) +engine = Compile(settings, Collect("src/engine/*.cpp")) client = Compile(settings, Collect("src/engine/client/*.cpp", "src/engine/client/pnglite/*.c")) server = Compile(settings, Collect("src/engine/server/*.cpp")) game_shared = Compile(settings, Collect("src/game/*.cpp")) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 3f7656457..de61ec09a 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include using namespace baselib; @@ -695,7 +695,7 @@ int main(int argc, char **argv) { // -n NAME i++; - set_player_name(&config, argv[i]); + config_set_player_name(&config, argv[i]); } else if(argv[i][0] == '-' && argv[i][1] == 'w' && argv[i][2] == 0) { diff --git a/src/engine/config.cpp b/src/engine/config.cpp index 844158c15..f38be184e 100644 --- a/src/engine/config.cpp +++ b/src/engine/config.cpp @@ -12,12 +12,10 @@ void config_reset() #define MACRO_CONFIG_INT(name,def,min,max) config.name = def; #define MACRO_CONFIG_STR(name,len,def) strncpy(config.name, def, len); - #include "config_define.h" + #include "config_variables.h" #undef MACRO_CONFIG_INT #undef MACRO_CONFIG_STR - - puts("woaaa"); } void config_load(const char *filename) @@ -25,8 +23,13 @@ void config_load(const char *filename) dbg_msg("config/load", "loading %s", filename); } -#define MACRO_CONFIG_INT(name,def,min,max) void set_ ## name (configuration *c, int val) { if (val < min) val = min; if (max != 0 && val > max) val = max; c->name = val; } -#define MACRO_CONFIG_STR(name,len,def) void set_ ## name (configuration *c, char *str) { strncpy(c->name, def, len-1); c->name[sizeof(c->name)-1] = 0; } -#include "config_define.h" +void config_save(const char *filename) +{ + dbg_msg("config/save", "saving config to %s", filename); +} + +#define MACRO_CONFIG_INT(name,def,min,max) void config_set_ ## name (configuration *c, int val) { if (val < min) val = min; if (max != 0 && val > max) val = max; c->name = val; } +#define MACRO_CONFIG_STR(name,len,def) void config_set_ ## name (configuration *c, char *str) { strncpy(c->name, def, len-1); c->name[sizeof(c->name)-1] = 0; } +#include "config_variables.h" #undef MACRO_CONFIG_INT #undef MACRO_CONFIG_STR diff --git a/src/engine/config.h b/src/engine/config.h index c1a356a53..04140bf5d 100644 --- a/src/engine/config.h +++ b/src/engine/config.h @@ -5,7 +5,7 @@ struct configuration { #define MACRO_CONFIG_INT(name,def,min,max) int name; #define MACRO_CONFIG_STR(name,len,def) char name[len]; - #include "config_define.h" + #include "config_variables.h" #undef MACRO_CONFIG_INT #undef MACRO_CONFIG_STR }; @@ -14,10 +14,11 @@ extern configuration config; void config_reset(); void config_load(const char *filename); +void config_save(const char *filename); -#define MACRO_CONFIG_INT(name,def,min,max) void set_ ## name (configuration *c, int val); -#define MACRO_CONFIG_STR(name,len,def) void set_ ## name (configuration *c, char *str); -#include "config_define.h" +#define MACRO_CONFIG_INT(name,def,min,max) void config_set_ ## name (configuration *c, int val); +#define MACRO_CONFIG_STR(name,len,def) void config_set_ ## name (configuration *c, char *str); +#include "config_variables.h" #undef MACRO_CONFIG_INT #undef MACRO_CONFIG_STR diff --git a/src/game/client/menu.cpp b/src/game/client/menu.cpp index 3c3c98e7d..35ee66af2 100644 --- a/src/game/client/menu.cpp +++ b/src/game/client/menu.cpp @@ -14,7 +14,7 @@ #include #include "mapres_image.h" #include "mapres_tilemap.h" -#include +#include using namespace baselib; @@ -852,15 +852,15 @@ static int settings_screen_render() // KEYS ui_do_label(column1_x, keys_y, "Keys:", 36); ui_do_label(column2_x, keys_y + 0, "Move Left:", 36); - set_key_move_left(&config_copy, ui_do_key_reader(&config_copy.key_move_left, column3_x, keys_y + 0, 70, 40, config_copy.key_move_left)); + config_set_key_move_left(&config_copy, ui_do_key_reader(&config_copy.key_move_left, column3_x, keys_y + 0, 70, 40, config_copy.key_move_left)); ui_do_label(column2_x, keys_y + 40, "Move Right:", 36); - set_key_move_right(&config_copy, ui_do_key_reader(&config_copy.key_move_right, column3_x, keys_y + 40, 70, 40, config_copy.key_move_right)); + config_set_key_move_right(&config_copy, ui_do_key_reader(&config_copy.key_move_right, column3_x, keys_y + 40, 70, 40, config_copy.key_move_right)); ui_do_label(column2_x, keys_y + 80, "Jump:", 36); - set_key_jump(&config_copy, ui_do_key_reader(&config_copy.key_jump, column3_x, keys_y + 80, 70, 40, config_copy.key_jump)); + config_set_key_jump(&config_copy, ui_do_key_reader(&config_copy.key_jump, column3_x, keys_y + 80, 70, 40, config_copy.key_jump)); ui_do_label(column2_x, keys_y + 120, "Fire:", 36); - set_key_fire(&config_copy, ui_do_key_reader(&config_copy.key_fire, column3_x, keys_y + 120, 70, 40, config_copy.key_fire)); + config_set_key_fire(&config_copy, ui_do_key_reader(&config_copy.key_fire, column3_x, keys_y + 120, 70, 40, config_copy.key_fire)); ui_do_label(column2_x, keys_y + 160, "Hook:", 36); - set_key_hook(&config_copy, ui_do_key_reader(&config_copy.key_hook, column3_x, keys_y + 160, 70, 40, config_copy.key_hook)); + config_set_key_hook(&config_copy, ui_do_key_reader(&config_copy.key_hook, column3_x, keys_y + 160, 70, 40, config_copy.key_hook)); // RESOLUTION static char resolutions[][128] = @@ -883,8 +883,8 @@ static int settings_screen_render() ui_do_label(column1_x, resolution_y, "Resolution:", 36); selected_index = ui_do_combo_box(&selected_index, column2_x, resolution_y, 170, (char **)resolutions, 5, selected_index); - set_screen_width(&config_copy, res[selected_index][0]); - set_screen_height(&config_copy, res[selected_index][1]); + config_set_screen_width(&config_copy, res[selected_index][0]); + config_set_screen_height(&config_copy, res[selected_index][1]); // SAVE BUTTON static int save_button; diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index d0aeb52a9..000000000 --- a/src/main.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -#include -#include "versions.h" -#include "config.h" - -using namespace baselib; - -extern int client_main(int argc, char **argv); -extern int editor_main(int argc, char **argv); -extern int server_main(int argc, char **argv); - -int main(int argc, char **argv) -{ -// config_reset(); -// config_load("teewars.cfg"); - kldfjg - - // search for server or editor argument - for(int i = 1; i < argc; i++) - { - if(argv[i][0] == '-' && argv[i][1] == 'v' && argv[i][2] == 0) - { - printf(TEEWARS_VERSION"\n"); - return 0; - } - else if(argv[i][0] == '-' && argv[i][1] == 's' && argv[i][2] == 0) - return server_main(argc, argv); - else if(argv[i][0] == '-' && argv[i][1] == 'e' && argv[i][2] == 0) - return editor_main(argc, argv); - } - - // no specific parameters, start the client - return client_main(argc, argv); -}