Skip to content

Commit

Permalink
models: ignore MDA tag before load
Browse files Browse the repository at this point in the history
  • Loading branch information
0lvin committed Nov 17, 2024
1 parent 4981c8b commit 3f4efa0
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 11 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/client/refresh/files/models.c
Original file line number Diff line number Diff line change
Expand Up @@ -3181,7 +3181,7 @@ Mod_LoadMinMaxUpdate(const char *mod_name, vec3_t mins, vec3_t maxs, void *extra

/*
=================
Mod_LoadModel
Mod_LoadModelFile
=================
*/
static void *
Expand Down
15 changes: 13 additions & 2 deletions src/client/refresh/gl1/gl1_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand Down Expand Up @@ -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)
{
Expand Down
15 changes: 13 additions & 2 deletions src/client/refresh/gl3/gl3_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand Down Expand Up @@ -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)
{
Expand Down
15 changes: 13 additions & 2 deletions src/client/refresh/gl4/gl4_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand Down Expand Up @@ -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)
{
Expand Down
15 changes: 13 additions & 2 deletions src/client/refresh/soft/sw_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand Down Expand Up @@ -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)
{
Expand Down
15 changes: 13 additions & 2 deletions src/client/refresh/vk/vk_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand Down Expand Up @@ -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)
{
Expand Down
9 changes: 9 additions & 0 deletions src/game/g_spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,11 @@ DynamicSpawnInit(void)
* max attenuation
*/


/* Fix path */
Q_replacebackslash(dynamicentities[curr_pos].model_path);

/* go to next row */
curr_pos ++;
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3f4efa0

Please sign in to comment.