diff options
Diffstat (limited to 'src/jake2/game/client_persistant_t.java')
-rw-r--r-- | src/jake2/game/client_persistant_t.java | 89 |
1 files changed, 64 insertions, 25 deletions
diff --git a/src/jake2/game/client_persistant_t.java b/src/jake2/game/client_persistant_t.java index 774cfa4..126d5d5 100644 --- a/src/jake2/game/client_persistant_t.java +++ b/src/jake2/game/client_persistant_t.java @@ -19,13 +19,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 31.10.2003 by RST. -// $Id: client_persistant_t.java,v 1.4 2004-07-12 20:47:01 hzi Exp $ +// $Id: client_persistant_t.java,v 1.5 2004-08-20 21:29:58 salomo Exp $ package jake2.game; import jake2.Defines; import jake2.util.Lib; +import jake2.util.QuakeFile; +import java.io.IOException; +import java.io.RandomAccessFile; import java.nio.ByteBuffer; public class client_persistant_t { @@ -89,42 +92,78 @@ public class client_persistant_t { int helpchanged; boolean spectator; // client is a spectator - public void load(ByteBuffer bb) { - // client persistant_t - userinfo = Lib.readString(bb, Defines.MAX_INFO_STRING); - netname = Lib.readString(bb, 16); + /** Reads a client_persistant structure from a file. */ + public void read(QuakeFile f) throws IOException { + + userinfo = f.readString(); + netname = f.readString(); - hand = bb.getInt(); + hand = f.readInt(); - connected = bb.getInt() != 0; - health = bb.getInt(); + connected = f.readInt() != 0; + health = f.readInt(); - max_health = bb.getInt(); - savedFlags = bb.getInt(); - selected_item = bb.getInt(); + max_health = f.readInt(); + savedFlags = f.readInt(); + selected_item = f.readInt(); for (int n = 0; n < Defines.MAX_ITEMS; n++) - inventory[n] = bb.getInt(); + inventory[n] = f.readInt(); + + max_bullets = f.readInt(); + max_shells = f.readInt(); + max_rockets = f.readInt(); + max_grenades = f.readInt(); + max_cells = f.readInt(); + max_slugs = f.readInt(); + + weapon = f.readItem(); + lastweapon = f.readItem(); + power_cubes = f.readInt(); + score = f.readInt(); + + game_helpchanged = f.readInt(); + helpchanged = f.readInt(); + spectator = f.readInt() != 0; + } - max_bullets = bb.getInt(); - max_shells = bb.getInt(); - max_rockets = bb.getInt(); - max_grenades = bb.getInt(); - max_cells = bb.getInt(); - max_slugs = bb.getInt(); + /** Writes a client_persistant structure to a file. */ + public void write(QuakeFile f) throws IOException { + // client persistant_t + f.writeString(userinfo); + f.writeString(netname); - weapon = GameAI.itemlist[bb.getInt()]; - lastweapon = GameAI.itemlist[bb.getInt()]; - power_cubes = bb.getInt(); - score = bb.getInt(); + f.writeInt(hand); - game_helpchanged = bb.getInt(); - helpchanged = bb.getInt(); - spectator = bb.getInt() != 0; + f.writeInt(connected ? 1:0); + f.writeInt(health); + f.writeInt(max_health); + f.writeInt(savedFlags); + f.writeInt(selected_item); + + for (int n = 0; n < Defines.MAX_ITEMS; n++) + f.writeInt(inventory[n]); + + f.writeInt(max_bullets); + f.writeInt(max_shells); + f.writeInt(max_rockets); + f.writeInt(max_grenades); + f.writeInt(max_cells); + f.writeInt(max_slugs); + + f.writeItem(weapon); + f.writeItem(lastweapon); + f.writeInt(power_cubes); + f.writeInt(score); + + f.writeInt(game_helpchanged); + f.writeInt(helpchanged); + f.writeInt(spectator?1:0); } + public void dump() { // client persistant_t |