diff options
Diffstat (limited to 'src/engine/client')
| -rw-r--r-- | src/engine/client/client.c | 105 | ||||
| -rw-r--r-- | src/engine/client/gfx.c | 12 | ||||
| -rw-r--r-- | src/engine/client/srvbrowse.c | 20 |
3 files changed, 43 insertions, 94 deletions
diff --git a/src/engine/client/client.c b/src/engine/client/client.c index df53d142..3246a7d6 100644 --- a/src/engine/client/client.c +++ b/src/engine/client/client.c @@ -6,6 +6,7 @@ #include <math.h> #include <engine/system.h> +#include <engine/engine.h> #include <engine/interface.h> #include "ui.h" @@ -301,7 +302,6 @@ static void client_send_error(const char *error) */ } - void client_rcon(const char *cmd) { msg_pack_start_system(NETMSG_CMD, MSGFLAG_VITAL); @@ -452,10 +452,10 @@ static void client_debug_render() static int64 last_snap = 0; static float frametime_avg = 0; char buffer[512]; - + if(!config.debug) return; - + gfx_blend_normal(); gfx_texture_set(debug_font); gfx_mapscreen(0,0,gfx_screenwidth(),gfx_screenheight()); @@ -478,7 +478,6 @@ static void client_debug_render() (int)(1.0f/frametime_avg)); gfx_quads_text(2, 2, 16, buffer); - /* render graphs */ gfx_mapscreen(0,0,400.0f,300.0f); graph_render(&predict_graph, 300, 10, 90, 50); @@ -596,12 +595,6 @@ static void client_process_packet(NETPACKET *packet) dbg_msg("client/network", "loading done"); client_send_ready(); modc_connected(); - - /* - modc_entergame(); - client_send_entergame(); - */ - /*client_on_enter_game();*/ } else { @@ -739,11 +732,6 @@ static void client_process_packet(NETPACKET *packet) /* add new */ snapstorage_add(&snapshot_storage, game_tick, time_get(), snapsize, (SNAPSHOT*)tmpbuffer3); - /*SNAPSTORAGE_HOLDER *snap = client_snapshot_add(game_tick, time_get(), tmpbuffer3, snapsize); */ - - /*int ncrc = snapshot_crc((snapshot*)tmpbuffer3); */ - /*if(crc != ncrc) */ - /* dbg_msg("client", "client snapshot crc failure %d %d", crc, ncrc); */ /* apply snapshot, cycle pointers */ recived_snapshots++; @@ -818,7 +806,7 @@ static void client_pump_network() client_process_packet(&packet); } -static void client_run(const char *direct_connect_server) +static void client_run() { NETADDR4 bindaddr; int64 reporttime = time_get(); @@ -832,15 +820,13 @@ static void client_run(const char *direct_connect_server) if(!gfx_init()) return; - snd_init(); /* sound is allowed to fail */ + /* sound is allowed to fail */ + snd_init(); /* load data */ if(!client_load_data()) return; - /* init menu */ - modmenu_init(); /* TODO: remove */ - /* init the mod */ modc_init(); dbg_msg("client", "version %s", modc_net_version()); @@ -850,14 +836,15 @@ static void client_run(const char *direct_connect_server) net = netclient_open(bindaddr, 0); /* connect to the server if wanted */ - if(direct_connect_server) - client_connect(direct_connect_server); + if(config.cl_connect) + client_connect(config.cl_connect); inp_mouse_mode_relative(); while (1) { int64 frame_start_time = time_get(); + frames++; /* switch snapshot */ if(recived_snapshots >= 3) @@ -865,9 +852,6 @@ static void client_run(const char *direct_connect_server) int repredict = 0; int64 now = st_get(&game_time, time_get()); - frames++; - - /*int64 now = time_get(); */ while(1) { SNAPSTORAGE_HOLDER *cur = snapshots[SNAP_CURRENT]; @@ -923,8 +907,6 @@ static void client_run(const char *direct_connect_server) client_send_input(); } } - - /*intrapredtick = current_predtick */ /* only do sane predictions */ if(repredict) @@ -968,7 +950,7 @@ static void client_run(const char *direct_connect_server) if(inp_key_down(config.key_screenshot)) gfx_screenshot(); - /* panic button */ + /* some debug keys */ if(config.debug) { if(inp_key_pressed(KEY_F1)) @@ -1034,8 +1016,6 @@ static void client_run(const char *direct_connect_server) modc_shutdown(); client_disconnect(); - modmenu_shutdown(); /* TODO: remove this */ - gfx_shutdown(); snd_shutdown(); } @@ -1043,70 +1023,17 @@ static void client_run(const char *direct_connect_server) int editor_main(int argc, char **argv); -/*client main_client; */ -/* -const char *user_directory() -{ - static char path[512] = {0}; - -}*/ - - - int main(int argc, char **argv) { -#ifdef CONF_PLATFORM_MACOSX - const char *config_filename = "~/.teewars"; -#else - const char *config_filename = "default.cfg"; -#endif - int i; - const char *direct_connect_server = 0x0; - int editor = 0; - + /* init the engine */ dbg_msg("client", "starting..."); + engine_init("Teewars", argc, argv); - config_reset(); - - for(i = 1; i < argc; i++) - { - if(argv[i][0] == '-' && argv[i][1] == 'f' && argv[i][2] == 0 && argc - i > 1) - { - config_filename = argv[i+1]; - i++; - } - } - - config_load(config_filename); - - snd_set_master_volume(config.volume / 255.0f); - - /* init network, need to be done first so we can do lookups */ - net_init(); - - /* parse arguments */ - for(i = 1; i < argc; i++) - { - if(argv[i][0] == '-' && argv[i][1] == 'c' && argv[i][2] == 0 && argc - i > 1) - { - /* -c SERVER:PORT */ - i++; - direct_connect_server = argv[i]; - } - else if(argv[i][0] == '-' && argv[i][1] == 'e' && argv[i][2] == 0) - { - editor = 1; - } - else - config_set(argv[i]); - } - - if(editor) + if(config.cl_editor) editor_main(argc, argv); else - { - /* start the client */ - client_run(direct_connect_server); - } + client_run(); + + engine_writeconfig(); return 0; } diff --git a/src/engine/client/gfx.c b/src/engine/client/gfx.c index 31a87611..58dc050b 100644 --- a/src/engine/client/gfx.c +++ b/src/engine/client/gfx.c @@ -3,6 +3,7 @@ #include <engine/system.h> #include <engine/interface.h> +#include <engine/engine.h> #include <engine/config.h> #include <engine/keys.h> @@ -530,16 +531,18 @@ void gfx_swap() /* find filename */ { - char filename[64]; + char wholepath[1024]; + char filename[128]; static int index = 1; png_t png; for(; index < 1000; index++) { IOHANDLE io; - sprintf(filename, "screenshot%04d.png", index); - io = io_open(filename, IOFLAG_READ); + sprintf(filename, "screenshots/screenshot%04d.png", index); + engine_savepath(filename, wholepath, sizeof(wholepath)); + io = io_open(wholepath, IOFLAG_READ); if(io) io_close(io); else @@ -547,7 +550,8 @@ void gfx_swap() } /* save png */ - png_open_file_write(&png, filename); + dbg_msg("client", "saved screenshot to '%s'", wholepath); + png_open_file_write(&png, wholepath); png_set_data(&png, w, h, 8, PNG_TRUECOLOR, (unsigned char *)pixel_data); png_close_file(&png); } diff --git a/src/engine/client/srvbrowse.c b/src/engine/client/srvbrowse.c index 471fdfd6..b3ff635a 100644 --- a/src/engine/client/srvbrowse.c +++ b/src/engine/client/srvbrowse.c @@ -94,6 +94,20 @@ static int client_serverbrowse_sort_compare_ping(const void *ai, const void *bi) return a->info.latency > b->info.latency; } +static int client_serverbrowse_sort_compare_gametype(const void *ai, const void *bi) +{ + SERVERENTRY *a = serverlist[*(const int*)ai]; + SERVERENTRY *b = serverlist[*(const int*)bi]; + return a->info.game_type > b->info.game_type; +} + +static int client_serverbrowse_sort_compare_progression(const void *ai, const void *bi) +{ + SERVERENTRY *a = serverlist[*(const int*)ai]; + SERVERENTRY *b = serverlist[*(const int*)bi]; + return a->info.progression > b->info.progression; +} + static int client_serverbrowse_sort_compare_numplayers(const void *ai, const void *bi) { SERVERENTRY *a = serverlist[*(const int*)ai]; @@ -139,7 +153,7 @@ static void client_serverbrowse_filter() static int client_serverbrowse_sorthash() { - int i = config.b_sort&3; + int i = config.b_sort&0xf; i |= config.b_filter_empty<<4; i |= config.b_filter_full<<5; i |= config.b_filter_pw<<6; @@ -162,6 +176,10 @@ static void client_serverbrowse_sort() qsort(sorted_serverlist, num_sorted_servers, sizeof(int), client_serverbrowse_sort_compare_map); else if(config.b_sort == BROWSESORT_NUMPLAYERS) qsort(sorted_serverlist, num_sorted_servers, sizeof(int), client_serverbrowse_sort_compare_numplayers); + else if(config.b_sort == BROWSESORT_GAMETYPE) + qsort(sorted_serverlist, num_sorted_servers, sizeof(int), client_serverbrowse_sort_compare_gametype); + else if(config.b_sort == BROWSESORT_PROGRESSION) + qsort(sorted_serverlist, num_sorted_servers, sizeof(int), client_serverbrowse_sort_compare_progression); /* set indexes */ for(i = 0; i < num_sorted_servers; i++) |