about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-30 22:38:56 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-30 22:38:56 +0000
commitcd7a3519a7a4e9914906d96b603cefdbf3a58a0e (patch)
tree75d5121c24bc6f449e399a227fcf7553f73e811f /src
parent432602c4ca5d47aee91d25271fa57ad0f6d67250 (diff)
downloadzcatch-cd7a3519a7a4e9914906d96b603cefdbf3a58a0e.tar.gz
zcatch-cd7a3519a7a4e9914906d96b603cefdbf3a58a0e.zip
added the loading screen again
Diffstat (limited to 'src')
-rw-r--r--src/engine/client/ec_gfx.c3
-rw-r--r--src/engine/client/ec_snd.c8
-rw-r--r--src/engine/client/ec_srvbrowse.c3
-rw-r--r--src/game/client/components/chat.cpp2
-rw-r--r--src/game/client/components/chat.hpp3
-rw-r--r--src/game/client/components/console.cpp90
-rw-r--r--src/game/client/components/controls.cpp13
-rw-r--r--src/game/client/components/menus.cpp4
-rw-r--r--src/game/client/components/menus.hpp6
-rw-r--r--src/game/client/components/motd.hpp3
-rw-r--r--src/game/client/components/particles.cpp5
-rw-r--r--src/game/client/gameclient.cpp92
12 files changed, 76 insertions, 156 deletions
diff --git a/src/engine/client/ec_gfx.c b/src/engine/client/ec_gfx.c
index 7b12e15d..d26c0b72 100644
--- a/src/engine/client/ec_gfx.c
+++ b/src/engine/client/ec_gfx.c
@@ -421,9 +421,6 @@ int gfx_load_texture_raw(int w, int h, int format, const void *data, int store_f
 		}
 	}
 	
-	if(config.debug)
-		dbg_msg("gfx", "%d = %dx%d", tex, w, h);
-
 	oglformat = GL_RGBA;
 	if(format == IMG_RGB)
 		oglformat = GL_RGB;
diff --git a/src/engine/client/ec_snd.c b/src/engine/client/ec_snd.c
index f7ab6639..9dcbafaa 100644
--- a/src/engine/client/ec_snd.c
+++ b/src/engine/client/ec_snd.c
@@ -266,7 +266,15 @@ int snd_init()
 
 	params.device = config.snd_device;
 	if(params.device == -1)
+	{
 		params.device = Pa_GetDefaultOutputDevice();
+		if(params.device < 0)
+		{
+			dbg_msg("snd", "no default device (%d)", params.device);
+			return 1;
+		}
+	}
+
 	if(params.device < 0)
 		return 1;
 	dbg_msg("snd", "device = %d", params.device);
diff --git a/src/engine/client/ec_srvbrowse.c b/src/engine/client/ec_srvbrowse.c
index 0cf6b59d..f26ac9e3 100644
--- a/src/engine/client/ec_srvbrowse.c
+++ b/src/engine/client/ec_srvbrowse.c
@@ -152,9 +152,6 @@ static void client_serverbrowse_filter()
 			filtered = 1;
 		else if(config.b_filter_ping < serverlist[i]->info.latency)
 			filtered = 1;
-		/* TODO: repair me
-		else if(!(config.b_filter_gametype&(1 << serverlist[i]->info.game_type)))
-			filtered = 1;*/
 		else if(config.b_filter_compatversion && strncmp(serverlist[i]->info.version, modc_net_version(), 3) != 0)
 			filtered = 1;
 		else if(config.b_filter_string[0] != 0)
diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp
index ca1d6ea5..017a5d74 100644
--- a/src/game/client/components/chat.cpp
+++ b/src/game/client/components/chat.cpp
@@ -87,7 +87,7 @@ void CHAT::on_message(int msgtype, void *rawmsg)
 		NETMSG_SV_CHAT *msg = (NETMSG_SV_CHAT *)rawmsg;
 		add_line(msg->cid, msg->team, msg->message);
 
-		if(msg->cid >= 0) // TODO: repair me
+		if(msg->cid >= 0)
 			gameclient.sounds->play(SOUNDS::CHN_GUI, SOUND_CHAT_CLIENT, 0, vec2(0,0));
 		else
 			gameclient.sounds->play(SOUNDS::CHN_GUI, SOUND_CHAT_SERVER, 0, vec2(0,0));
diff --git a/src/game/client/components/chat.hpp b/src/game/client/components/chat.hpp
index fc21ce1f..12d3be96 100644
--- a/src/game/client/components/chat.hpp
+++ b/src/game/client/components/chat.hpp
@@ -38,10 +38,9 @@ class CHAT : public COMPONENT
 	static void con_chat(void *result, void *user_data);
 	
 public:
