about summary refs log tree commit diff
path: root/src/game/client
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-09-04 21:36:44 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-09-04 21:36:44 +0000
commitfa266334fd825824d413c7817e1f3331c35e40a0 (patch)
tree2d8ce86721ac7c2feaa511dd4c9318e5f52ea0d7 /src/game/client
parenta9211ffd64291fd22d3bfd6ba796eb2ebe041b6e (diff)
downloadzcatch-fa266334fd825824d413c7817e1f3331c35e40a0.tar.gz
zcatch-fa266334fd825824d413c7817e1f3331c35e40a0.zip
fixed on_console_init and on_save
Diffstat (limited to 'src/game/client')
-rw-r--r--src/game/client/clienthooks.cpp10
-rw-r--r--src/game/client/component.hpp2
-rw-r--r--src/game/client/components/binds.cpp7
-rw-r--r--src/game/client/components/binds.hpp3
-rw-r--r--src/game/client/components/chat.cpp2
-rw-r--r--src/game/client/components/chat.hpp2
-rw-r--r--src/game/client/components/console.cpp2
-rw-r--r--src/game/client/components/console.hpp2
-rw-r--r--src/game/client/components/controls.cpp2
-rw-r--r--src/game/client/components/controls.hpp2
-rw-r--r--src/game/client/components/emoticon.cpp2
-rw-r--r--src/game/client/components/emoticon.hpp2
-rw-r--r--src/game/client/components/scoreboard.cpp2
-rw-r--r--src/game/client/components/scoreboard.hpp2
-rw-r--r--src/game/client/gameclient.cpp24
-rw-r--r--src/game/client/gameclient.hpp2
16 files changed, 39 insertions, 29 deletions
diff --git a/src/game/client/clienthooks.cpp b/src/game/client/clienthooks.cpp
index 3787b489..88a7722a 100644
--- a/src/game/client/clienthooks.cpp
+++ b/src/game/client/clienthooks.cpp
@@ -5,20 +5,14 @@
 #include "gameclient.hpp"
 #include "components/console.hpp"
 
-extern "C" void modc_console_init()
-{
-	//client_console_init();
-}
 
 
-extern "C" void modc_save_config()
-{
-	//binds_save();
-}
 
 // clean hooks
 extern "C" void modc_entergame() {}
 extern "C" void modc_shutdown() {}
+extern "C" void modc_console_init() { gameclient.on_console_init(); }
+extern "C" void modc_save_config() { gameclient.on_save(); }
 extern "C" void modc_init() { gameclient.on_init(); }
 extern "C" void modc_connected() { gameclient.on_connected(); }
 extern "C" void modc_predict() { gameclient.on_predict(); }
diff --git a/src/game/client/component.hpp b/src/game/client/component.hpp
index 8ba4a52b..5d14fa5e 100644
--- a/src/game/client/component.hpp
+++ b/src/game/client/component.hpp
@@ -13,7 +13,9 @@ public:
 	~COMPONENT() {}
 	
 	virtual void on_statechange(int new_state, int old_state) {};
+	virtual void on_console_init() {};
 	virtual void on_init() {};
+	virtual void on_save() {};
 	virtual void on_reset() {};
 	virtual void on_render() {};
 	virtual void on_message(int msg, void *rawmsg) {}
diff --git a/src/game/client/components/binds.cpp b/src/game/client/components/binds.cpp
index 7fd318ab..7fa5da5e 100644
--- a/src/game/client/components/binds.cpp
+++ b/src/game/client/components/binds.cpp
@@ -92,7 +92,7 @@ void BINDS::set_defaults()
 	bind('Y', "chat team");	
 }
 
-void BINDS::on_init()
+void BINDS::on_console_init()
 {
 	// bindings
 	MACRO_REGISTER_COMMAND("bind", "sr", con_bind, this);
@@ -176,8 +176,7 @@ int BINDS::get_key_id(const char *key_name)
 	return 0;
 }
 
