0

fix findbugs

This commit is contained in:
2018-03-08 20:02:35 +03:00
parent 5865259e9b
commit b8945f0295
16 changed files with 49 additions and 74 deletions

View File

@@ -18,6 +18,7 @@
package lwjake2;
import lombok.NonNull;
import lwjake2.qcommon.Com;
import lwjake2.qcommon.Cvar;
import lwjake2.qcommon.Qcommon;
@@ -34,7 +35,7 @@ public final class LWJake2 {
*
* @param args
*/
public static void main(String[] args) {
public static void main(@NonNull String[] args) {
boolean dedicated = false;

View File

@@ -141,8 +141,7 @@ public class CL_pred {
} else
tr.set(trace); // rst: solved the Z U P P E L - P R O B L E
// M
} else if (trace.startsolid)
tr.startsolid = true;
}
}
}

View File

@@ -664,12 +664,12 @@ public class CL_tent {
} else {
// Com_Printf ("No free sustains!\n");
// FIXME - read the stuff anyway
cnt = MSG.ReadByte(Globals.net_message);
MSG.ReadByte(Globals.net_message);
MSG.ReadPos(Globals.net_message, pos);
MSG.ReadDir(Globals.net_message, dir);
r = MSG.ReadByte(Globals.net_message);
magnitude = MSG.ReadShort(Globals.net_message);
magnitude = MSG.ReadLong(Globals.net_message); // really
MSG.ReadByte(Globals.net_message);
MSG.ReadShort(Globals.net_message);
MSG.ReadLong(Globals.net_message);
// interval
}
} else // instant
@@ -1027,7 +1027,7 @@ public class CL_tent {
case Defines.TE_PARASITE_ATTACK:
case Defines.TE_MEDIC_CABLE_ATTACK:
ent = ParseBeam(cl_mod_parasite_segment);
ParseBeam(cl_mod_parasite_segment);
break;
case Defines.TE_BOSSTPORT: // boss teleporting to station
@@ -1038,7 +1038,7 @@ public class CL_tent {
break;
case Defines.TE_GRAPPLE_CABLE:
ent = ParseBeam2(cl_mod_grapple_cable);
ParseBeam2(cl_mod_grapple_cable);
break;
// RAFAEL

View File

@@ -408,10 +408,7 @@ public class Key extends Globals {
return;
}
if (!down)
return; // other systems only care about key down events
// if (shift_down)
// if (shift_down)
// key = keyshift[key];
switch (Globals.cls.key_dest) {

View File

@@ -34,8 +34,6 @@ import lwjake2.sys.Timer;
import lwjake2.util.Lib;
import lwjake2.util.Math3D;
import lwjake2.util.QuakeFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.Dimension;
import java.io.RandomAccessFile;
@@ -53,7 +51,6 @@ abstract class keyfunc_t {
}
public final class Menu extends Key {
private static final Logger logger = LoggerFactory.getLogger(Menu.class);
private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance();
static int m_main_cursor;
@@ -246,7 +243,7 @@ public final class Menu extends Key {
menucommon_s item;
if (m != null) {
if ((item = ((menucommon_s) Menu_ItemAtCursor(m))) != null) {
if ((item = Menu_ItemAtCursor(m)) != null) {
if (item.type == MTYPE_FIELD) {
if (Field_Key((menufield_s) item, key))
return null;
@@ -4261,7 +4258,7 @@ public final class Menu extends Key {
else
offset = f.cursor;
if ((((int) (Timer.Milliseconds() / 250)) & 1) != 0) {
if ((Timer.Milliseconds() / 250 & 1) != 0) {
re.DrawChar(f.x + f.parent.x + (offset + 2) * 8 + 8, f.y
+ f.parent.y, 11);
} else {

View File

@@ -267,7 +267,7 @@ public final class Cmd {
// set cmd_args to everything after the first arg
if (cmd_argc == 1) {
cmd_args = new String(text, ph.index, len - ph.index);
cmd_args.trim();
cmd_args = cmd_args.trim();
}
com_token = Com.Parse(ph);

View File

@@ -1620,17 +1620,21 @@ public class GameMisc {
self.touch = misc_viper_bomb_touch;
self.activator = activator;
EdictIterator es = null;
EdictIterator es;
es = GameBase.G_Find(es, GameBase.findByClass, "misc_viper");
es = GameBase.G_Find(null, GameBase.findByClass, "misc_viper");
if (es != null)
viper = es.o;
Math3D.VectorScale(viper.moveinfo.dir, viper.moveinfo.speed,
Math3D.VectorScale(
(viper != null ? viper.moveinfo.dir : new float[0]),
(viper != null ? viper.moveinfo.speed : 0),
self.velocity);
self.timestamp = GameBase.level.time;
Math3D.VectorCopy(viper.moveinfo.dir, self.moveinfo.dir);
Math3D.VectorCopy(
(viper != null ? viper.moveinfo.dir : new float[0]),
self.moveinfo.dir);
}
};

View File

@@ -694,7 +694,7 @@ public class GameTarget {
GameBase.gi.dprintf(self.classname + " at "
+ Lib.vtos(self.s.origin) + ": " + self.target
+ " is a bad target\n");
self.enemy = edit.o;
self.enemy = (edit != null ? edit.o : null);
} else {
GameBase.G_SetMovedir(self.s.angles, self.movedir);
}

View File

@@ -590,8 +590,6 @@ public class M_Boss2 {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) {
chance = 0.4f;
} else if (enemy_range == Defines.RANGE_MELEE) {
chance = 0.8f;
} else if (enemy_range == Defines.RANGE_NEAR) {
chance = 0.8f;
} else if (enemy_range == Defines.RANGE_MID) {

View File

@@ -814,8 +814,6 @@ public class M_Boss31 {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) {
chance = 0.4f;
} else if (enemy_range == Defines.RANGE_MELEE) {
chance = 0.8f;
} else if (enemy_range == Defines.RANGE_NEAR) {
chance = 0.4f;
} else if (enemy_range == Defines.RANGE_MID) {

View File

@@ -1797,8 +1797,6 @@ public class M_Boss32 {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) {
chance = 0.4f;
} else if (enemy_range == Defines.RANGE_MELEE) {
chance = 0.8f;
} else if (enemy_range == Defines.RANGE_NEAR) {
chance = 0.4f;
} else if (enemy_range == Defines.RANGE_MID) {

View File

@@ -63,21 +63,19 @@ public class pmove_state_t {
}
public boolean equals(pmove_state_t p2) {
if (pm_type == p2.pm_type
&& origin[0] == p2.origin[0]
&& origin[1] == p2.origin[1]
&& origin[2] == p2.origin[2]
&& velocity[0] == p2.velocity[0]
&& velocity[1] == p2.velocity[1]
&& velocity[2] == p2.origin[2]
&& pm_flags == p2.pm_flags
&& pm_time == p2.pm_time
&& delta_angles[0] == p2.delta_angles[0]
&& delta_angles[1] == p2.delta_angles[1]
&& delta_angles[2] == p2.origin[2])
return true;
return pm_type == p2.pm_type
&& origin[0] == p2.origin[0]
&& origin[1] == p2.origin[1]
&& origin[2] == p2.origin[2]
&& velocity[0] == p2.velocity[0]
&& velocity[1] == p2.velocity[1]
&& velocity[2] == p2.origin[2]
&& pm_flags == p2.pm_flags
&& pm_time == p2.pm_time
&& delta_angles[0] == p2.delta_angles[0]
&& delta_angles[1] == p2.delta_angles[1]
&& delta_angles[2] == p2.origin[2];
return false;
}
/** Reads the playermove from the file. */

View File

@@ -1356,22 +1356,8 @@ public abstract class Image extends Main {
image.texnum = TEXNUM_IMAGES + image.getId(); // image pos in array
GL_Bind(image.texnum);
if (bits == 8) {
image.has_alpha =
GL_Upload8(pic, width, height, (image.type != it_pic && image.type != it_sky), image.type == it_sky);
}
else {
int[] tmp = new int[pic.length / 4];
for (i = 0; i < tmp.length; i++) {
tmp[i] = ((pic[4 * i + 0] & 0xFF) << 0); // & 0x000000FF;
tmp[i] |= ((pic[4 * i + 1] & 0xFF) << 8); // & 0x0000FF00;
tmp[i] |= ((pic[4 * i + 2] & 0xFF) << 16); // & 0x00FF0000;
tmp[i] |= ((pic[4 * i + 3] & 0xFF) << 24); // & 0xFF000000;
}
image.has_alpha = GL_Upload32(tmp, width, height, (image.type != it_pic && image.type != it_sky));
}
image.has_alpha =
GL_Upload8(pic, width, height, (image.type != it_pic && image.type != it_sky), image.type == it_sky);
image.upload_width = upload_width; // after power of 2 and scales
image.upload_height = upload_height;

View File

@@ -457,8 +457,7 @@ public class SV_WORLD {
clip.trace.startsolid = true;
} else
clip.trace.set(trace);
} else if (trace.startsolid)
clip.trace.startsolid = true;
}
}
}

View File

@@ -2451,7 +2451,7 @@ public class PrintfFormat {
private String printXFormat(String sx) {
int nLeadingZeros = 0;
int nBlanks = 0;
if (sx.equals("0") && precisionSet && precision == 0)
if (sx == null || sx.equals("0") && precisionSet && precision == 0)
sx = "";
if (precisionSet)
nLeadingZeros = precision - sx.length();
@@ -2727,7 +2727,7 @@ public class PrintfFormat {
private String printOFormat(String sx) {
int nLeadingZeros = 0;
int nBlanks = 0;
if (sx.equals("0") && precisionSet && precision == 0)
if (sx == null || sx.equals("0") && precisionSet && precision == 0)
sx = "";
if (precisionSet)
nLeadingZeros = precision - sx.length();

View File

@@ -30,7 +30,7 @@ public class Vargs {
// initial capacity
static final int SIZE = 5;
Vector<Object> v;
Vector<Object> v = null;
public Vargs() {
this(SIZE);
@@ -39,46 +39,46 @@ public class Vargs {
public Vargs(int initialSize) {
if (v != null)
v.clear(); // clear previous list for GC
v = new Vector<Object>(initialSize);
v = new Vector<>(initialSize);
}
public Vargs add(boolean value) {
v.add(new Boolean(value));
v.add(value);
return this;
}
public Vargs add(byte value) {
v.add(new Byte(value));
v.add(value);
return this;
}
public Vargs add(char value) {
v.add(new Character(value));
v.add(value);
return this;
}
public Vargs add(short value) {
v.add(new Short(value));
v.add(value);
return this;
}
public Vargs add(int value) {
v.add(new Integer(value));
v.add(value);
return this;
}
public Vargs add(long value) {
v.add(new Long(value));
v.add(value);
return this;
}
public Vargs add(float value) {
v.add(new Float(value));
v.add(value);
return this;
}
public Vargs add(double value) {
v.add(new Double(value));
v.add(value);
return this;
}