+	bool is_active() const { return mode != MODE_NONE; }
 	
 	void add_line(int client_id, int team, const char *line);
-	//void chat_reset();
-	//bool chat_input_handle(INPUT_EVENT e, void *user_data);
 	
 	void enable_mode(int team);
 	
diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp
index fe2ecfa5..77b85c97 100644
--- a/src/game/client/components/console.cpp
+++ b/src/game/client/components/console.cpp
@@ -367,14 +367,6 @@ void CONSOLE::on_init()
 	MACRO_REGISTER_COMMAND("toggle_remote_console", "", con_toggle_remote_console, this);
 }
 
-
-/*
-void console_rcon_print(const char *line)
-{
-	// TODO: repair me
-	//remote_console.print_line(line);
-}*/
-
 /*
 static void con_team(void *result, void *user_data)
 {
@@ -388,34 +380,6 @@ static void con_kill(void *result, void *user_data)
 
 void send_kill(int client_id);
 
-
-
-static void con_key_input_state(void *result, void *user_data)
-{
-	((int *)user_data)[0] = console_arg_int(result, 0);
-}
-
-static void con_key_input_counter(void *result, void *user_data)
-{
-	int *v = (int *)user_data;
-	if(((*v)&1) != console_arg_int(result, 0))
-		(*v)++;
-	*v &= INPUT_STATE_MASK;
-}
-
-static void con_key_input_weapon(void *result, void *user_data)
-{
-	int w = (char *)user_data - (char *)0;
-	if(console_arg_int(result, 0))
-		input_data.wanted_weapon = w;
-}
-
-static void con_key_input_nextprev_weapon(void *result, void *user_data)
-{
-	con_key_input_counter(result, user_data);
-	input_data.wanted_weapon = 0;
-}
-
 static void con_emote(void *result, void *user_data)
 {
 	send_emoticon(console_arg_int(result, 0));
@@ -425,66 +389,12 @@ extern void con_chat(void *result, void *user_data);
 
 void client_console_init()
 {
-	console_register_print_callback(client_console_print);
-
-	//
-	MACRO_REGISTER_COMMAND("toggle_local_console", "", con_toggle_local_console, 0x0);
-	MACRO_REGISTER_COMMAND("toggle_remote_console", "", con_toggle_remote_console, 0x0);
-
 	//
 	MACRO_REGISTER_COMMAND("team", "i", con_team, 0x0);
 	MACRO_REGISTER_COMMAND("kill", "", con_kill, 0x0);
-	
-	// bindings
-	MACRO_REGISTER_COMMAND("bind", "sr", con_bind, 0x0);
-	MACRO_REGISTER_COMMAND("unbind", "s", con_unbind, 0x0);
-	MACRO_REGISTER_COMMAND("unbindall", "", con_unbindall, 0x0);
-	
-	MACRO_REGISTER_COMMAND("dump_binds", "", con_dump_binds, 0x0);
 
 	// chatting
 	MACRO_REGISTER_COMMAND("emote", "i", con_emote, 0);
 	MACRO_REGISTER_COMMAND("+emote", "", con_key_input_state, &emoticon_selector_active);
 }
-
-bool console_input_cli(INPUT_EVENT e, void *user_data)
-{
-	if(!console_active())
-		return false;
-	
-	if(e.key == KEY_ESC && (e.flags&INPFLAG_PRESS))
-		console_toggle(console_type);
-	else
-		current_console()->handle_event(e);
-	return true;
-}
-
-static bool console_execute_event(INPUT_EVENT e)
-{
-	// don't handle invalid events and keys that arn't set to anything
-	if(e.key <= 0 || e.key >= KEY_LAST || keybindings[e.key][0] == 0)
-		return false;
-
-	int stroke = 0;
-	if(e.flags&INPFLAG_PRESS)
-		stroke = 1;
-	console_execute_line_stroked(stroke, keybindings[e.key]);
-	return true;
-}
-
-bool console_input_special_binds(INPUT_EVENT e, void *user_data)
-{
-	// only handle function keys
-	if(e.key < KEY_F1 || e.key > KEY_F25)
-		return false;
-	return console_execute_event(e);
-}
-
-bool console_input_normal_binds(INPUT_EVENT e, void *user_data)
-{
-	// need to be ingame for these binds
-	if(client_state() != CLIENTSTATE_ONLINE)
-		return false;
-	return console_execute_event(e);
-}
 */
diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp
index 15bb1388..0cf8b861 100644
--- a/src/game/client/components/controls.cpp
+++ b/src/game/client/components/controls.cpp
@@ -3,6 +3,8 @@
 #include <game/collision.hpp>
 #include <game/client/gameclient.hpp>
 #include <game/client/component.hpp>
