From b0cbc8ab2a59cd863c5c59f7593215fc1cd316a0 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Wed, 2 Mar 2016 23:47:06 -0600 Subject: [PATCH 01/68] Lua slope manipulation stuff! Warning: Incomplete. Very prone to crashing and I might not have handled some things properly. Use with caution. --- src/dehacked.c | 6 ++ src/lua_libs.h | 1 + src/lua_maplib.c | 212 ++++++++++++++++++++++++++++++++++++++++++++++- src/p_slopes.c | 2 +- src/p_slopes.h | 1 + 5 files changed, 220 insertions(+), 2 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index d6a1881e6..d8847fd38 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7230,6 +7230,12 @@ struct { {"FF_COLORMAPONLY",FF_COLORMAPONLY}, ///< Only copy the colormap, not the lightlevel {"FF_GOOWATER",FF_GOOWATER}, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop. + // Slope flags + {"SL_NOPHYSICS",SL_NOPHYSICS}, // Don't do momentum adjustment with this slope + {"SL_NODYNAMIC",SL_NODYNAMIC}, // Slope will never need to move during the level, so don't fuss with recalculating it + {"SL_ANCHORVERTEX",SL_ANCHORVERTEX},// Slope is using a Slope Vertex Thing to anchor its position + {"SL_VERTEXSLOPE",SL_VERTEXSLOPE}, // Slope is built from three Slope Vertex Things + // Angles {"ANG1",ANG1>>16}, {"ANG2",ANG2>>16}, diff --git a/src/lua_libs.h b/src/lua_libs.h index d19ad8857..893f56683 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -38,6 +38,7 @@ extern lua_State *gL; #define META_SUBSECTOR "SUBSECTOR_T*" #define META_SECTOR "SECTOR_T*" #define META_FFLOOR "FFLOOR_T*" +#define META_SLOPE "PSLOPE_T*" #define META_MAPHEADER "MAPHEADER_T*" #define META_CVAR "CONSVAR_T*" diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 16d05dacd..a6ebf1abe 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -16,6 +16,8 @@ #include "p_local.h" #include "p_setup.h" #include "z_zone.h" +#include "p_slopes.h" +#include "r_main.h" #include "lua_script.h" #include "lua_libs.h" @@ -37,7 +39,10 @@ enum sector_e { sector_thinglist, sector_heightsec, sector_camsec, - sector_ffloors + sector_ffloors, + sector_fslope, + sector_cslope, + sector_hasslope }; static const char *const sector_opt[] = { @@ -53,6 +58,9 @@ static const char *const sector_opt[] = { "heightsec", "camsec", "ffloors", + "f_slope", + "c_slope", + "hasslope", NULL}; enum subsector_e { @@ -158,6 +166,8 @@ enum ffloor_e { ffloor_toplightlevel, ffloor_bottomheight, ffloor_bottompic, + ffloor_tslope, + ffloor_bslope, ffloor_sector, ffloor_flags, ffloor_master, @@ -174,6 +184,8 @@ static const char *const ffloor_opt[] = { "toplightlevel", "bottomheight", "bottompic", + "t_slope", + "b_slope", "sector", // secnum pushed as control sector userdata "flags", "master", // control linedef @@ -183,6 +195,32 @@ static const char *const ffloor_opt[] = { "alpha", NULL}; +enum slope_e { + slope_valid = 0, + slope_o, + slope_d, + slope_zdelta, + slope_normal, + slope_zangle, + slope_xydirection, + slope_sourceline, + slope_refpos, + slope_flags +}; + +static const char *const slope_opt[] = { + "valid", + "o", + "d", + "zdelta", + "normal", + "zangle", + "xydirection", + "sourceline", + "refpos", + "flags", + NULL}; + static const char *const array_opt[] ={"iterate",NULL}; static const char *const valid_opt[] ={"valid",NULL}; @@ -330,6 +368,15 @@ static int sector_get(lua_State *L) LUA_PushUserdata(L, sector->ffloors, META_FFLOOR); lua_pushcclosure(L, sector_iterate, 2); // push lib_iterateFFloors and sector->ffloors as upvalues for the function return 1; + case sector_fslope: // f_slope + LUA_PushUserdata(L, sector->f_slope, META_SLOPE); + return 1; + case sector_cslope: // c_slope + LUA_PushUserdata(L, sector->c_slope, META_SLOPE); + return 1; + case sector_hasslope: // hasslope + lua_pushboolean(L, sector->hasslope); + return 1; } return 0; } @@ -392,6 +439,9 @@ static int sector_set(lua_State *L) case sector_heightsec: // heightsec case sector_camsec: // camsec case sector_ffloors: // ffloors + case sector_fslope: // f_slope + case sector_cslope: // c_slope + case sector_hasslope: // hasslope default: return luaL_error(L, "sector_t field " LUA_QS " cannot be set.", sector_opt[field]); case sector_floorheight: { // floorheight @@ -1026,6 +1076,12 @@ static int ffloor_get(lua_State *L) lua_pushlstring(L, levelflat->name, 8); return 1; } + case ffloor_tslope: + LUA_PushUserdata(L, *ffloor->t_slope, META_SLOPE); + return 1; + case ffloor_bslope: + LUA_PushUserdata(L, *ffloor->b_slope, META_SLOPE); + return 1; case ffloor_sector: LUA_PushUserdata(L, §ors[ffloor->secnum], META_SECTOR); return 1; @@ -1065,6 +1121,8 @@ static int ffloor_set(lua_State *L) switch(field) { case ffloor_valid: // valid + case ffloor_tslope: // t_slope + case ffloor_bslope: // b_slope case ffloor_sector: // sector case ffloor_master: // master case ffloor_target: // target @@ -1125,6 +1183,150 @@ static int ffloor_set(lua_State *L) return 0; } +static int slope_get(lua_State *L) +{ + pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE)); + enum slope_e field = luaL_checkoption(L, 2, slope_opt[0], slope_opt); + + if (!slope) + { + if (field == slope_valid) { + lua_pushboolean(L, 0); + return 1; + } + return luaL_error(L, "accessed pslope_t doesn't exist anymore."); + } + + switch(field) + { + case slope_valid: // valid + lua_pushboolean(L, 1); + return 1; + case slope_o: // o + lua_createtable(L, 0, 3); + lua_pushfixed(L, slope->o.x); + lua_setfield(L, -2, "x"); + lua_pushfixed(L, slope->o.y); + lua_setfield(L, -2, "y"); + lua_pushfixed(L, slope->o.z); + lua_setfield(L, -2, "z"); + return 1; + case slope_d: // d + lua_createtable(L, 0, 2); + lua_pushfixed(L, slope->o.x); + lua_setfield(L, -2, "x"); + lua_pushfixed(L, slope->o.y); + lua_setfield(L, -2, "y"); + return 1; + case slope_zdelta: // zdelta + lua_pushfixed(L, slope->zdelta); + return 1; + case slope_normal: // normal + lua_createtable(L, 0, 2); + lua_pushfixed(L, slope->o.x); + lua_setfield(L, -2, "x"); + lua_pushfixed(L, slope->o.y); + lua_setfield(L, -2, "y"); + return 1; + case slope_zangle: // zangle + lua_pushangle(L, slope->zangle); + return 1; + case slope_xydirection: // xydirection + lua_pushangle(L, slope->xydirection); + return 1; + case slope_sourceline: // source linedef + LUA_PushUserdata(L, slope->sourceline, META_LINE); + return 1; + case slope_refpos: // refpos + lua_pushinteger(L, slope->refpos); + return 1; + case slope_flags: // flags + lua_pushinteger(L, slope->flags); + return 1; + } + return 0; +} + +static int slope_set(lua_State *L) +{ + pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE)); + enum slope_e field = luaL_checkoption(L, 2, slope_opt[0], slope_opt); + + if (!slope) + return luaL_error(L, "accessed pslope_t doesn't exist anymore."); + + if (hud_running) + return luaL_error(L, "Do not alter pslope_t in HUD rendering code!"); + + switch(field) // todo: reorganize this shit + { + case slope_valid: // valid + case slope_sourceline: // sourceline + case slope_d: // d + case slope_flags: // flags + case slope_normal: // normal + case slope_refpos: // refpos + default: + return luaL_error(L, "pslope_t field " LUA_QS " cannot be set.", slope_opt[field]); + case slope_o: { // o + luaL_checktype(L, 3, LUA_TTABLE); + + lua_getfield(L, 3, "x"); + if (lua_isnil(L, -1)) + { + lua_pop(L, 1); + lua_rawgeti(L, 3, 1); + } + if (!lua_isnil(L, -1)) + slope->o.x = luaL_checkfixed(L, -1); + else + slope->o.x = 0; + lua_pop(L, 1); + + lua_getfield(L, 3, "y"); + if (lua_isnil(L, -1)) + { + lua_pop(L, 1); + lua_rawgeti(L, 3, 2); + } + if (!lua_isnil(L, -1)) + slope->o.y = luaL_checkfixed(L, -1); + else + slope->o.y = 0; + lua_pop(L, 1); + + lua_getfield(L, 3, "z"); + if (lua_isnil(L, -1)) + { + lua_pop(L, 1); + lua_rawgeti(L, 3, 3); + } + if (!lua_isnil(L, -1)) + slope->o.z = luaL_checkfixed(L, -1); + else + slope->o.z = 0; + lua_pop(L, 1); + break; + } + case slope_zdelta: { // zdelta, this is temp until i figure out wtf to do + slope->zdelta = luaL_checkfixed(L, 3); + slope->zangle = R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta); + P_CalculateSlopeNormal(slope); + break; + } + case slope_zangle: // zangle + slope->zangle = luaL_checkangle(L, 3); + slope->zdelta = FINETANGENT(slope->zangle); + P_CalculateSlopeNormal(slope); + break; + case slope_xydirection: // xydirection + slope->xydirection = luaL_checkangle(L, 3); + P_CalculateSlopeNormal(slope); + break; + } + return 0; +} + static int lib_getMapheaderinfo(lua_State *L) { // i -> mapheaderinfo[i-1] @@ -1293,6 +1495,14 @@ int LUA_MapLib(lua_State *L) lua_setfield(L, -2, "__newindex"); lua_pop(L, 1); + luaL_newmetatable(L, META_SLOPE); + lua_pushcfunction(L, slope_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, slope_set); + lua_setfield(L, -2, "__newindex"); + lua_pop(L, 1); + luaL_newmetatable(L, META_MAPHEADER); lua_pushcfunction(L, mapheaderinfo_get); lua_setfield(L, -2, "__index"); diff --git a/src/p_slopes.c b/src/p_slopes.c index 2d55cf194..b51b2a4dc 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -46,7 +46,7 @@ static pslope_t *slopelist = NULL; static UINT16 slopecount = 0; // Calculate line normal -static void P_CalculateSlopeNormal(pslope_t *slope) { +void P_CalculateSlopeNormal(pslope_t *slope) { slope->normal.z = FINECOSINE(slope->zangle>>ANGLETOFINESHIFT); slope->normal.x = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.x); slope->normal.y = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.y); diff --git a/src/p_slopes.h b/src/p_slopes.h index 8d82632ff..7898302e0 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -29,6 +29,7 @@ #define P_SLOPES_H__ #ifdef ESLOPE +void P_CalculateSlopeNormal(pslope_t *slope); void P_ResetDynamicSlopes(void); void P_RunDynamicSlopes(void); // P_SpawnSlope_Line From b3d842e8590938de3e4ac6cfea61a7df3023f4cc Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 3 Mar 2016 14:43:42 +0000 Subject: [PATCH 02/68] Fix accidental copy+paste of o to d and normal in slope_get code --- src/lua_maplib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index a6ebf1abe..218f26e1b 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1213,9 +1213,9 @@ static int slope_get(lua_State *L) return 1; case slope_d: // d lua_createtable(L, 0, 2); - lua_pushfixed(L, slope->o.x); + lua_pushfixed(L, slope->d.x); lua_setfield(L, -2, "x"); - lua_pushfixed(L, slope->o.y); + lua_pushfixed(L, slope->d.y); lua_setfield(L, -2, "y"); return 1; case slope_zdelta: // zdelta @@ -1223,9 +1223,9 @@ static int slope_get(lua_State *L) return 1; case slope_normal: // normal lua_createtable(L, 0, 2); - lua_pushfixed(L, slope->o.x); + lua_pushfixed(L, slope->normal.x); lua_setfield(L, -2, "x"); - lua_pushfixed(L, slope->o.y); + lua_pushfixed(L, slope->normal.y); lua_setfield(L, -2, "y"); return 1; case slope_zangle: // zangle From ad0069676a4cbc1201dbf3bfef35f28052df303b Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Thu, 3 Mar 2016 20:47:05 -0600 Subject: [PATCH 03/68] slope->normal is vector3_t, not vector2_t --- src/lua_maplib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 218f26e1b..f584ce4c3 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1222,11 +1222,13 @@ static int slope_get(lua_State *L) lua_pushfixed(L, slope->zdelta); return 1; case slope_normal: // normal - lua_createtable(L, 0, 2); + lua_createtable(L, 0, 3); lua_pushfixed(L, slope->normal.x); lua_setfield(L, -2, "x"); lua_pushfixed(L, slope->normal.y); lua_setfield(L, -2, "y"); + lua_pushfixed(L, slope->normal.z); + lua_setfield(L, -2, "z"); return 1; case slope_zangle: // zangle lua_pushangle(L, slope->zangle); From cb62f08364d4d53e51d4770198e2b65b3547e62b Mon Sep 17 00:00:00 2001 From: Prisima the Fox Date: Thu, 20 Oct 2016 22:23:50 -0400 Subject: [PATCH 04/68] "PlayerQuit" hook --- src/lua_hook.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_hook.h b/src/lua_hook.h index 804d99e12..240fdaece 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -43,6 +43,7 @@ enum hook { hook_PlayerMsg, hook_HurtMsg, hook_PlayerSpawn, + hook_PlayerQuit, hook_MAX // last hook }; @@ -77,5 +78,6 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg); // Hook for chat messages boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages #define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer +boolean LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting #endif From cfb2feff8ef4344130bed3456937ecb9609c593a Mon Sep 17 00:00:00 2001 From: Prisima the Fox Date: Thu, 20 Oct 2016 22:25:11 -0400 Subject: [PATCH 05/68] "PlayerQuit" hook --- src/lua_hooklib.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 1b9652571..be3f8b0e1 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -54,6 +54,7 @@ const char *const hookNames[hook_MAX+1] = { "PlayerMsg", "HurtMsg", "PlayerSpawn", + "PlayerQuit", NULL }; @@ -798,4 +799,41 @@ void LUAh_NetArchiveHook(lua_CFunction archFunc) // stack: tables } +boolean LUAh_PlayerQuit(player_t *plr, int reason) +{ + hook_p hookp; + boolean hooked = false; + if (!gL || !(hooksAvailable[hook_PlayerQuit/8] & (1<<(hook_PlayerQuit%8)))) + return false; + + lua_settop(gL, 0); + + for (hookp = roothook; hookp; hookp = hookp->next) + if (hookp->type == hook_PlayerQuit) + { + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit + lua_pushinteger(gL, reason); // Reason for quitting + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + return hooked; +} + #endif From 89e8766b77f0176e9680522cd4a9b325a2e1b33c Mon Sep 17 00:00:00 2001 From: Prisima the Fox Date: Thu, 20 Oct 2016 22:30:11 -0400 Subject: [PATCH 06/68] "PlayerQuit" hook --- src/d_clisrv.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c0f81ba32..973564a9b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2208,7 +2208,7 @@ void CL_ClearPlayer(INT32 playernum) // // Removes a player from the current game // -static void CL_RemovePlayer(INT32 playernum) +static void CL_RemovePlayer(INT32 playernum, INT32 reason) { // Sanity check: exceptional cases (i.e. c-fails) can cause multiple // kick commands to be issued for the same player. @@ -2262,6 +2262,10 @@ static void CL_RemovePlayer(INT32 playernum) } } } + +#ifdef HAVE_BLUA + LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting +#endif // Reset player data CL_ClearPlayer(playernum); @@ -2513,6 +2517,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) INT32 pnum, msg; XBOXSTATIC char buf[3 + MAX_REASONLENGTH]; char *reason = buf; + INT32 kickreason = 1; pnum = READUINT8(*p); msg = READUINT8(*p); @@ -2593,14 +2598,17 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) { case KICK_MSG_GO_AWAY: CONS_Printf(M_GetText("has been kicked (Go away)\n")); + kickreason = 1; break; #ifdef NEWPING case KICK_MSG_PING_HIGH: CONS_Printf(M_GetText("left the game (Broke ping limit)\n")); + kickreason = 2; break; #endif case KICK_MSG_CON_FAIL: CONS_Printf(M_GetText("left the game (Synch failure)\n")); + kickreason = 3; if (M_CheckParm("-consisdump")) // Helps debugging some problems { @@ -2637,21 +2645,26 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) break; case KICK_MSG_TIMEOUT: CONS_Printf(M_GetText("left the game (Connection timeout)\n")); + kickreason = 4; break; case KICK_MSG_PLAYER_QUIT: if (netgame) // not splitscreen/bots CONS_Printf(M_GetText("left the game\n")); + kickreason = 6; break; case KICK_MSG_BANNED: CONS_Printf(M_GetText("has been banned (Don't come back)\n")); + kickreason = 5; break; case KICK_MSG_CUSTOM_KICK: READSTRINGN(*p, reason, MAX_REASONLENGTH+1); CONS_Printf(M_GetText("has been kicked (%s)\n"), reason); + kickreason = 1; break; case KICK_MSG_CUSTOM_BAN: READSTRINGN(*p, reason, MAX_REASONLENGTH+1); CONS_Printf(M_GetText("has been banned (%s)\n"), reason); + kickreason = 5; break; } @@ -2679,7 +2692,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) M_StartMessage(M_GetText("You have been kicked by the server\n\nPress ESC\n"), NULL, MM_NOTHING); } else - CL_RemovePlayer(pnum); + CL_RemovePlayer(pnum, kickreason); } consvar_t cv_allownewplayer = {"allowjoin", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL }; From fcf2fe79e00dae735cf383ce04422a6548fe4288 Mon Sep 17 00:00:00 2001 From: Prisima the Fox Date: Thu, 20 Oct 2016 23:25:47 -0400 Subject: [PATCH 07/68] Oops; PlayerQuit isn't a boolean! --- src/lua_hook.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 240fdaece..94b934f32 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -78,6 +78,6 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg); // Hook for chat messages boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages #define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer -boolean LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting +void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting #endif From defc7c164545eeae8db8f81de5c8ca46eff9af14 Mon Sep 17 00:00:00 2001 From: Prisima the Fox Date: Thu, 20 Oct 2016 23:26:41 -0400 Subject: [PATCH 08/68] Oops; PlayerQuit isn't a boolean! --- src/lua_hooklib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index be3f8b0e1..5ac77da97 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -799,12 +799,12 @@ void LUAh_NetArchiveHook(lua_CFunction archFunc) // stack: tables } -boolean LUAh_PlayerQuit(player_t *plr, int reason) +void LUAh_PlayerQuit(player_t *plr, int reason) { hook_p hookp; boolean hooked = false; if (!gL || !(hooksAvailable[hook_PlayerQuit/8] & (1<<(hook_PlayerQuit%8)))) - return false; + return; lua_settop(gL, 0); From 673315265107da0740372f2ba1917cb89396c208 Mon Sep 17 00:00:00 2001 From: Prisima the Fox Date: Fri, 21 Oct 2016 16:16:54 -0400 Subject: [PATCH 09/68] No more magic numbers --- src/d_clisrv.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 973564a9b..cfe0c1cdd 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2517,7 +2517,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) INT32 pnum, msg; XBOXSTATIC char buf[3 + MAX_REASONLENGTH]; char *reason = buf; - INT32 kickreason = 1; + kickreason_t kickreason = KR_KICK; pnum = READUINT8(*p); msg = READUINT8(*p); @@ -2598,17 +2598,17 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) { case KICK_MSG_GO_AWAY: CONS_Printf(M_GetText("has been kicked (Go away)\n")); - kickreason = 1; + kickreason = KR_KICK; break; #ifdef NEWPING case KICK_MSG_PING_HIGH: CONS_Printf(M_GetText("left the game (Broke ping limit)\n")); - kickreason = 2; + kickreason = KR_PINGLIMIT; break; #endif case KICK_MSG_CON_FAIL: CONS_Printf(M_GetText("left the game (Synch failure)\n")); - kickreason = 3; + kickreason = KR_SYNCH; if (M_CheckParm("-consisdump")) // Helps debugging some problems { @@ -2645,26 +2645,26 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) break; case KICK_MSG_TIMEOUT: CONS_Printf(M_GetText("left the game (Connection timeout)\n")); - kickreason = 4; + kickreason = KR_TIMEOUT; break; case KICK_MSG_PLAYER_QUIT: if (netgame) // not splitscreen/bots CONS_Printf(M_GetText("left the game\n")); - kickreason = 6; + kickreason = KR_LEAVE; break; case KICK_MSG_BANNED: CONS_Printf(M_GetText("has been banned (Don't come back)\n")); - kickreason = 5; + kickreason = KR_BAN; break; case KICK_MSG_CUSTOM_KICK: READSTRINGN(*p, reason, MAX_REASONLENGTH+1); CONS_Printf(M_GetText("has been kicked (%s)\n"), reason); - kickreason = 1; + kickreason = KR_KICK; break; case KICK_MSG_CUSTOM_BAN: READSTRINGN(*p, reason, MAX_REASONLENGTH+1); CONS_Printf(M_GetText("has been banned (%s)\n"), reason); - kickreason = 5; + kickreason = KR_BAN; break; } From c38457f23c70509cef3fd131e380332c2e43ab4f Mon Sep 17 00:00:00 2001 From: Prisima the Fox Date: Fri, 21 Oct 2016 16:25:07 -0400 Subject: [PATCH 10/68] No more magic numbers --- src/d_clisrv.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 14b590926..cd726d9b3 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -436,6 +436,17 @@ extern consvar_t cv_playbackspeed; #define KICK_MSG_CUSTOM_KICK 7 #define KICK_MSG_CUSTOM_BAN 8 +typedef enum +{ + KR_KICK = 1, //Kicked by server + KR_PINGLIMIT = 2, //Broke Ping Limit + KR_SYNCH = 3, //Synch Failure + KR_TIMEOUT = 4, //Connection Timeout + KR_BAN = 5, //Banned by server + KR_LEAVE = 6, //Quit the game + +} kickreason_t; + extern boolean server; extern boolean dedicated; // for dedicated server extern UINT16 software_MAXPACKETLENGTH; From b5988e082cd012555e532d7c0a25b73818ec6566 Mon Sep 17 00:00:00 2001 From: Prisima the Fox Date: Fri, 21 Oct 2016 16:27:15 -0400 Subject: [PATCH 11/68] No more magic numbers --- src/dehacked.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index f03dd73b4..62a7ad811 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -31,6 +31,7 @@ #include "fastcmp.h" #include "lua_script.h" #include "lua_hook.h" +#include "d_clisrv.h" #include "m_cond.h" @@ -7392,6 +7393,14 @@ struct { {"V_CHARCOLORSHIFT",V_CHARCOLORSHIFT}, {"V_ALPHASHIFT",V_ALPHASHIFT}, + + //Kick Reasons + {"KR_KICK",KR_KICK}, + {"KR_PINGLIMIT",KR_PINGLIMIT}, + {"KR_SYNCH",KR_SYNCH}, + {"KR_TIMEOUT",KR_TIMEOUT}, + {"KR_BAN",KR_BAN}, + {"KR_LEAVE",KR_LEAVE}, #endif {NULL,0} From b1ce5896aa97509268589cbcba26431c08f8adf9 Mon Sep 17 00:00:00 2001 From: Prisima the Fox Date: Tue, 8 Nov 2016 10:30:01 -0500 Subject: [PATCH 12/68] Remove boolean remnants --- src/lua_hooklib.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 5ac77da97..16f8c55d3 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -802,7 +802,6 @@ void LUAh_NetArchiveHook(lua_CFunction archFunc) void LUAh_PlayerQuit(player_t *plr, int reason) { hook_p hookp; - boolean hooked = false; if (!gL || !(hooksAvailable[hook_PlayerQuit/8] & (1<<(hook_PlayerQuit%8)))) return; @@ -811,29 +810,16 @@ void LUAh_PlayerQuit(player_t *plr, int reason) for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_PlayerQuit) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit - lua_pushinteger(gL, reason); // Reason for quitting - } + LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit + lua_pushinteger(gL, reason); // Reason for quitting lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_Call(gL, 2); } lua_settop(gL, 0); - return hooked; } #endif From d788cb7676e8832147d9e6ae911b10005987a85c Mon Sep 17 00:00:00 2001 From: Prisima the Fox Date: Fri, 25 Nov 2016 15:20:41 -0500 Subject: [PATCH 13/68] Keeping the lua_gettop(gL) thing, otherwise the player/reason values will be pushed once to the stack each for every hook. Thanks MonsterIestyn! --- src/lua_hooklib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 16f8c55d3..7c10b7e38 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -810,7 +810,11 @@ void LUAh_PlayerQuit(player_t *plr, int reason) for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_PlayerQuit) { - LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit + lua_pushinteger(gL, reason); // Reason for quitting + } lua_pushinteger(gL, reason); // Reason for quitting lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); From dd13df230831debbfb08a447800ea8cc18bd4abf Mon Sep 17 00:00:00 2001 From: Prisima the Fox Date: Sat, 3 Dec 2016 18:18:16 -0500 Subject: [PATCH 14/68] Whoops, didn't see the duplicate line. --- src/lua_hooklib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 7c10b7e38..273264d7d 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -815,7 +815,6 @@ void LUAh_PlayerQuit(player_t *plr, int reason) LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit lua_pushinteger(gL, reason); // Reason for quitting } - lua_pushinteger(gL, reason); // Reason for quitting lua_pushfstring(gL, FMT_HOOKID, hookp->id); lua_gettable(gL, LUA_REGISTRYINDEX); lua_pushvalue(gL, -3); From f8834b02019b03c9bead2414a28f790d6ce933f9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 25 Mar 2018 19:07:21 -0400 Subject: [PATCH 15/68] MT_NIGHTSBUMPER Spawn: Don't reset mthing->options (cherry picked from commit dc9fd6f02ed4b681ed4982d119672f07cc91e585) --- src/p_mobj.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 5f85474c6..1e2fe4f8f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9194,9 +9194,6 @@ ML_NOCLIMB : Direction not controllable // the bumper in 30 degree increments. mobj->threshold = (mthing->options & 15) % 12; // It loops over, etc P_SetMobjState(mobj, mobj->info->spawnstate+mobj->threshold); - - // you can shut up now, OBJECTFLIP. And all of the other options, for that matter. - mthing->options &= ~0xF; break; case MT_EGGCAPSULE: if (mthing->angle <= 0) From b666fa3131ec391f85dfc1cc56de047ebaf53ec2 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 25 Mar 2018 19:42:46 -0400 Subject: [PATCH 16/68] P_SpawnMapThing: Ignore MTF_ flags if MT_NIGHTSBUMPER (cherry picked from commit d85f108997bfeca3e0b1731c1aad70617456400b) --- src/p_mobj.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index 1e2fe4f8f..a146027b9 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9381,6 +9381,14 @@ ML_NOCLIMB : Direction not controllable } } + // ignore MTF_ flags and return early + if (i == MT_NIGHTSBUMPER) + { + mobj->angle = FixedAngle(mthing->angle*FRACUNIT); + mthing->mobj = mobj; + return; + } + mobj->angle = FixedAngle(mthing->angle*FRACUNIT); if ((mthing->options & MTF_AMBUSH) From b9b0a8110c307bdf8457fa66a83a193ad0008461 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 16 Nov 2016 18:43:25 +0000 Subject: [PATCH 17/68] Add R_Draw2sMultiPatchTranslucentColumn_8, for columns of multi-patch textures used as midtextures on two-sided linedefs with both transparency AND translucency ...that was a mouthful --- src/r_draw.h | 1 + src/r_draw8.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/r_segs.c | 2 ++ src/screen.c | 2 ++ src/screen.h | 1 + 5 files changed, 103 insertions(+) diff --git a/src/r_draw.h b/src/r_draw.h index 6d85bd6a5..9cf7e9d54 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -161,6 +161,7 @@ void R_DrawSplat_8(void); void R_DrawTranslucentSplat_8(void); void R_DrawTranslucentSpan_8(void); void R_Draw2sMultiPatchColumn_8(void); +void R_Draw2sMultiPatchTranslucentColumn_8(void); void R_DrawFogSpan_8(void); void R_DrawFogColumn_8(void); void R_DrawColumnShadowed_8(void); diff --git a/src/r_draw8.c b/src/r_draw8.c index 800f28b6b..e5dbe7071 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -203,6 +203,103 @@ void R_Draw2sMultiPatchColumn_8(void) } } +void R_Draw2sMultiPatchTranslucentColumn_8(void) +{ + INT32 count; + register UINT8 *dest; + register fixed_t frac; + fixed_t fracstep; + + count = dc_yh - dc_yl; + + if (count < 0) // Zero length, column does not exceed a pixel. + return; + +#ifdef RANGECHECK + if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + return; +#endif + + // Framebuffer destination address. + // Use ylookup LUT to avoid multiply with ScreenWidth. + // Use columnofs LUT for subwindows? + + //dest = ylookup[dc_yl] + columnofs[dc_x]; + dest = &topleft[dc_yl*vid.width + dc_x]; + + count++; + + // Determine scaling, which is the only mapping to be done. + fracstep = dc_iscale; + //frac = dc_texturemid + (dc_yl - centery)*fracstep; + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); + + // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. + // This is as fast as it gets. + { + register const UINT8 *source = dc_source; + register const UINT8 *transmap = dc_transmap; + register const lighttable_t *colormap = dc_colormap; + register INT32 heightmask = dc_texheight-1; + register UINT8 val; + if (dc_texheight & heightmask) // not a power of 2 -- killough + { + heightmask++; + heightmask <<= FRACBITS; + + if (frac < 0) + while ((frac += heightmask) < 0); + else + while (frac >= heightmask) + frac -= heightmask; + + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + // heightmask is the Tutti-Frutti fix + val = source[frac>>FRACBITS]; + + if (val != TRANSPARENTPIXEL) + *dest = colormap[*(transmap + (val<<8) + (*dest))]; + + dest += vid.width; + + // Avoid overflow. + if (fracstep > 0x7FFFFFFF - frac) + frac += fracstep - heightmask; + else + frac += fracstep; + + while (frac >= heightmask) + frac -= heightmask; + } while (--count); + } + else + { + while ((count -= 2) >= 0) // texture height is a power of 2 + { + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + *dest = colormap[*(transmap + (val<<8) + (*dest))]; + dest += vid.width; + frac += fracstep; + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + *dest = colormap[*(transmap + (val<<8) + (*dest))]; + dest += vid.width; + frac += fracstep; + } + if (count & 1) + { + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + *dest = colormap[*(transmap + (val<<8) + (*dest))]; + } + } + } +} + /** \brief The R_DrawShadeColumn_8 function Experiment to make software go faster. Taken from the Boom source */ diff --git a/src/r_segs.c b/src/r_segs.c index 502ff3304..40184bddf 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -271,6 +271,8 @@ static void R_Render2sidedMultiPatchColumn(column_t *column) if (colfunc == wallcolfunc) twosmultipatchfunc(); + else if (colfunc == fuzzcolfunc) + twosmultipatchtransfunc(); else colfunc(); } diff --git a/src/screen.c b/src/screen.c index 2780edb60..58c38993b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -49,6 +49,7 @@ void (*splatfunc)(void); // span drawer w/ transparency void (*basespanfunc)(void); // default span func for color mode void (*transtransfunc)(void); // translucent translated column drawer void (*twosmultipatchfunc)(void); // for cols with transparent pixels +void (*twosmultipatchtransfunc)(void); // for cols with transparent pixels AND translucency // ------------------ // global video state @@ -127,6 +128,7 @@ void SCR_SetMode(void) fuzzcolfunc = R_DrawTranslucentColumn_8; walldrawerfunc = R_DrawWallColumn_8; twosmultipatchfunc = R_Draw2sMultiPatchColumn_8; + twosmultipatchtransfunc = R_Draw2sMultiPatchTranslucentColumn_8; #ifdef RUSEASM if (R_ASM) { diff --git a/src/screen.h b/src/screen.h index 2dff4590e..a61de7f92 100644 --- a/src/screen.h +++ b/src/screen.h @@ -136,6 +136,7 @@ extern void (*basespanfunc)(void); extern void (*splatfunc)(void); extern void (*transtransfunc)(void); extern void (*twosmultipatchfunc)(void); +extern void (*twosmultipatchtransfunc)(void); // ----- // CPUID From 72ab305bf4672edc9ead8a1004fcf1ab1f7b7cd5 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 10 Oct 2018 14:59:44 +0100 Subject: [PATCH 18/68] Change when and specifically what colormap[] is applied to in R_Draw2sMultiPatchTranslucentColumn_8 --- src/r_draw8.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index e5dbe7071..f9c5b7ada 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -261,7 +261,7 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) val = source[frac>>FRACBITS]; if (val != TRANSPARENTPIXEL) - *dest = colormap[*(transmap + (val<<8) + (*dest))]; + *dest = *(transmap + (colormap[val]<<8) + (*dest)); dest += vid.width; @@ -281,12 +281,12 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) { val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) - *dest = colormap[*(transmap + (val<<8) + (*dest))]; + *dest = *(transmap + (colormap[val]<<8) + (*dest)); dest += vid.width; frac += fracstep; val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) - *dest = colormap[*(transmap + (val<<8) + (*dest))]; + *dest = *(transmap + (colormap[val]<<8) + (*dest)); dest += vid.width; frac += fracstep; } @@ -294,7 +294,7 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) { val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) - *dest = colormap[*(transmap + (val<<8) + (*dest))]; + *dest = *(transmap + (colormap[val]<<8) + (*dest)); } } } From 4b7af892e1b7ddda002d3d5a3867a19b4d502285 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Apr 2017 17:45:27 +0100 Subject: [PATCH 19/68] Moved most of d_netcmd.h's 2P mouse consvar externs to the files with their 1P counterparts --- src/d_netcmd.h | 5 ----- src/g_game.h | 1 + src/g_input.h | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index d8fae72f7..8a15136c0 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -40,11 +40,6 @@ extern consvar_t cv_usemouse2; #if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) extern consvar_t cv_mouse2opt; #endif -extern consvar_t cv_invertmouse2; -extern consvar_t cv_alwaysfreelook2; -extern consvar_t cv_mousemove2; -extern consvar_t cv_mousesens2; -extern consvar_t cv_mouseysens2; // normally in p_mobj but the .h is not read extern consvar_t cv_itemrespawntime; diff --git a/src/g_game.h b/src/g_game.h index ada82404c..448d2855e 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -56,6 +56,7 @@ extern INT16 rw_maximums[NUM_WEAPONS]; // used in game menu extern consvar_t cv_crosshair, cv_crosshair2; extern consvar_t cv_invertmouse, cv_alwaysfreelook, cv_mousemove; +extern consvar_t cv_invertmouse2, cv_alwaysfreelook2, cv_mousemove2; extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_fireaxis,cv_firenaxis; extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_fireaxis2,cv_firenaxis2; extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest; diff --git a/src/g_input.h b/src/g_input.h index d65339321..2f86e5928 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -126,6 +126,7 @@ typedef enum // mouse values are used once extern consvar_t cv_mousesens, cv_mouseysens; +extern consvar_t cv_mousesens2, cv_mouseysens2; extern INT32 mousex, mousey; extern INT32 mlooky; //mousey with mlookSensitivity From e2a4c59e2190a92acb00921d783a43f484e39253 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Apr 2017 18:02:35 +0100 Subject: [PATCH 20/68] cv_controlperkey probably belongs in g_input.h too --- src/d_netcmd.h | 1 - src/g_input.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 8a15136c0..08cdfd2ee 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -32,7 +32,6 @@ extern consvar_t cv_joyport2; #endif extern consvar_t cv_joyscale; extern consvar_t cv_joyscale2; -extern consvar_t cv_controlperkey; // splitscreen with second mouse extern consvar_t cv_mouse2port; diff --git a/src/g_input.h b/src/g_input.h index 2f86e5928..f42ad89d8 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -127,6 +127,7 @@ typedef enum // mouse values are used once extern consvar_t cv_mousesens, cv_mouseysens; extern consvar_t cv_mousesens2, cv_mouseysens2; +extern consvar_t cv_controlperkey; extern INT32 mousex, mousey; extern INT32 mlooky; //mousey with mlookSensitivity From 933508db89376993f49ec8e074e8c5afd5edec90 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Apr 2017 18:14:15 +0100 Subject: [PATCH 21/68] Moved screenshot/movie consvar externs to m_misc.h --- src/d_netcmd.h | 12 +----------- src/m_misc.h | 7 +++++++ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 08cdfd2ee..2731ca7fb 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -115,17 +115,7 @@ extern consvar_t cv_maxping; extern consvar_t cv_skipmapcheck; -extern consvar_t cv_sleep, cv_screenshot_option, cv_screenshot_folder; - -extern consvar_t cv_moviemode; - -extern consvar_t cv_zlib_level, cv_zlib_memory, cv_zlib_strategy; - -extern consvar_t cv_zlib_window_bits, cv_zlib_levela, cv_zlib_memorya; - -extern consvar_t cv_zlib_strategya, cv_zlib_window_bitsa; - -extern consvar_t cv_apng_delay; +extern consvar_t cv_sleep; typedef enum { diff --git a/src/m_misc.h b/src/m_misc.h index dc540dc16..5bd7401e1 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -19,6 +19,7 @@ #include "tables.h" #include "d_event.h" // Screenshot responder +#include "command.h" typedef enum { MM_OFF = 0, @@ -28,6 +29,12 @@ typedef enum { } moviemode_t; extern moviemode_t moviemode; +extern consvar_t cv_screenshot_option, cv_screenshot_folder; +extern consvar_t cv_moviemode; +extern consvar_t cv_zlib_memory, cv_zlib_level, cv_zlib_strategy, cv_zlib_window_bits; +extern consvar_t cv_zlib_memorya, cv_zlib_levela, cv_zlib_strategya, cv_zlib_window_bitsa; +extern consvar_t cv_apng_delay; + void M_StartMovie(void); void M_SaveFrame(void); void M_StopMovie(void); From 0ad0f8afc451d172fb36f8f2b1a0e14021bbcd18 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Apr 2017 19:00:46 +0100 Subject: [PATCH 22/68] Move analog consvars to g_game.h --- src/d_netcmd.h | 3 --- src/g_game.h | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 2731ca7fb..40c806a33 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -71,9 +71,6 @@ extern consvar_t cv_autobalance; extern consvar_t cv_teamscramble; extern consvar_t cv_scrambleonchange; -extern consvar_t cv_useranalog, cv_useranalog2; -extern consvar_t cv_analog, cv_analog2; - extern consvar_t cv_netstat; #ifdef WALLSPLATS extern consvar_t cv_splats; diff --git a/src/g_game.h b/src/g_game.h index 448d2855e..ba4142695 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -57,6 +57,8 @@ extern INT16 rw_maximums[NUM_WEAPONS]; extern consvar_t cv_crosshair, cv_crosshair2; extern consvar_t cv_invertmouse, cv_alwaysfreelook, cv_mousemove; extern consvar_t cv_invertmouse2, cv_alwaysfreelook2, cv_mousemove2; +extern consvar_t cv_useranalog, cv_useranalog2; +extern consvar_t cv_analog, cv_analog2; extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_fireaxis,cv_firenaxis; extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_fireaxis2,cv_firenaxis2; extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest; From 38ec0cc50aa595f22e6e1f5ee19352cd42da355d Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Apr 2017 19:56:51 +0100 Subject: [PATCH 23/68] These convar externs aren't moving files, I'm just shifting them up to live with their relatives --- src/d_netcmd.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 40c806a33..e03089482 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -20,6 +20,12 @@ // console vars extern consvar_t cv_playername; extern consvar_t cv_playercolor; +extern consvar_t cv_skin; +// secondary splitscreen player +extern consvar_t cv_playername2; +extern consvar_t cv_playercolor2; +extern consvar_t cv_skin2; + #ifdef SEENAMES extern consvar_t cv_seenames, cv_allowseenames; #endif @@ -47,13 +53,6 @@ extern consvar_t cv_itemrespawn; extern consvar_t cv_flagtime; extern consvar_t cv_suddendeath; -extern consvar_t cv_skin; - -// secondary splitscreen player -extern consvar_t cv_playername2; -extern consvar_t cv_playercolor2; -extern consvar_t cv_skin2; - extern consvar_t cv_touchtag; extern consvar_t cv_hidetime; From b3faed190b4838ee88f88d75524ad228b690f195 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 11 Oct 2018 16:29:43 -0400 Subject: [PATCH 24/68] Move commands and console variable into s_sound.c --- src/d_netcmd.c | 95 ------------------------------------------------ src/d_netcmd.h | 6 +--- src/s_sound.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/s_sound.h | 1 + 4 files changed, 100 insertions(+), 100 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index bf26ca61a..a8e02bab6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -128,8 +128,6 @@ FUNCNORETURN static ATTRNORETURN void Command_Quit_f(void); static void Command_Playintro_f(void); static void Command_Displayplayer_f(void); -static void Command_Tunes_f(void); -static void Command_RestartAudio_f(void); static void Command_ExitLevel_f(void); static void Command_Showmap_f(void); @@ -319,7 +317,6 @@ consvar_t cv_overtime = {"overtime", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, consvar_t cv_rollingdemos = {"rollingdemos", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_timetic = {"timerres", "Normal", CV_SAVE, timetic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // use tics in display -consvar_t cv_resetmusic = {"resetmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t pointlimit_cons_t[] = {{0, "MIN"}, {999999990, "MAX"}, {0, NULL}}; consvar_t cv_pointlimit = {"pointlimit", "0", CV_NETVAR|CV_CALL|CV_NOINIT, pointlimit_cons_t, @@ -668,9 +665,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_ghost_guest); COM_AddCommand("displayplayer", Command_Displayplayer_f); - COM_AddCommand("tunes", Command_Tunes_f); - COM_AddCommand("restartaudio", Command_RestartAudio_f); - CV_RegisterVar(&cv_resetmusic); // FIXME: not to be here.. but needs be done for config loading CV_RegisterVar(&cv_usegamma); @@ -3881,95 +3875,6 @@ static void Command_Displayplayer_f(void) CONS_Printf(M_GetText("Displayplayer is %d\n"), displayplayer); } -static void Command_Tunes_f(void) -{ - const char *tunearg; - UINT16 tunenum, track = 0; - const size_t argc = COM_Argc(); - - if (argc < 2) //tunes slot ... - { - CONS_Printf("tunes [track] [speed] / <-show> / <-default> / <-none>:\n"); - CONS_Printf(M_GetText("Play an arbitrary music lump. If a map number is used, 'MAP##M' is played.\n")); - CONS_Printf(M_GetText("If the format supports multiple songs, you can specify which one to play.\n\n")); - CONS_Printf(M_GetText("* With \"-show\", shows the currently playing tune and track.\n")); - CONS_Printf(M_GetText("* With \"-default\", returns to the default music for the map.\n")); - CONS_Printf(M_GetText("* With \"-none\", any music playing will be stopped.\n")); - return; - } - - tunearg = COM_Argv(1); - tunenum = (UINT16)atoi(tunearg); - track = 0; - - if (!strcasecmp(tunearg, "-show")) - { - CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"), - mapmusname, (mapmusflags & MUSIC_TRACKMASK)); - return; - } - if (!strcasecmp(tunearg, "-none")) - { - S_StopMusic(); - return; - } - else if (!strcasecmp(tunearg, "-default")) - { - tunearg = mapheaderinfo[gamemap-1]->musname; - track = mapheaderinfo[gamemap-1]->mustrack; - } - else if (!tunearg[2] && toupper(tunearg[0]) >= 'A' && toupper(tunearg[0]) <= 'Z') - tunenum = (UINT16)M_MapNumber(tunearg[0], tunearg[1]); - - if (tunenum && tunenum >= 1036) - { - CONS_Alert(CONS_NOTICE, M_GetText("Valid music slots are 1 to 1035.\n")); - return; - } - if (!tunenum && strlen(tunearg) > 6) // This is automatic -- just show the error just in case - CONS_Alert(CONS_NOTICE, M_GetText("Music name too long - truncated to six characters.\n")); - - if (argc > 2) - track = (UINT16)atoi(COM_Argv(2))-1; - - if (tunenum) - snprintf(mapmusname, 7, "%sM", G_BuildMapName(tunenum)); - else - strncpy(mapmusname, tunearg, 7); - mapmusname[6] = 0; - mapmusflags = (track & MUSIC_TRACKMASK); - - S_ChangeMusic(mapmusname, mapmusflags, true); - - if (argc > 3) - { - float speed = (float)atof(COM_Argv(3)); - if (speed > 0.0f) - S_SpeedMusic(speed); - } -} - -static void Command_RestartAudio_f(void) -{ - if (dedicated) // No point in doing anything if game is a dedicated server. - return; - - S_StopMusic(); - I_ShutdownMusic(); - I_ShutdownSound(); - I_StartupSound(); - I_InitMusic(); - -// These must be called or no sound and music until manually set. - - I_SetSfxVolume(cv_soundvolume.value); - I_SetDigMusicVolume(cv_digmusicvolume.value); - I_SetMIDIMusicVolume(cv_midimusicvolume.value); - if (Playing()) // Gotta make sure the player is in a level - P_RestoreMusic(&players[consoleplayer]); - -} - /** Quits a game and returns to the title screen. * */ diff --git a/src/d_netcmd.h b/src/d_netcmd.h index d8fae72f7..7427252de 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -109,8 +109,6 @@ extern consvar_t cv_startinglives; // for F_finale.c extern consvar_t cv_rollingdemos; -extern consvar_t cv_resetmusic; - extern consvar_t cv_ringslinger, cv_soundtest; extern consvar_t cv_specialrings, cv_powerstones, cv_matchboxes, cv_competitionboxes; @@ -219,6 +217,4 @@ void D_SetPassword(const char *pw); // used for the player setup menu UINT8 CanChangeSkin(INT32 playernum); -#endif - - +#endif \ No newline at end of file diff --git a/src/s_sound.c b/src/s_sound.c index 76ee4c649..33c614051 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -36,6 +36,7 @@ extern INT32 msg_id; #include "d_main.h" #include "r_sky.h" // skyflatnum #include "p_local.h" // camera info +#include "m_misc.h" // for tunes command #ifdef HW3SOUND // 3D Sound Interface @@ -46,6 +47,8 @@ static INT32 S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, I CV_PossibleValue_t soundvolume_cons_t[] = {{0, "MIN"}, {31, "MAX"}, {0, NULL}}; static void SetChannelsNum(void); +static void Command_Tunes_f(void); +static void Command_RestartAudio_f(void); // commands for music and sound servers #ifdef MUSSERV @@ -89,6 +92,7 @@ consvar_t cv_numChannels = {"snd_channels", "32", CV_SAVE|CV_CALL, CV_Unsigned, #endif static consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_resetmusic = {"resetmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #define S_MAX_VOLUME 127 @@ -243,6 +247,11 @@ void S_RegisterSoundStuff(void) #endif CV_RegisterVar(&surround); CV_RegisterVar(&cv_samplerate); + CV_RegisterVar(&cv_resetmusic); + + COM_AddCommand("tunes", Command_Tunes_f); + COM_AddCommand("restartaudio", Command_RestartAudio_f); + #if defined (macintosh) && !defined (HAVE_SDL) // mp3 playlist stuff { @@ -1431,3 +1440,92 @@ void S_ResumeAudio(void) // resume cd music I_ResumeCD(); } + +static void Command_Tunes_f(void) +{ + const char *tunearg; + UINT16 tunenum, track = 0; + const size_t argc = COM_Argc(); + + if (argc < 2) //tunes slot ... + { + CONS_Printf("tunes [track] [speed] / <-show> / <-default> / <-none>:\n"); + CONS_Printf(M_GetText("Play an arbitrary music lump. If a map number is used, 'MAP##M' is played.\n")); + CONS_Printf(M_GetText("If the format supports multiple songs, you can specify which one to play.\n\n")); + CONS_Printf(M_GetText("* With \"-show\", shows the currently playing tune and track.\n")); + CONS_Printf(M_GetText("* With \"-default\", returns to the default music for the map.\n")); + CONS_Printf(M_GetText("* With \"-none\", any music playing will be stopped.\n")); + return; + } + + tunearg = COM_Argv(1); + tunenum = (UINT16)atoi(tunearg); + track = 0; + + if (!strcasecmp(tunearg, "-show")) + { + CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"), + mapmusname, (mapmusflags & MUSIC_TRACKMASK)); + return; + } + if (!strcasecmp(tunearg, "-none")) + { + S_StopMusic(); + return; + } + else if (!strcasecmp(tunearg, "-default")) + { + tunearg = mapheaderinfo[gamemap-1]->musname; + track = mapheaderinfo[gamemap-1]->mustrack; + } + else if (!tunearg[2] && toupper(tunearg[0]) >= 'A' && toupper(tunearg[0]) <= 'Z') + tunenum = (UINT16)M_MapNumber(tunearg[0], tunearg[1]); + + if (tunenum && tunenum >= 1036) + { + CONS_Alert(CONS_NOTICE, M_GetText("Valid music slots are 1 to 1035.\n")); + return; + } + if (!tunenum && strlen(tunearg) > 6) // This is automatic -- just show the error just in case + CONS_Alert(CONS_NOTICE, M_GetText("Music name too long - truncated to six characters.\n")); + + if (argc > 2) + track = (UINT16)atoi(COM_Argv(2))-1; + + if (tunenum) + snprintf(mapmusname, 7, "%sM", G_BuildMapName(tunenum)); + else + strncpy(mapmusname, tunearg, 7); + mapmusname[6] = 0; + mapmusflags = (track & MUSIC_TRACKMASK); + + S_ChangeMusic(mapmusname, mapmusflags, true); + + if (argc > 3) + { + float speed = (float)atof(COM_Argv(3)); + if (speed > 0.0f) + S_SpeedMusic(speed); + } +} + +static void Command_RestartAudio_f(void) +{ + if (dedicated) // No point in doing anything if game is a dedicated server. + return; + + S_StopMusic(); + I_ShutdownMusic(); + I_ShutdownSound(); + I_StartupSound(); + I_InitMusic(); + +// These must be called or no sound and music until manually set. + + I_SetSfxVolume(cv_soundvolume.value); + I_SetDigMusicVolume(cv_digmusicvolume.value); + I_SetMIDIMusicVolume(cv_midimusicvolume.value); + if (Playing()) // Gotta make sure the player is in a level + P_RestoreMusic(&players[consoleplayer]); + +} \ No newline at end of file diff --git a/src/s_sound.h b/src/s_sound.h index 39ec769a6..083815e15 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -25,6 +25,7 @@ extern consvar_t stereoreverse; extern consvar_t cv_soundvolume, cv_digmusicvolume, cv_midimusicvolume; extern consvar_t cv_numChannels; +extern consvar_t cv_resetmusic; #ifdef SNDSERV extern consvar_t sndserver_cmd, sndserver_arg; From 450b536147b6bf36f879ee0a5ae9164d32f15c72 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 11 Oct 2018 20:11:37 -0400 Subject: [PATCH 25/68] Remove the condition in restartaudio command. No longer needed as S_RegisterSoundStuff will return early if in dedicated mode. --- src/s_sound.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 33c614051..a79e56ce5 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1511,9 +1511,6 @@ static void Command_Tunes_f(void) static void Command_RestartAudio_f(void) { - if (dedicated) // No point in doing anything if game is a dedicated server. - return; - S_StopMusic(); I_ShutdownMusic(); I_ShutdownSound(); @@ -1527,5 +1524,4 @@ static void Command_RestartAudio_f(void) I_SetMIDIMusicVolume(cv_midimusicvolume.value); if (Playing()) // Gotta make sure the player is in a level P_RestoreMusic(&players[consoleplayer]); - } \ No newline at end of file From 61fa7026a107e30688bf836e0fc7c6a7c9f77861 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 20 Oct 2018 19:00:37 +0100 Subject: [PATCH 26/68] add vector2 and vector3 userdata types to simplify getting a slope's o/d/normal --- src/lua_libs.h | 2 ++ src/lua_maplib.c | 82 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 65 insertions(+), 19 deletions(-) diff --git a/src/lua_libs.h b/src/lua_libs.h index bf7fe03e9..a9c82bce2 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -39,6 +39,8 @@ extern lua_State *gL; #define META_SECTOR "SECTOR_T*" #define META_FFLOOR "FFLOOR_T*" #define META_SLOPE "PSLOPE_T*" +#define META_VECTOR2 "VECTOR2_T" +#define META_VECTOR3 "VECTOR3_T" #define META_MAPHEADER "MAPHEADER_T*" #define META_CVAR "CONSVAR_T*" diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 7a94060e5..e769a00dc 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -223,6 +223,19 @@ static const char *const slope_opt[] = { "flags", NULL}; +// shared by both vector2_t and vector3_t +enum vector_e { + vector_x = 0, + vector_y, + vector_z +}; + +static const char *const vector_opt[] = { + "x", + "y", + "z", + NULL}; + static const char *const array_opt[] ={"iterate",NULL}; static const char *const valid_opt[] ={"valid",NULL}; @@ -1232,32 +1245,16 @@ static int slope_get(lua_State *L) lua_pushboolean(L, 1); return 1; case slope_o: // o - lua_createtable(L, 0, 3); - lua_pushfixed(L, slope->o.x); - lua_setfield(L, -2, "x"); - lua_pushfixed(L, slope->o.y); - lua_setfield(L, -2, "y"); - lua_pushfixed(L, slope->o.z); - lua_setfield(L, -2, "z"); + LUA_PushUserdata(L, &slope->o, META_VECTOR3); return 1; case slope_d: // d - lua_createtable(L, 0, 2); - lua_pushfixed(L, slope->d.x); - lua_setfield(L, -2, "x"); - lua_pushfixed(L, slope->d.y); - lua_setfield(L, -2, "y"); + LUA_PushUserdata(L, &slope->d, META_VECTOR2); return 1; case slope_zdelta: // zdelta lua_pushfixed(L, slope->zdelta); return 1; case slope_normal: // normal - lua_createtable(L, 0, 3); - lua_pushfixed(L, slope->normal.x); - lua_setfield(L, -2, "x"); - lua_pushfixed(L, slope->normal.y); - lua_setfield(L, -2, "y"); - lua_pushfixed(L, slope->normal.z); - lua_setfield(L, -2, "z"); + LUA_PushUserdata(L, &slope->normal, META_VECTOR3); return 1; case slope_zangle: // zangle lua_pushangle(L, slope->zangle); @@ -1358,6 +1355,43 @@ static int slope_set(lua_State *L) return 0; } +static int vector2_get(lua_State *L) +{ + vector2_t *vec = *((vector2_t **)luaL_checkudata(L, 1, META_VECTOR2)); + enum vector_e field = luaL_checkoption(L, 2, vector_opt[0], vector_opt); + + if (!vec) + return luaL_error(L, "accessed vector2_t doesn't exist anymore."); + + switch(field) + { + case vector_x: lua_pushfixed(L, vec->x); return 1; + case vector_y: lua_pushfixed(L, vec->y); return 1; + default: break; + } + + return 0; +} + +static int vector3_get(lua_State *L) +{ + vector3_t *vec = *((vector3_t **)luaL_checkudata(L, 1, META_VECTOR3)); + enum vector_e field = luaL_checkoption(L, 2, vector_opt[0], vector_opt); + + if (!vec) + return luaL_error(L, "accessed vector3_t doesn't exist anymore."); + + switch(field) + { + case vector_x: lua_pushfixed(L, vec->x); return 1; + case vector_y: lua_pushfixed(L, vec->y); return 1; + case vector_z: lua_pushfixed(L, vec->z); return 1; + default: break; + } + + return 0; +} + static int lib_getMapheaderinfo(lua_State *L) { // i -> mapheaderinfo[i-1] @@ -1542,6 +1576,16 @@ int LUA_MapLib(lua_State *L) lua_setfield(L, -2, "__newindex"); lua_pop(L, 1); + luaL_newmetatable(L, META_VECTOR2); + lua_pushcfunction(L, vector2_get); + lua_setfield(L, -2, "__index"); + lua_pop(L, 1); + + luaL_newmetatable(L, META_VECTOR3); + lua_pushcfunction(L, vector3_get); + lua_setfield(L, -2, "__index"); + lua_pop(L, 1); + luaL_newmetatable(L, META_MAPHEADER); lua_pushcfunction(L, mapheaderinfo_get); lua_setfield(L, -2, "__index"); From 4edeeb69539267dce61e9841c564632dc6cad20d Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 20 Oct 2018 21:08:59 +0100 Subject: [PATCH 27/68] Add P_GetZAt to Lua --- src/lua_baselib.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index e8e8fd020..f60756f1c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -14,6 +14,9 @@ #ifdef HAVE_BLUA #include "p_local.h" #include "p_setup.h" // So we can have P_SetupLevelSky +#ifdef ESLOPE +#include "p_slopes.h" // P_GetZAt +#endif #include "z_zone.h" #include "r_main.h" #include "r_things.h" @@ -1547,6 +1550,24 @@ static int lib_evCrumbleChain(lua_State *L) return 0; } +#ifdef ESLOPE +// P_SLOPES +//////////// + +static int lib_pGetZAt(lua_State *L) +{ + pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE)); + fixed_t x = luaL_checkfixed(L, 2); + fixed_t y = luaL_checkfixed(L, 3); + //HUDSAFE + if (!slope) + return LUA_ErrInvalid(L, "pslope_t"); + + lua_pushfixed(L, P_GetZAt(slope, x, y)); + return 1; +} +#endif + // R_DEFS //////////// @@ -2113,6 +2134,11 @@ static luaL_Reg lib[] = { {"P_StartQuake",lib_pStartQuake}, {"EV_CrumbleChain",lib_evCrumbleChain}, +#ifdef ESLOPE + // p_slopes + {"P_GetZAt",lib_pGetZAt}, +#endif + // r_defs {"R_PointToAngle",lib_rPointToAngle}, {"R_PointToAngle2",lib_rPointToAngle2}, From 9296aaa28c720057b4b0752c82256701ee0ae6ac Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 20 Oct 2018 23:36:06 +0100 Subject: [PATCH 28/68] zangle should be shifted down by ANGLETOFINESHIFT if we're to use FINETANGENT on it --- src/lua_maplib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index e769a00dc..7635ded1c 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1344,7 +1344,7 @@ static int slope_set(lua_State *L) } case slope_zangle: // zangle slope->zangle = luaL_checkangle(L, 3); - slope->zdelta = FINETANGENT(slope->zangle); + slope->zdelta = FINETANGENT(slope->zangle>>ANGLETOFINESHIFT); P_CalculateSlopeNormal(slope); break; case slope_xydirection: // xydirection From 2ec4f2024f784af6bc5562cbd0e5f62d5d722d1a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 21 Oct 2018 15:00:07 +0100 Subject: [PATCH 29/68] Added support for pslope_t userdata variables in Lua archive/unarchive code --- src/lua_script.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index ddfbf5c70..0440efd58 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -22,6 +22,9 @@ #include "byteptr.h" #include "p_saveg.h" #include "p_local.h" +#ifdef ESLOPE +#include "p_slopes.h" // for P_SlopeById +#endif #ifdef LUA_ALLOW_BYTECODE #include "d_netfil.h" // for LUA_DumpFile #endif @@ -457,6 +460,9 @@ enum ARCH_SIDE, ARCH_SUBSECTOR, ARCH_SECTOR, +#ifdef ESLOPE + ARCH_SLOPE, +#endif ARCH_MAPHEADER, ARCH_TEND=0xFF, @@ -476,6 +482,9 @@ static const struct { {META_SIDE, ARCH_SIDE}, {META_SUBSECTOR,ARCH_SUBSECTOR}, {META_SECTOR, ARCH_SECTOR}, +#ifdef ESLOPE + {META_SLOPE, ARCH_SLOPE}, +#endif {META_MAPHEADER, ARCH_MAPHEADER}, {NULL, ARCH_NULL} }; @@ -680,6 +689,19 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) } break; } +#ifdef ESLOPE + case ARCH_SLOPE: + { + pslope_t *slope = *((pslope_t **)lua_touserdata(gL, myindex)); + if (!slope) + WRITEUINT8(save_p, ARCH_NULL); + else { + WRITEUINT8(save_p, ARCH_SLOPE); + WRITEUINT16(save_p, slope->id); + } + break; + } +#endif case ARCH_MAPHEADER: { mapheader_t *header = *((mapheader_t **)lua_touserdata(gL, myindex)); @@ -884,6 +906,11 @@ static UINT8 UnArchiveValue(int TABLESINDEX) case ARCH_SECTOR: LUA_PushUserdata(gL, §ors[READUINT16(save_p)], META_SECTOR); break; +#ifdef ESLOPE + case ARCH_SLOPE: + LUA_PushUserdata(gL, P_SlopeById(READUINT16(save_p)), META_SLOPE); + break; +#endif case ARCH_MAPHEADER: LUA_PushUserdata(gL, §ors[READUINT16(save_p)], META_MAPHEADER); break; From efff869e6e1e15b616f425ba84ce4d339e7052e3 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 21 Oct 2018 15:12:51 +0100 Subject: [PATCH 30/68] Add mobj.standingslope to Lua --- src/lua_mobjlib.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 6bb1388fc..05091f126 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -80,7 +80,12 @@ enum mobj_e { mobj_extravalue1, mobj_extravalue2, mobj_cusval, +#ifdef ESLOPE + mobj_cvmem, + mobj_standingslope +#else mobj_cvmem +#endif }; static const char *const mobj_opt[] = { @@ -140,6 +145,9 @@ static const char *const mobj_opt[] = { "extravalue2", "cusval", "cvmem", +#ifdef ESLOPE + "standingslope", +#endif NULL}; #define UNIMPLEMENTED luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " is not implemented for Lua and cannot be accessed.", mobj_opt[field]) @@ -343,6 +351,11 @@ static int mobj_get(lua_State *L) case mobj_cvmem: lua_pushinteger(L, mo->cvmem); break; +#ifdef ESLOPE + case mobj_standingslope: + LUA_PushUserdata(L, mo->standingslope, META_SLOPE); + break; +#endif default: // extra custom variables in Lua memory lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); I_Assert(lua_istable(L, -1)); @@ -634,6 +647,10 @@ static int mobj_set(lua_State *L) case mobj_cvmem: mo->cvmem = luaL_checkinteger(L, 3); break; +#ifdef ESLOPE + case mobj_standingslope: + return NOSET; +#endif default: lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); I_Assert(lua_istable(L, -1)); From 87afae9cf598922543e36df9efb16230bee36006 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 21 Oct 2018 15:15:54 +0100 Subject: [PATCH 31/68] Fix unarchiving of mapheader_t userdata Lua variables --- src/lua_script.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_script.c b/src/lua_script.c index 1c1b01f6c..9b87f0c29 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -853,7 +853,7 @@ static UINT8 UnArchiveValue(int TABLESINDEX) LUA_PushUserdata(gL, §ors[READUINT16(save_p)], META_SECTOR); break; case ARCH_MAPHEADER: - LUA_PushUserdata(gL, §ors[READUINT16(save_p)], META_MAPHEADER); + LUA_PushUserdata(gL, mapheaderinfo[READUINT16(save_p)], META_MAPHEADER); break; case ARCH_TEND: return 1; From e15ed742c124f556ebebd4983e9f09136fa7cca3 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 21 Oct 2018 16:27:54 +0100 Subject: [PATCH 32/68] add ESLOPE ifdef checks around all the Lua slope support code that was there before I was involved --- src/dehacked.c | 2 ++ src/lua_libs.h | 2 ++ src/lua_maplib.c | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index 251b0532a..d470c7fa9 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7261,11 +7261,13 @@ struct { {"FF_COLORMAPONLY",FF_COLORMAPONLY}, ///< Only copy the colormap, not the lightlevel {"FF_GOOWATER",FF_GOOWATER}, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop. +#ifdef ESLOPE // Slope flags {"SL_NOPHYSICS",SL_NOPHYSICS}, // Don't do momentum adjustment with this slope {"SL_NODYNAMIC",SL_NODYNAMIC}, // Slope will never need to move during the level, so don't fuss with recalculating it {"SL_ANCHORVERTEX",SL_ANCHORVERTEX},// Slope is using a Slope Vertex Thing to anchor its position {"SL_VERTEXSLOPE",SL_VERTEXSLOPE}, // Slope is built from three Slope Vertex Things +#endif // Angles {"ANG1",ANG1}, diff --git a/src/lua_libs.h b/src/lua_libs.h index a9c82bce2..15d988ef6 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -38,9 +38,11 @@ extern lua_State *gL; #define META_SUBSECTOR "SUBSECTOR_T*" #define META_SECTOR "SECTOR_T*" #define META_FFLOOR "FFLOOR_T*" +#ifdef ESLOPE #define META_SLOPE "PSLOPE_T*" #define META_VECTOR2 "VECTOR2_T" #define META_VECTOR3 "VECTOR3_T" +#endif #define META_MAPHEADER "MAPHEADER_T*" #define META_CVAR "CONSVAR_T*" diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 7635ded1c..d83634291 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -40,10 +40,14 @@ enum sector_e { sector_heightsec, sector_camsec, sector_lines, +#ifdef ESLOPE sector_ffloors, sector_fslope, sector_cslope, sector_hasslope +#else + sector_ffloors +#endif }; static const char *const sector_opt[] = { @@ -60,9 +64,11 @@ static const char *const sector_opt[] = { "camsec", "lines", "ffloors", +#ifdef ESLOPE "f_slope", "c_slope", "hasslope", +#endif NULL}; enum subsector_e { @@ -168,8 +174,10 @@ enum ffloor_e { ffloor_toplightlevel, ffloor_bottomheight, ffloor_bottompic, +#ifdef ESLOPE ffloor_tslope, ffloor_bslope, +#endif ffloor_sector, ffloor_flags, ffloor_master, @@ -186,8 +194,10 @@ static const char *const ffloor_opt[] = { "toplightlevel", "bottomheight", "bottompic", +#ifdef ESLOPE "t_slope", "b_slope", +#endif "sector", // secnum pushed as control sector userdata "flags", "master", // control linedef @@ -197,6 +207,7 @@ static const char *const ffloor_opt[] = { "alpha", NULL}; +#ifdef ESLOPE enum slope_e { slope_valid = 0, slope_o, @@ -235,6 +246,7 @@ static const char *const vector_opt[] = { "y", "z", NULL}; +#endif static const char *const array_opt[] ={"iterate",NULL}; static const char *const valid_opt[] ={"valid",NULL}; @@ -450,6 +462,7 @@ static int sector_get(lua_State *L) LUA_PushUserdata(L, sector->ffloors, META_FFLOOR); lua_pushcclosure(L, sector_iterate, 2); // push lib_iterateFFloors and sector->ffloors as upvalues for the function return 1; +#ifdef ESLOPE case sector_fslope: // f_slope LUA_PushUserdata(L, sector->f_slope, META_SLOPE); return 1; @@ -459,6 +472,7 @@ static int sector_get(lua_State *L) case sector_hasslope: // hasslope lua_pushboolean(L, sector->hasslope); return 1; +#endif } return 0; } @@ -481,9 +495,11 @@ static int sector_set(lua_State *L) case sector_heightsec: // heightsec case sector_camsec: // camsec case sector_ffloors: // ffloors +#ifdef ESLOPE case sector_fslope: // f_slope case sector_cslope: // c_slope case sector_hasslope: // hasslope +#endif default: return luaL_error(L, "sector_t field " LUA_QS " cannot be set.", sector_opt[field]); case sector_floorheight: { // floorheight @@ -1118,12 +1134,14 @@ static int ffloor_get(lua_State *L) lua_pushlstring(L, levelflat->name, 8); return 1; } +#ifdef ESLOPE case ffloor_tslope: LUA_PushUserdata(L, *ffloor->t_slope, META_SLOPE); return 1; case ffloor_bslope: LUA_PushUserdata(L, *ffloor->b_slope, META_SLOPE); return 1; +#endif case ffloor_sector: LUA_PushUserdata(L, §ors[ffloor->secnum], META_SECTOR); return 1; @@ -1163,8 +1181,10 @@ static int ffloor_set(lua_State *L) switch(field) { case ffloor_valid: // valid +#ifdef ESLOPE case ffloor_tslope: // t_slope case ffloor_bslope: // b_slope +#endif case ffloor_sector: // sector case ffloor_master: // master case ffloor_target: // target @@ -1225,6 +1245,7 @@ static int ffloor_set(lua_State *L) return 0; } +#ifdef ESLOPE static int slope_get(lua_State *L) { pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE)); @@ -1391,6 +1412,7 @@ static int vector3_get(lua_State *L) return 0; } +#endif static int lib_getMapheaderinfo(lua_State *L) { @@ -1568,6 +1590,7 @@ int LUA_MapLib(lua_State *L) lua_setfield(L, -2, "__newindex"); lua_pop(L, 1); +#ifdef ESLOPE luaL_newmetatable(L, META_SLOPE); lua_pushcfunction(L, slope_get); lua_setfield(L, -2, "__index"); @@ -1585,6 +1608,7 @@ int LUA_MapLib(lua_State *L) lua_pushcfunction(L, vector3_get); lua_setfield(L, -2, "__index"); lua_pop(L, 1); +#endif luaL_newmetatable(L, META_MAPHEADER); lua_pushcfunction(L, mapheaderinfo_get); From 3ec8743c1bbdec71ecaa7d4d4cd41a3f00f1516c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 21 Oct 2018 17:32:53 +0100 Subject: [PATCH 33/68] Fix up the ability to edit slope zdelta and zangle with Lua (zangle is untested as of writing) --- src/lua_maplib.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index d83634291..975ea1cb1 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1359,15 +1359,19 @@ static int slope_set(lua_State *L) } case slope_zdelta: { // zdelta, this is temp until i figure out wtf to do slope->zdelta = luaL_checkfixed(L, 3); - slope->zangle = R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta); + slope->zangle = R_PointToAngle2(0, 0, FRACUNIT, -slope->zdelta); P_CalculateSlopeNormal(slope); break; } - case slope_zangle: // zangle - slope->zangle = luaL_checkangle(L, 3); - slope->zdelta = FINETANGENT(slope->zangle>>ANGLETOFINESHIFT); + case slope_zangle: { // zangle + angle_t zangle = luaL_checkangle(L, 3); + if (zangle == ANGLE_90 || zangle == ANGLE_270) + return luaL_error(L, "invalid zangle for slope!"); + slope->zangle = zangle; + slope->zdelta = -FINETANGENT(((slope->zangle+ANGLE_90)>>ANGLETOFINESHIFT) & 4095); P_CalculateSlopeNormal(slope); break; + } case slope_xydirection: // xydirection slope->xydirection = luaL_checkangle(L, 3); P_CalculateSlopeNormal(slope); From 772004d3fd8032f6397b43221227af488e82cfd4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 21 Oct 2018 18:25:13 +0100 Subject: [PATCH 34/68] Fix editing slope xydirection with Lua --- src/lua_maplib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 975ea1cb1..2ccb3b5f7 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1374,6 +1374,8 @@ static int slope_set(lua_State *L) } case slope_xydirection: // xydirection slope->xydirection = luaL_checkangle(L, 3); + slope->d.x = -FINECOSINE((slope->xydirection>>ANGLETOFINESHIFT) & FINEMASK); + slope->d.y = -FINESINE((slope->xydirection>>ANGLETOFINESHIFT) & FINEMASK); P_CalculateSlopeNormal(slope); break; } From e95b54e64f2cbb13b79ac46b13b8e104f17f5517 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 21 Oct 2018 20:35:14 +0100 Subject: [PATCH 35/68] missed this ESLOPE-needed area from a few commits ago apparently :V --- src/lua_maplib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 2ccb3b5f7..b59c3c178 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -16,7 +16,9 @@ #include "p_local.h" #include "p_setup.h" #include "z_zone.h" +#ifdef ESLOPE #include "p_slopes.h" +#endif #include "r_main.h" #include "lua_script.h" From ab38e6cebb7765e1fe0ce846e2a30deab285e7d2 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 13 Oct 2018 20:44:01 +0100 Subject: [PATCH 36/68] Creating a quick get_WSAErrorStr function to act as a wrapper for FormatMessageA so we can string-ify Winsock errors properly Untested! --- src/i_tcp.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/i_tcp.c b/src/i_tcp.c index 6488e9845..9febd56f0 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -262,6 +262,28 @@ static void wattcp_outch(char s) } #endif +#ifdef USE_WINSOCK +// stupid microsoft makes things complicated +static inline char *get_WSAErrorStr(int e) +{ + char *buf = NULL; + + FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + (DWORD)e, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&buf, + 0, NULL); + + return buf; +} +#undef strerror +#define strerror get_WSAErrorStr +#endif + #ifdef USE_WINSOCK2 #define inet_ntop inet_ntopA #define HAVE_NTOP From 3b39a25adec80437e56f8a6d886d220786a889f6 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 27 Oct 2018 15:49:04 +0100 Subject: [PATCH 37/68] Save the result of errno (aka WSAGetLastError() for WinSock) as soon as possible, to prevent anything in SOCK_GetNodeAddress resetting the value to 0 while trying to print the message for the error itself! --- src/i_tcp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 9febd56f0..6a2127866 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -781,9 +781,13 @@ static void SOCK_Send(void) &clientaddress[doomcom->remotenode].any, d); } - if (c == ERRSOCKET && errno != ECONNREFUSED && errno != EWOULDBLOCK) - I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode, - SOCK_GetNodeAddress(doomcom->remotenode), errno, strerror(errno)); + if (c == ERRSOCKET) + { + int e = errno; // save error code so it can't be modified later + if (e != ECONNREFUSED && e != EWOULDBLOCK) + I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode, + SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e)); + } } #endif From e4e76f83c3e6c4de8ac467667df7daf05d2d9582 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 27 Oct 2018 16:09:14 +0100 Subject: [PATCH 38/68] Use temporary buffer with a max size of 255 bytes instead of having Microsoft's FormatMessageA alloc one for us. Also, provide a fallback message in case no message was available for some reason --- src/i_tcp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 6a2127866..c054b3a4a 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -266,17 +266,22 @@ static void wattcp_outch(char s) // stupid microsoft makes things complicated static inline char *get_WSAErrorStr(int e) { - char *buf = NULL; + char buf[256]; // allow up to 255 bytes + + buf[0] = '\0'; FormatMessageA( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, (DWORD)e, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&buf, - 0, NULL); + (LPTSTR)buf, + sizeof (buf), + NULL); + + if (!buf[0]) // provide a fallback error message if no message is available for some reason + sprintf(buf, "Unknown error"); return buf; } From bb3d850bbfaf9fe9c333e1c0c4a79706ec878c8c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 27 Oct 2018 16:27:00 +0100 Subject: [PATCH 39/68] static the buffer, forgot to do this earlier --- src/i_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index c054b3a4a..43dba4aa3 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -266,7 +266,7 @@ static void wattcp_outch(char s) // stupid microsoft makes things complicated static inline char *get_WSAErrorStr(int e) { - char buf[256]; // allow up to 255 bytes + static char buf[256]; // allow up to 255 bytes buf[0] = '\0'; From 9fb301ecb587ed933f300cc9b65f23f8072e9d57 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 27 Oct 2018 16:47:56 +0100 Subject: [PATCH 40/68] don't bother with inlining the function, on second thoughts --- src/i_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 43dba4aa3..0728c7aac 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -264,7 +264,7 @@ static void wattcp_outch(char s) #ifdef USE_WINSOCK // stupid microsoft makes things complicated -static inline char *get_WSAErrorStr(int e) +static char *get_WSAErrorStr(int e) { static char buf[256]; // allow up to 255 bytes From 29d8e34d03f0508cc75aa887a73d724b79837db6 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 5 Sep 2016 22:14:51 +0100 Subject: [PATCH 41/68] Call V_DoPostProcessor only in software mode (it cancels itself in OGL anyway) --- src/d_main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 170532675..78e370cc3 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -417,10 +417,13 @@ static void D_Display(void) } // Image postprocessing effect - if (postimgtype) - V_DoPostProcessor(0, postimgtype, postimgparam); - if (postimgtype2) - V_DoPostProcessor(1, postimgtype2, postimgparam2); + if (rendermode == render_soft) + { + if (postimgtype) + V_DoPostProcessor(0, postimgtype, postimgparam); + if (postimgtype2) + V_DoPostProcessor(1, postimgtype2, postimgparam2); + } } if (lastdraw) From b150e842fc4920b9298219ededd21f931c9de7f4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 5 Nov 2016 20:40:48 +0000 Subject: [PATCH 42/68] Add MD2_INDENT and MD2_VERSION so we can cleanly check that it's a valid MD2 from magic number/version --- src/hardware/hw_md2.c | 4 ++-- src/hardware/hw_md2.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 756d5a098..42f2afb28 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -304,8 +304,8 @@ static md2_model_t *md2_readModel(const char *filename) // initialize model and read header if (fread(&model->header, sizeof (model->header), 1, file) != 1 - || model->header.magic != - (INT32)(('2' << 24) + ('P' << 16) + ('D' << 8) + 'I')) + || model->header.magic != MD2_IDENT + || model->header.version != MD2_VERSION) { fclose(file); free(model); diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 5a7e6d2b3..299d12400 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -23,6 +23,11 @@ #include "hw_glob.h" +// magic number "IDP2" or 844121161 +#define MD2_IDENT (INT32)(('2' << 24) + ('P' << 16) + ('D' << 8) + 'I') +// model version +#define MD2_VERSION 8 + #define MD2_MAX_TRIANGLES 8192 #define MD2_MAX_VERTICES 4096 #define MD2_MAX_TEXCOORDS 4096 From 67a29225585bb2b978009d86ac3825021708d3bf Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 5 Nov 2016 20:51:48 +0000 Subject: [PATCH 43/68] Ensure file is closed whenever MD2 reading errors happen --- src/hardware/hw_md2.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 42f2afb28..cb33562d8 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -319,6 +319,7 @@ static md2_model_t *md2_readModel(const char *filename) { \ CONS_Alert(CONS_ERROR, "md2_readModel: %s has too many " msgname " (# found: %d, maximum: %d)\n", filename, field, max); \ md2_freeModel (model); \ + fclose(file); \ return 0; \ } @@ -340,6 +341,7 @@ static md2_model_t *md2_readModel(const char *filename) fread(model->skins, sizeof (md2_skin_t), model->header.numSkins, file)) { md2_freeModel (model); + fclose(file); return 0; } } @@ -353,6 +355,7 @@ static md2_model_t *md2_readModel(const char *filename) fread(model->texCoords, sizeof (md2_textureCoordinate_t), model->header.numTexCoords, file)) { md2_freeModel (model); + fclose(file); return 0; } } @@ -366,6 +369,7 @@ static md2_model_t *md2_readModel(const char *filename) fread(model->triangles, sizeof (md2_triangle_t), model->header.numTriangles, file)) { md2_freeModel (model); + fclose(file); return 0; } } @@ -378,6 +382,7 @@ static md2_model_t *md2_readModel(const char *filename) if (!model->frames) { md2_freeModel (model); + fclose(file); return 0; } @@ -391,6 +396,7 @@ static md2_model_t *md2_readModel(const char *filename) fread(frame, 1, model->header.frameSize, file)) { md2_freeModel (model); + fclose(file); return 0; } @@ -416,6 +422,7 @@ static md2_model_t *md2_readModel(const char *filename) fread(model->glCommandBuffer, sizeof (INT32), model->header.numGlCommands, file)) { md2_freeModel (model); + fclose(file); return 0; } } From 787d5b598dd9e681b1896d2f99cfb59a5c9fcc3c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 3 Jun 2017 21:40:41 +0100 Subject: [PATCH 44/68] gr_correcttricks fix: don't check if top/bottom textures are missing for sloped sectors, just ignore and cancel the hack This fixes GFZ2's mysterious flying flats at the ramp to the big room --- src/hardware/hw_trick.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/hardware/hw_trick.c b/src/hardware/hw_trick.c index e9ba19efb..7a92859f8 100644 --- a/src/hardware/hw_trick.c +++ b/src/hardware/hw_trick.c @@ -507,6 +507,14 @@ static boolean areToptexturesMissing(sector_t *thisSector) if (!frontSector || !backSector) continue; +#ifdef ESLOPE + if (frontSector->c_slope || backSector->c_slope) // the slope's height can be completely different from original ceiling height + { + nomiss++; + break; + } +#endif + sider = &sides[thisElem->line->sidenum[0]]; sidel = &sides[thisElem->line->sidenum[1]]; @@ -555,6 +563,14 @@ static boolean areBottomtexturesMissing(sector_t *thisSector) if (frontSector == NULL || backSector == NULL) continue; +#ifdef ESLOPE + if (frontSector->f_slope || backSector->f_slope) // the slope's height can be completely different from original floor height + { + nomiss++; + break; + } +#endif + sider = &sides[thisElem->line->sidenum[0]]; sidel = &sides[thisElem->line->sidenum[1]]; From 2107aab666b8147571ae5d63824412130a5cf50f Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 26 Jun 2017 10:51:19 +0100 Subject: [PATCH 45/68] Moved my added slope checks in hw_trick.c to isCeilingFloating/isFloorFloating I also optimised those two functions while I was there (why keep a "floating" variable when setting it to false guarantees the functions return false?) --- src/hardware/hw_trick.c | 86 ++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 58 deletions(-) diff --git a/src/hardware/hw_trick.c b/src/hardware/hw_trick.c index 7a92859f8..44c07a6b5 100644 --- a/src/hardware/hw_trick.c +++ b/src/hardware/hw_trick.c @@ -507,14 +507,6 @@ static boolean areToptexturesMissing(sector_t *thisSector) if (!frontSector || !backSector) continue; -#ifdef ESLOPE - if (frontSector->c_slope || backSector->c_slope) // the slope's height can be completely different from original ceiling height - { - nomiss++; - break; - } -#endif - sider = &sides[thisElem->line->sidenum[0]]; sidel = &sides[thisElem->line->sidenum[1]]; @@ -563,14 +555,6 @@ static boolean areBottomtexturesMissing(sector_t *thisSector) if (frontSector == NULL || backSector == NULL) continue; -#ifdef ESLOPE - if (frontSector->f_slope || backSector->f_slope) // the slope's height can be completely different from original floor height - { - nomiss++; - break; - } -#endif - sider = &sides[thisElem->line->sidenum[0]]; sidel = &sides[thisElem->line->sidenum[1]]; @@ -603,15 +587,14 @@ static boolean areBottomtexturesMissing(sector_t *thisSector) static boolean isCeilingFloating(sector_t *thisSector) { sector_t *adjSector, *refSector = NULL, *frontSector, *backSector; - boolean floating = true; linechain_t *thisElem, *nextElem; if (!thisSector) return false; - nextElem = thisSector->sectorLines; + nextElem = thisSector->sectorLines; - while (NULL != nextElem) // walk through chain + while (nextElem) // walk through chain { thisElem = nextElem; nextElem = thisElem->next; @@ -625,10 +608,12 @@ static boolean isCeilingFloating(sector_t *thisSector) adjSector = frontSector; if (!adjSector) // assume floating sectors have surrounding sectors - { - floating = false; - break; - } + return false; + +#ifdef ESLOPE + if (adjSector->c_slope) // Don't bother with slopes + return false; +#endif if (!refSector) { @@ -637,23 +622,15 @@ static boolean isCeilingFloating(sector_t *thisSector) } // if adjacent sector has same height or more than one adjacent sector exists -> stop - if (thisSector->ceilingheight == adjSector->ceilingheight || - refSector != adjSector) - { - floating = false; - break; - } + if (thisSector->ceilingheight == adjSector->ceilingheight || refSector != adjSector) + return false; } // now check for walltextures - if (floating) - { - if (!areToptexturesMissing(thisSector)) - { - floating = false; - } - } - return floating; + if (!areToptexturesMissing(thisSector)) + return false; + + return true; } // @@ -663,7 +640,6 @@ static boolean isCeilingFloating(sector_t *thisSector) static boolean isFloorFloating(sector_t *thisSector) { sector_t *adjSector, *refSector = NULL, *frontSector, *backSector; - boolean floating = true; linechain_t *thisElem, *nextElem; if (!thisSector) @@ -684,36 +660,30 @@ static boolean isFloorFloating(sector_t *thisSector) else adjSector = frontSector; - if (NULL == adjSector) // assume floating sectors have surrounding sectors - { - floating = false; - break; - } + if (!adjSector) // assume floating sectors have surrounding sectors + return false; - if (NULL == refSector) +#ifdef ESLOPE + if (adjSector->f_slope) // Don't bother with slopes + return false; +#endif + + if (!refSector) { refSector = adjSector; continue; } // if adjacent sector has same height or more than one adjacent sector exists -> stop - if (thisSector->floorheight == adjSector->floorheight || - refSector != adjSector) - { - floating = false; - break; - } + if (thisSector->floorheight == adjSector->floorheight || refSector != adjSector) + return false; } // now check for walltextures - if (floating) - { - if (!areBottomtexturesMissing(thisSector)) - { - floating = false; - } - } - return floating; + if (!areBottomtexturesMissing(thisSector)) + return false; + + return true; } // From 1cf2ce63c061f5288b088120c981e45ea613c399 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 26 Jun 2017 11:12:26 +0100 Subject: [PATCH 46/68] More optimising and otherwise fixing bizarre formatting in hw_trick.c --- src/hardware/hw_trick.c | 56 +++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/src/hardware/hw_trick.c b/src/hardware/hw_trick.c index 44c07a6b5..97d86b944 100644 --- a/src/hardware/hw_trick.c +++ b/src/hardware/hw_trick.c @@ -107,17 +107,17 @@ static void releaseLineChains(void) for (i = 0; i < numsectors; i++) { - sector = §ors[i]; - nextElem = sector->sectorLines; + sector = §ors[i]; + nextElem = sector->sectorLines; - while (nextElem) - { - thisElem = nextElem; - nextElem = thisElem->next; - free(thisElem); - } + while (nextElem) + { + thisElem = nextElem; + nextElem = thisElem->next; + free(thisElem); + } - sector->sectorLines = NULL; + sector->sectorLines = NULL; } } @@ -397,7 +397,7 @@ static void sortStacklist(sector_t *sector) i = 0; finished = true; - while (NULL != *(list+i+1)) + while (*(list+i+1)) { sec1 = *(list+i); sec2 = *(list+i+1); @@ -438,7 +438,7 @@ static double calcLineoutLength(sector_t *sector) double length = 0.0L; chain = sector->sectorLines; - while (NULL != chain) // sum up lengths of all lines + while (chain) // sum up lengths of all lines { length += lineLength(chain->line); chain = chain->next; @@ -454,7 +454,7 @@ static void calcLineouts(sector_t *sector) size_t secCount = 0; sector_t *encSector = *(sector->stackList); - while (NULL != encSector) + while (encSector) { if (encSector->lineoutLength < 0.0L) // if length has not yet been calculated { @@ -552,7 +552,7 @@ static boolean areBottomtexturesMissing(sector_t *thisSector) if (frontSector == backSector) // skip damn renderer tricks here continue; - if (frontSector == NULL || backSector == NULL) + if (!frontSector || !backSector) continue; sider = &sides[thisElem->line->sidenum[0]]; @@ -645,7 +645,7 @@ static boolean isFloorFloating(sector_t *thisSector) if (!thisSector) return false; - nextElem = thisSector->sectorLines; + nextElem = thisSector->sectorLines; while (nextElem) // walk through chain { @@ -693,14 +693,12 @@ static fixed_t estimateCeilHeight(sector_t *thisSector) { sector_t *adjSector; - if (!thisSector || - !thisSector->sectorLines || - !thisSector->sectorLines->line) + if (!thisSector || !thisSector->sectorLines || !thisSector->sectorLines->line) return 0; adjSector = thisSector->sectorLines->line->frontsector; if (adjSector == thisSector) - adjSector = thisSector->sectorLines->line->backsector; + adjSector = thisSector->sectorLines->line->backsector; if (!adjSector) return 0; @@ -715,17 +713,15 @@ static fixed_t estimateFloorHeight(sector_t *thisSector) { sector_t *adjSector; - if (!thisSector || - !thisSector->sectorLines || - !thisSector->sectorLines->line) - return 0; + if (!thisSector || !thisSector->sectorLines || !thisSector->sectorLines->line) + return 0; adjSector = thisSector->sectorLines->line->frontsector; if (adjSector == thisSector) - adjSector = thisSector->sectorLines->line->backsector; + adjSector = thisSector->sectorLines->line->backsector; - if (NULL == adjSector) - return 0; + if (!adjSector) + return 0; return adjSector->floorheight; } @@ -831,18 +827,12 @@ void HWR_CorrectSWTricks(void) // correct height of floating sectors if (isCeilingFloating(floatSector)) { - fixed_t corrheight; - - corrheight = estimateCeilHeight(floatSector); - floatSector->virtualCeilingheight = corrheight; + floatSector->virtualCeilingheight = estimateCeilHeight(floatSector); floatSector->virtualCeiling = true; } if (isFloorFloating(floatSector)) { - fixed_t corrheight; - - corrheight = estimateFloorHeight(floatSector); - floatSector->virtualFloorheight = corrheight; + floatSector->virtualFloorheight = estimateFloorHeight(floatSector); floatSector->virtualFloor = true; } } From 90cfa5ef16d9e283cf4b23be70d9ad3f7a6f41f7 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 7 Nov 2016 21:55:56 +0000 Subject: [PATCH 47/68] Make new pv1/pv2 seg pointers, so AdjustSeg doesn't modify the v1/v2 pointers directly anymore Yes I know they're void * in r_defs.h's seg_t definition, it's quicker than trying to figure out if including hardware/hw_glob.h is a good idea or not --- src/hardware/hw_bsp.c | 12 ++++---- src/hardware/hw_main.c | 64 +++++++++++++++++++++--------------------- src/p_setup.c | 1 + src/r_defs.h | 3 ++ 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index a32609fc8..97baec66c 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -914,7 +914,7 @@ static void AdjustSegs(void) } if (nearv1 <= NEARDIST*NEARDIST) // share vertice with segs - lseg->v1 = (vertex_t *)&(p->pts[v1found]); + lseg->pv1 = &(p->pts[v1found]); else { // BP: here we can do better, using PointInSeg and compute @@ -925,24 +925,24 @@ static void AdjustSegs(void) polyvertex_t *pv = HWR_AllocVertex(); pv->x = FIXED_TO_FLOAT(lseg->v1->x); pv->y = FIXED_TO_FLOAT(lseg->v1->y); - lseg->v1 = (vertex_t *)pv; + lseg->pv1 = pv; } if (nearv2 <= NEARDIST*NEARDIST) - lseg->v2 = (vertex_t *)&(p->pts[v2found]); + lseg->pv2 = &(p->pts[v2found]); else { polyvertex_t *pv = HWR_AllocVertex(); pv->x = FIXED_TO_FLOAT(lseg->v2->x); pv->y = FIXED_TO_FLOAT(lseg->v2->y); - lseg->v2 = (vertex_t *)pv; + lseg->pv2 = pv; } // recompute length { float x,y; - x = ((polyvertex_t *)lseg->v2)->x - ((polyvertex_t *)lseg->v1)->x + x = ((polyvertex_t *)lseg->pv2)->x - ((polyvertex_t *)lseg->pv1)->x + FIXED_TO_FLOAT(FRACUNIT/2); - y = ((polyvertex_t *)lseg->v2)->y - ((polyvertex_t *)lseg->v1)->y + y = ((polyvertex_t *)lseg->pv2)->y - ((polyvertex_t *)lseg->pv1)->y + FIXED_TO_FLOAT(FRACUNIT/2); lseg->flength = (float)hypot(x, y); // BP: debug see this kind of segs diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ecb70a0f9..85ddff082 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -856,11 +856,11 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) M_ClearBox(segbbox); M_AddToBox(segbbox, - FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->y)); + FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x), + FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y)); M_AddToBox(segbbox, - FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->y)); + FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x), + FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y)); splat = (wallsplat_t *)gr_curline->linedef->splats; for (; splat; splat = splat->next) @@ -1367,10 +1367,10 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) gr_sidedef = gr_curline->sidedef; gr_linedef = gr_curline->linedef; - vs.x = ((polyvertex_t *)gr_curline->v1)->x; - vs.y = ((polyvertex_t *)gr_curline->v1)->y; - ve.x = ((polyvertex_t *)gr_curline->v2)->x; - ve.y = ((polyvertex_t *)gr_curline->v2)->y; + vs.x = ((polyvertex_t *)gr_curline->pv1)->x; + vs.y = ((polyvertex_t *)gr_curline->pv1)->y; + ve.x = ((polyvertex_t *)gr_curline->pv2)->x; + ve.y = ((polyvertex_t *)gr_curline->pv2)->y; #ifdef ESLOPE v1x = FLOAT_TO_FIXED(vs.x); @@ -2456,7 +2456,7 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last) } else { - highfrac = HWR_ClipViewSegment(start->first+1, (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2); + highfrac = HWR_ClipViewSegment(start->first+1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2); HWR_StoreWallRange(0, highfrac); } // Now adjust the clip size. @@ -2480,8 +2480,8 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last) } else { - lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2); - highfrac = HWR_ClipViewSegment((next+1)->first+1, (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2); + lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2); + highfrac = HWR_ClipViewSegment((next+1)->first+1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2); HWR_StoreWallRange(lowfrac, highfrac); } next++; @@ -2515,7 +2515,7 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last) } else { - lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2); + lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2); HWR_StoreWallRange(lowfrac, 1); } } @@ -2578,8 +2578,8 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last) else { highfrac = HWR_ClipViewSegment(min(start->first + 1, - start->last), (polyvertex_t *)gr_curline->v1, - (polyvertex_t *)gr_curline->v2); + start->last), (polyvertex_t *)gr_curline->pv1, + (polyvertex_t *)gr_curline->pv2); HWR_StoreWallRange(0, highfrac); } } @@ -2598,8 +2598,8 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last) } else { - lowfrac = HWR_ClipViewSegment(max(start->last-1,start->first), (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2); - highfrac = HWR_ClipViewSegment(min((start+1)->first+1,(start+1)->last), (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2); + lowfrac = HWR_ClipViewSegment(max(start->last-1,start->first), (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2); + highfrac = HWR_ClipViewSegment(min((start+1)->first+1,(start+1)->last), (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2); HWR_StoreWallRange(lowfrac, highfrac); } start++; @@ -2629,8 +2629,8 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last) else { lowfrac = HWR_ClipViewSegment(max(start->last - 1, - start->first), (polyvertex_t *)gr_curline->v1, - (polyvertex_t *)gr_curline->v2); + start->first), (polyvertex_t *)gr_curline->pv1, + (polyvertex_t *)gr_curline->pv2); HWR_StoreWallRange(lowfrac, 1); } } @@ -2691,10 +2691,10 @@ static void HWR_AddLine(seg_t * line) gr_curline = line; // OPTIMIZE: quickly reject orthogonal back sides. - angle1 = R_PointToAngle(FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->y)); - angle2 = R_PointToAngle(FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->y)); + angle1 = R_PointToAngle(FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x), + FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y)); + angle2 = R_PointToAngle(FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x), + FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y)); // Clip to view edges. span = angle1 - angle2; @@ -2736,8 +2736,8 @@ static void HWR_AddLine(seg_t * line) float fx1,fx2,fy1,fy2; //BP: test with a better projection than viewangletox[R_PointToAngle(angle)] // do not enable this at release 4 mul and 2 div - fx1 = ((polyvertex_t *)(line->v1))->x-gr_viewx; - fy1 = ((polyvertex_t *)(line->v1))->y-gr_viewy; + fx1 = ((polyvertex_t *)(line->pv1))->x-gr_viewx; + fy1 = ((polyvertex_t *)(line->pv1))->y-gr_viewy; fy2 = (fx1 * gr_viewcos + fy1 * gr_viewsin); if (fy2 < 0) // the point is back @@ -2745,8 +2745,8 @@ static void HWR_AddLine(seg_t * line) else fx1 = gr_windowcenterx + (fx1 * gr_viewsin - fy1 * gr_viewcos) * gr_centerx / fy2; - fx2 = ((polyvertex_t *)(line->v2))->x-gr_viewx; - fy2 = ((polyvertex_t *)(line->v2))->y-gr_viewy; + fx2 = ((polyvertex_t *)(line->pv2))->x-gr_viewx; + fy2 = ((polyvertex_t *)(line->pv2))->y-gr_viewy; fy1 = (fx2 * gr_viewcos + fy2 * gr_viewsin); if (fy1 < 0) // the point is back @@ -2789,10 +2789,10 @@ static void HWR_AddLine(seg_t * line) fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends - v1x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->x); - v1y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->y); - v2x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->x); - v2y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->y); + v1x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x); + v1y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y); + v2x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x); + v2y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y); #define SLOPEPARAMS(slope, end1, end2, normalheight) \ if (slope) { \ end1 = P_GetZAt(slope, v1x, v1y); \ @@ -2987,8 +2987,8 @@ static inline void HWR_AddPolyObjectSegs(void) pv2->x = FIXED_TO_FLOAT(gr_fakeline->v2->x); pv2->y = FIXED_TO_FLOAT(gr_fakeline->v2->y); - gr_fakeline->v1 = (vertex_t *)pv1; - gr_fakeline->v2 = (vertex_t *)pv2; + gr_fakeline->pv1 = pv1; + gr_fakeline->pv2 = pv2; HWR_AddLine(gr_fakeline); } diff --git a/src/p_setup.c b/src/p_setup.c index 17a6797f4..f00781a5d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -451,6 +451,7 @@ static void P_LoadSegs(lumpnum_t lumpnum) //Hurdler: 04/12/2000: for now, only used in hardware mode li->lightmaps = NULL; // list of static lightmap for this seg } + li->pv1 = li->pv2 = NULL; #endif li->angle = (SHORT(ml->angle))< Date: Wed, 21 Dec 2016 22:10:27 +0000 Subject: [PATCH 48/68] Hack to make sure even (extra)subsectors without planepolys have segs adjusted this fixes a crash in (old) GFZ2 at the ramp as a result of creating pv1/pv2. This probably means before pv1/pv2 there could have been some silly typecasting from vertex_t to polyvertex_t to get fixed vertex coords and such... --- src/hardware/hw_bsp.c | 44 ++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 97baec66c..fa5bce308 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -878,8 +878,8 @@ static void AdjustSegs(void) count = subsectors[i].numlines; lseg = &segs[subsectors[i].firstline]; p = extrasubsectors[i].planepoly; - if (!p) - continue; + //if (!p) + //continue; for (; count--; lseg++) { float distv1,distv2,tmp; @@ -892,27 +892,29 @@ static void AdjustSegs(void) continue; #endif - for (j = 0; j < p->numpts; j++) - { - distv1 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v1->x); - tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v1->y); - distv1 = distv1*distv1+tmp*tmp; - if (distv1 <= nearv1) + if (p) { + for (j = 0; j < p->numpts; j++) { - v1found = j; - nearv1 = distv1; - } - // the same with v2 - distv2 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v2->x); - tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v2->y); - distv2 = distv2*distv2+tmp*tmp; - if (distv2 <= nearv2) - { - v2found = j; - nearv2 = distv2; + distv1 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v1->x); + tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v1->y); + distv1 = distv1*distv1+tmp*tmp; + if (distv1 <= nearv1) + { + v1found = j; + nearv1 = distv1; + } + // the same with v2 + distv2 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v2->x); + tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v2->y); + distv2 = distv2*distv2+tmp*tmp; + if (distv2 <= nearv2) + { + v2found = j; + nearv2 = distv2; + } } } - if (nearv1 <= NEARDIST*NEARDIST) + if (p && nearv1 <= NEARDIST*NEARDIST) // share vertice with segs lseg->pv1 = &(p->pts[v1found]); else @@ -927,7 +929,7 @@ static void AdjustSegs(void) pv->y = FIXED_TO_FLOAT(lseg->v1->y); lseg->pv1 = pv; } - if (nearv2 <= NEARDIST*NEARDIST) + if (p && nearv2 <= NEARDIST*NEARDIST) lseg->pv2 = &(p->pts[v2found]); else { From 3d88ee9d55385f5281108f90a4fea63ce4a8ad2e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 21 Dec 2016 22:31:09 +0000 Subject: [PATCH 49/68] Added missing checks in HWR_AddLine from the software version, move v** vars to the top since R_PointToAngle calls use the same values anyway --- src/hardware/hw_main.c | 49 ++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 85ddff082..d4b2832f8 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2685,16 +2685,21 @@ static void HWR_AddLine(seg_t * line) // SoM: Backsector needs to be run through R_FakeFlat static sector_t tempsec; + fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t + if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES)) return; gr_curline = line; + v1x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x); + v1y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y); + v2x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x); + v2y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y); + // OPTIMIZE: quickly reject orthogonal back sides. - angle1 = R_PointToAngle(FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y)); - angle2 = R_PointToAngle(FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y)); + angle1 = R_PointToAngle(v1x, v1y); + angle2 = R_PointToAngle(v2x, v2y); // Clip to view edges. span = angle1 - angle2; @@ -2785,14 +2790,9 @@ static void HWR_AddLine(seg_t * line) #ifdef ESLOPE if (gr_frontsector->f_slope || gr_frontsector->c_slope || gr_backsector->f_slope || gr_backsector->c_slope) { - fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends - v1x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x); - v1y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y); - v2x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x); - v2y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y); #define SLOPEPARAMS(slope, end1, end2, normalheight) \ if (slope) { \ end1 = P_GetZAt(slope, v1x, v1y); \ @@ -2813,6 +2813,13 @@ static void HWR_AddLine(seg_t * line) goto clipsolid; } + // Check for automap fix. + if (backc1 <= backf1 && backc2 <= backf2 + && ((backc1 >= frontc1 && backc2 >= frontc2) || gr_curline->sidedef->toptexture) + && ((backf1 <= frontf1 && backf2 >= frontf2) || gr_curline->sidedef->bottomtexture) + && (gr_backsector->ceilingpic != skyflatnum || gr_frontsector->ceilingpic != skyflatnum)) + goto clipsolid; + // Window. if (backc1 != frontc1 || backc2 != frontc2 || backf1 != frontf1 || backf2 != frontf2) @@ -2828,6 +2835,13 @@ static void HWR_AddLine(seg_t * line) gr_backsector->floorheight >= gr_frontsector->ceilingheight) goto clipsolid; + // Check for automap fix. + if (gr_backsector->ceilingheight <= gr_backsector->floorheight + && ((gr_backsector->ceilingheight >= gr_frontsector->ceilingheight) || gr_curline->sidedef->toptexture) + && ((gr_backsector->floorheight <= gr_backsector->floorheight) || gr_curline->sidedef->bottomtexture) + && (gr_backsector->ceilingpic != skyflatnum || gr_frontsector->ceilingpic != skyflatnum)) + goto clipsolid; + // Window. if (gr_backsector->ceilingheight != gr_frontsector->ceilingheight || gr_backsector->floorheight != gr_frontsector->floorheight) @@ -2849,8 +2863,21 @@ static void HWR_AddLine(seg_t * line) && gr_backsector->c_slope == gr_frontsector->c_slope #endif && gr_backsector->lightlevel == gr_frontsector->lightlevel - && gr_curline->sidedef->midtexture == 0 - && !gr_backsector->ffloors && !gr_frontsector->ffloors) + && !gr_curline->sidedef->midtexture + // Check offsets too! + && gr_backsector->floor_xoffs == gr_frontsector->floor_xoffs + && gr_backsector->floor_yoffs == gr_frontsector->floor_yoffs + && gr_backsector->floorpic_angle == gr_frontsector->floorpic_angle + && gr_backsector->ceiling_xoffs == gr_frontsector->ceiling_xoffs + && gr_backsector->ceiling_yoffs == gr_frontsector->ceiling_yoffs + && gr_backsector->ceilingpic_angle == gr_frontsector->ceilingpic_angle + // Consider altered lighting. + && gr_backsector->floorlightsec == gr_frontsector->floorlightsec + && gr_backsector->ceilinglightsec == gr_frontsector->ceilinglightsec + // Consider colormaps + && gr_backsector->extra_colormap == gr_frontsector->extra_colormap + && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) + || gr_frontsector->tag == gr_backsector->tag)) // SoM: For 3D sides... Boris, would you like to take a // crack at rendering 3D sides? You would need to add the // above check and add code to HWR_StoreWallRange... From aebcf3520b8814b11b694b571cb7c4352ced637b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 12 Jan 2017 21:43:37 +0000 Subject: [PATCH 50/68] Remove pointless drawtextured variable and redundant fake planes checks (R_FakeFlat would already have made gr_frontsector/backsector something else if they were) --- src/hardware/hw_main.c | 98 ++++++++---------------------------------- 1 file changed, 19 insertions(+), 79 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d4b2832f8..7e8152583 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -323,9 +323,6 @@ static angle_t gr_xtoviewangle[MAXVIDWIDTH+1]; // test change fov when looking up/down but bsp projection messup :( //#define NOCRAPPYMLOOK -/// \note crappy -#define drawtextured true - // base values set at SetViewSize static float gr_basecentery; @@ -1378,44 +1375,21 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) v2x = FLOAT_TO_FIXED(ve.x); v2y = FLOAT_TO_FIXED(ve.y); #endif - - if (gr_frontsector->heightsec != -1) - { #ifdef ESLOPE - worldtop = worldtopslope = sectors[gr_frontsector->heightsec].ceilingheight; - worldbottom = worldbottomslope = sectors[gr_frontsector->heightsec].floorheight; -#else - worldtop = sectors[gr_frontsector->heightsec].ceilingheight; - worldbottom = sectors[gr_frontsector->heightsec].floorheight; -#endif - } - else - { -#ifdef ESLOPE - if (gr_frontsector->c_slope) - { - worldtop = P_GetZAt(gr_frontsector->c_slope, v1x, v1y); - worldtopslope = P_GetZAt(gr_frontsector->c_slope, v2x, v2y); - } - else - { - worldtop = worldtopslope = gr_frontsector->ceilingheight; - } - if (gr_frontsector->f_slope) - { - worldbottom = P_GetZAt(gr_frontsector->f_slope, v1x, v1y); - worldbottomslope = P_GetZAt(gr_frontsector->f_slope, v2x, v2y); - } - else - { - worldbottom = worldbottomslope = gr_frontsector->floorheight; - } +#define SLOPEPARAMS(slope, end1, end2, normalheight) \ + if (slope) { \ + end1 = P_GetZAt(slope, v1x, v1y); \ + end2 = P_GetZAt(slope, v2x, v2y); \ + } else \ + end1 = end2 = normalheight; + + SLOPEPARAMS(gr_frontsector->c_slope, worldtop, worldtopslope, gr_frontsector->ceilingheight) + SLOPEPARAMS(gr_frontsector->f_slope, worldbottom, worldbottomslope, gr_frontsector->floorheight) #else - worldtop = gr_frontsector->ceilingheight; - worldbottom = gr_frontsector->floorheight; + worldtop = gr_frontsector->ceilingheight; + worldbottom = gr_frontsector->floorheight; #endif - } // remember vertices ordering // 3--2 @@ -1430,7 +1404,6 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) wallVerts[2].z = wallVerts[1].z = ve.y; wallVerts[0].w = wallVerts[1].w = wallVerts[2].w = wallVerts[3].w = 1.0f; - if (drawtextured) { // x offset the texture fixed_t texturehpeg = gr_sidedef->textureoffset + gr_curline->offset; @@ -1459,43 +1432,15 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) { INT32 gr_toptexture, gr_bottomtexture; // two sided line - if (gr_backsector->heightsec != -1) - { -#ifdef ESLOPE - worldhigh = worldhighslope = sectors[gr_backsector->heightsec].ceilingheight; - worldlow = worldlowslope = sectors[gr_backsector->heightsec].floorheight; -#else - worldhigh = sectors[gr_backsector->heightsec].ceilingheight; - worldlow = sectors[gr_backsector->heightsec].floorheight; -#endif - } - else - { -#ifdef ESLOPE - if (gr_backsector->c_slope) - { - worldhigh = P_GetZAt(gr_backsector->c_slope, v1x, v1y); - worldhighslope = P_GetZAt(gr_backsector->c_slope, v2x, v2y); - } - else - { - worldhigh = worldhighslope = gr_backsector->ceilingheight; - } - if (gr_backsector->f_slope) - { - worldlow = P_GetZAt(gr_backsector->f_slope, v1x, v1y); - worldlowslope = P_GetZAt(gr_backsector->f_slope, v2x, v2y); - } - else - { - worldlow = worldlowslope = gr_backsector->floorheight; - } +#ifdef ESLOPE + SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) + SLOPEPARAMS(gr_backsector->f_slope, worldlow, worldlowslope, gr_backsector->floorheight) +#undef SLOPEPARAMS #else - worldhigh = gr_backsector->ceilingheight; - worldlow = gr_backsector->floorheight; + worldhigh = gr_backsector->ceilingheight; + worldlow = gr_backsector->floorheight; #endif - } // hack to allow height changes in outdoor areas // This is what gets rid of the upper textures if there should be sky @@ -1519,7 +1464,6 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) worldhigh < worldtop ) && gr_toptexture) { - if (drawtextured) { fixed_t texturevpegtop; // top @@ -1600,7 +1544,6 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) #endif worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!! { - if (drawtextured) { fixed_t texturevpegbottom = 0; // bottom @@ -1792,7 +1735,6 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) h = min(highcut, polytop); l = max(polybottom, lowcut); - if (drawtextured) { // PEGGING #ifdef ESLOPE @@ -1848,7 +1790,6 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) h = min(highcut, polytop); l = max(polybottom, lowcut); - if (drawtextured) { // PEGGING if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) @@ -2039,7 +1980,6 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); if (gr_midtexture) { - if (drawtextured) { fixed_t texturevpeg; // PEGGING @@ -2180,7 +2120,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) wallVerts[0].s = wallVerts[3].s = 0; wallVerts[2].s = wallVerts[1].s = 0; } - else if (drawtextured) + else { fixed_t texturevpeg; @@ -2316,7 +2256,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) wallVerts[0].s = wallVerts[3].s = 0; wallVerts[2].s = wallVerts[1].s = 0; } - else if (drawtextured) + else { grTex = HWR_GetTexture(texnum); From 32077897b6af08a28e1fe28b9a2b9ef14393672f Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 27 Oct 2018 19:58:51 +0100 Subject: [PATCH 51/68] Removed all remaining traces of VID_X11 code in hw_drv.h and hw_data.h, the macro is no longer used by Linux etc versions of SRB2. Unlike the rest of the commits in this branch (as of writing), I didn't make this commit between 1 and 2 years ago, I made it right now ;) --- src/hardware/hw_data.h | 4 ---- src/hardware/hw_drv.h | 15 --------------- 2 files changed, 19 deletions(-) diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index d76fcc1c8..4bbc578ed 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -26,10 +26,6 @@ #include #endif -#if defined (VID_X11) && !defined (HAVE_SDL) -#include -#endif - #include "../doomdef.h" //THIS MUST DISAPPEAR!!! #include "hw_glide.h" diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index a5ac82001..e2fa90eb0 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -32,10 +32,6 @@ // STANDARD DLL EXPORTS // ========================================================================== -#ifdef HAVE_SDL -#undef VID_X11 -#endif - EXPORT boolean HWRAPI(Init) (I_Error_t ErrorFunction); #ifndef HAVE_SDL EXPORT void HWRAPI(Shutdown) (void); @@ -43,9 +39,6 @@ EXPORT void HWRAPI(Shutdown) (void); #ifdef _WINDOWS EXPORT void HWRAPI(GetModeList) (vmode_t **pvidmodes, INT32 *numvidmodes); #endif -#ifdef VID_X11 -EXPORT Window HWRAPI(HookXwin) (Display *, INT32, INT32, boolean); -#endif #if defined (PURESDL) || defined (macintosh) EXPORT void HWRAPI(SetPalette) (INT32 *, RGBA_t *gamma); #else @@ -71,10 +64,6 @@ EXPORT void HWRAPI(SetTransform) (FTransform *ptransform); EXPORT INT32 HWRAPI(GetTextureUsed) (void); EXPORT INT32 HWRAPI(GetRenderVersion) (void); -#ifdef VID_X11 // ifdef to be removed as soon as windoze supports that as well -// metzgermeister: added for Voodoo detection -EXPORT char *HWRAPI(GetRenderer) (void); -#endif #ifdef SHUFFLE #define SCREENVERTS 10 EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]); @@ -115,10 +104,6 @@ struct hwdriver_s #ifdef _WINDOWS GetModeList pfnGetModeList; #endif -#ifdef VID_X11 - HookXwin pfnHookXwin; - GetRenderer pfnGetRenderer; -#endif #ifndef HAVE_SDL Shutdown pfnShutdown; #endif From 834a5e6b3530a5ed3cc89b3528b8f35ea8689b55 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 29 Oct 2018 12:06:22 +0000 Subject: [PATCH 52/68] V_DrawFixedPatch: Tinker with the left/top offsets code so that V_OFFSET can support V_FLIP --- src/v_video.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 802a4d388..0d80dc50e 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -406,22 +406,35 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t colfrac = FixedDiv(FRACUNIT, fdup); rowfrac = FixedDiv(FRACUNIT, fdup); - if (scrn & V_OFFSET) // Crosshair shit + // So it turns out offsets aren't scaled in V_NOSCALESTART unless V_OFFSET is applied ...poo, that's terrible + // For now let's just at least give V_OFFSET the ability to support V_FLIP + // I'll probably make a better fix for 2.2 where I don't have to worry about breaking existing support for stuff + // -- Monster Iestyn 29/10/18 { - y -= FixedMul((SHORT(patch->topoffset)*dupy)<leftoffset)*dupx)<topoffset)<width) - SHORT(patch->leftoffset))<width) - SHORT(patch->leftoffset))<leftoffset)<leftoffset)<topoffset)< Date: Mon, 29 Oct 2018 12:36:09 +0000 Subject: [PATCH 53/68] Make V_OFFSET no thing without V_NOSCALESTART, to remove any potential glitches with using it on its own --- src/v_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v_video.c b/src/v_video.c index 0d80dc50e..b5abd009b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -426,7 +426,7 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t // TODO: make some kind of vertical version of V_FLIP, maybe by deprecating V_OFFSET in future?!? offsety = FixedMul(SHORT(patch->topoffset)< Date: Mon, 29 Oct 2018 13:29:16 +0000 Subject: [PATCH 54/68] HWR_DrawFixedPatch: Add V_OFFSET support for V_FLIP in hardware code as well, also add missing SHORTs for gpatch fields --- src/hardware/hw_draw.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 84081dd25..ad41c68d0 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -179,18 +179,29 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, dupx = dupy = (dupx < dupy ? dupx : dupy); fscale = FIXED_TO_FLOAT(pscale); - if (option & V_OFFSET) + // See my comments in v_video.c's V_DrawFixedPatch + // -- Monster Iestyn 29/10/18 { - cx -= (float)gpatch->leftoffset * dupx * fscale; - cy -= (float)gpatch->topoffset * dupy * fscale; - } - else - { - cy -= (float)gpatch->topoffset * fscale; + float offsetx = 0.0f, offsety = 0.0f; + + // left offset if (option & V_FLIP) - cx -= ((float)gpatch->width - (float)gpatch->leftoffset) * fscale; + offsetx = (float)(SHORT(gpatch->width) - SHORT(gpatch->leftoffset)) * fscale; else - cx -= (float)gpatch->leftoffset * fscale; + offsetx = (float)SHORT(gpatch->leftoffset) * fscale; + + // top offset + // TODO: make some kind of vertical version of V_FLIP, maybe by deprecating V_OFFSET in future?!? + offsety = (float)SHORT(patch->topoffset) * fscale; + + if ((option & (V_NOSCALESTART|V_OFFSET)) == (V_NOSCALESTART|V_OFFSET)) // Multiply by dupx/dupy for crosshairs + { + offsetx *= dupx; + offsety *= dupy; + } + + cx -= offsetx; + cy -= offsety; } if (option & V_SPLITSCREEN) @@ -237,13 +248,13 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, if (pscale != FRACUNIT) { - fwidth = (float)gpatch->width * fscale * dupx; - fheight = (float)gpatch->height * fscale * dupy; + fwidth = (float)SHORT(gpatch->width) * fscale * dupx; + fheight = (float)SHORT(gpatch->height) * fscale * dupy; } else { - fwidth = (float)gpatch->width * dupx; - fheight = (float)gpatch->height * dupy; + fwidth = (float)SHORT(gpatch->width) * dupx; + fheight = (float)SHORT(gpatch->height) * dupy; } // positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1 From b022ff02a5859dd597cc67c40367085fee40ac4c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 29 Oct 2018 13:34:54 +0000 Subject: [PATCH 55/68] add missing SHORTs in HWR_DrawPatch and HWR_DrawCroppedPatch as well --- src/hardware/hw_draw.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index ad41c68d0..ffd156862 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -112,10 +112,10 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option) if (option & V_NOSCALESTART) sdupx = sdupy = 2.0f; - v[0].x = v[3].x = (x*sdupx-gpatch->leftoffset*pdupx)/vid.width - 1; - v[2].x = v[1].x = (x*sdupx+(gpatch->width-gpatch->leftoffset)*pdupx)/vid.width - 1; - v[0].y = v[1].y = 1-(y*sdupy-gpatch->topoffset*pdupy)/vid.height; - v[2].y = v[3].y = 1-(y*sdupy+(gpatch->height-gpatch->topoffset)*pdupy)/vid.height; + v[0].x = v[3].x = (x*sdupx-SHORT(gpatch->leftoffset)*pdupx)/vid.width - 1; + v[2].x = v[1].x = (x*sdupx+(SHORT(gpatch->width)-SHORT(gpatch->leftoffset))*pdupx)/vid.width - 1; + v[0].y = v[1].y = 1-(y*sdupy-SHORT(gpatch->topoffset)*pdupy)/vid.height; + v[2].y = v[3].y = 1-(y*sdupy+(SHORT(gpatch->height)-SHORT(gpatch->topoffset))*pdupy)/vid.height; v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; @@ -352,8 +352,8 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal dupx = dupy = (dupx < dupy ? dupx : dupy); fscale = FIXED_TO_FLOAT(pscale); - cy -= (float)gpatch->topoffset * fscale; - cx -= (float)gpatch->leftoffset * fscale; + cy -= (float)SHORT(gpatch->topoffset) * fscale; + cx -= (float)SHORT(gpatch->leftoffset) * fscale; if (!(option & V_NOSCALESTART)) { @@ -403,11 +403,11 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal if (fheight > h - sy) fheight = h - sy; - if (fwidth > gpatch->width) - fwidth = gpatch->width; + if (fwidth > SHORT(gpatch->width)) + fwidth = SHORT(gpatch->width); - if (fheight > gpatch->height) - fheight = gpatch->height; + if (fheight > SHORT(gpatch->height)) + fheight = SHORT(gpatch->height); if (pscale != FRACUNIT) { @@ -437,10 +437,10 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; - v[0].sow = v[3].sow = ((sx)/(float)gpatch->width )*gpatch->max_s; - v[2].sow = v[1].sow = ((w )/(float)gpatch->width )*gpatch->max_s; - v[0].tow = v[1].tow = ((sy)/(float)gpatch->height)*gpatch->max_t; - v[2].tow = v[3].tow = ((h )/(float)gpatch->height)*gpatch->max_t; + v[0].sow = v[3].sow = ((sx)/(float)SHORT(gpatch->width) )*gpatch->max_s; + v[2].sow = v[1].sow = ((w )/(float)SHORT(gpatch->width) )*gpatch->max_s; + v[0].tow = v[1].tow = ((sy)/(float)SHORT(gpatch->height))*gpatch->max_t; + v[2].tow = v[3].tow = ((h )/(float)SHORT(gpatch->height))*gpatch->max_t; flags = BLENDMODE|PF_Clip|PF_NoZClip|PF_NoDepthTest; From 2fa0896fd020ef2eb83a42561344fe888df06588 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 30 Oct 2018 13:44:01 +0000 Subject: [PATCH 56/68] Fix an error I made in HWR_DrawFixedPatch --- src/hardware/hw_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index ffd156862..33f5e0318 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -192,7 +192,7 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, // top offset // TODO: make some kind of vertical version of V_FLIP, maybe by deprecating V_OFFSET in future?!? - offsety = (float)SHORT(patch->topoffset) * fscale; + offsety = (float)SHORT(gpatch->topoffset) * fscale; if ((option & (V_NOSCALESTART|V_OFFSET)) == (V_NOSCALESTART|V_OFFSET)) // Multiply by dupx/dupy for crosshairs { From 22e8dd1f9da40d0447531f848ae4cbbdd18b869c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 30 Oct 2018 14:22:21 +0000 Subject: [PATCH 57/68] now that V_FLIP's effects are always supported in V_DrawFixedPatch, there's no need for the "flip" variable anymore --- src/v_video.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index b5abd009b..933ec0f05 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -331,7 +331,6 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t { UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t); UINT32 alphalevel = 0; - boolean flip = false; fixed_t col, ofs, colfrac, rowfrac, fdup; INT32 dupx, dupy; @@ -415,10 +414,7 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t // left offset if (scrn & V_FLIP) - { - flip = true; offsetx = FixedMul((SHORT(patch->width) - SHORT(patch->leftoffset))<leftoffset)<>FRACBITS) < SHORT(patch->width); col += colfrac, ++offx, desttop++) { INT32 topdelta, prevdelta = -1; - if (flip) // offx is measured from right edge instead of left + if (scrn & V_FLIP) // offx is measured from right edge instead of left { if (x+pwidth-offx < 0) // don't draw off the left of the screen (WRAP PREVENTION) break; @@ -534,7 +530,7 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t prevdelta = topdelta; source = (const UINT8 *)(column) + 3; dest = desttop; - if (flip) + if (scrn & V_FLIP) dest = deststart + (destend - desttop); dest += FixedInt(FixedMul(topdelta< Date: Tue, 30 Oct 2018 19:40:59 +0100 Subject: [PATCH 58/68] Small hud library additions --- src/lua_hudlib.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 60cbbe501..893534960 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -560,6 +560,15 @@ static int libd_renderer(lua_State *L) return 1; } +// 30/10/18 Lat': Get cv_translucenthud's value for HUD rendering as a normal V_xxTRANS int +// Could as well be thrown in global vars for ease of access but I guess it makes sense for it to be a HUD fn +static int libd_getlocaltransflag(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, (10-cv_translucenthud.value)*V_10TRANS); // A bit weird that it's called "translucenthud" yet 10 is fully opaque :V + return 1; +} + static luaL_Reg lib_draw[] = { {"patchExists", libd_patchExists}, {"cachePatch", libd_cachePatch}, @@ -576,6 +585,7 @@ static luaL_Reg lib_draw[] = { {"dupx", libd_dupx}, {"dupy", libd_dupy}, {"renderer", libd_renderer}, + {"localTransFlag", libd_getlocaltransflag}, {NULL, NULL} }; @@ -599,6 +609,20 @@ static int lib_huddisable(lua_State *L) return 0; } +// 30/10/18: Lat': How come this wasn't here before? +static int lib_hudenabled(lua_State *L) +{ + enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options); + lua_settop(L, 2); + if (!gL || hud_enabled[option/8] & (1<<(option%8))) + lua_pushboolean(L, true); + else + lua_pushboolean(L, false); + + return 1; +} + + // add a HUD element for rendering static int lib_hudadd(lua_State *L) { @@ -623,6 +647,7 @@ static int lib_hudadd(lua_State *L) static luaL_Reg lib_hud[] = { {"enable", lib_hudenable}, {"disable", lib_huddisable}, + {"enabled", lib_hudenabled}, {"add", lib_hudadd}, {NULL, NULL} }; From 799d8d2749250218bd557d09c9727df3658f7a9f Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Tue, 30 Oct 2018 22:29:28 +0100 Subject: [PATCH 59/68] remove gL check --- src/lua_hudlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 893534960..2ba6c8a60 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -614,7 +614,7 @@ static int lib_hudenabled(lua_State *L) { enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options); lua_settop(L, 2); - if (!gL || hud_enabled[option/8] & (1<<(option%8))) + if (hud_enabled[option/8] & (1<<(option%8))) lua_pushboolean(L, true); else lua_pushboolean(L, false); From 68414585469fbb4e1c739253e9561b430dcaf0eb Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Tue, 30 Oct 2018 22:51:05 +0100 Subject: [PATCH 60/68] got rid of the settop as well --- src/lua_hudlib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 2ba6c8a60..bc9423bea 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -613,7 +613,6 @@ static int lib_huddisable(lua_State *L) static int lib_hudenabled(lua_State *L) { enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options); - lua_settop(L, 2); if (hud_enabled[option/8] & (1<<(option%8))) lua_pushboolean(L, true); else From e9ea1b47d5ec8f2d04452426341aa9c13e00ce2d Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 31 Oct 2018 19:26:29 +0000 Subject: [PATCH 61/68] Fix the game crashing if you put params with no "=" for some reason in some of the SOC blocks, just stop going through the lines if that happens --- src/dehacked.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 365241084..97e1965eb 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1035,7 +1035,10 @@ static void readlevelheader(MYFILE *f, INT32 num) // Get the part before the " = " tmp = strchr(s, '='); - *(tmp-1) = '\0'; + if (tmp) + *(tmp-1) = '\0'; + else + break; strupr(word); // Now get the part after @@ -1616,7 +1619,10 @@ static void readhuditem(MYFILE *f, INT32 num) // Get the part before the " = " tmp = strchr(s, '='); - *(tmp-1) = '\0'; + if (tmp) + *(tmp-1) = '\0'; + else + break; strupr(word); // Now get the part after @@ -2118,7 +2124,10 @@ static void reademblemdata(MYFILE *f, INT32 num) // Get the part before the " = " tmp = strchr(s, '='); - *(tmp-1) = '\0'; + if (tmp) + *(tmp-1) = '\0'; + else + break; strupr(word); // Now get the part after @@ -2258,7 +2267,10 @@ static void readextraemblemdata(MYFILE *f, INT32 num) // Get the part before the " = " tmp = strchr(s, '='); - *(tmp-1) = '\0'; + if (tmp) + *(tmp-1) = '\0'; + else + break; strupr(word); // Now get the part after @@ -2342,7 +2354,10 @@ static void readunlockable(MYFILE *f, INT32 num) // Get the part before the " = " tmp = strchr(s, '='); - *(tmp-1) = '\0'; + if (tmp) + *(tmp-1) = '\0'; + else + break; strupr(word); // Now get the part after @@ -2629,7 +2644,10 @@ static void readconditionset(MYFILE *f, UINT8 setnum) // Get the part before the " = " tmp = strchr(s, '='); - *(tmp-1) = '\0'; + if (tmp) + *(tmp-1) = '\0'; + else + break; strupr(word); // Now get the part after @@ -2874,7 +2892,10 @@ static void readmaincfg(MYFILE *f) // Get the part before the " = " tmp = strchr(s, '='); - *(tmp-1) = '\0'; + if (tmp) + *(tmp-1) = '\0'; + else + break; strupr(word); // Now get the part after @@ -3113,7 +3134,10 @@ static void readwipes(MYFILE *f) // Get the part before the " = " tmp = strchr(s, '='); - *(tmp-1) = '\0'; + if (tmp) + *(tmp-1) = '\0'; + else + break; strupr(word); // Now get the part after From 5a0cfc10f44206bedf1c764c112ac84f21772b20 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 1 Nov 2018 14:47:19 -0400 Subject: [PATCH 62/68] Update copyright info on some files --- src/sdl/i_system.c | 3 +++ src/sdl/i_video.c | 2 ++ src/sdl/mixer_sound.c | 8 ++++++++ src/sdl12/mixer_sound.c | 8 ++++++++ 4 files changed, 21 insertions(+) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 7b14f1f18..0ec8a980e 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1,8 +1,11 @@ // Emacs style mode select -*- C++ -*- +// +// SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // // Copyright (C) 1993-1996 by id Software, Inc. // Portions Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 2014-2018 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 30ef1b27b..c0ec99883 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1,8 +1,10 @@ // Emacs style mode select -*- C++ -*- +// SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // // Copyright (C) 1993-1996 by id Software, Inc. // Portions Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 2014-2018 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 4d86d7a3c..bbd1fcee4 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1,3 +1,11 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2014-2018 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- /// \file /// \brief SDL Mixer interface for sound diff --git a/src/sdl12/mixer_sound.c b/src/sdl12/mixer_sound.c index daf09ab91..dcae19b05 100644 --- a/src/sdl12/mixer_sound.c +++ b/src/sdl12/mixer_sound.c @@ -1,3 +1,11 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2008-2018 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- /// \file /// \brief SDL Mixer interface for sound From 0f37411e2bda94bd496f6fbbe6edd1a1d43dbc32 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 2 Nov 2018 20:48:12 +0000 Subject: [PATCH 63/68] Make sure handles of files opened by W_LoadWadFile are closed if we abort loading the files for whatever reason. ESPECIALLY if the file is already loaded in SRB2, that's just silly. --- src/w_wad.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/w_wad.c b/src/w_wad.c index 3f0082a16..3789eab55 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -381,6 +381,8 @@ UINT16 W_LoadWadFile(const char *filename) if (fread(&header, 1, sizeof header, handle) < sizeof header) { CONS_Alert(CONS_ERROR, M_GetText("Can't read wad header from %s because %s\n"), filename, strerror(ferror(handle))); + if (handle) + fclose(handle); return INT16_MAX; } @@ -391,6 +393,8 @@ UINT16 W_LoadWadFile(const char *filename) && memcmp(header.identification, "SDLL", 4) != 0) { CONS_Alert(CONS_ERROR, M_GetText("%s does not have a valid WAD header\n"), filename); + if (handle) + fclose(handle); return INT16_MAX; } @@ -405,6 +409,8 @@ UINT16 W_LoadWadFile(const char *filename) { CONS_Alert(CONS_ERROR, M_GetText("Wadfile directory in %s is corrupted (%s)\n"), filename, strerror(ferror(handle))); free(fileinfov); + if (handle) + fclose(handle); return INT16_MAX; } @@ -462,6 +468,8 @@ UINT16 W_LoadWadFile(const char *filename) if (!memcmp(wadfiles[i]->md5sum, md5sum, 16)) { CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), filename); + if (handle) + fclose(handle); return INT16_MAX; } } From 1cc8619c9e155a06f39821473c84b25ff11b0fac Mon Sep 17 00:00:00 2001 From: MPC Date: Mon, 5 Nov 2018 20:40:51 -0200 Subject: [PATCH 64/68] Minor remote viewpoint bugfixes. --- src/p_mobj.c | 5 +++-- src/p_user.c | 18 +++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 2a29c32ad..e94c4ff89 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3506,14 +3506,15 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled if (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP) postimg = postimg_flip; - else if (player->awayviewtics) + else if (player->awayviewtics && player->awayviewmobj != NULL) // Camera must obviously exist { camera_t dummycam; dummycam.subsector = player->awayviewmobj->subsector; dummycam.x = player->awayviewmobj->x; dummycam.y = player->awayviewmobj->y; dummycam.z = player->awayviewmobj->z; - dummycam.height = 40*FRACUNIT; // alt view height is 20*FRACUNIT + //dummycam.height = 40*FRACUNIT; // alt view height is 20*FRACUNIT + dummycam.height = 0; // Why? Remote viewpoint cameras have no height. // Are we in water? if (P_CameraCheckWater(&dummycam)) postimg = postimg_water; diff --git a/src/p_user.c b/src/p_user.c index 7e206930d..34191cdf7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8365,16 +8365,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // Make player translucent if camera is too close (only in single player). if (!(multiplayer || netgame) && !splitscreen) { - fixed_t vx = 0, vy = 0; - if (player->awayviewtics) { + fixed_t vx = thiscam->x, vy = thiscam->y; + if (player->awayviewtics && player->awayviewmobj != NULL) // Camera must obviously exist + { vx = player->awayviewmobj->x; vy = player->awayviewmobj->y; } - else - { - vx = thiscam->x; - vy = thiscam->y; - } if (P_AproxDistance(vx - player->mo->x, vy - player->mo->y) < FixedMul(48*FRACUNIT, mo->scale)) player->mo->flags2 |= MF2_SHADOW; @@ -8710,8 +8706,9 @@ void P_PlayerThink(player_t *player) if (player->flashcount) player->flashcount--; - if (player->awayviewtics) - player->awayviewtics--; + // By the time P_MoveChaseCamera is called, this might be zero. Do not do it here. + //if (player->awayviewtics) + // player->awayviewtics--; /// \note do this in the cheat code if (player->pflags & PF_NOCLIP) @@ -9489,6 +9486,9 @@ void P_PlayerAfterThink(player_t *player) } } + if (player->awayviewtics) + player->awayviewtics--; + // spectator invisibility and nogravity. if ((netgame || multiplayer) && player->spectator) { From a3bc7ddfa0bca4d52b8de2a7151095ecc6968e04 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 6 Nov 2018 18:09:45 -0600 Subject: [PATCH 65/68] Add Lua Ultimate Mode global variable so people can use it. --- src/dehacked.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index 97e1965eb..212715dd3 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8217,6 +8217,9 @@ static inline int lib_getenum(lua_State *L) } else if (fastcmp(word,"maptol")) { lua_pushinteger(L, maptol); return 1; + } else if (fastcmp(word,"ultimatemode")) { + lua_pushboolean(L, ultimatemode != 0); + return 1; } else if (fastcmp(word,"mariomode")) { lua_pushboolean(L, mariomode != 0); return 1; From 82c738ea4b7ee4b1c03de261d26387107da9dd3c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 8 Nov 2018 21:13:58 +0000 Subject: [PATCH 66/68] Remove hasslope, per colette's warning about it potentially causing desyncs --- src/lua_maplib.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index b59c3c178..37dae5faa 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -46,7 +46,6 @@ enum sector_e { sector_ffloors, sector_fslope, sector_cslope, - sector_hasslope #else sector_ffloors #endif @@ -69,7 +68,6 @@ static const char *const sector_opt[] = { #ifdef ESLOPE "f_slope", "c_slope", - "hasslope", #endif NULL}; @@ -471,9 +469,6 @@ static int sector_get(lua_State *L) case sector_cslope: // c_slope LUA_PushUserdata(L, sector->c_slope, META_SLOPE); return 1; - case sector_hasslope: // hasslope - lua_pushboolean(L, sector->hasslope); - return 1; #endif } return 0; @@ -500,7 +495,6 @@ static int sector_set(lua_State *L) #ifdef ESLOPE case sector_fslope: // f_slope case sector_cslope: // c_slope - case sector_hasslope: // hasslope #endif default: return luaL_error(L, "sector_t field " LUA_QS " cannot be set.", sector_opt[field]); From 98fd9f8e426e40cc70d6248bf7c5a42bf13f25f1 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 8 Nov 2018 21:22:45 +0000 Subject: [PATCH 67/68] WHY DID I FORGET THIS --- src/lua_maplib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 37dae5faa..1886d7d1a 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -45,7 +45,7 @@ enum sector_e { #ifdef ESLOPE sector_ffloors, sector_fslope, - sector_cslope, + sector_cslope #else sector_ffloors #endif From e937d1bacb1fd157244bfe2f203db0216b65a0e1 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Fri, 9 Nov 2018 16:01:29 -0500 Subject: [PATCH 68/68] Update readme --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index d16071454..7d92ab303 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,6 @@ - libupnp (Linux/OS X only) - libgme (Linux/OS X only) -Warning: 64-bit builds are not netgame compatible with 32-bit builds. Use at your own risk. - ## Compiling See [SRB2 Wiki/Source code compiling](http://wiki.srb2.org/wiki/Source_code_compiling)