mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 07:22:28 +00:00
Model fallback
This commit is contained in:
parent
304e4bb1f9
commit
386db4b7a1
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)
|
||||
{
|
||||
//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)
|
||||
|
@ -160,8 +166,12 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
|
|||
png_FILE = fopen(pngfilename, "rb");
|
||||
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);
|
||||
return 0;
|
||||
if (!png_FILE)
|
||||
return 0;
|
||||
}
|
||||
|
||||
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");
|
||||
file = fopen(pcxfilename, "rb");
|
||||
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)
|
||||
{
|
||||
|
@ -493,11 +509,15 @@ void HWR_InitModels(void)
|
|||
|
||||
if (!f)
|
||||
{
|
||||
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
|
||||
nomd2s = true;
|
||||
return;
|
||||
f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt");
|
||||
if (!f)
|
||||
{
|
||||
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
|
||||
nomd2s = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// length of the player model prefix
|
||||
prefixlen = strlen(PLAYERMODELPREFIX);
|
||||
|
||||
|
@ -569,9 +589,13 @@ void HWR_AddPlayerModel(int skin) // For skins that were added after startup
|
|||
|
||||
if (!f)
|
||||
{
|
||||
CONS_Printf("Error while loading models.dat\n");
|
||||
nomd2s = true;
|
||||
return;
|
||||
f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt");
|
||||
if (!f)
|
||||
{
|
||||
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
|
||||
nomd2s = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
CONS_Printf("Error while loading models.dat\n");
|
||||
nomd2s = true;
|
||||
return;
|
||||
f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt");
|
||||
if (!f)
|
||||
{
|
||||
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!
|
||||
|
|
Loading…
Reference in a new issue