protocol: extend entity_xstate_t.origin to floats

This commit is contained in:
Denis Pauk 2024-12-31 01:23:37 +02:00
parent 13bd293c17
commit d6da3a5362
9 changed files with 65 additions and 35 deletions

View file

@ -160,6 +160,7 @@ Goals, fully finished goals could be checked in [here](CHANGELOG):
* [ ] Support textures/*/*_glow.png load from ReRelease,
* [ ] Support tactile/*/*.bnvib/.wav feedback load from ReRelease,
* [ ] Fix physics with incorrect floor height in psx/base0.bsp,
* [ ] Make pmove_state_t.origin 29.3 (PS_M_ORIGIN),
* [ ] Fix statusbar for DoD `roarke`,
* [ ] Group `it_pic` images in vulkan render,
* [ ] Rearange surfaces in vulkan render before render,

View file

@ -295,17 +295,17 @@ CL_ParseDelta(const entity_xstate_t *from, entity_xstate_t *to, int number, int
if (bits & U_ORIGIN1)
{
to->origin[0] = MSG_ReadCoord(&net_message);
to->origin[0] = MSG_ReadCoord(&net_message, cls.serverProtocol);
}
if (bits & U_ORIGIN2)
{
to->origin[1] = MSG_ReadCoord(&net_message);
to->origin[1] = MSG_ReadCoord(&net_message, cls.serverProtocol);
}
if (bits & U_ORIGIN3)
{
to->origin[2] = MSG_ReadCoord(&net_message);
to->origin[2] = MSG_ReadCoord(&net_message, cls.serverProtocol);
}
if (bits & U_ANGLE1)
@ -325,7 +325,7 @@ CL_ParseDelta(const entity_xstate_t *from, entity_xstate_t *to, int number, int
if (bits & U_OLDORIGIN)
{
MSG_ReadPos(&net_message, to->old_origin);
MSG_ReadPosExt(&net_message, to->old_origin, cls.serverProtocol);
}
if (bits & U_SOUND)
@ -1361,7 +1361,7 @@ CL_ParseStartSoundPacket(void)
if (flags & SND_POS)
{
/* positioned in space */
MSG_ReadPos(&net_message, pos_v);
MSG_ReadPosExt(&net_message, pos_v, cls.serverProtocol);
pos = pos_v;
}

View file

@ -1177,9 +1177,9 @@ SCR_ExecuteLayoutString(char *s)
clientinfo_t *ci;
token = COM_Parse(&s);
x = viddef.width / 2 - scale * 160 + scale*(int)strtol(token, (char **)NULL, 10);
x = viddef.width / 2 - scale * 160 + scale * (int)strtol(token, (char **)NULL, 10);
token = COM_Parse(&s);
y = viddef.height / 2 - scale * 120 + scale*(int)strtol(token, (char **)NULL, 10);
y = viddef.height / 2 - scale * 120 + scale * (int)strtol(token, (char **)NULL, 10);
SCR_AddDirtyPoint(x, y);
SCR_AddDirtyPoint(x + scale * 159, y + scale * 31);

View file

@ -525,7 +525,7 @@ V_Render3dCrosshair(void)
if(crosshair_3d->value || crosshair_3d_glow->value){
VectorMA(cl.refdef.vieworg,8192,cl.v_forward,end);
VectorMA(cl.refdef.vieworg, 8192, cl.v_forward,end);
crosshair_trace = CL_PMTrace(cl.refdef.vieworg, vec3_origin, vec3_origin, end);
if(crosshair_3d_glow->value){

View file

@ -112,8 +112,9 @@ void MSG_WriteShort(sizebuf_t *sb, int c);
void MSG_WriteLong(sizebuf_t *sb, int c);
void MSG_WriteFloat(sizebuf_t *sb, float f);
void MSG_WriteString(sizebuf_t *sb, const char *s);
void MSG_WriteCoord(sizebuf_t *sb, float f);
void MSG_WritePos(sizebuf_t *sb, vec3_t pos);
void MSG_WriteCoord(sizebuf_t *sb, float f, int protocol);
void MSG_WritePosExt(sizebuf_t *sb, const vec3_t pos, int protocol);
void MSG_WritePos(sizebuf_t *sb, const vec3_t pos);
void MSG_WriteAngle(sizebuf_t *sb, float f);
void MSG_WriteAngle16(sizebuf_t *sb, float f);
void MSG_WriteDeltaUsercmd(sizebuf_t *sb, struct usercmd_s *from,
@ -121,7 +122,7 @@ void MSG_WriteDeltaUsercmd(sizebuf_t *sb, struct usercmd_s *from,
void MSG_WriteDeltaEntity(const struct entity_xstate_s *from,
const struct entity_xstate_s *to, sizebuf_t *msg,
qboolean force, qboolean newentity, int protocol);
void MSG_WriteDir(sizebuf_t *sb, vec3_t vector);
void MSG_WriteDir(sizebuf_t *sb, const vec3_t vector);
void MSG_BeginReading(sizebuf_t *sb);
@ -133,7 +134,8 @@ float MSG_ReadFloat(sizebuf_t *sb);
char *MSG_ReadString(sizebuf_t *sb);
char *MSG_ReadStringLine(sizebuf_t *sb);
float MSG_ReadCoord(sizebuf_t *sb);
float MSG_ReadCoord(sizebuf_t *sb, int protocol);
void MSG_ReadPosExt(sizebuf_t *sb, vec3_t pos, int protocol);
void MSG_ReadPos(sizebuf_t *sb, vec3_t pos);
float MSG_ReadAngle(sizebuf_t *sb);
float MSG_ReadAngle16(sizebuf_t *sb);

View file

@ -261,13 +261,28 @@ MSG_WriteString(sizebuf_t *sb, const char *s)
}
void
MSG_WriteCoord(sizebuf_t *sb, float f)
MSG_WriteCoord(sizebuf_t *sb, float f, int protocol)
{
MSG_WriteShort(sb, (int)(f * 8));
if (IS_QII97_PROTOCOL(protocol))
{
MSG_WriteShort(sb, (int)(f * 8));
}
else
{
MSG_WriteFloat(sb, f);
}
}
void
MSG_WritePos(sizebuf_t *sb, vec3_t pos)
MSG_WritePosExt(sizebuf_t *sb, const vec3_t pos, int protocol)
{
MSG_WriteCoord(sb, pos[0], protocol);
MSG_WriteCoord(sb, pos[1], protocol);
MSG_WriteCoord(sb, pos[2], protocol);
}
void
MSG_WritePos(sizebuf_t *sb, const vec3_t pos)
{
MSG_WriteShort(sb, (int)(pos[0] * 8));
MSG_WriteShort(sb, (int)(pos[1] * 8));
@ -381,7 +396,7 @@ MSG_WriteDeltaUsercmd(sizebuf_t *buf, usercmd_t *from, usercmd_t *cmd)
}
void
MSG_WriteDir(sizebuf_t *sb, vec3_t dir)
MSG_WriteDir(sizebuf_t *sb, const vec3_t dir)
{
int i, best;
float d, bestd;
@ -811,17 +826,17 @@ MSG_WriteDeltaEntity(const entity_xstate_t *from,
if (bits & U_ORIGIN1)
{
MSG_WriteCoord(msg, to->origin[0]);
MSG_WriteCoord(msg, to->origin[0], protocol);
}
if (bits & U_ORIGIN2)
{
MSG_WriteCoord(msg, to->origin[1]);
MSG_WriteCoord(msg, to->origin[1], protocol);
}
if (bits & U_ORIGIN3)
{
MSG_WriteCoord(msg, to->origin[2]);
MSG_WriteCoord(msg, to->origin[2], protocol);
}
if (bits & U_ANGLE1)
@ -841,9 +856,7 @@ MSG_WriteDeltaEntity(const entity_xstate_t *from,
if (bits & U_OLDORIGIN)
{
MSG_WriteCoord(msg, to->old_origin[0]);
MSG_WriteCoord(msg, to->old_origin[1]);
MSG_WriteCoord(msg, to->old_origin[2]);
MSG_WritePosExt(msg, to->old_origin, protocol);
}
if (bits & U_SOUND)
@ -1037,9 +1050,24 @@ MSG_ReadStringLine(sizebuf_t *msg_read)
}
float
MSG_ReadCoord(sizebuf_t *msg_read)
MSG_ReadCoord(sizebuf_t *msg_read, int protocol)
{
return MSG_ReadShort(msg_read) * (0.125f);
if (IS_QII97_PROTOCOL(protocol))
{
return MSG_ReadShort(msg_read) * (0.125f);
}
else
{
return MSG_ReadFloat(msg_read);
}
}
void
MSG_ReadPosExt(sizebuf_t *msg_read, vec3_t pos, int protocol)
{
pos[0] = MSG_ReadCoord(msg_read, protocol);
pos[1] = MSG_ReadCoord(msg_read, protocol);
pos[2] = MSG_ReadCoord(msg_read, protocol);
}
void

View file

@ -179,8 +179,8 @@ typedef struct
void (*WriteLong)(int c);
void (*WriteFloat)(float f);
void (*WriteString)(const char *s);
void (*WritePosition)(vec3_t pos); /* some fractional bits */
void (*WriteDir)(vec3_t pos); /* single byte encoded, very coarse */
void (*WritePosition)(const vec3_t pos); /* some fractional bits */
void (*WriteDir)(const vec3_t pos); /* single byte encoded, very coarse */
void (*WriteAngle)(float f);
/* managed memory allocation */

View file

@ -276,13 +276,13 @@ PF_WriteString(const char *s)
}
static void
PF_WritePos(vec3_t pos)
PF_WritePos(const vec3_t pos)
{
MSG_WritePos(&sv.multicast, pos);
}
static void
PF_WriteDir(vec3_t dir)
PF_WriteDir(const vec3_t dir)
{
MSG_WriteDir(&sv.multicast, dir);
}

View file

@ -283,12 +283,11 @@ void
SV_StartSound(vec3_t origin, edict_t *entity, int channel, int soundindex,
float volume, float attenuation, float timeofs)
{
int sendchan;
int flags;
int i;
int ent;
vec3_t origin_v;
int sendchan, flags, i, ent, protocol;
qboolean use_phs;
vec3_t origin_v;
protocol = sv_client ? sv_client->protocol : PROTOCOL_VERSION;
if ((volume < 0) || (volume > 1.0))
{
@ -370,7 +369,7 @@ SV_StartSound(vec3_t origin, edict_t *entity, int channel, int soundindex,
MSG_WriteByte(&sv.multicast, svc_sound);
MSG_WriteByte(&sv.multicast, flags);
if (sv_client && IS_QII97_PROTOCOL(sv_client->protocol))
if (IS_QII97_PROTOCOL(protocol))
{
MSG_WriteByte(&sv.multicast, soundindex);
}
@ -401,7 +400,7 @@ SV_StartSound(vec3_t origin, edict_t *entity, int channel, int soundindex,
if (flags & SND_POS)
{
MSG_WritePos(&sv.multicast, origin);
MSG_WritePosExt(&sv.multicast, origin, protocol);
}
/* if the sound doesn't attenuate,send it to everyone