r2086 - in trunk/data/qcsrc: common menu server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Tue Jan 2 09:14:20 EST 2007
Author: div0
Date: 2007-01-02 09:14:20 -0500 (Tue, 02 Jan 2007)
New Revision: 2086
Modified:
trunk/data/qcsrc/common/util.qc
trunk/data/qcsrc/common/util.qh
trunk/data/qcsrc/menu/msys.qc
trunk/data/qcsrc/server/clientcommands.qc
Log:
cmd info (something) prints the content of sv_info_(something), for server admins to put text there
Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc 2007-01-02 13:30:18 UTC (rev 2085)
+++ trunk/data/qcsrc/common/util.qc 2007-01-02 14:14:20 UTC (rev 2086)
@@ -1,17 +1,50 @@
+string wordwrap_buffer;
+void wordwrap_buffer_put(string s)
+{
+ wordwrap_buffer = strcat(wordwrap_buffer, s);
+}
+
string wordwrap(string s, float l)
{
- local string t, c;
+ wordwrap_buffer = "";
+ wordwrap_cb(s, l, wordwrap_buffer_put);
+ return wordwrap_buffer;
+}
+
+#ifndef MENUQC
+void wordwrap_buffer_sprint(string s)
+{
+ wordwrap_buffer = strcat(wordwrap_buffer, s);
+ if(s == "\n")
+ {
+ sprint(self, wordwrap_buffer);
+ wordwrap_buffer = "";
+ }
+}
+
+void wordwrap_sprint(string s, float l)
+{
+ wordwrap_buffer = "";
+ wordwrap_cb(s, l, wordwrap_buffer_sprint);
+ if(wordwrap_buffer != "")
+ sprint(self, strcat(wordwrap_buffer, "\n"));
+ return;
+}
+#endif
+
+void wordwrap_cb(string s, float l, void(string) callback)
+{
+ local string c;
local float lleft, i, j, wlen;
s = strzone(s);
- t = "";
lleft = l;
for (i = 0;i < strlen(s);i++)
{
if (substring(s, i, 2) == "\\n")
{
- t = strcat(t, "\n");
+ callback("\n");
lleft = l;
i++;
}
@@ -19,7 +52,7 @@
{
if (lleft > 0)
{
- t = strcat(t, " ");
+ callback(" ");
lleft = lleft - 1;
}
}
@@ -42,142 +75,20 @@
// we need to keep this tempstring alive even if substring is
// called repeatedly, so call strcat even though we're not
// doing anything
- t = strcat(t);
+ callback("");
}
wlen = j - i;
if (lleft < wlen)
{
- t = strcat(t, "\n");
+ callback("\n");
lleft = l;
}
- t = strcat(t, substring(s, i, wlen));
+ callback(substring(s, i, wlen));
lleft = lleft - wlen;
i = j - 1;
}
}
strunzone(s);
- return t;
-
-/*
- string t;
- string word;
-
- float lleft;
- float i;
-
- float startidx;
-
- startidx = 0;
-
- t = "";
- word = "";
- for (i = 0;i < strlen(s);i++)
- {
- c = substring(s, i, 1);
- forceflush = false;
- if (c == " ")
- dowhat = 0;
- else if (c == "\\" && substring(s, i + 1, 1) == "n")
- dowhat = 1;
- else
- {
- dowhat = 2;
- word = strcat(word, c);
- }
-
- if (dowhat < 2)
- {
- // a space may add some whitespace to the output, and flushes the word buffer
- if (word != "")
- {
- if (lleft < strlen(word) + 1)
- {
- // add a newline
- t = strcat(t, "\n");
- lleft = l;
- }
- else
- {
- // otherwise just add a space if there's already text in
- // this line
- if (lleft != l)
- t = strcat(t, " ");
- }
- t = strcat(t, word);
- word = "";
- }
- if (dowhat == 0)
- {
- // if this is a double space, add the space
- if (lleft)
- t = strcat(t, " ");
- }
- else if (dowhat == 1)
- {
- t = strcat(t, "\n");
- lleft = l;
- }
- }
- // we need to keep these tempstrings alive even if substring is
- // called repeatedly, so call strcat even though we're not doing
- // anything
- t = strcat(t);
- word = strcat(word);
- }
- return t;
-*/
-
-/*
- string t;
- string word;
-
- float lleft;
- float i;
-
- float startidx;
-
- startidx = 0;
-
- t = "";
-
- lleft = l;
- for(i = 0; i <= strlen(s); ++i)
- {
- if(i != strlen(s) && substring(s, i, 1) != " ")
- {
- // we need to keep this tempstring alive even if substring is
- // called repeatedly, so call strcat even though we're not doing
- // anything
- t = strcat(t);
- continue;
- }
-
- word = substring(s, startidx, i - startidx);
- startidx = i + 1;
-
- if(word == "+++")
- {
- t = strcat(t, "\n\n");
- lleft = l;
- }
- else if(!l || (strlen(word) < lleft))
- {
- if(lleft != l)
- {
- t = strcat(t, " ");
- lleft = lleft - 1;
- }
- t = strcat(t, word);
- lleft = lleft - strlen(word);
- }
- else
- {
- t = strcat(t, "\n", word);
- lleft = l - strlen(word);
- }
- }
- return t;
-*/
}
float dist_point_line(vector p, vector l0, vector ldir)
Modified: trunk/data/qcsrc/common/util.qh
===================================================================
--- trunk/data/qcsrc/common/util.qh 2007-01-02 13:30:18 UTC (rev 2085)
+++ trunk/data/qcsrc/common/util.qh 2007-01-02 14:14:20 UTC (rev 2086)
@@ -2,3 +2,7 @@
// this returns a tempstring containing a copy of s with additional \n newlines added, it also replaces \n in the text with a real newline
// NOTE: s IS allowed to be a tempstring
string wordwrap(string s, float l);
+#ifndef MENUQC
+void wordwrap_sprint(string s, float l);
+#endif
+void wordwrap_cb(string s, float l, void(string) callback)
Modified: trunk/data/qcsrc/menu/msys.qc
===================================================================
--- trunk/data/qcsrc/menu/msys.qc 2007-01-02 13:30:18 UTC (rev 2085)
+++ trunk/data/qcsrc/menu/msys.qc 2007-01-02 14:14:20 UTC (rev 2086)
@@ -1,4 +1,5 @@
#pragma flag off fastarrays // make dp behave with new fteqcc versions. remove when dp bug with fteqcc fastarrays is fixed
+#define MENUQC // so common/*.qc can check for menu QC or game QC
//////////////////////////////////////////////////////////
// sys globals
Modified: trunk/data/qcsrc/server/clientcommands.qc
===================================================================
--- trunk/data/qcsrc/server/clientcommands.qc 2007-01-02 13:30:18 UTC (rev 2085)
+++ trunk/data/qcsrc/server/clientcommands.qc 2007-01-02 14:14:20 UTC (rev 2086)
@@ -80,6 +80,7 @@
void SV_ParseClientCommand(string s) {
local float index;
+ local string cmd;
tokenize(s);
@@ -357,8 +358,13 @@
} else if(argv(0) == "say_team") {
Say(self, TRUE, substring(s, 9, strlen(s) - 9));
//clientcommand(self, formatmessage(s));
+ } else if(argv(0) == "info") {
+ cmd = cvar_string(strcat("sv_info_", argv(1)));
+ if(cmd == "")
+ sprint(self, "ERROR: unsupported info command\n");
+ else
+ wordwrap_sprint(cmd, 1111);
} else {
- string cmd;
cmd = argv(0);
if(cmd != "status")
if(cmd != "name")
More information about the nexuiz-commits
mailing list