about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/client/gc_client.h1
-rw-r--r--src/game/client/gc_hooks.cpp27
-rw-r--r--src/game/client/gc_menu.cpp107
-rw-r--r--src/game/g_protocol.def3
-rw-r--r--src/game/g_variables.h9
-rw-r--r--src/game/server/gs_server.cpp6
6 files changed, 113 insertions, 40 deletions
diff --git a/src/game/client/gc_client.h b/src/game/client/gc_client.h
index 5c89dc61..e6145954 100644
--- a/src/game/client/gc_client.h
+++ b/src/game/client/gc_client.h
@@ -35,6 +35,7 @@ struct snapstate
 
 extern snapstate netobjects;
 
+extern char server_motd[900]; // FUGLY
 /*
 extern const NETOBJ_PLAYER_CHARACTER *local_character;
 extern const NETOBJ_PLAYER_CHARACTER *local_prev_character;
diff --git a/src/game/client/gc_hooks.cpp b/src/game/client/gc_hooks.cpp
index 7d2e1546..0074bab7 100644
--- a/src/game/client/gc_hooks.cpp
+++ b/src/game/client/gc_hooks.cpp
@@ -456,6 +456,8 @@ void extraproj_reset()
 	extraproj_num = 0;
 }
 
+char server_motd[900] = {0};
+
 extern "C" void modc_message(int msg)
 {
 	if(msg == MSG_CHAT)
@@ -496,6 +498,31 @@ extern "C" void modc_message(int msg)
 			}
 		}
 	}
+	else if(msg == MSG_MOTD)
+	{
+		const char *message = msg_unpack_string();
+
+		/* check for errors and invalid inputs */
+		if(msg_unpack_error())
+			return;
+
+		// process escaping			
+		str_copy(server_motd, message, sizeof(server_motd));
+		for(int i = 0; server_motd[i]; i++)
+		{
+			if(server_motd[i] == '\\')
+			{
+				if(server_motd[i+1] == 'n')
+				{
+					server_motd[i] = ' ';
+					server_motd[i+1] = '\n';
+					i++;
+				}
+			}
+		}
+			
+		dbg_msg("game", "MOTD: %s", server_motd);
+	}
 	else if(msg == MSG_SETINFO)
 	{
 		int cid = msg_unpack_int();
diff --git a/src/game/client/gc_menu.cpp b/src/game/client/gc_menu.cpp
index 046b4f13..d0789d77 100644
--- a/src/game/client/gc_menu.cpp
+++ b/src/game/client/gc_menu.cpp
@@ -28,7 +28,7 @@ extern "C" {
 extern data_container *data;
 
 extern bool menu_active;
-extern bool menu_game_active;
+//extern bool menu_game_active;
 
 static bool need_restart = false;
 
@@ -60,6 +60,8 @@ static vec4 color_tabbar_active = color_tabbar_active_outgame;
 enum
 {
 	PAGE_NEWS=0,
+	PAGE_GAME,
+	PAGE_SERVER_INFO,
 	PAGE_INTERNET,
 	PAGE_LAN,
 	PAGE_FAVORITES,
@@ -67,6 +69,8 @@ enum
 	PAGE_SYSTEM,
 };
 
+static int menu_game_page = PAGE_GAME;
+
 static void ui_draw_browse_icon(int what, const RECT *r)
 {
 	gfx_texture_set(data->images[IMAGE_BROWSEICONS].id);
@@ -464,11 +468,13 @@ static int menu2_render_menubar(RECT r)
 	
 	int active_page = config.ui_page;
 	int new_page = -1;
-	if(menu_game_active)
-		active_page = -1;
+	
+	if(client_state() != CLIENTSTATE_OFFLINE)
+		active_page = menu_game_page;
 	
 	if(client_state() == CLIENTSTATE_OFFLINE)
 	{
+		/* offline menus */
 		if(0) // this is not done yet
 		{
 			ui_vsplit_l(&box, 90.0f, &button, &box);
@@ -477,43 +483,52 @@ static int menu2_render_menubar(RECT r)
 				new_page = PAGE_NEWS;
 			ui_vsplit_l(&box, 30.0f, 0, &box); 
 		}
+
+		ui_vsplit_l(&box, 110.0f, &button, &box);
+		static int internet_button=0;
+		if (ui_do_button(&internet_button, "Internet", active_page==PAGE_INTERNET, &button, ui_draw_menu_tab_button, 0))
+		{
+			client_serverbrowse_refresh(0);
+			new_page = PAGE_INTERNET;
+		}
+
+		ui_vsplit_l(&box, 4.0f, 0, &box);
+		ui_vsplit_l(&box, 90.0f, &button, &box);
+		static int lan_button=0;
+		if (ui_do_button(&lan_button, "LAN", active_page==PAGE_LAN, &button, ui_draw_menu_tab_button, 0))
+		{
+			client_serverbrowse_refresh(1);
+			new_page = PAGE_LAN;
+		}
+
+		if(0) // this one is not done yet
+		{
+			ui_vsplit_l(&box, 4.0f, 0, &box);
+			ui_vsplit_l(&box, 120.0f, &button, &box);
+			static int favorites_button=0;
+			if (ui_do_button(&favorites_button, "Favorites", active_page==PAGE_FAVORITES, &button, ui_draw_menu_tab_button, 0))
+				new_page  = PAGE_FAVORITES;
+		}
+
+
 	}
 	else
 	{
+		/* online menus */
 		ui_vsplit_l(&box, 90.0f, &button, &box);
 		static int game_button=0;
-		if (ui_do_button(&game_button, "Game", menu_game_active, &button, ui_draw_menu_tab_button, 0))
-			menu_game_active = true;
+		if (ui_do_button(&game_button, "Game", active_page==PAGE_GAME, &button, ui_draw_menu_tab_button, 0))
+			new_page = PAGE_GAME;
+
+		ui_vsplit_l(&box, 4.0f, 0, &box);
+		ui_vsplit_l(&box, 140.0f, &button, &box);
+		static int server_info_button=0;
+		if (ui_do_button(&server_info_button, "Server Info", active_page==PAGE_SERVER_INFO, &button, ui_draw_menu_tab_button, 0))
+			new_page = PAGE_SERVER_INFO;
 			
 		ui_vsplit_l(&box, 30.0f, 0, &box);
 	}
 		
-	ui_vsplit_l(&box, 110.0f, &button, &box);
-	static int internet_button=0;
-	if (ui_do_button(&internet_button, "Internet", active_page==PAGE_INTERNET, &button, ui_draw_menu_tab_button, 0))
-	{
-		client_serverbrowse_refresh(0);
-		new_page = PAGE_INTERNET;
-	}
-
-	ui_vsplit_l(&box, 4.0f, 0, &box);
-	ui_vsplit_l(&box, 90.0f, &button, &box);
-	static int lan_button=0;
-	if (ui_do_button(&lan_button, "LAN", active_page==PAGE_LAN, &button, ui_draw_menu_tab_button, 0))
-	{
-		client_serverbrowse_refresh(1);
-		new_page = PAGE_LAN;
-	}
-
-	if(0) // this one is not done yet
-	{
-		ui_vsplit_l(&box, 4.0f, 0, &box);
-		ui_vsplit_l(&box, 120.0f, &button, &box);
-		static int favorites_button=0;
-		if (ui_do_button(&favorites_button, "Favorites", active_page==PAGE_FAVORITES, &button, ui_draw_menu_tab_button, 0))
-			new_page  = PAGE_FAVORITES;
-	}
-
 	/*
 	ui_vsplit_r(&box, 110.0f, &box, &button);
 	static int system_button=0;
@@ -536,8 +551,10 @@ static int menu2_render_menubar(RECT r)
 	
 	if(new_page != -1)
 	{
-		config.ui_page = new_page;
-		menu_game_active = false;
+		if(client_state() == CLIENTSTATE_OFFLINE)
+			config.ui_page = new_page;
+		else
+			menu_game_page = new_page;
 	}
 		
 	return 0;
@@ -1655,7 +1672,6 @@ static void menu2_render_news(RECT main_view)
 	ui_draw_rect(&main_view, color_tabbar_active, CORNER_ALL, 10.0f);
 }
 
-
 static void menu2_render_game(RECT main_view)
 {
 	RECT button;
@@ -1728,6 +1744,18 @@ static void menu2_render_game(RECT main_view)
 	}
 }
 
+void menu2_render_serverinfo(RECT main_view)
+{
+	// render background
+	ui_draw_rect(&main_view, color_tabbar_active, CORNER_ALL, 10.0f);
+	
+	// render motd
+	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);
+	gfx_text(0, view.x, view.y, 16, server_motd, -1);
+}
+
 void menu_do_disconnected()
 {
 	popup = POPUP_NONE;
@@ -1835,8 +1863,15 @@ int menu2_render()
 		menu2_render_menubar(tab_bar);
 			
 		// render current page
-		if(menu_game_active)
-			menu2_render_game(main_view);
+		if(client_state() != CLIENTSTATE_OFFLINE)
+		{
+			if(menu_game_page == PAGE_GAME)
+				menu2_render_game(main_view);
+			else if(menu_game_page == PAGE_SERVER_INFO)
+				menu2_render_serverinfo(main_view);
+			else if(menu_game_page == PAGE_SETTINGS)
+				menu2_render_settings(main_view);
+		}
 		else if(config.ui_page == PAGE_NEWS)
 			menu2_render_news(main_view);
 		else if(config.ui_page == PAGE_INTERNET)
diff --git a/src/game/g_protocol.def b/src/game/g_protocol.def
index 211c21a3..75ae4012 100644
--- a/src/game/g_protocol.def
+++ b/src/game/g_protocol.def
@@ -40,6 +40,9 @@ raw_header
 	enum
 	{
 		MSG_NULL=0,
+		
+		MSG_MOTD, // server -> client, message of the day
+		
 		MSG_SAY, // client -> server
 		MSG_CHAT, // server -> client
 		MSG_SETINFO, // server -> client - contains name, skin and color info
diff --git a/src/game/g_variables.h b/src/game/g_variables.h
index ad3448bf..ce544ea1 100644
--- a/src/game/g_variables.h
+++ b/src/game/g_variables.h
@@ -40,16 +40,17 @@ MACRO_CONFIG_INT(ui_color_alpha, 228, 0, 255)
 
 
 MACRO_CONFIG_INT(sv_warmup, 0, 0, 0)
-MACRO_CONFIG_STR(sv_msg, 512, "")
+MACRO_CONFIG_STR(sv_motd, 900, "")
 MACRO_CONFIG_INT(sv_teamdamage, 0, 0, 1)
 MACRO_CONFIG_STR(sv_maprotation, 512, "")
 MACRO_CONFIG_INT(sv_powerups, 1, 0, 1)
 MACRO_CONFIG_INT(sv_scorelimit, 20, 0, 1000)
 MACRO_CONFIG_INT(sv_timelimit, 0, 0, 1000)
 MACRO_CONFIG_STR(sv_gametype, 32, "dm")
-MACRO_CONFIG_INT(sv_restart, 0, 0, 120)
-MACRO_CONFIG_INT(sv_kick, -1, 0, 0)
 MACRO_CONFIG_INT(sv_tournament_mode, 0, 0, 1)
 
 
-
+/* should be removed as they are commands and not variables */
+MACRO_CONFIG_INT(sv_restart, 0, 0, 120)
+MACRO_CONFIG_STR(sv_msg, 512, "")
+MACRO_CONFIG_INT(sv_kick, -1, 0, 0)
diff --git a/src/game/server/gs_server.cpp b/src/game/server/gs_server.cpp
index c37dac01..bb1b40bb 100644
--- a/src/game/server/gs_server.cpp
+++ b/src/game/server/gs_server.cpp
@@ -2138,6 +2138,12 @@ void mods_connected(int client_id)
 		else
 			players[client_id].team = gameobj->getteam(client_id);
 	}
+	
+	
+	msg_pack_start(MSG_MOTD, MSGFLAG_VITAL);
+	msg_pack_string(config.sv_motd, 900);
+	msg_pack_end();
+	server_send_msg(client_id);
 }
 
 void mods_client_drop(int client_id)