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
|
/*
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.4 2004-07-12 20:47:01 hzi Exp $
package jake2.game;
import jake2.Defines;
import jake2.util.Lib;
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
int max_bullets;
int max_shells;
int max_rockets;
int max_grenades;
int max_cells;
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
public void load(ByteBuffer bb) {
// client persistant_t
userinfo = Lib.readString(bb, Defines.MAX_INFO_STRING);
netname = Lib.readString(bb, 16);
hand = bb.getInt();
connected = bb.getInt() != 0;
health = bb.getInt();
max_health = bb.getInt();
savedFlags = bb.getInt();
selected_item = bb.getInt();
for (int n = 0; n < Defines.MAX_ITEMS; n++)
inventory[n] = bb.getInt();
max_bullets = bb.getInt();
max_shells = bb.getInt();
max_rockets = bb.getInt();
max_grenades = bb.getInt();
max_cells = bb.getInt();
max_slugs = bb.getInt();
weapon = GameAI.itemlist[bb.getInt()];
lastweapon = GameAI.itemlist[bb.getInt()];
power_cubes = bb.getInt();
score = bb.getInt();
game_helpchanged = bb.getInt();
helpchanged = bb.getInt();
spectator = bb.getInt() != 0;
}
public void dump() {
// client persistant_t
System.out.println("userinfo: " + userinfo);
System.out.println("netname: " + netname);
System.out.println("hand: " + hand);
System.out.println("connected: " + connected);
System.out.println("health: " + health);
System.out.println("max_health: " + max_health);
System.out.println("savedFlags: " + savedFlags);
System.out.println("selected_item: " + selected_item);
for (int n = 0; n < Defines.MAX_ITEMS; n++)
System.out.println("inventory[" + n + "]: " + inventory[n]);
System.out.println("max_bullets: " + max_bullets);
System.out.println("max_shells: " + max_shells);
System.out.println("max_rockets: " + max_rockets);
System.out.println("max_grenades: " + max_grenades);
System.out.println("max_cells: " + max_cells);
System.out.println("max_slugs: " + max_slugs);
System.out.println("weapon: " + weapon);
System.out.println("lastweapon: " + lastweapon);
System.out.println("powercubes: " + power_cubes);
System.out.println("score: " + score);
System.out.println("gamehelpchanged: " + game_helpchanged);
System.out.println("helpchanged: " + helpchanged);
System.out.println("spectator: " + spectator);
}
}
|