aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2
diff options
context:
space:
mode:
authorRene Stoeckel <[email protected]>2005-12-16 21:18:23 +0000
committerRene Stoeckel <[email protected]>2005-12-16 21:18:23 +0000
commit5b715313e8e57bccda74548a04edffd61c17477c (patch)
tree2c5ca2dc4be6db1f8b3ccd8cfa0dd8a5d845530a /src/jake2
parent219716897f191ccba136b8b2489ff3a9f3c35a2e (diff)
lots of bugfixes in redirection
Diffstat (limited to 'src/jake2')
-rw-r--r--src/jake2/qcommon/Com.java45
-rw-r--r--src/jake2/server/SV_SEND.java7
2 files changed, 13 insertions, 39 deletions
diff --git a/src/jake2/qcommon/Com.java b/src/jake2/qcommon/Com.java
index bb85942..597d9af 100644
--- a/src/jake2/qcommon/Com.java
+++ b/src/jake2/qcommon/Com.java
@@ -2,7 +2,7 @@
* Com.java
* Copyright (C) 2003
*
- * $Id: Com.java,v 1.13 2005-11-13 13:36:00 cawe Exp $
+ * $Id: Com.java,v 1.14 2005-12-16 21:17:08 salomo Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -51,15 +51,15 @@ public final class Com
public abstract static class RD_Flusher
{
- public abstract void rd_flush(int target, byte[] buffer);
+ public abstract void rd_flush(int target, StringBuffer buffer);
}
static int rd_target;
- static byte[] rd_buffer;
+ static StringBuffer rd_buffer;
static int rd_buffersize;
static RD_Flusher rd_flusher;
- public static void BeginRedirect(int target, byte[] buffer, int buffersize, RD_Flusher flush)
+ public static void BeginRedirect(int target, StringBuffer buffer, int buffersize, RD_Flusher flush)
{
if (0 == target || null == buffer || 0 == buffersize || null == flush)
return;
@@ -69,7 +69,7 @@ public final class Com
rd_buffersize= buffersize;
rd_flusher= flush;
- rd_buffer= null;
+ rd_buffer.setLength(0);
}
public static void EndRedirect()
@@ -123,17 +123,6 @@ public final class Com
return data[index];
}
return 0;
-// // faster than if
-// try
-// {
-// return data[index];
-// }
-// catch (Exception e)
-// {
-// data= null;
-// // last char
-// return 0;
-// }
}
public char nextchar()
@@ -144,19 +133,6 @@ public final class Com
return data[index];
}
return 0;
-// try
-// {
-// index++;
-// return data[index];
-// }
-// catch (Exception e)
-// {
-// data= null;
-// // avoid int wraps;
-// index--;
-// // last char
-// return 0;
-// }
}
public char prevchar() {
@@ -366,21 +342,18 @@ public final class Com
_debugContext="";
}
+ /** Prints out messages, which can also be redirected to a remote client. */
public static void Printf(String fmt, Vargs vargs)
{
- // Com.Printf is for testing only.
String msg= sprintf(_debugContext + fmt, vargs);
-
if (rd_target != 0)
{
- if ((msg.length() + Lib.strlen(rd_buffer)) > (rd_buffersize - 1))
+ if ((msg.length() + rd_buffer.length()) > (rd_buffersize - 1))
{
rd_flusher.rd_flush(rd_target, rd_buffer);
- // *rd_buffer = 0;
- rd_buffer[rd_buffersize]= '\0';
+ rd_buffer.setLength(0);
}
- // TODO handle rd_buffer
- // strcat(rd_buffer, msg);
+ rd_buffer.append(msg);
return;
}
diff --git a/src/jake2/server/SV_SEND.java b/src/jake2/server/SV_SEND.java
index d1165c2..12c762f 100644
--- a/src/jake2/server/SV_SEND.java
+++ b/src/jake2/server/SV_SEND.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_SEND.java,v 1.8 2005-01-17 23:09:41 cawe Exp $
+// $Id: SV_SEND.java,v 1.9 2005-12-16 21:18:23 salomo Exp $
package jake2.server;
@@ -30,6 +30,7 @@ import jake2.client.*;
import jake2.game.*;
import jake2.qcommon.*;
import jake2.render.*;
+import jake2.util.Lib;
import jake2.util.Math3D;
public class SV_SEND {
@@ -41,11 +42,11 @@ public class SV_SEND {
=============================================================================
*/
- public static byte sv_outputbuf[] = new byte[Defines.SV_OUTPUTBUF_LENGTH];
+ public static StringBuffer sv_outputbuf = new StringBuffer();
public static void SV_FlushRedirect(int sv_redirected, byte outputbuf[]) {
if (sv_redirected == Defines.RD_PACKET) {
- String s = ("print\n" + outputbuf);
+ String s = ("print\n" + Lib.CtoJava(outputbuf));
Netchan.Netchan_OutOfBand(Defines.NS_SERVER, Globals.net_from, s.length(), s.getBytes());
}
else if (sv_redirected == Defines.RD_CLIENT) {