about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/base/system.c10
-rw-r--r--src/base/system.h2
-rw-r--r--src/game/client/components/chat.cpp11
-rw-r--r--src/game/localization.cpp14
-rw-r--r--src/game/server/gamecontext.cpp7
5 files changed, 26 insertions, 18 deletions
diff --git a/src/base/system.c b/src/base/system.c
index be2a5d5a..f570fdf3 100644
--- a/src/base/system.c
+++ b/src/base/system.c
@@ -1354,6 +1354,16 @@ int str_utf8_decode(const char **ptr)
 	
 }
 
+
+unsigned str_quickhash(const char *str)
+{
+	unsigned hash = 5381;
+	for(; *str; str++)
+		hash = ((hash << 5) + hash) + (*str); /* hash * 33 + c */
+	return hash;
+}
+
+
 #if defined(__cplusplus)
 }
 #endif
diff --git a/src/base/system.h b/src/base/system.h
index 7a734cfd..cdbfe294 100644
--- a/src/base/system.h
+++ b/src/base/system.h
@@ -971,7 +971,7 @@ void net_stats(NETSTATS *stats);
 
 int str_isspace(char c);
 char str_uppercase(char c);
-
+unsigned str_quickhash(const char *str);
 
 /*
 	Function: gui_messagebox
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)