Merge branch 'public_next'

This commit is contained in:
Monster Iestyn 2016-05-06 18:06:18 +01:00
commit 01debc27a2
19 changed files with 815 additions and 196 deletions

View file

@ -30,8 +30,8 @@ addons:
before_script:
- mkdir -p $HOME/srb2_cache
- wget --verbose --server-response -c http://rosenthalcastle.org/srb2/SRB2-v2114-assets.7z -O $HOME/srb2_cache/SRB2-v2114-assets.7z
- 7z x $HOME/srb2_cache/SRB2-v2114-assets.7z -oassets
- wget --verbose --server-response -c http://rosenthalcastle.org/srb2/SRB2-v2115-assets-2.7z -O $HOME/srb2_cache/SRB2-v2115-assets-2.7z
- 7z x $HOME/srb2_cache/SRB2-v2115-assets-2.7z -oassets
- mkdir build
- cd build
- cmake ..

View file

@ -29,14 +29,14 @@
#else
/* Manually defined asset hashes for non-CMake builds
* Last updated 2000 / 00 / 00
* Last updated 2015 / 05 / 03
*/
#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7"
#define ASSET_HASH_ZONES_DTA "303838c6c534d9540288360fa49cca60"
#define ASSET_HASH_PLAYER_DTA "cfca0f1c73023cbbd8f844f45480f799"
#define ASSET_HASH_RINGS_DTA "85901ad4bf94637e5753d2ac2c03ea26"
#ifdef USE_PATCH_DTA
#define ASSET_HASH_PATCH_DTA "0c66790502e648bfce90fdc5bb15722e"
#define ASSET_HASH_PATCH_DTA "dbbf8bc6121618ee3be2d5b14650429b"
#endif
#endif

View file

@ -1113,6 +1113,13 @@ static void SendNameAndColor(void)
players[consoleplayer].mo->color = (UINT8)players[consoleplayer].skincolor;
}
}
else
{
cv_skin.value = players[consoleplayer].skin;
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name);
// will always be same as current
SetPlayerSkin(consoleplayer, cv_skin.string);
}
return;
}
@ -1230,6 +1237,13 @@ static void SendNameAndColor2(void)
players[secondplaya].mo->color = players[secondplaya].skincolor;
}
}
else
{
cv_skin2.value = players[secondplaya].skin;
CV_StealthSet(&cv_skin2, skins[players[secondplaya].skin].name);
// will always be same as current
SetPlayerSkin(secondplaya, cv_skin2.string);
}
return;
}

File diff suppressed because it is too large Load diff

View file

