0

Merge branch 'findbugs' into dev

This commit is contained in:
2018-03-08 21:04:07 +03:00
17 changed files with 175 additions and 296 deletions

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -29,6 +29,7 @@ import lwjake2.server.SV_WORLD;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import lwjake2.util.Math3D; import lwjake2.util.Math3D;
import javax.annotation.Nullable;
import java.util.StringTokenizer; import java.util.StringTokenizer;
@Slf4j @Slf4j

View File

@@ -1620,17 +1620,21 @@ public class GameMisc {
self.touch = misc_viper_bomb_touch; self.touch = misc_viper_bomb_touch;
self.activator = activator; 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) if (es != null)
viper = es.o; 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.velocity);
self.timestamp = GameBase.level.time; 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 " GameBase.gi.dprintf(self.classname + " at "
+ Lib.vtos(self.s.origin) + ": " + self.target + Lib.vtos(self.s.origin) + ": " + self.target
+ " is a bad target\n"); + " is a bad target\n");
self.enemy = edit.o; self.enemy = (edit != null ? edit.o : null);
} else { } else {
GameBase.G_SetMovedir(self.s.angles, self.movedir); 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) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) {
chance = 0.4f; chance = 0.4f;
} else if (enemy_range == Defines.RANGE_MELEE) {
chance = 0.8f;
} else if (enemy_range == Defines.RANGE_NEAR) { } else if (enemy_range == Defines.RANGE_NEAR) {
chance = 0.8f; chance = 0.8f;
} else if (enemy_range == Defines.RANGE_MID) { } 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) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) {
chance = 0.4f; chance = 0.4f;
} else if (enemy_range == Defines.RANGE_MELEE) {
chance = 0.8f;
} else if (enemy_range == Defines.RANGE_NEAR) { } else if (enemy_range == Defines.RANGE_NEAR) {
chance = 0.4f; chance = 0.4f;
} else if (enemy_range == Defines.RANGE_MID) { } 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) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) {
chance = 0.4f; chance = 0.4f;
} else if (enemy_range == Defines.RANGE_MELEE) {
chance = 0.8f;
} else if (enemy_range == Defines.RANGE_NEAR) { } else if (enemy_range == Defines.RANGE_NEAR) {
chance = 0.4f; chance = 0.4f;
} else if (enemy_range == Defines.RANGE_MID) { } else if (enemy_range == Defines.RANGE_MID) {

View File

@@ -63,7 +63,7 @@ public class pmove_state_t {
} }
public boolean equals(pmove_state_t p2) { public boolean equals(pmove_state_t p2) {
if (pm_type == p2.pm_type return pm_type == p2.pm_type
&& origin[0] == p2.origin[0] && origin[0] == p2.origin[0]
&& origin[1] == p2.origin[1] && origin[1] == p2.origin[1]
&& origin[2] == p2.origin[2] && origin[2] == p2.origin[2]
@@ -74,10 +74,8 @@ public class pmove_state_t {
&& pm_time == p2.pm_time && pm_time == p2.pm_time
&& delta_angles[0] == p2.delta_angles[0] && delta_angles[0] == p2.delta_angles[0]
&& delta_angles[1] == p2.delta_angles[1] && delta_angles[1] == p2.delta_angles[1]
&& delta_angles[2] == p2.origin[2]) && delta_angles[2] == p2.origin[2];
return true;
return false;
} }
/** Reads the playermove from the file. */ /** 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 image.texnum = TEXNUM_IMAGES + image.getId(); // image pos in array
GL_Bind(image.texnum); GL_Bind(image.texnum);
if (bits == 8) {
image.has_alpha = image.has_alpha =
GL_Upload8(pic, width, height, (image.type != it_pic && image.type != it_sky), image.type == it_sky); 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.upload_width = upload_width; // after power of 2 and scales image.upload_width = upload_width; // after power of 2 and scales
image.upload_height = upload_height; image.upload_height = upload_height;

View File

@@ -457,8 +457,7 @@ public class SV_WORLD {
clip.trace.startsolid = true; clip.trace.startsolid = true;
} else } else
clip.trace.set(trace); 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) { private String printXFormat(String sx) {
int nLeadingZeros = 0; int nLeadingZeros = 0;
int nBlanks = 0; int nBlanks = 0;
if (sx.equals("0") && precisionSet && precision == 0) if (sx == null || sx.equals("0") && precisionSet && precision == 0)
sx = ""; sx = "";
if (precisionSet) if (precisionSet)
nLeadingZeros = precision - sx.length(); nLeadingZeros = precision - sx.length();
@@ -2727,7 +2727,7 @@ public class PrintfFormat {
private String printOFormat(String sx) { private String printOFormat(String sx) {
int nLeadingZeros = 0; int nLeadingZeros = 0;
int nBlanks = 0; int nBlanks = 0;
if (sx.equals("0") && precisionSet && precision == 0) if (sx == null || sx.equals("0") && precisionSet && precision == 0)
sx = ""; sx = "";
if (precisionSet) if (precisionSet)
nLeadingZeros = precision - sx.length(); nLeadingZeros = precision - sx.length();

View File

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