-/*
-void binds_save()
+void BINDS::on_save()
 {
 	char buffer[256];
 	char *end = buffer+sizeof(buffer)-8;
@@ -204,5 +203,3 @@ void binds_save()
 		client_save_line(buffer);
 	}
 }
-
-*/
diff --git a/src/game/client/components/binds.hpp b/src/game/client/components/binds.hpp
index 5b53b194..1c9bf388 100644
--- a/src/game/client/components/binds.hpp
+++ b/src/game/client/components/binds.hpp
@@ -28,6 +28,7 @@ public:
 	void unbindall();
 	const char *get(int keyid);
 	
-	virtual void on_init();
+	virtual void on_save();
+	virtual void on_console_init();
 	virtual bool on_input(INPUT_EVENT e);
 };
diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp
index 017a5d74..27defd24 100644
--- a/src/game/client/components/chat.cpp
+++ b/src/game/client/components/chat.cpp
@@ -39,7 +39,7 @@ void CHAT::con_chat(void *result, void *user_data)
 		dbg_msg("console", "expected all or team as mode");
 }
 
-void CHAT::on_init()
+void CHAT::on_console_init()
 {
 	MACRO_REGISTER_COMMAND("say", "r", con_say, this);
 	MACRO_REGISTER_COMMAND("say_team", "r", con_sayteam, this);
diff --git a/src/game/client/components/chat.hpp b/src/game/client/components/chat.hpp
index 12d3be96..211b3085 100644
--- a/src/game/client/components/chat.hpp
+++ b/src/game/client/components/chat.hpp
@@ -46,7 +46,7 @@ public:
 	
 	void say(int team, const char *line);
 	
-	virtual void on_init();
+	virtual void on_console_init();
 	virtual void on_reset();
 	virtual void on_render();
 	virtual void on_message(int msgtype, void *rawmsg);
diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp
index 77b85c97..a5098ce1 100644
--- a/src/game/client/components/console.cpp
+++ b/src/game/client/components/console.cpp
@@ -358,7 +358,7 @@ void CONSOLE::print_line(int type, const char *line)
 		remote_console.print_line(line);
 }
 
-void CONSOLE::on_init()
+void CONSOLE::on_console_init()
 {
 	//
 	console_register_print_callback(client_console_print_callback, this);
diff --git a/src/game/client/components/console.hpp b/src/game/client/components/console.hpp
index a13a1d65..c3826058 100644
--- a/src/game/client/components/console.hpp
+++ b/src/game/client/components/console.hpp
@@ -50,7 +50,7 @@ public:
 
 	void print_line(int type, const char *line);
 
-	virtual void on_init();
+	virtual void on_console_init();
 	virtual void on_reset();
 	virtual void on_render();
 	virtual void on_message(int msgtype, void *rawmsg);
diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp
index 6cb89836..208cad5e 100644
--- a/src/game/client/components/controls.cpp
+++ b/src/game/client/components/controls.cpp
@@ -46,7 +46,7 @@ static void con_key_input_nextprev_weapon(void *result, void *user_data)
 	set->controls->input_data.wanted_weapon = 0;
 }
 
-void CONTROLS::on_init()
+void CONTROLS::on_console_init()
 {
 	// game commands
 	MACRO_REGISTER_COMMAND("+left", "", con_key_input_state, &input_direction_left);
diff --git a/src/game/client/components/controls.hpp b/src/game/client/components/controls.hpp
index 262fd235..39043f2a 100644
--- a/src/game/client/components/controls.hpp
+++ b/src/game/client/components/controls.hpp
@@ -14,7 +14,7 @@ public:
 	CONTROLS();
 	virtual void on_message(int msg, void *rawmsg);
 	virtual bool on_mousemove(float x, float y);
-	virtual void on_init();
+	virtual void on_console_init();
 	
 	int snapinput(int *data);
 };
diff --git a/src/game/client/components/emoticon.cpp b/src/game/client/components/emoticon.cpp
index af60ac19..ca1d64b7 100644
--- a/src/game/client/components/emoticon.cpp
+++ b/src/game/client/components/emoticon.cpp
@@ -23,7 +23,7 @@ void EMOTICON::con_emote(void *result, void *user_data)
 	((EMOTICON *)user_data)->emote(console_arg_int(result, 0));
 }
 