@ -287,8 +287,8 @@ static int lib_pSpawnMobj(lua_State *L)
fixed_t z = luaL_checkfixed(L, 3);
mobjtype_t type = luaL_checkinteger(L, 4);
NOHUD
if (type > MT_LASTFREESLOT)
return luaL_error(L, "mobjtype_t out of bounds error!");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SpawnMobj(x, y, z, type), META_MOBJ);
return 1;
}
@ -313,8 +313,8 @@ static int lib_pSpawnMissile(lua_State *L)
NOHUD
if (!source || !dest)
return LUA_ErrInvalid(L, "mobj_t");
if (type > MT_LASTFREESLOT)
return luaL_error(L, "mobjtype_t out of bounds error!");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SpawnMissile(source, dest, type), META_MOBJ);
return 1;
}
@ -330,8 +330,8 @@ static int lib_pSpawnXYZMissile(lua_State *L)
NOHUD
if (!source || !dest)
return LUA_ErrInvalid(L, "mobj_t");
if (type > MT_LASTFREESLOT)
return luaL_error(L, "mobjtype_t out of bounds error!");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SpawnXYZMissile(source, dest, type, x, y, z), META_MOBJ);
return 1;
}
@ -349,8 +349,8 @@ static int lib_pSpawnPointMissile(lua_State *L)
NOHUD
if (!source)
return LUA_ErrInvalid(L, "mobj_t");
if (type > MT_LASTFREESLOT)
return luaL_error(L, "mobjtype_t out of bounds error!");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SpawnPointMissile(source, xa, ya, za, type, x, y, z), META_MOBJ);
return 1;
}
@ -366,8 +366,8 @@ static int lib_pSpawnAlteredDirectionMissile(lua_State *L)
NOHUD
if (!source)
return LUA_ErrInvalid(L, "mobj_t");
if (type > MT_LASTFREESLOT)
return luaL_error(L, "mobjtype_t out of bounds error!");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SpawnAlteredDirectionMissile(source, type, x, y, z, shiftingAngle), META_MOBJ);
return 1;
}
@ -395,8 +395,8 @@ static int lib_pSPMAngle(lua_State *L)
NOHUD
if (!source)
return LUA_ErrInvalid(L, "mobj_t");
if (type > MT_LASTFREESLOT)
return luaL_error(L, "mobjtype_t out of bounds error!");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SPMAngle(source, type, angle, allowaim, flags2), META_MOBJ);
return 1;
}
@ -409,8 +409,8 @@ static int lib_pSpawnPlayerMissile(lua_State *L)
NOHUD
if (!source)
return LUA_ErrInvalid(L, "mobj_t");
if (type > MT_LASTFREESLOT)
return luaL_error(L, "mobjtype_t out of bounds error!");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SpawnPlayerMissile(source, type, flags2), META_MOBJ);
return 1;
}
@ -429,8 +429,8 @@ static int lib_pWeaponOrPanel(lua_State *L)
{
mobjtype_t type = luaL_checkinteger(L, 1);
//HUDSAFE
if (type > MT_LASTFREESLOT)
return luaL_error(L, "mobjtype_t out of bounds error!");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
lua_pushboolean(L, P_WeaponOrPanel(type));
return 1;
}
@ -469,8 +469,10 @@ static int lib_pSpawnParaloop(lua_State *L)
statenum_t nstate = luaL_optinteger(L, 8, S_NULL);
boolean spawncenter = lua_optboolean(L, 9);
NOHUD
if (type > MT_LASTFREESLOT)
return luaL_error(L, "mobjtype_t out of bounds error!");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
if (nstate >= NUMSTATES)
return luaL_error(L, "state %d out of range (0 - %d)", nstate, NUMSTATES-1);
P_SpawnParaloop(x, y, z, radius, number, type, nstate, rotangle, spawncenter);
return 0;
}
@ -900,8 +902,8 @@ static int lib_pSpawnSpinMobj(lua_State *L)
NOHUD
if (!player)
return LUA_ErrInvalid(L, "player_t");
if (type > MT_LASTFREESLOT)
return luaL_error(L, "mobjtype_t out of bounds error!");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
P_SpawnSpinMobj(player, type);
return 0;
}
@ -1270,6 +1272,8 @@ static int lib_pSetMobjStateNF(lua_State *L)
NOHUD
if (!mobj)
return LUA_ErrInvalid(L, "mobj_t");
if (state >= NUMSTATES)
return luaL_error(L, "state %d out of range (0 - %d)", state, NUMSTATES-1);
if (mobj->player && state == S_NULL)
return luaL_error(L, "Attempt to remove player mobj with S_NULL.");
lua_pushboolean(L, P_SetMobjStateNF(mobj, state));
@ -1381,8 +1385,8 @@ static int lib_pIsFlagAtBase(lua_State *L)
{
mobjtype_t flag = luaL_checkinteger(L, 1);
NOHUD
if (flag > MT_LASTFREESLOT)
return luaL_error(L, "mobjtype_t out of bounds error!");
if (flag >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", flag, NUMMOBJTYPES-1);
lua_pushboolean(L, P_IsFlagAtBase(flag));
return 1;
}
@ -1615,7 +1619,7 @@ static int lib_rSetPlayerSkin(lua_State *L)
{
INT32 i = luaL_checkinteger(L, 2);
if (i < 0 || i >= MAXSKINS)
return luaL_error(L, "argument #2 cannot exceed MAXSKINS");
return luaL_error(L, "skin number (argument #2) %d out of range (0 - %d)", i, MAXSKINS-1);
SetPlayerSkinByNum(player-players, i);
}
else // skin name
@ -1635,6 +1639,8 @@ static int lib_sStartSound(lua_State *L)
sfxenum_t sound_id = luaL_checkinteger(L, 2);
player_t *player = NULL;
NOHUD
if (sound_id >= NUMSFX)
return luaL_error(L, "sfx %d out of range (0 - %d)", sound_id, NUMSFX-1);
if (!lua_isnil(L, 1))
{
origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@ -1659,12 +1665,15 @@ static int lib_sStartSoundAtVolume(lua_State *L)
INT32 volume = (INT32)luaL_checkinteger(L, 3);
player_t *player = NULL;
NOHUD
if (!lua_isnil(L, 1))
{
origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
if (!origin)
return LUA_ErrInvalid(L, "mobj_t");
}
if (sound_id >= NUMSFX)
return luaL_error(L, "sfx %d out of range (0 - %d)", sound_id, NUMSFX-1);
if (!lua_isnone(L, 4) && lua_isuserdata(L, 4))
{
player = *((player_t **)luaL_checkudata(L, 4, META_PLAYER));
@ -1796,6 +1805,8 @@ static int lib_sIdPlaying(lua_State *L)
{
sfxenum_t id = luaL_checkinteger(L, 1);
NOHUD
if (id >= NUMSFX)
return luaL_error(L, "sfx %d out of range (0 - %d)", id, NUMSFX-1);
lua_pushboolean(L, S_IdPlaying(id));
return 1;
}
@ -1807,6 +1818,8 @@ static int lib_sSoundPlaying(lua_State *L)
NOHUD
if (!origin)
return LUA_ErrInvalid(L, "mobj_t");
if (id >= NUMSFX)
return luaL_error(L, "sfx %d out of range (0 - %d)", id, NUMSFX-1);
lua_pushboolean(L, S_SoundPlaying(origin, id));
return 1;
}
@ -1827,7 +1840,7 @@ static int lib_gDoReborn(lua_State *L)
INT32 playernum = luaL_checkinteger(L, 1);
NOHUD
if (playernum >= MAXPLAYERS)
return luaL_error(L, "playernum out of bounds error!");
return luaL_error(L, "playernum %d out of range (0 - %d)", playernum, MAXPLAYERS-1);
G_DoReborn(playernum);
return 0;
}

View file

@ -166,6 +166,8 @@ static int lib_getHudInfo(lua_State *L)
lua_remove(L, 1);
i = luaL_checkinteger(L, 1);
if (i >= NUMHUDITEMS)
return luaL_error(L, "hudinfo[] index %d out of range (0 - %d)", i, NUMHUDITEMS-1);
LUA_PushUserdata(L, &hudinfo[i], META_HUDINFO);
return 1;
}
@ -526,6 +528,22 @@ static int libd_height(lua_State *L)
return 1;
}
static int libd_dupx(lua_State *L)
{
HUDONLY
lua_pushinteger(L, vid.dupx); // push integral scale (patch scale)
lua_pushfixed(L, vid.fdupx); // push fixed point scale (position scale)
return 2;
}
static int libd_dupy(lua_State *L)
{
HUDONLY
lua_pushinteger(L, vid.dupy); // push integral scale (patch scale)
lua_pushfixed(L, vid.fdupy); // push fixed point scale (position scale)
return 2;
}
static int libd_renderer(lua_State *L)
{
HUDONLY
@ -550,6 +568,8 @@ static luaL_Reg lib_draw[] = {
{"getColormap", libd_getColormap},
{"width", libd_width},
{"height", libd_height},
{"dupx", libd_dupx},
{"dupy", libd_dupy},
{"renderer", libd_renderer},
{NULL, NULL}
};

View file

@ -184,6 +184,8 @@ static int lib_getState(lua_State *L)
lua_remove(L, 1);
i = luaL_checkinteger(L, 1);
if (i >= NUMSTATES)
return luaL_error(L, "states[] index %d out of range (0 - %d)", i, NUMSTATES-1);
LUA_PushUserdata(L, &states[i], META_STATE);
return 1;
}
@ -193,7 +195,12 @@ static int lib_setState(lua_State *L)
{
state_t *state;
lua_remove(L, 1); // don't care about states[] userdata.
state = &states[luaL_checkinteger(L, 1)]; // get the state to assign to.
{
UINT32 i = luaL_checkinteger(L, 1);
if (i >= NUMSTATES)
return luaL_error(L, "states[] index %d out of range (0 - %d)", i, NUMSTATES-1);
state = &states[i]; // get the state to assign to.
}
luaL_checktype(L, 2, LUA_TTABLE); // check that we've been passed a table.
lua_remove(L, 1); // pop state num, don't need it any more.
lua_settop(L, 1); // cut the stack here. the only thing left now is the table of data we're assigning to the state.
@ -474,6 +481,8 @@ static int lib_getMobjInfo(lua_State *L)
lua_remove(L, 1);
i = luaL_checkinteger(L, 1);
if (i >= NUMMOBJTYPES)
return luaL_error(L, "mobjinfo[] index %d out of range (0 - %d)", i, NUMMOBJTYPES-1);
LUA_PushUserdata(L, &mobjinfo[i], META_MOBJINFO);
return 1;
}
@ -483,7 +492,12 @@ static int lib_setMobjInfo(lua_State *L)
{
mobjinfo_t *info;
lua_remove(L, 1); // don't care about mobjinfo[] userdata.
info = &mobjinfo[luaL_checkinteger(L, 1)]; // get the mobjinfo to assign to.
{
UINT32 i = luaL_checkinteger(L, 1);
if (i >= NUMMOBJTYPES)
return luaL_error(L, "mobjinfo[] index %d out of range (0 - %d)", i, NUMMOBJTYPES-1);
info = &mobjinfo[i]; // get the mobjinfo to assign to.
}
luaL_checktype(L, 2, LUA_TTABLE); // check that we've been passed a table.
lua_remove(L, 1); // pop mobjtype num, don't need it any more.
lua_settop(L, 1); // cut the stack here. the only thing left now is the table of data we're assigning to the mobjinfo.
@ -755,6 +769,8 @@ static int lib_getSfxInfo(lua_State *L)
lua_remove(L, 1);
i = luaL_checkinteger(L, 1);
if (i >= NUMSFX)
return luaL_error(L, "sfxinfo[] index %d out of range (0 - %d)", i, NUMSFX-1);
LUA_PushUserdata(L, &S_sfx[i], META_SFXINFO);
return 1;
}
@ -765,7 +781,12 @@ static int lib_setSfxInfo(lua_State *L)
sfxinfo_t *info;
lua_remove(L, 1);
info = &S_sfx[luaL_checkinteger(L, 1)]; // get the mobjinfo to assign to.
{
UINT32 i = luaL_checkinteger(L, 1);
if (i >= NUMSFX)
return luaL_error(L, "sfxinfo[] index %d out of range (0 - %d)", i, NUMSFX-1);
info = &S_sfx[i]; // get the mobjinfo to assign to.
}
luaL_checktype(L, 2, LUA_TTABLE); // check that we've been passed a table.
lua_remove(L, 1); // pop mobjtype num, don't need it any more.
lua_settop(L, 1); // cut the stack here. the only thing left now is the table of data we're assigning to the mobjinfo.