+#include <game/client/components/chat.hpp>
+#include <game/client/components/menus.hpp>
 
 #include "controls.hpp"
 
@@ -69,17 +71,16 @@ int CONTROLS::snapinput(int *data)
 	static int64 last_send_time = 0;
 	
 	// update player state
-	/*if(chat_mode != CHATMODE_NONE) // TODO: repair me
+	if(gameclient.chat->is_active())
 		input_data.player_state = PLAYERSTATE_CHATTING;
-	else if(menu_active)
+	else if(gameclient.menus->is_active())
 		input_data.player_state = PLAYERSTATE_IN_MENU;
 	else
-		input_data.player_state = PLAYERSTATE_PLAYING;*/
+		input_data.player_state = PLAYERSTATE_PLAYING;
 	last_data.player_state = input_data.player_state;
 	
 	// we freeze the input if chat or menu is activated
-	/* repair me
-	if(menu_active || chat_mode != CHATMODE_NONE || console_active())
+	if(input_data.player_state != PLAYERSTATE_PLAYING)
 	{
 		last_data.direction = 0;
 		last_data.hook = 0;
@@ -89,7 +90,7 @@ int CONTROLS::snapinput(int *data)
 			
 		mem_copy(data, &input_data, sizeof(input_data));
 		return sizeof(input_data);
-	}*/
+	}
 	
 	input_data.target_x = (int)mouse_pos.x;
 	input_data.target_y = (int)mouse_pos.y;
diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp
index 4284f84c..6d0cbf38 100644
--- a/src/game/client/components/menus.cpp
+++ b/src/game/client/components/menus.cpp
@@ -22,6 +22,7 @@ extern "C" {
 
 #include <game/generated/gc_data.hpp>
 #include <game/client/components/binds.hpp>
+#include <game/client/components/motd.hpp>
 #include <game/client/gameclient.hpp>
 #include <game/client/animstate.hpp>
 #include <game/client/gc_render.hpp>
@@ -738,8 +739,7 @@ void MENUS::render_serverinfo(RECT main_view)
 	RECT view;
 	ui_margin(&main_view, 10.0f, &view);
 	//void gfx_text(void *font, float x, float y, float size, const char *text, int max_width);
-	// TODO: repair me
-	//gfx_text(0, view.x, view.y, 16, server_motd, -1);
+	gfx_text(0, view.x, view.y, 16, gameclient.motd->server_motd, -1);
 }
 
 void MENUS::init()
diff --git a/src/game/client/components/menus.hpp b/src/game/client/components/menus.hpp
index 71128498..f1c87270 100644
--- a/src/game/client/components/menus.hpp
+++ b/src/game/client/components/menus.hpp
@@ -72,7 +72,7 @@ class MENUS : public COMPONENT
 	// found in menus.cpp
 	int render();
 	void render_background();
-	void render_loading(float percent);
+	//void render_loading(float percent);
 	int render_menubar(RECT r);
 	void render_news(RECT main_view);
 	void render_game(RECT main_view);
@@ -91,6 +91,10 @@ class MENUS : public COMPONENT
 public:
 	MENUS();
 
+	void render_loading(float percent);
+
+	bool is_active() const { return menu_active; }
+
 	void init();
 
 	virtual void on_statechange(int new_state, int old_state);
