mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-28 13:21:10 +00:00
Made HWR_InitMD2 and HWR_AddSpriteMD2/HWR_AddPlayerMD2 slightly less stupid with MD2-related searches in md2.dat: *Don't go barmy and search for a player skin called "THOK" when you already found the sprite called "THOK" beforehand! (or any other sprite prefix for that matter) *Don't make errors appear only for the last sprite/skin when it doesn't make sense to do so!!
Todo: Stop the redundancy that currently goes on with adding MD2s on game start-up (note that HWR_AddSpriteMD2/HWR_AddPlayerMD2 are run for all sprites/skins BEFORE HWR_InitMD2 is called) git-svn-id: https://code.orospakr.ca/svn/srb2/trunk@8988 6de4a73c-47e2-0310-b8c1-93d6ecd3f8cd
This commit is contained in:
parent
f3e6770e9a
commit
2d8868feca
1 changed files with 32 additions and 49 deletions
|
@ -921,24 +921,25 @@ void HWR_InitMD2(void)
|
||||||
}
|
}
|
||||||
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
|
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
|
||||||
{
|
{
|
||||||
|
if (stricmp(name, "PLAY") == 0)
|
||||||
|
{
|
||||||
|
CONS_Printf("MD2 for sprite PLAY detected in md2.dat, use a player skin instead!\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < NUMSPRITES; i++)
|
for (i = 0; i < NUMSPRITES; i++)
|
||||||
{
|
{
|
||||||
if (stricmp(name, sprnames[i]) == 0)
|
if (stricmp(name, sprnames[i]) == 0)
|
||||||
{
|
{
|
||||||
if (stricmp(name, "PLAY") == 0)
|
//if (stricmp(name, "PLAY") == 0)
|
||||||
continue;
|
//continue;
|
||||||
|
|
||||||
//CONS_Debug(DBG_RENDER, " Found: %s %s %f %f\n", name, filename, scale, offset);
|
//CONS_Debug(DBG_RENDER, " Found: %s %s %f %f\n", name, filename, scale, offset);
|
||||||
md2_models[i].scale = scale;
|
md2_models[i].scale = scale;
|
||||||
md2_models[i].offset = offset;
|
md2_models[i].offset = offset;
|
||||||
md2_models[i].notfound = false;
|
md2_models[i].notfound = false;
|
||||||
strcpy(md2_models[i].filename, filename);
|
strcpy(md2_models[i].filename, filename);
|
||||||
break;
|
goto md2found;
|
||||||
}
|
|
||||||
if (i == NUMSPRITES)
|
|
||||||
{
|
|
||||||
CONS_Printf("MD2 for sprite %s not found\n", name);
|
|
||||||
md2_models[i].notfound = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,15 +953,14 @@ void HWR_InitMD2(void)
|
||||||
md2_playermodels[s].offset = offset;
|
md2_playermodels[s].offset = offset;
|
||||||
md2_playermodels[s].notfound = false;
|
md2_playermodels[s].notfound = false;
|
||||||
strcpy(md2_playermodels[s].filename, filename);
|
strcpy(md2_playermodels[s].filename, filename);
|
||||||
break;
|
goto md2found;
|
||||||
}
|
|
||||||
if (s == MAXSKINS-1)
|
|
||||||
{
|
|
||||||
CONS_Printf("MD2 for player skin %s not found\n", name);
|
|
||||||
md2_playermodels[s].notfound = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// no sprite/player skin name found?!?
|
||||||
|
CONS_Printf("Unknown sprite/player skin %s detected in md2.dat\n", name);
|
||||||
|
md2found:
|
||||||
|
// move on to next line...
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
@ -996,17 +996,14 @@ void HWR_AddPlayerMD2(int skin) // For MD2's that were added after startup
|
||||||
md2_playermodels[skin].offset = offset;
|
md2_playermodels[skin].offset = offset;
|
||||||
md2_playermodels[skin].notfound = false;
|
md2_playermodels[skin].notfound = false;
|
||||||
strcpy(md2_playermodels[skin].filename, filename);
|
strcpy(md2_playermodels[skin].filename, filename);
|
||||||
break;
|
goto playermd2found;
|
||||||
}
|
|
||||||
if (skin == MAXSKINS-1)
|
|
||||||
{
|
|
||||||
CONS_Printf("MD2 for player skin %s not found\n", name);
|
|
||||||
md2_playermodels[skin].notfound = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//CONS_Printf("MD2 for player skin %s not found\n", skins[skin].name);
|
||||||
|
md2_playermodels[skin].notfound = true;
|
||||||
|
playermd2found:
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1021,6 +1018,9 @@ void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startu
|
||||||
if (nomd2s)
|
if (nomd2s)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (spritenum == SPR_PLAY) // Handled already NEWMD2: Per sprite, per-skin check
|
||||||
|
return;
|
||||||
|
|
||||||
// Read the md2.dat file
|
// Read the md2.dat file
|
||||||
f = fopen("md2.dat", "rt");
|
f = fopen("md2.dat", "rt");
|
||||||
|
|
||||||
|
@ -1034,27 +1034,19 @@ void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startu
|
||||||
// Check for any MD2s that match the names of player skins!
|
// Check for any MD2s that match the names of player skins!
|
||||||
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
|
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
|
||||||
{
|
{
|
||||||
|
if (stricmp(name, sprnames[spritenum]) == 0)
|
||||||
{
|
{
|
||||||
if (stricmp(name, sprnames[spritenum]) == 0)
|
md2_models[spritenum].scale = scale;
|
||||||
{
|
md2_models[spritenum].offset = offset;
|
||||||
if (stricmp(name, "PLAY") == 0) // Handled already NEWMD2: Per sprite, per-skin check
|
md2_models[spritenum].notfound = false;
|
||||||
continue;
|
strcpy(md2_models[spritenum].filename, filename);
|
||||||
|
goto spritemd2found;
|
||||||
md2_models[spritenum].scale = scale;
|
|
||||||
md2_models[spritenum].offset = offset;
|
|
||||||
md2_models[spritenum].notfound = false;
|
|
||||||
strcpy(md2_models[spritenum].filename, filename);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (spritenum == NUMSPRITES-1)
|
|
||||||
{
|
|
||||||
CONS_Printf("MD2 for sprite %s not found\n", name);
|
|
||||||
md2_models[spritenum].notfound = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//CONS_Printf("MD2 for sprite %s not found\n", sprnames[spritenum]);
|
||||||
|
md2_models[spritenum].notfound = true;
|
||||||
|
spritemd2found:
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1094,7 +1086,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||||
// colormap test
|
// colormap test
|
||||||
{
|
{
|
||||||
sector_t *sector = spr->mobj->subsector->sector;
|
sector_t *sector = spr->mobj->subsector->sector;
|
||||||
UINT8 lightlevel = sector->lightlevel;
|
UINT8 lightlevel = 255;
|
||||||
extracolormap_t *colormap = sector->extra_colormap;
|
extracolormap_t *colormap = sector->extra_colormap;
|
||||||
|
|
||||||
if (sector->numlights)
|
if (sector->numlights)
|
||||||
|
@ -1105,8 +1097,6 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||||
|
|
||||||
if (!(spr->mobj->frame & FF_FULLBRIGHT))
|
if (!(spr->mobj->frame & FF_FULLBRIGHT))
|
||||||
lightlevel = *sector->lightlist[light].lightlevel;
|
lightlevel = *sector->lightlist[light].lightlevel;
|
||||||
else
|
|
||||||
lightlevel = 255;
|
|
||||||
|
|
||||||
if (sector->lightlist[light].extra_colormap)
|
if (sector->lightlist[light].extra_colormap)
|
||||||
colormap = sector->lightlist[light].extra_colormap;
|
colormap = sector->lightlist[light].extra_colormap;
|
||||||
|
@ -1115,16 +1105,11 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||||
{
|
{
|
||||||
if (!(spr->mobj->frame & FF_FULLBRIGHT))
|
if (!(spr->mobj->frame & FF_FULLBRIGHT))
|
||||||
lightlevel = sector->lightlevel;
|
lightlevel = sector->lightlevel;
|
||||||
else
|
|
||||||
lightlevel = 255;
|
|
||||||
|
|
||||||
if (sector->extra_colormap)
|
if (sector->extra_colormap)
|
||||||
colormap = sector->extra_colormap;
|
colormap = sector->extra_colormap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spr->mobj->frame & FF_FULLBRIGHT)
|
|
||||||
lightlevel = 255;
|
|
||||||
|
|
||||||
if (colormap)
|
if (colormap)
|
||||||
Surf.FlatColor.rgba = HWR_Lighting(lightlevel, colormap->rgba, colormap->fadergba, false, false);
|
Surf.FlatColor.rgba = HWR_Lighting(lightlevel, colormap->rgba, colormap->fadergba, false, false);
|
||||||
else
|
else
|
||||||
|
@ -1263,8 +1248,6 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||||
p.flip = false;
|
p.flip = false;
|
||||||
|
|
||||||
HWD.pfnDrawMD2i(buff, curr, durs, tics, next, &p, finalscale, flip, color);
|
HWD.pfnDrawMD2i(buff, curr, durs, tics, next, &p, finalscale, flip, color);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue