0

fix: String

This commit is contained in:
2019-06-05 23:51:44 +03:00
parent 88a1a27975
commit 62248f8da0
13 changed files with 22 additions and 38 deletions

View File

@@ -76,7 +76,7 @@ public class CL_view {
for (i = 1; i < Defines.MAX_MODELS for (i = 1; i < Defines.MAX_MODELS
&& Globals.cl.configstrings[Defines.CS_MODELS + i].length() != 0; i++) { && Globals.cl.configstrings[Defines.CS_MODELS + i].length() != 0; i++) {
name = new String(Globals.cl.configstrings[Defines.CS_MODELS + i]); name = Globals.cl.configstrings[Defines.CS_MODELS + i];
if (name.length() > 37) if (name.length() > 37)
name = name.substring(0, 36); name = name.substring(0, 36);

View File

@@ -741,14 +741,14 @@ public class Key {
} }
// copy the rest of the command line // copy the rest of the command line
String cmd = ""; // start out with a null string StringBuilder cmd = new StringBuilder(); // start out with a null string
for (int i = 2; i < c; i++) { for (int i = 2; i < c; i++) {
cmd += Cmd.Argv(i); cmd.append(Cmd.Argv(i));
if (i != (c - 1)) if (i != (c - 1))
cmd += " "; cmd.append(" ");
} }
SetBinding(b, cmd); SetBinding(b, cmd.toString());
} }
static void SetBinding(int keynum, String binding) { static void SetBinding(int keynum, String binding) {

View File

@@ -1622,11 +1622,11 @@ public final class Menu extends Key {
int n; int n;
int isdeveloper; int isdeveloper;
byte b[] = UnpackLoader.loadFile("credits"); byte[] b = UnpackLoader.loadFile("credits");
if (b != null) { if (b != null) {
creditsBuffer = new String(b); creditsBuffer = new String(b);
String line[] = creditsBuffer.split("\r\n"); String[] line = creditsBuffer.split("\r\n");
for (n = 0; n < line.length; n++) { for (n = 0; n < line.length; n++) {
creditsIndex[n] = line[n]; creditsIndex[n] = line[n];

View File

@@ -37,7 +37,7 @@ public class client_state_t {
} }
for (int n = 0; n < Defines.MAX_CONFIGSTRINGS; n++) for (int n = 0; n < Defines.MAX_CONFIGSTRINGS; n++)
configstrings[n] = new String(); configstrings[n] = "";
for (int n=0; n < Defines.MAX_CLIENTS; n++) for (int n=0; n < Defines.MAX_CLIENTS; n++)
clientinfo[n] = new clientinfo_t(); clientinfo[n] = new clientinfo_t();

View File

@@ -359,7 +359,7 @@ public final class Cmd {
} }
public static String Args() { public static String Args() {
return new String(cmd_args); return cmd_args;
} }
/** /**

View File

@@ -282,10 +282,6 @@ public class GameBase {
Math3D.VectorClear(angles); Math3D.VectorClear(angles);
} }
public static String G_CopyString(String in) {
return new String(in);
}
/** /**
* G_TouchTriggers * G_TouchTriggers
*/ */

View File

@@ -647,7 +647,7 @@ public class GameMisc {
func_clock_reset(self); func_clock_reset(self);
self.message = new String(); self.message = "";
self.think = func_clock_think; self.think = func_clock_think;

View File

@@ -727,7 +727,7 @@ public class GameTarget {
public String getID() { return "target_lightramp_think"; } public String getID() { return "target_lightramp_think"; }
public boolean think(edict_t self) { public boolean think(edict_t self) {
char tmp[] = {(char) ('a' + (int) (self.movedir[0] + (GameBase.level.time - self.timestamp) char[] tmp = { (char) ('a' + (int) (self.movedir[0] + (GameBase.level.time - self.timestamp)
/ Defines.FRAMETIME * self.movedir[2])) }; / Defines.FRAMETIME * self.movedir[2])) };
GameBase.gi.configstring(Defines.CS_LIGHTS + self.enemy.style, GameBase.gi.configstring(Defines.CS_LIGHTS + self.enemy.style,

View File

@@ -72,8 +72,8 @@ public class Cvar {
} }
} }
var = new cvar_t(); var = new cvar_t();
var.name = new String(var_name); var.name = var_name;
var.string = new String(var_value); var.string = var_value;
var.modified = true; var.modified = true;
// handles atof(var.string) // handles atof(var.string)
try { try {

View File

@@ -479,9 +479,8 @@ public class MSG {
l++; l++;
} while (l < 2047); } while (l < 2047);
String ret = new String(readbuf, 0, l);
// Com.dprintln("MSG.ReadString:[" + ret + "]"); // Com.dprintln("MSG.ReadString:[" + ret + "]");
return ret; return new String(readbuf, 0, l);
} }
public static String ReadStringLine(sizebuf_t msg_read) { public static String ReadStringLine(sizebuf_t msg_read) {

View File

@@ -436,7 +436,7 @@ public final class LWJGLSoundImpl implements Sound {
String s; String s;
int i; int i;
s = new String(truename); s = truename;
// find a free sfx // find a free sfx
for (i=0 ; i < num_sfx ; i++) for (i=0 ; i < num_sfx ; i++)
@@ -452,7 +452,7 @@ public final class LWJGLSoundImpl implements Sound {
sfx = known_sfx[i]; sfx = known_sfx[i];
sfx.clear(); sfx.clear();
sfx.name = new String(aliasname); sfx.name = aliasname;
sfx.registration_sequence = s_registration_sequence; sfx.registration_sequence = s_registration_sequence;
sfx.truename = s; sfx.truename = s;
// set the AL bufferId // set the AL bufferId
@@ -541,7 +541,7 @@ public final class LWJGLSoundImpl implements Sound {
i = 1; i = 1;
while (i < Cmd.Argc()) { while (i < Cmd.Argc()) {
name = new String(Cmd.Argv(i)); name = Cmd.Argv(i);
if (name.indexOf('.') == -1) if (name.indexOf('.') == -1)
name += ".wav"; name += ".wav";

View File

@@ -31,6 +31,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.nio.charset.StandardCharsets;
@Slf4j @Slf4j
public class Lib { public class Lib {
@@ -324,19 +325,7 @@ public class Lib {
* avoid new String(bytes) because it is using system specific character encoding. * avoid new String(bytes) because it is using system specific character encoding.
*/ */
public static String bytesToString(byte[] value) { public static String bytesToString(byte[] value) {
try { return new String(value, StandardCharsets.ISO_8859_1);
return new String(value, "ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// can't happen: Latin 1 is a standard encoding
return null;
}
}
/** Helper method that savely handles the null termination of old C String data. */
public static String CtoJava(String old) {
int index = old.indexOf('\0');
if (index == 0) return "";
return (index > 0) ? old.substring(0, index) : old;
} }
/** Helper method that savely handles the null termination of old C String data. */ /** Helper method that savely handles the null termination of old C String data. */

View File

@@ -66,7 +66,7 @@ public class QuakeFile extends RandomAccessFile {
if (len == 0) if (len == 0)
return ""; return "";
byte bb[] = new byte[len]; byte[] bb = new byte[len];
super.read(bb, 0, len); super.read(bb, 0, len);