protocol: CUSTOM_PLAYER_MODEL(MAX_MODELS - 1) as player model

This commit is contained in:
Denis Pauk 2024-11-17 14:58:30 +02:00
parent a09cbe20bd
commit 53e93824ca
8 changed files with 41 additions and 13 deletions

View file

@ -156,7 +156,7 @@ CL_AddPacketEntities(frame_t *frame)
else
{
/* set skin */
if (s1->modelindex == 255)
if (s1->modelindex == CUSTOM_PLAYER_MODEL)
{
/* use custom player skin */
ent.skinnum = 0;
@ -381,7 +381,7 @@ CL_AddPacketEntities(frame_t *frame)
/* duplicate for linked models */
if (s1->modelindex2)
{
if (s1->modelindex2 == 255)
if (s1->modelindex2 == CUSTOM_PLAYER_MODEL)
{
/* custom weapon */
ci = &cl.clientinfo[s1->skinnum & 0xff];

View file

@ -148,11 +148,19 @@ CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits)
if (bits & U_MODEL)
{
to->modelindex = MSG_ReadByte(&net_message);
if (to->modelindex == QII97_PLAYER_MODEL)
{
to->modelindex = CUSTOM_PLAYER_MODEL;
}
}
if (bits & U_MODEL2)
{
to->modelindex2 = MSG_ReadByte(&net_message);
if (to->modelindex2 == QII97_PLAYER_MODEL)
{
to->modelindex2 = CUSTOM_PLAYER_MODEL;
}
}
if (bits & U_MODEL3)

View file

@ -190,6 +190,9 @@ void Info_Print(char *s);
/* Quake 2 Customized Network Release */
#define PROTOCOL_VERSION 2024
/* Quake 2 originaly uses 255 as player model */
#define QII97_PLAYER_MODEL 255
#define IS_QII97_PROTOCOL(x) ( \
((x) == PROTOCOL_RELEASE_VERSION) || \
((x) == PROTOCOL_DEMO_VERSION) || \

View file

@ -178,6 +178,7 @@ typedef unsigned char byte;
#define MAX_IMAGES 256
#define MAX_ITEMS 256
#define MAX_GENERAL (MAX_CLIENTS * 2) /* general config strings */
#define CUSTOM_PLAYER_MODEL (MAX_MODELS - 1)
/* game print flags */
#define PRINT_LOW 0 /* pickup messages */

View file

@ -650,12 +650,28 @@ MSG_WriteDeltaEntity(entity_state_t *from,
{
if (bits & U_MODEL)
{
MSG_WriteByte(msg, to->modelindex);
int modelindex = to->modelindex;
/* New protocol use 16 bit for model id, and custom player model
* id is different to old one, converty back */
if (modelindex == CUSTOM_PLAYER_MODEL)
{
modelindex = QII97_PLAYER_MODEL;
}
MSG_WriteByte(msg, modelindex);
}
if (bits & U_MODEL2)
{
MSG_WriteByte(msg, to->modelindex2);
int modelindex = to->modelindex2;
/* New protocol use 16 bit for model id, and custom player model
* id is different to old one, converty back */
if (modelindex == CUSTOM_PLAYER_MODEL)
{
modelindex = QII97_PLAYER_MODEL;
}
MSG_WriteByte(msg, modelindex);
}
if (bits & U_MODEL3)

View file

@ -2265,8 +2265,8 @@ PutClientInServer(edict_t *ent)
/* clear entity state values */
ent->s.effects = 0;
ent->s.skinnum = ent - g_edicts - 1;
ent->s.modelindex = 255; /* will use the skin specified model */
ent->s.modelindex2 = 255; /* custom gun model */
ent->s.modelindex = CUSTOM_PLAYER_MODEL; /* will use the skin specified model */
ent->s.modelindex2 = CUSTOM_PLAYER_MODEL; /* custom gun model */
/* sknum is player num and weapon number
weapon number will be added in changeweapon */
@ -2840,7 +2840,7 @@ ClientThink(edict_t *ent, usercmd_t *ucmd)
{
client->ps.pmove.pm_type = PM_SPECTATOR;
}
else if (ent->s.modelindex != 255)
else if (ent->s.modelindex != CUSTOM_PLAYER_MODEL)
{
client->ps.pmove.pm_type = PM_GIB;
}

View file

@ -116,7 +116,7 @@ P_DamageFeedback(edict_t *player)
}
/* start a pain animation if still in the player model */
if ((client->anim_priority < ANIM_PAIN) && (player->s.modelindex == 255))
if ((client->anim_priority < ANIM_PAIN) && (player->s.modelindex == CUSTOM_PLAYER_MODEL))
{
static int i;
@ -782,7 +782,7 @@ P_FallingDamage(edict_t *ent)
return;
}
if (ent->s.modelindex != 255)
if (ent->s.modelindex != CUSTOM_PLAYER_MODEL)
{
return; /* not in the player model */
}
@ -1333,7 +1333,7 @@ G_SetClientFrame(edict_t *ent)
return;
}
if (ent->s.modelindex != 255)
if (ent->s.modelindex != CUSTOM_PLAYER_MODEL)
{
return; /* not in the player model */
}

View file

@ -477,7 +477,7 @@ ChangeWeapon(edict_t *ent)
ent->client->machinegun_shots = 0;
/* set visible model */
if (ent->s.modelindex == 255)
if (ent->s.modelindex == CUSTOM_PLAYER_MODEL)
{
if (ent->client->pers.weapon)
{
@ -847,7 +847,7 @@ Weapon_Generic2(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST,
return;
}
if (ent->deadflag || (ent->s.modelindex != 255)) /* VWep animations screw up corpses */
if (ent->deadflag || (ent->s.modelindex != CUSTOM_PLAYER_MODEL)) /* VWep animations screw up corpses */
{
return;
}
@ -1125,7 +1125,7 @@ weapon_grenade_fire(edict_t *ent, qboolean held)
ent->client->grenade_time = level.time + 1.0;
if (ent->deadflag || (ent->s.modelindex != 255)) /* VWep animations screw up corpses */
if (ent->deadflag || (ent->s.modelindex != CUSTOM_PLAYER_MODEL)) /* VWep animations screw up corpses */
{
return;
}