mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-06 08:22:01 +00:00
Merge branch 'model-fallback' into 'next'
Model fallback See merge request STJr/SRB2!1167
This commit is contained in:
commit
1cd73315f1
1 changed files with 41 additions and 13 deletions
|
@ -92,7 +92,13 @@ static void md2_freeModel (model_t *model)
|
||||||
static model_t *md2_readModel(const char *filename)
|
static model_t *md2_readModel(const char *filename)
|
||||||
{
|
{
|
||||||
//Filename checking fixed ~Monster Iestyn and Golden
|
//Filename checking fixed ~Monster Iestyn and Golden
|
||||||
return LoadModel(va("%s"PATHSEP"%s", srb2home, filename), PU_STATIC);
|
if (FIL_FileExists(va("%s"PATHSEP"%s", srb2home, filename)))
|
||||||
|
return LoadModel(va("%s"PATHSEP"%s", srb2home, filename), PU_STATIC);
|
||||||
|
|
||||||
|
if (FIL_FileExists(va("%s"PATHSEP"%s", srb2path, filename)))
|
||||||
|
return LoadModel(va("%s"PATHSEP"%s", srb2path, filename), PU_STATIC);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void md2_printModelInfo (model_t *model)
|
static inline void md2_printModelInfo (model_t *model)
|
||||||
|
@ -160,8 +166,12 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
|
||||||
png_FILE = fopen(pngfilename, "rb");
|
png_FILE = fopen(pngfilename, "rb");
|
||||||
if (!png_FILE)
|
if (!png_FILE)
|
||||||
{
|
{
|
||||||
|
pngfilename = va("%s"PATHSEP"models"PATHSEP"%s", srb2path, filename);
|
||||||
|
FIL_ForceExtension(pngfilename, ".png");
|
||||||
|
png_FILE = fopen(pngfilename, "rb");
|
||||||
//CONS_Debug(DBG_RENDER, "M_SavePNG: Error on opening %s for loading\n", filename);
|
//CONS_Debug(DBG_RENDER, "M_SavePNG: Error on opening %s for loading\n", filename);
|
||||||
return 0;
|
if (!png_FILE)
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
|
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
|
||||||
|
@ -288,7 +298,13 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
|
||||||
FIL_ForceExtension(pcxfilename, ".pcx");
|
FIL_ForceExtension(pcxfilename, ".pcx");
|
||||||
file = fopen(pcxfilename, "rb");
|
file = fopen(pcxfilename, "rb");
|
||||||
if (!file)
|
if (!file)
|
||||||
return 0;
|
{
|
||||||
|
pcxfilename = va("%s"PATHSEP"models"PATHSEP"%s", srb2path, filename);
|
||||||
|
FIL_ForceExtension(pcxfilename, ".pcx");
|
||||||
|
file = fopen(pcxfilename, "rb");
|
||||||
|
if (!file)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (fread(&header, sizeof (PcxHeader), 1, file) != 1)
|
if (fread(&header, sizeof (PcxHeader), 1, file) != 1)
|
||||||
{
|
{
|
||||||
|
@ -493,11 +509,15 @@ void HWR_InitModels(void)
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
|
f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt");
|
||||||
nomd2s = true;
|
if (!f)
|
||||||
return;
|
{
|
||||||
|
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
|
||||||
|
nomd2s = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// length of the player model prefix
|
// length of the player model prefix
|
||||||
prefixlen = strlen(PLAYERMODELPREFIX);
|
prefixlen = strlen(PLAYERMODELPREFIX);
|
||||||
|
|
||||||
|
@ -569,9 +589,13 @@ void HWR_AddPlayerModel(int skin) // For skins that were added after startup
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
CONS_Printf("Error while loading models.dat\n");
|
f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt");
|
||||||
nomd2s = true;
|
if (!f)
|
||||||
return;
|
{
|
||||||
|
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
|
||||||
|
nomd2s = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// length of the player model prefix
|
// length of the player model prefix
|
||||||
|
@ -624,9 +648,13 @@ void HWR_AddSpriteModel(size_t spritenum) // For sprites that were added after s
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
CONS_Printf("Error while loading models.dat\n");
|
f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt");
|
||||||
nomd2s = true;
|
if (!f)
|
||||||
return;
|
{
|
||||||
|
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
|
||||||
|
nomd2s = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for any models that match the names of sprite names!
|
// Check for any models that match the names of sprite names!
|
||||||
|
|
Loading…
Reference in a new issue