View file

@ -32,13 +32,17 @@ static int lib_abs(lua_State *L)
static int lib_min(lua_State *L)
{
lua_pushinteger(L, min(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)));
int a = luaL_checkinteger(L, 1);
int b = luaL_checkinteger(L, 2);
lua_pushinteger(L, min(a,b));
return 1;
}
static int lib_max(lua_State *L)
{
lua_pushinteger(L, max(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)));
int a = luaL_checkinteger(L, 1);
int b = luaL_checkinteger(L, 2);
lua_pushinteger(L, max(a,b));
return 1;
}

View file

@ -55,7 +55,7 @@ static int lib_getPlayer(lua_State *L)
{
lua_Integer i = luaL_checkinteger(L, 2);
if (i < 0 || i >= MAXPLAYERS)
return luaL_error(L, "players[] index cannot exceed MAXPLAYERS");
return luaL_error(L, "players[] index %d out of range (0 - %d)", i, MAXPLAYERS-1);
if (!playeringame[i])
return 0;
if (!players[i].mo)

View file

@ -244,7 +244,7 @@ static int lib_getSkin(lua_State *L)
{
i = luaL_checkinteger(L, 2);
if (i < 0 || i >= MAXSKINS)
return luaL_error(L, "skins[] index cannot exceed MAXSKINS");
return luaL_error(L, "skins[] index %d out of range (0 - %d)", i, MAXSKINS-1);
if (i >= numskins)
return 0;
LUA_PushUserdata(L, &skins[i], META_SKIN);

View file

@ -1787,17 +1787,6 @@ UINT8 M_CountBits(UINT32 num, UINT8 size)
return sum;
}
/** Get the most significant bit in a number.
* (integer log2)
*/
UINT8 M_HighestBit(UINT32 num)
{
UINT8 i = 0;
while (num >>= 1) ++i;
return i;
}
const char *GetRevisionString(void)
{
static char rev[9] = {0};

View file

@ -95,7 +95,6 @@ void M_SetupMemcpy(void);
// counting bits, for weapon ammo code, usually
FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size);
FUNCMATH UINT8 M_HighestBit(UINT32 num);
// Flags for AA trees.
#define AATREE_ZUSER 1 // Treat values as z_zone-allocated blocks and set their user fields

View file

@ -1979,22 +1979,28 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
else if (tmceilingz < thingtop && thingtop - tmceilingz <= maxstep)
#ifdef ESLOPE
// HACK TO FIX DSZ2: apply only if slopes are involved
else if (tmceilingslope && tmceilingz < thingtop && thingtop - tmceilingz <= maxstep)
{
thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
#endif
}
else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep)
{
thing->z = thing->floorz = tmfloorz;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
else if (tmfloorz > thing->z && tmfloorz - thing->z <= maxstep)
#ifdef ESLOPE
// HACK TO FIX DSZ2: apply only if slopes are involved
else if (tmfloorslope && tmfloorz > thing->z && tmfloorz - thing->z <= maxstep)
{
thing->z = thing->floorz = tmfloorz;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
#endif
}
if (thing->eflags & MFE_VERTICALFLIP)

View file

@ -1133,7 +1133,9 @@ void P_ButteredSlope(mobj_t *mo)
// This makes it harder to zigzag up steep slopes, as well as allows greater top speed when rolling down
// Multiply by gravity
thrust = FixedMul(thrust, FRACUNIT/2); // TODO actually get this
thrust = FixedMul(thrust, gravity); // TODO account for per-sector gravity etc
// Multiply by scale (gravity strength depends on mobj scale)
thrust = FixedMul(thrust, mo->scale);
P_Thrust(mo, mo->standingslope->xydirection, thrust);
}

