From f0cfc46cb75c0bb6dcff733b899947bc7c7876a4 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 29 May 2001 17:37:48 +0000 Subject: [PATCH] model.h: add a crc field to aliashdr_t model_alias.c: set it for all models cl_parse.c: set the pmodel and emodel info keys to the crcs of the player and eye models --- include/QF/model.h | 3 +++ libs/models/alias/model_alias.c | 35 ++++++++------------------------- qw/source/cl_parse.c | 17 ++++++++++++++++ 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/include/QF/model.h b/include/QF/model.h index 7a02104ef..53d2ef23c 100644 --- a/include/QF/model.h +++ b/include/QF/model.h @@ -324,6 +324,9 @@ typedef struct { int poseverts; int posedata; // numposes*poseverts trivert_t int commands; // gl command list with embedded s/t + + unsigned short crc; + int gl_texturenum[MAX_SKINS][4]; int gl_fb_texturenum[MAX_SKINS][4]; int texels[MAX_SKINS]; // only for player skins diff --git a/libs/models/alias/model_alias.c b/libs/models/alias/model_alias.c index e9e6743b1..c3cb03f04 100644 --- a/libs/models/alias/model_alias.c +++ b/libs/models/alias/model_alias.c @@ -94,34 +94,13 @@ Mod_LoadAliasModel (model_t *mod, void *buffer) daliasframetype_t *pframetype; daliasskintype_t *pskintype; int start, end, total; -#if 0 //XXX FIXME - if (!strcmp (loadmodel->name, "progs/player.mdl") || - !strcmp (loadmodel->name, "progs/eyes.mdl")) { - unsigned short crc; - byte *p; - int len; - char st[40]; + byte *p; + int len; + unsigned short crc; - CRC_Init (&crc); - for (len = com_filesize, p = buffer; len; len--, p++) - CRC_ProcessByte (&crc, *p); - - snprintf (st, sizeof (st), "%d", (int) crc); - Info_SetValueForKey (cls.userinfo, - !strcmp (loadmodel->name, - "progs/player.mdl") ? pmodel_name : - emodel_name, st, MAX_INFO_STRING); - - if (cls.state >= ca_connected) { - MSG_WriteByte (&cls.netchan.message, clc_stringcmd); - snprintf (st, sizeof (st), "setinfo %s %d", - !strcmp (loadmodel->name, - "progs/player.mdl") ? pmodel_name : emodel_name, - (int) crc); - SZ_Print (&cls.netchan.message, st); - } - } -#endif + CRC_Init (&crc); + for (len = com_filesize, p = buffer; len; len--, p++) + CRC_ProcessByte (&crc, *p); start = Hunk_LowMark (); @@ -142,6 +121,8 @@ Mod_LoadAliasModel (model_t *mod, void *buffer) pmodel = &pheader->mdl; pheader->model = (byte *) pmodel - (byte *) pheader; + pheader->crc = crc; + mod->flags = LittleLong (pinmodel->flags); // diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index 1b80a2a71..7352be888 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -272,6 +272,8 @@ Model_NextDownload (void) Netchan_AckPacket (&cls.netchan); for (i = 1; i < MAX_MODELS; i++) { + char *info_key = 0; + if (!cl.model_name[i][0]) break; @@ -285,6 +287,21 @@ Model_NextDownload (void) CL_Disconnect (); return; } + + if (strequal (cl.model_name[i], "progs/player.mdl") + && cl.model_precache[i]->type == mod_alias) + info_key = pmodel_name; + if (strequal (cl.model_name[i], "progs/eyes.mdl") + && cl.model_precache[i]->type == mod_alias) + info_key = emodel_name; + + if (info_key) { + aliashdr_t *ahdr = (aliashdr_t *) Mod_Extradata (cl.model_precache[i]); + Info_SetValueForKey (cls.userinfo, info_key, va ("%d", ahdr->crc), + MAX_INFO_STRING); + MSG_WriteByte (&cls.netchan.message, clc_stringcmd); + SZ_Print (&cls.netchan.message, va ("setinfo %s %d", info_key, ahdr->crc)); + } } // Something went wrong (probably in the server, probably a TF server)