Crawlas now use only one state for looking each SPR2_ constants added to dehacked.c for use in SOC/Lua (both "SPR2_RUN" and "SPR2_RUN_" are in theory the same thing in this implementation, likewise for other 3-char name cases) spr2names array/table also added for use in Lua - it works identically to Lua's sprnames, only with SPR2_ constants/string names instead Some minor cleanup for OpenGL sprite/MD2 code

git-svn-id: https://code.orospakr.ca/svn/srb2/trunk@9004 6de4a73c-47e2-0310-b8c1-93d6ecd3f8cd
This commit is contained in:
MonsterIestyn 2015-01-28 15:16:50 +00:00 committed by Ronald Kinard
parent 1d87f7d193
commit c93ae69d9d
6 changed files with 80 additions and 25 deletions

View File

@ -3796,7 +3796,6 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit
// Blue Crawla // Blue Crawla
"S_POSS_STND", "S_POSS_STND",
"S_POSS_STND2",
"S_POSS_RUN1", "S_POSS_RUN1",
"S_POSS_RUN2", "S_POSS_RUN2",
"S_POSS_RUN3", "S_POSS_RUN3",
@ -3806,7 +3805,6 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit
// Red Crawla // Red Crawla
"S_SPOS_STND", "S_SPOS_STND",
"S_SPOS_STND2",
"S_SPOS_RUN1", "S_SPOS_RUN1",
"S_SPOS_RUN2", "S_SPOS_RUN2",
"S_SPOS_RUN3", "S_SPOS_RUN3",
@ -8476,6 +8474,27 @@ static inline int lib_getenum(lua_State *L)
if (mathlib) return luaL_error(L, "sprite '%s' could not be found.\n", word); if (mathlib) return luaL_error(L, "sprite '%s' could not be found.\n", word);
return 0; return 0;
} }
else if (fastncmp("SPR2_",word,4)) {
p = word+5;
for (i = 0; i < NUMPLAYERSPRITES; i++)
if (!spr2names[i][4])
{
// special 3-char cases, e.g. SPR2_RUN
// the spr2names entry will have "_" on the end, as in "RUN_"
if (spr2names[i][3] == '_' && !p[3]) {
if (fastncmp(p,spr2names[i],3)) {
lua_pushinteger(L, i);
return 1;
}
}
else if (fastncmp(p,spr2names[i],4)) {
lua_pushinteger(L, i);
return 1;
}
}
if (mathlib) return luaL_error(L, "player sprite '%s' could not be found.\n", word);
return 0;
}
else if (!mathlib && fastncmp("sfx_",word,4)) { else if (!mathlib && fastncmp("sfx_",word,4)) {
p = word+4; p = word+4;
for (i = 0; i < NUMSFX; i++) for (i = 0; i < NUMSFX; i++)

View File

@ -3658,7 +3658,7 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t
/*if (spr->mobj->frame & FF_TRANSMASK || spr->mobj->flags2 & MF2_SHADOW) /*if (spr->mobj->frame & FF_TRANSMASK || spr->mobj->flags2 & MF2_SHADOW)
{ {
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)
@ -3667,8 +3667,6 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t
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;
@ -3830,7 +3828,7 @@ static void HWR_DrawSprite(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)
@ -3841,8 +3839,6 @@ static void HWR_DrawSprite(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;
@ -3851,16 +3847,11 @@ static void HWR_DrawSprite(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

View File

@ -1082,6 +1082,12 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
md2_t *md2; md2_t *md2;
UINT8 color[4]; UINT8 color[4];
if (!cv_grmd2.value)
return;
if (!spr->precip)
return;
// MD2 colormap fix // MD2 colormap fix
// colormap test // colormap test
{ {
@ -1116,8 +1122,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
Surf.FlatColor.rgba = HWR_Lighting(lightlevel, NORMALFOG, FADEFOG, false, false); Surf.FlatColor.rgba = HWR_Lighting(lightlevel, NORMALFOG, FADEFOG, false, false);
} }
// Look at HWR_ProjetctSprite for more // Look at HWR_ProjectSprite for more
if (cv_grmd2.value && ((md2_models[spr->mobj->sprite].scale > 0.0f) || (md2_playermodels[(skin_t*)spr->mobj->skin-skins].scale > 0.0f)) && !spr->precip)
{ {
GLPatch_t *gpatch; GLPatch_t *gpatch;
INT32 *buff; INT32 *buff;
@ -1134,15 +1139,11 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
//durs = tics; //durs = tics;
if (spr->mobj->flags2 & MF2_SHADOW) if (spr->mobj->flags2 & MF2_SHADOW)
{
Surf.FlatColor.s.alpha = 0x40; Surf.FlatColor.s.alpha = 0x40;
}
else if (spr->mobj->frame & FF_TRANSMASK) else if (spr->mobj->frame & FF_TRANSMASK)
HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf);
else else
{
Surf.FlatColor.s.alpha = 0xFF; Surf.FlatColor.s.alpha = 0xFF;
}
// dont forget to enabled the depth test because we can't do this like // dont forget to enabled the depth test because we can't do this like
// before: polygons models are not sorted // before: polygons models are not sorted

View File

@ -163,8 +163,7 @@ state_t states[NUMSTATES] =
{SPR_PLAY, SPR2_SIGN, 1, {NULL}, 0, 24, S_PLAY_SIGN}, // S_PLAY_SIGN {SPR_PLAY, SPR2_SIGN, 1, {NULL}, 0, 24, S_PLAY_SIGN}, // S_PLAY_SIGN
// Blue Crawla // Blue Crawla
{SPR_POSS, 0, 5, {A_Look}, 0, 0, S_POSS_STND2}, // S_POSS_STND {SPR_POSS, 0, 5, {A_Look}, 0, 0, S_POSS_STND}, // S_POSS_STND
{SPR_POSS, 0, 5, {A_Look}, 0, 0, S_POSS_STND}, // S_POSS_STND2
{SPR_POSS, 0, 3, {A_Chase}, 0, 0, S_POSS_RUN2}, // S_POSS_RUN1 {SPR_POSS, 0, 3, {A_Chase}, 0, 0, S_POSS_RUN2}, // S_POSS_RUN1
{SPR_POSS, 1, 3, {A_Chase}, 0, 0, S_POSS_RUN3}, // S_POSS_RUN2 {SPR_POSS, 1, 3, {A_Chase}, 0, 0, S_POSS_RUN3}, // S_POSS_RUN2
{SPR_POSS, 2, 3, {A_Chase}, 0, 0, S_POSS_RUN4}, // S_POSS_RUN3 {SPR_POSS, 2, 3, {A_Chase}, 0, 0, S_POSS_RUN4}, // S_POSS_RUN3
@ -173,8 +172,7 @@ state_t states[NUMSTATES] =
{SPR_POSS, 5, 3, {A_Chase}, 0, 0, S_POSS_RUN1}, // S_POSS_RUN6 {SPR_POSS, 5, 3, {A_Chase}, 0, 0, S_POSS_RUN1}, // S_POSS_RUN6
// Red Crawla // Red Crawla
{SPR_SPOS, 0, 5, {A_Look}, 0, 0, S_SPOS_STND2}, // S_SPOS_STND {SPR_SPOS, 0, 5, {A_Look}, 0, 0, S_SPOS_STND}, // S_SPOS_STND
{SPR_SPOS, 0, 5, {A_Look}, 0, 0, S_SPOS_STND}, // S_SPOS_STND2
{SPR_SPOS, 0, 1, {A_Chase}, 0, 0, S_SPOS_RUN2}, // S_SPOS_RUN1 {SPR_SPOS, 0, 1, {A_Chase}, 0, 0, S_SPOS_RUN2}, // S_SPOS_RUN1
{SPR_SPOS, 1, 1, {A_Chase}, 0, 0, S_SPOS_RUN3}, // S_SPOS_RUN2 {SPR_SPOS, 1, 1, {A_Chase}, 0, 0, S_SPOS_RUN3}, // S_SPOS_RUN2
{SPR_SPOS, 2, 1, {A_Chase}, 0, 0, S_SPOS_RUN4}, // S_SPOS_RUN3 {SPR_SPOS, 2, 1, {A_Chase}, 0, 0, S_SPOS_RUN4}, // S_SPOS_RUN3

View File

@ -683,7 +683,6 @@ typedef enum state
// Blue Crawla // Blue Crawla
S_POSS_STND, S_POSS_STND,
S_POSS_STND2,
S_POSS_RUN1, S_POSS_RUN1,
S_POSS_RUN2, S_POSS_RUN2,
S_POSS_RUN3, S_POSS_RUN3,
@ -693,7 +692,6 @@ typedef enum state
// Red Crawla // Red Crawla
S_SPOS_STND, S_SPOS_STND,
S_SPOS_STND2,
S_SPOS_RUN1, S_SPOS_RUN1,
S_SPOS_RUN2, S_SPOS_RUN2,
S_SPOS_RUN3, S_SPOS_RUN3,

View File

@ -91,6 +91,44 @@ static int lib_sprnamelen(lua_State *L)
return 1; return 1;
} }
//
// Player Sprite Names
//
// push sprite name
static int lib_getSpr2name(lua_State *L)
{
UINT32 i;
lua_remove(L, 1); // don't care about spr2names[] dummy userdata.
if (lua_isnumber(L, 1))
{
i = lua_tonumber(L, 1);
if (i > NUMPLAYERSPRITES)
return 0;
lua_pushlstring(L, spr2names[i], 4);
return 1;
}
else if (lua_isstring(L, 1))
{
const char *name = lua_tostring(L, 1);
for (i = 0; i < NUMPLAYERSPRITES; i++)
if (fastcmp(name, spr2names[i]))
{
lua_pushinteger(L, i);
return 1;
}
}
return 0;
}
static int lib_spr2namelen(lua_State *L)
{
lua_pushinteger(L, NUMPLAYERSPRITES);
return 1;
}
//////////////// ////////////////
// STATE INFO // // STATE INFO //
//////////////// ////////////////
@ -904,6 +942,16 @@ int LUA_InfoLib(lua_State *L)
lua_setmetatable(L, -2); lua_setmetatable(L, -2);
lua_setglobal(L, "sprnames"); lua_setglobal(L, "sprnames");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSpr2name);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_spr2namelen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "spr2names");
lua_newuserdata(L, 0); lua_newuserdata(L, 0);
lua_createtable(L, 0, 2); lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getState); lua_pushcfunction(L, lib_getState);