0

- Resolved all Eclipse warnings. The only compiler warning left is

sun.misc.Perf-related.
- Fixed a bug where menu.lst in baseq2 was not picked up. The order it
checks is now the user folder, then baseq2, then the pak files.
- Fixed a bug where it would not find all of the skins for a model.
This commit is contained in:
Ethan Lee
2012-02-07 03:31:09 -05:00
parent eac56b4bfd
commit 236b34ef67
13 changed files with 95 additions and 98 deletions

View File

@@ -664,7 +664,7 @@ public class Key extends Globals {
}
private static void printCompletions(String type, Vector compl) {
private static void printCompletions(String type, Vector<String> compl) {
Com.Printf(type);
for (int i = 0; i < compl.size(); i++) {
Com.Printf((String)compl.get(i) + " ");
@@ -683,8 +683,8 @@ public class Key extends Globals {
String s = new String(key_lines[edit_line], start, end-start);
Vector cmds = Cmd.CompleteCommand(s);
Vector vars = Cvar.CompleteVariable(s);
Vector<String> cmds = Cmd.CompleteCommand(s);
Vector<String> vars = Cvar.CompleteVariable(s);
int c = cmds.size();
int v = vars.size();

View File

@@ -2172,16 +2172,11 @@ public final class Menu extends Key {
try {
f = new QuakeFile(name, "r");
if (f == null) {
m_savestrings[i] = "<EMPTY>";
m_savevalid[i] = false;
} else {
String str = f.readString();
if (str != null)
m_savestrings[i] = str;
f.close();
m_savevalid[i] = true;
}
} catch (Exception e) {
m_savestrings[i] = "<EMPTY>";
m_savevalid[i] = false;
@@ -2707,11 +2702,14 @@ public final class Menu extends Key {
*/
mapsname = FS.Gamedir() + "/maps.lst";
// Check user dir first (default ~/.lwjake2)
if ((fp = Lib.fopen(mapsname, "r")) == null) {
// Check base dir first (baseq2 folder)
mapsname = FS.BaseGamedir() + "/maps.lst";
if ((fp = Lib.fopen(mapsname, "r")) == null) {
// Open the pak's maplist
buffer = FS.LoadFile("maps.lst");
if (buffer == null)
//if ((length = FS_LoadFile("maps.lst", (Object *) & buffer))
// == -1)
Com.Error(ERR_DROP, "couldn't find maps.lst\n");
} else {
try {
@@ -2722,6 +2720,15 @@ public final class Menu extends Key {
Com.Error(ERR_DROP, "couldn't load maps.lst\n");
}
}
} else {
try {
int len = (int) fp.length();
buffer = new byte[len];
fp.readFully(buffer);
} catch (Exception e) {
Com.Error(ERR_DROP, "couldn't load maps.lst\n");
}
}
s = new String(buffer);
String lines[] = s.split("\r\n");
@@ -3804,18 +3811,12 @@ public final class Menu extends Key {
pcxnames = FS.ListFiles(scratch, 0, 0);
npcxfiles = pcxnames.length;
if (pcxnames == null) {
dirnames[i] = null;
continue;
}
// count valid skins, which consist of a skin with a matching "_i"
// icon
for (k = 0; k < npcxfiles - 1; k++) {
if (!pcxnames[k].endsWith("_i.pcx")) {
//if (!strstr(pcxnames[k], "_i.pcx")) {
if (IconOfSkinExists(pcxnames[k], pcxnames, npcxfiles - 1)) {
if (IconOfSkinExists(pcxnames[k], pcxnames, npcxfiles)) {
nskins++;
}
}
@@ -3828,10 +3829,10 @@ public final class Menu extends Key {
//memset(skinnames, 0, sizeof(String) * (nskins + 1));
// copy the valid skins
for (s = 0, k = 0; k < npcxfiles - 1; k++) {
for (s = 0, k = 0; k < npcxfiles; k++) {
if (pcxnames[k].indexOf("_i.pcx") < 0) {
if (IconOfSkinExists(pcxnames[k], pcxnames, npcxfiles - 1)) {
if (IconOfSkinExists(pcxnames[k], pcxnames, npcxfiles)) {
a = pcxnames[k].lastIndexOf('/');
b = pcxnames[k].lastIndexOf('\\');
@@ -3878,9 +3879,7 @@ public final class Menu extends Key {
}
static int pmicmpfnc(Object _a, Object _b) {
playermodelinfo_s a = (playermodelinfo_s) _a;
playermodelinfo_s b = (playermodelinfo_s) _b;
static int pmicmpfnc(playermodelinfo_s a, playermodelinfo_s b) {
/*
* * sort by male, female, then alphabetical
@@ -3938,8 +3937,8 @@ public final class Menu extends Key {
}
//qsort(s_pmi, s_numplayermodels, sizeof(s_pmi[0]), pmicmpfnc);
Arrays.sort(s_pmi, 0, s_numplayermodels, new Comparator() {
public int compare(Object o1, Object o2) {
Arrays.sort(s_pmi, 0, s_numplayermodels, new Comparator<playermodelinfo_s>() {
public int compare(playermodelinfo_s o1, playermodelinfo_s o2) {
return pmicmpfnc(o1, o2);
}
});

View File

@@ -162,13 +162,11 @@ public final class Cmd {
private static char temporary[] = new char[Defines.MAX_STRING_CHARS];
public static Comparator PlayerSort = new Comparator() {
public int compare(Object o1, Object o2) {
int anum = ((Integer) o1).intValue();
int bnum = ((Integer) o2).intValue();
public static Comparator<Integer> PlayerSort = new Comparator<Integer>() {
public int compare(Integer o1, Integer o2) {
int anum1 = GameBase.game.clients[anum].ps.stats[Defines.STAT_FRAGS];
int bnum1 = GameBase.game.clients[bnum].ps.stats[Defines.STAT_FRAGS];
int anum1 = GameBase.game.clients[o1].ps.stats[Defines.STAT_FRAGS];
int bnum1 = GameBase.game.clients[o2].ps.stats[Defines.STAT_FRAGS];
if (anum1 < bnum1)
return -1;
@@ -1183,8 +1181,8 @@ public final class Cmd {
/**
* Cmd_CompleteCommand.
*/
public static Vector CompleteCommand(String partial) {
Vector cmds = new Vector();
public static Vector<String> CompleteCommand(String partial) {
Vector<String> cmds = new Vector<String>();
// check for match
for (cmd_function_t cmd = cmd_functions; cmd != null; cmd = cmd.next)

View File

@@ -234,9 +234,6 @@ public class GameSave {
f = new QuakeFile(filename, "rw");
if (f == null)
GameBase.gi.error("Couldn't write to " + filename);
GameBase.game.autosaved = autosave;
GameBase.game.write(f);
GameBase.game.autosaved = false;
@@ -247,6 +244,7 @@ public class GameSave {
Lib.fclose(f);
} catch (Exception e) {
e.printStackTrace();
GameBase.gi.error("Couldn't write to " + filename);
}
}
@@ -284,8 +282,6 @@ public class GameSave {
QuakeFile f;
f = new QuakeFile(filename, "rw");
if (f == null)
GameBase.gi.error("Couldn't open for writing: " + filename);
// write out level_locals_t
GameBase.level.write(f);
@@ -305,6 +301,7 @@ public class GameSave {
f.close();
} catch (Exception e) {
e.printStackTrace();
GameBase.gi.error("Couldn't open for writing: " + filename);
}
}
@@ -327,9 +324,6 @@ public class GameSave {
QuakeFile f = new QuakeFile(filename, "r");
if (f == null)
GameBase.gi.error("Couldn't read level file " + filename);
// wipe all the entities
CreateEdicts();
@@ -376,6 +370,7 @@ public class GameSave {
}
} catch (Exception e) {
e.printStackTrace();
GameBase.gi.error("Couldn't read level file " + filename);
}
}
}

View File

@@ -75,7 +75,7 @@ public final class FS extends Globals {
int numfiles;
Hashtable files; // with packfile_t entries
Hashtable<String, packfile_t> files; // with packfile_t entries
}
public static String fs_gamedir;
@@ -97,7 +97,7 @@ public final class FS extends Globals {
}
// with filelink_t entries
public static List fs_links = new LinkedList();
public static List<filelink_t> fs_links = new LinkedList<filelink_t>();
public static class searchpath_t {
String filename;
@@ -171,8 +171,8 @@ public final class FS extends Globals {
file_from_pak = 0;
// check for links first
for (Iterator it = fs_links.iterator(); it.hasNext();) {
link = (filelink_t) it.next();
for (Iterator<filelink_t> it = fs_links.iterator(); it.hasNext();) {
link = it.next();
if (filename.regionMatches(0, link.from, 0, link.fromlength)) {
netpath = link.to + filename.substring(link.fromlength);
@@ -193,7 +193,7 @@ public final class FS extends Globals {
// look through all the pak file elements
pak = search.pack;
filename = filename.toLowerCase();
packfile_t entry = (packfile_t) pak.files.get(filename);
packfile_t entry = pak.files.get(filename);
if (entry != null) {
// found it!
@@ -244,8 +244,8 @@ public final class FS extends Globals {
file_from_pak = 0;
// check for links first
for (Iterator it = fs_links.iterator(); it.hasNext();) {
link = (filelink_t) it.next();
for (Iterator<filelink_t> it = fs_links.iterator(); it.hasNext();) {
link = it.next();
// if (!strncmp (filename, link->from, link->fromlength))
if (filename.regionMatches(0, link.from, 0, link.fromlength)) {
@@ -268,7 +268,7 @@ public final class FS extends Globals {
// look through all the pak file elements
pak = search.pack;
filename = filename.toLowerCase();
packfile_t entry = (packfile_t) pak.files.get(filename);
packfile_t entry = pak.files.get(filename);
if (entry != null) {
// found it!
@@ -402,8 +402,8 @@ public final class FS extends Globals {
try {
// check for links first
for (Iterator it = fs_links.iterator(); it.hasNext();) {
link = (filelink_t) it.next();
for (Iterator<filelink_t> it = fs_links.iterator(); it.hasNext();) {
link = it.next();
if (filename.regionMatches(0, link.from, 0, link.fromlength)) {
netpath = link.to + filename.substring(link.fromlength);
@@ -430,7 +430,7 @@ public final class FS extends Globals {
// look through all the pak file elements
pak = search.pack;
filename = filename.toLowerCase();
packfile_t entry = (packfile_t) pak.files.get(filename);
packfile_t entry = pak.files.get(filename);
if (entry != null) {
// found it!
@@ -521,7 +521,7 @@ public final class FS extends Globals {
static pack_t LoadPackFile(String packfile) {
dpackheader_t header;
Hashtable newfiles;
Hashtable<String, packfile_t> newfiles;
RandomAccessFile file;
int numpackfiles = 0;
pack_t pack = null;
@@ -552,7 +552,7 @@ public final class FS extends Globals {
Com.Error(Defines.ERR_FATAL, packfile + " has " + numpackfiles
+ " files");
newfiles = new Hashtable(numpackfiles);
newfiles = new Hashtable<String, packfile_t>(numpackfiles);
packhandle.position(header.dirofs);
@@ -742,8 +742,8 @@ public final class FS extends Globals {
}
// see if the link already exists
for (Iterator it = fs_links.iterator(); it.hasNext();) {
entry = (filelink_t) it.next();
for (Iterator<filelink_t> it = fs_links.iterator(); it.hasNext();) {
entry = it.next();
if (entry.from.equals(Cmd.Argv(1))) {
if (Cmd.Argv(2).length() < 1) {
@@ -770,7 +770,7 @@ public final class FS extends Globals {
* ListFiles
*/
public static String[] ListFiles(String findname, int musthave, int canthave) {
String[] list = null;
String[] list = new String[0];
File[] files = Sys.FindAll(findname, musthave, canthave);
@@ -810,7 +810,7 @@ public final class FS extends Globals {
dirnames = ListFiles(findname, 0, 0);
if (dirnames != null) {
if (dirnames.length != 0) {
int index = 0;
for (int i = 0; i < dirnames.length; i++) {
if ((index = dirnames[i].lastIndexOf('/')) > 0) {
@@ -846,8 +846,8 @@ public final class FS extends Globals {
}
Com.Printf("\nLinks:\n");
for (Iterator it = fs_links.iterator(); it.hasNext();) {
link = (filelink_t) it.next();
for (Iterator<filelink_t> it = fs_links.iterator(); it.hasNext();) {
link = it.next();
Com.Printf(link.from + " : " + link.to + '\n');
}
}

View File

@@ -21,6 +21,7 @@ package lwjake2.qcommon;
/**
* longjmpException is used to replace the setjmp/longjmp code.
*/
@SuppressWarnings("serial")
public final class longjmpException extends IllegalStateException {
}

View File

@@ -29,7 +29,7 @@ import java.util.Vector;
*/
public class Renderer {
static Vector drivers = new Vector(1);
static Vector<Ref> drivers = new Vector<Ref>(1);
static {
try {
@@ -62,7 +62,7 @@ public class Renderer {
Ref driver = null;
int count = drivers.size();
for (int i = 0; i < count; i++) {
driver = (Ref) drivers.get(i);
driver = drivers.get(i);
if (driver.getName().equals(driverName)) {
return driver.GetRefAPI();
}
@@ -72,11 +72,11 @@ public class Renderer {
}
public static String getDefaultName() {
return (drivers.isEmpty()) ? null : ((Ref) drivers.firstElement()).getName();
return (drivers.isEmpty()) ? null : (drivers.firstElement()).getName();
}
public static String getPreferedName() {
return (drivers.isEmpty()) ? null : ((Ref) drivers.lastElement()).getName();
return (drivers.isEmpty()) ? null : (drivers.lastElement()).getName();
}
public static String[] getDriverNames() {
@@ -84,7 +84,7 @@ public class Renderer {
int count = drivers.size();
String[] names = new String[count];
for (int i = 0; i < count; i++) {
names[i] = ((Ref) drivers.get(i)).getName();
names[i] = (drivers.get(i)).getName();
}
return names;
}

View File

@@ -69,7 +69,7 @@ public abstract class LWJGLBase {
modes = Display.getAvailableDisplayModes();
LinkedList l = new LinkedList();
LinkedList<java.awt.DisplayMode> l = new LinkedList<java.awt.DisplayMode>();
l.add(toAwtDisplayMode(oldDisplayMode));
for (int i = 0; i < modes.length; i++) {
@@ -109,7 +109,7 @@ public abstract class LWJGLBase {
try {
DisplayMode[] modes = Display.getAvailableDisplayModes();
LinkedList l = new LinkedList();
LinkedList<DisplayMode> l = new LinkedList<DisplayMode>();
l.add(oldDisplayMode);
for (int i = 0; i < modes.length; i++) {

View File

@@ -34,7 +34,7 @@ public class S {
static Sound impl;
static cvar_t s_impl;
static Vector drivers = new Vector(1);
static Vector<Sound> drivers = new Vector<Sound>(1);
/**
* Searches for and initializes all known sound drivers.
@@ -78,14 +78,14 @@ public class S {
Sound driver = null;
int count = drivers.size();
for (int i = 0; i < count; i++) {
driver = (Sound) drivers.get(i);
driver = drivers.get(i);
if (driver.getName().equals(driverName)) {
impl = driver;
return;
}
}
// if driver not found use dummy
impl = (Sound)drivers.lastElement();
impl = drivers.lastElement();
}
/**
@@ -105,7 +105,7 @@ public class S {
// set the last registered driver as default
String defaultDriver = "dummy";
if (drivers.size() > 1){
defaultDriver = ((Sound)drivers.lastElement()).getName();
defaultDriver = (drivers.lastElement()).getName();
}
s_impl = Cvar.Get("s_impl", defaultDriver, Defines.CVAR_ARCHIVE);
@@ -203,7 +203,7 @@ public class S {
public static String[] getDriverNames() {
String[] names = new String[drivers.size()];
for (int i = 0; i < names.length; i++) {
names[i] = ((Sound)drivers.get(i)).getName();
names[i] = (drivers.get(i)).getName();
}
return names;
}

View File

@@ -56,7 +56,7 @@ public class Channel {
private static IntBuffer sources = Lib.newIntBuffer(MAX_CHANNELS);
// a reference of LWJGLSoundImpl.buffers
private static IntBuffer buffers;
private static Map looptable = new Hashtable(MAX_CHANNELS);
private static Map<Integer, Channel> looptable = new Hashtable<Integer, Channel>(MAX_CHANNELS);
private static int numChannels;
@@ -362,7 +362,7 @@ public class Channel {
sfxcache_t sc;
int num;
entity_state_t ent;
Object key;
int key;
int sound = 0;
for (int i=0 ; i<Globals.cl.frame.num_entities ; i++) {
@@ -372,8 +372,8 @@ public class Channel {
if (sound == 0) continue;
key = new Integer(ent.number);
ch = (Channel)looptable.get(key);
key = ent.number;
ch = looptable.get(key);
if (ch != null) {
// keep on looping
@@ -410,8 +410,8 @@ public class Channel {
private static void removeUnusedLoopSounds() {
Channel ch;
// stop unused loopsounds
for (Iterator iter = looptable.values().iterator(); iter.hasNext();) {
ch = (Channel)iter.next();
for (Iterator<Channel> iter = looptable.values().iterator(); iter.hasNext();) {
ch = iter.next();
if (!ch.autosound) {
AL10.alSourceStop(ch.sourceId);
AL10.alSourcei(ch.sourceId, AL10.AL_LOOPING, AL10.AL_FALSE);

View File

@@ -20,6 +20,8 @@ package lwjake2.sys;
import sun.misc.Perf;
// TODO: Is there an alternative to sun.misc.Perf? - flibit
class HighPrecisionTimer extends Timer {
private Perf perf = Perf.getPerf();

View File

@@ -545,7 +545,7 @@ public class PrintfFormat {
* @return The formatted String.
*/
public String sprintf(Object[] o) {
Enumeration e = vFmt.elements();
Enumeration<Object> e = vFmt.elements();
ConversionSpecification cs = null;
char c = 0;
int i = 0;
@@ -607,7 +607,7 @@ public class PrintfFormat {
* @return the formatted String.
*/
public String sprintf() {
Enumeration e = vFmt.elements();
Enumeration<Object> e = vFmt.elements();
ConversionSpecification cs = null;
char c = 0;
StringBuffer sb = new StringBuffer();
@@ -630,7 +630,7 @@ public class PrintfFormat {
* or S.
*/
public String sprintf(int x) throws IllegalArgumentException {
Enumeration e = vFmt.elements();
Enumeration<Object> e = vFmt.elements();
ConversionSpecification cs = null;
char c = 0;
StringBuffer sb = new StringBuffer();
@@ -655,7 +655,7 @@ public class PrintfFormat {
* or S.
*/
public String sprintf(long x) throws IllegalArgumentException {
Enumeration e = vFmt.elements();
Enumeration<Object> e = vFmt.elements();
ConversionSpecification cs = null;
char c = 0;
StringBuffer sb = new StringBuffer();
@@ -680,7 +680,7 @@ public class PrintfFormat {
* d, d, x, X, or o.
*/
public String sprintf(double x) throws IllegalArgumentException {
Enumeration e = vFmt.elements();
Enumeration<Object> e = vFmt.elements();
ConversionSpecification cs = null;
char c = 0;
StringBuffer sb = new StringBuffer();
@@ -704,7 +704,7 @@ public class PrintfFormat {
* conversion character is neither s nor S.
*/
public String sprintf(String x) throws IllegalArgumentException {
Enumeration e = vFmt.elements();
Enumeration<Object> e = vFmt.elements();
ConversionSpecification cs = null;
char c = 0;
StringBuffer sb = new StringBuffer();
@@ -734,7 +734,7 @@ public class PrintfFormat {
* formatting an unwrapped value.
*/
public String sprintf(Object x) throws IllegalArgumentException {
Enumeration e = vFmt.elements();
Enumeration<Object> e = vFmt.elements();
ConversionSpecification cs = null;
char c = 0;
StringBuffer sb = new StringBuffer();
@@ -3206,7 +3206,7 @@ public class PrintfFormat {
private String fmt;
}
/** Vector of control strings and format literals. */
private Vector vFmt = new Vector();
private Vector<Object> vFmt = new Vector<Object>();
/** Character position. Used by the constructor. */
private int cPos = 0;
/** Character position. Used by the constructor. */

View File

@@ -30,7 +30,7 @@ public class Vargs {
// initial capacity
static final int SIZE = 5;
Vector v;
Vector<Object> v;
public Vargs() {
this(SIZE);
@@ -39,7 +39,7 @@ public class Vargs {
public Vargs(int initialSize) {
if (v != null)
v.clear(); // clear previous list for GC
v = new Vector(initialSize);
v = new Vector<Object>(initialSize);
}
public Vargs add(boolean value) {
@@ -97,12 +97,14 @@ public class Vargs {
return this;
}
/* This apparently isn't even used? - flibit
public Vector toVector() {
// Vector tmp = v;
// v = null;
// return tmp;
return (Vector) v.clone();
}
*/
public Object[] toArray() {
return v.toArray();