More nail fixes, more MSG_* cleanups.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2002-06-29 03:25:25 +00:00
parent 66aa36b73f
commit 2a3c31edbe
1 changed files with 30 additions and 82 deletions

View File

@ -199,12 +199,9 @@ NET_SVC_Stufftext_Parse (net_svc_stufftext_t *block, msg_t *msg)
net_status_t net_status_t
NET_SVC_Damage_Emit (net_svc_damage_t *block, sizebuf_t *buf) NET_SVC_Damage_Emit (net_svc_damage_t *block, sizebuf_t *buf)
{ {
int i;
MSG_WriteByte (buf, block->armor); MSG_WriteByte (buf, block->armor);
MSG_WriteByte (buf, block->blood); MSG_WriteByte (buf, block->blood);
for (i = 0; i < 3; i++) MSG_WriteCoordV (buf, block->from);
MSG_WriteCoord (buf, block->from[i]);
return buf->overflowed; return buf->overflowed;
} }
@ -216,8 +213,7 @@ NET_SVC_Damage_Parse (net_svc_damage_t *block, msg_t *msg)
block->armor = MSG_ReadByte (msg); block->armor = MSG_ReadByte (msg);
block->blood = MSG_ReadByte (msg); block->blood = MSG_ReadByte (msg);
for (i = 0; i < 3; i++) block->from = MSG_ReadCoordV (msg);
block->from[i] = MSG_ReadCoord (msg);
return msg->badread; return msg->badread;
} }
@ -276,10 +272,7 @@ NET_SVC_ServerData_Parse (net_svc_serverdata_t *block, msg_t *msg)
net_status_t net_status_t
NET_SVC_SetAngle_Emit (net_svc_setangle_t *block, sizebuf_t *buf) NET_SVC_SetAngle_Emit (net_svc_setangle_t *block, sizebuf_t *buf)
{ {
int i; MSG_WriteAngleV (buf, block->angles);
for (i = 0; i < 3; i++)
MSG_WriteAngle (buf, block->angles[i]);
return buf->overflowed; return buf->overflowed;
} }
@ -287,10 +280,7 @@ NET_SVC_SetAngle_Emit (net_svc_setangle_t *block, sizebuf_t *buf)
net_status_t net_status_t
NET_SVC_SetAngle_Parse (net_svc_setangle_t *block, msg_t *msg) NET_SVC_SetAngle_Parse (net_svc_setangle_t *block, msg_t *msg)
{ {
int i; block->angles = MSG_ReadAngleV (msg);
for (i = 0; i < 3; i++)
block->angles[i] = MSG_ReadAngle (msg);
return msg->badread; return msg->badread;
} }
@ -465,10 +455,7 @@ NET_SVC_SpawnBaseline_Emit (net_svc_spawnbaseline_t *block, sizebuf_t *buf)
MSG_WriteByte (buf, block->colormap); MSG_WriteByte (buf, block->colormap);
MSG_WriteByte (buf, block->skinnum); MSG_WriteByte (buf, block->skinnum);
for (i = 0; i < 3; i++) { MSG_WriteCoordAngleV (buf, block->origin, block->angles);
MSG_WriteCoord (buf, block->origin[i]);
MSG_WriteAngle (buf, block->angles[i]);
}
return buf->overflowed; return buf->overflowed;
} }
@ -476,19 +463,13 @@ NET_SVC_SpawnBaseline_Emit (net_svc_spawnbaseline_t *block, sizebuf_t *buf)
net_status_t net_status_t
NET_SVC_SpawnBaseline_Parse (net_svc_spawnbaseline_t *block, msg_t *msg) NET_SVC_SpawnBaseline_Parse (net_svc_spawnbaseline_t *block, msg_t *msg)
{ {
int i;
block->num = MSG_ReadShort (msg); block->num = MSG_ReadShort (msg);
block->modelindex = MSG_ReadByte (msg); block->modelindex = MSG_ReadByte (msg);
block->frame = MSG_ReadByte (msg); block->frame = MSG_ReadByte (msg);
block->colormap = MSG_ReadByte (msg); block->colormap = MSG_ReadByte (msg);
block->skinnum = MSG_ReadByte (msg); block->skinnum = MSG_ReadByte (msg);
// these are interlaced? bad drugs... MSG_ReadCoordAngleV (msg, block->origin, block->angles);
for (i = 0; i < 3; i ++) {
block->origin[i] = MSG_ReadCoord (msg);
block->angles[i] = MSG_ReadAngle (msg);
}
return msg->badread; return msg->badread;
} }
@ -502,10 +483,7 @@ NET_SVC_SpawnStatic_Emit (net_svc_spawnstatic_t *block, sizebuf_t *buf)
MSG_WriteByte (buf, block->frame); MSG_WriteByte (buf, block->frame);
MSG_WriteByte (buf, block->colormap); MSG_WriteByte (buf, block->colormap);
MSG_WriteByte (buf, block->skinnum); MSG_WriteByte (buf, block->skinnum);
for (i = 0; i < 3; i++) { MSG_WriteCoordAngleV (buf, block->origin, block->angles);
MSG_WriteCoord (buf, block->origin[i]);
MSG_WriteAngle (buf, block->angles[i]);
}
return buf->overflowed; return buf->overflowed;
} }
@ -520,11 +498,7 @@ NET_SVC_SpawnStatic_Parse (net_svc_spawnstatic_t *block, msg_t *msg)
block->colormap = MSG_ReadByte (msg); block->colormap = MSG_ReadByte (msg);
block->skinnum = MSG_ReadByte (msg); block->skinnum = MSG_ReadByte (msg);
// these are interlaced? bad drugs... MSG_ReadCoordAngleV (msg, block->origin, block->angles);
for (i = 0; i < 3; i++) {
block->origin[i] = MSG_ReadCoord (msg);
block->angles[i] = MSG_ReadAngle (msg);
}
return msg->badread; return msg->badread;
} }
@ -545,8 +519,7 @@ NET_SVC_TempEntity_Emit (net_svc_tempentity_t *block, sizebuf_t *buf)
case TE_LAVASPLASH: case TE_LAVASPLASH:
case TE_TELEPORT: case TE_TELEPORT:
case TE_LIGHTNINGBLOOD: case TE_LIGHTNINGBLOOD:
for (i = 0; i < 3; i++) MSG_WriteCoordV (buf, block->position);
MSG_WriteCoord (buf, block->position[i]);
break; break;
case TE_LIGHTNING1: case TE_LIGHTNING1:
case TE_LIGHTNING2: case TE_LIGHTNING2:
@ -555,20 +528,17 @@ NET_SVC_TempEntity_Emit (net_svc_tempentity_t *block, sizebuf_t *buf)
MSG_WriteShort (buf, block->beamentity); MSG_WriteShort (buf, block->beamentity);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
MSG_WriteShort (buf, block->position[i]); MSG_WriteShort (buf, block->position[i]);
for (i = 0; i < 3; i++) MSG_WriteCoordV (buf, block->beamend);
MSG_WriteCoord (buf, block->beamend[i]);
break; break;
case TE_EXPLOSION2: case TE_EXPLOSION2:
for (i = 0; i < 3; i++) MSG_WriteCoordV (buf, block->position);
MSG_WriteCoord (buf, block->position[i]);
MSG_WriteByte (buf, block->colorstart); MSG_WriteByte (buf, block->colorstart);
MSG_WriteByte (buf, block->colorlength); MSG_WriteByte (buf, block->colorlength);
break; break;
case TE_GUNSHOT: case TE_GUNSHOT:
case TE_BLOOD: case TE_BLOOD:
MSG_WriteByte (buf, block->gunshotcount); MSG_WriteByte (buf, block->gunshotcount);
for (i = 0; i < 3; i++) MSG_WriteCoordV (buf, block->position);
MSG_WriteCoord (buf, block->position[i]);
break; break;
default: default:
return NET_ERROR; return NET_ERROR;
@ -593,30 +563,25 @@ NET_SVC_TempEntity_Parse (net_svc_tempentity_t *block, msg_t *msg)
case TE_LAVASPLASH: case TE_LAVASPLASH:
case TE_TELEPORT: case TE_TELEPORT:
case TE_LIGHTNINGBLOOD: case TE_LIGHTNINGBLOOD:
for (i = 0; i < 3; i++) MSG_ReadCoordV (msg, block->position);
block->position[i] = MSG_ReadCoord (msg);
break; break;
case TE_LIGHTNING1: case TE_LIGHTNING1:
case TE_LIGHTNING2: case TE_LIGHTNING2:
case TE_LIGHTNING3: case TE_LIGHTNING3:
case TE_BEAM: case TE_BEAM:
block->beamentity = MSG_ReadShort (msg); block->beamentity = MSG_ReadShort (msg);
for (i = 0; i < 3; i++) MSG_ReadCoordV (msg, block->position);
block->position[i] = MSG_ReadCoord (msg); MSG_ReadCoordV (msg, block->beamend);
for (i = 0; i < 3; i++)
block->beamend[i] = MSG_ReadCoord (msg);
break; break;
case TE_EXPLOSION2: case TE_EXPLOSION2:
for (i = 0; i < 3; i++) MSG_ReadCoordV (msg, block->position);
block->position[i] = MSG_ReadCoord (msg);
block->colorstart = MSG_ReadByte (msg); block->colorstart = MSG_ReadByte (msg);
block->colorlength = MSG_ReadByte (msg); block->colorlength = MSG_ReadByte (msg);
break; break;
case TE_GUNSHOT: case TE_GUNSHOT:
case TE_BLOOD: case TE_BLOOD:
block->gunshotcount = MSG_ReadByte (msg); block->gunshotcount = MSG_ReadByte (msg);
for (i = 0; i < 3; i++) MSG_ReadCoordV (msg, block->position);
block->position[i] = MSG_ReadCoord (msg);
break; break;
default: default:
return NET_ERROR; return NET_ERROR;
@ -653,10 +618,7 @@ net_status_t
NET_SVC_SpawnStaticSound_Emit (net_svc_spawnstaticsound_t *block, NET_SVC_SpawnStaticSound_Emit (net_svc_spawnstaticsound_t *block,
sizebuf_t *buf) sizebuf_t *buf)
{ {
int i; MSG_WriteCoordV (buf, block->position);
for (i = 0; i < 3; i++)
MSG_WriteCoord (buf, block->position[i]);
MSG_WriteByte (buf, block->sound_num); MSG_WriteByte (buf, block->sound_num);
MSG_WriteByte (buf, block->volume); MSG_WriteByte (buf, block->volume);
MSG_WriteByte (buf, block->attenuation); MSG_WriteByte (buf, block->attenuation);
@ -668,10 +630,7 @@ net_status_t
NET_SVC_SpawnStaticSound_Parse (net_svc_spawnstaticsound_t *block, NET_SVC_SpawnStaticSound_Parse (net_svc_spawnstaticsound_t *block,
msg_t *msg) msg_t *msg)
{ {
int i; MSG_ReadCoordV (msg, block->position);
for (i = 0; i < 3; i++)
block->position[i] = MSG_ReadCoord (msg);
block->sound_num = MSG_ReadByte (msg); block->sound_num = MSG_ReadByte (msg);
block->volume = MSG_ReadByte (msg); block->volume = MSG_ReadByte (msg);
block->attenuation = MSG_ReadByte (msg); block->attenuation = MSG_ReadByte (msg);
@ -734,12 +693,8 @@ NET_SVC_CDTrack_Parse (net_svc_cdtrack_t *block, msg_t *msg)
net_status_t net_status_t
NET_SVC_Intermission_Emit (net_svc_intermission_t *block, sizebuf_t *buf) NET_SVC_Intermission_Emit (net_svc_intermission_t *block, sizebuf_t *buf)
{ {
int i; MSG_WriteCoordV (buf, block->origin);
MSG_WriteAngleV (buf, block->angles);
for (i = 0; i < 3; i++)
MSG_WriteCoord (buf, block->origin[i]);
for (i = 0; i < 3; i++)
MSG_WriteAngle (buf, block->angles[i]);
return buf->overflowed; return buf->overflowed;
} }
@ -747,12 +702,8 @@ NET_SVC_Intermission_Emit (net_svc_intermission_t *block, sizebuf_t *buf)
net_status_t net_status_t
NET_SVC_Intermission_Parse (net_svc_intermission_t *block, msg_t *msg) NET_SVC_Intermission_Parse (net_svc_intermission_t *block, msg_t *msg)
{ {
int i; MSG_ReadCoordV (msg, block->origin);
MSG_ReadAngleV (msg, block->angles);
for (i = 0; i < 3; i++)
block->origin[i] = MSG_ReadCoord (msg);
for (i = 0; i < 3; i++)
block->angles[i] = MSG_ReadAngle (msg);
return msg->badread; return msg->badread;
} }
@ -930,8 +881,7 @@ NET_SVC_Playerinfo_Emit (net_svc_playerinfo_t *block, sizebuf_t *buf)
MSG_WriteByte (buf, block->playernum); MSG_WriteByte (buf, block->playernum);
MSG_WriteShort (buf, block->flags); MSG_WriteShort (buf, block->flags);
for (i = 0; i < 3; i++) MSG_WriteCoordV (buf, block->origin);
MSG_WriteCoord (buf, block->origin[i]);
MSG_WriteByte (buf, block->frame); MSG_WriteByte (buf, block->frame);
if (block->flags & PF_MSEC) if (block->flags & PF_MSEC)
@ -960,8 +910,7 @@ NET_SVC_Playerinfo_Parse (net_svc_playerinfo_t *block, msg_t *msg)
block->playernum = MSG_ReadByte (msg); block->playernum = MSG_ReadByte (msg);
block->flags = MSG_ReadShort (msg); block->flags = MSG_ReadShort (msg);
for (i = 0; i < 3; i++) MSG_ReadCoordV (msg, block->origin);
block->origin[i] = MSG_ReadCoord (msg);
block->frame = MSG_ReadByte (msg); block->frame = MSG_ReadByte (msg);
if (block->flags & PF_MSEC) if (block->flags & PF_MSEC)
@ -1016,11 +965,11 @@ NET_SVC_Nails_Emit (net_svc_nails_t *block, sizebuf_t *buf)
MSG_WriteByte (buf, block->numnails); MSG_WriteByte (buf, block->numnails);
for (i = 0; i < block->numnails; i++) { for (i = 0; i < block->numnails; i++) {
x = (int) (block->nails[i].origin[0] + 4096) >> 1; x = ((int) (block->nails[i].origin[0] + 4096 + 1) >> 1) & 4095;
y = (int) (block->nails[i].origin[1] + 4096) >> 1; y = ((int) (block->nails[i].origin[1] + 4096 + 1) >> 1) & 4095;
z = (int) (block->nails[i].origin[2] + 4096) >> 1; z = ((int) (block->nails[i].origin[2] + 4096 + 1) >> 1) & 4095;
p = (int) (16 * block->nails[i].angles[0] / 360) & 15; p = (int) (block->nails[i].angles[0] * (16.0 / 360.0)) & 15;
yaw = (int) (256 * block->nails[i].angles[1] / 360) & 255; yaw = (int) (block->nails[i].angles[1] * (256.0 / 360.0)) & 255;
bits[0] = x; bits[0] = x;
bits[1] = (x >> 8) | (y << 4); bits[1] = (x >> 8) | (y << 4);
@ -1433,4 +1382,3 @@ NET_SVC_SetPause_Parse (net_svc_setpause_t *block, msg_t *msg)
return msg->badread; return msg->badread;
} }