-void EMOTICON::on_init()
+void EMOTICON::on_console_init()
 {
 	MACRO_REGISTER_COMMAND("+emote", "", con_key_emoticon, this);
 	MACRO_REGISTER_COMMAND("emote", "", con_emote, this);
diff --git a/src/game/client/components/emoticon.hpp b/src/game/client/components/emoticon.hpp
index 22e1c44b..446b4b00 100644
--- a/src/game/client/components/emoticon.hpp
+++ b/src/game/client/components/emoticon.hpp
@@ -18,7 +18,7 @@ public:
 	EMOTICON();
 	
 	virtual void on_reset();
-	virtual void on_init();
+	virtual void on_console_init();
 	virtual void on_render();
 	virtual void on_message(int msgtype, void *rawmsg);
 	virtual bool on_mousemove(float x, float y);
diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp
index 2388c4c3..e0c7765a 100644
--- a/src/game/client/components/scoreboard.cpp
+++ b/src/game/client/components/scoreboard.cpp
@@ -24,7 +24,7 @@ void SCOREBOARD::on_reset()
 	active = false;
 }
 
-void SCOREBOARD::on_init()
+void SCOREBOARD::on_console_init()
 {
 	MACRO_REGISTER_COMMAND("+scoreboard", "", con_key_scoreboard, this);
 }
diff --git a/src/game/client/components/scoreboard.hpp b/src/game/client/components/scoreboard.hpp
index ba5b0a3d..222dab9d 100644
--- a/src/game/client/components/scoreboard.hpp
+++ b/src/game/client/components/scoreboard.hpp
@@ -13,7 +13,7 @@ class SCOREBOARD : public COMPONENT
 public:
 	SCOREBOARD();
 	virtual void on_reset();
-	virtual void on_init();
+	virtual void on_console_init();
 	virtual void on_render();
 };
 
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index 44d297b5..4f18cf65 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -88,7 +88,7 @@ static void load_sounds_thread(void *do_render)
 	}
 }
 
-void GAMECLIENT::on_init()
+void GAMECLIENT::on_console_init()
 {
 	// setup pointers
 	binds = &::binds;
@@ -146,15 +146,23 @@ void GAMECLIENT::on_init()
 	input.add(&emoticon);
 	input.add(controls);
 	input.add(binds);
+		
+	// add the some console commands
+	MACRO_REGISTER_COMMAND("team", "", con_team, this);
+	MACRO_REGISTER_COMMAND("kill", "", con_kill, this);
+			
+	for(int i = 0; i < all.num; i++)
+		all.components[i]->on_console_init();
+}
+
+void GAMECLIENT::on_init()
+{
+
 
 	// init all components
 	for(int i = 0; i < all.num; i++)
 		all.components[i]->on_init();
 	
-	// add the some console commands
-	MACRO_REGISTER_COMMAND("team", "", con_team, this);
-	MACRO_REGISTER_COMMAND("kill", "", con_kill, this);
-	
 	// setup item sizes
 	for(int i = 0; i < NUM_NETOBJTYPES; i++)
 		snap_set_staticsize(i, netobj_get_size(i));
@@ -197,6 +205,12 @@ void GAMECLIENT::on_init()
 	
 }
 
+void GAMECLIENT::on_save()
+{
+	for(int i = 0; i < all.num; i++)
+		all.components[i]->on_save();
+}
+
 void GAMECLIENT::dispatch_input()
 {
 	// handle mouse movement
diff --git a/src/game/client/gameclient.hpp b/src/game/client/gameclient.hpp
index 7f96b4fa..6be67284 100644
--- a/src/game/client/gameclient.hpp
+++ b/src/game/client/gameclient.hpp
@@ -90,6 +90,8 @@ public:
 	void on_connected();
 	void on_render();
 	void on_init();
+	void on_save();
+	void on_console_init();
 	void on_statechange(int new_state, int old_state);
 	void on_message(int msgtype);
 	void on_snapshot();