diff options
Diffstat (limited to 'src/jake2/qcommon')
-rw-r--r-- | src/jake2/qcommon/Com.java | 7 | ||||
-rw-r--r-- | src/jake2/qcommon/Cvar.java | 15 | ||||
-rw-r--r-- | src/jake2/qcommon/FS.java | 41 | ||||
-rw-r--r-- | src/jake2/qcommon/Q2DataDialog.java | 12 | ||||
-rw-r--r-- | src/jake2/qcommon/Qcommon.java | 6 |
5 files changed, 47 insertions, 34 deletions
diff --git a/src/jake2/qcommon/Com.java b/src/jake2/qcommon/Com.java index d3386d2..9ff3a99 100644 --- a/src/jake2/qcommon/Com.java +++ b/src/jake2/qcommon/Com.java @@ -2,7 +2,7 @@ * Com.java * Copyright (C) 2003 * - * $Id: Com.java,v 1.11 2005-02-06 19:25:55 salomo Exp $ + * $Id: Com.java,v 1.12 2005-06-11 17:21:21 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -400,9 +400,10 @@ public final class Com if (Globals.logfile_active.value > 2) try { - Globals.logfile= new RandomAccessFile(name, "a"); + Globals.logfile = new RandomAccessFile(name, "rw"); + Globals.logfile.seek(Globals.logfile.length()); } - catch (FileNotFoundException e) + catch (Exception e) { // TODO: do quake2 error handling! e.printStackTrace(); diff --git a/src/jake2/qcommon/Cvar.java b/src/jake2/qcommon/Cvar.java index d14cadd..c0aa6ab 100644 --- a/src/jake2/qcommon/Cvar.java +++ b/src/jake2/qcommon/Cvar.java @@ -2,7 +2,7 @@ * Cvar.java * Copyright (C) 2003 * - * $Id: Cvar.java,v 1.7 2005-02-08 18:00:02 cawe Exp $ + * $Id: Cvar.java,v 1.8 2005-05-26 16:56:32 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -294,10 +294,21 @@ public class Cvar extends Globals { /* * ============ Cvar_SetValue ============ */ - public static void SetValue(String var_name, float value) { + // the overloading is very important + // there was a problem with networt "rate" string + // 10000 became "10000.0" and that wasn't right + public static void SetValue(String var_name, int value) { Cvar.Set(var_name, "" + value); } + public static void SetValue(String var_name, float value) { + if (value == (int)value) { + Cvar.Set(var_name, "" + (int)value); + } else { + Cvar.Set(var_name, "" + value); + } + } + /* * ============ Cvar_VariableValue ============ */ diff --git a/src/jake2/qcommon/FS.java b/src/jake2/qcommon/FS.java index 5bab93e..0bea72b 100644 --- a/src/jake2/qcommon/FS.java +++ b/src/jake2/qcommon/FS.java @@ -2,7 +2,7 @@ * FS.java * Copyright (C) 2003 * - * $Id: FS.java,v 1.12 2004-11-10 20:41:40 cawe Exp $ + * $Id: FS.java,v 1.14 2005-05-26 16:56:32 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -36,8 +36,6 @@ import java.nio.ByteOrder; import java.nio.channels.FileChannel; import java.util.*; -import javax.imageio.stream.FileImageInputStream; - /** * FS * @@ -527,24 +525,26 @@ public final class FS extends Globals { dpackheader_t header; Hashtable newfiles; + RandomAccessFile file; int numpackfiles = 0; pack_t pack = null; - RandomAccessFile file; - FileImageInputStream packhandle; // unsigned checksum; // try { - packhandle = new FileImageInputStream(file = new RandomAccessFile( - packfile, "r")); - packhandle.setByteOrder(ByteOrder.LITTLE_ENDIAN); - - if (packhandle.length() < 1) + file = new RandomAccessFile(packfile, "r"); + FileChannel fc = file.getChannel(); + ByteBuffer packhandle = fc.map(FileChannel.MapMode.READ_ONLY, 0, file.length()); + packhandle.order(ByteOrder.LITTLE_ENDIAN); + + fc.close(); + + if (packhandle == null || packhandle.limit() < 1) return null; // header = new dpackheader_t(); - header.ident = packhandle.readInt(); - header.dirofs = packhandle.readInt(); - header.dirlen = packhandle.readInt(); + header.ident = packhandle.getInt(); + header.dirofs = packhandle.getInt(); + header.dirlen = packhandle.getInt(); if (header.ident != IDPAKHEADER) Com.Error(Globals.ERR_FATAL, packfile + " is not a packfile"); @@ -557,18 +557,18 @@ public final class FS extends Globals { newfiles = new Hashtable(numpackfiles); - packhandle.seek(header.dirofs); + packhandle.position(header.dirofs); // parse the directory packfile_t entry = null; for (int i = 0; i < numpackfiles; i++) { - packhandle.readFully(tmpText); + packhandle.get(tmpText); entry = new packfile_t(); entry.name = new String(tmpText).trim(); - entry.filepos = packhandle.readInt(); - entry.filelen = packhandle.readInt(); + entry.filepos = packhandle.getInt(); + entry.filelen = packhandle.getInt(); newfiles.put(entry.name.toLowerCase(), entry); } @@ -659,14 +659,11 @@ public final class FS extends Globals { * ExecAutoexec */ public static void ExecAutoexec() { + String dir = fs_userdir; - String dir; String name; - - dir = Cvar.VariableString("gamedir"); - if (dir != null && dir.length() > 0) { - name = fs_basedir.string + '/' + dir + "/autoexec.cfg"; + name = dir + "/autoexec.cfg"; } else { name = fs_basedir.string + '/' + Globals.BASEDIRNAME + "/autoexec.cfg"; diff --git a/src/jake2/qcommon/Q2DataDialog.java b/src/jake2/qcommon/Q2DataDialog.java index 16c1bf5..2d28629 100644 --- a/src/jake2/qcommon/Q2DataDialog.java +++ b/src/jake2/qcommon/Q2DataDialog.java @@ -2,7 +2,7 @@ * Q2DataDialog.java * Copyright (C) 2003 * - * $Id: Q2DataDialog.java,v 1.13 2005-05-12 12:52:50 hzi Exp $ + * $Id: Q2DataDialog.java,v 1.14 2005-05-26 16:56:32 hzi Exp $ */ package jake2.qcommon; @@ -35,7 +35,7 @@ public class Q2DataDialog extends javax.swing.JDialog { int x = (mode.getWidth() - getWidth()) / 2; int y = (mode.getHeight() - getHeight()) / 2; setLocation(x, y); - dir = home + sep + "jake2" + sep + "baseq2"; + dir = home + sep + "Jake2" + sep + "baseq2"; jTextField1.setText(dir); } @@ -183,7 +183,7 @@ public class Q2DataDialog extends javax.swing.JDialog { } private void okButtonActionPerformed(java.awt.event.ActionEvent evt) { - + dir = jTextField1.getText(); if (dir != null) { Cvar.Set("cddir", dir); FS.setCDDir(); @@ -227,7 +227,7 @@ public class Q2DataDialog extends javax.swing.JDialog { private InstallPanel installPanel; private NotFoundPanel notFoundPanel; private JLabel status; - private javax.swing.JTextField jTextField1; + javax.swing.JTextField jTextField1; private javax.swing.JButton okButton; // End of variables declaration//GEN-END:variables @@ -441,7 +441,7 @@ public class Q2DataDialog extends javax.swing.JDialog { public InstallPanel(Q2DataDialog d) { initComponents(); - String dir = Q2DataDialog.home + Q2DataDialog.sep + "jake2"; + String dir = Q2DataDialog.home + Q2DataDialog.sep + "Jake2"; destDir.setText(dir); initMirrors(); parent = d; @@ -760,7 +760,7 @@ public class Q2DataDialog extends javax.swing.JDialog { void endInstall(String message) { parent.notFoundPanel.message.setText(message); - parent.dir = destDir + "/baseq2"; + parent.jTextField1.setText(destDir + "/baseq2"); parent.showChooseDialog(); parent.okButtonActionPerformed(null); } diff --git a/src/jake2/qcommon/Qcommon.java b/src/jake2/qcommon/Qcommon.java index ed81b71..1035b73 100644 --- a/src/jake2/qcommon/Qcommon.java +++ b/src/jake2/qcommon/Qcommon.java @@ -2,7 +2,7 @@ * Qcommon.java * Copyright 2003 * - * $Id: Qcommon.java,v 1.16 2005-05-14 10:10:45 hzi Exp $ + * $Id: Qcommon.java,v 1.17 2005-05-26 16:56:32 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -246,6 +246,10 @@ public final class Qcommon extends Globals { Cbuf.AddText("exec default.cfg\n"); Cbuf.AddText("bind MWHEELUP weapnext\n"); Cbuf.AddText("bind MWHEELDOWN weapprev\n"); + Cbuf.AddText("bind w +forward\n"); + Cbuf.AddText("bind s +back\n"); + Cbuf.AddText("bind a +moveleft\n"); + Cbuf.AddText("bind d +moveright\n"); Cbuf.Execute(); Cvar.Set("vid_fullscreen", "0"); Cbuf.AddText("exec config.cfg\n"); |