mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-30 00:10:53 +00:00
client: add custom protocol with short model index
This commit is contained in:
parent
a77e52ad97
commit
28668972ff
7 changed files with 106 additions and 40 deletions
|
@ -247,7 +247,7 @@ CL_Record_f(void)
|
||||||
MSG_WriteByte(&buf, svc_spawnbaseline);
|
MSG_WriteByte(&buf, svc_spawnbaseline);
|
||||||
|
|
||||||
MSG_WriteDeltaEntity(&nullstate, &cl_entities[i].baseline,
|
MSG_WriteDeltaEntity(&nullstate, &cl_entities[i].baseline,
|
||||||
&buf, true, true);
|
&buf, true, true, PROTOCOL_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
MSG_WriteByte(&buf, svc_stufftext);
|
MSG_WriteByte(&buf, svc_stufftext);
|
||||||
|
|
|
@ -143,24 +143,51 @@ CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits)
|
||||||
VectorCopy(from->origin, to->old_origin);
|
VectorCopy(from->origin, to->old_origin);
|
||||||
to->number = number;
|
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)
|
if (bits & U_MODEL2)
|
||||||
{
|
{
|
||||||
to->modelindex2 = MSG_ReadByte(&net_message);
|
to->modelindex2 = MSG_ReadByte(&net_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bits & U_MODEL3)
|
if (bits & U_MODEL3)
|
||||||
{
|
{
|
||||||
to->modelindex3 = MSG_ReadByte(&net_message);
|
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)
|
if (bits & U_FRAME8)
|
||||||
|
@ -689,7 +716,7 @@ CL_ParseFrame(void)
|
||||||
cl.frame.servertime = cl.frame.serverframe * 100;
|
cl.frame.servertime = cl.frame.serverframe * 100;
|
||||||
|
|
||||||
/* BIG HACK to let old demos continue to work */
|
/* 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);
|
cl.surpressCount = MSG_ReadByte(&net_message);
|
||||||
}
|
}
|
||||||
|
@ -843,9 +870,10 @@ CL_ParseServerData(void)
|
||||||
if (Com_ServerState() && (
|
if (Com_ServerState() && (
|
||||||
(i == PROTOCOL_RELEASE_VERSION) ||
|
(i == PROTOCOL_RELEASE_VERSION) ||
|
||||||
(i == PROTOCOL_DEMO_VERSION) ||
|
(i == PROTOCOL_DEMO_VERSION) ||
|
||||||
(i == PROTOCOL_VERSION) ||
|
(i == PROTOCOL_RR97_VERSION) ||
|
||||||
(i == PROTOCOL_RR22_VERSION) ||
|
(i == PROTOCOL_RR22_VERSION) ||
|
||||||
(i == PROTOCOL_RR23_VERSION)))
|
(i == PROTOCOL_RR23_VERSION) ||
|
||||||
|
(i == PROTOCOL_VERSION)))
|
||||||
{
|
{
|
||||||
Com_Printf("Network protocol: ");
|
Com_Printf("Network protocol: ");
|
||||||
switch (i)
|
switch (i)
|
||||||
|
@ -856,7 +884,7 @@ CL_ParseServerData(void)
|
||||||
case PROTOCOL_DEMO_VERSION:
|
case PROTOCOL_DEMO_VERSION:
|
||||||
Com_Printf("Quake 2 Release Demo\n");
|
Com_Printf("Quake 2 Release Demo\n");
|
||||||
break;
|
break;
|
||||||
case PROTOCOL_VERSION:
|
case PROTOCOL_RR97_VERSION:
|
||||||
Com_Printf("Quake 2\n");
|
Com_Printf("Quake 2\n");
|
||||||
break;
|
break;
|
||||||
case PROTOCOL_RR22_VERSION:
|
case PROTOCOL_RR22_VERSION:
|
||||||
|
@ -865,6 +893,9 @@ CL_ParseServerData(void)
|
||||||
case PROTOCOL_RR23_VERSION:
|
case PROTOCOL_RR23_VERSION:
|
||||||
Com_Printf("ReRelease Quake 2\n");
|
Com_Printf("ReRelease Quake 2\n");
|
||||||
break;
|
break;
|
||||||
|
case PROTOCOL_VERSION:
|
||||||
|
Com_Printf("ReRelease Quake 2 Custom version\n");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Com_Printf("Unknown protocol version\n");
|
Com_Printf("Unknown protocol version\n");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -120,7 +120,7 @@ void MSG_WriteDeltaUsercmd(sizebuf_t *sb, struct usercmd_s *from,
|
||||||
struct usercmd_s *cmd);
|
struct usercmd_s *cmd);
|
||||||
void MSG_WriteDeltaEntity(struct entity_state_s *from,
|
void MSG_WriteDeltaEntity(struct entity_state_s *from,
|
||||||
struct entity_state_s *to, sizebuf_t *msg,
|
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_WriteDir(sizebuf_t *sb, vec3_t vector);
|
||||||
|
|
||||||
void MSG_BeginReading(sizebuf_t *sb);
|
void MSG_BeginReading(sizebuf_t *sb);
|
||||||
|
@ -180,11 +180,13 @@ void Info_Print(char *s);
|
||||||
/* Quake 2 Demo */
|
/* Quake 2 Demo */
|
||||||
#define PROTOCOL_DEMO_VERSION 31
|
#define PROTOCOL_DEMO_VERSION 31
|
||||||
/* Quake 2 Network Release */
|
/* Quake 2 Network Release */
|
||||||
#define PROTOCOL_VERSION 34
|
#define PROTOCOL_RR97_VERSION 34
|
||||||
/* ReRelease demo files */
|
/* ReRelease demo files */
|
||||||
#define PROTOCOL_RR22_VERSION 2022
|
#define PROTOCOL_RR22_VERSION 2022
|
||||||
/* ReRelease network protocol */
|
/* ReRelease network protocol */
|
||||||
#define PROTOCOL_RR23_VERSION 2023
|
#define PROTOCOL_RR23_VERSION 2023
|
||||||
|
/* Quake 2 Customized Network Release */
|
||||||
|
#define PROTOCOL_VERSION 2024
|
||||||
|
|
||||||
/* ========================================= */
|
/* ========================================= */
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,8 @@ MSG_WriteDeltaEntity(entity_state_t *from,
|
||||||
entity_state_t *to,
|
entity_state_t *to,
|
||||||
sizebuf_t *msg,
|
sizebuf_t *msg,
|
||||||
qboolean force,
|
qboolean force,
|
||||||
qboolean newentity)
|
qboolean newentity,
|
||||||
|
int protocol)
|
||||||
{
|
{
|
||||||
int bits;
|
int bits;
|
||||||
|
|
||||||
|
@ -644,24 +645,51 @@ MSG_WriteDeltaEntity(entity_state_t *from,
|
||||||
MSG_WriteByte(msg, to->number);
|
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)
|
if (bits & U_MODEL2)
|
||||||
{
|
{
|
||||||
MSG_WriteByte(msg, to->modelindex2);
|
MSG_WriteByte(msg, to->modelindex2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bits & U_MODEL3)
|
if (bits & U_MODEL3)
|
||||||
{
|
{
|
||||||
MSG_WriteByte(msg, to->modelindex3);
|
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)
|
if (bits & U_FRAME8)
|
||||||
|
|
|
@ -144,6 +144,7 @@ typedef struct client_s
|
||||||
int challenge; /* challenge of this user, randomly generated */
|
int challenge; /* challenge of this user, randomly generated */
|
||||||
|
|
||||||
netchan_t netchan;
|
netchan_t netchan;
|
||||||
|
int protocol;
|
||||||
} client_t;
|
} client_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -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.
|
* Writes a delta update of an entity_state_t list to the message.
|
||||||
*/
|
*/
|
||||||
static void
|
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;
|
entity_state_t *oldent, *newent;
|
||||||
int oldindex, newindex;
|
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
|
note that players are always 'newentities', this
|
||||||
updates their oldorigin always and prevents warping */
|
updates their oldorigin always and prevents warping */
|
||||||
MSG_WriteDeltaEntity(oldent, newent, msg,
|
MSG_WriteDeltaEntity(oldent, newent, msg,
|
||||||
false, newent->number <= maxclients->value);
|
false, newent->number <= maxclients->value, protocol);
|
||||||
oldindex++;
|
oldindex++;
|
||||||
newindex++;
|
newindex++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -107,7 +108,8 @@ SV_EmitPacketEntities(client_frame_t *from, client_frame_t *to, sizebuf_t *msg)
|
||||||
if (newnum < oldnum)
|
if (newnum < oldnum)
|
||||||
{
|
{
|
||||||
/* this is a new entity, send it from the baseline */
|
/* 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++;
|
newindex++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -432,7 +434,7 @@ SV_WriteFrameToClient(client_t *client, sizebuf_t *msg)
|
||||||
SV_WritePlayerstateToClient(oldframe, frame, msg);
|
SV_WritePlayerstateToClient(oldframe, frame, msg);
|
||||||
|
|
||||||
/* delta encode the entities */
|
/* 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.modelindex || ent->s.effects || ent->s.sound ||
|
||||||
ent->s.event) && !(ent->svflags & SVF_NOCLIENT))
|
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++;
|
e++;
|
||||||
|
|
|
@ -75,6 +75,7 @@ SV_New_f(void)
|
||||||
gamedir = (char *)Cvar_VariableString("gamedir");
|
gamedir = (char *)Cvar_VariableString("gamedir");
|
||||||
|
|
||||||
/* send the serverdata */
|
/* send the serverdata */
|
||||||
|
sv_client->protocol = PROTOCOL_VERSION;
|
||||||
MSG_WriteByte(&sv_client->netchan.message, svc_serverdata);
|
MSG_WriteByte(&sv_client->netchan.message, svc_serverdata);
|
||||||
MSG_WriteLong(&sv_client->netchan.message, PROTOCOL_VERSION);
|
MSG_WriteLong(&sv_client->netchan.message, PROTOCOL_VERSION);
|
||||||
MSG_WriteLong(&sv_client->netchan.message, svs.spawncount);
|
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_WriteByte(&sv_client->netchan.message, svc_spawnbaseline);
|
||||||
MSG_WriteDeltaEntity(&nullstate, base,
|
MSG_WriteDeltaEntity(&nullstate, base,
|
||||||
&sv_client->netchan.message,
|
&sv_client->netchan.message,
|
||||||
true, true);
|
true, true, sv_client->protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
start++;
|
start++;
|
||||||
|
|
Loading…
Reference in a new issue