mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-20 10:53:22 +00:00
Recombine the message handling back into one file
This commit is contained in:
parent
e0faf784a6
commit
d12f0c642f
3 changed files with 565 additions and 369 deletions
6
Makefile
6
Makefile
|
@ -470,13 +470,12 @@ CLIENT_OBJS_ := \
|
||||||
src/common/filesystem.o \
|
src/common/filesystem.o \
|
||||||
src/common/glob.o \
|
src/common/glob.o \
|
||||||
src/common/md4.o \
|
src/common/md4.o \
|
||||||
|
src/common/movemsg.o \
|
||||||
src/common/misc.o \
|
src/common/misc.o \
|
||||||
src/common/netchan.o \
|
src/common/netchan.o \
|
||||||
src/common/pmove.o \
|
src/common/pmove.o \
|
||||||
src/common/szone.o \
|
src/common/szone.o \
|
||||||
src/common/zone.o \
|
src/common/zone.o \
|
||||||
src/common/message/msg_io.o \
|
|
||||||
src/common/message/msg_read.o \
|
|
||||||
src/common/model/cm_areaportals.o \
|
src/common/model/cm_areaportals.o \
|
||||||
src/common/model/cm_box.o \
|
src/common/model/cm_box.o \
|
||||||
src/common/model/cm_boxtracing.o \
|
src/common/model/cm_boxtracing.o \
|
||||||
|
@ -532,12 +531,11 @@ SERVER_OBJS_ := \
|
||||||
src/common/glob.o \
|
src/common/glob.o \
|
||||||
src/common/md4.o \
|
src/common/md4.o \
|
||||||
src/common/misc.o \
|
src/common/misc.o \
|
||||||
|
src/common/movemsg.o \
|
||||||
src/common/netchan.o \
|
src/common/netchan.o \
|
||||||
src/common/pmove.o \
|
src/common/pmove.o \
|
||||||
src/common/szone.o \
|
src/common/szone.o \
|
||||||
src/common/zone.o \
|
src/common/zone.o \
|
||||||
src/common/message/msg_io.o \
|
|
||||||
src/common/message/msg_read.o \
|
|
||||||
src/common/model/cm_areaportals.o \
|
src/common/model/cm_areaportals.o \
|
||||||
src/common/model/cm_box.o \
|
src/common/model/cm_box.o \
|
||||||
src/common/model/cm_boxtracing.o \
|
src/common/model/cm_boxtracing.o \
|
||||||
|
|
|
@ -1,243 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* =======================================================================
|
|
||||||
*
|
|
||||||
* Message reading and preprocessing
|
|
||||||
*
|
|
||||||
* =======================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../header/common.h"
|
|
||||||
|
|
||||||
void MSG_BeginReading (sizebuf_t *msg)
|
|
||||||
{
|
|
||||||
msg->readcount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MSG_ReadChar (sizebuf_t *msg_read)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
|
|
||||||
if (msg_read->readcount+1 > msg_read->cursize)
|
|
||||||
c = -1;
|
|
||||||
|
|
||||||
else
|
|
||||||
c = (signed char)msg_read->data[msg_read->readcount];
|
|
||||||
|
|
||||||
msg_read->readcount++;
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MSG_ReadByte (sizebuf_t *msg_read)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
|
|
||||||
if (msg_read->readcount+1 > msg_read->cursize)
|
|
||||||
c = -1;
|
|
||||||
|
|
||||||
else
|
|
||||||
c = (unsigned char)msg_read->data[msg_read->readcount];
|
|
||||||
|
|
||||||
msg_read->readcount++;
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MSG_ReadShort (sizebuf_t *msg_read)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
|
|
||||||
if (msg_read->readcount+2 > msg_read->cursize)
|
|
||||||
c = -1;
|
|
||||||
|
|
||||||
else
|
|
||||||
c = (short)(msg_read->data[msg_read->readcount]
|
|
||||||
+ (msg_read->data[msg_read->readcount+1]<<8));
|
|
||||||
|
|
||||||
msg_read->readcount += 2;
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MSG_ReadLong (sizebuf_t *msg_read)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
|
|
||||||
if (msg_read->readcount+4 > msg_read->cursize)
|
|
||||||
c = -1;
|
|
||||||
|
|
||||||
else
|
|
||||||
c = msg_read->data[msg_read->readcount]
|
|
||||||
+ (msg_read->data[msg_read->readcount+1]<<8)
|
|
||||||
+ (msg_read->data[msg_read->readcount+2]<<16)
|
|
||||||
+ (msg_read->data[msg_read->readcount+3]<<24);
|
|
||||||
|
|
||||||
msg_read->readcount += 4;
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
float MSG_ReadFloat (sizebuf_t *msg_read)
|
|
||||||
{
|
|
||||||
union
|
|
||||||
{
|
|
||||||
byte b[4];
|
|
||||||
float f;
|
|
||||||
int l;
|
|
||||||
} dat;
|
|
||||||
|
|
||||||
if (msg_read->readcount+4 > msg_read->cursize)
|
|
||||||
dat.f = -1;
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dat.b[0] = msg_read->data[msg_read->readcount];
|
|
||||||
dat.b[1] = msg_read->data[msg_read->readcount+1];
|
|
||||||
dat.b[2] = msg_read->data[msg_read->readcount+2];
|
|
||||||
dat.b[3] = msg_read->data[msg_read->readcount+3];
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_read->readcount += 4;
|
|
||||||
|
|
||||||
dat.l = LittleLong (dat.l);
|
|
||||||
|
|
||||||
return dat.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *MSG_ReadString (sizebuf_t *msg_read)
|
|
||||||
{
|
|
||||||
static char string[2048];
|
|
||||||
int l,c;
|
|
||||||
|
|
||||||
l = 0;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = MSG_ReadChar (msg_read);
|
|
||||||
|
|
||||||
if (c == -1 || c == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
string[l] = c;
|
|
||||||
l++;
|
|
||||||
}
|
|
||||||
while (l < sizeof(string)-1);
|
|
||||||
|
|
||||||
string[l] = 0;
|
|
||||||
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *MSG_ReadStringLine (sizebuf_t *msg_read)
|
|
||||||
{
|
|
||||||
static char string[2048];
|
|
||||||
int l,c;
|
|
||||||
|
|
||||||
l = 0;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = MSG_ReadChar (msg_read);
|
|
||||||
|
|
||||||
if (c == -1 || c == 0 || c == '\n')
|
|
||||||
break;
|
|
||||||
|
|
||||||
string[l] = c;
|
|
||||||
l++;
|
|
||||||
}
|
|
||||||
while (l < sizeof(string)-1);
|
|
||||||
|
|
||||||
string[l] = 0;
|
|
||||||
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
float MSG_ReadCoord (sizebuf_t *msg_read)
|
|
||||||
{
|
|
||||||
return MSG_ReadShort(msg_read) * (0.125f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MSG_ReadPos (sizebuf_t *msg_read, vec3_t pos)
|
|
||||||
{
|
|
||||||
pos[0] = MSG_ReadShort(msg_read) * (0.125f);
|
|
||||||
pos[1] = MSG_ReadShort(msg_read) * (0.125f);
|
|
||||||
pos[2] = MSG_ReadShort(msg_read) * (0.125f);
|
|
||||||
}
|
|
||||||
|
|
||||||
float MSG_ReadAngle (sizebuf_t *msg_read)
|
|
||||||
{
|
|
||||||
return MSG_ReadChar(msg_read) * 1.40625f;
|
|
||||||
}
|
|
||||||
|
|
||||||
float MSG_ReadAngle16 (sizebuf_t *msg_read)
|
|
||||||
{
|
|
||||||
return SHORT2ANGLE(MSG_ReadShort(msg_read));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MSG_ReadDeltaUsercmd (sizebuf_t *msg_read, usercmd_t *from, usercmd_t *move)
|
|
||||||
{
|
|
||||||
int bits;
|
|
||||||
|
|
||||||
memcpy (move, from, sizeof(*move));
|
|
||||||
|
|
||||||
bits = MSG_ReadByte (msg_read);
|
|
||||||
|
|
||||||
/* read current angles */
|
|
||||||
if (bits & CM_ANGLE1)
|
|
||||||
move->angles[0] = MSG_ReadShort (msg_read);
|
|
||||||
|
|
||||||
if (bits & CM_ANGLE2)
|
|
||||||
move->angles[1] = MSG_ReadShort (msg_read);
|
|
||||||
|
|
||||||
if (bits & CM_ANGLE3)
|
|
||||||
move->angles[2] = MSG_ReadShort (msg_read);
|
|
||||||
|
|
||||||
/* read movement */
|
|
||||||
if (bits & CM_FORWARD)
|
|
||||||
move->forwardmove = MSG_ReadShort (msg_read);
|
|
||||||
|
|
||||||
if (bits & CM_SIDE)
|
|
||||||
move->sidemove = MSG_ReadShort (msg_read);
|
|
||||||
|
|
||||||
if (bits & CM_UP)
|
|
||||||
move->upmove = MSG_ReadShort (msg_read);
|
|
||||||
|
|
||||||
/* read buttons */
|
|
||||||
if (bits & CM_BUTTONS)
|
|
||||||
move->buttons = MSG_ReadByte (msg_read);
|
|
||||||
|
|
||||||
if (bits & CM_IMPULSE)
|
|
||||||
move->impulse = MSG_ReadByte (msg_read);
|
|
||||||
|
|
||||||
/* read time to run command */
|
|
||||||
move->msec = MSG_ReadByte (msg_read);
|
|
||||||
|
|
||||||
/* read the light level */
|
|
||||||
move->lightlevel = MSG_ReadByte (msg_read);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MSG_ReadData (sizebuf_t *msg_read, void *data, int len)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i=0 ; i<len ; i++)
|
|
||||||
((byte *)data)[i] = MSG_ReadByte (msg_read);
|
|
||||||
}
|
|
|
@ -19,15 +19,14 @@
|
||||||
*
|
*
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*
|
*
|
||||||
* Client / Server interactions
|
* Movement message (forward, backward, left, right, etc) handling.
|
||||||
*
|
*
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../header/common.h"
|
#include "header/common.h"
|
||||||
|
|
||||||
vec3_t bytedirs[NUMVERTEXNORMALS] =
|
vec3_t bytedirs[NUMVERTEXNORMALS] = {
|
||||||
{
|
|
||||||
{-0.525731, 0.000000, 0.850651},
|
{-0.525731, 0.000000, 0.850651},
|
||||||
{-0.442863, 0.238856, 0.864188},
|
{-0.442863, 0.238856, 0.864188},
|
||||||
{-0.295242, 0.000000, 0.955423},
|
{-0.295242, 0.000000, 0.955423},
|
||||||
|
@ -192,7 +191,8 @@ vec3_t bytedirs[NUMVERTEXNORMALS] =
|
||||||
{-0.688191, -0.587785, -0.425325}
|
{-0.688191, -0.587785, -0.425325}
|
||||||
};
|
};
|
||||||
|
|
||||||
void MSG_WriteChar (sizebuf_t *sb, int c)
|
void
|
||||||
|
MSG_WriteChar(sizebuf_t *sb, int c)
|
||||||
{
|
{
|
||||||
byte *buf;
|
byte *buf;
|
||||||
|
|
||||||
|
@ -200,7 +200,8 @@ void MSG_WriteChar (sizebuf_t *sb, int c)
|
||||||
buf[0] = c;
|
buf[0] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_WriteByte (sizebuf_t *sb, int c)
|
void
|
||||||
|
MSG_WriteByte(sizebuf_t *sb, int c)
|
||||||
{
|
{
|
||||||
byte *buf;
|
byte *buf;
|
||||||
|
|
||||||
|
@ -208,7 +209,8 @@ void MSG_WriteByte (sizebuf_t *sb, int c)
|
||||||
buf[0] = c;
|
buf[0] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_WriteShort (sizebuf_t *sb, int c)
|
void
|
||||||
|
MSG_WriteShort(sizebuf_t *sb, int c)
|
||||||
{
|
{
|
||||||
byte *buf;
|
byte *buf;
|
||||||
|
|
||||||
|
@ -217,7 +219,8 @@ void MSG_WriteShort (sizebuf_t *sb, int c)
|
||||||
buf[1] = c >> 8;
|
buf[1] = c >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_WriteLong (sizebuf_t *sb, int c)
|
void
|
||||||
|
MSG_WriteLong(sizebuf_t *sb, int c)
|
||||||
{
|
{
|
||||||
byte *buf;
|
byte *buf;
|
||||||
|
|
||||||
|
@ -228,7 +231,8 @@ void MSG_WriteLong (sizebuf_t *sb, int c)
|
||||||
buf[3] = c >> 24;
|
buf[3] = c >> 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_WriteFloat (sizebuf_t *sb, float f)
|
void
|
||||||
|
MSG_WriteFloat(sizebuf_t *sb, float f)
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
@ -236,45 +240,54 @@ void MSG_WriteFloat (sizebuf_t *sb, float f)
|
||||||
int l;
|
int l;
|
||||||
} dat;
|
} dat;
|
||||||
|
|
||||||
|
|
||||||
dat.f = f;
|
dat.f = f;
|
||||||
dat.l = LittleLong(dat.l);
|
dat.l = LittleLong(dat.l);
|
||||||
|
|
||||||
SZ_Write(sb, &dat.l, 4);
|
SZ_Write(sb, &dat.l, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_WriteString (sizebuf_t *sb, char *s)
|
void
|
||||||
|
MSG_WriteString(sizebuf_t *sb, char *s)
|
||||||
{
|
{
|
||||||
if (!s)
|
if (!s)
|
||||||
|
{
|
||||||
SZ_Write(sb, "", 1);
|
SZ_Write(sb, "", 1);
|
||||||
|
|
||||||
else
|
|
||||||
SZ_Write (sb, s, (int)strlen(s)+1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_WriteCoord (sizebuf_t *sb, float f)
|
else
|
||||||
|
{
|
||||||
|
SZ_Write(sb, s, (int)strlen(s) + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MSG_WriteCoord(sizebuf_t *sb, float f)
|
||||||
{
|
{
|
||||||
MSG_WriteShort(sb, (int)(f * 8));
|
MSG_WriteShort(sb, (int)(f * 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_WritePos (sizebuf_t *sb, vec3_t pos)
|
void
|
||||||
|
MSG_WritePos(sizebuf_t *sb, vec3_t pos)
|
||||||
{
|
{
|
||||||
MSG_WriteShort(sb, (int)(pos[0] * 8));
|
MSG_WriteShort(sb, (int)(pos[0] * 8));
|
||||||
MSG_WriteShort(sb, (int)(pos[1] * 8));
|
MSG_WriteShort(sb, (int)(pos[1] * 8));
|
||||||
MSG_WriteShort(sb, (int)(pos[2] * 8));
|
MSG_WriteShort(sb, (int)(pos[2] * 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_WriteAngle (sizebuf_t *sb, float f)
|
void
|
||||||
|
MSG_WriteAngle(sizebuf_t *sb, float f)
|
||||||
{
|
{
|
||||||
MSG_WriteByte(sb, (int)(f * 256 / 360) & 255);
|
MSG_WriteByte(sb, (int)(f * 256 / 360) & 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_WriteAngle16 (sizebuf_t *sb, float f)
|
void
|
||||||
|
MSG_WriteAngle16(sizebuf_t *sb, float f)
|
||||||
{
|
{
|
||||||
MSG_WriteShort(sb, ANGLE2SHORT(f));
|
MSG_WriteShort(sb, ANGLE2SHORT(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_WriteDeltaUsercmd (sizebuf_t *buf, usercmd_t *from, usercmd_t *cmd)
|
void
|
||||||
|
MSG_WriteDeltaUsercmd(sizebuf_t *buf, usercmd_t *from, usercmd_t *cmd)
|
||||||
{
|
{
|
||||||
int bits;
|
int bits;
|
||||||
|
|
||||||
|
@ -282,60 +295,93 @@ void MSG_WriteDeltaUsercmd (sizebuf_t *buf, usercmd_t *from, usercmd_t *cmd)
|
||||||
bits = 0;
|
bits = 0;
|
||||||
|
|
||||||
if (cmd->angles[0] != from->angles[0])
|
if (cmd->angles[0] != from->angles[0])
|
||||||
|
{
|
||||||
bits |= CM_ANGLE1;
|
bits |= CM_ANGLE1;
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd->angles[1] != from->angles[1])
|
if (cmd->angles[1] != from->angles[1])
|
||||||
|
{
|
||||||
bits |= CM_ANGLE2;
|
bits |= CM_ANGLE2;
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd->angles[2] != from->angles[2])
|
if (cmd->angles[2] != from->angles[2])
|
||||||
|
{
|
||||||
bits |= CM_ANGLE3;
|
bits |= CM_ANGLE3;
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd->forwardmove != from->forwardmove)
|
if (cmd->forwardmove != from->forwardmove)
|
||||||
|
{
|
||||||
bits |= CM_FORWARD;
|
bits |= CM_FORWARD;
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd->sidemove != from->sidemove)
|
if (cmd->sidemove != from->sidemove)
|
||||||
|
{
|
||||||
bits |= CM_SIDE;
|
bits |= CM_SIDE;
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd->upmove != from->upmove)
|
if (cmd->upmove != from->upmove)
|
||||||
|
{
|
||||||
bits |= CM_UP;
|
bits |= CM_UP;
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd->buttons != from->buttons)
|
if (cmd->buttons != from->buttons)
|
||||||
|
{
|
||||||
bits |= CM_BUTTONS;
|
bits |= CM_BUTTONS;
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd->impulse != from->impulse)
|
if (cmd->impulse != from->impulse)
|
||||||
|
{
|
||||||
bits |= CM_IMPULSE;
|
bits |= CM_IMPULSE;
|
||||||
|
}
|
||||||
|
|
||||||
MSG_WriteByte(buf, bits);
|
MSG_WriteByte(buf, bits);
|
||||||
|
|
||||||
if (bits & CM_ANGLE1)
|
if (bits & CM_ANGLE1)
|
||||||
|
{
|
||||||
MSG_WriteShort(buf, cmd->angles[0]);
|
MSG_WriteShort(buf, cmd->angles[0]);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & CM_ANGLE2)
|
if (bits & CM_ANGLE2)
|
||||||
|
{
|
||||||
MSG_WriteShort(buf, cmd->angles[1]);
|
MSG_WriteShort(buf, cmd->angles[1]);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & CM_ANGLE3)
|
if (bits & CM_ANGLE3)
|
||||||
|
{
|
||||||
MSG_WriteShort(buf, cmd->angles[2]);
|
MSG_WriteShort(buf, cmd->angles[2]);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & CM_FORWARD)
|
if (bits & CM_FORWARD)
|
||||||
|
{
|
||||||
MSG_WriteShort(buf, cmd->forwardmove);
|
MSG_WriteShort(buf, cmd->forwardmove);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & CM_SIDE)
|
if (bits & CM_SIDE)
|
||||||
|
{
|
||||||
MSG_WriteShort(buf, cmd->sidemove);
|
MSG_WriteShort(buf, cmd->sidemove);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & CM_UP)
|
if (bits & CM_UP)
|
||||||
|
{
|
||||||
MSG_WriteShort(buf, cmd->upmove);
|
MSG_WriteShort(buf, cmd->upmove);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & CM_BUTTONS)
|
if (bits & CM_BUTTONS)
|
||||||
|
{
|
||||||
MSG_WriteByte(buf, cmd->buttons);
|
MSG_WriteByte(buf, cmd->buttons);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & CM_IMPULSE)
|
if (bits & CM_IMPULSE)
|
||||||
|
{
|
||||||
MSG_WriteByte(buf, cmd->impulse);
|
MSG_WriteByte(buf, cmd->impulse);
|
||||||
|
}
|
||||||
|
|
||||||
MSG_WriteByte(buf, cmd->msec);
|
MSG_WriteByte(buf, cmd->msec);
|
||||||
MSG_WriteByte(buf, cmd->lightlevel);
|
MSG_WriteByte(buf, cmd->lightlevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_WriteDir (sizebuf_t *sb, vec3_t dir)
|
void
|
||||||
|
MSG_WriteDir(sizebuf_t *sb, vec3_t dir)
|
||||||
{
|
{
|
||||||
int i, best;
|
int i, best;
|
||||||
float d, bestd;
|
float d, bestd;
|
||||||
|
@ -363,14 +409,17 @@ void MSG_WriteDir (sizebuf_t *sb, vec3_t dir)
|
||||||
MSG_WriteByte(sb, best);
|
MSG_WriteByte(sb, best);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_ReadDir (sizebuf_t *sb, vec3_t dir)
|
void
|
||||||
|
MSG_ReadDir(sizebuf_t *sb, vec3_t dir)
|
||||||
{
|
{
|
||||||
int b;
|
int b;
|
||||||
|
|
||||||
b = MSG_ReadByte(sb);
|
b = MSG_ReadByte(sb);
|
||||||
|
|
||||||
if (b >= NUMVERTEXNORMALS)
|
if (b >= NUMVERTEXNORMALS)
|
||||||
|
{
|
||||||
Com_Error(ERR_DROP, "MSF_ReadDir: out of range");
|
Com_Error(ERR_DROP, "MSF_ReadDir: out of range");
|
||||||
|
}
|
||||||
|
|
||||||
VectorCopy(bytedirs[b], dir);
|
VectorCopy(bytedirs[b], dir);
|
||||||
}
|
}
|
||||||
|
@ -379,122 +428,191 @@ void MSG_ReadDir (sizebuf_t *sb, vec3_t dir)
|
||||||
* Writes part of a packetentities message.
|
* Writes part of a packetentities message.
|
||||||
* Can delta from either a baseline or a previous packet_entity
|
* Can delta from either a baseline or a previous packet_entity
|
||||||
*/
|
*/
|
||||||
void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, qboolean newentity)
|
void
|
||||||
|
MSG_WriteDeltaEntity(entity_state_t *from,
|
||||||
|
entity_state_t *to,
|
||||||
|
sizebuf_t *msg,
|
||||||
|
qboolean force,
|
||||||
|
qboolean newentity)
|
||||||
{
|
{
|
||||||
int bits;
|
int bits;
|
||||||
|
|
||||||
if (!to->number)
|
if (!to->number)
|
||||||
|
{
|
||||||
Com_Error(ERR_FATAL, "Unset entity number");
|
Com_Error(ERR_FATAL, "Unset entity number");
|
||||||
|
}
|
||||||
|
|
||||||
if (to->number >= MAX_EDICTS)
|
if (to->number >= MAX_EDICTS)
|
||||||
|
{
|
||||||
Com_Error(ERR_FATAL, "Entity number >= MAX_EDICTS");
|
Com_Error(ERR_FATAL, "Entity number >= MAX_EDICTS");
|
||||||
|
}
|
||||||
|
|
||||||
/* send an update */
|
/* send an update */
|
||||||
bits = 0;
|
bits = 0;
|
||||||
|
|
||||||
if (to->number >= 256)
|
if (to->number >= 256)
|
||||||
|
{
|
||||||
bits |= U_NUMBER16; /* number8 is implicit otherwise */
|
bits |= U_NUMBER16; /* number8 is implicit otherwise */
|
||||||
|
}
|
||||||
|
|
||||||
if (to->origin[0] != from->origin[0])
|
if (to->origin[0] != from->origin[0])
|
||||||
|
{
|
||||||
bits |= U_ORIGIN1;
|
bits |= U_ORIGIN1;
|
||||||
|
}
|
||||||
|
|
||||||
if (to->origin[1] != from->origin[1])
|
if (to->origin[1] != from->origin[1])
|
||||||
|
{
|
||||||
bits |= U_ORIGIN2;
|
bits |= U_ORIGIN2;
|
||||||
|
}
|
||||||
|
|
||||||
if (to->origin[2] != from->origin[2])
|
if (to->origin[2] != from->origin[2])
|
||||||
|
{
|
||||||
bits |= U_ORIGIN3;
|
bits |= U_ORIGIN3;
|
||||||
|
}
|
||||||
|
|
||||||
if (to->angles[0] != from->angles[0])
|
if (to->angles[0] != from->angles[0])
|
||||||
|
{
|
||||||
bits |= U_ANGLE1;
|
bits |= U_ANGLE1;
|
||||||
|
}
|
||||||
|
|
||||||
if (to->angles[1] != from->angles[1])
|
if (to->angles[1] != from->angles[1])
|
||||||
|
{
|
||||||
bits |= U_ANGLE2;
|
bits |= U_ANGLE2;
|
||||||
|
}
|
||||||
|
|
||||||
if (to->angles[2] != from->angles[2])
|
if (to->angles[2] != from->angles[2])
|
||||||
|
{
|
||||||
bits |= U_ANGLE3;
|
bits |= U_ANGLE3;
|
||||||
|
}
|
||||||
|
|
||||||
if (to->skinnum != from->skinnum)
|
if (to->skinnum != from->skinnum)
|
||||||
{
|
{
|
||||||
if ((unsigned)to->skinnum < 256)
|
if ((unsigned)to->skinnum < 256)
|
||||||
|
{
|
||||||
bits |= U_SKIN8;
|
bits |= U_SKIN8;
|
||||||
|
}
|
||||||
|
|
||||||
else if ((unsigned)to->skinnum < 0x10000)
|
else if ((unsigned)to->skinnum < 0x10000)
|
||||||
|
{
|
||||||
bits |= U_SKIN16;
|
bits |= U_SKIN16;
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
bits |= (U_SKIN8 | U_SKIN16);
|
bits |= (U_SKIN8 | U_SKIN16);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (to->frame != from->frame)
|
if (to->frame != from->frame)
|
||||||
{
|
{
|
||||||
if (to->frame < 256)
|
if (to->frame < 256)
|
||||||
|
{
|
||||||
bits |= U_FRAME8;
|
bits |= U_FRAME8;
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
bits |= U_FRAME16;
|
bits |= U_FRAME16;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (to->effects != from->effects)
|
if (to->effects != from->effects)
|
||||||
{
|
{
|
||||||
if (to->effects < 256)
|
if (to->effects < 256)
|
||||||
|
{
|
||||||
bits |= U_EFFECTS8;
|
bits |= U_EFFECTS8;
|
||||||
|
}
|
||||||
|
|
||||||
else if (to->effects < 0x8000)
|
else if (to->effects < 0x8000)
|
||||||
|
{
|
||||||
bits |= U_EFFECTS16;
|
bits |= U_EFFECTS16;
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
bits |= U_EFFECTS8 | U_EFFECTS16;
|
bits |= U_EFFECTS8 | U_EFFECTS16;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (to->renderfx != from->renderfx)
|
if (to->renderfx != from->renderfx)
|
||||||
{
|
{
|
||||||
if (to->renderfx < 256)
|
if (to->renderfx < 256)
|
||||||
|
{
|
||||||
bits |= U_RENDERFX8;
|
bits |= U_RENDERFX8;
|
||||||
|
}
|
||||||
|
|
||||||
else if (to->renderfx < 0x8000)
|
else if (to->renderfx < 0x8000)
|
||||||
|
{
|
||||||
bits |= U_RENDERFX16;
|
bits |= U_RENDERFX16;
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
bits |= U_RENDERFX8 | U_RENDERFX16;
|
bits |= U_RENDERFX8 | U_RENDERFX16;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (to->solid != from->solid)
|
if (to->solid != from->solid)
|
||||||
|
{
|
||||||
bits |= U_SOLID;
|
bits |= U_SOLID;
|
||||||
|
}
|
||||||
|
|
||||||
/* event is not delta compressed, just 0 compressed */
|
/* event is not delta compressed, just 0 compressed */
|
||||||
if (to->event)
|
if (to->event)
|
||||||
|
{
|
||||||
bits |= U_EVENT;
|
bits |= U_EVENT;
|
||||||
|
}
|
||||||
|
|
||||||
if (to->modelindex != from->modelindex)
|
if (to->modelindex != from->modelindex)
|
||||||
|
{
|
||||||
bits |= U_MODEL;
|
bits |= U_MODEL;
|
||||||
|
}
|
||||||
|
|
||||||
if (to->modelindex2 != from->modelindex2)
|
if (to->modelindex2 != from->modelindex2)
|
||||||
|
{
|
||||||
bits |= U_MODEL2;
|
bits |= U_MODEL2;
|
||||||
|
}
|
||||||
|
|
||||||
if (to->modelindex3 != from->modelindex3)
|
if (to->modelindex3 != from->modelindex3)
|
||||||
|
{
|
||||||
bits |= U_MODEL3;
|
bits |= U_MODEL3;
|
||||||
|
}
|
||||||
|
|
||||||
if (to->modelindex4 != from->modelindex4)
|
if (to->modelindex4 != from->modelindex4)
|
||||||
|
{
|
||||||
bits |= U_MODEL4;
|
bits |= U_MODEL4;
|
||||||
|
}
|
||||||
|
|
||||||
if (to->sound != from->sound)
|
if (to->sound != from->sound)
|
||||||
|
{
|
||||||
bits |= U_SOUND;
|
bits |= U_SOUND;
|
||||||
|
}
|
||||||
|
|
||||||
if (newentity || (to->renderfx & RF_BEAM))
|
if (newentity || (to->renderfx & RF_BEAM))
|
||||||
|
{
|
||||||
bits |= U_OLDORIGIN;
|
bits |= U_OLDORIGIN;
|
||||||
|
}
|
||||||
|
|
||||||
/* write the message */
|
/* write the message */
|
||||||
if (!bits && !force)
|
if (!bits && !force)
|
||||||
|
{
|
||||||
return; /* nothing to send! */
|
return; /* nothing to send! */
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & 0xff000000)
|
if (bits & 0xff000000)
|
||||||
|
{
|
||||||
bits |= U_MOREBITS3 | U_MOREBITS2 | U_MOREBITS1;
|
bits |= U_MOREBITS3 | U_MOREBITS2 | U_MOREBITS1;
|
||||||
|
}
|
||||||
|
|
||||||
else if (bits & 0x00ff0000)
|
else if (bits & 0x00ff0000)
|
||||||
|
{
|
||||||
bits |= U_MOREBITS2 | U_MOREBITS1;
|
bits |= U_MOREBITS2 | U_MOREBITS1;
|
||||||
|
}
|
||||||
|
|
||||||
else if (bits & 0x0000ff00)
|
else if (bits & 0x0000ff00)
|
||||||
|
{
|
||||||
bits |= U_MOREBITS1;
|
bits |= U_MOREBITS1;
|
||||||
|
}
|
||||||
|
|
||||||
MSG_WriteByte(msg, bits & 255);
|
MSG_WriteByte(msg, bits & 255);
|
||||||
|
|
||||||
|
@ -517,73 +635,119 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bits & U_NUMBER16)
|
if (bits & U_NUMBER16)
|
||||||
|
{
|
||||||
MSG_WriteShort(msg, to->number);
|
MSG_WriteShort(msg, to->number);
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
MSG_WriteByte(msg, to->number);
|
MSG_WriteByte(msg, to->number);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_MODEL)
|
if (bits & U_MODEL)
|
||||||
|
{
|
||||||
MSG_WriteByte(msg, to->modelindex);
|
MSG_WriteByte(msg, to->modelindex);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_MODEL2)
|
if (bits & U_MODEL2)
|
||||||
|
{
|
||||||
MSG_WriteByte(msg, to->modelindex2);
|
MSG_WriteByte(msg, to->modelindex2);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_MODEL3)
|
if (bits & U_MODEL3)
|
||||||
|
{
|
||||||
MSG_WriteByte(msg, to->modelindex3);
|
MSG_WriteByte(msg, to->modelindex3);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_MODEL4)
|
if (bits & U_MODEL4)
|
||||||
|
{
|
||||||
MSG_WriteByte(msg, to->modelindex4);
|
MSG_WriteByte(msg, to->modelindex4);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_FRAME8)
|
if (bits & U_FRAME8)
|
||||||
|
{
|
||||||
MSG_WriteByte(msg, to->frame);
|
MSG_WriteByte(msg, to->frame);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_FRAME16)
|
if (bits & U_FRAME16)
|
||||||
|
{
|
||||||
MSG_WriteShort(msg, to->frame);
|
MSG_WriteShort(msg, to->frame);
|
||||||
|
}
|
||||||
|
|
||||||
if ((bits & U_SKIN8) && (bits & U_SKIN16)) /*used for laser colors */
|
if ((bits & U_SKIN8) && (bits & U_SKIN16)) /*used for laser colors */
|
||||||
|
{
|
||||||
MSG_WriteLong(msg, to->skinnum);
|
MSG_WriteLong(msg, to->skinnum);
|
||||||
|
}
|
||||||
|
|
||||||
else if (bits & U_SKIN8)
|
else if (bits & U_SKIN8)
|
||||||
|
{
|
||||||
MSG_WriteByte(msg, to->skinnum);
|
MSG_WriteByte(msg, to->skinnum);
|
||||||
|
}
|
||||||
|
|
||||||
else if (bits & U_SKIN16)
|
else if (bits & U_SKIN16)
|
||||||
|
{
|
||||||
MSG_WriteShort(msg, to->skinnum);
|
MSG_WriteShort(msg, to->skinnum);
|
||||||
|
}
|
||||||
|
|
||||||
if ((bits & (U_EFFECTS8 | U_EFFECTS16)) == (U_EFFECTS8 | U_EFFECTS16))
|
if ((bits & (U_EFFECTS8 | U_EFFECTS16)) == (U_EFFECTS8 | U_EFFECTS16))
|
||||||
|
{
|
||||||
MSG_WriteLong(msg, to->effects);
|
MSG_WriteLong(msg, to->effects);
|
||||||
|
}
|
||||||
|
|
||||||
else if (bits & U_EFFECTS8)
|
else if (bits & U_EFFECTS8)
|
||||||
|
{
|
||||||
MSG_WriteByte(msg, to->effects);
|
MSG_WriteByte(msg, to->effects);
|
||||||
|
}
|
||||||
|
|
||||||
else if (bits & U_EFFECTS16)
|
else if (bits & U_EFFECTS16)
|
||||||
|
{
|
||||||
MSG_WriteShort(msg, to->effects);
|
MSG_WriteShort(msg, to->effects);
|
||||||
|
}
|
||||||
|
|
||||||
if ((bits & (U_RENDERFX8 | U_RENDERFX16)) == (U_RENDERFX8 | U_RENDERFX16))
|
if ((bits & (U_RENDERFX8 | U_RENDERFX16)) == (U_RENDERFX8 | U_RENDERFX16))
|
||||||
|
{
|
||||||
MSG_WriteLong(msg, to->renderfx);
|
MSG_WriteLong(msg, to->renderfx);
|
||||||
|
}
|
||||||
|
|
||||||
else if (bits & U_RENDERFX8)
|
else if (bits & U_RENDERFX8)
|
||||||
|
{
|
||||||
MSG_WriteByte(msg, to->renderfx);
|
MSG_WriteByte(msg, to->renderfx);
|
||||||
|
}
|
||||||
|
|
||||||
else if (bits & U_RENDERFX16)
|
else if (bits & U_RENDERFX16)
|
||||||
|
{
|
||||||
MSG_WriteShort(msg, to->renderfx);
|
MSG_WriteShort(msg, to->renderfx);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_ORIGIN1)
|
if (bits & U_ORIGIN1)
|
||||||
|
{
|
||||||
MSG_WriteCoord(msg, to->origin[0]);
|
MSG_WriteCoord(msg, to->origin[0]);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_ORIGIN2)
|
if (bits & U_ORIGIN2)
|
||||||
|
{
|
||||||
MSG_WriteCoord(msg, to->origin[1]);
|
MSG_WriteCoord(msg, to->origin[1]);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_ORIGIN3)
|
if (bits & U_ORIGIN3)
|
||||||
|
{
|
||||||
MSG_WriteCoord(msg, to->origin[2]);
|
MSG_WriteCoord(msg, to->origin[2]);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_ANGLE1)
|
if (bits & U_ANGLE1)
|
||||||
|
{
|
||||||
MSG_WriteAngle(msg, to->angles[0]);
|
MSG_WriteAngle(msg, to->angles[0]);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_ANGLE2)
|
if (bits & U_ANGLE2)
|
||||||
|
{
|
||||||
MSG_WriteAngle(msg, to->angles[1]);
|
MSG_WriteAngle(msg, to->angles[1]);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_ANGLE3)
|
if (bits & U_ANGLE3)
|
||||||
|
{
|
||||||
MSG_WriteAngle(msg, to->angles[2]);
|
MSG_WriteAngle(msg, to->angles[2]);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_OLDORIGIN)
|
if (bits & U_OLDORIGIN)
|
||||||
{
|
{
|
||||||
|
@ -593,11 +757,288 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bits & U_SOUND)
|
if (bits & U_SOUND)
|
||||||
|
{
|
||||||
MSG_WriteByte(msg, to->sound);
|
MSG_WriteByte(msg, to->sound);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_EVENT)
|
if (bits & U_EVENT)
|
||||||
|
{
|
||||||
MSG_WriteByte(msg, to->event);
|
MSG_WriteByte(msg, to->event);
|
||||||
|
}
|
||||||
|
|
||||||
if (bits & U_SOLID)
|
if (bits & U_SOLID)
|
||||||
|
{
|
||||||
MSG_WriteShort(msg, to->solid);
|
MSG_WriteShort(msg, to->solid);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MSG_BeginReading(sizebuf_t *msg)
|
||||||
|
{
|
||||||
|
msg->readcount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
MSG_ReadChar(sizebuf_t *msg_read)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
if (msg_read->readcount + 1 > msg_read->cursize)
|
||||||
|
{
|
||||||
|
c = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c = (signed char)msg_read->data[msg_read->readcount];
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_read->readcount++;
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
MSG_ReadByte(sizebuf_t *msg_read)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
if (msg_read->readcount + 1 > msg_read->cursize)
|
||||||
|
{
|
||||||
|
c = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c = (unsigned char)msg_read->data[msg_read->readcount];
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_read->readcount++;
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
MSG_ReadShort(sizebuf_t *msg_read)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
if (msg_read->readcount + 2 > msg_read->cursize)
|
||||||
|
{
|
||||||
|
c = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c = (short)(msg_read->data[msg_read->readcount]
|
||||||
|
+ (msg_read->data[msg_read->readcount + 1] << 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_read->readcount += 2;
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
MSG_ReadLong(sizebuf_t *msg_read)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
if (msg_read->readcount + 4 > msg_read->cursize)
|
||||||
|
{
|
||||||
|
c = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c = msg_read->data[msg_read->readcount]
|
||||||
|
+ (msg_read->data[msg_read->readcount + 1] << 8)
|
||||||
|
+ (msg_read->data[msg_read->readcount + 2] << 16)
|
||||||
|
+ (msg_read->data[msg_read->readcount + 3] << 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_read->readcount += 4;
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
MSG_ReadFloat(sizebuf_t *msg_read)
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
byte b[4];
|
||||||
|
float f;
|
||||||
|
int l;
|
||||||
|
} dat;
|
||||||
|
|
||||||
|
if (msg_read->readcount + 4 > msg_read->cursize)
|
||||||
|
{
|
||||||
|
dat.f = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dat.b[0] = msg_read->data[msg_read->readcount];
|
||||||
|
dat.b[1] = msg_read->data[msg_read->readcount + 1];
|
||||||
|
dat.b[2] = msg_read->data[msg_read->readcount + 2];
|
||||||
|
dat.b[3] = msg_read->data[msg_read->readcount + 3];
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_read->readcount += 4;
|
||||||
|
|
||||||
|
dat.l = LittleLong(dat.l);
|
||||||
|
|
||||||
|
return dat.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
MSG_ReadString(sizebuf_t *msg_read)
|
||||||
|
{
|
||||||
|
static char string[2048];
|
||||||
|
int l, c;
|
||||||
|
|
||||||
|
l = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
c = MSG_ReadChar(msg_read);
|
||||||
|
|
||||||
|
if ((c == -1) || (c == 0))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[l] = c;
|
||||||
|
l++;
|
||||||
|
}
|
||||||
|
while (l < sizeof(string) - 1);
|
||||||
|
|
||||||
|
string[l] = 0;
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
MSG_ReadStringLine(sizebuf_t *msg_read)
|
||||||
|
{
|
||||||
|
static char string[2048];
|
||||||
|
int l, c;
|
||||||
|
|
||||||
|
l = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
c = MSG_ReadChar(msg_read);
|
||||||
|
|
||||||
|
if ((c == -1) || (c == 0) || (c == '\n'))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[l] = c;
|
||||||
|
l++;
|
||||||
|
}
|
||||||
|
while (l < sizeof(string) - 1);
|
||||||
|
|
||||||
|
string[l] = 0;
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
MSG_ReadCoord(sizebuf_t *msg_read)
|
||||||
|
{
|
||||||
|
return MSG_ReadShort(msg_read) * (0.125f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MSG_ReadPos(sizebuf_t *msg_read, vec3_t pos)
|
||||||
|
{
|
||||||
|
pos[0] = MSG_ReadShort(msg_read) * (0.125f);
|
||||||
|
pos[1] = MSG_ReadShort(msg_read) * (0.125f);
|
||||||
|
pos[2] = MSG_ReadShort(msg_read) * (0.125f);
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
MSG_ReadAngle(sizebuf_t *msg_read)
|
||||||
|
{
|
||||||
|
return MSG_ReadChar(msg_read) * 1.40625f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
MSG_ReadAngle16(sizebuf_t *msg_read)
|
||||||
|
{
|
||||||
|
return SHORT2ANGLE(MSG_ReadShort(msg_read));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MSG_ReadDeltaUsercmd(sizebuf_t *msg_read, usercmd_t *from, usercmd_t *move)
|
||||||
|
{
|
||||||
|
int bits;
|
||||||
|
|
||||||
|
memcpy(move, from, sizeof(*move));
|
||||||
|
|
||||||
|
bits = MSG_ReadByte(msg_read);
|
||||||
|
|
||||||
|
/* read current angles */
|
||||||
|
if (bits & CM_ANGLE1)
|
||||||
|
{
|
||||||
|
move->angles[0] = MSG_ReadShort(msg_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bits & CM_ANGLE2)
|
||||||
|
{
|
||||||
|
move->angles[1] = MSG_ReadShort(msg_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bits & CM_ANGLE3)
|
||||||
|
{
|
||||||
|
move->angles[2] = MSG_ReadShort(msg_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read movement */
|
||||||
|
if (bits & CM_FORWARD)
|
||||||
|
{
|
||||||
|
move->forwardmove = MSG_ReadShort(msg_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bits & CM_SIDE)
|
||||||
|
{
|
||||||
|
move->sidemove = MSG_ReadShort(msg_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bits & CM_UP)
|
||||||
|
{
|
||||||
|
move->upmove = MSG_ReadShort(msg_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read buttons */
|
||||||
|
if (bits & CM_BUTTONS)
|
||||||
|
{
|
||||||
|
move->buttons = MSG_ReadByte(msg_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bits & CM_IMPULSE)
|
||||||
|
{
|
||||||
|
move->impulse = MSG_ReadByte(msg_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read time to run command */
|
||||||
|
move->msec = MSG_ReadByte(msg_read);
|
||||||
|
|
||||||
|
/* read the light level */
|
||||||
|
move->lightlevel = MSG_ReadByte(msg_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MSG_ReadData(sizebuf_t *msg_read, void *data, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
((byte *)data)[i] = MSG_ReadByte(msg_read);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue