about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlfred Eriksson <somerunce@gmail.com>2008-09-01 18:17:01 +0000
committerAlfred Eriksson <somerunce@gmail.com>2008-09-01 18:17:01 +0000
commitb649ab6c16c6275c9ef9c21b2971d410ffd5b0db (patch)
treefe8f911031777913a9626081ff4ebdf5b7eba963
parent67aa042dcbf9938896f20f47d2a778761efa4dcc (diff)
downloadzcatch-b649ab6c16c6275c9ef9c21b2971d410ffd5b0db.tar.gz
zcatch-b649ab6c16c6275c9ef9c21b2971d410ffd5b0db.zip
merged teambalance-warning and mini-/maximize-stuff from 0.4.3
-rw-r--r--src/engine/client/ec_gfx.c10
-rw-r--r--src/engine/e_if_gfx.h28
-rw-r--r--src/engine/server/es_server.c16
-rw-r--r--src/game/client/components/hud.cpp20
-rw-r--r--src/game/client/components/hud.hpp1
-rw-r--r--src/game/client/gameclient.cpp6
-rw-r--r--src/game/client/gameclient.hpp1
-rw-r--r--src/game/variables.hpp1
8 files changed, 83 insertions, 0 deletions
diff --git a/src/engine/client/ec_gfx.c b/src/engine/client/ec_gfx.c
index c062ebbd..279194ef 100644
--- a/src/engine/client/ec_gfx.c
+++ b/src/engine/client/ec_gfx.c
@@ -1153,3 +1153,13 @@ void gfx_clip_disable()
 {
 	glDisable(GL_SCISSOR_TEST);
 }
+
+void gfx_minimize()
+{
+	glfwIconifyWindow();
+}
+
+void gfx_maximize()
+{
+	glfwRestoreWindow();
+}
diff --git a/src/engine/e_if_gfx.h b/src/engine/e_if_gfx.h
index acbd4afc..73b1aa22 100644
--- a/src/engine/e_if_gfx.h
+++ b/src/engine/e_if_gfx.h
@@ -221,6 +221,34 @@ void gfx_lines_begin();
 void gfx_lines_draw(float x0, float y0, float x1, float y1);
 
 /*
+	Function: gfx_minimize
+		Minimizes the window.
+		
+	Arguments:
+		arg1 - desc
+	
+	Returns:
+
+	See Also:
+		<other_func>
+*/
+void gfx_minimize();
+
+/*
+	Function: gfx_minimize
+		Maximizes the window.
+		
+	Arguments:
+		arg1 - desc
+	
+	Returns:
+
+	See Also:
+		<other_func>
+*/
+void gfx_maximize();
+
+/*
 	Function: gfx_lines_end
 		TODO
 	
diff --git a/src/engine/server/es_server.c b/src/engine/server/es_server.c
index 62a8921d..afd0b16b 100644
--- a/src/engine/server/es_server.c
+++ b/src/engine/server/es_server.c
@@ -21,6 +21,11 @@
 
 #include <mastersrv/mastersrv.h>
 
+#if defined(CONF_FAMILY_WINDOWS) 
+	#define _WIN32_WINNT 0x0500 
+	#include <windows.h> 
+#endif 
+
 static SNAPBUILD builder;
 
 static int64 game_start_time;
@@ -1152,6 +1157,17 @@ int main(int argc, char **argv)
 	buffer[pos] = 0;
 	chdir(buffer);
 #endif
+#if defined(CONF_FAMILY_WINDOWS)
+	int i;
+	for(i = 1; i < argc; i++)
+	{
+		if(strcmp("-s", argv[i]) == 0 || strcmp("--silent", argv[i]) == 0)
+		{
+			ShowWindow(GetConsoleWindow(), SW_HIDE);
+			break;
+		}
+	}
+#endif
 
 	/* init the engine */
 	dbg_msg("server", "starting...");
diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp
index 762ed1fb..f2c37b83 100644
--- a/src/game/client/components/hud.cpp
+++ b/src/game/client/components/hud.cpp
@@ -183,6 +183,25 @@ void HUD::render_tunewarning()
 	}
 }		
 
+void HUD::render_teambalancewarning()
+{
+	// render prompt about team-balance
+	bool flash = time_get()/(time_freq()/2)%2 == 0;
+	if (gameclient.snap.gameobj && gameclient.snap.gameobj->flags&GAMEFLAG_TEAMS != 0)
+	{	
+		if (config.cl_warning_teambalance && abs(gameclient.snap.team_size[0]-gameclient.snap.team_size[1]) >= 2)
+		{
+			const char *text = "Please balance teams!";
+			if(flash)
+				gfx_text_color(1,1,0.5f,1);
+			else
+				gfx_text_color(0.7f,0.7f,0.2f,1.0f);
+			gfx_text(0x0, 5, 50, 6, text, -1);
+			gfx_text_color(1,1,1,1);
+		}
+	}
+}
+
 void HUD::render_cursor()
 {
 	if(!gameclient.snap.local_character)
@@ -263,5 +282,6 @@ void HUD::on_render()
 	render_fps();
 	render_connectionwarning();
 	render_tunewarning();
+	render_teambalancewarning();
 	render_cursor();
 }
diff --git a/src/game/client/components/hud.hpp b/src/game/client/components/hud.hpp
index f8eb5e8f..15b9e52c 100644
--- a/src/game/client/components/hud.hpp
+++ b/src/game/client/components/hud.hpp
@@ -9,6 +9,7 @@ class HUD : public COMPONENT
 	void render_fps();
 	void render_connectionwarning();
 	void render_tunewarning();
+	void render_teambalancewarning();
 	void render_healthandammo();
 	void render_goals();
 	
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index 6403873a..5efc9413 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -501,6 +501,7 @@ void GAMECLIENT::on_snapshot()
 	{
 		// 1. fetch local player
 		// 2. set him to the center
+		gameclient.snap.team_size[0] = gameclient.snap.team_size[1] = 0;
 		int num = snap_num_items(SNAP_CURRENT);
 		for(int i = 0; i < num; i++)
 		{
@@ -527,6 +528,11 @@ void GAMECLIENT::on_snapshot()
 							gameclient.snap.local_prev_character = (NETOBJ_CHARACTER *)p;
 					}
 				}
+				
+				// calculate team-balance
+				if(info->team != -1)
+					gameclient.snap.team_size[info->team]++;
+				
 			}
 			else if(item.type == NETOBJTYPE_GAME)
 				gameclient.snap.gameobj = (NETOBJ_GAME *)data;
diff --git a/src/game/client/gameclient.hpp b/src/game/client/gameclient.hpp
index 8e3284bf..7f96b4fa 100644
--- a/src/game/client/gameclient.hpp
+++ b/src/game/client/gameclient.hpp
@@ -57,6 +57,7 @@ public:
 		const NETOBJ_PLAYER_INFO *player_infos[MAX_CLIENTS];
 		const NETOBJ_PLAYER_INFO *info_by_score[MAX_CLIENTS];
 		int num_players;
+		int team_size[2];
 	};
 
 	SNAPSTATE snap;
diff --git a/src/game/variables.hpp b/src/game/variables.hpp
index c0852bc4..543e9e1f 100644
--- a/src/game/variables.hpp
+++ b/src/game/variables.hpp
@@ -11,6 +11,7 @@ MACRO_CONFIG_INT(cl_threadsoundloading, 0, 0, 1)
 
 
 MACRO_CONFIG_INT(cl_warning_tuning, 1, 0, 1)
+MACRO_CONFIG_INT(cl_warning_teambalance, 1, 0, 1)
 
 MACRO_CONFIG_INT(cl_mouse_deadzone, 300, 0, 0)
 MACRO_CONFIG_INT(cl_mouse_followfactor, 60, 0, 200)