1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
/*
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 31.10.2003 by RST.
// $Id: client_persistant_t.java,v 1.7 2005-02-06 18:52:55 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 {
public void set(client_persistant_t from) {
userinfo= from.userinfo;
netname= from.netname;
hand= from.hand;
connected= from.connected;
health= from.health;
max_health= from.max_health;
savedFlags= from.savedFlags;
selected_item= from.selected_item;
System.arraycopy(from.inventory, 0, inventory, 0, inventory.length);
max_bullets= from.max_bullets;
max_shells= from.max_shells;
max_rockets= from.max_rockets;
max_grenades= from.max_grenades;
max_cells= from.max_cells;
max_slugs= from.max_slugs;
weapon= from.weapon;
lastweapon= from.lastweapon;
power_cubes= from.power_cubes;
score= from.score;
game_helpchanged= from.game_helpchanged;
helpchanged= from.helpchanged;
spectator= from.spectator;
}
// client data that stays across multiple level loads
String userinfo= "";
String netname= "";
int hand;
boolean connected; // a loadgame will leave valid entities that
// just don't have a connection yet
// values saved and restored from edicts when changing levels
int health;
int max_health;
int savedFlags;
int selected_item;
int inventory[]= new int[Defines.MAX_ITEMS];
// ammo capacities
public int max_bullets;
public int max_shells;
public int max_rockets;
public int max_grenades;
public int max_cells;
public int max_slugs;
//pointer
gitem_t weapon;
//pointer
gitem_t lastweapon;
int power_cubes; // used for tracking the cubes in coop games
int score; // for calculating total unit score in coop games
int game_helpchanged;
int helpchanged;
boolean spectator; // client is a spectator
/** Reads a client_persistant structure from a file. */
public void read(QuakeFile f) throws IOException {
userinfo= f.readString();
netname= f.readString();
hand= f.readInt();
connected= f.readInt() != 0;
health= f.readInt();
max_health= f.readInt();
savedFlags= f.readInt();
selected_item= f.readInt();
for (int n= 0; n < Defines.MAX_ITEMS; n++)
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;
}
/** Writes a client_persistant structure to a file. */
public void write(QuakeFile f) throws IOException {
// client persistant_t
f.writeString(userinfo);
f.writeString(netname);
f.writeInt(hand);
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);
}
}
|