mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 17:22:12 +00:00
I know this isn't my branch, but found several reference haemmoragers and figured it'd be appropriate to commit here.
This commit is contained in:
parent
166f1fac66
commit
47f138ac34
6 changed files with 57 additions and 16 deletions
|
@ -804,6 +804,14 @@ void HWR_WallLighting(FOutVector *wlVerts)
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf;
|
||||||
float dist_p2d, d[4], s;
|
float dist_p2d, d[4], s;
|
||||||
|
|
||||||
|
if (!dynlights->mo[j])
|
||||||
|
continue;
|
||||||
|
if (P_MobjWasRemoved(dynlights->mo[j]))
|
||||||
|
{
|
||||||
|
P_SetTarget(&dynlights->mo[j], NULL);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// check bounding box first
|
// check bounding box first
|
||||||
if (SphereTouchBBox3D(&wlVerts[2], &wlVerts[0], &LIGHT_POS(j), DL_RADIUS(j))==false)
|
if (SphereTouchBBox3D(&wlVerts[2], &wlVerts[0], &LIGHT_POS(j), DL_RADIUS(j))==false)
|
||||||
continue;
|
continue;
|
||||||
|
@ -854,8 +862,6 @@ void HWR_WallLighting(FOutVector *wlVerts)
|
||||||
#ifdef DL_HIGH_QUALITY
|
#ifdef DL_HIGH_QUALITY
|
||||||
Surf.FlatColor.s.alpha = (UINT8)((1-dist_p2d/DL_SQRRADIUS(j))*Surf.FlatColor.s.alpha);
|
Surf.FlatColor.s.alpha = (UINT8)((1-dist_p2d/DL_SQRRADIUS(j))*Surf.FlatColor.s.alpha);
|
||||||
#endif
|
#endif
|
||||||
if (!dynlights->mo[j]->state)
|
|
||||||
return;
|
|
||||||
// next state is null so fade out with alpha
|
// next state is null so fade out with alpha
|
||||||
if (dynlights->mo[j]->state->nextstate == S_NULL)
|
if (dynlights->mo[j]->state->nextstate == S_NULL)
|
||||||
Surf.FlatColor.s.alpha = (UINT8)(((float)dynlights->mo[j]->tics/(float)dynlights->mo[j]->state->tics)*Surf.FlatColor.s.alpha);
|
Surf.FlatColor.s.alpha = (UINT8)(((float)dynlights->mo[j]->tics/(float)dynlights->mo[j]->state->tics)*Surf.FlatColor.s.alpha);
|
||||||
|
@ -886,6 +892,14 @@ void HWR_PlaneLighting(FOutVector *clVerts, int nrClipVerts)
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf;
|
||||||
float dist_p2d, s;
|
float dist_p2d, s;
|
||||||
|
|
||||||
|
if (!dynlights->mo[j])
|
||||||
|
continue;
|
||||||
|
if (P_MobjWasRemoved(dynlights->mo[j]))
|
||||||
|
{
|
||||||
|
P_SetTarget(&dynlights->mo[j], NULL);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// BP: The kickass Optimization: check if light touch bounding box
|
// BP: The kickass Optimization: check if light touch bounding box
|
||||||
if (SphereTouchBBox3D(&p1, &p2, &dynlights->position[j], DL_RADIUS(j))==false)
|
if (SphereTouchBBox3D(&p1, &p2, &dynlights->position[j], DL_RADIUS(j))==false)
|
||||||
continue;
|
continue;
|
||||||
|
@ -917,8 +931,6 @@ void HWR_PlaneLighting(FOutVector *clVerts, int nrClipVerts)
|
||||||
#ifdef DL_HIGH_QUALITY
|
#ifdef DL_HIGH_QUALITY
|
||||||
Surf.FlatColor.s.alpha = (unsigned char)((1 - dist_p2d/DL_SQRRADIUS(j))*Surf.FlatColor.s.alpha);
|
Surf.FlatColor.s.alpha = (unsigned char)((1 - dist_p2d/DL_SQRRADIUS(j))*Surf.FlatColor.s.alpha);
|
||||||
#endif
|
#endif
|
||||||
if (!dynlights->mo[j]->state)
|
|
||||||
return;
|
|
||||||
// next state is null so fade out with alpha
|
// next state is null so fade out with alpha
|
||||||
if ((dynlights->mo[j]->state->nextstate == S_NULL))
|
if ((dynlights->mo[j]->state->nextstate == S_NULL))
|
||||||
Surf.FlatColor.s.alpha = (unsigned char)(((float)dynlights->mo[j]->tics/(float)dynlights->mo[j]->state->tics)*Surf.FlatColor.s.alpha);
|
Surf.FlatColor.s.alpha = (unsigned char)(((float)dynlights->mo[j]->tics/(float)dynlights->mo[j]->state->tics)*Surf.FlatColor.s.alpha);
|
||||||
|
@ -1110,7 +1122,8 @@ void HWR_DrawCoronas(void)
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
void HWR_ResetLights(void)
|
void HWR_ResetLights(void)
|
||||||
{
|
{
|
||||||
dynlights->nb = 0;
|
while (dynlights->nb)
|
||||||
|
P_SetTarget(&dynlights->mo[--dynlights->nb], NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
@ -1145,9 +1158,7 @@ void HWR_DL_AddLight(gr_vissprite_t *spr, GLPatch_t *patch)
|
||||||
p_lspr = t_lspr[spr->mobj->sprite];
|
p_lspr = t_lspr[spr->mobj->sprite];
|
||||||
if ((p_lspr->type&DYNLIGHT_SPR)
|
if ((p_lspr->type&DYNLIGHT_SPR)
|
||||||
&& ((p_lspr->type != LIGHT_SPR) || cv_grstaticlighting.value)
|
&& ((p_lspr->type != LIGHT_SPR) || cv_grstaticlighting.value)
|
||||||
&& (dynlights->nb < DL_MAX_LIGHT)
|
&& (dynlights->nb < DL_MAX_LIGHT))
|
||||||
|
|
||||||
&& spr->mobj->state)
|
|
||||||
{
|
{
|
||||||
LIGHT_POS(dynlights->nb).x = FIXED_TO_FLOAT(spr->mobj->x);
|
LIGHT_POS(dynlights->nb).x = FIXED_TO_FLOAT(spr->mobj->x);
|
||||||
LIGHT_POS(dynlights->nb).y = FIXED_TO_FLOAT(spr->mobj->z)+FIXED_TO_FLOAT(spr->mobj->height>>1)+p_lspr->light_yoffset;
|
LIGHT_POS(dynlights->nb).y = FIXED_TO_FLOAT(spr->mobj->z)+FIXED_TO_FLOAT(spr->mobj->height>>1)+p_lspr->light_yoffset;
|
||||||
|
@ -1380,7 +1391,7 @@ void HWR_CreateStaticLightmaps(int bspnum)
|
||||||
#ifdef STATICLIGHT
|
#ifdef STATICLIGHT
|
||||||
CONS_Debug(DBG_RENDER, "HWR_CreateStaticLightmaps\n");
|
CONS_Debug(DBG_RENDER, "HWR_CreateStaticLightmaps\n");
|
||||||
|
|
||||||
dynlights->nb = 0;
|
HWR_ResetLights();
|
||||||
|
|
||||||
// First: Searching for lights
|
// First: Searching for lights
|
||||||
// BP: if i was you, I will make it in create mobj since mobj can be create
|
// BP: if i was you, I will make it in create mobj since mobj can be create
|
||||||
|
@ -1392,7 +1403,7 @@ void HWR_CreateStaticLightmaps(int bspnum)
|
||||||
validcount++; // to be sure
|
validcount++; // to be sure
|
||||||
HWR_ComputeLightMapsInBSPNode(bspnum, NULL);
|
HWR_ComputeLightMapsInBSPNode(bspnum, NULL);
|
||||||
|
|
||||||
dynlights->nb = 0;
|
HWR_ResetLights();
|
||||||
#else
|
#else
|
||||||
(void)bspnum;
|
(void)bspnum;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -54,10 +54,12 @@ static UINT8 lib_searchBlockmap_Objects(lua_State *L, INT32 x, INT32 y, mobj_t *
|
||||||
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
|
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
|
||||||
lua_pop(gL, 1);
|
lua_pop(gL, 1);
|
||||||
blockfuncerror = true;
|
blockfuncerror = true;
|
||||||
|
P_SetTarget(&bnext, NULL);
|
||||||
return 0; // *shrugs*
|
return 0; // *shrugs*
|
||||||
}
|
}
|
||||||
if (!lua_isnil(gL, -1))
|
if (!lua_isnil(gL, -1))
|
||||||
{ // if nil, continue
|
{ // if nil, continue
|
||||||
|
P_SetTarget(&bnext, NULL);
|
||||||
if (lua_toboolean(gL, -1))
|
if (lua_toboolean(gL, -1))
|
||||||
return 2; // stop whole search
|
return 2; // stop whole search
|
||||||
else
|
else
|
||||||
|
|
|
@ -274,10 +274,19 @@ static int mobj_get(lua_State *L)
|
||||||
// bprev -- same deal as sprev above, but for the blockmap.
|
// bprev -- same deal as sprev above, but for the blockmap.
|
||||||
return UNIMPLEMENTED;
|
return UNIMPLEMENTED;
|
||||||
case mobj_hnext:
|
case mobj_hnext:
|
||||||
|
if (mo->hnext && P_MobjWasRemoved(mo->hnext))
|
||||||
|
{ // don't put invalid mobj back into Lua.
|
||||||
|
P_SetTarget(&mo->hnext, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
LUA_PushUserdata(L, mo->hnext, META_MOBJ);
|
LUA_PushUserdata(L, mo->hnext, META_MOBJ);
|
||||||
break;
|
break;
|
||||||
case mobj_hprev:
|
case mobj_hprev:
|
||||||
// implimented differently from sprev and bprev because SSNTails.
|
if (mo->hprev && P_MobjWasRemoved(mo->hprev))
|
||||||
|
{ // don't put invalid mobj back into Lua.
|
||||||
|
P_SetTarget(&mo->hprev, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
LUA_PushUserdata(L, mo->hprev, META_MOBJ);
|
LUA_PushUserdata(L, mo->hprev, META_MOBJ);
|
||||||
break;
|
break;
|
||||||
case mobj_type:
|
case mobj_type:
|
||||||
|
|
|
@ -476,7 +476,12 @@ static int player_set(lua_State *L)
|
||||||
else if (fastcmp(field,"followitem"))
|
else if (fastcmp(field,"followitem"))
|
||||||
plr->followitem = luaL_checkinteger(L, 3);
|
plr->followitem = luaL_checkinteger(L, 3);
|
||||||
else if (fastcmp(field,"followmobj"))
|
else if (fastcmp(field,"followmobj"))
|
||||||
P_SetTarget(&plr->followmobj, *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)));
|
{
|
||||||
|
mobj_t *mo = NULL;
|
||||||
|
if (!lua_isnil(L, 3))
|
||||||
|
mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
|
||||||
|
P_SetTarget(&plr->followmobj, mo);
|
||||||
|
}
|
||||||
else if (fastcmp(field,"actionspd"))
|
else if (fastcmp(field,"actionspd"))
|
||||||
plr->actionspd = (INT32)luaL_checkinteger(L, 3);
|
plr->actionspd = (INT32)luaL_checkinteger(L, 3);
|
||||||
else if (fastcmp(field,"mindash"))
|
else if (fastcmp(field,"mindash"))
|
||||||
|
@ -560,9 +565,19 @@ static int player_set(lua_State *L)
|
||||||
else if (fastcmp(field,"old_angle_pos"))
|
else if (fastcmp(field,"old_angle_pos"))
|
||||||
plr->old_angle_pos = luaL_checkangle(L, 3);
|
plr->old_angle_pos = luaL_checkangle(L, 3);
|
||||||
else if (fastcmp(field,"axis1"))
|
else if (fastcmp(field,"axis1"))
|
||||||
P_SetTarget(&plr->axis1, *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)));
|
{
|
||||||
|
mobj_t *mo = NULL;
|
||||||
|
if (!lua_isnil(L, 3))
|
||||||
|
mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
|
||||||
|
P_SetTarget(&plr->axis1, mo);
|
||||||
|
}
|
||||||
else if (fastcmp(field,"axis2"))
|
else if (fastcmp(field,"axis2"))
|
||||||
P_SetTarget(&plr->axis2, *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)));
|
{
|
||||||
|
mobj_t *mo = NULL;
|
||||||
|
if (!lua_isnil(L, 3))
|
||||||
|
mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
|
||||||
|
P_SetTarget(&plr->axis2, mo);
|
||||||
|
}
|
||||||
else if (fastcmp(field,"bumpertime"))
|
else if (fastcmp(field,"bumpertime"))
|
||||||
plr->bumpertime = (tic_t)luaL_checkinteger(L, 3);
|
plr->bumpertime = (tic_t)luaL_checkinteger(L, 3);
|
||||||
else if (fastcmp(field,"flyangle"))
|
else if (fastcmp(field,"flyangle"))
|
||||||
|
|
|
@ -1093,7 +1093,10 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *))
|
||||||
{
|
{
|
||||||
P_SetTarget(&bnext, mobj->bnext); // We want to note our reference to bnext here incase it is MF_NOTHINK and gets removed!
|
P_SetTarget(&bnext, mobj->bnext); // We want to note our reference to bnext here incase it is MF_NOTHINK and gets removed!
|
||||||
if (!func(mobj))
|
if (!func(mobj))
|
||||||
|
{
|
||||||
|
P_SetTarget(&bnext, NULL);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
if (P_MobjWasRemoved(tmthing) // func just popped our tmthing, cannot continue.
|
if (P_MobjWasRemoved(tmthing) // func just popped our tmthing, cannot continue.
|
||||||
|| (bnext && P_MobjWasRemoved(bnext))) // func just broke blockmap chain, cannot continue.
|
|| (bnext && P_MobjWasRemoved(bnext))) // func just broke blockmap chain, cannot continue.
|
||||||
{
|
{
|
||||||
|
|
|
@ -3655,7 +3655,8 @@ static void P_DoTeeter(player_t *player)
|
||||||
if (teeter) // only bother with objects as a last resort if you were already teetering
|
if (teeter) // only bother with objects as a last resort if you were already teetering
|
||||||
{
|
{
|
||||||
mobj_t *oldtmthing = tmthing;
|
mobj_t *oldtmthing = tmthing;
|
||||||
tmthing = teeterer = player->mo;
|
teeterer = player->mo;
|
||||||
|
P_SetTarget(&tmthing, teeterer);
|
||||||
teeterxl = teeterxh = player->mo->x;
|
teeterxl = teeterxh = player->mo->x;
|
||||||
teeteryl = teeteryh = player->mo->y;
|
teeteryl = teeteryh = player->mo->y;
|
||||||
couldteeter = false;
|
couldteeter = false;
|
||||||
|
@ -3669,7 +3670,7 @@ static void P_DoTeeter(player_t *player)
|
||||||
}
|
}
|
||||||
teeterdone:
|
teeterdone:
|
||||||
teeter = solidteeter;
|
teeter = solidteeter;
|
||||||
tmthing = oldtmthing; // restore old tmthing, goodness knows what the game does with this before mobj thinkers
|
P_SetTarget(&tmthing, oldtmthing); // restore old tmthing, goodness knows what the game does with this before mobj thinkers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (teeter)
|
if (teeter)
|
||||||
|
|
Loading…
Reference in a new issue