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
|
/*
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: pmove_state_t.java,v 1.3 2005-01-21 01:08:48 cawe Exp $
package jake2.game;
import jake2.qcommon.Com;
import jake2.util.Math3D;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
public class pmove_state_t {
// this structure needs to be communicated bit-accurate
// from the server to the client to guarantee that
// prediction stays in sync, so no floats are used.
// if any part of the game code modifies this struct, it
// will result in a prediction error of some degree.
public int pm_type;
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();
public void clear()
{
this.set(prototype);
}
public void set(pmove_state_t from) {
pm_type = from.pm_type;
Math3D.VectorCopy(from.origin, origin);
Math3D.VectorCopy(from.velocity, velocity);
pm_flags = from.pm_flags;
pm_time = from.pm_time;
gravity = from.gravity;
Math3D.VectorCopy(from.delta_angles, delta_angles);
}
public boolean equals(pmove_state_t p2) {
if (pm_type == p2.pm_type
&& origin[0] == p2.origin[0]
&& origin[1] == p2.origin[1]
&& origin[2] == p2.origin[2]
&& velocity[0] == p2.velocity[0]
&& velocity[1] == p2.velocity[1]
&& velocity[2] == p2.origin[2]
&& pm_flags == p2.pm_flags
&& pm_time == p2.pm_time
&& gravity == gravity
&& delta_angles[0] == p2.delta_angles[0]
&& delta_angles[1] == p2.delta_angles[1]
&& delta_angles[2] == p2.origin[2])
return true;
return false;
}
/** 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]);
}
public void dump() {
Com.Println("pm_type: " + pm_type);
Com.Println("origin[0]: " + origin[0]);
Com.Println("origin[1]: " + origin[0]);
Com.Println("origin[2]: " + origin[0]);
Com.Println("velocity[0]: " + velocity[0]);
Com.Println("velocity[1]: " + velocity[1]);
Com.Println("velocity[2]: " + velocity[2]);
Com.Println("pmflags: " + pm_flags);
Com.Println("pmtime: " + pm_time);
Com.Println("gravity: " + gravity);
Com.Println("delta-angle[0]: " + delta_angles[0]);
Com.Println("delta-angle[1]: " + delta_angles[0]);
Com.Println("delta-angle[2]: " + delta_angles[0]);
}
}
|