r2278 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Apr 1 09:26:09 EDT 2007


Author: div0
Date: 2007-04-01 09:26:09 -0400 (Sun, 01 Apr 2007)
New Revision: 2278

Modified:
   trunk/data/qcsrc/server/clientcommands.qc
   trunk/data/qcsrc/server/miscfunctions.qc
Log:
never trust Dresk's code (back to QC implementation of strlennocol and strdecolorize); line width isn't 50


Modified: trunk/data/qcsrc/server/clientcommands.qc
===================================================================
--- trunk/data/qcsrc/server/clientcommands.qc	2007-04-01 12:53:52 UTC (rev 2277)
+++ trunk/data/qcsrc/server/clientcommands.qc	2007-04-01 13:26:09 UTC (rev 2278)
@@ -46,6 +46,8 @@
 		namestr = playername(source);
 	else
 		namestr = source.netname;
+	if(substring(namestr, strlen(namestr) - 1, 1) == "^")
+		namestr = strdecolorize(namestr); // BROKEN!
 	if(teamsay)
 	{
 		msgstr = strzone(strcat("\{1}\{13}", colorstr, "(^3", namestr, colorstr, ") ^7", msgin, "\n"));
@@ -78,7 +80,7 @@
 		}
 		flood_burst = max(0, flood_burst - 1);
 		// to match explanation in default.cfg, a value of 3 must allow three-line bursts and not four!
-		lines = ceil(strlennocol(msgstr) / 50);
+		lines = ceil(strlennocol(msgstr) / 75);
 		if(flood_lmax && lines > flood_lmax)
 			flood = 2;
 		else if(time >= self.flood_field)

Modified: trunk/data/qcsrc/server/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/server/miscfunctions.qc	2007-04-01 12:53:52 UTC (rev 2277)
+++ trunk/data/qcsrc/server/miscfunctions.qc	2007-04-01 13:26:09 UTC (rev 2278)
@@ -450,6 +450,60 @@
 		return "^7";
 }
 
+string decolorize(string s)
+{
+	string out;
+	out = "";
+	while(s != "")
+	{
+		float n;
+		string ch1, ch2;
+		n = 1;
+		ch1 = substring(s, 0, 1);
+		ch2 = substring(s, 1, 1);
+		if(ch1 == "^")
+		{
+			n = 2;
+			if(ch2 == "^")
+				out = strcat(out, "^^");
+			else if(ch2 == "0")
+				out = strcat1(out);
+			else if(ch2 == "1")
+				out = strcat1(out);
+			else if(ch2 == "2")
+				out = strcat1(out);
+			else if(ch2 == "3")
+				out = strcat1(out);
+			else if(ch2 == "4")
+				out = strcat1(out);
+			else if(ch2 == "5")
+				out = strcat1(out);
+			else if(ch2 == "6")
+				out = strcat1(out);
+			else if(ch2 == "7")
+				out = strcat1(out);
+			else if(ch2 == "8")
+				out = strcat1(out);
+			else if(ch2 == "9")
+				out = strcat1(out);
+			else
+			{
+				n = 1;
+				out = strcat(out, "^^");
+			}
+			s = substring(s, n, strlen(s) - n);
+		}
+		else
+		{
+			s = substring(s, 1, strlen(s) - 1);
+			out = strcat(out, ch1);
+		}
+	}
+	return out;
+}
+#define strdecolorize(s) decolorize(s)
+#define strlennocol(s) strlen(decolorize(s))
+
 #define CENTERPRIO_POINT 1
 #define CENTERPRIO_REBALANCE 2
 #define CENTERPRIO_VOTE 4




More information about the nexuiz-commits mailing list