View file

@ -6873,7 +6873,7 @@ static void P_MovePlayer(player_t *player)
}
}
// Super Sonic move
if (player->charflags & SF_SUPER && player->powers[pw_super] && player->speed > FixedMul(5<<FRACBITS, player->mo->scale)
if (player->skin == 0 && player->powers[pw_super] && player->speed > FixedMul(5<<FRACBITS, player->mo->scale)
&& P_MobjFlip(player->mo)*player->mo->momz <= 0)
{
if (player->panim == PA_ROLL || player->mo->state-states == S_PLAY_PAIN || player->panim == PA_WALK)

View file

@ -299,7 +299,7 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
}
length = FixedMul (distance,distscale[x1]);
angle = (currentplane->viewangle + xtoviewangle[x1])>>ANGLETOFINESHIFT;
angle = (currentplane->viewangle + currentplane->plangle + xtoviewangle[x1])>>ANGLETOFINESHIFT;
/// \note Wouldn't it be faster just to add viewx and viewy
// to the plane's x/yoffs anyway??
@ -475,7 +475,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
&& lightlevel == check->lightlevel
&& xoff == check->xoffs && yoff == check->yoffs
&& planecolormap == check->extra_colormap
&& !pfloor && !check->ffloor && check->viewz == viewz
&& !pfloor && !check->ffloor
&& check->viewx == viewx && check->viewy == viewy && check->viewz == viewz
&& check->viewangle == viewangle
#ifdef ESLOPE
&& check->slope == slope
@ -497,8 +498,10 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
check->yoffs = yoff;
check->extra_colormap = planecolormap;
check->ffloor = pfloor;
check->viewx = viewx;
check->viewy = viewy;
check->viewz = viewz;
check->viewangle = viewangle + plangle;
check->viewangle = viewangle;
check->plangle = plangle;
#ifdef POLYOBJECTS_PLANES
check->polyobj = NULL;
@ -567,6 +570,8 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
new_pl->yoffs = pl->yoffs;
new_pl->extra_colormap = pl->extra_colormap;
new_pl->ffloor = pl->ffloor;
new_pl->viewx = pl->viewx;
new_pl->viewy = pl->viewy;
new_pl->viewz = pl->viewz;
new_pl->viewangle = pl->viewangle;
new_pl->plangle = pl->plangle;
@ -665,7 +670,6 @@ void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2)
void R_DrawPlanes(void)
{
visplane_t *pl;
angle_t skyviewangle = viewangle; // the flat angle itself can mess with viewangle, so do your own angle instead!
INT32 x;
INT32 angle;
INT32 i;
@ -704,7 +708,7 @@ void R_DrawPlanes(void)
if (dc_yl <= dc_yh)
{
angle = (skyviewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT;
angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT;
dc_x = x;
dc_source =
R_GetColumn(skytexture,
@ -857,13 +861,13 @@ void R_DrawSinglePlane(visplane_t *pl)
#ifdef ESLOPE
if (!pl->slope) // Don't mess with angle on slopes! We'll handle this ourselves later
#endif
if (viewangle != pl->viewangle)
if (viewangle != pl->viewangle+pl->plangle)
{
memset(cachedheight, 0, sizeof (cachedheight));
angle = (pl->viewangle-ANGLE_90)>>ANGLETOFINESHIFT;
angle = (pl->viewangle+pl->plangle-ANGLE_90)>>ANGLETOFINESHIFT;
basexscale = FixedDiv(FINECOSINE(angle),centerxfrac);
baseyscale = -FixedDiv(FINESINE(angle),centerxfrac);
viewangle = pl->viewangle;
viewangle = pl->viewangle+pl->plangle;
}
currentplane = pl;
@ -954,11 +958,11 @@ void R_DrawSinglePlane(visplane_t *pl)
xoffs *= fudge;
yoffs /= fudge;
vx = FIXED_TO_FLOAT(viewx+xoffs);
vy = FIXED_TO_FLOAT(viewy-yoffs);
vz = FIXED_TO_FLOAT(viewz);
vx = FIXED_TO_FLOAT(pl->viewx+xoffs);
vy = FIXED_TO_FLOAT(pl->viewy-yoffs);
vz = FIXED_TO_FLOAT(pl->viewz);
temp = P_GetZAt(pl->slope, viewx, viewy);
temp = P_GetZAt(pl->slope, pl->viewx, pl->viewy);
zeroheight = FIXED_TO_FLOAT(temp);
#define ANG2RAD(angle) ((float)((angle)*M_PI)/ANGLE_180)
@ -966,14 +970,14 @@ void R_DrawSinglePlane(visplane_t *pl)
// p is the texture origin in view space
// Don't add in the offsets at this stage, because doing so can result in
// errors if the flat is rotated.
ang = ANG2RAD(ANGLE_270 - viewangle);
ang = ANG2RAD(ANGLE_270 - pl->viewangle);
p.x = vx * cos(ang) - vy * sin(ang);
p.z = vx * sin(ang) + vy * cos(ang);
temp = P_GetZAt(pl->slope, -xoffs, yoffs);
p.y = FIXED_TO_FLOAT(temp) - vz;
// m is the v direction vector in view space
ang = ANG2RAD(ANGLE_180 - viewangle - pl->plangle);
ang = ANG2RAD(ANGLE_180 - (pl->viewangle + pl->plangle));
m.x = cos(ang);
m.z = sin(ang);
@ -982,9 +986,9 @@ void R_DrawSinglePlane(visplane_t *pl)
n.z = -cos(ang);
ang = ANG2RAD(pl->plangle);
temp = P_GetZAt(pl->slope, viewx + FLOAT_TO_FIXED(sin(ang)), viewy + FLOAT_TO_FIXED(cos(ang)));
temp = P_GetZAt(pl->slope, pl->viewx + FLOAT_TO_FIXED(sin(ang)), pl->viewy + FLOAT_TO_FIXED(cos(ang)));
m.y = FIXED_TO_FLOAT(temp) - zeroheight;
temp = P_GetZAt(pl->slope, viewx + FLOAT_TO_FIXED(cos(ang)), viewy - FLOAT_TO_FIXED(sin(ang)));
temp = P_GetZAt(pl->slope, pl->viewx + FLOAT_TO_FIXED(cos(ang)), pl->viewy - FLOAT_TO_FIXED(sin(ang)));
n.y = FIXED_TO_FLOAT(temp) - zeroheight;
m.x /= fudge;
@ -1040,6 +1044,14 @@ void R_DrawSinglePlane(visplane_t *pl)
stop = pl->maxx + 1;
if (viewx != pl->viewx || viewy != pl->viewy)
{
viewx = pl->viewx;
viewy = pl->viewy;
}
if (viewz != pl->viewz)
viewz = pl->viewz;
for (x = pl->minx; x <= stop; x++)
{
R_MakeSpans(x, pl->top[x-1], pl->bottom[x-1],

View file

@ -27,7 +27,8 @@ typedef struct visplane_s
{
struct visplane_s *next;
fixed_t height, viewz;
fixed_t height;
fixed_t viewx, viewy, viewz;
angle_t viewangle;
angle_t plangle;
INT32 picnum;

View file

@ -288,6 +288,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
line_t *ldef;
sector_t *front, *back;
INT32 times, repeats;
INT64 overflow_test;
#ifdef ESLOPE
INT32 range;
#endif
@ -485,7 +486,6 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep;
}
#ifndef ESLOPE
if (curline->linedef->flags & ML_DONTPEGBOTTOM)
{
@ -523,6 +523,24 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
// calculate lighting
if (maskedtexturecol[dc_x] != INT16_MAX)
{
// Check for overflows first
overflow_test = (INT64)centeryfrac - (((INT64)dc_texturemid*spryscale)>>FRACBITS);
if (overflow_test < 0) overflow_test = -overflow_test;
if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL)
{
// Eh, no, go away, don't waste our time
if (dc_numlights)
{
for (i = 0; i < dc_numlights; i++)
{
rlight = &dc_lightlist[i];
rlight->height += rlight->heightstep;
}
}
spryscale += rw_scalestep;
continue;
}
if (dc_numlights)
{
lighttable_t **xwalllights;
@ -708,7 +726,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
line_t *newline = NULL;
#ifdef ESLOPE
// Render FOF sides kinda like normal sides, with the frac and step and everything
fixed_t top_frac, top_step, bottom_frac, bottom_step;
// NOTE: INT64 instead of fixed_t because overflow concerns
INT64 top_frac, top_step, bottom_frac, bottom_step;
#endif
void (*colfunc_2s) (column_t *);
@ -788,6 +807,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
#ifdef ESLOPE
fixed_t leftheight, rightheight;
fixed_t pfloorleft, pfloorright;
INT64 overflow_test;
#endif
light = &frontsector->lightlist[i];
rlight = &dc_lightlist[p];
@ -823,6 +843,14 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
leftheight -= viewz;
rightheight -= viewz;
overflow_test = (INT64)centeryfrac - (((INT64)leftheight*ds->scale1)>>FRACBITS);
if (overflow_test < 0) overflow_test = -overflow_test;
if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) continue;
overflow_test = (INT64)centeryfrac - (((INT64)rightheight*ds->scale2)>>FRACBITS);
if (overflow_test < 0) overflow_test = -overflow_test;
if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) continue;
rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1);
rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2);
rlight->heightstep = (rlight->heightstep-rlight->height)/(range);
@ -832,7 +860,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
continue;
if (light->height > *pfloor->topheight && i+1 < dc_numlights && frontsector->lightlist[i+1].height > *pfloor->topheight)
continue;
continue;
lheight = light->height;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : light->height;
rlight->heightstep = -FixedMul (rw_scalestep, (lheight - viewz));
@ -851,6 +879,13 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
leftheight -= viewz;
rightheight -= viewz;
overflow_test = (INT64)centeryfrac - (((INT64)leftheight*ds->scale1)>>FRACBITS);
if (overflow_test < 0) overflow_test = -overflow_test;
if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) continue;
overflow_test = (INT64)centeryfrac - (((INT64)rightheight*ds->scale2)>>FRACBITS);
if (overflow_test < 0) overflow_test = -overflow_test;
if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) continue;
rlight->botheight = (centeryfrac) - FixedMul(leftheight, ds->scale1);
rlight->botheightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2);
rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range);
@ -948,20 +983,27 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
{
fixed_t left_top, right_top, left_bottom, right_bottom;
left_top = *pfloor->t_slope ? P_GetZAt(*pfloor->t_slope, ds->leftpos.x, ds->leftpos.y) : *pfloor->topheight;
right_top = *pfloor->t_slope ? P_GetZAt(*pfloor->t_slope, ds->rightpos.x, ds->rightpos.y) : *pfloor->topheight;
left_bottom = *pfloor->b_slope ? P_GetZAt(*pfloor->b_slope, ds->leftpos.x, ds->leftpos.y) : *pfloor->bottomheight;
right_bottom = *pfloor->b_slope ? P_GetZAt(*pfloor->b_slope, ds->rightpos.x, ds->rightpos.y) : *pfloor->bottomheight;
if (*pfloor->t_slope)
{
left_top = P_GetZAt(*pfloor->t_slope, ds->leftpos.x, ds->leftpos.y) - viewz;
right_top = P_GetZAt(*pfloor->t_slope, ds->rightpos.x, ds->rightpos.y) - viewz;
}
else
left_top = right_top = *pfloor->topheight - viewz;
left_top -= viewz;
right_top -= viewz;
left_bottom -= viewz;
right_bottom -= viewz;
if (*pfloor->b_slope)
{
left_bottom = P_GetZAt(*pfloor->b_slope, ds->leftpos.x, ds->leftpos.y) - viewz;
right_bottom = P_GetZAt(*pfloor->b_slope, ds->rightpos.x, ds->rightpos.y) - viewz;
}
else
left_bottom = right_bottom = *pfloor->bottomheight - viewz;
top_frac = centeryfrac - FixedMul(left_top, ds->scale1);
bottom_frac = centeryfrac - FixedMul(left_bottom, ds->scale1);
top_step = centeryfrac - FixedMul(right_top, ds->scale2);
bottom_step = centeryfrac - FixedMul(right_bottom, ds->scale2);
// using INT64 to avoid 32bit overflow
top_frac = (INT64)centeryfrac - (((INT64)left_top * ds->scale1) >> FRACBITS);
bottom_frac = (INT64)centeryfrac - (((INT64)left_bottom * ds->scale1) >> FRACBITS);
top_step = (INT64)centeryfrac - (((INT64)right_top * ds->scale2) >> FRACBITS);
bottom_step = (INT64)centeryfrac - (((INT64)right_bottom * ds->scale2) >> FRACBITS);
top_step = (top_step-top_frac)/(range);
bottom_step = (bottom_step-bottom_frac)/(range);
@ -971,6 +1013,9 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
}
#endif
#define CLAMPMAX INT32_MAX
#define CLAMPMIN (-INT32_MAX) // This is not INT32_MIN on purpose! INT32_MIN makes the drawers freak out.
// draw the columns
for (dc_x = x1; dc_x <= x2; dc_x++)
{
@ -987,8 +1032,12 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
INT32 lighteffect = 0;
#ifdef ESLOPE
sprtopscreen = windowtop = top_frac;
sprbotscreen = windowbottom = bottom_frac;
if (top_frac > (INT64)CLAMPMAX) sprtopscreen = windowtop = CLAMPMAX;
else if (top_frac > (INT64)CLAMPMIN) sprtopscreen = windowtop = (fixed_t)top_frac;
else sprtopscreen = windowtop = CLAMPMIN;
if (bottom_frac > (INT64)CLAMPMAX) sprbotscreen = windowbottom = CLAMPMAX;
else if (bottom_frac > (INT64)CLAMPMIN) sprbotscreen = windowbottom = (fixed_t)bottom_frac;
else sprbotscreen = windowbottom = CLAMPMIN;
top_frac += top_step;
bottom_frac += bottom_step;
@ -1133,22 +1182,13 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
if (pfloor->flags & FF_FOG && pfloor->master->frontsector->extra_colormap)
dc_colormap = pfloor->master->frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
//Handle over/underflows before they happen. This fixes the textures part of the FOF rendering bug.
//...for the most part, anyway.
if (((signed)dc_texturemid > 0 && (spryscale>>FRACBITS > INT32_MAX / (signed)dc_texturemid))
|| ((signed)dc_texturemid < 0 && (spryscale) && (signed)(dc_texturemid)>>FRACBITS < (INT32_MIN / spryscale)))
{
spryscale += rw_scalestep;
#ifdef ESLOPE
top_frac += top_step;
bottom_frac += bottom_step;
#endif
continue;
}
#ifdef ESLOPE
sprtopscreen = windowtop = top_frac;
sprbotscreen = windowbottom = bottom_frac;
if (top_frac > (INT64)CLAMPMAX) sprtopscreen = windowtop = CLAMPMAX;
else if (top_frac > (INT64)CLAMPMIN) sprtopscreen = windowtop = (fixed_t)top_frac;
else sprtopscreen = windowtop = CLAMPMIN;
if (bottom_frac > (INT64)CLAMPMAX) sprbotscreen = windowbottom = CLAMPMAX;
else if (bottom_frac > (INT64)CLAMPMIN) sprbotscreen = windowbottom = (fixed_t)bottom_frac;
else sprbotscreen = windowbottom = CLAMPMIN;
top_frac += top_step;
bottom_frac += bottom_step;
@ -1167,6 +1207,9 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
}
}
colfunc = wallcolfunc;
#undef CLAMPMAX
#undef CLAMPMIN
}
//
@ -2046,13 +2089,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
markceiling = false;
}
#ifdef ESLOPE
if ((worldhigh <= worldbottom && worldhighslope <= worldbottomslope)
|| (worldlow >= worldtop && worldlowslope >= worldtopslope))
#else
if (backsector->ceilingheight <= frontsector->floorheight ||
backsector->floorheight >= frontsector->ceilingheight)
#endif
{
// closed door
markceiling = markfloor = true;

View file

@ -748,10 +748,16 @@ static void R_DrawVisSprite(vissprite_t *vis)
patch_t *patch = W_CacheLumpNum(vis->patch, PU_CACHE);
fixed_t this_scale = vis->mobj->scale;
INT32 x1, x2;
INT64 overflow_test;
if (!patch)
return;
// Check for overflow
overflow_test = (INT64)centeryfrac - (((INT64)vis->texturemid*vis->scale)>>FRACBITS);
if (overflow_test < 0) overflow_test = -overflow_test;
if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) return; // fixed point mult would overflow
colfunc = basecolfunc; // hack: this isn't resetting properly somewhere.
dc_colormap = vis->colormap;
if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash"
@ -1248,15 +1254,6 @@ static void R_ProjectSprite(mobj_t *thing)
return;
}
// quick check for possible overflows
// if either of these triggers then there's a possibility that drawing is unsafe
if (M_HighestBit(abs(gzt - viewz)) + M_HighestBit(abs(yscale)) > 47 // 31 bits + 16 from the division by FRACUNIT
|| M_HighestBit(abs(gz - viewz)) + M_HighestBit(abs(yscale)) > 47)
{
CONS_Debug(DBG_RENDER, "Suspected overflow in ProjectSprite (sprite %s), ignoring\n", sprnames[thing->sprite]);
return;
}
// store information in a vissprite
vis = R_NewVisSprite();
vis->heightsec = heightsec; //SoM: 3/17/2000
@ -1467,14 +1464,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
return;
}
// quick check for possible overflows
// if either of these triggers then there's a possibility that drawing is unsafe
if (M_HighestBit(abs(gzt - viewz)) + M_HighestBit(abs(yscale)) > 47) // 31 bits + 16 from the division by FRACUNIT
{
CONS_Debug(DBG_RENDER, "Suspected overflow in ProjectPrecipitationSprite (sprite %s), ignoring\n", sprnames[thing->sprite]);
return;
}
// store information in a vissprite
vis = R_NewVisSprite();
vis->scale = yscale; //<<detailshift;