client: add custom protocol with short model index

This commit is contained in:
Denis Pauk 2024-02-27 00:37:26 +02:00
parent a77e52ad97
commit 28668972ff
7 changed files with 106 additions and 40 deletions

View file

@ -247,7 +247,7 @@ CL_Record_f(void)
MSG_WriteByte(&buf, svc_spawnbaseline);
MSG_WriteDeltaEntity(&nullstate, &cl_entities[i].baseline,
&buf, true, true);
&buf, true, true, PROTOCOL_VERSION);
}
MSG_WriteByte(&buf, svc_stufftext);

View file

@ -143,24 +143,51 @@ CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits)
VectorCopy(from->origin, to->old_origin);
to->number = number;
if (bits & U_MODEL)
if ((cls.serverProtocol == PROTOCOL_RELEASE_VERSION) ||
(cls.serverProtocol == PROTOCOL_DEMO_VERSION) ||
(cls.serverProtocol == PROTOCOL_RR97_VERSION))
{
to->modelindex = MSG_ReadByte(&net_message);
}
if (bits & U_MODEL)
{
to->modelindex = MSG_ReadByte(&net_message);
}
if (bits & U_MODEL2)
{
to->modelindex2 = MSG_ReadByte(&net_message);
}
if (bits & U_MODEL2)
{
to->modelindex2 = MSG_ReadByte(&net_message);
}
if (bits & U_MODEL3)
{
to->modelindex3 = MSG_ReadByte(&net_message);
}
if (bits & U_MODEL3)
{
to->modelindex3 = MSG_ReadByte(&net_message);
}
if (bits & U_MODEL4)
if (bits & U_MODEL4)
{
to->modelindex4 = MSG_ReadByte(&net_message);
}
}
else
{
to->modelindex4 = MSG_ReadByte(&net_message);
if (bits & U_MODEL)
{
to->modelindex = MSG_ReadShort(&net_message);
}
if (bits & U_MODEL2)
{
to->modelindex2 = MSG_ReadShort(&net_message);
}
if (bits & U_MODEL3)
{
to->modelindex3 = MSG_ReadShort(&net_message);
}
if (bits & U_MODEL4)
{
to->modelindex4 = MSG_ReadShort(&net_message);
}
}
if (bits & U_FRAME8)
@ -689,7 +716,7 @@ CL_ParseFrame(void)
cl.frame.servertime = cl.frame.serverframe * 100;
/* BIG HACK to let old demos continue to work */
if (cls.serverProtocol != 26)
if (cls.serverProtocol != PROTOCOL_RELEASE_VERSION)
{
cl.surpressCount = MSG_ReadByte(&net_message);
}
@ -843,9 +870,10 @@ CL_ParseServerData(void)
if (Com_ServerState() && (
(i == PROTOCOL_RELEASE_VERSION) ||
(i == PROTOCOL_DEMO_VERSION) ||
(i == PROTOCOL_VERSION) ||
(i == PROTOCOL_RR97_VERSION) ||
(i == PROTOCOL_RR22_VERSION) ||
(i == PROTOCOL_RR23_VERSION)))
(i == PROTOCOL_RR23_VERSION) ||
(i == PROTOCOL_VERSION)))
{
Com_Printf("Network protocol: ");
switch (i)
@ -856,7 +884,7 @@ CL_ParseServerData(void)
case PROTOCOL_DEMO_VERSION:
Com_Printf("Quake 2 Release Demo\n");
break;
case PROTOCOL_VERSION:
case PROTOCOL_RR97_VERSION:
Com_Printf("Quake 2\n");
break;
case PROTOCOL_RR22_VERSION:
@ -865,6 +893,9 @@ CL_ParseServerData(void)
case PROTOCOL_RR23_VERSION:
Com_Printf("ReRelease Quake 2\n");
break;
case PROTOCOL_VERSION:
Com_Printf("ReRelease Quake 2 Custom version\n");
break;
default:
Com_Printf("Unknown protocol version\n");
break;

View file

@ -120,7 +120,7 @@ void MSG_WriteDeltaUsercmd(sizebuf_t *sb, struct usercmd_s *from,
struct usercmd_s *cmd);
void MSG_WriteDeltaEntity(struct entity_state_s *from,
struct entity_state_s *to, sizebuf_t *msg,
qboolean force, qboolean newentity);
qboolean force, qboolean newentity, int protocol);
void MSG_WriteDir(sizebuf_t *sb, vec3_t vector);
void MSG_BeginReading(sizebuf_t *sb);
@ -180,11 +180,13 @@ void Info_Print(char *s);
/* Quake 2 Demo */
#define PROTOCOL_DEMO_VERSION 31
/* Quake 2 Network Release */
#define PROTOCOL_VERSION 34
#define PROTOCOL_RR97_VERSION 34
/* ReRelease demo files */
#define PROTOCOL_RR22_VERSION 2022
/* ReRelease network protocol */
#define PROTOCOL_RR23_VERSION 2023
/* Quake 2 Customized Network Release */
#define PROTOCOL_VERSION 2024
/* ========================================= */

