1
0
Fork 0
forked from fte/fteqw

removed Sys_Errors with SPR/SP2 loading

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2102 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-03-13 06:15:11 +00:00
parent 5ebe24d121
commit 0138b991e1
2 changed files with 96 additions and 27 deletions

View file

@ -49,8 +49,8 @@ void CM_Init(void);
qboolean GLMod_LoadCompositeAnim(model_t *mod, void *buffer);
qboolean GL_LoadHeightmapModel (model_t *mod, void *buffer);
qboolean GLMod_LoadDarkPlacesModel(model_t *mod, void *buffer);
void GLMod_LoadSpriteModel (model_t *mod, void *buffer);
void GLMod_LoadSprite2Model (model_t *mod, void *buffer);
qboolean GLMod_LoadSpriteModel (model_t *mod, void *buffer);
qboolean GLMod_LoadSprite2Model (model_t *mod, void *buffer);
qboolean GLMod_LoadBrushModel (model_t *mod, void *buffer);
#ifdef Q2BSPS
qboolean Mod_LoadQ2BrushModel (model_t *mod, void *buffer);
@ -547,12 +547,14 @@ couldntload:
#ifdef SP2MODELS
case IDSPRITE2HEADER:
GLMod_LoadSprite2Model (mod, buf);
if (!GLMod_LoadSprite2Model (mod, buf))
goto couldntload;
break;
#endif
case IDSPRITEHEADER:
GLMod_LoadSpriteModel (mod, buf);
if (!GLMod_LoadSpriteModel (mod, buf))
goto couldntload;
break;
#ifdef Q2BSPS
case ('R'<<0)+('B'<<8)+('S'<<16)+('P'<<24):
@ -575,7 +577,8 @@ couldntload:
#ifdef DOOMWADS
case (('D'<<24)+('A'<<16)+('W'<<8)+'I'):
case (('D'<<24)+('A'<<16)+('W'<<8)+'P'):
Mod_LoadDoomLevel (mod);
if (!Mod_LoadDoomLevel (mod))
goto couldntload;
break;
#endif
@ -2957,7 +2960,10 @@ void * GLMod_LoadSpriteGroup (void * pin, mspriteframe_t **ppframe, int framenum
{
*poutintervals = LittleFloat (pin_intervals->interval);
if (*poutintervals <= 0.0)
Sys_Error ("Mod_LoadSpriteGroup: interval<=0");
{
Con_Printf (S_ERROR "Mod_LoadSpriteGroup: interval<=0\n");
return NULL;
}
poutintervals++;
pin_intervals++;
@ -2978,7 +2984,7 @@ void * GLMod_LoadSpriteGroup (void * pin, mspriteframe_t **ppframe, int framenum
Mod_LoadSpriteModel
=================
*/
void GLMod_LoadSpriteModel (model_t *mod, void *buffer)
qboolean GLMod_LoadSpriteModel (model_t *mod, void *buffer)
{
int i;
int version;
@ -2990,15 +2996,20 @@ void GLMod_LoadSpriteModel (model_t *mod, void *buffer)
int rendertype=0;
unsigned char pal[256*4];
int sptype;
int hunkstart;
hunkstart = Hunk_LowMark();
pin = (dsprite_t *)buffer;
version = LittleLong (pin->version);
if (version != SPRITE_VERSION)
if (version != SPRITE32_VERSION)
if (version != SPRITEHL_VERSION)
Sys_Error ("%s has wrong version number "
"(%i should be %i)", mod->name, version, SPRITE_VERSION);
{
Con_Printf (S_ERROR "%s has wrong version number "
"(%i should be %i)\n", mod->name, version, SPRITE_VERSION);
return false;
}
sptype = LittleLong (pin->type);
@ -3034,7 +3045,11 @@ void GLMod_LoadSpriteModel (model_t *mod, void *buffer)
short *numi = (short*)(pin+1);
unsigned char *src = (unsigned char *)(numi+1);
if (*numi != 256)
Sys_Error("%s has wrong number of palette indexes (we only support 256)\n", mod->name);
{
Con_Printf(S_ERROR "%s has wrong number of palette indexes (we only support 256)\n", mod->name);
Hunk_FreeToLowMark(hunkstart);
return false;
}
for (i = 0; i < 256; i++)
{
@ -3053,7 +3068,11 @@ void GLMod_LoadSpriteModel (model_t *mod, void *buffer)
// load the frames
//
if (numframes < 1)
Sys_Error ("Mod_LoadSpriteModel: Invalid # of frames: %d\n", numframes);
{
Con_Printf (S_ERROR "Mod_LoadSpriteModel: Invalid # of frames: %d\n", numframes);
Hunk_FreeToLowMark(hunkstart);
return false;
}
mod->numframes = numframes;
@ -3076,12 +3095,19 @@ void GLMod_LoadSpriteModel (model_t *mod, void *buffer)
GLMod_LoadSpriteGroup (pframetype + 1,
&psprite->frames[i].frameptr, i, version, pal);
}
if (pframetype == NULL)
{
Hunk_FreeToLowMark(hunkstart);
return false;
}
}
mod->type = mod_sprite;
return true;
}
void GLMod_LoadSprite2Model (model_t *mod, void *buffer)
qboolean GLMod_LoadSprite2Model (model_t *mod, void *buffer)
{
int i;
int version;
@ -3092,13 +3118,19 @@ void GLMod_LoadSprite2Model (model_t *mod, void *buffer)
dmd2sprframe_t *pframetype;
mspriteframe_t *frame;
float origin[2];
int hunkstart;
hunkstart = Hunk_LowMark();
pin = (dmd2sprite_t *)buffer;
version = LittleLong (pin->version);
if (version != SPRITE2_VERSION)
Sys_Error ("%s has wrong version number "
{
Con_Printf (S_ERROR "%s has wrong version number "
"(%i should be %i)", mod->name, version, SPRITE2_VERSION);
return false;
}
numframes = LittleLong (pin->numframes);
@ -3124,7 +3156,11 @@ void GLMod_LoadSprite2Model (model_t *mod, void *buffer)
// load the frames
//
if (numframes < 1)
Sys_Error ("Mod_LoadSpriteModel: Invalid # of frames: %d\n", numframes);
{
Con_Printf (S_ERROR "Mod_LoadSpriteModel: Invalid # of frames: %d\n", numframes);
Hunk_FreeToLowMark(hunkstart);
return false;
}
mod->numframes = numframes;
@ -3154,6 +3190,8 @@ void GLMod_LoadSprite2Model (model_t *mod, void *buffer)
}
mod->type = mod_sprite;
return true;
}

View file

@ -28,8 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
model_t *loadmodel;
char loadname[32]; // for hunk tags
void SWMod_LoadSpriteModel (model_t *mod, void *buffer);
void SWMod_LoadSprite2Model (model_t *mod, void *buffer);
qboolean SWMod_LoadSpriteModel (model_t *mod, void *buffer);
qboolean SWMod_LoadSprite2Model (model_t *mod, void *buffer);
qboolean SWMod_LoadBrushModel (model_t *mod, void *buffer);
qboolean Mod_LoadQ2BrushModel (model_t *mod, void *buffer);
qboolean SWMod_LoadAliasModel (model_t *mod, void *buffer);
@ -391,11 +391,13 @@ model_t *SWMod_LoadModel (model_t *mod, qboolean crash)
break;
case IDSPRITEHEADER:
SWMod_LoadSpriteModel (mod, buf);
if (!SWMod_LoadSpriteModel (mod, buf))
goto couldntload;
break;
case IDSPRITE2HEADER:
SWMod_LoadSprite2Model (mod, buf);
if (!SWMod_LoadSprite2Model (mod, buf))
goto couldntload;
break;
#endif
#ifdef Q2BSPS
@ -3609,7 +3611,10 @@ void * SWMod_LoadSpriteGroup (void * pin, mspriteframe_t **ppframe, int version)
{
*poutintervals = LittleFloat (pin_intervals->interval);
if (*poutintervals <= 0.0)
Sys_Error ("Mod_LoadSpriteGroup: interval<=0");
{
Con_Printf (S_ERROR "Mod_LoadSpriteGroup: interval<=0\n");
return NULL;
}
poutintervals++;
pin_intervals++;
@ -3631,7 +3636,7 @@ void * SWMod_LoadSpriteGroup (void * pin, mspriteframe_t **ppframe, int version)
Mod_LoadSpriteModel
=================
*/
void SWMod_LoadSpriteModel (model_t *mod, void *buffer)
qboolean SWMod_LoadSpriteModel (model_t *mod, void *buffer)
{
int i;
int version;
@ -3640,14 +3645,20 @@ void SWMod_LoadSpriteModel (model_t *mod, void *buffer)
int numframes;
int size;
dspriteframetype_t *pframetype;
int hunkstart;
hunkstart = Hunk_LowMark();
pin = (dsprite_t *)buffer;
version = LittleLong (pin->version);
if (version != SPRITE32_VERSION)
if (version != SPRITE_VERSION)
Sys_Error ("%s has wrong version number "
"(%i should be %i)", mod->name, version, SPRITE_VERSION);
{
Con_Printf (S_ERROR "%s has wrong version number "
"(%i should be %i)\n", mod->name, version, SPRITE_VERSION);
return false;
}
numframes = LittleLong (pin->numframes);
@ -3673,7 +3684,10 @@ void SWMod_LoadSpriteModel (model_t *mod, void *buffer)
// load the frames
//
if (numframes < 1)
Sys_Error ("Mod_LoadSpriteModel: Invalid # of frames: %d\n", numframes);
{
Con_Printf (S_ERROR "Mod_LoadSpriteModel: Invalid # of frames: %d\n", numframes);
return false;
}
mod->numframes = numframes;
@ -3698,12 +3712,18 @@ void SWMod_LoadSpriteModel (model_t *mod, void *buffer)
SWMod_LoadSpriteGroup (pframetype + 1,
&psprite->frames[i].frameptr, version);
}
if (pframetype == NULL)
{
Hunk_FreeToLowMark(hunkstart);
return false;
}
}
mod->type = mod_sprite;
return true;
}
void SWMod_LoadSprite2Model (model_t *mod, void *buffer)
qboolean SWMod_LoadSprite2Model (model_t *mod, void *buffer)
{
int i, j;
int version;
@ -3718,13 +3738,19 @@ void SWMod_LoadSprite2Model (model_t *mod, void *buffer)
int height;
qbyte *framefile;
qbyte *framedata;
int hunkstart;
hunkstart = Hunk_LowMark();
pin = (dmd2sprite_t *)buffer;
version = LittleLong (pin->version);
if (version != SPRITE2_VERSION)
Sys_Error ("%s has wrong version number "
"(%i should be %i)", mod->name, version, SPRITE2_VERSION);
{
Con_Printf ("%s has wrong version number "
"(%i should be %i)\n", mod->name, version, SPRITE2_VERSION);
return false;
}
numframes = LittleLong (pin->numframes);
@ -3750,7 +3776,11 @@ void SWMod_LoadSprite2Model (model_t *mod, void *buffer)
// load the frames
//
if (numframes < 1)
Sys_Error ("Mod_LoadSpriteModel: Invalid # of frames: %d\n", numframes);
{
Con_Printf (S_ERROR "Mod_LoadSpriteModel: Invalid # of frames: %d\n", numframes);
Hunk_FreeToLowMark(hunkstart);
return false;
}
mod->numframes = 0;
@ -3814,6 +3844,7 @@ void SWMod_LoadSprite2Model (model_t *mod, void *buffer)
}
mod->type = mod_sprite;
return true;
}
//=============================================================================