mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-21 10:21:49 +00:00
Add P_GetSectorLightLevelAt
This commit is contained in:
parent
91395fcfc9
commit
eb3129490f
4 changed files with 42 additions and 4 deletions
|
@ -2023,6 +2023,28 @@ static int lib_pCeilingzAtPos(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int lib_pGetSectorLightLevelAt(lua_State *L)
|
||||
{
|
||||
boolean has_sector = false;
|
||||
sector_t *sector = NULL;
|
||||
if (!lua_isnoneornil(L, 1))
|
||||
{
|
||||
has_sector = true;
|
||||
sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR));
|
||||
}
|
||||
fixed_t x = luaL_checkfixed(L, 2);
|
||||
fixed_t y = luaL_checkfixed(L, 3);
|
||||
fixed_t z = luaL_checkfixed(L, 4);
|
||||
INLEVEL
|
||||
if (has_sector && !sector)
|
||||
return LUA_ErrInvalid(L, "sector_t");
|
||||
if (sector)
|
||||
lua_pushinteger(L, P_GetLightLevelFromSectorAt(sector, x, y, z));
|
||||
else
|
||||
lua_pushinteger(L, P_GetSectorLightLevelAt(x, y, z));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_pGetSectorColormapAt(lua_State *L)
|
||||
{
|
||||
boolean has_sector = false;
|
||||
|
@ -4329,6 +4351,7 @@ static luaL_Reg lib[] = {
|
|||
{"P_RadiusAttack",lib_pRadiusAttack},
|
||||
{"P_FloorzAtPos",lib_pFloorzAtPos},
|
||||
{"P_CeilingzAtPos",lib_pCeilingzAtPos},
|
||||
{"P_GetSectorLightLevelAt",lib_pGetSectorLightLevelAt},
|
||||
{"P_GetSectorColormapAt",lib_pGetSectorColormapAt},
|
||||
{"P_DoSpring",lib_pDoSpring},
|
||||
{"P_TouchSpecialThing",lib_pTouchSpecialThing},
|
||||
|
|
|
@ -445,7 +445,9 @@ boolean PIT_PushableMoved(mobj_t *thing);
|
|||
|
||||
boolean P_DoSpring(mobj_t *spring, mobj_t *object);
|
||||
|
||||
INT32 P_GetSectorLightAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z);
|
||||
INT32 P_GetSectorLightNumAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z);
|
||||
INT32 P_GetLightLevelFromSectorAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z);
|
||||
INT32 P_GetSectorLightLevelAt(fixed_t x, fixed_t y, fixed_t z);
|
||||
extracolormap_t *P_GetColormapFromSectorAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z);
|
||||
extracolormap_t *P_GetSectorColormapAt(fixed_t x, fixed_t y, fixed_t z);
|
||||
|
||||
|
|
17
src/p_map.c
17
src/p_map.c
|
@ -5072,7 +5072,7 @@ fixed_t P_CeilingzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
|
|||
return ceilingz;
|
||||
}
|
||||
|
||||
INT32 P_GetSectorLightAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z)
|
||||
INT32 P_GetSectorLightNumAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z)
|
||||
{
|
||||
if (!sector->numlights)
|
||||
return -1;
|
||||
|
@ -5091,10 +5091,23 @@ INT32 P_GetSectorLightAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z)
|
|||
return light;
|
||||
}
|
||||
|
||||
INT32 P_GetLightLevelFromSectorAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z)
|
||||
{
|
||||
if (sector->numlights)
|
||||
return *sector->lightlist[P_GetSectorLightNumAt(sector, x, y, z)].lightlevel;
|
||||
else
|
||||
return sector->lightlevel;
|
||||
}
|
||||
|
||||
INT32 P_GetSectorLightLevelAt(fixed_t x, fixed_t y, fixed_t z)
|
||||
{
|
||||
return P_GetLightLevelFromSectorAt(R_PointInSubsector(x, y)->sector, x, y, z);
|
||||
}
|
||||
|
||||
extracolormap_t *P_GetColormapFromSectorAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z)
|
||||
{
|
||||
if (sector->numlights)
|
||||
return *sector->lightlist[P_GetSectorLightAt(sector, x, y, z)].extra_colormap;
|
||||
return *sector->lightlist[P_GetSectorLightNumAt(sector, x, y, z)].extra_colormap;
|
||||
else
|
||||
return sector->extra_colormap;
|
||||
}
|
||||
|
|
|
@ -2134,7 +2134,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
|
||||
if (thing->subsector->sector->numlights)
|
||||
{
|
||||
light = P_GetSectorLightAt(thing->subsector->sector, interp.x, interp.y, splat ? gz : gzt);
|
||||
light = P_GetSectorLightNumAt(thing->subsector->sector, interp.x, interp.y, splat ? gz : gzt);
|
||||
|
||||
INT32 lightnum = (*thing->subsector->sector->lightlist[light].lightlevel >> LIGHTSEGSHIFT);
|
||||
if (lightnum < 0)
|
||||
|
|
Loading…
Reference in a new issue