DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
cl_ents_nq.c
Go to the documentation of this file.
1#include "quakedef.h"
2#include "protocol.h"
3
5{
6 int num;
7 entity_t *ent;
9
10 if (bits & U_MOREBITS)
11 bits |= (MSG_ReadByte(&cl_message)<<8);
13 {
14 bits |= MSG_ReadByte(&cl_message) << 16;
15 if (bits & U_EXTEND2)
16 bits |= MSG_ReadByte(&cl_message) << 24;
17 }
18
19 if (bits & U_LONGENTITY)
20 num = (unsigned short) MSG_ReadShort(&cl_message);
21 else
23
24 if (num >= MAX_EDICTS)
25 Host_Error("EntityFrameQuake_ReadEntity: entity number (%i) >= MAX_EDICTS (%i)", num, MAX_EDICTS);
26 if (num < 1)
27 Host_Error("EntityFrameQuake_ReadEntity: invalid entity number (%i)", num);
28
29 if (cl.num_entities <= num)
30 {
31 cl.num_entities = num + 1;
32 if (num >= cl.max_entities)
34 }
35
36 ent = cl.entities + num;
37
38 // note: this inherits the 'active' state of the baseline chosen
39 // (state_baseline is always active, state_current may not be active if
40 // the entity was missing in the last frame)
41 if (bits & U_DELTA)
42 s = ent->state_current;
43 else
44 {
45 s = ent->state_baseline;
47 }
48
49 cl.isquakeentity[num] = true;
50 if (cl.lastquakeentity < num)
51 cl.lastquakeentity = num;
52 s.number = num;
53 s.time = cl.mtime[0];
54 s.flags = 0;
55 if (bits & U_MODEL)
56 {
58 s.modelindex = (unsigned short) MSG_ReadShort(&cl_message);
59 else
60 s.modelindex = (s.modelindex & 0xFF00) | MSG_ReadByte(&cl_message);
61 }
62 if (bits & U_FRAME) s.frame = (s.frame & 0xFF00) | MSG_ReadByte(&cl_message);
64 if (bits & U_SKIN) s.skin = MSG_ReadByte(&cl_message);
65 if (bits & U_EFFECTS) s.effects = (s.effects & 0xFF00) | MSG_ReadByte(&cl_message);
67 if (bits & U_ANGLE1) s.angles[0] = MSG_ReadAngle(&cl_message, cls.protocol);
69 if (bits & U_ANGLE2) s.angles[1] = MSG_ReadAngle(&cl_message, cls.protocol);
71 if (bits & U_ANGLE3) s.angles[2] = MSG_ReadAngle(&cl_message, cls.protocol);
72 if (bits & U_STEP) s.flags |= RENDER_STEP;
73 if (bits & U_ALPHA) s.alpha = MSG_ReadByte(&cl_message);
74 if (bits & U_SCALE) s.scale = MSG_ReadByte(&cl_message);
75 if (bits & U_EFFECTS2) s.effects = (s.effects & 0x00FF) | (MSG_ReadByte(&cl_message) << 8);
78 if (bits & U_COLORMOD) {int c = MSG_ReadByte(&cl_message);s.colormod[0] = (unsigned char)(((c >> 5) & 7) * (32.0f / 7.0f));s.colormod[1] = (unsigned char)(((c >> 2) & 7) * (32.0f / 7.0f));s.colormod[2] = (unsigned char)((c & 3) * (32.0f / 3.0f));}
79 if (bits & U_GLOWTRAIL) s.flags |= RENDER_GLOWTRAIL;
80 if (bits & U_FRAME2) s.frame = (s.frame & 0x00FF) | (MSG_ReadByte(&cl_message) << 8);
81 if (bits & U_MODEL2) s.modelindex = (s.modelindex & 0x00FF) | (MSG_ReadByte(&cl_message) << 8);
82 if (bits & U_VIEWMODEL) s.flags |= RENDER_VIEWMODEL;
84
85 // LadyHavoc: to allow playback of the Nehahra movie
87 {
88 // LadyHavoc: evil format
90 int j = (int)(MSG_ReadFloat(&cl_message) * 255.0f);
91 if (i == 2)
92 {
94 if (i)
96 }
97 if (j < 0)
98 s.alpha = 0;
99 else if (j == 0 || j >= 255)
100 s.alpha = 255;
101 else
102 s.alpha = j;
103 }
104
105 ent->state_previous = ent->state_current;
106 ent->state_current = s;
108 {
111 }
112
114 Host_Error("EntityFrameQuake_ReadEntity: read error");
115}
116
118{
119 int num, lastentity;
120 if (cl.lastquakeentity == 0)
121 return;
122 lastentity = cl.lastquakeentity;
124 for (num = 0;num <= lastentity;num++)
125 {
126 if (cl.isquakeentity[num])
127 {
128 if (cl.entities_active[num] && cl.entities[num].state_current.time == cl.mtime[0])
129 {
130 cl.isquakeentity[num] = true;
131 cl.lastquakeentity = num;
132 }
133 else
134 {
135 cl.isquakeentity[num] = false;
138 cl.entities[num].state_current.number = num;
139 }
140 }
141 }
142}
void EntityFrameQuake_ReadEntity(int bits)
Definition cl_ents_nq.c:4
void EntityFrameQuake_ISeeDeadEntities(void)
Definition cl_ents_nq.c:117
client_state_t cl
Definition cl_main.c:117
client_static_t cls
Definition cl_main.c:116
void CL_ExpandEntities(int num)
Definition cl_main.c:300
void CL_MoveLerpEntityStates(entity_t *ent)
Definition cl_parse.c:1991
float MSG_ReadAngle(sizebuf_t *sb, protocolversion_t protocol)
Definition com_msg.c:424
float MSG_ReadCoord(sizebuf_t *sb, protocolversion_t protocol)
Definition com_msg.c:389
#define MSG_ReadShort
Definition common.h:191
#define MSG_ReadFloat
Definition common.h:193
@ PROTOCOL_NEHAHRABJP2
same as NEHAHRABJP but with 16bit soundindex
Definition common.h:147
@ PROTOCOL_NEHAHRABJP
same as QUAKEDP but with 16bit modelindex
Definition common.h:146
@ PROTOCOL_NEHAHRABJP3
same as NEHAHRABJP2 but with some changes
Definition common.h:148
@ PROTOCOL_NEHAHRAMOVIE
Nehahra movie protocol, a big nasty hack dating back to early days of the Quake Standards Group (but ...
Definition common.h:143
#define MSG_ReadByte(sb)
Definition common.h:188
static int(ZEXPORT *qz_inflate)(z_stream *strm
void Host_Error(const char *error,...)
Definition host.c:85
sizebuf_t cl_message
Definition netconn.c:71
entity_state_t defaultstate
Definition protocol.c:4
#define RENDER_EXTERIORMODEL
Definition protocol.h:359
#define EF_FULLBRIGHT
Definition protocol.h:77
#define U_ANGLE2
Definition protocol.h:115
#define U_COLORMOD
1 byte, 3 bit red, 3 bit green, 2 bit blue, this lets you tint an object artifically,...
Definition protocol.h:139
#define U_ANGLE3
Definition protocol.h:123
#define U_SCALE
1 byte, scale / 16 positive, not sent if 1.0
Definition protocol.h:135
#define U_EFFECTS2
1 byte, this is .effects & 0xFF00 (second byte)
Definition protocol.h:136
#define U_STEP
Definition protocol.h:117
#define U_EXTEND1
Definition protocol.h:131
#define U_GLOWCOLOR
1 byte, palette index, default is 254 (white), this IS used for darklight (allowing colored darklight...
Definition protocol.h:138
#define U_DELTA
no data, while this is set the entity is delta compressed (uses previous frame as a baseline,...
Definition protocol.h:133
#define U_ORIGIN2
Definition protocol.h:113
#define U_ORIGIN1
Definition protocol.h:112
#define U_MODEL
Definition protocol.h:124
#define RENDER_VIEWMODEL
Definition protocol.h:358
#define U_ORIGIN3
Definition protocol.h:114
#define U_COLORMAP
Definition protocol.h:125
#define U_FRAME2
1 byte, this is .frame & 0xFF00 (second byte)
Definition protocol.h:144
#define RENDER_GLOWTRAIL
Definition protocol.h:357
#define U_EFFECTS
Definition protocol.h:127
#define U_GLOWTRAIL
leaves a trail of particles (of color .glowcolor, or black if it is a negative glowsize)
Definition protocol.h:142
#define U_EXTEND2
another byte to follow
Definition protocol.h:140
#define U_VIEWMODEL
attachs the model to the view (origin and angles become relative to it), only shown to owner,...
Definition protocol.h:143
#define U_SKIN
Definition protocol.h:126
@ ACTIVE_NETWORK
Definition protocol.h:433
@ ACTIVE_NOT
Definition protocol.h:432
#define RENDER_STEP
Definition protocol.h:356
#define U_LONGENTITY
Definition protocol.h:128
#define U_FRAME
Definition protocol.h:118
#define U_ALPHA
1 byte, 0.0-1.0 maps to 0-255, not sent if exactly 1, and the entity is not sent if <=0 unless it has...
Definition protocol.h:134
#define U_MOREBITS
Definition protocol.h:111
#define U_MODEL2
1 byte, this is .modelindex & 0xFF00 (second byte)
Definition protocol.h:145
#define U_ANGLE1
Definition protocol.h:122
#define U_GLOWSIZE
1 byte, encoding is float/4.0, unsigned, not sent if 0
Definition protocol.h:137
#define U_EXTERIORMODEL
causes this model to not be drawn when using a first person view (third person will draw it,...
Definition protocol.h:146
int i
#define MAX_EDICTS
max number of objects in game world at once (32768 protocol limit)
Definition qdefs.h:105
unsigned char isquakeentity[MAX_EDICTS]
Definition client.h:969
unsigned char * entities_active
Definition client.h:993
entity_t * entities
Definition client.h:991
int lastquakeentity
Definition client.h:968
int max_entities
Definition client.h:980
double mtime[2]
Definition client.h:861
protocolversion_t protocol
Definition client.h:617
unsigned char flags
Definition protocol.h:468
unsigned char skin
Definition protocol.h:463
unsigned char glowcolor
Definition protocol.h:467
unsigned char glowsize
Definition protocol.h:466
float origin[3]
Definition protocol.h:444
unsigned char colormap
Definition protocol.h:462
unsigned short modelindex
Definition protocol.h:449
unsigned char colormod[3]
Definition protocol.h:471
unsigned char alpha
Definition protocol.h:464
float angles[3]
Definition protocol.h:445
unsigned char active
Definition protocol.h:459
unsigned short frame
Definition protocol.h:450
unsigned short number
Definition protocol.h:448
unsigned char scale
Definition protocol.h:465
entity_state_t state_baseline
Definition client.h:467
entity_state_t state_current
Definition client.h:471
entity_state_t state_previous
Definition client.h:469
qbool badread
Definition common.h:56