You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(52) |
Aug
(34) |
Sep
(99) |
Oct
(110) |
Nov
(21) |
Dec
(69) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(117) |
Feb
(90) |
Mar
(1) |
Apr
(22) |
May
(96) |
Jun
(25) |
Jul
(22) |
Aug
|
Sep
|
Oct
(18) |
Nov
(43) |
Dec
(71) |
2006 |
Jan
(20) |
Feb
(10) |
Mar
|
Apr
(4) |
May
(2) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
(60) |
Nov
(63) |
Dec
(35) |
2007 |
Jan
(18) |
Feb
(40) |
Mar
(14) |
Apr
(18) |
May
(33) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2008 |
Jan
|
Feb
(1) |
Mar
(25) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(5) |
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(15) |
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Holger Z. <hz...@us...> - 2004-10-04 12:50:49
|
Update of /cvsroot/jake2/jake2/src/jake2/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13966/src/jake2/util Modified Files: Lib.java Log Message: remove Lib.linesplit() Index: Lib.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/util/Lib.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Lib.java 22 Sep 2004 19:22:13 -0000 1.6 --- Lib.java 4 Oct 2004 12:50:38 -0000 1.7 *************** *** 31,35 **** import java.io.*; import java.nio.*; - import java.util.StringTokenizer; import net.java.games.jogl.util.BufferUtils; --- 31,34 ---- *************** *** 239,259 **** return ""; } ! public static String[] linesplit(String in) { ! ! StringTokenizer tk = new StringTokenizer(in, "\r\n"); ! ! int count = tk.countTokens(); ! if (count == 0) ! return new String[] { ! }; ! ! String result[] = new String[count]; ! ! for (int i = 0; tk.hasMoreTokens(); i++) { ! result[i] = tk.nextToken(); ! } ! ! return result; ! } public static int rename(String oldn, String newn) { try { --- 238,242 ---- return ""; } ! public static int rename(String oldn, String newn) { try { |
From: Holger Z. <hz...@us...> - 2004-10-04 12:50:49
|
Update of /cvsroot/jake2/jake2/src/jake2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13966/src/jake2 Modified Files: Defines.java Log Message: remove Lib.linesplit() Index: Defines.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/Defines.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Defines.java 22 Sep 2004 19:22:14 -0000 1.5 --- Defines.java 4 Oct 2004 12:50:38 -0000 1.6 *************** *** 26,31 **** package jake2; - import jake2.game.pmove_t; - import jake2.util.*; public class Defines { --- 26,29 ---- |
From: Holger Z. <hz...@us...> - 2004-10-04 12:50:49
|
Update of /cvsroot/jake2/jake2/src/jake2/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13966/src/jake2/client Modified Files: CL_pred.java CL.java CL_tent.java Menu.java CL_newfx.java Log Message: remove Lib.linesplit() Index: Menu.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/Menu.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Menu.java 27 Sep 2004 19:47:26 -0000 1.10 --- Menu.java 4 Oct 2004 12:50:37 -0000 1.11 *************** *** 1910,1914 **** if (b != null) { creditsBuffer = new String(b); ! String line[] = Lib.linesplit(creditsBuffer); for (n = 0; n < line.length; n++) { --- 1910,1914 ---- if (b != null) { creditsBuffer = new String(b); ! String line[] = creditsBuffer.split("\r\n"); for (n = 0; n < line.length; n++) { *************** *** 2725,2729 **** s = new String(buffer); ! String lines[] = Lib.linesplit(s); nummaps = lines.length; --- 2725,2729 ---- s = new String(buffer); ! String lines[] = s.split("\r\n"); nummaps = lines.length; *************** *** 4493,4497 **** if ((cbd = Sys.GetClipboardData()) != null) { //strtok(cbd, "\n\r\b"); ! String lines[] = Lib.linesplit(cbd); if (lines.length > 0 && lines[0].length() != 0) { //strncpy(f.buffer, cbd, f.length - 1); --- 4493,4497 ---- if ((cbd = Sys.GetClipboardData()) != null) { //strtok(cbd, "\n\r\b"); ! String lines[] = cbd.split("\r\n"); if (lines.length > 0 && lines[0].length() != 0) { //strncpy(f.buffer, cbd, f.length - 1); Index: CL_newfx.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_newfx.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CL_newfx.java 22 Sep 2004 19:22:08 -0000 1.4 --- CL_newfx.java 4 Oct 2004 12:50:37 -0000 1.5 *************** *** 30,34 **** import jake2.Defines; import jake2.Globals; - import jake2.client.CL_fx.cdlight_t; import jake2.util.Lib; import jake2.util.Math3D; --- 30,33 ---- Index: CL_tent.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_tent.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CL_tent.java 22 Sep 2004 19:22:08 -0000 1.5 --- CL_tent.java 4 Oct 2004 12:50:37 -0000 1.6 *************** *** 28,37 **** import jake2.Defines; import jake2.Globals; - import jake2.client.cl_sustain_t.ThinkAdapter; import jake2.game.player_state_t; import jake2.qcommon.Com; import jake2.qcommon.MSG; import jake2.render.model_t; ! import jake2.sound.*; import jake2.util.Lib; import jake2.util.Math3D; --- 28,37 ---- import jake2.Defines; import jake2.Globals; import jake2.game.player_state_t; import jake2.qcommon.Com; import jake2.qcommon.MSG; import jake2.render.model_t; ! import jake2.sound.S; ! import jake2.sound.sfx_t; import jake2.util.Lib; import jake2.util.Math3D; Index: CL_pred.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_pred.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CL_pred.java 22 Sep 2004 19:22:08 -0000 1.5 --- CL_pred.java 4 Oct 2004 12:50:37 -0000 1.6 *************** *** 28,36 **** import jake2.Defines; import jake2.Globals; - import jake2.Defines; - import jake2.game.pmove_t.PointContentsAdapter; - import jake2.game.pmove_t.TraceAdapter; - - import jake2.Globals; import jake2.game.*; import jake2.qcommon.*; --- 28,31 ---- Index: CL.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** CL.java 22 Sep 2004 19:22:08 -0000 1.11 --- CL.java 4 Oct 2004 12:50:37 -0000 1.12 *************** *** 30,40 **** import jake2.game.*; import jake2.qcommon.*; - import jake2.qcommon.qfiles.dmdl_t; import jake2.server.SV_MAIN; ! import jake2.sound.*; import jake2.sys.*; ! import jake2.util.Lib; ! import jake2.util.Math3D; ! import jake2.util.Vargs; import java.io.IOException; --- 30,37 ---- import jake2.game.*; import jake2.qcommon.*; import jake2.server.SV_MAIN; ! import jake2.sound.S; import jake2.sys.*; ! import jake2.util.*; import java.io.IOException; |
From: Carsten W. <ca...@us...> - 2004-09-28 22:48:00
|
Update of /cvsroot/jake2/jake2/src/jake2/game In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3335/src/jake2/game Modified Files: SuperAdapter.java Log Message: instatiate is not necessary Index: SuperAdapter.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/SuperAdapter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SuperAdapter.java 12 Sep 2004 18:25:49 -0000 1.4 --- SuperAdapter.java 28 Sep 2004 22:47:41 -0000 1.5 *************** *** 54,58 **** try { //Com.DPrintf("SuperAdapter.getFromID():loading class->" + classname + "\n"); ! Class.forName(classname).newInstance(); } catch (Exception e) { --- 54,58 ---- try { //Com.DPrintf("SuperAdapter.getFromID():loading class->" + classname + "\n"); ! Class.forName(classname); } catch (Exception e) { |
From: Rene S. <sa...@us...> - 2004-09-27 19:47:37
|
Update of /cvsroot/jake2/jake2/src/jake2/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26619/src/jake2/client Modified Files: Menu.java Log Message: bugs in the server list address menu fixed Index: Menu.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/Menu.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Menu.java 22 Sep 2004 19:22:07 -0000 1.9 --- Menu.java 27 Sep 2004 19:47:26 -0000 1.10 *************** *** 2400,2405 **** return; ! local_server_netadr[m_num_servers] = adr; local_server_names[m_num_servers] = x; m_num_servers++; } --- 2400,2406 ---- return; ! local_server_netadr[m_num_servers].set(adr); local_server_names[m_num_servers] = x; + s_joinserver_server_actions[m_num_servers].name = x; m_num_servers++; } |
From: Holger Z. <hz...@us...> - 2004-09-26 21:12:49
|
Update of /cvsroot/jake2/jake2/src/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8501/src/jake2/qcommon Modified Files: Q2DataDialog.java Log Message: show Kbytes in progress bar Index: Q2DataDialog.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Q2DataDialog.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Q2DataDialog.java 26 Sep 2004 19:58:56 -0000 1.11 --- Q2DataDialog.java 26 Sep 2004 21:12:40 -0000 1.12 *************** *** 11,16 **** import java.awt.*; ! import java.awt.event.ActionEvent; ! import java.awt.event.ActionListener; import java.io.*; import java.net.URL; --- 11,15 ---- import java.awt.*; ! import java.awt.event.*; import java.io.*; import java.net.URL; *************** *** 189,193 **** FS.setCDDir(); } ! synchronized(this) { notifyAll(); --- 188,192 ---- FS.setCDDir(); } ! synchronized(this) { notifyAll(); *************** *** 355,363 **** constraints.insets = new Insets(0, 2, 0, 5); constraints.anchor = GridBagConstraints.WEST; ! add(new JLabel("select baseq2 directory from existing Quake2 installation"), constraints); constraints.gridx = 1; constraints.gridy = 2; ! add(new JLabel("download and install Quake2 demo data (38MB)"), constraints); selection = new ButtonGroup(); --- 354,374 ---- constraints.insets = new Insets(0, 2, 0, 5); constraints.anchor = GridBagConstraints.WEST; ! JLabel label = new JLabel("select baseq2 directory from existing Quake2 installation"); ! label.addMouseListener(new MouseAdapter() { ! public void mouseClicked(MouseEvent e) { ! dir.setSelected(true); ! } ! }); ! add(label, constraints); constraints.gridx = 1; constraints.gridy = 2; ! label = new JLabel("download and install Quake2 demo data (38MB)"); ! label.addMouseListener(new MouseAdapter() { ! public void mouseClicked(MouseEvent e) { ! install.setSelected(true); ! } ! }); ! add(label, constraints); selection = new ButtonGroup(); *************** *** 662,671 **** try { if (!dir.isDirectory() || !dir.canWrite()) { ! endInstall(); return; } } catch (Exception e) { ! endInstall(); return; } --- 673,682 ---- try { if (!dir.isDirectory() || !dir.canWrite()) { ! endInstall("can't write to " + destDir); return; } } catch (Exception e) { ! endInstall(e.getMessage()); return; } *************** *** 676,680 **** int length = conn.getContentLength(); progress.setMaximum(length / 1024); ! in = conn.getInputStream(); --- 687,692 ---- int length = conn.getContentLength(); progress.setMaximum(length / 1024); ! progress.setMinimum(0); ! in = conn.getInputStream(); *************** *** 685,689 **** copyStream(in, out); } catch (Exception e) { ! endInstall(); return; } finally { --- 697,701 ---- copyStream(in, out); } catch (Exception e) { ! endInstall(e.getMessage()); return; } finally { *************** *** 699,703 **** installData(outFile.getCanonicalPath()); } catch (Exception e) { ! endInstall(); return; } --- 711,715 ---- installData(outFile.getCanonicalPath()); } catch (Exception e) { ! endInstall(e.getMessage()); return; } *************** *** 708,714 **** } catch (Exception e) {} ! parent.dir = destDir + "/baseq2"; ! parent.showChooseDialog(); ! parent.okButtonActionPerformed(null); } --- 720,724 ---- } catch (Exception e) {} ! endInstall("installation successful"); } *************** *** 741,745 **** } } catch (Exception e) { ! throw new Exception(); } finally { try {in.close();} catch (Exception e1) {} --- 751,755 ---- } } catch (Exception e) { ! throw e; } finally { try {in.close();} catch (Exception e1) {} *************** *** 748,752 **** } ! void endInstall() { parent.dir = destDir + "/baseq2"; parent.showChooseDialog(); --- 758,763 ---- } ! void endInstall(String message) { ! parent.notFoundPanel.message.setText(message); parent.dir = destDir + "/baseq2"; parent.showChooseDialog(); *************** *** 762,769 **** out.write(buf, 0, l); c += l; ! progress.setValue(c / 1024); } } catch (Exception e) { ! throw new Exception(); } finally { try { --- 773,782 ---- out.write(buf, 0, l); c += l; ! int k = c / 1024; ! progress.setValue(k); ! progress.setString(k + "/" + progress.getMaximum() + " KB"); } } catch (Exception e) { ! throw e; } finally { try { |
From: Holger Z. <hz...@us...> - 2004-09-26 21:09:57
|
Update of /cvsroot/jake2/jake2/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7710/resources Modified Files: mirrors Log Message: working http mirrors Index: mirrors =================================================================== RCS file: /cvsroot/jake2/jake2/resources/mirrors,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mirrors 26 Sep 2004 20:00:40 -0000 1.2 --- mirrors 26 Sep 2004 21:09:46 -0000 1.3 *************** *** 1,10 **** ! HTTP US 3DGamers ! http://3dgamers.intelenet.net/pub/3dgamers/games/quake2/q2-314-demo-x86.exe ! HTTP US 3DGamers ! http://ftp4.3dgamers.com/pub/3dgamers/games/quake2/q2-314-demo-x86.exe ! HTTP NL 3DGamers ! http://3dgamers.gameservers.net/pub/3dgamers/games/quake2/q2-314-demo-x86.exe ! HTTP AU 3DGamers ! http://3dgamers.planetmirror.com/pub/3dgamers/games/quake2/q2-314-demo-x86.exe FTP DE ftp.fu-berlin.de ftp://ftp.fu-berlin.de/pc/msdos/games/idgames/idstuff/quake2/q2-314-demo-x86.exe --- 1,6 ---- ! HTTP xmission ! http://mirrors.xmission.com/idsoftware/quake2/q2-314-demo-x86.exe ! HTTP SE fragzone ! http://ftp.fz.port80.se/spel/quake2/q2-314-demo-x86.exe FTP DE ftp.fu-berlin.de ftp://ftp.fu-berlin.de/pc/msdos/games/idgames/idstuff/quake2/q2-314-demo-x86.exe |
From: Holger Z. <hz...@us...> - 2004-09-26 20:01:07
|
Update of /cvsroot/jake2/jake2/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22308/resources Modified Files: mirrors Log Message: removed my local test mirror Index: mirrors =================================================================== RCS file: /cvsroot/jake2/jake2/resources/mirrors,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mirrors 26 Sep 2004 19:53:22 -0000 1.1 --- mirrors 26 Sep 2004 20:00:40 -0000 1.2 *************** *** 15,18 **** FTP US ftp.idsoftware.com ftp://ftp.idsoftware.com/idstuff/quake2/q2-314-demo-x86.exe - FTP LOC gate - ftp://gate/q2-314-demo-x86.exe \ No newline at end of file --- 15,16 ---- |
From: Holger Z. <hz...@us...> - 2004-09-26 19:59:24
|
Update of /cvsroot/jake2/jake2/src/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21778/src/jake2/qcommon Modified Files: Q2DataDialog.java Log Message: load download mirrors from resource file Index: Q2DataDialog.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Q2DataDialog.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Q2DataDialog.java 26 Sep 2004 18:31:14 -0000 1.10 --- Q2DataDialog.java 26 Sep 2004 19:58:56 -0000 1.11 *************** *** 1,10 **** /* * Q2DataDialog.java ! * ! * Created on 17. September 2004, 20:13 */ package jake2.qcommon; import java.awt.*; import java.awt.event.ActionEvent; --- 1,13 ---- /* * Q2DataDialog.java ! * Copyright (C) 2003 ! * ! * $Id$ */ package jake2.qcommon; + import jake2.Globals; + import java.awt.*; import java.awt.event.ActionEvent; *************** *** 14,17 **** --- 17,21 ---- import java.net.URLConnection; import java.util.Enumeration; + import java.util.Vector; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; *************** *** 20,28 **** import javax.swing.*; ! /** ! * ! * @author hoz ! */ public class Q2DataDialog extends javax.swing.JDialog { public Q2DataDialog() { --- 24,32 ---- import javax.swing.*; ! public class Q2DataDialog extends javax.swing.JDialog { + + static final String home = System.getProperty("user.home"); + static final String sep = System.getProperty("file.separator"); public Q2DataDialog() { *************** *** 34,38 **** int y = (mode.getHeight() - getHeight()) / 2; setLocation(x, y); ! dir = System.getProperty("user.home") + "/jake2"; jTextField1.setText(dir); } --- 38,42 ---- int y = (mode.getHeight() - getHeight()) / 2; setLocation(x, y); ! dir = home + sep + "jake2" + sep + "baseq2"; jTextField1.setText(dir); } *************** *** 414,423 **** static class InstallPanel extends JPanel { ! private static final String[][] mirrors = { ! //{"LOC gate", "ftp://gate/q2-314-demo-x86.exe"}, // local test @home ! {"DE ftp.fu-berlin.de", "ftp://ftp.fu-berlin.de/pc/msdos/games/idgames/idstuff/quake2/q2-314-demo-x86.exe"}, ! {"UK ftp.demon.co.uk", "ftp://ftp.demon.co.uk/pub/mirrors/idsoftware/quake2/q2-314-demo-x86.exe"}, ! {"SE ftp.fragzone.se", "ftp://ftp.fragzone.se/pub/spel/quake2/q2-314-demo-x86.exe"}, ! {"US ftp.idsoftware.com", "ftp://ftp.idsoftware.com/idstuff/quake2/q2-314-demo-x86.exe"} }; private Q2DataDialog parent; private JComboBox mirrorBox; --- 418,423 ---- static class InstallPanel extends JPanel { ! private Vector mirrorNames = new Vector(); ! private Vector mirrorLinks = new Vector(); private Q2DataDialog parent; private JComboBox mirrorBox; *************** *** 430,433 **** --- 430,435 ---- public InstallPanel(Q2DataDialog d) { initComponents(); + String dir = Q2DataDialog.home + Q2DataDialog.sep + "jake2"; + destDir.setText(dir); initMirrors(); parent = d; *************** *** 518,528 **** private void readMirrors() { } private void initMirrors() { readMirrors(); ! for (int i = 0; i < mirrors.length; i++) { ! mirrorBox.addItem(mirrors[i][0]); } } --- 520,552 ---- private void readMirrors() { + InputStream in = getClass().getResourceAsStream("/mirrors"); + BufferedReader r = new BufferedReader(new InputStreamReader(in)); + try { + int i = 0; + while (true) { + String name = r.readLine(); + String value = r.readLine(); + if (name == null || value == null) break; + mirrorNames.add(name); + mirrorLinks.add(value); + } + } catch (Exception e) {} + finally { + try { + r.close(); + } catch (Exception e1) {} + try { + in.close(); + } catch (Exception e1) {} + } } private void initMirrors() { readMirrors(); ! for (int i = 0; i < mirrorNames.size(); i++) { ! mirrorBox.addItem(mirrorNames.get(i)); } + int i = Globals.rnd.nextInt(mirrorNames.size()); + mirrorBox.setSelectedIndex(i); } *************** *** 533,537 **** private void install() { parent.progressPanel.destDir = destDir.getText(); ! parent.progressPanel.mirror = mirrors[mirrorBox.getSelectedIndex()][1]; parent.showProgressPanel(); new Thread(parent.progressPanel).start(); --- 557,561 ---- private void install() { parent.progressPanel.destDir = destDir.getText(); ! parent.progressPanel.mirror = (String)mirrorLinks.get(mirrorBox.getSelectedIndex()); parent.showProgressPanel(); new Thread(parent.progressPanel).start(); *************** *** 565,570 **** JProgressBar progress = new JProgressBar(); ! JLabel label = new JLabel("test"); Q2DataDialog parent; public ProgressPanel(Q2DataDialog d) { --- 589,596 ---- JProgressBar progress = new JProgressBar(); ! JLabel label = new JLabel(""); ! JButton cancel = new JButton("Cancel"); Q2DataDialog parent; + boolean running; public ProgressPanel(Q2DataDialog d) { *************** *** 576,594 **** progress.setMinimum(0); progress.setMaximum(100); setLayout(new GridBagLayout()); GridBagConstraints gridBagConstraints = new GridBagConstraints(); ! gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 1; ! gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); gridBagConstraints.weightx = 1.0; gridBagConstraints.anchor = GridBagConstraints.SOUTH; add(label, gridBagConstraints); gridBagConstraints.gridy = 1; gridBagConstraints.anchor = GridBagConstraints.NORTH; add(progress, gridBagConstraints); Dimension d = new Dimension(400, 100); setMinimumSize(d); --- 602,634 ---- progress.setMinimum(0); progress.setMaximum(100); + progress.setStringPainted(true); setLayout(new GridBagLayout()); GridBagConstraints gridBagConstraints = new GridBagConstraints(); ! gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 1; ! gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; ! gridBagConstraints.insets = new Insets(5, 10, 5, 10); gridBagConstraints.weightx = 1.0; gridBagConstraints.anchor = GridBagConstraints.SOUTH; add(label, gridBagConstraints); + gridBagConstraints.gridy = 1; gridBagConstraints.anchor = GridBagConstraints.NORTH; add(progress, gridBagConstraints); + + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = GridBagConstraints.SOUTH; + gridBagConstraints.fill = GridBagConstraints.NONE; + gridBagConstraints.weighty = 1; + gridBagConstraints.weightx = 0; + cancel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + cancel(); + }}); + add(cancel, gridBagConstraints); + Dimension d = new Dimension(400, 100); setMinimumSize(d); *************** *** 596,602 **** setPreferredSize(d); } public void run() { ! InputStream in = null; OutputStream out = null; --- 636,651 ---- setPreferredSize(d); } + + void cancel() { + synchronized(this) { + running = false; + } + } public void run() { ! synchronized(this) { ! running = true; ! } ! InputStream in = null; OutputStream out = null; *************** *** 710,713 **** --- 759,763 ---- int l; while ((l = in.read(buf)) > 0) { + if (!running) throw new Exception("installation canceled"); out.write(buf, 0, l); c += l; |
From: Holger Z. <hz...@us...> - 2004-09-26 18:31:28
|
Update of /cvsroot/jake2/jake2/src/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28690/src/jake2/qcommon Modified Files: Q2DataDialog.java Log Message: reorganized install dialog Index: Q2DataDialog.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Q2DataDialog.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Q2DataDialog.java 26 Sep 2004 12:07:32 -0000 1.9 --- Q2DataDialog.java 26 Sep 2004 18:31:14 -0000 1.10 *************** *** 65,74 **** choosePanel.setPreferredSize(new java.awt.Dimension(400, 100)); gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; ! gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 2); gridBagConstraints.weightx = 1; choosePanel.add(jTextField1, gridBagConstraints); --- 65,84 ---- choosePanel.setPreferredSize(new java.awt.Dimension(400, 100)); + + gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 0; ! gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 1; ! gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); ! gridBagConstraints.weightx = 0; ! gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST; ! choosePanel.add(new JLabel("baseq2 directory"),gridBagConstraints); ! ! gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; ! gridBagConstraints.insets = new java.awt.Insets(5, 2, 5, 2); gridBagConstraints.weightx = 1; choosePanel.add(jTextField1, gridBagConstraints); *************** *** 89,92 **** --- 99,110 ---- choosePanel.add(changeButton, gridBagConstraints); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridwidth = 4; + gridBagConstraints.weightx = 0; + gridBagConstraints.weighty = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; + choosePanel.add(new JPanel(), gridBagConstraints); + cancelButton.setText("Cancel"); cancelButton.addActionListener(new java.awt.event.ActionListener() { *************** *** 96,100 **** }); gridBagConstraints.gridx = 0; ! gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 4; gridBagConstraints.weighty = 0; --- 114,118 ---- }); gridBagConstraints.gridx = 0; ! gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 4; gridBagConstraints.weighty = 0; *************** *** 110,114 **** }); gridBagConstraints.gridx = 0; ! gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; --- 128,132 ---- }); gridBagConstraints.gridx = 0; ! gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; *************** *** 122,126 **** }); gridBagConstraints.gridx = 2; ! gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST; --- 140,144 ---- }); gridBagConstraints.gridx = 2; ! gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST; *************** *** 249,252 **** --- 267,271 ---- void showNotFoundPanel() { getContentPane().remove(choosePanel); + getContentPane().remove(installPanel); getContentPane().remove(statusPanel); getContentPane().add(notFoundPanel, BorderLayout.SOUTH); *************** *** 321,325 **** constraints.gridy = 0; constraints.gridwidth = 2; ! constraints.insets = new Insets(5, 5, 5, 5); constraints.anchor = GridBagConstraints.CENTER; add(message, constraints); --- 340,344 ---- constraints.gridy = 0; constraints.gridwidth = 2; ! constraints.insets = new Insets(5, 5, 2, 5); constraints.anchor = GridBagConstraints.CENTER; add(message, constraints); *************** *** 468,477 **** constraints.weighty = 1; constraints.fill = GridBagConstraints.NONE; ! cancel = new JButton("Cancel"); ! cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ! cancel(); }}); ! add(cancel, constraints); constraints.gridx = 0; --- 487,496 ---- constraints.weighty = 1; constraints.fill = GridBagConstraints.NONE; ! exit = new JButton("Exit"); ! exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ! exit(); }}); ! add(exit, constraints); constraints.gridx = 0; *************** *** 479,488 **** constraints.gridwidth = 4; constraints.anchor = GridBagConstraints.SOUTH; ! exit = new JButton("Exit"); ! exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ! exit(); }}); ! add(exit, constraints); constraints.gridx = 2; --- 498,507 ---- constraints.gridwidth = 4; constraints.anchor = GridBagConstraints.SOUTH; ! cancel = new JButton("Cancel"); ! cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ! cancel(); }}); ! add(cancel, constraints); constraints.gridx = 2; *************** *** 509,513 **** private void cancel() { ! parent.showChooseDialog(); } --- 528,532 ---- private void cancel() { ! parent.showNotFoundPanel(); } |
From: Holger Z. <hz...@us...> - 2004-09-26 12:07:46
|
Update of /cvsroot/jake2/jake2/src/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29005/src/jake2/qcommon Modified Files: Q2DataDialog.java Log Message: reorganized install dialog Index: Q2DataDialog.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Q2DataDialog.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Q2DataDialog.java 25 Sep 2004 15:17:45 -0000 1.8 --- Q2DataDialog.java 26 Sep 2004 12:07:32 -0000 1.9 *************** *** 26,30 **** public class Q2DataDialog extends javax.swing.JDialog { - /** Creates new form Q2DataDialog */ public Q2DataDialog() { super(); --- 26,29 ---- *************** *** 39,47 **** } - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ private void initComponents() {//GEN-BEGIN:initComponents java.awt.GridBagConstraints gridBagConstraints; --- 38,41 ---- *************** *** 52,56 **** jTextField1 = new javax.swing.JTextField(); changeButton = new javax.swing.JButton(); ! installButton = new javax.swing.JButton(); exitButton = new javax.swing.JButton(); okButton = new javax.swing.JButton(); --- 46,50 ---- jTextField1 = new javax.swing.JTextField(); changeButton = new javax.swing.JButton(); ! cancelButton = new javax.swing.JButton(); exitButton = new javax.swing.JButton(); okButton = new javax.swing.JButton(); *************** *** 67,85 **** choosePanel.setLayout(new java.awt.GridBagLayout()); - choosePanel.setMaximumSize(new java.awt.Dimension(400, 100)); choosePanel.setMinimumSize(new java.awt.Dimension(400, 100)); choosePanel.setPreferredSize(new java.awt.Dimension(400, 100)); ! jTextField1.setPreferredSize(null); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 2; ! gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.weightx = 1.0; choosePanel.add(jTextField1, gridBagConstraints); ! changeButton.setText("change"); changeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { --- 61,78 ---- choosePanel.setLayout(new java.awt.GridBagLayout()); choosePanel.setMaximumSize(new java.awt.Dimension(400, 100)); choosePanel.setMinimumSize(new java.awt.Dimension(400, 100)); choosePanel.setPreferredSize(new java.awt.Dimension(400, 100)); ! gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 3; ! gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; ! gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 2); ! gridBagConstraints.weightx = 1; choosePanel.add(jTextField1, gridBagConstraints); ! changeButton.setText("..."); changeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { *************** *** 87,111 **** } }); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; choosePanel.add(changeButton, gridBagConstraints); ! installButton.setText("Install"); ! installButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ! installButtonActionPerformed(evt); } }); - - gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; ! choosePanel.add(installButton, gridBagConstraints); exitButton.setText("Exit"); --- 80,105 ---- } }); ! gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 1; ! gridBagConstraints.weightx = 0; ! gridBagConstraints.fill = java.awt.GridBagConstraints.NONE; ! gridBagConstraints.insets = new java.awt.Insets(5, 2, 5, 5); gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; choosePanel.add(changeButton, gridBagConstraints); ! cancelButton.setText("Cancel"); ! cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ! cancelButtonActionPerformed(evt); } }); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; ! gridBagConstraints.gridwidth = 4; ! gridBagConstraints.weighty = 0; ! gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); ! gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; ! choosePanel.add(cancelButton, gridBagConstraints); exitButton.setText("Exit"); *************** *** 115,123 **** } }); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); choosePanel.add(exitButton, gridBagConstraints); --- 109,116 ---- } }); ! gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; ! gridBagConstraints.gridwidth = 1; ! gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; choosePanel.add(exitButton, gridBagConstraints); *************** *** 128,141 **** } }); - - gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; ! choosePanel.add(okButton, gridBagConstraints); ! ! //getContentPane().add(choosePanel, java.awt.BorderLayout.SOUTH); Jake2Canvas c = new Jake2Canvas(); getContentPane().add(c, BorderLayout.CENTER); --- 121,131 ---- } }); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; ! gridBagConstraints.gridwidth = 2; ! gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST; ! choosePanel.add(okButton, gridBagConstraints); + Jake2Canvas c = new Jake2Canvas(); getContentPane().add(c, BorderLayout.CENTER); *************** *** 157,175 **** progressPanel = new ProgressPanel(this); installPanel = new InstallPanel(this); pack(); ! }//GEN-END:initComponents ! ! private void installButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_installButtonActionPerformed ! showInstallPanel(); ! }//GEN-LAST:event_installButtonActionPerformed ! ! private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed System.exit(1); dispose(); ! }//GEN-LAST:event_exitButtonActionPerformed ! ! private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed if (dir != null) { --- 147,165 ---- progressPanel = new ProgressPanel(this); installPanel = new InstallPanel(this); + notFoundPanel = new NotFoundPanel(this); pack(); ! } ! private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) { ! showNotFoundPanel(); ! } ! ! private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) { System.exit(1); dispose(); ! } ! ! private void okButtonActionPerformed(java.awt.event.ActionEvent evt) { if (dir != null) { *************** *** 181,185 **** notifyAll(); } ! }//GEN-LAST:event_okButtonActionPerformed private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeButtonActionPerformed --- 171,175 ---- notifyAll(); } ! } private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeButtonActionPerformed *************** *** 208,212 **** private javax.swing.JButton changeButton; private javax.swing.JButton exitButton; ! private javax.swing.JButton installButton; private Jake2Canvas canvas; private javax.swing.JPanel choosePanel; --- 198,202 ---- private javax.swing.JButton changeButton; private javax.swing.JButton exitButton; ! private javax.swing.JButton cancelButton; private Jake2Canvas canvas; private javax.swing.JPanel choosePanel; *************** *** 214,217 **** --- 204,208 ---- private ProgressPanel progressPanel; private InstallPanel installPanel; + private NotFoundPanel notFoundPanel; private JLabel status; private javax.swing.JTextField jTextField1; *************** *** 225,228 **** --- 216,220 ---- getContentPane().remove(progressPanel); getContentPane().remove(installPanel); + getContentPane().remove(notFoundPanel); getContentPane().add(choosePanel, BorderLayout.SOUTH); validate(); *************** *** 249,252 **** --- 241,245 ---- getContentPane().remove(choosePanel); getContentPane().remove(statusPanel); + getContentPane().remove(notFoundPanel); getContentPane().add(installPanel, BorderLayout.SOUTH); validate(); *************** *** 254,257 **** --- 247,258 ---- } + void showNotFoundPanel() { + getContentPane().remove(choosePanel); + getContentPane().remove(statusPanel); + getContentPane().add(notFoundPanel, BorderLayout.SOUTH); + validate(); + repaint(); + } + void setStatus(String text) { status.setText(text); *************** *** 260,264 **** void testQ2Data() { while (FS.LoadFile("pics/colormap.pcx") == null) { ! showChooseDialog(); try { --- 261,265 ---- void testQ2Data() { while (FS.LoadFile("pics/colormap.pcx") == null) { ! showNotFoundPanel(); try { *************** *** 292,299 **** } static class InstallPanel extends JPanel { private static final String[][] mirrors = { ! {"LOC gate", "ftp://gate/q2-314-demo-x86.exe"}, // local test @home {"DE ftp.fu-berlin.de", "ftp://ftp.fu-berlin.de/pc/msdos/games/idgames/idstuff/quake2/q2-314-demo-x86.exe"}, {"UK ftp.demon.co.uk", "ftp://ftp.demon.co.uk/pub/mirrors/idsoftware/quake2/q2-314-demo-x86.exe"}, --- 293,400 ---- } + static class NotFoundPanel extends JPanel { + + private Q2DataDialog parent; + private ButtonGroup selection; + private JRadioButton dir; + private JRadioButton install; + private JButton exit; + private JButton ok; + private JLabel message; + + NotFoundPanel(Q2DataDialog d) { + parent = d; + initComponents(); + } + + private void initComponents() { + GridBagConstraints constraints = new GridBagConstraints(); + setLayout(new GridBagLayout()); + Dimension d = new Dimension(400, 100); + setMinimumSize(d); + setMaximumSize(d); + setPreferredSize(d); + + message = new JLabel("Quake2 level data not found"); + message.setForeground(Color.RED); + constraints.gridx = 0; + constraints.gridy = 0; + constraints.gridwidth = 2; + constraints.insets = new Insets(5, 5, 5, 5); + constraints.anchor = GridBagConstraints.CENTER; + add(message, constraints); + + constraints.gridx = 1; + constraints.gridy = 1; + constraints.gridwidth = 2; + constraints.weightx = 1; + constraints.fill = GridBagConstraints.HORIZONTAL; + constraints.insets = new Insets(0, 2, 0, 5); + constraints.anchor = GridBagConstraints.WEST; + add(new JLabel("select baseq2 directory from existing Quake2 installation"), constraints); + + constraints.gridx = 1; + constraints.gridy = 2; + add(new JLabel("download and install Quake2 demo data (38MB)"), constraints); + + selection = new ButtonGroup(); + dir = new JRadioButton(); + install = new JRadioButton(); + selection.add(dir); + selection.add(install); + + constraints.gridx = 0; + constraints.gridy = 1; + constraints.gridwidth = 1; + constraints.weightx = 0; + constraints.insets = new Insets(0, 5, 0, 2); + constraints.fill = GridBagConstraints.NONE; + constraints.anchor = GridBagConstraints.EAST; + dir.setSelected(true); + add(dir, constraints); + + constraints.gridx = 0; + constraints.gridy = 2; + add(install, constraints); + + constraints.gridx = 0; + constraints.gridy = 3; + constraints.gridwidth = 2; + constraints.weighty = 1; + constraints.insets = new Insets(5, 5, 5, 5); + constraints.fill = GridBagConstraints.NONE; + constraints.anchor = GridBagConstraints.SOUTHWEST; + exit = new JButton("Exit"); + exit.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.exit(0); + }}); + add(exit, constraints); + + constraints.gridx = 2; + constraints.gridy = 3; + constraints.gridwidth = 1; + constraints.anchor = GridBagConstraints.SOUTHEAST; + ok = new JButton("OK"); + ok.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + ok(); + }}); + add(ok, constraints); + } + + private void ok() { + if (dir.isSelected()) { + parent.showChooseDialog(); + } else { + parent.showInstallPanel(); + } + } + } + static class InstallPanel extends JPanel { private static final String[][] mirrors = { ! //{"LOC gate", "ftp://gate/q2-314-demo-x86.exe"}, // local test @home {"DE ftp.fu-berlin.de", "ftp://ftp.fu-berlin.de/pc/msdos/games/idgames/idstuff/quake2/q2-314-demo-x86.exe"}, {"UK ftp.demon.co.uk", "ftp://ftp.demon.co.uk/pub/mirrors/idsoftware/quake2/q2-314-demo-x86.exe"}, *************** *** 397,401 **** --- 498,506 ---- } + private void readMirrors() { + } + private void initMirrors() { + readMirrors(); for (int i = 0; i < mirrors.length; i++) { mirrorBox.addItem(mirrors[i][0]); *************** *** 429,434 **** try { dir = chooser.getSelectedFile().getCanonicalPath(); ! } catch (IOException e) {} ! destDir.setText(dir); } } --- 534,539 ---- try { dir = chooser.getSelectedFile().getCanonicalPath(); ! } catch (Exception e) {} ! if (dir != null) destDir.setText(dir); } } |
From: Holger Z. <hz...@us...> - 2004-09-25 15:18:29
|
Update of /cvsroot/jake2/jake2/src/jake2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13065/src/jake2 Modified Files: Jake2.java Log Message: download mirror selection Index: Jake2.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/Jake2.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Jake2.java 22 Sep 2004 19:22:14 -0000 1.5 --- Jake2.java 25 Sep 2004 15:17:44 -0000 1.6 *************** *** 28,33 **** import jake2.client.SCR; import jake2.qcommon.*; - import jake2.qcommon.Cvar; - import jake2.qcommon.Qcommon; import jake2.sys.Sys; --- 28,31 ---- *************** *** 37,53 **** public final class Jake2 { - static class MemMonitor implements Runnable { - public void run() { - while (true) { - Com.Printf("Memory:" - + (Runtime.getRuntime().totalMemory() - Runtime - .getRuntime().freeMemory()) + "\n"); - try { - Thread.sleep(1000); - } catch (Exception e) { - } - } - } - } public static Q2DataDialog Q2Dialog = new Q2DataDialog(); --- 35,38 ---- *************** *** 63,69 **** Q2Dialog.setVisible(true); - // uncomment to have a memory debugger (RST). - //new Thread(new MemMonitor()).start(); - // in C the first arg is the filename int argc = (args == null) ? 1 : args.length + 1; --- 48,51 ---- |
From: Holger Z. <hz...@us...> - 2004-09-25 15:18:17
|
Update of /cvsroot/jake2/jake2/src/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13065/src/jake2/qcommon Modified Files: Q2DataDialog.java Log Message: download mirror selection Index: Q2DataDialog.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Q2DataDialog.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Q2DataDialog.java 22 Sep 2004 19:22:09 -0000 1.7 --- Q2DataDialog.java 25 Sep 2004 15:17:45 -0000 1.8 *************** *** 8,11 **** --- 8,13 ---- import java.awt.*; + import java.awt.event.ActionEvent; + import java.awt.event.ActionListener; import java.io.*; import java.net.URL; *************** *** 15,18 **** --- 17,21 ---- import java.util.zip.ZipFile; + import javax.imageio.ImageIO; import javax.swing.*; *************** *** 152,155 **** --- 155,159 ---- getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH); + progressPanel = new ProgressPanel(this); installPanel = new InstallPanel(this); *************** *** 159,170 **** private void installButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_installButtonActionPerformed - dir = jTextField1.getText(); showInstallPanel(); - installPanel.destDir = dir; - - dir += "/baseq2"; - jTextField1.setText(dir); - - new Thread(installPanel).start(); }//GEN-LAST:event_installButtonActionPerformed --- 163,167 ---- *************** *** 176,182 **** private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed ! dir = jTextField1.getText(); ! Cvar.Set("cddir", dir); ! FS.setCDDir(); synchronized(this) { --- 173,180 ---- private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed ! if (dir != null) { ! Cvar.Set("cddir", dir); ! FS.setCDDir(); ! } synchronized(this) { *************** *** 196,201 **** try { dir = chooser.getSelectedFile().getCanonicalPath(); ! } catch (IOException e) {} ! jTextField1.setText(dir); }//GEN-LAST:event_changeButtonActionPerformed --- 194,200 ---- try { dir = chooser.getSelectedFile().getCanonicalPath(); ! } catch (Exception e) {} ! if (dir != null) jTextField1.setText(dir); ! else dir = jTextField1.getText(); }//GEN-LAST:event_changeButtonActionPerformed *************** *** 213,216 **** --- 212,216 ---- private javax.swing.JPanel choosePanel; private JPanel statusPanel; + private ProgressPanel progressPanel; private InstallPanel installPanel; private JLabel status; *************** *** 223,226 **** --- 223,227 ---- void showChooseDialog() { getContentPane().remove(statusPanel); + getContentPane().remove(progressPanel); getContentPane().remove(installPanel); getContentPane().add(choosePanel, BorderLayout.SOUTH); *************** *** 231,234 **** --- 232,236 ---- void showStatus() { getContentPane().remove(choosePanel); + getContentPane().remove(installPanel); getContentPane().add(statusPanel, BorderLayout.SOUTH); validate(); *************** *** 236,241 **** --- 238,252 ---- } + void showProgressPanel() { + getContentPane().remove(choosePanel); + getContentPane().remove(installPanel); + getContentPane().add(progressPanel, BorderLayout.SOUTH); + validate(); + repaint(); + } + void showInstallPanel() { getContentPane().remove(choosePanel); + getContentPane().remove(statusPanel); getContentPane().add(installPanel, BorderLayout.SOUTH); validate(); *************** *** 265,274 **** Jake2Canvas() { setSize(400, 200); ! image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/splash.png")); ! while (!Toolkit.getDefaultToolkit().prepareImage(image, -1, -1, null)) { ! try { ! Thread.sleep(50); ! } catch (InterruptedException e) {} ! } } --- 276,283 ---- Jake2Canvas() { setSize(400, 200); ! try { ! image = ImageIO.read(getClass().getResource("/splash.png")); ! } catch (Exception e) {} ! } *************** *** 283,295 **** } ! static class InstallPanel extends JPanel implements Runnable { - static final String[] locs = { - "ftp://ftp.fu-berlin.de/pc/msdos/games/idgames/idstuff/quake2/q2-314-demo-x86.exe", - "ftp://ftp.demon.co.uk/pub/mirrors/idsoftware/quake2/q2-314-demo-x86.exe", - "ftp://ftp.fragzone.se/pub/spel/quake2/q2-314-demo-x86.exe", - "ftp://ftp.idsoftware.com/idstuff/quake2/q2-314-demo-x86.exe" }; static byte[] buf = new byte[8192]; String destDir; JProgressBar progress = new JProgressBar(); --- 292,442 ---- } ! static class InstallPanel extends JPanel { ! ! private static final String[][] mirrors = { ! {"LOC gate", "ftp://gate/q2-314-demo-x86.exe"}, // local test @home ! {"DE ftp.fu-berlin.de", "ftp://ftp.fu-berlin.de/pc/msdos/games/idgames/idstuff/quake2/q2-314-demo-x86.exe"}, ! {"UK ftp.demon.co.uk", "ftp://ftp.demon.co.uk/pub/mirrors/idsoftware/quake2/q2-314-demo-x86.exe"}, ! {"SE ftp.fragzone.se", "ftp://ftp.fragzone.se/pub/spel/quake2/q2-314-demo-x86.exe"}, ! {"US ftp.idsoftware.com", "ftp://ftp.idsoftware.com/idstuff/quake2/q2-314-demo-x86.exe"} }; ! private Q2DataDialog parent; ! private JComboBox mirrorBox; ! private JTextField destDir; ! private JButton cancel; ! private JButton exit; ! private JButton install; ! private JButton choose; ! ! public InstallPanel(Q2DataDialog d) { ! initComponents(); ! initMirrors(); ! parent = d; ! } ! ! private void initComponents() { ! GridBagConstraints constraints = new GridBagConstraints(); ! setLayout(new GridBagLayout()); ! Dimension d = new Dimension(400, 100); ! setMinimumSize(d); ! setMaximumSize(d); ! setPreferredSize(d); ! ! constraints.gridx = 0; ! constraints.gridy = 0; ! constraints.insets = new Insets(5, 5, 0, 5); ! constraints.anchor = GridBagConstraints.SOUTHWEST; ! add(new JLabel("download mirror"), constraints); ! ! constraints.gridx = 0; ! constraints.gridy = 1; ! constraints.insets = new Insets(5, 5, 5, 5); ! add(new JLabel("destination directory"), constraints); ! ! constraints.gridx = 1; ! constraints.gridy = 0; ! constraints.weightx = 1; ! constraints.gridwidth = 3; ! constraints.insets = new Insets(5, 5, 0, 5); ! constraints.fill = GridBagConstraints.HORIZONTAL; ! mirrorBox = new JComboBox(); ! add(mirrorBox, constraints); ! ! constraints.gridx = 1; ! constraints.gridy = 1; ! constraints.gridwidth = 2; ! constraints.fill = GridBagConstraints.BOTH; ! constraints.insets = new Insets(5, 5, 5, 5); ! destDir = new JTextField(); ! add(destDir, constraints); ! ! constraints.gridx = 3; ! constraints.gridy = 1; ! constraints.weightx = 0; ! constraints.gridwidth = 1; ! constraints.fill = GridBagConstraints.NONE; ! choose = new JButton("..."); ! choose.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! choose(); ! }}); ! add(choose, constraints); ! ! constraints.gridx = 0; ! constraints.gridy = 2; ! constraints.gridwidth = 1; ! constraints.weighty = 1; ! constraints.fill = GridBagConstraints.NONE; ! cancel = new JButton("Cancel"); ! cancel.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! cancel(); ! }}); ! add(cancel, constraints); ! ! constraints.gridx = 0; ! constraints.gridy = 2; ! constraints.gridwidth = 4; ! constraints.anchor = GridBagConstraints.SOUTH; ! exit = new JButton("Exit"); ! exit.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! exit(); ! }}); ! add(exit, constraints); ! ! constraints.gridx = 2; ! constraints.gridy = 2; ! constraints.gridwidth = 2; ! constraints.anchor = GridBagConstraints.SOUTHEAST; ! install = new JButton("Install"); ! install.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! install(); ! }}); ! add(install, constraints); ! } ! ! private void initMirrors() { ! for (int i = 0; i < mirrors.length; i++) { ! mirrorBox.addItem(mirrors[i][0]); ! } ! } ! ! private void cancel() { ! parent.showChooseDialog(); ! } ! ! private void install() { ! parent.progressPanel.destDir = destDir.getText(); ! parent.progressPanel.mirror = mirrors[mirrorBox.getSelectedIndex()][1]; ! parent.showProgressPanel(); ! new Thread(parent.progressPanel).start(); ! } ! ! private void exit() { ! System.exit(0); ! } ! ! private void choose() { ! JFileChooser chooser = new JFileChooser(); ! chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); ! chooser.setDialogType(JFileChooser.CUSTOM_DIALOG); ! chooser.setMultiSelectionEnabled(false); ! chooser.setDialogTitle("choose destination directory"); ! chooser.showDialog(this, "OK"); ! ! String dir = null; ! try { ! dir = chooser.getSelectedFile().getCanonicalPath(); ! } catch (IOException e) {} ! destDir.setText(dir); ! } ! } ! ! static class ProgressPanel extends JPanel implements Runnable { static byte[] buf = new byte[8192]; String destDir; + String mirror; JProgressBar progress = new JProgressBar(); *************** *** 297,301 **** Q2DataDialog parent; ! public InstallPanel(Q2DataDialog d) { initComponents(); parent = d; --- 444,448 ---- Q2DataDialog parent; ! public ProgressPanel(Q2DataDialog d) { initComponents(); parent = d; *************** *** 341,370 **** catch (Exception e) {} try { ! if (!dir.isDirectory() || !dir.canWrite()) return; } catch (Exception e) { return; } ! for (int i = 0; i < locs.length; i++) { ! try { ! URL url = new URL(locs[i]); ! URLConnection conn = url.openConnection(); ! int length = conn.getContentLength(); ! progress.setMaximum(length / 1024); ! in = conn.getInputStream(); ! outFile = File.createTempFile("Jake2Data", ".zip"); ! outFile.deleteOnExit(); ! out = new FileOutputStream(outFile); ! copyStream(in, out); ! break; } catch (Exception e) {} } try { installData(outFile.getCanonicalPath()); ! } catch (Exception e) {} --- 488,532 ---- catch (Exception e) {} try { ! if (!dir.isDirectory() || !dir.canWrite()) { ! endInstall(); ! return; ! } } catch (Exception e) { + endInstall(); return; } ! try { ! URL url = new URL(mirror); ! URLConnection conn = url.openConnection(); ! int length = conn.getContentLength(); ! progress.setMaximum(length / 1024); ! in = conn.getInputStream(); ! outFile = File.createTempFile("Jake2Data", ".zip"); ! outFile.deleteOnExit(); ! out = new FileOutputStream(outFile); ! copyStream(in, out); ! } catch (Exception e) { ! endInstall(); ! return; ! } finally { ! try { ! in.close(); } catch (Exception e) {} + try { + out.close(); + } catch (Exception e) {} } + try { installData(outFile.getCanonicalPath()); ! } catch (Exception e) { ! endInstall(); ! return; ! } *************** *** 373,376 **** --- 535,539 ---- } catch (Exception e) {} + parent.dir = destDir + "/baseq2"; parent.showChooseDialog(); parent.okButtonActionPerformed(null); *************** *** 378,382 **** ! void installData(String filename) { try { ZipFile f = new ZipFile(filename); --- 541,547 ---- ! void installData(String filename) throws Exception { ! InputStream in = null; ! OutputStream out = null; try { ZipFile f = new ZipFile(filename); *************** *** 396,409 **** progress.setValue(0); outFile.getParentFile().mkdirs(); ! OutputStream out = new FileOutputStream(outFile); ! InputStream in = f.getInputStream(entry); copyStream(in, out); } } } ! } catch (Exception e) {} } ! void copyStream(InputStream in, OutputStream out) { try { int c = 0; --- 561,585 ---- progress.setValue(0); outFile.getParentFile().mkdirs(); ! out = new FileOutputStream(outFile); ! in = f.getInputStream(entry); copyStream(in, out); } } } ! } catch (Exception e) { ! throw new Exception(); ! } finally { ! try {in.close();} catch (Exception e1) {} ! try {out.close();} catch (Exception e1) {} ! } } ! void endInstall() { ! parent.dir = destDir + "/baseq2"; ! parent.showChooseDialog(); ! parent.okButtonActionPerformed(null); ! } ! ! void copyStream(InputStream in, OutputStream out) throws Exception { try { int c = 0; *************** *** 414,427 **** progress.setValue(c / 1024); } ! } catch (Exception e) {} ! ! try { ! in.close(); ! } catch (Exception e) {} ! try { ! out.close(); ! } catch (Exception e) {} } } ! } --- 590,605 ---- progress.setValue(c / 1024); } ! } catch (Exception e) { ! throw new Exception(); ! } finally { ! try { ! in.close(); ! } catch (Exception e) {} ! try { ! out.close(); ! } catch (Exception e) {} ! } } } ! } |
From: Carsten W. <ca...@us...> - 2004-09-22 20:03:59
|
Update of /cvsroot/jake2/jake2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21871 Modified Files: .classpath Log Message: sackgang Index: .classpath =================================================================== RCS file: /cvsroot/jake2/jake2/.classpath,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** .classpath 22 Sep 2004 19:22:13 -0000 1.5 --- .classpath 22 Sep 2004 20:03:27 -0000 1.6 *************** *** 4,10 **** <classpathentry kind="src" path="test"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="lib" path="resources"/> - <classpathentry kind="lib" path="D:/javajake/jake2sfg/lib/jogl/jogl.jar"/> - <classpathentry kind="lib" path="D:/javajake/jake2sfg/lib/joal/windows/joal.jar"/> <classpathentry kind="output" path="build"/> </classpath> --- 4,11 ---- <classpathentry kind="src" path="test"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="lib" path="lib/joal/linux/joal.jar"/> + <classpathentry kind="lib" path="lib/joal/windows/joal.jar"/> + <classpathentry kind="lib" path="lib/jogl/jogl.jar"/> <classpathentry kind="lib" path="resources"/> <classpathentry kind="output" path="build"/> </classpath> |
Update of /cvsroot/jake2/jake2/src/jake2/game In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11556/src/jake2/game Modified Files: game_import_t.java M_Brain.java M_Flash.java M_Boss32.java M_Gunner.java GameSave.java M_Mutant.java edict_t.java M_Boss2.java M_Float.java M_Flyer.java M_Hover.java M_Actor.java Cmd.java M_Chick.java GameWeapon.java M_Tank.java Fire.java M_Berserk.java PlayerView.java M_Medic.java Info.java GameTarget.java PlayerHud.java GameMisc.java GamePWeapon.java M_Player.java M_Insane.java PlayerTrail.java M_Soldier.java pmove_t.java GameFunc.java gitem_t.java M_Supertank.java M_Boss3.java GameBase.java GameSpawn.java PlayerClientAdapters.java GameTurret.java GameSVCmds.java GameUtil.java M_Parasite.java M_Gladiator.java GameTrigger.java PlayerClient.java game_locals_t.java Monster.java M_Flipper.java M_Infantry.java GameAI.java M_Boss31.java Removed Files: GameTurretAdapters.java GameTargetAdapters.java GameTriggerAdapters.java GameAIAdapters.java GameWeaponAdapters.java M_Rider.java GameUtilAdapters.java GameFuncAdapters.java Game.java M_SoldierAdapters.java GameMiscAdapters.java MonsterAdapters.java GameSpawnAdapters.java Log Message: major refactoring in game, server and client package Index: M_Insane.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/M_Insane.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** M_Insane.java 8 Jul 2004 15:58:44 -0000 1.2 --- M_Insane.java 22 Sep 2004 19:22:03 -0000 1.3 *************** *** 1,959 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...2216 lines suppressed...] ! ! if ((self.spawnflags & 16) != 0) // Stand Ground ! self.monsterinfo.aiflags |= Defines.AI_STAND_GROUND; ! ! self.monsterinfo.currentmove = insane_move_stand_normal; ! ! self.monsterinfo.scale = MODEL_SCALE; ! if ((self.spawnflags & 8) != 0) // Crucified ? ! { ! Math3D.VectorSet(self.mins, -16, 0, 0); ! Math3D.VectorSet(self.maxs, 16, 8, 32); ! self.flags |= Defines.FL_NO_KNOCKBACK; ! GameAI.flymonster_start.think(self); ! } else { ! GameAI.walkmonster_start.think(self); ! self.s.skinnum = Lib.rand() % 3; ! } ! } ! } \ No newline at end of file Index: M_Soldier.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/M_Soldier.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** M_Soldier.java 8 Jul 2004 15:58:44 -0000 1.2 --- M_Soldier.java 22 Sep 2004 19:22:04 -0000 1.3 *************** *** 1,1159 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...3355 lines suppressed...] ! self.monsterinfo.currentmove = soldier_move_duck; ! else ! self.monsterinfo.currentmove = soldier_move_attack3; ! return; ! } ! ! if (GameBase.skill.value >= 2) { ! if (r > 0.66) ! self.monsterinfo.currentmove = soldier_move_duck; ! else ! self.monsterinfo.currentmove = soldier_move_attack3; ! return; ! } ! ! self.monsterinfo.currentmove = soldier_move_attack3; ! } ! }; ! ! } \ No newline at end of file Index: Info.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/Info.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Info.java 10 Sep 2004 19:02:54 -0000 1.3 --- Info.java 22 Sep 2004 19:22:03 -0000 1.4 *************** *** 1,263 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ ! // Created on 27.12.2003 by RST. ! // $Id$ ! package jake2.game; ! import java.util.StringTokenizer; ! import jake2.*; ! import jake2.client.*; ! import jake2.qcommon.*; ! import jake2.render.*; ! import jake2.server.*; ! public class Info extends PlayerView { ! public static String Info_ValueForKey(String s, String key) { ! ! StringTokenizer tk = new StringTokenizer(s, "\\"); ! while (tk.hasMoreTokens()) { ! String key1 = tk.nextToken(); ! ! if (!tk.hasMoreTokens()) { ! Com.Printf("MISSING VALUE\n"); ! return s; ! } ! String value1 = tk.nextToken(); ! if (key.equals(key1)) ! return value1; ! } ! ! return ""; ! } ! /**TODO RST: DANGEROUS port, returns the modified userinfo string, was pointer-pointer manipulation first*/ ! public static String Info_SetValueForKey1(String s, String key, String value) { ! if (value == null || value.length() == 0) ! return s; ! if (key.indexOf('\\') != -1 || value.indexOf('\\') != -1) { ! Com.Printf("Can't use keys or values with a \\\n"); ! return s; ! } ! if (key.indexOf(';') != -1) { ! Com.Printf("Can't use keys or values with a semicolon\n"); ! return s; ! } ! if (key.indexOf('"') != -1 || value.indexOf('"') != -1) { ! Com.Printf("Can't use keys or values with a \"\n"); ! return s; ! } ! if (key.length() > MAX_INFO_KEY - 1 || value.length() > MAX_INFO_KEY - 1) { ! Com.Printf("Keys and values must be < 64 characters.\n"); ! return s; ! } ! StringBuffer sb = new StringBuffer(Info_RemoveKey1(s, key)); ! ! if (sb.length() + 2 + key.length() + value.length() > Defines.MAX_INFO_STRING){ ! ! ! Com.Printf("Info string length exceeded\n"); ! return s; ! } ! ! sb.append('\\').append(key).append('\\').append(value); ! ! return sb.toString(); ! } ! ! ! /** TODO RST: DANGEROUS port, returns now the modified userinfo string.*/ ! public static String Info_RemoveKey1(String s, String key) { ! StringBuffer sb = new StringBuffer(512); ! if (key.indexOf('\\') != -1) { ! Com.Printf("Can't use a key with a \\\n"); ! return s; ! } ! StringTokenizer tk = new StringTokenizer(s, "\\"); ! while (tk.hasMoreTokens()) { ! String key1 = tk.nextToken(); ! ! if (!tk.hasMoreTokens()) { ! Com.Printf("MISSING VALUE\n"); ! return s; ! } ! String value1 = tk.nextToken(); ! if (!key.equals(key1)) ! sb.append('\\').append(key1).append('\\').append(value1); ! } ! return sb.toString(); ! //some old code follows ! /* ! char * start; ! char pkey[512]; ! char value[512]; ! char * o; ! ! if (key.indexOf('\\')!=-1) { ! Com.Printf ("Can't use a key with a \\\n"); ! return s; ! } ! ! while () { ! start = s; ! if (* s == '\\') ! s++; ! o = pkey; ! while (* s != '\\') { ! if (!* s) ! return; ! * o++ = * s++; ! } ! * o = 0; ! s++; ! ! o = value; ! while (* s != '\\' && * s) { ! if (!* s) ! return; ! * o++ = * s++; ! } ! * o = 0; ! ! if (!strcmp(key, pkey)) { ! strcpy(start, s); // remove this part ! return; ! } ! ! if (!* s) ! return; ! } ! */ ! } ! /* ! ================== ! Info_Validate ! ! Some characters are illegal in info strings because they ! can mess up the server's parsing ! ================== ! */ ! public static boolean Info_Validate(String s) { ! if (s.indexOf('"') != -1) ! //return false; ! if (s.indexOf(';') != -1) ! return false; ! return true; ! } ! private static String fillspaces = " "; ! public static void Print(String s) { ! StringBuffer sb = new StringBuffer(512); ! StringTokenizer tk = new StringTokenizer(s, "\\"); ! while (tk.hasMoreTokens()) { ! String key1 = tk.nextToken(); ! if (!tk.hasMoreTokens()) { ! Com.Printf("MISSING VALUE\n"); ! return; ! } ! String value1 = tk.nextToken(); ! sb.append(key1); ! int len = key1.length(); ! if (len < 20) { ! sb.append(fillspaces.substring(len)); ! } ! ! sb.append('=').append(value1).append('\n'); ! } ! Com.Printf(sb.toString()); ! /* some old code follows ! ! char * o; ! int l; ! ! if (* s == '\\') ! s++; ! while (* s) { ! o = key; ! while (* s && * s != '\\') ! * o++ = * s++; ! ! l = o - key; ! if (l < 20) { ! memset(o, ' ', 20 - l); ! key[20] = 0; ! } ! else ! * o = 0; ! Com_Printf("%s", key); ! ! if (!* s) { ! Com_Printf("MISSING VALUE\n"); ! return; ! } ! ! o = value; ! s++; ! while (* s && * s != '\\') ! * o++ = * s++; ! * o = 0; ! ! if (* s) ! s++; ! Com_Printf("%s\n", value); ! } ! */ ! } ! public static void testintern(StringBuffer in) { ! in.setLength(0); ! in.append("123!"); ! } ! } --- 1,211 ---- /* ! * Copyright (C) 1997-2001 Id Software, Inc. ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. ! * ! * See the GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! * ! */ ! // Created on 27.12.2003 by RST. ! // $Id$ ! package jake2.game; ! import jake2.Defines; ! import jake2.qcommon.Com; ! import java.util.StringTokenizer; ! public class Info { ! public static String Info_ValueForKey(String s, String key) { ! StringTokenizer tk = new StringTokenizer(s, "\\"); ! while (tk.hasMoreTokens()) { ! String key1 = tk.nextToken(); ! if (!tk.hasMoreTokens()) { ! Com.Printf("MISSING VALUE\n"); ! return s; ! } ! String value1 = tk.nextToken(); ! if (key.equals(key1)) ! return value1; ! } ! return ""; ! } + /** + * TODO RST: DANGEROUS port, returns the modified userinfo string, was + * pointer-pointer manipulation first + */ + public static String Info_SetValueForKey1(String s, String key, String value) { ! if (value == null || value.length() == 0) ! return s; ! if (key.indexOf('\\') != -1 || value.indexOf('\\') != -1) { ! Com.Printf("Can't use keys or values with a \\\n"); ! return s; ! } ! if (key.indexOf(';') != -1) { ! Com.Printf("Can't use keys or values with a semicolon\n"); ! return s; ! } ! if (key.indexOf('"') != -1 || value.indexOf('"') != -1) { ! Com.Printf("Can't use keys or values with a \"\n"); ! return s; ! } ! if (key.length() > Defines.MAX_INFO_KEY - 1 ! || value.length() > Defines.MAX_INFO_KEY - 1) { ! Com.Printf("Keys and values must be < 64 characters.\n"); ! return s; ! } ! StringBuffer sb = new StringBuffer(Info_RemoveKey1(s, key)); ! if (sb.length() + 2 + key.length() + value.length() > Defines.MAX_INFO_STRING) { ! Com.Printf("Info string length exceeded\n"); ! return s; ! } ! sb.append('\\').append(key).append('\\').append(value); ! return sb.toString(); ! } ! /** TODO RST: DANGEROUS port, returns now the modified userinfo string. */ ! public static String Info_RemoveKey1(String s, String key) { ! StringBuffer sb = new StringBuffer(512); ! if (key.indexOf('\\') != -1) { ! Com.Printf("Can't use a key with a \\\n"); ! return s; ! } ! StringTokenizer tk = new StringTokenizer(s, "\\"); ! while (tk.hasMoreTokens()) { ! String key1 = tk.nextToken(); ! if (!tk.hasMoreTokens()) { ! Com.Printf("MISSING VALUE\n"); ! return s; ! } ! String value1 = tk.nextToken(); ! if (!key.equals(key1)) ! sb.append('\\').append(key1).append('\\').append(value1); ! } ! return sb.toString(); ! //some old code follows ! /* ! * char * start; char pkey[512]; char value[512]; char * o; ! * ! * if (key.indexOf('\\')!=-1) { Com.Printf ("Can't use a key with a ! * \\\n"); return s; } ! * ! * while () { start = s; if (* s == '\\') s++; o = pkey; while (* s != ! * '\\') { if (!* s) return; o++ = * s++; } o = 0; s++; ! * ! * o = value; while (* s != '\\' && * s) { if (!* s) return; o++ = * ! * s++; } o = 0; ! * ! * if (!strcmp(key, pkey)) { strcpy(start, s); // remove this part ! * return; } ! * ! * if (!* s) return; } ! */ ! } ! /* ! * ================== Info_Validate ! * ! * Some characters are illegal in info strings because they can mess up the ! * server's parsing ================== ! */ ! public static boolean Info_Validate(String s) { ! if (s.indexOf('"') != -1) ! //return false; ! if (s.indexOf(';') != -1) ! return false; ! return true; ! } + private static String fillspaces = " "; ! public static void Print(String s) { ! StringBuffer sb = new StringBuffer(512); ! StringTokenizer tk = new StringTokenizer(s, "\\"); ! while (tk.hasMoreTokens()) { ! String key1 = tk.nextToken(); ! if (!tk.hasMoreTokens()) { ! Com.Printf("MISSING VALUE\n"); ! return; ! } ! String value1 = tk.nextToken(); ! sb.append(key1); ! int len = key1.length(); ! if (len < 20) { ! sb.append(fillspaces.substring(len)); ! } ! sb.append('=').append(value1).append('\n'); ! } ! Com.Printf(sb.toString()); ! /* ! * some old code follows ! * ! * char * o; int l; ! * ! * if (* s == '\\') s++; while (* s) { o = key; while (* s && * s != ! * '\\') o++ = * s++; ! * ! * l = o - key; if (l < 20) { memset(o, ' ', 20 - l); key[20] = 0; } ! * else o = 0; Com_Printf("%s", key); ! * ! * if (!* s) { Com_Printf("MISSING VALUE\n"); return; } ! * ! * o = value; s++; while (* s && * s != '\\') o++ = * s++; o = 0; ! * ! * if (* s) s++; Com_Printf("%s\n", value); } ! */ ! } ! public static void testintern(StringBuffer in) { ! in.setLength(0); ! in.append("123!"); ! } ! } \ No newline at end of file Index: M_Parasite.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/M_Parasite.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** M_Parasite.java 8 Jul 2004 15:58:43 -0000 1.2 --- M_Parasite.java 22 Sep 2004 19:22:06 -0000 1.3 *************** *** 1,675 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...1488 lines suppressed...] ! ! static boolean parasite_drain_attack_ok(float[] start, float[] end) { ! float[] dir = { 0, 0, 0 }, angles = { 0, 0, 0 }; ! ! // check for max distance ! Math3D.VectorSubtract(start, end, dir); ! if (Math3D.VectorLength(dir) > 256) ! return false; ! ! // check for min/max pitch ! Math3D.vectoangles(dir, angles); ! if (angles[0] < -180) ! angles[0] += 360; ! if (Math.abs(angles[0]) > 30) ! return false; ! ! return true; ! } ! } \ No newline at end of file Index: M_Float.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/M_Float.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** M_Float.java 8 Jul 2004 15:58:44 -0000 1.2 --- M_Float.java 22 Sep 2004 19:22:01 -0000 1.3 *************** *** 1,1007 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...2191 lines suppressed...] ! self.monsterinfo.run = floater_run; ! // self.monsterinfo.dodge = floater_dodge; ! self.monsterinfo.attack = floater_attack; ! self.monsterinfo.melee = floater_melee; ! self.monsterinfo.sight = floater_sight; ! self.monsterinfo.idle = floater_idle; ! ! GameBase.gi.linkentity(self); ! ! if (Lib.random() <= 0.5) ! self.monsterinfo.currentmove = floater_move_stand1; ! else ! self.monsterinfo.currentmove = floater_move_stand2; ! ! self.monsterinfo.scale = MODEL_SCALE; ! ! GameAI.flymonster_start.think(self); ! } ! } \ No newline at end of file --- M_Rider.java DELETED --- --- GameWeaponAdapters.java DELETED --- --- GameUtilAdapters.java DELETED --- Index: GameTrigger.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameTrigger.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GameTrigger.java 8 Jul 2004 15:58:44 -0000 1.2 --- GameTrigger.java 22 Sep 2004 19:22:06 -0000 1.3 *************** *** 1,25 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! ! See the GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! ! */ // Created on 27.12.2003 by RST. // $Id$ - package jake2.game; --- 1,24 ---- /* ! * Copyright (C) 1997-2001 Id Software, Inc. ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. ! * ! * See the GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! * ! */ // Created on 27.12.2003 by RST. // $Id$ package jake2.game; *************** *** 32,239 **** import jake2.util.Math3D; ! public class GameTrigger extends M_Player { ! public static void InitTrigger(edict_t self) { ! if (Math3D.VectorCompare(self.s.angles, vec3_origin) != 0) ! G_SetMovedir(self.s.angles, self.movedir); ! self.solid = SOLID_TRIGGER; ! self.movetype = MOVETYPE_NONE; ! gi.setmodel(self, self.model); ! self.svflags = SVF_NOCLIENT; ! } ! // the trigger was just activated ! // ent.activator should be set to the activator so it can be held through a delay ! // so wait for the delay time before firing ! public static void multi_trigger(edict_t ent) { ! if (ent.nextthink != 0) ! return; // already been triggered ! G_UseTargets(ent, ent.activator); ! if (ent.wait > 0) { ! ent.think = GameTriggerAdapters.multi_wait; ! ent.nextthink = level.time + ent.wait; ! } ! else { // we can't just remove (self) here, because this is a touch function ! // called while looping through area links... ! ent.touch = null; ! ent.nextthink = level.time + FRAMETIME; ! ent.think = GameUtilAdapters.G_FreeEdictA; ! } ! } ! public static void SP_trigger_multiple(edict_t ent) { ! if (ent.sounds == 1) ! ent.noise_index = gi.soundindex("misc/secret.wav"); ! else if (ent.sounds == 2) ! ent.noise_index = gi.soundindex("misc/talk.wav"); ! else if (ent.sounds == 3) ! ent.noise_index = gi.soundindex("misc/trigger1.wav"); ! if (ent.wait == 0) ! ent.wait = 0.2f; ! ! ent.touch = GameTriggerAdapters.Touch_Multi; ! ent.movetype = MOVETYPE_NONE; ! ent.svflags |= SVF_NOCLIENT; ! if ((ent.spawnflags & 4) != 0) { ! ent.solid = SOLID_NOT; ! ent.use = GameTriggerAdapters.trigger_enable; ! } ! else { ! ent.solid = SOLID_TRIGGER; ! ent.use = GameTriggerAdapters.Use_Multi; ! } ! if (0 == Math3D.VectorCompare(ent.s.angles, vec3_origin)) ! G_SetMovedir(ent.s.angles, ent.movedir); ! gi.setmodel(ent, ent.model); ! gi.linkentity(ent); ! } ! /*QUAKED trigger_once (.5 .5 .5) ? x x TRIGGERED ! Triggers once, then removes itself. ! You must set the key "target" to the name of another object in the level that has a matching "targetname". ! ! If TRIGGERED, this trigger must be triggered before it is live. ! ! sounds ! 1) secret ! 2) beep beep ! 3) large switch ! 4) ! ! "message" string to be displayed when triggered ! */ ! public static void SP_trigger_once(edict_t ent) { ! // make old maps work because I messed up on flag assignments here ! // triggered was on bit 1 when it should have been on bit 4 ! if ((ent.spawnflags & 1) != 0) { ! float[] v = { 0, 0, 0 }; ! VectorMA(ent.mins, 0.5f, ent.size, v); ! ent.spawnflags &= ~1; ! ent.spawnflags |= 4; ! gi.dprintf("fixed TRIGGERED flag on " + ent.classname + " at " + vtos(v) + "\n"); ! } ! ent.wait = -1; ! SP_trigger_multiple(ent); ! } ! public static void SP_trigger_relay(edict_t self) { ! self.use = GameTriggerAdapters.trigger_relay_use; ! } ! public static void SP_trigger_key(edict_t self) { ! if (st.item == null) { ! gi.dprintf("no key item for trigger_key at " + vtos(self.s.origin) + "\n"); ! return; ! } ! self.item = FindItemByClassname(st.item); ! if (null == self.item) { ! gi.dprintf("item " + st.item + " not found for trigger_key at " + vtos(self.s.origin) + "\n"); ! return; ! } ! if (self.target == null) { ! gi.dprintf(self.classname + " at " + vtos(self.s.origin) + " has no target\n"); ! return; ! } ! gi.soundindex("misc/keytry.wav"); ! gi.soundindex("misc/keyuse.wav"); ! self.use = GameTriggerAdapters.trigger_key_use; ! } ! public static void SP_trigger_counter(edict_t self) { ! self.wait = -1; ! if (0 == self.count) ! self.count = 2; ! self.use = GameTriggerAdapters.trigger_counter_use; ! } ! /* ! ============================================================================== ! ! trigger_always ! ! ============================================================================== ! */ ! /*QUAKED trigger_always (.5 .5 .5) (-8 -8 -8) (8 8 8) ! This trigger will always fire. It is activated by the world. ! */ ! public static void SP_trigger_always(edict_t ent) { ! // we must have some delay to make sure our use targets are present ! if (ent.delay < 0.2f) ! ent.delay = 0.2f; ! G_UseTargets(ent, ent); ! } ! /*QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE ! Pushes the player ! "speed" defaults to 1000 ! */ ! public static void SP_trigger_push(edict_t self) { ! InitTrigger(self); ! GameTriggerAdapters.windsound = gi.soundindex("misc/windfly.wav"); ! self.touch = GameTriggerAdapters.trigger_push_touch; ! if (0 == self.speed) ! self.speed = 1000; ! gi.linkentity(self); ! } ! public static void SP_trigger_hurt(edict_t self) { ! InitTrigger(self); ! self.noise_index = gi.soundindex("world/electro.wav"); ! self.touch = GameTriggerAdapters.hurt_touch; ! if (0 == self.dmg) ! self.dmg = 5; ! if ((self.spawnflags & 1) != 0) ! self.solid = SOLID_NOT; ! else ! self.solid = SOLID_TRIGGER; ! if ((self.spawnflags & 2) != 0) ! self.use = GameTriggerAdapters.hurt_use; ! gi.linkentity(self); ! } ! public static void SP_trigger_gravity(edict_t self) { ! if (st.gravity == null) { ! gi.dprintf("trigger_gravity without gravity set at " + vtos(self.s.origin) + "\n"); ! G_FreeEdict(self); ! return; ! } ! InitTrigger(self); ! self.gravity = atoi(st.gravity); ! self.touch = GameTriggerAdapters.trigger_gravity_touch; ! } ! public static void SP_trigger_monsterjump(edict_t self) { ! if (0 == self.speed) ! self.speed = 200; ! if (0 == st.height) ! st.height = 200; ! if (self.s.angles[YAW] == 0) ! self.s.angles[YAW] = 360; ! InitTrigger(self); ! self.touch = GameTriggerAdapters.trigger_monsterjump_touch; ! self.movedir[2] = st.height; ! } ! } --- 31,595 ---- import jake2.util.Math3D; ! public class GameTrigger { ! public static void InitTrigger(edict_t self) { ! if (Math3D.VectorCompare(self.s.angles, Globals.vec3_origin) != 0) ! GameBase.G_SetMovedir(self.s.angles, self.movedir); ! self.solid = Defines.SOLID_TRIGGER; ! self.movetype = Defines.MOVETYPE_NONE; ! GameBase.gi.setmodel(self, self.model); ! self.svflags = Defines.SVF_NOCLIENT; ! } ! // the trigger was just activated ! // ent.activator should be set to the activator so it can be held through a ! // delay ! // so wait for the delay time before firing ! public static void multi_trigger(edict_t ent) { ! if (ent.nextthink != 0) ! return; // already been triggered ! GameUtil.G_UseTargets(ent, ent.activator); ! if (ent.wait > 0) { ! ent.think = GameTrigger.multi_wait; ! ent.nextthink = GameBase.level.time + ent.wait; ! } else { // we can't just remove (self) here, because this is a touch ! // function ! // called while looping through area links... ! ent.touch = null; ! ent.nextthink = GameBase.level.time + Defines.FRAMETIME; ! ent.think = GameUtil.G_FreeEdictA; ! } ! } ! public static void SP_trigger_multiple(edict_t ent) { ! if (ent.sounds == 1) ! ent.noise_index = GameBase.gi.soundindex("misc/secret.wav"); ! else if (ent.sounds == 2) ! ent.noise_index = GameBase.gi.soundindex("misc/talk.wav"); ! else if (ent.sounds == 3) ! ent.noise_index = GameBase.gi.soundindex("misc/trigger1.wav"); ! if (ent.wait == 0) ! ent.wait = 0.2f; ! ent.touch = GameTrigger.Touch_Multi; ! ent.movetype = Defines.MOVETYPE_NONE; ! ent.svflags |= Defines.SVF_NOCLIENT; ! if ((ent.spawnflags & 4) != 0) { ! ent.solid = Defines.SOLID_NOT; ! ent.use = GameTrigger.trigger_enable; ! } else { ! ent.solid = Defines.SOLID_TRIGGER; ! ent.use = GameTrigger.Use_Multi; ! } ! if (0 == Math3D.VectorCompare(ent.s.angles, Globals.vec3_origin)) ! GameBase.G_SetMovedir(ent.s.angles, ent.movedir); ! GameBase.gi.setmodel(ent, ent.model); ! GameBase.gi.linkentity(ent); ! } ! /* ! * QUAKED trigger_once (.5 .5 .5) ? x x TRIGGERED Triggers once, then ! * removes itself. You must set the key "target" to the name of another ! * object in the level that has a matching "targetname". ! * ! * If TRIGGERED, this trigger must be triggered before it is live. ! * ! * sounds 1) secret 2) beep beep 3) large switch 4) ! * ! * "message" string to be displayed when triggered ! */ ! public static void SP_trigger_once(edict_t ent) { ! // make old maps work because I messed up on flag assignments here ! // triggered was on bit 1 when it should have been on bit 4 ! if ((ent.spawnflags & 1) != 0) { ! float[] v = { 0, 0, 0 }; ! Math3D.VectorMA(ent.mins, 0.5f, ent.size, v); ! ent.spawnflags &= ~1; ! ent.spawnflags |= 4; ! GameBase.gi.dprintf("fixed TRIGGERED flag on " + ent.classname ! + " at " + Lib.vtos(v) + "\n"); ! } ! ent.wait = -1; ! SP_trigger_multiple(ent); ! } ! public static void SP_trigger_relay(edict_t self) { ! self.use = GameTrigger.trigger_relay_use; ! } ! public static void SP_trigger_key(edict_t self) { ! if (GameBase.st.item == null) { ! GameBase.gi.dprintf("no key item for trigger_key at " ! + Lib.vtos(self.s.origin) + "\n"); ! return; ! } ! self.item = GameUtil.FindItemByClassname(GameBase.st.item); ! if (null == self.item) { ! GameBase.gi.dprintf("item " + GameBase.st.item ! + " not found for trigger_key at " ! + Lib.vtos(self.s.origin) + "\n"); ! return; ! } ! if (self.target == null) { ! GameBase.gi.dprintf(self.classname + " at " ! + Lib.vtos(self.s.origin) + " has no target\n"); ! return; ! } ! GameBase.gi.soundindex("misc/keytry.wav"); ! GameBase.gi.soundindex("misc/keyuse.wav"); ! self.use = GameTrigger.trigger_key_use; ! } ! public static void SP_trigger_counter(edict_t self) { ! self.wait = -1; ! if (0 == self.count) ! self.count = 2; ! self.use = GameTrigger.trigger_counter_use; ! } ! /* ! * ============================================================================== ! * ! * trigger_always ! * ! * ============================================================================== ! */ ! /* ! * QUAKED trigger_always (.5 .5 .5) (-8 -8 -8) (8 8 8) This trigger will ! * always fire. It is activated by the world. ! */ ! public static void SP_trigger_always(edict_t ent) { ! // we must have some delay to make sure our use targets are present ! if (ent.delay < 0.2f) ! ent.delay = 0.2f; ! GameUtil.G_UseTargets(ent, ent); ! } ! /* ! * QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE Pushes the player "speed" ! * defaults to 1000 ! */ ! public static void SP_trigger_push(edict_t self) { ! InitTrigger(self); ! GameTrigger.windsound = GameBase.gi.soundindex("misc/windfly.wav"); ! self.touch = GameTrigger.trigger_push_touch; ! if (0 == self.speed) ! self.speed = 1000; ! GameBase.gi.linkentity(self); ! } ! public static void SP_trigger_hurt(edict_t self) { ! InitTrigger(self); ! self.noise_index = GameBase.gi.soundindex("world/electro.wav"); ! self.touch = GameTrigger.hurt_touch; ! if (0 == self.dmg) ! self.dmg = 5; ! if ((self.spawnflags & 1) != 0) ! self.solid = Defines.SOLID_NOT; ! else ! self.solid = Defines.SOLID_TRIGGER; ! if ((self.spawnflags & 2) != 0) ! self.use = GameTrigger.hurt_use; ! GameBase.gi.linkentity(self); ! } ! public static void SP_trigger_gravity(edict_t self) { ! if (GameBase.st.gravity == null) { ! GameBase.gi.dprintf("trigger_gravity without gravity set at " ! + Lib.vtos(self.s.origin) + "\n"); ! GameUtil.G_FreeEdict(self); ! return; ! } ! InitTrigger(self); ! self.gravity = Lib.atoi(GameBase.st.gravity); ! self.touch = GameTrigger.trigger_gravity_touch; ! } ! public static void SP_trigger_monsterjump(edict_t self) { ! if (0 == self.speed) ! self.speed = 200; ! if (0 == GameBase.st.height) ! GameBase.st.height = 200; ! if (self.s.angles[Defines.YAW] == 0) ! self.s.angles[Defines.YAW] = 360; ! InitTrigger(self); ! self.touch = GameTrigger.trigger_monsterjump_touch; ! self.movedir[2] = GameBase.st.height; ! } ! ! // the wait time has passed, so set back up for another activation ! public static EntThinkAdapter multi_wait = new EntThinkAdapter() { ! public boolean think(edict_t ent) { ! ! ent.nextthink = 0; ! return true; ! } ! }; ! ! static EntUseAdapter Use_Multi = new EntUseAdapter() { ! public void use(edict_t ent, edict_t other, edict_t activator) { ! ent.activator = activator; ! GameTrigger.multi_trigger(ent); ! } ! }; ! ! static EntTouchAdapter Touch_Multi = new EntTouchAdapter() { ! public void touch(edict_t self, edict_t other, cplane_t plane, ! csurface_t surf) { ! if (other.client != null) { ! if ((self.spawnflags & 2) != 0) ! return; ! } else if ((other.svflags & Defines.SVF_MONSTER) != 0) { ! if (0 == (self.spawnflags & 1)) ! return; ! } else ! return; ! ! if (0 == Math3D.VectorCompare(self.movedir, Globals.vec3_origin)) { ! float[] forward = { 0, 0, 0 }; ! ! Math3D.AngleVectors(other.s.angles, forward, null, null); ! if (Math3D.DotProduct(forward, self.movedir) < 0) ! return; ! } ! ! self.activator = other; ! GameTrigger.multi_trigger(self); ! } ! }; ! ! /* ! * QUAKED trigger_multiple (.5 .5 .5) ? MONSTER NOT_PLAYER TRIGGERED ! * Variable sized repeatable trigger. Must be targeted at one or more ! * entities. If "delay" is set, the trigger waits some time after activating ! * before firing. "wait" : Seconds between triggerings. (.2 default) sounds ! * 1) secret 2) beep beep 3) large switch 4) set "message" to text string ! */ ! static EntUseAdapter trigger_enable = new EntUseAdapter() { ! public void use(edict_t self, edict_t other, edict_t activator) { ! self.solid = Defines.SOLID_TRIGGER; ! self.use = Use_Multi; ! GameBase.gi.linkentity(self); ! } ! }; ! ! /* ! * QUAKED trigger_relay (.5 .5 .5) (-8 -8 -8) (8 8 8) This fixed size ! * trigger cannot be touched, it can only be fired by other events. ! */ ! public static EntUseAdapter trigger_relay_use = new EntUseAdapter() { ! public void use(edict_t self, edict_t other, edict_t activator) { ! GameUtil.G_UseTargets(self, activator); ! } ! }; ! ! /* ! * ============================================================================== ! * ! * trigger_key ! * ! * ============================================================================== ! */ ! ! /* ! * QUAKED trigger_key (.5 .5 .5) (-8 -8 -8) (8 8 8) A relay trigger that ! * only fires it's targets if player has the proper key. Use "item" to ! * specify the required key, for example "key_data_cd" ! */ ! ! static EntUseAdapter trigger_key_use = new EntUseAdapter() { ! public void use(edict_t self, edict_t other, edict_t activator) { ! int index; ! ! if (self.item == null) ! return; ! if (activator.client == null) ! return; ! ! index = GameUtil.ITEM_INDEX(self.item); ! if (activator.client.pers.inventory[index] == 0) { ! if (GameBase.level.time < self.touch_debounce_time) ! return; ! self.touch_debounce_time = GameBase.level.time + 5.0f; ! GameBase.gi.centerprintf(activator, "You need the " ! + self.item.pickup_name); ! GameBase.gi ! .sound(activator, Defines.CHAN_AUTO, GameBase.gi ! .soundindex("misc/keytry.wav"), 1, ! Defines.ATTN_NORM, 0); ! return; ! } ! ! GameBase.gi.sound(activator, Defines.CHAN_AUTO, GameBase.gi ! .soundindex("misc/keyuse.wav"), 1, Defines.ATTN_NORM, 0); ! if (GameBase.coop.value != 0) { ! int player; ! edict_t ent; ! ! if (Lib.strcmp(self.item.classname, "key_power_cube") == 0) { ! int cube; ! ! for (cube = 0; cube < 8; cube++) ! if ((activator.client.pers.power_cubes & (1 << cube)) != 0) ! break; ! for (player = 1; player <= GameBase.game.maxclients; player++) { ! ent = GameBase.g_edicts[player]; ! if (!ent.inuse) ! continue; ! if (null == ent.client) ! continue; ! if ((ent.client.pers.power_cubes & (1 << cube)) != 0) { ! ent.client.pers.inventory[index]--; ! ent.client.pers.power_cubes &= ~(1 << cube); ! } ! } ! } else { ! for (player = 1; player <= GameBase.game.maxclients; player++) { ! ent = GameBase.g_edicts[player]; ! if (!ent.inuse) ! continue; ! if (ent.client == null) ! continue; ! ent.client.pers.inventory[index] = 0; ! } ! } ! } else { ! activator.client.pers.inventory[index]--; ! } ! ! GameUtil.G_UseTargets(self, activator); ! ! self.use = null; ! } ! }; ! ! /* ! * ============================================================================== ! * ! * trigger_counter ! * ! * ============================================================================== ! */ ! ! /* ! * QUAKED trigger_counter (.5 .5 .5) ? nomessage Acts as an intermediary for ! * an action that takes multiple inputs. ! * ! * If nomessage is not set, t will print "1 more.. " etc when triggered and ! * "sequence complete" when finished. ! * ! * After the counter has been triggered "count" times (default 2), it will ! * fire all of it's targets and remove itself. ! */ ! static EntUseAdapter trigger_counter_use = new EntUseAdapter() { ! ! public void use(edict_t self, edict_t other, edict_t activator) { ! if (self.count == 0) ! return; ! ! self.count--; ! ! if (self.count == 0) { ! if (0 == (self.spawnflags & 1)) { ! GameBase.gi.centerprintf(activator, self.count ! + " more to go..."); ! GameBase.gi.sound(activator, Defines.CHAN_AUTO, GameBase.gi ! .soundindex("misc/talk1.wav"), 1, ! Defines.ATTN_NORM, 0); ! } ! return; ! } ! ! if (0 == (self.spawnflags & 1)) { ! GameBase.gi.centerprintf(activator, "Sequence completed!"); ! GameBase.gi.sound(activator, Defines.CHAN_AUTO, GameBase.gi ! .soundindex("misc/talk1.wav"), 1, Defines.ATTN_NORM, 0); ! } ! self.activator = activator; ! GameTrigger.multi_trigger(self); ! } ! }; ! ! /* ! * ============================================================================== ! * ! * trigger_push ! * ! * ============================================================================== ! */ ! ! public static final int PUSH_ONCE = 1; ! ! public static int windsound; ! ! static EntTouchAdapter trigger_push_touch = new EntTouchAdapter() { ! public void touch(edict_t self, edict_t other, cplane_t plane, ! csurface_t surf) { ! if (Lib.strcmp(other.classname, "grenade") == 0) { ! Math3D.VectorScale(self.movedir, self.speed * 10, ! other.velocity); ! } else if (other.health > 0) { ! Math3D.VectorScale(self.movedir, self.speed * 10, ! other.velocity); ! ! if (other.client != null) { ! // don't take falling damage immediately from this ! Math3D.VectorCopy(other.velocity, other.client.oldvelocity); ! if (other.fly_sound_debounce_time < GameBase.level.time) { ! other.fly_sound_debounce_time = GameBase.level.time + 1.5f; ! GameBase.gi.sound(other, Defines.CHAN_AUTO, windsound, ! 1, Defines.ATTN_NORM, 0); ! } ! } ! } ! if ((self.spawnflags & PUSH_ONCE) != 0) ! GameUtil.G_FreeEdict(self); ! } ! }; ! ! /* ! * ============================================================================== ! * ! * trigger_hurt ! * ! * ============================================================================== ! */ ! ! /* ! * QUAKED trigger_hurt (.5 .5 .5) ? START_OFF TOGGLE SILENT NO_PROTECTION ! * SLOW Any entity that touches this will be hurt. ! * ! * It does dmg points of damage each server frame ! * ! * SILENT supresses playing the sound SLOW changes the damage rate to once ! * per second NO_PROTECTION *nothing* stops the damage ! * ! * "dmg" default 5 (whole numbers only) ! * ! */ ! static EntUseAdapter hurt_use = new EntUseAdapter() { ! ! public void use(edict_t self, edict_t other, edict_t activator) { ! if (self.solid == Defines.SOLID_NOT) ! self.solid = Defines.SOLID_TRIGGER; ! else ! self.solid = Defines.SOLID_NOT; ! GameBase.gi.linkentity(self); ! ! if (0 == (self.spawnflags & 2)) ! self.use = null; ! } ! }; ! ! static EntTouchAdapter hurt_touch = new EntTouchAdapter() { ! public void touch(edict_t self, edict_t other, cplane_t plane, ! csurface_t surf) { ! int dflags; ! ! if (other.takedamage == 0) ! return; ! ! if (self.timestamp > GameBase.level.time) ! return; ! ! if ((self.spawnflags & 16) != 0) ! self.timestamp = GameBase.level.time + 1; ! else ! self.timestamp = GameBase.level.time + Defines.FRAMETIME; ! ! if (0 == (self.spawnflags & 4)) { ! if ((GameBase.level.framenum % 10) == 0) ! GameBase.gi.sound(other, Defines.CHAN_AUTO, ! self.noise_index, 1, Defines.ATTN_NORM, 0); ! } ! ! if ((self.spawnflags & 8) != 0) ! dflags = Defines.DAMAGE_NO_PROTECTION; ! else ! dflags = 0; ! GameUtil.T_Damage(other, self, self, Globals.vec3_origin, ! other.s.origin, Globals.vec3_origin, self.dmg, self.dmg, ! dflags, Defines.MOD_TRIGGER_HURT); ! } ! }; ! ! /* ! * ============================================================================== ! * ! * trigger_gravity ! * ! * ============================================================================== ! */ ! ! /* ! * QUAKED trigger_gravity (.5 .5 .5) ? Changes the touching entites gravity ! * to the value of "gravity". 1.0 is standard gravity for the level. ! */ ! ! static EntTouchAdapter trigger_gravity_touch = new EntTouchAdapter() { ! ! public void touch(edict_t self, edict_t other, cplane_t plane, ! csurface_t surf) { ! other.gravity = self.gravity; ! } ! }; ! ! /* ! * ============================================================================== ! * ! * trigger_monsterjump ! * ! * ============================================================================== ! */ ! ! /* ! * QUAKED trigger_monsterjump (.5 .5 .5) ? Walking monsters that touch this ! * will jump in the direction of the trigger's angle "speed" default to 200, ! * the speed thrown forward "height" default to 200, the speed thrown ! * upwards ! */ ! ! static EntTouchAdapter trigger_monsterjump_touch = new EntTouchAdapter() { ! public void touch(edict_t self, edict_t other, cplane_t plane, ! csurface_t surf) { ! if ((other.flags & (Defines.FL_FLY | Defines.FL_SWIM)) != 0) ! return; ! if ((other.svflags & Defines.SVF_DEADMONSTER) != 0) ! return; ! if (0 == (other.svflags & Defines.SVF_MONSTER)) ! return; ! ! // set XY even if not on ground, so the jump will clear lips ! other.velocity[0] = self.movedir[0] * self.speed; ! other.velocity[1] = self.movedir[1] * self.speed; ! ! if (other.groundentity != null) ! return; ! ! other.groundentity = null; ! other.velocity[2] = self.movedir[2]; ! } ! }; ! } \ No newline at end of file Index: GameUtil.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameUtil.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GameUtil.java 12 Sep 2004 18:25:49 -0000 1.6 --- GameUtil.java 22 Sep 2004 19:22:05 -0000 1.7 *************** *** 1,27 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...3031 lines suppressed...] ! if ((null == activator.client) ! && 0 == (activator.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) ! return; ! ! // delay reaction so if the monster is teleported, its sound is ! // still heard ! self.enemy = activator; ! GameUtil.FoundTarget(self); ! } ! }; ! ! static boolean enemy_vis; ! ! static boolean enemy_infront; ! ! static int enemy_range; ! ! static float enemy_yaw; ! } \ No newline at end of file Index: M_Chick.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/M_Chick.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** M_Chick.java 8 Jul 2004 15:58:44 -0000 1.2 --- M_Chick.java 22 Sep 2004 19:22:02 -0000 1.3 *************** *** 1,987 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...2261 lines suppressed...] ! self.pain = chick_pain; ! self.die = chick_die; ! ! self.monsterinfo.stand = chick_stand; ! self.monsterinfo.walk = chick_walk; ! self.monsterinfo.run = chick_run; ! self.monsterinfo.dodge = chick_dodge; ! self.monsterinfo.attack = chick_attack; ! self.monsterinfo.melee = chick_melee; ! self.monsterinfo.sight = chick_sight; ! ! GameBase.gi.linkentity(self); ! ! self.monsterinfo.currentmove = chick_move_stand; ! self.monsterinfo.scale = MODEL_SCALE; ! ! GameAI.walkmonster_start.think(self); ! } ! } \ No newline at end of file --- GameSpawnAdapters.java DELETED --- --- GameAIAdapters.java DELETED --- Index: PlayerView.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/PlayerView.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PlayerView.java 7 Jul 2004 19:59:24 -0000 1.1.1.1 --- PlayerView.java 22 Sep 2004 19:22:03 -0000 1.2 *************** *** 1,1054 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...2094 lines suppressed...] ! Math3D.VectorClear(ent.client.kick_angles); ! // if the scoreboard is up, update it ! if (ent.client.showscores && 0 == (GameBase.level.framenum & 31)) { ! PlayerHud.DeathmatchScoreboardMessage(ent, ent.enemy); ! GameBase.gi.unicast(ent, false); ! } ! } ! public static float xyspeed; ! public static float bobmove; ! public static int bobcycle; // odd cycles are right foot going forward ! public static float bobfracsin; // sin(bobfrac*M_PI)} ! ! private static int xxxi = 0; ! } \ No newline at end of file Index: M_Gladiator.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/M_Gladiator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** M_Gladiator.java 8 Jul 2004 15:58:44 -0000 1.2 --- M_Gladiator.java 22 Sep 2004 19:22:06 -0000 1.3 *************** *** 1,570 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...1180 lines suppressed...] ! self.die = gladiator_die; ! ! self.monsterinfo.stand = gladiator_stand; ! self.monsterinfo.walk = gladiator_walk; ! self.monsterinfo.run = gladiator_run; ! self.monsterinfo.dodge = null; ! self.monsterinfo.attack = gladiator_attack; ! self.monsterinfo.melee = gladiator_melee; ! self.monsterinfo.sight = gladiator_sight; ! self.monsterinfo.idle = gladiator_idle; ! self.monsterinfo.search = gladiator_search; ! ! GameBase.gi.linkentity(self); ! self.monsterinfo.currentmove = gladiator_move_stand; ! self.monsterinfo.scale = MODEL_SCALE; ! ! GameAI.walkmonster_start.think(self); ! } ! } \ No newline at end of file Index: M_Boss3.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/M_Boss3.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** M_Boss3.java 7 Jul 2004 19:59:09 -0000 1.1.1.1 --- M_Boss3.java 22 Sep 2004 19:22:05 -0000 1.2 *************** *** 1,76 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! ! See the GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! ! */ // Created on 13.11.2003 by RST. // $Id$ - package jake2.game; ! public class M_Boss3 extends M_Boss32 { ! static EntUseAdapter Use_Boss3 = new EntUseAdapter() { ! public void use(edict_t ent, edict_t other, edict_t activator) { ! gi.WriteByte(svc_temp_entity); ! gi.WriteByte(TE_BOSSTPORT); ! gi.WritePosition(ent.s.origin); ! gi.multicast(ent.s.origin, MULTICAST_PVS); ! G_FreeEdict(ent); ! } ! }; ! static EntThinkAdapter Think_Boss3Stand = new EntThinkAdapter() { ! public boolean think(edict_t ent) { ! if (ent.s.frame == FRAME_stand260) ! ent.s.frame = FRAME_stand201; ! else ! ent.s.frame++; ! ent.nextthink = level.time + FRAMETIME; ! return true; ! } ! }; ! /*QUAKED monster_boss3_stand (1 .5 0) (-32 -32 0) (32 32 90) ! ! Just stands and cycles in one place until targeted, then teleports away. ! */ ! static void SP_monster_boss3_stand(edict_t self) { ! if (deathmatch.value != 0) { ! G_FreeEdict(self); ! return; ! } ! self.movetype = MOVETYPE_STEP; ! self.solid = SOLID_BBOX; ! self.model = "models/monsters/boss3/rider/tris.md2"; ! self.s.modelindex = gi.modelindex(self.model); ! self.s.frame = FRAME_stand201; ! gi.soundindex("misc/bigtele.wav"); ! VectorSet(self.mins, -32, -32, 0); ! VectorSet(self.maxs, 32, 32, 90); ! self.use = Use_Boss3; ! self.think = Think_Boss3Stand; ! self.nextthink = level.time + FRAMETIME; ! gi.linkentity(self); ! } ! } --- 1,79 ---- /* ! * Copyright (C) 1997-2001 Id Software, Inc. ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. ! * ! * See the GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! * ! */ // Created on 13.11.2003 by RST. // $Id$ package jake2.game; ! import jake2.Defines; ! import jake2.util.Math3D; ! public class M_Boss3 { ! static EntUseAdapter Use_Boss3 = new EntUseAdapter() { ! public void use(edict_t ent, edict_t other, edict_t activator) { ! GameBase.gi.WriteByte(Defines.svc_temp_entity); ! GameBase.gi.WriteByte(Defines.TE_BOSSTPORT); ! GameBase.gi.WritePosition(ent.s.origin); ! GameBase.gi.multicast(ent.s.origin, Defines.MULTICAST_PVS); ! GameUtil.G_FreeEdict(ent); ! } ! }; ! static EntThinkAdapter Think_Boss3Stand = new EntThinkAdapter() { ! public boolean think(edict_t ent) { ! if (ent.s.frame == M_Boss32.FRAME_stand260) ! ent.s.frame = M_Boss32.FRAME_stand201; ! else ! ent.s.frame++; ! ent.nextthink = GameBase.level.time + Defines.FRAMETIME; ! return true; ! } ! }; ! /* ! * QUAKED monster_boss3_stand (1 .5 0) (-32 -32 0) (32 32 90) ! * ! * Just stands and cycles in one place until targeted, then teleports away. ! */ ! static void SP_monster_boss3_stand(edict_t self) { ! if (GameBase.deathmatch.value != 0) { ! GameUtil.G_FreeEdict(self); ! return; ! } ! self.movetype = Defines.MOVETYPE_STEP; ! self.solid = Defines.SOLID_BBOX; ! self.model = "models/monsters/boss3/rider/tris.md2"; ! self.s.modelindex = GameBase.gi.modelindex(self.model); ! self.s.frame = M_Boss32.FRAME_stand201; ! GameBase.gi.soundindex("misc/bigtele.wav"); ! Math3D.VectorSet(self.mins, -32, -32, 0); ! Math3D.VectorSet(self.maxs, 32, 32, 90); ! ! self.use = Use_Boss3; ! self.think = Think_Boss3Stand; ! self.nextthink = GameBase.level.time + Defines.FRAMETIME; ! GameBase.gi.linkentity(self); ! } ! } \ No newline at end of file Index: PlayerTrail.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/PlayerTrail.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PlayerTrail.java 7 Jul 2004... [truncated message content] |
From: Rene S. <sa...@us...> - 2004-09-22 19:22:56
|
Update of /cvsroot/jake2/jake2/src/jake2/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11556/src/jake2/client Modified Files: CL_view.java Menu.java CL_parse.java M.java CL_ents.java CL_tent.java SCR.java CL.java CL_pred.java CL_newfx.java V.java CL_fx.java CL_inv.java Console.java CL_input.java Log Message: major refactoring in game, server and client package Index: V.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/V.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** V.java 9 Jul 2004 06:50:50 -0000 1.2 --- V.java 22 Sep 2004 19:22:08 -0000 1.3 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.client; --- 6,27 ---- */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.client; *************** *** 41,418 **** */ public final class V extends Globals { - - static cvar_t cl_testblend; - static cvar_t cl_testparticles; - static cvar_t cl_testentities; - static cvar_t cl_testlights; - static cvar_t cl_stats; - - static int r_numdlights; - static dlight_t[] r_dlights = new dlight_t[MAX_DLIGHTS]; ! static int r_numentities; ! static entity_t[] r_entities = new entity_t[MAX_ENTITIES]; ! ! static int r_numparticles; ! //static particle_t[] r_particles = new particle_t[MAX_PARTICLES]; ! ! static lightstyle_t[] r_lightstyles = new lightstyle_t[MAX_LIGHTSTYLES]; ! static { ! for (int i = 0; i < r_dlights.length; i++) ! r_dlights[i] = new dlight_t(); ! for (int i = 0; i < r_entities.length; i++) ! r_entities[i] = new entity_t(); ! for (int i = 0; i < r_lightstyles.length; i++) ! r_lightstyles[i] = new lightstyle_t(); ! } ! ! /* ! ==================== ! V_ClearScene ! Specifies the model that will be used as the world ! ==================== ! */ ! static void ClearScene() { ! r_numdlights = 0; ! r_numentities = 0; ! r_numparticles = 0; ! } ! /* ! ===================== ! V_AddEntity ! ===================== ! */ ! static void AddEntity(entity_t ent) { ! if (r_numentities >= MAX_ENTITIES) ! return; ! r_entities[r_numentities++].set(ent); ! } ! /* ! ===================== ! V_AddParticle ! ===================== ! */ ! static void AddParticle(float[] org, int color, float alpha) { ! if (r_numparticles >= MAX_PARTICLES) ! return; ! int i = r_numparticles++; ! int c = particle_t.colorTable[color]; ! c |= (int)(alpha * 255) << 24; ! particle_t.colorArray.put(i, c); ! ! i *= 3; ! FloatBuffer vertexBuf = particle_t.vertexArray; ! vertexBuf.put(i++, org[0]); ! vertexBuf.put(i++, org[1]); ! vertexBuf.put(i++, org[2]); ! } ! /* ! ===================== ! V_AddLight ! ===================== ! */ ! static void AddLight(float[] org, float intensity, float r, float g, float b) { ! dlight_t dl; ! if (r_numdlights >= MAX_DLIGHTS) ! return; ! dl = r_dlights[r_numdlights++]; ! VectorCopy(org, dl.origin); ! dl.intensity = intensity; ! dl.color[0] = r; ! dl.color[1] = g; ! dl.color[2] = b; ! } ! /* ! ===================== ! V_AddLightStyle ! ===================== ! */ ! static void AddLightStyle(int style, float r, float g, float b) { ! lightstyle_t ls; ! if (style < 0 || style > MAX_LIGHTSTYLES) ! Com.Error(ERR_DROP, "Bad light style " + style); ! ls = r_lightstyles[style]; ! ls.white = r + g + b; ! ls.rgb[0] = r; ! ls.rgb[1] = g; ! ls.rgb[2] = b; ! } ! /* ! ================ ! V_TestParticles ! If cl_testparticles is set, create 4096 particles in the view ! ================ ! */ ! static void TestParticles() { ! int i, j; ! float d, r, u; ! float[] origin = {0,0,0}; ! r_numparticles = 0; ! for (i = 0; i < MAX_PARTICLES; i++) { ! d = i * 0.25f; ! r = 4 * ((i & 7) - 3.5f); ! u = 4 * (((i >> 3) & 7) - 3.5f); ! for (j = 0; j < 3; j++) ! origin[j] = ! cl.refdef.vieworg[j] ! + cl.v_forward[j] * d ! + cl.v_right[j] * r ! + cl.v_up[j] * u; ! AddParticle(origin, 8, cl_testparticles.value); ! } ! } ! /* ! ================ ! V_TestEntities ! If cl_testentities is set, create 32 player models ! ================ ! */ ! static void TestEntities() { ! int i, j; ! float f, r; ! entity_t ent; ! r_numentities = 32; ! //memset (r_entities, 0, sizeof(r_entities)); ! for (i = 0; i < r_entities.length; i++) ! r_entities[i] = new entity_t(); ! for (i=0 ; i<r_numentities ; i++) ! { ! ent = r_entities[i]; ! r = 64 * ( (i%4) - 1.5f ); ! f = 64 * (i/4) + 128; ! for (j=0 ; j<3 ; j++) ! ent.origin[j] = cl.refdef.vieworg[j] + cl.v_forward[j]*f + ! cl.v_right[j]*r; ! ent.model = cl.baseclientinfo.model; ! ent.skin = cl.baseclientinfo.skin; ! } ! } ! ! /* ! ================ ! V_TestLights ! If cl_testlights is set, create 32 lights models ! ================ ! */ ! static void TestLights() { ! int i, j; ! float f, r; ! dlight_t dl; ! r_numdlights = 32; ! //memset (r_dlights, 0, sizeof(r_dlights)); ! for (i = 0; i < r_dlights.length; i++) ! r_dlights[i] = new dlight_t(); ! for (i=0 ; i<r_numdlights ; i++) ! { ! dl = r_dlights[i]; ! r = 64 * ( (i%4) - 1.5f ); ! f = 64 * (i/4) + 128; ! for (j=0 ; j<3 ; j++) ! dl.origin[j] = cl.refdef.vieworg[j] + cl.v_forward[j]*f + ! cl.v_right[j]*r; ! dl.color[0] = ((i%6)+1) & 1; ! dl.color[1] = (((i%6)+1) & 2)>>1; ! dl.color[2] = (((i%6)+1) & 4)>>2; ! dl.intensity = 200; ! } ! } ! static xcommand_t Gun_Next_f = new xcommand_t() { ! public void execute() { ! gun_frame++; ! Com.Printf("frame " + gun_frame + "\n"); ! } ! }; ! static xcommand_t Gun_Prev_f = new xcommand_t() { ! public void execute() { ! gun_frame--; ! if (gun_frame < 0) ! gun_frame = 0; ! Com.Printf("frame " + gun_frame + "\n"); ! } ! }; ! static xcommand_t Gun_Model_f = new xcommand_t() { ! public void execute() { ! if (Cmd.Argc() != 2) { ! gun_model = null; ! return; ! } ! String name = "models/" + Cmd.Argv(1) + "/tris.md2"; ! gun_model = re.RegisterModel(name); ! } ! }; ! /* ! ================== ! V_RenderView ! ! ================== ! */ ! static void RenderView(float stereo_separation) { ! // extern int entitycmpfnc( const entity_t *, const entity_t * ); ! // ! if (cls.state != ca_active) return; ! if (!cl.refresh_prepped) return; // still loading ! if (cl_timedemo.value != 0.0f) { ! if (cl.timedemo_start == 0) ! cl.timedemo_start = Sys.Milliseconds(); ! cl.timedemo_frames++; ! } ! // an invalid frame will just use the exact previous refdef ! // we can't use the old frame if the video mode has changed, though... ! if ( cl.frame.valid && (cl.force_refdef || cl_paused.value == 0.0f) ) { ! cl.force_refdef = false; ! V.ClearScene(); ! // build a refresh entity list and calc cl.sim* ! // this also calls CL_CalcViewValues which loads ! // v_forward, etc. ! CL.AddEntities(); ! if (cl_testparticles.value != 0.0f) ! TestParticles(); ! if (cl_testentities.value != 0.0f) ! TestEntities(); ! if (cl_testlights.value != 0.0f) ! TestLights(); ! if (cl_testblend.value != 0.0f) { ! cl.refdef.blend[0] = 1.0f; ! cl.refdef.blend[1] = 0.5f; ! cl.refdef.blend[2] = 0.25f; ! cl.refdef.blend[3] = 0.5f; ! } ! // offset vieworg appropriately if we're doing stereo separation ! if ( stereo_separation != 0 ) { ! float[] tmp = new float[3]; ! Math3D.VectorScale( cl.v_right, stereo_separation, tmp ); ! Math3D.VectorAdd( cl.refdef.vieworg, tmp, cl.refdef.vieworg ); ! } ! // never let it sit exactly on a node line, because a water plane can ! // dissapear when viewed with the eye exactly on it. ! // the server protocol only specifies to 1/8 pixel, so add 1/16 in each axis ! cl.refdef.vieworg[0] += 1.0/16; ! cl.refdef.vieworg[1] += 1.0/16; ! cl.refdef.vieworg[2] += 1.0/16; ! cl.refdef.x = scr_vrect.x; ! cl.refdef.y = scr_vrect.y; ! cl.refdef.width = scr_vrect.width; ! cl.refdef.height = scr_vrect.height; ! cl.refdef.fov_y = Math3D.CalcFov(cl.refdef.fov_x, cl.refdef.width, cl.refdef.height); ! cl.refdef.time = cl.time*0.001f; ! cl.refdef.areabits = cl.frame.areabits; ! if (cl_add_entities.value == 0.0f) ! r_numentities = 0; ! if (cl_add_particles.value == 0.0f) ! r_numparticles = 0; ! if (cl_add_lights.value == 0.0f) ! r_numdlights = 0; ! if (cl_add_blend.value == 0) { ! Math3D.VectorClear(cl.refdef.blend); ! } ! cl.refdef.num_entities = r_numentities; ! cl.refdef.entities = r_entities; ! cl.refdef.num_particles = r_numparticles; ! cl.refdef.num_dlights = r_numdlights; ! cl.refdef.dlights = r_dlights; ! cl.refdef.lightstyles = r_lightstyles; ! cl.refdef.rdflags = cl.frame.playerstate.rdflags; ! // sort entities for better cache locality ! // !!! useless in Java !!! ! //Arrays.sort(cl.refdef.entities, entitycmpfnc); ! } ! re.RenderFrame(cl.refdef); ! if (cl_stats.value != 0.0f) ! Com.Printf("ent:%i lt:%i part:%i\n", new Vargs(3).add(r_numentities).add( ! r_numdlights).add(r_numparticles)); ! if ( log_stats.value != 0.0f && ( log_stats_file != null ) ) ! try { ! log_stats_file.write(r_numentities + "," + r_numdlights + "," + r_numparticles); ! } catch (IOException e) {} ! SCR.AddDirtyPoint(scr_vrect.x, scr_vrect.y); ! SCR.AddDirtyPoint(scr_vrect.x+scr_vrect.width-1, scr_vrect.y+scr_vrect.height-1); ! SCR.DrawCrosshair(); ! } ! ! /* ! ============= ! V_Viewpos_f ! ============= ! */ ! static xcommand_t Viewpos_f = new xcommand_t() { ! public void execute() { ! Com.Printf("(%i %i %i) : %i\n", ! new Vargs(4).add((int)cl.refdef.vieworg[0]).add( ! (int)cl.refdef.vieworg[1]).add( ! (int)cl.refdef.vieworg[2]).add( ! (int)cl.refdef.viewangles[YAW])); ! } ! }; ! ! public static void Init() { ! Cmd.AddCommand("gun_next", Gun_Next_f); ! Cmd.AddCommand("gun_prev", Gun_Prev_f); ! Cmd.AddCommand("gun_model", Gun_Model_f); ! Cmd.AddCommand("viewpos", Viewpos_f); ! crosshair = Cvar.Get("crosshair", "0", CVAR_ARCHIVE); ! cl_testblend = Cvar.Get("cl_testblend", "0", 0); ! cl_testparticles = Cvar.Get("cl_testparticles", "0", 0); ! cl_testentities = Cvar.Get("cl_testentities", "0", 0); ! cl_testlights = Cvar.Get("cl_testlights", "0", 0); ! cl_stats = Cvar.Get("cl_stats", "0", 0); ! } ! } --- 41,412 ---- */ public final class V extends Globals { ! static cvar_t cl_testblend; ! static cvar_t cl_testparticles; ! static cvar_t cl_testentities; ! static cvar_t cl_testlights; ! static cvar_t cl_stats; ! static int r_numdlights; ! static dlight_t[] r_dlights = new dlight_t[MAX_DLIGHTS]; ! static int r_numentities; ! static entity_t[] r_entities = new entity_t[MAX_ENTITIES]; ! static int r_numparticles; ! //static particle_t[] r_particles = new particle_t[MAX_PARTICLES]; + static lightstyle_t[] r_lightstyles = new lightstyle_t[MAX_LIGHTSTYLES]; + static { + for (int i = 0; i < r_dlights.length; i++) + r_dlights[i] = new dlight_t(); + for (int i = 0; i < r_entities.length; i++) + r_entities[i] = new entity_t(); + for (int i = 0; i < r_lightstyles.length; i++) + r_lightstyles[i] = new lightstyle_t(); + } ! /* ! * ==================== V_ClearScene ! * ! * Specifies the model that will be used as the world ==================== ! */ ! static void ClearScene() { ! r_numdlights = 0; ! r_numentities = 0; ! r_numparticles = 0; ! } ! /* ! * ===================== V_AddEntity ! * ! * ===================== ! */ ! static void AddEntity(entity_t ent) { ! if (r_numentities >= MAX_ENTITIES) ! return; ! r_entities[r_numentities++].set(ent); ! } ! /* ! * ===================== V_AddParticle ! * ! * ===================== ! */ ! static void AddParticle(float[] org, int color, float alpha) { ! if (r_numparticles >= MAX_PARTICLES) ! return; ! int i = r_numparticles++; ! int c = particle_t.colorTable[color]; ! c |= (int) (alpha * 255) << 24; ! particle_t.colorArray.put(i, c); ! i *= 3; ! FloatBuffer vertexBuf = particle_t.vertexArray; ! vertexBuf.put(i++, org[0]); ! vertexBuf.put(i++, org[1]); ! vertexBuf.put(i++, org[2]); ! } ! /* ! * ===================== V_AddLight ! * ! * ===================== ! */ ! static void AddLight(float[] org, float intensity, float r, float g, float b) { ! dlight_t dl; ! if (r_numdlights >= MAX_DLIGHTS) ! return; ! dl = r_dlights[r_numdlights++]; ! Math3D.VectorCopy(org, dl.origin); ! dl.intensity = intensity; ! dl.color[0] = r; ! dl.color[1] = g; ! dl.color[2] = b; ! } ! /* ! * ===================== V_AddLightStyle ! * ! * ===================== ! */ ! static void AddLightStyle(int style, float r, float g, float b) { ! lightstyle_t ls; ! if (style < 0 || style > MAX_LIGHTSTYLES) ! Com.Error(ERR_DROP, "Bad light style " + style); ! ls = r_lightstyles[style]; ! ls.white = r + g + b; ! ls.rgb[0] = r; ! ls.rgb[1] = g; ! ls.rgb[2] = b; ! } ! /* ! * ================ V_TestParticles ! * ! * If cl_testparticles is set, create 4096 particles in the view ! * ================ ! */ ! static void TestParticles() { ! int i, j; ! float d, r, u; ! float[] origin = { 0, 0, 0 }; ! r_numparticles = 0; ! for (i = 0; i < MAX_PARTICLES; i++) { ! d = i * 0.25f; ! r = 4 * ((i & 7) - 3.5f); ! u = 4 * (((i >> 3) & 7) - 3.5f); ! for (j = 0; j < 3; j++) ! origin[j] = cl.refdef.vieworg[j] + cl.v_forward[j] * d ! + cl.v_right[j] * r + cl.v_up[j] * u; ! AddParticle(origin, 8, cl_testparticles.value); ! } ! } ! /* ! * ================ V_TestEntities ! * ! * If cl_testentities is set, create 32 player models ================ ! */ ! static void TestEntities() { ! int i, j; ! float f, r; ! entity_t ent; ! r_numentities = 32; ! //memset (r_entities, 0, sizeof(r_entities)); ! for (i = 0; i < r_entities.length; i++) ! r_entities[i] = new entity_t(); ! for (i = 0; i < r_numentities; i++) { ! ent = r_entities[i]; ! r = 64 * ((i % 4) - 1.5f); ! f = 64 * (i / 4) + 128; ! for (j = 0; j < 3; j++) ! ent.origin[j] = cl.refdef.vieworg[j] + cl.v_forward[j] * f ! + cl.v_right[j] * r; ! ent.model = cl.baseclientinfo.model; ! ent.skin = cl.baseclientinfo.skin; ! } ! } ! /* ! * ================ V_TestLights ! * ! * If cl_testlights is set, create 32 lights models ================ ! */ ! static void TestLights() { ! int i, j; ! float f, r; ! dlight_t dl; ! r_numdlights = 32; ! //memset (r_dlights, 0, sizeof(r_dlights)); ! for (i = 0; i < r_dlights.length; i++) ! r_dlights[i] = new dlight_t(); ! for (i = 0; i < r_numdlights; i++) { ! dl = r_dlights[i]; ! r = 64 * ((i % 4) - 1.5f); ! f = 64 * (i / 4) + 128; ! for (j = 0; j < 3; j++) ! dl.origin[j] = cl.refdef.vieworg[j] + cl.v_forward[j] * f ! + cl.v_right[j] * r; ! dl.color[0] = ((i % 6) + 1) & 1; ! dl.color[1] = (((i % 6) + 1) & 2) >> 1; ! dl.color[2] = (((i % 6) + 1) & 4) >> 2; ! dl.intensity = 200; ! } ! } ! static xcommand_t Gun_Next_f = new xcommand_t() { ! public void execute() { ! gun_frame++; ! Com.Printf("frame " + gun_frame + "\n"); ! } ! }; ! static xcommand_t Gun_Prev_f = new xcommand_t() { ! public void execute() { ! gun_frame--; ! if (gun_frame < 0) ! gun_frame = 0; ! Com.Printf("frame " + gun_frame + "\n"); ! } ! }; ! static xcommand_t Gun_Model_f = new xcommand_t() { ! public void execute() { ! if (Cmd.Argc() != 2) { ! gun_model = null; ! return; ! } ! String name = "models/" + Cmd.Argv(1) + "/tris.md2"; ! gun_model = re.RegisterModel(name); ! } ! }; ! /* ! * ================== V_RenderView ! * ! * ================== ! */ ! static void RenderView(float stereo_separation) { ! // extern int entitycmpfnc( const entity_t *, const entity_t * ); ! // ! if (cls.state != ca_active) ! return; ! if (!cl.refresh_prepped) ! return; // still loading ! if (cl_timedemo.value != 0.0f) { ! if (cl.timedemo_start == 0) ! cl.timedemo_start = Sys.Milliseconds(); ! cl.timedemo_frames++; ! } ! // an invalid frame will just use the exact previous refdef ! // we can't use the old frame if the video mode has changed, though... ! if (cl.frame.valid && (cl.force_refdef || cl_paused.value == 0.0f)) { ! cl.force_refdef = false; ! V.ClearScene(); ! // build a refresh entity list and calc cl.sim* ! // this also calls CL_CalcViewValues which loads ! // v_forward, etc. ! CL_ents.AddEntities(); ! if (cl_testparticles.value != 0.0f) ! TestParticles(); ! if (cl_testentities.value != 0.0f) ! TestEntities(); ! if (cl_testlights.value != 0.0f) ! TestLights(); ! if (cl_testblend.value != 0.0f) { ! cl.refdef.blend[0] = 1.0f; ! cl.refdef.blend[1] = 0.5f; ! cl.refdef.blend[2] = 0.25f; ! cl.refdef.blend[3] = 0.5f; ! } ! // offset vieworg appropriately if we're doing stereo separation ! if (stereo_separation != 0) { ! float[] tmp = new float[3]; ! Math3D.VectorScale(cl.v_right, stereo_separation, tmp); ! Math3D.VectorAdd(cl.refdef.vieworg, tmp, cl.refdef.vieworg); ! } ! // never let it sit exactly on a node line, because a water plane ! // can ! // dissapear when viewed with the eye exactly on it. ! // the server protocol only specifies to 1/8 pixel, so add 1/16 in ! // each axis ! cl.refdef.vieworg[0] += 1.0 / 16; ! cl.refdef.vieworg[1] += 1.0 / 16; ! cl.refdef.vieworg[2] += 1.0 / 16; ! cl.refdef.x = scr_vrect.x; ! cl.refdef.y = scr_vrect.y; ! cl.refdef.width = scr_vrect.width; ! cl.refdef.height = scr_vrect.height; ! cl.refdef.fov_y = Math3D.CalcFov(cl.refdef.fov_x, cl.refdef.width, ! cl.refdef.height); ! cl.refdef.time = cl.time * 0.001f; ! cl.refdef.areabits = cl.frame.areabits; ! if (cl_add_entities.value == 0.0f) ! r_numentities = 0; ! if (cl_add_particles.value == 0.0f) ! r_numparticles = 0; ! if (cl_add_lights.value == 0.0f) ! r_numdlights = 0; ! if (cl_add_blend.value == 0) { ! Math3D.VectorClear(cl.refdef.blend); ! } ! cl.refdef.num_entities = r_numentities; ! cl.refdef.entities = r_entities; ! cl.refdef.num_particles = r_numparticles; ! cl.refdef.num_dlights = r_numdlights; ! cl.refdef.dlights = r_dlights; ! cl.refdef.lightstyles = r_lightstyles; ! cl.refdef.rdflags = cl.frame.playerstate.rdflags; ! // sort entities for better cache locality ! // !!! useless in Java !!! ! //Arrays.sort(cl.refdef.entities, entitycmpfnc); ! } ! re.RenderFrame(cl.refdef); ! if (cl_stats.value != 0.0f) ! Com.Printf("ent:%i lt:%i part:%i\n", new Vargs(3).add( ! r_numentities).add(r_numdlights).add(r_numparticles)); ! if (log_stats.value != 0.0f && (log_stats_file != null)) ! try { ! log_stats_file.write(r_numentities + "," + r_numdlights + "," ! + r_numparticles); ! } catch (IOException e) { ! } ! SCR.AddDirtyPoint(scr_vrect.x, scr_vrect.y); ! SCR.AddDirtyPoint(scr_vrect.x + scr_vrect.width - 1, scr_vrect.y ! + scr_vrect.height - 1); ! ! SCR.DrawCrosshair(); ! } ! ! /* ! * ============= V_Viewpos_f ============= ! */ ! static xcommand_t Viewpos_f = new xcommand_t() { ! public void execute() { ! Com.Printf("(%i %i %i) : %i\n", new Vargs(4).add( ! (int) cl.refdef.vieworg[0]).add((int) cl.refdef.vieworg[1]) ! .add((int) cl.refdef.vieworg[2]).add( ! (int) cl.refdef.viewangles[YAW])); ! } ! }; ! ! public static void Init() { ! Cmd.AddCommand("gun_next", Gun_Next_f); ! Cmd.AddCommand("gun_prev", Gun_Prev_f); ! Cmd.AddCommand("gun_model", Gun_Model_f); ! ! Cmd.AddCommand("viewpos", Viewpos_f); ! ! crosshair = Cvar.Get("crosshair", "0", CVAR_ARCHIVE); ! ! cl_testblend = Cvar.Get("cl_testblend", "0", 0); ! cl_testparticles = Cvar.Get("cl_testparticles", "0", 0); ! cl_testentities = Cvar.Get("cl_testentities", "0", 0); ! cl_testlights = Cvar.Get("cl_testlights", "0", 0); ! ! cl_stats = Cvar.Get("cl_stats", "0", 0); ! } ! } \ No newline at end of file Index: CL_newfx.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_newfx.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CL_newfx.java 8 Jul 2004 20:24:29 -0000 1.3 --- CL_newfx.java 22 Sep 2004 19:22:08 -0000 1.4 *************** *** 6,1029 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...2002 lines suppressed...] ! p.next = CL_fx.active_particles; ! CL_fx.active_particles = p; ! Math3D.VectorClear(p.accel); ! p.time = Globals.cl.time; ! p.alpha = 1.0f; ! p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f); ! p.color = 0xd0; ! for (j = 0; j < 3; j++) { ! p.org[j] = move[j] + Lib.crand(); ! p.vel[j] = Lib.crand() * 5; ! p.accel[j] = 0; ! } ! Math3D.VectorAdd(move, vec, move); ! } ! } ! } \ No newline at end of file Index: CL_parse.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_parse.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CL_parse.java 30 Jul 2004 06:03:40 -0000 1.8 --- CL_parse.java 22 Sep 2004 19:22:07 -0000 1.9 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...1520 lines suppressed...] ! ! case Defines.svc_playerinfo: ! case Defines.svc_packetentities: ! case Defines.svc_deltapacketentities: ! Com.Error(Defines.ERR_DROP, "Out of place frame data"); ! break; ! } ! } ! ! CL_view.AddNetgraph(); ! ! // ! // we don't know if it is ok to save a demo message until ! // after we have parsed the frame ! // ! if (Globals.cls.demorecording && !Globals.cls.demowaiting) ! CL.WriteDemoMessage(); ! } ! } \ No newline at end of file Index: M.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/M.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** M.java 8 Jul 2004 20:56:50 -0000 1.4 --- M.java 22 Sep 2004 19:22:07 -0000 1.5 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...1152 lines suppressed...] ! }; ! /** Adds some flies after a random time */ ! public static EntThinkAdapter M_FlyCheck = new EntThinkAdapter() { ! public boolean think(edict_t self) { ! ! if (self.waterlevel != 0) ! return true; ! ! if (Globals.rnd.nextFloat() > 0.5) ! return true; ! ! self.think = M_FliesOn; ! self.nextthink = GameBase.level.time + 5 + 10 ! * Globals.rnd.nextFloat(); ! return true; ! } ! }; ! } \ No newline at end of file Index: Menu.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/Menu.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Menu.java 12 Sep 2004 19:52:58 -0000 1.8 --- Menu.java 22 Sep 2004 19:22:07 -0000 1.9 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...9867 lines suppressed...] ! Menu_DrawString(RCOLUMN_OFFSET + s.x + s.parent.x, ! s.y + s.parent.y, s.itemnames[s.curvalue]); ! } else { ! String line1, line2; ! line1 = Lib.leftFrom(s.itemnames[s.curvalue], '\n'); ! Menu_DrawString(RCOLUMN_OFFSET + s.x + s.parent.x, ! s.y + s.parent.y, line1); ! ! line2 = Lib.rightFrom(s.itemnames[s.curvalue], '\n'); ! ! int pos = line2.indexOf('\n'); ! if (pos != -1) ! line2 = line2.substring(0, pos); ! ! Menu_DrawString(RCOLUMN_OFFSET + s.x + s.parent.x, s.y + s.parent.y ! + 10, line2); ! } ! } ! } \ No newline at end of file Index: CL_fx.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_fx.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CL_fx.java 13 Jul 2004 11:09:55 -0000 1.5 --- CL_fx.java 22 Sep 2004 19:22:08 -0000 1.6 *************** *** 1,4 **** /* ! * CL_fx.java * Copyright (C) 2004 * --- 1,4 ---- /* ! * java * Copyright (C) 2004 * *************** [...3796 lines suppressed...] ! * ============================================================== ! * ! * PARTICLE MANAGEMENT ! * ! * ============================================================== ! */ ! ! static final int PARTICLE_GRAVITY = 40; ! ! static cparticle_t active_particles, free_particles; ! ! /* ! * =============== CL_BigTeleportParticles =============== ! */ ! private static int[] colortable = { 2 * 8, 13 * 8, 21 * 8, 18 * 8 }; ! ! private static final int BEAMLENGTH = 16; ! ! } \ No newline at end of file Index: Console.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/Console.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Console.java 30 Jul 2004 06:03:40 -0000 1.4 --- Console.java 22 Sep 2004 19:22:08 -0000 1.5 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...1168 lines suppressed...] ! sb.append((char) 0x81); ! } ! sb.append((char) 0x82); ! ! dlbar = sb.toString(); ! dlbar += Com.sprintf(" %02d%%", new Vargs(1) ! .add(cls.downloadpercent)); ! ! // draw it ! y = con.vislines - 12; ! for (i = 0; i < dlbar.length(); i++) ! re.DrawChar((i + 1) << 3, y, dlbar.charAt(i)); ! } ! //ZOID ! ! // draw the input prompt, user text, and cursor if desired ! DrawInput(); ! } ! } \ No newline at end of file Index: CL.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CL.java 8 Sep 2004 09:37:39 -0000 1.10 --- CL.java 22 Sep 2004 19:22:08 -0000 1.11 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...3250 lines suppressed...] ! Cbuf.Execute(); ! } ! ! /** ! * Called after an ERR_DROP was thrown. ! */ ! public static void Drop() { ! if (Globals.cls.state == Defines.ca_uninitialized) ! return; ! if (Globals.cls.state == Defines.ca_disconnected) ! return; ! ! Disconnect(); ! ! // drop loading plaque unless this is the initial game start ! if (Globals.cls.disable_servercount != -1) ! SCR.EndLoadingPlaque(); // get rid of loading plaque ! } ! } \ No newline at end of file Index: CL_input.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_input.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CL_input.java 9 Jul 2004 06:50:50 -0000 1.3 --- CL_input.java 22 Sep 2004 19:22:08 -0000 1.4 *************** *** 1,4 **** /* ! * CL_input.java * Copyright (C) 2004 * --- 1,4 ---- /* ! * java * Copyright (C) 2004 * *************** [...1214 lines suppressed...] ! MSG.WriteDeltaUsercmd(buf, oldcmd, cmd); oldcmd = cmd; ! i = (Globals.cls.netchan.outgoing_sequence) & (Defines.CMD_BACKUP - 1); ! cmd = Globals.cl.cmds[i]; MSG.WriteDeltaUsercmd(buf, oldcmd, cmd); // calculate a checksum over the move commands ! buf.data[checksumIndex] = Com.BlockSequenceCRCByte(buf.data, checksumIndex + 1, buf.cursize - checksumIndex - 1, ! Globals.cls.netchan.outgoing_sequence); // // deliver the message // ! Netchan.Transmit(Globals.cls.netchan, buf.cursize, buf.data); } ! } \ No newline at end of file Index: CL_view.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_view.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CL_view.java 9 Jul 2004 06:50:50 -0000 1.3 --- CL_view.java 22 Sep 2004 19:22:07 -0000 1.4 *************** *** 1,29 **** /* ! * CL_view.java ! * Copyright (C) 2004 * * $Id$ */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! ! See the GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! ! */ package jake2.client; import jake2.qcommon.CM; import jake2.qcommon.Com; --- 1,30 ---- /* ! * CL_view.java Copyright (C) 2004 * * $Id$ */ /* ! * Copyright (C) 1997-2001 Id Software, Inc. ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. ! * ! * See the GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! * ! */ package jake2.client; + import jake2.Defines; + import jake2.Globals; import jake2.qcommon.CM; import jake2.qcommon.Com; *************** *** 32,174 **** import java.util.StringTokenizer; ! public class CL_view extends CL_input { ! ! static int num_cl_weaponmodels; ! static String[] cl_weaponmodels = new String[MAX_CLIENTWEAPONMODELS]; ! /* ! ================= ! CL_PrepRefresh ! Call before entering a new level, or after changing dlls ! ================= ! */ ! static void PrepRefresh() { ! String mapname; ! int i; ! String name; ! float rotate; ! float[] axis = new float[3]; ! if ((i=cl.configstrings[CS_MODELS+1].length()) == 0) ! return; // no map loaded ! SCR.AddDirtyPoint(0, 0); ! SCR.AddDirtyPoint(viddef.width-1, viddef.height-1); ! // let the render dll load the map ! mapname = cl.configstrings[CS_MODELS+1].substring(5, i - 4); // skip "maps/" ! // cut off ".bsp" ! // register models, pics, and skins ! Com.Printf("Map: " + mapname + "\r"); ! SCR.UpdateScreen(); ! re.BeginRegistration(mapname); ! Com.Printf(" \r"); ! // precache status bar pics ! Com.Printf("pics\r"); ! SCR.UpdateScreen(); ! SCR.TouchPics(); ! Com.Printf(" \r"); ! CL.RegisterTEntModels(); ! num_cl_weaponmodels = 1; ! cl_weaponmodels[0] = "weapon.md2"; ! for (i=1 ; i<MAX_MODELS && cl.configstrings[CS_MODELS+i].length() != 0 ; i++) { ! name = new String(cl.configstrings[CS_MODELS+i]); ! if (name.length() > 37) name = name.substring(0, 36); ! ! if (name.charAt(0) != '*') ! Com.Printf(name + "\r"); ! ! SCR.UpdateScreen(); ! Sys.SendKeyEvents(); // pump message loop ! if (name.charAt(0) == '#') { ! // special player weapon model ! if (num_cl_weaponmodels < MAX_CLIENTWEAPONMODELS) { ! cl_weaponmodels[num_cl_weaponmodels] = cl.configstrings[CS_MODELS+i].substring(1); ! num_cl_weaponmodels++; ! } ! } else { ! cl.model_draw[i] = re.RegisterModel(cl.configstrings[CS_MODELS+i]); ! if (name.charAt(0) == '*') ! cl.model_clip[i] = CM.InlineModel(cl.configstrings[CS_MODELS+i]); ! else ! cl.model_clip[i] = null; ! } ! if (name.charAt(0) != '*') ! Com.Printf(" \r"); ! } ! Com.Printf("images\r"); ! SCR.UpdateScreen(); ! for (i=1 ; i<MAX_IMAGES && cl.configstrings[CS_IMAGES+i].length() > 0 ; i++) { ! cl.image_precache[i] = re.RegisterPic(cl.configstrings[CS_IMAGES+i]); ! Sys.SendKeyEvents(); // pump message loop ! } ! Com.Printf(" \r"); ! for (i=0 ; i<MAX_CLIENTS ; i++) { ! if (cl.configstrings[CS_PLAYERSKINS+i].length() == 0) ! continue; ! Com.Printf("client " + i + '\r'); ! SCR.UpdateScreen(); ! Sys.SendKeyEvents(); // pump message loop ! CL.ParseClientinfo(i); ! Com.Printf(" \r"); ! } ! CL_parse.LoadClientinfo(cl.baseclientinfo, "unnamed\\male/grunt"); ! // set sky textures and speed ! Com.Printf("sky\r"); ! SCR.UpdateScreen(); ! rotate = Float.parseFloat(cl.configstrings[CS_SKYROTATE]); ! StringTokenizer st = new StringTokenizer(cl.configstrings[CS_SKYAXIS]); ! axis[0] = Float.parseFloat(st.nextToken()); ! axis[1] = Float.parseFloat(st.nextToken()); ! axis[2] = Float.parseFloat(st.nextToken()); ! re.SetSky(cl.configstrings[CS_SKY], rotate, axis); ! Com.Printf(" \r"); ! // the renderer can now free unneeded stuff ! re.EndRegistration (); ! // clear any lines of console text ! Console.ClearNotify(); ! SCR.UpdateScreen(); ! cl.refresh_prepped = true; ! cl.force_refdef = true; // make sure we have a valid refdef ! } ! ! public static void AddNetgraph() { ! int i; ! int in; ! int ping; ! // if using the debuggraph for something else, don't ! // add the net lines ! if (SCR.scr_debuggraph.value == 0.0f || SCR.scr_timegraph.value == 0.0f) ! return; ! for (i=0 ; i<cls.netchan.dropped ; i++) ! SCR.DebugGraph(30, 0x40); ! for (i=0 ; i<cl.surpressCount ; i++) ! SCR.DebugGraph(30, 0xdf); ! // see what the latency was on this packet ! in = cls.netchan.incoming_acknowledged & (CMD_BACKUP-1); ! ping = (int)(cls.realtime - cl.cmd_time[in]); ! ping /= 30; ! if (ping > 30) ! ping = 30; ! SCR.DebugGraph (ping, 0xd0); ! } ! } --- 33,190 ---- import java.util.StringTokenizer; ! public class CL_view { + static int num_cl_weaponmodels; ! static String[] cl_weaponmodels = new String[Defines.MAX_CLIENTWEAPONMODELS]; ! /* ! * ================= ! * ! * CL_PrepRefresh ! * ! * Call before entering a new level, or after changing dlls ! * ================= ! */ ! static void PrepRefresh() { ! String mapname; ! int i; ! String name; ! float rotate; ! float[] axis = new float[3]; ! if ((i = Globals.cl.configstrings[Defines.CS_MODELS + 1].length()) == 0) ! return; // no map loaded ! SCR.AddDirtyPoint(0, 0); ! SCR.AddDirtyPoint(Globals.viddef.width - 1, Globals.viddef.height - 1); ! // let the render dll load the map ! mapname = Globals.cl.configstrings[Defines.CS_MODELS + 1].substring(5, ! i - 4); // skip "maps/" ! // cut off ".bsp" ! // register models, pics, and skins ! Com.Printf("Map: " + mapname + "\r"); ! SCR.UpdateScreen(); ! Globals.re.BeginRegistration(mapname); ! Com.Printf(" \r"); ! // precache status bar pics ! Com.Printf("pics\r"); ! SCR.UpdateScreen(); ! SCR.TouchPics(); ! Com.Printf(" \r"); ! CL_tent.RegisterTEntModels(); ! num_cl_weaponmodels = 1; ! cl_weaponmodels[0] = "weapon.md2"; ! 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]); ! if (name.length() > 37) ! name = name.substring(0, 36); ! if (name.charAt(0) != '*') ! Com.Printf(name + "\r"); ! SCR.UpdateScreen(); ! Sys.SendKeyEvents(); // pump message loop ! if (name.charAt(0) == '#') { ! // special player weapon model ! if (num_cl_weaponmodels < Defines.MAX_CLIENTWEAPONMODELS) { ! cl_weaponmodels[num_cl_weaponmodels] = Globals.cl.configstrings[Defines.CS_MODELS ! + i].substring(1); ! num_cl_weaponmodels++; ! } ! } else { ! Globals.cl.model_draw[i] = Globals.re ! .RegisterModel(Globals.cl.configstrings[Defines.CS_MODELS ! + i]); ! if (name.charAt(0) == '*') ! Globals.cl.model_clip[i] = CM ! .InlineModel(Globals.cl.configstrings[Defines.CS_MODELS ! + i]); ! else ! Globals.cl.model_clip[i] = null; ! } ! if (name.charAt(0) != '*') ! Com.Printf(" \r"); ! } ! Com.Printf("images\r"); ! SCR.UpdateScreen(); ! for (i = 1; i < Defines.MAX_IMAGES ! && Globals.cl.configstrings[Defines.CS_IMAGES + i].length() > 0; i++) { ! Globals.cl.image_precache[i] = Globals.re ! .RegisterPic(Globals.cl.configstrings[Defines.CS_IMAGES + i]); ! Sys.SendKeyEvents(); // pump message loop ! } ! Com.Printf(" \r"); ! for (i = 0; i < Defines.MAX_CLIENTS; i++) { ! if (Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i].length() == 0) ! continue; ! Com.Printf("client " + i + '\r'); ! SCR.UpdateScreen(); ! Sys.SendKeyEvents(); // pump message loop ! CL_parse.ParseClientinfo(i); ! Com.Printf(" \r"); ! } ! CL_parse.LoadClientinfo(Globals.cl.baseclientinfo, ! "unnamed\\male/grunt"); ! // set sky textures and speed ! Com.Printf("sky\r"); ! SCR.UpdateScreen(); ! rotate = Float ! .parseFloat(Globals.cl.configstrings[Defines.CS_SKYROTATE]); ! StringTokenizer st = new StringTokenizer( ! Globals.cl.configstrings[Defines.CS_SKYAXIS]); ! axis[0] = Float.parseFloat(st.nextToken()); ! axis[1] = Float.parseFloat(st.nextToken()); ! axis[2] = Float.parseFloat(st.nextToken()); ! Globals.re.SetSky(Globals.cl.configstrings[Defines.CS_SKY], rotate, ! axis); ! Com.Printf(" \r"); ! // the renderer can now free unneeded stuff ! Globals.re.EndRegistration(); ! // clear any lines of console text ! Console.ClearNotify(); ! SCR.UpdateScreen(); ! Globals.cl.refresh_prepped = true; ! Globals.cl.force_refdef = true; // make sure we have a valid refdef ! } ! public static void AddNetgraph() { ! int i; ! int in; ! int ping; ! // if using the debuggraph for something else, don't ! // add the net lines ! if (SCR.scr_debuggraph.value == 0.0f || SCR.scr_timegraph.value == 0.0f) ! return; ! for (i = 0; i < Globals.cls.netchan.dropped; i++) ! SCR.DebugGraph(30, 0x40); ! ! for (i = 0; i < Globals.cl.surpressCount; i++) ! SCR.DebugGraph(30, 0xdf); ! ! // see what the latency was on this packet ! in = Globals.cls.netchan.incoming_acknowledged ! & (Defines.CMD_BACKUP - 1); ! ping = (int) (Globals.cls.realtime - Globals.cl.cmd_time[in]); ! ping /= 30; ! if (ping > 30) ! ping = 30; ! SCR.DebugGraph(ping, 0xd0); ! } ! } \ No newline at end of file Index: CL_ents.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_ents.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CL_ents.java 12 Jul 2004 20:47:01 -0000 1.5 --- CL_ents.java 22 Sep 2004 19:22:07 -0000 1.6 *************** *** 1,4 **** /* ! * CL_ents.java * Copyright (C) 2004 * --- 1,4 ---- /* ! * java * Copyright (C) 2004 * *************** [...2441 lines suppressed...] ! CL_fx.AddLightStyles(); } /* ! * =============== CL_GetEntitySoundOrigin ! * ! * Called to get the sound spatialization origin =============== ! */ public static void GetEntitySoundOrigin(int ent, float[] org) { centity_t old; ! if (ent < 0 || ent >= Defines.MAX_EDICTS) ! Com.Error(Defines.ERR_DROP, "CL_GetEntitySoundOrigin: bad ent"); ! old = Globals.cl_entities[ent]; ! Math3D.VectorCopy(old.lerp_origin, org); // FIXME: bmodel issues... } ! } \ No newline at end of file Index: SCR.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/SCR.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SCR.java 27 Aug 2004 21:07:01 -0000 1.7 --- SCR.java 22 Sep 2004 19:22:08 -0000 1.8 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...3951 lines suppressed...] ! // cin.s_channels = LittleLong(cin.s_channels); ! // ! // Huff1TableInit (); ! // ! // // switch up to 22 khz sound if necessary ! // old_khz = Cvar_VariableValue ("s_khz"); ! // if (old_khz != cin.s_rate/1000) ! // { ! // cin.restart_sound = true; ! // Cvar_SetValue ("s_khz", cin.s_rate/1000); ! // CL_Snd_Restart_f (); ! // Cvar_SetValue ("s_khz", old_khz); ! // } ! // ! // cl.cinematicframe = 0; ! // cin.pic = SCR_ReadNextFrame (); ! // cl.cinematictime = Sys_Milliseconds (); ! } } \ No newline at end of file Index: CL_tent.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_tent.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CL_tent.java 9 Jul 2004 10:19:57 -0000 1.4 --- CL_tent.java 22 Sep 2004 19:22:08 -0000 1.5 *************** *** 1,4 **** /* ! * CL_tent.java * Copyright (C) 2004 * --- 1,4 ---- /* ! * java * Copyright (C) 2004 * *************** [...3500 lines suppressed...] ! s[i].think.think(s[i]); ! } else if (s[i].endtime < Globals.cl.time) ! s[i].id = 0; ! } ! } ! ! /* ! * ================= CL_AddTEnts ================= ! */ ! static void AddTEnts() { ! AddBeams(); ! // PMM - draw plasma beams ! AddPlayerBeams(); ! AddExplosions(); ! AddLasers(); ! // PMM - set up sustain ! ProcessSustain(); ! } ! } \ No newline at end of file Index: CL_pred.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_pred.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CL_pred.java 19 Jul 2004 19:20:22 -0000 1.4 --- CL_pred.java 22 Sep 2004 19:22:08 -0000 1.5 *************** *** 6,287 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.client; import jake2.game.*; import jake2.qcommon.*; /** * CL_pred */ ! public class CL_pred extends CL_parse { ! /* ! =================== ! CL_CheckPredictionError ! =================== ! */ ! static void CheckPredictionError() { ! int frame; ! int[] delta = new int[3]; ! int i; ! int len; ! if (cl_predict.value == 0.0f || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION) != 0) ! return; ! // calculate the last usercmd_t we sent that the server has processed ! frame = cls.netchan.incoming_acknowledged; ! frame &= (CMD_BACKUP - 1); ! // compare what the server returned with what we had predicted it to be ! VectorSubtract(cl.frame.playerstate.pmove.origin, cl.predicted_origins[frame], delta); ! // save the prediction error for interpolation ! len = Math.abs(delta[0]) + Math.abs(delta[1]) + Math.abs(delta[2]); ! if (len > 640) // 80 world units ! { // a teleport or something ! VectorClear(cl.prediction_error); ! } ! else { ! if (cl_showmiss.value != 0.0f && (delta[0] != 0 || delta[1] != 0 || delta[2] != 0)) ! Com.Printf("prediction miss on " + cl.frame.serverframe + ": " + (delta[0] + delta[1] + delta[2]) + "\n"); ! VectorCopy(cl.frame.playerstate.pmove.origin, cl.predicted_origins[frame]); ! // save for error itnerpolation ! for (i = 0; i < 3; i++) ! cl.prediction_error[i] = delta[i] * 0.125f; ! } ! } ! /* ! ==================== ! CL_ClipMoveToEntities ! ! ==================== ! */ ! static void ClipMoveToEntities(float[] start, float[] mins, float[] maxs, float[] end, trace_t tr) { ! int i, x, zd, zu; ! trace_t trace; ! int headnode; ! float[] angles; ! entity_state_t ent; ! int num; ! cmodel_t cmodel; ! float[] bmins = new float[3]; ! float[] bmaxs = new float[3]; ! for (i = 0; i < cl.frame.num_entities; i++) { ! num = (cl.frame.parse_entities + i) & (MAX_PARSE_ENTITIES - 1); ! ent = cl_parse_entities[num]; ! if (ent.solid == 0) ! continue; ! if (ent.number == cl.playernum + 1) ! continue; ! if (ent.solid == 31) { // special value for bmodel ! cmodel = cl.model_clip[ent.modelindex]; ! if (cmodel == null) ! continue; ! headnode = cmodel.headnode; ! angles = ent.angles; ! } ! else { // encoded bbox ! x = 8 * (ent.solid & 31); ! zd = 8 * ((ent.solid >>> 5) & 31); ! zu = 8 * ((ent.solid >>> 10) & 63) - 32; ! bmins[0] = bmins[1] = -x; ! bmaxs[0] = bmaxs[1] = x; ! bmins[2] = -zd; ! bmaxs[2] = zu; ! headnode = CM.HeadnodeForBox(bmins, bmaxs); ! angles = vec3_origin; // boxes don't rotate ! } ! if (tr.allsolid) ! return; ! trace = CM.TransformedBoxTrace(start, end, mins, maxs, headnode, MASK_PLAYERSOLID, ent.origin, angles); ! if (trace.allsolid || trace.startsolid || trace.fraction < tr.fraction) { ! trace.ent = ent.surrounding_ent; ! if (tr.startsolid) { ! tr.set(trace); // rst: solved the Z U P P E L - P R O B L E M ! tr.startsolid = true; ! } ! 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; ! } ! } ! /* ! ================ ! CL_PMTrace ! ================ ! */ ! public static edict_t DUMMY_ENT = new edict_t(-1); ! static trace_t PMTrace(float[] start, float[] mins, float[] maxs, float[] end) { ! trace_t t; ! // check against world ! t = CM.BoxTrace(start, end, mins, maxs, 0, MASK_PLAYERSOLID); ! if (t.fraction < 1.0f) { ! t.ent = DUMMY_ENT; ! } ! // check all other solid models ! CL.ClipMoveToEntities(start, mins, maxs, end, t); ! return t; ! } ! /* ! ================= ! PMpointcontents ! ! Returns the content identificator of the point. ! ================= ! */ ! static int PMpointcontents(float[] point) { ! int i; ! entity_state_t ent; ! int num; ! cmodel_t cmodel; ! int contents; ! contents = CM.PointContents(point, 0); ! for (i = 0; i < cl.frame.num_entities; i++) { ! num = (cl.frame.parse_entities + i) & (MAX_PARSE_ENTITIES - 1); ! ent = cl_parse_entities[num]; ! if (ent.solid != 31) // special value for bmodel ! continue; ! cmodel = cl.model_clip[ent.modelindex]; ! if (cmodel == null) ! continue; ! contents |= CM.TransformedPointContents(point, cmodel.headnode, ent.origin, ent.angles); ! } ! return contents; ! } ! /* ! ================= ! CL_PredictMovement ! ! Sets cl.predicted_origin and cl.predicted_angles ! ================= ! */ ! static void PredictMovement() { ! if (cls.state != ca_active) ! return; ! if (cl_paused.value != 0.0f) ! return; ! if (cl_predict.value == 0.0f || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION) != 0) { ! // just set angles ! for (int i = 0; i < 3; i++) { ! cl.predicted_angles[i] = cl.viewangles[i] + SHORT2ANGLE(cl.frame.playerstate.pmove.delta_angles[i]); ! } ! return; ! } ! int ack = cls.netchan.incoming_acknowledged; ! int current = cls.netchan.outgoing_sequence; ! // if we are too far out of date, just freeze ! if (current - ack >= CMD_BACKUP) { ! if (cl_showmiss.value != 0.0f) ! Com.Printf("exceeded CMD_BACKUP\n"); ! return; ! } ! // copy current state to pmove ! //memset (pm, 0, sizeof(pm)); ! pmove_t pm = new pmove_t(); ! pm.trace = new pmove_t.TraceAdapter() { ! public trace_t trace(float[] start, float[] mins, float[] maxs, float[] end) { ! return CL.PMTrace(start, mins, maxs, end); ! } ! }; ! pm.pointcontents = new pmove_t.PointContentsAdapter() { ! public int pointcontents(float[] point) { ! return CL.PMpointcontents(point); ! } ! }; ! try { ! PMove.pm_airaccelerate = Float.parseFloat(cl.configstrings[CS_AIRACCEL]); ! } catch (Exception e) { ! PMove.pm_airaccelerate = 0; ! } ! // bugfix (rst) yeah !!!!!!!! found the solution to the B E W E G U N G S P R O B L E M. ! pm.s.set(cl.frame.playerstate.pmove); ! // SCR_DebugGraph (current - ack - 1, 0); ! int frame = 0; ! // run frames ! usercmd_t cmd; ! while (++ack < current) { ! frame = ack & (CMD_BACKUP - 1); ! cmd = cl.cmds[frame]; ! pm.cmd.set(cmd); ! PMove.Pmove(pm); ! // save for debug checking ! VectorCopy(pm.s.origin, cl.predicted_origins[frame]); ! } ! int oldframe = (ack - 2) & (CMD_BACKUP - 1); ! int oldz = cl.predicted_origins[oldframe][2]; ! int step = pm.s.origin[2] - oldz; ! if (step > 63 && step < 160 && (pm.s.pm_flags & PMF_ON_GROUND) != 0) { ! cl.predicted_step = step * 0.125f; ! cl.predicted_step_time = (int) (cls.realtime - cls.frametime * 500); ! } ! // copy results out for rendering ! cl.predicted_origin[0] = pm.s.origin[0] * 0.125f; ! cl.predicted_origin[1] = pm.s.origin[1] * 0.125f; ! cl.predicted_origin[2] = pm.s.origin[2] * 0.125f; ! VectorCopy(pm.viewangles, cl.predicted_angles); ! } ! } --- 6,303 ---- */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.client; + import jake2.Defines; + import jake2.Globals; + import jake2.Defines; + import jake2.game.pmove_t.PointContentsAdapter; + import jake2.game.pmove_t.TraceAdapter; + + import jake2.Globals; import jake2.game.*; import jake2.qcommon.*; + import jake2.util.Math3D; /** * CL_pred */ ! public class CL_pred { ! /* ! * =================== CL_CheckPredictionError =================== ! */ ! static void CheckPredictionError() { ! int frame; ! int[] delta = new int[3]; ! int i; ! int len; ! if (Globals.cl_predict.value == 0.0f ! || (Globals.cl.frame.playerstate.pmove.pm_flags & pmove_t.PMF_NO_PREDICTION) != 0) ! return; ! // calculate the last usercmd_t we sent that the server has processed ! frame = Globals.cls.netchan.incoming_acknowledged; ! frame &= (Defines.CMD_BACKUP - 1); ! // compare what the server returned with what we had pre... [truncated message content] |
From: Rene S. <sa...@us...> - 2004-09-22 19:22:56
|
Update of /cvsroot/jake2/jake2/src/jake2/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11556/src/jake2/sys Modified Files: IN.java Sys.java Log Message: major refactoring in game, server and client package Index: IN.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/IN.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IN.java 8 Sep 2004 09:37:39 -0000 1.4 --- IN.java 22 Sep 2004 19:22:14 -0000 1.5 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.sys; --- 6,27 ---- */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.sys; *************** *** 33,38 **** import jake2.qcommon.Cvar; import jake2.qcommon.xcommand_t; ! import java.awt.*; import javax.swing.ImageIcon; --- 33,41 ---- import jake2.qcommon.Cvar; import jake2.qcommon.xcommand_t; + import jake2.util.Math3D; ! import java.awt.Component; ! import java.awt.Cursor; ! import java.awt.Point; import javax.swing.ImageIcon; *************** *** 43,208 **** public final class IN extends Globals { ! static Component c = null; ! static Cursor emptyCursor = null; ! static boolean mouse_avail = true; ! static boolean mouse_active = false; ! static boolean ignorefirst = false; ! static int mouse_buttonstate; ! static int mouse_oldbuttonstate; ! static int old_mouse_x; ! static int old_mouse_y; ! static boolean mlooking; ! ! public static void ActivateMouse() { ! if (!mouse_avail || c == null) return; ! if (!mouse_active) { ! KBD.mx = KBD.my = 0; // don't spazz ! install_grabs(); ! mouse_active = true; ! } ! } ! public static void DeactivateMouse() { ! // if (!mouse_avail || c == null) return; ! if (mouse_active) { ! uninstall_grabs(); ! mouse_active = false; ! } ! } ! private static void install_grabs() { ! if (emptyCursor == null) { ! ImageIcon emptyIcon = new ImageIcon(new byte[0]); ! emptyCursor = c.getToolkit().createCustomCursor(emptyIcon.getImage(), new Point(0, 0), "emptyCursor"); ! } ! c.setCursor(emptyCursor); ! KBD.centerMouse(); ! ignorefirst = true; ! } ! private static void uninstall_grabs() { ! c.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); ! } ! public static void toggleMouse() { ! if (mouse_avail) { ! mouse_avail=false; ! DeactivateMouse(); ! } else { ! mouse_avail=true; ! ActivateMouse(); ! } ! } ! public static void Init() { ! in_mouse = Cvar.Get("in_mouse", "1", CVAR_ARCHIVE); ! in_joystick = Cvar.Get("in_joystick", "0", CVAR_ARCHIVE); ! } ! public static void Shutdown() { ! mouse_avail = false; ! } ! public static void Real_IN_Init() { ! // mouse variables ! Globals.m_filter = Cvar.Get("m_filter", "0", 0); ! Globals.in_mouse = Cvar.Get("in_mouse", "1", CVAR_ARCHIVE); ! Globals.freelook = Cvar.Get("freelook", "1", 0 ); ! Globals.lookstrafe = Cvar.Get("lookstrafe", "0", 0); ! Globals.sensitivity = Cvar.Get("sensitivity", "3", 0); ! Globals.m_pitch = Cvar.Get("m_pitch", "0.022", 0); ! Globals.m_yaw = Cvar.Get("m_yaw", "0.022", 0); ! Globals.m_forward = Cvar.Get("m_forward", "1", 0); ! Globals.m_side = Cvar.Get("m_side", "0.8", 0); ! ! Cmd.AddCommand("+mlook", new xcommand_t() { ! public void execute() {MLookDown();}}); ! Cmd.AddCommand("-mlook", new xcommand_t() { ! public void execute() {MLookUp();}}); ! ! Cmd.AddCommand ("force_centerview", new xcommand_t() { ! public void execute() {Force_CenterView_f();}}); ! Cmd.AddCommand ("togglemouse", new xcommand_t() { ! public void execute() {toggleMouse();}}); ! ! IN.mouse_avail = true; ! } ! public static void Commands() { ! int i; ! ! if (!IN.mouse_avail) ! return; ! ! for (i=0 ; i<3 ; i++) { ! if ( (IN.mouse_buttonstate & (1<<i)) != 0 && (IN.mouse_oldbuttonstate & (1<<i)) == 0 ) ! KBD.Do_Key_Event(Key.K_MOUSE1 + i, true); ! ! if ( (IN.mouse_buttonstate & (1<<i)) == 0 && (IN.mouse_oldbuttonstate & (1<<i)) != 0 ) ! KBD.Do_Key_Event(Key.K_MOUSE1 + i, false); ! } ! IN.mouse_oldbuttonstate = IN.mouse_buttonstate; ! } ! public static void Frame() { ! if ( !cl.refresh_prepped || cls.key_dest == key_console || cls.key_dest == key_menu) ! DeactivateMouse(); ! else ! ActivateMouse(); ! } ! public static void CenterView() { ! cl.viewangles[PITCH] = -SHORT2ANGLE(cl.frame.playerstate.pmove.delta_angles[PITCH]); ! } ! ! public static void Move(usercmd_t cmd) { ! if (!IN.mouse_avail) ! return; ! ! if (Globals.m_filter.value != 0.0f) { ! KBD.mx = (KBD.mx + IN.old_mouse_x) / 2; ! KBD.my = (KBD.my + IN.old_mouse_y) / 2; ! } ! ! IN.old_mouse_x = KBD.mx; ! IN.old_mouse_y = KBD.my; ! ! KBD.mx = (int)(KBD.mx * Globals.sensitivity.value); ! KBD.my = (int)(KBD.my * Globals.sensitivity.value); ! ! // add mouse X/Y movement to cmd ! if ( (CL_input.in_strafe.state & 1) != 0 || ((Globals.lookstrafe.value != 0) && IN.mlooking )) { ! cmd.sidemove += Globals.m_side.value * KBD.mx; ! } else { ! Globals.cl.viewangles[YAW] -= Globals.m_yaw.value * KBD.mx; ! } ! ! if ( (IN.mlooking || Globals.freelook.value != 0.0f) && (CL_input.in_strafe.state & 1) == 0) { ! Globals.cl.viewangles[PITCH] += Globals.m_pitch.value * KBD.my; ! } else { ! cmd.forwardmove -= Globals.m_forward.value * KBD.my; ! } ! KBD.mx = KBD.my = 0; ! } ! static void MLookDown() { ! mlooking = true; ! } ! static void MLookUp() { ! mlooking = false; ! CenterView(); ! } ! static void Force_CenterView_f() { ! Globals.cl.viewangles[PITCH] = 0; ! } ! } --- 46,236 ---- public final class IN extends Globals { ! static Component c = null; ! static Cursor emptyCursor = null; ! static boolean mouse_avail = true; ! static boolean mouse_active = false; ! static boolean ignorefirst = false; ! static int mouse_buttonstate; ! static int mouse_oldbuttonstate; ! static int old_mouse_x; ! static int old_mouse_y; ! static boolean mlooking; ! public static void ActivateMouse() { ! if (!mouse_avail || c == null) ! return; ! if (!mouse_active) { ! KBD.mx = KBD.my = 0; // don't spazz ! install_grabs(); ! mouse_active = true; ! } ! } ! public static void DeactivateMouse() { ! // if (!mouse_avail || c == null) return; ! if (mouse_active) { ! uninstall_grabs(); ! mouse_active = false; ! } ! } ! private static void install_grabs() { ! if (emptyCursor == null) { ! ImageIcon emptyIcon = new ImageIcon(new byte[0]); ! emptyCursor = c.getToolkit().createCustomCursor( ! emptyIcon.getImage(), new Point(0, 0), "emptyCursor"); ! } ! c.setCursor(emptyCursor); ! KBD.centerMouse(); ! ignorefirst = true; ! } ! private static void uninstall_grabs() { ! c.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); ! } ! public static void toggleMouse() { ! if (mouse_avail) { ! mouse_avail = false; ! DeactivateMouse(); ! } else { ! mouse_avail = true; ! ActivateMouse(); ! } ! } ! public static void Init() { ! in_mouse = Cvar.Get("in_mouse", "1", CVAR_ARCHIVE); ! in_joystick = Cvar.Get("in_joystick", "0", CVAR_ARCHIVE); ! } ! public static void Shutdown() { ! mouse_avail = false; ! } ! public static void Real_IN_Init() { ! // mouse variables ! Globals.m_filter = Cvar.Get("m_filter", "0", 0); ! Globals.in_mouse = Cvar.Get("in_mouse", "1", CVAR_ARCHIVE); ! Globals.freelook = Cvar.Get("freelook", "1", 0); ! Globals.lookstrafe = Cvar.Get("lookstrafe", "0", 0); ! Globals.sensitivity = Cvar.Get("sensitivity", "3", 0); ! Globals.m_pitch = Cvar.Get("m_pitch", "0.022", 0); ! Globals.m_yaw = Cvar.Get("m_yaw", "0.022", 0); ! Globals.m_forward = Cvar.Get("m_forward", "1", 0); ! Globals.m_side = Cvar.Get("m_side", "0.8", 0); ! Cmd.AddCommand("+mlook", new xcommand_t() { ! public void execute() { ! MLookDown(); ! } ! }); ! Cmd.AddCommand("-mlook", new xcommand_t() { ! public void execute() { ! MLookUp(); ! } ! }); ! Cmd.AddCommand("force_centerview", new xcommand_t() { ! public void execute() { ! Force_CenterView_f(); ! } ! }); ! Cmd.AddCommand("togglemouse", new xcommand_t() { ! public void execute() { ! toggleMouse(); ! } ! }); ! ! IN.mouse_avail = true; ! } ! ! public static void Commands() { ! int i; ! ! if (!IN.mouse_avail) ! return; ! ! for (i = 0; i < 3; i++) { ! if ((IN.mouse_buttonstate & (1 << i)) != 0 ! && (IN.mouse_oldbuttonstate & (1 << i)) == 0) ! KBD.Do_Key_Event(Key.K_MOUSE1 + i, true); ! ! if ((IN.mouse_buttonstate & (1 << i)) == 0 ! && (IN.mouse_oldbuttonstate & (1 << i)) != 0) ! KBD.Do_Key_Event(Key.K_MOUSE1 + i, false); ! } ! IN.mouse_oldbuttonstate = IN.mouse_buttonstate; ! } ! ! public static void Frame() { ! ! if (!cl.refresh_prepped || cls.key_dest == key_console ! || cls.key_dest == key_menu) ! DeactivateMouse(); ! else ! ActivateMouse(); ! } ! ! public static void CenterView() { ! cl.viewangles[PITCH] = -Math3D ! .SHORT2ANGLE(cl.frame.playerstate.pmove.delta_angles[PITCH]); ! } ! ! public static void Move(usercmd_t cmd) { ! if (!IN.mouse_avail) ! return; ! ! if (Globals.m_filter.value != 0.0f) { ! KBD.mx = (KBD.mx + IN.old_mouse_x) / 2; ! KBD.my = (KBD.my + IN.old_mouse_y) / 2; ! } ! ! IN.old_mouse_x = KBD.mx; ! IN.old_mouse_y = KBD.my; ! ! KBD.mx = (int) (KBD.mx * Globals.sensitivity.value); ! KBD.my = (int) (KBD.my * Globals.sensitivity.value); ! ! // add mouse X/Y movement to cmd ! if ((CL_input.in_strafe.state & 1) != 0 ! || ((Globals.lookstrafe.value != 0) && IN.mlooking)) { ! cmd.sidemove += Globals.m_side.value * KBD.mx; ! } else { ! Globals.cl.viewangles[YAW] -= Globals.m_yaw.value * KBD.mx; ! } ! ! if ((IN.mlooking || Globals.freelook.value != 0.0f) ! && (CL_input.in_strafe.state & 1) == 0) { ! Globals.cl.viewangles[PITCH] += Globals.m_pitch.value * KBD.my; ! } else { ! cmd.forwardmove -= Globals.m_forward.value * KBD.my; ! } ! KBD.mx = KBD.my = 0; ! } ! ! static void MLookDown() { ! mlooking = true; ! } ! ! static void MLookUp() { ! mlooking = false; ! CenterView(); ! } ! ! static void Force_CenterView_f() { ! Globals.cl.viewangles[PITCH] = 0; ! } ! ! } \ No newline at end of file Index: Sys.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/Sys.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Sys.java 10 Sep 2004 19:02:56 -0000 1.8 --- Sys.java 22 Sep 2004 19:22:14 -0000 1.9 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.sys; --- 6,27 ---- */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.sys; *************** *** 41,246 **** public final class Sys extends Defines { ! public static void Error(String error) { ! CL.Shutdown(); ! //StackTrace(); ! new Exception(error).printStackTrace(); ! System.exit(1); ! } ! public static void Quit() { ! CL.Shutdown(); ! System.exit(0); ! } ! //ok! ! public static File[] FindAll(String path, int musthave, int canthave) { ! int index= path.lastIndexOf('/'); ! if (index != -1) { ! findbase= path.substring(0, index); ! findpattern= path.substring(index + 1, path.length()); ! } ! else { ! findbase= path; ! findpattern= "*"; ! } ! if (findpattern.equals("*.*")) { ! findpattern= "*"; ! } ! File fdir= new File(findbase); ! if (!fdir.exists()) ! return null; ! FilenameFilter filter= new FileFilter(findpattern, musthave, canthave); ! return fdir.listFiles(filter); ! } ! /** ! * Match the pattern findpattern against the filename. ! * ! * In the pattern string, `*' matches any sequence of characters, ! * `?' matches any character, [SET] matches any character in the specified set, ! * [!SET] matches any character not in the specified set. ! * A set is composed of characters or ranges; a range looks like ! * character hyphen character (as in 0-9 or A-Z). ! * [0-9a-zA-Z_] is the set of characters allowed in C identifiers. ! * Any other character in the pattern must be matched exactly. ! * To suppress the special syntactic significance of any of `[]*?!-\', ! * and match the character exactly, precede it with a `\'. ! */ ! static class FileFilter implements FilenameFilter { ! String regexpr; ! int musthave, canthave; ! FileFilter(String findpattern, int musthave, int canthave) { ! this.regexpr= convert2regexpr(findpattern); ! this.musthave= musthave; ! this.canthave= canthave; ! } ! /* ! * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String) ! */ ! public boolean accept(File dir, String name) { ! if (name.matches(regexpr)) { ! return CompareAttributes(dir, musthave, canthave); ! } ! return false; ! } ! String convert2regexpr(String pattern) { ! StringBuffer sb= new StringBuffer(); ! char c; ! boolean escape= false; ! String subst; ! // convert pattern ! for (int i= 0; i < pattern.length(); i++) { ! c= pattern.charAt(i); ! subst= null; ! switch (c) { ! case '*' : ! subst= (!escape) ? ".*" : "*"; ! break; ! case '.' : ! subst= (!escape) ? "\\." : "."; ! break; ! case '!' : ! subst= (!escape) ? "^" : "!"; ! break; ! case '?' : ! subst= (!escape) ? "." : "?"; ! break; ! case '\\' : ! escape= !escape; ! break; ! default : ! escape= false; ! } ! if (subst != null) { ! sb.append(subst); ! escape= false; ! } ! else ! sb.append(c); ! } ! // the converted pattern ! String regexpr= sb.toString(); ! //Com.DPrintf("pattern: " + pattern + " regexpr: " + regexpr + '\n'); ! try { ! Pattern.compile(regexpr); ! } ! catch (PatternSyntaxException e) { ! Com.Printf("invalid file pattern ( *.* is used instead )\n"); ! return ".*"; // the default ! } ! return regexpr; ! } ! boolean CompareAttributes(File dir, int musthave, int canthave) { ! // . and .. never match ! String name= dir.getName(); ! if (name.equals(".") || name.equals("..")) ! return false; ! return true; ! } ! } ! private static long secbase= System.currentTimeMillis(); ! public static int Milliseconds() { ! return Globals.curtime= (int) (System.currentTimeMillis() - secbase); ! } ! //============================================ ! static File[] fdir; ! static int fileindex; ! static String findbase; ! static String findpattern; ! // ok. ! public static File FindFirst(String path, int musthave, int canthave) { ! if (fdir != null) ! Sys.Error("Sys_BeginFind without close"); ! // COM_FilePath (path, findbase); ! fdir= FindAll(path, canthave, musthave); ! fileindex= 0; ! if (fdir == null) ! return null; ! return FindNext(); ! } ! public static File FindNext() { ! if (fileindex >= fdir.length) ! return null; ! return fdir[fileindex++]; ! } ! public static void FindClose() { ! fdir= null; ! } ! public static void SendKeyEvents() { ! KBD.Update(); ! // grab frame time ! Globals.sys_frame_time= Sys.Milliseconds(); ! } ! public static String GetClipboardData() { ! // TODO: implement GetClipboardData ! return null; ! } ! public static void ConsoleOutput(String msg) { ! if (Globals.nostdout != null && Globals.nostdout.value != 0) ! return; ! System.out.print(msg); ! } ! } --- 41,248 ---- public final class Sys extends Defines { ! public static void Error(String error) { ! CL.Shutdown(); ! //StackTrace(); ! new Exception(error).printStackTrace(); ! System.exit(1); ! } ! public static void Quit() { ! CL.Shutdown(); ! System.exit(0); ! } ! //ok! ! public static File[] FindAll(String path, int musthave, int canthave) { ! int index = path.lastIndexOf('/'); ! if (index != -1) { ! findbase = path.substring(0, index); ! findpattern = path.substring(index + 1, path.length()); ! } else { ! findbase = path; ! findpattern = "*"; ! } ! if (findpattern.equals("*.*")) { ! findpattern = "*"; ! } ! File fdir = new File(findbase); ! if (!fdir.exists()) ! return null; ! FilenameFilter filter = new FileFilter(findpattern, musthave, canthave); ! return fdir.listFiles(filter); ! } ! /** ! * Match the pattern findpattern against the filename. ! * ! * In the pattern string, `*' matches any sequence of characters, `?' ! * matches any character, [SET] matches any character in the specified set, ! * [!SET] matches any character not in the specified set. A set is composed ! * of characters or ranges; a range looks like character hyphen character ! * (as in 0-9 or A-Z). [0-9a-zA-Z_] is the set of characters allowed in C ! * identifiers. Any other character in the pattern must be matched exactly. ! * To suppress the special syntactic significance of any of `[]*?!-\', and ! * match the character exactly, precede it with a `\'. ! */ ! static class FileFilter implements FilenameFilter { ! String regexpr; ! int musthave, canthave; ! FileFilter(String findpattern, int musthave, int canthave) { ! this.regexpr = convert2regexpr(findpattern); ! this.musthave = musthave; ! this.canthave = canthave; ! } ! /* ! * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String) ! */ ! public boolean accept(File dir, String name) { ! if (name.matches(regexpr)) { ! return CompareAttributes(dir, musthave, canthave); ! } ! return false; ! } ! String convert2regexpr(String pattern) { ! StringBuffer sb = new StringBuffer(); ! char c; ! boolean escape = false; ! String subst; ! // convert pattern ! for (int i = 0; i < pattern.length(); i++) { ! c = pattern.charAt(i); ! subst = null; ! switch (c) { ! case '*': ! subst = (!escape) ? ".*" : "*"; ! break; ! case '.': ! subst = (!escape) ? "\\." : "."; ! break; ! case '!': ! subst = (!escape) ? "^" : "!"; ! break; ! case '?': ! subst = (!escape) ? "." : "?"; ! break; ! case '\\': ! escape = !escape; ! break; ! default: ! escape = false; ! } ! if (subst != null) { ! sb.append(subst); ! escape = false; ! } else ! sb.append(c); ! } ! // the converted pattern ! String regexpr = sb.toString(); ! //Com.DPrintf("pattern: " + pattern + " regexpr: " + regexpr + ! // '\n'); ! try { ! Pattern.compile(regexpr); ! } catch (PatternSyntaxException e) { ! Com.Printf("invalid file pattern ( *.* is used instead )\n"); ! return ".*"; // the default ! } ! return regexpr; ! } ! boolean CompareAttributes(File dir, int musthave, int canthave) { ! // . and .. never match ! String name = dir.getName(); ! if (name.equals(".") || name.equals("..")) ! return false; ! return true; ! } ! } ! private static long secbase = System.currentTimeMillis(); ! public static int Milliseconds() { ! return Globals.curtime = (int) (System.currentTimeMillis() - secbase); ! } ! //============================================ ! static File[] fdir; ! static int fileindex; ! static String findbase; ! static String findpattern; ! // ok. ! public static File FindFirst(String path, int musthave, int canthave) { ! if (fdir != null) ! Sys.Error("Sys_BeginFind without close"); ! // COM_FilePath (path, findbase); ! fdir = FindAll(path, canthave, musthave); ! fileindex = 0; ! if (fdir == null) ! return null; ! return FindNext(); ! } ! public static File FindNext() { ! if (fileindex >= fdir.length) ! return null; ! return fdir[fileindex++]; ! } ! public static void FindClose() { ! fdir = null; ! } ! public static void SendKeyEvents() { ! KBD.Update(); ! ! // grab frame time ! Globals.sys_frame_time = Sys.Milliseconds(); ! } ! ! public static String GetClipboardData() { ! // TODO: implement GetClipboardData ! return null; ! } ! ! public static void ConsoleOutput(String msg) { ! if (Globals.nostdout != null && Globals.nostdout.value != 0) ! return; ! ! System.out.print(msg); ! } ! ! } \ No newline at end of file |
From: Rene S. <sa...@us...> - 2004-09-22 19:22:56
|
Update of /cvsroot/jake2/jake2/src/jake2/render/fastjogl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11556/src/jake2/render/fastjogl Modified Files: Model.java Misc.java Image.java Surf.java Light.java Mesh.java Warp.java Log Message: major refactoring in game, server and client package Index: Model.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Model.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Model.java 19 Jul 2004 19:39:57 -0000 1.4 --- Model.java 22 Sep 2004 19:22:10 -0000 1.5 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...2576 lines suppressed...] ! model.counts[i] = count; ! ! count = (count < 0) ? -count : count; ! model.vertexIndexBuf.position(pos); ! model.indexElements[i] = model.vertexIndexBuf.slice(); ! pos += count; ! } ! } ! ! static void resetModelArrays() { ! globalModelTextureCoordBuf.rewind(); ! globalModelVertexIndexBuf.rewind(); ! } ! ! static void modelMemoryUsage() { ! System.out.println("AliasModels: globalVertexBuffer size " ! + globalModelVertexIndexBuf.position()); ! } ! } \ No newline at end of file Index: Surf.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Surf.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Surf.java 19 Jul 2004 19:39:57 -0000 1.4 --- Surf.java 22 Sep 2004 19:22:11 -0000 1.5 *************** *** 6,38 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...2783 lines suppressed...] ! // pix.get(pixel); ! // ! // BufferedImage image = new BufferedImage(w, h, ! // BufferedImage.TYPE_4BYTE_ABGR); ! // image.setRGB(0, 0, w, h, pixel, 0, w); ! // AffineTransformOp op = new ! // AffineTransformOp(AffineTransform.getScaleInstance(scale, scale), ! // AffineTransformOp.TYPE_NEAREST_NEIGHBOR); ! // BufferedImage tmp = op.filter(image, null); ! // ! // if (frame == null) { ! // frame = new ImageFrame(null); ! // frame.show(); ! // } ! // frame.showImage(tmp); ! // ! // } ! ! } \ No newline at end of file Index: Image.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Image.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Image.java 19 Jul 2004 19:39:57 -0000 1.5 --- Image.java 22 Sep 2004 19:22:10 -0000 1.6 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...3280 lines suppressed...] ! /* ! * =============== GL_ShutdownImages =============== ! */ ! void GL_ShutdownImages() { ! image_t image; ! ! for (int i = 0; i < numgltextures; i++) { ! image = gltextures[i]; ! ! if (image.registration_sequence == 0) ! continue; // free image_t slot ! // free it ! // TODO jogl bug ! gl.glDeleteTextures(1, new int[] { image.texnum }); ! image.clear(); ! } ! } ! ! } \ No newline at end of file Index: Light.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Light.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Light.java 10 Sep 2004 19:02:52 -0000 1.8 --- Light.java 22 Sep 2004 19:22:11 -0000 1.9 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...1432 lines suppressed...] ! a = 255 - ((r + g + b) / 3); ! r *= a / 255.0f; ! g *= a / 255.0f; ! b *= a / 255.0f; ! break; ! case 'A': ! default: ! r = g = b = 0; ! a = 255 - a; ! break; ! } ! //r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF; ! dest.put(destp++, (a << 24) | (b << 16) | (g << 8) ! | (r << 0)); ! } ! } ! } ! } ! } \ No newline at end of file Index: Warp.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Warp.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Warp.java 16 Jul 2004 10:11:35 -0000 1.3 --- Warp.java 22 Sep 2004 19:22:11 -0000 1.4 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...1365 lines suppressed...] ! } ! ! sky_images[i] = GL_FindImage(pathname, it_sky); ! ! if (sky_images[i] == null) ! sky_images[i] = r_notexture; ! ! if (gl_skymip.value != 0 || skyrotate != 0) { // take less memory ! gl_picmip.value--; ! sky_min = 1.0f / 256; ! sky_max = 255.0f / 256; ! } else { ! sky_min = 1.0f / 512; ! sky_max = 511.0f / 512; ! } ! } ! } ! ! } \ No newline at end of file Index: Mesh.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Mesh.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Mesh.java 19 Jul 2004 19:39:57 -0000 1.5 --- Mesh.java 22 Sep 2004 19:22:11 -0000 1.6 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...1343 lines suppressed...] ! if ((currententity.flags & Defines.RF_DEPTHHACK) != 0) ! gl.glDepthRange(gldepthmin, gldepthmax); ! ! if (gl_shadows.value != 0.0f ! && (currententity.flags & (Defines.RF_TRANSLUCENT | Defines.RF_WEAPONMODEL)) == 0) { ! gl.glPushMatrix(); ! R_RotateForEntity(e); ! gl.glDisable(GL.GL_TEXTURE_2D); ! gl.glEnable(GL.GL_BLEND); ! gl.glColor4f(0, 0, 0, 0.5f); ! GL_DrawAliasShadow(paliashdr, currententity.frame); ! gl.glEnable(GL.GL_TEXTURE_2D); ! gl.glDisable(GL.GL_BLEND); ! gl.glPopMatrix(); ! } ! gl.glColor4f(1, 1, 1, 1); ! } ! ! } \ No newline at end of file Index: Misc.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Misc.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Misc.java 16 Jul 2004 10:11:35 -0000 1.2 --- Misc.java 22 Sep 2004 19:22:10 -0000 1.3 *************** *** 26,34 **** package jake2.render.fastjogl; - import net.java.games.jogl.GL; - import net.java.games.jogl.WGL; - import jake2.Defines; import jake2.client.VID; /** --- 26,33 ---- package jake2.render.fastjogl; import jake2.Defines; import jake2.client.VID; + import net.java.games.jogl.GL; + import net.java.games.jogl.WGL; /** *************** *** 44,62 **** ================== */ ! byte[][] dottexture = ! { ! {0,0,0,0,0,0,0,0}, ! {0,0,1,1,0,0,0,0}, ! {0,1,1,1,1,0,0,0}, ! {0,1,1,1,1,0,0,0}, ! {0,0,1,1,0,0,0,0}, ! {0,0,0,0,0,0,0,0}, ! {0,0,0,0,0,0,0,0}, ! {0,0,0,0,0,0,0,0}, ! }; ! void R_InitParticleTexture() ! { ! int x,y; byte[] data = new byte[8 * 8 * 4]; --- 43,57 ---- ================== */ ! byte[][] dottexture = { { 0, 0, 0, 0, 0, 0, 0, 0 }, { ! 0, 0, 1, 1, 0, 0, 0, 0 }, { ! 0, 1, 1, 1, 1, 0, 0, 0 }, ! { 0, 1, 1, 1, 1, 0, 0, 0 }, { ! 0, 0, 1, 1, 0, 0, 0, 0 }, { ! 0, 0, 0, 0, 0, 0, 0, 0 }, { ! 0, 0, 0, 0, 0, 0, 0, 0 }, { ! 0, 0, 0, 0, 0, 0, 0, 0 }, }; ! void R_InitParticleTexture() { ! int x, y; byte[] data = new byte[8 * 8 * 4]; *************** *** 64,75 **** // particle texture // ! for (x=0 ; x<8 ; x++) ! { ! for (y=0 ; y<8 ; y++) ! { ! data[y * 32 + x * 4 + 0] = (byte)255; ! data[y * 32 + x * 4 + 1] = (byte)255; ! data[y * 32 + x * 4 + 2] = (byte)255; ! data[y * 32 + x * 4 + 3] = (byte)(dottexture[x][y]*255); } --- 59,68 ---- // particle texture // ! for (x = 0; x < 8; x++) { ! for (y = 0; y < 8; y++) { ! data[y * 32 + x * 4 + 0] = (byte) 255; ! data[y * 32 + x * 4 + 1] = (byte) 255; ! data[y * 32 + x * 4 + 2] = (byte) 255; ! data[y * 32 + x * 4 + 3] = (byte) (dottexture[x][y] * 255); } *************** *** 80,91 **** // also use this for bad textures, but without alpha // ! for (x=0 ; x<8 ; x++) ! { ! for (y=0 ; y<8 ; y++) ! { ! data[y * 32 + x * 4 + 0] = (byte)(dottexture[x&3][y&3]*255); data[y * 32 + x * 4 + 1] = 0; // dottexture[x&3][y&3]*255; data[y * 32 + x * 4 + 2] = 0; //dottexture[x&3][y&3]*255; ! data[y * 32 + x * 4 + 3] = (byte)255; } } --- 73,82 ---- // also use this for bad textures, but without alpha // ! for (x = 0; x < 8; x++) { ! for (y = 0; y < 8; y++) { ! data[y * 32 + x * 4 + 0] = (byte) (dottexture[x & 3][y & 3] * 255); data[y * 32 + x * 4 + 1] = 0; // dottexture[x&3][y&3]*255; data[y * 32 + x * 4 + 2] = 0; //dottexture[x&3][y&3]*255; ! data[y * 32 + x * 4 + 3] = (byte) 255; } } *************** *** 93,113 **** } ! ! // /* ! // ============================================================================== ! // ! // SCREEN SHOTS ! // ! // ============================================================================== ! // */ ! // ! // typedef struct _TargaHeader { ! // unsigned char id_length, colormap_type, image_type; ! // unsigned short colormap_index, colormap_length; ! // unsigned char colormap_size; ! // unsigned short x_origin, y_origin, width, height; ! // unsigned char pixel_size, attributes; ! // } TargaHeader; ! /* --- 84,102 ---- } ! // /* ! // ============================================================================== ! // ! // SCREEN SHOTS ! // ! // ============================================================================== ! // */ ! // ! // typedef struct _TargaHeader { ! // unsigned char id_length, colormap_type, image_type; ! // unsigned short colormap_index, colormap_length; ! // unsigned char colormap_size; ! // unsigned short x_origin, y_origin, width, height; ! // unsigned char pixel_size, attributes; ! // } TargaHeader; /* *************** *** 115,185 **** GL_ScreenShot_f ================== ! */ ! void GL_ScreenShot_f() ! { ! // byte *buffer; ! // char picname[80]; ! // char checkname[MAX_OSPATH]; ! // int i, c, temp; ! // FILE *f; ! // ! // // create the scrnshots directory if it doesn't exist ! // Com_sprintf (checkname, sizeof(checkname), "%s/scrnshot", ri.FS_Gamedir()); ! // Sys_Mkdir (checkname); ! // ! //// ! //// find a file name to save it to ! //// ! // strcpy(picname,"quake00.tga"); ! // ! // for (i=0 ; i<=99 ; i++) ! // { ! // picname[5] = i/10 + '0'; ! // picname[6] = i%10 + '0'; ! // Com_sprintf (checkname, sizeof(checkname), "%s/scrnshot/%s", ri.FS_Gamedir(), picname); ! // f = fopen (checkname, "r"); ! // if (!f) ! // break; // file doesn't exist ! // fclose (f); ! // } ! // if (i==100) ! // { ! // VID.Printf (PRINT_ALL, "SCR_ScreenShot_f: Couldn't create a file\n"); ! // return; ! // } ! // ! // ! // buffer = malloc(vid.width*vid.height*3 + 18); ! // memset (buffer, 0, 18); ! // buffer[2] = 2; // uncompressed type ! // buffer[12] = vid.width&255; ! // buffer[13] = vid.width>>8; ! // buffer[14] = vid.height&255; ! // buffer[15] = vid.height>>8; ! // buffer[16] = 24; // pixel size ! // ! // qglReadPixels (0, 0, vid.width, vid.height, GL_RGB, GL_UNSIGNED_BYTE, buffer+18 ); ! // ! // // swap rgb to bgr ! // c = 18+vid.width*vid.height*3; ! // for (i=18 ; i<c ; i+=3) ! // { ! // temp = buffer[i]; ! // buffer[i] = buffer[i+2]; ! // buffer[i+2] = temp; ! // } ! // ! // f = fopen (checkname, "rw"); ! // fwrite (buffer, 1, c, f); ! // fclose (f); ! // ! // free (buffer); ! // VID.Printf (PRINT_ALL, "Wrote %s\n", picname); ! } /* ** GL_Strings_f */ ! void GL_Strings_f() { VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); VID.Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); --- 104,173 ---- GL_ScreenShot_f ================== ! */ ! void GL_ScreenShot_f() { ! // byte *buffer; ! // char picname[80]; ! // char checkname[MAX_OSPATH]; ! // int i, c, temp; ! // FILE *f; ! // ! // // create the scrnshots directory if it doesn't exist ! // Com_sprintf (checkname, sizeof(checkname), "%s/scrnshot", ri.FS_Gamedir()); ! // Sys_Mkdir (checkname); ! // ! //// ! //// find a file name to save it to ! //// ! // strcpy(picname,"quake00.tga"); ! // ! // for (i=0 ; i<=99 ; i++) ! // { ! // picname[5] = i/10 + '0'; ! // picname[6] = i%10 + '0'; ! // Com_sprintf (checkname, sizeof(checkname), "%s/scrnshot/%s", ri.FS_Gamedir(), picname); ! // f = fopen (checkname, "r"); ! // if (!f) ! // break; // file doesn't exist ! // fclose (f); ! // } ! // if (i==100) ! // { ! // VID.Printf (PRINT_ALL, "SCR_ScreenShot_f: Couldn't create a file\n"); ! // return; ! // } ! // ! // ! // buffer = malloc(vid.width*vid.height*3 + 18); ! // memset (buffer, 0, 18); ! // buffer[2] = 2; // uncompressed type ! // buffer[12] = vid.width&255; ! // buffer[13] = vid.width>>8; ! // buffer[14] = vid.height&255; ! // buffer[15] = vid.height>>8; ! // buffer[16] = 24; // pixel size ! // ! // qglReadPixels (0, 0, vid.width, vid.height, GL_RGB, GL_UNSIGNED_BYTE, buffer+18 ); ! // ! // // swap rgb to bgr ! // c = 18+vid.width*vid.height*3; ! // for (i=18 ; i<c ; i+=3) ! // { ! // temp = buffer[i]; ! // buffer[i] = buffer[i+2]; ! // buffer[i+2] = temp; ! // } ! // ! // f = fopen (checkname, "rw"); ! // fwrite (buffer, 1, c, f); ! // fclose (f); ! // ! // free (buffer); ! // VID.Printf (PRINT_ALL, "Wrote %s\n", picname); ! } /* ** GL_Strings_f */ ! void GL_Strings_f() { VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); VID.Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); *************** *** 191,197 **** ** GL_SetDefaultState */ ! void GL_SetDefaultState() ! { ! gl.glClearColor(1f,0f, 0.5f , 0.5f); // original quake2 //gl.glClearColor(0, 0, 0, 0); // replaced with black gl.glCullFace(GL.GL_FRONT); --- 179,184 ---- ** GL_SetDefaultState */ ! void GL_SetDefaultState() { ! gl.glClearColor(1f, 0f, 0.5f, 0.5f); // original quake2 //gl.glClearColor(0, 0, 0, 0); // replaced with black gl.glCullFace(GL.GL_FRONT); *************** *** 201,216 **** gl.glAlphaFunc(GL.GL_GREATER, 0.666f); ! gl.glDisable (GL.GL_DEPTH_TEST); ! gl.glDisable (GL.GL_CULL_FACE); ! gl.glDisable (GL.GL_BLEND); ! gl.glColor4f (1,1,1,1); ! gl.glPolygonMode (GL.GL_FRONT_AND_BACK, GL.GL_FILL); ! gl.glShadeModel (GL.GL_FLAT); ! GL_TextureMode( gl_texturemode.string ); ! GL_TextureAlphaMode( gl_texturealphamode.string ); ! GL_TextureSolidMode( gl_texturesolidmode.string ); gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, gl_filter_min); --- 188,203 ---- gl.glAlphaFunc(GL.GL_GREATER, 0.666f); ! gl.glDisable(GL.GL_DEPTH_TEST); ! gl.glDisable(GL.GL_CULL_FACE); ! gl.glDisable(GL.GL_BLEND); ! gl.glColor4f(1, 1, 1, 1); ! gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL); ! gl.glShadeModel(GL.GL_FLAT); ! GL_TextureMode(gl_texturemode.string); ! GL_TextureAlphaMode(gl_texturealphamode.string); ! GL_TextureSolidMode(gl_texturesolidmode.string); gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, gl_filter_min); *************** *** 220,246 **** gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); ! gl.glBlendFunc (GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); ! GL_TexEnv( GL.GL_REPLACE ); ! if ( qglPointParameterfEXT ) ! { float[] attenuations = { gl_particle_att_a.value, gl_particle_att_b.value, gl_particle_att_c.value }; ! gl.glEnable( GL.GL_POINT_SMOOTH ); ! gl.glPointParameterfEXT( GL.GL_POINT_SIZE_MIN_EXT, gl_particle_min_size.value ); ! gl.glPointParameterfEXT( GL.GL_POINT_SIZE_MAX_EXT, gl_particle_max_size.value ); ! gl.glPointParameterfvEXT( GL.GL_DISTANCE_ATTENUATION_EXT, attenuations ); } ! if ( qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f ) ! { ! gl.glEnable( GL.GL_SHARED_TEXTURE_PALETTE_EXT ); ! GL_SetTexturePalette( d_8to24table ); } GL_UpdateSwapInterval(); ! /* * vertex array extension --- 207,231 ---- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); ! gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); ! GL_TexEnv(GL.GL_REPLACE); ! if (qglPointParameterfEXT) { float[] attenuations = { gl_particle_att_a.value, gl_particle_att_b.value, gl_particle_att_c.value }; ! gl.glEnable(GL.GL_POINT_SMOOTH); ! gl.glPointParameterfEXT(GL.GL_POINT_SIZE_MIN_EXT, gl_particle_min_size.value); ! gl.glPointParameterfEXT(GL.GL_POINT_SIZE_MAX_EXT, gl_particle_max_size.value); ! gl.glPointParameterfvEXT(GL.GL_DISTANCE_ATTENUATION_EXT, attenuations); } ! if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f) { ! gl.glEnable(GL.GL_SHARED_TEXTURE_PALETTE_EXT); ! GL_SetTexturePalette(d_8to24table); } GL_UpdateSwapInterval(); ! /* * vertex array extension *************** *** 251,263 **** } ! void GL_UpdateSwapInterval() ! { ! if ( gl_swapinterval.modified ) ! { gl_swapinterval.modified = false; ! if ( !gl_state.stereo_enabled ) ! { if (qwglSwapIntervalEXT) { ! ((WGL)gl).wglSwapIntervalEXT((int)gl_swapinterval.value); } } --- 236,245 ---- } ! void GL_UpdateSwapInterval() { ! if (gl_swapinterval.modified) { gl_swapinterval.modified = false; ! if (!gl_state.stereo_enabled) { if (qwglSwapIntervalEXT) { ! ((WGL) gl).wglSwapIntervalEXT((int) gl_swapinterval.value); } } |
From: Rene S. <sa...@us...> - 2004-09-22 19:22:55
|
Update of /cvsroot/jake2/jake2/src/jake2/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11556/src/jake2/server Modified Files: SV_INIT.java SV.java SV_SEND.java SV_WORLD.java SV_GAME.java server_t.java server_static_t.java SV_CCMDS.java SV_ENTS.java SV_USER.java SV_MAIN.java Log Message: major refactoring in game, server and client package Index: SV_WORLD.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_WORLD.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SV_WORLD.java 29 Aug 2004 21:39:25 -0000 1.6 --- SV_WORLD.java 22 Sep 2004 19:22:12 -0000 1.7 *************** *** 1,682 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...1182 lines suppressed...] ! clip.trace.ent = GameBase.g_edicts[0]; ! if (clip.trace.fraction == 0) ! return clip.trace; // blocked by the world ! clip.contentmask = contentmask; ! clip.start = start; ! clip.end = end; ! clip.mins = mins; ! clip.maxs = maxs; ! clip.passedict = passedict; ! Math3D.VectorCopy(mins, clip.mins2); ! Math3D.VectorCopy(maxs, clip.maxs2); ! // create the bounding box of the entire move ! SV_TraceBounds(start, clip.mins2, clip.maxs2, end, clip.boxmins, ! clip.boxmaxs); ! // clip to other solid entities ! SV_ClipMoveToEntities(clip); ! return clip.trace; ! } ! } \ No newline at end of file Index: SV_MAIN.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_MAIN.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SV_MAIN.java 10 Sep 2004 19:02:56 -0000 1.7 --- SV_MAIN.java 22 Sep 2004 19:22:12 -0000 1.8 *************** *** 1,31 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...2031 lines suppressed...] ! SV_INIT.sv.demofile.close(); ! } catch (IOException e) { ! e.printStackTrace(); ! } ! ! SV_INIT.sv = new server_t(); ! ! Globals.server_state = SV_INIT.sv.state; ! ! if (SV_INIT.svs.demofile != null) ! try { ! SV_INIT.svs.demofile.close(); ! } catch (IOException e1) { ! e1.printStackTrace(); ! } ! ! SV_INIT.svs = new server_static_t(); ! } ! } \ No newline at end of file Index: SV_INIT.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_INIT.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SV_INIT.java 29 Aug 2004 21:39:25 -0000 1.8 --- SV_INIT.java 22 Sep 2004 19:22:12 -0000 1.9 *************** *** 1,27 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...963 lines suppressed...] ! SV_SpawnServer(level, spawnpoint, Defines.ss_pic, attractloop, ! loadgame); ! } else { ! SCR.BeginLoadingPlaque(); // for local system ! SV_SEND.SV_BroadcastCommand("changing\n"); ! SV_SEND.SV_SendClientMessages(); ! SV_SpawnServer(level, spawnpoint, Defines.ss_game, attractloop, ! loadgame); ! Cbuf.CopyToDefer(); ! } ! SV_SEND.SV_BroadcastCommand("reconnect\n"); ! } ! public static server_static_t svs = new server_static_t(); // persistant ! // server info ! ! public static server_t sv = new server_t(); // local server ! } \ No newline at end of file Index: server_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/server_t.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** server_t.java 7 Jul 2004 19:59:51 -0000 1.1.1.1 --- server_t.java 22 Sep 2004 19:22:12 -0000 1.2 *************** *** 1,76 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ ! // Created on 14.01.2004 by RST. ! // $Id$ ! package jake2.server; ! import java.io.File; ! import java.io.RandomAccessFile; ! import jake2.*; ! import jake2.client.*; ! import jake2.game.*; ! import jake2.qcommon.*; ! import jake2.render.*; ! public class server_t { ! public server_t() { ! models = new cmodel_t[Defines.MAX_MODELS]; ! for (int n = 0; n < Defines.MAX_MODELS; n++) ! models[n] = new cmodel_t(); ! ! for (int n=0; n < Defines.MAX_EDICTS; n++) ! baselines[n] = new entity_state_t(null); ! ! //for (int n=0; n < Defines.MAX_CONFIGSTRINGS; n++) ! //configstrings[n] = ""; ! } ! //server_state_t state; ! int state; // precache commands are only valid during load ! boolean attractloop; // running cinematics and demos for the local system only ! boolean loadgame; // client begins should reuse existing entity ! int time; // always sv.framenum * 100 msec ! int framenum; ! //char name[MAX_QPATH]; ! String name = ""; // map name, or cinematic name ! //struct cmodel_s *models[MAX_MODELS]; ! cmodel_t models[]; ! //char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH]; ! String configstrings[] = new String[Defines.MAX_CONFIGSTRINGS]; ! entity_state_t baselines[] = new entity_state_t[Defines.MAX_EDICTS]; ! // the multicast buffer is used to send a message to a set of clients ! // it is only used to marshall data until SV_Multicast is called ! sizebuf_t multicast = new sizebuf_t(); ! byte multicast_buf[] = new byte[Defines.MAX_MSGLEN]; ! // demo server information ! RandomAccessFile demofile; ! boolean timedemo; // don't time sync ! } --- 1,72 ---- /* ! * Copyright (C) 1997-2001 Id Software, Inc. ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. ! * ! * See the GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! * ! */ ! // Created on 14.01.2004 by RST. ! // $Id$ ! package jake2.server; ! import jake2.Defines; ! import jake2.game.cmodel_t; ! import jake2.game.entity_state_t; ! import jake2.qcommon.sizebuf_t; ! import java.io.RandomAccessFile; ! public class server_t { ! public server_t() { ! models = new cmodel_t[Defines.MAX_MODELS]; ! for (int n = 0; n < Defines.MAX_MODELS; n++) ! models[n] = new cmodel_t(); ! for (int n = 0; n < Defines.MAX_EDICTS; n++) ! baselines[n] = new entity_state_t(null); ! } ! int state; // precache commands are only valid during load ! boolean attractloop; // running cinematics and demos for the local system ! // only ! boolean loadgame; // client begins should reuse existing entity ! int time; // always sv.framenum * 100 msec ! int framenum; ! String name = ""; // map name, or cinematic name ! cmodel_t models[]; ! String configstrings[] = new String[Defines.MAX_CONFIGSTRINGS]; ! entity_state_t baselines[] = new entity_state_t[Defines.MAX_EDICTS]; ! // the multicast buffer is used to send a message to a set of clients ! // it is only used to marshall data until SV_Multicast is called ! sizebuf_t multicast = new sizebuf_t(); ! byte multicast_buf[] = new byte[Defines.MAX_MSGLEN]; ! // demo server information ! RandomAccessFile demofile; ! boolean timedemo; // don't time sync ! } \ No newline at end of file Index: SV.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SV.java 29 Aug 2004 21:39:25 -0000 1.9 --- SV.java 22 Sep 2004 19:22:12 -0000 1.10 *************** *** 6,32 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...2301 lines suppressed...] ! } ! /* ! * ====================== SV_CloseEnough ! * ! * ====================== ! *///ok ! public static boolean SV_CloseEnough(edict_t ent, edict_t goal, float dist) { ! int i; ! for (i = 0; i < 3; i++) { ! if (goal.absmin[i] > ent.absmax[i] + dist) ! return false; ! if (goal.absmax[i] < ent.absmin[i] - dist) ! return false; ! } ! return true; ! } ! } \ No newline at end of file Index: SV_CCMDS.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_CCMDS.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SV_CCMDS.java 10 Sep 2004 19:02:56 -0000 1.11 --- SV_CCMDS.java 22 Sep 2004 19:22:12 -0000 1.12 *************** *** 24,39 **** package jake2.server; import jake2.Globals; ! import jake2.game.*; ! import jake2.qcommon.*; import jake2.sys.NET; import jake2.sys.Sys; import jake2.util.QuakeFile; import jake2.util.Vargs; [...1357 lines suppressed...] *************** *** 1095,1099 **** }); ! if (dedicated.value != 0) Cmd.AddCommand("say", new xcommand_t() { public void execute() { --- 1088,1092 ---- }); ! if (Globals.dedicated.value != 0) Cmd.AddCommand("say", new xcommand_t() { public void execute() { *************** *** 1136,1139 **** }); } - } --- 1129,1131 ---- Index: SV_ENTS.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_ENTS.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SV_ENTS.java 29 Aug 2004 21:39:25 -0000 1.4 --- SV_ENTS.java 22 Sep 2004 19:22:12 -0000 1.5 *************** *** 1,603 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...1195 lines suppressed...] ! // now add the accumulated multicast information ! SZ.Write(buf, SV_INIT.svs.demo_multicast.data, ! SV_INIT.svs.demo_multicast.cursize); ! SZ.Clear(SV_INIT.svs.demo_multicast); ! // now write the entire message to the file, prefixed by the length ! len = EndianHandler.swapInt(buf.cursize); ! ! try { ! //fwrite (len, 4, 1, svs.demofile); ! SV_INIT.svs.demofile.writeInt(len); ! //fwrite (buf.data, buf.cursize, 1, svs.demofile); ! SV_INIT.svs.demofile.write(buf.data, 0, buf.cursize); ! } catch (IOException e1) { ! Com.Printf("Error writing demo file:" + e); ! } ! } ! } \ No newline at end of file Index: server_static_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/server_static_t.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** server_static_t.java 7 Jul 2004 19:59:51 -0000 1.1.1.1 --- server_static_t.java 22 Sep 2004 19:22:12 -0000 1.2 *************** *** 1,65 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ ! // Created on 14.01.2004 by RST. ! // $Id$ ! package jake2.server; ! import jake2.*; ! import jake2.client.*; ! import jake2.game.*; ! import jake2.qcommon.*; ! import jake2.render.*; ! import jake2.server.*; ! import java.io.*; ! public class server_static_t { ! public server_static_t() { ! for (int n = 0; n < Defines.MAX_CHALLENGES; n++) { ! challenges[n] = new challenge_t(); ! } ! } ! boolean initialized; // sv_init has completed ! int realtime; // always increasing, no clamping, etc ! //char mapcmd[MAX_TOKEN_CHARS]; // ie: *intro.cin+base ! String mapcmd = ""; // ie: *intro.cin+base ! int spawncount; // incremented each server start ! // used to check late spawns ! client_t clients[]; // [maxclients->value]; ! int num_client_entities; // maxclients->value*UPDATE_BACKUP*MAX_PACKET_ENTITIES ! int next_client_entities; // next client_entity to use ! entity_state_t client_entities[]; // [num_client_entities] ! int last_heartbeat; ! challenge_t challenges[] = new challenge_t[Defines.MAX_CHALLENGES]; // to prevent invalid IPs from connecting ! // serverrecord values ! RandomAccessFile demofile; ! sizebuf_t demo_multicast = new sizebuf_t(); ! byte demo_multicast_buf[] = new byte[Defines.MAX_MSGLEN]; ! } --- 1,71 ---- /* ! * Copyright (C) 1997-2001 Id Software, Inc. ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. ! * ! * See the GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! * ! */ ! // Created on 14.01.2004 by RST. ! // $Id$ ! package jake2.server; ! import jake2.Defines; ! import jake2.game.entity_state_t; ! import jake2.qcommon.sizebuf_t; ! import java.io.RandomAccessFile; ! public class server_static_t { ! public server_static_t() { ! for (int n = 0; n < Defines.MAX_CHALLENGES; n++) { ! challenges[n] = new challenge_t(); ! } ! } ! boolean initialized; // sv_init has completed ! int realtime; // always increasing, no clamping, etc ! String mapcmd = ""; // ie: *intro.cin+base ! int spawncount; // incremented each server start ! // used to check late spawns ! client_t clients[]; // [maxclients->value]; ! int num_client_entities; // maxclients->value*UPDATE_BACKUP*MAX_PACKET_ENTITIES ! int next_client_entities; // next client_entity to use ! entity_state_t client_entities[]; // [num_client_entities] ! int last_heartbeat; ! challenge_t challenges[] = new challenge_t[Defines.MAX_CHALLENGES]; // to ! // prevent ! // invalid ! // IPs ! // from ! // connecting ! // serverrecord values ! RandomAccessFile demofile; ! sizebuf_t demo_multicast = new sizebuf_t(); ! byte demo_multicast_buf[] = new byte[Defines.MAX_MSGLEN]; ! } \ No newline at end of file Index: SV_SEND.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_SEND.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SV_SEND.java 10 Sep 2004 19:02:56 -0000 1.5 --- SV_SEND.java 22 Sep 2004 19:22:12 -0000 1.6 *************** *** 31,36 **** import jake2.qcommon.*; import jake2.render.*; ! public class SV_SEND extends SV_MAIN { /* ============================================================================= --- 31,37 ---- import jake2.qcommon.*; import jake2.render.*; + import jake2.util.Math3D; ! public class SV_SEND { /* ============================================================================= *************** *** 41,58 **** */ ! public static byte sv_outputbuf[]= new byte[SV_OUTPUTBUF_LENGTH]; public static void SV_FlushRedirect(int sv_redirected, byte outputbuf[]) { ! if (sv_redirected == RD_PACKET) { ! String s= ("print\n" + outputbuf); ! Netchan.Netchan_OutOfBand(NS_SERVER, Netchan.net_from, s.length(), s.getBytes()); } ! else if (sv_redirected == RD_CLIENT) { ! MSG.WriteByte(SV_MAIN.sv_client.netchan.message, svc_print); ! MSG.WriteByte(SV_MAIN.sv_client.netchan.message, PRINT_HIGH); MSG.WriteString(SV_MAIN.sv_client.netchan.message, outputbuf); ! } } - /* ============================================================================= --- 42,58 ---- */ ! public static byte sv_outputbuf[] = new byte[Defines.SV_OUTPUTBUF_LENGTH]; public static void SV_FlushRedirect(int sv_redirected, byte outputbuf[]) { ! if (sv_redirected == Defines.RD_PACKET) { ! String s = ("print\n" + outputbuf); ! Netchan.Netchan_OutOfBand(Defines.NS_SERVER, Globals.net_from, s.length(), s.getBytes()); } ! else if (sv_redirected == Defines.RD_CLIENT) { ! MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_print); ! MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.PRINT_HIGH); MSG.WriteString(SV_MAIN.sv_client.netchan.message, outputbuf); ! } } /* ============================================================================= *************** *** 75,83 **** return; ! MSG.WriteByte(cl.netchan.message, svc_print); MSG.WriteByte(cl.netchan.message, level); MSG.WriteString(cl.netchan.message, s); } - /* ================= --- 75,82 ---- return; ! MSG.WriteByte(cl.netchan.message, Defines.svc_print); MSG.WriteByte(cl.netchan.message, level); MSG.WriteString(cl.netchan.message, s); } /* ================= *************** *** 92,112 **** // echo to console ! if (dedicated.value != 0) { Com.Printf(s); } ! for (int i= 0; i < SV_MAIN.maxclients.value; i++) { ! cl= SV_MAIN.svs.clients[i]; if (level < cl.messagelevel) continue; ! if (cl.state != cs_spawned) continue; ! MSG.WriteByte(cl.netchan.message, svc_print); MSG.WriteByte(cl.netchan.message, level); MSG.WriteString(cl.netchan.message, s); } } - /* ================= --- 91,110 ---- // echo to console ! if (Globals.dedicated.value != 0) { Com.Printf(s); } ! for (int i = 0; i < SV_MAIN.maxclients.value; i++) { ! cl = SV_INIT.svs.clients[i]; if (level < cl.messagelevel) continue; ! if (cl.state != Defines.cs_spawned) continue; ! MSG.WriteByte(cl.netchan.message, Defines.svc_print); MSG.WriteByte(cl.netchan.message, level); MSG.WriteString(cl.netchan.message, s); } } /* ================= *************** *** 118,129 **** public static void SV_BroadcastCommand(String s) { ! if (sv.state == 0) return; ! MSG.WriteByte(sv.multicast, svc_stufftext); ! MSG.WriteString(sv.multicast, s); ! SV_Multicast(null, MULTICAST_ALL_R); } - /* ================= --- 116,126 ---- public static void SV_BroadcastCommand(String s) { ! if (SV_INIT.sv.state == 0) return; ! MSG.WriteByte(SV_INIT.sv.multicast, Defines.svc_stufftext); ! MSG.WriteString(SV_INIT.sv.multicast, s); ! SV_Multicast(null, Defines.MULTICAST_ALL_R); } /* ================= *************** *** 146,206 **** int area1, area2; ! reliable= false; ! if (to != MULTICAST_ALL_R && to != MULTICAST_ALL) { ! leafnum= CM.CM_PointLeafnum(origin); ! area1= CM.CM_LeafArea(leafnum); } else { ! leafnum= 0; // just to avoid compiler warnings ! area1= 0; } // if doing a serverrecord, store everything ! if (svs.demofile != null) ! SZ.Write(svs.demo_multicast, sv.multicast.data, sv.multicast.cursize); switch (to) { ! case MULTICAST_ALL_R : ! reliable= true; // intentional fallthrough, no break here ! case MULTICAST_ALL : ! leafnum= 0; ! mask= null; break; ! case MULTICAST_PHS_R : ! reliable= true; // intentional fallthrough ! case MULTICAST_PHS : ! leafnum= CM.CM_PointLeafnum(origin); ! cluster= CM.CM_LeafCluster(leafnum); ! mask= CM.CM_ClusterPHS(cluster); break; ! case MULTICAST_PVS_R : ! reliable= true; // intentional fallthrough ! case MULTICAST_PVS : ! leafnum= CM.CM_PointLeafnum(origin); ! cluster= CM.CM_LeafCluster(leafnum); ! mask= CM.CM_ClusterPVS(cluster); break; default : ! mask= null; ! Com.Error(ERR_FATAL, "SV_Multicast: bad to:" + to + "\n"); } // send the data to all relevent clients ! for (j= 0; j < maxclients.value; j++) { ! client= svs.clients[j]; ! if (client.state == cs_free || client.state == cs_zombie) continue; ! if (client.state != cs_spawned && !reliable) continue; if (mask != null) { ! leafnum= CM.CM_PointLeafnum(client.edict.s.origin); ! cluster= CM.CM_LeafCluster(leafnum); ! area2= CM.CM_LeafArea(leafnum); if (!CM.CM_AreasConnected(area1, area2)) continue; --- 143,203 ---- int area1, area2; ! reliable = false; ! if (to != Defines.MULTICAST_ALL_R && to != Defines.MULTICAST_ALL) { ! leafnum = CM.CM_PointLeafnum(origin); ! area1 = CM.CM_LeafArea(leafnum); } else { ! leafnum = 0; // just to avoid compiler warnings ! area1 = 0; } // if doing a serverrecord, store everything ! if (SV_INIT.svs.demofile != null) ! SZ.Write(SV_INIT.svs.demo_multicast, SV_INIT.sv.multicast.data, SV_INIT.sv.multicast.cursize); switch (to) { ! case Defines.MULTICAST_ALL_R : ! reliable = true; // intentional fallthrough, no break here ! case Defines.MULTICAST_ALL : ! leafnum = 0; ! mask = null; break; ! case Defines.MULTICAST_PHS_R : ! reliable = true; // intentional fallthrough ! case Defines.MULTICAST_PHS : ! leafnum = CM.CM_PointLeafnum(origin); ! cluster = CM.CM_LeafCluster(leafnum); ! mask = CM.CM_ClusterPHS(cluster); break; ! case Defines.MULTICAST_PVS_R : ! reliable = true; // intentional fallthrough ! case Defines.MULTICAST_PVS : ! leafnum = CM.CM_PointLeafnum(origin); ! cluster = CM.CM_LeafCluster(leafnum); ! mask = CM.CM_ClusterPVS(cluster); break; default : ! mask = null; ! Com.Error(Defines.ERR_FATAL, "SV_Multicast: bad to:" + to + "\n"); } // send the data to all relevent clients ! for (j = 0; j < SV_MAIN.maxclients.value; j++) { ! client = SV_INIT.svs.clients[j]; ! if (client.state == Defines.cs_free || client.state == Defines.cs_zombie) continue; ! if (client.state != Defines.cs_spawned && !reliable) continue; if (mask != null) { ! leafnum = CM.CM_PointLeafnum(client.edict.s.origin); ! cluster = CM.CM_LeafCluster(leafnum); ! area2 = CM.CM_LeafArea(leafnum); if (!CM.CM_AreasConnected(area1, area2)) continue; *************** *** 214,225 **** if (reliable) ! SZ.Write(client.netchan.message, sv.multicast.data, sv.multicast.cursize); else ! SZ.Write(client.datagram, sv.multicast.data, sv.multicast.cursize); } ! SZ.Clear(sv.multicast); } - /* ================== --- 211,221 ---- if (reliable) ! SZ.Write(client.netchan.message, SV_INIT.sv.multicast.data, SV_INIT.sv.multicast.cursize); else ! SZ.Write(client.datagram, SV_INIT.sv.multicast.data, SV_INIT.sv.multicast.cursize); } ! SZ.Clear(SV_INIT.sv.multicast); } /* ================== *************** *** 260,271 **** int i; int ent; ! float[] origin_v= { 0, 0, 0 }; boolean use_phs; if (volume < 0 || volume > 1.0) ! Com.Error(ERR_FATAL, "SV_StartSound: volume = " + volume); if (attenuation < 0 || attenuation > 4) ! Com.Error(ERR_FATAL, "SV_StartSound: attenuation = " + attenuation); // if (channel < 0 || channel > 15) --- 256,267 ---- int i; int ent; ! float[] origin_v = { 0, 0, 0 }; boolean use_phs; if (volume < 0 || volume > 1.0) ! Com.Error(Defines.ERR_FATAL, "SV_StartSound: volume = " + volume); if (attenuation < 0 || attenuation > 4) ! Com.Error(Defines.ERR_FATAL, "SV_StartSound: attenuation = " + attenuation); // if (channel < 0 || channel > 15) *************** *** 273,355 **** if (timeofs < 0 || timeofs > 0.255) ! Com.Error(ERR_FATAL, "SV_StartSound: timeofs = " + timeofs); ! ent= entity.index; // no PHS flag if ((channel & 8) != 0) { ! use_phs= false; channel &= 7; } else ! use_phs= true; ! sendchan= (ent << 3) | (channel & 7); ! flags= 0; if (volume != Defines.DEFAULT_SOUND_PACKET_VOLUME) ! flags |= SND_VOLUME; ! if (attenuation != DEFAULT_SOUND_PACKET_ATTENUATION) ! flags |= SND_ATTENUATION; // the client doesn't know that bmodels have weird origins // the origin can also be explicitly set ! if ((entity.svflags & SVF_NOCLIENT) != 0 || (entity.solid == SOLID_BSP) || origin != null) ! flags |= SND_POS; // always send the entity number for channel overrides ! flags |= SND_ENT; if (timeofs != 0) ! flags |= SND_OFFSET; // use the entity origin unless it is a bmodel or explicitly specified if (origin == null) { ! origin= origin_v; ! if (entity.solid == SOLID_BSP) { ! for (i= 0; i < 3; i++) ! origin_v[i]= entity.s.origin[i] + 0.5f * (entity.mins[i] + entity.maxs[i]); } else { ! VectorCopy(entity.s.origin, origin_v); } } ! MSG.WriteByte(sv.multicast, svc_sound); ! MSG.WriteByte(sv.multicast, flags); ! MSG.WriteByte(sv.multicast, soundindex); ! if ((flags & SND_VOLUME) != 0) ! MSG.WriteByte(sv.multicast, volume * 255); ! if ((flags & SND_ATTENUATION) != 0) ! MSG.WriteByte(sv.multicast, attenuation * 64); ! if ((flags & SND_OFFSET) != 0) ! MSG.WriteByte(sv.multicast, timeofs * 1000); ! if ((flags & SND_ENT) != 0) ! MSG.WriteShort(sv.multicast, sendchan); ! if ((flags & SND_POS) != 0) ! MSG.WritePos(sv.multicast, origin); // if the sound doesn't attenuate,send it to everyone // (global radio chatter, voiceovers, etc) ! if (attenuation == ATTN_NONE) ! use_phs= false; ! if ((channel & CHAN_RELIABLE) != 0) { if (use_phs) ! SV_Multicast(origin, MULTICAST_PHS_R); else ! SV_Multicast(origin, MULTICAST_ALL_R); } else { if (use_phs) ! SV_Multicast(origin, MULTICAST_PHS); else ! SV_Multicast(origin, MULTICAST_ALL); } } - /* =============================================================================== --- 269,350 ---- if (timeofs < 0 || timeofs > 0.255) ! Com.Error(Defines.ERR_FATAL, "SV_StartSound: timeofs = " + timeofs); ! ent = entity.index; // no PHS flag if ((channel & 8) != 0) { ! use_phs = false; channel &= 7; } else ! use_phs = true; ! sendchan = (ent << 3) | (channel & 7); ! flags = 0; if (volume != Defines.DEFAULT_SOUND_PACKET_VOLUME) ! flags |= Defines.SND_VOLUME; ! if (attenuation != Defines.DEFAULT_SOUND_PACKET_ATTENUATION) ! flags |= Defines.SND_ATTENUATION; // the client doesn't know that bmodels have weird origins // the origin can also be explicitly set ! if ((entity.svflags & Defines.SVF_NOCLIENT) != 0 || (entity.solid == Defines.SOLID_BSP) || origin != null) ! flags |= Defines.SND_POS; // always send the entity number for channel overrides ! flags |= Defines.SND_ENT; if (timeofs != 0) ! flags |= Defines.SND_OFFSET; // use the entity origin unless it is a bmodel or explicitly specified if (origin == null) { ! origin = origin_v; ! if (entity.solid == Defines.SOLID_BSP) { ! for (i = 0; i < 3; i++) ! origin_v[i] = entity.s.origin[i] + 0.5f * (entity.mins[i] + entity.maxs[i]); } else { ! Math3D.VectorCopy(entity.s.origin, origin_v); } } ! MSG.WriteByte(SV_INIT.sv.multicast, Defines.svc_sound); ! MSG.WriteByte(SV_INIT.sv.multicast, flags); ! MSG.WriteByte(SV_INIT.sv.multicast, soundindex); ! if ((flags & Defines.SND_VOLUME) != 0) ! MSG.WriteByte(SV_INIT.sv.multicast, volume * 255); ! if ((flags & Defines.SND_ATTENUATION) != 0) ! MSG.WriteByte(SV_INIT.sv.multicast, attenuation * 64); ! if ((flags & Defines.SND_OFFSET) != 0) ! MSG.WriteByte(SV_INIT.sv.multicast, timeofs * 1000); ! if ((flags & Defines.SND_ENT) != 0) ! MSG.WriteShort(SV_INIT.sv.multicast, sendchan); ! if ((flags & Defines.SND_POS) != 0) ! MSG.WritePos(SV_INIT.sv.multicast, origin); // if the sound doesn't attenuate,send it to everyone // (global radio chatter, voiceovers, etc) ! if (attenuation == Defines.ATTN_NONE) ! use_phs = false; ! if ((channel & Defines.CHAN_RELIABLE) != 0) { if (use_phs) ! SV_Multicast(origin, Defines.MULTICAST_PHS_R); else ! SV_Multicast(origin, Defines.MULTICAST_ALL_R); } else { if (use_phs) ! SV_Multicast(origin, Defines.MULTICAST_PHS); else ! SV_Multicast(origin, Defines.MULTICAST_ALL); } } /* =============================================================================== *************** *** 366,380 **** */ public static boolean SV_SendClientDatagram(client_t client) { ! byte msg_buf[]= new byte[MAX_MSGLEN]; ! sizebuf_t msg= new sizebuf_t(); SV_ENTS.SV_BuildClientFrame(client); SZ.Init(msg, msg_buf, msg_buf.length); ! msg.allowoverflow= true; // send over all the relevant entity_state_t // and the player_state_t ! SV_CCMDS.SV_WriteFrameToClient(client, msg); // copy the accumulated multicast datagram --- 361,375 ---- */ public static boolean SV_SendClientDatagram(client_t client) { ! byte msg_buf[] = new byte[Defines.MAX_MSGLEN]; ! sizebuf_t msg = new sizebuf_t(); SV_ENTS.SV_BuildClientFrame(client); SZ.Init(msg, msg_buf, msg_buf.length); ! msg.allowoverflow = true; // send over all the relevant entity_state_t // and the player_state_t ! SV_ENTS.SV_WriteFrameToClient(client, msg); // copy the accumulated multicast datagram *************** *** 397,405 **** // record the size for rate estimation ! client.message_size[sv.framenum % RATE_MESSAGES]= msg.cursize; return true; } - /* ================== --- 392,399 ---- // record the size for rate estimation ! client.message_size[SV_INIT.sv.framenum % Defines.RATE_MESSAGES] = msg.cursize; return true; } /* ================== *************** *** 408,423 **** */ public static void SV_DemoCompleted() { ! if (sv.demofile != null) { try { ! sv.demofile.close(); } catch (IOException e) { Com.Printf("IOError closing d9emo fiele:" + e); } ! sv.demofile= null; } ! SV_ENTS.SV_Nextserver(); } - /* ======================= --- 402,416 ---- */ public static void SV_DemoCompleted() { ! if (SV_INIT.sv.demofile != null) { try { ! SV_INIT.sv.demofile.close(); } catch (IOException e) { Com.Printf("IOError closing d9emo fiele:" + e); } ! SV_INIT.sv.demofile = null; } ! SV_USER.SV_Nextserver(); } /* ======================= *************** *** 433,442 **** // never drop over the loopback ! if (c.netchan.remote_address.type == NA_LOOPBACK) return false; ! total= 0; ! for (i= 0; i < RATE_MESSAGES; i++) { total += c.message_size[i]; } --- 426,435 ---- // never drop over the loopback ! if (c.netchan.remote_address.type == Defines.NA_LOOPBACK) return false; ! total = 0; ! for (i = 0; i < Defines.RATE_MESSAGES; i++) { total += c.message_size[i]; } *************** *** 444,448 **** if (total > c.rate) { c.surpressCount++; ! c.message_size[sv.framenum % RATE_MESSAGES]= 0; return true; } --- 437,441 ---- if (total > c.rate) { c.surpressCount++; ! c.message_size[SV_INIT.sv.framenum % Defines.RATE_MESSAGES] = 0; return true; } *************** *** 450,454 **** return false; } - /* ======================= --- 443,446 ---- *************** *** 460,477 **** client_t c; int msglen; ! byte msgbuf[]= new byte[MAX_MSGLEN]; int r; ! msglen= 0; // read the next demo message if needed ! if (sv.state == ss_demo && sv.demofile != null) { ! if (sv_paused.value != 0) ! msglen= 0; else { // get the next message //r = fread (&msglen, 4, 1, sv.demofile); try { ! msglen= EndianHandler.swapInt(sv.demofile.readInt()); } catch (Exception e) { --- 452,469 ---- client_t c; int msglen; ! byte msgbuf[] = new byte[Defines.MAX_MSGLEN]; int r; ! msglen = 0; // read the next demo message if needed ! if (SV_INIT.sv.state == Defines.ss_demo && SV_INIT.sv.demofile != null) { ! if (SV_MAIN.sv_paused.value != 0) ! msglen = 0; else { // get the next message //r = fread (&msglen, 4, 1, sv.demofile); try { ! msglen = EndianHandler.swapInt(SV_INIT.sv.demofile.readInt()); } catch (Exception e) { *************** *** 485,495 **** return; } ! if (msglen > MAX_MSGLEN) ! Com.Error(ERR_DROP, "SV_SendClientMessages: msglen > MAX_MSGLEN"); //r = fread (msgbuf, msglen, 1, sv.demofile); ! r= 0; try { ! r= sv.demofile.read(msgbuf, 0, msglen); } catch (IOException e1) { --- 477,487 ---- return; } ! if (msglen > Defines.MAX_MSGLEN) ! Com.Error(Defines.ERR_DROP, "SV_SendClientMessages: msglen > MAX_MSGLEN"); //r = fread (msgbuf, msglen, 1, sv.demofile); ! r = 0; try { ! r = SV_INIT.sv.demofile.read(msgbuf, 0, msglen); } catch (IOException e1) { *************** *** 504,509 **** // send a message to each connected client ! for (i= 0; i < maxclients.value; i++) { ! c= svs.clients[i]; if (c.state == 0) --- 496,501 ---- // send a message to each connected client ! for (i = 0; i < SV_MAIN.maxclients.value; i++) { ! c = SV_INIT.svs.clients[i]; if (c.state == 0) *************** *** 514,524 **** SZ.Clear(c.netchan.message); SZ.Clear(c.datagram); ! SV_BroadcastPrintf(PRINT_HIGH, c.name + " overflowed\n"); ! SV_DropClient(c); } ! if (sv.state == ss_cinematic || sv.state == ss_demo || sv.state == ss_pic) Netchan.Transmit(c.netchan, msglen, msgbuf); ! else if (c.state == cs_spawned) { // don't overrun bandwidth if (SV_RateDrop(c)) --- 506,518 ---- SZ.Clear(c.netchan.message); SZ.Clear(c.datagram); ! SV_BroadcastPrintf(Defines.PRINT_HIGH, c.name + " overflowed\n"); ! SV_MAIN.SV_DropClient(c); } ! if (SV_INIT.sv.state == Defines.ss_cinematic ! || SV_INIT.sv.state == Defines.ss_demo ! || SV_INIT.sv.state == Defines.ss_pic) Netchan.Transmit(c.netchan, msglen, msgbuf); ! else if (c.state == Defines.cs_spawned) { // don't overrun bandwidth if (SV_RateDrop(c)) Index: SV_USER.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_USER.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SV_USER.java 29 Aug 2004 21:39:25 -0000 1.5 --- SV_USER.java 22 Sep 2004 19:22:12 -0000 1.6 *************** *** 1,735 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...1398 lines suppressed...] ! // copy. ! cl.lastcmd.set(newcmd); ! break; ! ! case Defines.clc_stringcmd: ! s = MSG.ReadString(Globals.net_message); ! ! // malicious users may try using too many string commands ! if (++stringCmdCount < SV_USER.MAX_STRINGCMDS) ! SV_ExecuteUserCommand(s); ! ! if (cl.state == Defines.cs_zombie) ! return; // disconnect command ! break; ! } ! } ! } ! } \ No newline at end of file Index: SV_GAME.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_GAME.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SV_GAME.java 29 Aug 2004 21:39:25 -0000 1.7 --- SV_GAME.java 22 Sep 2004 19:22:12 -0000 1.8 *************** *** 1,318 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ ! // Created on 14.01.2004 by RST. ! // $Id$ ! package jake2.server; ! import jake2.game.*; ! import jake2.qcommon.*; ! public class SV_GAME extends SV_INIT { ! /* ! =============== ! PF_Unicast ! ! Sends the contents of the mutlicast buffer to a single client ! =============== ! */ ! public static void PF_Unicast(edict_t ent, boolean reliable) { ! int p; ! client_t client; ! if (ent == null) ! return; ! p = ent.index; ! if (p < 1 || p > SV_MAIN.maxclients.value) ! return; ! client = SV_INIT.svs.clients[p - 1]; ! if (reliable) ! SZ.Write(client.netchan.message, SV_INIT.sv.multicast.data, SV_INIT.sv.multicast.cursize); ! else ! SZ.Write(client.datagram, sv.multicast.data, sv.multicast.cursize); ! SZ.Clear(sv.multicast); ! } ! /* ! =============== ! PF_dprintf ! ! Debug print to server console ! =============== ! */ ! public static void PF_dprintf(String fmt) { ! Com.Printf(fmt); ! } ! /* ! =============== ! PF_cprintf ! ! Print to a single client ! =============== ! */ ! public static void PF_cprintf(edict_t ent, int level, String fmt) { ! int n = 0; ! if (ent != null) { ! n = ent.index; ! if (n < 1 || n > SV_MAIN.maxclients.value) ! Com.Error(ERR_DROP, "cprintf to a non-client"); ! } ! if (ent != null) ! SV_SEND.SV_ClientPrintf(svs.clients[n - 1], level, fmt); ! else ! Com.Printf(fmt); ! } ! /* ! =============== ! PF_centerprintf ! ! centerprint to a single client ! =============== ! */ ! public static void PF_centerprintf(edict_t ent, String fmt) { ! int n; ! n = ent.index; ! if (n < 1 || n > SV_MAIN.maxclients.value) ! return; // Com_Error (ERR_DROP, "centerprintf to a non-client"); ! MSG.WriteByte(sv.multicast, svc_centerprint); ! MSG.WriteString(sv.multicast, fmt); ! PF_Unicast(ent, true); ! } ! /* ! =============== ! PF_error ! ! Abort the server with a game error ! =============== ! */ ! public static void PF_error(String fmt) { ! Com.Error(ERR_DROP, "Game Error: " + fmt); ! } ! public static void PF_error(int level, String fmt) { ! Com.Error(level, fmt); ! } ! /* ! ================= ! PF_setmodel ! ! Also sets mins and maxs for inline bmodels ! ================= ! */ ! public static void PF_setmodel(edict_t ent, String name) { ! int i; ! cmodel_t mod; ! if (name == null) ! Com.Error(ERR_DROP, "PF_setmodel: NULL"); ! i = SV_ModelIndex(name); ! ent.s.modelindex = i; ! // if it is an inline model, get the size information for it ! if (name.startsWith("*")) { ! mod = CM.InlineModel(name); ! VectorCopy(mod.mins, ent.mins); ! VectorCopy(mod.maxs, ent.maxs); ! SV_WORLD.SV_LinkEdict(ent); ! } ! } ! /* ! =============== ! PF_Configstring ! ! =============== ! */ ! public static void PF_Configstring(int index, String val) { ! if (index < 0 || index >= MAX_CONFIGSTRINGS) ! Com.Error(ERR_DROP, "configstring: bad index " + index + "\n"); ! if (val == null) ! val = ""; ! // change the string in sv ! sv.configstrings[index] = val; ! if (sv.state != ss_loading) { // send the update to everyone ! SZ.Clear(sv.multicast); ! MSG.WriteChar(sv.multicast, svc_configstring); ! MSG.WriteShort(sv.multicast, index); ! MSG.WriteString(sv.multicast, val); ! SV_SEND.SV_Multicast(vec3_origin, MULTICAST_ALL_R); ! } ! } ! public static void PF_WriteChar(int c) { ! MSG.WriteChar(sv.multicast, c); ! } ! public static void PF_WriteByte(int c) { ! MSG.WriteByte(sv.multicast, c); ! } ! public static void PF_WriteShort(int c) { ! MSG.WriteShort(sv.multicast, c); ! } ! public static void PF_WriteLong(int c) { ! MSG.WriteLong(sv.multicast, c); ! } ! public static void PF_WriteFloat(float f) { ! MSG.WriteFloat(sv.multicast, f); ! } ! public static void PF_WriteString(String s) { ! MSG.WriteString(sv.multicast, s); ! } ! public static void PF_WritePos(float[] pos) { ! MSG.WritePos(sv.multicast, pos); ! } ! public static void PF_WriteDir(float[] dir) { ! MSG.WriteDir(sv.multicast, dir); ! } ! public static void PF_WriteAngle(float f) { ! MSG.WriteAngle(sv.multicast, f); ! } ! /* ! ================= ! PF_inPVS ! ! Also checks portalareas so that doors block sight ! ================= ! */ ! public static boolean PF_inPVS(float[] p1, float[] p2) { ! int leafnum; ! int cluster; ! int area1, area2; ! byte mask[]; ! leafnum = CM.CM_PointLeafnum(p1); ! cluster = CM.CM_LeafCluster(leafnum); ! area1 = CM.CM_LeafArea(leafnum); ! mask = CM.CM_ClusterPVS(cluster); ! leafnum = CM.CM_PointLeafnum(p2); ! cluster = CM.CM_LeafCluster(leafnum); ! area2 = CM.CM_LeafArea(leafnum); ! // quake2 bugfix ! if (cluster == -1) ! return false; ! if (mask != null && (0 == (mask[cluster >>> 3] & (1 << (cluster & 7))))) ! return false; ! if (!CM.CM_AreasConnected(area1, area2)) ! return false; // a door blocks sight ! return true; ! } ! /* ! ================= ! PF_inPHS ! ! Also checks portalareas so that doors block sound ! ================= ! */ ! public static boolean PF_inPHS(float[] p1, float[] p2) { ! int leafnum; ! int cluster; ! int area1, area2; ! byte mask[]; ! leafnum = CM.CM_PointLeafnum(p1); ! cluster = CM.CM_LeafCluster(leafnum); ! area1 = CM.CM_LeafArea(leafnum); ! mask = CM.CM_ClusterPHS(cluster); ! leafnum = CM.CM_PointLeafnum(p2); ! cluster = CM.CM_LeafCluster(leafnum); ! area2 = CM.CM_LeafArea(leafnum); ! // quake2 bugfix ! if (cluster == -1) ! return false; ! if (mask != null && (0 == (mask[cluster >> 3] & (1 << (cluster & 7))))) ! return false; // more than one bounce away ! if (!CM.CM_AreasConnected(area1, area2)) ! return false; // a door blocks hearing ! return true; ! } ! public static void PF_StartSound(edict_t entity, int channel, int sound_num, float volume, float attenuation, float timeofs) { ! ! if (null == entity) ! return; ! SV_SEND.SV_StartSound (null, entity, channel, sound_num, volume, attenuation, timeofs); ! ! } ! //============================================== ! /* ! =============== ! SV_ShutdownGameProgs ! ! Called when either the entire server is being killed, or ! it is changing to a different game directory. ! =============== ! */ ! public static void SV_ShutdownGameProgs() { ! Game.ShutdownGame(); ! } ! /* ! =============== ! SV_InitGameProgs ! ! Init the game subsystem for a new map ! =============== ! */ ! public static void SV_InitGameProgs() { ! // unload anything we have now ! SV_ShutdownGameProgs(); ! game_import_t gimport = new game_import_t(); ! // all functions set in game_export_t (rst) ! GameBase.GetGameApi(gimport); ! Game.InitGame(); ! } ! } --- 1,313 ---- /* ! * Copyright (C) 1997-2001 Id Software, Inc. ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. ! * ! * See the GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! * ! */ ! // Created on 14.01.2004 by RST. ! // $Id$ ! package jake2.server; ! import jake2.Defines; ! import jake2.Globals; ! import jake2.game.*; ! import jake2.qcommon.*; ! import jake2.util.Math3D; ! public class SV_GAME { ! /* ! * =============== PF_Unicast ! * ! * Sends the contents of the mutlicast buffer to a single client ! * =============== ! */ ! public static void PF_Unicast(edict_t ent, boolean reliable) { ! int p; ! client_t client; ! if (ent == null) ! return; ! p = ent.index; ! if (p < 1 || p > SV_MAIN.maxclients.value) ! return; ! client = SV_INIT.svs.clients[p - 1]; ! if (reliable) ! SZ.Write(client.netchan.message, SV_INIT.sv.multicast.data, ! SV_INIT.sv.multicast.cursize); ! else ! SZ.Write(client.datagram, SV_INIT.sv.multicast.data, ! SV_INIT.sv.multicast.cursize); ! SZ.Clear(SV_INIT.sv.multicast); ! } + /* + * =============== PF_dprintf + * + * Debug print to server console =============== + */ + public static void PF_dprintf(String fmt) { + Com.Printf(fmt); + } ! /* ! * =============== PF_cprintf ! * ! * Print to a single client =============== ! */ ! public static void PF_cprintf(edict_t ent, int level, String fmt) { ! int n = 0; ! if (ent != null) { ! n = ent.index; ! if (n < 1 || n > SV_MAIN.maxclients.value) ! Com.Error(Defines.ERR_DROP, "cprintf to a non-client"); ! } ! if (ent != null) ! SV_SEND.SV_ClientPrintf(SV_INIT.svs.clients[n - 1], level, fmt); ! else ! Com.Printf(fmt); ! } ! /* ! * =============== PF_centerprintf ! * ! * centerprint to a single client =============== ! */ ! public static void PF_centerprintf(edict_t ent, String fmt) { ! int n; ! n = ent.index; ! if (n < 1 || n > SV_MAIN.maxclients.value) ! return; // Com_Error (ERR_DROP, "centerprintf to a non-client"); ! MSG.WriteByte(SV_INIT.sv.multicast, Defines.svc_centerprint); ! MSG.WriteString(SV_INIT.sv.multicast, fmt); ! PF_Unicast(ent, true); ! } ! /* ! * =============== PF_error ! * ! * Abort the server with a game error =============== ! */ ! public static void PF_error(String fmt) { ! Com.Error(Defines.ERR_DROP, "Game Error: " + fmt); ! } ! public static void PF_error(int level, String fmt) { ! Com.Error(level, fmt); ! } ! /* ! * ================= PF_setmodel ! * ! * Also sets mins and maxs for inline bmodels ================= ! */ ! public static void PF_setmodel(edict_t ent, String name) { ! int i; ! cmodel_t mod; ! if (name == null) ! Com.Error(Defines.ERR_DROP, "PF_setmodel: NULL"); ! i = SV_INIT.SV_ModelIndex(name); ! ent.s.modelindex = i; ! // if it is an inline model, get the size information for it ! if (name.startsWith("*")) { ! mod = CM.InlineModel(name); ! Math3D.VectorCopy(mod.mins, ent.mins); ! Math3D.VectorCopy(mod.maxs, ent.maxs); ! SV_WORLD.SV_LinkEdict(ent); ! } ! } ! /* ! * =============== PF_Configstring ! * ! * =============== ! */ ! public static void PF_Configstring(int index, String val) { ! if (index < 0 || index >= Defines.MAX_CONFIGSTRINGS) ! Com.Error(Defines.ERR_DROP, "configstring: bad index " + index ! + "\n"); ! if (val == null) ! val = ""; ! // change the string in sv ! SV_INIT.sv.configstrings[index] = val; ! if (SV_INIT.sv.state != Defines.ss_loading) { // send the update to ! // everyone ! SZ.Clear(SV_INIT.sv.multicast); ! MSG.WriteChar(SV_INIT.sv.multicast, Defines.svc_configstring); ! MSG.WriteShort(SV_INIT.sv.multicast, index); ! MSG.WriteString(SV_INIT.sv.multicast, val); ! SV_SEND.SV_Multicast(Globals.vec3_origin, Defines.MULTICAST_ALL_R); ! } ! } ! public static void PF_WriteChar(int c) { ! MSG.WriteChar(SV_INIT.sv.multicast, c); ! } ! public static void PF_WriteByte(int c) { ! MSG.WriteByte(SV_INIT.sv.multicast, c); ! } ! public static void PF_WriteShort(int c) { ! MSG.WriteShort(SV_INIT.sv.multicast, c); ! } ! public static void PF_WriteLong(int c) { ! MSG.WriteLong(SV_INIT.sv.multicast, c); ! } ! public static void PF_WriteFloat(float f) { ! MSG.WriteFloat(SV_INIT.sv.multicast, f); ! } ! public static void PF_WriteString(String s) { ! MSG.WriteString(SV_INIT.sv.multicast, s); ! } ! public static void PF_WritePos(float[] pos) { ! MSG.WritePos(SV_INIT.sv.multicast, pos); ! } ! public static void PF_WriteDir(float[] dir) { ! MSG.WriteDir(SV_INIT.sv.multicast, dir); ! } ! public static void PF_WriteAngle(float f) { ! MSG.WriteAngle(SV_INIT.sv.multicast, f); ! } ! /* ! * ================= PF_inPVS ! * ! * Also checks portalareas so that doors block sight ================= ! */ ! public static boolean PF_inPVS(float[] p1, float[] p2) { ! int leafnum; ! int cluster; ! int area1, area2; ! byte mask[]; ! leafnum = CM.CM_PointLeafnum(p1); ! cluster = CM.CM_LeafCluster(leafnum); ! area1 = CM.CM_LeafArea(leafnum); ! mask = CM.CM_ClusterPVS(cluster); ! leafnum = CM.CM_PointLeafnum(p2); ! cluster = CM.CM_LeafCluster(leafnum); ! area2 = CM.CM_LeafArea(leafnum); ! // quake2 bugfix ! if (cluster == -1) ! return false; ! if (mask != null && (0 == (mask[cluster >>> 3] & (1 << (cluster & 7))))) ! return false; ! if (!CM.CM_AreasConnected(area1, area2)) ! return false; // a door blocks sight ! return true; ! } ! /* ! * ================= PF_inPHS ! * ! * Also checks portalareas so that doors block sound ================= ! */ ! public static boolean PF_inPHS(float[] p1, float[] p2) { ! int leafnum; ! int cluster; ! int area1, area2; ! byte mask[]; ! leafnum = CM.CM_PointLeafnum(p1); ! cluster = CM.CM_LeafCluster(leafnum); ! area1 = CM.CM_LeafArea(leafnum); ! mask = CM.CM_ClusterPHS(cluster); ! leafnum = CM.CM_PointLeafnum(p2); ! cluster = CM.CM_LeafCluster(leafnum); ! area2 = CM.CM_LeafArea(leafnum); ! // quake2 bugfix ! if (cluster == -1) ! return false; ! if (mask != null && (0 == (mask[cluster >> 3] & (1 << (cluster & 7))))) ! return false; // more than one bounce away ! if (!CM.CM_AreasConnected(area1, area2)) ! return false; // a door blocks hearing ! return true; ! } ! public static void PF_StartSound(edict_t entity, int channel, ! int sound_num, float volume, float attenuation, float timeofs) { ! if (null == entity) ! return; ! SV_SEND.SV_StartSound(null, entity, channel, sound_num, volume, ! attenuation, timeofs); ! } ! //============================================== ! /* ! * =============== SV_ShutdownGameProgs ! * ! * Called when either the entire server is being killed, or it is changing ! * to a different game directory. =============== ! */ ! public static void SV_ShutdownGameProgs() { ! GameBase.ShutdownGame(); ! } ! /* ! * =============== SV_InitGameProgs ! * ! * Init the game subsystem for a new map =============== ! */ ! public static void SV_InitGameProgs() { ! // unload anything we have now ! SV_ShutdownGameProgs(); ! ! game_import_t gimport = new game_import_t(); ! ! // all functions set in game_export_t (rst) ! GameBase.GetGameApi(gimport); ! ! GameSave.InitGame(); ! } ! } \ No newline at end of file |
From: Rene S. <sa...@us...> - 2004-09-22 19:22:55
|
Update of /cvsroot/jake2/jake2/src/jake2/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11556/src/jake2/util Modified Files: QuakeFile.java Lib.java Math3D.java Log Message: major refactoring in game, server and client package Index: Lib.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/util/Lib.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Lib.java 23 Jul 2004 10:09:55 -0000 1.5 --- Lib.java 22 Sep 2004 19:22:13 -0000 1.6 *************** *** 49,57 **** return (int) v[0] + " " + (int) v[1] + " " + (int) v[2]; } - public static String vtofs(float[] v) { return v[0] + " " + v[1] + " " + v[2]; } - public static String vtofsbeaty(float[] v) { return Com.sprintf("%8.2f %8.2f %8.2f", new Vargs().add(v[0]).add(v[1]).add(v[2])); --- 49,55 ---- *************** *** 71,86 **** return (Globals.rnd.nextFloat() - 0.5f) * 2.0f; } - public static int strcmp(String in1, String in2) { return in1.compareTo(in2); } - public static boolean strstr(String i1, String i2) { return (i1.indexOf(i2) != -1); } - public static float atof(String in) { float res = 0; ! try { res = Float.parseFloat(in); --- 69,81 ---- return (Globals.rnd.nextFloat() - 0.5f) * 2.0f; } public static int strcmp(String in1, String in2) { return in1.compareTo(in2); } public static boolean strstr(String i1, String i2) { return (i1.indexOf(i2) != -1); } public static float atof(String in) { float res = 0; ! try { res = Float.parseFloat(in); *************** *** 88,101 **** catch (Exception e) { } ! return res; } - public static int Q_stricmp(String in1, String in2) { return in1.compareToIgnoreCase(in2); } - // ================================================================================= ! public static int atoi(String in) { try { --- 83,94 ---- catch (Exception e) { } ! return res; } public static int Q_stricmp(String in1, String in2) { return in1.compareToIgnoreCase(in2); } // ================================================================================= ! public static int atoi(String in) { try { *************** *** 106,123 **** } } - public static float[] atov(String v) { float[] res = { 0, 0, 0 }; ! int i1 = v.indexOf(" "); int i2 = v.indexOf(" ", i1 + 1); ! res[0] = atof(v.substring(0, i1)); res[1] = atof(v.substring(i1 + 1, i2)); res[2] = atof(v.substring(i2 + 1, v.length())); ! return res; } - public static int strlen(char in[]) { for (int i = 0; i < in.length; i++) --- 99,114 ---- } } public static float[] atov(String v) { float[] res = { 0, 0, 0 }; ! int i1 = v.indexOf(" "); int i2 = v.indexOf(" ", i1 + 1); ! res[0] = atof(v.substring(0, i1)); res[1] = atof(v.substring(i1 + 1, i2)); res[2] = atof(v.substring(i2 + 1, v.length())); ! return res; } public static int strlen(char in[]) { for (int i = 0; i < in.length; i++) *************** *** 126,130 **** return in.length; } - public static int strlen(byte in[]) { for (int i = 0; i < in.length; i++) --- 117,120 ---- *************** *** 133,137 **** return in.length; } - static byte[] buffer = new byte[Defines.MAX_INFO_STRING]; public static String readString(ByteBuffer bb, int len) { --- 123,126 ---- *************** *** 139,154 **** return new String(buffer, 0, len); } - public static String hexdumpfile(ByteBuffer bb, int len) throws IOException { ! ByteBuffer bb1 = bb.slice(); ! byte buf[] = new byte[len]; ! bb1.get(buf); ! return hexDump(buf, len, false); } - // dump data as hexstring public static String hexDump(byte data1[], int len, boolean showAddress) { --- 128,141 ---- return new String(buffer, 0, len); } public static String hexdumpfile(ByteBuffer bb, int len) throws IOException { ! ByteBuffer bb1 = bb.slice(); ! byte buf[] = new byte[len]; ! bb1.get(buf); ! return hexDump(buf, len, false); } // dump data as hexstring public static String hexDump(byte data1[], int len, boolean showAddress) { *************** *** 165,175 **** } int v = data1[i]; ! result.append(hex2(v)); result.append(" "); ! charfield.append(readableChar(v)); i++; ! // nach dem letzten, newline einfuegen if ((i & 0xf) == 0) { --- 152,162 ---- } int v = data1[i]; ! result.append(hex2(v)); result.append(" "); ! charfield.append(readableChar(v)); i++; ! // nach dem letzten, newline einfuegen if ((i & 0xf) == 0) { *************** *** 185,189 **** return result.toString(); } - //formats an hex byte public static String hex2(int i) { --- 172,175 ---- *************** *** 191,195 **** return ("00".substring(0, 2 - val.length()) + val).toUpperCase(); } - public static char readableChar(int i) { if ((i < 0x20) || (i > 0x7f)) --- 177,180 ---- *************** *** 198,202 **** return (char) i; } - public static void printv(String in, float arr[]) { for (int n = 0; n < arr.length; n++) { --- 183,186 ---- *************** *** 204,210 **** } } - static final byte nullfiller[] = new byte[8192]; - public static void fwriteString(String s, int len, RandomAccessFile f) throws IOException { if (s == null) --- 188,192 ---- *************** *** 213,217 **** if (diff > 0) { f.write(s.getBytes()); ! f.write(nullfiller, 0, diff); } --- 195,199 ---- if (diff > 0) { f.write(s.getBytes()); ! f.write(nullfiller, 0, diff); } *************** *** 219,223 **** f.write(s.getBytes(), 0, len); } - public static RandomAccessFile fopen(String name, String mode) { try { --- 201,204 ---- *************** *** 229,233 **** } } - public static void fclose(RandomAccessFile f) { try { --- 210,213 ---- *************** *** 237,248 **** } } - public static String freadString(RandomAccessFile f, int len) { byte buffer[] = new byte[len]; FS.Read(buffer, len, f); ! return new String(buffer).trim(); } - public static String rightFrom(String in, char c) { int pos = in.lastIndexOf(c); --- 217,226 ---- } } public static String freadString(RandomAccessFile f, int len) { byte buffer[] = new byte[len]; FS.Read(buffer, len, f); ! return new String(buffer).trim(); } public static String rightFrom(String in, char c) { int pos = in.lastIndexOf(c); *************** *** 253,257 **** return ""; } - public static String leftFrom(String in, char c) { int pos = in.lastIndexOf(c); --- 231,234 ---- *************** *** 262,284 **** return ""; } - public static String[] linesplit(String in) { ! StringTokenizer tk = new StringTokenizer(in, "\r\n"); ! int count = tk.countTokens(); if (count == 0) return new String[] { }; ! String result[] = new String[count]; ! for (int i = 0; tk.hasMoreTokens(); i++) { result[i] = tk.nextToken(); } ! return result; } - public static int rename(String oldn, String newn) { try { --- 239,259 ---- return ""; } public static String[] linesplit(String in) { ! StringTokenizer tk = new StringTokenizer(in, "\r\n"); ! int count = tk.countTokens(); if (count == 0) return new String[] { }; ! String result[] = new String[count]; ! for (int i = 0; tk.hasMoreTokens(); i++) { result[i] = tk.nextToken(); } ! return result; } public static int rename(String oldn, String newn) { try { *************** *** 292,296 **** } } - public static byte[] getIntBytes(int c) { byte b[] = new byte[4]; --- 267,270 ---- *************** *** 301,318 **** return b; } - public static int getInt(byte b[]) { return (b[0] & 0xff) | ((b[1] & 0xff) << 8) | ((b[2] & 0xff) << 16) | ((b[3] & 0xff) << 24); } - public static float[] clone(float in[]) { float out[] = new float[in.length]; ! if (in.length != 0) System.arraycopy(in, 0, out, 0, in.length); ! return out; } ! /* * java.nio.* Buffer util functions --- 275,290 ---- return b; } public static int getInt(byte b[]) { return (b[0] & 0xff) | ((b[1] & 0xff) << 8) | ((b[2] & 0xff) << 16) | ((b[3] & 0xff) << 24); } public static float[] clone(float in[]) { float out[] = new float[in.length]; ! if (in.length != 0) System.arraycopy(in, 0, out, 0, in.length); ! return out; } ! /* * java.nio.* Buffer util functions *************** *** 321,345 **** public static final int SIZEOF_FLOAT = BufferUtils.SIZEOF_FLOAT; public static final int SIZEOF_INT = BufferUtils.SIZEOF_INT; - public static FloatBuffer newFloatBuffer(int numElements) { ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT); return bb.asFloatBuffer(); } - public static FloatBuffer newFloatBuffer(int numElements, ByteOrder order) { ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT, order); return bb.asFloatBuffer(); } - public static IntBuffer newIntBuffer(int numElements) { ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT); return bb.asIntBuffer(); } - public static IntBuffer newIntBuffer(int numElements, ByteOrder order) { ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT, order); return bb.asIntBuffer(); } - public static ByteBuffer newByteBuffer(int numElements) { ByteBuffer bb = ByteBuffer.allocateDirect(numElements); --- 293,312 ---- *************** *** 347,351 **** return bb; } - public static ByteBuffer newByteBuffer(int numElements, ByteOrder order) { ByteBuffer bb = ByteBuffer.allocateDirect(numElements); --- 314,317 ---- *************** *** 353,356 **** return bb; } - } --- 319,321 ---- Index: Math3D.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/util/Math3D.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Math3D.java 10 Sep 2004 19:02:56 -0000 1.6 --- Math3D.java 22 Sep 2004 19:22:13 -0000 1.7 *************** *** 28,36 **** import jake2.qcommon.Com; ! public class Math3D extends Lib { ! static final float shortratio = 360.0f / 65536.0f; ! static final float piratio = (float)(Math.PI / 360.0); ! public static void set(float v1[], float v2[]) { v1[0] = v2[0]; --- 28,35 ---- import jake2.qcommon.Com; ! public class Math3D { ! static final float shortratio = 360.0f / 65536.0f; ! static final float piratio = (float) (Math.PI / 360.0); public static void set(float v1[], float v2[]) { v1[0] = v2[0]; *************** *** 38,43 **** v1[2] = v2[2]; } - - public static void VectorSubtract(float[] a, float[] b, float[] c) { c[0] = a[0] - b[0]; --- 37,40 ---- *************** *** 45,49 **** c[2] = a[2] - b[2]; } - public static void VectorSubtract(short[] a, short[] b, int[] c) { c[0] = a[0] - b[0]; --- 42,45 ---- *************** *** 51,55 **** c[2] = a[2] - b[2]; } - public static void VectorAdd(float[] a, float[] b, float[] to) { to[0] = a[0] + b[0]; --- 47,50 ---- *************** *** 57,61 **** to[2] = a[2] + b[2]; } - public static void VectorCopy(float[] from, float[] to) { to[0] = from[0]; --- 52,55 ---- *************** *** 63,67 **** to[2] = from[2]; } - public static void VectorCopy(short[] from, short[] to) { to[0] = from[0]; --- 57,60 ---- *************** *** 69,73 **** to[2] = from[2]; } - public static void VectorCopy(short[] from, float[] to) { to[0] = from[0]; --- 62,65 ---- *************** *** 75,79 **** to[2] = from[2]; } - public static void VectorCopy(float[] from, short[] to) { to[0] = (short) from[0]; --- 67,70 ---- *************** *** 81,85 **** to[2] = (short) from[2]; } - public static void VectorClear(float[] a) { a[0] = a[1] = a[2] = 0; --- 72,75 ---- *************** *** 117,121 **** return length; } - public static final float VectorLength(float v[]) { return (float) Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); --- 107,110 ---- *************** *** 131,135 **** out[2] = in[2] * scale; } - public static float vectoyaw(float[] vec) { float yaw; --- 120,123 ---- *************** *** 152,156 **** return yaw; } - public static void vectoangles(float[] value1, float[] angles) { --- 140,143 ---- *************** *** 184,195 **** angles[Defines.ROLL] = 0; } - private static float m[][] = new float[3][3]; private static float im[][] = new float[3][3]; private static float tmpmat[][] = new float[3][3]; private static float zrot[][] = new float[3][3]; - public static void RotatePointAroundVector(float[] dst, float[] dir, float[] point, float degrees) { ! float[] vr = { 0.0f, 0.0f, 0.0f }; float[] vup = { 0.0f, 0.0f, 0.0f }; --- 171,180 ---- angles[Defines.ROLL] = 0; } private static float m[][] = new float[3][3]; private static float im[][] = new float[3][3]; private static float tmpmat[][] = new float[3][3]; private static float zrot[][] = new float[3][3]; public static void RotatePointAroundVector(float[] dst, float[] dir, float[] point, float degrees) { ! float[] vr = { 0.0f, 0.0f, 0.0f }; float[] vup = { 0.0f, 0.0f, 0.0f }; *************** *** 200,205 **** vf[2] = dir[2]; ! Math3D.PerpendicularVector(vr, dir); ! Math3D.CrossProduct(vr, vf, vup); m[0][0] = vr[0]; --- 185,190 ---- vf[2] = dir[2]; ! PerpendicularVector(vr, dir); ! CrossProduct(vr, vf, vup); m[0][0] = vr[0]; *************** *** 229,238 **** zrot[2][2] = 1.0F; ! zrot[0][0] = zrot[1][1] = (float) Math.cos(Math3D.DEG2RAD(degrees)); ! zrot[0][1] = (float) Math.sin(Math3D.DEG2RAD(degrees)); zrot[1][0] = -zrot[0][1]; ! Math3D.R_ConcatRotations(m, zrot, tmpmat); ! Math3D.R_ConcatRotations(tmpmat, im, zrot); for (int i = 0; i < 3; i++) { --- 214,223 ---- zrot[2][2] = 1.0F; ! zrot[0][0] = zrot[1][1] = (float) Math.cos(DEG2RAD(degrees)); ! zrot[0][1] = (float) Math.sin(DEG2RAD(degrees)); zrot[1][0] = -zrot[0][1]; ! R_ConcatRotations(m, zrot, tmpmat); ! R_ConcatRotations(tmpmat, im, zrot); for (int i = 0; i < 3; i++) { *************** *** 240,245 **** } } - - public static void MakeNormalVectors(float[] forward, float[] right, float[] up) { // this rotate and negat guarantees a vector --- 225,228 ---- *************** *** 254,263 **** CrossProduct(right, forward, up); } - - public static float SHORT2ANGLE(int x) { return (x * shortratio); } - /* ================ --- 237,243 ---- *************** *** 279,283 **** out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] + in1[2][2] * in2[2][3] + in1[2][3]; } - /** * concatenates 2 matrices each [3][3]. --- 259,262 ---- *************** *** 294,303 **** out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + in1[2][2] * in2[2][2]; } - public static void ProjectPointOnPlane(float[] dst, float[] p, float[] normal) { ! float inv_denom = 1.0F / Math3D.DotProduct(normal, normal); ! float d = Math3D.DotProduct(normal, p) * inv_denom; dst[0] = normal[0] * inv_denom; --- 273,281 ---- out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + in1[2][2] * in2[2][2]; } public static void ProjectPointOnPlane(float[] dst, float[] p, float[] normal) { ! float inv_denom = 1.0F / DotProduct(normal, normal); ! float d = DotProduct(normal, p) * inv_denom; dst[0] = normal[0] * inv_denom; *************** *** 309,313 **** dst[2] = p[2] - d * dst[2]; } - /** assumes "src" is normalized */ public static void PerpendicularVector(float[] dst, float[] src) { --- 287,290 ---- *************** *** 316,320 **** float minelem = 1.0F; - // find the smallest magnitude axially aligned vector for (pos = 0, i = 0; i < 3; i++) { --- 293,296 ---- *************** *** 331,337 **** //normalize the result ! Math3D.VectorNormalize(dst); } - //===================================================================== /** --- 307,312 ---- //normalize the result ! VectorNormalize(dst); } //===================================================================== /** *************** *** 340,346 **** erste Version mit vec3_t... */ public static final int BoxOnPlaneSide(float emins[], float emaxs[], cplane_t p) { ! ! assert (emins.length == 3 && emaxs.length == 3) : "vec3_t bug"; ! float dist1, dist2; int sides; --- 315,321 ---- erste Version mit vec3_t... */ public static final int BoxOnPlaneSide(float emins[], float emaxs[], cplane_t p) { ! ! assert(emins.length == 3 && emaxs.length == 3) : "vec3_t bug"; ! float dist1, dist2; int sides; *************** *** 391,395 **** default : dist1 = dist2 = 0; ! assert (false) : "BoxOnPlaneSide bug"; break; } --- 366,370 ---- default : dist1 = dist2 = 0; ! assert(false) : "BoxOnPlaneSide bug"; break; } *************** *** 401,413 **** sides |= 2; ! assert (sides != 0) : "BoxOnPlaneSide(): sides == 0 bug"; return sides; ! } ! // this is the slow, general version private static float corners[][] = new float[2][3]; public static final int BoxOnPlaneSide2(float[] emins, float[] emaxs, cplane_t p) { - for (int i = 0; i < 3; i++) { --- 376,386 ---- sides |= 2; ! assert(sides != 0) : "BoxOnPlaneSide(): sides == 0 bug"; return sides; ! } // this is the slow, general version private static float corners[][] = new float[2][3]; public static final int BoxOnPlaneSide2(float[] emins, float[] emaxs, cplane_t p) { for (int i = 0; i < 3; i++) { *************** *** 421,426 **** } } ! float dist1 = Math3D.DotProduct(p.normal, corners[0]) - p.dist; ! float dist2 = Math3D.DotProduct(p.normal, corners[1]) - p.dist; int sides = 0; if (dist1 >= 0) --- 394,399 ---- } } ! float dist1 = DotProduct(p.normal, corners[0]) - p.dist; ! float dist2 = DotProduct(p.normal, corners[1]) - p.dist; int sides = 0; if (dist1 >= 0) *************** *** 431,435 **** return sides; } - public static void AngleVectors(float[] angles, float[] forward, float[] right, float[] up) { --- 404,407 ---- *************** *** 465,483 **** } } ! ! public static void G_ProjectSource(float[] point, float[] distance, float[] forward, float[] right, float[] result) { result[0] = point[0] + forward[0] * distance[0] + right[0] * distance[1]; result[1] = point[1] + forward[1] * distance[0] + right[1] * distance[1]; result[2] = point[2] + forward[2] * distance[0] + right[2] * distance[1] + distance[2]; } - - - public static final float DotProduct(float[] x, float[] y) { return x[0] * y[0] + x[1] * y[1] + x[2] * y[2]; } - - - public static void CrossProduct(float[] v1, float[] v2, float[] cross) { cross[0] = v1[1] * v2[2] - v1[2] * v2[1]; --- 437,453 ---- } } ! public static void G_ProjectSource( ! float[] point, ! float[] distance, ! float[] forward, ! float[] right, ! float[] result) { result[0] = point[0] + forward[0] * distance[0] + right[0] * distance[1]; result[1] = point[1] + forward[1] * distance[0] + right[1] * distance[1]; result[2] = point[2] + forward[2] * distance[0] + right[2] * distance[1] + distance[2]; } public static final float DotProduct(float[] x, float[] y) { return x[0] * y[0] + x[1] * y[1] + x[2] * y[2]; } public static void CrossProduct(float[] v1, float[] v2, float[] cross) { cross[0] = v1[1] * v2[2] - v1[2] * v2[1]; *************** *** 485,491 **** cross[2] = v1[0] * v2[1] - v1[1] * v2[0]; } - - - public static int Q_log2(int val) { int answer = 0; --- 455,458 ---- *************** *** 494,518 **** return answer; } - - - public static float DEG2RAD(float in) { return (in * (float) Math.PI) / 180.0f; } - - - public static float anglemod(float a) { return (float) (shortratio) * ((int) (a / (shortratio)) & 65535); } - - - public static int ANGLE2SHORT(float x) { return ((int) ((x) / shortratio) & 65535); } - - - public static float LerpAngle(float a2, float a1, float frac) { if (a1 - a2 > 180) --- 461,473 ---- *************** *** 522,527 **** return a2 + frac * (a1 - a2); } - - public static float CalcFov(float fov_x, float width, float height) { double a = 0.0f; --- 477,480 ---- *************** *** 537,541 **** a = a / piratio; ! return (float)a; } } --- 490,494 ---- a = a / piratio; ! return (float) a; } } Index: QuakeFile.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/util/QuakeFile.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** QuakeFile.java 10 Sep 2004 19:02:56 -0000 1.3 --- QuakeFile.java 22 Sep 2004 19:22:13 -0000 1.4 *************** *** 1,28 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ // Created on 24.07.2004 by RST. // $Id$ - package jake2.util; ! import jake2.game.Game; import jake2.game.SuperAdapter; import jake2.game.edict_t; --- 1,28 ---- /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ // Created on 24.07.2004 by RST. // $Id$ package jake2.util; ! import jake2.game.GameAI; ! import jake2.game.GameBase; import jake2.game.SuperAdapter; import jake2.game.edict_t; *************** *** 30,182 **** import jake2.qcommon.Com; ! import java.io.*; ! /** ! * RandomAccessFile, but handles readString/WriteString specially and ! * offers other helper functions */ ! public class QuakeFile extends RandomAccessFile ! { ! /** Standard Constructor.*/ ! public QuakeFile(String filename, String mode) throws FileNotFoundException ! { ! super(filename, mode); ! } ! /** Writes a Vector to a RandomAccessFile. */ ! public void writeVector(float v[]) throws IOException ! { ! for (int n= 0; n < 3; n++) ! writeFloat(v[n]); ! } ! /** Writes a Vector to a RandomAccessFile. */ ! public float[] readVector() throws IOException ! { ! float res[]= { 0, 0, 0 }; ! for (int n= 0; n < 3; n++) ! res[n]= readFloat(); ! return res; ! } ! /** Reads a length specified string from a file. */ ! public String readString() throws IOException ! { ! int len= readInt(); ! if (len == -1) ! return null; ! if (len == 0) ! return ""; ! byte bb[]= new byte[len]; ! super.read(bb, 0, len); ! return new String(bb, 0, len); ! } ! /** Writes a length specified string to a file. */ ! public void writeString(String s) throws IOException ! { ! if (s == null) ! { ! writeInt(-1); ! return; ! } ! writeInt(s.length()); ! if (s.length() != 0) ! writeBytes(s); ! } ! /** Writes the edict reference. */ ! public void writeEdictRef(edict_t ent) throws IOException ! { ! if (ent == null) ! writeInt(-1); ! else ! { ! writeInt(ent.s.number); ! } ! } ! /** ! * Reads an edict index from a file and returns the edict. ! */ ! public edict_t readEdictRef() throws IOException ! { ! int i= readInt(); ! // handle -1 ! if (i < 0) ! return null; ! if (i > Game.g_edicts.length) ! { ! Com.DPrintf("jake2: illegal edict num:" + i + "\n"); ! return null; ! } ! // valid edict. ! return Game.g_edicts[i]; ! } ! /** Writes the Adapter-ID to the file. */ ! public void writeAdapter(SuperAdapter a) throws IOException ! { ! writeInt(3988); ! if (a == null) ! writeString(null); ! else ! { ! String str= a.getID(); ! if (a == null) ! { ! Com.DPrintf("writeAdapter: invalid Adapter id for " + a + "\n"); ! } ! writeString(str); ! } ! } ! /** Reads the adapter id and returns the adapter. */ ! public SuperAdapter readAdapter() throws IOException ! { ! if (readInt() != 3988) ! Com.DPrintf("wrong read position: readadapter 3988 \n"); ! String id= readString(); ! if (id == null) ! { ! // null adapter. :-) ! return null; ! } ! return SuperAdapter.getFromID(id); ! } ! /** Writes an item reference. */ ! public void writeItem(gitem_t item) throws IOException ! { ! if (item == null) ! writeInt(-1); ! else ! writeInt(item.index); ! } ! /** Reads the item index and returns the game item. */ ! public gitem_t readItem() throws IOException ! { ! int ndx= readInt(); ! if (ndx == -1) ! return null; ! else ! return Game.itemlist[ndx]; ! } ! } --- 30,166 ---- import jake2.qcommon.Com; ! import java.io.FileNotFoundException; ! import java.io.IOException; ! import java.io.RandomAccessFile; ! /** ! * RandomAccessFile, but handles readString/WriteString specially and offers ! * other helper functions */ ! public class QuakeFile extends RandomAccessFile { ! /** Standard Constructor. */ ! public QuakeFile(String filename, String mode) throws FileNotFoundException { ! super(filename, mode); ! } ! /** Writes a Vector to a RandomAccessFile. */ ! public void writeVector(float v[]) throws IOException { ! for (int n = 0; n < 3; n++) ! writeFloat(v[n]); ! } ! /** Writes a Vector to a RandomAccessFile. */ ! public float[] readVector() throws IOException { ! float res[] = { 0, 0, 0 }; ! for (int n = 0; n < 3; n++) ! res[n] = readFloat(); ! return res; ! } ! /** Reads a length specified string from a file. */ ! public String readString() throws IOException { ! int len = readInt(); ! if (len == -1) ! return null; ! if (len == 0) ! return ""; ! byte bb[] = new byte[len]; ! super.read(bb, 0, len); ! return new String(bb, 0, len); ! } ! /** Writes a length specified string to a file. */ ! public void writeString(String s) throws IOException { ! if (s == null) { ! writeInt(-1); ! return; ! } ! writeInt(s.length()); ! if (s.length() != 0) ! writeBytes(s); ! } ! /** Writes the edict reference. */ ! public void writeEdictRef(edict_t ent) throws IOException { ! if (ent == null) ! writeInt(-1); ! else { ! writeInt(ent.s.number); ! } ! } ! /** ! * Reads an edict index from a file and returns the edict. ! */ ! public edict_t readEdictRef() throws IOException { ! int i = readInt(); ! // handle -1 ! if (i < 0) ! return null; ! if (i > GameBase.g_edicts.length) { ! Com.DPrintf("jake2: illegal edict num:" + i + "\n"); ! return null; ! } ! // valid edict. ! return GameBase.g_edicts[i]; ! } ! /** Writes the Adapter-ID to the file. */ ! public void writeAdapter(SuperAdapter a) throws IOException { ! writeInt(3988); ! if (a == null) ! writeString(null); ! else { ! String str = a.getID(); ! if (a == null) { ! Com.DPrintf("writeAdapter: invalid Adapter id for " + a + "\n"); ! } ! writeString(str); ! } ! } ! /** Reads the adapter id and returns the adapter. */ ! public SuperAdapter readAdapter() throws IOException { ! if (readInt() != 3988) ! Com.DPrintf("wrong read position: readadapter 3988 \n"); ! String id = readString(); ! if (id == null) { ! // null adapter. :-) ! return null; ! } ! return SuperAdapter.getFromID(id); ! } ! /** Writes an item reference. */ ! public void writeItem(gitem_t item) throws IOException { ! if (item == null) ! writeInt(-1); ! else ! writeInt(item.index); ! } ! /** Reads the item index and returns the game item. */ ! public gitem_t readItem() throws IOException { ! int ndx = readInt(); ! if (ndx == -1) ! return null; ! else ! return GameAI.itemlist[ndx]; ! } ! } \ No newline at end of file |
From: Rene S. <sa...@us...> - 2004-09-22 19:22:54
|
Update of /cvsroot/jake2/jake2/src/jake2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11556/src/jake2 Modified Files: Jake2.java Defines.java Log Message: major refactoring in game, server and client package Index: Jake2.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/Jake2.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Jake2.java 19 Sep 2004 19:53:51 -0000 1.4 --- Jake2.java 22 Sep 2004 19:22:14 -0000 1.5 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2; --- 6,27 ---- */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2; *************** *** 37,80 **** public final class Jake2 { ! public static Q2DataDialog Q2Dialog = new Q2DataDialog(); ! ! /** ! * main is used to start the game. Quake2 for Java supports the ! * following command line arguments: ! * @param args ! */ ! public static void main(String[] args) { ! Q2Dialog.setVisible(true); ! ! // in C the first arg is the filename ! int argc = (args == null) ? 1 : args.length + 1; ! String[] c_args = new String[argc]; ! c_args[0] = "Jake2"; ! if (argc > 1) { ! System.arraycopy(args, 0, c_args, 1, argc - 1); ! } ! Qcommon.Init(c_args); ! Globals.nostdout = Cvar.Get("nostdout", "0", 0); ! int oldtime = Sys.Milliseconds(); ! int newtime; ! int time; ! while (true) { ! // find time spending rendering last frame ! newtime = Sys.Milliseconds(); ! time = newtime - oldtime; ! ! // TODO this is a timer hack for Win2000 ! // System.currentTimeMillis() resolution bug ! if (time == 0 && (Globals.cl_timedemo.value != 0 || SCR.fps.value != 0)) { ! time++; ! } ! ! if (time > 0) ! Qcommon.Frame(time); ! oldtime = newtime; ! } ! } ! } --- 37,99 ---- public final class Jake2 { ! static class MemMonitor implements Runnable { ! public void run() { ! while (true) { ! Com.Printf("Memory:" ! + (Runtime.getRuntime().totalMemory() - Runtime ! .getRuntime().freeMemory()) + "\n"); ! try { ! Thread.sleep(1000); ! } catch (Exception e) { ! } ! } ! } ! } ! public static Q2DataDialog Q2Dialog = new Q2DataDialog(); ! /** ! * main is used to start the game. Quake2 for Java supports the following ! * command line arguments: ! * ! * @param args ! */ ! public static void main(String[] args) { ! Q2Dialog.setVisible(true); ! ! // uncomment to have a memory debugger (RST). ! //new Thread(new MemMonitor()).start(); ! ! // in C the first arg is the filename ! int argc = (args == null) ? 1 : args.length + 1; ! String[] c_args = new String[argc]; ! c_args[0] = "Jake2"; ! if (argc > 1) { ! System.arraycopy(args, 0, c_args, 1, argc - 1); ! } ! Qcommon.Init(c_args); ! ! Globals.nostdout = Cvar.Get("nostdout", "0", 0); ! ! int oldtime = Sys.Milliseconds(); ! int newtime; ! int time; ! while (true) { ! // find time spending rendering last frame ! newtime = Sys.Milliseconds(); ! time = newtime - oldtime; ! ! // TODO this is a timer hack for Win2000 ! // System.currentTimeMillis() resolution bug ! if (time == 0 ! && (Globals.cl_timedemo.value != 0 || SCR.fps.value != 0)) { ! time++; ! } ! ! if (time > 0) ! Qcommon.Frame(time); ! oldtime = newtime; ! } ! } ! } \ No newline at end of file Index: Defines.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/Defines.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Defines.java 10 Sep 2004 19:02:57 -0000 1.4 --- Defines.java 22 Sep 2004 19:22:14 -0000 1.5 *************** *** 26,46 **** package jake2; import jake2.util.*; ! public class Defines extends Math3D { ! ! // used by filefinders in Sys ! public final static int FILEISREADABLE = 1; ! public final static int FILEISWRITABLE = 2; ! public final static int FILEISFILE = 4; ! public final static int FILEISDIRECTORY = 8; ! ! // datentyp konstanten ! // groesse in bytes ! public final static int SIZE_OF_SHORT = 2; ! public final static int SIZE_OF_INT = 4; ! public final static int SIZE_OF_LONG = 8; ! public final static int SIZE_OF_FLOAT = 4; ! public final static int SIZE_OF_DOUBLE = 8; public final static int WEAPON_READY = 0; --- 26,33 ---- package jake2; + import jake2.game.pmove_t; import jake2.util.*; ! public class Defines { public final static int WEAPON_READY = 0; *************** *** 170,182 **** public final static int SURF_NODRAW = 0x80; // don't bother referencing the texture - // pmove->pm_flags - public final static int PMF_DUCKED = 1; - public final static int PMF_JUMP_HELD = 2; - public final static int PMF_ON_GROUND = 4; - public final static int PMF_TIME_WATERJUMP = 8; // pm_time is waterjump - public final static int PMF_TIME_LAND = 16; // pm_time is time before rejump - public final static int PMF_TIME_TELEPORT = 32; // pm_time is non-moving time - public final static int PMF_NO_PREDICTION = 64; // temporarily disables prediction (used for grappling hook) - // // button bits --- 157,160 ---- *************** *** 1356,1358 **** public final static String NO_SERVER_STRING = "<no server>"; public final static int NUM_ADDRESSBOOK_ENTRIES = 9; ! } --- 1334,1375 ---- public final static String NO_SERVER_STRING = "<no server>"; public final static int NUM_ADDRESSBOOK_ENTRIES = 9; ! ! public final static int STEPSIZE = 18; ! ! ! public static final float MOVE_STOP_EPSILON = 0.1f; ! ! /* ! ================== ! PM_StepSlideMove ! ! Each intersection will try to step over the obstruction instead of ! sliding along it. ! ! Returns a new origin, velocity, and contact entity ! Does not modify any world state? ! ================== ! */ ! public final static float MIN_STEP_NORMAL = 0.7f; // can't step up onto very steep slopes ! ! ! // used by filefinders in Sys ! public final static int FILEISREADABLE = 1; ! ! public final static int FILEISWRITABLE = 2; ! ! public final static int FILEISFILE = 4; ! ! public final static int FILEISDIRECTORY = 8; ! ! // datentyp konstanten ! // groesse in bytes ! public final static int SIZE_OF_SHORT = 2; ! ! public final static int SIZE_OF_INT = 4; ! ! public final static int SIZE_OF_LONG = 8; ! ! public final static int SIZE_OF_FLOAT = 4; ! ! public final static int SIZE_OF_DOUBLE = 8;} |
Update of /cvsroot/jake2/jake2/src/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11556/src/jake2/qcommon Modified Files: Cvar.java PMove.java Netchan.java Cbuf.java CM.java MSG.java netchan_t.java Q2DataDialog.java Log Message: major refactoring in game, server and client package Index: Q2DataDialog.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Q2DataDialog.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Q2DataDialog.java 21 Sep 2004 12:52:14 -0000 1.6 --- Q2DataDialog.java 22 Sep 2004 19:22:09 -0000 1.7 *************** *** 1,427 **** ! /* ! * Q2DataDialog.java ! * ! * Created on 17. September 2004, 20:13 ! */ ! ! package jake2.qcommon; ! ! import java.awt.*; ! import java.io.*; ! import java.net.URL; ! import java.net.URLConnection; ! import java.util.Enumeration; ! import java.util.zip.ZipEntry; ! import java.util.zip.ZipFile; ! ! import javax.swing.*; ! ! /** ! * ! * @author hoz ! */ ! public class Q2DataDialog extends javax.swing.JDialog { ! ! /** Creates new form Q2DataDialog */ ! public Q2DataDialog() { ! super(); ! initComponents(); ! ! DisplayMode mode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode(); ! int x = (mode.getWidth() - getWidth()) / 2; ! int y = (mode.getHeight() - getHeight()) / 2; ! setLocation(x, y); ! dir = System.getProperty("user.home") + "/jake2"; ! jTextField1.setText(dir); ! } ! ! /** This method is called from within the constructor to ! * initialize the form. ! * WARNING: Do NOT modify this code. The content of this method is ! * always regenerated by the Form Editor. ! */ ! private void initComponents() {//GEN-BEGIN:initComponents ! java.awt.GridBagConstraints gridBagConstraints; ! ! choosePanel = new javax.swing.JPanel(); ! statusPanel = new JPanel(); ! status = new JLabel("initializing Jake2..."); ! jTextField1 = new javax.swing.JTextField(); ! changeButton = new javax.swing.JButton(); ! installButton = new javax.swing.JButton(); ! exitButton = new javax.swing.JButton(); ! okButton = new javax.swing.JButton(); ! ! setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); ! setTitle("Jake2 - Bytonic Software"); ! ! setResizable(false); ! addWindowListener(new java.awt.event.WindowAdapter() { ! public void windowClosing(java.awt.event.WindowEvent evt) { ! formWindowClosing(evt); ! } ! }); ! ! choosePanel.setLayout(new java.awt.GridBagLayout()); ! ! choosePanel.setMaximumSize(new java.awt.Dimension(400, 100)); ! choosePanel.setMinimumSize(new java.awt.Dimension(400, 100)); ! choosePanel.setPreferredSize(new java.awt.Dimension(400, 100)); ! jTextField1.setPreferredSize(null); ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 0; ! gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 2; ! gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.weightx = 1.0; ! choosePanel.add(jTextField1, gridBagConstraints); ! ! changeButton.setText("change"); ! changeButton.addActionListener(new java.awt.event.ActionListener() { ! public void actionPerformed(java.awt.event.ActionEvent evt) { ! changeButtonActionPerformed(evt); ! } ! }); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 2; ! gridBagConstraints.gridy = 0; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; ! choosePanel.add(changeButton, gridBagConstraints); ! ! installButton.setText("Install"); ! installButton.addActionListener(new java.awt.event.ActionListener() { ! public void actionPerformed(java.awt.event.ActionEvent evt) { ! installButtonActionPerformed(evt); ! } ! }); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 0; ! gridBagConstraints.gridy = 1; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; ! choosePanel.add(installButton, gridBagConstraints); ! ! exitButton.setText("Exit"); ! exitButton.addActionListener(new java.awt.event.ActionListener() { ! public void actionPerformed(java.awt.event.ActionEvent evt) { ! exitButtonActionPerformed(evt); ! } ! }); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 1; ! gridBagConstraints.gridy = 1; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! choosePanel.add(exitButton, gridBagConstraints); ! ! okButton.setText("OK"); ! okButton.addActionListener(new java.awt.event.ActionListener() { ! public void actionPerformed(java.awt.event.ActionEvent evt) { ! okButtonActionPerformed(evt); ! } ! }); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 2; ! gridBagConstraints.gridy = 1; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; ! choosePanel.add(okButton, gridBagConstraints); ! ! //getContentPane().add(choosePanel, java.awt.BorderLayout.SOUTH); ! ! Jake2Canvas c = new Jake2Canvas(); ! getContentPane().add(c, BorderLayout.CENTER); ! ! statusPanel.setLayout(new java.awt.GridBagLayout()); ! statusPanel.setMaximumSize(new java.awt.Dimension(400, 100)); ! statusPanel.setMinimumSize(new java.awt.Dimension(400, 100)); ! statusPanel.setPreferredSize(new java.awt.Dimension(400, 100)); ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 0; ! gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 1; ! gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.weightx = 1.0; ! statusPanel.add(status, gridBagConstraints); ! getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH); ! ! installPanel = new InstallPanel(this); ! ! pack(); ! }//GEN-END:initComponents ! ! ! private void installButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_installButtonActionPerformed ! dir = jTextField1.getText(); ! showInstallPanel(); ! installPanel.destDir = dir; ! ! dir += "/baseq2"; ! jTextField1.setText(dir); ! ! new Thread(installPanel).start(); ! }//GEN-LAST:event_installButtonActionPerformed ! ! private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed ! System.exit(1); ! dispose(); ! }//GEN-LAST:event_exitButtonActionPerformed ! ! private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed ! ! dir = jTextField1.getText(); ! Cvar.Set("cddir", dir); ! FS.setCDDir(); ! ! synchronized(this) { ! notifyAll(); ! } ! }//GEN-LAST:event_okButtonActionPerformed ! ! private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeButtonActionPerformed ! JFileChooser chooser = new JFileChooser(); ! chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); ! chooser.setDialogType(JFileChooser.CUSTOM_DIALOG); ! chooser.setMultiSelectionEnabled(false); ! chooser.setDialogTitle("choose a valid baseq2 directory"); ! chooser.showDialog(this, "OK"); ! ! dir = null; ! try { ! dir = chooser.getSelectedFile().getCanonicalPath(); ! } catch (IOException e) {} ! jTextField1.setText(dir); ! ! }//GEN-LAST:event_changeButtonActionPerformed ! ! private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing ! System.exit(1); ! dispose(); ! }//GEN-LAST:event_formWindowClosing ! ! // Variables declaration - do not modify//GEN-BEGIN:variables ! private javax.swing.JButton changeButton; ! private javax.swing.JButton exitButton; ! private javax.swing.JButton installButton; ! private Jake2Canvas canvas; ! private javax.swing.JPanel choosePanel; ! private JPanel statusPanel; ! private InstallPanel installPanel; ! private JLabel status; ! private javax.swing.JTextField jTextField1; ! private javax.swing.JButton okButton; ! // End of variables declaration//GEN-END:variables ! ! private String dir; ! ! void showChooseDialog() { ! getContentPane().remove(statusPanel); ! getContentPane().remove(installPanel); ! getContentPane().add(choosePanel, BorderLayout.SOUTH); ! validate(); ! repaint(); ! } ! ! void showStatus() { ! getContentPane().remove(choosePanel); ! getContentPane().add(statusPanel, BorderLayout.SOUTH); ! validate(); ! repaint(); ! } ! ! void showInstallPanel() { ! getContentPane().remove(choosePanel); ! getContentPane().add(installPanel, BorderLayout.SOUTH); ! validate(); ! repaint(); ! } ! ! void setStatus(String text) { ! status.setText(text); ! } ! ! void testQ2Data() { ! while (FS.LoadFile("pics/colormap.pcx") == null) { ! showChooseDialog(); ! ! try { ! synchronized(this) { ! wait(); ! } ! } catch (InterruptedException e) {} ! } ! showStatus(); ! repaint(); ! } ! ! static class Jake2Canvas extends Canvas { ! private Image image; ! Jake2Canvas() { ! setSize(400, 200); ! image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/splash.png")); ! while (!Toolkit.getDefaultToolkit().prepareImage(image, -1, -1, null)) { ! try { ! Thread.sleep(50); ! } catch (InterruptedException e) {} ! } ! } ! ! ! /* (non-Javadoc) ! * @see java.awt.Component#paint(java.awt.Graphics) ! */ ! public void paint(Graphics g) { ! g.drawImage(image, 0, 0, null); ! } ! ! } ! ! static class InstallPanel extends JPanel implements Runnable { ! ! static final String[] locs = { ! "ftp://ftp.fu-berlin.de/pc/msdos/games/idgames/idstuff/quake2/q2-314-demo-x86.exe", ! "ftp://ftp.demon.co.uk/pub/mirrors/idsoftware/quake2/q2-314-demo-x86.exe", ! "ftp://ftp.fragzone.se/pub/spel/quake2/q2-314-demo-x86.exe", ! "ftp://ftp.idsoftware.com/idstuff/quake2/q2-314-demo-x86.exe" }; ! static byte[] buf = new byte[8192]; ! String destDir; ! ! JProgressBar progress = new JProgressBar(); ! JLabel label = new JLabel("test"); ! Q2DataDialog parent; ! ! public InstallPanel(Q2DataDialog d) { ! initComponents(); ! parent = d; ! } ! ! void initComponents() { ! progress.setMinimum(0); ! progress.setMaximum(100); ! setLayout(new GridBagLayout()); ! GridBagConstraints gridBagConstraints = new GridBagConstraints(); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 0; ! gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 1; ! gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.weightx = 1.0; ! gridBagConstraints.anchor = GridBagConstraints.SOUTH; ! add(label, gridBagConstraints); ! gridBagConstraints.gridy = 1; ! gridBagConstraints.anchor = GridBagConstraints.NORTH; ! add(progress, gridBagConstraints); ! Dimension d = new Dimension(400, 100); ! setMinimumSize(d); ! setMaximumSize(d); ! setPreferredSize(d); ! } ! ! public void run() { ! ! InputStream in = null; ! OutputStream out = null; ! File outFile = null; ! ! label.setText("downloading..."); ! ! File dir = null; ! try { ! dir = new File(destDir); ! dir.mkdirs(); ! } ! catch (Exception e) {} ! try { ! if (!dir.isDirectory() || !dir.canWrite()) return; ! } ! catch (Exception e) { ! return; ! } ! ! for (int i = 0; i < locs.length; i++) { ! try { ! URL url = new URL(locs[i]); ! URLConnection conn = url.openConnection(); ! int length = conn.getContentLength(); ! progress.setMaximum(length / 1024); ! ! in = conn.getInputStream(); ! ! outFile = File.createTempFile("Jake2Data", ".zip"); ! outFile.deleteOnExit(); ! out = new FileOutputStream(outFile); ! ! copyStream(in, out); ! break; ! } catch (Exception e) {} ! } ! try { ! installData(outFile.getCanonicalPath()); ! } catch (Exception e) {} ! ! ! try { ! if (outFile != null) outFile.delete(); ! } catch (Exception e) {} ! ! parent.showChooseDialog(); ! parent.okButtonActionPerformed(null); ! } ! ! ! void installData(String filename) { ! try { ! ZipFile f = new ZipFile(filename); ! Enumeration e = f.entries(); ! while (e.hasMoreElements()) { ! ZipEntry entry = (ZipEntry)e.nextElement(); ! String name = entry.getName(); ! int i; ! if ((i = name.indexOf("/baseq2")) > -1 && name.indexOf(".dll") == -1) { ! name = destDir + name.substring(i); ! File outFile = new File(name); ! if (entry.isDirectory()) { ! outFile.mkdirs(); ! } else { ! label.setText("installing " + outFile.getName()); ! progress.setMaximum((int)entry.getSize()/1024); ! progress.setValue(0); ! outFile.getParentFile().mkdirs(); ! OutputStream out = new FileOutputStream(outFile); ! InputStream in = f.getInputStream(entry); ! copyStream(in, out); ! } ! } ! } ! } catch (Exception e) {} ! } ! ! void copyStream(InputStream in, OutputStream out) { ! try { ! int c = 0; ! int l; ! while ((l = in.read(buf)) > 0) { ! out.write(buf, 0, l); ! c += l; ! progress.setValue(c / 1024); ! } ! } catch (Exception e) {} ! ! try { ! in.close(); ! } catch (Exception e) {} ! try { ! out.close(); ! } catch (Exception e) {} ! } ! } ! ! } --- 1,427 ---- ! /* ! * Q2DataDialog.java ! * ! * Created on 17. September 2004, 20:13 ! */ ! ! package jake2.qcommon; ! ! import java.awt.*; ! import java.io.*; ! import java.net.URL; ! import java.net.URLConnection; ! import java.util.Enumeration; ! import java.util.zip.ZipEntry; ! import java.util.zip.ZipFile; ! ! import javax.swing.*; ! ! /** ! * ! * @author hoz ! */ ! public class Q2DataDialog extends javax.swing.JDialog { ! ! /** Creates new form Q2DataDialog */ ! public Q2DataDialog() { ! super(); ! initComponents(); ! ! DisplayMode mode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode(); ! int x = (mode.getWidth() - getWidth()) / 2; ! int y = (mode.getHeight() - getHeight()) / 2; ! setLocation(x, y); ! dir = System.getProperty("user.home") + "/jake2"; ! jTextField1.setText(dir); ! } ! ! /** This method is called from within the constructor to ! * initialize the form. ! * WARNING: Do NOT modify this code. The content of this method is ! * always regenerated by the Form Editor. ! */ ! private void initComponents() {//GEN-BEGIN:initComponents ! java.awt.GridBagConstraints gridBagConstraints; ! ! choosePanel = new javax.swing.JPanel(); ! statusPanel = new JPanel(); ! status = new JLabel("initializing Jake2..."); ! jTextField1 = new javax.swing.JTextField(); ! changeButton = new javax.swing.JButton(); ! installButton = new javax.swing.JButton(); ! exitButton = new javax.swing.JButton(); ! okButton = new javax.swing.JButton(); ! ! setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); ! setTitle("Jake2 - Bytonic Software"); ! ! setResizable(false); ! addWindowListener(new java.awt.event.WindowAdapter() { ! public void windowClosing(java.awt.event.WindowEvent evt) { ! formWindowClosing(evt); ! } ! }); ! ! choosePanel.setLayout(new java.awt.GridBagLayout()); ! ! choosePanel.setMaximumSize(new java.awt.Dimension(400, 100)); ! choosePanel.setMinimumSize(new java.awt.Dimension(400, 100)); ! choosePanel.setPreferredSize(new java.awt.Dimension(400, 100)); ! jTextField1.setPreferredSize(null); ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 0; ! gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 2; ! gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.weightx = 1.0; ! choosePanel.add(jTextField1, gridBagConstraints); ! ! changeButton.setText("change"); ! changeButton.addActionListener(new java.awt.event.ActionListener() { ! public void actionPerformed(java.awt.event.ActionEvent evt) { ! changeButtonActionPerformed(evt); ! } ! }); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 2; ! gridBagConstraints.gridy = 0; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; ! choosePanel.add(changeButton, gridBagConstraints); ! ! installButton.setText("Install"); ! installButton.addActionListener(new java.awt.event.ActionListener() { ! public void actionPerformed(java.awt.event.ActionEvent evt) { ! installButtonActionPerformed(evt); ! } ! }); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 0; ! gridBagConstraints.gridy = 1; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; ! choosePanel.add(installButton, gridBagConstraints); ! ! exitButton.setText("Exit"); ! exitButton.addActionListener(new java.awt.event.ActionListener() { ! public void actionPerformed(java.awt.event.ActionEvent evt) { ! exitButtonActionPerformed(evt); ! } ! }); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 1; ! gridBagConstraints.gridy = 1; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! choosePanel.add(exitButton, gridBagConstraints); ! ! okButton.setText("OK"); ! okButton.addActionListener(new java.awt.event.ActionListener() { ! public void actionPerformed(java.awt.event.ActionEvent evt) { ! okButtonActionPerformed(evt); ! } ! }); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 2; ! gridBagConstraints.gridy = 1; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; ! choosePanel.add(okButton, gridBagConstraints); ! ! //getContentPane().add(choosePanel, java.awt.BorderLayout.SOUTH); ! ! Jake2Canvas c = new Jake2Canvas(); ! getContentPane().add(c, BorderLayout.CENTER); ! ! statusPanel.setLayout(new java.awt.GridBagLayout()); ! statusPanel.setMaximumSize(new java.awt.Dimension(400, 100)); ! statusPanel.setMinimumSize(new java.awt.Dimension(400, 100)); ! statusPanel.setPreferredSize(new java.awt.Dimension(400, 100)); ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 0; ! gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 1; ! gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.weightx = 1.0; ! statusPanel.add(status, gridBagConstraints); ! getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH); ! ! installPanel = new InstallPanel(this); ! ! pack(); ! }//GEN-END:initComponents ! ! ! private void installButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_installButtonActionPerformed ! dir = jTextField1.getText(); ! showInstallPanel(); ! installPanel.destDir = dir; ! ! dir += "/baseq2"; ! jTextField1.setText(dir); ! ! new Thread(installPanel).start(); ! }//GEN-LAST:event_installButtonActionPerformed ! ! private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed ! System.exit(1); ! dispose(); ! }//GEN-LAST:event_exitButtonActionPerformed ! ! private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed ! ! dir = jTextField1.getText(); ! Cvar.Set("cddir", dir); ! FS.setCDDir(); ! ! synchronized(this) { ! notifyAll(); ! } ! }//GEN-LAST:event_okButtonActionPerformed ! ! private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeButtonActionPerformed ! JFileChooser chooser = new JFileChooser(); ! chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); ! chooser.setDialogType(JFileChooser.CUSTOM_DIALOG); ! chooser.setMultiSelectionEnabled(false); ! chooser.setDialogTitle("choose a valid baseq2 directory"); ! chooser.showDialog(this, "OK"); ! ! dir = null; ! try { ! dir = chooser.getSelectedFile().getCanonicalPath(); ! } catch (IOException e) {} ! jTextField1.setText(dir); ! ! }//GEN-LAST:event_changeButtonActionPerformed ! ! private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing ! System.exit(1); ! dispose(); ! }//GEN-LAST:event_formWindowClosing ! ! // Variables declaration - do not modify//GEN-BEGIN:variables ! private javax.swing.JButton changeButton; ! private javax.swing.JButton exitButton; ! private javax.swing.JButton installButton; ! private Jake2Canvas canvas; ! private javax.swing.JPanel choosePanel; ! private JPanel statusPanel; ! private InstallPanel installPanel; ! private JLabel status; ! private javax.swing.JTextField jTextField1; ! private javax.swing.JButton okButton; ! // End of variables declaration//GEN-END:variables ! ! private String dir; ! ! void showChooseDialog() { ! getContentPane().remove(statusPanel); ! getContentPane().remove(installPanel); ! getContentPane().add(choosePanel, BorderLayout.SOUTH); ! validate(); ! repaint(); ! } ! ! void showStatus() { ! getContentPane().remove(choosePanel); ! getContentPane().add(statusPanel, BorderLayout.SOUTH); ! validate(); ! repaint(); ! } ! ! void showInstallPanel() { ! getContentPane().remove(choosePanel); ! getContentPane().add(installPanel, BorderLayout.SOUTH); ! validate(); ! repaint(); ! } ! ! void setStatus(String text) { ! status.setText(text); ! } ! ! void testQ2Data() { ! while (FS.LoadFile("pics/colormap.pcx") == null) { ! showChooseDialog(); ! ! try { ! synchronized(this) { ! wait(); ! } ! } catch (InterruptedException e) {} ! } ! showStatus(); ! repaint(); ! } ! ! static class Jake2Canvas extends Canvas { ! private Image image; ! Jake2Canvas() { ! setSize(400, 200); ! image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/splash.png")); ! while (!Toolkit.getDefaultToolkit().prepareImage(image, -1, -1, null)) { ! try { ! Thread.sleep(50); ! } catch (InterruptedException e) {} ! } ! } ! ! ! /* (non-Javadoc) ! * @see java.awt.Component#paint(java.awt.Graphics) ! */ ! public void paint(Graphics g) { ! g.drawImage(image, 0, 0, null); ! } ! ! } ! ! static class InstallPanel extends JPanel implements Runnable { ! ! static final String[] locs = { ! "ftp://ftp.fu-berlin.de/pc/msdos/games/idgames/idstuff/quake2/q2-314-demo-x86.exe", ! "ftp://ftp.demon.co.uk/pub/mirrors/idsoftware/quake2/q2-314-demo-x86.exe", ! "ftp://ftp.fragzone.se/pub/spel/quake2/q2-314-demo-x86.exe", ! "ftp://ftp.idsoftware.com/idstuff/quake2/q2-314-demo-x86.exe" }; ! static byte[] buf = new byte[8192]; ! String destDir; ! ! JProgressBar progress = new JProgressBar(); ! JLabel label = new JLabel("test"); ! Q2DataDialog parent; ! ! public InstallPanel(Q2DataDialog d) { ! initComponents(); ! parent = d; ! } ! ! void initComponents() { ! progress.setMinimum(0); ! progress.setMaximum(100); ! setLayout(new GridBagLayout()); ! GridBagConstraints gridBagConstraints = new GridBagConstraints(); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 0; ! gridBagConstraints.gridy = 0; ! gridBagConstraints.gridwidth = 1; ! gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; ! gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); ! gridBagConstraints.weightx = 1.0; ! gridBagConstraints.anchor = GridBagConstraints.SOUTH; ! add(label, gridBagConstraints); ! gridBagConstraints.gridy = 1; ! gridBagConstraints.anchor = GridBagConstraints.NORTH; ! add(progress, gridBagConstraints); ! Dimension d = new Dimension(400, 100); ! setMinimumSize(d); ! setMaximumSize(d); ! setPreferredSize(d); ! } ! ! public void run() { ! ! InputStream in = null; ! OutputStream out = null; ! File outFile = null; ! ! label.setText("downloading..."); ! ! File dir = null; ! try { ! dir = new File(destDir); ! dir.mkdirs(); ! } ! catch (Exception e) {} ! try { ! if (!dir.isDirectory() || !dir.canWrite()) return; ! } ! catch (Exception e) { ! return; ! } ! ! for (int i = 0; i < locs.length; i++) { ! try { ! URL url = new URL(locs[i]); ! URLConnection conn = url.openConnection(); ! int length = conn.getContentLength(); ! progress.setMaximum(length / 1024); ! ! in = conn.getInputStream(); ! ! outFile = File.createTempFile("Jake2Data", ".zip"); ! outFile.deleteOnExit(); ! out = new FileOutputStream(outFile); ! ! copyStream(in, out); ! break; ! } catch (Exception e) {} ! } ! try { ! installData(outFile.getCanonicalPath()); ! } catch (Exception e) {} ! ! ! try { ! if (outFile != null) outFile.delete(); ! } catch (Exception e) {} ! ! parent.showChooseDialog(); ! parent.okButtonActionPerformed(null); ! } ! ! ! void installData(String filename) { ! try { ! ZipFile f = new ZipFile(filename); ! Enumeration e = f.entries(); ! while (e.hasMoreElements()) { ! ZipEntry entry = (ZipEntry)e.nextElement(); ! String name = entry.getName(); ! int i; ! if ((i = name.indexOf("/baseq2")) > -1 && name.indexOf(".dll") == -1) { ! name = destDir + name.substring(i); ! File outFile = new File(name); ! if (entry.isDirectory()) { ! outFile.mkdirs(); ! } else { ! label.setText("installing " + outFile.getName()); ! progress.setMaximum((int)entry.getSize()/1024); ! progress.setValue(0); ! outFile.getParentFile().mkdirs(); ! OutputStream out = new FileOutputStream(outFile); ! InputStream in = f.getInputStream(entry); ! copyStream(in, out); ! } ! } ! } ! } catch (Exception e) {} ! } ! ! void copyStream(InputStream in, OutputStream out) { ! try { ! int c = 0; ! int l; ! while ((l = in.read(buf)) > 0) { ! out.write(buf, 0, l); ! c += l; ! progress.setValue(c / 1024); ! } ! } catch (Exception e) {} ! ! try { ! in.close(); ! } catch (Exception e) {} ! try { ! out.close(); ! } catch (Exception e) {} ! } ! } ! ! } Index: PMove.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/PMove.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PMove.java 10 Sep 2004 19:02:53 -0000 1.4 --- PMove.java 22 Sep 2004 19:22:09 -0000 1.5 *************** *** 1,25 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...2416 lines suppressed...] ! ! Math3D.VectorCopy(PMove.pm.viewangles, angles); ! if (angles[Defines.PITCH] > 180) ! angles[Defines.PITCH] = angles[Defines.PITCH] - 360; ! angles[Defines.PITCH] /= 3; ! ! Math3D.AngleVectors(angles, PMove.pml.forward, PMove.pml.right, ! PMove.pml.up); ! ! PMove.PM_AirMove(); ! } ! } ! ! // set groundentity, watertype, and waterlevel for final spot ! PMove.PM_CatagorizePosition(); ! ! PM_SnapPosition(); ! } ! } \ No newline at end of file Index: MSG.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/MSG.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MSG.java 28 Jul 2004 11:58:10 -0000 1.4 --- MSG.java 22 Sep 2004 19:22:09 -0000 1.5 *************** *** 1,562 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...1093 lines suppressed...] ! if ((bits & CM_BUTTONS) != 0) ! move.buttons = (byte) ReadByte(msg_read); ! if ((bits & CM_IMPULSE) != 0) ! move.impulse = (byte) ReadByte(msg_read); ! ! // read time to run command ! move.msec = (byte) ReadByte(msg_read); ! ! // read the light level ! move.lightlevel = (byte) ReadByte(msg_read); ! ! } ! ! public static void ReadData(sizebuf_t msg_read, byte data[], int len) { ! for (int i = 0; i < len; i++) ! data[i] = (byte) ReadByte(msg_read); ! } ! } \ No newline at end of file Index: Cbuf.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Cbuf.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Cbuf.java 18 Sep 2004 13:07:46 -0000 1.4 --- Cbuf.java 22 Sep 2004 19:22:09 -0000 1.5 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.qcommon; --- 6,27 ---- */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.qcommon; *************** *** 29,32 **** --- 29,33 ---- import jake2.Globals; import jake2.game.Cmd; + import jake2.util.Lib; /** *************** *** 35,246 **** public final class Cbuf { ! /** ! * ! */ ! public static void Init() { ! SZ.Init(Globals.cmd_text, Globals.cmd_text_buf, Globals.cmd_text_buf.length); ! } ! public static void InsertText(String text) { ! byte[] temp = null; ! int templen = 0; ! // copy off any commands still remaining in the exec buffer ! templen = Globals.cmd_text.cursize; ! if (templen != 0) { ! temp = new byte[templen]; ! System.arraycopy(Globals.cmd_text.data, 0, temp, 0, templen); ! SZ.Clear(Globals.cmd_text); ! } ! // add the entire text of the file ! Cbuf.AddText(text); ! // add the copied off data ! if (templen != 0) { ! SZ.Write(Globals.cmd_text, temp, templen); ! temp = null; ! } ! } ! /** ! * @param clear ! */ ! static void AddEarlyCommands(boolean clear) { ! for (int i = 0; i < Com.Argc(); i++) { ! String s = Com.Argv(i); ! if (!s.equals("+set")) ! continue; ! Cbuf.AddText("set " + Com.Argv(i + 1) + " " + Com.Argv(i + 2) + "\n"); ! if (clear) { ! Com.ClearArgv(i); ! Com.ClearArgv(i + 1); ! Com.ClearArgv(i + 2); ! } ! i += 2; ! } ! } ! /** ! * @return ! */ ! static boolean AddLateCommands() { ! int i; ! int j; ! boolean ret = false; ! // build the combined string to parse from ! int s = 0; ! int argc = Com.Argc(); ! for (i = 1; i < argc; i++) { ! s += Com.Argv(i).length(); ! } ! if (s == 0) ! return false; ! String text = ""; ! for (i = 1; i < argc; i++) { ! text += Com.Argv(i); ! if (i != argc - 1) ! text += " "; ! } ! // pull out the commands ! String build = ""; ! for (i = 0; i < text.length(); i++) { ! if (text.charAt(i) == '+') { ! i++; ! for (j = i;(text.charAt(j) != '+') && (text.charAt(j) != '-') && j < text.length(); j++); ! build += text.substring(i, j - 1); ! build += "\n"; ! i = j - 1; ! } ! } ! ret = (build.length() != 0); ! if (ret) ! Cbuf.AddText(build); ! text = null; ! build = null; ! return ret; ! } ! /** ! * @param text ! */ ! public static void AddText(String text) { ! int l = text.length(); ! if (Globals.cmd_text.cursize + l >= Globals.cmd_text.maxsize) { ! Com.Printf("Cbuf_AddText: overflow\n"); ! return; ! } ! SZ.Write(Globals.cmd_text, text.getBytes(), l); ! } ! /** ! * ! */ ! public static void Execute() { ! byte[] text = null; ! byte[] line = new byte[1024]; ! Globals.alias_count = 0; // don't allow infinite alias loops ! ! while (Globals.cmd_text.cursize != 0) { ! // find a \n or ; line break ! text = Globals.cmd_text.data; ! int quotes = 0; ! int i; ! for (i = 0; i < Globals.cmd_text.cursize; i++) { ! if (text[i] == '"') ! quotes++; ! if (!(quotes % 2 != 0) && text[i] == ';') ! break; // don't break if inside a quoted string ! if (text[i] == '\n') ! break; ! } ! System.arraycopy(text, 0, line, 0, i); ! line[i] = 0; ! // delete the text from the command buffer and move remaining commands down ! // this is necessary because commands (exec, alias) can insert data at the ! // beginning of the text buffer ! if (i == Globals.cmd_text.cursize) ! Globals.cmd_text.cursize = 0; ! else { ! i++; ! Globals.cmd_text.cursize -= i; ! byte[] tmp = new byte[Globals.cmd_text.cursize]; ! System.arraycopy(text, i, tmp, 0, Globals.cmd_text.cursize); ! System.arraycopy(tmp, 0, text, 0, Globals.cmd_text.cursize); ! text[Globals.cmd_text.cursize] = '\0'; ! } ! // execute the command line ! int len = jake2.util.Lib.strlen(line); ! String cmd = new String(line, 0, len); ! Cmd.ExecuteString(cmd); ! if (Globals.cmd_wait) { ! // skip out while text still remains in buffer, leaving it ! // for next frame ! Globals.cmd_wait = false; ! break; ! } ! } ! } ! public static void ExecuteText(int exec_when, String text) { ! switch(exec_when) { ! case Defines.EXEC_NOW: ! Cmd.ExecuteString(text); ! break; ! case Defines.EXEC_INSERT: ! Cbuf.InsertText(text); ! break; ! case Defines.EXEC_APPEND: ! Cbuf.AddText(text); ! break; ! default: ! Com.Error(Defines.ERR_FATAL, "Cbuf_ExecuteText: bad exec_when"); ! } ! } ! /* ! ============ ! Cbuf_CopyToDefer ! ============ ! */ ! public static void CopyToDefer() { ! System.arraycopy(Globals.cmd_text_buf, 0, Globals.defer_text_buf, 0, Globals.cmd_text.cursize); ! Globals.defer_text_buf[Globals.cmd_text.cursize] = 0; ! Globals.cmd_text.cursize = 0; ! } ! /* ! ============ ! Cbuf_InsertFromDefer ! ============ ! */ ! public static void InsertFromDefer() { ! InsertText(new String(Globals.defer_text_buf).trim()); ! Globals.defer_text_buf[0] = 0; ! } ! } --- 36,250 ---- public final class Cbuf { ! /** ! * ! */ ! public static void Init() { ! SZ.Init(Globals.cmd_text, Globals.cmd_text_buf, ! Globals.cmd_text_buf.length); ! } ! public static void InsertText(String text) { ! byte[] temp = null; ! int templen = 0; ! // copy off any commands still remaining in the exec buffer ! templen = Globals.cmd_text.cursize; ! if (templen != 0) { ! temp = new byte[templen]; ! System.arraycopy(Globals.cmd_text.data, 0, temp, 0, templen); ! SZ.Clear(Globals.cmd_text); ! } ! // add the entire text of the file ! Cbuf.AddText(text); ! // add the copied off data ! if (templen != 0) { ! SZ.Write(Globals.cmd_text, temp, templen); ! temp = null; ! } ! } ! /** ! * @param clear ! */ ! static void AddEarlyCommands(boolean clear) { ! for (int i = 0; i < Com.Argc(); i++) { ! String s = Com.Argv(i); ! if (!s.equals("+set")) ! continue; ! Cbuf.AddText("set " + Com.Argv(i + 1) + " " + Com.Argv(i + 2) ! + "\n"); ! if (clear) { ! Com.ClearArgv(i); ! Com.ClearArgv(i + 1); ! Com.ClearArgv(i + 2); ! } ! i += 2; ! } ! } ! /** ! * @return ! */ ! static boolean AddLateCommands() { ! int i; ! int j; ! boolean ret = false; ! // build the combined string to parse from ! int s = 0; ! int argc = Com.Argc(); ! for (i = 1; i < argc; i++) { ! s += Com.Argv(i).length(); ! } ! if (s == 0) ! return false; ! String text = ""; ! for (i = 1; i < argc; i++) { ! text += Com.Argv(i); ! if (i != argc - 1) ! text += " "; ! } ! // pull out the commands ! String build = ""; ! for (i = 0; i < text.length(); i++) { ! if (text.charAt(i) == '+') { ! i++; ! for (j = i; (text.charAt(j) != '+') && (text.charAt(j) != '-') ! && j < text.length(); j++) ! ; ! build += text.substring(i, j - 1); ! build += "\n"; ! i = j - 1; ! } ! } ! ret = (build.length() != 0); ! if (ret) ! Cbuf.AddText(build); ! text = null; ! build = null; ! return ret; ! } ! /** ! * @param text ! */ ! public static void AddText(String text) { ! int l = text.length(); ! if (Globals.cmd_text.cursize + l >= Globals.cmd_text.maxsize) { ! Com.Printf("Cbuf_AddText: overflow\n"); ! return; ! } ! SZ.Write(Globals.cmd_text, text.getBytes(), l); ! } ! /** ! * ! */ ! public static void Execute() { ! byte[] text = null; ! byte[] line = new byte[1024]; ! Globals.alias_count = 0; // don't allow infinite alias loops ! while (Globals.cmd_text.cursize != 0) { ! // find a \n or ; line break ! text = Globals.cmd_text.data; ! int quotes = 0; ! int i; ! for (i = 0; i < Globals.cmd_text.cursize; i++) { ! if (text[i] == '"') ! quotes++; ! if (!(quotes % 2 != 0) && text[i] == ';') ! break; // don't break if inside a quoted string ! if (text[i] == '\n') ! break; ! } ! System.arraycopy(text, 0, line, 0, i); ! line[i] = 0; ! // delete the text from the command buffer and move remaining ! // commands down ! // this is necessary because commands (exec, alias) can insert data ! // at the ! // beginning of the text buffer ! if (i == Globals.cmd_text.cursize) ! Globals.cmd_text.cursize = 0; ! else { ! i++; ! Globals.cmd_text.cursize -= i; ! byte[] tmp = new byte[Globals.cmd_text.cursize]; ! System.arraycopy(text, i, tmp, 0, Globals.cmd_text.cursize); ! System.arraycopy(tmp, 0, text, 0, Globals.cmd_text.cursize); ! text[Globals.cmd_text.cursize] = '\0'; ! } ! // execute the command line ! int len = Lib.strlen(line); ! String cmd = new String(line, 0, len); ! Cmd.ExecuteString(cmd); ! if (Globals.cmd_wait) { ! // skip out while text still remains in buffer, leaving it ! // for next frame ! Globals.cmd_wait = false; ! break; ! } ! } ! } ! public static void ExecuteText(int exec_when, String text) { ! switch (exec_when) { ! case Defines.EXEC_NOW: ! Cmd.ExecuteString(text); ! break; ! case Defines.EXEC_INSERT: ! Cbuf.InsertText(text); ! break; ! case Defines.EXEC_APPEND: ! Cbuf.AddText(text); ! break; ! default: ! Com.Error(Defines.ERR_FATAL, "Cbuf_ExecuteText: bad exec_when"); ! } ! } ! /* ! * ============ Cbuf_CopyToDefer ============ ! */ ! public static void CopyToDefer() { ! System.arraycopy(Globals.cmd_text_buf, 0, Globals.defer_text_buf, 0, ! Globals.cmd_text.cursize); ! Globals.defer_text_buf[Globals.cmd_text.cursize] = 0; ! Globals.cmd_text.cursize = 0; ! } ! /* ! * ============ Cbuf_InsertFromDefer ============ ! */ ! public static void InsertFromDefer() { ! InsertText(new String(Globals.defer_text_buf).trim()); ! Globals.defer_text_buf[0] = 0; ! } ! ! } \ No newline at end of file Index: CM.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/CM.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CM.java 28 Jul 2004 12:01:27 -0000 1.5 --- CM.java 22 Sep 2004 19:22:09 -0000 1.6 *************** *** 1,28 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...3784 lines suppressed...] ! int cluster; ! cnode_t node; ! ! if (nodenum < 0) { ! leafnum = -1 - nodenum; ! cluster = map_leafs[leafnum].cluster; ! if (cluster == -1) ! return false; ! if (0 != (visbits[cluster >>> 3] & (1 << (cluster & 7)))) ! return true; ! return false; ! } ! ! node = map_nodes[nodenum]; ! if (CM_HeadnodeVisible(node.children[0], visbits)) ! return true; ! return CM_HeadnodeVisible(node.children[1], visbits); ! } ! } \ No newline at end of file Index: netchan_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/netchan_t.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** netchan_t.java 7 Jul 2004 19:59:34 -0000 1.1.1.1 --- netchan_t.java 22 Sep 2004 19:22:09 -0000 1.2 *************** *** 1,79 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ ! // Created on 27.11.2003 by RST. ! // $Id$ ! package jake2.qcommon; ! import jake2.*; ! public class netchan_t { ! public boolean fatal_error; ! // was enum {NS_CLIENT, NS_SERVER} ! public int sock; ! public int dropped; // between last packet and previous ! public int last_received; // for timeouts ! public int last_sent; // for retransmits ! public netadr_t remote_address = new netadr_t(); ! public int qport; // qport value to write when transmitting ! // sequencing variables ! public int incoming_sequence; ! public int incoming_acknowledged; ! public int incoming_reliable_acknowledged; // single bit ! public int incoming_reliable_sequence; // single bit, maintained local ! public int outgoing_sequence; ! public int reliable_sequence; // single bit ! public int last_reliable_sequence; // sequence number of last send ! // reliable staging and holding areas ! public sizebuf_t message = new sizebuf_t(); // writing buffer to send to server ! public byte message_buf[] = new byte[Defines.MAX_MSGLEN - 16]; // leave space for header ! // message is copied to this buffer when it is first transfered ! int reliable_length; ! ! byte reliable_buf[] = new byte[Defines.MAX_MSGLEN - 16]; // unpcked reliable message ! //ok. ! public void clear() ! { ! sock=dropped=last_received=last_sent=0; ! remote_address = new netadr_t(); ! qport = incoming_sequence = incoming_acknowledged = incoming_reliable_acknowledged = incoming_reliable_sequence ! = outgoing_sequence = reliable_sequence = last_reliable_sequence =0; ! message = new sizebuf_t(); ! ! message_buf = new byte[Defines.MAX_MSGLEN - 16]; ! ! reliable_length =0; ! reliable_buf = new byte[Defines.MAX_MSGLEN - 16]; ! } ! ! } --- 1,87 ---- /* ! * Copyright (C) 1997-2001 Id Software, Inc. ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. ! * ! * See the GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! * ! */ ! // Created on 27.11.2003 by RST. ! // $Id$ ! package jake2.qcommon; ! import jake2.*; ! public class netchan_t { ! public boolean fatal_error; ! // was enum {NS_CLIENT, NS_SERVER} ! public int sock; ! public int dropped; // between last packet and previous ! public int last_received; // for timeouts ! public int last_sent; // for retransmits ! public netadr_t remote_address = new netadr_t(); + public int qport; // qport value to write when transmitting ! // sequencing variables ! public int incoming_sequence; ! public int incoming_acknowledged; ! public int incoming_reliable_acknowledged; // single bit ! public int incoming_reliable_sequence; // single bit, maintained local ! public int outgoing_sequence; ! public int reliable_sequence; // single bit ! public int last_reliable_sequence; // sequence number of last send ! // reliable staging and holding areas ! public sizebuf_t message = new sizebuf_t(); // writing buffer to send to ! // server ! public byte message_buf[] = new byte[Defines.MAX_MSGLEN - 16]; // leave ! // space for ! // header ! // message is copied to this buffer when it is first transfered ! public int reliable_length; ! public byte reliable_buf[] = new byte[Defines.MAX_MSGLEN - 16]; // unpcked ! // reliable ! // message ! ! //ok. ! public void clear() { ! sock = dropped = last_received = last_sent = 0; ! remote_address = new netadr_t(); ! qport = incoming_sequence = incoming_acknowledged = incoming_reliable_acknowledged = incoming_reliable_sequence = outgoing_sequence = reliable_sequence = last_reliable_sequence = 0; ! message = new sizebuf_t(); ! ! message_buf = new byte[Defines.MAX_MSGLEN - 16]; ! ! reliable_length = 0; ! reliable_buf = new byte[Defines.MAX_MSGLEN - 16]; ! } ! ! } \ No newline at end of file Index: Netchan.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Netchan.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Netchan.java 12 Jul 2004 20:47:00 -0000 1.3 --- Netchan.java 22 Sep 2004 19:22:09 -0000 1.4 *************** *** 6,27 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.qcommon; --- 6,27 ---- */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.qcommon; *************** *** 38,386 **** public final class Netchan extends SV_MAIN { ! /* ! ! packet header ! ------------- ! 31 sequence ! 1 does this message contains a reliable payload ! 31 acknowledge sequence ! 1 acknowledge receipt of even/odd message ! 16 qport ! ! The remote connection never knows if it missed a reliable message, the ! local side detects that it has been dropped by seeing a sequence acknowledge ! higher thatn the last reliable sequence, but without the correct evon/odd ! bit for the reliable set. ! ! If the sender notices that a reliable message has been dropped, it will be ! retransmitted. It will not be retransmitted again until a message after ! the retransmit has been acknowledged and the reliable still failed to get there. ! ! if the sequence number is -1, the packet should be handled without a netcon ! ! The reliable message can be added to at any time by doing ! MSG_Write* (&netchan.message, <data>). ! ! If the message buffer is overflowed, either by a single message, or by ! multiple frames worth piling up while the last reliable transmit goes ! unacknowledged, the netchan signals a fatal error. ! ! Reliable messages are always placed first in a packet, then the unreliable ! message is included if there is sufficient room. ! ! To the receiver, there is no distinction between the reliable and unreliable ! parts of the message, they are just processed out as a single larger message. ! ! Illogical packet sequence numbers cause the packet to be dropped, but do ! not kill the connection. This, combined with the tight window of valid ! reliable acknowledgement numbers provides protection against malicious ! address spoofing. ! ! ! The qport field is a workaround for bad address translating routers that ! sometimes remap the client's source port on a packet during gameplay. ! ! If the base part of the net address matches and the qport matches, then the ! channel matches even if the IP port differs. The IP port should be updated ! to the new value before sending out any replies. ! ! ! If there is no information that needs to be transfered on a given frame, ! such as during the connection stage while waiting for the client to load, ! then a packet only needs to be delivered if there is something in the ! unacknowledged reliable ! */ ! public static cvar_t showpackets; ! public static cvar_t showdrop; ! public static cvar_t qport; ! //public static netadr_t net_from = new netadr_t(); ! public static sizebuf_t net_message = new sizebuf_t(); ! public static byte net_message_buffer[] = new byte[Defines.MAX_MSGLEN]; ! /* ! =============== ! Netchan_Init ! ! =============== ! */ ! //ok. ! public static void Netchan_Init() { ! long port; ! // pick a port value that should be nice and random ! port = Sys.Milliseconds() & 0xffff; ! showpackets = Cvar.Get("showpackets", "0", 0); ! showdrop = Cvar.Get("showdrop", "0", 0); ! qport = Cvar.Get("qport", "" + port, Defines.CVAR_NOSET); ! } ! /* ! =============== ! Netchan_OutOfBand ! ! Sends an out-of-band datagram ! ================ ! */ ! //ok. ! public static void Netchan_OutOfBand(int net_socket, netadr_t adr, int length, byte data[]) { ! sizebuf_t send = new sizebuf_t(); ! byte send_buf[] = new byte[Defines.MAX_MSGLEN]; ! // write the packet header ! SZ.Init(send, send_buf, Defines.MAX_MSGLEN); ! MSG.WriteInt(send, -1); // -1 sequence means out of band ! SZ.Write(send, data, length); ! // send the datagram ! NET.SendPacket(net_socket, send.cursize, send.data, adr); ! } ! ! public static void OutOfBandPrint(int net_socket, netadr_t adr, String s) { ! Netchan_OutOfBand(net_socket, adr, s.length(), s.getBytes()); ! } ! /* ! ============== ! Netchan_Setup ! ! called to open a channel to a remote system ! ============== ! */ ! public static void Setup(int sock, netchan_t chan, netadr_t adr, int qport) { ! //memset (chan, 0, sizeof(*chan)); ! chan.clear(); ! chan.sock = sock; ! chan.remote_address.set(adr); ! chan.qport = qport; ! chan.last_received = Globals.curtime; ! chan.incoming_sequence = 0; ! chan.outgoing_sequence = 1; ! SZ.Init(chan.message, chan.message_buf, chan.message_buf.length); ! chan.message.allowoverflow = true; ! } ! /* ! =============== ! Netchan_CanReliable ! ! Returns true if the last reliable message has acked ! ================ ! */ ! public static boolean Netchan_CanReliable(netchan_t chan) { ! if (chan.reliable_length != 0) ! return false; // waiting for ack ! return true; ! } ! // das ist richtig !!! ! public static boolean Netchan_NeedReliable(netchan_t chan) { ! boolean send_reliable; ! // if the remote side dropped the last reliable message, resend it ! send_reliable = false; ! if (chan.incoming_acknowledged > chan.last_reliable_sequence && chan.incoming_reliable_acknowledged != chan.reliable_sequence) ! send_reliable = true; ! // if the reliable transmit buffer is empty, copy the current message out ! if (0 == chan.reliable_length && chan.message.cursize != 0) { ! send_reliable = true; ! } ! return send_reliable; ! } ! /* ! =============== ! Netchan_Transmit ! ! tries to send an unreliable message to a connection, and handles the ! transmition / retransmition of the reliable messages. ! ! A 0 length will still generate a packet and deal with the reliable messages. ! ================ ! */ ! public static void Transmit(netchan_t chan, int length, byte data[]) { ! sizebuf_t send = new sizebuf_t(); ! byte send_buf[] = new byte[MAX_MSGLEN]; ! int send_reliable; ! int w1, w2; ! // check for message overflow ! if (chan.message.overflowed) { ! chan.fatal_error = true; ! Com.Printf(NET.AdrToString(chan.remote_address) + ":Outgoing message overflow\n"); ! return; ! } ! send_reliable = Netchan_NeedReliable(chan) ? 1 : 0; ! if (chan.reliable_length == 0 && chan.message.cursize != 0) { ! System.arraycopy(chan.message_buf, 0, chan.reliable_... [truncated message content] |
From: Rene S. <sa...@us...> - 2004-09-22 19:22:54
|
Update of /cvsroot/jake2/jake2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11556 Modified Files: .classpath Log Message: major refactoring in game, server and client package Index: .classpath =================================================================== RCS file: /cvsroot/jake2/jake2/.classpath,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** .classpath 19 Sep 2004 12:48:53 -0000 1.4 --- .classpath 22 Sep 2004 19:22:13 -0000 1.5 *************** *** 4,11 **** <classpathentry kind="src" path="test"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="lib" path="lib/joal/linux/joal.jar"/> - <classpathentry kind="lib" path="lib/joal/windows/joal.jar"/> - <classpathentry kind="lib" path="lib/jogl/jogl.jar"/> <classpathentry kind="lib" path="resources"/> <classpathentry kind="output" path="build"/> </classpath> --- 4,10 ---- <classpathentry kind="src" path="test"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="lib" path="resources"/> + <classpathentry kind="lib" path="D:/javajake/jake2sfg/lib/jogl/jogl.jar"/> + <classpathentry kind="lib" path="D:/javajake/jake2sfg/lib/joal/windows/joal.jar"/> <classpathentry kind="output" path="build"/> </classpath> |
From: Rene S. <sa...@us...> - 2004-09-22 19:22:50
|
Update of /cvsroot/jake2/jake2/src/jake2/sound/jsound In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11556/src/jake2/sound/jsound Modified Files: SND_MIX.java SND_DMA.java Log Message: major refactoring in game, server and client package Index: SND_MIX.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/jsound/SND_MIX.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SND_MIX.java 9 Jul 2004 06:50:48 -0000 1.1 --- SND_MIX.java 22 Sep 2004 19:22:09 -0000 1.2 *************** *** 6,39 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.sound.jsound; - import java.nio.*; - import java.nio.ByteBuffer; - import java.nio.ShortBuffer; - import jake2.game.cvar_t; ! import jake2.sound.*; import jake2.sound.sfx_t; import jake2.sound.sfxcache_t; import jake2.util.Math3D; /** * SND_MIX --- 6,40 ---- */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package jake2.sound.jsound; import jake2.game.cvar_t; ! import jake2.sound.WaveLoader; import jake2.sound.sfx_t; import jake2.sound.sfxcache_t; import jake2.util.Math3D; + import java.nio.ByteBuffer; + import java.nio.ByteOrder; + import java.nio.IntBuffer; + import java.nio.ShortBuffer; + /** * SND_MIX *************** *** 41,491 **** public class SND_MIX extends SND_JAVA { ! static final int MAX_CHANNELS = 32; ! static final int MAX_RAW_SAMPLES = 8192; ! ! static class playsound_t { ! playsound_t prev, next; ! sfx_t sfx; ! float volume; ! float attenuation; ! int entnum; ! int entchannel; ! boolean fixed_origin; // use origin field instead of entnum's origin ! float[] origin = { 0, 0, 0 }; ! long begin; // begin on this sample ! ! public void clear() { ! prev = next = null; ! sfx = null; ! volume = attenuation = begin = entnum = entchannel = 0; ! fixed_origin = false; ! Math3D.VectorClear(origin); ! } ! }; ! static class channel_t { ! sfx_t sfx; // sfx number ! int leftvol; // 0-255 volume ! int rightvol; // 0-255 volume ! int end; // end time in global paintsamples ! int pos; // sample position in sfx ! int looping; // where to loop, -1 = no looping OBSOLETE? ! int entnum; // to allow overriding a specific sound ! int entchannel; // ! float[] origin = { 0, 0, 0 }; // only use if fixed_origin is set ! float dist_mult; // distance multiplier (attenuation/clipK) ! int master_vol; // 0-255 master volume ! boolean fixed_origin; // use origin instead of fetching entnum's origin ! boolean autosound; // from an entity->sound, cleared each frame ! ! void clear() { ! sfx = null; ! dist_mult = leftvol = rightvol = end = pos = looping = entnum = entchannel = master_vol = 0; ! Math3D.VectorClear(origin); ! fixed_origin = autosound = false; ! } ! }; ! ! static class portable_samplepair_t { ! int left; ! int right; ! }; ! ! static cvar_t s_volume; ! static int s_rawend; ! //// snd_mix.c -- portable code to mix sounds for snd_dma.c ! // ! // #include "client.h" ! // #include "snd_loc.h" ! // ! static final int PAINTBUFFER_SIZE = 2048; ! //static portable_samplepair_t[] paintbuffer = new portable_samplepair_t[PAINTBUFFER_SIZE]; ! static IntBuffer paintbuffer = IntBuffer.allocate(PAINTBUFFER_SIZE*2); ! static int[][] snd_scaletable = new int[32][256]; ! // int *snd_p, snd_linear_count, snd_vol; ! // short *snd_out; ! static IntBuffer snd_p; ! static ShortBuffer snd_out; ! static int snd_linear_count; ! static int snd_vol; ! ! static int paintedtime; // sample PAIRS ! static playsound_t s_pendingplays = new playsound_t(); ! ! //static portable_samplepair_t[] s_rawsamples = new portable_samplepair_t[MAX_RAW_SAMPLES]; ! static IntBuffer s_rawsamples = IntBuffer.allocate(MAX_RAW_SAMPLES*2); ! static channel_t[] channels = new channel_t[MAX_CHANNELS]; ! static { ! for(int i=0; i < MAX_CHANNELS; i++) ! channels[i] = new channel_t(); ! } ! static void WriteLinearBlastStereo16() ! { ! int i; ! int val; ! for (i=0 ; i<snd_linear_count ; i+=2) ! { ! val = snd_p.get(i)>>8; ! if (val > 0x7fff) ! snd_out.put(i, (short)0x7fff); ! else if (val < (short)0x8000) ! snd_out.put(i,(short)0x8000); ! else ! snd_out.put(i, (short)val); ! val = snd_p.get(i+1)>>8; ! if (val > 0x7fff) ! snd_out.put(i+1, (short)0x7fff); ! else if (val < (short)0x8000) ! snd_out.put(i+1, (short)0x8000); ! else ! snd_out.put(i+1, (short)val); ! } ! } ! static void TransferStereo16(ByteBuffer pbuf, int endtime) ! { ! int lpos; ! int lpaintedtime; ! ! snd_p = paintbuffer; ! lpaintedtime = paintedtime; ! while (lpaintedtime < endtime) ! { ! // handle recirculating buffer issues ! lpos = lpaintedtime & ((dma.samples>>1)-1); ! // snd_out = (short *) pbuf + (lpos<<1); ! snd_out = pbuf.asShortBuffer(); ! snd_out.position(lpos<<1); ! snd_out = snd_out.slice(); ! snd_linear_count = (dma.samples>>1) - lpos; ! if (lpaintedtime + snd_linear_count > endtime) ! snd_linear_count = endtime - lpaintedtime; ! snd_linear_count <<= 1; ! // write a linear blast of samples ! WriteLinearBlastStereo16(); ! //snd_p += snd_linear_count; ! paintbuffer.position(snd_linear_count); ! snd_p = paintbuffer.slice(); ! ! lpaintedtime += (snd_linear_count>>1); ! } ! } ! /* ! =================== ! S_TransferPaintBuffer ! =================== ! */ ! static void TransferPaintBuffer(int endtime) ! { ! int out_idx; ! int count; ! int out_mask; ! int p; ! int step; ! int val; ! //unsigned long *pbuf; ! ByteBuffer pbuf = ByteBuffer.wrap(dma.buffer); ! pbuf.order(ByteOrder.LITTLE_ENDIAN); ! if (SND_DMA.s_testsound.value != 0.0f) ! { ! int i; ! int count2; ! // write a fixed sine wave ! count2 = (endtime - paintedtime)*2; ! int v; ! for (i=0 ; i<count2 ; i+=2) { ! v = (int)(Math.sin((paintedtime+i)*0.1)*20000*256); ! paintbuffer.put(i, v); ! paintbuffer.put(i+1, v); ! } ! } ! if (dma.samplebits == 16 && dma.channels == 2) ! { // optimized case ! TransferStereo16(pbuf, endtime); ! } ! else ! { // general case ! p = 0; ! count = (endtime - paintedtime) * dma.channels; ! out_mask = dma.samples - 1; ! out_idx = paintedtime * dma.channels & out_mask; ! step = 3 - dma.channels; ! if (dma.samplebits == 16) ! { ! // short *out = (short *) pbuf; ! ShortBuffer out = pbuf.asShortBuffer(); ! while (count-- > 0) ! { ! val = paintbuffer.get(p) >> 8; ! p+= step; ! if (val > 0x7fff) ! val = 0x7fff; ! else if (val < (short)0x8000) ! val = (short)0x8000; ! out.put(out_idx, (short)val); ! //System.out.println(out_idx + " " + val); ! out_idx = (out_idx + 1) & out_mask; ! } ! } ! else if (dma.samplebits == 8) ! { ! // unsigned char *out = (unsigned char *) pbuf; ! ByteBuffer out = pbuf; ! while (count-- > 0) ! { ! val = paintbuffer.get(p) >> 8; ! p += step; ! if (val > 0x7fff) ! val = 0x7fff; ! else if (val < (short)0x8000) ! val = (short)0x8000; ! out.put(out_idx,(byte)(val>>>8)); ! out_idx = (out_idx + 1) & out_mask; ! } ! } ! } ! } ! /* ! =============================================================================== ! CHANNEL MIXING ! =============================================================================== ! */ ! static void PaintChannels(int endtime) ! { ! int i; ! int end; ! channel_t ch; ! sfxcache_t sc; ! int ltime, count; ! playsound_t ps; ! snd_vol = (int)(s_volume.value*256); ! // Com_Printf ("%i to %i\n", paintedtime, endtime); ! while (paintedtime < endtime) ! { ! // if paintbuffer is smaller than DMA buffer ! end = endtime; ! if (endtime - paintedtime > PAINTBUFFER_SIZE) ! end = paintedtime + PAINTBUFFER_SIZE; ! // start any playsounds ! while (true) ! { ! ps = s_pendingplays.next; ! if (ps == s_pendingplays) ! break; // no more pending sounds ! if (ps.begin <= paintedtime) ! { ! SND_DMA.IssuePlaysound(ps); ! continue; ! } ! if (ps.begin < end) ! end = (int)ps.begin; // stop here ! break; ! } ! // clear the paint buffer ! if (s_rawend < paintedtime) ! { ! // Com_Printf ("clear\n"); ! for (i = 0; i < (end-paintedtime)*2; i++) { ! paintbuffer.put(i, 0); ! } ! //memset(paintbuffer, 0, (end - paintedtime) * sizeof(portable_samplepair_t)); ! } ! else ! { // copy from the streaming sound source ! int s; ! int stop; ! stop = (end < s_rawend) ? end : s_rawend; ! for (i=paintedtime ; i<stop ; i++) ! { ! s = i&(MAX_RAW_SAMPLES-1); ! //paintbuffer[i-paintedtime] = s_rawsamples[s]; ! paintbuffer.put((i-paintedtime)*2, s_rawsamples.get(2*s)); ! paintbuffer.put((i-paintedtime)*2+1, s_rawsamples.get(2*s)+1); ! } ! // if (i != end) ! // Com_Printf ("partial stream\n"); ! // else ! // Com_Printf ("full stream\n"); ! for ( ; i<end ; i++) ! { ! //paintbuffer[i-paintedtime].left = ! //paintbuffer[i-paintedtime].right = 0; ! paintbuffer.put((i-paintedtime)*2, 0); ! paintbuffer.put((i-paintedtime)*2+1, 0); ! } ! } ! // paint in the channels. ! //ch = channels; ! for (i=0; i<MAX_CHANNELS ; i++) ! { ! ch = channels[i]; ! ltime = paintedtime; ! ! while (ltime < end) ! { ! if (ch.sfx == null || (ch.leftvol == 0 && ch.rightvol == 0)) ! break; ! // max painting is to the end of the buffer ! count = end - ltime; ! // might be stopped by running out of data ! if (ch.end - ltime < count) ! count = ch.end - ltime; ! ! sc = WaveLoader.LoadSound(ch.sfx); ! if (sc == null) ! break; ! if (count > 0 && ch.sfx != null) ! { ! if (sc.width == 1)// FIXME; 8 bit asm is wrong now ! PaintChannelFrom8(ch, sc, count, ltime - paintedtime); ! else ! PaintChannelFrom16(ch, sc, count, ltime - paintedtime); ! ! ltime += count; ! } ! // if at end of loop, restart ! if (ltime >= ch.end) ! { ! if (ch.autosound) ! { // autolooping sounds always go back to start ! ch.pos = 0; ! ch.end = ltime + sc.length; ! } ! else if (sc.loopstart >= 0) ! { ! ch.pos = sc.loopstart; ! ch.end = ltime + sc.length - ch.pos; ! } ! else ! { // channel just stopped ! ch.sfx = null; ! } ! } ! } ! ! } ! // transfer out according to DMA format ! TransferPaintBuffer(end); ! paintedtime = end; ! } ! } ! static void InitScaletable () ! { ! int i, j; ! int scale; ! s_volume.modified = false; ! for (i=0 ; i<32 ; i++) ! { ! scale = (int)(i * 8 * 256 * s_volume.value); ! for (j=0 ; j<256 ; j++) ! snd_scaletable[i][j] = ((byte)j) * scale; ! } ! } ! static void PaintChannelFrom8(channel_t ch, sfxcache_t sc, int count, int offset) ! { ! int data; ! int[] lscale; ! int[] rscale; ! int sfx; ! int i; ! portable_samplepair_t samp; ! if (ch.leftvol > 255) ! ch.leftvol = 255; ! if (ch.rightvol > 255) ! ch.rightvol = 255; ! ! //ZOID-- >>11 has been changed to >>3, >>11 didn't make much sense ! //as it would always be zero. ! lscale = snd_scaletable[ ch.leftvol >> 3]; ! rscale = snd_scaletable[ ch.rightvol >> 3]; ! sfx = ch.pos; ! //samp = paintbuffer[offset]; ! for (i=0 ; i<count ; i++, offset++) ! { ! int left = paintbuffer.get(offset*2); ! int right = paintbuffer.get(offset*2+1); ! data = sc.data[sfx+i]; ! left += lscale[data]; ! right += rscale[data]; ! paintbuffer.put(offset*2, left); ! paintbuffer.put(offset*2+1, right); ! } ! ! ch.pos += count; ! } ! private static ByteBuffer bb; ! private static ShortBuffer sb; ! static void PaintChannelFrom16(channel_t ch, sfxcache_t sc, int count, int offset) ! { ! int data; ! int left, right; ! int leftvol, rightvol; ! int sfx; ! int i; ! portable_samplepair_t samp; ! leftvol = ch.leftvol*snd_vol; ! rightvol = ch.rightvol*snd_vol; ! ByteBuffer bb = ByteBuffer.wrap(sc.data); ! bb.order(ByteOrder.LITTLE_ENDIAN); ! sb = bb.asShortBuffer(); ! sfx = ch.pos; ! //samp = paintbuffer[offset]; ! for (i=0 ; i<count ; i++, offset++) ! { ! left = paintbuffer.get(offset*2); ! right = paintbuffer.get(offset*2+1); ! data = sb.get(sfx+i); ! left += (data * leftvol)>>8; ! right += (data * rightvol)>>8; ! paintbuffer.put(offset*2, left); ! paintbuffer.put(offset*2+1, right); ! } ! ch.pos += count; ! } } \ No newline at end of file --- 42,494 ---- public class SND_MIX extends SND_JAVA { ! static final int MAX_CHANNELS = 32; ! static final int MAX_RAW_SAMPLES = 8192; ! static class playsound_t { ! playsound_t prev, next; ! sfx_t sfx; ! float volume; ! float attenuation; ! int entnum; ! int entchannel; ! boolean fixed_origin; // use origin field instead of entnum's origin ! float[] origin = { 0, 0, 0 }; ! long begin; // begin on this sample ! public void clear() { ! prev = next = null; ! sfx = null; ! volume = attenuation = begin = entnum = entchannel = 0; ! fixed_origin = false; ! Math3D.VectorClear(origin); ! } ! }; ! static class channel_t { ! sfx_t sfx; // sfx number ! int leftvol; // 0-255 volume ! int rightvol; // 0-255 volume ! int end; // end time in global paintsamples ! int pos; // sample position in sfx + int looping; // where to loop, -1 = no looping OBSOLETE? ! int entnum; // to allow overriding a specific sound ! int entchannel; // + float[] origin = { 0, 0, 0 }; // only use if fixed_origin is set ! float dist_mult; // distance multiplier (attenuation/clipK) ! int master_vol; // 0-255 master volume ! boolean fixed_origin; // use origin instead of fetching entnum's origin ! boolean autosound; // from an entity->sound, cleared each frame ! void clear() { ! sfx = null; ! dist_mult = leftvol = rightvol = end = pos = looping = entnum = entchannel = master_vol = 0; ! Math3D.VectorClear(origin); ! fixed_origin = autosound = false; ! } ! }; ! static class portable_samplepair_t { ! int left; ! int right; ! }; ! static cvar_t s_volume; ! static int s_rawend; ! //// snd_mix.c -- portable code to mix sounds for snd_dma.c ! // ! // #include "client.h" ! // #include "snd_loc.h" ! // ! static final int PAINTBUFFER_SIZE = 2048; + //static portable_samplepair_t[] paintbuffer = new + // portable_samplepair_t[PAINTBUFFER_SIZE]; + static IntBuffer paintbuffer = IntBuffer.allocate(PAINTBUFFER_SIZE * 2); ! static int[][] snd_scaletable = new int[32][256]; ! // int *snd_p, snd_linear_count, snd_vol; ! // short *snd_out; ! static IntBuffer snd_p; ! static ShortBuffer snd_out; ! static int snd_linear_count; ! static int snd_vol; ! static int paintedtime; // sample PAIRS ! static playsound_t s_pendingplays = new playsound_t(); ! //static portable_samplepair_t[] s_rawsamples = new ! // portable_samplepair_t[MAX_RAW_SAMPLES]; ! static IntBuffer s_rawsamples = IntBuffer.allocate(MAX_RAW_SAMPLES * 2); ! static channel_t[] channels = new channel_t[MAX_CHANNELS]; ! static { ! for (int i = 0; i < MAX_CHANNELS; i++) ! channels[i] = new channel_t(); ! } ! static void WriteLinearBlastStereo16() { ! int i; ! int val; ! for (i = 0; i < snd_linear_count; i += 2) { ! val = snd_p.get(i) >> 8; ! if (val > 0x7fff) ! snd_out.put(i, (short) 0x7fff); ! else if (val < (short) 0x8000) ! snd_out.put(i, (short) 0x8000); ! else ! snd_out.put(i, (short) val); ! val = snd_p.get(i + 1) >> 8; ! if (val > 0x7fff) ! snd_out.put(i + 1, (short) 0x7fff); ! else if (val < (short) 0x8000) ! snd_out.put(i + 1, (short) 0x8000); ! else ! snd_out.put(i + 1, (short) val); ! } ! } ! static void TransferStereo16(ByteBuffer pbuf, int endtime) { ! int lpos; ! int lpaintedtime; ! snd_p = paintbuffer; ! lpaintedtime = paintedtime; ! while (lpaintedtime < endtime) { ! // handle recirculating buffer issues ! lpos = lpaintedtime & ((dma.samples >> 1) - 1); ! // snd_out = (short *) pbuf + (lpos<<1); ! snd_out = pbuf.asShortBuffer(); ! snd_out.position(lpos << 1); ! snd_out = snd_out.slice(); ! ! snd_linear_count = (dma.samples >> 1) - lpos; ! if (lpaintedtime + snd_linear_count > endtime) ! snd_linear_count = endtime - lpaintedtime; ! ! snd_linear_count <<= 1; ! ! // write a linear blast of samples ! WriteLinearBlastStereo16(); ! ! //snd_p += snd_linear_count; ! paintbuffer.position(snd_linear_count); ! snd_p = paintbuffer.slice(); ! ! lpaintedtime += (snd_linear_count >> 1); ! } ! } ! ! /* ! * =================== S_TransferPaintBuffer ! * ! * =================== ! */ ! static void TransferPaintBuffer(int endtime) { ! int out_idx; ! int count; ! int out_mask; ! int p; ! int step; ! int val; ! //unsigned long *pbuf; ! ! ByteBuffer pbuf = ByteBuffer.wrap(dma.buffer); ! pbuf.order(ByteOrder.LITTLE_ENDIAN); ! ! if (SND_DMA.s_testsound.value != 0.0f) { ! int i; ! int count2; ! ! // write a fixed sine wave ! count2 = (endtime - paintedtime) * 2; ! int v; ! for (i = 0; i < count2; i += 2) { ! v = (int) (Math.sin((paintedtime + i) * 0.1) * 20000 * 256); ! paintbuffer.put(i, v); ! paintbuffer.put(i + 1, v); ! } ! } ! ! if (dma.samplebits == 16 && dma.channels == 2) { // optimized case ! TransferStereo16(pbuf, endtime); ! } else { // general case ! p = 0; ! count = (endtime - paintedtime) * dma.channels; ! out_mask = dma.samples - 1; ! out_idx = paintedtime * dma.channels & out_mask; ! step = 3 - dma.channels; ! ! if (dma.samplebits == 16) { ! // short *out = (short *) pbuf; ! ShortBuffer out = pbuf.asShortBuffer(); ! while (count-- > 0) { ! val = paintbuffer.get(p) >> 8; ! p += step; ! if (val > 0x7fff) ! val = 0x7fff; ! else if (val < (short) 0x8000) ! val = (short) 0x8000; ! out.put(out_idx, (short) val); ! //System.out.println(out_idx + " " + val); ! out_idx = (out_idx + 1) & out_mask; ! } ! } else if (dma.samplebits == 8) { ! // unsigned char *out = (unsigned char *) pbuf; ! ByteBuffer out = pbuf; ! while (count-- > 0) { ! val = paintbuffer.get(p) >> 8; ! p += step; ! if (val > 0x7fff) ! val = 0x7fff; ! else if (val < (short) 0x8000) ! val = (short) 0x8000; ! out.put(out_idx, (byte) (val >>> 8)); ! out_idx = (out_idx + 1) & out_mask; ! } ! } ! } ! } ! ! /* ! * =============================================================================== ! * ! * CHANNEL MIXING ! * ! * =============================================================================== ! */ ! static void PaintChannels(int endtime) { ! int i; ! int end; ! channel_t ch; ! sfxcache_t sc; ! int ltime, count; ! playsound_t ps; ! ! snd_vol = (int) (s_volume.value * 256); ! ! // Com_Printf ("%i to %i\n", paintedtime, endtime); ! while (paintedtime < endtime) { ! // if paintbuffer is smaller than DMA buffer ! end = endtime; ! if (endtime - paintedtime > PAINTBUFFER_SIZE) ! end = paintedtime + PAINTBUFFER_SIZE; ! ! // start any playsounds ! while (true) { ! ps = s_pendingplays.next; ! if (ps == s_pendingplays) ! break; // no more pending sounds ! if (ps.begin <= paintedtime) { ! SND_DMA.IssuePlaysound(ps); ! continue; ! } ! ! if (ps.begin < end) ! end = (int) ps.begin; // stop here ! break; ! } ! ! // clear the paint buffer ! if (s_rawend < paintedtime) { ! // Com_Printf ("clear\n"); ! for (i = 0; i < (end - paintedtime) * 2; i++) { ! paintbuffer.put(i, 0); ! } ! //memset(paintbuffer, 0, (end - paintedtime) * ! // sizeof(portable_samplepair_t)); ! } else { // copy from the streaming sound source ! int s; ! int stop; ! ! stop = (end < s_rawend) ? end : s_rawend; ! ! for (i = paintedtime; i < stop; i++) { ! s = i & (MAX_RAW_SAMPLES - 1); ! //paintbuffer[i-paintedtime] = s_rawsamples[s]; ! paintbuffer.put((i - paintedtime) * 2, s_rawsamples ! .get(2 * s)); ! paintbuffer.put((i - paintedtime) * 2 + 1, s_rawsamples ! .get(2 * s) + 1); ! } ! // if (i != end) ! // Com_Printf ("partial stream\n"); ! // else ! // Com_Printf ("full stream\n"); ! for (; i < end; i++) { ! //paintbuffer[i-paintedtime].left = ! //paintbuffer[i-paintedtime].right = 0; ! paintbuffer.put((i - paintedtime) * 2, 0); ! paintbuffer.put((i - paintedtime) * 2 + 1, 0); ! } ! } ! ! // paint in the channels. ! //ch = channels; ! for (i = 0; i < MAX_CHANNELS; i++) { ! ch = channels[i]; ! ltime = paintedtime; ! ! while (ltime < end) { ! if (ch.sfx == null || (ch.leftvol == 0 && ch.rightvol == 0)) ! break; ! ! // max painting is to the end of the buffer ! count = end - ltime; ! ! // might be stopped by running out of data ! if (ch.end - ltime < count) ! count = ch.end - ltime; ! ! sc = WaveLoader.LoadSound(ch.sfx); ! if (sc == null) ! break; ! ! if (count > 0 && ch.sfx != null) { ! if (sc.width == 1)// FIXME; 8 bit asm is wrong now ! PaintChannelFrom8(ch, sc, count, ltime ! - paintedtime); ! else ! PaintChannelFrom16(ch, sc, count, ltime ! - paintedtime); ! ! ltime += count; ! } ! ! // if at end of loop, restart ! if (ltime >= ch.end) { ! if (ch.autosound) { // autolooping sounds always go back ! // to start ! ch.pos = 0; ! ch.end = ltime + sc.length; ! } else if (sc.loopstart >= 0) { ! ch.pos = sc.loopstart; ! ch.end = ltime + sc.length - ch.pos; ! } else { // channel just stopped ! ch.sfx = null; ! } ! } ! } ! ! } ! ! // transfer out according to DMA format ! TransferPaintBuffer(end); ! paintedtime = end; ! } ! } ! ! static void InitScaletable() { ! int i, j; ! int scale; ! ! s_volume.modified = false; ! for (i = 0; i < 32; i++) { ! scale = (int) (i * 8 * 256 * s_volume.value); ! for (j = 0; j < 256; j++) ! snd_scaletable[i][j] = ((byte) j) * scale; ! } ! } ! ! static void PaintChannelFrom8(channel_t ch, sfxcache_t sc, int count, ! int offset) { ! int data; ! int[] lscale; ! int[] rscale; ! int sfx; ! int i; ! portable_samplepair_t samp; ! ! if (ch.leftvol > 255) ! ch.leftvol = 255; ! if (ch.rightvol > 255) ! ch.rightvol = 255; ! ! //ZOID-- >>11 has been changed to >>3, >>11 didn't make much sense ! //as it would always be zero. ! lscale = snd_scaletable[ch.leftvol >> 3]; ! rscale = snd_scaletable[ch.rightvol >> 3]; ! sfx = ch.pos; ! ! //samp = paintbuffer[offset]; ! ! for (i = 0; i < count; i++, offset++) { ! int left = paintbuffer.get(offset * 2); ! int right = paintbuffer.get(offset * 2 + 1); ! data = sc.data[sfx + i]; ! left += lscale[data]; ! right += rscale[data]; ! paintbuffer.put(offset * 2, left); ! paintbuffer.put(offset * 2 + 1, right); ! } ! ! ch.pos += count; ! } ! ! private static ByteBuffer bb; ! ! private static ShortBuffer sb; ! ! static void PaintChannelFrom16(channel_t ch, sfxcache_t sc, int count, ! int offset) { ! int data; ! int left, right; ! int leftvol, rightvol; ! int sfx; ! int i; ! portable_samplepair_t samp; ! ! leftvol = ch.leftvol * snd_vol; ! rightvol = ch.rightvol * snd_vol; ! ByteBuffer bb = ByteBuffer.wrap(sc.data); ! bb.order(ByteOrder.LITTLE_ENDIAN); ! sb = bb.asShortBuffer(); ! sfx = ch.pos; ! ! //samp = paintbuffer[offset]; ! for (i = 0; i < count; i++, offset++) { ! left = paintbuffer.get(offset * 2); ! right = paintbuffer.get(offset * 2 + 1); ! data = sb.get(sfx + i); ! left += (data * leftvol) >> 8; ! right += (data * rightvol) >> 8; ! paintbuffer.put(offset * 2, left); ! paintbuffer.put(offset * 2 + 1, right); ! } ! ! ch.pos += count; ! } } \ No newline at end of file Index: SND_DMA.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/jsound/SND_DMA.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SND_DMA.java 9 Jul 2004 06:50:48 -0000 1.1 --- SND_DMA.java 22 Sep 2004 19:22:09 -0000 1.2 *************** *** 6,37 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...2319 lines suppressed...] ! size = sc.length * sc.width * (sc.stereo + 1); ! total += size; ! if (sc.loopstart >= 0) ! Com.Printf("L"); ! else ! Com.Printf(" "); ! Com.Printf("(%2db) %6i : %s\n", new Vargs(3).add(sc.width * 8) ! .add(size).add(sfx.name)); ! } else { ! if (sfx.name.charAt(0) == '*') ! Com.Printf(" placeholder : " + sfx.name + "\n"); ! else ! Com.Printf(" not loaded : " + sfx.name + "\n"); ! } ! } ! Com.Printf("Total resident: " + total + "\n"); ! } ! ! } \ No newline at end of file |