From 7830a9e27baa14c6ad9318669ff6129446071d51 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 10 Apr 2016 20:27:55 +0100 Subject: [PATCH 1/6] Splitscreen fix: half of GFZ1's invinc monitor should no longer appear above the bridge for player 2 I don't know if there's any other vid.height/viewheight confusion like this around, but that was the cause apparently --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 5616c2224..2ec2f6ead 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -964,7 +964,7 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->scale))>>FRACBITS); if (cutfrac < 0) continue; - if (cutfrac > vid.height) + if (cutfrac > viewheight) return; // Found a split! Make a new sprite, copy the old sprite to it, and From f96b830f36916d71ec78e24f91d202401b586933 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 16 Apr 2016 18:06:26 +0100 Subject: [PATCH 2/6] Write/read FOF flags as 32-bit not 16-bit, whoops --- src/p_saveg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index e0112bb79..952e567d7 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -613,7 +613,7 @@ static void P_NetArchiveWorld(void) WRITEUINT16(put, j); // save ffloor "number" WRITEUINT8(put, fflr_diff); if (fflr_diff & 1) - WRITEUINT16(put, rover->flags); + WRITEUINT32(put, rover->flags); if (fflr_diff & 2) WRITEINT16(put, rover->alpha); } @@ -815,7 +815,7 @@ static void P_NetUnArchiveWorld(void) fflr_diff = READUINT8(get); if (fflr_diff & 1) - rover->flags = READUINT16(get); + rover->flags = READUINT32(get); if (fflr_diff & 2) rover->alpha = READINT16(get); From be7b866e4ff102d65ed8c33f5fa907a144acd032 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 16 Apr 2016 18:40:14 +0100 Subject: [PATCH 3/6] resynch_pak changes * add skidtime, which we forgot before 2.1 release apparently * change tics from INT16 to INT32 * change eflags from UINT8 to UINT16 * change actionspd/mindash/maxdash from INT32 to fixed_t --- src/d_clisrv.c | 18 ++++++++++-------- src/d_clisrv.h | 11 ++++++----- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d20c0e5ea..7852a0a22 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -517,9 +517,9 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) rsp->thokitem = (UINT32)LONG(players[i].thokitem); //mobjtype_t rsp->spinitem = (UINT32)LONG(players[i].spinitem); //mobjtype_t rsp->revitem = (UINT32)LONG(players[i].revitem); //mobjtype_t - rsp->actionspd = LONG(players[i].actionspd); - rsp->mindash = LONG(players[i].mindash); - rsp->maxdash = LONG(players[i].maxdash); + rsp->actionspd = (fixed_t)LONG(players[i].actionspd); + rsp->mindash = (fixed_t)LONG(players[i].mindash); + rsp->maxdash = (fixed_t)LONG(players[i].maxdash); rsp->jumpfactor = (fixed_t)LONG(players[i].jumpfactor); rsp->speed = (fixed_t)LONG(players[i].speed); @@ -531,6 +531,7 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) rsp->deadtimer = players[i].deadtimer; rsp->exiting = (tic_t)LONG(players[i].exiting); rsp->homing = players[i].homing; + rsp->skidtime = (tic_t)LONG(players[i].skidtime); rsp->cmomx = (fixed_t)LONG(players[i].cmomx); rsp->cmomy = (fixed_t)LONG(players[i].cmomy); rsp->rmomx = (fixed_t)LONG(players[i].rmomx); @@ -590,7 +591,7 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) rsp->tics = LONG(players[i].mo->tics); rsp->statenum = (statenum_t)LONG(players[i].mo->state-states); // :( - rsp->eflags = (UINT32)LONG(players[i].mo->eflags); + rsp->eflags = (UINT16)SHORT(players[i].mo->eflags); rsp->flags = LONG(players[i].mo->flags); rsp->flags2 = LONG(players[i].mo->flags2); @@ -642,9 +643,9 @@ static void resynch_read_player(resynch_pak *rsp) players[i].thokitem = (UINT32)LONG(rsp->thokitem); //mobjtype_t players[i].spinitem = (UINT32)LONG(rsp->spinitem); //mobjtype_t players[i].revitem = (UINT32)LONG(rsp->revitem); //mobjtype_t - players[i].actionspd = LONG(rsp->actionspd); - players[i].mindash = LONG(rsp->mindash); - players[i].maxdash = LONG(rsp->maxdash); + players[i].actionspd = (fixed_t)LONG(rsp->actionspd); + players[i].mindash = (fixed_t)LONG(rsp->mindash); + players[i].maxdash = (fixed_t)LONG(rsp->maxdash); players[i].jumpfactor = (fixed_t)LONG(rsp->jumpfactor); players[i].speed = (fixed_t)LONG(rsp->speed); @@ -656,6 +657,7 @@ static void resynch_read_player(resynch_pak *rsp) players[i].deadtimer = rsp->deadtimer; players[i].exiting = (tic_t)LONG(rsp->exiting); players[i].homing = rsp->homing; + players[i].skidtime = (tic_t)LONG(rsp->skidtime); players[i].cmomx = (fixed_t)LONG(rsp->cmomx); players[i].cmomy = (fixed_t)LONG(rsp->cmomy); players[i].rmomx = (fixed_t)LONG(rsp->rmomx); @@ -713,7 +715,7 @@ static void resynch_read_player(resynch_pak *rsp) //At this point, the player should have a body, whether they were respawned or not. P_UnsetThingPosition(players[i].mo); players[i].mo->angle = (angle_t)LONG(rsp->angle); - players[i].mo->eflags = (UINT32)LONG(rsp->eflags); + players[i].mo->eflags = (UINT16)SHORT(rsp->eflags); players[i].mo->flags = LONG(rsp->flags); players[i].mo->flags2 = LONG(rsp->flags2); players[i].mo->friction = LONG(rsp->friction); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 6bc06f13a..246447ed6 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -177,9 +177,9 @@ typedef struct UINT32 thokitem; //mobjtype_t UINT32 spinitem; //mobjtype_t UINT32 revitem; //mobjtype_t - INT32 actionspd; - INT32 mindash; - INT32 maxdash; + fixed_t actionspd; + fixed_t mindash; + fixed_t maxdash; fixed_t jumpfactor; fixed_t speed; @@ -191,6 +191,7 @@ typedef struct INT32 deadtimer; tic_t exiting; UINT8 homing; + tic_t skidtime; fixed_t cmomx; fixed_t cmomy; fixed_t rmomx; @@ -241,11 +242,11 @@ typedef struct fixed_t friction; fixed_t movefactor; - INT16 tics; + INT32 tics; statenum_t statenum; UINT32 flags; UINT32 flags2; - UINT8 eflags; + UINT16 eflags; fixed_t radius; fixed_t height; From 18d5d64a4d7242a4a532b276f26b773b8ca7d905 Mon Sep 17 00:00:00 2001 From: Inuyasha Date: Mon, 18 Apr 2016 14:50:15 -0700 Subject: [PATCH 4/6] error conditions for Lua fixed point math --- src/lua_mathlib.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index fd00180d5..00379b888 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -100,7 +100,11 @@ static int lib_fixedint(lua_State *L) static int lib_fixeddiv(lua_State *L) { - lua_pushfixed(L, FixedDiv(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2))); + fixed_t i = luaL_checkfixed(L, 1); + fixed_t j = luaL_checkfixed(L, 2); + if (j == 0) + return luaL_error(L, "divide by zero"); + lua_pushfixed(L, FixedDiv(i, j)); return 1; } @@ -112,7 +116,10 @@ static int lib_fixedrem(lua_State *L) static int lib_fixedsqrt(lua_State *L) { - lua_pushfixed(L, FixedSqrt(luaL_checkfixed(L, 1))); + fixed_t i = luaL_checkfixed(L, 1); + if (i < 0) + return luaL_error(L, "can't take the square root of a negative number"); + lua_pushfixed(L, FixedSqrt(i)); return 1; } From a26989c903f3c9dca8754a20cbd3d970a9c493d2 Mon Sep 17 00:00:00 2001 From: Inuyasha Date: Mon, 18 Apr 2016 21:59:33 -0700 Subject: [PATCH 5/6] brevity is a virtue or something like that --- src/lua_mathlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index 00379b888..a55e3a0e4 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -118,7 +118,7 @@ static int lib_fixedsqrt(lua_State *L) { fixed_t i = luaL_checkfixed(L, 1); if (i < 0) - return luaL_error(L, "can't take the square root of a negative number"); + return luaL_error(L, "square root domain error"); lua_pushfixed(L, FixedSqrt(i)); return 1; } From 0aba2f607ba0cdfc723d41ea2bb4dc24b1ccb6cc Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 20 Apr 2016 18:04:51 +0100 Subject: [PATCH 6/6] Fix FOFs with FF_CUTSOLIDS but not FF_SOLID causing software renderer problems and even crashes Always wondered why a flag meant for FOF physics was used in the rendering code, lol --- src/r_segs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 3171bced6..d656108f6 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1352,7 +1352,7 @@ static void R_RenderSegLoop (void) for (i = 0; i < dc_numlights; i++) { dc_lightlist[i].height += dc_lightlist[i].heightstep; - if (dc_lightlist[i].flags & FF_SOLID) + if (dc_lightlist[i].flags & FF_CUTSOLIDS) dc_lightlist[i].botheight += dc_lightlist[i].botheightstep; } } @@ -2001,7 +2001,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) rlight->heightstep = -FixedMul (rw_scalestep, (light->height - viewz) >> 4); rlight->flags = light->flags; - if (light->caster && light->caster->flags & FF_SOLID) + if (light->caster && light->caster->flags & FF_CUTSOLIDS) { rlight->botheight = (centeryfrac >> 4) - FixedMul((*light->caster->bottomheight - viewz) >> 4, rw_scale); rlight->botheightstep = -FixedMul (rw_scalestep, (*light->caster->bottomheight - viewz) >> 4);