summaryrefslogtreecommitdiffstats
path: root/src/jake2/game/client_respawn_t.java
blob: 0b8d4be62ff7e349c6f938522f739d40869dc08a (plain)
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
/*
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.

package jake2.game;

import jake2.util.Math3D;
import jake2.util.QuakeFile;

import java.io.IOException;

/** 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)
	{
		coop_respawn.set(from.coop_respawn);
		enterframe = from.enterframe;
		score = from.score;
		Math3D.VectorCopy(from.cmd_angles, cmd_angles);
		spectator = from.spectator;
	}

	/** Clears the client reaspawn informations. */
	public void clear()
	{
		coop_respawn = new client_persistant_t();
		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);
	}
}