mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 18:01:15 +00:00
Change MSG_ReadShort to return an unsigned short.
Avoiding the sign extension by default seems to be more useful.
This commit is contained in:
parent
9ace9f2bfa
commit
9afb691dd9
7 changed files with 38 additions and 41 deletions
|
@ -250,8 +250,8 @@ MSG_ReadShort (qmsg_t *msg)
|
|||
int c;
|
||||
|
||||
if (msg->readcount + 2 <= msg->message->cursize) {
|
||||
c = (short) (msg->message->data[msg->readcount]
|
||||
+ (msg->message->data[msg->readcount + 1] << 8));
|
||||
c = (msg->message->data[msg->readcount]
|
||||
+ (msg->message->data[msg->readcount + 1] << 8));
|
||||
msg->readcount += 2;
|
||||
return c;
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ MSG_ReadBytes (qmsg_t *msg, void *buf, int len)
|
|||
VISIBLE float
|
||||
MSG_ReadCoord (qmsg_t *msg)
|
||||
{
|
||||
return MSG_ReadShort (msg) * (1.0 / 8.0);
|
||||
return (short) MSG_ReadShort (msg) * (1.0 / 8.0);
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
|
@ -363,7 +363,7 @@ MSG_ReadCoordV (qmsg_t *msg, vec3_t coord)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
coord[i] = MSG_ReadShort (msg) * (1.0 / 8.0);
|
||||
coord[i] = (short) MSG_ReadShort (msg) * (1.0 / 8.0);
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
|
@ -372,7 +372,7 @@ MSG_ReadCoordAngleV (qmsg_t *msg, vec3_t coord, vec3_t angles)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
coord[i] = MSG_ReadShort (msg) * (1.0 / 8.0);
|
||||
coord[i] = (short) MSG_ReadShort (msg) * (1.0 / 8.0);
|
||||
angles[i] = ((signed char) MSG_ReadByte (msg)) * (360.0 / 256.0);
|
||||
}
|
||||
}
|
||||
|
@ -395,20 +395,16 @@ MSG_ReadAngleV (qmsg_t *msg, vec3_t angles)
|
|||
VISIBLE float
|
||||
MSG_ReadAngle16 (qmsg_t *msg)
|
||||
{
|
||||
return MSG_ReadShort (msg) * (360.0 / 65536.0);
|
||||
return (short) MSG_ReadShort (msg) * (360.0 / 65536.0);
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
MSG_ReadAngle16V (qmsg_t *msg, vec3_t angles)
|
||||
{
|
||||
int i;
|
||||
short ang;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
ang = MSG_ReadByte (msg);
|
||||
ang |= MSG_ReadByte (msg) << 8;
|
||||
angles[i] = ang * (360.0 / 65536.0);
|
||||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
angles[i] = (short) MSG_ReadShort (msg) * (360.0 / 65536.0);
|
||||
}
|
||||
|
||||
VISIBLE int
|
||||
|
|
|
@ -185,16 +185,16 @@ CL_ParseStartSoundPacket (void)
|
|||
attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
|
||||
|
||||
if (field_mask & SND_LARGEENTITY) {
|
||||
ent = (uint16_t) MSG_ReadShort (net_message);
|
||||
ent = MSG_ReadShort (net_message);
|
||||
channel = MSG_ReadByte (net_message);
|
||||
} else {
|
||||
channel = (uint16_t) MSG_ReadShort (net_message);
|
||||
channel = MSG_ReadShort (net_message);
|
||||
ent = channel >> 3;
|
||||
channel &= 7;
|
||||
}
|
||||
|
||||
if (field_mask & SND_LARGESOUND)
|
||||
sound_num = (uint16_t) MSG_ReadShort (net_message);
|
||||
sound_num = MSG_ReadShort (net_message);
|
||||
else
|
||||
sound_num = MSG_ReadByte (net_message);
|
||||
|
||||
|
@ -688,7 +688,7 @@ CL_ParseClientdata (void)
|
|||
int i, j;
|
||||
int bits;
|
||||
|
||||
bits = (uint16_t) MSG_ReadShort (net_message);
|
||||
bits = MSG_ReadShort (net_message);
|
||||
if (bits & SU_EXTEND1)
|
||||
bits |= MSG_ReadByte (net_message) << 16;
|
||||
if (bits & SU_EXTEND2)
|
||||
|
@ -1006,7 +1006,7 @@ CL_ParseServerMessage (void)
|
|||
if (i >= cl.maxclients)
|
||||
Host_Error ("CL_ParseServerMessage: svc_updatefrags > "
|
||||
"MAX_SCOREBOARD");
|
||||
cl.scores[i].frags = MSG_ReadShort (net_message);
|
||||
cl.scores[i].frags = (short) MSG_ReadShort (net_message);
|
||||
break;
|
||||
|
||||
case svc_updatecolors:
|
||||
|
|
|
@ -435,9 +435,9 @@ SV_ReadClientMove (usercmd_t *move)
|
|||
VectorCopy (angle, SVvector (host_client->edict, v_angle));
|
||||
|
||||
// read movement
|
||||
move->forwardmove = MSG_ReadShort (net_message);
|
||||
move->sidemove = MSG_ReadShort (net_message);
|
||||
move->upmove = MSG_ReadShort (net_message);
|
||||
move->forwardmove = (short) MSG_ReadShort (net_message);
|
||||
move->sidemove = (short) MSG_ReadShort (net_message);
|
||||
move->upmove = (short) MSG_ReadShort (net_message);
|
||||
|
||||
// read buttons
|
||||
bits = MSG_ReadByte (net_message);
|
||||
|
|
|
@ -527,7 +527,7 @@ parse_player_delta (qmsg_t *msg, plent_state_t *from, plent_state_t *to)
|
|||
MSG_ReadDeltaUsercmd (msg, &from->cmd, &to->cmd);
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (flags & (PF_VELOCITY1 << i))
|
||||
to->velocity[i] = MSG_ReadShort (msg);
|
||||
to->velocity[i] = (short) MSG_ReadShort (msg);
|
||||
}
|
||||
if (flags & PF_MODEL)
|
||||
to->modelindex = MSG_ReadByte (msg);
|
||||
|
|
|
@ -181,7 +181,7 @@ FlushEntityPacket (void)
|
|||
|
||||
// read it all, but ignore it
|
||||
while (1) {
|
||||
word = (unsigned short) MSG_ReadShort (net_message);
|
||||
word = MSG_ReadShort (net_message);
|
||||
if (net_message->badread) { // something didn't parse right...
|
||||
Host_Error ("msg_badread in packetentities");
|
||||
return;
|
||||
|
@ -238,7 +238,7 @@ CL_ParsePacketEntities (qboolean delta)
|
|||
newp->num_entities = 0;
|
||||
|
||||
while (1) {
|
||||
word = (unsigned short) MSG_ReadShort (net_message);
|
||||
word = MSG_ReadShort (net_message);
|
||||
if (net_message->badread) { // something didn't parse right...
|
||||
Host_Error ("msg_badread in packetentities");
|
||||
return;
|
||||
|
@ -436,7 +436,7 @@ CL_ParsePlayerinfo (void)
|
|||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (flags & (PF_VELOCITY1 << i))
|
||||
state->pls.velocity[i] = MSG_ReadShort (net_message);
|
||||
state->pls.velocity[i] = (short) MSG_ReadShort (net_message);
|
||||
else
|
||||
state->pls.velocity[i] = 0;
|
||||
}
|
||||
|
|
|
@ -1412,7 +1412,7 @@ CL_ParseServerMessage (void)
|
|||
if (i >= MAX_CLIENTS)
|
||||
Host_Error ("CL_ParseServerMessage: svc_updatefrags > "
|
||||
"MAX_SCOREBOARD");
|
||||
cl.players[i].frags = MSG_ReadShort (net_message);
|
||||
cl.players[i].frags = (short) MSG_ReadShort (net_message);
|
||||
break;
|
||||
|
||||
case svc_updateping:
|
||||
|
|
|
@ -470,7 +470,8 @@ Parse_Server_Packet (int has_sequence)
|
|||
break;
|
||||
case svc_updatefrags:
|
||||
Net_LogPrintf ("player: %d ", MSG_ReadByte (&packet));
|
||||
Net_LogPrintf ("frags: %d", MSG_ReadShort (&packet));
|
||||
Net_LogPrintf ("frags: %d",
|
||||
(short) MSG_ReadShort (&packet));
|
||||
break;
|
||||
case svc_clientdata:
|
||||
Net_LogPrintf ("**QW OBSOLETE**");
|
||||
|
@ -538,8 +539,8 @@ Parse_Server_Packet (int has_sequence)
|
|||
case 5:
|
||||
case 6:
|
||||
case 9:
|
||||
Net_LogPrintf (" created by %d", MSG_ReadShort
|
||||
(&packet));
|
||||
Net_LogPrintf (" created by %d",
|
||||
MSG_ReadShort (&packet));
|
||||
Net_LogPrintf (" origin:");
|
||||
for (i = 0; i < 3; i++)
|
||||
Net_LogPrintf ("%c%f", i ? ',' : ' ',
|
||||
|
@ -663,14 +664,14 @@ Parse_Server_Packet (int has_sequence)
|
|||
Net_LogPrintf (" Roll: %f", MSG_ReadAngle16
|
||||
(&packet));
|
||||
if (mask2 & 0x04)
|
||||
Net_LogPrintf (" Speed1: %d", MSG_ReadShort
|
||||
(&packet));
|
||||
Net_LogPrintf (" Speed1: %d",
|
||||
MSG_ReadShort (&packet));
|
||||
if (mask2 & 0x08)
|
||||
Net_LogPrintf (" Speed2: %d", MSG_ReadShort
|
||||
(&packet));
|
||||
Net_LogPrintf (" Speed2: %d",
|
||||
MSG_ReadShort (&packet));
|
||||
if (mask2 & 0x10)
|
||||
Net_LogPrintf (" Speed3: %d", MSG_ReadShort
|
||||
(&packet));
|
||||
Net_LogPrintf (" Speed3: %d",
|
||||
MSG_ReadShort (&packet));
|
||||
if (mask2 & 0x20)
|
||||
Net_LogPrintf (" Flag: %d", MSG_ReadByte
|
||||
(&packet));
|
||||
|
@ -782,7 +783,7 @@ Parse_Server_Packet (int has_sequence)
|
|||
case svc_packetentities:
|
||||
packetentities:
|
||||
while (1) {
|
||||
mask1 = (unsigned short) MSG_ReadShort (&packet);
|
||||
mask1 = MSG_ReadShort (&packet);
|
||||
if (packet.badread) {
|
||||
Net_LogPrintf ("Badread\n");
|
||||
return;
|
||||
|
@ -897,14 +898,14 @@ Parse_Client_Packet (int has_sequence)
|
|||
Net_LogPrintf (" Roll: %f", MSG_ReadAngle16
|
||||
(&packet));
|
||||
if (mask & 0x04)
|
||||
Net_LogPrintf (" Fwd: %d", MSG_ReadShort
|
||||
(&packet));
|
||||
Net_LogPrintf (" Fwd: %d",
|
||||
MSG_ReadShort (&packet));
|
||||
if (mask & 0x08)
|
||||
Net_LogPrintf (" Right: %d", MSG_ReadShort
|
||||
(&packet));
|
||||
Net_LogPrintf (" Right: %d",
|
||||
MSG_ReadShort (&packet));
|
||||
if (mask & 0x10)
|
||||
Net_LogPrintf (" Up: %d", MSG_ReadShort
|
||||
(&packet));
|
||||
Net_LogPrintf (" Up: %d",
|
||||
MSG_ReadShort (&packet));
|
||||
if (mask & 0x20)
|
||||
Net_LogPrintf (" Flags: %d", MSG_ReadByte
|
||||
(&packet));
|
||||
|
|
Loading…
Reference in a new issue