about summary refs log tree commit diff
path: root/src/game/server/game_server.cpp
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-10-04 22:00:10 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-10-04 22:00:10 +0000
commit10812e621a4cf485a62d76444a6af5dec6cc92f1 (patch)
treedc31febf0a946c2dce1d70e792f0e66d3dc2f47e /src/game/server/game_server.cpp
parent855f16c18b724b0e88b495b78a5a5852617958f9 (diff)
downloadzcatch-10812e621a4cf485a62d76444a6af5dec6cc92f1.tar.gz
zcatch-10812e621a4cf485a62d76444a6af5dec6cc92f1.zip
added teamchat
Diffstat (limited to 'src/game/server/game_server.cpp')
-rw-r--r--src/game/server/game_server.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp
index 78b95de3..cf4be747 100644
--- a/src/game/server/game_server.cpp
+++ b/src/game/server/game_server.cpp
@@ -1446,12 +1446,29 @@ void send_chat(int cid, int team, const char *msg)
 	else
 		dbg_msg("chat", "*** %s", msg);
 	
-	msg_pack_start(MSG_CHAT, MSGFLAG_VITAL);
-	msg_pack_int(cid);
-	msg_pack_int(team);
-	msg_pack_string(msg, 512);
-	msg_pack_end();
-	server_send_msg(-1);
+	if(team == -1)
+	{
+		msg_pack_start(MSG_CHAT, MSGFLAG_VITAL);
+		msg_pack_int(cid);
+		msg_pack_int(0);
+		msg_pack_string(msg, 512);
+		msg_pack_end();
+		server_send_msg(-1);
+	}
+	else
+	{
+		msg_pack_start(MSG_CHAT, MSGFLAG_VITAL);
+		msg_pack_int(cid);
+		msg_pack_int(1);
+		msg_pack_string(msg, 512);
+		msg_pack_end();
+				
+		for(int i = 0; i < MAX_CLIENTS; i++)
+		{
+			if(players[i].client_id != -1 && players[i].team == team)
+				server_send_msg(i);
+		}
+	}
 }
 
 void send_set_name(int cid, const char *old_name, const char *new_name)
@@ -1542,6 +1559,10 @@ void mods_message(int msg, int client_id)
 	{
 		int team = msg_unpack_int();
 		const char *text = msg_unpack_string();
+		if(team)
+			team = players[client_id].team;
+		else
+			team = -1;
 		send_chat(client_id, team, text);
 	}
 	else if (msg == MSG_SWITCHTEAM)