about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-31 13:36:30 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-31 13:36:30 +0000
commit5198d6bf016014dd85c96ebd97147fa3f24bcc7a (patch)
treef1782af9828c727c5292fbfdc5904226b218865b
parent132da5396b83405801e3271094359e8d5b88d5ab (diff)
downloadzcatch-5198d6bf016014dd85c96ebd97147fa3f24bcc7a.tar.gz
zcatch-5198d6bf016014dd85c96ebd97147fa3f24bcc7a.zip
fixed some crashes and added kill and team console commands
-rw-r--r--src/game/client/components/hud.cpp3
-rw-r--r--src/game/client/gameclient.cpp50
-rw-r--r--src/game/client/gameclient.hpp3
3 files changed, 42 insertions, 14 deletions
diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp
index 8344754e..5349401b 100644
--- a/src/game/client/components/hud.cpp
+++ b/src/game/client/components/hud.cpp
@@ -186,6 +186,9 @@ void HUD::render_tunewarning()
 
 void HUD::render_cursor()
 {
+	if(!gameclient.snap.local_character)
+		return;
+		
 	mapscreen_to_group(gameclient.camera->center.x, gameclient.camera->center.y, layers_game_group());
 	gfx_texture_set(data->images[IMAGE_GAME].id);
 	gfx_quads_begin();
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index 813e0ca0..1fde8f18 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -8,27 +8,30 @@
 #include "gc_map_image.hpp"
 
 #include "gameclient.hpp"
-#include "components/killmessages.hpp"
-#include "components/chat.hpp"
-#include "components/motd.hpp"
+
+
+#include "components/binds.hpp"
 #include "components/broadcast.hpp"
+#include "components/camera.hpp"
+#include "components/chat.hpp"
 #include "components/console.hpp"
-#include "components/binds.hpp"
-#include "components/particles.hpp"
-#include "components/menus.hpp"
-#include "components/skins.hpp"
+#include "components/controls.hpp"
+#include "components/damageind.hpp"
+#include "components/debughud.hpp"
+#include "components/effects.hpp"
+#include "components/emoticon.hpp"
 #include "components/flow.hpp"
-#include "components/players.hpp"
+#include "components/hud.hpp"
 #include "components/items.hpp"
+#include "components/killmessages.hpp"
 #include "components/maplayers.hpp"
-#include "components/camera.hpp"
-#include "components/hud.hpp"
-#include "components/debughud.hpp"
-#include "components/controls.hpp"
-#include "components/effects.hpp"
+#include "components/menus.hpp"
+#include "components/motd.hpp"
+#include "components/particles.hpp"
+#include "components/players.hpp"
 #include "components/scoreboard.hpp"
+#include "components/skins.hpp"
 #include "components/sounds.hpp"
-#include "components/emoticon.hpp"
 
 GAMECLIENT gameclient;
 
@@ -51,6 +54,7 @@ static EFFECTS effects;
 static SCOREBOARD scoreboard;
 static SOUNDS sounds;
 static EMOTICON emoticon;
+static DAMAGEIND damageind;
 
 static PLAYERS players;
 static ITEMS items;
@@ -97,6 +101,7 @@ void GAMECLIENT::on_init()
 	effects = &::effects;
 	sounds = &::sounds;
 	motd = &::motd;
+	damageind = &::damageind;
 	
 	// make a list of all the systems, make sure to add them in the corrent render order
 	all.add(skins);
@@ -115,6 +120,7 @@ void GAMECLIENT::on_init()
 	all.add(&players);
 	all.add(&maplayers_foreground);
 	all.add(&particles->render_general);
+	all.add(damageind);
 	all.add(&hud);
 	all.add(&emoticon);
 	all.add(&killmessages);
@@ -140,6 +146,10 @@ void GAMECLIENT::on_init()
 	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));
@@ -720,3 +730,15 @@ void GAMECLIENT::send_kill(int client_id)
 	msg.pack(MSGFLAG_VITAL);
 	client_send_msg();
 }
+
+
+
+void GAMECLIENT::con_team(void *result, void *user_data)
+{
+	((GAMECLIENT*)user_data)->send_switch_team(console_arg_int(result, 0));
+}
+
+void GAMECLIENT::con_kill(void *result, void *user_data)
+{
+	((GAMECLIENT*)user_data)->send_kill(-1);
+}
diff --git a/src/game/client/gameclient.hpp b/src/game/client/gameclient.hpp
index cfcf6a65..5aa37afc 100644
--- a/src/game/client/gameclient.hpp
+++ b/src/game/client/gameclient.hpp
@@ -30,6 +30,9 @@ class GAMECLIENT
 	int predicted_tick;
 	int last_new_predicted_tick;
 
+	static void con_team(void *result, void *user_data);
+	static void con_kill(void *result, void *user_data);
+	
 public:
 
 	// TODO: move this