about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2009-06-15 13:01:04 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2009-06-15 13:01:04 +0000
commit8bd49fe30b8663a27e1103f149f6f836866bbfc8 (patch)
tree4243fc55ca2b3a00d765cc4754c8732d2fc422e1 /src/game
parentf817cb231999e51d6721d2b2a3c95d985b08d836 (diff)
downloadzcatch-8bd49fe30b8663a27e1103f149f6f836866bbfc8.tar.gz
zcatch-8bd49fe30b8663a27e1103f149f6f836866bbfc8.zip
some clean up. fixed double server side record messages
Diffstat (limited to 'src/game')
-rw-r--r--src/game/client/components/chat.cpp11
-rw-r--r--src/game/localization.cpp14
-rw-r--r--src/game/server/gamecontext.cpp7
3 files changed, 15 insertions, 17 deletions
diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp
index a03aab65..37015337 100644
--- a/src/game/client/components/chat.cpp
+++ b/src/game/client/components/chat.cpp
@@ -89,11 +89,6 @@ void CHAT::on_message(int msgtype, void *rawmsg)
 	{
 		NETMSG_SV_CHAT *msg = (NETMSG_SV_CHAT *)rawmsg;
 		add_line(msg->cid, msg->team, msg->message);
-
-		if(msg->cid >= 0)
-			gameclient.sounds->play(SOUNDS::CHN_GUI, SOUND_CHAT_CLIENT, 0, vec2(0,0));
-		else
-			gameclient.sounds->play(SOUNDS::CHN_GUI, SOUND_CHAT_SERVER, 0, vec2(0,0));
 	}
 }
 
@@ -127,6 +122,12 @@ void CHAT::add_line(int client_id, int team, const char *line)
 		str_format(lines[current_line].text, sizeof(lines[current_line].text), ": %s", line);
 	}
 	
+	// play sound
+	if(client_id >= 0)
+		gameclient.sounds->play(SOUNDS::CHN_GUI, SOUND_CHAT_CLIENT, 0, vec2(0,0));
+	else
+		gameclient.sounds->play(SOUNDS::CHN_GUI, SOUND_CHAT_SERVER, 0, vec2(0,0));
+	
 	dbg_msg("chat", "%s%s", lines[current_line].name, lines[current_line].text);
 }
 
diff --git a/src/game/localization.cpp b/src/game/localization.cpp
index cf637eff..202e6ca0 100644
--- a/src/game/localization.cpp
+++ b/src/game/localization.cpp
@@ -6,24 +6,16 @@ extern "C" {
 #include <engine/e_linereader.h>
 }
 
-static unsigned str_hash(const char *str)
-{
-	unsigned hash = 5381;
-	for(; *str; str++)
-		hash = ((hash << 5) + hash) + (*str); /* hash * 33 + c */
-	return hash;
-}
-
 const char *localize(const char *str)
 {
-	const char *new_str = localization.find_string(str_hash(str));
+	const char *new_str = localization.find_string(str_quickhash(str));
 	return new_str ? new_str : str;
 }
 
 LOC_CONSTSTRING::LOC_CONSTSTRING(const char *str)
 {
 	default_str = str;
-	hash = str_hash(default_str);
+	hash = str_quickhash(default_str);
 	version = -1;
 }
 
@@ -44,7 +36,7 @@ LOCALIZATIONDATABASE::LOCALIZATIONDATABASE()
 void LOCALIZATIONDATABASE::add_string(const char *org_str, const char *new_str)
 {
 	STRING s;
-	s.hash = str_hash(org_str);
+	s.hash = str_quickhash(org_str);
 	s.replacement = new_str;
 	strings.add(s);
 }
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp
index 9e53d6ff..736d437f 100644
--- a/src/game/server/gamecontext.cpp
+++ b/src/game/server/gamecontext.cpp
@@ -193,8 +193,13 @@ void GAMECONTEXT::send_chat(int chatter_cid, int team, const char *text)
 		msg.team = 1;
 		msg.cid = chatter_cid;
 		msg.message = text;
-		msg.pack(MSGFLAG_VITAL);
+		
+		// pack one for the recording only
+		msg.pack(MSGFLAG_VITAL|MSGFLAG_NOSEND);
+		server_send_msg(-1);
 
+		// send to the clients
+		msg.pack(MSGFLAG_VITAL|MSGFLAG_NORECORD);
 		for(int i = 0; i < MAX_CLIENTS; i++)
 		{
 			if(game.players[i] && game.players[i]->team == team)