Update of /cvsroot/jake2/jake2/src/jake2/game In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2637/src/jake2/game Modified Files: Tag: r_0_9 monsterinfo_t.java PlayerClient.java PlayerClientAdapters.java GameTargetAdapters.java Cmd.java entity_state_t.java GameUtil.java pmove_state_t.java trace_t.java GameSpawn.java level_locals_t.java client_persistant_t.java edict_t.java mframe_t.java GameMiscAdapters.java gclient_t.java GameSave.java moveinfo_t.java client_respawn_t.java PlayerHud.java GameAIAdapters.java GameBase.java player_state_t.java GameAI.java GameFuncAdapters.java SuperAdapter.java GameTriggerAdapters.java game_locals_t.java M_Flyer.java mmove_t.java game_import_t.java gitem_t.java Removed Files: Tag: r_0_9 game_export_t.java Swap.java Log Message: merge changes for 0.9.3 Index: GameTargetAdapters.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameTargetAdapters.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** GameTargetAdapters.java 8 Jul 2004 15:58:43 -0000 1.1 --- GameTargetAdapters.java 6 Sep 2004 19:39:14 -0000 1.1.2.1 *************** *** 24,32 **** package jake2.game; ! import jake2.*; ! import jake2.client.*; ! import jake2.qcommon.*; ! import jake2.render.*; ! import jake2.server.*; import jake2.util.Lib; import jake2.util.Math3D; --- 24,29 ---- package jake2.game; ! import jake2.Defines; ! import jake2.Globals; import jake2.util.Lib; import jake2.util.Math3D; *************** *** 92,99 **** if ((ent.spawnflags & 1) != 0) //strncpy(game.helpmessage1, ent.message, sizeof(game.helpmessage2) - 1); ! ent.message = GameBase.game.helpmessage1; else //strncpy(game.helpmessage2, ent.message, sizeof(game.helpmessage1) - 1); ! ent.message = GameBase.game.helpmessage2; GameBase.game.helpchanged++; --- 89,96 ---- if ((ent.spawnflags & 1) != 0) //strncpy(game.helpmessage1, ent.message, sizeof(game.helpmessage2) - 1); ! GameBase.game.helpmessage1 = ent.message; else //strncpy(game.helpmessage2, ent.message, sizeof(game.helpmessage1) - 1); ! GameBase.game.helpmessage2 = ent.message; GameBase.game.helpchanged++; *************** *** 554,558 **** } ! for (i = 1; i < GameBase.globals.num_edicts; i++) { e = GameBase.g_edicts[i]; --- 551,555 ---- } ! for (i = 1; i < GameBase.num_edicts; i++) { e = GameBase.g_edicts[i]; Index: edict_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/edict_t.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** edict_t.java 8 Jul 2004 15:58:44 -0000 1.2 --- edict_t.java 6 Sep 2004 19:39:15 -0000 1.2.2.1 *************** *** 19,110 **** */ package jake2.game; import jake2.*; import jake2.util.*; public class edict_t { ! public edict_t(int i) { [...1090 lines suppressed...] + style= f.readInt(); + + item= f.readItem(); + + moveinfo.read(f); + monsterinfo.read(f); + + int ndx= f.readInt(); + if (ndx == -1) + client= null; + else + client= Game.game.clients[ndx]; + + owner= f.readEdictRef(); + + // rst's checker :-) + if (f.readInt() != 9876) + System.err.println("ent load check failed for num " + index); + } } Index: monsterinfo_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/monsterinfo_t.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** monsterinfo_t.java 7 Jul 2004 19:59:26 -0000 1.1.1.1 --- monsterinfo_t.java 6 Sep 2004 19:39:14 -0000 1.1.1.1.2.1 *************** *** 24,27 **** --- 24,32 ---- package jake2.game; + import jake2.util.QuakeFile; + + import java.io.IOException; + import java.io.RandomAccessFile; + public class monsterinfo_t { *************** *** 61,63 **** --- 66,162 ---- public int power_armor_power; + /** Writes the monsterinfo to the file.*/ + public void write(QuakeFile f) throws IOException + { + f.writeBoolean(currentmove != null); + if (currentmove != null) + currentmove.write(f); + f.writeInt(aiflags); + f.writeInt(nextframe); + f.writeFloat(scale); + f.writeAdapter(stand); + f.writeAdapter(idle); + f.writeAdapter(search); + f.writeAdapter(walk); + f.writeAdapter(run); + + f.writeAdapter(dodge); + + f.writeAdapter(attack); + f.writeAdapter(melee); + + f.writeAdapter(sight); + + f.writeAdapter(checkattack); + + f.writeFloat(pausetime); + f.writeFloat(attack_finished); + + f.writeVector(saved_goal); + + f.writeFloat(search_time); + f.writeFloat(trail_time); + + f.writeVector(last_sighting); + + f.writeInt(attack_state); + f.writeInt(lefty); + + f.writeFloat(idle_time); + f.writeInt(linkcount); + + f.writeInt(power_armor_power); + f.writeInt(power_armor_type); + } + + /** Writes the monsterinfo to the file.*/ + public void read(QuakeFile f) throws IOException + { + if (f.readBoolean()) + { + currentmove= new mmove_t(); + currentmove.read(f); + } + else + currentmove= null; + aiflags = f.readInt(); + nextframe = f.readInt(); + scale = f.readFloat(); + stand = (EntThinkAdapter) f.readAdapter(); + idle = (EntThinkAdapter) f.readAdapter(); + search = (EntThinkAdapter) f.readAdapter(); + walk = (EntThinkAdapter) f.readAdapter(); + run = (EntThinkAdapter) f.readAdapter(); + + dodge = (EntDodgeAdapter) f.readAdapter(); + + attack = (EntThinkAdapter) f.readAdapter(); + melee = (EntThinkAdapter) f.readAdapter(); + + sight = (EntInteractAdapter) f.readAdapter(); + + checkattack = (EntThinkAdapter) f.readAdapter(); + + pausetime = f.readFloat(); + attack_finished = f.readFloat(); + + saved_goal = f.readVector(); + + search_time = f.readFloat(); + trail_time = f.readFloat(); + + last_sighting = f.readVector(); + + attack_state = f.readInt(); + lefty = f.readInt(); + + idle_time = f.readFloat(); + linkcount = f.readInt(); + + power_armor_power = f.readInt(); + power_armor_type = f.readInt(); + + } + + } Index: moveinfo_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/moveinfo_t.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** moveinfo_t.java 7 Jul 2004 19:59:26 -0000 1.1.1.1 --- moveinfo_t.java 6 Sep 2004 19:39:15 -0000 1.1.1.1.2.1 *************** *** 24,27 **** --- 24,31 ---- package jake2.game; + import java.io.IOException; + + import jake2.util.QuakeFile; + public class moveinfo_t { // fixed data *************** *** 52,54 **** --- 56,116 ---- float decel_distance; EntThinkAdapter endfunc; + + /** saves the moveinfo to the file.*/ + public void write(QuakeFile f) throws IOException { + f.writeVector(start_origin); + f.writeVector(start_angles); + f.writeVector(end_origin); + f.writeVector(end_angles); + + f.writeInt(sound_start); + f.writeInt(sound_middle); + f.writeInt(sound_end); + + f.writeFloat(accel); + f.writeFloat(speed); + f.writeFloat(decel); + f.writeFloat(distance); + + f.writeFloat(wait); + + f.writeInt(state); + f.writeVector(dir); + + f.writeFloat(current_speed); + f.writeFloat(move_speed); + f.writeFloat(next_speed); + f.writeFloat(remaining_distance); + f.writeFloat(decel_distance); + f.writeAdapter(endfunc); + } + + /** Reads the moveinfo from a file. */ + public void read(QuakeFile f) throws IOException { + start_origin= f.readVector(); + start_angles= f.readVector(); + end_origin= f.readVector(); + end_angles= f.readVector(); + + sound_start= f.readInt(); + sound_middle= f.readInt(); + sound_end= f.readInt(); + + accel= f.readFloat(); + speed= f.readFloat(); + decel= f.readFloat(); + distance= f.readFloat(); + + wait= f.readFloat(); + + state= f.readInt(); + dir= f.readVector(); + + current_speed= f.readFloat(); + move_speed= f.readFloat(); + next_speed= f.readFloat(); + remaining_distance= f.readFloat(); + decel_distance= f.readFloat(); + endfunc= (EntThinkAdapter) f.readAdapter(); + } } Index: player_state_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/player_state_t.java,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** player_state_t.java 9 Jul 2004 08:38:29 -0000 1.2.2.1 --- player_state_t.java 6 Sep 2004 19:39:15 -0000 1.2.2.2 *************** *** 25,28 **** --- 25,29 ---- import java.io.IOException; + import java.io.RandomAccessFile; import java.nio.ByteBuffer; *************** *** 33,56 **** import jake2.util.Math3D; public class player_state_t { - // player_state_t is the information needed in addition to pmove_state_t - // to rendered a view. There will only be 10 player_state_t sent each second, - // but the number of pmove_state_t changes will be reletive to client - // frame rates ! public pmove_state_t pmove = new pmove_state_t(); // for prediction // these fields do not need to be communicated bit-precise ! public float[] viewangles = { 0, 0, 0 }; // for fixed views ! public float[] viewoffset = { 0, 0, 0 }; // add to pmovestate->origin ! public float[] kick_angles = { 0, 0, 0 }; // add to view direction to get render angles // set by weapon kicks, pain effects, etc ! public float[] gunangles = { 0, 0, 0 }; ! public float[] gunoffset = { 0, 0, 0 }; public int gunindex; public int gunframe; ! public float blend[] = new float[4]; // rgba full screen effect public float fov; // horizontal field of view --- 34,60 ---- import jake2.util.Math3D; + /** + Player_state_t is the information needed in addition to pmove_state_t + to rendered a view. There will only be 10 player_state_t sent each second, + but the number of pmove_state_t changes will be relative to client + frame rates. + */ + public class player_state_t { ! public pmove_state_t pmove= new pmove_state_t(); // for prediction // these fields do not need to be communicated bit-precise ! public float[] viewangles= { 0, 0, 0 }; // for fixed views ! public float[] viewoffset= { 0, 0, 0 }; // add to pmovestate->origin ! public float[] kick_angles= { 0, 0, 0 }; // add to view direction to get render angles // set by weapon kicks, pain effects, etc ! public float[] gunangles= { 0, 0, 0 }; ! public float[] gunoffset= { 0, 0, 0 }; public int gunindex; public int gunframe; ! public float blend[]= new float[4]; // rgba full screen effect public float fov; // horizontal field of view *************** *** 58,144 **** public int rdflags; // refdef flags ! public short stats[] = new short[Defines.MAX_STATS]; ! /** ! * ! */ ! private static player_state_t prototype = new player_state_t(); ! public void clear() { this.set(prototype); } ! ! public player_state_t getClone() ! { return new player_state_t().set(this); } ! ! public player_state_t set(player_state_t from) ! { pmove.set(from.pmove); Math3D.VectorCopy(from.viewangles, viewangles); ! Math3D.VectorCopy(from.viewoffset,viewoffset); Math3D.VectorCopy(from.kick_angles, kick_angles); ! Math3D.VectorCopy(from.gunangles,gunangles); Math3D.VectorCopy(from.gunoffset, gunoffset); ! gunindex = from.gunindex; ! gunframe = from.gunframe; - blend[0] = from.blend[0]; - blend[1] = from.blend[1]; - blend[2] = from.blend[2]; - blend[3] = from.blend[3]; - - fov = from.fov; - rdflags = from.rdflags; - - //stats = new short[Defines.MAX_STATS]; - System.arraycopy(from.stats, 0, stats,0, Defines.MAX_STATS); - return this; } ! public void load(ByteBuffer bb) throws IOException { ! pmove.load(bb); ! viewangles[0] = bb.getFloat(); ! viewangles[1] = bb.getFloat(); ! viewangles[2] = bb.getFloat(); ! viewoffset[0] = bb.getFloat(); ! viewoffset[1] = bb.getFloat(); ! viewoffset[2] = bb.getFloat(); ! kick_angles[0] = bb.getFloat(); ! kick_angles[1] = bb.getFloat(); ! kick_angles[2] = bb.getFloat(); ! gunangles[0] = bb.getFloat(); ! gunangles[1] = bb.getFloat(); ! gunangles[2] = bb.getFloat(); ! gunoffset[0] = bb.getFloat(); ! gunoffset[1] = bb.getFloat(); ! gunoffset[2] = bb.getFloat(); ! gunindex = bb.getInt(); ! gunframe = bb.getInt(); ! blend[0] = bb.getFloat(); ! blend[1] = bb.getFloat(); ! blend[2] = bb.getFloat(); ! blend[3] = bb.getFloat(); ! fov = bb.getFloat(); ! rdflags = bb.getInt(); ! for (int n = 0; n < Defines.MAX_STATS; n++) ! stats[n] = bb.getShort(); } public void dump() { pmove.dump(); --- 62,187 ---- public int rdflags; // refdef flags ! public short stats[]= new short[Defines.MAX_STATS]; ! /** Lets cleverly reset the structure. */ ! private static player_state_t prototype= new player_state_t(); ! ! /** Clears the player_state.*/ public void clear() { this.set(prototype); } ! ! /** Clones the object.*/ ! public player_state_t getClone() { return new player_state_t().set(this); } ! ! /** Copies the player state data. */ ! public player_state_t set(player_state_t from) { pmove.set(from.pmove); Math3D.VectorCopy(from.viewangles, viewangles); ! Math3D.VectorCopy(from.viewoffset, viewoffset); Math3D.VectorCopy(from.kick_angles, kick_angles); ! Math3D.VectorCopy(from.gunangles, gunangles); Math3D.VectorCopy(from.gunoffset, gunoffset); ! gunindex= from.gunindex; ! gunframe= from.gunframe; ! ! blend[0]= from.blend[0]; ! blend[1]= from.blend[1]; ! blend[2]= from.blend[2]; ! blend[3]= from.blend[3]; ! ! fov= from.fov; ! rdflags= from.rdflags; ! ! System.arraycopy(from.stats, 0, stats, 0, Defines.MAX_STATS); return this; } ! /** Reads a player_state from a file.*/ ! public void load(RandomAccessFile f) throws IOException { ! pmove.load(f); ! viewangles[0]= f.readFloat(); ! viewangles[1]= f.readFloat(); ! viewangles[2]= f.readFloat(); ! viewoffset[0]= f.readFloat(); ! viewoffset[1]= f.readFloat(); ! viewoffset[2]= f.readFloat(); ! kick_angles[0]= f.readFloat(); ! kick_angles[1]= f.readFloat(); ! kick_angles[2]= f.readFloat(); ! gunangles[0]= f.readFloat(); ! gunangles[1]= f.readFloat(); ! gunangles[2]= f.readFloat(); ! gunoffset[0]= f.readFloat(); ! gunoffset[1]= f.readFloat(); ! gunoffset[2]= f.readFloat(); ! gunindex= f.readInt(); ! gunframe= f.readInt(); ! blend[0]= f.readFloat(); ! blend[1]= f.readFloat(); ! blend[2]= f.readFloat(); ! blend[3]= f.readFloat(); ! fov= f.readFloat(); ! rdflags= f.readInt(); ! for (int n= 0; n < Defines.MAX_STATS; n++) ! stats[n]= f.readShort(); ! } ! ! /** Writes a player_state to a file.*/ ! public void write(RandomAccessFile f) throws IOException { ! pmove.write(f); ! ! f.writeFloat(viewangles[0]); ! f.writeFloat(viewangles[1]); ! f.writeFloat(viewangles[2]); ! ! f.writeFloat(viewoffset[0]); ! f.writeFloat(viewoffset[1]); ! f.writeFloat(viewoffset[2]); ! ! f.writeFloat(kick_angles[0]); ! f.writeFloat(kick_angles[1]); ! f.writeFloat(kick_angles[2]); ! ! f.writeFloat(gunangles[0]); ! f.writeFloat(gunangles[1]); ! f.writeFloat(gunangles[2]); + f.writeFloat(gunoffset[0]); + f.writeFloat(gunoffset[1]); + f.writeFloat(gunoffset[2]); + + f.writeInt(gunindex); + f.writeInt(gunframe); + + f.writeFloat(blend[0]); + f.writeFloat(blend[1]); + f.writeFloat(blend[2]); + f.writeFloat(blend[3]); + + f.writeFloat(fov); + + f.writeInt(rdflags); + + for (int n= 0; n < Defines.MAX_STATS; n++) + f.writeShort(stats[n]); } + /** Prints the player state. */ public void dump() { pmove.dump(); *************** *** 159,163 **** Com.Println("rdflags: " + rdflags); ! for (int n = 0; n < Defines.MAX_STATS; n++) System.out.println("stats[" + n + "]: " + stats[n]); } --- 202,206 ---- Com.Println("rdflags: " + rdflags); ! for (int n= 0; n < Defines.MAX_STATS; n++) System.out.println("stats[" + n + "]: " + stats[n]); } Index: GameBase.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameBase.java,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** GameBase.java 9 Jul 2004 08:38:28 -0000 1.2.2.1 --- GameBase.java 6 Sep 2004 19:39:15 -0000 1.2.2.2 *************** *** 22,26 **** // $Id$ ! /** Father of all Objects. */ package jake2.game; --- 22,26 ---- // $Id$ ! /** Father of all GameObjects. */ [...1165 lines suppressed...] }; ! //globals.apiversion= GAME_API_VERSION; /* globals.Init = InitGame; *************** *** 874,878 **** */ ! return globals; } } \ No newline at end of file --- 711,715 ---- */ ! //return globals; } } \ No newline at end of file Index: GameUtil.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameUtil.java,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** GameUtil.java 9 Jul 2004 08:38:28 -0000 1.2.2.1 --- GameUtil.java 6 Sep 2004 19:39:15 -0000 1.2.2.2 *************** *** 24,33 **** package jake2.game; - import java.sql.Savepoint; - - import jake2.Defines; import jake2.client.M; import jake2.qcommon.Com; ! import jake2.util.*; public class GameUtil extends GameBase --- 24,31 ---- package jake2.game; import jake2.client.M; import jake2.qcommon.Com; ! import jake2.util.Lib; ! import jake2.util.Math3D; public class GameUtil extends GameBase *************** *** 166,170 **** edict_t e = null; ! for (i = (int) maxclients.value + 1; i < globals.num_edicts; i++) { e = g_edicts[i]; --- 164,168 ---- edict_t e = null; ! for (i = (int) maxclients.value + 1; i < num_edicts; i++) { e = g_edicts[i]; *************** *** 183,187 **** e = g_edicts[i] = new edict_t(i); ! globals.num_edicts++; G_InitEdict(e, i); return e; --- 181,185 ---- e = g_edicts[i] = new edict_t(i); ! num_edicts++; G_InitEdict(e, i); return e; *************** *** 888,892 **** static gitem_t FindItem(String pickup_name) { - //Com.Printf("FindItem:" + pickup_name + "\n"); for (int i = 1; i < game.num_items; i++) { --- 886,889 ---- Index: GameAIAdapters.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameAIAdapters.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** GameAIAdapters.java 8 Jul 2004 20:24:29 -0000 1.2 --- GameAIAdapters.java 6 Sep 2004 19:39:15 -0000 1.2.2.1 *************** *** 32,52 **** import java.util.*; ! public class GameAIAdapters ! { /** Common Boss explode animation.*/ ! public static EntThinkAdapter BossExplode = new EntThinkAdapter() ! { ! public boolean think(edict_t self) ! { [...1800 lines suppressed...] }; ! public static ItemDropAdapter Drop_PowerArmor= new ItemDropAdapter() { ! public void drop(edict_t ent, gitem_t item) { if (0 != (ent.flags & Defines.FL_POWER_ARMOR) && (ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)] == 1)) Use_PowerArmor.use(ent, item); *************** *** 1173,1178 **** } }; ! public static gitem_armor_t jacketarmor_info = new gitem_armor_t(25, 50, .30f, .00f, Defines.ARMOR_JACKET); ! public static gitem_armor_t combatarmor_info = new gitem_armor_t(50, 100, .60f, .30f, Defines.ARMOR_COMBAT); ! public static gitem_armor_t bodyarmor_info = new gitem_armor_t(100, 200, .80f, .60f, Defines.ARMOR_BODY); } --- 1044,1049 ---- } }; ! public static gitem_armor_t jacketarmor_info= new gitem_armor_t(25, 50, .30f, .00f, Defines.ARMOR_JACKET); ! public static gitem_armor_t combatarmor_info= new gitem_armor_t(50, 100, .60f, .30f, Defines.ARMOR_COMBAT); ! public static gitem_armor_t bodyarmor_info= new gitem_armor_t(100, 200, .80f, .60f, Defines.ARMOR_BODY); } Index: GameSave.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameSave.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** GameSave.java 7 Jul 2004 19:59:01 -0000 1.1.1.1 --- GameSave.java 6 Sep 2004 19:39:15 -0000 1.1.1.1.2.1 *************** *** 24,42 **** package jake2.game; ! import java.io.FileNotFoundException; ! import java.io.IOException; ! import java.io.RandomAccessFile; ! import java.nio.*; ! ! import jake2.*; ! import jake2.client.*; ! import jake2.qcommon.*; ! import jake2.render.*; ! import jake2.server.*; ! import jake2.util.*; public class GameSave extends GameFunc { ! public static field_t levelfields[] = { new field_t("changemap", F_LSTRING), --- 24,33 ---- package jake2.game; ! import jake2.qcommon.Com; ! import jake2.util.QuakeFile; public class GameSave extends GameFunc { ! public static field_t levelfields[]= { new field_t("changemap", F_LSTRING), *************** *** 47,51 **** new field_t(null, F_INT)}; ! public static field_t clientfields[] = { new field_t("pers.weapon", F_ITEM), --- 38,42 ---- new field_t(null, F_INT)}; ! public static field_t clientfields[]= { new field_t("pers.weapon", F_ITEM), *************** *** 55,67 **** public static void CreateEdicts() { ! g_edicts = new edict_t[game.maxentities]; ! for (int i = 0; i < game.maxentities; i++) ! g_edicts[i] = new edict_t(i); } public static void CreateClients() { ! game.clients = new gclient_t[game.maxclients]; ! for (int i = 0; i < game.maxclients; i++) ! game.clients[i] = new gclient_t(i); } --- 46,59 ---- public static void CreateEdicts() { ! g_edicts= new edict_t[game.maxentities]; ! for (int i= 0; i < game.maxentities; i++) ! g_edicts[i]= new edict_t(i); ! GameBase.g_edicts= g_edicts; } public static void CreateClients() { ! game.clients= new gclient_t[game.maxclients]; ! for (int i= 0; i < game.maxclients; i++) ! game.clients[i]= new gclient_t(i); } *************** *** 79,733 **** gi.dprintf("==== InitGame ====\n"); ! gun_x = gi.cvar("gun_x", "0", 0); ! gun_y = gi.cvar("gun_y", "0", 0); ! gun_z = gi.cvar("gun_z", "0", 0); //FIXME: sv_ prefix is wrong for these ! sv_rollspeed = gi.cvar("sv_rollspeed", "200", 0); ! sv_rollangle = gi.cvar("sv_rollangle", "2", 0); ! sv_maxvelocity = gi.cvar("sv_maxvelocity", "2000", 0); ! sv_gravity = gi.cvar("sv_gravity", "800", 0); // noset vars ! dedicated = gi.cvar("dedicated", "0", CVAR_NOSET); // latched vars ! sv_cheats = gi.cvar("cheats", "0", CVAR_SERVERINFO | CVAR_LATCH); gi.cvar("gamename", GAMEVERSION, CVAR_SERVERINFO | CVAR_LATCH); gi.cvar("gamedate", __DATE__, CVAR_SERVERINFO | CVAR_LATCH); ! maxclients = gi.cvar("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH); ! maxspectators = gi.cvar("maxspectators", "4", CVAR_SERVERINFO); ! deathmatch = gi.cvar("deathmatch", "0", CVAR_LATCH); ! coop = gi.cvar("coop", "0", CVAR_LATCH); ! skill = gi.cvar("skill", "0", CVAR_LATCH); ! maxentities = gi.cvar("maxentities", "1024", CVAR_LATCH); // change anytime vars ! dmflags = gi.cvar("dmflags", "0", CVAR_SERVERINFO); ! fraglimit = gi.cvar("fraglimit", "0", CVAR_SERVERINFO); ! timelimit = gi.cvar("timelimit", "0", CVAR_SERVERINFO); ! password = gi.cvar("password", "", CVAR_USERINFO); ! spectator_password = gi.cvar("spectator_password", "", CVAR_USERINFO); ! needpass = gi.cvar("needpass", "0", CVAR_SERVERINFO); ! filterban = gi.cvar("filterban", "1", 0); ! g_select_empty = gi.cvar("g_select_empty", "0", CVAR_ARCHIVE); ! run_pitch = gi.cvar("run_pitch", "0.002", 0); ! run_roll = gi.cvar("run_roll", "0.005", 0); ! bob_up = gi.cvar("bob_up", "0.005", 0); ! bob_pitch = gi.cvar("bob_pitch", "0.002", 0); ! bob_roll = gi.cvar("bob_roll", "0.002", 0); // flood control ! flood_msgs = gi.cvar("flood_msgs", "4", 0); ! flood_persecond = gi.cvar("flood_persecond", "4", 0); ! flood_waitdelay = gi.cvar("flood_waitdelay", "10", 0); // dm map list ! sv_maplist = gi.cvar("sv_maplist", "", 0); // items InitItems(); ! //Com_sprintf (game.helpmessage1, sizeof(game.helpmessage1), ""); ! game.helpmessage1 = ""; ! ! //Com_sprintf (game.helpmessage2, sizeof(game.helpmessage2), ""); ! game.helpmessage2 = ""; // initialize all entities for this game ! game.maxentities = (int) maxentities.value; ! ! //g_edicts = gi.TagMalloc(game.maxentities * sizeof(g_edicts[0]), TAG_GAME); CreateEdicts(); ! globals.edicts = g_edicts; ! globals.max_edicts = game.maxentities; // initialize all clients for this game ! game.maxclients = (int) maxclients.value; - //game.clients = gi.TagMalloc(game.maxclients * sizeof(game.clients[0]), TAG_GAME); CreateClients(); ! globals.num_edicts = game.maxclients + 1; } - ////========================================================= - // - //public static void WriteField1 (FILE *f, field_t field, byte base) - //{ - // void *p; - // int len; - // int index; - // - // if (field.flags & FFL_SPAWNTEMP) - // return; - // - // p = (void *)(base + field.ofs); - // switch (field.type) - // { - // case F_INT: - // case F_FLOAT: - // case F_ANGLEHACK: - // case F_VECTOR: - // case F_IGNORE: - // break; - // - // case F_LSTRING: - // case F_GSTRING: - // if ( *(char **)p ) - // len = strlen(*(char **)p) + 1; - // else - // len = 0; - // *(int *)p = len; - // break; - // case F_EDICT: - // if ( *(edict_t **)p == NULL) - // index = -1; - // else - // index = *(edict_t **)p - g_edicts; - // *(int *)p = index; - // break; - // case F_CLIENT: - // if ( *(gclient_t **)p == NULL) - // index = -1; - // else - // index = *(gclient_t **)p - game.clients; - // *(int *)p = index; - // break; - // case F_ITEM: - // if ( *(edict_t **)p == NULL) - // index = -1; - // else - // index = *(gitem_t **)p - itemlist; - // *(int *)p = index; - // break; - // - // //relative to code segment - // case F_FUNCTION: - // if (*(byte **)p == NULL) - // index = 0; - // else - // index = *(byte **)p - ((byte *)InitGame); - // *(int *)p = index; - // break; - // - // //relative to data segment - // case F_MMOVE: - // if (*(byte **)p == NULL) - // index = 0; - // else - // index = *(byte **)p - (byte *)&mmove_reloc; - // *(int *)p = index; - // break; - // - // default: - // gi.error ("WriteEdict: unknown field type"); - // } - //} - // - // - //void WriteField2 (FILE *f, field_t *field, byte *base) - //{ - // int len; - // void *p; - // - // if (field.flags & FFL_SPAWNTEMP) - // return; - // - // p = (void *)(base + field.ofs); - // switch (field.type) - // { - // case F_LSTRING: - // if ( *(char **)p ) - // { - // len = strlen(*(char **)p) + 1; - // fwrite (*(char **)p, len, 1, f); - // } - // break; - // } - //} - // - //void ReadField (FILE *f, field_t *field, byte *base) - //{ - // void *p; - // int len; - // int index; - // - // if (field.flags & FFL_SPAWNTEMP) - // return; - // - // p = (void *)(base + field.ofs); - // switch (field.type) - // { - // case F_INT: - // case F_FLOAT: - // case F_ANGLEHACK: - // case F_VECTOR: - // case F_IGNORE: - // break; - // - // case F_LSTRING: - // len = *(int *)p; - // if (!len) - // *(char **)p = NULL; - // else - // { - // *(char **)p = gi.TagMalloc (len, TAG_LEVEL); - // fread (*(char **)p, len, 1, f); - // } - // break; - // case F_EDICT: - // index = *(int *)p; - // if ( index == -1 ) - // *(edict_t **)p = NULL; - // else - // *(edict_t **)p = &g_edicts[index]; - // break; - // case F_CLIENT: - // index = *(int *)p; - // if ( index == -1 ) - // *(gclient_t **)p = NULL; - // else - // *(gclient_t **)p = &game.clients[index]; - // break; - // case F_ITEM: - // index = *(int *)p; - // if ( index == -1 ) - // *(gitem_t **)p = NULL; - // else - // *(gitem_t **)p = &itemlist[index]; - // break; - // - // //relative to code segment - // case F_FUNCTION: - // index = *(int *)p; - // if ( index == 0 ) - // *(byte **)p = NULL; - // else - // *(byte **)p = ((byte *)InitGame) + index; - // break; - // - // //relative to data segment - // case F_MMOVE: - // index = *(int *)p; - // if (index == 0) - // *(byte **)p = NULL; - // else - // *(byte **)p = (byte *)&mmove_reloc + index; - // break; - // - // default: - // gi.error ("ReadEdict: unknown field type"); - // } - //} - // - ////========================================================= - // - ///* - //============== - //WriteClient - // - //All pointer variables (except function pointers) must be handled specially. - //============== - //*/ - //void WriteClient (FILE *f, gclient_t *client) - //{ - // field_t *field; - // gclient_t temp; - // - // // all of the ints, floats, and vectors stay as they are - // temp = *client; - // - // // change the pointers to lengths or indexes - // for (field=clientfields ; field.name ; field++) - // { - // WriteField1 (f, field, (byte *)&temp); - // } - // - // // write the block - // fwrite (&temp, sizeof(temp), 1, f); - // - // // now write any allocated data following the edict - // for (field=clientfields ; field.name ; field++) - // { - // WriteField2 (f, field, (byte *)client); - // } - //} - // /* ! ============== ! ReadClient ! All pointer variables (except function pointers) must be handled specially. ! ============== */ ! //} // ! ! /* ! //============ ! //WriteGame ! // ! //This will be called whenever the game goes to a new level, ! //and when the user explicitly saves the game. ! // ! //Game information include cross level data, like multi level ! //triggers, help computer info, and all client states. ! // ! //A single player death will automatically restore from the ! //last save position. ! //============ ! //*/ ! //public static void WriteGame (String filename, boolean autosave) ! //{ ! // FILE *f; ! // int i; ! // char str[16]; ! // ! // if (!autosave) ! // SaveClientData (); ! // ! // f = fopen (filename, "rw"); ! // if (!f) ! // gi.error ("Couldn't open %s", filename); ! // ! // memset (str, 0, sizeof(str)); ! // strcpy (str, __DATE__); ! // fwrite (str, sizeof(str), 1, f); ! // ! // game.autosaved = autosave; ! // fwrite (&game, sizeof(game), 1, f); ! // game.autosaved = false; ! // ! // for (i=0 ; i<game.maxclients ; i++) ! // WriteClient (f, &game.clients[i]); ! // ! // fclose (f); ! //} ! // ! ! public static void ReadGame(String filename) { ! RandomAccessFile f = null; ! try { ! f = new RandomAccessFile(filename, "r"); ! byte buf[] = new byte[(int) f.length()]; ! Com.Printf("loading game:" + filename); ! f.readFully(buf); ! ByteBuffer bb = ByteBuffer.wrap(buf); ! bb.order(ByteOrder.LITTLE_ENDIAN); CreateEdicts(); ! game.load(bb); ! //game.dump(); ! for (int i = 0; i < game.maxclients; i++) { ! game.clients[i] = new gclient_t(i); ! game.clients[i].load(bb); } - - Com.Println(""); - Com.Println("file length:" + f.length()); - Com.Println("processed bytes:" + bb.position()); } catch (Exception e) { e.printStackTrace(); ! //gi.error ("File problems in "+ filename); ! } //if (!f) ! // gi.error ("Couldn't open %s", filename); ! // ! // fread (str, sizeof(str), 1, f); ! // if (strcmp (str, __DATE__)) ! // { ! // fclose (f); ! // gi.error ("Savegame from an older version.\n"); ! // } ! // ! // CreateEdicts(); ! // ! // fread (game, sizeof(game), 1, f); ! // ! // CreateClients(); ! // ! // for (i=0 ; i<game.maxclients ; i++) ! // ReadClient (f, game.clients[i]); ! // ! // fclose (f); try { f.close(); } ! catch (IOException e) { ! Com.Error(Defines.ERR_DROP, "Unable to load savegame"); } } ! // ! ////========================================================== ! // ! // ! ///* ! //============== ! //WriteEdict ! // ! //All pointer variables (except function pointers) must be handled specially. ! //============== ! //*/ ! //void WriteEdict (FILE *f, edict_t *ent) ! //{ ! // field_t *field; ! // edict_t temp; ! // ! // // all of the ints, floats, and vectors stay as they are ! // temp = *ent; ! // ! // // change the pointers to lengths or indexes ! // for (field=fields ; field.name ; field++) ! // { ! // WriteField1 (f, field, (byte *)&temp); ! // } ! // ! // // write the block ! // fwrite (&temp, sizeof(temp), 1, f); ! // ! // // now write any allocated data following the edict ! // for (field=fields ; field.name ; field++) ! // { ! // WriteField2 (f, field, (byte *)ent); ! // } ! // ! //} ! // ! ///* ! //============== ! //WriteLevelLocals ! // ! //All pointer variables (except function pointers) must be handled specially. ! //============== ! //*/ ! //void WriteLevelLocals (FILE *f) ! //{ ! // field_t *field; ! // level_locals_t temp; ! // ! // // all of the ints, floats, and vectors stay as they are ! // temp = level; ! // ! // // change the pointers to lengths or indexes ! // for (field=levelfields ; field.name ; field++) ! // { ! // WriteField1 (f, field, (byte *)&temp); ! // } ! // ! // // write the block ! // fwrite (&temp, sizeof(temp), 1, f); ! // ! // // now write any allocated data following the edict ! // for (field=levelfields ; field.name ; field++) ! // { ! // WriteField2 (f, field, (byte *)&level); ! // } ! //} ! // ! // ! ///* ! //============== ! //ReadEdict ! // ! //All pointer variables (except function pointers) must be handled specially. ! //============== ! //*/ ! //void ReadEdict (FILE *f, edict_t *ent) ! //{ ! // field_t *field; ! // ! // fread (ent, sizeof(*ent), 1, f); ! // ! // for (field=fields ; field.name ; field++) ! // { ! // ReadField (f, field, (byte *)ent); ! // } ! //} ! // ! ///* ! //============== ! //ReadLevelLocals ! // ! //All pointer variables (except function pointers) must be handled specially. ! //============== ! //*/ ! //void ReadLevelLocals (FILE *f) ! //{ ! // field_t *field; ! // ! // fread (&level, sizeof(level), 1, f); ! // ! // for (field=levelfields ; field.name ; field++) ! // { ! // ReadField (f, field, (byte *)&level); ! // } ! //} ! // ! ///* ! //================= ! //WriteLevel ! // ! //================= ! //*/ ! //void WriteLevel (char *filename) ! //{ ! // int i; ! // edict_t *ent; ! // FILE *f; ! // void *base; ! // ! // f = fopen (filename, "rw"); ! // if (!f) ! // gi.error ("Couldn't open %s", filename); ! // ! // // write out edict size for checking ! // i = sizeof(edict_t); ! // fwrite (&i, sizeof(i), 1, f); ! // ! // // write out a function pointer for checking ! // base = (void *)InitGame; ! // fwrite (&base, sizeof(base), 1, f); ! // ! // // write out level_locals_t ! // WriteLevelLocals (f); ! // ! // // write out all the entities ! // for (i=0 ; i<globals.num_edicts ; i++) ! // { ! // ent = &g_edicts[i]; ! // if (!ent.inuse) ! // continue; ! // fwrite (&i, sizeof(i), 1, f); ! // WriteEdict (f, ent); ! // } ! // i = -1; ! // fwrite (&i, sizeof(i), 1, f); ! // ! // fclose (f); ! //} ! // ! // ! ///* ! //================= ! //ReadLevel ! // ! //SpawnEntities will allready have been called on the ! //level the same way it was when the level was saved. ! // ! //That is necessary to get the baselines ! //set up identically. ! // ! //The server will have cleared all of the world links before ! //calling ReadLevel. ! // ! //No clients are connected yet. ! //================= ! //*/ ! //void ReadLevel (char *filename) ! //{ ! // int entnum; ! // FILE *f; ! // int i; ! // void *base; ! // edict_t *ent; ! // ! // f = fopen (filename, "r"); ! // if (!f) ! // gi.error ("Couldn't open %s", filename); ! // ! // // free any dynamic memory allocated by loading the level ! // // base state ! // gi.FreeTags (TAG_LEVEL); ! // ! // // wipe all the entities ! // memset (g_edicts, 0, game.maxentities*sizeof(g_edicts[0])); ! // globals.num_edicts = maxclients.value+1; ! // ! // // check edict size ! // fread (&i, sizeof(i), 1, f); ! // if (i != sizeof(edict_t)) ! // { ! // fclose (f); ! // gi.error ("ReadLevel: mismatched edict size"); ! // } ! // ! // // check function pointer base address ! // fread (&base, sizeof(base), 1, f); ! //#ifdef _WIN32 ! // if (base != (void *)InitGame) ! // { ! // fclose (f); ! // gi.error ("ReadLevel: function pointers have moved"); ! // } ! //#else ! // gi.dprintf("Function offsets %d\n", ((byte *)base) - ((byte *)InitGame)); ! //#endif ! // ! // // load the level locals ! // ReadLevelLocals (f); ! // ! // // load all the entities ! // while (1) ! // { ! // if (fread (&entnum, sizeof(entnum), 1, f) != 1) ! // { ! // fclose (f); ! // gi.error ("ReadLevel: failed to read entnum"); ! // } ! // if (entnum == -1) ! // break; ! // if (entnum >= globals.num_edicts) ! // globals.num_edicts = entnum+1; ! // ! // ent = &g_edicts[entnum]; ! // ReadEdict (f, ent); ! // ! // // let the server rebuild world links for this ent ! // memset (&ent.area, 0, sizeof(ent.area)); ! // gi.linkentity (ent); ! // } ! // ! // fclose (f); ! // ! // // mark all clients as unconnected ! // for (i=0 ; i<maxclients.value ; i++) ! // { ! // ent = &g_edicts[i+1]; ! // ent.client = game.clients + i; ! // ent.client.pers.connected = false; ! // } ! // ! // // do any load time things at this point ! // for (i=0 ; i<globals.num_edicts ; i++) ! // { ! // ent = &g_edicts[i]; ! // ! // if (!ent.inuse) ! // continue; ! // ! // // fire any cross-level triggers ! // if (ent.classname) ! // if (strcmp(ent.classname, "target_crosslevel_target") == 0) ! // ent.nextthink = level.time + ent.delay; ! // } ! //} } --- 71,321 ---- gi.dprintf("==== InitGame ====\n"); ! gun_x= gi.cvar("gun_x", "0", 0); ! gun_y= gi.cvar("gun_y", "0", 0); ! gun_z= gi.cvar("gun_z", "0", 0); //FIXME: sv_ prefix is wrong for these ! sv_rollspeed= gi.cvar("sv_rollspeed", "200", 0); ! sv_rollangle= gi.cvar("sv_rollangle", "2", 0); ! sv_maxvelocity= gi.cvar("sv_maxvelocity", "2000", 0); ! sv_gravity= gi.cvar("sv_gravity", "800", 0); // noset vars ! dedicated= gi.cvar("dedicated", "0", CVAR_NOSET); // latched vars ! sv_cheats= gi.cvar("cheats", "0", CVAR_SERVERINFO | CVAR_LATCH); gi.cvar("gamename", GAMEVERSION, CVAR_SERVERINFO | CVAR_LATCH); gi.cvar("gamedate", __DATE__, CVAR_SERVERINFO | CVAR_LATCH); ! maxclients= gi.cvar("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH); ! maxspectators= gi.cvar("maxspectators", "4", CVAR_SERVERINFO); ! deathmatch= gi.cvar("deathmatch", "0", CVAR_LATCH); ! coop= gi.cvar("coop", "0", CVAR_LATCH); ! skill= gi.cvar("skill", "0", CVAR_LATCH); ! maxentities= gi.cvar("maxentities", "1024", CVAR_LATCH); // change anytime vars ! dmflags= gi.cvar("dmflags", "0", CVAR_SERVERINFO); ! fraglimit= gi.cvar("fraglimit", "0", CVAR_SERVERINFO); ! timelimit= gi.cvar("timelimit", "0", CVAR_SERVERINFO); ! password= gi.cvar("password", "", CVAR_USERINFO); ! spectator_password= gi.cvar("spectator_password", "", CVAR_USERINFO); ! needpass= gi.cvar("needpass", "0", CVAR_SERVERINFO); ! filterban= gi.cvar("filterban", "1", 0); ! g_select_empty= gi.cvar("g_select_empty", "0", CVAR_ARCHIVE); ! run_pitch= gi.cvar("run_pitch", "0.002", 0); ! run_roll= gi.cvar("run_roll", "0.005", 0); ! bob_up= gi.cvar("bob_up", "0.005", 0); ! bob_pitch= gi.cvar("bob_pitch", "0.002", 0); ! bob_roll= gi.cvar("bob_roll", "0.002", 0); // flood control ! flood_msgs= gi.cvar("flood_msgs", "4", 0); ! flood_persecond= gi.cvar("flood_persecond", "4", 0); ! flood_waitdelay= gi.cvar("flood_waitdelay", "10", 0); // dm map list ! sv_maplist= gi.cvar("sv_maplist", "", 0); // items InitItems(); ! game.helpmessage1= ""; ! game.helpmessage2= ""; // initialize all entities for this game ! game.maxentities= (int) maxentities.value; CreateEdicts(); ! // globals.edicts= g_edicts; ! // globals.max_edicts= game.maxentities; // initialize all clients for this game ! game.maxclients= (int) maxclients.value; CreateClients(); ! num_edicts= game.maxclients + 1; } /* ! ============ ! WriteGame ! This will be called whenever the game goes to a new level, ! and when the user explicitly saves the game. ! ! Game information include cross level data, like multi level ! triggers, help computer info, and all client states. ! ! A single player death will automatically restore from the ! last save position. ! ============ */ + public static void WriteGame(String filename, boolean autosave) { + try { + QuakeFile f; ! if (!autosave) ! SaveClientData(); ! f= new QuakeFile(filename, "rw"); ! if (f == null) ! gi.error("Couldn't write to " + filename); ! game.autosaved= autosave; ! game.write(f); ! game.autosaved= false; ! for (int i= 0; i < game.maxclients; i++) ! game.clients[i].write(f); ! fclose(f); ! } ! catch (Exception e) { ! e.printStackTrace(); ! } ! } ! public static void ReadGame(String filename) { ! QuakeFile f= null; ! try { + f= new QuakeFile(filename, "r"); CreateEdicts(); ! game.load(f); ! for (int i= 0; i < game.maxclients; i++) { ! game.clients[i]= new gclient_t(i); ! game.clients[i].read(f); } + f.close(); } catch (Exception e) { e.printStackTrace(); ! } ! } ! ! /* ! ================= ! WriteLevel ! ! ================= ! */ ! public static void WriteLevel(String filename) { try { + int i; + edict_t ent; + QuakeFile f; + + f= new QuakeFile(filename, "rw"); + if (f == null) + gi.error("Couldn't open for writing: " + filename); + + // write out level_locals_t + level.write(f); + + // write out all the entities + for (i= 0; i < num_edicts; i++) { + ent= g_edicts[i]; + if (!ent.inuse) + continue; + f.writeInt(i); + ent.write(f); + + } + + i= -1; + f.writeInt(-1); + f.close(); } ! catch (Exception e) { ! e.printStackTrace(); } } ! /* ! ================= ! ReadLevel ! ! SpawnEntities will allready have been called on the ! level the same way it was when the level was saved. ! ! That is necessary to get the baselines ! set up identically. ! ! The server will have cleared all of the world links before ! calling ReadLevel. ! ! No clients are connected yet. ! ================= ! */ ! public static void ReadLevel(String filename) { ! try { ! edict_t ent; ! ! QuakeFile f= new QuakeFile(filename, "r"); + if (f == null) + gi.error("Couldn't read level file " + filename); + + // wipe all the entities + Game.CreateEdicts(); + + num_edicts= (int) maxclients.value + 1; + + // load the level locals + level.read(f); + + // load all the entities + while (true) { + int entnum= f.readInt(); + if (entnum == -1) + break; + + if (entnum >= num_edicts) + num_edicts= entnum + 1; + + ent= g_edicts[entnum]; + ent.read(f); + ent.cleararealinks(); + gi.linkentity(ent); + } + + fclose(f); + + // mark all clients as unconnected + for (int i= 0; i < maxclients.value; i++) { + ent= g_edicts[i + 1]; + ent.client= game.clients[i]; + ent.client.pers.connected= false; + } + + // do any load time things at this point + for (int i= 0; i < num_edicts; i++) { + ent= g_edicts[i]; + + if (!ent.inuse) + continue; + + // fire any cross-level triggers + if (ent.classname != null) + if (strcmp(ent.classname, "target_crosslevel_target") == 0) + ent.nextthink= level.time + ent.delay; + } + } + catch (Exception e) { + e.printStackTrace(); + } + } } Index: client_respawn_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/client_respawn_t.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** client_respawn_t.java 8 Jul 2004 20:24:29 -0000 1.3 --- client_respawn_t.java 6 Sep 2004 19:39:15 -0000 1.3.2.1 *************** *** 25,41 **** import jake2.qcommon.Com; import jake2.util.Lib; import java.io.IOException; import java.nio.ByteBuffer; public class client_respawn_t ! // client data that stays across deathmatch respawns { ! client_persistant_t coop_respawn = new client_persistant_t(); // what to set client->pers to on a respawn ! int enterframe; // level.framenum the client entered the game ! int score; // frags, etc ! float cmd_angles[] = { 0, 0, 0 }; // angles sent over in the last command ! boolean spectator; // client is a spectator public void set(client_respawn_t from) { --- 25,56 ---- import jake2.qcommon.Com; import jake2.util.Lib; + import jake2.util.Math3D; + import jake2.util.QuakeFile; import java.io.IOException; + import java.io.RandomAccessFile; import java.nio.ByteBuffer; + /** Client data that stays across deathmatch respawns.*/ public class client_respawn_t ! { ! /** What to set client->pers to on a respawn */ ! protected client_persistant_t coop_respawn = new client_persistant_t(); ! ! /** Level.framenum the client entered the game. */ ! protected int enterframe; ! ! /** frags, etc. */ ! protected int score; ! ! /** angles sent over in the last command. */ ! protected float cmd_angles[] = { 0, 0, 0 }; ! ! /** client is a spectator. */ ! protected boolean spectator; + + /** Copies the client respawn data. */ public void set(client_respawn_t from) { *************** *** 43,51 **** enterframe = from.enterframe; score = from.score; ! cmd_angles = Lib.clone(from.cmd_angles); spectator = from.spectator; } ! //ok public void clear() { --- 58,66 ---- enterframe = from.enterframe; score = from.score; ! Math3D.VectorCopy(from.cmd_angles, cmd_angles); spectator = from.spectator; } ! /** Clears the client reaspawn informations. */ public void clear() { *************** *** 53,71 **** enterframe = 0; score = 0; ! cmd_angles = new float[3]; spectator = false; } ! public void load(ByteBuffer bb) throws IOException { ! coop_respawn.load(bb); ! enterframe = bb.getInt(); ! score = bb.getInt(); ! cmd_angles[0] = bb.getFloat(); ! cmd_angles[1] = bb.getFloat(); ! cmd_angles[2] = bb.getFloat(); ! spectator = bb.getInt() != 0; } public void dump() { --- 68,102 ---- enterframe = 0; score = 0; ! Math3D.VectorClear(cmd_angles); spectator = false; } ! /** Reads a client_respawn from a file. */ ! public void read(QuakeFile f) throws IOException { ! coop_respawn.read(f); ! enterframe = f.readInt(); ! score = f.readInt(); ! cmd_angles[0] = f.readFloat(); ! cmd_angles[1] = f.readFloat(); ! cmd_angles[2] = f.readFloat(); ! spectator = f.readInt() != 0; ! } ! ! /** Writes a client_respawn to a file. */ ! public void write(QuakeFile f) throws IOException ! { ! coop_respawn.write(f); ! f.writeInt(enterframe); ! f.writeInt(score); ! f.writeFloat(cmd_angles[0]); ! f.writeFloat(cmd_angles[1]); ! f.writeFloat(cmd_angles[2]); ! f.writeInt(spectator?1:0); } + + + /** Prints out a client_respawn_t to the quake console.*/ public void dump() { Index: GameSpawn.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameSpawn.java,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** GameSpawn.java 9 Jul 2004 08:38:29 -0000 1.2.2.1 --- GameSpawn.java 6 Sep 2004 19:39:15 -0000 1.2.2.2 *************** *** 24,30 **** package jake2.game; ! import jake2.Defines; ! import jake2.util.*; ! import jake2.qcommon.*; public class GameSpawn extends GameSave { --- 24,29 ---- package jake2.game; ! import jake2.qcommon.Com; ! import jake2.util.Lib; public class GameSpawn extends GameSave { *************** *** 129,146 **** static String ED_NewString(String string) { ! //String newb, new_p; ! int i, l; ! ! l = string.length() + 1; ! //newb = gi.TagMalloc(l, TAG_LEVEL); ! StringBuffer newb = new StringBuffer(l); ! for (i = 0; i < l - 1; i++) { ! char c; ! ! c = string.charAt(i); if (c == '\\' && i < l - 1) { ! c = string.charAt(i++); if (c == 'n') newb.append('\n'); --- 128,138 ---- static String ED_NewString(String string) { ! int l = string.length(); StringBuffer newb = new StringBuffer(l); ! for (int i = 0; i < l; i++) { ! char c = string.charAt(i); if (c == '\\' && i < l - 1) { ! c = string.charAt(++i); if (c == 'n') newb.append('\n'); *************** *** 175,221 **** gi.dprintf("??? The key [" + key + "] is not a field\n"); - - - /** OLD CODE, delegated to ent.set(...) and st.set(...) - - for (f = fields; f.name; f++) { - if (!(f.flags & FFL_NOSPAWN) && !Q_stricmp(f.name, key)) { - // found it - if (f.flags & FFL_SPAWNTEMP) - b = (byte *) & st; - else - b = (byte *) ent; - - switch (f.type) { - case F_LSTRING : - * (String *) (b + f.ofs) = ED_NewString(value); - break; - case F_VECTOR : - sscanf(value, "%f %f %f", & vec[0], & vec[1], & vec[2]); - ((float *) (b + f.ofs))[0] = vec[0]; - ((float *) (b + f.ofs))[1] = vec[1]; - ((float *) (b + f.ofs))[2] = vec[2]; - break; - case F_INT : - * (int *) (b + f.ofs) = atoi(value); - break; - case F_FLOAT : - * (float *) (b + f.ofs) = atof(value); - break; - case F_ANGLEHACK : - v = atof(value); - ((float *) (b + f.ofs))[0] = 0; - ((float *) (b + f.ofs))[1] = v; - ((float *) (b + f.ofs))[2] = 0; - break; - case F_IGNORE : - break; - } - return; - } - } - gi.dprintf("%s is not a field\n", key); - - */ } --- 167,170 ---- *************** *** 293,297 **** c = 0; c2 = 0; ! for (i = 1; i < globals.num_edicts; i++) { e = g_edicts[i]; --- 242,246 ---- c = 0; c2 = 0; ! for (i = 1; i < num_edicts; i++) { e = g_edicts[i]; *************** *** 307,311 **** c2++; //Com.Printf("Team:" + e.team+" entity: " + e.index + "\n"); ! for (j = i + 1; j < globals.num_edicts; j++) { e2 = g_edicts[j]; if (!e2.inuse) --- 256,260 ---- c2++; //Com.Printf("Team:" + e.team+" entity: " + e.index + "\n"); ! for (j = i + 1; j < num_edicts; j++) { e2 = g_edicts[j]; if (!e2.inuse) *************** *** 337,341 **** */ ! static void SpawnEntities(String mapname, String entities, String spawnpoint) { edict_t ent; int inhibit; --- 286,290 ---- */ ! public static void SpawnEntities(String mapname, String entities, String spawnpoint) { edict_t ent; int inhibit; *************** *** 596,600 **** if (item.classname == null) continue; ! if (0 == Lib.stricmp(item.classname, ent.classname)) { // found it SpawnItem(ent, item); return; --- 545,549 ---- if (item.classname == null) continue; ! if (item.classname.equalsIgnoreCase(ent.classname)) { // found it SpawnItem(ent, item); return; *************** *** 603,607 **** for (i=0; (s = spawns[i]) !=null && s.name != null; i++) { ! if (0 == Lib.stricmp(s.name, ent.classname)) { // found it if (s.spawn == null) --- 552,556 ---- for (i=0; (s = spawns[i]) !=null && s.name != null; i++) { ! if (s.name.equalsIgnoreCase(ent.classname)) { // found it if (s.spawn == null) Index: GameMiscAdapters.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameMiscAdapters.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** GameMiscAdapters.java 8 Jul 2004 20:24:29 -0000 1.2 --- GameMiscAdapters.java 6 Sep 2004 19:39:15 -0000 1.2.2.1 *************** *** 30,34 **** import jake2.util.Math3D; ! import java.util.Date; public class GameMiscAdapters --- 30,34 ---- import jake2.util.Math3D; ! import java.util.Calendar; public class GameMiscAdapters *************** *** 879,884 **** else { ! Date d = new Date(); ! self.message = "" + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds(); /* --- 879,884 ---- else { ! Calendar c = Calendar.getInstance(); ! self.message = "" + c.get(Calendar.HOUR_OF_DAY) + ":" + c.get(Calendar.MINUTE) + ":" + c.get(Calendar.SECOND); /* Index: GameTriggerAdapters.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameTriggerAdapters.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** GameTriggerAdapters.java 8 Jul 2004 15:58:44 -0000 1.1 --- GameTriggerAdapters.java 6 Sep 2004 19:39:15 -0000 1.1.2.1 *************** *** 115,119 **** int index; - Com.p("trigger_key_use!"); if (self.item == null) return; --- 115,118 ---- *************** *** 225,229 **** static EntTouchAdapter trigger_push_touch = new EntTouchAdapter() { public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { - Com.p("TRIGGER TOUCH!"); if (Lib.strcmp(other.classname, "grenade") == 0) { Math3D.VectorScale(self.movedir, self.speed * 10, other.velocity); --- 224,227 ---- --- game_export_t.java DELETED --- Index: GameFuncAdapters.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/GameFuncAdapters.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** GameFuncAdapters.java 8 Jul 2004 15:58:44 -0000 1.1 --- GameFuncAdapters.java 6 Sep 2004 19:39:15 -0000 1.1.2.1 *************** *** 31,36 **** import jake2.util.*; ! public class GameFuncAdapters ! { /* --- 31,35 ---- import jake2.util.*; ! public class GameFuncAdapters { [...2696 lines suppressed...] GameBase.gi.setmodel(ent, ent.model); ! ent.use = use_killbox; ! ent.svflags = Defines.SVF_NOCLIENT; return true; } --- 1623,1636 ---- Kills everything inside when fired, irrespective of protection. */ ! static EntUseAdapter use_killbox= new EntUseAdapter() { ! public void use(edict_t self, edict_t other, edict_t activator) { GameUtil.KillBox(self); } }; ! static EntThinkAdapter SP_func_killbox= new EntThinkAdapter() { ! public boolean think(edict_t ent) { GameBase.gi.setmodel(ent, ent.model); ! ent.use= use_killbox; ! ent.svflags= Defines.SVF_NOCLIENT; return true; } Index: pmove_state_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/pmove_state_t.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** pmove_state_t.java 7 Jul 2004 19:59:26 -0000 1.1.1.1 --- pmove_state_t.java 6 Sep 2004 19:39:15 -0000 1.1.1.1.2.1 *************** *** 27,30 **** --- 27,31 ---- import java.io.IOException; + import java.io.RandomAccessFile; import java.nio.ByteBuffer; *************** *** 40,49 **** public short origin[] = { 0, 0, 0 }; // 12.3 public short velocity[] = { 0, 0, 0 }; // 12.3 ! public byte pm_flags; // ducked, jump_held, etc ! public byte pm_time; // each unit = 8 ms public short gravity; ! public short delta_angles[] = { 0, 0, 0 }; // add to command angles to get view direction ! // changed by spawns, rotating objects, and teleporters ! private static pmove_state_t prototype = new pmove_state_t(); --- 41,53 ---- public short origin[] = { 0, 0, 0 }; // 12.3 public short velocity[] = { 0, 0, 0 }; // 12.3 ! /** ducked, jump_held, etc. */ ! public byte pm_flags; ! /** each unit = 8 ms. */ ! public byte pm_time; public short gravity; ! /** add to command angles to get view direction. */ ! public short delta_angles[] = { 0, 0, 0 }; ! /** changed by spawns, rotating objects, and teleporters.*/ ! private static pmove_state_t prototype = new pmove_state_t(); *************** *** 82,107 **** } ! public void load(ByteBuffer bb) throws IOException { ! pm_type = bb.getInt(); ! origin[0] = bb.getShort(); ! origin[1] = bb.getShort(); ! origin[2] = bb.getShort(); ! velocity[0] = bb.getShort(); ! velocity[1] = bb.getShort(); ! velocity[2] = bb.getShort(); ! pm_flags = bb.get(); ! pm_time = bb.get(); ! gravity = bb.getShort(); ! bb.getShort(); ! delta_angles[0] = bb.getShort(); ! delta_angles[1] = bb.getShort(); ! delta_angles[2] = bb.getShort(); } --- 86,136 ---- } ! /** Reads the playermove from the file.*/ ! public void load(RandomAccessFile f) throws IOException { ! pm_type = f.readInt(); ! origin[0] = f.readShort(); ! origin[1] = f.readShort(); ! origin[2] = f.readShort(); ! velocity[0] = f.readShort(); ! velocity[1] = f.readShort(); ! velocity[2] = f.readShort(); ! pm_flags = f.readByte(); ! pm_time = f.readByte(); ! gravity = f.readShort(); ! f.readShort(); ! delta_angles[0] = f.readShort(); ! delta_angles[1] = f.readShort(); ! delta_angles[2] = f.readShort(); ! ! } ! ! /** Writes the playermove to the file. */ ! public void write (RandomAccessFile f) throws IOException { ! ! f.writeInt(pm_type); ! ! f.writeShort(origin[0]); ! f.writeShort(origin[1]); ! f.writeShort(origin[2]); ! ! f.writeShort(velocity[0]); ! f.writeShort(velocity[1]); ! f.writeShort(velocity[2]); ! ! f.writeByte(pm_flags); ! f.writeByte(pm_time); ! f.writeShort(gravity); ! ! f.writeShort(0); + f.writeShort(delta_angles[0]); + f.writeShort(delta_angles[1]); + f.writeShort(delta_angles[2]); } *************** *** 125,130 **** Com.Println("delta-angle[2]: " + delta_angles[0]); } - - - } \ No newline at end of file --- 154,156 ---- Index: PlayerHud.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/game/PlayerHud.java,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** PlayerHud.java 9 Jul 2004 08:38:28 -0000 1.2.2.1 --- PlayerHud.java 6 Sep 2004 19:39:15 -0000 1.2.2.2 *************** *** 99,113 **** level.intermissiontime = level.time; ! ! // TODO: BIG HACK TO IGNORE CINEMATIC ! ! String xxx = targ.map; ! int pos = xxx.indexOf(".cin"); ! if (pos != -1) ! level.changemap = xxx.substring(pos + 5); // including "+" ! else ! level.changemap = xxx; ! // ------------------------ ! //level.changemap = targ.map; if (level.changemap.indexOf('*') > -1) { if (coop.value != 0) { --- 99,104 ---- level.intermissiontime = level.time; ! level.changemap = targ.map; ! if (level.changemap.indexOf('*') > -1) { if (coop.value != 0) { *************** *** 319,396 **** } - /* - ================== - HelpComputer - - Draw help computer. - ================== - */ - public static void HelpComputer(edict_t ent) { - //char string[1024]; - String string; - - String s... [truncated message content] |