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: Rene S. <sa...@us...> - 2005-12-27 21:02:43
|
Update of /cvsroot/jake2/jake2/src/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7724/src/jake2/qcommon Modified Files: Cvar.java PMove.java Log Message: code cleanups and beautification Index: PMove.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/PMove.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PMove.java 12 Jan 2005 12:14:16 -0000 1.6 --- PMove.java 27 Dec 2005 21:02:30 -0000 1.7 *************** *** 55,59 **** public static pmove_t pm; ! public static PMove.pml_t pml = new PMove.pml_t(); // movement parameters --- 55,59 ---- public static pmove_t pm; ! public static pml_t pml = new pml_t(); [...1977 lines suppressed...] else { float[] angles = { 0, 0, 0 }; ! Math3D.VectorCopy(pm.viewangles, angles); ! if (angles[Defines.PITCH] > 180) angles[Defines.PITCH] = angles[Defines.PITCH] - 360; + angles[Defines.PITCH] /= 3; ! Math3D.AngleVectors(angles, pml.forward, pml.right, pml.up); ! PM_AirMove(); } } // set groundentity, watertype, and waterlevel for final spot ! PM_CatagorizePosition(); PM_SnapPosition(); } Index: Cvar.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Cvar.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Cvar.java 26 May 2005 16:56:32 -0000 1.8 --- Cvar.java 27 Dec 2005 21:02:30 -0000 1.9 *************** *** 115,120 **** } ! /* ! * ============ Cvar_FullSet ============ */ public static cvar_t FullSet(String var_name, String value, int flags) { --- 115,120 ---- } ! /** ! * Creates a variable if not found and sets their value, the parsed float value and their flags. */ public static cvar_t FullSet(String var_name, String value, int flags) { *************** *** 143,148 **** } ! /* ! * ============ Cvar_Set ============ */ public static cvar_t Set(String var_name, String value) { --- 143,148 ---- } ! /** ! * Sets the value of the variable without forcing. */ public static cvar_t Set(String var_name, String value) { *************** *** 150,160 **** } ! /* ! * ============ Cvar_Set2 ============ */ static cvar_t Set2(String var_name, String value, boolean force) { cvar_t var = Cvar.FindVar(var_name); ! if (var == null) { // create it return Cvar.Get(var_name, value, 0); } --- 150,169 ---- } ! /** ! * Sets the value of the variable with forcing. ! */ ! public static cvar_t ForceSet(String var_name, String value) { ! return Cvar.Set2(var_name, value, true); ! } ! ! /** ! * Gereric set function, sets the value of the variable, with forcing its even possible to ! * override the variables write protection. */ static cvar_t Set2(String var_name, String value, boolean force) { cvar_t var = Cvar.FindVar(var_name); ! if (var == null) { ! // create it return Cvar.Get(var_name, value, 0); } *************** *** 177,181 **** if (value.equals(var.latched_string)) return var; - //Z_Free (var.latched_string); var.latched_string = null; } else { --- 186,189 ---- *************** *** 203,207 **** } else { if (var.latched_string != null) { - //Z_Free(var.latched_string); var.latched_string = null; } --- 211,214 ---- *************** *** 226,229 **** --- 233,240 ---- } + /** + * Set command, sets variables. + */ + static xcommand_t Set_f = new xcommand_t() { public void execute() { *************** *** 254,257 **** --- 265,271 ---- }; + /** + * List command, lists all available commands. + */ static xcommand_t List_f = new xcommand_t() { public void execute() { *************** *** 285,301 **** }; - /* - * ============ Cvar_ForceSet ============ - */ - public static cvar_t ForceSet(String var_name, String value) { - return Cvar.Set2(var_name, value, true); - } ! /* ! * ============ Cvar_SetValue ============ */ - // the overloading is very important - // there was a problem with networt "rate" string - // 10000 became "10000.0" and that wasn't right public static void SetValue(String var_name, int value) { Cvar.Set(var_name, "" + value); --- 299,310 ---- }; ! ! /** ! * Sets a float value of a variable. ! * ! * The overloading is very important, there was a problem with ! * networt "rate" string --> 10000 became "10000.0" and that wasn't right. */ public static void SetValue(String var_name, int value) { Cvar.Set(var_name, "" + value); *************** *** 310,315 **** } ! /* ! * ============ Cvar_VariableValue ============ */ public static float VariableValue(String var_name) { --- 319,324 ---- } ! /** ! * Returns the float value of a variable. */ public static float VariableValue(String var_name) { *************** *** 325,332 **** } ! /* ! * ============ Cvar_Command ! * ! * Handles variable inspection and changing from the console ============ */ public static boolean Command() { --- 334,339 ---- } ! /** ! * Handles variable inspection and changing from the console. */ public static boolean Command() { *************** *** 356,369 **** for (var = Globals.cvar_vars; var != null; var = var.next) { if ((var.flags & bit) != 0) ! info = Info.Info_SetValueForKey1(info, var.name, var.string); } return info; } ! // returns an info string containing all the CVAR_SERVERINFO cvars public static String Serverinfo() { return BitInfo(Defines.CVAR_SERVERINFO); } public static void GetLatchedVars() { cvar_t var; --- 363,382 ---- for (var = Globals.cvar_vars; var != null; var = var.next) { if ((var.flags & bit) != 0) ! info = Info.Info_SetValueForKey(info, var.name, var.string); } return info; } ! /** ! * Returns an info string containing all the CVAR_SERVERINFO cvars. ! */ public static String Serverinfo() { return BitInfo(Defines.CVAR_SERVERINFO); } + + /** + * Any variables with latched values will be updated. + */ public static void GetLatchedVars() { cvar_t var; *************** *** 387,395 **** /** ! * returns an info string containing all the CVAR_USERINFO cvars. */ public static String Userinfo() { return BitInfo(CVAR_USERINFO); } public static void WriteVariables(String path) { --- 400,413 ---- /** ! * Returns an info string containing all the CVAR_USERINFO cvars. */ public static String Userinfo() { return BitInfo(CVAR_USERINFO); } + + /** + * Appends lines containing \"set vaqriable value\" for all variables + * with the archive flag set true. + */ public static void WriteVariables(String path) { *************** *** 420,425 **** } ! /* ! * ============ Cvar_CompleteVariable ============ */ public static Vector CompleteVariable(String partial) { --- 438,443 ---- } ! /** ! * Variable typing auto completition. */ public static Vector CompleteVariable(String partial) { *************** *** 435,440 **** } ! /* ! * ============ Cvar_InfoValidate ============ */ static boolean InfoValidate(String s) { --- 453,458 ---- } ! /** ! * Some characters are invalid for info strings. */ static boolean InfoValidate(String s) { |
From: Rene S. <sa...@us...> - 2005-12-27 21:02:43
|
Update of /cvsroot/jake2/jake2/test/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7724/test/jake2/qcommon Modified Files: TestINFO.java Log Message: code cleanups and beautification Index: TestINFO.java =================================================================== RCS file: /cvsroot/jake2/jake2/test/jake2/qcommon/TestINFO.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestINFO.java 22 Sep 2004 19:22:10 -0000 1.2 --- TestINFO.java 27 Dec 2005 21:02:30 -0000 1.3 *************** *** 35,39 **** String test = "\\key1\\value 1\\key 2 \\value2\\key3\\ v a l u e 3\\key4\\val ue 4"; Info.Print(test); ! test = Info.Info_RemoveKey1(test, "key1"); Info.Print(test); } --- 35,39 ---- String test = "\\key1\\value 1\\key 2 \\value2\\key3\\ v a l u e 3\\key4\\val ue 4"; Info.Print(test); ! test = Info.Info_RemoveKey(test, "key1"); Info.Print(test); } |
From: Rene S. <sa...@us...> - 2005-12-27 21:02:42
|
Update of /cvsroot/jake2/jake2/src/jake2/game In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7724/src/jake2/game Modified Files: PlayerView.java PlayerClient.java GameAI.java GameUtil.java Info.java Log Message: code cleanups and beautification Index: PlayerView.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/PlayerView.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PlayerView.java 16 Nov 2005 22:24:52 -0000 1.4 --- PlayerView.java 27 Dec 2005 21:02:30 -0000 1.5 *************** *** 41,49 **** public static float[] up = { 0, 0, 0 }; ! /* ! * =============== ! * SV_CalcRoll ! * ! * =============== */ public static float SV_CalcRoll(float[] angles, float[] velocity) { --- 41,46 ---- public static float[] up = { 0, 0, 0 }; ! /** ! * SV_CalcRoll. */ public static float SV_CalcRoll(float[] angles, float[] velocity) { *************** *** 213,228 **** } ! /* ! * =============== ! * SV_CalcViewOffset ! * ! * Auto pitching on slopes? ! * ! * fall from 128: 400 = 160000 fall from 256: 580 = 336400 fall from 384: ! * 720 = 518400 fall from 512: 800 = 640000 fall from 640: 960 = * * damage = deltavelocity*deltavelocity * 0.0001 - * - * =============== */ public static void SV_CalcViewOffset(edict_t ent) { --- 210,221 ---- } ! /** * + * fall from 128: 400 = 160000 + * fall from 256: 580 = 336400 + * fall from 384: 720 = 518400 + * fall from 512: 800 = 640000 + * fall from 640: 960 = * damage = deltavelocity*deltavelocity * 0.0001 */ public static void SV_CalcViewOffset(edict_t ent) { *************** *** 233,238 **** float[] v = { 0, 0, 0 }; - //=================================== - // base angles angles = ent.client.ps.kick_angles; --- 226,229 ---- *************** *** 246,255 **** ent.client.ps.viewangles[Defines.YAW] = ent.client.killer_yaw; } else { // add angles based on weapon kick - Math3D.VectorCopy(ent.client.kick_angles, angles); // add angles based on damage kick - ratio = (ent.client.v_dmg_time - GameBase.level.time) / Defines.DAMAGE_TIME; --- 237,245 ---- ent.client.ps.viewangles[Defines.YAW] = ent.client.killer_yaw; } else { + // add angles based on weapon kick Math3D.VectorCopy(ent.client.kick_angles, angles); // add angles based on damage kick ratio = (ent.client.v_dmg_time - GameBase.level.time) / Defines.DAMAGE_TIME; *************** *** 263,267 **** // add pitch based on fall kick - ratio = (ent.client.fall_time - GameBase.level.time) / Defines.FALL_TIME; --- 253,256 ---- *************** *** 271,275 **** // add angles based on velocity - delta = Math3D.DotProduct(ent.velocity, forward); angles[Defines.PITCH] += delta * GameBase.run_pitch.value; --- 260,263 ---- *************** *** 279,283 **** // add angles based on bob - delta = bobfracsin * GameBase.bob_pitch.value * xyspeed; if ((ent.client.ps.pmove.pm_flags & pmove_t.PMF_DUCKED) != 0) --- 267,270 ---- *************** *** 292,307 **** } - //=================================== - // base origin - Math3D.VectorClear(v); // add view height - v[2] += ent.viewheight; // add fall height - ratio = (ent.client.fall_time - GameBase.level.time) / Defines.FALL_TIME; --- 279,289 ---- *************** *** 311,318 **** // add bob height - bob = bobfracsin * xyspeed * GameBase.bob_up.value; if (bob > 6) bob = 6; //gi.DebugGraph (bob *2, 255); v[2] += bob; --- 293,300 ---- // add bob height bob = bobfracsin * xyspeed * GameBase.bob_up.value; if (bob > 6) bob = 6; + //gi.DebugGraph (bob *2, 255); v[2] += bob; *************** *** 341,348 **** } ! /* ! * ============== ! * SV_CalcGunOffset ! * ============== */ public static void SV_CalcGunOffset(edict_t ent) { --- 323,328 ---- } ! /** ! * Calculates where to draw the gun. */ public static void SV_CalcGunOffset(edict_t ent) { *************** *** 388,395 **** } ! /* ! * ============= ! * SV_AddBlend ! * ============= */ public static void SV_AddBlend(float r, float g, float b, float a, --- 368,373 ---- } ! /** ! * Adds a blending effect to the clients view. */ public static void SV_AddBlend(float r, float g, float b, float a, *************** *** 408,415 **** } ! /* ! * ============= ! * SV_CalcBlend ! * ============= */ public static void SV_CalcBlend(edict_t ent) { --- 386,391 ---- } ! /** ! * Calculates the blending color according to the players environment. */ public static void SV_CalcBlend(edict_t ent) { *************** *** 439,454 **** remaining = (int) (ent.client.quad_framenum - GameBase.level.framenum); if (remaining == 30) // beginning to fade ! GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi ! .soundindex("items/damage2.wav"), 1, Defines.ATTN_NORM, ! 0); if (remaining > 30 || (remaining & 4) != 0) SV_AddBlend(0, 0, 1, 0.08f, ent.client.ps.blend); } else if (ent.client.invincible_framenum > GameBase.level.framenum) { ! remaining = (int) ent.client.invincible_framenum ! - GameBase.level.framenum; if (remaining == 30) // beginning to fade ! GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi ! .soundindex("items/protect2.wav"), 1, ! Defines.ATTN_NORM, 0); if (remaining > 30 || (remaining & 4) != 0) SV_AddBlend(1, 1, 0, 0.08f, ent.client.ps.blend); --- 415,427 ---- remaining = (int) (ent.client.quad_framenum - GameBase.level.framenum); if (remaining == 30) // beginning to fade ! GameBase.gi.sound(ent, Defines.CHAN_ITEM, ! GameBase.gi.soundindex("items/damage2.wav"), 1, Defines.ATTN_NORM, 0); if (remaining > 30 || (remaining & 4) != 0) SV_AddBlend(0, 0, 1, 0.08f, ent.client.ps.blend); } else if (ent.client.invincible_framenum > GameBase.level.framenum) { ! remaining = (int) ent.client.invincible_framenum - GameBase.level.framenum; if (remaining == 30) // beginning to fade ! GameBase.gi.sound(ent, Defines.CHAN_ITEM, ! GameBase.gi.soundindex("items/protect2.wav"), 1, Defines.ATTN_NORM, 0); if (remaining > 30 || (remaining & 4) != 0) SV_AddBlend(1, 1, 0, 0.08f, ent.client.ps.blend); *************** *** 457,463 **** - GameBase.level.framenum; if (remaining == 30) // beginning to fade ! GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi ! .soundindex("items/airout.wav"), 1, Defines.ATTN_NORM, ! 0); if (remaining > 30 || (remaining & 4) != 0) SV_AddBlend(0, 1, 0, 0.08f, ent.client.ps.blend); --- 430,435 ---- - GameBase.level.framenum; if (remaining == 30) // beginning to fade ! GameBase.gi.sound(ent, Defines.CHAN_ITEM, ! GameBase.gi.soundindex("items/airout.wav"), 1, Defines.ATTN_NORM, 0); if (remaining > 30 || (remaining & 4) != 0) SV_AddBlend(0, 1, 0, 0.08f, ent.client.ps.blend); *************** *** 494,501 **** } ! /* ! * ================= ! * P_FallingDamage ! * ================= */ public static void P_FallingDamage(edict_t ent) { --- 466,471 ---- } ! /** ! * Calculates damage and effect when a player falls down. */ public static void P_FallingDamage(edict_t ent) { *************** *** 567,574 **** } ! /* ! * ============= ! * P_WorldEffects ! * ============= */ public static void P_WorldEffects() { --- 537,542 ---- } ! /** ! * General effect handling for a player. */ public static void P_WorldEffects() { *************** *** 951,961 **** } ! /* ! * ================= ! * ClientEndServerFrame ! * * Called for each player at the end of the server frame and right after ! * spawning ! * ================= */ public static void ClientEndServerFrame(edict_t ent) { --- 919,926 ---- } ! ! /** * Called for each player at the end of the server frame and right after ! * spawning. */ public static void ClientEndServerFrame(edict_t ent) { Index: Info.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/Info.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Info.java 21 Oct 2004 03:32:53 -0000 1.5 --- Info.java 27 Dec 2005 21:02:31 -0000 1.6 *************** *** 20,24 **** --- 20,26 ---- // Created on 27.12.2003 by RST. + // $Id$ + package jake2.game; *************** *** 30,33 **** --- 32,38 ---- public class Info { + /** + * Returns a value for a key from an info string. + */ public static String Info_ValueForKey(String s, String key) { *************** *** 51,58 **** /** ! * 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) --- 56,62 ---- /** ! * Sets a value for a key in the user info string. */ ! public static String Info_SetValueForKey(String s, String key, String value) { if (value == null || value.length() == 0) *************** *** 80,84 **** } ! StringBuffer sb = new StringBuffer(Info_RemoveKey1(s, key)); if (sb.length() + 2 + key.length() + value.length() > Defines.MAX_INFO_STRING) { --- 84,88 ---- } ! StringBuffer sb = new StringBuffer(Info_RemoveKey(s, key)); if (sb.length() + 2 + key.length() + value.length() > Defines.MAX_INFO_STRING) { *************** *** 93,98 **** } ! /** TODO RST: DANGEROUS port, returns now the modified userinfo string. */ ! public static String Info_RemoveKey1(String s, String key) { StringBuffer sb = new StringBuffer(512); --- 97,104 ---- } ! /** ! * Removes a key and value from an info string. ! */ ! public static String Info_RemoveKey(String s, String key) { StringBuffer sb = new StringBuffer(512); *************** *** 120,152 **** 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) { ! return !((s.indexOf('"') != -1) || (s.indexOf(';') != -1)); } --- 126,137 ---- return sb.toString(); } ! /** * Some characters are illegal in info strings because they can mess up the ! * server's parsing. */ public static boolean Info_Validate(String s) { ! return !((s.indexOf('"') != -1) || (s.indexOf(';') != -1) || (s.indexOf('\\') != -1)); } *************** *** 176,207 **** 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 --- 161,167 ---- Index: GameAI.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameAI.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** GameAI.java 20 Nov 2005 22:18:33 -0000 1.9 --- GameAI.java 27 Dec 2005 21:02:30 -0000 1.10 *************** *** 38,46 **** } ! /* ! * ============= ai_turn ! * ! * don't move, but turn towards ideal_yaw Distance is for slight position ! * adjustments needed by the animations ============= */ public static void ai_turn(edict_t self, float dist) { --- 38,43 ---- } ! /** Don't move, but turn towards ideal_yaw Distance is for slight position ! * adjustments needed by the animations. */ public static void ai_turn(edict_t self, float dist) { *************** *** 53,83 **** M.M_ChangeYaw(self); } ! ! /* ! * ! * .enemy Will be world if not currently angry at anyone. ! * ! * .movetarget The next path spot to walk toward. If .enemy, ignore ! * .movetarget. When an enemy is killed, the monster will try to return to ! * it's path. ! * ! * .hunt_time Set to time + something when the player is in sight, but ! * movement straight for him is blocked. This causes the monster to use wall ! * following code for movement direction instead of sighting on the player. ! * ! * .ideal_yaw A yaw angle of the intended direction, which will be turned ! * towards at up to 45 deg / state. If the enemy is in view and hunt_time is ! * not active, this will be the exact line towards the enemy. ! * ! * .pausetime A monster will leave it's stand state and head towards it's ! * .movetarget when time > .pausetime. ! * ! * walkmove(angle, speed) primitive is all or nothing ! */ ! ! /* ! * ============ FacingIdeal ! * ! * ============ */ --- 50,56 ---- M.M_ChangeYaw(self); } ! ! /** ! * Checks, if the monster should turn left/right. */ *************** *** 91,99 **** } ! /* ! * ============= ai_run_melee ! * ! * Turn and close until within an angle to launch a melee attack ! * ============= */ public static void ai_run_melee(edict_t self) { --- 64,69 ---- } ! /** ! * Turn and close until within an angle to launch a melee attack. */ public static void ai_run_melee(edict_t self) { *************** *** 107,115 **** } ! /* ! * ============= ai_run_missile ! * ! * Turn in place until within an angle to launch a missile attack ! * ============= */ public static void ai_run_missile(edict_t self) { --- 77,82 ---- } ! /** ! * Turn in place until within an angle to launch a missile attack. */ public static void ai_run_missile(edict_t self) { *************** *** 123,130 **** }; ! /* ! * ============= ai_run_slide ! * ! * Strafe sideways, but stay at aproximately the same range ============= */ public static void ai_run_slide(edict_t self, float distance) { --- 90,95 ---- }; ! /** ! * Strafe sideways, but stay at aproximately the same range. */ public static void ai_run_slide(edict_t self, float distance) { *************** *** 146,154 **** } ! /* ! * ============= ai_checkattack ! * * Decides if we're going to attack or do something else used by ai_run and ! * ai_stand ============= */ public static boolean ai_checkattack(edict_t self, float dist) { --- 111,136 ---- } ! /** * Decides if we're going to attack or do something else used by ai_run and ! * ai_stand. ! * ! * .enemy Will be world if not currently angry at anyone. ! * ! * .movetarget The next path spot to walk toward. If .enemy, ignore ! * .movetarget. When an enemy is killed, the monster will try to return to ! * it's path. ! * ! * .hunt_time Set to time + something when the player is in sight, but ! * movement straight for him is blocked. This causes the monster to use wall ! * following code for movement direction instead of sighting on the player. ! * ! * .ideal_yaw A yaw angle of the intended direction, which will be turned ! * towards at up to 45 deg / state. If the enemy is in view and hunt_time is ! * not active, this will be the exact line towards the enemy. ! * ! * .pausetime A monster will leave it's stand state and head towards it's ! * .movetarget when time > .pausetime. ! * ! * walkmove(angle, speed) primitive is all or nothing */ public static boolean ai_checkattack(edict_t self, float dist) { *************** *** 157,161 **** boolean hesDeadJim; ! // this causes monsters to run blindly to the combat point w/o firing if (self.goalentity != null) { if ((self.monsterinfo.aiflags & Defines.AI_COMBAT_POINT) != 0) --- 139,143 ---- boolean hesDeadJim; ! // this causes monsters to run blindly to the combat point w/o firing if (self.goalentity != null) { if ((self.monsterinfo.aiflags & Defines.AI_COMBAT_POINT) != 0) *************** *** 181,185 **** enemy_vis = false; ! // see if the enemy is dead hesDeadJim = false; if ((null == self.enemy) || (!self.enemy.inuse)) { --- 163,167 ---- enemy_vis = false; ! // see if the enemy is dead hesDeadJim = false; if ((null == self.enemy) || (!self.enemy.inuse)) { *************** *** 224,230 **** self.show_hostile = (int) GameBase.level.time + 1; // wake up other ! // monsters ! ! // check knowledge of enemy enemy_vis = GameUtil.visible(self, self.enemy); if (enemy_vis) { --- 206,211 ---- self.show_hostile = (int) GameBase.level.time + 1; // wake up other ! ! // monsters check knowledge of enemy enemy_vis = GameUtil.visible(self, self.enemy); if (enemy_vis) { *************** *** 234,244 **** } - // look for other coop players here - // if (coop && self.monsterinfo.search_time < level.time) - // { - // if (FindTarget (self)) - // return true; - // } - enemy_infront = GameUtil.infront(self, self.enemy); enemy_range = GameUtil.range(self, self.enemy); --- 215,218 ---- *************** *** 266,270 **** /** * The monster is walking it's beat. - * */ static void ai_walk(edict_t self, float dist) { --- 240,243 ---- *************** *** 288,295 **** } ! /* ! * ================= ! * AI_SetSightClient ! * * Called once each frame to set level.sight_client to the player to be * checked for in findtarget. --- 261,265 ---- } ! /** * Called once each frame to set level.sight_client to the player to be * checked for in findtarget. *************** *** 298,302 **** * * In coop games, sight_client will cycle between the clients. - * ================= */ static void AI_SetSightClient() { --- 268,271 ---- *************** *** 328,338 **** } ! /* ! * ============= ! * ai_move ! * * Move the specified distance at current facing. This replaces the QC * functions: ai_forward, ai_back, ai_pain, and ai_painforward - * ============== */ static void ai_move(edict_t self, float dist) { --- 297,303 ---- } ! /** * Move the specified distance at current facing. This replaces the QC * functions: ai_forward, ai_back, ai_pain, and ai_painforward */ static void ai_move(edict_t self, float dist) { *************** *** 340,345 **** } ! // ============================================================================ ! //ok static void HuntTarget(edict_t self) { float[] vec = { 0, 0, 0 }; --- 305,312 ---- } ! ! /** ! * Decides running or standing according to flag AI_STAND_GROUND. ! */ static void HuntTarget(edict_t self) { float[] vec = { 0, 0, 0 }; *************** *** 352,355 **** --- 319,323 ---- Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, vec); self.ideal_yaw = Math3D.vectoyaw(vec); + // wait a while before first attack if (0 == (self.monsterinfo.aiflags & Defines.AI_STAND_GROUND)) *************** *** 357,360 **** --- 325,329 ---- } + public static EntThinkAdapter walkmonster_start_go = new EntThinkAdapter() { public String getID() { return "walkmonster_start_go"; } *************** *** 447,456 **** }; ! /* ! * ============= ai_turn ! * ! * don't move, but turn towards ideal_yaw Distance is for slight position * adjustments needed by the animations - * ============= */ public static AIAdapter ai_turn = new AIAdapter() { --- 416,423 ---- }; ! ! /** ! * Don't move, but turn towards ideal_yaw Distance is for slight position * adjustments needed by the animations */ public static AIAdapter ai_turn = new AIAdapter() { *************** *** 468,478 **** }; ! /* ! * ============= ! * ai_move ! * * Move the specified distance at current facing. This replaces the QC * functions: ai_forward, ai_back, ai_pain, and ai_painforward - * ============== */ public static AIAdapter ai_move = new AIAdapter() { --- 435,442 ---- }; ! ! /** * Move the specified distance at current facing. This replaces the QC * functions: ai_forward, ai_back, ai_pain, and ai_painforward */ public static AIAdapter ai_move = new AIAdapter() { *************** *** 483,499 **** }; ! /* ! * ============= ! * ai_walk ! * ! * The monster is walking it's beat ! * ============= */ public static AIAdapter ai_walk = new AIAdapter() { public String getID() { return "ai_walk";} public void ai(edict_t self, float dist) { - if (self.index == 312) - self.index = 312; - M.M_MoveToGoal(self, dist); --- 447,457 ---- }; ! ! /** ! * The monster is walking it's beat. */ public static AIAdapter ai_walk = new AIAdapter() { public String getID() { return "ai_walk";} public void ai(edict_t self, float dist) { M.M_MoveToGoal(self, dist); *************** *** 506,514 **** if (self.monsterinfo.idle_time != 0) { self.monsterinfo.search.think(self); ! self.monsterinfo.idle_time = GameBase.level.time + 15 ! + Globals.rnd.nextFloat() * 15; } else { ! self.monsterinfo.idle_time = GameBase.level.time ! + Globals.rnd.nextFloat() * 15; } } --- 464,470 ---- if (self.monsterinfo.idle_time != 0) { self.monsterinfo.search.think(self); ! self.monsterinfo.idle_time = GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15; } else { ! self.monsterinfo.idle_time = GameBase.level.time + Globals.rnd.nextFloat() * 15; } } *************** *** 516,526 **** }; ! /* ! * ============= ! * ai_stand ! * * Used for standing around and looking for players Distance is for slight ! * position adjustments needed by the animations ! * ============== */ --- 472,479 ---- }; ! ! /** * Used for standing around and looking for players Distance is for slight ! * position adjustments needed by the animations. */ *************** *** 535,541 **** if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) { if (self.enemy != null) { ! Math3D ! .VectorSubtract(self.enemy.s.origin, self.s.origin, ! v); self.ideal_yaw = Math3D.vectoyaw(v); if (self.s.angles[Defines.YAW] != self.ideal_yaw --- 488,492 ---- if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) { if (self.enemy != null) { ! Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, v); self.ideal_yaw = Math3D.vectoyaw(v); if (self.s.angles[Defines.YAW] != self.ideal_yaw *************** *** 563,571 **** if (self.monsterinfo.idle_time != 0) { self.monsterinfo.idle.think(self); ! self.monsterinfo.idle_time = GameBase.level.time + 15 ! + Globals.rnd.nextFloat() * 15; } else { ! self.monsterinfo.idle_time = GameBase.level.time ! + Globals.rnd.nextFloat() * 15; } } --- 514,520 ---- if (self.monsterinfo.idle_time != 0) { self.monsterinfo.idle.think(self); ! self.monsterinfo.idle_time = GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15; } else { ! self.monsterinfo.idle_time = GameBase.level.time + Globals.rnd.nextFloat() * 15; } } *************** *** 573,583 **** }; ! /* ! * ============= ! * ai_charge ! * * Turns towards target and advances Use this call with a distnace of 0 to ! * replace ai_face ! * ============== */ public static AIAdapter ai_charge = new AIAdapter() { --- 522,528 ---- }; ! /** * Turns towards target and advances Use this call with a distnace of 0 to ! * replace ai_face. */ public static AIAdapter ai_charge = new AIAdapter() { *************** *** 595,604 **** }; ! /* ! * ============= ! * ai_run ! * ! * The monster has an enemy it is trying to kill ! * ============= */ public static AIAdapter ai_run = new AIAdapter() { --- 540,546 ---- }; ! ! /** ! * The monster has an enemy it is trying to kill. */ public static AIAdapter ai_run = new AIAdapter() { *************** *** 623,627 **** } - // rst: monster heard a sound.... if ((self.monsterinfo.aiflags & Defines.AI_SOUND_TARGET) != 0) { Math3D.VectorSubtract(self.s.origin, self.enemy.s.origin, v); --- 565,568 ---- *************** *** 653,667 **** if (enemy_vis) { ! // if (self.aiflags & AI_LOST_SIGHT) ! // dprint("regained sight\n"); M.M_MoveToGoal(self, dist); self.monsterinfo.aiflags &= ~Defines.AI_LOST_SIGHT; ! Math3D.VectorCopy(self.enemy.s.origin, ! self.monsterinfo.last_sighting); self.monsterinfo.trail_time = GameBase.level.time; return; } ! // coop will change to another enemy if visible^ if (GameBase.coop.value != 0) { // FIXME: insane guys get mad with this, which causes crashes! --- 594,607 ---- if (enemy_vis) { ! //if (self.aiflags & AI_LOST_SIGHT) ! // dprint("regained sight\n"); M.M_MoveToGoal(self, dist); self.monsterinfo.aiflags &= ~Defines.AI_LOST_SIGHT; ! Math3D.VectorCopy(self.enemy.s.origin, self.monsterinfo.last_sighting); self.monsterinfo.trail_time = GameBase.level.time; return; } ! // coop will change to another enemy if visible if (GameBase.coop.value != 0) { // FIXME: insane guys get mad with this, which causes crashes! *************** *** 687,692 **** if (0 == (self.monsterinfo.aiflags & Defines.AI_LOST_SIGHT)) { // just lost sight of the player, decide where to go first ! // dprint("lost sight of player, last seen at "); ! // dprint(vtos(self.last_sighting)); dprint("\n"); self.monsterinfo.aiflags |= (Defines.AI_LOST_SIGHT | Defines.AI_PURSUIT_LAST_SEEN); self.monsterinfo.aiflags &= ~(Defines.AI_PURSUE_NEXT | Defines.AI_PURSUE_TEMP); --- 627,633 ---- if (0 == (self.monsterinfo.aiflags & Defines.AI_LOST_SIGHT)) { // just lost sight of the player, decide where to go first ! // dprint("lost sight of player, last seen at "); ! // dprint(vtos(self.last_sighting)); ! // dprint("\n"); self.monsterinfo.aiflags |= (Defines.AI_LOST_SIGHT | Defines.AI_PURSUIT_LAST_SEEN); self.monsterinfo.aiflags &= ~(Defines.AI_PURSUE_NEXT | Defines.AI_PURSUE_TEMP); *************** *** 696,701 **** if ((self.monsterinfo.aiflags & Defines.AI_PURSUE_NEXT) != 0) { self.monsterinfo.aiflags &= ~Defines.AI_PURSUE_NEXT; ! // dprint("reached current goal: "); dprint(vtos(self.origin)); ! // dprint(" "); dprint(vtos(self.last_sighting)); dprint(" "); // dprint(ftos(vlen(self.origin - self.last_sighting))); // dprint("\n"); --- 637,646 ---- if ((self.monsterinfo.aiflags & Defines.AI_PURSUE_NEXT) != 0) { self.monsterinfo.aiflags &= ~Defines.AI_PURSUE_NEXT; ! ! // dprint("reached current goal: "); ! // dprint(vtos(self.origin)); ! // dprint(" "); ! // dprint(vtos(self.last_sighting)); ! // dprint(" "); // dprint(ftos(vlen(self.origin - self.last_sighting))); // dprint("\n"); *************** *** 705,713 **** if ((self.monsterinfo.aiflags & Defines.AI_PURSUE_TEMP) != 0) { ! // dprint("was temp goal; retrying original\n"); self.monsterinfo.aiflags &= ~Defines.AI_PURSUE_TEMP; marker = null; ! Math3D.VectorCopy(self.monsterinfo.saved_goal, ! self.monsterinfo.last_sighting); new1 = true; } else if ((self.monsterinfo.aiflags & Defines.AI_PURSUIT_LAST_SEEN) != 0) { --- 650,657 ---- if ((self.monsterinfo.aiflags & Defines.AI_PURSUE_TEMP) != 0) { ! // dprint("was temp goal; retrying original\n"); self.monsterinfo.aiflags &= ~Defines.AI_PURSUE_TEMP; marker = null; ! Math3D.VectorCopy(self.monsterinfo.saved_goal, self.monsterinfo.last_sighting); new1 = true; } else if ((self.monsterinfo.aiflags & Defines.AI_PURSUIT_LAST_SEEN) != 0) { *************** *** 719,736 **** if (marker != null) { ! Math3D.VectorCopy(marker.s.origin, ! self.monsterinfo.last_sighting); self.monsterinfo.trail_time = marker.timestamp; self.s.angles[Defines.YAW] = self.ideal_yaw = marker.s.angles[Defines.YAW]; ! // dprint("heading is "); dprint(ftos(self.ideal_yaw)); // dprint("\n"); ! ! // debug_drawline(self.origin, self.last_sighting, 52); new1 = true; } } ! Math3D.VectorSubtract(self.s.origin, ! self.monsterinfo.last_sighting, v); d1 = Math3D.VectorLength(v); if (d1 <= dist) { --- 663,678 ---- if (marker != null) { ! Math3D.VectorCopy(marker.s.origin, self.monsterinfo.last_sighting); self.monsterinfo.trail_time = marker.timestamp; self.s.angles[Defines.YAW] = self.ideal_yaw = marker.s.angles[Defines.YAW]; ! // dprint("heading is "); ! // dprint(ftos(self.ideal_yaw)); // dprint("\n"); ! // debug_drawline(self.origin, self.last_sighting, 52); new1 = true; } } ! Math3D.VectorSubtract(self.s.origin, self.monsterinfo.last_sighting, v); d1 = Math3D.VectorLength(v); if (d1 <= dist) { *************** *** 739,747 **** } ! Math3D.VectorCopy(self.monsterinfo.last_sighting, ! self.goalentity.s.origin); if (new1) { ! // gi.dprintf("checking for course correction\n"); tr = GameBase.gi.trace(self.s.origin, self.mins, self.maxs, --- 681,688 ---- } ! Math3D.VectorCopy(self.monsterinfo.last_sighting, self.goalentity.s.origin); if (new1) { ! // gi.dprintf("checking for course correction\n"); tr = GameBase.gi.trace(self.s.origin, self.mins, self.maxs, *************** *** 749,766 **** Defines.MASK_PLAYERSOLID); if (tr.fraction < 1) { ! Math3D.VectorSubtract(self.goalentity.s.origin, ! self.s.origin, v); d1 = Math3D.VectorLength(v); center = tr.fraction; d2 = d1 * ((center + 1) / 2); ! self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D ! .vectoyaw(v); ! Math3D ! .AngleVectors(self.s.angles, v_forward, v_right, ! null); Math3D.VectorSet(v, d2, -16, 0); ! Math3D.G_ProjectSource(self.s.origin, v, v_forward, ! v_right, left_target); tr = GameBase.gi.trace(self.s.origin, self.mins, self.maxs, left_target, self, Defines.MASK_PLAYERSOLID); --- 690,702 ---- Defines.MASK_PLAYERSOLID); if (tr.fraction < 1) { ! Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v); d1 = Math3D.VectorLength(v); center = tr.fraction; d2 = d1 * ((center + 1) / 2); ! self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D.vectoyaw(v); ! Math3D.AngleVectors(self.s.angles, v_forward, v_right, null); Math3D.VectorSet(v, d2, -16, 0); ! Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, left_target); tr = GameBase.gi.trace(self.s.origin, self.mins, self.maxs, left_target, self, Defines.MASK_PLAYERSOLID); *************** *** 780,800 **** Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, left_target); ! // gi.dprintf("incomplete path, go part way and ! // adjust again\n"); } ! Math3D.VectorCopy(self.monsterinfo.last_sighting, ! self.monsterinfo.saved_goal); self.monsterinfo.aiflags |= Defines.AI_PURSUE_TEMP; ! Math3D ! .VectorCopy(left_target, ! self.goalentity.s.origin); ! Math3D.VectorCopy(left_target, ! self.monsterinfo.last_sighting); ! Math3D.VectorSubtract(self.goalentity.s.origin, ! self.s.origin, v); ! self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D ! .vectoyaw(v); ! // gi.dprintf("adjusted left\n"); ! // debug_drawline(self.origin, self.last_sighting, 152); } else if (right >= center && right > left) { if (right < 1) { --- 716,729 ---- Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, left_target); ! // gi.dprintf("incomplete path, go part way and adjust again\n"); } ! Math3D.VectorCopy(self.monsterinfo.last_sighting, self.monsterinfo.saved_goal); self.monsterinfo.aiflags |= Defines.AI_PURSUE_TEMP; ! Math3D.VectorCopy(left_target, self.goalentity.s.origin); ! Math3D.VectorCopy(left_target, self.monsterinfo.last_sighting); ! Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v); ! self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D.vectoyaw(v); ! // gi.dprintf("adjusted left\n"); ! // debug_drawline(self.origin, self.last_sighting, 152); } else if (right >= center && right > left) { if (right < 1) { *************** *** 802,819 **** Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, right_target); ! // gi.dprintf("incomplete path, go part way and ! // adjust again\n"); } ! Math3D.VectorCopy(self.monsterinfo.last_sighting, ! self.monsterinfo.saved_goal); self.monsterinfo.aiflags |= Defines.AI_PURSUE_TEMP; ! Math3D.VectorCopy(right_target, ! self.goalentity.s.origin); ! Math3D.VectorCopy(right_target, ! self.monsterinfo.last_sighting); ! Math3D.VectorSubtract(self.goalentity.s.origin, ! self.s.origin, v); ! self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D ! .vectoyaw(v); // gi.dprintf("adjusted right\n"); // debug_drawline(self.origin, self.last_sighting, 152); --- 731,742 ---- Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, right_target); ! // gi.dprintf("incomplete path, go part way and adjust again\n"); } ! Math3D.VectorCopy(self.monsterinfo.last_sighting, self.monsterinfo.saved_goal); self.monsterinfo.aiflags |= Defines.AI_PURSUE_TEMP; ! Math3D.VectorCopy(right_target, self.goalentity.s.origin); ! Math3D.VectorCopy(right_target, self.monsterinfo.last_sighting); ! Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v); ! self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D.vectoyaw(v); // gi.dprintf("adjusted right\n"); // debug_drawline(self.origin, self.last_sighting, 152); Index: GameUtil.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameUtil.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** GameUtil.java 20 Nov 2005 22:18:33 -0000 1.14 --- GameUtil.java 27 Dec 2005 21:02:31 -0000 1.15 *************** *** 41,46 **** } ! /** ! * the global "activator" should be set to the entity that initiated the * firing. * --- 41,48 ---- } ! /** ! * Use the targets. ! * ! * The global "activator" should be set to the entity that initiated the * firing. * *************** *** 59,65 **** checkClassname(ent); ! // ! // check for a delay ! // if (ent.delay != 0) { // create a temp object to fire at a later time --- 61,65 ---- checkClassname(ent); ! // check for a delay if (ent.delay != 0) { // create a temp object to fire at a later time *************** *** 77,83 **** } ! // ! // print the message ! // if ((ent.message != null) && (activator.svflags & Defines.SVF_MONSTER) == 0) { --- 77,82 ---- } ! ! // print the message if ((ent.message != null) && (activator.svflags & Defines.SVF_MONSTER) == 0) { *************** *** 91,98 **** } - // // kill killtargets - // - EdictIterator edit = null; --- 90,94 ---- *************** *** 111,115 **** // fire targets - if (ent.target != null) { edit = null; --- 107,110 ---- *************** *** 187,197 **** //if ((ed - g_edicts) <= (maxclients.value + BODY_QUEUE_SIZE)) if (ed.index <= (GameBase.maxclients.value + Defines.BODY_QUEUE_SIZE)) { ! // gi.dprintf("tried to free special edict\n"); return; } - //memset(ed, 0, sizeof(* ed)); GameBase.g_edicts[ed.index] = new edict_t(ed.index); - //ed.clear(); ed.classname = "freed"; ed.freetime = GameBase.level.time; --- 182,190 ---- //if ((ed - g_edicts) <= (maxclients.value + BODY_QUEUE_SIZE)) if (ed.index <= (GameBase.maxclients.value + Defines.BODY_QUEUE_SIZE)) { ! // gi.dprintf("tried to free special edict\n"); return; } GameBase.g_edicts[ed.index] = new edict_t(ed.index); ed.classname = "freed"; ed.freetime = GameBase.level.time; *************** *** 209,232 **** } - public static void G_TouchSolids(edict_t ent) { - int i, num; - edict_t touch[] = new edict_t[Defines.MAX_EDICTS], hit; - - num = GameBase.gi.BoxEdicts(ent.absmin, ent.absmax, touch, - Defines.MAX_EDICTS, Defines.AREA_SOLID); - - // be careful, it is possible to have an entity in this - // list removed before we get to it (killtriggered) - for (i = 0; i < num; i++) { - hit = touch[i]; - if (!hit.inuse) - continue; - if (ent.touch != null) { - ent.touch.touch(hit, ent, GameBase.dummyplane, null); - } - if (!ent.inuse) - break; - } - } /** --- 202,205 ---- *************** *** 257,260 **** --- 230,236 ---- } + /** + * Returns true, if two edicts are on the same team. + */ public static boolean OnSameTeam(edict_t ent1, edict_t ent2) { if (0 == ((int) (GameBase.dmflags.value) & (Defines.DF_MODELTEAMS | Defines.DF_SKINTEAMS))) *************** *** 266,269 **** --- 242,249 ---- } + /** + * Returns the team string of an entity + * with respect to rteam_by_model and team_by_skin. + */ static String ClientTeam(edict_t ent) { String value; *************** *** 297,307 **** } ! /* ! * ============= range ! * ! * returns the range catagorization of an entity reletive to self 0 melee * range, will become hostile even if back is turned 1 visibility and * infront, or visibility and show hostile 2 infront and show hostile 3 only ! * triggered by damage ============= */ public static int range(edict_t self, edict_t other) { --- 277,285 ---- } ! /** ! * Returns the range catagorization of an entity reletive to self 0 melee * range, will become hostile even if back is turned 1 visibility and * infront, or visibility and show hostile 2 infront and show hostile 3 only ! * triggered by damage. */ public static int range(edict_t self, edict_t other) { *************** *** 324,331 **** } ! /* ! * ============= infront ! * ! * returns true if the entity is in front (in sight) of self ============= */ public static boolean infront(edict_t self, edict_t other) { --- 302,307 ---- } ! /** ! * Returns true if the entity is in front (in sight) of self */ public static boolean infront(edict_t self, edict_t other) { *************** *** 344,352 **** } ! /* ! * ============= visible ! * ! * returns 1 if the entity is visible to self, even if not infront () ! * ============= */ public static boolean visible(edict_t self, edict_t other) { --- 320,325 ---- } ! /** ! * Returns 1 if the entity is visible to self, even if not infront(). */ public static boolean visible(edict_t self, edict_t other) { *************** *** 367,372 **** } ! /* ! * =========== FindTarget * * Self is currently not attacking anything, so try to find a target --- 340,345 ---- } ! /** ! * Finds a target. * * Self is currently not attacking anything, so try to find a target *************** *** 380,384 **** * To avoid spending too much time, only a single client (or fakeclient) is * checked each frame. This means multi player games will have slightly ! * slower noticing monsters. ============ */ static boolean FindTarget(edict_t self) { --- 353,357 ---- * To avoid spending too much time, only a single client (or fakeclient) is * checked each frame. This means multi player games will have slightly ! * slower noticing monsters. */ static boolean FindTarget(edict_t self) { *************** *** 387,395 **** int r; ! if ((self.monsterinfo.aiflags & Defines.AI_GOOD_GUY) != 0) ! { if (self.goalentity != null && self.goalentity.inuse ! && self.goalentity.classname != null) ! { if (self.goalentity.classname.equals("target_actor")) return false; --- 360,366 ---- int r; ! if ((self.monsterinfo.aiflags & Defines.AI_GOOD_GUY) != 0) { if (self.goalentity != null && self.goalentity.inuse ! && self.goalentity.classname != null) { if (self.goalentity.classname.equals("target_actor")) return false; *************** *** 524,531 **** self.enemy = client; } ! ! // ! // got one ! // FoundTarget(self); --- 495,500 ---- self.enemy = client; } ! ! // got one FoundTarget(self); *************** *** 615,644 **** }; ! /* ! * ============= ! * range ! * ! * returns the range catagorization of an entity reletive to self. 0 melee ! * range, will become hostile even if back is turned 1 visibility and ! * infront, or visibility and show hostile 2 infront and show hostile 3 only ! * triggered by damage ! * ! */ ! // static int range(edict_t self, edict_t other) ! // { ! // float[] v= { 0, 0, 0 }; ! // float len; ! // ! // VectorSubtract(self.s.origin, other.s.origin, v); ! // len= VectorLength(v); ! // if (len < MELEE_DISTANCE) ! // return RANGE_MELEE; ! // if (len < 500) ! // return RANGE_NEAR; ! // if (len < 1000) ! // return RANGE_MID; ! // return RANGE_FAR; ! // } ! // ============================================================================ public static EntThinkAdapter M_CheckAttack = new EntThinkAdapter() { public String getID() { return "M_CheckAttack"; } --- 584,588 ---- }; ! public static EntThinkAdapter M_CheckAttack = new EntThinkAdapter() { public String getID() { return "M_CheckAttack"; } *************** *** 681,685 **** } ! // missile attack if (self.monsterinfo.attack == null) return false; --- 625,629 ---- } ! // missile attack if (self.monsterinfo.attack == null) return false; Index: PlayerClient.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/PlayerClient.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PlayerClient.java 20 Nov 2005 22:18:33 -0000 1.11 --- PlayerClient.java 27 Dec 2005 21:02:30 -0000 1.12 *************** *** 34,41 **** public static int player_die_i = 0; ! /* ! * ================== ! * player_die ! * ================== */ static EntDieAdapter player_die = new EntDieAdapter() { --- 34,40 ---- public static int player_die_i = 0; ! ! /** ! * player_die. */ static EntDieAdapter player_die = new EntDieAdapter() { *************** *** 60,64 **** self.maxs[2] = -8; ! // self.solid = SOLID_NOT; self.svflags |= Defines.SVF_DEADMONSTER; --- 59,63 ---- self.maxs[2] = -8; ! // self.solid = SOLID_NOT; self.svflags |= Defines.SVF_DEADMONSTER; *************** *** 162,166 **** if ((self.targetname == null) || Lib.Q_stricmp(self.targetname, spot.targetname) != 0) { ! // gi.dprintf("FixCoopSpots changed %s at %s targetname // from %s to %s\n", self.classname, // vtos(self.s.origin), self.targetname, --- 161,165 ---- if ((self.targetname == null) || Lib.Q_stricmp(self.targetname, spot.targetname) != 0) { ! // gi.dprintf("FixCoopSpots changed %s at %s targetname // from %s to %s\n", self.classname, // vtos(self.s.origin), self.targetname, *************** *** 221,231 **** if (self.health < -40) { ! GameBase.gi ! .sound(self, Defines.CHAN_BODY, GameBase.gi ! .soundindex("misc/udeath.wav"), 1, ! Defines.ATTN_NORM, 0); for (n = 0; n < 4; n++) ! GameMisc.ThrowGib(self, ! "models/objects/gibs/sm_meat/tris.md2", damage, Defines.GIB_ORGANIC); self.s.origin[2] -= 48; --- 220,227 ---- if (self.health < -40) { ! GameBase.gi.sound(self, Defines.CHAN_BODY, ! GameBase.gi.soundindex("misc/udeath.wav"), 1, Defines.ATTN_NORM, 0); for (n = 0; n < 4; n++) ! GameMisc.ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, Defines.GIB_ORGANIC); self.s.origin[2] -= 48; *************** *** 251,255 **** }; ! /* * QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 32) The normal * starting point for a level. --- 247,251 ---- }; ! /** * QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 32) The normal * starting point for a level. *************** *** 265,271 **** } ! /* * QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 32) potential ! * spawning position for deathmatch games */ public static void SP_info_player_deathmatch(edict_t self) { --- 261,267 ---- } ! /** * QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 32) potential ! * spawning position for deathmatch games. */ public static void SP_info_player_deathmatch(edict_t self) { *************** *** 277,283 **** } ! /* * QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 32) potential ! * spawning position for coop games */ --- 273,279 ---- } ! /** * QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 32) potential ! * spawning position for coop games. */ *************** *** 308,312 **** } ! /* * QUAKED info_player_intermission (1 0 1) (-16 -16 -24) (16 16 32) The * deathmatch intermission point will be at one of these Use 'angles' --- 304,308 ---- } ! /** * QUAKED info_player_intermission (1 0 1) (-16 -16 -24) (16 16 32) The * deathmatch intermission point will be at one of these Use 'angles' *************** *** 509,520 **** } ! //======================================================================= ! /* ! * ============== ! * InitClientPersistant ! * * This is only called when the game first initializes in single player, but ! * is called after each death and level change in deathmatch ! * ============== */ public static void InitClientPersistant(gclient_t client) { --- 505,511 ---- } ! /** * This is only called when the game first initializes in single player, but ! * is called after each death and level change in deathmatch. */ public static void InitClientPersistant(gclient_t client) { *************** *** 555,566 **** } ! /* ! * ================== ! * SaveClientData ! * * Some information that should be persistant, like health, is still stored * in the edict structure, so it needs to be mirrored out to the client * structure before all the edicts are wiped. - * ================== */ public static void SaveClientData() { --- 546,553 ---- } ! /** * Some information that should be persistant, like health, is still stored * in the edict structure, so it needs to be mirrored out to the client * structure before all the edicts are wiped. */ public static void SaveClientData() { *************** *** 591,600 **** } ! /* ! * ================ ! * PlayersRangeFromSpot ! * ! * Returns the distance to the nearest player from the given spot ! * ================ */ static float PlayersRangeFromSpot(edict_t spot) { --- 578,583 ---- } ! /** ! * Returns the distance to the nearest player from the given spot. */ static float PlayersRangeFromSpot(edict_t spot) { *************** *** 626,635 **** } ! /* ! * ================ ! * SelectRandomDeathmatchSpawnPoint ! * ! * go to a random point, but NOT the two points closest to other players ! * ================ */ public static edict_t SelectRandomDeathmatchSpawnPoint() { --- 609,614 ---- } ! /** ! * Go to a random point, but NOT the two points closest to other players. */ public static edict_t SelectRandomDeathmatchSpawnPoint() { *************** *** 686,694 **** } ! /* ! * ================ ! * SelectFarthestDeathmatchSpawnPoint ! * ! * ================ */ static edict_t SelectFarthestDeathmatchSpawnPoint() { --- 665,670 ---- } ! /** ! * If turned on in the dmflags, select a spawn point far away from other players. */ static edict_t SelectFarthestDeathmatchSpawnPoint() { *************** *** 703,707 **** EdictIterator es = null; while ((es = GameBase.G_Find(es, GameBase.findByClass, ! "info_player_deathmatch")).o != null) { spot = es.o; bestplayerdistance = PlayersRangeFromSpot(spot); --- 679,683 ---- EdictIterator es = null; while ((es = GameBase.G_Find(es, GameBase.findByClass, ! "info_player_deathmatch")) != null) { spot = es.o; bestplayerdistance = PlayersRangeFromSpot(spot); *************** *** 727,730 **** --- 703,707 ---- } + public static edict_t SelectDeathmatchSpawnPoint() { if (0 != ((int) (GameBase.dmflags.value) & Defines.DF_SPAWN_FARTHEST)) *************** *** 755,759 **** "info_player_coop"); - // nullpointer exi fixed (RST). if (es == null) return null; --- 732,735 ---- *************** *** 777,786 **** } ! /* ! * =========== ! * SelectSpawnPoint ! * ! * Chooses a player start, deathmatch start, coop start, etc ! * ============ */ public static void SelectSpawnPoint(edict_t ent, float[] origin, --- 753,758 ---- } ! /** ! * Chooses a player start, deathmatch start, coop start, etc. */ public static void SelectSpawnPoint(edict_t ent, float[] origin, *************** *** 836,840 **** } - //====================================================================== public static void InitBodyQue() { --- 808,811 ---- *************** *** 914,919 **** } ! /* ! * only ca... [truncated message content] |
From: Rene S. <sa...@us...> - 2005-12-27 21:02:42
|
Update of /cvsroot/jake2/jake2/src/jake2/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7724/src/jake2/server Modified Files: SV_MAIN.java SV_ENTS.java Log Message: code cleanups and beautification Index: SV_ENTS.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_ENTS.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SV_ENTS.java 3 Dec 2005 19:46:17 -0000 1.6 --- SV_ENTS.java 27 Dec 2005 21:02:30 -0000 1.7 *************** *** 20,24 **** --- 20,26 ---- // Created on 17.01.2004 by RST. + // $Id$ + package jake2.server; *************** *** 32,36 **** public class SV_ENTS { ! /* * ============================================================================= * --- 34,38 ---- public class SV_ENTS { ! /** * ============================================================================= * *************** *** 50,58 **** */ ! /* ! * ============= SV_EmitPacketEntities ! * * Writes a delta update of an entity_state_t list to the message. - * ============= */ static void SV_EmitPacketEntities(client_frame_t from, client_frame_t to, --- 52,57 ---- */ ! /** * Writes a delta update of an entity_state_t list to the message. */ static void SV_EmitPacketEntities(client_frame_t from, client_frame_t to, *************** *** 90,98 **** } ! if (newnum == oldnum) { // delta update from old position // because the force parm is false, this will not result // in any bytes being emited if the entity has not changed at ! // all ! // note that players are always 'newentities', this updates // their oldorigin always // and prevents warping --- 89,97 ---- } ! if (newnum == oldnum) { ! // delta update from old position // because the force parm is false, this will not result // in any bytes being emited if the entity has not changed at ! // all note that players are always 'newentities', this updates // their oldorigin always // and prevents warping *************** *** 104,109 **** } ! if (newnum < oldnum) { // this is a new entity, send it from the ! // baseline MSG.WriteDeltaEntity(SV_INIT.sv.baselines[newnum], newent, msg, true, true); --- 103,108 ---- } ! if (newnum < oldnum) { ! // this is a new entity, send it from the baseline MSG.WriteDeltaEntity(SV_INIT.sv.baselines[newnum], newent, msg, true, true); *************** *** 112,117 **** } ! if (newnum > oldnum) { // the old entity isn't present in the new ! // message bits = Defines.U_REMOVE; if (oldnum >= 256) --- 111,116 ---- } ! if (newnum > oldnum) { ! // the old entity isn't present in the new message bits = Defines.U_REMOVE; if (oldnum >= 256) *************** *** 136,143 **** } ! /* ! * ============= SV_WritePlayerstateToClient ! * ! * ============= */ static void SV_WritePlayerstateToClient(client_frame_t from, --- 135,140 ---- } ! /** ! * Writes the status of a player to a client system. */ static void SV_WritePlayerstateToClient(client_frame_t from, *************** *** 159,165 **** ops = from.ps; - // // determine what needs to be sent - // pflags = 0; --- 156,160 ---- *************** *** 221,233 **** pflags |= Defines.PS_WEAPONINDEX; - // // write it - // MSG.WriteByte(msg, Defines.svc_playerinfo); MSG.WriteShort(msg, pflags); - // // write the pmove_state_t - // if ((pflags & Defines.PS_M_TYPE) != 0) MSG.WriteByte(msg, ps.pmove.pm_type); --- 216,224 ---- *************** *** 260,266 **** } - // // write the rest of the player_state_t - // if ((pflags & Defines.PS_VIEWOFFSET) != 0) { MSG.WriteChar(msg, ps.viewoffset[0] * 4); --- 251,255 ---- *************** *** 317,322 **** } ! /* ! * ================== SV_WriteFrameToClient ================== */ public static void SV_WriteFrameToClient(client_t client, sizebuf_t msg) { --- 306,311 ---- } ! /** ! * Writes a frame to a client system. */ public static void SV_WriteFrameToClient(client_t client, sizebuf_t msg) { *************** *** 360,365 **** } ! /** The client will interpolate the view position, so we can't use a single ! * PVS point. */ public static void SV_FatPVS(float[] org) { int leafs[] = new int[64]; --- 349,356 ---- } ! /** ! * The client will interpolate the view position, so we can't use a single ! * PVS point. ! */ public static void SV_FatPVS(float[] org) { int leafs[] = new int[64]; *************** *** 473,477 **** // ignore if not touching a PV leaf ! // check area if (ent != clent) { if (!CM.CM_AreasConnected(clientarea, ent.areanum)) { --- 464,468 ---- // ignore if not touching a PV leaf ! // check area if (ent != clent) { if (!CM.CM_AreasConnected(clientarea, ent.areanum)) { *************** *** 544,552 **** } ! /* ! * ================== SV_RecordDemoMessage ! * * Save everything in the world out without deltas. Used for recording ! * footage for merged or assembled demos ================== */ public static void SV_RecordDemoMessage() { --- 535,541 ---- } ! /** * Save everything in the world out without deltas. Used for recording ! * footage for merged or assembled demos. */ public static void SV_RecordDemoMessage() { Index: SV_MAIN.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_MAIN.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** SV_MAIN.java 18 Dec 2005 22:10:13 -0000 1.14 --- SV_MAIN.java 27 Dec 2005 21:02:30 -0000 1.15 *************** *** 35,42 **** public class SV_MAIN { ! public static netadr_t master_adr[] = new netadr_t[Defines.MAX_MASTERS]; // address ! // of ! // group ! // servers static { for (int i = 0; i < Defines.MAX_MASTERS; i++) { --- 35,43 ---- public class SV_MAIN { ! /** Addess of group servers.*/ ! public static netadr_t master_adr[] = new netadr_t[Defines.MAX_MASTERS]; ! ! ! static { for (int i = 0; i < Defines.MAX_MASTERS; i++) { *************** *** 86,107 **** // messages ! //============================================================================ ! ! /* ! * ================ Master_Heartbeat ! * * Send a message to the master every few minutes to let it know we are ! * alive, and log information ================ */ public static final int HEARTBEAT_SECONDS = 300; ! //============================================================================ ! ! /* ! * ===================== SV_DropClient ! * * Called when the player is totally leaving the server, either willingly or * unwillingly. This is NOT called if the entire server is quiting or ! * crashing. ===================== */ public static void SV_DropClient(client_t drop) { --- 87,100 ---- // messages ! /** * Send a message to the master every few minutes to let it know we are ! * alive, and log information. */ public static final int HEARTBEAT_SECONDS = 300; ! /** * Called when the player is totally leaving the server, either willingly or * unwillingly. This is NOT called if the entire server is quiting or ! * crashing. */ public static void SV_DropClient(client_t drop) { *************** *** 124,140 **** } ! /* ! * ============================================================================== * * CONNECTIONLESS COMMANDS * ! * ============================================================================== ! */ ! ! /* ! * =============== SV_StatusString ! * ! * Builds the string that is sent as heartbeats and status replies ! * =============== */ public static String SV_StatusString() { --- 117,129 ---- } ! ! /* ============================================================================== * * CONNECTIONLESS COMMANDS * ! * ==============================================================================*/ ! ! /** ! * Builds the string that is sent as heartbeats and status replies. */ public static String SV_StatusString() { *************** *** 168,175 **** } ! /* ! * ================ SVC_Status ! * ! * Responds with all the info that qplug or qspy can see ================ */ public static void SVC_Status() { --- 157,162 ---- } ! /** ! * Responds with all the info that qplug or qspy can see */ public static void SVC_Status() { *************** *** 178,185 **** } ! /* ! * ================ SVC_Ack ! * ! * ================ */ public static void SVC_Ack() { --- 165,170 ---- } ! /** ! * SVC_Ack */ public static void SVC_Ack() { *************** *** 188,196 **** } ! /* ! * ================ SVC_Info ! * ! * Responds with short info for broadcast scans The second parameter should ! * be the current protocol version number. ================ */ public static void SVC_Info() { --- 173,179 ---- } ! /** ! * SVC_Info, responds with short info for broadcast scans The second parameter should ! * be the current protocol version number. */ public static void SVC_Info() { *************** *** 220,227 **** } ! /* ! * ================ SVC_Ping ! * ! * Just responds with an acknowledgement ================ */ public static void SVC_Ping() { --- 203,208 ---- } ! /** ! * SVC_Ping, Just responds with an acknowledgement. */ public static void SVC_Ping() { *************** *** 229,239 **** } ! /* ! * ================= SVC_GetChallenge ! * * Returns a challenge number that can be used in a subsequent * client_connect command. We do this to prevent denial of service attacks * that flood the server with invalid connection IPs. With a challenge, they ! * must give a valid IP address. ================= */ public static void SVC_GetChallenge() { --- 210,218 ---- } ! /** * Returns a challenge number that can be used in a subsequent * client_connect command. We do this to prevent denial of service attacks * that flood the server with invalid connection IPs. With a challenge, they ! * must give a valid IP address. */ public static void SVC_GetChallenge() { *************** *** 269,276 **** } ! /* ! * ================== SVC_DirectConnect ! * ! * A connection request that did not come from the master ================== */ public static void SVC_DirectConnect() { --- 248,253 ---- } ! /** ! * A connection request that did not come from the master. */ public static void SVC_DirectConnect() { *************** *** 280,285 **** client_t cl; - edict_t ent; - int edictnum; int version; int qport; --- 257,260 ---- *************** *** 301,309 **** userinfo = Cmd.Argv(4); - //userinfo[sizeof(userinfo) - 1] = 0; - // force the IP key/value pair so the game can filter based on ip ! userinfo = Info.Info_SetValueForKey1(userinfo, "ip", NET ! .AdrToString(Globals.net_from)); // attractloop servers are ONLY for local clients --- 276,281 ---- userinfo = Cmd.Argv(4); // force the IP key/value pair so the game can filter based on ip ! userinfo = Info.Info_SetValueForKey(userinfo, "ip", NET.AdrToString(Globals.net_from)); // attractloop servers are ONLY for local clients *************** *** 376,379 **** --- 348,354 ---- } + /** + * Initializes player structures after successfull connection. + */ public static void gotnewcl(int i, int challenge, String userinfo, netadr_t adr, int qport) { *************** *** 381,393 **** // accept the new client // this is the only place a client_t is ever initialized - //*newcl = temp; SV_MAIN.sv_client = SV_INIT.svs.clients[i]; ! //edictnum = (newcl-svs.clients)+1; int edictnum = i + 1; edict_t ent = GameBase.g_edicts[edictnum]; SV_INIT.svs.clients[i].edict = ent; ! SV_INIT.svs.clients[i].challenge = challenge; // save challenge for ! // checksumming // get the game a chance to reject this connection or modify the --- 356,371 ---- // accept the new client // this is the only place a client_t is ever initialized SV_MAIN.sv_client = SV_INIT.svs.clients[i]; ! int edictnum = i + 1; + edict_t ent = GameBase.g_edicts[edictnum]; SV_INIT.svs.clients[i].edict = ent; ! ! // save challenge for checksumming ! SV_INIT.svs.clients[i].challenge = challenge; ! ! // get the game a chance to reject this connection or modify the *************** *** 412,417 **** Netchan.OutOfBandPrint(Defines.NS_SERVER, adr, "client_connect"); ! Netchan.Setup(Defines.NS_SERVER, SV_INIT.svs.clients[i].netchan, adr, ! qport); SV_INIT.svs.clients[i].state = Defines.cs_connected; --- 390,394 ---- Netchan.OutOfBandPrint(Defines.NS_SERVER, adr, "client_connect"); ! Netchan.Setup(Defines.NS_SERVER, SV_INIT.svs.clients[i].netchan, adr, qport); SV_INIT.svs.clients[i].state = Defines.cs_connected; *************** *** 420,430 **** SV_INIT.svs.clients[i].datagram_buf, SV_INIT.svs.clients[i].datagram_buf.length); SV_INIT.svs.clients[i].datagram.allowoverflow = true; ! SV_INIT.svs.clients[i].lastmessage = SV_INIT.svs.realtime; // don't ! // timeout SV_INIT.svs.clients[i].lastconnect = SV_INIT.svs.realtime; Com.DPrintf("new client added.\n"); } public static int Rcon_Validate() { if (0 == SV_MAIN.rcon_password.string.length()) --- 397,411 ---- SV_INIT.svs.clients[i].datagram_buf, SV_INIT.svs.clients[i].datagram_buf.length); + SV_INIT.svs.clients[i].datagram.allowoverflow = true; ! SV_INIT.svs.clients[i].lastmessage = SV_INIT.svs.realtime; // don't timeout SV_INIT.svs.clients[i].lastconnect = SV_INIT.svs.realtime; Com.DPrintf("new client added.\n"); } + + /** + * Checks if the rcon password is corect. + */ public static int Rcon_Validate() { if (0 == SV_MAIN.rcon_password.string.length()) *************** *** 479,488 **** } ! /* ! * ================= SV_ConnectionlessPacket ! * * A connectionless packet has four leading 0xff characters to distinguish * it from a game channel. Clients that are in the game can still send ! * connectionless packets. ================= */ public static void SV_ConnectionlessPacket() { --- 460,467 ---- } ! /** * A connectionless packet has four leading 0xff characters to distinguish * it from a game channel. Clients that are in the game can still send ! * connectionless packets. It is used also by rcon commands. */ public static void SV_ConnectionlessPacket() { *************** *** 498,503 **** c = Cmd.Argv(0); ! //Com.Printf("Packet " + NET.AdrToString(Netchan.net_from) + " : " + c ! // + "\n"); //Com.Printf(Lib.hexDump(net_message.data, 64, false) + "\n"); --- 477,483 ---- c = Cmd.Argv(0); ! ! //for debugging purposes ! //Com.Printf("Packet " + NET.AdrToString(Netchan.net_from) + " : " + c + "\n"); //Com.Printf(Lib.hexDump(net_message.data, 64, false) + "\n"); *************** *** 524,533 **** } ! //============================================================================ ! ! /* ! * =================== SV_CalcPings ! * ! * Updates the cl.ping variables =================== */ public static void SV_CalcPings() { --- 504,509 ---- } ! /** ! * Updates the cl.ping variables. */ public static void SV_CalcPings() { *************** *** 559,568 **** } ! /* ! * =================== SV_GiveMsec ! * * Every few frames, gives all clients an allotment of milliseconds for * their command moves. If they exceed it, assume cheating. - * =================== */ public static void SV_GiveMsec() { --- 535,541 ---- } ! /** * Every few frames, gives all clients an allotment of milliseconds for * their command moves. If they exceed it, assume cheating. */ public static void SV_GiveMsec() { *************** *** 582,587 **** } ! /* ! * ================= SV_ReadPackets ================= */ public static void SV_ReadPackets() { --- 555,560 ---- } ! /** ! * Reads packets from the network or loopback. */ public static void SV_ReadPackets() { *************** *** 639,645 **** } ! /* ! * ================== SV_CheckTimeouts ! * * If a packet has not been received from a client for timeout.value * seconds, drop the conneciton. Server frames are used instead of realtime --- 612,616 ---- } ! /** * If a packet has not been received from a client for timeout.value * seconds, drop the conneciton. Server frames are used instead of realtime *************** *** 648,652 **** * When a client is normally dropped, the client_t goes into a zombie state * for a few seconds to make sure any final reliable message gets resent if ! * necessary ================== */ public static void SV_CheckTimeouts() { --- 619,623 ---- * When a client is normally dropped, the client_t goes into a zombie state * for a few seconds to make sure any final reliable message gets resent if ! * necessary. */ public static void SV_CheckTimeouts() { *************** *** 679,687 **** } ! /* ! * ================ SV_PrepWorldFrame * * This has to be done before the world logic, because player processing ! * happens outside RunWorldFrame ================ */ public static void SV_PrepWorldFrame() { --- 650,658 ---- } ! /** ! * SV_PrepWorldFrame * * This has to be done before the world logic, because player processing ! * happens outside RunWorldFrame. */ public static void SV_PrepWorldFrame() { *************** *** 697,702 **** } ! /* ! * ================= SV_RunGameFrame ================= */ public static void SV_RunGameFrame() { --- 668,673 ---- } ! /** ! * SV_RunGameFrame. */ public static void SV_RunGameFrame() { *************** *** 728,735 **** } ! /* ! * ================== SV_Frame ! * ! * ================== */ public static void SV_Frame(long msec) { --- 699,704 ---- } ! /** ! * SV_Frame. */ public static void SV_Frame(long msec) { *************** *** 768,776 **** // update ping based on the last known frame from all clients - //TODO: dont need yet SV_CalcPings(); // give the clients some timeslices - //TODO: dont need yet SV_GiveMsec(); --- 737,743 ---- *************** *** 782,790 **** // save the entire world state if recording a serverdemo ! //TODO: dont need yet ! //SV_WORLD.SV_RecordDemoMessage(); // send a heartbeat to the master if needed - //TODO: dont need yet Master_Heartbeat(); --- 749,755 ---- // save the entire world state if recording a serverdemo ! SV_ENTS.SV_RecordDemoMessage(); // send a heartbeat to the master if needed Master_Heartbeat(); *************** *** 827,835 **** } } ! /* ! * ================= Master_Shutdown ! * ! * Informs all masters that this server is going down ================= */ public static void Master_Shutdown() { --- 792,799 ---- } } + ! /** ! * Master_Shutdown, Informs all masters that this server is going down. */ public static void Master_Shutdown() { *************** *** 854,865 **** } } ! //============================================================================ ! ! /* ! * ================= SV_UserinfoChanged ! * * Pull specific info from a newly changed userinfo string into a more C ! * freindly form. ================= */ public static void SV_UserinfoChanged(client_t cl) { --- 818,826 ---- } } + ! /** * Pull specific info from a newly changed userinfo string into a more C ! * freindly form. */ public static void SV_UserinfoChanged(client_t cl) { *************** *** 898,906 **** } ! //============================================================================ ! ! /* ! * =============== SV_Init ! * * Only called at quake2.exe startup, not for each game =============== */ --- 859,863 ---- } ! /** * Only called at quake2.exe startup, not for each game =============== */ *************** *** 953,963 **** } ! /* ! * ================== SV_FinalMessage ! * * Used by SV_Shutdown to send a final message to all connected clients * before the server goes down. The messages are sent immediately, not just * stuck on the outgoing message list, because the server is going to ! * totally exit after returning from this function. ================== */ public static void SV_FinalMessage(String message, boolean reconnect) { --- 910,918 ---- } ! /** * Used by SV_Shutdown to send a final message to all connected clients * before the server goes down. The messages are sent immediately, not just * stuck on the outgoing message list, because the server is going to ! * totally exit after returning from this function. */ public static void SV_FinalMessage(String message, boolean reconnect) { *************** *** 992,1000 **** } ! /* ! * ================ SV_Shutdown ! * ! * Called when each game quits, before Sys_Quit or Sys_Error ! * ================ */ public static void SV_Shutdown(String finalmsg, boolean reconnect) { --- 947,952 ---- } ! /** ! * Called when each game quits, before Sys_Quit or Sys_Error. */ public static void SV_Shutdown(String finalmsg, boolean reconnect) { |
From: Rene S. <sa...@us...> - 2005-12-27 21:02:42
|
Update of /cvsroot/jake2/jake2/src/jake2/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7724/src/jake2/sys Modified Files: NET.java Log Message: code cleanups and beautification Index: NET.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/NET.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NET.java 26 Jun 2005 09:17:33 -0000 1.8 --- NET.java 27 Dec 2005 21:02:31 -0000 1.9 *************** *** 46,50 **** private final static int MAX_LOOPBACK = 4; ! // local loopback adress private static netadr_t net_local_adr = new netadr_t(); --- 46,50 ---- private final static int MAX_LOOPBACK = 4; ! /** Local loopback adress. */ private static netadr_t net_local_adr = new netadr_t(); *************** *** 78,85 **** private static DatagramSocket[] ip_sockets = { null, null }; ! /* ! * CompareAdr ! * ! * Compares with the port */ public static boolean CompareAdr(netadr_t a, netadr_t b) { --- 78,83 ---- private static DatagramSocket[] ip_sockets = { null, null }; ! /** ! * Compares ip address and port. */ public static boolean CompareAdr(netadr_t a, netadr_t b) { *************** *** 88,95 **** } ! /* ! * CompareBaseAdr ! * ! * Compares without the port */ public static boolean CompareBaseAdr(netadr_t a, netadr_t b) { --- 86,91 ---- } ! /** ! * Compares ip address without the port. */ public static boolean CompareBaseAdr(netadr_t a, netadr_t b) { *************** *** 107,114 **** } ! /* ! * AdrToString ! * ! * IP address with the port */ public static String AdrToString(netadr_t a) { --- 103,108 ---- } ! /** ! * Returns a string holding ip address and port like "ip0.ip1.ip2.ip3:port". */ public static String AdrToString(netadr_t a) { *************** *** 121,128 **** } ! /* ! * BaseAdrToString ! * ! * IP address without the port */ public static String BaseAdrToString(netadr_t a) { --- 115,120 ---- } ! /** ! * Returns IP address without the port as string. */ public static String BaseAdrToString(netadr_t a) { *************** *** 134,139 **** } ! /* ! * StringToAdr */ public static boolean StringToAdr(String s, netadr_t a) { --- 126,131 ---- } ! /** ! * Creates an netadr_t from an string. */ public static boolean StringToAdr(String s, netadr_t a) { *************** *** 156,161 **** } ! /* ! * IsLocalAddress */ public static boolean IsLocalAddress(netadr_t adr) { --- 148,153 ---- } ! /** ! * Seems to return true, if the address is is on 127.0.0.1. */ public static boolean IsLocalAddress(netadr_t adr) { *************** *** 171,174 **** --- 163,169 ---- */ + /** + * Gets a packet from internal loopback. + */ public static boolean GetLoopPacket(int sock, netadr_t net_from, sizebuf_t net_message) { *************** *** 193,198 **** } ! /* ! * SendLoopPacket */ public static void SendLoopPacket(int sock, int length, byte[] data, --- 188,193 ---- } ! /** ! * Sends a packet via internal loopback. */ public static void SendLoopPacket(int sock, int length, byte[] data, *************** *** 211,216 **** } ! /* ! * GetPacket */ public static boolean GetPacket(int sock, netadr_t net_from, --- 206,211 ---- } ! /** ! * Gets a packet from a network channel */ public static boolean GetPacket(int sock, netadr_t net_from, *************** *** 256,261 **** } ! /* ! * SendPacket */ public static void SendPacket(int sock, int length, byte[] data, netadr_t to) { --- 251,256 ---- } ! /** ! * Sends a Packet. */ public static void SendPacket(int sock, int length, byte[] data, netadr_t to) { *************** *** 274,289 **** try { ! SocketAddress dstSocket = new InetSocketAddress( ! to.getInetAddress(), to.port); ip_channels[sock].send(ByteBuffer.wrap(data, 0, length), dstSocket); } catch (Exception e) { ! Com ! .Println("NET_SendPacket ERROR: " + e + " to " ! + AdrToString(to)); } } ! /* ! * OpenIP */ public static void OpenIP() { --- 269,281 ---- try { ! SocketAddress dstSocket = new InetSocketAddress(to.getInetAddress(), to.port); ip_channels[sock].send(ByteBuffer.wrap(data, 0, length), dstSocket); } catch (Exception e) { ! Com.Println("NET_SendPacket ERROR: " + e + " to " + AdrToString(to)); } } ! /** ! * OpenIP, creates the network sockets. */ public static void OpenIP() { *************** *** 302,309 **** } ! /* ! * Config ! * ! * A single player game will only use the loopback code */ public static void Config(boolean multiplayer) { --- 294,299 ---- } ! /** ! * Config multi or singlepalyer - A single player game will only use the loopback code. */ public static void Config(boolean multiplayer) { *************** *** 322,326 **** } ! /* * Init */ --- 312,316 ---- } ! /** * Init */ *************** *** 364,369 **** } ! /* ! * Shutdown */ public static void Shutdown() { --- 354,359 ---- } ! /** ! * Shutdown - closes the sockets */ public static void Shutdown() { *************** *** 372,376 **** } ! // sleeps msec or until net socket is ready public static void Sleep(int msec) { if (ip_sockets[Defines.NS_SERVER] == null --- 362,366 ---- } ! /** Sleeps msec or until net socket is ready. */ public static void Sleep(int msec) { if (ip_sockets[Defines.NS_SERVER] == null *************** *** 387,401 **** // this should wait up to 100ms until a packet /* ! * struct timeval timeout; fd_set fdset; extern cvar_t *dedicated; * extern qboolean stdin_active; * * if (!ip_sockets[NS_SERVER] || (dedicated && !dedicated.value)) ! * return; // we're not a server, just run full speed * ! * FD_ZERO(&fdset); if (stdin_active) FD_SET(0, &fdset); // stdin is ! * processed too FD_SET(ip_sockets[NS_SERVER], &fdset); // network ! * socket timeout.tv_sec = msec/1000; timeout.tv_usec = ! * (msec%1000)*1000; select(ip_sockets[NS_SERVER]+1, &fdset, NULL, NULL, ! * &timeout); */ } --- 377,399 ---- // this should wait up to 100ms until a packet /* ! * struct timeval timeout; ! * fd_set fdset; ! * extern cvar_t *dedicated; * extern qboolean stdin_active; * * if (!ip_sockets[NS_SERVER] || (dedicated && !dedicated.value)) ! * return; // we're not a server, just run full speed * ! * FD_ZERO(&fdset); ! * ! * if (stdin_active) ! * FD_SET(0, &fdset); // stdin is processed too ! * ! * FD_SET(ip_sockets[NS_SERVER], &fdset); // network socket ! * ! * timeout.tv_sec = msec/1000; ! * timeout.tv_usec = (msec%1000)*1000; ! * ! * select(ip_sockets[NS_SERVER]+1, &fdset, NULL, NULL, &timeout); */ } |
From: Rene S. <sa...@us...> - 2005-12-27 21:02:38
|
Update of /cvsroot/jake2/jake2/src/jake2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7724/src/jake2 Modified Files: Defines.java Log Message: code cleanups and beautification Index: Defines.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/Defines.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Defines.java 16 Dec 2005 21:13:42 -0000 1.7 --- Defines.java 27 Dec 2005 21:02:30 -0000 1.8 *************** *** 1337,1352 **** 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 --- 1337,1341 ---- |
From: Carsten W. <ca...@us...> - 2005-12-25 18:16:46
|
Update of /cvsroot/jake2/jake2/src/jake2/sound/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28775/src/jake2/sound/lwjgl Modified Files: Tag: render-refactoring LWJGLSoundImpl.java Channel.java Log Message: merge with current HEAD Index: Channel.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/lwjgl/Channel.java,v retrieving revision 1.6 retrieving revision 1.6.6.1 diff -C2 -d -r1.6 -r1.6.6.1 *** Channel.java 8 May 2005 13:37:46 -0000 1.6 --- Channel.java 25 Dec 2005 18:16:38 -0000 1.6.6.1 *************** *** 31,41 **** import jake2.client.CL_ents; import jake2.game.entity_state_t; ! import jake2.sound.sfx_t; ! import jake2.sound.sfxcache_t; import jake2.util.Lib; import jake2.util.Math3D; ! import java.nio.FloatBuffer; ! import java.nio.IntBuffer; import java.util.Hashtable; import java.util.Iterator; --- 31,40 ---- import jake2.client.CL_ents; import jake2.game.entity_state_t; ! import jake2.qcommon.Com; ! import jake2.sound.*; import jake2.util.Lib; import jake2.util.Math3D; ! import java.nio.*; import java.util.Hashtable; import java.util.Iterator; *************** *** 64,68 **** private static boolean isInitialized = false; ! private static int numChannels; // sound attributes --- 63,71 ---- private static boolean isInitialized = false; ! private static int numChannels; ! ! // stream handling ! private static boolean streamingEnabled = false; ! private static int streamQueue = 0; // sound attributes *************** *** 105,109 **** // create channels int sourceId; - int error; for (int i = 0; i < MAX_CHANNELS; i++) { --- 108,111 ---- *************** *** 111,114 **** --- 113,117 ---- sourceId = tmp.get(0); + // can't generate more sources if (sourceId <= 0) break; *************** *** 146,149 **** --- 149,228 ---- } + static void enableStreaming() { + if (streamingEnabled) return; + + // use the last source + numChannels--; + streamingEnabled = true; + streamQueue = 0; + + int source = channels[numChannels].sourceId; + AL10.alSourcei (source, AL10.AL_SOURCE_RELATIVE, AL10.AL_TRUE); + AL10.alSourcef(source, AL10.AL_GAIN, 1.0f); + channels[numChannels].volumeChanged = true; + + Com.DPrintf("streaming enabled\n"); + } + + static void disableStreaming() { + if (!streamingEnabled) return; + unqueueStreams(); + int source = channels[numChannels].sourceId; + AL10.alSourcei (source, AL10.AL_SOURCE_ABSOLUTE, AL10.AL_TRUE); + + // free the last source + numChannels++; + streamingEnabled = false; + Com.DPrintf("streaming disabled\n"); + } + + static void unqueueStreams() { + if (!streamingEnabled) return; + int source = channels[numChannels].sourceId; + + // stop streaming + AL10.alSourceStop(source); + int count = AL10.alGetSourcei(source, AL10.AL_BUFFERS_QUEUED); + Com.DPrintf("unqueue " + count + " buffers\n"); + while (count-- > 0) { + AL10.alSourceUnqueueBuffers(source, tmp); + } + streamQueue = 0; + } + + static void updateStream(ByteBuffer samples, int count, int format, int rate) { + enableStreaming(); + int source = channels[numChannels].sourceId; + int processed = AL10.alGetSourcei(source, AL10.AL_BUFFERS_PROCESSED); + + boolean playing = (AL10.alGetSourcei(source, AL10.AL_SOURCE_STATE) == AL10.AL_PLAYING); + boolean interupted = !playing && streamQueue > 2; + + IntBuffer buffer = tmp; + if (interupted) { + unqueueStreams(); + buffer.put(0, buffers.get(Sound.MAX_SFX + streamQueue++)); + Com.DPrintf("queue " + (streamQueue - 1) + '\n'); + } else if (processed < 2) { + // check queue overrun + if (streamQueue >= Sound.STREAM_QUEUE) return; + buffer.put(0, buffers.get(Sound.MAX_SFX + streamQueue++)); + Com.DPrintf("queue " + (streamQueue - 1) + '\n'); + } else { + // reuse the buffer + AL10.alSourceUnqueueBuffers(source, buffer); + } + + samples.position(0); + samples.limit(count); + AL10.alBufferData(buffer.get(0), format, samples, rate); + AL10.alSourceQueueBuffers(source, buffer); + + if (streamQueue > 1 && !playing) { + Com.DPrintf("start sound\n"); + AL10.alSourcePlay(source); + } + } + static void addPlaySounds() { while (Channel.assign(PlaySound.nextPlayableSound())); Index: LWJGLSoundImpl.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/lwjgl/LWJGLSoundImpl.java,v retrieving revision 1.7 retrieving revision 1.7.6.1 diff -C2 -d -r1.7 -r1.7.6.1 *** LWJGLSoundImpl.java 27 Apr 2005 12:21:24 -0000 1.7 --- LWJGLSoundImpl.java 25 Dec 2005 18:16:38 -0000 1.7.6.1 *************** *** 15,21 **** import jake2.util.Vargs; ! import java.nio.ByteBuffer; ! import java.nio.FloatBuffer; ! import java.nio.IntBuffer; import org.lwjgl.LWJGLException; --- 15,20 ---- import jake2.util.Vargs; ! import java.nio.*; ! import java.util.Random; import org.lwjgl.LWJGLException; *************** *** 40,46 **** private cvar_t s_volume; ! private static final int MAX_SFX = Defines.MAX_SOUNDS * 2; ! ! private IntBuffer buffers = Lib.newIntBuffer(MAX_SFX); // singleton --- 39,44 ---- private cvar_t s_volume; ! // the last 4 buffers are used for cinematics streaming ! private IntBuffer buffers = Lib.newIntBuffer(MAX_SFX + STREAM_QUEUE); // singleton *************** *** 508,518 **** } ! /* (non-Javadoc) * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[]) */ ! public void RawSamples(int samples, int rate, int width, int channels, byte[] data) { ! // TODO implement RawSamples } ! /* =============================================================================== --- 506,543 ---- } ! private ShortBuffer streamBuffer = sfxDataBuffer.slice().order(ByteOrder.BIG_ENDIAN).asShortBuffer(); ! ! /* (non-Javadoc) * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[]) */ ! public void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) { ! int format; ! if (channels == 2) { ! format = (width == 2) ? AL10.AL_FORMAT_STEREO16 ! : AL10.AL_FORMAT_STEREO8; ! } else { ! format = (width == 2) ? AL10.AL_FORMAT_MONO16 ! : AL10.AL_FORMAT_MONO8; ! } ! ! // convert to signed 16 bit samples ! if (format == AL10.AL_FORMAT_MONO8) { ! ShortBuffer sampleData = streamBuffer; ! int value; ! for (int i = 0; i < samples; i++) { ! value = (data.get(i) & 0xFF) - 128; ! sampleData.put(i, (short) value); ! } ! format = AL10.AL_FORMAT_MONO16; ! width = 2; ! data = sfxDataBuffer.slice(); ! } ! ! Channel.updateStream(data, samples * channels * width, format, rate); } ! ! public void disableStreaming() { ! Channel.disableStreaming(); ! } /* =============================================================================== |
From: Carsten W. <ca...@us...> - 2005-12-25 18:16:31
|
Update of /cvsroot/jake2/jake2/src/jake2/sound/jsound In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28697/src/jake2/sound/jsound Modified Files: Tag: render-refactoring JSoundImpl.java SND_DMA.java Log Message: merge with current HEAD Index: SND_DMA.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/jsound/SND_DMA.java,v retrieving revision 1.2 retrieving revision 1.2.12.1 diff -C2 -d -r1.2 -r1.2.12.1 *** SND_DMA.java 22 Sep 2004 19:22:09 -0000 1.2 --- SND_DMA.java 25 Dec 2005 18:16:22 -0000 1.2.12.1 *************** *** 45,48 **** --- 45,49 ---- import java.io.IOException; import java.io.RandomAccessFile; + import java.nio.ByteBuffer; /** *************** *** 879,883 **** */ static void RawSamples(int samples, int rate, int width, int channels, ! byte[] data) { //TODO RawSamples int i; --- 880,884 ---- */ static void RawSamples(int samples, int rate, int width, int channels, ! ByteBuffer data) { //TODO RawSamples int i; Index: JSoundImpl.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/jsound/JSoundImpl.java,v retrieving revision 1.1 retrieving revision 1.1.12.1 diff -C2 -d -r1.1 -r1.1.12.1 *** JSoundImpl.java 9 Jul 2004 06:50:48 -0000 1.1 --- JSoundImpl.java 25 Dec 2005 18:16:22 -0000 1.1.12.1 *************** *** 7,13 **** package jake2.sound.jsound; import jake2.sound.*; - import jake2.sound.Sound; - import jake2.sound.sfx_t; /** --- 7,13 ---- package jake2.sound.jsound; + import java.nio.ByteBuffer; + import jake2.sound.*; /** *************** *** 92,98 **** * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[]) */ ! public void RawSamples(int samples, int rate, int width, int channels, byte[] data) { SND_DMA.RawSamples(samples, rate, width, channels, data); } } --- 92,101 ---- * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[]) */ ! public void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) { SND_DMA.RawSamples(samples, rate, width, channels, data); } + + public void disableStreaming() { + } } |
From: Carsten W. <ca...@us...> - 2005-12-25 18:16:14
|
Update of /cvsroot/jake2/jake2/src/jake2/sound/joal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28654/src/jake2/sound/joal Modified Files: Tag: render-refactoring JOALSoundImpl.java Channel.java Log Message: merge with current HEAD Index: Channel.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/joal/Channel.java,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -C2 -d -r1.4 -r1.4.6.1 *** Channel.java 8 May 2005 13:37:28 -0000 1.4 --- Channel.java 25 Dec 2005 18:16:06 -0000 1.4.6.1 *************** *** 31,41 **** import jake2.client.CL_ents; import jake2.game.entity_state_t; ! import jake2.sound.sfx_t; ! import jake2.sound.sfxcache_t; import jake2.util.Math3D; ! import java.util.Hashtable; ! import java.util.Iterator; ! import java.util.Map; import net.java.games.joal.AL; --- 31,40 ---- import jake2.client.CL_ents; import jake2.game.entity_state_t; ! import jake2.qcommon.Com; ! import jake2.sound.*; import jake2.util.Math3D; ! import java.nio.ByteBuffer; ! import java.util.*; import net.java.games.joal.AL; *************** *** 63,67 **** private static boolean isInitialized = false; private static int numChannels; ! // sound attributes private int type; --- 62,70 ---- private static boolean isInitialized = false; private static int numChannels; ! ! // stream handling ! private static boolean streamingEnabled = false; ! private static int streamQueue = 0; ! // sound attributes private int type; *************** *** 96,107 **** modified = false; } ! static int init(AL al, int[] buffers) { Channel.al = al; Channel.buffers = buffers; // create channels int sourceId; - int[] tmp = {0}; - int error; for (int i = 0; i < MAX_CHANNELS; i++) { --- 99,110 ---- modified = false; } + + private static int[] tmp = new int[1]; ! static int init(AL al, int[] buffers) { Channel.al = al; Channel.buffers = buffers; // create channels int sourceId; for (int i = 0; i < MAX_CHANNELS; i++) { *************** *** 143,146 **** --- 146,225 ---- isInitialized = false; } + + static void enableStreaming() { + if (streamingEnabled) return; + + // use the last source + numChannels--; + streamingEnabled = true; + streamQueue = 0; + + int source = channels[numChannels].sourceId; + al.alSourcei (source, AL.AL_SOURCE_RELATIVE, AL.AL_TRUE); + al.alSourcef(source, AL.AL_GAIN, 1.0f); + channels[numChannels].volumeChanged = true; + + Com.DPrintf("streaming enabled\n"); + } + + static void disableStreaming() { + if (!streamingEnabled) return; + unqueueStreams(); + int source = channels[numChannels].sourceId; + al.alSourcei (source, AL.AL_SOURCE_ABSOLUTE, AL.AL_TRUE); + + // free the last source + numChannels++; + streamingEnabled = false; + Com.DPrintf("streaming disabled\n"); + } + + static void unqueueStreams() { + if (!streamingEnabled) return; + int source = channels[numChannels].sourceId; + + // stop streaming + al.alSourceStop(source); + int count = al.alGetSourcei(source, AL.AL_BUFFERS_QUEUED); + Com.DPrintf("unqueue " + count + " buffers\n"); + while (count-- > 0) { + al.alSourceUnqueueBuffers(source, 1, tmp); + } + streamQueue = 0; + } + + static void updateStream(ByteBuffer samples, int count, int format, int rate) { + enableStreaming(); + int[] buffer = tmp; + int source = channels[numChannels].sourceId; + int processed = al.alGetSourcei(source, AL.AL_BUFFERS_PROCESSED); + + boolean playing = (al.alGetSourcei(source, AL.AL_SOURCE_STATE) == AL.AL_PLAYING); + boolean interupted = !playing && streamQueue > 2; + + if (interupted) { + unqueueStreams(); + buffer[0] = buffers[Sound.MAX_SFX + streamQueue++]; + Com.DPrintf("queue " + (streamQueue - 1) + '\n'); + } else if (processed < 2) { + // check queue overrun + if (streamQueue >= Sound.STREAM_QUEUE) return; + buffer[0] = buffers[Sound.MAX_SFX + streamQueue++]; + Com.DPrintf("queue " + (streamQueue - 1) + '\n'); + } else { + // reuse the buffer + al.alSourceUnqueueBuffers(source, 1, buffer); + } + + samples.position(0); + samples.limit(count); + al.alBufferData(buffer[0], format, samples, count, rate); + al.alSourceQueueBuffers(source, 1, buffer); + + if (streamQueue > 1 && !playing) { + Com.DPrintf("start sound\n"); + al.alSourcePlay(source); + } + } static void addPlaySounds() { Index: JOALSoundImpl.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/joal/JOALSoundImpl.java,v retrieving revision 1.13 retrieving revision 1.13.6.1 diff -C2 -d -r1.13 -r1.13.6.1 *** JOALSoundImpl.java 27 Apr 2005 12:39:23 -0000 1.13 --- JOALSoundImpl.java 25 Dec 2005 18:16:06 -0000 1.13.6.1 *************** *** 15,21 **** import jake2.util.Vargs; - import java.awt.image.SampleModel; import java.io.*; ! import java.nio.IntBuffer; import net.java.games.joal.*; --- 15,20 ---- import jake2.util.Vargs; import java.io.*; ! import java.nio.*; import net.java.games.joal.*; *************** *** 38,43 **** cvar_t s_volume; ! private static final int MAX_SFX = Defines.MAX_SOUNDS * 2; ! private int[] buffers = new int[MAX_SFX]; // singleton --- 37,41 ---- cvar_t s_volume; ! private int[] buffers = new int[MAX_SFX + STREAM_QUEUE]; // singleton *************** *** 97,101 **** s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE); ! al.alGenBuffers(MAX_SFX, buffers); int count = Channel.init(al, buffers); Com.Printf("... using " + count + " channels\n"); --- 95,99 ---- s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE); ! al.alGenBuffers(buffers.length, buffers); int count = Channel.init(al, buffers); Com.Printf("... using " + count + " channels\n"); *************** *** 155,159 **** } ! private void initOpenALExtensions() throws OpenALException { if (al.alIsExtensionPresent("EAX2.0")) { Com.Printf("... using EAX2.0\n"); --- 153,157 ---- } ! private void initOpenALExtensions() { if (al.alIsExtensionPresent("EAX2.0")) { Com.Printf("... using EAX2.0\n"); *************** *** 177,187 **** } ! /* (non-Javadoc) ! * @see jake2.sound.SoundImpl#RegisterSound(jake2.sound.sfx_t) ! */ ! private void initBuffer(byte[] samples, int bufferId, int freq) { ! al.alBufferData(buffers[bufferId], AL.AL_FORMAT_MONO16, samples, ! samples.length, freq); ! } private void checkError() { --- 175,191 ---- } ! // TODO check the sfx direct buffer size ! // 2MB sfx buffer ! private ByteBuffer sfxDataBuffer = Lib.newByteBuffer(2 * 1024 * 1024); ! ! /* (non-Javadoc) ! * @see jake2.sound.SoundImpl#RegisterSound(jake2.sound.sfx_t) ! */ ! private void initBuffer(byte[] samples, int bufferId, int freq) { ! ByteBuffer data = sfxDataBuffer.slice(); ! data.put(samples).flip(); ! al.alBufferData(buffers[bufferId], AL.AL_FORMAT_MONO16, ! data, data.limit(), freq); ! } private void checkError() { *************** *** 345,349 **** int i; sfx_t sfx; - int size; // free any sounds not from this registration sequence --- 349,352 ---- *************** *** 532,541 **** } ! /* (non-Javadoc) ! * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[]) ! */ ! public void RawSamples(int samples, int rate, int width, int channels, byte[] data) { ! // TODO implement RawSamples ! } /* --- 535,572 ---- } ! private ShortBuffer streamBuffer = sfxDataBuffer.slice().order(ByteOrder.BIG_ENDIAN).asShortBuffer(); ! ! /* (non-Javadoc) ! * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[]) ! */ ! public void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) { ! int format; ! if (channels == 2) { ! format = (width == 2) ? AL.AL_FORMAT_STEREO16 ! : AL.AL_FORMAT_STEREO8; ! } else { ! format = (width == 2) ? AL.AL_FORMAT_MONO16 ! : AL.AL_FORMAT_MONO8; ! } ! ! // convert to signed 16 bit samples ! if (format == AL.AL_FORMAT_MONO8) { ! ShortBuffer sampleData = streamBuffer; ! int value; ! for (int i = 0; i < samples; i++) { ! value = (data.get(i) & 0xFF) - 128; ! sampleData.put(i, (short) value); ! } ! format = AL.AL_FORMAT_MONO16; ! width = 2; ! data = sfxDataBuffer.slice(); ! } ! ! Channel.updateStream(data, samples * channels * width, format, rate); ! } ! ! public void disableStreaming() { ! Channel.disableStreaming(); ! } /* *************** *** 548,556 **** void Play() { ! int i; ! String name; ! sfx_t sfx; ! ! i = 1; while (i < Cmd.Argc()) { name = new String(Cmd.Argv(i)); --- 579,584 ---- void Play() { ! int i = 1; ! String name; while (i < Cmd.Argc()) { name = new String(Cmd.Argv(i)); *************** *** 558,562 **** name += ".wav"; ! sfx = RegisterSound(name); StartLocalSound(name); i++; --- 586,590 ---- name += ".wav"; ! RegisterSound(name); StartLocalSound(name); i++; |
From: Carsten W. <ca...@us...> - 2005-12-25 18:13:39
|
Update of /cvsroot/jake2/jake2/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28272/scripts Modified Files: Tag: render-refactoring Jake2_mac_lwjgl.sh Log Message: merge with current HEAD Index: Jake2_mac_lwjgl.sh =================================================================== RCS file: /cvsroot/jake2/jake2/scripts/Jake2_mac_lwjgl.sh,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** Jake2_mac_lwjgl.sh 26 May 2005 16:56:31 -0000 1.2 --- Jake2_mac_lwjgl.sh 25 Dec 2005 18:13:31 -0000 1.2.4.1 *************** *** 1,5 **** #!/bin/sh ! export LD_LIBRARY_PATH=lib/linux/osx CP=lib/jake2.jar:lib/lwjgl.jar:lib/lwjgl_util.jar --- 1,5 ---- #!/bin/sh ! export LD_LIBRARY_PATH=lib/osx CP=lib/jake2.jar:lib/lwjgl.jar:lib/lwjgl_util.jar |
Update of /cvsroot/jake2/jake2/src/jake2/game In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27365/src/jake2/game Modified Files: Tag: render-refactoring Monster.java PlayerClient.java GameTarget.java PlayerView.java GameSave.java PlayerHud.java Cmd.java GameUtil.java GameBase.java GameAI.java GameSpawn.java GameFunc.java cplane_t.java SuperAdapter.java ItemUseAdapter.java GameTrigger.java GameTurret.java GameMisc.java ItemDropAdapter.java GameWeapon.java Added Files: Tag: render-refactoring GameItems.java PlayerWeapon.java GameChase.java GameItemList.java GameCombat.java Removed Files: Tag: render-refactoring GamePWeapon.java Fire.java PlayerClientAdapters.java Log Message: merge with current HEAD Index: GameTrigger.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameTrigger.java,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -C2 -d -r1.4 -r1.4.6.1 *** GameTrigger.java 20 Feb 2005 21:49:46 -0000 1.4 --- GameTrigger.java 25 Dec 2005 18:11:20 -0000 1.4.6.1 *************** *** 20,24 **** --- 20,26 ---- // Created on 27.12.2003 by RST. + // $Id$ + package jake2.game; *************** *** 54,58 **** 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 --- 56,60 ---- if (ent.wait > 0) { ! ent.think = multi_wait; ent.nextthink = GameBase.level.time + ent.wait; } else { // we can't just remove (self) here, because this is a touch *************** *** 76,80 **** ent.wait = 0.2f; ! ent.touch = GameTrigger.Touch_Multi; ent.movetype = Defines.MOVETYPE_NONE; ent.svflags |= Defines.SVF_NOCLIENT; --- 78,82 ---- ent.wait = 0.2f; ! ent.touch = Touch_Multi; ent.movetype = Defines.MOVETYPE_NONE; ent.svflags |= Defines.SVF_NOCLIENT; *************** *** 82,89 **** 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; } --- 84,91 ---- if ((ent.spawnflags & 4) != 0) { ent.solid = Defines.SOLID_NOT; ! ent.use = trigger_enable; } else { ent.solid = Defines.SOLID_TRIGGER; ! ent.use = Use_Multi; } *************** *** 125,129 **** public static void SP_trigger_relay(edict_t self) { ! self.use = GameTrigger.trigger_relay_use; } --- 127,131 ---- public static void SP_trigger_relay(edict_t self) { ! self.use = trigger_relay_use; } *************** *** 134,138 **** return; } ! self.item = GameUtil.FindItemByClassname(GameBase.st.item); if (null == self.item) { --- 136,140 ---- return; } ! self.item = GameItems.FindItemByClassname(GameBase.st.item); if (null == self.item) { *************** *** 152,156 **** GameBase.gi.soundindex("misc/keyuse.wav"); ! self.use = GameTrigger.trigger_key_use; } --- 154,158 ---- GameBase.gi.soundindex("misc/keyuse.wav"); ! self.use = trigger_key_use; } *************** *** 160,164 **** self.count = 2; ! self.use = GameTrigger.trigger_counter_use; } --- 162,166 ---- self.count = 2; ! self.use = trigger_counter_use; } *************** *** 188,193 **** 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; --- 190,195 ---- public static void SP_trigger_push(edict_t self) { InitTrigger(self); ! windsound = GameBase.gi.soundindex("misc/windfly.wav"); ! self.touch = trigger_push_touch; if (0 == self.speed) self.speed = 1000; *************** *** 199,203 **** self.noise_index = GameBase.gi.soundindex("world/electro.wav"); ! self.touch = GameTrigger.hurt_touch; if (0 == self.dmg) --- 201,205 ---- self.noise_index = GameBase.gi.soundindex("world/electro.wav"); ! self.touch = hurt_touch; if (0 == self.dmg) *************** *** 210,214 **** if ((self.spawnflags & 2) != 0) ! self.use = GameTrigger.hurt_use; GameBase.gi.linkentity(self); --- 212,216 ---- if ((self.spawnflags & 2) != 0) ! self.use = hurt_use; GameBase.gi.linkentity(self); *************** *** 225,229 **** InitTrigger(self); self.gravity = Lib.atoi(GameBase.st.gravity); ! self.touch = GameTrigger.trigger_gravity_touch; } --- 227,231 ---- InitTrigger(self); self.gravity = Lib.atoi(GameBase.st.gravity); ! self.touch = trigger_gravity_touch; } *************** *** 236,240 **** self.s.angles[Defines.YAW] = 360; InitTrigger(self); ! self.touch = GameTrigger.trigger_monsterjump_touch; self.movedir[2] = GameBase.st.height; } --- 238,242 ---- self.s.angles[Defines.YAW] = 360; InitTrigger(self); ! self.touch = trigger_monsterjump_touch; self.movedir[2] = GameBase.st.height; } *************** *** 242,245 **** --- 244,248 ---- // the wait time has passed, so set back up for another activation public static EntThinkAdapter multi_wait = new EntThinkAdapter() { + public String getID(){ return "multi_wait"; } public boolean think(edict_t ent) { *************** *** 250,260 **** 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) { --- 253,265 ---- static EntUseAdapter Use_Multi = new EntUseAdapter() { + public String getID(){ return "Use_Multi"; } public void use(edict_t ent, edict_t other, edict_t activator) { ent.activator = activator; ! multi_trigger(ent); } }; static EntTouchAdapter Touch_Multi = new EntTouchAdapter() { + public String getID(){ return "Touch_Multi"; } public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { *************** *** 277,281 **** self.activator = other; ! GameTrigger.multi_trigger(self); } }; --- 282,286 ---- self.activator = other; ! multi_trigger(self); } }; *************** *** 289,292 **** --- 294,298 ---- */ static EntUseAdapter trigger_enable = new EntUseAdapter() { + public String getID(){ return "trigger_enable"; } public void use(edict_t self, edict_t other, edict_t activator) { self.solid = Defines.SOLID_TRIGGER; *************** *** 301,304 **** --- 307,311 ---- */ public static EntUseAdapter trigger_relay_use = new EntUseAdapter() { + public String getID(){ return "trigger_relay_use"; } public void use(edict_t self, edict_t other, edict_t activator) { GameUtil.G_UseTargets(self, activator); *************** *** 321,324 **** --- 328,332 ---- static EntUseAdapter trigger_key_use = new EntUseAdapter() { + public String getID(){ return "trigger_key_use"; } public void use(edict_t self, edict_t other, edict_t activator) { int index; *************** *** 329,333 **** return; ! index = GameUtil.ITEM_INDEX(self.item); if (activator.client.pers.inventory[index] == 0) { if (GameBase.level.time < self.touch_debounce_time) --- 337,341 ---- return; ! index = GameItems.ITEM_INDEX(self.item); if (activator.client.pers.inventory[index] == 0) { if (GameBase.level.time < self.touch_debounce_time) *************** *** 386,398 **** }; ! /* ! * ============================================================================== ! * ! * trigger_counter ! * ! * ============================================================================== ! */ ! ! /* * QUAKED trigger_counter (.5 .5 .5) ? nomessage Acts as an intermediary for * an action that takes multiple inputs. --- 394,398 ---- }; ! /** * QUAKED trigger_counter (.5 .5 .5) ? nomessage Acts as an intermediary for * an action that takes multiple inputs. *************** *** 405,408 **** --- 405,409 ---- */ static EntUseAdapter trigger_counter_use = new EntUseAdapter() { + public String getID(){ return "trigger_counter_use"; } public void use(edict_t self, edict_t other, edict_t activator) { *************** *** 412,416 **** self.count--; ! if (self.count == 0) { if (0 == (self.spawnflags & 1)) { GameBase.gi.centerprintf(activator, self.count --- 413,417 ---- self.count--; ! if (self.count != 0) { if (0 == (self.spawnflags & 1)) { GameBase.gi.centerprintf(activator, self.count *************** *** 429,433 **** } self.activator = activator; ! GameTrigger.multi_trigger(self); } }; --- 430,434 ---- } self.activator = activator; ! multi_trigger(self); } }; *************** *** 446,449 **** --- 447,451 ---- static EntTouchAdapter trigger_push_touch = new EntTouchAdapter() { + public String getID(){ return "trigger_push_touch"; } public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { *************** *** 470,482 **** }; - /* - * ============================================================================== - * - * trigger_hurt - * - * ============================================================================== - */ ! /* * QUAKED trigger_hurt (.5 .5 .5) ? START_OFF TOGGLE SILENT NO_PROTECTION * SLOW Any entity that touches this will be hurt. --- 472,477 ---- }; ! /** * QUAKED trigger_hurt (.5 .5 .5) ? START_OFF TOGGLE SILENT NO_PROTECTION * SLOW Any entity that touches this will be hurt. *************** *** 491,494 **** --- 486,490 ---- */ static EntUseAdapter hurt_use = new EntUseAdapter() { + public String getID(){ return "hurt_use"; } public void use(edict_t self, edict_t other, edict_t activator) { *************** *** 505,508 **** --- 501,505 ---- static EntTouchAdapter hurt_touch = new EntTouchAdapter() { + public String getID(){ return "hurt_touch"; } public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { *************** *** 530,534 **** 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); --- 527,531 ---- else dflags = 0; ! GameCombat.T_Damage(other, self, self, Globals.vec3_origin, other.s.origin, Globals.vec3_origin, self.dmg, self.dmg, dflags, Defines.MOD_TRIGGER_HURT); *************** *** 550,553 **** --- 547,551 ---- static EntTouchAdapter trigger_gravity_touch = new EntTouchAdapter() { + public String getID(){ return "trigger_gravity_touch"; } public void touch(edict_t self, edict_t other, cplane_t plane, *************** *** 573,576 **** --- 571,575 ---- static EntTouchAdapter trigger_monsterjump_touch = new EntTouchAdapter() { + public String getID(){ return "trigger_monsterjump_touch"; } public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { Index: GameTurret.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameTurret.java,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -C2 -d -r1.4 -r1.4.6.1 *** GameTurret.java 6 Feb 2005 19:03:54 -0000 1.4 --- GameTurret.java 25 Dec 2005 18:11:20 -0000 1.4.6.1 *************** *** 80,84 **** damage = (int) (100 + Lib.random() * 50); speed = (int) (550 + 50 * GameBase.skill.value); ! Fire.fire_rocket(self.teammaster.owner, start, f, damage, speed, 150, damage); GameBase.gi.positioned_sound(start, self, Defines.CHAN_WEAPON, --- 80,84 ---- damage = (int) (100 + Lib.random() * 50); speed = (int) (550 + 50 * GameBase.skill.value); ! GameWeapon.fire_rocket(self.teammaster.owner, start, f, damage, speed, 150, damage); GameBase.gi.positioned_sound(start, self, Defines.CHAN_WEAPON, *************** *** 112,118 **** self.move_angles[Defines.YAW] = self.ideal_yaw; ! self.blocked = GameTurret.turret_blocked; ! self.think = GameTurret.turret_breach_finish_init; self.nextthink = GameBase.level.time + Defines.FRAMETIME; GameBase.gi.linkentity(self); --- 112,118 ---- self.move_angles[Defines.YAW] = self.ideal_yaw; ! self.blocked = turret_blocked; ! self.think = turret_breach_finish_init; self.nextthink = GameBase.level.time + Defines.FRAMETIME; GameBase.gi.linkentity(self); *************** *** 128,132 **** self.movetype = Defines.MOVETYPE_PUSH; GameBase.gi.setmodel(self, self.model); ! self.blocked = GameTurret.turret_blocked; GameBase.gi.linkentity(self); } --- 128,132 ---- self.movetype = Defines.MOVETYPE_PUSH; GameBase.gi.setmodel(self, self.model); ! self.blocked = turret_blocked; GameBase.gi.linkentity(self); } *************** *** 150,154 **** self.viewheight = 24; ! self.die = GameTurret.turret_driver_die; self.monsterinfo.stand = M_Infantry.infantry_stand; --- 150,154 ---- self.viewheight = 24; ! self.die = turret_driver_die; self.monsterinfo.stand = M_Infantry.infantry_stand; *************** *** 166,170 **** if (GameBase.st.item != null) { ! self.item = GameUtil.FindItemByClassname(GameBase.st.item); if (self.item == null) GameBase.gi.dprintf(self.classname + " at " --- 166,170 ---- if (GameBase.st.item != null) { ! self.item = GameItems.FindItemByClassname(GameBase.st.item); if (self.item == null) GameBase.gi.dprintf(self.classname + " at " *************** *** 173,177 **** } ! self.think = GameTurret.turret_driver_link; self.nextthink = GameBase.level.time + Defines.FRAMETIME; --- 173,177 ---- } ! self.think = turret_driver_link; self.nextthink = GameBase.level.time + Defines.FRAMETIME; *************** *** 180,184 **** static EntBlockedAdapter turret_blocked = new EntBlockedAdapter() { ! public void blocked(edict_t self, edict_t other) { edict_t attacker; --- 180,184 ---- static EntBlockedAdapter turret_blocked = new EntBlockedAdapter() { ! public String getID() { return "turret_blocked"; } public void blocked(edict_t self, edict_t other) { edict_t attacker; *************** *** 189,193 **** else attacker = self.teammaster; ! GameUtil.T_Damage(other, self, attacker, Globals.vec3_origin, other.s.origin, Globals.vec3_origin, self.teammaster.dmg, 10, 0, Defines.MOD_CRUSH); --- 189,193 ---- else attacker = self.teammaster; ! GameCombat.T_Damage(other, self, attacker, Globals.vec3_origin, other.s.origin, Globals.vec3_origin, self.teammaster.dmg, 10, 0, Defines.MOD_CRUSH); *************** *** 197,200 **** --- 197,201 ---- static EntThinkAdapter turret_breach_think = new EntThinkAdapter() { + public String getID() { return "turret_breach_think"; } public boolean think(edict_t self) { *************** *** 204,210 **** Math3D.VectorCopy(self.s.angles, current_angles); ! GameTurret.AnglesNormalize(current_angles); ! GameTurret.AnglesNormalize(self.move_angles); if (self.move_angles[Defines.PITCH] > 180) self.move_angles[Defines.PITCH] -= 360; --- 205,211 ---- Math3D.VectorCopy(self.s.angles, current_angles); ! AnglesNormalize(current_angles); ! AnglesNormalize(self.move_angles); if (self.move_angles[Defines.PITCH] > 180) self.move_angles[Defines.PITCH] -= 360; *************** *** 305,309 **** if ((self.spawnflags & 65536) != 0) { ! GameTurret.turret_breach_fire(self); self.spawnflags &= ~65536; } --- 306,310 ---- if ((self.spawnflags & 65536) != 0) { ! turret_breach_fire(self); self.spawnflags &= ~65536; } *************** *** 314,317 **** --- 315,319 ---- static EntThinkAdapter turret_breach_finish_init = new EntThinkAdapter() { + public String getID() { return "turret_breach_finish_init"; } public boolean think(edict_t self) { *************** *** 340,343 **** --- 342,346 ---- */ static EntDieAdapter turret_driver_die = new EntDieAdapter() { + public String getID() { return "turret_driver_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { *************** *** 365,368 **** --- 368,372 ---- static EntThinkAdapter turret_driver_think = new EntThinkAdapter() { + public String getID() { return "turret_driver_think"; } public boolean think(edict_t self) { *************** *** 417,420 **** --- 421,425 ---- public static EntThinkAdapter turret_driver_link = new EntThinkAdapter() { + public String getID() { return "turret_driver_link"; } public boolean think(edict_t self) { *************** *** 437,445 **** Math3D.VectorSubtract(self.s.origin, self.target_ent.s.origin, vec); Math3D.vectoangles(vec, vec); ! GameTurret.AnglesNormalize(vec); self.move_origin[1] = vec[1]; ! ! self.move_origin[2] = self.s.origin[2] ! - self.target_ent.s.origin[2]; // add the driver to the end of them team chain --- 442,449 ---- Math3D.VectorSubtract(self.s.origin, self.target_ent.s.origin, vec); Math3D.vectoangles(vec, vec); ! AnglesNormalize(vec); ! self.move_origin[1] = vec[1]; ! self.move_origin[2] = self.s.origin[2] - self.target_ent.s.origin[2]; // add the driver to the end of them team chain Index: PlayerView.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/PlayerView.java,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -C2 -d -r1.3 -r1.3.6.1 *** PlayerView.java 6 Feb 2005 19:13:56 -0000 1.3 --- PlayerView.java 25 Dec 2005 18:11:19 -0000 1.3.6.1 *************** *** 42,46 **** /* ! * =============== SV_CalcRoll * * =============== --- 42,47 ---- /* ! * =============== ! * SV_CalcRoll * * =============== *************** *** 66,72 **** /* ! * =============== P_DamageFeedback * ! * Handles color blends and view kicks =============== */ --- 67,75 ---- /* ! * =============== ! * P_DamageFeedback * ! * Handles color blends and view kicks ! * =============== */ *************** *** 159,162 **** --- 162,167 ---- // the color of the blend will vary based on how much was absorbed // by different armors + // + Math3D.VectorClear(v); if (client.damage_parmor != 0) *************** *** 209,213 **** /* ! * =============== SV_CalcViewOffset * * Auto pitching on slopes? --- 214,219 ---- /* ! * =============== ! * SV_CalcViewOffset * * Auto pitching on slopes? *************** *** 336,340 **** /* ! * ============== SV_CalcGunOffset ============== */ public static void SV_CalcGunOffset(edict_t ent) { --- 342,348 ---- /* ! * ============== ! * SV_CalcGunOffset ! * ============== */ public static void SV_CalcGunOffset(edict_t ent) { *************** *** 381,385 **** /* ! * ============= SV_AddBlend ============= */ public static void SV_AddBlend(float r, float g, float b, float a, --- 389,395 ---- /* ! * ============= ! * SV_AddBlend ! * ============= */ public static void SV_AddBlend(float r, float g, float b, float a, *************** *** 399,403 **** /* ! * ============= SV_CalcBlend ============= */ public static void SV_CalcBlend(edict_t ent) { --- 409,415 ---- /* ! * ============= ! * SV_CalcBlend ! * ============= */ public static void SV_CalcBlend(edict_t ent) { *************** *** 483,487 **** /* ! * ================= P_FallingDamage ================= */ public static void P_FallingDamage(edict_t ent) { --- 495,501 ---- /* ! * ================= ! * P_FallingDamage ! * ================= */ public static void P_FallingDamage(edict_t ent) { *************** *** 544,548 **** if (GameBase.deathmatch.value == 0 || 0 == ((int) GameBase.dmflags.value & Defines.DF_NO_FALLING)) ! GameUtil.T_Damage(ent, GameBase.g_edicts[0], GameBase.g_edicts[0], dir, ent.s.origin, Globals.vec3_origin, damage, 0, 0, Defines.MOD_FALLING); --- 558,562 ---- if (GameBase.deathmatch.value == 0 || 0 == ((int) GameBase.dmflags.value & Defines.DF_NO_FALLING)) ! GameCombat.T_Damage(ent, GameBase.g_edicts[0], GameBase.g_edicts[0], dir, ent.s.origin, Globals.vec3_origin, damage, 0, 0, Defines.MOD_FALLING); *************** *** 554,558 **** /* ! * ============= P_WorldEffects ============= */ public static void P_WorldEffects() { --- 568,574 ---- /* ! * ============= ! * P_WorldEffects ! * ============= */ public static void P_WorldEffects() { *************** *** 578,582 **** // if (old_waterlevel == 0 && waterlevel != 0) { ! GameWeapon.PlayerNoise(current_player, current_player.s.origin, Defines.PNOISE_SELF); if ((current_player.watertype & Defines.CONTENTS_LAVA) != 0) --- 594,598 ---- // if (old_waterlevel == 0 && waterlevel != 0) { ! PlayerWeapon.PlayerNoise(current_player, current_player.s.origin, Defines.PNOISE_SELF); if ((current_player.watertype & Defines.CONTENTS_LAVA) != 0) *************** *** 602,606 **** // if (old_waterlevel != 0 && waterlevel == 0) { ! GameWeapon.PlayerNoise(current_player, current_player.s.origin, Defines.PNOISE_SELF); GameBase.gi --- 618,622 ---- // if (old_waterlevel != 0 && waterlevel == 0) { ! PlayerWeapon.PlayerNoise(current_player, current_player.s.origin, Defines.PNOISE_SELF); GameBase.gi *************** *** 628,632 **** GameBase.gi.soundindex("player/gasp1.wav"), 1, Defines.ATTN_NORM, 0); ! GameWeapon.PlayerNoise(current_player, current_player.s.origin, Defines.PNOISE_SELF); } else if (current_player.air_finished < GameBase.level.time + 11) { // just --- 644,648 ---- GameBase.gi.soundindex("player/gasp1.wav"), 1, Defines.ATTN_NORM, 0); ! PlayerWeapon.PlayerNoise(current_player, current_player.s.origin, Defines.PNOISE_SELF); } else if (current_player.air_finished < GameBase.level.time + 11) { // just *************** *** 657,661 **** 1, Defines.ATTN_NORM, 0); current_client.breather_sound ^= 1; ! GameWeapon.PlayerNoise(current_player, current_player.s.origin, Defines.PNOISE_SELF); //FIXME: release a bubble? --- 673,677 ---- 1, Defines.ATTN_NORM, 0); current_client.breather_sound ^= 1; ! PlayerWeapon.PlayerNoise(current_player, current_player.s.origin, Defines.PNOISE_SELF); //FIXME: release a bubble? *************** *** 690,694 **** current_player.pain_debounce_time = GameBase.level.time; ! GameUtil.T_Damage(current_player, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, current_player.s.origin, Globals.vec3_origin, --- 706,710 ---- current_player.pain_debounce_time = GameBase.level.time; ! GameCombat.T_Damage(current_player, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, current_player.s.origin, Globals.vec3_origin, *************** *** 723,732 **** if (envirosuit) // take 1/3 damage with envirosuit ! GameUtil.T_Damage(current_player, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, current_player.s.origin, Globals.vec3_origin, 1 * waterlevel, 0, 0, Defines.MOD_LAVA); else ! GameUtil.T_Damage(current_player, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, current_player.s.origin, Globals.vec3_origin, --- 739,748 ---- if (envirosuit) // take 1/3 damage with envirosuit ! GameCombat.T_Damage(current_player, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, current_player.s.origin, Globals.vec3_origin, 1 * waterlevel, 0, 0, Defines.MOD_LAVA); else ! GameCombat.T_Damage(current_player, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, current_player.s.origin, Globals.vec3_origin, *************** *** 736,740 **** if ((current_player.watertype & Defines.CONTENTS_SLIME) != 0) { if (!envirosuit) { // no damage from slime with envirosuit ! GameUtil.T_Damage(current_player, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, current_player.s.origin, Globals.vec3_origin, --- 752,756 ---- if ((current_player.watertype & Defines.CONTENTS_SLIME) != 0) { if (!envirosuit) { // no damage from slime with envirosuit ! GameCombat.T_Damage(current_player, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, current_player.s.origin, Globals.vec3_origin, *************** *** 746,750 **** /* ! * =============== G_SetClientEffects =============== */ public static void G_SetClientEffects(edict_t ent) { --- 762,768 ---- /* ! * =============== ! * G_SetClientEffects ! * =============== */ public static void G_SetClientEffects(edict_t ent) { *************** *** 759,763 **** if (ent.powerarmor_time > GameBase.level.time) { ! pa_type = GameUtil.PowerArmorType(ent); if (pa_type == Defines.POWER_ARMOR_SCREEN) { ent.s.effects |= Defines.EF_POWERSCREEN; --- 777,781 ---- if (ent.powerarmor_time > GameBase.level.time) { ! pa_type = GameItems.PowerArmorType(ent); if (pa_type == Defines.POWER_ARMOR_SCREEN) { ent.s.effects |= Defines.EF_POWERSCREEN; *************** *** 790,794 **** /* ! * =============== G_SetClientEvent =============== */ public static void G_SetClientEvent(edict_t ent) { --- 808,814 ---- /* ! * =============== ! * G_SetClientEvent ! * =============== */ public static void G_SetClientEvent(edict_t ent) { *************** *** 803,807 **** /* ! * =============== G_SetClientSound =============== */ public static void G_SetClientSound(edict_t ent) { --- 823,829 ---- /* ! * =============== ! * G_SetClientSound ! * =============== */ public static void G_SetClientSound(edict_t ent) { *************** *** 841,845 **** /* ! * =============== G_SetClientFrame =============== */ public static void G_SetClientFrame(edict_t ent) { --- 863,869 ---- /* ! * =============== ! * G_SetClientFrame ! * =============== */ public static void G_SetClientFrame(edict_t ent) { *************** *** 928,935 **** /* ! * ================= ClientEndServerFrame * * Called for each player at the end of the server frame and right after ! * spawning ================= */ public static void ClientEndServerFrame(edict_t ent) { --- 952,961 ---- /* ! * ================= ! * ClientEndServerFrame * * Called for each player at the end of the server frame and right after ! * spawning ! * ================= */ public static void ClientEndServerFrame(edict_t ent) { --- NEW FILE: GameCombat.java --- /* 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 16.11.2005 by RST. // $Id: GameCombat.java,v 1.2.2.2 2005/12/25 18:11:20 cawe Exp $ package jake2.game; import jake2.Defines; import jake2.Globals; import jake2.qcommon.Com; import jake2.util.Math3D; public class GameCombat { /* * ============ CanDamage * * Returns true if the inflictor can directly damage the target. Used for * explosions and melee attacks. ============ */ static boolean CanDamage(edict_t targ, edict_t inflictor) { float[] dest = { 0, 0, 0 }; trace_t trace; // bmodels need special checking because their origin is 0,0,0 if (targ.movetype == Defines.MOVETYPE_PUSH) { Math3D.VectorAdd(targ.absmin, targ.absmax, dest); Math3D.VectorScale(dest, 0.5f, dest); trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin, Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID); if (trace.fraction == 1.0f) return true; if (trace.ent == targ) return true; return false; } trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin, Globals.vec3_origin, targ.s.origin, inflictor, Defines.MASK_SOLID); if (trace.fraction == 1.0) return true; Math3D.VectorCopy(targ.s.origin, dest); dest[0] += 15.0; dest[1] += 15.0; trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin, Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID); if (trace.fraction == 1.0) return true; Math3D.VectorCopy(targ.s.origin, dest); dest[0] += 15.0; dest[1] -= 15.0; trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin, Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID); if (trace.fraction == 1.0) return true; Math3D.VectorCopy(targ.s.origin, dest); dest[0] -= 15.0; dest[1] += 15.0; trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin, Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID); if (trace.fraction == 1.0) return true; Math3D.VectorCopy(targ.s.origin, dest); dest[0] -= 15.0; dest[1] -= 15.0; trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin, Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID); if (trace.fraction == 1.0) return true; return false; } /* * ============ Killed ============ */ public static void Killed(edict_t targ, edict_t inflictor, edict_t attacker, int damage, float[] point) { Com.DPrintf("Killing a " + targ.classname + "\n"); if (targ.health < -999) targ.health = -999; //Com.Println("Killed:" + targ.classname); targ.enemy = attacker; if ((targ.svflags & Defines.SVF_MONSTER) != 0 && (targ.deadflag != Defines.DEAD_DEAD)) { // targ.svflags |= SVF_DEADMONSTER; // now treat as a different // content type if (0 == (targ.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) { GameBase.level.killed_monsters++; if (GameBase.coop.value != 0 && attacker.client != null) attacker.client.resp.score++; // medics won't heal monsters that they kill themselves if (attacker.classname.equals("monster_medic")) targ.owner = attacker; } } if (targ.movetype == Defines.MOVETYPE_PUSH || targ.movetype == Defines.MOVETYPE_STOP || targ.movetype == Defines.MOVETYPE_NONE) { // doors, triggers, // etc targ.die.die(targ, inflictor, attacker, damage, point); return; } if ((targ.svflags & Defines.SVF_MONSTER) != 0 && (targ.deadflag != Defines.DEAD_DEAD)) { targ.touch = null; Monster.monster_death_use(targ); } targ.die.die(targ, inflictor, attacker, damage, point); } /* * ================ SpawnDamage ================ */ static void SpawnDamage(int type, float[] origin, float[] normal, int damage) { if (damage > 255) damage = 255; GameBase.gi.WriteByte(Defines.svc_temp_entity); GameBase.gi.WriteByte(type); // gi.WriteByte (damage); GameBase.gi.WritePosition(origin); GameBase.gi.WriteDir(normal); GameBase.gi.multicast(origin, Defines.MULTICAST_PVS); } static int CheckPowerArmor(edict_t ent, float[] point, float[] normal, int damage, int dflags) { gclient_t client; int save; int power_armor_type; int index = 0; int damagePerCell; int pa_te_type; int power = 0; int power_used; if (damage == 0) return 0; client = ent.client; if ((dflags & Defines.DAMAGE_NO_ARMOR) != 0) return 0; if (client != null) { power_armor_type = GameItems.PowerArmorType(ent); if (power_armor_type != Defines.POWER_ARMOR_NONE) { index = GameItems.ITEM_INDEX(GameItems.FindItem("Cells")); power = client.pers.inventory[index]; } } else if ((ent.svflags & Defines.SVF_MONSTER) != 0) { power_armor_type = ent.monsterinfo.power_armor_type; power = ent.monsterinfo.power_armor_power; } else return 0; if (power_armor_type == Defines.POWER_ARMOR_NONE) return 0; if (power == 0) return 0; if (power_armor_type == Defines.POWER_ARMOR_SCREEN) { float[] vec = { 0, 0, 0 }; float dot; float[] forward = { 0, 0, 0 }; // only works if damage point is in front Math3D.AngleVectors(ent.s.angles, forward, null, null); Math3D.VectorSubtract(point, ent.s.origin, vec); Math3D.VectorNormalize(vec); dot = Math3D.DotProduct(vec, forward); if (dot <= 0.3) return 0; damagePerCell = 1; pa_te_type = Defines.TE_SCREEN_SPARKS; damage = damage / 3; } else { damagePerCell = 2; pa_te_type = Defines.TE_SHIELD_SPARKS; damage = (2 * damage) / 3; } save = power * damagePerCell; if (save == 0) return 0; if (save > damage) save = damage; SpawnDamage(pa_te_type, point, normal, save); ent.powerarmor_time = GameBase.level.time + 0.2f; power_used = save / damagePerCell; if (client != null) client.pers.inventory[index] -= power_used; else ent.monsterinfo.power_armor_power -= power_used; return save; } static int CheckArmor(edict_t ent, float[] point, float[] normal, int damage, int te_sparks, int dflags) { gclient_t client; int save; int index; gitem_t armor; if (damage == 0) return 0; client = ent.client; if (client == null) return 0; if ((dflags & Defines.DAMAGE_NO_ARMOR) != 0) return 0; index = GameItems.ArmorIndex(ent); if (index == 0) return 0; armor = GameItems.GetItemByIndex(index); gitem_armor_t garmor = (gitem_armor_t) armor.info; if (0 != (dflags & Defines.DAMAGE_ENERGY)) save = (int) Math.ceil(garmor.energy_protection * damage); else save = (int) Math.ceil(garmor.normal_protection * damage); if (save >= client.pers.inventory[index]) save = client.pers.inventory[index]; if (save == 0) return 0; client.pers.inventory[index] -= save; SpawnDamage(te_sparks, point, normal, save); return save; } public static void M_ReactToDamage(edict_t targ, edict_t attacker) { if ((null != attacker.client) && 0 != (attacker.svflags & Defines.SVF_MONSTER)) return; if (attacker == targ || attacker == targ.enemy) return; // if we are a good guy monster and our attacker is a player // or another good guy, do not get mad at them if (0 != (targ.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) { if (attacker.client != null || (attacker.monsterinfo.aiflags & Defines.AI_GOOD_GUY) != 0) return; } // we now know that we are not both good guys // if attacker is a client, get mad at them because he's good and we're // not if (attacker.client != null) { targ.monsterinfo.aiflags &= ~Defines.AI_SOUND_TARGET; // this can only happen in coop (both new and old enemies are // clients) // only switch if can't see the current enemy if (targ.enemy != null && targ.enemy.client != null) { if (GameUtil.visible(targ, targ.enemy)) { targ.oldenemy = attacker; return; } targ.oldenemy = targ.enemy; } targ.enemy = attacker; if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED)) GameUtil.FoundTarget(targ); return; } // it's the same base (walk/swim/fly) type and a different classname and // it's not a tank // (they spray too much), get mad at them if (((targ.flags & (Defines.FL_FLY | Defines.FL_SWIM)) == (attacker.flags & (Defines.FL_FLY | Defines.FL_SWIM))) && (!(targ.classname.equals(attacker.classname))) && (!(attacker.classname.equals("monster_tank"))) && (!(attacker.classname.equals("monster_supertank"))) && (!(attacker.classname.equals("monster_makron"))) && (!(attacker.classname.equals("monster_jorg")))) { if (targ.enemy != null && targ.enemy.client != null) targ.oldenemy = targ.enemy; targ.enemy = attacker; if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED)) GameUtil.FoundTarget(targ); } // if they *meant* to shoot us, then shoot back else if (attacker.enemy == targ) { if (targ.enemy != null && targ.enemy.client != null) targ.oldenemy = targ.enemy; targ.enemy = attacker; if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED)) GameUtil.FoundTarget(targ); } // otherwise get mad at whoever they are mad at (help our buddy) unless // it is us! else if (attacker.enemy != null && attacker.enemy != targ) { if (targ.enemy != null && targ.enemy.client != null) targ.oldenemy = targ.enemy; targ.enemy = attacker.enemy; if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED)) GameUtil.FoundTarget(targ); } } static boolean CheckTeamDamage(edict_t targ, edict_t attacker) { //FIXME make the next line real and uncomment this block // if ((ability to damage a teammate == OFF) && (targ's team == // attacker's team)) return false; } /* * ============ T_RadiusDamage ============ */ static void T_RadiusDamage(edict_t inflictor, edict_t attacker, float damage, edict_t ignore, float radius, int mod) { float points; EdictIterator edictit = null; float[] v = { 0, 0, 0 }; float[] dir = { 0, 0, 0 }; while ((edictit = GameBase.findradius(edictit, inflictor.s.origin, radius)) != null) { edict_t ent = edictit.o; if (ent == ignore) continue; if (ent.takedamage == 0) continue; Math3D.VectorAdd(ent.mins, ent.maxs, v); Math3D.VectorMA(ent.s.origin, 0.5f, v, v); Math3D.VectorSubtract(inflictor.s.origin, v, v); points = damage - 0.5f * Math3D.VectorLength(v); if (ent == attacker) points = points * 0.5f; if (points > 0) { if (CanDamage(ent, inflictor)) { Math3D.VectorSubtract(ent.s.origin, inflictor.s.origin, dir); T_Damage(ent, inflictor, attacker, dir, inflictor.s.origin, Globals.vec3_origin, (int) points, (int) points, Defines.DAMAGE_RADIUS, mod); } } } } public static void T_Damage(edict_t targ, edict_t inflictor, edict_t attacker, float[] dir, float[] point, float[] normal, int damage, int knockback, int dflags, int mod) { gclient_t client; int take; int save; int asave; int psave; int te_sparks; if (targ.takedamage == 0) return; // friendly fire avoidance // if enabled you can't hurt teammates (but you can hurt yourself) // knockback still occurs if ((targ != attacker) && ((GameBase.deathmatch.value != 0 && 0 != ((int) (GameBase.dmflags.value) & (Defines.DF_MODELTEAMS | Defines.DF_SKINTEAMS))) || GameBase.coop.value != 0)) { if (GameUtil.OnSameTeam(targ, attacker)) { if (((int) (GameBase.dmflags.value) & Defines.DF_NO_FRIENDLY_FIRE) != 0) damage = 0; else mod |= Defines.MOD_FRIENDLY_FIRE; } } GameBase.meansOfDeath = mod; // easy mode takes half damage if (GameBase.skill.value == 0 && GameBase.deathmatch.value == 0 && targ.client != null) { damage *= 0.5; if (damage == 0) damage = 1; } client = targ.client; if ((dflags & Defines.DAMAGE_BULLET) != 0) te_sparks = Defines.TE_BULLET_SPARKS; else te_sparks = Defines.TE_SPARKS; Math3D.VectorNormalize(dir); // bonus damage for suprising a monster if (0 == (dflags & Defines.DAMAGE_RADIUS) && (targ.svflags & Defines.SVF_MONSTER) != 0 && (attacker.client != null) && (targ.enemy == null) && (targ.health > 0)) damage *= 2; if ((targ.flags & Defines.FL_NO_KNOCKBACK) != 0) knockback = 0; // figure momentum add if (0 == (dflags & Defines.DAMAGE_NO_KNOCKBACK)) { if ((knockback != 0) && (targ.movetype != Defines.MOVETYPE_NONE) && (targ.movetype != Defines.MOVETYPE_BOUNCE) && (targ.movetype != Defines.MOVETYPE_PUSH) && (targ.movetype != Defines.MOVETYPE_STOP)) { float[] kvel = { 0, 0, 0 }; float mass; if (targ.mass < 50) mass = 50; else mass = targ.mass; if (targ.client != null && attacker == targ) Math3D.VectorScale(dir, 1600.0f * (float) knockback / mass, kvel); // the rocket jump hack... else Math3D.VectorScale(dir, 500.0f * (float) knockback / mass, kvel); Math3D.VectorAdd(targ.velocity, kvel, targ.velocity); } } take = damage; save = 0; // check for godmode if ((targ.flags & Defines.FL_GODMODE) != 0 && 0 == (dflags & Defines.DAMAGE_NO_PROTECTION)) { take = 0; save = damage; SpawnDamage(te_sparks, point, normal, save); } // check for invincibility if ((client != null && client.invincible_framenum > GameBase.level.framenum) && 0 == (dflags & Defines.DAMAGE_NO_PROTECTION)) { if (targ.pain_debounce_time < GameBase.level.time) { GameBase.gi.sound(targ, Defines.CHAN_ITEM, GameBase.gi .soundindex("items/protect4.wav"), 1, Defines.ATTN_NORM, 0); targ.pain_debounce_time = GameBase.level.time + 2; } take = 0; save = damage; } psave = CheckPowerArmor(targ, point, normal, take, dflags); take -= psave; asave = CheckArmor(targ, point, normal, take, te_sparks, dflags); take -= asave; // treat cheat/powerup savings the same as armor asave += save; // team damage avoidance if (0 == (dflags & Defines.DAMAGE_NO_PROTECTION) && CheckTeamDamage(targ, attacker)) return; // do the damage if (take != 0) { if (0 != (targ.svflags & Defines.SVF_MONSTER) || (client != null)) SpawnDamage(Defines.TE_BLOOD, point, normal, take); else SpawnDamage(te_sparks, point, normal, take); targ.health = targ.health - take; if (targ.health <= 0) { if ((targ.svflags & Defines.SVF_MONSTER) != 0 || (client != null)) targ.flags |= Defines.FL_NO_KNOCKBACK; Killed(targ, inflictor, attacker, take, point); return; } } if ((targ.svflags & Defines.SVF_MONSTER) != 0) { M_ReactToDamage(targ, attacker); if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED) && (take != 0)) { targ.pain.pain(targ, attacker, knockback, take); // nightmare mode monsters don't go into pain frames often if (GameBase.skill.value == 3) targ.pain_debounce_time = GameBase.level.time + 5; } } else if (client != null) { if (((targ.flags & Defines.FL_GODMODE) == 0) && (take != 0)) targ.pain.pain(targ, attacker, knockback, take); } else if (take != 0) { if (targ.pain != null) targ.pain.pain(targ, attacker, knockback, take); } // add to the damage inflicted on a player this frame // the total will be turned into screen blends and view angle kicks // at the end of the frame if (client != null) { client.damage_parmor += psave; client.damage_armor += asave; client.damage_blood += take; client.damage_knockback += knockback; Math3D.VectorCopy(point, client.damage_from); } } } --- NEW FILE: GameItems.java --- /* 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. */ [...1321 lines suppressed...] } if (0 == (ent.spawnflags & Defines.ITEM_TARGETS_USED)) { GameUtil.G_UseTargets(ent, other); ent.spawnflags |= Defines.ITEM_TARGETS_USED; } if (!taken) return; if (!((GameBase.coop.value != 0) && (ent.item.flags & Defines.IT_STAY_COOP) != 0) || 0 != (ent.spawnflags & (Defines.DROPPED_ITEM | Defines.DROPPED_PLAYER_ITEM))) { if ((ent.flags & Defines.FL_RESPAWN) != 0) ent.flags &= ~Defines.FL_RESPAWN; else GameUtil.G_FreeEdict(ent); } } } Index: ItemUseAdapter.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/ItemUseAdapter.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.16.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.16.1 *** ItemUseAdapter.java 7 Jul 2004 19:59:07 -0000 1.1.1.1 --- ItemUseAdapter.java 25 Dec 2005 18:11:20 -0000 1.1.1.1.16.1 *************** *** 24,28 **** package jake2.game; ! class ItemUseAdapter extends SuperAdapter { public void use(edict_t ent, gitem_t item) { } --- 24,28 ---- package jake2.game; ! public abstract class ItemUseAdapter extends SuperAdapter { public void use(edict_t ent, gitem_t item) { } Index: PlayerClient.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/PlayerClient.java,v retrieving revision 1.9 retrieving revision 1.9.6.1 diff -C2 -d -r1.9 -r1.9.6.1 *** PlayerClient.java 19 Feb 2005 21:20:10 -0000 1.9 --- PlayerClient.java 25 Dec 2005 18:11:19 -0000 1.9.6.1 *************** *** 20,27 **** --- 20,31 ---- // Created on 28.12.2003 by RST. + // $Id$ + package jake2.game; import jake2.Defines; + import jake2.game.monsters.M_Player; + import jake2.game.pmove_t.TraceAdapter; import jake2.util.Lib; import jake2.util.Math3D; *************** *** 29,32 **** --- 33,254 ---- public class PlayerClient { + public static int player_die_i = 0; + /* + * ================== + * player_die + * ================== + */ + static EntDieAdapter player_die = new EntDieAdapter() { + public String getID() { return "player_die"; } + public void die(edict_t self, edict_t inflictor, edict_t attacker, + int damage, float[] point) { + int n; + + Math3D.VectorClear(self.avelocity); + + self.takedamage = Defines.DAMAGE_YES; + self.movetype = Defines.MOVETYPE_TOSS; + + self.s.modelindex2 = 0; // remove linked weapon model + + self.s.angles[0] = 0; + self.s.angles[2] = 0; + + self.s.sound = 0; + self.client.weapon_sound = 0; + + self.maxs[2] = -8; + + // self.solid = SOLID_NOT; + self.svflags |= Defines.SVF_DEADMONSTER; + + if (self.deadflag == 0) { + self.client.respawn_time = GameBase.level.time + 1.0f; + PlayerClient.LookAtKiller(self, inflictor, attacker); + self.client.ps.pmove.pm_type = Defines.PM_DEAD; + ClientObituary(self, inflictor, attacker); + PlayerClient.TossClientWeapon(self); + if (GameBase.deathmatch.value != 0) + Cmd.Help_f(self); // show scores + + // clear inventory + // this is kind of ugly, but it's how we want to handle keys in + // coop + for (n = 0; n < GameBase.game.num_items; n++) { + if (GameBase.coop.value != 0 + && (GameItemList.itemlist[n].flags & Defines.IT_KEY) != 0) + self.client.resp.coop_respawn.inventory[n] = self.client.pers.inventory[n]; + self.client.pers.inventory[n] = 0; + } + } + + // remove powerups + self.client.quad_framenum = 0; + self.client.invincible_framenum = 0; + self.client.breather_framenum = 0; + self.client.enviro_framenum = 0; + self.flags &= ~Defines.FL_POWER_ARMOR; + + if (self.health < -40) { // gib + GameBase.gi + .sound(self, Defines.CHAN_BODY, GameBase.gi + .soundindex("misc/udeath.wav"), 1, + Defines.ATTN_NORM, 0); + for (n = 0; n < 4; n++) + GameMisc.ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", + damage, Defines.GIB_ORGANIC); + GameMisc.ThrowClientHead(self, damage); + + self.takedamage = Defines.DAMAGE_NO; + } else { // normal death + if (self.deadflag == 0) { + + player_die_i = (player_die_i + 1) % 3; + // start a death animation + self.client.anim_priority = Defines.ANIM_DEATH; + if ((self.client.ps.pmove.pm_flags & pmove_t.PMF_DUCKED) != 0) { + self.s.frame = M_Player.FRAME_crdeath1 - 1; + self.client.anim_end = M_Player.FRAME_crdeath5; + } else + switch (player_die_i) { + case 0: + self.s.frame = M_Player.FRAME_death101 - 1; + self.client.anim_end = M_Player.FRAME_death106; + break; + case 1: + self.s.frame = M_Player.FRAME_death201 - 1; + self.client.anim_end = M_Player.FRAME_death206; + break; + case 2: + self.s.frame = M_Player.FRAME_death301 - 1; + self.client.anim_end = M_Player.FRAME_death308; + break; + } + + GameBase.gi.sound(self, Defines.CHAN_VOICE, GameBase.gi + .soundindex("*death" + ((Lib.rand() % 4) + 1) + + ".wav"), 1, Defines.ATTN_NORM, 0); + } + } + + self.deadflag = Defines.DEAD_DEAD; + + GameBase.gi.linkentity(self); + } + }; + static EntThinkAdapter SP_FixCoopSpots = new EntThinkAdapter() { + public String getID() { return "SP_FixCoopSpots"; } + public boolean think(edict_t self) { + + edict_t spot; + float[] d = { 0, 0, 0 }; + + spot = null; + EdictIterator es = null; + + while (true) { + es = GameBase.G_Find(es, GameBase.findByClass, + "info_player_start"); + + if (es == null) + return true; + + spot = es.o; + + if (spot.targetname == null) + continue; + Math3D.VectorSubtract(self.s.origin, spot.s.origin, d); + if (Math3D.VectorLength(d) < 384) { + if ((self.targetname == null) + || Lib.Q_stricmp(self.targetname, spot.targetname) != 0) { + // gi.dprintf("FixCoopSpots changed %s at %s targetname + // from %s to %s\n", self.classname, + // vtos(self.s.origin), self.targetname, + // spot.targetname); + self.targetname = spot.targetn... [truncated message content] |
From: Carsten W. <ca...@us...> - 2005-12-25 18:12:03
|
Update of /cvsroot/jake2/jake2/src/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27365/src/jake2/qcommon Modified Files: Tag: render-refactoring Netchan.java Qcommon.java netadr_t.java MSG.java CM.java FS.java Com.java Cbuf.java SZ.java Log Message: merge with current HEAD Index: SZ.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/SZ.java,v retrieving revision 1.5 retrieving revision 1.5.6.1 diff -C2 -d -r1.5 -r1.5.6.1 *** SZ.java 6 Feb 2005 19:26:50 -0000 1.5 --- SZ.java 25 Dec 2005 18:11:22 -0000 1.5.6.1 *************** *** 27,30 **** --- 27,31 ---- import jake2.Defines; + import jake2.util.Lib; /** *************** *** 91,95 **** Com.dprintln("SZ.print():<" + data + ">" ); int length = data.length(); ! byte str[] = data.getBytes(); if (buf.cursize != 0) { --- 92,96 ---- Com.dprintln("SZ.print():<" + data + ">" ); int length = data.length(); ! byte str[] = Lib.stringToBytes(data); if (buf.cursize != 0) { Index: MSG.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/MSG.java,v retrieving revision 1.7 retrieving revision 1.7.6.1 diff -C2 -d -r1.7 -r1.7.6.1 *** MSG.java 19 Feb 2005 21:20:47 -0000 1.7 --- MSG.java 25 Dec 2005 18:11:22 -0000 1.7.6.1 *************** *** 86,90 **** x = ""; ! SZ.Write(sb, x.getBytes()); WriteByte(sb, 0); //Com.dprintln("MSG.WriteString:" + s.replace('\0', '@')); --- 86,90 ---- x = ""; ! SZ.Write(sb, Lib.stringToBytes(x)); WriteByte(sb, 0); //Com.dprintln("MSG.WriteString:" + s.replace('\0', '@')); Index: Cbuf.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Cbuf.java,v retrieving revision 1.7 retrieving revision 1.7.6.1 diff -C2 -d -r1.7 -r1.7.6.1 *** Cbuf.java 19 Feb 2005 11:12:42 -0000 1.7 --- Cbuf.java 25 Dec 2005 18:11:22 -0000 1.7.6.1 *************** *** 146,150 **** return; } ! SZ.Write(Globals.cmd_text, text.getBytes(), l); } --- 146,150 ---- return; } ! SZ.Write(Globals.cmd_text, Lib.stringToBytes(text), l); } Index: CM.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/CM.java,v retrieving revision 1.10 retrieving revision 1.10.6.1 diff -C2 -d -r1.10 -r1.10.6.1 *** CM.java 6 Feb 2005 19:25:14 -0000 1.10 --- CM.java 25 Dec 2005 18:11:22 -0000 1.10.6.1 *************** *** 20,24 **** --- 20,26 ---- // Created on 02.01.2004 by RST. + // $Id$ + package jake2.qcommon; *************** *** 102,106 **** static int numplanes; ! // extra for box hull ( +6) static cplane_t map_planes[] = new cplane_t[Defines.MAX_MAP_PLANES + 6]; --- 104,108 ---- static int numplanes; ! /** Extra for box hull ( +6) */ static cplane_t map_planes[] = new cplane_t[Defines.MAX_MAP_PLANES + 6]; *************** *** 112,116 **** static int numnodes; ! // extra for box hull ( +6) static cnode_t map_nodes[] = new cnode_t[Defines.MAX_MAP_NODES + 6]; --- 114,118 ---- static int numnodes; ! /** Extra for box hull ( +6) */ static cnode_t map_nodes[] = new cnode_t[Defines.MAX_MAP_NODES + 6]; *************** *** 132,136 **** static int numleafbrushes; - //static unsigned short map_leafbrushes[Defines.MAX_MAP_LEAFBRUSHES]; public static int map_leafbrushes[] = new int[Defines.MAX_MAP_LEAFBRUSHES]; --- 134,137 ---- *************** *** 157,162 **** public static byte map_visibility[] = new byte[Defines.MAX_MAP_VISIBILITY]; ! // main visibility data. rst ! // was: static dvis_t *map_vis = (dvis_t *)map_visibility; public static qfiles.dvis_t map_vis = new qfiles.dvis_t(ByteBuffer .wrap(map_visibility)); --- 158,162 ---- public static byte map_visibility[] = new byte[Defines.MAX_MAP_VISIBILITY]; ! /** Main visibility data. */ public static qfiles.dvis_t map_vis = new qfiles.dvis_t(ByteBuffer .wrap(map_visibility)); *************** *** 195,217 **** public static cvar_t map_noareas; - /* - * =============================================================================== - * - * MAP LOADING - * - * =============================================================================== - */ - public static byte cmod_base[]; - // is that right (rst) ? public static int checksum; public static int last_checksum; ! /* ! * ================== CM_LoadMap ! * ! * Loads in the map and all submodels ================== */ public static cmodel_t CM_LoadMap(String name, boolean clientload, --- 195,206 ---- public static cvar_t map_noareas; public static byte cmod_base[]; public static int checksum; public static int last_checksum; ! /** ! * Loads in the map and all submodels. */ public static cmodel_t CM_LoadMap(String name, boolean clientload, *************** *** 304,321 **** map_name = name; - // debug (rst) - /* - * Com.p("Testing pointleafes:"); for (int n = 0; n < 20; n++) { float - * pos[] = new float[] {(float) (Math.random() * 1000), (float) - * (Math.random() * 1000), 0 }; int x = CM_PointLeafnum(pos); - * Com.p(Lib.vtofsbeaty(pos) + " ---> leaf=" + x + " area = " - * +map_leafs[x].area); } - */ return map_cmodels[0]; } ! /* ! * ================= CMod_LoadSubmodels ================= ! */ public static void CMod_LoadSubmodels(lump_t l) { Com.DPrintf("CMod_LoadSubmodels()\n"); --- 293,300 ---- map_name = name; return map_cmodels[0]; } ! /** Loads Submodels. */ public static void CMod_LoadSubmodels(lump_t l) { Com.DPrintf("CMod_LoadSubmodels()\n"); *************** *** 367,373 **** static boolean debugloadmap = false; ! /* ! * ================= CMod_LoadSurfaces ================= ! */ public static void CMod_LoadSurfaces(lump_t l) { Com.DPrintf("CMod_LoadSurfaces()\n"); --- 346,350 ---- static boolean debugloadmap = false; ! /** Loads surfaces. */ public static void CMod_LoadSurfaces(lump_t l) { Com.DPrintf("CMod_LoadSurfaces()\n"); *************** *** 409,417 **** } ! /* ! * ================= CMod_LoadNodes ! * ! * ================= ! */ public static void CMod_LoadNodes(lump_t l) { Com.DPrintf("CMod_LoadNodes()\n"); --- 386,390 ---- } ! /** Loads nodes. */ public static void CMod_LoadNodes(lump_t l) { Com.DPrintf("CMod_LoadNodes()\n"); *************** *** 455,463 **** } ! /* ! * ================= CMod_LoadBrushes ! * ! * ================= ! */ public static void CMod_LoadBrushes(lump_t l) { Com.DPrintf("CMod_LoadBrushes()\n"); --- 428,432 ---- } ! /** Loads brushes.*/ public static void CMod_LoadBrushes(lump_t l) { Com.DPrintf("CMod_LoadBrushes()\n"); *************** *** 496,502 **** } ! /* ! * ================= CMod_LoadLeafs ================= ! */ public static void CMod_LoadLeafs(lump_t l) { Com.DPrintf("CMod_LoadLeafs()\n"); --- 465,469 ---- } ! /** Loads leafs. */ public static void CMod_LoadLeafs(lump_t l) { Com.DPrintf("CMod_LoadLeafs()\n"); *************** *** 566,572 **** } ! /* ! * ================= CMod_LoadPlanes ================= ! */ public static void CMod_LoadPlanes(lump_t l) { Com.DPrintf("CMod_LoadPlanes()\n"); --- 533,537 ---- } ! /** Loads planes. */ public static void CMod_LoadPlanes(lump_t l) { Com.DPrintf("CMod_LoadPlanes()\n"); *************** *** 624,630 **** } ! /* ! * ================= CMod_LoadLeafBrushes ================= ! */ public static void CMod_LoadLeafBrushes(lump_t l) { Com.DPrintf("CMod_LoadLeafBrushes()\n"); --- 589,593 ---- } ! /** Loads leaf brushes. */ public static void CMod_LoadLeafBrushes(lump_t l) { Com.DPrintf("CMod_LoadLeafBrushes()\n"); *************** *** 666,672 **** } ! /* ! * ================= CMod_LoadBrushSides ================= ! */ public static void CMod_LoadBrushSides(lump_t l) { Com.DPrintf("CMod_LoadBrushSides()\n"); --- 629,633 ---- } ! /** Loads brush sides. */ public static void CMod_LoadBrushSides(lump_t l) { Com.DPrintf("CMod_LoadBrushSides()\n"); *************** *** 709,715 **** Com.Error(Defines.ERR_DROP, "Bad brushside texinfo"); ! // rst: some mysterious happens here, even in the original code ???, ! // texinfo is -1!!! ! // hoz: checked against c version: ok. if (j == -1) out.surface = new mapsurface_t(); // just for safety --- 670,674 ---- Com.Error(Defines.ERR_DROP, "Bad brushside texinfo"); ! // java specific handling of -1 if (j == -1) out.surface = new mapsurface_t(); // just for safety *************** *** 723,729 **** } ! /* ! * ================= CMod_LoadAreas ================= ! */ public static void CMod_LoadAreas(lump_t l) { Com.DPrintf("CMod_LoadAreas()\n"); --- 682,686 ---- } ! /** Loads areas. */ public static void CMod_LoadAreas(lump_t l) { Com.DPrintf("CMod_LoadAreas()\n"); *************** *** 765,771 **** } ! /* ! * ================= CMod_LoadAreaPortals ================= ! */ public static void CMod_LoadAreaPortals(lump_t l) { Com.DPrintf("CMod_LoadAreaPortals()\n"); --- 722,726 ---- } ! /** Loads area portals. */ public static void CMod_LoadAreaPortals(lump_t l) { Com.DPrintf("CMod_LoadAreaPortals()\n"); *************** *** 804,810 **** } ! /* ! * ================= CMod_LoadVisibility ================= ! */ public static void CMod_LoadVisibility(lump_t l) { Com.DPrintf("CMod_LoadVisibility()\n"); --- 759,763 ---- } ! /** Loads visibility data. */ public static void CMod_LoadVisibility(lump_t l) { Com.DPrintf("CMod_LoadVisibility()\n"); *************** *** 827,833 **** } ! /* ! * ================= CMod_LoadEntityString ================= ! */ public static void CMod_LoadEntityString(lump_t l) { Com.DPrintf("CMod_LoadEntityString()\n"); --- 780,784 ---- } ! /** Loads entity strings. */ public static void CMod_LoadEntityString(lump_t l) { Com.DPrintf("CMod_LoadEntityString()\n"); *************** *** 847,855 **** } ! /* ! * ================== CM_InlineModel ================== ! */ ! ! // works fine public static cmodel_t InlineModel(String name) { int num; --- 798,802 ---- } ! /** Returns the model with a given id "*" + <number> */ public static cmodel_t InlineModel(String name) { int num; *************** *** 896,901 **** } - //======================================================================= - static cplane_t box_planes[]; --- 843,846 ---- *************** *** 906,915 **** static cleaf_t box_leaf; ! /* ! * =================== CM_InitBoxHull ! * ! * Set up the planes and nodes so that the six floats of a bounding box can * just be stored out and get a proper clipping hull structure. - * =================== */ public static void CM_InitBoxHull() { --- 851,856 ---- static cleaf_t box_leaf; ! /** Set up the planes and nodes so that the six floats of a bounding box can * just be stored out and get a proper clipping hull structure. */ public static void CM_InitBoxHull() { *************** *** 920,924 **** cbrushside_t s; ! box_headnode = numnodes; // noch platz f?r 6 brushes box_planes = new cplane_t[] { map_planes[numplanes], --- 861,865 ---- cbrushside_t s; ! box_headnode = numnodes; //rst: still room for 6 brushes left? box_planes = new cplane_t[] { map_planes[numplanes], *************** *** 981,990 **** } ! /* ! * =================== CM_HeadnodeForBox ! * ! * To keep everything totally uniform, bounding boxes are turned into small ! * BSP trees instead of being compared directly. =================== ! */ public static int HeadnodeForBox(float[] mins, float[] maxs) { box_planes[0].dist = maxs[0]; --- 922,927 ---- } ! /** To keep everything totally uniform, bounding boxes are turned into small ! * BSP trees instead of being compared directly. */ public static int HeadnodeForBox(float[] mins, float[] maxs) { box_planes[0].dist = maxs[0]; *************** *** 1004,1011 **** } ! /* ! * ================== CM_PointLeafnum_r ================== ! */ ! public static int CM_PointLeafnum_r(float[] p, int num) { float d; cnode_t node; --- 941,946 ---- } ! /** Recursively searches the leaf number that contains the 3d point. */ ! private static int CM_PointLeafnum_r(float[] p, int num) { float d; cnode_t node; *************** *** 1031,1054 **** } public static int CM_PointLeafnum(float[] p) { if (numplanes == 0) ! return 0; // sound may call this without map loaded return CM_PointLeafnum_r(p, 0); } - /* - * ============= CM_BoxLeafnums - * - * Fills in a list of all the leafs touched ============= - */ - static int leaf_count, leaf_maxcount; ! static int leaf_list[]; ! static float leaf_mins[], leaf_maxs[]; ! static int leaf_topnode; ! public static void CM_BoxLeafnums_r(int nodenum) { cplane_t plane; cnode_t node; --- 966,988 ---- } + /** Searches the leaf number that contains the 3d point. */ public static int CM_PointLeafnum(float[] p) { + // sound may call this without map loaded if (numplanes == 0) ! return 0; return CM_PointLeafnum_r(p, 0); } ! private static int leaf_count, leaf_maxcount; ! private static int leaf_list[]; ! private static float leaf_mins[], leaf_maxs[]; ! private static int leaf_topnode; ! ! /** Recursively fills in a list of all the leafs touched. */ ! private static void CM_BoxLeafnums_r(int nodenum) { cplane_t plane; cnode_t node; *************** *** 1058,1063 **** if (nodenum < 0) { if (leaf_count >= leaf_maxcount) { ! //TODO: here is still an error. ! //Com.DPrintf("CM_BoxLeafnums_r: overflow\n"); return; } --- 992,996 ---- if (nodenum < 0) { if (leaf_count >= leaf_maxcount) { ! Com.DPrintf("CM_BoxLeafnums_r: overflow\n"); return; } *************** *** 1085,1089 **** } ! public static int CM_BoxLeafnums_headnode(float[] mins, float[] maxs, int list[], int listsize, int headnode, int topnode[]) { leaf_list = list; --- 1018,1023 ---- } ! /** Fills in a list of all the leafs touched and starts with the head node. */ ! private static int CM_BoxLeafnums_headnode(float[] mins, float[] maxs, int list[], int listsize, int headnode, int topnode[]) { leaf_list = list; *************** *** 1103,1106 **** --- 1037,1041 ---- } + /** Fills in a list of all the leafs touched. */ public static int CM_BoxLeafnums(float[] mins, float[] maxs, int list[], int listsize, int topnode[]) { *************** *** 1109,1119 **** } ! /* ! * public static class intwrap1 { public intwrap(int i) { this.i = i; } ! * public int i; } ! */ ! /* ! * ================== CM_PointContents ================== ! */ public static int PointContents(float[] p, int headnode) { int l; --- 1044,1048 ---- } ! /** Returns a tag that describes the content of the point. */ public static int PointContents(float[] p, int headnode) { int l; *************** *** 1512,1518 **** trace_trace.surface = nullsurface.c; ! if (numnodes == 0) // map not loaded ! { ! Com.DPrintf("dummy trace zurueck, da map not loaded!\n"); return trace_trace; } --- 1441,1446 ---- trace_trace.surface = nullsurface.c; ! if (numnodes == 0) { ! // map not loaded return trace_trace; } Index: Com.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Com.java,v retrieving revision 1.12.4.1 retrieving revision 1.12.4.2 diff -C2 -d -r1.12.4.1 -r1.12.4.2 *** Com.java 13 Nov 2005 12:57:56 -0000 1.12.4.1 --- Com.java 25 Dec 2005 18:11:22 -0000 1.12.4.2 *************** *** 52,64 **** public abstract static class RD_Flusher { ! public abstract void rd_flush(int target, byte[] buffer); } static int rd_target; ! static byte[] rd_buffer; static int rd_buffersize; static RD_Flusher rd_flusher; ! public static void BeginRedirect(int target, byte[] buffer, int buffersize, RD_Flusher flush) { if (0 == target || null == buffer || 0 == buffersize || null == flush) --- 52,64 ---- public abstract static class RD_Flusher { ! public abstract void rd_flush(int target, StringBuffer buffer); } static int rd_target; ! static StringBuffer rd_buffer; static int rd_buffersize; static RD_Flusher rd_flusher; ! public static void BeginRedirect(int target, StringBuffer buffer, int buffersize, RD_Flusher flush) { if (0 == target || null == buffer || 0 == buffersize || null == flush) *************** *** 70,74 **** rd_flusher= flush; ! rd_buffer= null; } --- 70,74 ---- rd_flusher= flush; ! rd_buffer.setLength(0); } *************** *** 124,138 **** } return 0; - // // faster than if - // try - // { - // return data[index]; - // } - // catch (Exception e) - // { - // data= null; - // // last char - // return 0; - // } } --- 124,127 ---- *************** *** 145,161 **** } return 0; - // try - // { - // index++; - // return data[index]; - // } - // catch (Exception e) - // { - // data= null; - // // avoid int wraps; - // index--; - // // last char - // return 0; - // } } --- 134,137 ---- *************** *** 367,385 **** } public static void Printf(String fmt, Vargs vargs) { - // Com.Printf is for testing only. String msg= sprintf(_debugContext + fmt, vargs); - if (rd_target != 0) { ! if ((msg.length() + Lib.strlen(rd_buffer)) > (rd_buffersize - 1)) { rd_flusher.rd_flush(rd_target, rd_buffer); ! // *rd_buffer = 0; ! rd_buffer[rd_buffersize]= '\0'; } ! // TODO handle rd_buffer ! // strcat(rd_buffer, msg); return; } --- 343,358 ---- } + /** Prints out messages, which can also be redirected to a remote client. */ public static void Printf(String fmt, Vargs vargs) { String msg= sprintf(_debugContext + fmt, vargs); if (rd_target != 0) { ! if ((msg.length() + rd_buffer.length()) > (rd_buffersize - 1)) { rd_flusher.rd_flush(rd_target, rd_buffer); ! rd_buffer.setLength(0); } ! rd_buffer.append(msg); return; } Index: netadr_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/netadr_t.java,v retrieving revision 1.5 retrieving revision 1.5.10.1 diff -C2 -d -r1.5 -r1.5.10.1 *** netadr_t.java 20 Oct 2004 20:37:32 -0000 1.5 --- netadr_t.java 25 Dec 2005 18:11:22 -0000 1.5.10.1 *************** *** 41,45 **** this.port = 0; // any try { ! this.ip = InetAddress.getByName("localhost").getAddress(); } catch (UnknownHostException e) { } --- 41,46 ---- this.port = 0; // any try { ! // localhost / 127.0.0.1 ! this.ip = InetAddress.getByName(null).getAddress(); } catch (UnknownHostException e) { } *************** *** 51,55 **** return InetAddress.getByName("255.255.255.255"); case Defines.NA_LOOPBACK: ! return InetAddress.getByName("localhost"); case Defines.NA_IP: return InetAddress.getByAddress(ip); --- 52,57 ---- return InetAddress.getByName("255.255.255.255"); case Defines.NA_LOOPBACK: ! // localhost / 127.0.0.1 ! return InetAddress.getByName(null); case Defines.NA_IP: return InetAddress.getByAddress(ip); Index: Qcommon.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Qcommon.java,v retrieving revision 1.19 retrieving revision 1.19.2.1 diff -C2 -d -r1.19 -r1.19.2.1 *** Qcommon.java 1 Jul 2005 14:20:56 -0000 1.19 --- Qcommon.java 25 Dec 2005 18:11:22 -0000 1.19.2.1 *************** *** 75,87 **** Cbuf.Execute(); ! Jake2.Q2Dialog.setStatus("initializing filesystem..."); FS.InitFilesystem(); ! Jake2.Q2Dialog.setStatus("loading config..."); reconfigure(false); FS.setCDDir(); // use cddir from config.cfg FS.markBaseSearchPaths(); // mark the default search paths ! Jake2.Q2Dialog.testQ2Data(); // test for valid baseq2 reconfigure(true); // reload default.cfg and config.cfg --- 75,94 ---- Cbuf.Execute(); ! if (Globals.dedicated.value != 1.0f) ! Jake2.Q2Dialog.setStatus("initializing filesystem..."); ! FS.InitFilesystem(); ! if (Globals.dedicated.value != 1.0f) ! Jake2.Q2Dialog.setStatus("loading config..."); ! reconfigure(false); FS.setCDDir(); // use cddir from config.cfg FS.markBaseSearchPaths(); // mark the default search paths ! ! if (Globals.dedicated.value != 1.0f) ! Jake2.Q2Dialog.testQ2Data(); // test for valid baseq2 ! reconfigure(true); // reload default.cfg and config.cfg *************** *** 111,121 **** Cvar.Get("version", s, CVAR_SERVERINFO | CVAR_NOSET); ! Jake2.Q2Dialog.setStatus("initializing network subsystem..."); NET.Init(); //ok Netchan.Netchan_Init(); //ok ! Jake2.Q2Dialog.setStatus("initializing server subsystem..."); SV_MAIN.SV_Init(); //ok ! Jake2.Q2Dialog.setStatus("initializing client subsystem..."); CL.Init(); --- 118,134 ---- Cvar.Get("version", s, CVAR_SERVERINFO | CVAR_NOSET); ! if (Globals.dedicated.value != 1.0f) ! Jake2.Q2Dialog.setStatus("initializing network subsystem..."); ! NET.Init(); //ok Netchan.Netchan_Init(); //ok ! if (Globals.dedicated.value != 1.0f) ! Jake2.Q2Dialog.setStatus("initializing server subsystem..."); SV_MAIN.SV_Init(); //ok ! ! if (Globals.dedicated.value != 1.0f) ! Jake2.Q2Dialog.setStatus("initializing client subsystem..."); ! CL.Init(); *************** *** 136,140 **** Com.Printf("====== Quake2 Initialized ======\n\n"); ! Jake2.Q2Dialog.dispose(); } catch (longjmpException e) { --- 149,155 ---- Com.Printf("====== Quake2 Initialized ======\n\n"); ! ! if (Globals.dedicated.value != 1.0f) ! Jake2.Q2Dialog.dispose(); } catch (longjmpException e) { *************** *** 241,244 **** --- 256,260 ---- } catch (longjmpException e) { + Com.DPrintf("lonjmp exception:" + e); } } Index: Netchan.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Netchan.java,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** Netchan.java 1 Jul 2005 14:20:56 -0000 1.6 --- Netchan.java 25 Dec 2005 18:11:22 -0000 1.6.2.1 *************** *** 32,35 **** --- 32,36 ---- import jake2.sys.NET; import jake2.sys.Timer; + import jake2.util.Lib; /** *************** *** 141,145 **** public static void OutOfBandPrint(int net_socket, netadr_t adr, String s) { ! Netchan_OutOfBand(net_socket, adr, s.length(), s.getBytes()); } --- 142,146 ---- public static void OutOfBandPrint(int net_socket, netadr_t adr, String s) { ! Netchan_OutOfBand(net_socket, adr, s.length(), Lib.stringToBytes(s)); } |
From: Carsten W. <ca...@us...> - 2005-12-25 18:12:02
|
Update of /cvsroot/jake2/jake2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27365 Modified Files: Tag: render-refactoring build.xml Added Files: Tag: render-refactoring Jake2.bat Log Message: merge with current HEAD Index: build.xml =================================================================== RCS file: /cvsroot/jake2/jake2/build.xml,v retrieving revision 1.26 retrieving revision 1.26.4.1 diff -C2 -d -r1.26 -r1.26.4.1 *** build.xml 7 Jun 2005 08:50:12 -0000 1.26 --- build.xml 25 Dec 2005 18:11:21 -0000 1.26.4.1 *************** *** 144,147 **** --- 144,151 ---- <include name="mirrors"/> </jar> + <property name="classes" value="${java.home}/lib/rt.jar"/> + <condition property="classes" value="${java.home}/../Classes/classes.jar"> + <os name="Mac OS X"/> + </condition> <!-- proguard printseeds="on" printusage="off" outjar="${dist}/lib/jake2.jar" defaultpackage="" overloadaggressively="off" printmapping="jake2.map"> *************** *** 149,153 **** <libraryjar name="lib/jogl/jogl.jar"/> <libraryjar name="lib/joal/linux/joal.jar"/> ! <libraryjar name="${java.home}/lib/rt.jar"/> <keep access="public" name="jake2.Jake2"> <method name="main(java.lang.String[])"/> --- 153,157 ---- <libraryjar name="lib/jogl/jogl.jar"/> <libraryjar name="lib/joal/linux/joal.jar"/> ! <libraryjar name="${classes}"/> <keep access="public" name="jake2.Jake2"> <method name="main(java.lang.String[])"/> --- NEW FILE: Jake2.bat --- @echo off SET PATH=lib\joal\windows;%PATH% SET CP=build;resources;lib/jogl/jogl.jar;lib/joal/windows/joal.jar;lib/lwjgl/lwjgl.jar;lib/lwjgl/lwjgl_util.jar java -Xmx100M -Dsun.java2d.noddraw=true -Djava.library.path=lib/jogl/windows;lib/joal/windows;lib/lwjgl/windows -cp %CP% jake2.Jake2 |
From: Carsten W. <ca...@us...> - 2005-12-25 18:11:59
|
Update of /cvsroot/jake2/jake2/src/jake2/sound In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27365/src/jake2/sound Modified Files: Tag: render-refactoring WaveLoader.java Sound.java S.java DummyDriver.java Log Message: merge with current HEAD Index: S.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/S.java,v retrieving revision 1.11 retrieving revision 1.11.4.1 diff -C2 -d -r1.11 -r1.11.4.1 *** S.java 26 May 2005 16:56:33 -0000 1.11 --- S.java 25 Dec 2005 18:11:21 -0000 1.11.4.1 *************** *** 31,34 **** --- 31,35 ---- import jake2.qcommon.Cvar; + import java.nio.ByteBuffer; import java.util.Vector; *************** *** 42,46 **** static Vector drivers = new Vector(3); ! static { // dummy driver (no sound) --- 43,50 ---- static Vector drivers = new Vector(3); ! ! /** ! * Searches for and initializes all known sound drivers. ! */ static { // dummy driver (no sound) *************** *** 73,76 **** --- 77,83 ---- }; + /** + * Registers a new Sound Implementor. + */ public static void register(Sound driver) { if (driver == null) { *************** *** 82,85 **** --- 89,95 ---- } + /** + * Switches to the specific sound driver. + */ public static void useDriver(String driverName) { Sound driver = null; *************** *** 96,99 **** --- 106,112 ---- } + /** + * Initializes the sound module. + */ public static void Init() { *************** *** 132,211 **** } ! /* ! ===================== ! S_BeginRegistration ! ===================== ! */ public static void BeginRegistration() { impl.BeginRegistration(); } ! /* ! ===================== ! S_RegisterSound ! ===================== ! */ public static sfx_t RegisterSound(String sample) { return impl.RegisterSound(sample); } ! /* ! ===================== ! S_EndRegistration ! ===================== ! */ public static void EndRegistration() { impl.EndRegistration(); } ! /* ! ================== ! S_StartLocalSound ! ================== ! */ public static void StartLocalSound(String sound) { impl.StartLocalSound(sound); } ! /* ! ==================== ! S_StartSound ! ! Validates the parms and ques the sound up ! if pos is NULL, the sound will be dynamically sourced from the entity ! Entchannel 0 will never override a playing sound ! ==================== ! */ public static void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) { impl.StartSound(origin, entnum, entchannel, sfx, fvol, attenuation, timeofs); } ! /* ! ============ ! S_Update ! ! Called once each time through the main loop ! ============ ! */ public static void Update(float[] origin, float[] forward, float[] right, float[] up) { impl.Update(origin, forward, right, up); } ! /* ! ============ ! S_RawSamples ! ! Cinematic streaming and voice over network ! ============ ! */ ! public static void RawSamples(int samples, int rate, int width, int channels, byte[] data) { impl.RawSamples(samples, rate, width, channels, data); } ! /* ! ================== ! S_StopAllSounds ! ================== ! */ public static void StopAllSounds() { impl.StopAllSounds(); --- 145,210 ---- } ! /** ! * Called before the sounds are to be loaded and registered. ! */ public static void BeginRegistration() { impl.BeginRegistration(); } ! /** ! * Registers and loads a sound. ! */ public static sfx_t RegisterSound(String sample) { return impl.RegisterSound(sample); } ! /** ! * Called after all sounds are registered and loaded. ! */ public static void EndRegistration() { impl.EndRegistration(); } ! /** ! * Starts a local sound. ! */ public static void StartLocalSound(String sound) { impl.StartLocalSound(sound); } ! /** ! * StartSound - Validates the parms and ques the sound up ! * if pos is NULL, the sound will be dynamically sourced from the entity ! * Entchannel 0 will never override a playing sound ! */ public static void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) { impl.StartSound(origin, entnum, entchannel, sfx, fvol, attenuation, timeofs); } ! /** ! * Updates the sound renderer according to the changes in the environment, ! * called once each time through the main loop. ! */ public static void Update(float[] origin, float[] forward, float[] right, float[] up) { impl.Update(origin, forward, right, up); } ! /** ! * Cinematic streaming and voice over network. ! */ ! public static void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) { impl.RawSamples(samples, rate, width, channels, data); } + + /** + * Switches off the sound streaming. + */ + public static void disableStreaming() { + impl.disableStreaming(); + } ! /** ! * Stops all sounds. ! */ public static void StopAllSounds() { impl.StopAllSounds(); *************** *** 216,219 **** --- 215,221 ---- } + /** + * Returns a string array containing all sound driver names. + */ public static String[] getDriverNames() { String[] names = new String[drivers.size()]; *************** *** 223,225 **** --- 225,237 ---- return names; } + + /** + * This is used, when resampling to this default sampling rate is activated + * in the wavloader. It is placed here that sound implementors can override + * this one day. + */ + public static int getDefaultSampleRate() + { + return 44100; + } } \ No newline at end of file Index: Sound.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/Sound.java,v retrieving revision 1.1 retrieving revision 1.1.16.1 diff -C2 -d -r1.1 -r1.1.16.1 *** Sound.java 8 Jul 2004 20:56:49 -0000 1.1 --- Sound.java 25 Dec 2005 18:11:21 -0000 1.1.16.1 *************** *** 27,30 **** --- 27,34 ---- package jake2.sound; + import jake2.Defines; + + import java.nio.ByteBuffer; + /** * Sound *************** *** 33,37 **** */ public interface Sound { ! String getName(); --- 37,43 ---- */ public interface Sound { ! ! static final int MAX_SFX = Defines.MAX_SOUNDS * 2; ! static final int STREAM_QUEUE = 8; String getName(); *************** *** 94,99 **** ============ */ ! void RawSamples(int samples, int rate, int width, int channels, byte[] data); /* ================== --- 100,106 ---- ============ */ ! void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data); + void disableStreaming(); /* ================== Index: DummyDriver.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/DummyDriver.java,v retrieving revision 1.1 retrieving revision 1.1.16.1 diff -C2 -d -r1.1 -r1.1.16.1 *** DummyDriver.java 8 Jul 2004 20:56:49 -0000 1.1 --- DummyDriver.java 25 Dec 2005 18:11:21 -0000 1.1.16.1 *************** *** 27,30 **** --- 27,32 ---- package jake2.sound; + import java.nio.ByteBuffer; + /** * DummyDriver *************** *** 94,101 **** * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[]) */ ! public void RawSamples(int samples, int rate, int width, int channels, byte[] data) { } ! /* (non-Javadoc) * @see jake2.sound.Sound#StopAllSounds() */ --- 96,106 ---- * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[]) */ ! public void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) { } ! public void disableStreaming() { ! } ! ! /* (non-Javadoc) * @see jake2.sound.Sound#StopAllSounds() */ Index: WaveLoader.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/WaveLoader.java,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -C2 -d -r1.5 -r1.5.2.1 *** WaveLoader.java 27 Jun 2005 08:46:15 -0000 1.5 --- WaveLoader.java 25 Dec 2005 18:11:21 -0000 1.5.2.1 *************** *** 41,59 **** public class WaveLoader { ! private static AudioFormat sampleFormat; ! static { ! if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) { ! sampleFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 22050, 16, 1, 2, 22050, false); ! } else { ! sampleFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 22050, 16, 1, 2, 22050, true); ! } ! ! } ! ! /* ! ============== ! S_LoadSound ! ============== ! */ public static sfxcache_t LoadSound(sfx_t s) { if (s.name.charAt(0) == '*') --- 41,60 ---- public class WaveLoader { ! /** ! * The ResampleSfx can squeeze and stretch samples to a default sample rate. ! * Since Joal and lwjgl sound drivers support this, we don't need it and the samples ! * can keep their original sample rate. Use this switch for reactivating resampling. ! */ ! private static boolean DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL = true; ! ! /** ! * This is the maximum sample length in bytes which has to be replaced by ! * a configurable variable. ! */ ! private static int maxsamplebytes = 2048 * 1024; ! ! /** ! * Loads a sound from a wav file. ! */ public static sfxcache_t LoadSound(sfx_t s) { if (s.name.charAt(0) == '*') *************** *** 84,115 **** return null; } int size = data.length; wavinfo_t info = GetWavinfo(s.name, data, size); ! ! AudioInputStream in = null; ! AudioInputStream out = null; ! try { ! in = AudioSystem.getAudioInputStream(new ByteArrayInputStream(data)); ! if (in.getFormat().getSampleSizeInBits() == 8) { ! in = convertTo16bit(in); ! } ! out = AudioSystem.getAudioInputStream(sampleFormat, in); ! int l = (int)out.getFrameLength(); ! sc = s.cache = new sfxcache_t(l*2); ! sc.length = l; ! int c = out.read(sc.data, 0, l * 2); ! out.close(); ! in.close(); ! } catch (Exception e) { ! Com.Printf("Couldn't load " + namebuffer + "\n"); return null; } ! sc.loopstart = info.loopstart * ((int)sampleFormat.getSampleRate() / info.rate); ! sc.speed = (int)sampleFormat.getSampleRate(); ! sc.width = sampleFormat.getSampleSizeInBits() / 8; ! sc.stereo = 0; data = null; --- 85,124 ---- return null; } + int size = data.length; wavinfo_t info = GetWavinfo(s.name, data, size); ! ! if (info.channels != 1) ! { ! Com.Printf(s.name + " is a stereo sample - ignoring\n"); return null; } + + float stepscale; + if (DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL) + stepscale = 1; + else + stepscale = (float)info.rate / S.getDefaultSampleRate(); ! int len = (int) (info.samples / stepscale); ! len = len * info.width * info.channels; ! ! // TODO: handle max sample bytes with a cvar ! if (len >= maxsamplebytes) ! { ! Com.Printf(s.name + " is too long: " + len + " bytes?! ignoring.\n"); ! return null; ! } + sc = s.cache = new sfxcache_t(len); + + sc.length = info.samples; + sc.loopstart = info.loopstart; + sc.speed = info.rate; + sc.width = info.width; + sc.stereo = info.channels; + + ResampleSfx(s, sc.speed, sc.width, data, info.dataofs); data = null; *************** *** 117,142 **** } - static AudioInputStream convertTo16bit(AudioInputStream in) throws IOException { - AudioFormat format = in.getFormat(); - int length = (int)in.getFrameLength(); - byte[] samples = new byte[2*length]; - - for (int i = 0; i < length; i++) { - in.read(samples, 2*i+1, 1); - samples[2*i+1] -= 128; - } - in.close(); ! AudioFormat newformat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, format.getSampleRate(), 16, format.getChannels(), 2, format.getFrameRate(), false); ! return new AudioInputStream(new ByteArrayInputStream(samples), newformat, length); ! } ! ! /* ! =============================================================================== ! WAV loading - =============================================================================== - */ static byte[] data_b; --- 126,196 ---- } ! /** ! * Converts sample data with respect to the endianess and adjusts ! * the sample rate of a loaded sample, see flag DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL. ! */ ! public static void ResampleSfx (sfx_t sfx, int inrate, int inwidth, byte data[], int offset) ! { ! int outcount; ! int srcsample; ! int i; ! int sample, samplefrac, fracstep; ! sfxcache_t sc; ! ! sc = sfx.cache; ! ! if (sc == null) ! return; ! // again calculate the stretching factor. ! // this is usually 0.5, 1, or 2 ! ! float stepscale; ! if (DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL) ! stepscale = 1; ! else ! stepscale = (float)inrate / S.getDefaultSampleRate(); ! outcount = (int) (sc.length/stepscale); ! sc.length = outcount; ! ! if (sc.loopstart != -1) ! sc.loopstart = (int) (sc.loopstart / stepscale); ! ! // if resampled, sample has now the default sample rate ! if (DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL == false) ! sc.speed = S.getDefaultSampleRate(); ! ! sc.width = inwidth; ! sc.stereo = 0; ! samplefrac = 0; ! fracstep = (int) (stepscale * 256); ! ! for (i=0 ; i<outcount ; i++) ! { ! srcsample = samplefrac >> 8; ! samplefrac += fracstep; ! ! if (inwidth == 2) ! { ! sample = (int) ((data[offset + srcsample * 2] & 0xff) + (data[offset + srcsample * 2 + 1] << 8)); ! } ! else ! { ! sample = ((data[offset + srcsample] &0xff) - 128) << 8; ! } ! ! if (sc.width == 2) ! { ! sc.data[i*2] = (byte) (sample & 0xff); ! sc.data[i*2+1] = (byte) ((sample>>>8) & 0xff); ! } ! else ! { ! sc.data[i] = (byte) (sample >> 8); ! } ! } ! } static byte[] data_b; |
From: Carsten W. <ca...@us...> - 2005-12-25 18:11:57
|
Update of /cvsroot/jake2/jake2/src/jake2/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27365/src/jake2/server Modified Files: Tag: render-refactoring SV_INIT.java SV_CCMDS.java SV_SEND.java SV_ENTS.java SV_MAIN.java SV_USER.java Log Message: merge with current HEAD Index: SV_MAIN.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_MAIN.java,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -C2 -d -r1.11 -r1.11.2.1 *** SV_MAIN.java 1 Jul 2005 14:20:55 -0000 1.11 --- SV_MAIN.java 25 Dec 2005 18:11:18 -0000 1.11.2.1 *************** *** 437,454 **** } ! /* ! * =============== SVC_RemoteCommand ! * * A client issued an rcon command. Shift down the remaining args Redirect ! * all printfs =============== */ public static void SVC_RemoteCommand() { int i; - //char remaining[1024]; String remaining; i = Rcon_Validate(); ! String msg = new String(Globals.net_message.data, 4, -1); if (i == 0) --- 437,451 ---- } ! /** * A client issued an rcon command. Shift down the remaining args Redirect ! * all printfs fromt hte server to the client. */ public static void SVC_RemoteCommand() { int i; String remaining; i = Rcon_Validate(); ! String msg = Lib.CtoJava(Globals.net_message.data, 4, 1024); if (i == 0) *************** *** 461,466 **** Com.BeginRedirect(Defines.RD_PACKET, SV_SEND.sv_outputbuf, Defines.SV_OUTPUTBUF_LENGTH, new Com.RD_Flusher() { ! public void rd_flush(int target, byte[] buffer) { ! SV_SEND.SV_FlushRedirect(target, buffer); } }); --- 458,463 ---- Com.BeginRedirect(Defines.RD_PACKET, SV_SEND.sv_outputbuf, Defines.SV_OUTPUTBUF_LENGTH, new Com.RD_Flusher() { ! public void rd_flush(int target, StringBuffer buffer) { ! SV_SEND.SV_FlushRedirect(target, Lib.stringToBytes(buffer.toString())); } }); *************** *** 919,924 **** Cvar.Get("fraglimit", "0", Defines.CVAR_SERVERINFO); Cvar.Get("timelimit", "0", Defines.CVAR_SERVERINFO); ! //TODO: set cheats 0 ! Cvar.Get("cheats", "1", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); Cvar.Get("protocol", "" + Defines.PROTOCOL_VERSION, Defines.CVAR_SERVERINFO | Defines.CVAR_NOSET); --- 916,920 ---- Cvar.Get("fraglimit", "0", Defines.CVAR_SERVERINFO); Cvar.Get("timelimit", "0", Defines.CVAR_SERVERINFO); ! Cvar.Get("cheats", "0", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); Cvar.Get("protocol", "" + Defines.PROTOCOL_VERSION, Defines.CVAR_SERVERINFO | Defines.CVAR_NOSET); *************** *** 935,940 **** SV_MAIN.sv_enforcetime = Cvar.Get("sv_enforcetime", "0", 0); ! // TODO: carsten, re-allow downloads per default ! SV_MAIN.allow_download = Cvar.Get("allow_download", "0", Defines.CVAR_ARCHIVE); SV_MAIN.allow_download_players = Cvar.Get("allow_download_players", --- 931,935 ---- SV_MAIN.sv_enforcetime = Cvar.Get("sv_enforcetime", "0", 0); ! SV_MAIN.allow_download = Cvar.Get("allow_download", "1", Defines.CVAR_ARCHIVE); SV_MAIN.allow_download_players = Cvar.Get("allow_download_players", Index: SV_INIT.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_INIT.java,v retrieving revision 1.13 retrieving revision 1.13.6.1 diff -C2 -d -r1.13 -r1.13.6.1 *** SV_INIT.java 19 Feb 2005 21:21:46 -0000 1.13 --- SV_INIT.java 25 Dec 2005 18:11:18 -0000 1.13.6.1 *************** *** 392,395 **** --- 392,397 ---- } + private static String firstmap = ""; + /* * ====================== SV_Map *************** *** 432,446 **** int c = level.indexOf('+'); if (c != -1) { ! Cvar ! .Set("nextserver", "gamemap \"" + level.substring(c + 1) ! + "\""); level = level.substring(0, c); } else { Cvar.Set("nextserver", ""); } //ZOID special hack for end game screen in coop mode if (Cvar.VariableValue("coop") != 0 && level.equals("victory.pcx")) ! Cvar.Set("nextserver", "gamemap \"*base1\""); // if there is a $, use the remainder as a spawnpoint --- 434,456 ---- int c = level.indexOf('+'); if (c != -1) { ! Cvar.Set("nextserver", "gamemap \"" + level.substring(c + 1) + "\""); level = level.substring(0, c); } else { Cvar.Set("nextserver", ""); } + + // rst: base1 works for full, damo1 works for demo, so we need to store first map. + if (firstmap.length() == 0) + { + if (!levelstring.endsWith(".cin") && !levelstring.endsWith(".pcx") && !levelstring.endsWith(".dm2")) + { + int pos = levelstring.indexOf('+'); + firstmap = levelstring.substring(pos + 1); + } + } //ZOID special hack for end game screen in coop mode if (Cvar.VariableValue("coop") != 0 && level.equals("victory.pcx")) ! Cvar.Set("nextserver", "gamemap \"*" + firstmap + "\""); // if there is a $, use the remainder as a spawnpoint Index: SV_CCMDS.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_CCMDS.java,v retrieving revision 1.14 retrieving revision 1.14.6.1 diff -C2 -d -r1.14 -r1.14.6.1 *** SV_CCMDS.java 19 Feb 2005 21:21:19 -0000 1.14 --- SV_CCMDS.java 25 Dec 2005 18:11:18 -0000 1.14.6.1 *************** *** 174,184 **** } } - /* - ===================== - SV_WipeSavegame ! Delete save/<XXX>/ ! ===================== ! */ public static void SV_WipeSavegame(String savename) { --- 174,179 ---- } } ! /** Delete save files save/(number)/. */ public static void SV_WipeSavegame(String savename) { Index: SV_ENTS.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_ENTS.java,v retrieving revision 1.5 retrieving revision 1.5.12.1 diff -C2 -d -r1.5 -r1.5.12.1 *** SV_ENTS.java 22 Sep 2004 19:22:12 -0000 1.5 --- SV_ENTS.java 25 Dec 2005 18:11:18 -0000 1.5.12.1 *************** *** 360,369 **** } ! /* ! * ============ SV_FatPVS ! * ! * The client will interpolate the view position, so we can't use a single ! * PVS point =========== ! */ public static void SV_FatPVS(float[] org) { int leafs[] = new int[64]; --- 360,365 ---- } ! /** The client will interpolate the view position, so we can't use a single ! * PVS point. */ public static void SV_FatPVS(float[] org) { int leafs[] = new int[64]; *************** *** 413,421 **** } ! /* ! * ============= SV_BuildClientFrame ! * * Decides which entities are going to be visible to the client, and copies ! * off the playerstat and areabits. ============= */ public static void SV_BuildClientFrame(client_t client) { --- 409,415 ---- } ! /** * Decides which entities are going to be visible to the client, and copies ! * off the playerstat and areabits. */ public static void SV_BuildClientFrame(client_t client) { *************** *** 479,494 **** // ignore if not touching a PV leaf - if (ent != clent) { // check area ! if (!CM.CM_AreasConnected(clientarea, ent.areanum)) { // doors ! // can ! // legally ! // straddle ! // two ! // areas, ! // so ! // we may need to check another one ! if (0 == ent.areanum2 ! || !CM.CM_AreasConnected(clientarea, ent.areanum2)) continue; // blocked by a door } --- 473,481 ---- // ignore if not touching a PV leaf // check area ! if (ent != clent) { ! if (!CM.CM_AreasConnected(clientarea, ent.areanum)) { ! // doors can legally straddle two areas, so we may need to check another one ! if (0 == ent.areanum2 || !CM.CM_AreasConnected(clientarea, ent.areanum2)) continue; // blocked by a door } Index: SV_SEND.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_SEND.java,v retrieving revision 1.8 retrieving revision 1.8.6.1 diff -C2 -d -r1.8 -r1.8.6.1 *** SV_SEND.java 17 Jan 2005 23:09:41 -0000 1.8 --- SV_SEND.java 25 Dec 2005 18:11:18 -0000 1.8.6.1 *************** *** 31,34 **** --- 31,35 ---- import jake2.qcommon.*; import jake2.render.*; + import jake2.util.Lib; import jake2.util.Math3D; *************** *** 42,51 **** */ ! 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) { --- 43,52 ---- */ ! public static StringBuffer sv_outputbuf = new StringBuffer(); public static void SV_FlushRedirect(int sv_redirected, byte outputbuf[]) { if (sv_redirected == Defines.RD_PACKET) { ! String s = ("print\n" + Lib.CtoJava(outputbuf)); ! Netchan.Netchan_OutOfBand(Defines.NS_SERVER, Globals.net_from, s.length(), Lib.stringToBytes(s)); } else if (sv_redirected == Defines.RD_CLIENT) { Index: SV_USER.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_USER.java,v retrieving revision 1.8 retrieving revision 1.8.6.1 diff -C2 -d -r1.8 -r1.8.6.1 *** SV_USER.java 6 Feb 2005 19:28:16 -0000 1.8 --- SV_USER.java 25 Dec 2005 18:11:18 -0000 1.8.6.1 *************** *** 418,421 **** --- 418,428 ---- SV_MAIN.sv_client.download = FS.LoadFile(name); + + // rst: this handles loading errors, no message yet visible + if (SV_MAIN.sv_client.download == null) + { + return; + } + SV_MAIN.sv_client.downloadsize = SV_MAIN.sv_client.download.length; SV_MAIN.sv_client.downloadcount = offset; *************** *** 427,431 **** // came from a pak file, don't // allow ! // download ZOID || (name.startsWith("maps/") && FS.file_from_pak != 0)) { Com.DPrintf("Couldn't download " + name + " to " --- 434,438 ---- // came from a pak file, don't // allow ! // download ZOID || (name.startsWith("maps/") && FS.file_from_pak != 0)) { Com.DPrintf("Couldn't download " + name + " to " *************** *** 532,536 **** if (i == SV_USER.ucmds.length && SV_INIT.sv.state == Defines.ss_game) ! GameAI.ClientCommand(SV_USER.sv_player); // SV_EndRedirect (); --- 539,543 ---- if (i == SV_USER.ucmds.length && SV_INIT.sv.state == Defines.ss_game) ! Cmd.ClientCommand(SV_USER.sv_player); // SV_EndRedirect (); |
From: Carsten W. <ca...@us...> - 2005-12-25 18:11:56
|
Update of /cvsroot/jake2/jake2/src/jake2/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27365/src/jake2/util Modified Files: Tag: render-refactoring Lib.java QuakeFile.java Log Message: merge with current HEAD Index: Lib.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/util/Lib.java,v retrieving revision 1.13 retrieving revision 1.13.4.1 diff -C2 -d -r1.13 -r1.13.4.1 *** Lib.java 26 May 2005 16:56:31 -0000 1.13 --- Lib.java 25 Dec 2005 18:11:16 -0000 1.13.4.1 *************** *** 34,72 **** ! /* ! ============= ! VectorToString ! ! This is just a convenience function ! for printing vectors ! ============= ! */ public static String vtos(float[] v) { 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])); } public static short rand() { - //return (short) (Math.random() * 0x8000); return (short)Globals.rnd.nextInt(Short.MAX_VALUE+1); } public static float crandom() { return (Globals.rnd.nextFloat() - 0.5f) * 2.0f; - //return (float) (Math.random() - 0.5) * 2.0f; } public static float random() { return Globals.rnd.nextFloat(); } public static float crand() { return (Globals.rnd.nextFloat() - 0.5f) * 2.0f; } public static int strcmp(String in1, String in2) { return in1.compareTo(in2); } public static float atof(String in) { float res = 0; --- 34,78 ---- ! /** Converts a vector to a string. */ public static String vtos(float[] v) { return (int) v[0] + " " + (int) v[1] + " " + (int) v[2]; } + + /** Converts a vector to a string. */ public static String vtofs(float[] v) { return v[0] + " " + v[1] + " " + v[2]; } + + /** Converts a vector to a beatiful string. */ 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])); } + + /** Like in libc. */ public static short rand() { return (short)Globals.rnd.nextInt(Short.MAX_VALUE+1); } + + /** Like in libc. */ public static float crandom() { return (Globals.rnd.nextFloat() - 0.5f) * 2.0f; } + + /** Like in libc. */ public static float random() { return Globals.rnd.nextFloat(); } + + /** Like in libc. */ public static float crand() { return (Globals.rnd.nextFloat() - 0.5f) * 2.0f; } + + /** Like in libc. */ public static int strcmp(String in1, String in2) { return in1.compareTo(in2); } + /** Like in libc. */ public static float atof(String in) { float res = 0; *************** *** 80,88 **** return res; } public static int Q_stricmp(String in1, String in2) { return in1.compareToIgnoreCase(in2); } - // ================================================================================= public static int atoi(String in) { try { --- 86,96 ---- return res; } + + /** Like in quake2. */ public static int Q_stricmp(String in1, String in2) { return in1.compareToIgnoreCase(in2); } + /** Like in libc. */ public static int atoi(String in) { try { *************** *** 97,112 **** } } 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++) --- 105,121 ---- } } + + /** Converts a string to a vector. Needs improvement. */ public static float[] atov(String v) { float[] res = { 0, 0, 0 }; ! String strres[] = v.split(" "); ! for (int n=0; n < 3 && n < strres.length; n++) ! { ! res[n] = atof(strres[n]); ! } return res; } + + /** Like in libc. */ public static int strlen(char in[]) { for (int i = 0; i < in.length; i++) *************** *** 115,118 **** --- 124,129 ---- return in.length; } + + /** Like in libc. */ public static int strlen(byte in[]) { for (int i = 0; i < in.length; i++) *************** *** 122,125 **** --- 133,137 ---- } + /** Converts memory to a memory dump string. */ public static String hexdumpfile(ByteBuffer bb, int len) throws IOException { *************** *** 132,136 **** return hexDump(buf, len, false); } ! // dump data as hexstring public static String hexDump(byte data1[], int len, boolean showAddress) { StringBuffer result = new StringBuffer(); --- 144,149 ---- return hexDump(buf, len, false); } ! ! /** Converts memory to a memory dump string. */ public static String hexDump(byte data1[], int len, boolean showAddress) { StringBuffer result = new StringBuffer(); *************** *** 166,174 **** return result.toString(); } ! //formats an hex byte public static String hex2(int i) { String val = Integer.toHexString(i & 0xff); ! return ("00".substring(0, 2 - val.length()) + val).toUpperCase(); } public static char readableChar(int i) { if ((i < 0x20) || (i > 0x7f)) --- 179,190 ---- return result.toString(); } ! ! /** Formats an hex byte. */ public static String hex2(int i) { String val = Integer.toHexString(i & 0xff); ! return ("00".substring(0, 2 - val.length()) + val).toUpperCase(); } + + /** Returns true if the char is alphanumeric. */ public static char readableChar(int i) { if ((i < 0x20) || (i > 0x7f)) *************** *** 177,180 **** --- 193,198 ---- return (char) i; } + + /** Prints a vector to the quake console. */ public static void printv(String in, float arr[]) { for (int n = 0; n < arr.length; n++) { *************** *** 182,186 **** --- 200,207 ---- } } + static final byte nullfiller[] = new byte[8192]; + + /** Like in libc. */ public static void fwriteString(String s, int len, RandomAccessFile f) throws IOException { if (s == null) *************** *** 188,198 **** int diff = len - s.length(); if (diff > 0) { ! f.write(s.getBytes()); f.write(nullfiller, 0, diff); } else ! f.write(s.getBytes(), 0, len); } public static RandomAccessFile fopen(String name, String mode) { try { --- 209,221 ---- int diff = len - s.length(); if (diff > 0) { ! f.write(stringToBytes(s)); f.write(nullfiller, 0, diff); } else ! f.write(stringToBytes(s), 0, len); } + + /** Like in libc */ public static RandomAccessFile fopen(String name, String mode) { try { *************** *** 204,207 **** --- 227,232 ---- } } + + /** Like in libc */ public static void fclose(RandomAccessFile f) { try { *************** *** 211,214 **** --- 236,241 ---- } } + + /** Like in libc */ public static String freadString(RandomAccessFile f, int len) { byte buffer[] = new byte[len]; *************** *** 217,220 **** --- 244,249 ---- return Lib.CtoJava(buffer); } + + /** Returns the right part of the string from the last occruence of c. */ public static String rightFrom(String in, char c) { int pos = in.lastIndexOf(c); *************** *** 225,228 **** --- 254,259 ---- return ""; } + + /** Returns the left part of the string from the last occruence of c. */ public static String leftFrom(String in, char c) { int pos = in.lastIndexOf(c); *************** *** 234,237 **** --- 265,269 ---- } + /** Renames a file. */ public static int rename(String oldn, String newn) { try { *************** *** 245,248 **** --- 277,282 ---- } } + + /** Converts an int to 4 bytes java representation. */ public static byte[] getIntBytes(int c) { byte b[] = new byte[4]; *************** *** 253,259 **** --- 287,297 ---- return b; } + + /** Converts an 4 bytes java int representation to an int. */ public static int getInt(byte b[]) { return (b[0] & 0xff) | ((b[1] & 0xff) << 8) | ((b[2] & 0xff) << 16) | ((b[3] & 0xff) << 24); } + + /** Duplicates a float array. */ public static float[] clone(float in[]) { float out[] = new float[in.length]; *************** *** 264,268 **** --- 302,335 ---- return out; } + + /** + * convert a java string to byte[] with 8bit latin 1 + * + * avoid String.getBytes() because it is using system specific character encoding. + */ + public static byte[] stringToBytes(String value) { + try { + return value.getBytes("ISO-8859-1"); + } catch (UnsupportedEncodingException e) { + // can't happen: Latin 1 is a standard encoding + return null; + } + } + + /** + * convert a byte[] with 8bit latin 1 to java string + * + * avoid new String(bytes) because it is using system specific character encoding. + */ + public static String bytesToString(byte[] value) { + try { + return new String(value, "ISO-8859-1"); + } catch (UnsupportedEncodingException e) { + // can't happen: Latin 1 is a standard encoding + return null; + } + } + /** Helper method that savely handles the null termination of old C String data. */ public static String CtoJava(String old) { int index = old.indexOf('\0'); *************** *** 271,289 **** } public static String CtoJava(byte[] old) { return CtoJava(old, 0, old.length); } public static String CtoJava(byte[] old, int offset, int maxLenght) { if (old.length == 0 || old[0] == 0) return ""; int i; ! for (i = offset; old[i] != 0 && (i - offset) < maxLenght; i++); return new String(old, offset, i - offset); } ! /* ! * java.nio.* Buffer util functions ! */ public static final int SIZEOF_FLOAT = 4; --- 338,356 ---- } + /** Helper method that savely handles the null termination of old C String data. */ public static String CtoJava(byte[] old) { return CtoJava(old, 0, old.length); } + /** Helper method that savely handles the null termination of old C String data. */ public static String CtoJava(byte[] old, int offset, int maxLenght) { if (old.length == 0 || old[0] == 0) return ""; int i; ! for (i = offset; (i - offset) < maxLenght && old[i] != 0; i++); return new String(old, offset, i - offset); } ! /* java.nio.* Buffer util functions */ public static final int SIZEOF_FLOAT = 4; Index: QuakeFile.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/util/QuakeFile.java,v retrieving revision 1.4 retrieving revision 1.4.12.1 diff -C2 -d -r1.4 -r1.4.12.1 *** QuakeFile.java 22 Sep 2004 19:22:13 -0000 1.4 --- QuakeFile.java 25 Dec 2005 18:11:18 -0000 1.4.12.1 *************** *** 20,36 **** // 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; ! import jake2.game.gitem_t; import jake2.qcommon.Com; ! import java.io.FileNotFoundException; ! import java.io.IOException; ! import java.io.RandomAccessFile; /** --- 20,32 ---- // Created on 24.07.2004 by RST. + // $Id$ + package jake2.util; ! import jake2.game.*; import jake2.qcommon.Com; ! import java.io.*; /** *************** *** 161,165 **** return null; else ! return GameAI.itemlist[ndx]; } --- 157,161 ---- return null; else ! return GameItemList.itemlist[ndx]; } |
From: Carsten W. <ca...@us...> - 2005-12-25 18:11:36
|
Update of /cvsroot/jake2/jake2/src/jake2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27365/src/jake2 Modified Files: Tag: render-refactoring Jake2.java Defines.java Log Message: merge with current HEAD Index: Jake2.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/Jake2.java,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -C2 -d -r1.8 -r1.8.2.1 *** Jake2.java 1 Jul 2005 14:20:53 -0000 1.8 --- Jake2.java 25 Dec 2005 18:11:25 -0000 1.8.2.1 *************** *** 36,41 **** public final class Jake2 { ! ! public static Q2DataDialog Q2Dialog = new Q2DataDialog(); /** --- 36,40 ---- public final class Jake2 { ! public static Q2DataDialog Q2Dialog; /** *************** *** 46,52 **** */ public static void main(String[] args) { ! Locale.setDefault(Locale.US); ! Q2Dialog.setVisible(true); // in C the first arg is the filename --- 45,88 ---- */ public static void main(String[] args) { + + boolean dedicated = false; ! // check if we are in dedicated mode to hide the java dialog. ! for (int n = 0; n < args.length; n++) ! { ! if (args[n].equals("+set")) ! { ! if (n++ >= args.length) ! break; ! ! if (!args[n].equals("dedicated")) ! continue; ! ! if (n++ >= args.length) ! break; ! ! if (args[n].equals("1") || args[n].equals("\"1\"")) ! { ! Com.Printf("Starting in dedicated mode.\n"); ! dedicated = true; ! } ! } ! } ! ! // TODO: check if dedicated is set in config file ! ! Globals.dedicated= Cvar.Get("dedicated", "0", Qcommon.CVAR_NOSET); ! ! if (dedicated) ! Globals.dedicated.value = 1.0f; ! ! ! // open the q2dialog, if we are not in dedicated mode. ! if (Globals.dedicated.value != 1.0f) ! { ! Q2Dialog = new Q2DataDialog(); ! Locale.setDefault(Locale.US); ! Q2Dialog.setVisible(true); ! } // in C the first arg is the filename Index: Defines.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/Defines.java,v retrieving revision 1.6 retrieving revision 1.6.12.1 diff -C2 -d -r1.6 -r1.6.12.1 *** Defines.java 4 Oct 2004 12:50:38 -0000 1.6 --- Defines.java 25 Dec 2005 18:11:25 -0000 1.6.12.1 *************** *** 65,69 **** public final static int MAX_STRING_CHARS = 1024; // max length of a string passed to Cmd_TokenizeString public final static int MAX_STRING_TOKENS = 80; // max tokens resulting from Cmd_TokenizeString ! public final static int MAX_TOKEN_CHARS = 128; // max length of an individual token public final static int MAX_QPATH = 64; // max length of a quake game pathname --- 65,69 ---- public final static int MAX_STRING_CHARS = 1024; // max length of a string passed to Cmd_TokenizeString public final static int MAX_STRING_TOKENS = 80; // max tokens resulting from Cmd_TokenizeString ! public final static int MAX_TOKEN_CHARS = 1024; // max length of an individual token public final static int MAX_QPATH = 64; // max length of a quake game pathname |
Update of /cvsroot/jake2/jake2/src/jake2/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27365/src/jake2/client Modified Files: Tag: render-refactoring client_state_t.java Menu.java CL_inv.java SCR.java VID.java CL.java Key.java M.java Log Message: merge with current HEAD Index: M.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/M.java,v retrieving revision 1.6 retrieving revision 1.6.12.1 diff -C2 -d -r1.6 -r1.6.12.1 *** M.java 7 Oct 2004 14:13:07 -0000 1.6 --- M.java 25 Dec 2005 18:11:24 -0000 1.6.12.1 *************** *** 50,54 **** } ! // if the hull point one-quarter unit down is solid the entity is on // ground point[0] = ent.s.origin[0]; --- 50,54 ---- } ! // if the hull point one-quarter unit down is solid the entity is on // ground point[0] = ent.s.origin[0]; *************** *** 65,72 **** } ! // ent.groundentity = trace.ent; ! // ent.groundentity_linkcount = trace.ent.linkcount; ! // if (!trace.startsolid && !trace.allsolid) ! // VectorCopy (trace.endpos, ent.s.origin); if (!trace.startsolid && !trace.allsolid) { Math3D.VectorCopy(trace.endpos, ent.s.origin); --- 65,72 ---- } ! // ent.groundentity = trace.ent; ! // ent.groundentity_linkcount = trace.ent.linkcount; ! // if (!trace.startsolid && !trace.allsolid) ! // VectorCopy (trace.endpos, ent.s.origin); if (!trace.startsolid && !trace.allsolid) { Math3D.VectorCopy(trace.endpos, ent.s.origin); *************** *** 145,150 **** /* ! * =============== M_ChangeYaw ! * * =============== *///ok --- 145,150 ---- /* ! * =============== ! * M_ChangeYaw * =============== *///ok *************** *** 182,187 **** /* ! * ====================== M_MoveToGoal ====================== ! */// ok public static void M_MoveToGoal(edict_t ent, float dist) { edict_t goal = ent.goalentity; --- 182,189 ---- /* ! * ====================== ! * M_MoveToGoal ! * ====================== ! */ public static void M_MoveToGoal(edict_t ent, float dist) { edict_t goal = ent.goalentity; *************** *** 204,208 **** /* ! * =============== M_walkmove =============== */ public static boolean M_walkmove(edict_t ent, float yaw, float dist) { --- 206,212 ---- /* ! * =============== ! * M_walkmove ! * =============== */ public static boolean M_walkmove(edict_t ent, float yaw, float dist) { *************** *** 268,272 **** if (dmg > 15) dmg = 15; ! GameUtil.T_Damage(ent, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, ent.s.origin, Globals.vec3_origin, dmg, 0, --- 272,276 ---- if (dmg > 15) dmg = 15; ! GameCombat.T_Damage(ent, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, ent.s.origin, Globals.vec3_origin, dmg, 0, *************** *** 285,289 **** if (dmg > 15) dmg = 15; ! GameUtil.T_Damage(ent, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, ent.s.origin, Globals.vec3_origin, dmg, 0, --- 289,293 ---- if (dmg > 15) dmg = 15; ! GameCombat.T_Damage(ent, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, ent.s.origin, Globals.vec3_origin, dmg, 0, *************** *** 309,313 **** if (ent.damage_debounce_time < GameBase.level.time) { ent.damage_debounce_time = GameBase.level.time + 0.2f; ! GameUtil.T_Damage(ent, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, ent.s.origin, Globals.vec3_origin, 10 * ent.waterlevel, --- 313,317 ---- if (ent.damage_debounce_time < GameBase.level.time) { ent.damage_debounce_time = GameBase.level.time + 0.2f; ! GameCombat.T_Damage(ent, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, ent.s.origin, Globals.vec3_origin, 10 * ent.waterlevel, *************** *** 319,323 **** if (ent.damage_debounce_time < GameBase.level.time) { ent.damage_debounce_time = GameBase.level.time + 1; ! GameUtil.T_Damage(ent, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, ent.s.origin, Globals.vec3_origin, 4 * ent.waterlevel, --- 323,327 ---- if (ent.damage_debounce_time < GameBase.level.time) { ent.damage_debounce_time = GameBase.level.time + 1; ! GameCombat.T_Damage(ent, GameBase.g_edicts[0], GameBase.g_edicts[0], Globals.vec3_origin, ent.s.origin, Globals.vec3_origin, 4 * ent.waterlevel, *************** *** 353,356 **** --- 357,361 ---- public static EntThinkAdapter M_droptofloor = new EntThinkAdapter() { + public String getID() { return "m_drop_to_floor";} public boolean think(edict_t ent) { float[] end = { 0, 0, 0 }; *************** *** 449,527 **** } - public static void M_ReactToDamage(edict_t targ, edict_t attacker) { - if ((null != attacker.client) - && 0 != (attacker.svflags & Defines.SVF_MONSTER)) - return; - - if (attacker == targ || attacker == targ.enemy) - return; - - // if we are a good guy monster and our attacker is a player - // or another good guy, do not get mad at them - if (0 != (targ.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) { - if (attacker.client != null - || (attacker.monsterinfo.aiflags & Defines.AI_GOOD_GUY) != 0) - return; - } - - // we now know that we are not both good guys - - // if attacker is a client, get mad at them because he's good and we're - // not - if (attacker.client != null) { - targ.monsterinfo.aiflags &= ~Defines.AI_SOUND_TARGET; - - // this can only happen in coop (both new and old enemies are - // clients) - // only switch if can't see the current enemy - if (targ.enemy != null && targ.enemy.client != null) { - if (GameUtil.visible(targ, targ.enemy)) { - targ.oldenemy = attacker; - return; - } - targ.oldenemy = targ.enemy; - } - targ.enemy = attacker; - if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED)) - GameUtil.FoundTarget(targ); - return; - } - - // it's the same base (walk/swim/fly) type and a different classname and - // it's not a tank - // (they spray too much), get mad at them - if (((targ.flags & (Defines.FL_FLY | Defines.FL_SWIM)) == (attacker.flags & (Defines.FL_FLY | Defines.FL_SWIM))) - && (!(targ.classname.equals(attacker.classname))) - && (!(attacker.classname.equals("monster_tank"))) - && (!(attacker.classname.equals("monster_supertank"))) - && (!(attacker.classname.equals("monster_makron"))) - && (!(attacker.classname.equals("monster_jorg")))) { - if (targ.enemy != null && targ.enemy.client != null) - targ.oldenemy = targ.enemy; - targ.enemy = attacker; - if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED)) - GameUtil.FoundTarget(targ); - } - // if they *meant* to shoot us, then shoot back - else if (attacker.enemy == targ) { - if (targ.enemy != null && targ.enemy.client != null) - targ.oldenemy = targ.enemy; - targ.enemy = attacker; - if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED)) - GameUtil.FoundTarget(targ); - } - // otherwise get mad at whoever they are mad at (help our buddy) unless - // it is us! - else if (attacker.enemy != null && attacker.enemy != targ) { - if (targ.enemy != null && targ.enemy.client != null) - targ.oldenemy = targ.enemy; - targ.enemy = attacker.enemy; - if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED)) - GameUtil.FoundTarget(targ); - } - } - /** Stops the Flies. */ public static EntThinkAdapter M_FliesOff = new EntThinkAdapter() { public boolean think(edict_t self) { self.s.effects &= ~Defines.EF_FLIES; --- 454,460 ---- } /** Stops the Flies. */ public static EntThinkAdapter M_FliesOff = new EntThinkAdapter() { + public String getID() { return "m_fliesoff";} public boolean think(edict_t self) { self.s.effects &= ~Defines.EF_FLIES; *************** *** 533,536 **** --- 466,470 ---- /** Starts the Flies as setting the animation flag in the entity. */ public static EntThinkAdapter M_FliesOn = new EntThinkAdapter() { + public String getID() { return "m_flies_on";} public boolean think(edict_t self) { if (self.waterlevel != 0) *************** *** 547,550 **** --- 481,485 ---- /** Adds some flies after a random time */ public static EntThinkAdapter M_FlyCheck = new EntThinkAdapter() { + public String getID() { return "m_fly_check";} public boolean think(edict_t self) { Index: Menu.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/Menu.java,v retrieving revision 1.19 retrieving revision 1.19.2.1 diff -C2 -d -r1.19 -r1.19.2.1 *** Menu.java 1 Jul 2005 14:20:50 -0000 1.19 --- Menu.java 25 Dec 2005 18:11:22 -0000 1.19.2.1 *************** *** 4104,4109 **** if (s_pmi[s_player_model_box.curvalue].skindisplaynames != null) { - int maxframe = 29; - //memset(entity, 0, sizeof(entity)); entity.clear(); --- 4104,4107 ---- *************** *** 4162,4166 **** if (key == K_ESCAPE) { - //char scratch[1024]; String scratch; --- 4160,4163 ---- Index: CL.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL.java,v retrieving revision 1.23 retrieving revision 1.23.2.1 diff -C2 -d -r1.23 -r1.23.2.1 *** CL.java 1 Jul 2005 14:20:48 -0000 1.23 --- CL.java 25 Dec 2005 18:11:24 -0000 1.23.2.1 *************** *** 57,65 **** public static final int PLAYER_MULT = 5; - /* - * ================== CL_FixCvarCheats - * - * ================== - */ public static class cheatvar_t { String name; --- 57,60 ---- *************** *** 90,97 **** static int numcheatvars; ! /* ! * ==================== CL_Stop_f * ! * stop recording a demo ==================== */ static xcommand_t Stop_f = new xcommand_t() { --- 85,92 ---- static int numcheatvars; ! /** ! * Stop_f * ! * Stop recording a demo. */ static xcommand_t Stop_f = new xcommand_t() { *************** *** 118,130 **** }; - /* - * ==================== CL_Record_f - * - * record <demoname> - * - * Begins recording a demo from the current position ==================== - */ static entity_state_t nullstate = new entity_state_t(null); static xcommand_t Record_f = new xcommand_t() { public void execute() { --- 113,124 ---- }; static entity_state_t nullstate = new entity_state_t(null); + /** + * Record_f + * + * record <demoname> + * Begins recording a demo from the current position. + */ static xcommand_t Record_f = new xcommand_t() { public void execute() { *************** *** 234,239 **** }; ! /* ! * ================== CL_ForwardToServer_f ================== */ static xcommand_t ForwardToServer_f = new xcommand_t() { --- 228,233 ---- }; ! /** ! * ForwardToServer_f */ static xcommand_t ForwardToServer_f = new xcommand_t() { *************** *** 254,259 **** }; ! /* ! * ================== CL_Pause_f ================== */ static xcommand_t Pause_f = new xcommand_t() { --- 248,253 ---- }; ! /** ! * Pause_f */ static xcommand_t Pause_f = new xcommand_t() { *************** *** 271,276 **** }; ! /* ! * ================== CL_Quit_f ================== */ static xcommand_t Quit_f = new xcommand_t() { --- 265,270 ---- }; ! /** ! * Quit_f */ static xcommand_t Quit_f = new xcommand_t() { *************** *** 281,288 **** }; ! /* ! * ================ CL_Connect_f ! * ! * ================ */ static xcommand_t Connect_f = new xcommand_t() { --- 275,280 ---- }; ! /** ! * Connect_f */ static xcommand_t Connect_f = new xcommand_t() { *************** *** 316,376 **** }; ! /* ! * ===================== CL_Rcon_f * * Send the rest of the command line over as an unconnected command. - * ===================== */ static xcommand_t Rcon_f = new xcommand_t() { public void execute() { - StringBuffer message = new StringBuffer(1024); - int i; - netadr_t to = new netadr_t(); ! if (Globals.rcon_client_password.string == null) { ! Com ! .Printf("You must set 'rcon_password' before\nissuing an rcon command.\n"); return; } ! message.append((char) 255); ! message.append((char) 255); ! message.append((char) 255); ! message.append((char) 255); ! NET.Config(true); // allow remote ! //strcat (message, "rcon "); ! message.append("rcon "); ! //strcat (message, rcon_client_password.string); message.append(Globals.rcon_client_password.string); - //strcat (message, " "); message.append(" "); ! for (i = 1; i < Cmd.Argc(); i++) { ! //strcat (message, Cmd.Argv(i)); message.append(Cmd.Argv(i)); - //strcat (message, " "); message.append(" "); } if (Globals.cls.state >= Defines.ca_connected) to = Globals.cls.netchan.remote_address; else { if (Globals.rcon_address.string.length() == 0) { ! Com ! .Printf("You must either be connected,\nor set the 'rcon_address' cvar\nto issue rcon commands\n"); ! return; } NET.StringToAdr(Globals.rcon_address.string, to); ! if (to.port == 0) ! //to.port = BigShort (PORT_SERVER); ! to.port = Defines.PORT_SERVER; } message.append('\0'); String b = message.toString(); ! NET.SendPacket(Defines.NS_CLIENT, b.length(), b.getBytes(), to); } }; --- 308,359 ---- }; ! /** ! * Rcon_f * * Send the rest of the command line over as an unconnected command. */ static xcommand_t Rcon_f = new xcommand_t() { public void execute() { ! if (Globals.rcon_client_password.string.length() == 0) { ! Com.Printf("You must set 'rcon_password' before\nissuing an rcon command.\n"); return; } ! StringBuffer message = new StringBuffer(1024); ! // connection less packet ! message.append('\u00ff'); ! message.append('\u00ff'); ! message.append('\u00ff'); ! message.append('\u00ff'); ! // allow remote ! NET.Config(true); ! message.append("rcon "); message.append(Globals.rcon_client_password.string); message.append(" "); ! for (int i = 1; i < Cmd.Argc(); i++) { message.append(Cmd.Argv(i)); message.append(" "); } + netadr_t to = new netadr_t(); + if (Globals.cls.state >= Defines.ca_connected) to = Globals.cls.netchan.remote_address; else { if (Globals.rcon_address.string.length() == 0) { ! Com.Printf("You must either be connected,\nor set the 'rcon_address' cvar\nto issue rcon commands\n"); return; } NET.StringToAdr(Globals.rcon_address.string, to); ! if (to.port == 0) to.port = Defines.PORT_SERVER; } message.append('\0'); String b = message.toString(); ! NET.SendPacket(Defines.NS_CLIENT, b.length(), Lib.stringToBytes(b), to); } }; *************** *** 382,390 **** }; ! /* ! * ================= CL_Changing_f * ! * Just sent as a hint to the client that they should drop to full console ! * ================= */ static xcommand_t Changing_f = new xcommand_t() { --- 365,372 ---- }; ! /** ! * Changing_f * ! * Just sent as a hint to the client that they should drop to full console. */ static xcommand_t Changing_f = new xcommand_t() { *************** *** 404,411 **** }; ! /* ! * ================= CL_Reconnect_f * ! * The server is changing levels ================= */ static xcommand_t Reconnect_f = new xcommand_t() { --- 386,393 ---- }; ! /** ! * Reconnect_f * ! * The server is changing levels. */ static xcommand_t Reconnect_f = new xcommand_t() { *************** *** 440,445 **** }; ! /* ! * ================= CL_PingServers_f ================= */ static xcommand_t PingServers_f = new xcommand_t() { --- 422,427 ---- }; ! /** ! * PingServers_f */ static xcommand_t PingServers_f = new xcommand_t() { *************** *** 499,506 **** }; ! /* ! * ================= CL_Skins_f * ! * Load or download any custom player skins and models ================= */ static xcommand_t Skins_f = new xcommand_t() { --- 481,488 ---- }; ! /** ! * Skins_f * ! * Load or download any custom player skins and models. */ static xcommand_t Skins_f = new xcommand_t() { *************** *** 521,526 **** }; ! /* ! * ============== CL_Userinfo_f ============== */ static xcommand_t Userinfo_f = new xcommand_t() { --- 503,508 ---- }; ! /** ! * Userinfo_f */ static xcommand_t Userinfo_f = new xcommand_t() { *************** *** 531,539 **** }; ! /* ! * ================= CL_Snd_Restart_f * * Restart the sound subsystem so it can pick up new parameters and flush ! * all sounds ================= */ static xcommand_t Snd_Restart_f = new xcommand_t() { --- 513,521 ---- }; ! /** ! * Snd_Restart_f * * Restart the sound subsystem so it can pick up new parameters and flush ! * all sounds. */ static xcommand_t Snd_Restart_f = new xcommand_t() { *************** *** 553,568 **** static String env_suf[] = { "rt", "bk", "lf", "ft", "up", "dn" }; ! /* ! * ================= CL_Precache_f ! * * The server will send this command right before allowing the client into ! * the server ================= */ static xcommand_t Precache_f = new xcommand_t() { public void execute() { ! /* ! * Yet another hack to let old demos work the old precache sequence ! */ ! if (Cmd.Argc() < 2) { --- 535,545 ---- static String env_suf[] = { "rt", "bk", "lf", "ft", "up", "dn" }; ! /** * The server will send this command right before allowing the client into ! * the server. */ static xcommand_t Precache_f = new xcommand_t() { public void execute() { ! // Yet another hack to let old demos work the old precache sequence. if (Cmd.Argc() < 2) { *************** *** 571,575 **** CM.CM_LoadMap(Globals.cl.configstrings[Defines.CS_MODELS + 1], true, iw); ! int mapchecksum = iw[0]; CL_parse.RegisterSounds(); CL_view.PrepRefresh(); --- 548,552 ---- CM.CM_LoadMap(Globals.cl.configstrings[Defines.CS_MODELS + 1], true, iw); ! CL_parse.RegisterSounds(); CL_view.PrepRefresh(); *************** *** 586,612 **** }; - /* - * ================== CL_Frame - * - * ================== - */ private static int extratime; // ============================================================================ ! /* ! * =============== CL_Shutdown * * FIXME: this is a callback from Sys_Quit and Com_Error. It would be better * to run quit through here before the final handoff to the sys code. - * =============== */ static boolean isdown = false; ! /* ! * ==================== CL_WriteDemoMessage * * Dumps the current net message, prefixed by the length - * ==================== */ static void WriteDemoMessage() { --- 563,582 ---- }; private static int extratime; // ============================================================================ ! /** ! * Shutdown * * FIXME: this is a callback from Sys_Quit and Com_Error. It would be better * to run quit through here before the final handoff to the sys code. */ static boolean isdown = false; ! /** ! * WriteDemoMessage * * Dumps the current net message, prefixed by the length */ static void WriteDemoMessage() { *************** *** 624,632 **** } ! /* ! * ======================= CL_SendConnectPacket * * We have gotten a challenge from the server, so try and connect. - * ====================== */ static void SendConnectPacket() { --- 594,601 ---- } ! /** ! * SendConnectPacket * * We have gotten a challenge from the server, so try and connect. */ static void SendConnectPacket() { *************** *** 651,658 **** } ! /* ! * ================= CL_CheckForResend * ! * Resend a connect message if the last one has timed out ================= */ static void CheckForResend() { --- 620,627 ---- } ! /** ! * CheckForResend * ! * Resend a connect message if the last one has timed out. */ static void CheckForResend() { *************** *** 683,691 **** } if (adr.port == 0) - // adr.port = BigShort(PORT_SERVER); adr.port = Defines.PORT_SERVER; ! Globals.cls.connect_time = Globals.cls.realtime; // for retransmit ! // requests Com.Printf("Connecting to " + Globals.cls.servername + "...\n"); --- 652,659 ---- } if (adr.port == 0) adr.port = Defines.PORT_SERVER; ! // for retransmit requests ! Globals.cls.connect_time = Globals.cls.realtime; Com.Printf("Connecting to " + Globals.cls.servername + "...\n"); *************** *** 694,703 **** } ! /* ! * ===================== CL_ClearState * - * ===================== */ - static void ClearState() { S.StopAllSounds(); --- 662,669 ---- } ! /** ! * ClearState * */ static void ClearState() { S.StopAllSounds(); *************** *** 715,726 **** } ! /* ! * ===================== CL_Disconnect * * Goes from a connected state to full screen console state Sends a * disconnect message to the server This is also called on Com_Error, so it ! * shouldn't cause any errors ===================== */ - static void Disconnect() { --- 681,691 ---- } ! /** ! * Disconnect * * Goes from a connected state to full screen console state Sends a * disconnect message to the server This is also called on Com_Error, so it ! * shouldn't cause any errors. */ static void Disconnect() { *************** *** 742,746 **** Math3D.VectorClear(Globals.cl.refdef.blend); ! //re.CinematicSetPalette(null); Menu.ForceMenuOff(); --- 707,712 ---- Math3D.VectorClear(Globals.cl.refdef.blend); ! ! Globals.re.CinematicSetPalette(null); Menu.ForceMenuOff(); *************** *** 748,752 **** Globals.cls.connect_time = 0; ! // SCR.StopCinematic(); if (Globals.cls.demorecording) --- 714,718 ---- Globals.cls.connect_time = 0; ! SCR.StopCinematic(); if (Globals.cls.demorecording) *************** *** 755,761 **** // send a disconnect message to the server fin = (char) Defines.clc_stringcmd + "disconnect"; ! Netchan.Transmit(Globals.cls.netchan, fin.length(), fin.getBytes()); ! Netchan.Transmit(Globals.cls.netchan, fin.length(), fin.getBytes()); ! Netchan.Transmit(Globals.cls.netchan, fin.length(), fin.getBytes()); ClearState(); --- 721,727 ---- // send a disconnect message to the server fin = (char) Defines.clc_stringcmd + "disconnect"; ! Netchan.Transmit(Globals.cls.netchan, fin.length(), Lib.stringToBytes(fin)); ! Netchan.Transmit(Globals.cls.netchan, fin.length(), Lib.stringToBytes(fin)); ! Netchan.Transmit(Globals.cls.netchan, fin.length(), Lib.stringToBytes(fin)); ClearState(); *************** *** 765,770 **** Lib.fclose(Globals.cls.download); Globals.cls.download = null; - // fclose(cls.download); - // cls.download = NULL; } --- 731,734 ---- *************** *** 772,779 **** } ! /* ! * ================= CL_ParseStatusMessage * ! * Handle a reply from a ping ================= */ static void ParseStatusMessage() { --- 736,743 ---- } ! /** ! * ParseStatusMessage * ! * Handle a reply from a ping. */ static void ParseStatusMessage() { *************** *** 786,793 **** } ! /* ! * ================= CL_ConnectionlessPacket * ! * Responses to broadcasts, etc ================= */ static void ConnectionlessPacket() { --- 750,757 ---- } ! /** ! * ConnectionlessPacket * ! * Responses to broadcasts, etc */ static void ConnectionlessPacket() { *************** *** 840,844 **** if (c.equals("print")) { s = MSG.ReadString(Globals.net_message); ! Com.Printf(s); return; } --- 804,809 ---- if (c.equals("print")) { s = MSG.ReadString(Globals.net_message); ! if (s.length() > 0) ! Com.Printf(s); return; } *************** *** 868,873 **** ! /* ! * ================= CL_ReadPackets ================= */ static void ReadPackets() { --- 833,838 ---- ! /** ! * ReadPackets */ static void ReadPackets() { *************** *** 928,933 **** // ============================================================================= ! /* ! * ============== CL_FixUpGender_f ============== */ static void FixUpGender() { --- 893,898 ---- // ============================================================================= ! /** ! * FixUpGender_f */ static void FixUpGender() { *************** *** 1272,1277 **** } ! /* ! * ================= CL_InitLocal ================= */ public static void InitLocal() { --- 1237,1242 ---- } ! /** ! * InitLocal */ public static void InitLocal() { *************** *** 1422,1429 **** } ! /* ! * =============== CL_WriteConfiguration * ! * Writes key bindings and archived cvars to config.cfg =============== */ public static void WriteConfiguration() { --- 1387,1394 ---- } ! /** ! * WriteConfiguration * ! * Writes key bindings and archived cvars to config.cfg. */ public static void WriteConfiguration() { *************** *** 1455,1458 **** --- 1420,1426 ---- } + /** + * FixCvarCheats + */ public static void FixCvarCheats() { int i; *************** *** 1483,1492 **** } ! // ============================================================================ ! /* ! * ================== CL_SendCommand ! * ! * ================== */ public static void SendCommand() { --- 1451,1458 ---- } ! // ============================================================= ! /** ! * SendCommand */ public static void SendCommand() { *************** *** 1512,1515 **** --- 1478,1484 ---- // private static int lasttimecalled; + /** + * Frame + */ public static void Frame(int msec) { *************** *** 1573,1577 **** CL_fx.RunDLights(); CL_fx.RunLightStyles(); ! SCR.RunConsole(); --- 1542,1546 ---- CL_fx.RunDLights(); CL_fx.RunLightStyles(); ! SCR.RunCinematic(); SCR.RunConsole(); *************** *** 1586,1589 **** --- 1555,1561 ---- } + /** + * Shutdown + */ public static void Shutdown() { *************** *** 1602,1606 **** /** ! * initialize client subsystem */ public static void Init() { --- 1574,1578 ---- /** ! * Initialize client subsystem. */ public static void Init() { Index: Key.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/Key.java,v retrieving revision 1.11 retrieving revision 1.11.4.1 diff -C2 -d -r1.11 -r1.11.4.1 *** Key.java 7 Jun 2005 12:57:21 -0000 1.11 --- Key.java 25 Dec 2005 18:11:24 -0000 1.11.4.1 *************** *** 705,709 **** key_lines[edit_line][1] = '/'; ! byte[] bytes = s.getBytes(); System.arraycopy(bytes, 0, key_lines[edit_line], 2, bytes.length); key_linepos = bytes.length + 2; --- 705,709 ---- key_lines[edit_line][1] = '/'; ! byte[] bytes = Lib.stringToBytes(s); System.arraycopy(bytes, 0, key_lines[edit_line], 2, bytes.length); key_linepos = bytes.length + 2; Index: client_state_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/client_state_t.java,v retrieving revision 1.4 retrieving revision 1.4.8.1 diff -C2 -d -r1.4 -r1.4.8.1 *** client_state_t.java 26 Oct 2004 18:18:19 -0000 1.4 --- client_state_t.java 25 Dec 2005 18:11:22 -0000 1.4.8.1 *************** *** 32,35 **** --- 32,36 ---- import java.io.RandomAccessFile; + import java.nio.ByteBuffer; public class client_state_t { *************** *** 107,111 **** // non-gameserver infornamtion // FIXME: move this cinematic stuff into the cin_t structure ! RandomAccessFile cinematic_file; int cinematictime; // cls.realtime for first cinematic frame --- 108,112 ---- // non-gameserver infornamtion // FIXME: move this cinematic stuff into the cin_t structure ! ByteBuffer cinematic_file; int cinematictime; // cls.realtime for first cinematic frame Index: SCR.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/SCR.java,v retrieving revision 1.15 retrieving revision 1.15.2.1 diff -C2 -d -r1.15 -r1.15.2.1 *** SCR.java 1 Jul 2005 14:20:52 -0000 1.15 --- SCR.java 25 Dec 2005 18:11:24 -0000 1.15.2.1 *************** *** 33,36 **** --- 33,37 ---- import jake2.qcommon.*; import jake2.sound.S; + import jake2.sys.Sys; import jake2.sys.Timer; import jake2.util.Lib; *************** *** 38,42 **** --- 39,47 ---- import java.awt.Dimension; + import java.io.IOException; + import java.io.RandomAccessFile; import java.nio.ByteBuffer; + import java.nio.ByteOrder; + import java.util.Arrays; /** *************** *** 1369,1379 **** */ - // typedef struct - // { - // byte *data; - // int count; - // } cblock_t; - // - private static class cinematics_t { boolean restart_sound; --- 1374,1377 ---- *************** *** 1473,1504 **** /** ! * TODO StopCinematic */ static void StopCinematic() { ! cl.cinematictime = 0; // done ! cin.pic = null; ! cin.pic_pending = null; ! if (cl.cinematicpalette_active) { ! re.CinematicSetPalette(null); ! cl.cinematicpalette_active = false; } - // if (cl.cinematic_file) - // { - // fclose (cl.cinematic_file); - // cl.cinematic_file = NULL; - // } - // if (cin.hnodes1) - // { - // Z_Free (cin.hnodes1); - // cin.hnodes1 = NULL; - // } - // - // // switch back down to 11 khz sound if necessary - // if (cin.restart_sound) - // { - // cin.restart_sound = false; - // CL_Snd_Restart_f (); - // } - // } --- 1471,1497 ---- /** ! * StopCinematic */ static void StopCinematic() { ! if (cin.restart_sound) { ! // done ! cl.cinematictime = 0; ! cin.pic = null; ! cin.pic_pending = null; ! if (cl.cinematicpalette_active) { ! re.CinematicSetPalette(null); ! cl.cinematicpalette_active = false; ! } ! if (cl.cinematic_file != null) { ! // free the mapped byte buffer ! cl.cinematic_file = null; ! } ! if (cin.hnodes1 != null) { ! cin.hnodes1 = null; ! } ! ! S.disableStreaming(); ! cin.restart_sound = false; } } *************** *** 1516,1799 **** // ========================================================================== ! // /* ! // ================== ! // SmallestNode1 ! // ================== ! // */ ! // int SmallestNode1 (int numhnodes) ! // { ! // int i; ! // int best, bestnode; ! // ! // best = 99999999; ! // bestnode = -1; ! // for (i=0 ; i<numhnodes ; i++) ! // { ! // if (cin.h_used[i]) ! // continue; ! // if (!cin.h_count[i]) ! // continue; ! // if (cin.h_count[i] < best) ! // { ! // best = cin.h_count[i]; ! // bestnode = i; ! // } ! // } ! // ! // if (bestnode == -1) ! // return -1; ! // ! // cin.h_used[bestnode] = true; ! // return bestnode; ! // } ! // ! // ! // /* ! // ================== ! // Huff1TableInit ! // ! // Reads the 64k counts table and initializes the node trees ! // ================== ! // */ ! // void Huff1TableInit (void) ! // { ! // int prev; ! // int j; ! // int *node, *nodebase; ! // byte counts[256]; ! // int numhnodes; ! // ! // cin.hnodes1 = Z_Malloc (256*256*2*4); ! // memset (cin.hnodes1, 0, 256*256*2*4); ! // ! // for (prev=0 ; prev<256 ; prev++) ! // { ! // memset (cin.h_count,0,sizeof(cin.h_count)); ! // memset (cin.h_used,0,sizeof(cin.h_used)); ! // ! // // read a row of counts ! // FS_Read (counts, sizeof(counts), cl.cinematic_file); ! // for (j=0 ; j<256 ; j++) ! // cin.h_count[j] = counts[j]; ! // ! // // build the nodes ! // numhnodes = 256; ! // nodebase = cin.hnodes1 + prev*256*2; ! // ! // while (numhnodes != 511) ! // { ! // node = nodebase + (numhnodes-256)*2; ! // ! // // pick two lowest counts ! // node[0] = SmallestNode1 (numhnodes); ! // if (node[0] == -1) ! // break; // no more ! // ! // node[1] = SmallestNode1 (numhnodes); ! // if (node[1] == -1) ! // break; ! // ! // cin.h_count[numhnodes] = cin.h_count[node[0]] + cin.h_count[node[1]]; ! // numhnodes++; ! // } ! // ! // cin.numhnodes1[prev] = numhnodes-1; ! // } ! // } ! // ! // /* ! // ================== ! // Huff1Decompress ! // ================== ! // */ ! // cblock_t Huff1Decompress (cblock_t in) ! // { ! // byte *input; ! // byte *out_p; ! // int nodenum; ! // int count; ! // cblock_t out; ! // int inbyte; ! // int *hnodes, *hnodesbase; ! //// int i; ! // ! // // get decompressed count ! // count = in.data[0] + (in.data[1]<<8) + (in.data[2]<<16) + ! // (in.data[3]<<24); ! // input = in.data + 4; ! // out_p = out.data = Z_Malloc (count); ! // ! // // read bits ! // ! // hnodesbase = cin.hnodes1 - 256*2; // nodes 0-255 aren't stored ! // ! // hnodes = hnodesbase; ! // nodenum = cin.numhnodes1[0]; ! // while (count) ! // { ! // inbyte = *input++; ! // //----------- ! // if (nodenum < 256) ! // { ! // hnodes = hnodesbase + (nodenum<<9); ! // *out_p++ = nodenum; ! // if (!--count) ! // break; ! // nodenum = cin.numhnodes1[nodenum]; ! // } ! // nodenum = hnodes[nodenum*2 + (inbyte&1)]; ! // inbyte >>=1; ! // //----------- ! // if (nodenum < 256) ! // { ! // hnodes = hnodesbase + (nodenum<<9); ! // *out_p++ = nodenum; ! // if (!--count) ! // break; ! // nodenum = cin.numhnodes1[nodenum]; ! // } ! // nodenum = hnodes[nodenum*2 + (inbyte&1)]; ! // inbyte >>=1; ! // //----------- ! // if (nodenum < 256) ! // { ! // hnodes = hnodesbase + (nodenum<<9); ! // *out_p++ = nodenum; ! // if (!--count) ! // break; ! // nodenum = cin.numhnodes1[nodenum]; ! // } ! // nodenum = hnodes[nodenum*2 + (inbyte&1)]; ! // inbyte >>=1; ! // //----------- ! // if (nodenum < 256) ! // { ! // hnodes = hnodesbase + (nodenum<<9); ! // *out_p++ = nodenum; ! // if (!--count) ! // break; ! // nodenum = cin.numhnodes1[nodenum]; ! // } ! // nodenum = hnodes[nodenum*2 + (inbyte&1)]; ! // inbyte >>=1; ! // //----------- ! // if (nodenum < 256) ! // { ! // hnodes = hnodesbase + (nodenum<<9); ! // *out_p++ = nodenum; ! // if (!--count) ! // break; ! // nodenum = cin.numhnodes1[nodenum]; ! // } ! // nodenum = hnodes[nodenum*2 + (inbyte&1)]; ! // inbyte >>=1; ! // //----------- ! // if (nodenum < 256) ! // { ! // hnodes = hnodesbase + (nodenum<<9); ! // *out_p++ = nodenum; ! // if (!--count) ! // break; ! // nodenum = cin.numhnodes1[nodenum]; ! // } ! // nodenum = hnodes[nodenum*2 + (inbyte&1)]; ! // inbyte >>=1; ! // //----------- ! // if (nodenum < 256) ! // { ! // hnodes = hnodesbase + (nodenum<<9); ! // *out_p++ = nodenum; ! // if (!--count) ! // break; ! // nodenum = cin.numhnodes1[nodenum]; ! // } ! // nodenum = hnodes[nodenum*2 + (inbyte&1)]; ! // inbyte >>=1; ! // //----------- ! // if (nodenum < 256) ! // { ! // hnodes = hnodesbase + (nodenum<<9); ! // *out_p++ = nodenum; ! // if (!--count) ! // break; ! // nodenum = cin.numhnodes1[nodenum]; ! // } ! // nodenum = hnodes[nodenum*2 + (inbyte&1)]; ! // inbyte >>=1; ! // } ! // ! // if (input - in.data != in.count && input - in.data != in.count+1) ! // { ! // Com_Printf ("Decompression overread by %i", (input - in.data) - ! // in.count); ! // } ! // out.count = out_p - out.data; ! // ! // return out; ! // } ! // /** ! * TODO ReadNextFrame */ static byte[] ReadNextFrame() { ! // TODO implement video frame loading ! return null; ! // int r; ! // int command; ! // byte samples[22050/14*4]; ! // byte compressed[0x20000]; ! // int size; ! // byte *pic; ! // cblock_t in, huf1; ! // int start, end, count; ! // ! // // read the next frame ! // r = fread (&command, 4, 1, cl.cinematic_file); ! // if (r == 0) // we'll give it one more chance ! // r = fread (&command, 4, 1, cl.cinematic_file); ! // ! // if (r != 1) ! // return NULL; ! // command = LittleLong(command); ! // if (command == 2) ! // return NULL; // last frame marker ! // ! // if (command == 1) ! // { // read palette ! // FS_Read (cl.cinematicpalette, sizeof(cl.cinematicpalette), ! // cl.cinematic_file); ! // cl.cinematicpalette_active=0; // dubious.... exposes an edge case ! // } ! // ! // // decompress the next frame ! // FS_Read (&size, 4, cl.cinematic_file); ! // size = LittleLong(size); ! // if (size > sizeof(compressed) || size < 1) ! // Com_Error (ERR_DROP, "Bad compressed frame size"); ! // FS_Read (compressed, size, cl.cinematic_file); ! // ! // // read sound ! // start = cl.cinematicframe*cin.s_rate/14; ! // end = (cl.cinematicframe+1)*cin.s_rate/14; ! // count = end - start; ! // ! // FS_Read (samples, count*cin.s_width*cin.s_channels, cl.cinematic_file); ! // ! // S_RawSamples (count, cin.s_rate, cin.s_width, cin.s_channels, samples); ! // ! // in.data = compressed; ! // in.count = size; ! // ! // huf1 = Huff1Decompress (in); ! // ! // pic = huf1.data; ! // ! // cl.cinematicframe++; ! // ! // return pic; } ! // ! // /** * RunCinematic --- 1509,1743 ---- // ========================================================================== ! /** ! * SmallestNode1 ! * ! */ ! private static int SmallestNode1(int numhnodes) { ! ! int best = 99999999; ! int bestnode = -1; ! for (int i = 0; i < numhnodes; i++) { ! if (cin.h_used[i] != 0) ! continue; ! if (cin.h_count[i] == 0) ! continue; ! if (cin.h_count[i] < best) { ! best = cin.h_count[i]; ! bestnode = i; ! } ! } ! ! if (bestnode == -1) ! return -1; ! ! cin.h_used[bestnode] = 1; // true ! return bestnode; ! } ! /** ! * Huff1TableInit ! * ! * Reads the 64k counts table and initializes the node trees. ! * ! */ ! private static void Huff1TableInit() { ! int[] node; ! byte[] counts = new byte[256]; ! int numhnodes; ! ! cin.hnodes1 = new int[256 * 256 * 2]; ! Arrays.fill(cin.hnodes1, 0); ! ! for (int prev = 0; prev < 256; prev++) { ! Arrays.fill(cin.h_count, 0); ! Arrays.fill(cin.h_used, 0); ! ! // read a row of counts ! cl.cinematic_file.get(counts); ! for (int j = 0; j < 256; j++) ! cin.h_count[j] = counts[j] & 0xFF; ! ! // build the nodes ! numhnodes = 256; ! int nodebase = 0 + prev * 256 * 2; ! int index = 0; ! node = cin.hnodes1; ! while (numhnodes != 511) { ! index = nodebase + (numhnodes - 256) * 2; ! ! // pick two lowest counts ! node[index] = SmallestNode1(numhnodes); ! if (node[index] == -1) ! break; // no more ! ! node[index + 1] = SmallestNode1(numhnodes); ! if (node[index + 1] == -1) ! break; ! ! cin.h_count[numhnodes] = cin.h_count[node[index]] + cin.h_count[node[index + 1]]; ! numhnodes++; ! } ! ! cin.numhnodes1[prev] = numhnodes - 1; ! } ! } ! ! /** ! * Huff1Decompress ! * ! */ ! private static byte[] Huff1Decompress(byte[] in, int size) { ! // get decompressed count ! int count = (in[0] & 0xFF) | ((in[1] & 0xFF)<< 8) | ((in[2] & 0xFF) << 16) | ((in[3] & 0xFF) << 24); ! // used as index for in[]; ! int input = 4; ! byte[] out = new byte[count]; ! // used as index for out[]; ! int out_p = 0; ! ! // read bits ! ! int hnodesbase = -256 * 2; // nodes 0-255 aren't stored ! int index = hnodesbase; ! int[] hnodes = cin.hnodes1; ! int nodenum = cin.numhnodes1[0]; ! int inbyte; ! while (count != 0) { ! inbyte = in[input++] & 0xFF; ! ! if (nodenum < 256) { ! index = hnodesbase + (nodenum << 9); ! out[out_p++] = (byte) nodenum; ! if (--count == 0) ! break; ! nodenum = cin.numhnodes1[nodenum]; ! } ! nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)]; ! inbyte >>= 1; ! ! if (nodenum < 256) { ! index = hnodesbase + (nodenum << 9); ! out[out_p++] = (byte) nodenum; ! if (--count == 0) ! break; ! nodenum = cin.numhnodes1[nodenum]; ! } ! nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)]; ! inbyte >>= 1; ! ! if (nodenum < 256) { ! index = hnodesbase + (nodenum << 9); ! out[out_p++] = (byte) nodenum; ! if (--count == 0) ! break; ! nodenum = cin.numhnodes1[nodenum]; ! } ! nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)]; ! inbyte >>= 1; ! ! if (nodenum < 256) { ! index = hnodesbase + (nodenum << 9); ! out[out_p++] = (byte) nodenum; ! if (--count == 0) ! break; ! nodenum = cin.numhnodes1[nodenum]; ! } ! nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)]; ! inbyte >>= 1; ! ! if (nodenum < 256) { ! index = hnodesbase + (nodenum << 9); ! out[out_p++] = (byte) nodenum; ! if (--count == 0) ! break; ! nodenum = cin.numhnodes1[nodenum]; ! } ! nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)]; ! inbyte >>= 1; ! ! if (nodenum < 256) { ! index = hnodesbase + (nodenum << 9); ! out[out_p++] = (byte) nodenum; ! if (--count == 0) ! break; ! nodenum = cin.numhnodes1[nodenum]; ! } ! nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)]; ! inbyte >>= 1; ! ! if (nodenum < 256) { ! index = hnodesbase + (nodenum << 9); ! out[out_p++] = (byte) nodenum; ! if (--count == 0) ! break; ! nodenum = cin.numhnodes1[nodenum]; ! } ! nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)]; ! inbyte >>= 1; ! ! if (nodenum < 256) { ! index = hnodesbase + (nodenum << 9); ! out[out_p++] = (byte) nodenum; ! if (--count == 0) ! break; ! nodenum = cin.numhnodes1[nodenum]; ! } ! nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)]; ! inbyte >>= 1; ! } ! ! if (input != size && input != size + 1) { ! Com.Printf("Decompression overread by " + (input - size)); ! } ! ! return out; ! } ! ! private static byte[] compressed = new byte[0x20000]; ! ! /** ! * ReadNextFrame */ static byte[] ReadNextFrame() { ! ! ByteBuffer file = cl.cinematic_file; ! ! // read the next frame ! int command = file.getInt(); ! ! if (command == 2) { ! // last frame marker ! return null; ! } ! ! if (command == 1) { ! // read palette ! file.get(cl.cinematicpalette); ! // dubious.... exposes an edge case ! cl.cinematicpalette_active = false; ! } ! // decompress the next frame ! int size = file.getInt(); ! if (size > compressed.length || size < 1) ! Com.Error(ERR_DROP, "Bad compressed frame size:" + size); ! ! file.get(compressed, 0, size); ! ! // read sound ! int start = cl.cinematicframe * cin.s_rate / 14; ! int end = (cl.cinematicframe + 1) * cin.s_rate / 14; ! int count = end - start; ! ! S.RawSamples(count, cin.s_rate, cin.s_width, cin.s_channels, file.slice()); ! // skip the sound samples ! file.position(file.position() + count * cin.s_width * cin.s_channels); ! ! byte[] pic = Huff1Decompress(compressed, size); ! cl.cinematicframe++; ! ! return pic; } ! /** * RunCinematic *************** *** 1805,1833 **** } ! if (cl.cinematicframe == -1) ! return; // static image ! ! if (cls.key_dest != key_game) ! { // pause if menu or console is up ! cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14; return; } - int frame = (int)((cls.realtime - cl.cinematictime) * 14.0f/1000); if (frame <= cl.cinematicframe) return; ! ! if (frame > cl.cinematicframe+1) ! { ! Com.Println("Dropped frame: " + frame + " > " + (cl.cinematicframe+1)); ! cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14; } cin.pic = cin.pic_pending; cin.pic_pending = ReadNextFrame(); ! if (cin.pic_pending == null) ! { StopCinematic(); FinishCinematic(); ! cl.cinematictime = 1; // hack to get the black screen behind loading BeginLoadingPlaque(); cl.cinematictime = 0; --- 1749,1782 ---- } ! if (cl.cinematicframe == -1) { ! // static image ! return; ! } ! ! if (cls.key_dest != key_game) { ! // pause if menu or console is up ! cl.cinematictime = cls.realtime - cl.cinematicframe * 1000 / 14; return; } + + int frame = (int) ((cls.realtime - cl.cinematictime) * 14.0f / 1000); if (frame <= cl.cinematicframe) return; ! ! if (frame > cl.cinematicframe + 1) { ! Com.Println("Dropped frame: " + frame + " > " ! + (cl.cinematicframe + 1)); ! cl.cinematictime = cls.realtime - cl.cinematicframe * 1000 / 14; } + cin.pic = cin.pic_pending; cin.pic_pending = ReadNextFrame(); ! ! if (cin.pic_pending == null) { StopCinematic(); FinishCinematic(); ! // hack to get the black screen behind loading ! cl.cinematictime = 1; BeginLoadingPlaque(); cl.cinematictime = 0; *************** *** 1868,1880 **** /** ! * TODO PlayCinematic */ static void PlayCinematic(String arg) { ! // int width, height; ! // byte *palette; ! // char name[MAX_OSPATH], *dot; ! // int old_khz; ! // ! // // make sure CD isn't playing music //CDAudio.Stop(); --- 1817,1825 ---- /** ! * PlayCinematic */ static void PlayCinematic(String arg) { ! ! // make sure CD isn't playing music //CDAudio.Stop(); *************** *** 1894,1939 **** return; } ! // ! // Com_sprintf (name, sizeof(name), "video/%s", arg); ! // FS_FOpenFile (name, &cl.cinematic_file); ! // if (!cl.cinematic_file) ! // { ! // Com_Error (ERR_DROP, "Cinematic %s not found.\n", name); ! FinishCinematic(); ! cl.cinematictime = 0; // done ! return; ! // } ! // ! // SCR_EndLoadingPlaque (); ! // ! // cls.state = ca_active; ! // ! // FS_Read (&width, 4, cl.cinematic_file); ! // FS_Read (&height, 4, cl.cinematic_file); ! // cin.width = LittleLong(width); ! // cin.height = LittleLong(height); ! // ! // FS_Read (&cin.s_rate, 4, cl.cinematic_file); ! // cin.s_rate = LittleLong(cin.s_rate); ! // FS_Read (&cin.s_width, 4, cl.cinematic_file); ! // cin.s_width = LittleLong(cin.s_width); ! // FS_Read (&cin.s_channels, 4, cl.cinematic_file); ! // 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 --- 1839,1871 ---- return; } ! ! String name = "video/" + arg; ! cl.cinematic_file = FS.LoadMappedFile(name); ! if (cl.cinematic_file == null) { ! //Com.Error(ERR_DROP, "Cinematic " + name + " not found.\n"); ! FinishCinematic(); ! // done ! cl.cinematictime = 0; ! return; ! } ! ! EndLoadingPlaque(); ! ! cls.state = ca_active; ! ! cl.cinematic_file.order(ByteOrder.LITTLE_ENDIAN); ! ByteBuffer file = cl.cinematic_file; ! cin.width = file.getInt(); ! cin.height = file.getInt(); ! cin.s_rate = file.getInt(); ! cin.s_width = file.getInt(); ! cin.s_channels = file.getInt(); ! ! Huff1TableInit(); ! ! cin.restart_sound = true; ! cl.cinematicframe = 0; ! cin.pic = ReadNextFrame(); ! cl.cinematictime = Timer.Milliseconds(); } } \ No newline at end of file Index: CL_inv.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_inv.java,v retrieving revision 1.2 retrieving revision 1.2.12.1 diff -C2 -d -r1.2 -r1.2.12.1 *** CL_inv.java 22 Sep 2004 19:22:08 -0000 1.2 --- CL_inv.java 25 Dec 2005 18:11:22 -0000 1.2.12.1 *************** *** 32,35 **** --- 32,36 ---- import jake2.qcommon.Com; import jake2.qcommon.MSG; + import jake2.util.Lib; import jake2.util.Vargs; *************** *** 59,68 **** } ! static void SetStringHighBit(String s) { ! byte[] b = s.getBytes(); for (int i = 0; i < b.length; i++) { b[i] = (byte) (b[i] | 128); } ! s = new String(b); } --- 60,69 ---- } ! static String getHighBitString(String s) { ! byte[] b = Lib.stringToBytes(s); for (int i = 0; i < b.length; i++) { b[i] = (byte) (b[i] | 128); } ! return Lib.bytesToString(b); } *************** *** 132,136 **** Globals.cl.configstrings[Defines.CS_ITEMS + item])); if (item != selected) ! SetStringHighBit(string); else // draw a blinky cursor by the selected item { --- 133,137 ---- Globals.cl.configstrings[Defines.CS_ITEMS + item])); if (item != selected) ! string = getHighBitString(string); else // draw a blinky cursor by the selected item { |
From: Carsten W. <ca...@us...> - 2005-12-18 22:10:52
|
Update of /cvsroot/jake2/jake2/src/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26351/src/jake2/qcommon Modified Files: MSG.java SZ.java Netchan.java Cbuf.java Log Message: byte[] <--> String with latin 1 alias ISO-8859-1 Index: SZ.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/SZ.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SZ.java 6 Feb 2005 19:26:50 -0000 1.5 --- SZ.java 18 Dec 2005 22:10:07 -0000 1.6 *************** *** 27,30 **** --- 27,31 ---- import jake2.Defines; + import jake2.util.Lib; /** *************** *** 91,95 **** Com.dprintln("SZ.print():<" + data + ">" ); int length = data.length(); ! byte str[] = data.getBytes(); if (buf.cursize != 0) { --- 92,96 ---- Com.dprintln("SZ.print():<" + data + ">" ); int length = data.length(); ! byte str[] = Lib.stringToBytes(data); if (buf.cursize != 0) { Index: Cbuf.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Cbuf.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Cbuf.java 19 Feb 2005 11:12:42 -0000 1.7 --- Cbuf.java 18 Dec 2005 22:10:09 -0000 1.8 *************** *** 146,150 **** return; } ! SZ.Write(Globals.cmd_text, text.getBytes(), l); } --- 146,150 ---- return; } ! SZ.Write(Globals.cmd_text, Lib.stringToBytes(text), l); } Index: Netchan.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/Netchan.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Netchan.java 1 Jul 2005 14:20:56 -0000 1.6 --- Netchan.java 18 Dec 2005 22:10:08 -0000 1.7 *************** *** 32,35 **** --- 32,36 ---- import jake2.sys.NET; import jake2.sys.Timer; + import jake2.util.Lib; /** *************** *** 141,145 **** public static void OutOfBandPrint(int net_socket, netadr_t adr, String s) { ! Netchan_OutOfBand(net_socket, adr, s.length(), s.getBytes()); } --- 142,146 ---- public static void OutOfBandPrint(int net_socket, netadr_t adr, String s) { ! Netchan_OutOfBand(net_socket, adr, s.length(), Lib.stringToBytes(s)); } Index: MSG.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/MSG.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MSG.java 19 Feb 2005 21:20:47 -0000 1.7 --- MSG.java 18 Dec 2005 22:10:02 -0000 1.8 *************** *** 86,90 **** x = ""; ! SZ.Write(sb, x.getBytes()); WriteByte(sb, 0); //Com.dprintln("MSG.WriteString:" + s.replace('\0', '@')); --- 86,90 ---- x = ""; ! SZ.Write(sb, Lib.stringToBytes(x)); WriteByte(sb, 0); //Com.dprintln("MSG.WriteString:" + s.replace('\0', '@')); |
From: Carsten W. <ca...@us...> - 2005-12-18 22:10:24
|
Update of /cvsroot/jake2/jake2/src/jake2/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26351/src/jake2/client Modified Files: CL_inv.java CL.java Key.java Log Message: byte[] <--> String with latin 1 alias ISO-8859-1 Index: Key.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/Key.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Key.java 7 Jun 2005 12:57:21 -0000 1.11 --- Key.java 18 Dec 2005 22:10:12 -0000 1.12 *************** *** 705,709 **** key_lines[edit_line][1] = '/'; ! byte[] bytes = s.getBytes(); System.arraycopy(bytes, 0, key_lines[edit_line], 2, bytes.length); key_linepos = bytes.length + 2; --- 705,709 ---- key_lines[edit_line][1] = '/'; ! byte[] bytes = Lib.stringToBytes(s); System.arraycopy(bytes, 0, key_lines[edit_line], 2, bytes.length); key_linepos = bytes.length + 2; Index: CL.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** CL.java 18 Dec 2005 16:43:51 -0000 1.28 --- CL.java 18 Dec 2005 22:10:10 -0000 1.29 *************** *** 721,727 **** // send a disconnect message to the server fin = (char) Defines.clc_stringcmd + "disconnect"; ! Netchan.Transmit(Globals.cls.netchan, fin.length(), fin.getBytes()); ! Netchan.Transmit(Globals.cls.netchan, fin.length(), fin.getBytes()); ! Netchan.Transmit(Globals.cls.netchan, fin.length(), fin.getBytes()); ClearState(); --- 721,727 ---- // send a disconnect message to the server fin = (char) Defines.clc_stringcmd + "disconnect"; ! Netchan.Transmit(Globals.cls.netchan, fin.length(), Lib.stringToBytes(fin)); ! Netchan.Transmit(Globals.cls.netchan, fin.length(), Lib.stringToBytes(fin)); ! Netchan.Transmit(Globals.cls.netchan, fin.length(), Lib.stringToBytes(fin)); ClearState(); Index: CL_inv.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_inv.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CL_inv.java 22 Sep 2004 19:22:08 -0000 1.2 --- CL_inv.java 18 Dec 2005 22:10:10 -0000 1.3 *************** *** 32,35 **** --- 32,36 ---- import jake2.qcommon.Com; import jake2.qcommon.MSG; + import jake2.util.Lib; import jake2.util.Vargs; *************** *** 59,68 **** } ! static void SetStringHighBit(String s) { ! byte[] b = s.getBytes(); for (int i = 0; i < b.length; i++) { b[i] = (byte) (b[i] | 128); } ! s = new String(b); } --- 60,69 ---- } ! static String getHighBitString(String s) { ! byte[] b = Lib.stringToBytes(s); for (int i = 0; i < b.length; i++) { b[i] = (byte) (b[i] | 128); } ! return Lib.bytesToString(b); } *************** *** 132,136 **** Globals.cl.configstrings[Defines.CS_ITEMS + item])); if (item != selected) ! SetStringHighBit(string); else // draw a blinky cursor by the selected item { --- 133,137 ---- Globals.cl.configstrings[Defines.CS_ITEMS + item])); if (item != selected) ! string = getHighBitString(string); else // draw a blinky cursor by the selected item { |
From: Carsten W. <ca...@us...> - 2005-12-18 22:10:24
|
Update of /cvsroot/jake2/jake2/src/jake2/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26351/src/jake2/util Modified Files: Lib.java Log Message: byte[] <--> String with latin 1 alias ISO-8859-1 Index: Lib.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/util/Lib.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Lib.java 18 Dec 2005 16:34:13 -0000 1.17 --- Lib.java 18 Dec 2005 22:10:12 -0000 1.18 *************** *** 209,218 **** int diff = len - s.length(); if (diff > 0) { ! f.write(s.getBytes()); f.write(nullfiller, 0, diff); } else ! f.write(s.getBytes(), 0, len); } --- 209,218 ---- int diff = len - s.length(); if (diff > 0) { ! f.write(stringToBytes(s)); f.write(nullfiller, 0, diff); } else ! f.write(stringToBytes(s), 0, len); } *************** *** 316,319 **** --- 316,333 ---- } } + + /** + * convert a byte[] with 8bit latin 1 to java string + * + * avoid new String(bytes) because it is using system specific character encoding. + */ + public static String bytesToString(byte[] value) { + try { + return new String(value, "ISO-8859-1"); + } catch (UnsupportedEncodingException e) { + // can't happen: Latin 1 is a standard encoding + return null; + } + } /** Helper method that savely handles the null termination of old C String data. */ |
From: Carsten W. <ca...@us...> - 2005-12-18 22:10:24
|
Update of /cvsroot/jake2/jake2/src/jake2/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26351/src/jake2/server Modified Files: SV_SEND.java SV_MAIN.java Log Message: byte[] <--> String with latin 1 alias ISO-8859-1 Index: SV_MAIN.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_MAIN.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SV_MAIN.java 18 Dec 2005 17:25:09 -0000 1.13 --- SV_MAIN.java 18 Dec 2005 22:10:13 -0000 1.14 *************** *** 459,463 **** Defines.SV_OUTPUTBUF_LENGTH, new Com.RD_Flusher() { public void rd_flush(int target, StringBuffer buffer) { ! SV_SEND.SV_FlushRedirect(target, buffer.toString().getBytes()); } }); --- 459,463 ---- Defines.SV_OUTPUTBUF_LENGTH, new Com.RD_Flusher() { public void rd_flush(int target, StringBuffer buffer) { ! SV_SEND.SV_FlushRedirect(target, Lib.stringToBytes(buffer.toString())); } }); Index: SV_SEND.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_SEND.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SV_SEND.java 16 Dec 2005 21:18:23 -0000 1.9 --- SV_SEND.java 18 Dec 2005 22:10:12 -0000 1.10 *************** *** 48,52 **** if (sv_redirected == Defines.RD_PACKET) { String s = ("print\n" + Lib.CtoJava(outputbuf)); ! Netchan.Netchan_OutOfBand(Defines.NS_SERVER, Globals.net_from, s.length(), s.getBytes()); } else if (sv_redirected == Defines.RD_CLIENT) { --- 48,52 ---- if (sv_redirected == Defines.RD_PACKET) { String s = ("print\n" + Lib.CtoJava(outputbuf)); ! Netchan.Netchan_OutOfBand(Defines.NS_SERVER, Globals.net_from, s.length(), Lib.stringToBytes(s)); } else if (sv_redirected == Defines.RD_CLIENT) { |
From: Carsten W. <ca...@us...> - 2005-12-18 17:25:21
|
Update of /cvsroot/jake2/jake2/src/jake2/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32759/src/jake2/server Modified Files: SV_MAIN.java Log Message: removed TODO allow downloads per default set cheats to 0 per default Index: SV_MAIN.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_MAIN.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SV_MAIN.java 16 Dec 2005 21:17:51 -0000 1.12 --- SV_MAIN.java 18 Dec 2005 17:25:09 -0000 1.13 *************** *** 916,921 **** Cvar.Get("fraglimit", "0", Defines.CVAR_SERVERINFO); Cvar.Get("timelimit", "0", Defines.CVAR_SERVERINFO); ! //TODO: set cheats 0 ! Cvar.Get("cheats", "1", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); Cvar.Get("protocol", "" + Defines.PROTOCOL_VERSION, Defines.CVAR_SERVERINFO | Defines.CVAR_NOSET); --- 916,920 ---- Cvar.Get("fraglimit", "0", Defines.CVAR_SERVERINFO); Cvar.Get("timelimit", "0", Defines.CVAR_SERVERINFO); ! Cvar.Get("cheats", "0", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); Cvar.Get("protocol", "" + Defines.PROTOCOL_VERSION, Defines.CVAR_SERVERINFO | Defines.CVAR_NOSET); *************** *** 932,937 **** SV_MAIN.sv_enforcetime = Cvar.Get("sv_enforcetime", "0", 0); ! // TODO: carsten, re-allow downloads per default ! SV_MAIN.allow_download = Cvar.Get("allow_download", "0", Defines.CVAR_ARCHIVE); SV_MAIN.allow_download_players = Cvar.Get("allow_download_players", --- 931,935 ---- SV_MAIN.sv_enforcetime = Cvar.Get("sv_enforcetime", "0", 0); ! SV_MAIN.allow_download = Cvar.Get("allow_download", "1", Defines.CVAR_ARCHIVE); SV_MAIN.allow_download_players = Cvar.Get("allow_download_players", |
From: Rene S. <sa...@us...> - 2005-12-18 17:08:40
|
Update of /cvsroot/jake2/jake2/src/jake2/game In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29486/src/jake2/game Modified Files: Cmd.java Log Message: cheat bugfix in God_f and Give_f Index: Cmd.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/Cmd.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Cmd.java 20 Nov 2005 22:18:33 -0000 1.16 --- Cmd.java 18 Dec 2005 17:08:27 -0000 1.17 *************** *** 479,483 **** edict_t it_ent; ! if (GameBase.deathmatch.value == 0 && GameBase.sv_cheats.value == 0) { SV_GAME .PF_cprintf(ent, Defines.PRINT_HIGH, --- 479,483 ---- edict_t it_ent; ! if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0) { SV_GAME .PF_cprintf(ent, Defines.PRINT_HIGH, *************** *** 614,618 **** String msg; ! if (GameBase.deathmatch.value == 0 && GameBase.sv_cheats.value == 0) { SV_GAME .PF_cprintf(ent, Defines.PRINT_HIGH, --- 614,618 ---- String msg; ! if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0) { SV_GAME .PF_cprintf(ent, Defines.PRINT_HIGH, |
From: Carsten W. <ca...@us...> - 2005-12-18 16:43:59
|
Update of /cvsroot/jake2/jake2/src/jake2/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25474/src/jake2/client Modified Files: CL.java Log Message: bugfix: resolves the char encoding problem with String.getBytes() (see RCon_f) ... code cleanup Index: CL.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** CL.java 16 Dec 2005 21:14:36 -0000 1.27 --- CL.java 18 Dec 2005 16:43:51 -0000 1.28 *************** *** 33,39 **** import jake2.sound.S; import jake2.sys.*; ! import jake2.util.Lib; ! import jake2.util.Math3D; ! import jake2.util.Vargs; import java.io.IOException; --- 33,37 ---- import jake2.sound.S; import jake2.sys.*; ! import jake2.util.*; import java.io.IOException; *************** *** 317,369 **** static xcommand_t Rcon_f = new xcommand_t() { public void execute() { - StringBuffer message = new StringBuffer(1024); - int i; - netadr_t to = new netadr_t(); ! if (Globals.rcon_client_password.string == null) { ! Com ! .Printf("You must set 'rcon_password' before\nissuing an rcon command.\n"); return; } ! message.append((char) 255); ! message.append((char) 255); ! message.append((char) 255); ! message.append((char) 255); ! NET.Config(true); // allow remote ! //strcat (message, "rcon "); ! message.append("rcon "); ! //strcat (message, rcon_client_password.string); message.append(Globals.rcon_client_password.string); - //strcat (message, " "); message.append(" "); ! for (i = 1; i < Cmd.Argc(); i++) { ! //strcat (message, Cmd.Argv(i)); message.append(Cmd.Argv(i)); - //strcat (message, " "); message.append(" "); } if (Globals.cls.state >= Defines.ca_connected) to = Globals.cls.netchan.remote_address; else { if (Globals.rcon_address.string.length() == 0) { ! Com ! .Printf("You must either be connected,\nor set the 'rcon_address' cvar\nto issue rcon commands\n"); ! return; } NET.StringToAdr(Globals.rcon_address.string, to); ! if (to.port == 0) ! //to.port = BigShort (PORT_SERVER); ! to.port = Defines.PORT_SERVER; } message.append('\0'); String b = message.toString(); ! NET.SendPacket(Defines.NS_CLIENT, b.length(), b.getBytes(), to); } }; --- 315,359 ---- static xcommand_t Rcon_f = new xcommand_t() { public void execute() { ! if (Globals.rcon_client_password.string.length() == 0) { ! Com.Printf("You must set 'rcon_password' before\nissuing an rcon command.\n"); return; } ! StringBuffer message = new StringBuffer(1024); ! // connection less packet ! message.append('\u00ff'); ! message.append('\u00ff'); ! message.append('\u00ff'); ! message.append('\u00ff'); ! // allow remote ! NET.Config(true); ! message.append("rcon "); message.append(Globals.rcon_client_password.string); message.append(" "); ! for (int i = 1; i < Cmd.Argc(); i++) { message.append(Cmd.Argv(i)); message.append(" "); } + netadr_t to = new netadr_t(); + if (Globals.cls.state >= Defines.ca_connected) to = Globals.cls.netchan.remote_address; else { if (Globals.rcon_address.string.length() == 0) { ! Com.Printf("You must either be connected,\nor set the 'rcon_address' cvar\nto issue rcon commands\n"); return; } NET.StringToAdr(Globals.rcon_address.string, to); ! if (to.port == 0) to.port = Defines.PORT_SERVER; } message.append('\0'); String b = message.toString(); ! NET.SendPacket(Defines.NS_CLIENT, b.length(), Lib.stringToBytes(b), to); } }; |