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
&& 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)
name = name.substring(0, 36);

View File

@@ -741,14 +741,14 @@ public class Key {
}
// 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++) {
cmd += Cmd.Argv(i);
cmd.append(Cmd.Argv(i));
if (i != (c - 1))
cmd += " ";
cmd.append(" ");
}
SetBinding(b, cmd);
SetBinding(b, cmd.toString());
}
static void SetBinding(int keynum, String binding) {

View File

@@ -1622,11 +1622,11 @@ public final class Menu extends Key {
int n;
int isdeveloper;
byte b[] = UnpackLoader.loadFile("credits");
byte[] b = UnpackLoader.loadFile("credits");
if (b != null) {
creditsBuffer = new String(b);
String line[] = creditsBuffer.split("\r\n");
String[] line = creditsBuffer.split("\r\n");
for (n = 0; n < line.length; 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++)
configstrings[n] = new String();
configstrings[n] = "";
for (int n=0; n < Defines.MAX_CLIENTS; n++)
clientinfo[n] = new clientinfo_t();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -31,6 +31,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.charset.StandardCharsets;
@Slf4j
public class Lib {
@@ -324,19 +325,7 @@ public class Lib {
* avoid new String(bytes) because it is using system specific character encoding.
*/
public static String bytesToString(byte[] value) {
try {
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;
return new String(value, StandardCharsets.ISO_8859_1);
}
/** 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)
return "";
byte bb[] = new byte[len];
byte[] bb = new byte[len];
super.read(bb, 0, len);