View file

@ -433,7 +433,8 @@ MSG_WriteDeltaEntity(entity_state_t *from,
entity_state_t *to,
sizebuf_t *msg,
qboolean force,
qboolean newentity)
qboolean newentity,
int protocol)
{
int bits;
@ -644,24 +645,51 @@ MSG_WriteDeltaEntity(entity_state_t *from,
MSG_WriteByte(msg, to->number);
}
if (bits & U_MODEL)
if ((protocol == PROTOCOL_RELEASE_VERSION) ||
(protocol == PROTOCOL_DEMO_VERSION) ||
(protocol == PROTOCOL_RR97_VERSION))
{
MSG_WriteByte(msg, to->modelindex);
}
if (bits & U_MODEL)
{
MSG_WriteByte(msg, to->modelindex);
}
if (bits & U_MODEL2)
{
MSG_WriteByte(msg, to->modelindex2);
}
if (bits & U_MODEL2)
{
MSG_WriteByte(msg, to->modelindex2);
}
if (bits & U_MODEL3)
{
MSG_WriteByte(msg, to->modelindex3);
}
if (bits & U_MODEL3)
{
MSG_WriteByte(msg, to->modelindex3);
}
if (bits & U_MODEL4)
if (bits & U_MODEL4)
{
MSG_WriteByte(msg, to->modelindex4);
}
}
else
{
MSG_WriteByte(msg, to->modelindex4);
if (bits & U_MODEL)
{
MSG_WriteShort(msg, to->modelindex);
}
if (bits & U_MODEL2)
{
MSG_WriteShort(msg, to->modelindex2);
}
if (bits & U_MODEL3)
{
MSG_WriteShort(msg, to->modelindex3);
}
if (bits & U_MODEL4)
{
MSG_WriteShort(msg, to->modelindex4);
}
}
if (bits & U_FRAME8)

View file

@ -144,6 +144,7 @@ typedef struct client_s
int challenge; /* challenge of this user, randomly generated */
netchan_t netchan;
int protocol;
} client_t;
typedef struct

View file

@ -37,7 +37,8 @@ static YQ2_ALIGNAS_TYPE(int32_t) byte fatpvs[65536 / 8];
* Writes a delta update of an entity_state_t list to the message.
*/
static void
SV_EmitPacketEntities(client_frame_t *from, client_frame_t *to, sizebuf_t *msg)
SV_EmitPacketEntities(client_frame_t *from, client_frame_t *to, sizebuf_t *msg,
int protocol)
{
entity_state_t *oldent, *newent;
int oldindex, newindex;
@ -98,7 +99,7 @@ SV_EmitPacketEntities(client_frame_t *from, client_frame_t *to, sizebuf_t *msg)
note that players are always 'newentities', this
updates their oldorigin always and prevents warping */
MSG_WriteDeltaEntity(oldent, newent, msg,
false, newent->number <= maxclients->value);
false, newent->number <= maxclients->value, protocol);
oldindex++;
newindex++;
continue;
@ -107,7 +108,8 @@ SV_EmitPacketEntities(client_frame_t *from, client_frame_t *to, sizebuf_t *msg)
if (newnum < oldnum)
{
/* this is a new entity, send it from the baseline */
MSG_WriteDeltaEntity(&sv.baselines[newnum], newent, msg, true, true);
MSG_WriteDeltaEntity(&sv.baselines[newnum], newent, msg,
true, true, protocol);
newindex++;
continue;
}
@ -432,7 +434,7 @@ SV_WriteFrameToClient(client_t *client, sizebuf_t *msg)
SV_WritePlayerstateToClient(oldframe, frame, msg);
/* delta encode the entities */
SV_EmitPacketEntities(oldframe, frame, msg);
SV_EmitPacketEntities(oldframe, frame, msg, client->protocol);
}
/*
@ -705,7 +707,8 @@ SV_RecordDemoMessage(void)
(ent->s.modelindex || ent->s.effects || ent->s.sound ||
ent->s.event) && !(ent->svflags & SVF_NOCLIENT))
{
MSG_WriteDeltaEntity(&nostate, &ent->s, &buf, false, true);
MSG_WriteDeltaEntity(&nostate, &ent->s, &buf,
false, true, PROTOCOL_VERSION);
}
e++;

View file

@ -75,6 +75,7 @@ SV_New_f(void)
gamedir = (char *)Cvar_VariableString("gamedir");
/* send the serverdata */
sv_client->protocol = PROTOCOL_VERSION;
MSG_WriteByte(&sv_client->netchan.message, svc_serverdata);
MSG_WriteLong(&sv_client->netchan.message, PROTOCOL_VERSION);
MSG_WriteLong(&sv_client->netchan.message, svs.spawncount);
@ -201,7 +202,7 @@ SV_Baselines_f(void)
MSG_WriteByte(&sv_client->netchan.message, svc_spawnbaseline);
MSG_WriteDeltaEntity(&nullstate, base,
&sv_client->netchan.message,
true, true);
true, true, sv_client->protocol);
}
start++;