models: ignore MDA tag before load

This commit is contained in:
Denis Pauk 2024-11-17 18:32:27 +02:00
parent 4981c8b972
commit 3f4efa05a1
8 changed files with 78 additions and 11 deletions

View file

@ -150,6 +150,9 @@ Goals:
* [x] MDR model format from Star Trek: Voyager Elite Force,
* [x] MDA entity format from Anachronox,
* [ ] CTC entity format from Anachronox,
* [ ] ATD texture format from Anachronox,
* [ ] MDA model skin selection by tag,
* [ ] SDEF/MDA dynamicaly allocate list of skins,
* [ ] Support material load textures/textureinfo.dat from Anachronox,
* [ ] Support textures/*/*.mat load from ReRelease,
* [ ] Support textures/*/*_glow.png load from ReRelease,

View file

@ -3181,7 +3181,7 @@ Mod_LoadMinMaxUpdate(const char *mod_name, vec3_t mins, vec3_t maxs, void *extra
/*
=================
Mod_LoadModel
Mod_LoadModelFile
=================
*/
static void *

View file

@ -397,9 +397,10 @@ Mod_ReadFile(const char *path, void **buffer)
static model_t *
Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
{
char filename[256] = {0}, *tag;
int i, modfilelen;
model_t *mod;
void *buf;
int i, modfilelen;
if (!name[0])
{
@ -455,8 +456,18 @@ Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
strcpy(mod->name, name);
/* Anachronox has tags in model path*/
strncpy(filename, name, sizeof(filename) - 1);
tag = strstr(filename, ".mda!");
if (tag)
{
tag += 4; /* strlen(.mda) */
*tag = 0;
tag ++;
}
/* load the file */
modfilelen = ri.Mod_LoadFile(mod->name, &buf);
modfilelen = ri.Mod_LoadFile(filename, &buf);
if (!buf)
{

View file

@ -398,9 +398,10 @@ Mod_ReadFile(const char *path, void **buffer)
static gl3model_t *
Mod_ForName(const char *name, gl3model_t *parent_model, qboolean crash)
{
char filename[256] = {0}, *tag;
int i, modfilelen;
gl3model_t *mod;
void *buf;
int i, modfilelen;
if (!name[0])
{
@ -456,8 +457,18 @@ Mod_ForName(const char *name, gl3model_t *parent_model, qboolean crash)
strcpy(mod->name, name);
/* Anachronox has tags in model path*/
strncpy(filename, name, sizeof(filename) - 1);
tag = strstr(filename, ".mda!");
if (tag)
{
tag += 4; /* strlen(.mda) */
*tag = 0;
tag ++;
}
/* load the file */
modfilelen = ri.Mod_LoadFile(mod->name, &buf);
modfilelen = ri.Mod_LoadFile(filename, &buf);
if (!buf)
{

View file

@ -398,9 +398,10 @@ Mod_ReadFile(const char *path, void **buffer)
static gl4model_t *
Mod_ForName(const char *name, gl4model_t *parent_model, qboolean crash)
{
char filename[256] = {0}, *tag;
int i, modfilelen;
gl4model_t *mod;
void *buf;
int i, modfilelen;
if (!name[0])
{
@ -456,8 +457,18 @@ Mod_ForName(const char *name, gl4model_t *parent_model, qboolean crash)
strcpy(mod->name, name);
/* Anachronox has tags in model path*/
strncpy(filename, name, sizeof(filename) - 1);
tag = strstr(filename, ".mda!");
if (tag)
{
tag += 4; /* strlen(.mda) */
*tag = 0;
tag ++;
}
/* load the file */
modfilelen = ri.Mod_LoadFile(mod->name, &buf);
modfilelen = ri.Mod_LoadFile(filename, &buf);
if (!buf)
{

View file

@ -405,9 +405,10 @@ Mod_ReadFile(const char *path, void **buffer)
static model_t *
Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
{
char filename[256] = {0}, *tag;
int i, modfilelen;
model_t *mod;
void *buf;
int i, modfilelen;
if (!name[0])
{
@ -463,8 +464,18 @@ Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
strcpy(mod->name, name);
/* Anachronox has tags in model path*/
strncpy(filename, name, sizeof(filename) - 1);
tag = strstr(filename, ".mda!");
if (tag)
{
tag += 4; /* strlen(.mda) */
*tag = 0;
tag ++;
}
/* load the file */
modfilelen = ri.Mod_LoadFile(mod->name, &buf);
modfilelen = ri.Mod_LoadFile(filename, &buf);
if (!buf)
{

View file

@ -372,9 +372,10 @@ Mod_ReadFile(const char *path, void **buffer)
static model_t *
Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
{
char filename[256] = {0}, *tag;
int i, modfilelen;
model_t *mod;
void *buf;
int i, modfilelen;
if (!name[0])
{
@ -430,8 +431,18 @@ Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
strcpy(mod->name, name);
/* Anachronox has tags in model path*/
strncpy(filename, name, sizeof(filename) - 1);
tag = strstr(filename, ".mda!");
if (tag)
{
tag += 4; /* strlen(.mda) */
*tag = 0;
tag ++;
}
/* load the file */
modfilelen = ri.Mod_LoadFile(mod->name, &buf);
modfilelen = ri.Mod_LoadFile(filename, &buf);
if (!buf)
{

View file

@ -2164,6 +2164,11 @@ DynamicSpawnInit(void)
* max attenuation
*/
/* Fix path */
Q_replacebackslash(dynamicentities[curr_pos].model_path);
/* go to next row */
curr_pos ++;
}
@ -2231,6 +2236,10 @@ DynamicSpawnInit(void)
/* Additional field for cover for color from QUAKED */
line = DynamicFloatParse(line, dynamicentities[curr_pos].color, 3, '|');
/* Fix path */
Q_replacebackslash(dynamicentities[curr_pos].model_path);
/* go to next row */
curr_pos ++;
}
curr += linesize;