diff --git a/src/game/client/components/motd.hpp b/src/game/client/components/motd.hpp
index bc2c962e..5ee16086 100644
--- a/src/game/client/components/motd.hpp
+++ b/src/game/client/components/motd.hpp
@@ -4,8 +4,9 @@ class MOTD : public COMPONENT
 {
 	// motd
 	int64 server_motd_time;
-	char server_motd[900]; // FUGLY
 public:
+	char server_motd[900];
+
 	void clear();
 	bool is_active();
 	
diff --git a/src/game/client/components/particles.cpp b/src/game/client/components/particles.cpp
index 0c449263..58af6f55 100644
--- a/src/game/client/components/particles.cpp
+++ b/src/game/client/components/particles.cpp
@@ -1,6 +1,7 @@
 #include <base/math.hpp>
 #include <game/generated/gc_data.hpp>
 #include <game/client/gc_render.hpp>
+#include <game/gamecore.hpp>
 #include "particles.hpp"
 
 PARTICLES::PARTICLES()
@@ -82,9 +83,7 @@ void PARTICLES::update(float time_passed)
 			
 			// move the point
 			vec2 vel = particles[i].vel*time_passed;
-			
-			// TODO: repair me
-			//move_point(&particles[i].pos, &vel, 0.1f+0.9f*frandom(), NULL);
+			move_point(&particles[i].pos, &vel, 0.1f+0.9f*frandom(), NULL);
 			particles[i].vel = vel* (1.0f/time_passed);
 			
 			particles[i].life += time_passed;
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index e808b4be..813e0ca0 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -61,67 +61,29 @@ static MAPLAYERS maplayers_foreground(MAPLAYERS::TYPE_FOREGROUND);
 GAMECLIENT::STACK::STACK() { num = 0; }
 void GAMECLIENT::STACK::add(class COMPONENT *component) { components[num++] = component; }
 
+static int load_current;
+static int load_total;
 
 static void load_sounds_thread(void *do_render)
 {
 	// load sounds
 	for(int s = 0; s < data->num_sounds; s++)
 	{
-		//if(do_render) // TODO: repair me
-			//render_loading(load_current/load_total);
+		if(do_render) // TODO: repair me
+			gameclient.menus->render_loading(load_current/(float)load_total);
 		for(int i = 0; i < data->sounds[s].num_sounds; i++)
 		{
 			int id = snd_load_wv(data->sounds[s].sounds[i].filename);
 			data->sounds[s].sounds[i].id = id;
 		}
 
-		//if(do_render)
-		//	load_current++;
+		if(do_render)
+			load_current++;
 	}
 }
 
 void GAMECLIENT::on_init()
 {
-	// setup item sizes
-	for(int i = 0; i < NUM_NETOBJTYPES; i++)
-		snap_set_staticsize(i, netobj_get_size(i));
-	
-	// load default font	
-	static FONT_SET default_font;
-	int64 start = time_get();
-	
-	int before = gfx_memory_usage();
-	font_set_load(&default_font, "data/fonts/default_font%d.tfnt", "data/fonts/default_font%d.png", "data/fonts/default_font%d_b.png", 14, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 36);
-	dbg_msg("font", "gfx memory used for font textures: %d", gfx_memory_usage()-before);
-	
-	gfx_text_set_default_font(&default_font);
-
-	// setup load amount
-	/*
-	load_total = data->num_images;
-	load_current = 0;
-	if(!config.cl_threadsoundloading)
-		load_total += data->num_sounds;*/
-	
-	// load textures
-	for(int i = 0; i < data->num_images; i++)
-	{
-		// TODO: repair me
-		//render_loading(load_current/load_total);
-		data->images[i].id = gfx_load_texture(data->images[i].filename, IMG_AUTO, 0);
-		//load_current++;
-	}
-
-	gameclient.skins->init();
-	
-	if(config.cl_threadsoundloading)
-		thread_create(load_sounds_thread, 0);
-	else
-		load_sounds_thread((void*)1);
-	
-	int64 end = time_get();
-	dbg_msg("", "%f.2ms", ((end-start)*1000)/(float)time_freq());
-	
 	// setup pointers
 	binds = &::binds;
 	console = &::console;
@@ -177,6 +139,48 @@ void GAMECLIENT::on_init()
 	// init all components
 	for(int i = 0; i < all.num; i++)
 		all.components[i]->on_init();
+	
+	// setup item sizes
+	for(int i = 0; i < NUM_NETOBJTYPES; i++)
+		snap_set_staticsize(i, netobj_get_size(i));
+	
+	// load default font	
+	static FONT_SET default_font;
+	int64 start = time_get();
+	
+	int before = gfx_memory_usage();
+	font_set_load(&default_font, "data/fonts/default_font%d.tfnt", "data/fonts/default_font%d.png", "data/fonts/default_font%d_b.png", 14, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 36);
+	dbg_msg("font", "gfx memory used for font textures: %d", gfx_memory_usage()-before);
+	
+	gfx_text_set_default_font(&default_font);
+
+	config.cl_threadsoundloading = 0;
+
+	// setup load amount
+	load_total = data->num_images;
+	load_current = 0;
+	if(!config.cl_threadsoundloading)
+		load_total += data->num_sounds;
+	
+	// load textures
+	for(int i = 0; i < data->num_images; i++)
+	{
+		// TODO: repair me
+		gameclient.menus->render_loading(load_current/load_total);
+		data->images[i].id = gfx_load_texture(data->images[i].filename, IMG_AUTO, 0);
+		load_current++;
+	}
+
+	::skins.init();
+	
+	if(config.cl_threadsoundloading)
+		thread_create(load_sounds_thread, 0);
+	else
+		load_sounds_thread((void*)1);
+	
+	int64 end = time_get();
+	dbg_msg("", "%f.2ms", ((end-start)*1000)/(float)time_freq());
+	
 }
 
 void GAMECLIENT::dispatch_input()