Skip to content

Commit

Permalink
protocol: send scale values
Browse files Browse the repository at this point in the history
  • Loading branch information
0lvin committed Nov 23, 2024
1 parent f520148 commit 319c3a8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/client/cl_entities.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ CL_AddPacketEntities(frame_t *frame)
ent.skin = NULL;
ent.model = cl.model_draw[s1->modelindex];
}

/* store scale */
VectorCopy(s1->scale, ent.scale);
}

/* only used for black hole model right now */
Expand Down
21 changes: 21 additions & 0 deletions src/client/cl_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits)
}
}

if (cls.serverProtocol != PROTOCOL_VERSION)
{
int i;

/* Always set scale to 1.0f for old clients */
for (i = 0; i < 3; i++)
{
to->scale[i] = 1.0f;
}
}

if (IS_QII97_PROTOCOL(cls.serverProtocol))
{
if (bits & U_MODEL)
Expand Down Expand Up @@ -224,6 +235,16 @@ CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits)
if ((bits & U_SKIN8) && (bits & U_SKIN16))
{
to->skinnum = MSG_ReadLong(&net_message);
/* Additional scale with skinnum */
if (cls.serverProtocol == PROTOCOL_VERSION)
{
int i;

for (i = 0; i < 3; i++)
{
to->scale[i] = MSG_ReadFloat(&net_message);
}
}
}
else if (bits & U_SKIN8)
{
Expand Down
20 changes: 20 additions & 0 deletions src/common/movemsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,15 @@ MSG_WriteDeltaEntity(entity_state_t *from,
}
}

/* Scale with skins if force or different */
if ((protocol == PROTOCOL_VERSION) &&
((to->scale[0] != from->scale[0]) ||
(to->scale[1] != from->scale[1]) ||
(to->scale[2] != from->scale[2])))
{
bits |= (U_SKIN8 | U_SKIN16);
}

if (to->frame != from->frame)
{
if (to->frame < 256)
Expand Down Expand Up @@ -723,6 +732,17 @@ MSG_WriteDeltaEntity(entity_state_t *from,
if ((bits & U_SKIN8) && (bits & U_SKIN16)) /*used for laser colors */
{
MSG_WriteLong(msg, to->skinnum);

/* Send scale */
if (protocol == PROTOCOL_VERSION)
{
int i;

for (i = 0; i < 3; i++)
{
MSG_WriteFloat(msg, to->scale[i]);
}
}
}

else if (bits & U_SKIN8)
Expand Down

0 comments on commit 319c3a8

Please sign in to comment.