From b0cbc8ab2a59cd863c5c59f7593215fc1cd316a0 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Wed, 2 Mar 2016 23:47:06 -0600 Subject: [PATCH 001/573] 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 002/573] 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 003/573] 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 004/573] "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 005/573] "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 006/573] "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 007/573] 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 008/573] 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 009/573] 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 010/573] 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 011/573] 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 012/573] 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 013/573] 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 014/573] 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 a7dc20e7d2d53dad20f41884f382bfedf8f1d44e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 29 Aug 2016 22:42:06 +0100 Subject: [PATCH 015/573] Upper Unpegged on an FOF's control linedef now enables skewing of walls with respect to slopes Skewing direction is decided per in-level wall by the Lower Unpegged flag on in-level linedefs themselves, since they already decide the stuff for FOF wall pegging as it is. That is unless Transfer Line is involved which moves everything to the control sector linedefs instead... --- src/r_segs.c | 73 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 9 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 502ff3304..fff98dbf2 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -743,6 +743,12 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) // Render FOF sides kinda like normal sides, with the frac and step and everything // NOTE: INT64 instead of fixed_t because overflow concerns INT64 top_frac, top_step, bottom_frac, bottom_step; + // skew FOF walls with slopes? + boolean slopeskew = false; + fixed_t ffloortextureslide = 0; + INT32 oldx = -1; + fixed_t left_top, left_bottom; // needed here for slope skewing + pslope_t *skewslope = NULL; #endif void (*colfunc_2s) (column_t *); @@ -966,21 +972,68 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) mceilingclip = ds->sprtopclip; dc_texheight = textureheight[texnum]>>FRACBITS; +#ifdef ESLOPE + // calculate both left ends + if (*pfloor->t_slope) + left_top = P_GetZAt(*pfloor->t_slope, ds->leftpos.x, ds->leftpos.y) - viewz; + else + left_top = *pfloor->topheight - viewz; + + if (*pfloor->b_slope) + left_bottom = P_GetZAt(*pfloor->b_slope, ds->leftpos.x, ds->leftpos.y) - viewz; + else + left_bottom = *pfloor->bottomheight - viewz; + dc_texturemid = left_top; + skewslope = *pfloor->t_slope; // skew using top slope by default +#else dc_texturemid = *pfloor->topheight - viewz; +#endif if (newline) { offsetvalue = sides[newline->sidenum[0]].rowoffset; if (newline->flags & ML_DONTPEGBOTTOM) +#ifdef ESLOPE + { + dc_texturemid = left_bottom; + skewslope = *pfloor->b_slope; // skew using bottom slope + } +#else offsetvalue -= *pfloor->topheight - *pfloor->bottomheight; +#endif +#ifdef ESLOPE + if (newline->flags & ML_DONTPEGTOP) + slopeskew = true; +#endif } else { offsetvalue = sides[pfloor->master->sidenum[0]].rowoffset; if (curline->linedef->flags & ML_DONTPEGBOTTOM) +#ifdef ESLOPE + { + dc_texturemid = left_bottom; + skewslope = *pfloor->b_slope; // skew using bottom slope + } +#else offsetvalue -= *pfloor->topheight - *pfloor->bottomheight; +#endif +#ifdef ESLOPE + if (pfloor->master->flags & ML_DONTPEGTOP) // use control linedef's flags + slopeskew = true; +#endif } +#ifdef ESLOPE + if (slopeskew) + { + angle_t lineangle = R_PointToAngle2(curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y); + + if (skewslope) + ffloortextureslide = FixedMul(skewslope->zdelta, FINECOSINE((lineangle-skewslope->xydirection)>>ANGLETOFINESHIFT)); + } +#endif + dc_texturemid += offsetvalue; // Texture must be cached before setting colfunc_2s, @@ -999,23 +1052,18 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) #ifdef ESLOPE // Set heights according to plane, or slope, whichever { - fixed_t left_top, right_top, left_bottom, right_bottom; + fixed_t right_top, right_bottom; + // calculate right ends now if (*pfloor->t_slope) - { - left_top = P_GetZAt(*pfloor->t_slope, ds->leftpos.x, ds->leftpos.y) - viewz; right_top = P_GetZAt(*pfloor->t_slope, ds->rightpos.x, ds->rightpos.y) - viewz; - } else - left_top = right_top = *pfloor->topheight - viewz; + right_top = *pfloor->topheight - viewz; if (*pfloor->b_slope) - { - left_bottom = P_GetZAt(*pfloor->b_slope, ds->leftpos.x, ds->leftpos.y) - viewz; right_bottom = P_GetZAt(*pfloor->b_slope, ds->rightpos.x, ds->rightpos.y) - viewz; - } else - left_bottom = right_bottom = *pfloor->bottomheight - viewz; + right_bottom = *pfloor->bottomheight - viewz; // using INT64 to avoid 32bit overflow top_frac = (INT64)centeryfrac - (((INT64)left_top * ds->scale1) >> FRACBITS); @@ -1039,6 +1087,13 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) { if (maskedtexturecol[dc_x] != INT16_MAX) { +#ifdef ESLOPE + if (ffloortextureslide) { // skew FOF walls + if (oldx != -1) + dc_texturemid += FixedMul(ffloortextureslide, (maskedtexturecol[oldx]-maskedtexturecol[dc_x])< Date: Mon, 29 Aug 2016 23:21:57 +0100 Subject: [PATCH 016/573] If NOT skewing FOF walls, make sure dc_texturemid reverts to using unsloped FOF topheight/bottomheight rather than actual left side top/bottom heights --- src/r_segs.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index fff98dbf2..0d3a6430e 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -983,45 +983,45 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) left_bottom = P_GetZAt(*pfloor->b_slope, ds->leftpos.x, ds->leftpos.y) - viewz; else left_bottom = *pfloor->bottomheight - viewz; - dc_texturemid = left_top; skewslope = *pfloor->t_slope; // skew using top slope by default -#else - dc_texturemid = *pfloor->topheight - viewz; + if (newline && newline->flags & ML_DONTPEGTOP) + slopeskew = true; + else if (pfloor->master->flags & ML_DONTPEGTOP) + slopeskew = true; + + if (slopeskew) + dc_texturemid = left_top; + else #endif + dc_texturemid = *pfloor->topheight - viewz; if (newline) { offsetvalue = sides[newline->sidenum[0]].rowoffset; if (newline->flags & ML_DONTPEGBOTTOM) -#ifdef ESLOPE { - dc_texturemid = left_bottom; - skewslope = *pfloor->b_slope; // skew using bottom slope - } -#else - offsetvalue -= *pfloor->topheight - *pfloor->bottomheight; -#endif #ifdef ESLOPE - if (newline->flags & ML_DONTPEGTOP) - slopeskew = true; + skewslope = *pfloor->b_slope; // skew using bottom slope + if (slopeskew) + dc_texturemid = left_bottom; + else #endif + offsetvalue -= *pfloor->topheight - *pfloor->bottomheight; + } } else { offsetvalue = sides[pfloor->master->sidenum[0]].rowoffset; if (curline->linedef->flags & ML_DONTPEGBOTTOM) -#ifdef ESLOPE { - dc_texturemid = left_bottom; - skewslope = *pfloor->b_slope; // skew using bottom slope - } -#else - offsetvalue -= *pfloor->topheight - *pfloor->bottomheight; -#endif #ifdef ESLOPE - if (pfloor->master->flags & ML_DONTPEGTOP) // use control linedef's flags - slopeskew = true; + skewslope = *pfloor->b_slope; // skew using bottom slope + if (slopeskew) + dc_texturemid = left_bottom; + else #endif + offsetvalue -= *pfloor->topheight - *pfloor->bottomheight; + } } #ifdef ESLOPE From 40cb22a130be5dc06b22a280b44588430f5a8610 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 29 Aug 2016 23:24:59 +0100 Subject: [PATCH 017/573] probably best if we did this instead actually --- src/r_segs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 0d3a6430e..b997c2a88 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -984,8 +984,11 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else left_bottom = *pfloor->bottomheight - viewz; skewslope = *pfloor->t_slope; // skew using top slope by default - if (newline && newline->flags & ML_DONTPEGTOP) - slopeskew = true; + if (newline) + { + if (newline->flags & ML_DONTPEGTOP) + slopeskew = true; + } else if (pfloor->master->flags & ML_DONTPEGTOP) slopeskew = true; From 56d7f9ed389277bee8f8c6bf3590fa362e7cfd14 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 30 Mar 2018 14:22:59 -0400 Subject: [PATCH 018/573] Nights LE checkpoint --- src/p_map.c | 7 +++++-- src/p_spec.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/p_user.c | 4 ++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 6d1760596..8c58570c8 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -905,7 +905,7 @@ static boolean PIT_CheckThing(mobj_t *thing) P_SetTarget(&thing->target, tmthing); } - // Respawn rings and items + // NiGHTS lap logic if ((tmthing->type == MT_NIGHTSDRONE || thing->type == MT_NIGHTSDRONE) && (tmthing->player || thing->player)) { @@ -921,8 +921,11 @@ static boolean PIT_CheckThing(mobj_t *thing) ^ (droneobj->extravalue1 >= 90 && droneobj->extravalue1 <= 270) )) { - // Reload all the fancy ring stuff! + // Respawn rings and items P_ReloadRings(); + + // \todo store current lap in player mobj + P_RunNightsLapExecutors(pl->mo); } droneobj->extravalue1 = pl->anotherflyangle; droneobj->extravalue2 = (INT32)leveltime + TICRATE; diff --git a/src/p_spec.c b/src/p_spec.c index 0b005baff..b26fab821 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5487,6 +5487,48 @@ static void P_RunLevelLoadExecutors(void) } } +// +// P_RunNightserizeExecutors +// +static void P_RunNightserizeExecutors(mobj_t *actor) +{ + size_t i; + + for (i = 0; i < numlines; i++) + { + if (lines[i].special == 323 || lines[i].special == 324) + P_RunTriggerLinedef(&lines[i], actor, NULL); + } +} + +// +// P_RunDeNightserizeExecutors +// +static void P_RunDeNightserizeExecutors(mobj_t *actor) +{ + size_t i; + + for (i = 0; i < numlines; i++) + { + if (lines[i].special == 325 || lines[i].special == 326) + P_RunTriggerLinedef(&lines[i], actor, NULL); + } +} + +// +// P_RunNightsLapExecutors +// +static void P_RunNightsLapExecutors(mobj_t *actor) +{ + size_t i; + + for (i = 0; i < numlines; i++) + { + if (lines[i].special == 327 || lines[i].special == 328) + P_RunTriggerLinedef(&lines[i], actor, NULL); + } +} + /** Before things are loaded, initialises certain stuff in case they're needed * by P_ResetDynamicSlopes or P_LoadThings. This was split off from * P_SpawnSpecials, in case you couldn't tell. @@ -6408,6 +6450,12 @@ void P_SpawnSpecials(INT32 fromnetsave) } break; + // NiGHTS trigger executors + case 323: + case 324: + case 325: + break; + case 399: // Linedef execute on map load // This is handled in P_RunLevelLoadExecutors. break; diff --git a/src/p_user.c b/src/p_user.c index f422e9b65..f4be0cf59 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -636,6 +636,8 @@ static void P_DeNightserizePlayer(player_t *player) // Restore from drowning music P_RestoreMusic(player); + + P_RunDeNightserizeExecutors(); } // @@ -771,6 +773,8 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) } player->powers[pw_carry] = CR_NIGHTSMODE; + + P_RunNightserizeExecutors(player->mo); } pflags_t P_GetJumpFlags(player_t *player) From 637a4a844646754c412a9fc00419e02e78bbc280 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 30 Mar 2018 14:36:49 -0400 Subject: [PATCH 019/573] Add player_t marelap and marebonuslap, with logic --- src/d_player.h | 2 ++ src/lua_playerlib.c | 8 ++++++++ src/p_map.c | 17 ++++++++++++----- src/p_saveg.c | 4 ++++ src/p_setup.c | 1 + src/p_user.c | 2 ++ 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index e1350fe67..f919eddb0 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -455,6 +455,8 @@ typedef struct player_s boolean bonustime; // Capsule destroyed, now it's bonus time! mobj_t *capsule; // Go inside the capsule UINT8 mare; // Current mare + UINT8 marelap; // Current mare lap + UINT8 marebonuslap; // Current mare lap starting from bonus time // Statistical purposes. tic_t marebegunat; // Leveltime when mare begun diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 12b2646d0..9b5aa6fdc 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -288,6 +288,10 @@ static int player_get(lua_State *L) LUA_PushUserdata(L, plr->capsule, META_MOBJ); else if (fastcmp(field,"mare")) lua_pushinteger(L, plr->mare); + else if (fastcmp(field,"marelap")) + lua_pushinteger(L, plr->marelap); + else if (fastcmp(field,"marebonuslap")) + lua_pushinteger(L, plr->marebonuslap); else if (fastcmp(field,"marebegunat")) lua_pushinteger(L, plr->marebegunat); else if (fastcmp(field,"startedtime")) @@ -564,6 +568,10 @@ static int player_set(lua_State *L) } else if (fastcmp(field,"mare")) plr->mare = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"marelap")) + plr->marelap = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"marebonuslap")) + plr->marebonuslap = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"marebegunat")) plr->marebegunat = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"startedtime")) diff --git a/src/p_map.c b/src/p_map.c index 6d1760596..565680e22 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -905,24 +905,31 @@ static boolean PIT_CheckThing(mobj_t *thing) P_SetTarget(&thing->target, tmthing); } - // Respawn rings and items + // NiGHTS lap logic if ((tmthing->type == MT_NIGHTSDRONE || thing->type == MT_NIGHTSDRONE) && (tmthing->player || thing->player)) { mobj_t *droneobj = (tmthing->type == MT_NIGHTSDRONE) ? tmthing : thing; player_t *pl = (droneobj == thing) ? tmthing->player : thing->player; - // Must be in bonus time, and must be NiGHTS, must wait about a second + // Must be NiGHTS, must wait about a second // must be flying in the SAME DIRECTION as the last time you came through. // not (your direction) xor (stored direction) // In other words, you can't u-turn and respawn rings near the drone. - if (pl->bonustime && (pl->powers[pw_carry] == CR_NIGHTSMODE) && (INT32)leveltime > droneobj->extravalue2 && ( + if ((pl->powers[pw_carry] == CR_NIGHTSMODE) && (INT32)leveltime > droneobj->extravalue2 && ( !(pl->anotherflyangle >= 90 && pl->anotherflyangle <= 270) ^ (droneobj->extravalue1 >= 90 && droneobj->extravalue1 <= 270) )) { - // Reload all the fancy ring stuff! - P_ReloadRings(); + pl->marelap++; + + if (pl->bonustime) + { + pl->marebonuslap++; + + // Respawn rings and items + P_ReloadRings(); + } } droneobj->extravalue1 = pl->anotherflyangle; droneobj->extravalue2 = (INT32)leveltime + TICRATE; diff --git a/src/p_saveg.c b/src/p_saveg.c index 029df08f4..59d1775a8 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -197,6 +197,8 @@ static void P_NetArchivePlayers(void) WRITEUINT8(save_p, players[i].drilldelay); WRITEUINT8(save_p, players[i].bonustime); WRITEUINT8(save_p, players[i].mare); + WRITEUINT8(save_p, players[i].marelap); + WRITEUINT8(save_p, players[i].marebonuslap); WRITEUINT32(save_p, players[i].marebegunat); WRITEUINT32(save_p, players[i].startedtime); @@ -384,6 +386,8 @@ static void P_NetUnArchivePlayers(void) players[i].drilldelay = READUINT8(save_p); players[i].bonustime = (boolean)READUINT8(save_p); players[i].mare = READUINT8(save_p); + players[i].marelap = READUINT8(save_p); + players[i].marebonuslap = READUINT8(save_p); players[i].marebegunat = READUINT32(save_p); players[i].startedtime = READUINT32(save_p); diff --git a/src/p_setup.c b/src/p_setup.c index a9fc57652..f3e92abce 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2350,6 +2350,7 @@ static void P_LevelInitStuff(void) players[i].linkcount = players[i].linktimer = 0; players[i].flyangle = players[i].anotherflyangle = 0; players[i].nightstime = players[i].mare = 0; + players[i].marelap = 0; players[i].marebonuslap = 0; P_SetTarget(&players[i].capsule, NULL); players[i].drillmeter = 40*20; diff --git a/src/p_user.c b/src/p_user.c index f422e9b65..c8f364193 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -399,6 +399,8 @@ boolean P_TransferToNextMare(player_t *player) CONS_Debug(DBG_NIGHTS, "Mare is %d\n", mare); player->mare = mare; + player->marelap = 0; + player->marebonuslap = 0; // scan the thinkers // to find the closest axis point From 0fedd2e566553143d202fc1bbbece55fa6d85be9 Mon Sep 17 00:00:00 2001 From: Marco Z Date: Fri, 30 Mar 2018 15:27:37 -0400 Subject: [PATCH 020/573] Define fader thinker names --- src/p_saveg.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/p_spec.c | 33 +++++++++++++++++++++++++++++++++ src/p_spec.h | 16 ++++++++++++++++ 3 files changed, 98 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index 029df08f4..5542b3cda 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -988,6 +988,7 @@ typedef enum tc_noenemies, tc_eachtime, tc_disappear, + tc_fade, tc_planedisplace, #ifdef POLYOBJECTS tc_polyrotate, // haleyjd 03/26/06: polyobjects @@ -1552,6 +1553,25 @@ static void SaveDisappearThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->exists); } +// +// SaveFadeThinker +// +// Saves a fade_t thinker +// +static void SaveFadeThinker(const thinker_t *th, const UINT8 type) +{ + const fade_t *ht = (const void *)th; + // \todo fields + WRITEUINT8(save_p, type); + WRITEUINT32(save_p, ht->appeartime); + WRITEUINT32(save_p, ht->disappeartime); + WRITEUINT32(save_p, ht->offset); + WRITEUINT32(save_p, ht->timer); + WRITEINT32(save_p, ht->affectee); + WRITEINT32(save_p, ht->sourceline); + WRITEINT32(save_p, ht->exists); +} + // // SavePlaneDisplaceThinker // @@ -1854,6 +1874,11 @@ static void P_NetArchiveThinkers(void) SaveDisappearThinker(th, tc_disappear); continue; } + else if (th->function.acp1 == (actionf_p1)T_Fade) + { + SaveFadeThinker(th, tc_fade); + continue; + } else if (th->function.acp1 == (actionf_p1)T_PlaneDisplace) { @@ -2530,6 +2555,26 @@ static inline void LoadDisappearThinker(actionf_p1 thinker) P_AddThinker(&ht->thinker); } +// +// LoadFadeThinker +// +// Loads a fade_t thinker +// +static inline void LoadFadeThinker(actionf_p1 thinker) +{ + fade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); + ht->thinker.function.acp1 = thinker; + // \todo fields + ht->appeartime = READUINT32(save_p); + ht->disappeartime = READUINT32(save_p); + ht->offset = READUINT32(save_p); + ht->timer = READUINT32(save_p); + ht->affectee = READINT32(save_p); + ht->sourceline = READINT32(save_p); + ht->exists = READINT32(save_p); + P_AddThinker(&ht->thinker); +} + // // LoadPlaneDisplaceThinker // @@ -2833,6 +2878,10 @@ static void P_NetUnArchiveThinkers(void) LoadDisappearThinker((actionf_p1)T_Disappear); break; + case tc_fade: + LoadFadeThinker((actionf_p1)T_Fade); + break; + case tc_planedisplace: LoadPlaneDisplaceThinker((actionf_p1)T_PlaneDisplace); break; diff --git a/src/p_spec.c b/src/p_spec.c index 0b005baff..b1ede46d8 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7056,6 +7056,39 @@ void T_Disappear(disappear_t *d) } } +/** Adds master fader thinker. + * + * \param appeartime tics to be existent + * \param disappeartime tics to be nonexistent + * \param sector pointer to control sector + */ +static void P_AddMasterFader(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline) +{ + fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); + + // \todo fields + d->thinker.function.acp1 = (actionf_p1)T_Disappear; + d->appeartime = appeartime; + d->disappeartime = disappeartime; + d->offset = offset; + d->affectee = line; + d->sourceline = sourceline; + d->exists = true; + d->timer = 1; + + P_AddThinker(&d->thinker); +} + +/** Makes a FOF fade + * + * \param d Fade thinker. + * \sa P_AddMasterFader + */ +void T_Fade(fade_t *d) +{ + // \todo everything +} + /* SoM: 3/8/2000: Friction functions start. Add_Friction, diff --git a/src/p_spec.h b/src/p_spec.h index c4e05e072..3ed66f149 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -449,6 +449,22 @@ typedef struct void T_Disappear(disappear_t *d); +// Model for fading FOFs +typedef struct +{ + // \todo fields + thinker_t thinker; ///< Thinker structure for effect. + tic_t appeartime; ///< Tics to be appeared for + tic_t disappeartime;///< Tics to be disappeared for + tic_t offset; ///< Time to wait until thinker starts + tic_t timer; ///< Timer between states + INT32 affectee; ///< Number of affected line + INT32 sourceline; ///< Number of source line + INT32 exists; ///< Exists toggle +} fade_t; + +void T_Fade(fade_t *d); + // Prototype functions for pushers void T_Pusher(pusher_t *p); mobj_t *P_GetPushThing(UINT32 s); From 44b25be69af83a02bed7d8a90274a60f9ea111cf Mon Sep 17 00:00:00 2001 From: Marco Z Date: Fri, 30 Mar 2018 16:17:35 -0400 Subject: [PATCH 021/573] fade_t fields --- src/p_saveg.c | 20 ++++++-------------- src/p_spec.c | 19 ++++++++----------- src/p_spec.h | 10 +++------- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 5542b3cda..eb76fede5 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1561,15 +1561,11 @@ static void SaveDisappearThinker(const thinker_t *th, const UINT8 type) static void SaveFadeThinker(const thinker_t *th, const UINT8 type) { const fade_t *ht = (const void *)th; - // \todo fields WRITEUINT8(save_p, type); - WRITEUINT32(save_p, ht->appeartime); - WRITEUINT32(save_p, ht->disappeartime); - WRITEUINT32(save_p, ht->offset); - WRITEUINT32(save_p, ht->timer); WRITEINT32(save_p, ht->affectee); - WRITEINT32(save_p, ht->sourceline); - WRITEINT32(save_p, ht->exists); + WRITEINT32(save_p, ht->destvalue); + WRITEINT32(save_p, ht->speed); + WRITEUINT8(save_p, ht->ignoreflags); } // @@ -2564,14 +2560,10 @@ static inline void LoadFadeThinker(actionf_p1 thinker) { fade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; - // \todo fields - ht->appeartime = READUINT32(save_p); - ht->disappeartime = READUINT32(save_p); - ht->offset = READUINT32(save_p); - ht->timer = READUINT32(save_p); ht->affectee = READINT32(save_p); - ht->sourceline = READINT32(save_p); - ht->exists = READINT32(save_p); + ht->destvalue = READINT32(save_p); + ht->speed = READINT32(save_p); + ht->ignoreflags = READUINT8(save_p); P_AddThinker(&ht->thinker); } diff --git a/src/p_spec.c b/src/p_spec.c index b1ede46d8..43dba0dc3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7058,23 +7058,20 @@ void T_Disappear(disappear_t *d) /** Adds master fader thinker. * - * \param appeartime tics to be existent - * \param disappeartime tics to be nonexistent - * \param sector pointer to control sector + * \param destvalue transparency value to fade to + * \param speed speed to fade by + * \param ignoreexists do not handle FF_EXISTS + * \param line line to target FOF */ -static void P_AddMasterFader(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline) +static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL ignoreflags, INT32 line) { fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); - // \todo fields d->thinker.function.acp1 = (actionf_p1)T_Disappear; - d->appeartime = appeartime; - d->disappeartime = disappeartime; - d->offset = offset; d->affectee = line; - d->sourceline = sourceline; - d->exists = true; - d->timer = 1; + d->destvalue = destvalue; + d->speed = speed; + d->ignoreflags = (UINT8)ignoreflags; P_AddThinker(&d->thinker); } diff --git a/src/p_spec.h b/src/p_spec.h index 3ed66f149..355f0c111 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -452,15 +452,11 @@ void T_Disappear(disappear_t *d); // Model for fading FOFs typedef struct { - // \todo fields thinker_t thinker; ///< Thinker structure for effect. - tic_t appeartime; ///< Tics to be appeared for - tic_t disappeartime;///< Tics to be disappeared for - tic_t offset; ///< Time to wait until thinker starts - tic_t timer; ///< Timer between states INT32 affectee; ///< Number of affected line - INT32 sourceline; ///< Number of source line - INT32 exists; ///< Exists toggle + INT32 destvalue; ///< Transparency value to fade to + INT32 speed; ///< Speed to fade by + UINT8 ignoreflags; ///< Do not handle FF_EXISTS } fade_t; void T_Fade(fade_t *d); From e617753d0011a16b9e79eaa29427e214cd4654c3 Mon Sep 17 00:00:00 2001 From: Marco Z Date: Fri, 30 Mar 2018 16:17:35 -0400 Subject: [PATCH 022/573] Initial logic attempt * Front X offset: ffloor alpha target (1-256) * Front Y offset: Speed, alpha per tic (1+) * MF_BLOCKMONSTERS: Do not handle FF_EXISTS --- src/p_spec.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 4 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 43dba0dc3..2c0418847 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -102,6 +102,7 @@ static void P_SpawnFriction(void); static void P_SpawnPushers(void); static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t *source, INT32 affectee, INT32 referrer, INT32 exclusive, INT32 slider); //SoM: 3/9/2000 static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); +static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL ignoreflags, INT32 line); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3092,6 +3093,20 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; } + case 452: // Fade FOF + { + //CONS_Printf("Hello! Found a Fade special!\n"); + INT32 s, j; + for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;) + for (j = 0; (unsigned)j < sectors[s].linecount; j++) + if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) + P_AddMasterFader(sides[line->sidenum[0]].textureoffset>>FRACBITS, sides[line->sidenum[0]].rowoffset>>FRACBITS, (line->flags & ML_BLOCKMONSTERS), (INT32)(sectors[s].lines[j]-lines)); + break; + } + + case 453: // Stop fading FOF + break; + #ifdef POLYOBJECTS case 480: // Polyobj_DoorSlide case 481: // Polyobj_DoorSwing @@ -7067,13 +7082,17 @@ static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL ignoreflags, INT { fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); - d->thinker.function.acp1 = (actionf_p1)T_Disappear; + //CONS_Printf("Adding fader | Dest %i | Speed %i | Ignore %i\n", destvalue, speed, ignoreflags); + + d->thinker.function.acp1 = (actionf_p1)T_Fade; d->affectee = line; - d->destvalue = destvalue; - d->speed = speed; + d->destvalue = max(1, min(256, destvalue)); // ffloor->alpha is 1-256 + d->speed = max(1, speed); // minimum speed 1/tic d->ignoreflags = (UINT8)ignoreflags; P_AddThinker(&d->thinker); + + //CONS_Printf("Added fader | Dest %i | Speed %i | Ignore %i\n", d->destvalue, d->speed, d->ignoreflags); } /** Makes a FOF fade @@ -7083,7 +7102,69 @@ static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL ignoreflags, INT */ void T_Fade(fade_t *d) { - // \todo everything + ffloor_t *rover; + register INT32 s; + INT32 affectedffloors = 0; + + for (s = -1; (s = P_FindSectorFromLineTag(&lines[d->affectee], s)) >= 0 ;) + { + for (rover = sectors[s].ffloors; rover; rover = rover->next) + { + if (rover->master != &lines[d->affectee]) + continue; + + // fade out + //CONS_Printf("Fading from %i to %i\n", rover->alpha, d->destvalue); + if (rover->alpha > d->destvalue) + { + // we'll reach our destvalue + if (rover->alpha - d->speed <= d->destvalue + d->speed) + { + //CONS_Printf("Finished fading out\n"); + rover->alpha = d->destvalue; + if (!d->ignoreflags && rover->alpha <= 1) + rover->flags &= ~FF_EXISTS; + else + rover->flags |= FF_EXISTS; + } + else + { + //CONS_Printf("Fading out...\n"); + rover->alpha -= d->speed; + if (!d->ignoreflags) + rover->flags |= FF_EXISTS; + affectedffloors++; + } + } + else // fade in + { + // we'll reach our destvalue + if (rover->alpha + d->speed >= d->destvalue - d->speed) + { + //CONS_Printf("Finished fading in\n"); + rover->alpha = d->destvalue; + if (!d->ignoreflags) + rover->flags |= FF_EXISTS; + } + else + { + //CONS_Printf("Fading in...\n"); + rover->alpha += d->speed; + if (!d->ignoreflags) + rover->flags |= FF_EXISTS; + affectedffloors++; + } + } + } + } + + // no more ffloors to fade? remove myself + if (affectedffloors == 0) + { + //CONS_Printf("No more FOFs to fade!\n"); + // \todo how to erase the fade_t struct? + P_RemoveThinker(&d->thinker); + } } /* From d449aae76d75c0da97c422eefdc5030ab0d7cb28 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 30 Mar 2018 14:36:49 -0400 Subject: [PATCH 023/573] Add predefined behaviors for fading FOF flags * ML_BLOCKMONSTERS: Handle FF_EXISTS * ML_NOCLIMB: Handle FF_SOLID * ML_EFFECT1: Don't handle FF_TRANSLUCENT --- src/p_saveg.c | 4 +- src/p_spec.c | 118 ++++++++++++++++++++++++++++++++++++++++++-------- src/p_spec.h | 2 +- 3 files changed, 102 insertions(+), 22 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index eb76fede5..aa48afde1 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1565,7 +1565,7 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->affectee); WRITEINT32(save_p, ht->destvalue); WRITEINT32(save_p, ht->speed); - WRITEUINT8(save_p, ht->ignoreflags); + WRITEUINT8(save_p, ht->handleflags); } // @@ -2563,7 +2563,7 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->affectee = READINT32(save_p); ht->destvalue = READINT32(save_p); ht->speed = READINT32(save_p); - ht->ignoreflags = READUINT8(save_p); + ht->handleflags = READUINT8(save_p); P_AddThinker(&ht->thinker); } diff --git a/src/p_spec.c b/src/p_spec.c index 2c0418847..6b9b9499f 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -102,7 +102,7 @@ static void P_SpawnFriction(void); static void P_SpawnPushers(void); static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t *source, INT32 affectee, INT32 referrer, INT32 exclusive, INT32 slider); //SoM: 3/9/2000 static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); -static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL ignoreflags, INT32 line); +static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOOL handlesolid, BOOL handletrans, INT32 line); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3100,7 +3100,12 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;) for (j = 0; (unsigned)j < sectors[s].linecount; j++) if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) - P_AddMasterFader(sides[line->sidenum[0]].textureoffset>>FRACBITS, sides[line->sidenum[0]].rowoffset>>FRACBITS, (line->flags & ML_BLOCKMONSTERS), (INT32)(sectors[s].lines[j]-lines)); + P_AddMasterFader(sides[line->sidenum[0]].textureoffset>>FRACBITS, + sides[line->sidenum[0]].rowoffset>>FRACBITS, + (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS + (line->flags & ML_NOCLIMB), // handle FF_SOLID + !(line->flags & ML_EFFECT1), // do not handle FF_TRANSLUCENT + (INT32)(sectors[s].lines[j]-lines)); break; } @@ -7075,24 +7080,37 @@ void T_Disappear(disappear_t *d) * * \param destvalue transparency value to fade to * \param speed speed to fade by - * \param ignoreexists do not handle FF_EXISTS + * \param handleexist handle FF_EXISTS + * \param handlesolid handle FF_SOLID + * \param handletrans do not handle FF_TRANSLUCENT * \param line line to target FOF */ -static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL ignoreflags, INT32 line) +static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOOL handlesolid, BOOL handletrans, INT32 line) { fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); - //CONS_Printf("Adding fader | Dest %i | Speed %i | Ignore %i\n", destvalue, speed, ignoreflags); + //CONS_Printf("Adding fader | Dest %i | Speed %i | Ignore %i\n", destvalue, speed, handleflags); d->thinker.function.acp1 = (actionf_p1)T_Fade; d->affectee = line; d->destvalue = max(1, min(256, destvalue)); // ffloor->alpha is 1-256 d->speed = max(1, speed); // minimum speed 1/tic - d->ignoreflags = (UINT8)ignoreflags; + + // combine the flags-to-handle, this is more convenient than separate BOOLS + d->handleflags = 0; + + if (handleexist) + d->handleflags |= FF_EXISTS; + + if (handlesolid) + d->handleflags |= FF_SOLID; + + if (handletrans) + d->handleflags |= FF_TRANSLUCENT; P_AddThinker(&d->thinker); - //CONS_Printf("Added fader | Dest %i | Speed %i | Ignore %i\n", d->destvalue, d->speed, d->ignoreflags); + //CONS_Printf("Added fader | Dest %i | Speed %i | Ignore %i\n", d->destvalue, d->speed, d->handleflags); } /** Makes a FOF fade @@ -7120,19 +7138,49 @@ void T_Fade(fade_t *d) // we'll reach our destvalue if (rover->alpha - d->speed <= d->destvalue + d->speed) { - //CONS_Printf("Finished fading out\n"); - rover->alpha = d->destvalue; - if (!d->ignoreflags && rover->alpha <= 1) - rover->flags &= ~FF_EXISTS; - else - rover->flags |= FF_EXISTS; + if (rover->alpha != d->destvalue) + { + //CONS_Printf("Finished fading out\n"); + rover->alpha = d->destvalue; + + if (d->handleflags & FF_EXISTS) + { + if (rover->alpha <= 1) + rover->flags &= ~FF_EXISTS; + else + rover->flags |= FF_EXISTS; + } + + if ((d->handleflags & FF_SOLID) + && !(rover->flags & FF_SWIMMABLE) + && !(rover->flags & FF_QUICKSAND)) + rover->flags &= ~FF_SOLID; // make intangible at end of fade-out + + if (d->handleflags & FF_TRANSLUCENT) + { + if (rover->alpha >= 256) + rover->flags &= ~FF_TRANSLUCENT; + else + rover->flags |= FF_TRANSLUCENT; + } + } } else { //CONS_Printf("Fading out...\n"); rover->alpha -= d->speed; - if (!d->ignoreflags) + + if (d->handleflags & FF_EXISTS) rover->flags |= FF_EXISTS; + + if ((d->handleflags & FF_SOLID) + && !(rover->flags & FF_SWIMMABLE) + && !(rover->flags & FF_QUICKSAND)) + rover->flags |= FF_SOLID; // keep solid during fade + + if (d->handleflags & FF_TRANSLUCENT) + rover->flags |= FF_TRANSLUCENT; // assume we're not completely opaque + affectedffloors++; } } @@ -7141,17 +7189,49 @@ void T_Fade(fade_t *d) // we'll reach our destvalue if (rover->alpha + d->speed >= d->destvalue - d->speed) { - //CONS_Printf("Finished fading in\n"); - rover->alpha = d->destvalue; - if (!d->ignoreflags) - rover->flags |= FF_EXISTS; + if (rover->alpha != d->destvalue) + { + //CONS_Printf("Finished fading in\n"); + rover->alpha = d->destvalue; + + if (d->handleflags & FF_EXISTS) + { + if (rover->alpha <= 1) + rover->flags &= ~FF_EXISTS; + else + rover->flags |= FF_EXISTS; + } + + if ((d->handleflags & FF_SOLID) + && !(rover->flags & FF_SWIMMABLE) + && !(rover->flags & FF_QUICKSAND)) + rover->flags |= FF_SOLID; // make solid at end of fade-in + + if (d->handleflags & FF_TRANSLUCENT) + { + if (rover->alpha >= 256) + rover->flags &= ~FF_TRANSLUCENT; + else + rover->flags |= FF_TRANSLUCENT; + } + } } else { //CONS_Printf("Fading in...\n"); rover->alpha += d->speed; - if (!d->ignoreflags) + + if (d->handleflags & FF_EXISTS) rover->flags |= FF_EXISTS; + + if ((d->handleflags & FF_SOLID) + && !(rover->flags & FF_SWIMMABLE) + && !(rover->flags & FF_QUICKSAND)) + rover->flags |= FF_SOLID; // keep solid during fade + + if (d->handleflags & FF_TRANSLUCENT) + rover->flags |= FF_TRANSLUCENT; // assume we're not completely opaque + affectedffloors++; } } diff --git a/src/p_spec.h b/src/p_spec.h index 355f0c111..9c0b3c2c5 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -456,7 +456,7 @@ typedef struct INT32 affectee; ///< Number of affected line INT32 destvalue; ///< Transparency value to fade to INT32 speed; ///< Speed to fade by - UINT8 ignoreflags; ///< Do not handle FF_EXISTS + UINT8 handleflags; ///< Do not handle FF_EXISTS } fade_t; void T_Fade(fade_t *d); From 73c7df6f5b6a719ea36ab9b06e5735fd6fc3f892 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 30 Mar 2018 22:56:43 -0400 Subject: [PATCH 024/573] Maybe let's not handle FF_TRANSLUCENT for fade FOF. Why: FF_TRANSLUCENT is often packaged with flags FF_EXTRA, FF_CUTEXTRA; for intangibles, FF_CUTSPIRTES; in some cases (?), FF_CUTLEVEL. I *think* the rules are consistent amongst predefined FOFs, but maybe there are exceptions? There's too much that can go wrong with assuming too many flags for an FOF. Just make it the modder's responsibility to tag this special to the proper translucent FOF. --- src/p_spec.c | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 6b9b9499f..249d50f7d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -102,7 +102,7 @@ static void P_SpawnFriction(void); static void P_SpawnPushers(void); static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t *source, INT32 affectee, INT32 referrer, INT32 exclusive, INT32 slider); //SoM: 3/9/2000 static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); -static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOOL handlesolid, BOOL handletrans, INT32 line); +static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOOL handlesolid, INT32 line); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3104,7 +3104,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) sides[line->sidenum[0]].rowoffset>>FRACBITS, (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS (line->flags & ML_NOCLIMB), // handle FF_SOLID - !(line->flags & ML_EFFECT1), // do not handle FF_TRANSLUCENT (INT32)(sectors[s].lines[j]-lines)); break; } @@ -7082,10 +7081,9 @@ void T_Disappear(disappear_t *d) * \param speed speed to fade by * \param handleexist handle FF_EXISTS * \param handlesolid handle FF_SOLID - * \param handletrans do not handle FF_TRANSLUCENT * \param line line to target FOF */ -static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOOL handlesolid, BOOL handletrans, INT32 line) +static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOOL handlesolid, INT32 line) { fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); @@ -7105,9 +7103,6 @@ static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOO if (handlesolid) d->handleflags |= FF_SOLID; - if (handletrans) - d->handleflags |= FF_TRANSLUCENT; - P_AddThinker(&d->thinker); //CONS_Printf("Added fader | Dest %i | Speed %i | Ignore %i\n", d->destvalue, d->speed, d->handleflags); @@ -7155,14 +7150,6 @@ void T_Fade(fade_t *d) && !(rover->flags & FF_SWIMMABLE) && !(rover->flags & FF_QUICKSAND)) rover->flags &= ~FF_SOLID; // make intangible at end of fade-out - - if (d->handleflags & FF_TRANSLUCENT) - { - if (rover->alpha >= 256) - rover->flags &= ~FF_TRANSLUCENT; - else - rover->flags |= FF_TRANSLUCENT; - } } } else @@ -7178,9 +7165,6 @@ void T_Fade(fade_t *d) && !(rover->flags & FF_QUICKSAND)) rover->flags |= FF_SOLID; // keep solid during fade - if (d->handleflags & FF_TRANSLUCENT) - rover->flags |= FF_TRANSLUCENT; // assume we're not completely opaque - affectedffloors++; } } @@ -7206,14 +7190,6 @@ void T_Fade(fade_t *d) && !(rover->flags & FF_SWIMMABLE) && !(rover->flags & FF_QUICKSAND)) rover->flags |= FF_SOLID; // make solid at end of fade-in - - if (d->handleflags & FF_TRANSLUCENT) - { - if (rover->alpha >= 256) - rover->flags &= ~FF_TRANSLUCENT; - else - rover->flags |= FF_TRANSLUCENT; - } } } else @@ -7229,9 +7205,6 @@ void T_Fade(fade_t *d) && !(rover->flags & FF_QUICKSAND)) rover->flags |= FF_SOLID; // keep solid during fade - if (d->handleflags & FF_TRANSLUCENT) - rover->flags |= FF_TRANSLUCENT; // assume we're not completely opaque - affectedffloors++; } } From 047fffb6da5d4dfb0d0caeab5cfc08eab09959e7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 30 Mar 2018 22:59:33 -0400 Subject: [PATCH 025/573] Remove log comments for Fade FOF --- src/p_spec.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 2c0418847..a5c040892 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3095,7 +3095,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 452: // Fade FOF { - //CONS_Printf("Hello! Found a Fade special!\n"); INT32 s, j; for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;) for (j = 0; (unsigned)j < sectors[s].linecount; j++) @@ -7082,8 +7081,6 @@ static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL ignoreflags, INT { fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); - //CONS_Printf("Adding fader | Dest %i | Speed %i | Ignore %i\n", destvalue, speed, ignoreflags); - d->thinker.function.acp1 = (actionf_p1)T_Fade; d->affectee = line; d->destvalue = max(1, min(256, destvalue)); // ffloor->alpha is 1-256 @@ -7091,8 +7088,6 @@ static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL ignoreflags, INT d->ignoreflags = (UINT8)ignoreflags; P_AddThinker(&d->thinker); - - //CONS_Printf("Added fader | Dest %i | Speed %i | Ignore %i\n", d->destvalue, d->speed, d->ignoreflags); } /** Makes a FOF fade @@ -7114,22 +7109,19 @@ void T_Fade(fade_t *d) continue; // fade out - //CONS_Printf("Fading from %i to %i\n", rover->alpha, d->destvalue); if (rover->alpha > d->destvalue) { // we'll reach our destvalue if (rover->alpha - d->speed <= d->destvalue + d->speed) { - //CONS_Printf("Finished fading out\n"); rover->alpha = d->destvalue; if (!d->ignoreflags && rover->alpha <= 1) rover->flags &= ~FF_EXISTS; else rover->flags |= FF_EXISTS; } - else + else // continue fading out { - //CONS_Printf("Fading out...\n"); rover->alpha -= d->speed; if (!d->ignoreflags) rover->flags |= FF_EXISTS; @@ -7141,14 +7133,12 @@ void T_Fade(fade_t *d) // we'll reach our destvalue if (rover->alpha + d->speed >= d->destvalue - d->speed) { - //CONS_Printf("Finished fading in\n"); rover->alpha = d->destvalue; if (!d->ignoreflags) rover->flags |= FF_EXISTS; } - else + else // continue fading in { - //CONS_Printf("Fading in...\n"); rover->alpha += d->speed; if (!d->ignoreflags) rover->flags |= FF_EXISTS; @@ -7161,7 +7151,6 @@ void T_Fade(fade_t *d) // no more ffloors to fade? remove myself if (affectedffloors == 0) { - //CONS_Printf("No more FOFs to fade!\n"); // \todo how to erase the fade_t struct? P_RemoveThinker(&d->thinker); } From bf0f24b16e88f9c63a12099640d10038fda1e10b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 30 Mar 2018 23:29:41 -0400 Subject: [PATCH 026/573] Bring back FF_TRANSLUCENT processing for fade FOF The rules for accompanying flags are: * If FF_TRANSLUCENT, deflag FF_CUTLEVEL and flag FF_EXTRA | FF_CUTEXTRA. * If not FF_TRANSLUCENT, flag FF_CUTLEVEL and deflag FF_EXTRA | FF_CUTEXTRA * If FF_SOLID, deflag FF_CUTSPRITES * If not FF_SOLID, flag FF_CUTSPRITES This reverts commit 73c7df6f5b6a719ea36ab9b06e5735fd6fc3f892. --- src/p_spec.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 02233cf92..412ac6185 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -102,7 +102,7 @@ static void P_SpawnFriction(void); static void P_SpawnPushers(void); static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t *source, INT32 affectee, INT32 referrer, INT32 exclusive, INT32 slider); //SoM: 3/9/2000 static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); -static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOOL handlesolid, INT32 line); +static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOOL handlesolid, BOOL handletrans, INT32 line); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3103,6 +3103,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) sides[line->sidenum[0]].rowoffset>>FRACBITS, (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS (line->flags & ML_NOCLIMB), // handle FF_SOLID + !(line->flags & ML_EFFECT1), // do not handle FF_TRANSLUCENT (INT32)(sectors[s].lines[j]-lines)); break; } @@ -7080,9 +7081,10 @@ void T_Disappear(disappear_t *d) * \param speed speed to fade by * \param handleexist handle FF_EXISTS * \param handlesolid handle FF_SOLID + * \param handletrans do not handle FF_TRANSLUCENT * \param line line to target FOF */ -static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOOL handlesolid, INT32 line) +static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOOL handlesolid, BOOL handletrans, INT32 line) { fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); @@ -7100,6 +7102,9 @@ static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOO if (handlesolid) d->handleflags |= FF_SOLID; + if (handletrans) + d->handleflags |= FF_TRANSLUCENT; + P_AddThinker(&d->thinker); } @@ -7143,6 +7148,25 @@ void T_Fade(fade_t *d) && !(rover->flags & FF_SWIMMABLE) && !(rover->flags & FF_QUICKSAND)) rover->flags &= ~FF_SOLID; // make intangible at end of fade-out + + if (d->handleflags & FF_TRANSLUCENT) + { + if (rover->alpha >= 256) + { + rover->flags |= FF_CUTLEVEL; + rover->flags &= ~(FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA); + } + else + { + rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; + rover->flags &= ~FF_CUTLEVEL; + } + + if (rover->flags & FF_SOLID) + rover->flags &= ~FF_CUTSPRITES; + else + rover->flags |= FF_CUTSPRITES; + } } } else // continue fading out @@ -7157,6 +7181,17 @@ void T_Fade(fade_t *d) && !(rover->flags & FF_QUICKSAND)) rover->flags |= FF_SOLID; // keep solid during fade + if (d->handleflags & FF_TRANSLUCENT) + { + rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; + rover->flags &= ~FF_CUTLEVEL; + + if (rover->flags & FF_SOLID) + rover->flags &= ~FF_CUTSPRITES; + else + rover->flags |= FF_CUTSPRITES; + } + affectedffloors++; } } @@ -7181,6 +7216,25 @@ void T_Fade(fade_t *d) && !(rover->flags & FF_SWIMMABLE) && !(rover->flags & FF_QUICKSAND)) rover->flags |= FF_SOLID; // make solid at end of fade-in + + if (d->handleflags & FF_TRANSLUCENT) + { + if (rover->alpha >= 256) + { + rover->flags |= FF_CUTLEVEL; + rover->flags &= ~(FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA); + } + else + { + rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; + rover->flags &= ~FF_CUTLEVEL; + } + + if (rover->flags & FF_SOLID) + rover->flags &= ~FF_CUTSPRITES; + else + rover->flags |= FF_CUTSPRITES; + } } } else // continue fading in @@ -7195,6 +7249,17 @@ void T_Fade(fade_t *d) && !(rover->flags & FF_QUICKSAND)) rover->flags |= FF_SOLID; // keep solid during fade + if (d->handleflags & FF_TRANSLUCENT) + { + rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; + rover->flags &= ~FF_CUTLEVEL; + + if (rover->flags & FF_SOLID) + rover->flags &= ~FF_CUTSPRITES; + else + rover->flags |= FF_CUTSPRITES; + } + affectedffloors++; } } From c13f561b5026ffec8b444d3b3c57896628d3beed Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 31 Mar 2018 00:02:37 -0400 Subject: [PATCH 027/573] Fix fade_t handleflags to UINT32 --- src/p_saveg.c | 4 ++-- src/p_spec.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index aa48afde1..d07644c53 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1565,7 +1565,7 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->affectee); WRITEINT32(save_p, ht->destvalue); WRITEINT32(save_p, ht->speed); - WRITEUINT8(save_p, ht->handleflags); + WRITEUINT32(save_p, ht->handleflags); } // @@ -2563,7 +2563,7 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->affectee = READINT32(save_p); ht->destvalue = READINT32(save_p); ht->speed = READINT32(save_p); - ht->handleflags = READUINT8(save_p); + ht->handleflags = READUINT32(save_p); P_AddThinker(&ht->thinker); } diff --git a/src/p_spec.h b/src/p_spec.h index 9c0b3c2c5..e59e2ea0f 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -456,7 +456,7 @@ typedef struct INT32 affectee; ///< Number of affected line INT32 destvalue; ///< Transparency value to fade to INT32 speed; ///< Speed to fade by - UINT8 handleflags; ///< Do not handle FF_EXISTS + UINT32 handleflags; ///< FOF flags to handle } fade_t; void T_Fade(fade_t *d); From c1c6b4746fea8f680a08ef5c1e395fe0913f59ee Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 31 Mar 2018 00:10:46 -0400 Subject: [PATCH 028/573] Better fading comments --- src/p_spec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 412ac6185..de11369f9 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7129,7 +7129,7 @@ void T_Fade(fade_t *d) // fade out if (rover->alpha > d->destvalue) { - // we'll reach our destvalue + // finish fading out if (rover->alpha - d->speed <= d->destvalue + d->speed) { if (rover->alpha != d->destvalue) @@ -7197,7 +7197,7 @@ void T_Fade(fade_t *d) } else // fade in { - // we'll reach our destvalue + // finish fading in if (rover->alpha + d->speed >= d->destvalue - d->speed) { if (rover->alpha != d->destvalue) From 3e8d264a2d4b14ad6ed43f379e2af2ddc7d3965b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 31 Mar 2018 00:40:41 -0400 Subject: [PATCH 029/573] Add fadingdata to sector_t --- src/p_saveg.c | 7 ++++++- src/p_setup.c | 1 + src/r_defs.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index d07644c53..b22b6495e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2564,6 +2564,11 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->destvalue = READINT32(save_p); ht->speed = READINT32(save_p); ht->handleflags = READUINT32(save_p); + + sector_t *ffloorsector = LoadSector(ht->affectee); + if (ffloorsector) + ffloorsector->fadingdata = ht; + P_AddThinker(&ht->thinker); } @@ -2753,7 +2758,7 @@ static void P_NetUnArchiveThinkers(void) // clear sector thinker pointers so they don't point to non-existant thinkers for all of eternity for (i = 0; i < numsectors; i++) { - sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = NULL; + sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = sectors[i].fadingdata = NULL; } // read in saved thinkers diff --git a/src/p_setup.c b/src/p_setup.c index a9fc57652..3edae5655 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -693,6 +693,7 @@ static void P_LoadRawSectors(UINT8 *data, size_t i) ss->floordata = NULL; ss->ceilingdata = NULL; ss->lightingdata = NULL; + ss->fadingdata = NULL; ss->linecount = 0; ss->lines = NULL; diff --git a/src/r_defs.h b/src/r_defs.h index 7c8f2a73f..b4c7d2112 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -308,6 +308,7 @@ typedef struct sector_s void *floordata; // floor move thinker void *ceilingdata; // ceiling move thinker void *lightingdata; // lighting change thinker + void *fadingdata; // fading FOF thinker // floor and ceiling texture offsets fixed_t floor_xoffs, floor_yoffs; From cd7573550b99d76fbdf03d21f717bf7f7583e9ad Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 31 Mar 2018 01:15:24 -0400 Subject: [PATCH 030/573] Remove fader thinkers by stored pointers in fadingdata --- src/p_spec.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index de11369f9..789ab6c43 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -102,6 +102,8 @@ static void P_SpawnFriction(void); static void P_SpawnPushers(void); static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t *source, INT32 affectee, INT32 referrer, INT32 exclusive, INT32 slider); //SoM: 3/9/2000 static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); +static void P_ResetFading(line_t *line, fade_t *data); +#define P_RemoveFading(l) P_ResetFading(l, NULL); static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOOL handlesolid, BOOL handletrans, INT32 line); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); @@ -3109,7 +3111,14 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } case 453: // Stop fading FOF + { + INT32 s, j; + for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;) + for (j = 0; (unsigned)j < sectors[s].linecount; j++) + if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) + P_RemoveFading(&lines[(INT32)(sectors[s].lines[j]-lines)]); break; + } #ifdef POLYOBJECTS case 480: // Polyobj_DoorSlide @@ -7075,6 +7084,35 @@ void T_Disappear(disappear_t *d) } } +/** Removes fadingdata from FOF control sector + * + * \param line line to search for target faders + * \param data pointer to set new fadingdata to. Can be NULL to erase. + */ +static void P_ResetFading(line_t *line, fade_t *data) +{ + ffloor_t *rover; + register INT32 s; + + // find any existing thinkers and remove them, then replace with new data + for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;) + { + for (rover = sectors[s].ffloors; rover; rover = rover->next) + { + if (rover->master != line) + continue; + + if(((fade_t *)rover->master->frontsector->fadingdata) != data) + { + if(&((fade_t *)rover->master->frontsector->fadingdata)->thinker) + P_RemoveThinker(&((fade_t *)rover->master->frontsector->fadingdata)->thinker); + + rover->master->frontsector->fadingdata = data; + } + } + } +} + /** Adds master fader thinker. * * \param destvalue transparency value to fade to @@ -7105,6 +7143,9 @@ static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOO if (handletrans) d->handleflags |= FF_TRANSLUCENT; + // find any existing thinkers and remove them, then replace with new data + P_ResetFading(&lines[d->affectee], d); + P_AddThinker(&d->thinker); } @@ -7268,10 +7309,7 @@ void T_Fade(fade_t *d) // no more ffloors to fade? remove myself if (affectedffloors == 0) - { - // \todo how to erase the fade_t struct? - P_RemoveThinker(&d->thinker); - } + P_RemoveFading(&lines[d->affectee]); } /* From 3d72c105df07f59929b8cac0bdba7b9f8c43c5e6 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 31 Mar 2018 10:11:27 -0400 Subject: [PATCH 031/573] Initial checkpoint for NiGHTS LE triggers --- src/p_spec.c | 147 ++++++++++++++++++++++++++++++++++++--------------- src/p_spec.h | 3 ++ src/p_user.c | 7 +-- 3 files changed, 112 insertions(+), 45 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index b26fab821..a23374c13 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1374,6 +1374,48 @@ void P_ChangeSectorTag(UINT32 sector, INT16 newtag) } } +// +// P_RunNightserizeExecutors +// +void P_RunNightserizeExecutors(mobj_t *actor) +{ + size_t i; + + for (i = 0; i < numlines; i++) + { + if (lines[i].special == 323 || lines[i].special == 324) + P_RunTriggerLinedef(&lines[i], actor, NULL); + } +} + +// +// P_RunDeNightserizeExecutors +// +void P_RunDeNightserizeExecutors(mobj_t *actor) +{ + size_t i; + + for (i = 0; i < numlines; i++) + { + if (lines[i].special == 325 || lines[i].special == 326) + P_RunTriggerLinedef(&lines[i], actor, NULL); + } +} + +// +// P_RunNightsLapExecutors +// +void P_RunNightsLapExecutors(mobj_t *actor) +{ + size_t i; + + for (i = 0; i < numlines; i++) + { + if (lines[i].special == 327 || lines[i].special == 328) + P_RunTriggerLinedef(&lines[i], actor, NULL); + } +} + /** Hashes the sector tags across the sectors and linedefs. * * \sa P_FindSectorFromTag, P_ChangeSectorTag @@ -1667,6 +1709,69 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller return false; } break; + case 323: // each time + case 324: // once + { // nightserize + INT32 mareinput = sides[triggerline->sidenum[0]].textureoffset>>FRACBITS; + INT32 lapinput = sides[triggerline->sidenum[0]].rowoffset>>FRACBITS; + BOOL ltemare = triggerline->flags & ML_NOCLIMB; + BOOL gtemare = triggerline->flags & ML_BLOCKMONSTERS; + BOOL ltelap = triggerline->flags & ML_EFFECT1; + BOOL gtelap = triggerline->flags & ML_EFFECT2; + BOOL lapfrombonustime = triggerline->flags & ML_EFFECT3; + BOOL doglobal = triggerline->flags & ML_EFFECT4; + BOOL donomares = triggerline->flags & ML_EFFECT5; // unused for nights lap + BOOL fromnonights = triggerline->flags & ML_BOUNCY; // unused for nights lap + + CONS_Printf("Trigger Nightserize %i\n", triggerline->special); + CONS_Printf("M-I %i | M-V %i | M-GTE %i | M-LTE %i | L-I %i | L-V %i/%i | L-GTE %i | L-LTE %i\n" + , mareinput, actor->player->mare, gtemare, ltemare + , lapinput, actor->player->marebonuslap, actor->player->marelap, gtelap, ltelap); + CONS_Printf("L-Bonus %i | Global %i | No Mares %i | From No NiGHTS %i\n", lapfrombonustime, doglobal, donomares, fromnonights); + } + break; + case 325: // each time + case 326: // once + { // denightserize + INT32 mareinput = sides[triggerline->sidenum[0]].textureoffset>>FRACBITS; + INT32 lapinput = sides[triggerline->sidenum[0]].rowoffset>>FRACBITS; + BOOL ltemare = triggerline->flags & ML_NOCLIMB; + BOOL gtemare = triggerline->flags & ML_BLOCKMONSTERS; + BOOL ltelap = triggerline->flags & ML_EFFECT1; + BOOL gtelap = triggerline->flags & ML_EFFECT2; + BOOL lapfrombonustime = triggerline->flags & ML_EFFECT3; + BOOL doglobal = triggerline->flags & ML_EFFECT4; + BOOL donomares = triggerline->flags & ML_EFFECT5; // all no nights // unused for nights lap + BOOL fromnonights = triggerline->flags & ML_BOUNCY; // unused for nights lap + + CONS_Printf("Trigger DeNightserize %i\n", triggerline->special); + CONS_Printf("M-I %i | M-V %i | M-GTE %i | M-LTE %i | L-I %i | L-V %i/%i | L-GTE %i | L-LTE %i\n" + , mareinput, actor->player->mare, gtemare, ltemare + , lapinput, actor->player->marebonuslap, actor->player->marelap, gtelap, ltelap); + CONS_Printf("L-Bonus %i | Global %i | No Mares %i | From No NiGHTS %i\n", lapfrombonustime, doglobal, donomares, fromnonights); + } + break; + case 327: // each time + case 328: // once + { // nights lap + INT32 mareinput = sides[triggerline->sidenum[0]].textureoffset>>FRACBITS; + INT32 lapinput = sides[triggerline->sidenum[0]].rowoffset>>FRACBITS; + BOOL ltemare = triggerline->flags & ML_NOCLIMB; + BOOL gtemare = triggerline->flags & ML_BLOCKMONSTERS; + BOOL ltelap = triggerline->flags & ML_EFFECT1; + BOOL gtelap = triggerline->flags & ML_EFFECT2; + BOOL lapfrombonustime = triggerline->flags & ML_EFFECT3; + BOOL doglobal = triggerline->flags & ML_EFFECT4; + BOOL donomares = triggerline->flags & ML_EFFECT5; // unused for nights lap + BOOL fromnonights = triggerline->flags & ML_BOUNCY; // unused for nights lap + + CONS_Printf("Trigger NiGHTS Lap %i\n", triggerline->special); + CONS_Printf("M-I %i | M-V %i | M-GTE %i | M-LTE %i | L-I %i | L-V %i/%i | L-GTE %i | L-LTE %i\n" + , mareinput, actor->player->mare, gtemare, ltemare + , lapinput, actor->player->marebonuslap, actor->player->marelap, gtelap, ltelap); + CONS_Printf("L-Bonus %i | Global %i | No Mares %i | From No NiGHTS %i\n", lapfrombonustime, doglobal, donomares, fromnonights); + } + break; default: break; } @@ -5487,48 +5592,6 @@ static void P_RunLevelLoadExecutors(void) } } -// -// P_RunNightserizeExecutors -// -static void P_RunNightserizeExecutors(mobj_t *actor) -{ - size_t i; - - for (i = 0; i < numlines; i++) - { - if (lines[i].special == 323 || lines[i].special == 324) - P_RunTriggerLinedef(&lines[i], actor, NULL); - } -} - -// -// P_RunDeNightserizeExecutors -// -static void P_RunDeNightserizeExecutors(mobj_t *actor) -{ - size_t i; - - for (i = 0; i < numlines; i++) - { - if (lines[i].special == 325 || lines[i].special == 326) - P_RunTriggerLinedef(&lines[i], actor, NULL); - } -} - -// -// P_RunNightsLapExecutors -// -static void P_RunNightsLapExecutors(mobj_t *actor) -{ - size_t i; - - for (i = 0; i < numlines; i++) - { - if (lines[i].special == 327 || lines[i].special == 328) - P_RunTriggerLinedef(&lines[i], actor, NULL); - } -} - /** Before things are loaded, initialises certain stuff in case they're needed * by P_ResetDynamicSlopes or P_LoadThings. This was split off from * P_SpawnSpecials, in case you couldn't tell. diff --git a/src/p_spec.h b/src/p_spec.h index c4e05e072..76ddc237c 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -66,6 +66,9 @@ void P_SwitchWeather(INT32 weathernum); boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller); void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller); void P_ChangeSectorTag(UINT32 sector, INT16 newtag); +void P_RunNightserizeExecutors(mobj_t *actor); +void P_RunDeNightserizeExecutors(mobj_t *actor); +void P_RunNightsLapExecutors(mobj_t *actor); ffloor_t *P_GetFFloorByID(sector_t *sec, UINT16 id); diff --git a/src/p_user.c b/src/p_user.c index 54411b25a..befd91f63 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -639,7 +639,7 @@ static void P_DeNightserizePlayer(player_t *player) // Restore from drowning music P_RestoreMusic(player); - P_RunDeNightserizeExecutors(); + P_RunDeNightserizeExecutors(player->mo); } // @@ -774,9 +774,10 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) player->texttimer = (UINT8)(110 - timeinmap); } - player->powers[pw_carry] = CR_NIGHTSMODE; - + // Do this before setting CR_NIGHTSMODE so we can tell if player was non-NiGHTS P_RunNightserizeExecutors(player->mo); + + player->powers[pw_carry] = CR_NIGHTSMODE; } pflags_t P_GetJumpFlags(player_t *player) From 9dc90f2df86da42e77be84cd08e8a1ee47dc89ee Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 1 Apr 2018 08:23:59 -0400 Subject: [PATCH 032/573] Implement logic branching for NiGHTS LE triggers and add Bonus Time trigger --- src/p_spec.c | 179 +++++++++++++++++++++++++++++++++++---------------- src/p_spec.h | 1 + src/p_user.c | 1 + 3 files changed, 127 insertions(+), 54 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index a23374c13..9c3f3df7d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1416,6 +1416,20 @@ void P_RunNightsLapExecutors(mobj_t *actor) } } +// +// P_RunNightsBonusTimeExecutors +// +void P_RunNightsBonusTimeExecutors(mobj_t *actor) +{ + size_t i; + + for (i = 0; i < numlines; i++) + { + if (lines[i].special == 329 || lines[i].special == 330) + P_RunTriggerLinedef(&lines[i], actor, NULL); + } +} + /** Hashes the sector tags across the sectors and linedefs. * * \sa P_FindSectorFromTag, P_ChangeSectorTag @@ -1709,69 +1723,117 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller return false; } break; - case 323: // each time - case 324: // once + + // Let's do the NiGHTS triggers in one code block; they mostly have the same logic + case 323: // nightserize - each time + case 324: // nightserize - once + case 325: // denightserize - each time + case 326: // denightserize - once + case 327: // nights lap - each time + case 328: // nights lap - once + case 329: // nights bonus time - each time + case 330: // nights bonus time - once { // nightserize - INT32 mareinput = sides[triggerline->sidenum[0]].textureoffset>>FRACBITS; - INT32 lapinput = sides[triggerline->sidenum[0]].rowoffset>>FRACBITS; + UINT8 inputmare = max(0, min(255, sides[triggerline->sidenum[0]].textureoffset>>FRACBITS)); + UINT8 inputlap = max(0, min(255, sides[triggerline->sidenum[0]].rowoffset>>FRACBITS)); + BOOL ltemare = triggerline->flags & ML_NOCLIMB; BOOL gtemare = triggerline->flags & ML_BLOCKMONSTERS; BOOL ltelap = triggerline->flags & ML_EFFECT1; BOOL gtelap = triggerline->flags & ML_EFFECT2; - BOOL lapfrombonustime = triggerline->flags & ML_EFFECT3; - BOOL doglobal = triggerline->flags & ML_EFFECT4; - BOOL donomares = triggerline->flags & ML_EFFECT5; // unused for nights lap - BOOL fromnonights = triggerline->flags & ML_BOUNCY; // unused for nights lap - CONS_Printf("Trigger Nightserize %i\n", triggerline->special); - CONS_Printf("M-I %i | M-V %i | M-GTE %i | M-LTE %i | L-I %i | L-V %i/%i | L-GTE %i | L-LTE %i\n" - , mareinput, actor->player->mare, gtemare, ltemare - , lapinput, actor->player->marebonuslap, actor->player->marelap, gtelap, ltelap); - CONS_Printf("L-Bonus %i | Global %i | No Mares %i | From No NiGHTS %i\n", lapfrombonustime, doglobal, donomares, fromnonights); + BOOL lapfrombonustime = triggerline->flags & ML_EFFECT3; + BOOL perglobalinverse = triggerline->flags & ML_DONTPEGBOTTOM; + BOOL perglobal = !(triggerline->flags & ML_EFFECT4) && !perglobalinverse; + + BOOL donomares = triggerline->flags & ML_BOUNCY; // nightserize: run at end of level (no mares) + BOOL fromnonights = triggerline->flags & ML_TFERLINE; // nightserize: from non-nights // denightserize: all players no nights + + UINT8 currentmare = UINT8_MAX; + UINT8 currentlap = UINT8_MAX; + + // Do early returns for Nightserize + if (specialtype >= 323 && specialtype <= 324) + { + // run only when no mares are found + if (donomares && P_FindLowestMare() != UINT8_MAX) + return false; + + // run only if player is nightserizing from non-nights + if (fromnonights) + { + if (!actor->player) + return false; + else if (actor->player->powers[pw_carry] == CR_NIGHTSMODE) + return false; + } + } + + // Get current mare and lap (and check early return for DeNightserize) + if (perglobal || perglobalinverse + || (specialtype >= 325 && specialtype <= 326 && fromnonights)) + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator) + continue; + + // denightserize: run only if all players are not nights + if (specialtype >= 325 && specialtype <= 326 && fromnonights + && players[i].powers[pw_carry] == CR_NIGHTSMODE) + return false; + + UINT8 lap = lapfrombonustime ? players[i].marebonuslap : players[i].marelap; + + // get highest mare/lap of players + if (perglobal) + { + if (players[i].mare > currentmare || currentmare == UINT8_MAX) + { + currentmare = players[i].mare; + currentlap = UINT8_MAX; + } + if (players[i].mare == currentmare + && (lap > currentlap || currentlap == UINT8_MAX)) + currentlap = lap; + } + // get lowest mare/lap of players + else if (perglobalinverse) + { + if (players[i].mare < currentmare || currentmare == UINT8_MAX) + { + currentmare = players[i].mare; + currentlap = UINT8_MAX; + } + if (players[i].mare == currentmare + && (lap < currentlap || currentlap == UINT8_MAX)) + currentlap = lap; + } + } + } + + // get current mare/lap from triggering player + if (!perglobal && !perglobalinverse) + { + if (!actor->player) + return false; + currentmare = actor->player->mare; + currentlap = lapfrombonustime ? actor->player->marebonuslap : actor->player->marelap; + } + + // Compare current mare/lap to input mare/lap based on rules + if (!(specialtype >= 323 && specialtype <= 324 && donomares) // don't return false if donomares and we got this far + && ((ltemare && currentmare > inputmare) + || (gtemare && currentmare < inputmare) + || (!ltemare && !gtemare && currentmare != inputmare) + || (ltelap && currentlap > inputlap) + || (gtelap && currentlap < inputlap) + || (!ltelap && !gtelap && currentlap != inputlap)) + ) + return false; } break; - case 325: // each time - case 326: // once - { // denightserize - INT32 mareinput = sides[triggerline->sidenum[0]].textureoffset>>FRACBITS; - INT32 lapinput = sides[triggerline->sidenum[0]].rowoffset>>FRACBITS; - BOOL ltemare = triggerline->flags & ML_NOCLIMB; - BOOL gtemare = triggerline->flags & ML_BLOCKMONSTERS; - BOOL ltelap = triggerline->flags & ML_EFFECT1; - BOOL gtelap = triggerline->flags & ML_EFFECT2; - BOOL lapfrombonustime = triggerline->flags & ML_EFFECT3; - BOOL doglobal = triggerline->flags & ML_EFFECT4; - BOOL donomares = triggerline->flags & ML_EFFECT5; // all no nights // unused for nights lap - BOOL fromnonights = triggerline->flags & ML_BOUNCY; // unused for nights lap - CONS_Printf("Trigger DeNightserize %i\n", triggerline->special); - CONS_Printf("M-I %i | M-V %i | M-GTE %i | M-LTE %i | L-I %i | L-V %i/%i | L-GTE %i | L-LTE %i\n" - , mareinput, actor->player->mare, gtemare, ltemare - , lapinput, actor->player->marebonuslap, actor->player->marelap, gtelap, ltelap); - CONS_Printf("L-Bonus %i | Global %i | No Mares %i | From No NiGHTS %i\n", lapfrombonustime, doglobal, donomares, fromnonights); - } - break; - case 327: // each time - case 328: // once - { // nights lap - INT32 mareinput = sides[triggerline->sidenum[0]].textureoffset>>FRACBITS; - INT32 lapinput = sides[triggerline->sidenum[0]].rowoffset>>FRACBITS; - BOOL ltemare = triggerline->flags & ML_NOCLIMB; - BOOL gtemare = triggerline->flags & ML_BLOCKMONSTERS; - BOOL ltelap = triggerline->flags & ML_EFFECT1; - BOOL gtelap = triggerline->flags & ML_EFFECT2; - BOOL lapfrombonustime = triggerline->flags & ML_EFFECT3; - BOOL doglobal = triggerline->flags & ML_EFFECT4; - BOOL donomares = triggerline->flags & ML_EFFECT5; // unused for nights lap - BOOL fromnonights = triggerline->flags & ML_BOUNCY; // unused for nights lap - - CONS_Printf("Trigger NiGHTS Lap %i\n", triggerline->special); - CONS_Printf("M-I %i | M-V %i | M-GTE %i | M-LTE %i | L-I %i | L-V %i/%i | L-GTE %i | L-LTE %i\n" - , mareinput, actor->player->mare, gtemare, ltemare - , lapinput, actor->player->marebonuslap, actor->player->marelap, gtelap, ltelap); - CONS_Printf("L-Bonus %i | Global %i | No Mares %i | From No NiGHTS %i\n", lapfrombonustime, doglobal, donomares, fromnonights); - } - break; default: break; } @@ -1900,6 +1962,10 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller || specialtype == 318 // Unlockable trigger - Once || specialtype == 320 // Unlockable - Once || specialtype == 321 || specialtype == 322 // Trigger on X calls - Continuous + Each Time + || specialtype == 324 // Nightserize - Once + || specialtype == 326 // DeNightserize - Once + || specialtype == 328 // Nights lap - Once + || specialtype == 330 // Nights Bonus Time - Once || specialtype == 399) // Level Load triggerline->special = 0; // Clear it out @@ -6517,6 +6583,11 @@ void P_SpawnSpecials(INT32 fromnetsave) case 323: case 324: case 325: + case 326: + case 327: + case 328: + case 329: + case 330: break; case 399: // Linedef execute on map load diff --git a/src/p_spec.h b/src/p_spec.h index 76ddc237c..5bcf25b7b 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -69,6 +69,7 @@ void P_ChangeSectorTag(UINT32 sector, INT16 newtag); void P_RunNightserizeExecutors(mobj_t *actor); void P_RunDeNightserizeExecutors(mobj_t *actor); void P_RunNightsLapExecutors(mobj_t *actor); +void P_RunNightsBonusTimeExecutors(mobj_t *actor); ffloor_t *P_GetFFloorByID(sector_t *sec, UINT16 id); diff --git a/src/p_user.c b/src/p_user.c index befd91f63..4de9759c1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6031,6 +6031,7 @@ static void P_DoNiGHTSCapsule(player_t *player) if (playeringame[i] && players[i].mare == player->mare) P_SetTarget(&players[i].capsule, NULL); // Remove capsule from everyone now that it is dead! S_StartScreamSound(player->mo, sfx_ngdone); + P_RunNightsBonusTimeExecutors(player->mo); } } else From 2c72c6e6602e1b8877c20f9500b7a4141c7f52d3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 2 Apr 2018 08:11:28 -0400 Subject: [PATCH 033/573] Split NiGHTS LE trigger logic into P_CheckNightsTriggerLine This makes P_RunTriggerLinedef more readable because the logic is too different from the other triggers. Also replace BOOL with boolean --- src/p_spec.c | 213 +++++++++++++++++++++++++++------------------------ 1 file changed, 114 insertions(+), 99 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 9c3f3df7d..4f6898658 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1513,6 +1513,118 @@ static void P_AddExecutorDelay(line_t *line, mobj_t *mobj, sector_t *sector) P_AddThinker(&e->thinker); } +/** Used by P_RunTriggerLinedef to check a NiGHTS trigger linedef's conditions + * + * \param triggerline Trigger linedef to check conditions for; should NEVER be NULL. + * \param actor Object initiating the action; should not be NULL. + * \sa P_RunTriggerLinedef + */ +static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) +{ + INT16 specialtype = triggerline->special; + size_t i; + + UINT8 inputmare = max(0, min(255, sides[triggerline->sidenum[0]].textureoffset>>FRACBITS)); + UINT8 inputlap = max(0, min(255, sides[triggerline->sidenum[0]].rowoffset>>FRACBITS)); + + boolean ltemare = triggerline->flags & ML_NOCLIMB; + boolean gtemare = triggerline->flags & ML_BLOCKMONSTERS; + boolean ltelap = triggerline->flags & ML_EFFECT1; + boolean gtelap = triggerline->flags & ML_EFFECT2; + + boolean lapfrombonustime = triggerline->flags & ML_EFFECT3; + boolean perglobalinverse = triggerline->flags & ML_DONTPEGBOTTOM; + boolean perglobal = !(triggerline->flags & ML_EFFECT4) && !perglobalinverse; + + boolean donomares = triggerline->flags & ML_BOUNCY; // nightserize: run at end of level (no mares) + boolean fromnonights = triggerline->flags & ML_TFERLINE; // nightserize: from non-nights // denightserize: all players no nights + + UINT8 currentmare = UINT8_MAX; + UINT8 currentlap = UINT8_MAX; + + // Do early returns for Nightserize + if (specialtype >= 323 && specialtype <= 324) + { + // run only when no mares are found + if (donomares && P_FindLowestMare() != UINT8_MAX) + return false; + + // run only if player is nightserizing from non-nights + if (fromnonights) + { + if (!actor->player) + return false; + else if (actor->player->powers[pw_carry] == CR_NIGHTSMODE) + return false; + } + } + + // Get current mare and lap (and check early return for DeNightserize) + if (perglobal || perglobalinverse + || (specialtype >= 325 && specialtype <= 326 && fromnonights)) + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator) + continue; + + // denightserize: run only if all players are not nights + if (specialtype >= 325 && specialtype <= 326 && fromnonights + && players[i].powers[pw_carry] == CR_NIGHTSMODE) + return false; + + UINT8 lap = lapfrombonustime ? players[i].marebonuslap : players[i].marelap; + + // get highest mare/lap of players + if (perglobal) + { + if (players[i].mare > currentmare || currentmare == UINT8_MAX) + { + currentmare = players[i].mare; + currentlap = UINT8_MAX; + } + if (players[i].mare == currentmare + && (lap > currentlap || currentlap == UINT8_MAX)) + currentlap = lap; + } + // get lowest mare/lap of players + else if (perglobalinverse) + { + if (players[i].mare < currentmare || currentmare == UINT8_MAX) + { + currentmare = players[i].mare; + currentlap = UINT8_MAX; + } + if (players[i].mare == currentmare + && (lap < currentlap || currentlap == UINT8_MAX)) + currentlap = lap; + } + } + } + + // get current mare/lap from triggering player + if (!perglobal && !perglobalinverse) + { + if (!actor->player) + return false; + currentmare = actor->player->mare; + currentlap = lapfrombonustime ? actor->player->marebonuslap : actor->player->marelap; + } + + // Compare current mare/lap to input mare/lap based on rules + if (!(specialtype >= 323 && specialtype <= 324 && donomares) // don't return false if donomares and we got this far + && ((ltemare && currentmare > inputmare) + || (gtemare && currentmare < inputmare) + || (!ltemare && !gtemare && currentmare != inputmare) + || (ltelap && currentlap > inputlap) + || (gtelap && currentlap < inputlap) + || (!ltelap && !gtelap && currentlap != inputlap)) + ) + return false; + + return true; +} + /** Used by P_LinedefExecute to check a trigger linedef's conditions * The linedef executor specials in the trigger linedef's sector are run if all conditions are met. * Return false cancels P_LinedefExecute, this happens if a condition is not met. @@ -1733,105 +1845,8 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller case 328: // nights lap - once case 329: // nights bonus time - each time case 330: // nights bonus time - once - { // nightserize - UINT8 inputmare = max(0, min(255, sides[triggerline->sidenum[0]].textureoffset>>FRACBITS)); - UINT8 inputlap = max(0, min(255, sides[triggerline->sidenum[0]].rowoffset>>FRACBITS)); - - BOOL ltemare = triggerline->flags & ML_NOCLIMB; - BOOL gtemare = triggerline->flags & ML_BLOCKMONSTERS; - BOOL ltelap = triggerline->flags & ML_EFFECT1; - BOOL gtelap = triggerline->flags & ML_EFFECT2; - - BOOL lapfrombonustime = triggerline->flags & ML_EFFECT3; - BOOL perglobalinverse = triggerline->flags & ML_DONTPEGBOTTOM; - BOOL perglobal = !(triggerline->flags & ML_EFFECT4) && !perglobalinverse; - - BOOL donomares = triggerline->flags & ML_BOUNCY; // nightserize: run at end of level (no mares) - BOOL fromnonights = triggerline->flags & ML_TFERLINE; // nightserize: from non-nights // denightserize: all players no nights - - UINT8 currentmare = UINT8_MAX; - UINT8 currentlap = UINT8_MAX; - - // Do early returns for Nightserize - if (specialtype >= 323 && specialtype <= 324) - { - // run only when no mares are found - if (donomares && P_FindLowestMare() != UINT8_MAX) - return false; - - // run only if player is nightserizing from non-nights - if (fromnonights) - { - if (!actor->player) - return false; - else if (actor->player->powers[pw_carry] == CR_NIGHTSMODE) - return false; - } - } - - // Get current mare and lap (and check early return for DeNightserize) - if (perglobal || perglobalinverse - || (specialtype >= 325 && specialtype <= 326 && fromnonights)) - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; - - // denightserize: run only if all players are not nights - if (specialtype >= 325 && specialtype <= 326 && fromnonights - && players[i].powers[pw_carry] == CR_NIGHTSMODE) - return false; - - UINT8 lap = lapfrombonustime ? players[i].marebonuslap : players[i].marelap; - - // get highest mare/lap of players - if (perglobal) - { - if (players[i].mare > currentmare || currentmare == UINT8_MAX) - { - currentmare = players[i].mare; - currentlap = UINT8_MAX; - } - if (players[i].mare == currentmare - && (lap > currentlap || currentlap == UINT8_MAX)) - currentlap = lap; - } - // get lowest mare/lap of players - else if (perglobalinverse) - { - if (players[i].mare < currentmare || currentmare == UINT8_MAX) - { - currentmare = players[i].mare; - currentlap = UINT8_MAX; - } - if (players[i].mare == currentmare - && (lap < currentlap || currentlap == UINT8_MAX)) - currentlap = lap; - } - } - } - - // get current mare/lap from triggering player - if (!perglobal && !perglobalinverse) - { - if (!actor->player) - return false; - currentmare = actor->player->mare; - currentlap = lapfrombonustime ? actor->player->marebonuslap : actor->player->marelap; - } - - // Compare current mare/lap to input mare/lap based on rules - if (!(specialtype >= 323 && specialtype <= 324 && donomares) // don't return false if donomares and we got this far - && ((ltemare && currentmare > inputmare) - || (gtemare && currentmare < inputmare) - || (!ltemare && !gtemare && currentmare != inputmare) - || (ltelap && currentlap > inputlap) - || (gtelap && currentlap < inputlap) - || (!ltelap && !gtelap && currentlap != inputlap)) - ) - return false; - } + if (!P_CheckNightsTriggerLine(triggerline, actor)) + return false; break; default: From 53503cd01f8212ef72e574b6c58156ca2d3455ae Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 2 Apr 2018 08:13:53 -0400 Subject: [PATCH 034/573] Slight fixes for NiGHTS LE Trigger logic --- src/p_spec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 4f6898658..fe9f8b18c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1549,6 +1549,10 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) if (donomares && P_FindLowestMare() != UINT8_MAX) return false; + // run only if there is a mare present + if (!donomares && P_FindLowestMare() == UINT8_MAX) + return false; + // run only if player is nightserizing from non-nights if (fromnonights) { @@ -1601,9 +1605,8 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) } } } - // get current mare/lap from triggering player - if (!perglobal && !perglobalinverse) + else if (!perglobal && !perglobalinverse) { if (!actor->player) return false; From 73e4cab1e48b84e5a31b45a69f1323feb126b234 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 6 Apr 2018 22:34:45 -0400 Subject: [PATCH 035/573] Little adjustments * Swap MF_NOCLIMB and MF_EFFECT1 * Implement if Front Y Offset < 1 (== 0), then set alpha immediately --- src/p_spec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 0f0a2996d..c60771dbf 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3105,8 +3105,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_AddMasterFader(sides[line->sidenum[0]].textureoffset>>FRACBITS, sides[line->sidenum[0]].rowoffset>>FRACBITS, (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS - (line->flags & ML_NOCLIMB), // handle FF_SOLID - !(line->flags & ML_EFFECT1), // do not handle FF_TRANSLUCENT + (line->flags & ML_EFFECT1), // handle FF_SOLID + !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT (INT32)(sectors[s].lines[j]-lines)); break; } @@ -7130,7 +7130,7 @@ static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOO d->thinker.function.acp1 = (actionf_p1)T_Fade; d->affectee = line; d->destvalue = max(1, min(256, destvalue)); // ffloor->alpha is 1-256 - d->speed = max(1, speed); // minimum speed 1/tic + d->speed = speed; // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker // combine the flags-to-handle, this is more convenient than separate BOOLS d->handleflags = 0; @@ -7172,7 +7172,7 @@ void T_Fade(fade_t *d) if (rover->alpha > d->destvalue) { // finish fading out - if (rover->alpha - d->speed <= d->destvalue + d->speed) + if (d->speed < 1 || rover->alpha - d->speed <= d->destvalue + d->speed) { if (rover->alpha != d->destvalue) { @@ -7240,7 +7240,7 @@ void T_Fade(fade_t *d) else // fade in { // finish fading in - if (rover->alpha + d->speed >= d->destvalue - d->speed) + if (d->speed < 1 || rover->alpha + d->speed >= d->destvalue - d->speed) { if (rover->alpha != d->destvalue) { From afa0aae131ff2bfce85fa047b943d5990fbdcb30 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 6 Apr 2018 23:14:48 -0400 Subject: [PATCH 036/573] Refactor flag handling toggles --- src/p_saveg.c | 12 ++++++++-- src/p_spec.c | 61 ++++++++++++++++++++++++++------------------------- src/p_spec.h | 6 ++++- 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index b22b6495e..e8643b6b1 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1565,7 +1565,11 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->affectee); WRITEINT32(save_p, ht->destvalue); WRITEINT32(save_p, ht->speed); - WRITEUINT32(save_p, ht->handleflags); + WRITEUINT8(save_p, ht->doexists); + WRITEUINT8(save_p, ht->dotranslucent); + WRITEUINT8(save_p, ht->dosolid); + WRITEUINT8(save_p, ht->dospawnflags); + WRITEUINT8(save_p, ht->dofadeinonly); } // @@ -2563,7 +2567,11 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->affectee = READINT32(save_p); ht->destvalue = READINT32(save_p); ht->speed = READINT32(save_p); - ht->handleflags = READUINT32(save_p); + ht->doexists = READUINT8(save_p); + ht->dotranslucent = READUINT8(save_p); + ht->dosolid = READUINT8(save_p); + ht->dospawnflags = READUINT8(save_p); + ht->dofadeinonly = READUINT8(save_p); sector_t *ffloorsector = LoadSector(ht->affectee); if (ffloorsector) diff --git a/src/p_spec.c b/src/p_spec.c index c60771dbf..f1425d857 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -105,7 +105,9 @@ static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t * static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); static void P_ResetFading(line_t *line, fade_t *data); #define P_RemoveFading(l) P_ResetFading(l, NULL); -static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOOL handlesolid, BOOL handletrans, INT32 line); +static void P_AddMasterFader(INT32 destvalue, INT32 speed, + BOOL doexists, BOOL dotranslucent, BOOL dosolid, BOOL dospawnflags + , BOOL dofadeinonly, INT32 line); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3105,8 +3107,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_AddMasterFader(sides[line->sidenum[0]].textureoffset>>FRACBITS, sides[line->sidenum[0]].rowoffset>>FRACBITS, (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS - (line->flags & ML_EFFECT1), // handle FF_SOLID !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT + (line->flags & ML_BOUNCY), // handle FF_SOLID + (line->flags & ML_EFFECT1), // handle spawnflags + (line->flags & ML_EFFECT2), // enable flags on fade-in finish only (INT32)(sectors[s].lines[j]-lines)); break; } @@ -7118,12 +7122,16 @@ static void P_ResetFading(line_t *line, fade_t *data) * * \param destvalue transparency value to fade to * \param speed speed to fade by - * \param handleexist handle FF_EXISTS - * \param handlesolid handle FF_SOLID - * \param handletrans do not handle FF_TRANSLUCENT + * \param doexists handle FF_EXISTS + * \param dotranslucent handle FF_TRANSLUCENT + * \param dosolid handle FF_SOLID + * \param dospawnflags handle spawnflags + * \param dofadeinonly enable flags when fade-in is finished; never on fade-out * \param line line to target FOF */ -static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOOL handlesolid, BOOL handletrans, INT32 line) +static void P_AddMasterFader(INT32 destvalue, INT32 speed, + BOOL doexists, BOOL dotranslucent, BOOL dosolid, BOOL dospawnflags + , BOOL dofadeinonly, INT32 line) { fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); @@ -7131,18 +7139,11 @@ static void P_AddMasterFader(INT32 destvalue, INT32 speed, BOOL handleexist, BOO d->affectee = line; d->destvalue = max(1, min(256, destvalue)); // ffloor->alpha is 1-256 d->speed = speed; // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker - - // combine the flags-to-handle, this is more convenient than separate BOOLS - d->handleflags = 0; - - if (handleexist) - d->handleflags |= FF_EXISTS; - - if (handlesolid) - d->handleflags |= FF_SOLID; - - if (handletrans) - d->handleflags |= FF_TRANSLUCENT; + d->doexists = doexists; + d->dotranslucent = dotranslucent; + d->dosolid = dosolid; + d->dospawnflags = dospawnflags; + d->dofadeinonly = dofadeinonly; // find any existing thinkers and remove them, then replace with new data P_ResetFading(&lines[d->affectee], d); @@ -7178,7 +7179,7 @@ void T_Fade(fade_t *d) { rover->alpha = d->destvalue; - if (d->handleflags & FF_EXISTS) + if (d->doexists) { if (rover->alpha <= 1) rover->flags &= ~FF_EXISTS; @@ -7186,12 +7187,12 @@ void T_Fade(fade_t *d) rover->flags |= FF_EXISTS; } - if ((d->handleflags & FF_SOLID) + if (d->dosolid && !(rover->flags & FF_SWIMMABLE) && !(rover->flags & FF_QUICKSAND)) rover->flags &= ~FF_SOLID; // make intangible at end of fade-out - if (d->handleflags & FF_TRANSLUCENT) + if (d->dotranslucent) { if (rover->alpha >= 256) { @@ -7215,15 +7216,15 @@ void T_Fade(fade_t *d) { rover->alpha -= d->speed; - if (d->handleflags & FF_EXISTS) + if (d->doexists) rover->flags |= FF_EXISTS; - if ((d->handleflags & FF_SOLID) + if (d->dosolid && !(rover->flags & FF_SWIMMABLE) && !(rover->flags & FF_QUICKSAND)) rover->flags |= FF_SOLID; // keep solid during fade - if (d->handleflags & FF_TRANSLUCENT) + if (d->dotranslucent) { rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; rover->flags &= ~FF_CUTLEVEL; @@ -7246,7 +7247,7 @@ void T_Fade(fade_t *d) { rover->alpha = d->destvalue; - if (d->handleflags & FF_EXISTS) + if (d->doexists) { if (rover->alpha <= 1) rover->flags &= ~FF_EXISTS; @@ -7254,12 +7255,12 @@ void T_Fade(fade_t *d) rover->flags |= FF_EXISTS; } - if ((d->handleflags & FF_SOLID) + if (d->dosolid && !(rover->flags & FF_SWIMMABLE) && !(rover->flags & FF_QUICKSAND)) rover->flags |= FF_SOLID; // make solid at end of fade-in - if (d->handleflags & FF_TRANSLUCENT) + if (d->dotranslucent) { if (rover->alpha >= 256) { @@ -7283,15 +7284,15 @@ void T_Fade(fade_t *d) { rover->alpha += d->speed; - if (d->handleflags & FF_EXISTS) + if (d->doexists) rover->flags |= FF_EXISTS; - if ((d->handleflags & FF_SOLID) + if (d->dosolid && !(rover->flags & FF_SWIMMABLE) && !(rover->flags & FF_QUICKSAND)) rover->flags |= FF_SOLID; // keep solid during fade - if (d->handleflags & FF_TRANSLUCENT) + if (d->dotranslucent) { rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; rover->flags &= ~FF_CUTLEVEL; diff --git a/src/p_spec.h b/src/p_spec.h index e59e2ea0f..670fe116e 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -456,7 +456,11 @@ typedef struct INT32 affectee; ///< Number of affected line INT32 destvalue; ///< Transparency value to fade to INT32 speed; ///< Speed to fade by - UINT32 handleflags; ///< FOF flags to handle + boolean doexists; ///< Handle FF_EXISTS handling + boolean dotranslucent; ///< Handle FF_TRANSLUCENT handling + boolean dosolid; ///< Handle FF_SOLID handling + boolean dospawnflags; ///< Enable spawnflags handling + boolean dofadeinonly; ///< Set flags only when fade-in is finished; never during fade-out } fade_t; void T_Fade(fade_t *d); From 27ca70d06968f4d6faf62c30472f0d3d00c90510 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 7 Apr 2018 05:52:01 -0400 Subject: [PATCH 037/573] checkpoint --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index f1425d857..66097740a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7138,7 +7138,7 @@ static void P_AddMasterFader(INT32 destvalue, INT32 speed, d->thinker.function.acp1 = (actionf_p1)T_Fade; d->affectee = line; d->destvalue = max(1, min(256, destvalue)); // ffloor->alpha is 1-256 - d->speed = speed; // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker + d->speed = max(1, speed); // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker d->doexists = doexists; d->dotranslucent = dotranslucent; d->dosolid = dosolid; From bd6276a39ec2210776a80a333c897fbd46648561 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 7 Apr 2018 07:09:04 -0400 Subject: [PATCH 038/573] Allow immediate alpha setting when speed = 0; refactoring * Separate fade logic into P_FindFakeFloorsDoAlpha, P_DoFakeFloorAlpha * Change INT32 destvalue and speed to INT16 --- src/p_saveg.c | 8 +- src/p_spec.c | 364 +++++++++++++++++++++++++++----------------------- src/p_spec.h | 4 +- 3 files changed, 206 insertions(+), 170 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index e8643b6b1..e8e5b4eb6 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1563,8 +1563,8 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) const fade_t *ht = (const void *)th; WRITEUINT8(save_p, type); WRITEINT32(save_p, ht->affectee); - WRITEINT32(save_p, ht->destvalue); - WRITEINT32(save_p, ht->speed); + WRITEINT16(save_p, ht->destvalue); + WRITEINT16(save_p, ht->speed); WRITEUINT8(save_p, ht->doexists); WRITEUINT8(save_p, ht->dotranslucent); WRITEUINT8(save_p, ht->dosolid); @@ -2565,8 +2565,8 @@ static inline void LoadFadeThinker(actionf_p1 thinker) fade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->affectee = READINT32(save_p); - ht->destvalue = READINT32(save_p); - ht->speed = READINT32(save_p); + ht->destvalue = READINT16(save_p); + ht->speed = READINT16(save_p); ht->doexists = READUINT8(save_p); ht->dotranslucent = READUINT8(save_p); ht->dosolid = READUINT8(save_p); diff --git a/src/p_spec.c b/src/p_spec.c index 66097740a..f3ea699d6 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -105,9 +105,12 @@ static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t * static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); static void P_ResetFading(line_t *line, fade_t *data); #define P_RemoveFading(l) P_ResetFading(l, NULL); -static void P_AddMasterFader(INT32 destvalue, INT32 speed, - BOOL doexists, BOOL dotranslucent, BOOL dosolid, BOOL dospawnflags - , BOOL dofadeinonly, INT32 line); +static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, + boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, + boolean dofadeinonly, INT32 line); +static void P_AddMasterFader(INT16 destvalue, INT16 speed, + boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, + boolean dofadeinonly, INT32 line); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3104,14 +3107,29 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;) for (j = 0; (unsigned)j < sectors[s].linecount; j++) if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) - P_AddMasterFader(sides[line->sidenum[0]].textureoffset>>FRACBITS, - sides[line->sidenum[0]].rowoffset>>FRACBITS, - (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS - !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT - (line->flags & ML_BOUNCY), // handle FF_SOLID - (line->flags & ML_EFFECT1), // handle spawnflags - (line->flags & ML_EFFECT2), // enable flags on fade-in finish only - (INT32)(sectors[s].lines[j]-lines)); + { + if (sides[line->sidenum[0]].rowoffset>>FRACBITS > 0) + P_AddMasterFader(sides[line->sidenum[0]].textureoffset>>FRACBITS, + sides[line->sidenum[0]].rowoffset>>FRACBITS, + (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT + (line->flags & ML_BOUNCY), // handle FF_SOLID + (line->flags & ML_EFFECT1), // handle spawnflags + (line->flags & ML_EFFECT2), // enable flags on fade-in finish only + (INT32)(sectors[s].lines[j]-lines)); + else + { + P_RemoveFading(&lines[(INT32)(sectors[s].lines[j]-lines)]); + P_FindFakeFloorsDoAlpha(sides[line->sidenum[0]].textureoffset>>FRACBITS, + 0, // set alpha immediately + (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT + (line->flags & ML_BOUNCY), // handle FF_SOLID + (line->flags & ML_EFFECT1), // handle spawnflags + (line->flags & ML_EFFECT2), // enable flags on fade-in finish only + (INT32)(sectors[s].lines[j]-lines)); + } + } break; } @@ -7118,6 +7136,171 @@ static void P_ResetFading(line_t *line, fade_t *data) } } +static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, + boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, + boolean dofadeinonly) +{ + boolean result = false; + + if (rover->alpha == destvalue) + return result; + // fade out + else if (rover->alpha > destvalue) + { + // finish fading out + if (speed < 1 || rover->alpha - speed <= destvalue + speed) + { + rover->alpha = destvalue; + + if (doexists) + { + if (rover->alpha <= 1) + rover->flags &= ~FF_EXISTS; + else + rover->flags |= FF_EXISTS; + } + + if (dosolid + && !(rover->flags & FF_SWIMMABLE) + && !(rover->flags & FF_QUICKSAND)) + rover->flags &= ~FF_SOLID; // make intangible at end of fade-out + + if (dotranslucent) + { + if (rover->alpha >= 256) + { + rover->flags |= FF_CUTLEVEL; + rover->flags &= ~(FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA); + } + else + { + rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; + rover->flags &= ~FF_CUTLEVEL; + } + + if (rover->flags & FF_SOLID) + rover->flags &= ~FF_CUTSPRITES; + else + rover->flags |= FF_CUTSPRITES; + } + } + else // continue fading out + { + rover->alpha -= speed; + + if (doexists) + rover->flags |= FF_EXISTS; + + if (dosolid + && !(rover->flags & FF_SWIMMABLE) + && !(rover->flags & FF_QUICKSAND)) + rover->flags |= FF_SOLID; // keep solid during fade + + if (dotranslucent) + { + rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; + rover->flags &= ~FF_CUTLEVEL; + + if (rover->flags & FF_SOLID) + rover->flags &= ~FF_CUTSPRITES; + else + rover->flags |= FF_CUTSPRITES; + } + + result = true; + } + } + else // fade in + { + // finish fading in + if (speed < 1 || rover->alpha + speed >= destvalue - speed) + { + rover->alpha = destvalue; + + if (doexists) + { + if (rover->alpha <= 1) + rover->flags &= ~FF_EXISTS; + else + rover->flags |= FF_EXISTS; + } + + if (dosolid + && !(rover->flags & FF_SWIMMABLE) + && !(rover->flags & FF_QUICKSAND)) + rover->flags |= FF_SOLID; // make solid at end of fade-in + + if (dotranslucent) + { + if (rover->alpha >= 256) + { + rover->flags |= FF_CUTLEVEL; + rover->flags &= ~(FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA); + } + else + { + rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; + rover->flags &= ~FF_CUTLEVEL; + } + + if (rover->flags & FF_SOLID) + rover->flags &= ~FF_CUTSPRITES; + else + rover->flags |= FF_CUTSPRITES; + } + } + else // continue fading in + { + rover->alpha += speed; + + if (doexists) + rover->flags |= FF_EXISTS; + + if (dosolid + && !(rover->flags & FF_SWIMMABLE) + && !(rover->flags & FF_QUICKSAND)) + rover->flags |= FF_SOLID; // keep solid during fade + + if (dotranslucent) + { + rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; + rover->flags &= ~FF_CUTLEVEL; + + if (rover->flags & FF_SOLID) + rover->flags &= ~FF_CUTSPRITES; + else + rover->flags |= FF_CUTSPRITES; + } + + result = true; + } + } + + return result; +} + +static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, + boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, + boolean dofadeinonly, INT32 line) +{ + ffloor_t *rover; + register INT32 s; + INT32 affectedffloors = 0; + + for (s = -1; (s = P_FindSectorFromLineTag(&lines[line], s)) >= 0 ;) + { + for (rover = sectors[s].ffloors; rover; rover = rover->next) + { + if (rover->master != &lines[line]) + continue; + + affectedffloors += (INT32)P_DoFakeFloorAlpha(rover, destvalue, speed, doexists, dotranslucent, dosolid, dospawnflags, dofadeinonly); + } + } + + return affectedffloors; +} + /** Adds master fader thinker. * * \param destvalue transparency value to fade to @@ -7129,9 +7312,9 @@ static void P_ResetFading(line_t *line, fade_t *data) * \param dofadeinonly enable flags when fade-in is finished; never on fade-out * \param line line to target FOF */ -static void P_AddMasterFader(INT32 destvalue, INT32 speed, - BOOL doexists, BOOL dotranslucent, BOOL dosolid, BOOL dospawnflags - , BOOL dofadeinonly, INT32 line) +static void P_AddMasterFader(INT16 destvalue, INT16 speed, + boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, + boolean dofadeinonly, INT32 line) { fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); @@ -7158,156 +7341,9 @@ static void P_AddMasterFader(INT32 destvalue, INT32 speed, */ void T_Fade(fade_t *d) { - ffloor_t *rover; - register INT32 s; - INT32 affectedffloors = 0; - - for (s = -1; (s = P_FindSectorFromLineTag(&lines[d->affectee], s)) >= 0 ;) - { - for (rover = sectors[s].ffloors; rover; rover = rover->next) - { - if (rover->master != &lines[d->affectee]) - continue; - - // fade out - if (rover->alpha > d->destvalue) - { - // finish fading out - if (d->speed < 1 || rover->alpha - d->speed <= d->destvalue + d->speed) - { - if (rover->alpha != d->destvalue) - { - rover->alpha = d->destvalue; - - if (d->doexists) - { - if (rover->alpha <= 1) - rover->flags &= ~FF_EXISTS; - else - rover->flags |= FF_EXISTS; - } - - if (d->dosolid - && !(rover->flags & FF_SWIMMABLE) - && !(rover->flags & FF_QUICKSAND)) - rover->flags &= ~FF_SOLID; // make intangible at end of fade-out - - if (d->dotranslucent) - { - if (rover->alpha >= 256) - { - rover->flags |= FF_CUTLEVEL; - rover->flags &= ~(FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA); - } - else - { - rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; - rover->flags &= ~FF_CUTLEVEL; - } - - if (rover->flags & FF_SOLID) - rover->flags &= ~FF_CUTSPRITES; - else - rover->flags |= FF_CUTSPRITES; - } - } - } - else // continue fading out - { - rover->alpha -= d->speed; - - if (d->doexists) - rover->flags |= FF_EXISTS; - - if (d->dosolid - && !(rover->flags & FF_SWIMMABLE) - && !(rover->flags & FF_QUICKSAND)) - rover->flags |= FF_SOLID; // keep solid during fade - - if (d->dotranslucent) - { - rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; - rover->flags &= ~FF_CUTLEVEL; - - if (rover->flags & FF_SOLID) - rover->flags &= ~FF_CUTSPRITES; - else - rover->flags |= FF_CUTSPRITES; - } - - affectedffloors++; - } - } - else // fade in - { - // finish fading in - if (d->speed < 1 || rover->alpha + d->speed >= d->destvalue - d->speed) - { - if (rover->alpha != d->destvalue) - { - rover->alpha = d->destvalue; - - if (d->doexists) - { - if (rover->alpha <= 1) - rover->flags &= ~FF_EXISTS; - else - rover->flags |= FF_EXISTS; - } - - if (d->dosolid - && !(rover->flags & FF_SWIMMABLE) - && !(rover->flags & FF_QUICKSAND)) - rover->flags |= FF_SOLID; // make solid at end of fade-in - - if (d->dotranslucent) - { - if (rover->alpha >= 256) - { - rover->flags |= FF_CUTLEVEL; - rover->flags &= ~(FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA); - } - else - { - rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; - rover->flags &= ~FF_CUTLEVEL; - } - - if (rover->flags & FF_SOLID) - rover->flags &= ~FF_CUTSPRITES; - else - rover->flags |= FF_CUTSPRITES; - } - } - } - else // continue fading in - { - rover->alpha += d->speed; - - if (d->doexists) - rover->flags |= FF_EXISTS; - - if (d->dosolid - && !(rover->flags & FF_SWIMMABLE) - && !(rover->flags & FF_QUICKSAND)) - rover->flags |= FF_SOLID; // keep solid during fade - - if (d->dotranslucent) - { - rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; - rover->flags &= ~FF_CUTLEVEL; - - if (rover->flags & FF_SOLID) - rover->flags &= ~FF_CUTSPRITES; - else - rover->flags |= FF_CUTSPRITES; - } - - affectedffloors++; - } - } - } - } + INT32 affectedffloors = P_FindFakeFloorsDoAlpha(d->destvalue, d->speed, + d->doexists, d->dotranslucent, d->dosolid, d->dospawnflags, + d->dofadeinonly, d->affectee); // no more ffloors to fade? remove myself if (affectedffloors == 0) diff --git a/src/p_spec.h b/src/p_spec.h index 670fe116e..c8607f868 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -454,8 +454,8 @@ typedef struct { thinker_t thinker; ///< Thinker structure for effect. INT32 affectee; ///< Number of affected line - INT32 destvalue; ///< Transparency value to fade to - INT32 speed; ///< Speed to fade by + INT16 destvalue; ///< Transparency value to fade to + INT16 speed; ///< Speed to fade by boolean doexists; ///< Handle FF_EXISTS handling boolean dotranslucent; ///< Handle FF_TRANSLUCENT handling boolean dosolid; ///< Handle FF_SOLID handling From f903d01bc142b1f59a21d7a00128430ab13b431f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 7 Apr 2018 07:33:07 -0400 Subject: [PATCH 039/573] Add ML_DONPTEGTOP flag to Nights LE * Nightserize: Run only if player is already NiGHTS * DeNightserize: Run only if >0 players are NiGHTS --- src/p_spec.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 590d97a5d..e628b853d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1539,6 +1539,7 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) boolean donomares = triggerline->flags & ML_BOUNCY; // nightserize: run at end of level (no mares) boolean fromnonights = triggerline->flags & ML_TFERLINE; // nightserize: from non-nights // denightserize: all players no nights + boolean fromnights = triggerline->flags & ML_DONTPEGTOP; // nightserize: from nights // denightserize: >0 players are nights UINT8 currentmare = UINT8_MAX; UINT8 currentlap = UINT8_MAX; @@ -1562,12 +1563,22 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) else if (actor->player->powers[pw_carry] == CR_NIGHTSMODE) return false; } + // run only if player is nightserizing from nights + else if (fromnights) + { + if (!actor->player) + return false; + else if (actor->player->powers[pw_carry] != CR_NIGHTSMODE) + return false; + } } // Get current mare and lap (and check early return for DeNightserize) if (perglobal || perglobalinverse - || (specialtype >= 325 && specialtype <= 326 && fromnonights)) + || (specialtype >= 325 && specialtype <= 326 && (fromnonights || fromnights))) { + UINT8 playersarenights = 0; + for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].spectator) @@ -1578,6 +1589,11 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) && players[i].powers[pw_carry] == CR_NIGHTSMODE) return false; + // count number of nights players for denightserize return + if (specialtype >= 325 && specialtype <= 326 && fromnights + && players[i].powers[pw_carry] == CR_NIGHTSMODE) + playersarenights++; + UINT8 lap = lapfrombonustime ? players[i].marebonuslap : players[i].marelap; // get highest mare/lap of players @@ -1605,6 +1621,11 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) currentlap = lap; } } + + // denightserize: run only if >0 players are nights + if (specialtype >= 325 && specialtype <= 326 && fromnights + && playersarenights < 1) + return false; } // get current mare/lap from triggering player else if (!perglobal && !perglobalinverse) @@ -1839,8 +1860,6 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller return false; } break; - - // Let's do the NiGHTS triggers in one code block; they mostly have the same logic case 323: // nightserize - each time case 324: // nightserize - once case 325: // denightserize - each time From 89478a7ba46eaa4932dc45bbfdaf520343e1e46d Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 14 Jun 2018 21:51:21 +0100 Subject: [PATCH 040/573] Added linedef 447 as the change colormap linedef exec special. IMPORTANT NOTE: UNTESTED --- src/p_setup.c | 1 + src/p_spec.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index a5544c26b..052006a35 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1428,6 +1428,7 @@ static void P_LoadRawSideDefs2(void *data) { case 63: // variable colormap via 242 linedef case 606: //SoM: 4/4/2000: Just colormap transfer + case 447: // Change colormap of tagged sectors! -- Monster Iestyn 14/06/18 // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. if (rendermode == render_soft || rendermode == render_none) diff --git a/src/p_spec.c b/src/p_spec.c index 93b5c89ca..9d1e85366 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3033,6 +3033,15 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } break; + case 447: // Change colormap of tagged sectors! + // Basically this special applies a colormap to the tagged sectors, just like 606 (the colormap linedef) + // Except it is activated by linedef executor, not level load + // This could even override existing colormaps I believe + // -- Monster Iestyn 14/06/18 + for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + sectors[secnum].midmap = line->frontsector->midmap; + break; + case 448: // Change skybox viewpoint/centerpoint if ((mo && mo->player && P_IsLocalPlayer(mo->player)) || (line->flags & ML_NOCLIMB)) { From fc2517d8e22650ad56cc7e7c1bb55b070892be5f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 00:13:08 -0400 Subject: [PATCH 041/573] FlickyFly: Configure gravity by MTF_AMBUSH --- src/p_enemy.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 9235a1d0f..2db32adc3 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10884,9 +10884,14 @@ void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fi if (actor->target && abs(chasez - actor->z) > targetdist) targetdist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); - vertangle = (R_PointToAngle2(0, actor->z, targetdist, chasez) >> ANGLETOFINESHIFT) & FINEMASK; - P_InstaThrust(actor, actor->angle, FixedMul(FINECOSINE(vertangle), flyspeed)); - actor->momz = FixedMul(FINESINE(vertangle), flyspeed); + if (actor->spawnpoint && (actor->spawnpoint->options & MTF_AMBUSH)) + actor->momz = 0; + else + { + vertangle = (R_PointToAngle2(0, actor->z, targetdist, chasez) >> ANGLETOFINESHIFT) & FINEMASK; + P_InstaThrust(actor, actor->angle, FixedMul(FINECOSINE(vertangle), flyspeed)); + actor->momz = FixedMul(FINESINE(vertangle), flyspeed); + } } // Function: A_FlickyFly @@ -11636,4 +11641,4 @@ void A_CheckFlags2(mobj_t *actor) if (actor->flags2 & locvar1) P_SetMobjState(actor, (statenum_t)locvar2); -} \ No newline at end of file +} From 332136b9bf9513a82682866ce7e664d48977a0c3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 00:17:46 -0400 Subject: [PATCH 042/573] Assign mapthingnums to MT_FLICKY * Type # 570-585 --- src/info.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/info.c b/src/info.c index 1489917b7..cb0c0940c 100644 --- a/src/info.c +++ b/src/info.c @@ -13687,7 +13687,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = // Bluebird { // MT_FLICKY_01 - -1, // doomednum + 570, // doomednum S_FLICKY_01_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13714,7 +13714,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_02 - -1, // doomednum + 571, // doomednum S_FLICKY_02_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13741,7 +13741,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_03 - -1, // doomednum + 572, // doomednum S_FLICKY_03_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13768,7 +13768,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_04 - -1, // doomednum + 573, // doomednum S_FLICKY_04_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13795,7 +13795,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_05 - -1, // doomednum + 574, // doomednum S_FLICKY_05_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13822,7 +13822,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_06 - -1, // doomednum + 575, // doomednum S_FLICKY_06_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13849,7 +13849,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_07 - -1, // doomednum + 576, // doomednum S_FLICKY_07_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13876,7 +13876,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_08 - -1, // doomednum + 577, // doomednum S_FLICKY_08_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13903,7 +13903,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_09 - -1, // doomednum + 578, // doomednum S_FLICKY_09_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13930,7 +13930,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_10 - -1, // doomednum + 579, // doomednum S_FLICKY_10_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13957,7 +13957,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_11 - -1, // doomednum + 580, // doomednum S_FLICKY_11_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13984,7 +13984,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_12 - -1, // doomednum + 581, // doomednum S_FLICKY_12_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14011,7 +14011,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_13 - -1, // doomednum + 582, // doomednum S_FLICKY_13_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14038,7 +14038,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_14 - -1, // doomednum + 583, // doomednum S_FLICKY_14_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14065,7 +14065,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_15 - -1, // doomednum + 584, // doomednum S_FLICKY_15_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14092,7 +14092,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_16 - -1, // doomednum + 585, // doomednum S_FLICKY_16_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate From 292654e498793d04d74bcf4dfb5dfec185e96347 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 00:51:46 -0400 Subject: [PATCH 043/573] Fix FlickyFly momentum on MTF_OBJECTSPECIAL --- src/p_enemy.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 2db32adc3..7c1540ce4 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10884,14 +10884,13 @@ void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fi if (actor->target && abs(chasez - actor->z) > targetdist) targetdist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); - if (actor->spawnpoint && (actor->spawnpoint->options & MTF_AMBUSH)) - actor->momz = 0; + if (actor->spawnpoint && (actor->spawnpoint->options & MTF_OBJECTSPECIAL)) + vertangle = 0; else - { vertangle = (R_PointToAngle2(0, actor->z, targetdist, chasez) >> ANGLETOFINESHIFT) & FINEMASK; - P_InstaThrust(actor, actor->angle, FixedMul(FINECOSINE(vertangle), flyspeed)); - actor->momz = FixedMul(FINESINE(vertangle), flyspeed); - } + + P_InstaThrust(actor, actor->angle, FixedMul(FINECOSINE(vertangle), flyspeed)); + actor->momz = FixedMul(FINESINE(vertangle), flyspeed); } // Function: A_FlickyFly From db7bc927e7ba897ab8102d88d43dd441f508f11c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 01:01:20 -0400 Subject: [PATCH 044/573] Mapthingnums for MT_SECRETFLICKYies --- src/info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/info.c b/src/info.c index cb0c0940c..8b97071ef 100644 --- a/src/info.c +++ b/src/info.c @@ -14119,7 +14119,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_SECRETFLICKY_01 - -1, // doomednum + 586, // doomednum S_SECRETFLICKY_01_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14146,7 +14146,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_SECRETFLICKY_02 - -1, // doomednum + 587, // doomednum S_SECRETFLICKY_02_OUT, // spawnstate 1000, // spawnhealth S_NULL, // seestate From d5f32cc0e5da535654280198c63d16408595d4c4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 01:44:08 -0400 Subject: [PATCH 045/573] Flicky stand states --- src/dehacked.c | 18 +++++++++++++++++ src/info.c | 54 +++++++++++++++++++++++++++++++++----------------- src/info.h | 18 +++++++++++++++++ 3 files changed, 72 insertions(+), 18 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index c4d0bc104..37a4a08c9 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -5393,6 +5393,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_01_FLAP1", "S_FLICKY_01_FLAP2", "S_FLICKY_01_FLAP3", + "S_FLICKY_01_STAND", // Rabbit "S_FLICKY_02_OUT", @@ -5400,6 +5401,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_02_HOP", "S_FLICKY_02_UP", "S_FLICKY_02_DOWN", + "S_FLICKY_02_STAND", // Chicken "S_FLICKY_03_OUT", @@ -5408,6 +5410,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_03_UP", "S_FLICKY_03_FLAP1", "S_FLICKY_03_FLAP2", + "S_FLICKY_03_STAND", // Seal "S_FLICKY_04_OUT", @@ -5419,6 +5422,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_04_SWIM2", "S_FLICKY_04_SWIM3", "S_FLICKY_04_SWIM4", + "S_FLICKY_04_STAND", // Pig "S_FLICKY_05_OUT", @@ -5426,6 +5430,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_05_HOP", "S_FLICKY_05_UP", "S_FLICKY_05_DOWN", + "S_FLICKY_05_STAND", // Chipmunk "S_FLICKY_06_OUT", @@ -5433,6 +5438,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_06_HOP", "S_FLICKY_06_UP", "S_FLICKY_06_DOWN", + "S_FLICKY_06_STAND", // Penguin "S_FLICKY_07_OUT", @@ -5447,6 +5453,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_07_SWIM1", "S_FLICKY_07_SWIM2", "S_FLICKY_07_SWIM3", + "S_FLICKY_07_STAND", // Fish "S_FLICKY_08_OUT", @@ -5460,6 +5467,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_08_SWIM2", "S_FLICKY_08_SWIM3", "S_FLICKY_08_SWIM4", + "S_FLICKY_08_STAND", // Ram "S_FLICKY_09_OUT", @@ -5467,11 +5475,13 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_09_HOP", "S_FLICKY_09_UP", "S_FLICKY_09_DOWN", + "S_FLICKY_09_STAND", // Puffin "S_FLICKY_10_OUT", "S_FLICKY_10_FLAP1", "S_FLICKY_10_FLAP2", + "S_FLICKY_10_STAND", // Cow "S_FLICKY_11_OUT", @@ -5479,6 +5489,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_11_RUN1", "S_FLICKY_11_RUN2", "S_FLICKY_11_RUN3", + "S_FLICKY_11_STAND", // Rat "S_FLICKY_12_OUT", @@ -5486,6 +5497,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_12_RUN1", "S_FLICKY_12_RUN2", "S_FLICKY_12_RUN3", + "S_FLICKY_12_STAND", // Bear "S_FLICKY_13_OUT", @@ -5493,12 +5505,14 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_13_HOP", "S_FLICKY_13_UP", "S_FLICKY_13_DOWN", + "S_FLICKY_13_STAND", // Dove "S_FLICKY_14_OUT", "S_FLICKY_14_FLAP1", "S_FLICKY_14_FLAP2", "S_FLICKY_14_FLAP3", + "S_FLICKY_14_STAND", // Cat "S_FLICKY_15_OUT", @@ -5506,12 +5520,14 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_15_HOP", "S_FLICKY_15_UP", "S_FLICKY_15_DOWN", + "S_FLICKY_15_STAND", // Canary "S_FLICKY_16_OUT", "S_FLICKY_16_FLAP1", "S_FLICKY_16_FLAP2", "S_FLICKY_16_FLAP3", + "S_FLICKY_16_STAND", // Spider "S_SECRETFLICKY_01_OUT", @@ -5519,12 +5535,14 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_SECRETFLICKY_01_HOP", "S_SECRETFLICKY_01_UP", "S_SECRETFLICKY_01_DOWN", + "S_SECRETFLICKY_01_STAND", // Bat "S_SECRETFLICKY_02_OUT", "S_SECRETFLICKY_02_FLAP1", "S_SECRETFLICKY_02_FLAP2", "S_SECRETFLICKY_02_FLAP3", + "S_SECRETFLICKY_02_STAND", // Fan "S_FAN", diff --git a/src/info.c b/src/info.c index 8b97071ef..8ebbdc131 100644 --- a/src/info.c +++ b/src/info.c @@ -2638,6 +2638,7 @@ state_t states[NUMSTATES] = {SPR_FL01, 1, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP2}, // S_FLICKY_01_FLAP1 {SPR_FL01, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP3}, // S_FLICKY_01_FLAP2 {SPR_FL01, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP1}, // S_FLICKY_01_FLAP3 + {SPR_FL01, FF_ANIMATE, -1, {NULL}, 3, 3, S_NULL}, // S_FLICKY_01_STAND // Rabbit {SPR_FL02, 0, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_OUT}, // S_FLICKY_02_OUT @@ -2645,6 +2646,7 @@ state_t states[NUMSTATES] = {SPR_FL02, 1, 1, {A_FlickyHop}, 6*FRACUNIT, 4*FRACUNIT, S_FLICKY_02_UP}, // S_FLICKY_02_HOP {SPR_FL02, 2, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, S_FLICKY_02_DOWN, S_FLICKY_02_UP}, // S_FLICKY_02_UP {SPR_FL02, 3, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_DOWN}, // S_FLICKY_02_DOWN + {SPR_FL02, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_FLICKY_02_STAND // Chicken {SPR_FL03, 0, 2, {A_FlickyCheck}, S_FLICKY_03_AIM, S_FLICKY_03_FLAP1, S_FLICKY_03_OUT}, // S_FLICKY_03_OUT @@ -2653,6 +2655,7 @@ state_t states[NUMSTATES] = {SPR_FL03, 2, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, S_FLICKY_03_FLAP1, S_FLICKY_03_UP}, // S_FLICKY_03_UP {SPR_FL03, 3, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP2}, // S_FLICKY_03_FLAP1 {SPR_FL03, 4, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP1}, // S_FLICKY_03_FLAP2 + {SPR_FL03, FF_ANIMATE, -1, {NULL}, 4, 2, S_NULL}, // S_FLICKY_03_STAND // Seal {SPR_FL04, 0, 2, {A_FlickyCheck}, S_FLICKY_04_AIM, 0, S_FLICKY_04_OUT}, // S_FLICKY_04_OUT @@ -2664,6 +2667,7 @@ state_t states[NUMSTATES] = {SPR_FL04, 4, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM3}, // S_FLICKY_04_SWIM2 {SPR_FL04, 3, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM4}, // S_FLICKY_04_SWIM3 {SPR_FL04, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM1}, // S_FLICKY_04_SWIM4 + {SPR_FL04, FF_ANIMATE, -1, {NULL}, 5, 4, S_NULL}, // S_FLICKY_04_STAND // Pig {SPR_FL05, 0, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_OUT}, // S_FLICKY_05_OUT @@ -2671,6 +2675,7 @@ state_t states[NUMSTATES] = {SPR_FL05, 1, 1, {A_FlickyHop}, 4*FRACUNIT, 3*FRACUNIT, S_FLICKY_05_UP}, // S_FLICKY_05_HOP {SPR_FL05, 2, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, S_FLICKY_05_DOWN, S_FLICKY_05_UP}, // S_FLICKY_05_UP {SPR_FL05, 3, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_DOWN}, // S_FLICKY_05_DOWN + {SPR_FL05, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_FLICKY_05_STAND // Chipmunk {SPR_FL06, 0, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_OUT}, // S_FLICKY_06_OUT @@ -2678,6 +2683,7 @@ state_t states[NUMSTATES] = {SPR_FL06, 1, 1, {A_FlickyHop}, 5*FRACUNIT, 6*FRACUNIT, S_FLICKY_06_UP}, // S_FLICKY_06_HOP {SPR_FL06, 2, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, S_FLICKY_06_DOWN, S_FLICKY_06_UP}, // S_FLICKY_06_UP {SPR_FL06, 3, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_DOWN}, // S_FLICKY_06_DOWN + {SPR_FL06, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_FLICKY_06_STAND // Penguin {SPR_FL07, 0, 2, {A_FlickyCheck}, S_FLICKY_07_AIML, 0, S_FLICKY_07_OUT}, // S_FLICKY_07_OUT @@ -2692,6 +2698,7 @@ state_t states[NUMSTATES] = {SPR_FL07, 4, 4, {A_FlickyFly}, 3*FRACUNIT, 72*FRACUNIT, S_FLICKY_07_SWIM2}, // S_FLICKY_07_SWIM1 {SPR_FL07, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM2 {SPR_FL07, 6, 4, {A_FlickyCoast}, 2*FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM3 + {SPR_FL07, FF_ANIMATE, -1, {NULL}, 6, 4, S_NULL}, // S_FLICKY_07_STAND // Fish {SPR_FL08, 0, 2, {A_FlickyCheck}, S_FLICKY_08_AIM, 0, S_FLICKY_08_OUT}, // S_FLICKY_08_OUT @@ -2705,6 +2712,7 @@ state_t states[NUMSTATES] = {SPR_FL08, 1, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_08_SWIM1, S_FLICKY_08_SWIM3}, // S_FLICKY_08_SWIM2 {SPR_FL08, 0, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_08_SWIM1, S_FLICKY_08_SWIM4}, // S_FLICKY_08_SWIM3 {SPR_FL08, 2, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_08_SWIM1, S_FLICKY_08_SWIM4}, // S_FLICKY_08_SWIM4 + {SPR_FL08, FF_ANIMATE, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_08_STAND // Ram {SPR_FL09, 0, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, 0, S_FLICKY_09_OUT}, // S_FLICKY_09_OUT @@ -2712,11 +2720,13 @@ state_t states[NUMSTATES] = {SPR_FL09, 1, 1, {A_FlickyHop}, 7*FRACUNIT, 2*FRACUNIT, S_FLICKY_09_UP}, // S_FLICKY_09_HOP {SPR_FL09, 2, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, S_FLICKY_09_DOWN, S_FLICKY_09_UP}, // S_FLICKY_09_UP {SPR_FL09, 3, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, 0, S_FLICKY_09_DOWN}, // S_FLICKY_09_DOWN + {SPR_FL09, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_FLICKY_09_STAND // Puffin {SPR_FL10, 0, 2, {A_FlickyCheck}, S_FLICKY_10_FLAP1, S_FLICKY_10_FLAP1, S_FLICKY_10_OUT}, // S_FLICKY_10_OUT {SPR_FL10, 1, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP2}, // S_FLICKY_10_FLAP1 {SPR_FL10, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP1}, // S_FLICKY_10_FLAP2 + {SPR_FL10, FF_ANIMATE, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_10_STAND // Cow {SPR_FL11, 0, 2, {A_FlickyCheck}, S_FLICKY_11_AIM, 0, S_FLICKY_11_OUT}, // S_FLICKY_11_OUT @@ -2724,6 +2734,7 @@ state_t states[NUMSTATES] = {SPR_FL11, 1, 3, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_RUN2}, // S_FLICKY_11_RUN1 {SPR_FL11, 2, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_RUN3}, // S_FLICKY_11_RUN2 {SPR_FL11, 3, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_AIM}, // S_FLICKY_11_RUN3 + {SPR_FL11, FF_ANIMATE, -1, {NULL}, 3, 4, S_NULL}, // S_FLICKY_11_STAND // Rat {SPR_FL12, 0, 2, {A_FlickyCheck}, S_FLICKY_12_AIM, 0, S_FLICKY_12_OUT}, // S_FLICKY_12_OUT @@ -2731,6 +2742,7 @@ state_t states[NUMSTATES] = {SPR_FL12, 1, 2, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_RUN2}, // S_FLICKY_12_RUN1 {SPR_FL12, 2, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_RUN3}, // S_FLICKY_12_RUN2 {SPR_FL12, 3, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_AIM}, // S_FLICKY_12_RUN3 + {SPR_FL12, FF_ANIMATE, -1, {NULL}, 3, 3, S_NULL}, // S_FLICKY_12_STAND // Bear {SPR_FL13, 0, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_OUT}, // S_FLICKY_13_OUT @@ -2738,12 +2750,14 @@ state_t states[NUMSTATES] = {SPR_FL13, 1, 1, {A_FlickyHop}, 5*FRACUNIT, 3*FRACUNIT, S_FLICKY_13_UP}, // S_FLICKY_13_HOP {SPR_FL13, 2, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, S_FLICKY_13_DOWN, S_FLICKY_13_UP}, // S_FLICKY_13_UP {SPR_FL13, 3, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_DOWN}, // S_FLICKY_13_DOWN + {SPR_FL13, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_FLICKY_13_STAND // Dove {SPR_FL14, 0, 2, {A_FlickyCheck}, S_FLICKY_14_FLAP1, S_FLICKY_14_FLAP1, S_FLICKY_14_OUT}, // S_FLICKY_14_OUT {SPR_FL14, 1, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP2}, // S_FLICKY_14_FLAP1 {SPR_FL14, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP3}, // S_FLICKY_14_FLAP2 {SPR_FL14, 3, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP1}, // S_FLICKY_14_FLAP3 + {SPR_FL14, FF_ANIMATE, -1, {NULL}, 3, 3, S_NULL}, // S_FLICKY_14_STAND // Cat {SPR_FL15, 0, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_OUT}, // S_FLICKY_15_OUT @@ -2751,12 +2765,14 @@ state_t states[NUMSTATES] = {SPR_FL15, 1, 1, {A_FlickyFlounder}, 2*FRACUNIT, 6*FRACUNIT, S_FLICKY_15_UP}, // S_FLICKY_15_HOP {SPR_FL15, 2, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, S_FLICKY_15_DOWN, S_FLICKY_15_UP}, // S_FLICKY_15_UP {SPR_FL15, 3, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_DOWN}, // S_FLICKY_15_DOWN + {SPR_FL15, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_FLICKY_15_STAND // Canary {SPR_FL16, 0, 2, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_OUT}, // S_FLICKY_16_OUT {SPR_FL16, 1, 3, {A_FlickyFly}, 4*FRACUNIT, 8*FRACUNIT, S_FLICKY_16_FLAP2}, // S_FLICKY_16_FLAP1 {SPR_FL16, 2, 3, {A_SetObjectFlags}, MF_NOGRAVITY, 1, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP2 {SPR_FL16, 3, 3, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP3 + {SPR_FL16, FF_ANIMATE, -1, {NULL}, 3, 3, S_NULL}, // S_FLICKY_16_STAND // Spider {SPR_FS01, 0, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_OUT}, // S_SECRETFLICKY_01_OUT @@ -2764,12 +2780,14 @@ state_t states[NUMSTATES] = {SPR_FS01, 1, 1, {A_FlickyFlounder}, 2*FRACUNIT, 6*FRACUNIT, S_SECRETFLICKY_01_UP}, // S_SECRETFLICKY_01_HOP {SPR_FS01, 2, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, S_SECRETFLICKY_01_DOWN, S_SECRETFLICKY_01_UP}, // S_SECRETFLICKY_01_UP {SPR_FS01, 3, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_DOWN}, // S_SECRETFLICKY_01_DOWN + {SPR_FS01, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_SECRETFLICKY_01_STAND // Bat {SPR_FS02, 0, 2, {A_FlickyHeightCheck}, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_OUT}, // S_SECRETFLICKY_02_OUT {SPR_FS02, 1, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP2}, // S_SECRETFLICKY_02_FLAP1 {SPR_FS02, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP3}, // S_SECRETFLICKY_02_FLAP2 {SPR_FS02, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP1}, // S_SECRETFLICKY_02_FLAP3 + {SPR_FS02, FF_ANIMATE, -1, {NULL}, 3, 3, S_NULL}, // S_SECRETFLICKY_02_STAND // Fan {SPR_FANS, 0, 1, {A_FanBubbleSpawn}, 2048, 0, S_FAN2}, // S_FAN @@ -13690,7 +13708,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 570, // doomednum S_FLICKY_01_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_01_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -13717,7 +13735,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 571, // doomednum S_FLICKY_02_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_02_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -13744,7 +13762,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 572, // doomednum S_FLICKY_03_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_03_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -13771,7 +13789,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 573, // doomednum S_FLICKY_04_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_04_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -13798,7 +13816,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 574, // doomednum S_FLICKY_05_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_05_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -13825,7 +13843,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 575, // doomednum S_FLICKY_06_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_06_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -13852,7 +13870,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 576, // doomednum S_FLICKY_07_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_07_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -13879,7 +13897,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 577, // doomednum S_FLICKY_08_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_08_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -13906,7 +13924,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 578, // doomednum S_FLICKY_09_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_09_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -13933,7 +13951,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 579, // doomednum S_FLICKY_10_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_10_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -13960,7 +13978,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 580, // doomednum S_FLICKY_11_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_11_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -13987,7 +14005,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 581, // doomednum S_FLICKY_12_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_12_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -14014,7 +14032,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 582, // doomednum S_FLICKY_13_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_13_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -14041,7 +14059,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 583, // doomednum S_FLICKY_14_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_14_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -14068,7 +14086,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 584, // doomednum S_FLICKY_15_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_15_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -14095,7 +14113,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 585, // doomednum S_FLICKY_16_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_FLICKY_16_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -14122,7 +14140,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 586, // doomednum S_SECRETFLICKY_01_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_SECRETFLICKY_01_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound @@ -14149,7 +14167,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 587, // doomednum S_SECRETFLICKY_02_OUT, // spawnstate 1000, // spawnhealth - S_NULL, // seestate + S_SECRETFLICKY_02_STAND, // seestate sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound diff --git a/src/info.h b/src/info.h index c9f7299d8..33ab6943f 100644 --- a/src/info.h +++ b/src/info.h @@ -2746,6 +2746,7 @@ typedef enum state S_FLICKY_01_FLAP1, S_FLICKY_01_FLAP2, S_FLICKY_01_FLAP3, + S_FLICKY_01_STAND, // Rabbit S_FLICKY_02_OUT, @@ -2753,6 +2754,7 @@ typedef enum state S_FLICKY_02_HOP, S_FLICKY_02_UP, S_FLICKY_02_DOWN, + S_FLICKY_02_STAND, // Chicken S_FLICKY_03_OUT, @@ -2761,6 +2763,7 @@ typedef enum state S_FLICKY_03_UP, S_FLICKY_03_FLAP1, S_FLICKY_03_FLAP2, + S_FLICKY_03_STAND, // Seal S_FLICKY_04_OUT, @@ -2772,6 +2775,7 @@ typedef enum state S_FLICKY_04_SWIM2, S_FLICKY_04_SWIM3, S_FLICKY_04_SWIM4, + S_FLICKY_04_STAND, // Pig S_FLICKY_05_OUT, @@ -2779,6 +2783,7 @@ typedef enum state S_FLICKY_05_HOP, S_FLICKY_05_UP, S_FLICKY_05_DOWN, + S_FLICKY_05_STAND, // Chipmunk S_FLICKY_06_OUT, @@ -2786,6 +2791,7 @@ typedef enum state S_FLICKY_06_HOP, S_FLICKY_06_UP, S_FLICKY_06_DOWN, + S_FLICKY_06_STAND, // Penguin S_FLICKY_07_OUT, @@ -2800,6 +2806,7 @@ typedef enum state S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM2, S_FLICKY_07_SWIM3, + S_FLICKY_07_STAND, // Fish S_FLICKY_08_OUT, @@ -2813,6 +2820,7 @@ typedef enum state S_FLICKY_08_SWIM2, S_FLICKY_08_SWIM3, S_FLICKY_08_SWIM4, + S_FLICKY_08_STAND, // Ram S_FLICKY_09_OUT, @@ -2820,11 +2828,13 @@ typedef enum state S_FLICKY_09_HOP, S_FLICKY_09_UP, S_FLICKY_09_DOWN, + S_FLICKY_09_STAND, // Puffin S_FLICKY_10_OUT, S_FLICKY_10_FLAP1, S_FLICKY_10_FLAP2, + S_FLICKY_10_STAND, // Cow S_FLICKY_11_OUT, @@ -2832,6 +2842,7 @@ typedef enum state S_FLICKY_11_RUN1, S_FLICKY_11_RUN2, S_FLICKY_11_RUN3, + S_FLICKY_11_STAND, // Rat S_FLICKY_12_OUT, @@ -2839,6 +2850,7 @@ typedef enum state S_FLICKY_12_RUN1, S_FLICKY_12_RUN2, S_FLICKY_12_RUN3, + S_FLICKY_12_STAND, // Bear S_FLICKY_13_OUT, @@ -2846,12 +2858,14 @@ typedef enum state S_FLICKY_13_HOP, S_FLICKY_13_UP, S_FLICKY_13_DOWN, + S_FLICKY_13_STAND, // Dove S_FLICKY_14_OUT, S_FLICKY_14_FLAP1, S_FLICKY_14_FLAP2, S_FLICKY_14_FLAP3, + S_FLICKY_14_STAND, // Cat S_FLICKY_15_OUT, @@ -2859,12 +2873,14 @@ typedef enum state S_FLICKY_15_HOP, S_FLICKY_15_UP, S_FLICKY_15_DOWN, + S_FLICKY_15_STAND, // Canary S_FLICKY_16_OUT, S_FLICKY_16_FLAP1, S_FLICKY_16_FLAP2, S_FLICKY_16_FLAP3, + S_FLICKY_16_STAND, // Spider S_SECRETFLICKY_01_OUT, @@ -2872,12 +2888,14 @@ typedef enum state S_SECRETFLICKY_01_HOP, S_SECRETFLICKY_01_UP, S_SECRETFLICKY_01_DOWN, + S_SECRETFLICKY_01_STAND, // Bat S_SECRETFLICKY_02_OUT, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_FLAP2, S_SECRETFLICKY_02_FLAP3, + S_SECRETFLICKY_02_STAND, // Fan S_FAN, From abbc7631cd5df55d1ed1635e4557723f71310a93 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 01:49:24 -0400 Subject: [PATCH 046/573] Flicky stand implementation by MTF_AMBUSH * MTF_OBJECTSPECIAL: Set no gravity for flicky --- src/p_enemy.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 7c1540ce4..6eadefb9c 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -11040,7 +11040,17 @@ void A_FlickyCheck(mobj_t *actor) if (LUA_CallAction("A_FlickyCheck", actor)) return; #endif - if (locvar2 && P_MobjFlip(actor)*actor->momz < 1) + if (actor->spawnpoint && (actor->spawnpoint->options & MTF_AMBUSH)) + { + if (actor->spawnpoint->options & MTF_OBJECTSPECIAL) + { + actor->momz = 0; + actor->flags |= MF_NOGRAVITY; + } + actor->flags |= MF_NOCLIP | MF_NOBLOCKMAP | MF_SCENERY; + P_SetMobjState(actor, mobjinfo[actor->type].seestate); + } + else if (locvar2 && P_MobjFlip(actor)*actor->momz < 1) P_SetMobjState(actor, locvar2); else if (locvar1 && ((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) || ((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz))) @@ -11065,7 +11075,17 @@ void A_FlickyHeightCheck(mobj_t *actor) if (LUA_CallAction("A_FlickyHeightCheck", actor)) return; #endif - if (locvar1 && actor->target && P_MobjFlip(actor)*actor->momz < 1 + if (actor->spawnpoint && (actor->spawnpoint->options & MTF_AMBUSH)) + { + if (actor->spawnpoint->options & MTF_OBJECTSPECIAL) + { + actor->momz = 0; + actor->flags |= MF_NOGRAVITY; + } + actor->flags |= MF_NOCLIP | MF_NOBLOCKMAP | MF_SCENERY; + P_SetMobjState(actor, mobjinfo[actor->type].seestate); + } + else if (locvar1 && actor->target && P_MobjFlip(actor)*actor->momz < 1 && ((P_MobjFlip(actor)*((actor->z + actor->height/2) - (actor->target->z + actor->target->height/2)) < locvar2) || (actor->z - actor->height < actor->floorz) || (actor->z + 2*actor->height > actor->ceilingz))) P_SetMobjState(actor, locvar1); From 9127a835c1eabec3747c3fc23e5929b010176c8e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 02:27:25 -0400 Subject: [PATCH 047/573] Flicky stand animation fixes --- src/info.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/info.c b/src/info.c index 8ebbdc131..aad7a74d4 100644 --- a/src/info.c +++ b/src/info.c @@ -2638,7 +2638,7 @@ state_t states[NUMSTATES] = {SPR_FL01, 1, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP2}, // S_FLICKY_01_FLAP1 {SPR_FL01, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP3}, // S_FLICKY_01_FLAP2 {SPR_FL01, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP1}, // S_FLICKY_01_FLAP3 - {SPR_FL01, FF_ANIMATE, -1, {NULL}, 3, 3, S_NULL}, // S_FLICKY_01_STAND + {SPR_FL01, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_01_STAND // Rabbit {SPR_FL02, 0, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_OUT}, // S_FLICKY_02_OUT @@ -2646,7 +2646,7 @@ state_t states[NUMSTATES] = {SPR_FL02, 1, 1, {A_FlickyHop}, 6*FRACUNIT, 4*FRACUNIT, S_FLICKY_02_UP}, // S_FLICKY_02_HOP {SPR_FL02, 2, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, S_FLICKY_02_DOWN, S_FLICKY_02_UP}, // S_FLICKY_02_UP {SPR_FL02, 3, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_DOWN}, // S_FLICKY_02_DOWN - {SPR_FL02, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_FLICKY_02_STAND + {SPR_FL02, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_02_STAND // Chicken {SPR_FL03, 0, 2, {A_FlickyCheck}, S_FLICKY_03_AIM, S_FLICKY_03_FLAP1, S_FLICKY_03_OUT}, // S_FLICKY_03_OUT @@ -2655,7 +2655,7 @@ state_t states[NUMSTATES] = {SPR_FL03, 2, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, S_FLICKY_03_FLAP1, S_FLICKY_03_UP}, // S_FLICKY_03_UP {SPR_FL03, 3, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP2}, // S_FLICKY_03_FLAP1 {SPR_FL03, 4, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP1}, // S_FLICKY_03_FLAP2 - {SPR_FL03, FF_ANIMATE, -1, {NULL}, 4, 2, S_NULL}, // S_FLICKY_03_STAND + {SPR_FL03, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_03_STAND // Seal {SPR_FL04, 0, 2, {A_FlickyCheck}, S_FLICKY_04_AIM, 0, S_FLICKY_04_OUT}, // S_FLICKY_04_OUT @@ -2667,7 +2667,7 @@ state_t states[NUMSTATES] = {SPR_FL04, 4, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM3}, // S_FLICKY_04_SWIM2 {SPR_FL04, 3, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM4}, // S_FLICKY_04_SWIM3 {SPR_FL04, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM1}, // S_FLICKY_04_SWIM4 - {SPR_FL04, FF_ANIMATE, -1, {NULL}, 5, 4, S_NULL}, // S_FLICKY_04_STAND + {SPR_FL04, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_04_STAND // Pig {SPR_FL05, 0, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_OUT}, // S_FLICKY_05_OUT @@ -2675,7 +2675,7 @@ state_t states[NUMSTATES] = {SPR_FL05, 1, 1, {A_FlickyHop}, 4*FRACUNIT, 3*FRACUNIT, S_FLICKY_05_UP}, // S_FLICKY_05_HOP {SPR_FL05, 2, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, S_FLICKY_05_DOWN, S_FLICKY_05_UP}, // S_FLICKY_05_UP {SPR_FL05, 3, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_DOWN}, // S_FLICKY_05_DOWN - {SPR_FL05, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_FLICKY_05_STAND + {SPR_FL05, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_05_STAND // Chipmunk {SPR_FL06, 0, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_OUT}, // S_FLICKY_06_OUT @@ -2683,7 +2683,7 @@ state_t states[NUMSTATES] = {SPR_FL06, 1, 1, {A_FlickyHop}, 5*FRACUNIT, 6*FRACUNIT, S_FLICKY_06_UP}, // S_FLICKY_06_HOP {SPR_FL06, 2, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, S_FLICKY_06_DOWN, S_FLICKY_06_UP}, // S_FLICKY_06_UP {SPR_FL06, 3, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_DOWN}, // S_FLICKY_06_DOWN - {SPR_FL06, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_FLICKY_06_STAND + {SPR_FL06, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_06_STAND // Penguin {SPR_FL07, 0, 2, {A_FlickyCheck}, S_FLICKY_07_AIML, 0, S_FLICKY_07_OUT}, // S_FLICKY_07_OUT @@ -2698,7 +2698,7 @@ state_t states[NUMSTATES] = {SPR_FL07, 4, 4, {A_FlickyFly}, 3*FRACUNIT, 72*FRACUNIT, S_FLICKY_07_SWIM2}, // S_FLICKY_07_SWIM1 {SPR_FL07, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM2 {SPR_FL07, 6, 4, {A_FlickyCoast}, 2*FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM3 - {SPR_FL07, FF_ANIMATE, -1, {NULL}, 6, 4, S_NULL}, // S_FLICKY_07_STAND + {SPR_FL07, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_07_STAND // Fish {SPR_FL08, 0, 2, {A_FlickyCheck}, S_FLICKY_08_AIM, 0, S_FLICKY_08_OUT}, // S_FLICKY_08_OUT @@ -2720,13 +2720,13 @@ state_t states[NUMSTATES] = {SPR_FL09, 1, 1, {A_FlickyHop}, 7*FRACUNIT, 2*FRACUNIT, S_FLICKY_09_UP}, // S_FLICKY_09_HOP {SPR_FL09, 2, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, S_FLICKY_09_DOWN, S_FLICKY_09_UP}, // S_FLICKY_09_UP {SPR_FL09, 3, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, 0, S_FLICKY_09_DOWN}, // S_FLICKY_09_DOWN - {SPR_FL09, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_FLICKY_09_STAND + {SPR_FL09, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_09_STAND // Puffin {SPR_FL10, 0, 2, {A_FlickyCheck}, S_FLICKY_10_FLAP1, S_FLICKY_10_FLAP1, S_FLICKY_10_OUT}, // S_FLICKY_10_OUT {SPR_FL10, 1, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP2}, // S_FLICKY_10_FLAP1 {SPR_FL10, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP1}, // S_FLICKY_10_FLAP2 - {SPR_FL10, FF_ANIMATE, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_10_STAND + {SPR_FL10, FF_ANIMATE|1, -1, {NULL}, 1, 3, S_NULL}, // S_FLICKY_10_STAND // Cow {SPR_FL11, 0, 2, {A_FlickyCheck}, S_FLICKY_11_AIM, 0, S_FLICKY_11_OUT}, // S_FLICKY_11_OUT @@ -2734,7 +2734,7 @@ state_t states[NUMSTATES] = {SPR_FL11, 1, 3, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_RUN2}, // S_FLICKY_11_RUN1 {SPR_FL11, 2, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_RUN3}, // S_FLICKY_11_RUN2 {SPR_FL11, 3, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_AIM}, // S_FLICKY_11_RUN3 - {SPR_FL11, FF_ANIMATE, -1, {NULL}, 3, 4, S_NULL}, // S_FLICKY_11_STAND + {SPR_FL11, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_11_STAND // Rat {SPR_FL12, 0, 2, {A_FlickyCheck}, S_FLICKY_12_AIM, 0, S_FLICKY_12_OUT}, // S_FLICKY_12_OUT @@ -2742,7 +2742,7 @@ state_t states[NUMSTATES] = {SPR_FL12, 1, 2, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_RUN2}, // S_FLICKY_12_RUN1 {SPR_FL12, 2, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_RUN3}, // S_FLICKY_12_RUN2 {SPR_FL12, 3, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_AIM}, // S_FLICKY_12_RUN3 - {SPR_FL12, FF_ANIMATE, -1, {NULL}, 3, 3, S_NULL}, // S_FLICKY_12_STAND + {SPR_FL12, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_12_STAND // Bear {SPR_FL13, 0, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_OUT}, // S_FLICKY_13_OUT @@ -2750,14 +2750,14 @@ state_t states[NUMSTATES] = {SPR_FL13, 1, 1, {A_FlickyHop}, 5*FRACUNIT, 3*FRACUNIT, S_FLICKY_13_UP}, // S_FLICKY_13_HOP {SPR_FL13, 2, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, S_FLICKY_13_DOWN, S_FLICKY_13_UP}, // S_FLICKY_13_UP {SPR_FL13, 3, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_DOWN}, // S_FLICKY_13_DOWN - {SPR_FL13, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_FLICKY_13_STAND + {SPR_FL13, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_13_STAND // Dove {SPR_FL14, 0, 2, {A_FlickyCheck}, S_FLICKY_14_FLAP1, S_FLICKY_14_FLAP1, S_FLICKY_14_OUT}, // S_FLICKY_14_OUT {SPR_FL14, 1, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP2}, // S_FLICKY_14_FLAP1 {SPR_FL14, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP3}, // S_FLICKY_14_FLAP2 {SPR_FL14, 3, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP1}, // S_FLICKY_14_FLAP3 - {SPR_FL14, FF_ANIMATE, -1, {NULL}, 3, 3, S_NULL}, // S_FLICKY_14_STAND + {SPR_FL14, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_14_STAND // Cat {SPR_FL15, 0, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_OUT}, // S_FLICKY_15_OUT @@ -2765,14 +2765,14 @@ state_t states[NUMSTATES] = {SPR_FL15, 1, 1, {A_FlickyFlounder}, 2*FRACUNIT, 6*FRACUNIT, S_FLICKY_15_UP}, // S_FLICKY_15_HOP {SPR_FL15, 2, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, S_FLICKY_15_DOWN, S_FLICKY_15_UP}, // S_FLICKY_15_UP {SPR_FL15, 3, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_DOWN}, // S_FLICKY_15_DOWN - {SPR_FL15, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_FLICKY_15_STAND + {SPR_FL15, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_15_STAND // Canary {SPR_FL16, 0, 2, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_OUT}, // S_FLICKY_16_OUT {SPR_FL16, 1, 3, {A_FlickyFly}, 4*FRACUNIT, 8*FRACUNIT, S_FLICKY_16_FLAP2}, // S_FLICKY_16_FLAP1 {SPR_FL16, 2, 3, {A_SetObjectFlags}, MF_NOGRAVITY, 1, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP2 {SPR_FL16, 3, 3, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP3 - {SPR_FL16, FF_ANIMATE, -1, {NULL}, 3, 3, S_NULL}, // S_FLICKY_16_STAND + {SPR_FL16, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_16_STAND // Spider {SPR_FS01, 0, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_OUT}, // S_SECRETFLICKY_01_OUT @@ -2780,14 +2780,14 @@ state_t states[NUMSTATES] = {SPR_FS01, 1, 1, {A_FlickyFlounder}, 2*FRACUNIT, 6*FRACUNIT, S_SECRETFLICKY_01_UP}, // S_SECRETFLICKY_01_HOP {SPR_FS01, 2, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, S_SECRETFLICKY_01_DOWN, S_SECRETFLICKY_01_UP}, // S_SECRETFLICKY_01_UP {SPR_FS01, 3, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_DOWN}, // S_SECRETFLICKY_01_DOWN - {SPR_FS01, FF_ANIMATE, -1, {NULL}, 3, 2, S_NULL}, // S_SECRETFLICKY_01_STAND + {SPR_FS01, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_SECRETFLICKY_01_STAND // Bat {SPR_FS02, 0, 2, {A_FlickyHeightCheck}, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_OUT}, // S_SECRETFLICKY_02_OUT {SPR_FS02, 1, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP2}, // S_SECRETFLICKY_02_FLAP1 {SPR_FS02, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP3}, // S_SECRETFLICKY_02_FLAP2 {SPR_FS02, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP1}, // S_SECRETFLICKY_02_FLAP3 - {SPR_FS02, FF_ANIMATE, -1, {NULL}, 3, 3, S_NULL}, // S_SECRETFLICKY_02_STAND + {SPR_FS02, FF_ANIMATE|1, -1, {NULL}, 2, 2, S_NULL}, // S_SECRETFLICKY_02_STAND // Fan {SPR_FANS, 0, 1, {A_FanBubbleSpawn}, 2048, 0, S_FAN2}, // S_FAN From f7c80f39801d8347f1d006173b5a70dac3adba68 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 02:55:22 -0400 Subject: [PATCH 048/573] Make standing flickies bounce if MTF_AMBUSH and not MTF_OBJECTSPECIAL --- src/p_mobj.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index be373fbf4..4e1c18344 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7089,6 +7089,34 @@ void P_MobjThinker(mobj_t *mobj) S_StartSound(flame, sfx_fire); } break; + case MT_FLICKY_01: + case MT_FLICKY_02: + case MT_FLICKY_03: + case MT_FLICKY_04: + case MT_FLICKY_05: + case MT_FLICKY_06: + case MT_FLICKY_07: + case MT_FLICKY_08: + case MT_FLICKY_09: + case MT_FLICKY_10: + case MT_FLICKY_11: + case MT_FLICKY_12: + case MT_FLICKY_13: + case MT_FLICKY_14: + case MT_FLICKY_15: + case MT_FLICKY_16: + case MT_SECRETFLICKY_01: + case MT_SECRETFLICKY_02: + if (mobj->spawnpoint + && (mobj->spawnpoint->options & MTF_AMBUSH) + && !(mobj->spawnpoint->options & MTF_OBJECTSPECIAL)) + { + if (!(mobj->flags2 & MF2_OBJECTFLIP) && mobj->z <= mobj->floorz) + mobj->momz = 7*FRACUNIT; + else if ((mobj->flags2 & MF2_OBJECTFLIP) && mobj->z >= mobj->ceilingz - mobj->height) + mobj->momz = -7*FRACUNIT; + } + break; case MT_SEED: if (P_MobjFlip(mobj)*mobj->momz < mobj->info->speed) mobj->momz = P_MobjFlip(mobj)*mobj->info->speed; From 904ff6fccb4e46b34955327e22068389feca00d1 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 04:19:18 -0400 Subject: [PATCH 049/573] Choose Flicky Fish Color by Thing Parameter --- src/p_mobj.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index 4e1c18344..1261091da 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10435,6 +10435,38 @@ ML_EFFECT4 : Don't clip inside the ground break; } + case MT_FLICKY_08: + if (mthing->extrainfo == 1) + mobj->color = SKINCOLOR_RED; + else if (mthing->extrainfo == 2) + mobj->color = SKINCOLOR_CYAN; + else if (mthing->extrainfo == 3) + mobj->color = SKINCOLOR_BLUE; + else if (mthing->extrainfo == 4) + mobj->color = SKINCOLOR_VAPOR; + else if (mthing->extrainfo == 5) + mobj->color = SKINCOLOR_PURPLE; + else if (mthing->extrainfo == 6) + mobj->color = SKINCOLOR_BUBBLEGUM; + else if (mthing->extrainfo == 7) + mobj->color = SKINCOLOR_NEON; + else if (mthing->extrainfo == 8) + mobj->color = SKINCOLOR_BLACK; + else if (mthing->extrainfo == 9) + mobj->color = SKINCOLOR_BEIGE; + else if (mthing->extrainfo == 10) + mobj->color = SKINCOLOR_LAVENDER; + else if (mthing->extrainfo == 11) + mobj->color = SKINCOLOR_RUBY; + else if (mthing->extrainfo == 12) + mobj->color = SKINCOLOR_SALMON; + else if (mthing->extrainfo == 13) + mobj->color = SKINCOLOR_SUNSET; + else if (mthing->extrainfo == 14) + mobj->color = SKINCOLOR_ORANGE; + else if (mthing->extrainfo == 15) + mobj->color = SKINCOLOR_YELLOW; + break; case MT_PARTICLEGEN: { fixed_t radius, speed; From 38eae01400c3b2b97f6a05a8388958a042cf3db7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 12:08:06 -0400 Subject: [PATCH 050/573] MT_FLICKY_x_CENTER defs --- src/dehacked.c | 36 ++++ src/info.c | 540 +++++++++++++++++++++++++++++++++++++++++++++++-- src/info.h | 36 ++++ 3 files changed, 594 insertions(+), 18 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 37a4a08c9..26361dab1 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -5394,6 +5394,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_01_FLAP2", "S_FLICKY_01_FLAP3", "S_FLICKY_01_STAND", + "S_FLICKY_01_CENTER", // Rabbit "S_FLICKY_02_OUT", @@ -5402,6 +5403,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_02_UP", "S_FLICKY_02_DOWN", "S_FLICKY_02_STAND", + "S_FLICKY_02_CENTER", // Chicken "S_FLICKY_03_OUT", @@ -5411,6 +5413,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_03_FLAP1", "S_FLICKY_03_FLAP2", "S_FLICKY_03_STAND", + "S_FLICKY_03_CENTER", // Seal "S_FLICKY_04_OUT", @@ -5423,6 +5426,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_04_SWIM3", "S_FLICKY_04_SWIM4", "S_FLICKY_04_STAND", + "S_FLICKY_04_CENTER", // Pig "S_FLICKY_05_OUT", @@ -5431,6 +5435,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_05_UP", "S_FLICKY_05_DOWN", "S_FLICKY_05_STAND", + "S_FLICKY_05_CENTER", // Chipmunk "S_FLICKY_06_OUT", @@ -5439,6 +5444,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_06_UP", "S_FLICKY_06_DOWN", "S_FLICKY_06_STAND", + "S_FLICKY_06_CENTER", // Penguin "S_FLICKY_07_OUT", @@ -5454,6 +5460,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_07_SWIM2", "S_FLICKY_07_SWIM3", "S_FLICKY_07_STAND", + "S_FLICKY_07_CENTER", // Fish "S_FLICKY_08_OUT", @@ -5468,6 +5475,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_08_SWIM3", "S_FLICKY_08_SWIM4", "S_FLICKY_08_STAND", + "S_FLICKY_08_CENTER", // Ram "S_FLICKY_09_OUT", @@ -5476,12 +5484,14 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_09_UP", "S_FLICKY_09_DOWN", "S_FLICKY_09_STAND", + "S_FLICKY_09_CENTER", // Puffin "S_FLICKY_10_OUT", "S_FLICKY_10_FLAP1", "S_FLICKY_10_FLAP2", "S_FLICKY_10_STAND", + "S_FLICKY_10_CENTER", // Cow "S_FLICKY_11_OUT", @@ -5490,6 +5500,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_11_RUN2", "S_FLICKY_11_RUN3", "S_FLICKY_11_STAND", + "S_FLICKY_11_CENTER", // Rat "S_FLICKY_12_OUT", @@ -5498,6 +5509,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_12_RUN2", "S_FLICKY_12_RUN3", "S_FLICKY_12_STAND", + "S_FLICKY_12_CENTER", // Bear "S_FLICKY_13_OUT", @@ -5506,6 +5518,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_13_UP", "S_FLICKY_13_DOWN", "S_FLICKY_13_STAND", + "S_FLICKY_13_CENTER", // Dove "S_FLICKY_14_OUT", @@ -5513,6 +5526,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_14_FLAP2", "S_FLICKY_14_FLAP3", "S_FLICKY_14_STAND", + "S_FLICKY_14_CENTER", // Cat "S_FLICKY_15_OUT", @@ -5521,6 +5535,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_15_UP", "S_FLICKY_15_DOWN", "S_FLICKY_15_STAND", + "S_FLICKY_15_CENTER", // Canary "S_FLICKY_16_OUT", @@ -5528,6 +5543,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FLICKY_16_FLAP2", "S_FLICKY_16_FLAP3", "S_FLICKY_16_STAND", + "S_FLICKY_16_CENTER", // Spider "S_SECRETFLICKY_01_OUT", @@ -5536,6 +5552,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_SECRETFLICKY_01_UP", "S_SECRETFLICKY_01_DOWN", "S_SECRETFLICKY_01_STAND", + "S_SECRETFLICKY_01_CENTER", // Bat "S_SECRETFLICKY_02_OUT", @@ -5543,6 +5560,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_SECRETFLICKY_02_FLAP2", "S_SECRETFLICKY_02_FLAP3", "S_SECRETFLICKY_02_STAND", + "S_SECRETFLICKY_02_CENTER", // Fan "S_FAN", @@ -6739,23 +6757,41 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s // Flickies "MT_FLICKY_01", // Bluebird + "MT_FLICKY_01_CENTER", "MT_FLICKY_02", // Rabbit + "MT_FLICKY_02_CENTER", "MT_FLICKY_03", // Chicken + "MT_FLICKY_03_CENTER", "MT_FLICKY_04", // Seal + "MT_FLICKY_04_CENTER", "MT_FLICKY_05", // Pig + "MT_FLICKY_05_CENTER", "MT_FLICKY_06", // Chipmunk + "MT_FLICKY_06_CENTER", "MT_FLICKY_07", // Penguin + "MT_FLICKY_07_CENTER", "MT_FLICKY_08", // Fish + "MT_FLICKY_08_CENTER", "MT_FLICKY_09", // Ram + "MT_FLICKY_09_CENTER", "MT_FLICKY_10", // Puffin + "MT_FLICKY_10_CENTER", "MT_FLICKY_11", // Cow + "MT_FLICKY_11_CENTER", "MT_FLICKY_12", // Rat + "MT_FLICKY_12_CENTER", "MT_FLICKY_13", // Bear + "MT_FLICKY_13_CENTER", "MT_FLICKY_14", // Dove + "MT_FLICKY_14_CENTER", "MT_FLICKY_15", // Cat + "MT_FLICKY_15_CENTER", "MT_FLICKY_16", // Canary + "MT_FLICKY_16_CENTER", "MT_SECRETFLICKY_01", // Spider + "MT_SECRETFLICKY_01_CENTER", "MT_SECRETFLICKY_02", // Bat + "MT_SECRETFLICKY_02_CENTER", "MT_SEED", // Environmental Effects diff --git a/src/info.c b/src/info.c index aad7a74d4..f3828caf1 100644 --- a/src/info.c +++ b/src/info.c @@ -2639,6 +2639,7 @@ state_t states[NUMSTATES] = {SPR_FL01, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP3}, // S_FLICKY_01_FLAP2 {SPR_FL01, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP1}, // S_FLICKY_01_FLAP3 {SPR_FL01, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_01_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_01, 128*FRACUNIT, S_FLICKY_01_CENTER}, // S_FLICKY_01_CENTER // Rabbit {SPR_FL02, 0, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_OUT}, // S_FLICKY_02_OUT @@ -2647,6 +2648,7 @@ state_t states[NUMSTATES] = {SPR_FL02, 2, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, S_FLICKY_02_DOWN, S_FLICKY_02_UP}, // S_FLICKY_02_UP {SPR_FL02, 3, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_DOWN}, // S_FLICKY_02_DOWN {SPR_FL02, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_02_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_02, 128*FRACUNIT, S_FLICKY_02_CENTER}, // S_FLICKY_02_CENTER // Chicken {SPR_FL03, 0, 2, {A_FlickyCheck}, S_FLICKY_03_AIM, S_FLICKY_03_FLAP1, S_FLICKY_03_OUT}, // S_FLICKY_03_OUT @@ -2656,6 +2658,7 @@ state_t states[NUMSTATES] = {SPR_FL03, 3, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP2}, // S_FLICKY_03_FLAP1 {SPR_FL03, 4, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP1}, // S_FLICKY_03_FLAP2 {SPR_FL03, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_03_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_03, 128*FRACUNIT, S_FLICKY_03_CENTER}, // S_FLICKY_03_CENTER // Seal {SPR_FL04, 0, 2, {A_FlickyCheck}, S_FLICKY_04_AIM, 0, S_FLICKY_04_OUT}, // S_FLICKY_04_OUT @@ -2668,6 +2671,7 @@ state_t states[NUMSTATES] = {SPR_FL04, 3, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM4}, // S_FLICKY_04_SWIM3 {SPR_FL04, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM1}, // S_FLICKY_04_SWIM4 {SPR_FL04, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_04_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_04, 128*FRACUNIT, S_FLICKY_04_CENTER}, // S_FLICKY_04_CENTER // Pig {SPR_FL05, 0, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_OUT}, // S_FLICKY_05_OUT @@ -2676,6 +2680,7 @@ state_t states[NUMSTATES] = {SPR_FL05, 2, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, S_FLICKY_05_DOWN, S_FLICKY_05_UP}, // S_FLICKY_05_UP {SPR_FL05, 3, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_DOWN}, // S_FLICKY_05_DOWN {SPR_FL05, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_05_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_05, 128*FRACUNIT, S_FLICKY_05_CENTER}, // S_FLICKY_05_CENTER // Chipmunk {SPR_FL06, 0, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_OUT}, // S_FLICKY_06_OUT @@ -2684,6 +2689,7 @@ state_t states[NUMSTATES] = {SPR_FL06, 2, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, S_FLICKY_06_DOWN, S_FLICKY_06_UP}, // S_FLICKY_06_UP {SPR_FL06, 3, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_DOWN}, // S_FLICKY_06_DOWN {SPR_FL06, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_06_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_06, 128*FRACUNIT, S_FLICKY_06_CENTER}, // S_FLICKY_06_CENTER // Penguin {SPR_FL07, 0, 2, {A_FlickyCheck}, S_FLICKY_07_AIML, 0, S_FLICKY_07_OUT}, // S_FLICKY_07_OUT @@ -2699,6 +2705,7 @@ state_t states[NUMSTATES] = {SPR_FL07, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM2 {SPR_FL07, 6, 4, {A_FlickyCoast}, 2*FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM3 {SPR_FL07, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_07_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_07, 128*FRACUNIT, S_FLICKY_07_CENTER}, // S_FLICKY_07_CENTER // Fish {SPR_FL08, 0, 2, {A_FlickyCheck}, S_FLICKY_08_AIM, 0, S_FLICKY_08_OUT}, // S_FLICKY_08_OUT @@ -2713,6 +2720,7 @@ state_t states[NUMSTATES] = {SPR_FL08, 0, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_08_SWIM1, S_FLICKY_08_SWIM4}, // S_FLICKY_08_SWIM3 {SPR_FL08, 2, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_08_SWIM1, S_FLICKY_08_SWIM4}, // S_FLICKY_08_SWIM4 {SPR_FL08, FF_ANIMATE, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_08_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_08, 128*FRACUNIT, S_FLICKY_08_CENTER}, // S_FLICKY_08_CENTER // Ram {SPR_FL09, 0, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, 0, S_FLICKY_09_OUT}, // S_FLICKY_09_OUT @@ -2721,12 +2729,14 @@ state_t states[NUMSTATES] = {SPR_FL09, 2, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, S_FLICKY_09_DOWN, S_FLICKY_09_UP}, // S_FLICKY_09_UP {SPR_FL09, 3, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, 0, S_FLICKY_09_DOWN}, // S_FLICKY_09_DOWN {SPR_FL09, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_09_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_09, 128*FRACUNIT, S_FLICKY_09_CENTER}, // S_FLICKY_09_CENTER // Puffin {SPR_FL10, 0, 2, {A_FlickyCheck}, S_FLICKY_10_FLAP1, S_FLICKY_10_FLAP1, S_FLICKY_10_OUT}, // S_FLICKY_10_OUT {SPR_FL10, 1, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP2}, // S_FLICKY_10_FLAP1 {SPR_FL10, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP1}, // S_FLICKY_10_FLAP2 {SPR_FL10, FF_ANIMATE|1, -1, {NULL}, 1, 3, S_NULL}, // S_FLICKY_10_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_10, 128*FRACUNIT, S_FLICKY_10_CENTER}, // S_FLICKY_10_CENTER // Cow {SPR_FL11, 0, 2, {A_FlickyCheck}, S_FLICKY_11_AIM, 0, S_FLICKY_11_OUT}, // S_FLICKY_11_OUT @@ -2735,6 +2745,7 @@ state_t states[NUMSTATES] = {SPR_FL11, 2, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_RUN3}, // S_FLICKY_11_RUN2 {SPR_FL11, 3, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_AIM}, // S_FLICKY_11_RUN3 {SPR_FL11, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_11_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_11, 128*FRACUNIT, S_FLICKY_11_CENTER}, // S_FLICKY_11_CENTER // Rat {SPR_FL12, 0, 2, {A_FlickyCheck}, S_FLICKY_12_AIM, 0, S_FLICKY_12_OUT}, // S_FLICKY_12_OUT @@ -2743,6 +2754,7 @@ state_t states[NUMSTATES] = {SPR_FL12, 2, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_RUN3}, // S_FLICKY_12_RUN2 {SPR_FL12, 3, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_AIM}, // S_FLICKY_12_RUN3 {SPR_FL12, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_12_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_12, 128*FRACUNIT, S_FLICKY_12_CENTER}, // S_FLICKY_12_CENTER // Bear {SPR_FL13, 0, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_OUT}, // S_FLICKY_13_OUT @@ -2751,6 +2763,7 @@ state_t states[NUMSTATES] = {SPR_FL13, 2, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, S_FLICKY_13_DOWN, S_FLICKY_13_UP}, // S_FLICKY_13_UP {SPR_FL13, 3, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_DOWN}, // S_FLICKY_13_DOWN {SPR_FL13, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_13_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_13, 128*FRACUNIT, S_FLICKY_13_CENTER}, // S_FLICKY_13_CENTER // Dove {SPR_FL14, 0, 2, {A_FlickyCheck}, S_FLICKY_14_FLAP1, S_FLICKY_14_FLAP1, S_FLICKY_14_OUT}, // S_FLICKY_14_OUT @@ -2758,6 +2771,7 @@ state_t states[NUMSTATES] = {SPR_FL14, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP3}, // S_FLICKY_14_FLAP2 {SPR_FL14, 3, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP1}, // S_FLICKY_14_FLAP3 {SPR_FL14, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_14_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_14, 128*FRACUNIT, S_FLICKY_14_CENTER}, // S_FLICKY_14_CENTER // Cat {SPR_FL15, 0, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_OUT}, // S_FLICKY_15_OUT @@ -2766,6 +2780,7 @@ state_t states[NUMSTATES] = {SPR_FL15, 2, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, S_FLICKY_15_DOWN, S_FLICKY_15_UP}, // S_FLICKY_15_UP {SPR_FL15, 3, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_DOWN}, // S_FLICKY_15_DOWN {SPR_FL15, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_15_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_15, 128*FRACUNIT, S_FLICKY_15_CENTER}, // S_FLICKY_15_CENTER // Canary {SPR_FL16, 0, 2, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_OUT}, // S_FLICKY_16_OUT @@ -2773,6 +2788,7 @@ state_t states[NUMSTATES] = {SPR_FL16, 2, 3, {A_SetObjectFlags}, MF_NOGRAVITY, 1, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP2 {SPR_FL16, 3, 3, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP3 {SPR_FL16, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_16_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_16, 128*FRACUNIT, S_FLICKY_16_CENTER}, // S_FLICKY_16_CENTER // Spider {SPR_FS01, 0, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_OUT}, // S_SECRETFLICKY_01_OUT @@ -2781,6 +2797,7 @@ state_t states[NUMSTATES] = {SPR_FS01, 2, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, S_SECRETFLICKY_01_DOWN, S_SECRETFLICKY_01_UP}, // S_SECRETFLICKY_01_UP {SPR_FS01, 3, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_DOWN}, // S_SECRETFLICKY_01_DOWN {SPR_FS01, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_SECRETFLICKY_01_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_01, 128*FRACUNIT, S_SECRETFLICKY_01_CENTER}, // S_SECRETFLICKY_01_CENTER // Bat {SPR_FS02, 0, 2, {A_FlickyHeightCheck}, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_OUT}, // S_SECRETFLICKY_02_OUT @@ -2788,6 +2805,7 @@ state_t states[NUMSTATES] = {SPR_FS02, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP3}, // S_SECRETFLICKY_02_FLAP2 {SPR_FS02, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP1}, // S_SECRETFLICKY_02_FLAP3 {SPR_FS02, FF_ANIMATE|1, -1, {NULL}, 2, 2, S_NULL}, // S_SECRETFLICKY_02_STAND + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_02, 128*FRACUNIT, S_SECRETFLICKY_02_CENTER}, // S_SECRETFLICKY_02_CENTER // Fan {SPR_FANS, 0, 1, {A_FanBubbleSpawn}, 2048, 0, S_FAN2}, // S_FAN @@ -13705,7 +13723,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = // Bluebird { // MT_FLICKY_01 - 570, // doomednum + -1, // doomednum S_FLICKY_01_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_01_STAND, // seestate @@ -13731,8 +13749,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_FLICKY_01_CENTER + 570, // doomednum + S_FLICKY_01_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_02 - 571, // doomednum + -1, // doomednum S_FLICKY_02_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_02_STAND, // seestate @@ -13758,8 +13803,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_FLICKY_02_CENTER + 571, // doomednum + S_FLICKY_02_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_03 - 572, // doomednum + -1, // doomednum S_FLICKY_03_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_03_STAND, // seestate @@ -13785,8 +13857,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_FLICKY_03_CENTER + 572, // doomednum + S_FLICKY_03_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_04 - 573, // doomednum + -1, // doomednum S_FLICKY_04_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_04_STAND, // seestate @@ -13812,8 +13911,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_FLICKY_04_CENTER + 573, // doomednum + S_FLICKY_04_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_05 - 574, // doomednum + -1, // doomednum S_FLICKY_05_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_05_STAND, // seestate @@ -13839,8 +13965,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_FLICKY_05_CENTER + 574, // doomednum + S_FLICKY_05_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_06 - 575, // doomednum + -1, // doomednum S_FLICKY_06_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_06_STAND, // seestate @@ -13866,8 +14019,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_FLICKY_06_CENTER + 575, // doomednum + S_FLICKY_06_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_07 - 576, // doomednum + -1, // doomednum S_FLICKY_07_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_07_STAND, // seestate @@ -13893,8 +14073,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_FLICKY_07_CENTER + 576, // doomednum + S_FLICKY_07_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_08 - 577, // doomednum + -1, // doomednum S_FLICKY_08_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_08_STAND, // seestate @@ -13920,8 +14127,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_FLICKY_08_CENTER + 577, // doomednum + S_FLICKY_08_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_09 - 578, // doomednum + -1, // doomednum S_FLICKY_09_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_09_STAND, // seestate @@ -13947,8 +14181,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_FLICKY_09_CENTER + 578, // doomednum + S_FLICKY_09_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_10 - 579, // doomednum + -1, // doomednum S_FLICKY_10_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_10_STAND, // seestate @@ -13974,8 +14235,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_FLICKY_10_CENTER + 579, // doomednum + S_FLICKY_10_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_11 - 580, // doomednum + -1, // doomednum S_FLICKY_11_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_11_STAND, // seestate @@ -14001,8 +14289,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_FLICKY_11_CENTER + 580, // doomednum + S_FLICKY_11_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_12 - 581, // doomednum + -1, // doomednum S_FLICKY_12_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_12_STAND, // seestate @@ -14028,8 +14343,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_FLICKY_12_CENTER + 581, // doomednum + S_FLICKY_12_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_13 - 582, // doomednum + -1, // doomednum S_FLICKY_13_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_13_STAND, // seestate @@ -14055,8 +14397,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_FLICKY_13_CENTER + 582, // doomednum + S_FLICKY_13_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_14 - 583, // doomednum + -1, // doomednum S_FLICKY_14_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_14_STAND, // seestate @@ -14082,8 +14451,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_FLICKY_14_CENTER + 583, // doomednum + S_FLICKY_14_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_15 - 584, // doomednum + -1, // doomednum S_FLICKY_15_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_15_STAND, // seestate @@ -14109,8 +14505,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_FLICKY_15_CENTER + 584, // doomednum + S_FLICKY_15_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_FLICKY_16 - 585, // doomednum + -1, // doomednum S_FLICKY_16_OUT, // spawnstate 1000, // spawnhealth S_FLICKY_16_STAND, // seestate @@ -14136,8 +14559,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_FLICKY_16_CENTER + 585, // doomednum + S_FLICKY_16_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_SECRETFLICKY_01 - 586, // doomednum + -1, // doomednum S_SECRETFLICKY_01_OUT, // spawnstate 1000, // spawnhealth S_SECRETFLICKY_01_STAND, // seestate @@ -14163,8 +14613,35 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_SECRETFLICKY_01_CENTER + 586, // doomednum + S_SECRETFLICKY_01_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_SECRETFLICKY_02 - 587, // doomednum + -1, // doomednum S_SECRETFLICKY_02_OUT, // spawnstate 1000, // spawnhealth S_SECRETFLICKY_02_STAND, // seestate @@ -14190,6 +14667,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_FLICKY_BUBBLE // raisestate }, + { // MT_SECRETFLICKY_02_CENTER + 587, // doomednum + S_SECRETFLICKY_02_CENTER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 8, // speed + 8*FRACUNIT, // radius + 20*FRACUNIT, // height + 0, // display offset + 16, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + { // MT_SEED -1, // doomednum S_SEED, // spawnstate diff --git a/src/info.h b/src/info.h index 33ab6943f..183e0218a 100644 --- a/src/info.h +++ b/src/info.h @@ -2747,6 +2747,7 @@ typedef enum state S_FLICKY_01_FLAP2, S_FLICKY_01_FLAP3, S_FLICKY_01_STAND, + S_FLICKY_01_CENTER, // Rabbit S_FLICKY_02_OUT, @@ -2755,6 +2756,7 @@ typedef enum state S_FLICKY_02_UP, S_FLICKY_02_DOWN, S_FLICKY_02_STAND, + S_FLICKY_02_CENTER, // Chicken S_FLICKY_03_OUT, @@ -2764,6 +2766,7 @@ typedef enum state S_FLICKY_03_FLAP1, S_FLICKY_03_FLAP2, S_FLICKY_03_STAND, + S_FLICKY_03_CENTER, // Seal S_FLICKY_04_OUT, @@ -2776,6 +2779,7 @@ typedef enum state S_FLICKY_04_SWIM3, S_FLICKY_04_SWIM4, S_FLICKY_04_STAND, + S_FLICKY_04_CENTER, // Pig S_FLICKY_05_OUT, @@ -2784,6 +2788,7 @@ typedef enum state S_FLICKY_05_UP, S_FLICKY_05_DOWN, S_FLICKY_05_STAND, + S_FLICKY_05_CENTER, // Chipmunk S_FLICKY_06_OUT, @@ -2792,6 +2797,7 @@ typedef enum state S_FLICKY_06_UP, S_FLICKY_06_DOWN, S_FLICKY_06_STAND, + S_FLICKY_06_CENTER, // Penguin S_FLICKY_07_OUT, @@ -2807,6 +2813,7 @@ typedef enum state S_FLICKY_07_SWIM2, S_FLICKY_07_SWIM3, S_FLICKY_07_STAND, + S_FLICKY_07_CENTER, // Fish S_FLICKY_08_OUT, @@ -2821,6 +2828,7 @@ typedef enum state S_FLICKY_08_SWIM3, S_FLICKY_08_SWIM4, S_FLICKY_08_STAND, + S_FLICKY_08_CENTER, // Ram S_FLICKY_09_OUT, @@ -2829,12 +2837,14 @@ typedef enum state S_FLICKY_09_UP, S_FLICKY_09_DOWN, S_FLICKY_09_STAND, + S_FLICKY_09_CENTER, // Puffin S_FLICKY_10_OUT, S_FLICKY_10_FLAP1, S_FLICKY_10_FLAP2, S_FLICKY_10_STAND, + S_FLICKY_10_CENTER, // Cow S_FLICKY_11_OUT, @@ -2843,6 +2853,7 @@ typedef enum state S_FLICKY_11_RUN2, S_FLICKY_11_RUN3, S_FLICKY_11_STAND, + S_FLICKY_11_CENTER, // Rat S_FLICKY_12_OUT, @@ -2851,6 +2862,7 @@ typedef enum state S_FLICKY_12_RUN2, S_FLICKY_12_RUN3, S_FLICKY_12_STAND, + S_FLICKY_12_CENTER, // Bear S_FLICKY_13_OUT, @@ -2859,6 +2871,7 @@ typedef enum state S_FLICKY_13_UP, S_FLICKY_13_DOWN, S_FLICKY_13_STAND, + S_FLICKY_13_CENTER, // Dove S_FLICKY_14_OUT, @@ -2866,6 +2879,7 @@ typedef enum state S_FLICKY_14_FLAP2, S_FLICKY_14_FLAP3, S_FLICKY_14_STAND, + S_FLICKY_14_CENTER, // Cat S_FLICKY_15_OUT, @@ -2874,6 +2888,7 @@ typedef enum state S_FLICKY_15_UP, S_FLICKY_15_DOWN, S_FLICKY_15_STAND, + S_FLICKY_15_CENTER, // Canary S_FLICKY_16_OUT, @@ -2881,6 +2896,7 @@ typedef enum state S_FLICKY_16_FLAP2, S_FLICKY_16_FLAP3, S_FLICKY_16_STAND, + S_FLICKY_16_CENTER, // Spider S_SECRETFLICKY_01_OUT, @@ -2889,6 +2905,7 @@ typedef enum state S_SECRETFLICKY_01_UP, S_SECRETFLICKY_01_DOWN, S_SECRETFLICKY_01_STAND, + S_SECRETFLICKY_01_CENTER, // Bat S_SECRETFLICKY_02_OUT, @@ -2896,6 +2913,7 @@ typedef enum state S_SECRETFLICKY_02_FLAP2, S_SECRETFLICKY_02_FLAP3, S_SECRETFLICKY_02_STAND, + S_SECRETFLICKY_02_CENTER, // Fan S_FAN, @@ -4112,23 +4130,41 @@ typedef enum mobj_type // Flickies MT_FLICKY_01, // Bluebird + MT_FLICKY_01_CENTER, MT_FLICKY_02, // Rabbit + MT_FLICKY_02_CENTER, MT_FLICKY_03, // Chicken + MT_FLICKY_03_CENTER, MT_FLICKY_04, // Seal + MT_FLICKY_04_CENTER, MT_FLICKY_05, // Pig + MT_FLICKY_05_CENTER, MT_FLICKY_06, // Chipmunk + MT_FLICKY_06_CENTER, MT_FLICKY_07, // Penguin + MT_FLICKY_07_CENTER, MT_FLICKY_08, // Fish + MT_FLICKY_08_CENTER, MT_FLICKY_09, // Ram + MT_FLICKY_09_CENTER, MT_FLICKY_10, // Puffin + MT_FLICKY_10_CENTER, MT_FLICKY_11, // Cow + MT_FLICKY_11_CENTER, MT_FLICKY_12, // Rat + MT_FLICKY_12_CENTER, MT_FLICKY_13, // Bear + MT_FLICKY_13_CENTER, MT_FLICKY_14, // Dove + MT_FLICKY_14_CENTER, MT_FLICKY_15, // Cat + MT_FLICKY_15_CENTER, MT_FLICKY_16, // Canary + MT_FLICKY_16_CENTER, MT_SECRETFLICKY_01, // Spider + MT_SECRETFLICKY_01_CENTER, MT_SECRETFLICKY_02, // Bat + MT_SECRETFLICKY_02_CENTER, MT_SEED, // Environmental Effects From 5eafebe4d46733393c35f7b7c19839d2c7ca8f37 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 13:35:36 -0400 Subject: [PATCH 051/573] A_FlickyCenter implementation - now Flickies can be attracted to players! * Changed default movement to attraction, vs. aimless * Flickies spawned from this will always have the FLICKY_CENTER mobj as its target * Use P_IsFlickyCenter to identify FLICKY_CENTER mobjs versus players * FLICKY_CENTER mobj tracer points to the spawned Flicky * Thanks toaster for the original code~~ --- src/info.h | 1 + src/p_enemy.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/p_local.h | 1 + src/p_mobj.c | 79 ++++++++++---------------------- 4 files changed, 145 insertions(+), 60 deletions(-) diff --git a/src/info.h b/src/info.h index 183e0218a..49c35deb8 100644 --- a/src/info.h +++ b/src/info.h @@ -216,6 +216,7 @@ void A_BrakLobShot(); void A_NapalmScatter(); void A_SpawnFreshCopy(); void A_FlickySpawn(); +void A_FlickyCenter(); void A_FlickyAim(); void A_FlickyFly(); void A_FlickySoar(); diff --git a/src/p_enemy.c b/src/p_enemy.c index 6eadefb9c..7eca785e0 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -243,6 +243,7 @@ void A_BrakLobShot(mobj_t *actor); void A_NapalmScatter(mobj_t *actor); void A_SpawnFreshCopy(mobj_t *actor); void A_FlickySpawn(mobj_t *actor); +void A_FlickyCenter(mobj_t *actor); void A_FlickyAim(mobj_t *actor); void A_FlickyFly(mobj_t *actor); void A_FlickySoar(mobj_t *actor); @@ -10774,6 +10775,105 @@ void A_FlickySpawn(mobj_t *actor) P_InternalFlickySpawn(actor, locvar1, ((locvar2) ? locvar2 : 8*FRACUNIT), true); } +// Internal Flicky color setting +void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo) +{ + UINT8 flickycolors[] = { + SKINCOLOR_RED, + SKINCOLOR_CYAN, + SKINCOLOR_BLUE, + SKINCOLOR_VAPOR, + SKINCOLOR_PURPLE, + SKINCOLOR_BUBBLEGUM, + SKINCOLOR_NEON, + SKINCOLOR_BLACK, + SKINCOLOR_BEIGE, + SKINCOLOR_LAVENDER, + SKINCOLOR_RUBY, + SKINCOLOR_SALMON, + SKINCOLOR_SUNSET, + SKINCOLOR_ORANGE, + SKINCOLOR_YELLOW, + }; + + if (extrainfo == 0) + actor->color = flickycolors[P_RandomKey(sizeof(flickycolors))]; + else if (extrainfo-1 < sizeof(flickycolors)) + actor->color = flickycolors[extrainfo-1]; +} + +// Function: A_FlickyCenter +// +// Description: Place flickies in-level. +// +// var1 = if 0, spawns random flicky based on level header. Else, spawns the designated thing type. +// var2 = maximum default distance away from spawn the flickies are allowed to travel. If angle != 0, then that's the radius. +// +// If MTF_EXTRA is flagged, Flickies move independently of a target. Else, move around the target. +// If MTF_OBJECTSPECIAL and NOT MTF_EXTRA are flagged, Angle sign determines direction of circular movement. +// If MTF_AMBUSH is flagged, Flickies hop in-place. +// If MTF_AMBUSH and MTF_OBJECTSPECIAL is flagged, Flickies stand in-place without gravity. +// +void A_FlickyCenter(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; +#ifdef HAVE_BLUA + if (LUA_CallAction("A_FlickyCenter", actor)) + return; +#endif + + if (!actor->tracer) + { + if (actor->spawnpoint && (actor->spawnpoint->options & MTF_EXTRA)) + { + actor->tracer = P_InternalFlickySpawn(actor, locvar1, 1, false); + P_SetTarget(&actor->tracer->target, actor); + actor->tracer->fuse = 0; // < 2*TICRATE means move aimlessly. + + if (!(actor->spawnpoint->options & MTF_AMBUSH)) + actor->tracer->angle = P_RandomKey(180)*ANG2; + } + else + { + actor->tracer = P_InternalFlickySpawn(actor, locvar1, 1, false); + P_SetTarget(&actor->tracer->target, actor); + actor->tracer->fuse = FRACUNIT; + + if (actor->spawnpoint + && (actor->spawnpoint->options & MTF_OBJECTSPECIAL) + && !(actor->spawnpoint->options & MTF_EXTRA)) + actor->tracer->movedir = actor->spawnpoint->angle >= 0 ? 1 : -1; + } + + if (locvar1 == MT_FLICKY_08 && actor->spawnpoint) + P_InternalFlickySetColor(actor->tracer, actor->spawnpoint->extrainfo); + + actor->extravalue1 = 0; + } + + if (actor->spawnpoint && !(actor->spawnpoint->options & MTF_EXTRA) && !(actor->spawnpoint->options & MTF_AMBUSH)) + { + actor->tracer->fuse = FRACUNIT; + + if (actor->spawnpoint->angle) + locvar2 = abs(actor->spawnpoint->angle)*FRACUNIT; + + P_LookForPlayers(actor, true, false, locvar2); + + if (actor->target && P_AproxDistance(actor->target->x - actor->spawnpoint->x*FRACUNIT, actor->target->y - actor->spawnpoint->y*FRACUNIT) < locvar2) + { + actor->extravalue1 = 1; + P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z); + } + else if(actor->extravalue1) + { + actor->extravalue1 = 0; + P_TeleportMove(actor, actor->spawnpoint->x*FRACUNIT, actor->spawnpoint->y*FRACUNIT, actor->spawnpoint->z*FRACUNIT); + } + } +} + // Internal Flicky bubbling function. void P_InternalFlickyBubble(mobj_t *actor) { @@ -10884,7 +10984,11 @@ void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fi if (actor->target && abs(chasez - actor->z) > targetdist) targetdist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); - if (actor->spawnpoint && (actor->spawnpoint->options & MTF_OBJECTSPECIAL)) + if (actor->target + && P_IsFlickyCenter(actor->target->type) + && actor->target->spawnpoint + && (actor->target->spawnpoint->options & MTF_OBJECTSPECIAL) + && (actor->target->spawnpoint->options & MTF_EXTRA)) vertangle = 0; else vertangle = (R_PointToAngle2(0, actor->z, targetdist, chasez) >> ANGLETOFINESHIFT) & FINEMASK; @@ -10900,6 +11004,8 @@ void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fi // var1 = how fast to fly // var2 = how far ahead the target should be considered // +// If MTF_EXTRA and MTF_OBJECTSPECIAL are flagged, Flicky will always fly at same Z height. +// void A_FlickyFly(mobj_t *actor) { INT32 locvar1 = var1; @@ -10920,6 +11026,8 @@ void A_FlickyFly(mobj_t *actor) // var1 = how fast to fly // var2 = how far ahead the target should be considered // +// If MTF_EXTRA and MTF_OBJECTSPECIAL are flagged, Flicky will always fly at same Z height. +// void A_FlickySoar(mobj_t *actor) { INT32 locvar1 = var1; @@ -11040,9 +11148,12 @@ void A_FlickyCheck(mobj_t *actor) if (LUA_CallAction("A_FlickyCheck", actor)) return; #endif - if (actor->spawnpoint && (actor->spawnpoint->options & MTF_AMBUSH)) + if (actor->target + && P_IsFlickyCenter(actor->target->type) + && actor->target->spawnpoint + && (actor->target->spawnpoint->options & MTF_AMBUSH)) { - if (actor->spawnpoint->options & MTF_OBJECTSPECIAL) + if (actor->target->spawnpoint->options & MTF_OBJECTSPECIAL) { actor->momz = 0; actor->flags |= MF_NOGRAVITY; @@ -11075,9 +11186,12 @@ void A_FlickyHeightCheck(mobj_t *actor) if (LUA_CallAction("A_FlickyHeightCheck", actor)) return; #endif - if (actor->spawnpoint && (actor->spawnpoint->options & MTF_AMBUSH)) + if (actor->target + && P_IsFlickyCenter(actor->target->type) + && actor->target->spawnpoint + && (actor->target->spawnpoint->options & MTF_AMBUSH)) { - if (actor->spawnpoint->options & MTF_OBJECTSPECIAL) + if (actor->target->spawnpoint->options & MTF_OBJECTSPECIAL) { actor->momz = 0; actor->flags |= MF_NOGRAVITY; diff --git a/src/p_local.h b/src/p_local.h index 682fb7b55..d2537aa37 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -311,6 +311,7 @@ void P_NewChaseDir(mobj_t *actor); boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed_t dist); mobj_t *P_InternalFlickySpawn(mobj_t *actor, mobjtype_t flickytype, fixed_t momz, boolean lookforplayers); +#define P_IsFlickyCenter(type) (type > MT_FLICKY_01 && type < MT_SEED && (type - MT_FLICKY_01) % 2 ? 1 : 0) void P_InternalFlickyBubble(mobj_t *actor); void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fixed_t chasez); void P_InternalFlickyHop(mobj_t *actor, fixed_t momz, fixed_t momh, angle_t angle); diff --git a/src/p_mobj.c b/src/p_mobj.c index 1261091da..b071470dd 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7089,32 +7089,33 @@ void P_MobjThinker(mobj_t *mobj) S_StartSound(flame, sfx_fire); } break; - case MT_FLICKY_01: - case MT_FLICKY_02: - case MT_FLICKY_03: - case MT_FLICKY_04: - case MT_FLICKY_05: - case MT_FLICKY_06: - case MT_FLICKY_07: - case MT_FLICKY_08: - case MT_FLICKY_09: - case MT_FLICKY_10: - case MT_FLICKY_11: - case MT_FLICKY_12: - case MT_FLICKY_13: - case MT_FLICKY_14: - case MT_FLICKY_15: - case MT_FLICKY_16: - case MT_SECRETFLICKY_01: - case MT_SECRETFLICKY_02: - if (mobj->spawnpoint + case MT_FLICKY_01_CENTER: + case MT_FLICKY_02_CENTER: + case MT_FLICKY_03_CENTER: + case MT_FLICKY_04_CENTER: + case MT_FLICKY_05_CENTER: + case MT_FLICKY_06_CENTER: + case MT_FLICKY_07_CENTER: + case MT_FLICKY_08_CENTER: + case MT_FLICKY_09_CENTER: + case MT_FLICKY_10_CENTER: + case MT_FLICKY_11_CENTER: + case MT_FLICKY_12_CENTER: + case MT_FLICKY_13_CENTER: + case MT_FLICKY_14_CENTER: + case MT_FLICKY_15_CENTER: + case MT_FLICKY_16_CENTER: + case MT_SECRETFLICKY_01_CENTER: + case MT_SECRETFLICKY_02_CENTER: + if (mobj->tracer + && mobj->spawnpoint && (mobj->spawnpoint->options & MTF_AMBUSH) && !(mobj->spawnpoint->options & MTF_OBJECTSPECIAL)) { - if (!(mobj->flags2 & MF2_OBJECTFLIP) && mobj->z <= mobj->floorz) - mobj->momz = 7*FRACUNIT; - else if ((mobj->flags2 & MF2_OBJECTFLIP) && mobj->z >= mobj->ceilingz - mobj->height) - mobj->momz = -7*FRACUNIT; + if (!(mobj->tracer->flags2 & MF2_OBJECTFLIP) && mobj->tracer->z <= mobj->tracer->floorz) + mobj->tracer->momz = 7*FRACUNIT; + else if ((mobj->tracer->flags2 & MF2_OBJECTFLIP) && mobj->tracer->z >= mobj->tracer->ceilingz - mobj->tracer->height) + mobj->tracer->momz = -7*FRACUNIT; } break; case MT_SEED: @@ -10435,38 +10436,6 @@ ML_EFFECT4 : Don't clip inside the ground break; } - case MT_FLICKY_08: - if (mthing->extrainfo == 1) - mobj->color = SKINCOLOR_RED; - else if (mthing->extrainfo == 2) - mobj->color = SKINCOLOR_CYAN; - else if (mthing->extrainfo == 3) - mobj->color = SKINCOLOR_BLUE; - else if (mthing->extrainfo == 4) - mobj->color = SKINCOLOR_VAPOR; - else if (mthing->extrainfo == 5) - mobj->color = SKINCOLOR_PURPLE; - else if (mthing->extrainfo == 6) - mobj->color = SKINCOLOR_BUBBLEGUM; - else if (mthing->extrainfo == 7) - mobj->color = SKINCOLOR_NEON; - else if (mthing->extrainfo == 8) - mobj->color = SKINCOLOR_BLACK; - else if (mthing->extrainfo == 9) - mobj->color = SKINCOLOR_BEIGE; - else if (mthing->extrainfo == 10) - mobj->color = SKINCOLOR_LAVENDER; - else if (mthing->extrainfo == 11) - mobj->color = SKINCOLOR_RUBY; - else if (mthing->extrainfo == 12) - mobj->color = SKINCOLOR_SALMON; - else if (mthing->extrainfo == 13) - mobj->color = SKINCOLOR_SUNSET; - else if (mthing->extrainfo == 14) - mobj->color = SKINCOLOR_ORANGE; - else if (mthing->extrainfo == 15) - mobj->color = SKINCOLOR_YELLOW; - break; case MT_PARTICLEGEN: { fixed_t radius, speed; From bf74b81842cbda88806fddb28b6aa057e3d24108 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 21:00:05 -0400 Subject: [PATCH 052/573] Snappier NiGHTS pickup attraction * Old attraction is still used for non-NiGHTS players due to a momentum bug. The old way is good enough to sidestep the bug. * Thanks Inuyasha (KS) for original code :dog: --- src/p_inter.c | 4 ++++ src/p_mobj.c | 40 ++++++++++++++++++++++++++++++++-------- src/p_user.c | 1 + 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 5737e2c2a..01343cfb1 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -944,6 +944,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Yay! The thing's in reach! Pull it in! mo2->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; mo2->flags2 |= MF2_NIGHTSPULL; + mo2->movecount = 24*FRACUNIT; // initialize the NightsItemChase timer P_SetTarget(&mo2->tracer, toucher); } } @@ -2122,7 +2123,10 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget target->flags |= MF_NOGRAVITY|MF_NOCLIP|MF_NOCLIPHEIGHT; // Don't drop Tails 03-08-2000 if (target->flags2 & MF2_NIGHTSPULL) + { P_SetTarget(&target->tracer, NULL); + target->movecount = 0; // reset NightsItemChase timer + } // dead target is no more shootable target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SPECIAL); diff --git a/src/p_mobj.c b/src/p_mobj.c index be373fbf4..c0924050c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6096,9 +6096,11 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale) void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on your target { fixed_t dist, ndist, speedmul; + angle_t vangle; fixed_t tx = dest->x; fixed_t ty = dest->y; fixed_t tz = dest->z + (dest->height/2); // Aim for center + fixed_t xydist = P_AproxDistance(tx - source->x, ty - source->y); if (!dest || dest->health <= 0 || !dest->player || !source->tracer) return; @@ -6107,19 +6109,40 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y source->angle = R_PointToAngle2(source->x, source->y, tx, ty); // change slope - dist = P_AproxDistance(P_AproxDistance(tx - source->x, ty - source->y), tz - source->z); + dist = P_AproxDistance(xydist, tz - source->z); if (dist < 1) dist = 1; - if (nightsgrab) - speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(8*FRACUNIT, source->scale); - else - speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(source->info->speed, source->scale); + if (nightsgrab && dest->player->powers[pw_carry] == CR_NIGHTSMODE) + { + source->movecount += FRACUNIT/2; - source->momx = FixedMul(FixedDiv(tx - source->x, dist), speedmul); - source->momy = FixedMul(FixedDiv(ty - source->y, dist), speedmul); - source->momz = FixedMul(FixedDiv(tz - source->z, dist), speedmul); + if (dist < source->movecount) + { + source->momx = source->momy = source->momz = 0; + P_TeleportMove(source, tx, ty, tz); + } + else + { + vangle = R_PointToAngle2(source->z, 0, tz, xydist); + + source->momx = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINECOSINE(source->angle >> ANGLETOFINESHIFT), source->movecount)); + source->momy = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINESINE(source->angle >> ANGLETOFINESHIFT), source->movecount)); + source->momz = FixedMul(FINECOSINE(vangle >> ANGLETOFINESHIFT), source->movecount); + } + } + else + { + if (nightsgrab) + speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(8*FRACUNIT, source->scale); + else + speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(source->info->speed, source->scale); + + source->momx = FixedMul(FixedDiv(tx - source->x, dist), speedmul); + source->momy = FixedMul(FixedDiv(ty - source->y, dist), speedmul); + source->momz = FixedMul(FixedDiv(tz - source->z, dist), speedmul); + } // Instead of just unsetting NOCLIP like an idiot, let's check the distance to our target. ndist = P_AproxDistance(P_AproxDistance(tx - (source->x+source->momx), @@ -6144,6 +6167,7 @@ static void P_NightsItemChase(mobj_t *thing) { P_SetTarget(&thing->tracer, NULL); thing->flags2 &= ~MF2_NIGHTSPULL; + //thing->movecount = 0; return; } diff --git a/src/p_user.c b/src/p_user.c index 357933f14..a601c5c2f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9762,6 +9762,7 @@ void P_PlayerThink(player_t *player) // Yay! The thing's in reach! Pull it in! mo2->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; mo2->flags2 |= MF2_NIGHTSPULL; + mo2->movecount = 24*FRACUNIT; // initialize NightsItemChase timer P_SetTarget(&mo2->tracer, player->mo); } } From b28183129f5bb147c1075d6368c97bb98e7e33a8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 22:13:06 -0400 Subject: [PATCH 053/573] NiGHTS drill meter penalty when mashing jump button Thanks Inuyasha (KS) for code --- src/p_user.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index a601c5c2f..416ca807e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6635,6 +6635,13 @@ static void P_NiGHTSMovement(player_t *player) S_StartSound(player->mo, sfx_drill1); player->drilltimer = 32; } + else if (player->drilltimer == 32) + { + player->drilltimer = 31; + player->drillmeter -= TICRATE/2; + if (player->drillmeter <= 0) + player->drillmeter = TICRATE/10; + } else if (--player->drilltimer <= 0) { player->drilltimer = 10; From 09f4309f4566cbc841d31fbcba156c08f8ba1e34 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 23:14:14 -0400 Subject: [PATCH 054/573] Standardize NiGHTS link timer w/ NightsLinkTics MAINCFG option --- src/dehacked.c | 5 ++++- src/doomstat.h | 1 + src/g_game.c | 1 + src/p_inter.c | 10 +++++----- src/st_stuff.c | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index c4d0bc104..3a18f2a45 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2730,11 +2730,14 @@ static void readmaincfg(MYFILE *f) { extralifetics = (UINT16)get_number(word2); } + else if (fastcmp(word, "NIGHTSLINKTICS")) + { + nightslinktics = (UINT16)get_number(word2); + } else if (fastcmp(word, "GAMEOVERTICS")) { gameovertics = get_number(word2); } - else if (fastcmp(word, "INTROTOPLAY")) { introtoplay = (UINT8)get_number(word2); diff --git a/src/doomstat.h b/src/doomstat.h index 24b9e5753..97710c05d 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -413,6 +413,7 @@ extern UINT16 tailsflytics; extern UINT16 underwatertics; extern UINT16 spacetimetics; extern UINT16 extralifetics; +extern UINT16 nightslinktics; extern UINT8 introtoplay; extern UINT8 creditscutscene; diff --git a/src/g_game.c b/src/g_game.c index 52358a8b9..5af4743c4 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -201,6 +201,7 @@ UINT16 tailsflytics = 8*TICRATE; UINT16 underwatertics = 30*TICRATE; UINT16 spacetimetics = 11*TICRATE + (TICRATE/2); UINT16 extralifetics = 4*TICRATE; +UINT16 nightslinktics = 2*TICRATE; INT32 gameovertics = 15*TICRATE; diff --git a/src/p_inter.c b/src/p_inter.c index 01343cfb1..f4c1afada 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -182,14 +182,14 @@ void P_DoNightsScore(player_t *player) { if (++players[i].linkcount > players[i].maxlink) players[i].maxlink = players[i].linkcount; - players[i].linktimer = 2*TICRATE; + players[i].linktimer = nightslinktics; } } else // Individual link counts { if (++player->linkcount > player->maxlink) player->maxlink = player->linkcount; - player->linktimer = 2*TICRATE; + player->linktimer = nightslinktics; } if (player->linkcount < 10) @@ -1162,7 +1162,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!G_IsSpecialStage(gamemap)) { player->powers[pw_nights_linkfreeze] = (UINT16)special->info->speed; - player->linktimer = 2*TICRATE; + player->linktimer = nightslinktics; } else { @@ -1170,7 +1170,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE) { players[i].powers[pw_nights_linkfreeze] += (UINT16)special->info->speed; - players[i].linktimer = 2*TICRATE; + players[i].linktimer = nightslinktics; } if (special->info->deathsound != sfx_None) S_StartSound(NULL, special->info->deathsound); @@ -2185,7 +2185,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget // to make people want to actually dash towards/paraloop enemies if (++source->player->linkcount > source->player->maxlink) source->player->maxlink = source->player->linkcount; - source->player->linktimer = 2*TICRATE; + source->player->linktimer = nightslinktics; } } else diff --git a/src/st_stuff.c b/src/st_stuff.c index 3ecd0acdf..64d3db7f2 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1535,8 +1535,8 @@ static void ST_drawNiGHTSHUD(void) else colornum = linkColor[mag][sel]; - aflag |= ((stplyr->linktimer < 2*TICRATE/3) - ? (9 - 9*stplyr->linktimer/(2*TICRATE/3)) << V_ALPHASHIFT + aflag |= ((stplyr->linktimer < nightslinktics/3) + ? (9 - 9*stplyr->linktimer/(nightslinktics/3)) << V_ALPHASHIFT : 0); y = (160+11)< Date: Fri, 10 Aug 2018 04:24:14 -0400 Subject: [PATCH 055/573] Make bigger default Flicky follow trigger from 128 radius to 320 radius --- src/info.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/info.c b/src/info.c index f3828caf1..2e1396681 100644 --- a/src/info.c +++ b/src/info.c @@ -2639,7 +2639,7 @@ state_t states[NUMSTATES] = {SPR_FL01, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP3}, // S_FLICKY_01_FLAP2 {SPR_FL01, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP1}, // S_FLICKY_01_FLAP3 {SPR_FL01, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_01_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_01, 128*FRACUNIT, S_FLICKY_01_CENTER}, // S_FLICKY_01_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_01, 320*FRACUNIT, S_FLICKY_01_CENTER}, // S_FLICKY_01_CENTER // Rabbit {SPR_FL02, 0, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_OUT}, // S_FLICKY_02_OUT @@ -2648,7 +2648,7 @@ state_t states[NUMSTATES] = {SPR_FL02, 2, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, S_FLICKY_02_DOWN, S_FLICKY_02_UP}, // S_FLICKY_02_UP {SPR_FL02, 3, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_DOWN}, // S_FLICKY_02_DOWN {SPR_FL02, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_02_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_02, 128*FRACUNIT, S_FLICKY_02_CENTER}, // S_FLICKY_02_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_02, 320*FRACUNIT, S_FLICKY_02_CENTER}, // S_FLICKY_02_CENTER // Chicken {SPR_FL03, 0, 2, {A_FlickyCheck}, S_FLICKY_03_AIM, S_FLICKY_03_FLAP1, S_FLICKY_03_OUT}, // S_FLICKY_03_OUT @@ -2658,7 +2658,7 @@ state_t states[NUMSTATES] = {SPR_FL03, 3, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP2}, // S_FLICKY_03_FLAP1 {SPR_FL03, 4, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP1}, // S_FLICKY_03_FLAP2 {SPR_FL03, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_03_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_03, 128*FRACUNIT, S_FLICKY_03_CENTER}, // S_FLICKY_03_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_03, 320*FRACUNIT, S_FLICKY_03_CENTER}, // S_FLICKY_03_CENTER // Seal {SPR_FL04, 0, 2, {A_FlickyCheck}, S_FLICKY_04_AIM, 0, S_FLICKY_04_OUT}, // S_FLICKY_04_OUT @@ -2671,7 +2671,7 @@ state_t states[NUMSTATES] = {SPR_FL04, 3, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM4}, // S_FLICKY_04_SWIM3 {SPR_FL04, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM1}, // S_FLICKY_04_SWIM4 {SPR_FL04, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_04_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_04, 128*FRACUNIT, S_FLICKY_04_CENTER}, // S_FLICKY_04_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_04, 320*FRACUNIT, S_FLICKY_04_CENTER}, // S_FLICKY_04_CENTER // Pig {SPR_FL05, 0, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_OUT}, // S_FLICKY_05_OUT @@ -2680,7 +2680,7 @@ state_t states[NUMSTATES] = {SPR_FL05, 2, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, S_FLICKY_05_DOWN, S_FLICKY_05_UP}, // S_FLICKY_05_UP {SPR_FL05, 3, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_DOWN}, // S_FLICKY_05_DOWN {SPR_FL05, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_05_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_05, 128*FRACUNIT, S_FLICKY_05_CENTER}, // S_FLICKY_05_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_05, 320*FRACUNIT, S_FLICKY_05_CENTER}, // S_FLICKY_05_CENTER // Chipmunk {SPR_FL06, 0, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_OUT}, // S_FLICKY_06_OUT @@ -2689,7 +2689,7 @@ state_t states[NUMSTATES] = {SPR_FL06, 2, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, S_FLICKY_06_DOWN, S_FLICKY_06_UP}, // S_FLICKY_06_UP {SPR_FL06, 3, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_DOWN}, // S_FLICKY_06_DOWN {SPR_FL06, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_06_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_06, 128*FRACUNIT, S_FLICKY_06_CENTER}, // S_FLICKY_06_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_06, 320*FRACUNIT, S_FLICKY_06_CENTER}, // S_FLICKY_06_CENTER // Penguin {SPR_FL07, 0, 2, {A_FlickyCheck}, S_FLICKY_07_AIML, 0, S_FLICKY_07_OUT}, // S_FLICKY_07_OUT @@ -2705,7 +2705,7 @@ state_t states[NUMSTATES] = {SPR_FL07, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM2 {SPR_FL07, 6, 4, {A_FlickyCoast}, 2*FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM3 {SPR_FL07, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_07_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_07, 128*FRACUNIT, S_FLICKY_07_CENTER}, // S_FLICKY_07_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_07, 320*FRACUNIT, S_FLICKY_07_CENTER}, // S_FLICKY_07_CENTER // Fish {SPR_FL08, 0, 2, {A_FlickyCheck}, S_FLICKY_08_AIM, 0, S_FLICKY_08_OUT}, // S_FLICKY_08_OUT @@ -2720,7 +2720,7 @@ state_t states[NUMSTATES] = {SPR_FL08, 0, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_08_SWIM1, S_FLICKY_08_SWIM4}, // S_FLICKY_08_SWIM3 {SPR_FL08, 2, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_08_SWIM1, S_FLICKY_08_SWIM4}, // S_FLICKY_08_SWIM4 {SPR_FL08, FF_ANIMATE, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_08_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_08, 128*FRACUNIT, S_FLICKY_08_CENTER}, // S_FLICKY_08_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_08, 320*FRACUNIT, S_FLICKY_08_CENTER}, // S_FLICKY_08_CENTER // Ram {SPR_FL09, 0, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, 0, S_FLICKY_09_OUT}, // S_FLICKY_09_OUT @@ -2729,14 +2729,14 @@ state_t states[NUMSTATES] = {SPR_FL09, 2, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, S_FLICKY_09_DOWN, S_FLICKY_09_UP}, // S_FLICKY_09_UP {SPR_FL09, 3, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, 0, S_FLICKY_09_DOWN}, // S_FLICKY_09_DOWN {SPR_FL09, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_09_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_09, 128*FRACUNIT, S_FLICKY_09_CENTER}, // S_FLICKY_09_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_09, 320*FRACUNIT, S_FLICKY_09_CENTER}, // S_FLICKY_09_CENTER // Puffin {SPR_FL10, 0, 2, {A_FlickyCheck}, S_FLICKY_10_FLAP1, S_FLICKY_10_FLAP1, S_FLICKY_10_OUT}, // S_FLICKY_10_OUT {SPR_FL10, 1, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP2}, // S_FLICKY_10_FLAP1 {SPR_FL10, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP1}, // S_FLICKY_10_FLAP2 {SPR_FL10, FF_ANIMATE|1, -1, {NULL}, 1, 3, S_NULL}, // S_FLICKY_10_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_10, 128*FRACUNIT, S_FLICKY_10_CENTER}, // S_FLICKY_10_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_10, 320*FRACUNIT, S_FLICKY_10_CENTER}, // S_FLICKY_10_CENTER // Cow {SPR_FL11, 0, 2, {A_FlickyCheck}, S_FLICKY_11_AIM, 0, S_FLICKY_11_OUT}, // S_FLICKY_11_OUT @@ -2745,7 +2745,7 @@ state_t states[NUMSTATES] = {SPR_FL11, 2, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_RUN3}, // S_FLICKY_11_RUN2 {SPR_FL11, 3, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_AIM}, // S_FLICKY_11_RUN3 {SPR_FL11, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_11_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_11, 128*FRACUNIT, S_FLICKY_11_CENTER}, // S_FLICKY_11_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_11, 320*FRACUNIT, S_FLICKY_11_CENTER}, // S_FLICKY_11_CENTER // Rat {SPR_FL12, 0, 2, {A_FlickyCheck}, S_FLICKY_12_AIM, 0, S_FLICKY_12_OUT}, // S_FLICKY_12_OUT @@ -2754,7 +2754,7 @@ state_t states[NUMSTATES] = {SPR_FL12, 2, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_RUN3}, // S_FLICKY_12_RUN2 {SPR_FL12, 3, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_AIM}, // S_FLICKY_12_RUN3 {SPR_FL12, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_12_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_12, 128*FRACUNIT, S_FLICKY_12_CENTER}, // S_FLICKY_12_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_12, 320*FRACUNIT, S_FLICKY_12_CENTER}, // S_FLICKY_12_CENTER // Bear {SPR_FL13, 0, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_OUT}, // S_FLICKY_13_OUT @@ -2763,7 +2763,7 @@ state_t states[NUMSTATES] = {SPR_FL13, 2, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, S_FLICKY_13_DOWN, S_FLICKY_13_UP}, // S_FLICKY_13_UP {SPR_FL13, 3, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_DOWN}, // S_FLICKY_13_DOWN {SPR_FL13, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_13_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_13, 128*FRACUNIT, S_FLICKY_13_CENTER}, // S_FLICKY_13_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_13, 320*FRACUNIT, S_FLICKY_13_CENTER}, // S_FLICKY_13_CENTER // Dove {SPR_FL14, 0, 2, {A_FlickyCheck}, S_FLICKY_14_FLAP1, S_FLICKY_14_FLAP1, S_FLICKY_14_OUT}, // S_FLICKY_14_OUT @@ -2771,7 +2771,7 @@ state_t states[NUMSTATES] = {SPR_FL14, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP3}, // S_FLICKY_14_FLAP2 {SPR_FL14, 3, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP1}, // S_FLICKY_14_FLAP3 {SPR_FL14, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_14_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_14, 128*FRACUNIT, S_FLICKY_14_CENTER}, // S_FLICKY_14_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_14, 320*FRACUNIT, S_FLICKY_14_CENTER}, // S_FLICKY_14_CENTER // Cat {SPR_FL15, 0, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_OUT}, // S_FLICKY_15_OUT @@ -2780,7 +2780,7 @@ state_t states[NUMSTATES] = {SPR_FL15, 2, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, S_FLICKY_15_DOWN, S_FLICKY_15_UP}, // S_FLICKY_15_UP {SPR_FL15, 3, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_DOWN}, // S_FLICKY_15_DOWN {SPR_FL15, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_15_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_15, 128*FRACUNIT, S_FLICKY_15_CENTER}, // S_FLICKY_15_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_15, 320*FRACUNIT, S_FLICKY_15_CENTER}, // S_FLICKY_15_CENTER // Canary {SPR_FL16, 0, 2, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_OUT}, // S_FLICKY_16_OUT @@ -2788,7 +2788,7 @@ state_t states[NUMSTATES] = {SPR_FL16, 2, 3, {A_SetObjectFlags}, MF_NOGRAVITY, 1, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP2 {SPR_FL16, 3, 3, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP3 {SPR_FL16, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_16_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_16, 128*FRACUNIT, S_FLICKY_16_CENTER}, // S_FLICKY_16_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_16, 320*FRACUNIT, S_FLICKY_16_CENTER}, // S_FLICKY_16_CENTER // Spider {SPR_FS01, 0, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_OUT}, // S_SECRETFLICKY_01_OUT @@ -2797,7 +2797,7 @@ state_t states[NUMSTATES] = {SPR_FS01, 2, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, S_SECRETFLICKY_01_DOWN, S_SECRETFLICKY_01_UP}, // S_SECRETFLICKY_01_UP {SPR_FS01, 3, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_DOWN}, // S_SECRETFLICKY_01_DOWN {SPR_FS01, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_SECRETFLICKY_01_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_01, 128*FRACUNIT, S_SECRETFLICKY_01_CENTER}, // S_SECRETFLICKY_01_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_01, 320*FRACUNIT, S_SECRETFLICKY_01_CENTER}, // S_SECRETFLICKY_01_CENTER // Bat {SPR_FS02, 0, 2, {A_FlickyHeightCheck}, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_OUT}, // S_SECRETFLICKY_02_OUT @@ -2805,7 +2805,7 @@ state_t states[NUMSTATES] = {SPR_FS02, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP3}, // S_SECRETFLICKY_02_FLAP2 {SPR_FS02, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP1}, // S_SECRETFLICKY_02_FLAP3 {SPR_FS02, FF_ANIMATE|1, -1, {NULL}, 2, 2, S_NULL}, // S_SECRETFLICKY_02_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_02, 128*FRACUNIT, S_SECRETFLICKY_02_CENTER}, // S_SECRETFLICKY_02_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_02, 320*FRACUNIT, S_SECRETFLICKY_02_CENTER}, // S_SECRETFLICKY_02_CENTER // Fan {SPR_FANS, 0, 1, {A_FanBubbleSpawn}, 2048, 0, S_FAN2}, // S_FAN From 872761e258a865ab5e269fb4a7f2cf291eb076a8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 10 Aug 2018 17:12:26 -0400 Subject: [PATCH 056/573] Add lapbegunat and lapstartedtime player variables There is no lapfinishedtime because [mare]finishedtime refers to when Egg Capsule is destroyed. That concept does not apply to laps. --- src/d_player.h | 2 ++ src/lua_playerlib.c | 8 ++++++++ src/p_inter.c | 2 ++ src/p_map.c | 2 ++ src/p_saveg.c | 4 ++++ src/p_setup.c | 3 ++- src/p_user.c | 3 ++- 7 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 498b7166d..648867b92 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -463,6 +463,8 @@ typedef struct player_s tic_t marebegunat; // Leveltime when mare begun tic_t startedtime; // Time which you started this mare with. tic_t finishedtime; // Time it took you to finish the mare (used for display) + tic_t lapbegunat; // Leveltime when lap begun + tic_t lapstartedtime; // Time which you started this lap with. INT16 finishedspheres; // The spheres you had left upon finishing the mare INT16 finishedrings; // The rings/stars you had left upon finishing the mare UINT32 marescore; // score for this nights stage diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 7deefa7ff..114aa27b0 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -300,6 +300,10 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->startedtime); else if (fastcmp(field,"finishedtime")) lua_pushinteger(L, plr->finishedtime); + else if (fastcmp(field,"lapbegunat")) + lua_pushinteger(L, plr->lapbegunat); + else if (fastcmp(field,"lapstartedtime")) + lua_pushinteger(L, plr->lapstartedtime); else if (fastcmp(field,"finishedspheres")) lua_pushinteger(L, plr->finishedspheres); else if (fastcmp(field,"finishedrings")) @@ -588,6 +592,10 @@ static int player_set(lua_State *L) plr->startedtime = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"finishedtime")) plr->finishedtime = (tic_t)luaL_checkinteger(L, 3); + else if (fastcmp(field,"lapbegunat")) + plr->lapbegunat = (tic_t)luaL_checkinteger(L, 3); + else if (fastcmp(field,"lapstartedtime")) + plr->lapstartedtime = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"finishedspheres")) plr->finishedspheres = (INT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"finishedrings")) diff --git a/src/p_inter.c b/src/p_inter.c index ce8bba6b6..e7590439e 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1134,6 +1134,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { player->nightstime += special->info->speed; player->startedtime += special->info->speed; + player->lapstartedtime += special->info->speed; P_RestoreMusic(player); } else @@ -1143,6 +1144,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { players[i].nightstime += special->info->speed; players[i].startedtime += special->info->speed; + players[i].lapstartedtime += special->info->speed; P_RestoreMusic(&players[i]); } if (special->info->deathsound != sfx_None) diff --git a/src/p_map.c b/src/p_map.c index 415e2bac1..7d3538573 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1114,6 +1114,8 @@ static boolean PIT_CheckThing(mobj_t *thing) )) { pl->marelap++; + pl->lapbegunat = leveltime; + pl->lapstartedtime = pl->nightstime; if (pl->bonustime) { diff --git a/src/p_saveg.c b/src/p_saveg.c index 2b48cc783..e18802f57 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -204,6 +204,8 @@ static void P_NetArchivePlayers(void) WRITEUINT32(save_p, players[i].marebegunat); WRITEUINT32(save_p, players[i].startedtime); WRITEUINT32(save_p, players[i].finishedtime); + WRITEUINT32(save_p, players[i].lapbegunat); + WRITEUINT32(save_p, players[i].lapstartedtime); WRITEINT16(save_p, players[i].finishedspheres); WRITEINT16(save_p, players[i].finishedrings); WRITEUINT32(save_p, players[i].marescore); @@ -397,6 +399,8 @@ static void P_NetUnArchivePlayers(void) players[i].marebegunat = READUINT32(save_p); players[i].startedtime = READUINT32(save_p); players[i].finishedtime = READUINT32(save_p); + players[i].lapbegunat = READUINT32(save_p); + players[i].lapstartedtime = READUINT32(save_p); players[i].finishedspheres = READINT16(save_p); players[i].finishedrings = READINT16(save_p); players[i].marescore = READUINT32(save_p); diff --git a/src/p_setup.c b/src/p_setup.c index e4b6034b1..4b10f431c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2387,7 +2387,8 @@ static void P_LevelInitStuff(void) players[i].linktimer = players[i].flyangle =\ players[i].anotherflyangle = players[i].nightstime =\ players[i].mare = players[i].marelap =\ - players[i].marebonuslap = players[i].realtime =\ + players[i].marebonuslap = players[i].lapbegunat =\ + players[i].lapstartedtime = players[i].realtime =\ players[i].exiting = 0; // i guess this could be part of the above but i feel mildly uncomfortable implicitly casting diff --git a/src/p_user.c b/src/p_user.c index 99ecb8154..ddaa6384a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -666,7 +666,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) player->followitem = skins[DEFAULTNIGHTSSKIN].followitem; } - player->nightstime = player->startedtime = nighttime*TICRATE; + player->nightstime = player->startedtime = player->lapstartedtime = nightstime*TICRATE; player->bonustime = false; P_RestoreMusic(player); @@ -762,6 +762,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) player->lastmarescore = player->marescore; player->marescore = 0; player->marebegunat = leveltime; + player->lapbegunat = leveltime; player->spheres = player->rings = 0; } From 0b88c364bca99887530e6d00db3b4c8f56c0a43b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Aug 2018 18:01:54 +0100 Subject: [PATCH 057/573] Add "Tutorial" to the 1P menu, above "Start Game". It doesn't actually do anything yet, mind! Also, change said menu's def to start at "Start Game" when entering it for the first time. --- src/m_menu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index f99f5d860..50850ecee 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -731,6 +731,7 @@ static menuitem_t SR_EmblemHintMenu[] = // Single Player Main static menuitem_t SP_MainMenu[] = { + {IT_STRING, NULL, "Tutorial", NULL, 84}, {IT_CALL | IT_STRING, NULL, "Start Game", M_LoadGame, 92}, {IT_SECRET, NULL, "Record Attack", M_TimeAttack, 100}, {IT_SECRET, NULL, "NiGHTS Mode", M_NightsAttack, 108}, @@ -739,6 +740,7 @@ static menuitem_t SP_MainMenu[] = enum { + sptutorial, sploadgame, sprecordattack, spnightsmode, @@ -1554,7 +1556,18 @@ menu_t SR_EmblemHintDef = }; // Single Player -menu_t SP_MainDef = CENTERMENUSTYLE(NULL, SP_MainMenu, &MainDef, 72); +menu_t SP_MainDef = //CENTERMENUSTYLE(NULL, SP_MainMenu, &MainDef, 72); +{ + NULL, + sizeof(SP_MainMenu)/sizeof(menuitem_t), + &MainDef, + SP_MainMenu, + M_DrawCenteredMenu, + BASEVIDWIDTH/2, 72, + 1, // start at "Start Game" on first entry + NULL +}; + menu_t SP_LoadDef = { "M_PICKG", From 51b8d6e01a512f758b8ebc0e933a959b140e1057 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Aug 2018 21:17:52 +0100 Subject: [PATCH 058/573] Make "Tutorial" warp directly to MAPZ0 (not configurable yet) --- src/m_menu.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 50850ecee..f8324ab7e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -273,6 +273,7 @@ menu_t SP_MainDef, OP_MainDef; menu_t MISC_ScrambleTeamDef, MISC_ChangeTeamDef; // Single Player +static void M_StartTutorial(INT32 choice); static void M_LoadGame(INT32 choice); static void M_TimeAttackLevelSelect(INT32 choice); static void M_TimeAttack(INT32 choice); @@ -731,7 +732,7 @@ static menuitem_t SR_EmblemHintMenu[] = // Single Player Main static menuitem_t SP_MainMenu[] = { - {IT_STRING, NULL, "Tutorial", NULL, 84}, + {IT_STRING, NULL, "Tutorial", M_StartTutorial, 84}, {IT_CALL | IT_STRING, NULL, "Start Game", M_LoadGame, 92}, {IT_SECRET, NULL, "Record Attack", M_TimeAttack, 100}, {IT_SECRET, NULL, "NiGHTS Mode", M_NightsAttack, 108}, @@ -6131,6 +6132,22 @@ static void M_LoadGameLevelSelect(INT32 choice) M_SetupNextMenu(&SP_LevelSelectDef); } +static INT32 tutorialmap = 1000; // MAPZ0, temporary value + +// Starts up the tutorial immediately (tbh I wasn't sure where else to put this) +static void M_StartTutorial(INT32 choice) +{ + (void)choice; + if (!tutorialmap) + return; // no map to go to, don't bother + + emeralds = 0; + M_ClearMenus(true); + gamecomplete = false; + cursaveslot = 0; + G_DeferedInitNew(false, G_BuildMapName(tutorialmap), 0, false, false); +} + // ============== // LOAD GAME MENU // ============== From f4a813891fbebb87178f155a9487c4c536b640fe Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 00:51:01 -0400 Subject: [PATCH 059/573] Decouple Flicky Thing logic from spawnpoint variables; use mobj variables --- src/p_enemy.c | 100 +++++++++++++++++++++++++++++--------------------- src/p_mobj.c | 5 +-- 2 files changed, 61 insertions(+), 44 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 7eca785e0..85818a2f3 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10779,11 +10779,11 @@ void A_FlickySpawn(mobj_t *actor) void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo) { UINT8 flickycolors[] = { - SKINCOLOR_RED, - SKINCOLOR_CYAN, - SKINCOLOR_BLUE, - SKINCOLOR_VAPOR, - SKINCOLOR_PURPLE, + SKINCOLOR_RED, + SKINCOLOR_CYAN, + SKINCOLOR_BLUE, + SKINCOLOR_VAPOR, + SKINCOLOR_PURPLE, SKINCOLOR_BUBBLEGUM, SKINCOLOR_NEON, SKINCOLOR_BLACK, @@ -10809,10 +10809,14 @@ void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo) // var1 = if 0, spawns random flicky based on level header. Else, spawns the designated thing type. // var2 = maximum default distance away from spawn the flickies are allowed to travel. If angle != 0, then that's the radius. // -// If MTF_EXTRA is flagged, Flickies move independently of a target. Else, move around the target. -// If MTF_OBJECTSPECIAL and NOT MTF_EXTRA are flagged, Angle sign determines direction of circular movement. -// If MTF_AMBUSH is flagged, Flickies hop in-place. -// If MTF_AMBUSH and MTF_OBJECTSPECIAL is flagged, Flickies stand in-place without gravity. +// If MTF_EXTRA (MF_SLIDEME) is flagged, Flickies move independently of a target. Else, move around the target. +// If MTF_OBJECTSPECIAL (MF_GRENADEBOUNCE) and NOT MTF_EXTRA (MF_SLIDEME) are flagged, Angle sign determines direction of circular movement. +// If MTF_AMBUSH (MF_NOCLIPTHING) is flagged, Flickies hop in-place. +// If MTF_AMBUSH (MF_NOCLIPTHING) and MTF_OBJECTSPECIAL (MF_GRENADEBOUNCE) is flagged, Flickies stand in-place without gravity. +// +// actor->friction = X origin +// actor->movefactor = Y origin +// actor->radius = Z origin // void A_FlickyCenter(mobj_t *actor) { @@ -10825,13 +10829,28 @@ void A_FlickyCenter(mobj_t *actor) if (!actor->tracer) { - if (actor->spawnpoint && (actor->spawnpoint->options & MTF_EXTRA)) + if (actor->spawnpoint) + { + actor->flags &= ~(MF_SLIDEME|MF_GRENADEBOUNCE|MF_NOCLIPTHING); + actor->flags |= ( + ((actor->spawnpoint->options & MTF_EXTRA) ? MF_SLIDEME : 0) + | ((actor->spawnpoint->options & MTF_OBJECTSPECIAL) ? MF_GRENADEBOUNCE : 0) + | ((actor->spawnpoint->options & MTF_AMBUSH) ? MF_NOCLIPTHING : 0) + ); + actor->extravalue1 = actor->spawnpoint->angle; + actor->extravalue2 = actor->spawnpoint->extrainfo; + actor->friction = actor->spawnpoint->x*FRACUNIT; + actor->movefactor = actor->spawnpoint->y*FRACUNIT; + actor->watertop = actor->spawnpoint->z*FRACUNIT; + } + + if (actor->flags & MF_SLIDEME) { actor->tracer = P_InternalFlickySpawn(actor, locvar1, 1, false); P_SetTarget(&actor->tracer->target, actor); actor->tracer->fuse = 0; // < 2*TICRATE means move aimlessly. - if (!(actor->spawnpoint->options & MTF_AMBUSH)) + if (!(actor->flags & MF_NOCLIPTHING)) actor->tracer->angle = P_RandomKey(180)*ANG2; } else @@ -10840,36 +10859,38 @@ void A_FlickyCenter(mobj_t *actor) P_SetTarget(&actor->tracer->target, actor); actor->tracer->fuse = FRACUNIT; - if (actor->spawnpoint - && (actor->spawnpoint->options & MTF_OBJECTSPECIAL) - && !(actor->spawnpoint->options & MTF_EXTRA)) - actor->tracer->movedir = actor->spawnpoint->angle >= 0 ? 1 : -1; + if ((actor->flags & MF_GRENADEBOUNCE) && !(actor->flags & MF_SLIDEME)) + actor->tracer->movedir = actor->extravalue1 >= 0 ? 1 : -1; } - if (locvar1 == MT_FLICKY_08 && actor->spawnpoint) - P_InternalFlickySetColor(actor->tracer, actor->spawnpoint->extrainfo); + if (locvar1 == MT_FLICKY_08) + P_InternalFlickySetColor(actor->tracer, actor->extravalue2); - actor->extravalue1 = 0; + actor->extravalue2 = 0; } - if (actor->spawnpoint && !(actor->spawnpoint->options & MTF_EXTRA) && !(actor->spawnpoint->options & MTF_AMBUSH)) + if (!(actor->flags & MF_SLIDEME) && !(actor->flags & MF_NOCLIPTHING)) { + fixed_t originx = actor->friction; + fixed_t originy = actor->movefactor; + fixed_t originz = actor->watertop; + actor->tracer->fuse = FRACUNIT; - if (actor->spawnpoint->angle) - locvar2 = abs(actor->spawnpoint->angle)*FRACUNIT; + if (actor->extravalue1) + locvar2 = abs(actor->extravalue1)*FRACUNIT; P_LookForPlayers(actor, true, false, locvar2); - if (actor->target && P_AproxDistance(actor->target->x - actor->spawnpoint->x*FRACUNIT, actor->target->y - actor->spawnpoint->y*FRACUNIT) < locvar2) + if (actor->target && P_AproxDistance(actor->target->x - originx, actor->target->y - originy) < locvar2) { - actor->extravalue1 = 1; + actor->extravalue2 = 1; P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z); } - else if(actor->extravalue1) + else if(actor->extravalue2) { - actor->extravalue1 = 0; - P_TeleportMove(actor, actor->spawnpoint->x*FRACUNIT, actor->spawnpoint->y*FRACUNIT, actor->spawnpoint->z*FRACUNIT); + actor->extravalue2 = 0; + P_TeleportMove(actor, originx, originy, originz); } } } @@ -10984,11 +11005,10 @@ void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fi if (actor->target && abs(chasez - actor->z) > targetdist) targetdist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); - if (actor->target - && P_IsFlickyCenter(actor->target->type) - && actor->target->spawnpoint - && (actor->target->spawnpoint->options & MTF_OBJECTSPECIAL) - && (actor->target->spawnpoint->options & MTF_EXTRA)) + if (actor->target + && P_IsFlickyCenter(actor->target->type) + && (actor->target->flags & MF_GRENADEBOUNCE) + && (actor->target->flags & MF_SLIDEME)) vertangle = 0; else vertangle = (R_PointToAngle2(0, actor->z, targetdist, chasez) >> ANGLETOFINESHIFT) & FINEMASK; @@ -11148,12 +11168,11 @@ void A_FlickyCheck(mobj_t *actor) if (LUA_CallAction("A_FlickyCheck", actor)) return; #endif - if (actor->target - && P_IsFlickyCenter(actor->target->type) - && actor->target->spawnpoint - && (actor->target->spawnpoint->options & MTF_AMBUSH)) + if (actor->target + && P_IsFlickyCenter(actor->target->type) + && (actor->target->flags & MF_NOCLIPTHING)) { - if (actor->target->spawnpoint->options & MTF_OBJECTSPECIAL) + if (actor->target->flags & MF_GRENADEBOUNCE) { actor->momz = 0; actor->flags |= MF_NOGRAVITY; @@ -11186,12 +11205,11 @@ void A_FlickyHeightCheck(mobj_t *actor) if (LUA_CallAction("A_FlickyHeightCheck", actor)) return; #endif - if (actor->target - && P_IsFlickyCenter(actor->target->type) - && actor->target->spawnpoint - && (actor->target->spawnpoint->options & MTF_AMBUSH)) + if (actor->target + && P_IsFlickyCenter(actor->target->type) + && (actor->target->flags & MF_NOCLIPTHING)) { - if (actor->target->spawnpoint->options & MTF_OBJECTSPECIAL) + if (actor->target->flags & MF_GRENADEBOUNCE) { actor->momz = 0; actor->flags |= MF_NOGRAVITY; diff --git a/src/p_mobj.c b/src/p_mobj.c index a5ebfd1ea..a96f28721 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7114,9 +7114,8 @@ void P_MobjThinker(mobj_t *mobj) case MT_SECRETFLICKY_01_CENTER: case MT_SECRETFLICKY_02_CENTER: if (mobj->tracer - && mobj->spawnpoint - && (mobj->spawnpoint->options & MTF_AMBUSH) - && !(mobj->spawnpoint->options & MTF_OBJECTSPECIAL)) + && (mobj->flags & MF_NOCLIPTHING) + && !(mobj->flags & MF_GRENADEBOUNCE)) { if (!(mobj->tracer->flags2 & MF2_OBJECTFLIP) && mobj->tracer->z <= mobj->tracer->floorz) mobj->tracer->momz = 7*FRACUNIT; From 2f6c0d7e4e9f7e3ec0bfe2ef8dceb9125df7199e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 09:23:50 -0400 Subject: [PATCH 060/573] Make Flicky color, move direction, and flags configurable by A_FlickyCenter var1 --- src/p_enemy.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 85818a2f3..6d074e5f8 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10806,7 +10806,16 @@ void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo) // // Description: Place flickies in-level. // -// var1 = if 0, spawns random flicky based on level header. Else, spawns the designated thing type. +// var1: +// Lower 16 bits = if 0, spawns random flicky based on level header. Else, spawns the designated thing type. +// Bits 17-20 = Flicky color, up to 15. Applies to fish. +// Bit 21 = Flag MF_SLIDEME (see below) +// Bit 22 = Flag MF_GRENADEBOUNCE (see below) +// Bit 23 = Flag MF_NOCLIPTHING (see below) +// Bit 24 = Flicky movedir, 0 or 1 +// +// If actor is placed from a spawnpoint (map Thing), the Thing's properties take precedence. +// // var2 = maximum default distance away from spawn the flickies are allowed to travel. If angle != 0, then that's the radius. // // If MTF_EXTRA (MF_SLIDEME) is flagged, Flickies move independently of a target. Else, move around the target. @@ -10814,14 +10823,13 @@ void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo) // If MTF_AMBUSH (MF_NOCLIPTHING) is flagged, Flickies hop in-place. // If MTF_AMBUSH (MF_NOCLIPTHING) and MTF_OBJECTSPECIAL (MF_GRENADEBOUNCE) is flagged, Flickies stand in-place without gravity. // -// actor->friction = X origin -// actor->movefactor = Y origin -// actor->radius = Z origin -// void A_FlickyCenter(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; + UINT16 flickytype = (locvar1 & 0xFFFF); + UINT8 flickycolor = ((locvar1 >> 16) & 0xFF); + UINT8 flickyflags = ((locvar1 >> 20) & 0xF); #ifdef HAVE_BLUA if (LUA_CallAction("A_FlickyCenter", actor)) return; @@ -10843,6 +10851,21 @@ void A_FlickyCenter(mobj_t *actor) actor->movefactor = actor->spawnpoint->y*FRACUNIT; actor->watertop = actor->spawnpoint->z*FRACUNIT; } + else + { + actor->flags &= ~(MF_SLIDEME|MF_GRENADEBOUNCE|MF_NOCLIPTHING); + actor->flags |= ( + ((flickyflags & 1) ? MF_SLIDEME : 0) + | ((flickyflags & 2) ? MF_GRENADEBOUNCE : 0) + | ((flickyflags & 4) ? MF_NOCLIPTHING : 0) + ); + actor->extravalue1 = 0; // move sign from var1 bit 24, distance from var2 + actor->extravalue2 = flickycolor; + actor->friction = actor->x; + actor->movefactor = actor->y; + actor->watertop = actor->z; + locvar1 = flickytype; + } if (actor->flags & MF_SLIDEME) { @@ -10860,7 +10883,12 @@ void A_FlickyCenter(mobj_t *actor) actor->tracer->fuse = FRACUNIT; if ((actor->flags & MF_GRENADEBOUNCE) && !(actor->flags & MF_SLIDEME)) - actor->tracer->movedir = actor->extravalue1 >= 0 ? 1 : -1; + { + if (!actor->spawnpoint) + actor->tracer->movedir = (flickyflags & 8) ? 1 : -1; + else + actor->tracer->movedir = actor->extravalue1 >= 0 ? 1 : -1; + } } if (locvar1 == MT_FLICKY_08) From 0da21244c0b0f36da86509916aaee66c6966cf07 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 12 Aug 2018 14:30:49 +0100 Subject: [PATCH 061/573] Added "Tutorialmap" MainCfg option for SOC --- src/dehacked.c | 13 +++++++++++++ src/doomstat.h | 2 ++ src/g_game.c | 2 ++ src/m_menu.c | 2 -- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index fb0f958c3..28c86f56e 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2863,6 +2863,19 @@ static void readmaincfg(MYFILE *f) startchar = (INT16)value; char_on = -1; } + else if (fastcmp(word, "TUTORIALMAP")) + { + // Support using the actual map name, + // i.e., Level AB, Level FZ, etc. + + // Convert to map number + if (word2[0] >= 'A' && word2[0] <= 'Z') + value = M_MapNumber(word2[0], word2[1]); + else + value = get_number(word2); + + tutorialmap = (INT16)value; + } else deh_warning("Maincfg: unknown word '%s'", word); } diff --git a/src/doomstat.h b/src/doomstat.h index 24b9e5753..18ae04584 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -132,6 +132,8 @@ extern INT16 titlemap; extern boolean hidetitlepics; extern INT16 bootmap; //bootmap for loading a map on startup +extern INT16 tutorialmap; // map to load for tutorial + extern boolean looptitle; // CTF colors. diff --git a/src/g_game.c b/src/g_game.c index 52358a8b9..da6f1bbd1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -127,6 +127,8 @@ INT16 titlemap = 0; boolean hidetitlepics = false; INT16 bootmap; //bootmap for loading a map on startup +INT16 tutorialmap = 0; // map to load for tutorial + boolean looptitle = false; UINT8 skincolor_redteam = SKINCOLOR_RED; diff --git a/src/m_menu.c b/src/m_menu.c index f8324ab7e..ec7215d46 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6132,8 +6132,6 @@ static void M_LoadGameLevelSelect(INT32 choice) M_SetupNextMenu(&SP_LevelSelectDef); } -static INT32 tutorialmap = 1000; // MAPZ0, temporary value - // Starts up the tutorial immediately (tbh I wasn't sure where else to put this) static void M_StartTutorial(INT32 choice) { From 02d5e4e90262ea0725f4f4557a21988be922bcce Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 12:49:23 -0400 Subject: [PATCH 062/573] MT_FLICKY_CENTER flag adjustments --- src/info.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/info.c b/src/info.c index 1089cdd65..36a6b510e 100644 --- a/src/info.c +++ b/src/info.c @@ -13799,7 +13799,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -13853,7 +13853,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -13907,7 +13907,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -13961,7 +13961,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14015,7 +14015,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14069,7 +14069,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14123,7 +14123,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14177,7 +14177,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14231,7 +14231,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14285,7 +14285,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14339,7 +14339,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14393,7 +14393,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14447,7 +14447,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14501,7 +14501,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14555,7 +14555,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14609,7 +14609,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14663,7 +14663,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, @@ -14717,7 +14717,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags + MF_NOSECTOR|MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_SCENERY|MF_RUNSPAWNFUNC, // flags S_NULL // raisestate }, From 61999100e5c8a73e1d6304fc5add3979c1283f20 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 19:19:41 -0400 Subject: [PATCH 063/573] totalmarescore player variable for NiGHTS scoring --- src/d_player.h | 1 + src/lua_playerlib.c | 4 ++++ src/p_saveg.c | 2 ++ src/p_setup.c | 4 ++-- src/p_user.c | 2 ++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 7bee5f337..bc6a171d9 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -465,6 +465,7 @@ typedef struct player_s INT16 finishedrings; // The rings/stars you had left upon finishing the mare UINT32 marescore; // score for this nights stage UINT32 lastmarescore; // score for the last mare + UINT32 totalmarescore; // score for all mares UINT8 lastmare; // previous mare INT32 maxlink; // maximum link obtained UINT8 texttimer; // nights_texttime should not be local diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index ff62f2459..504097558 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -304,6 +304,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->marescore); else if (fastcmp(field,"lastmarescore")) lua_pushinteger(L, plr->lastmarescore); + else if (fastcmp(field,"totalmarescore")) + lua_pushinteger(L, plr->totalmarescore); else if (fastcmp(field,"lastmare")) lua_pushinteger(L, plr->lastmare); else if (fastcmp(field,"maxlink")) @@ -584,6 +586,8 @@ static int player_set(lua_State *L) plr->marescore = (UINT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"lastmarescore")) plr->lastmarescore = (UINT32)luaL_checkinteger(L, 3); + else if (fastcmp(field,"totalmarescore")) + plr->totalmarescore = (UINT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"lastmare")) plr->lastmare = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"maxlink")) diff --git a/src/p_saveg.c b/src/p_saveg.c index 7cf437384..6b2b61048 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -206,6 +206,7 @@ static void P_NetArchivePlayers(void) WRITEINT16(save_p, players[i].finishedrings); WRITEUINT32(save_p, players[i].marescore); WRITEUINT32(save_p, players[i].lastmarescore); + WRITEUINT32(save_p, players[i].totalmarescore); WRITEUINT8(save_p, players[i].lastmare); WRITEINT32(save_p, players[i].maxlink); WRITEUINT8(save_p, players[i].texttimer); @@ -395,6 +396,7 @@ static void P_NetUnArchivePlayers(void) players[i].finishedrings = READINT16(save_p); players[i].marescore = READUINT32(save_p); players[i].lastmarescore = READUINT32(save_p); + players[i].totalmarescore = READUINT32(save_p); players[i].lastmare = READUINT8(save_p); players[i].maxlink = READINT32(save_p); players[i].texttimer = READUINT8(save_p); diff --git a/src/p_setup.c b/src/p_setup.c index c62f281b3..285e4d22d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2385,8 +2385,8 @@ static void P_LevelInitStuff(void) players[i].texttimer = players[i].linkcount =\ players[i].linktimer = players[i].flyangle =\ players[i].anotherflyangle = players[i].nightstime =\ - players[i].mare = players[i].realtime =\ - players[i].exiting = 0; + players[i].mare = players[i].totalmarescore =\ + players[i].realtime = players[i].exiting = 0; // i guess this could be part of the above but i feel mildly uncomfortable implicitly casting players[i].gotcontinue = false; diff --git a/src/p_user.c b/src/p_user.c index fd09b0847..6728a3c54 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -725,6 +725,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) G_AddTempNightsRecords(players[i].marescore, leveltime - player->marebegunat, players[i].mare + 1); // transfer scores anyway + players[i].totalmarescore += players[i].marescore; players[i].lastmarescore = players[i].marescore; players[i].marescore = 0; @@ -748,6 +749,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) G_AddTempNightsRecords(player->marescore, leveltime - player->marebegunat, (UINT8)(oldmare + 1)); // Starting a new mare, transfer scores + player->totalmarescore += players[i].marescore; player->lastmarescore = player->marescore; player->marescore = 0; player->marebegunat = leveltime; From 30d57eac7912a7a99e506a4c975566ccefe444b0 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 19:23:23 -0400 Subject: [PATCH 064/573] NiGHTS bonus implementation --- src/dehacked.c | 3 +++ src/y_inter.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index fb0f958c3..35b0ce4b1 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1196,6 +1196,9 @@ static void readlevelheader(MYFILE *f, INT32 num) else if (fastcmp(word2, "NORMAL")) i = 0; else if (fastcmp(word2, "BOSS")) i = 1; else if (fastcmp(word2, "ERZ3")) i = 2; + else if (fastcmp(word2, "NIGHTS")) i = 3; + else if (fastcmp(word2, "NIGHTSLINK")) i = 4; + else if (fastcmp(word2, "NIGHTSALL")) i = 5; if (i >= -1 && i <= 2) // -1 for no bonus. Max is 2. mapheaderinfo[num-1]->bonustype = (SINT8)i; diff --git a/src/y_inter.c b/src/y_inter.c index 68dda198c..b3603bb34 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1754,6 +1754,16 @@ static void Y_SetRingBonus(player_t *player, y_bonus_t *bstruct) bstruct->points = max(0, (player->rings) * 100); } +// +// Y_SetNightsBonus +// +static void Y_SetNightsBonus(player_t *player, y_bonus_t *bstruct) +{ + strncpy(bstruct->patch, "YB_NIGHT", sizeof(bstruct->patch)); + bstruct->display = true; + bstruct->points = player->totalmarescore; +} + // // Y_SetLinkBonus // @@ -1815,7 +1825,7 @@ static void Y_SetPerfectBonus(player_t *player, y_bonus_t *bstruct) // This list can be extended in the future with SOC/Lua, perhaps. typedef void (*bonus_f)(player_t *, y_bonus_t *); -bonus_f bonuses_list[4][4] = { +bonus_f bonuses_list[7][4] = { { Y_SetNullBonus, Y_SetNullBonus, @@ -1840,6 +1850,24 @@ bonus_f bonuses_list[4][4] = { Y_SetRingBonus, Y_SetPerfectBonus, }, + { + Y_SetNullBonus, + Y_SetNightsBonus, + Y_SetNullBonus, + Y_SetNullBonus, + }, + { + Y_SetNullBonus, + Y_SetLinkBonus, + Y_SetNullBonus, + Y_SetNullBonus, + }, + { + Y_SetNullBonus, + Y_SetNightsBonus, + Y_SetLinkBonus, + Y_SetNullBonus, + }, }; From 372fc540bccf12bc3df9659a18c51d0bf6610aaa Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 19:26:18 -0400 Subject: [PATCH 065/573] Totalmarescore typo --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 6728a3c54..d8f096109 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -749,7 +749,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) G_AddTempNightsRecords(player->marescore, leveltime - player->marebegunat, (UINT8)(oldmare + 1)); // Starting a new mare, transfer scores - player->totalmarescore += players[i].marescore; + player->totalmarescore += player->marescore; player->lastmarescore = player->marescore; player->marescore = 0; player->marebegunat = leveltime; From feadcbfc949076caa74554e561f2464a0df32742 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 19:29:35 -0400 Subject: [PATCH 066/573] BONUSTYPE typo; bonus alignment --- src/dehacked.c | 2 +- src/y_inter.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 35b0ce4b1..41d41405c 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1200,7 +1200,7 @@ static void readlevelheader(MYFILE *f, INT32 num) else if (fastcmp(word2, "NIGHTSLINK")) i = 4; else if (fastcmp(word2, "NIGHTSALL")) i = 5; - if (i >= -1 && i <= 2) // -1 for no bonus. Max is 2. + if (i >= -1 && i <= 5) // -1 for no bonus. Max is 2. mapheaderinfo[num-1]->bonustype = (SINT8)i; else deh_warning("Level header %d: invalid bonus type number %d", num, i); diff --git a/src/y_inter.c b/src/y_inter.c index b3603bb34..de0335523 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1852,14 +1852,14 @@ bonus_f bonuses_list[7][4] = { }, { Y_SetNullBonus, - Y_SetNightsBonus, Y_SetNullBonus, + Y_SetNightsBonus, Y_SetNullBonus, }, { Y_SetNullBonus, - Y_SetLinkBonus, Y_SetNullBonus, + Y_SetLinkBonus, Y_SetNullBonus, }, { From fe904b0eb28ba4d32280a86c5ee0364c67f14710 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 19:45:34 -0400 Subject: [PATCH 067/573] NiGHTS lap score bonus --- src/dehacked.c | 6 ++++-- src/y_inter.c | 26 ++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 41d41405c..c672cbee4 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1198,9 +1198,11 @@ static void readlevelheader(MYFILE *f, INT32 num) else if (fastcmp(word2, "ERZ3")) i = 2; else if (fastcmp(word2, "NIGHTS")) i = 3; else if (fastcmp(word2, "NIGHTSLINK")) i = 4; - else if (fastcmp(word2, "NIGHTSALL")) i = 5; + else if (fastcmp(word2, "NIGHTSLAP")) i = 5; + else if (fastcmp(word2, "NIGHTSLINKLAP")) i = 6; + else if (fastcmp(word2, "NIGHTSALL")) i = 7; - if (i >= -1 && i <= 5) // -1 for no bonus. Max is 2. + if (i >= -1 && i <= 7) // -1 for no bonus. Max is 2. mapheaderinfo[num-1]->bonustype = (SINT8)i; else deh_warning("Level header %d: invalid bonus type number %d", num, i); diff --git a/src/y_inter.c b/src/y_inter.c index de0335523..f34bc06c0 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1764,6 +1764,16 @@ static void Y_SetNightsBonus(player_t *player, y_bonus_t *bstruct) bstruct->points = player->totalmarescore; } +// +// Y_SetLapBonus +// +static void Y_SetLapBonus(player_t *player, y_bonus_t *bstruct) +{ + strncpy(bstruct->patch, "YB_LAP", sizeof(bstruct->patch)); + bstruct->display = true; + bstruct->points = max(0, (player->totalmarebonuslap) * 100); +} + // // Y_SetLinkBonus // @@ -1825,7 +1835,7 @@ static void Y_SetPerfectBonus(player_t *player, y_bonus_t *bstruct) // This list can be extended in the future with SOC/Lua, perhaps. typedef void (*bonus_f)(player_t *, y_bonus_t *); -bonus_f bonuses_list[7][4] = { +bonus_f bonuses_list[9][4] = { { Y_SetNullBonus, Y_SetNullBonus, @@ -1862,11 +1872,23 @@ bonus_f bonuses_list[7][4] = { Y_SetLinkBonus, Y_SetNullBonus, }, + { + Y_SetNullBonus, + Y_SetNullBonus, + Y_SetLapBonus, + Y_SetNullBonus, + }, + { + Y_SetNullBonus, + Y_SetLinkBonus, + Y_SetLapBonus, + Y_SetNullBonus, + }, { Y_SetNullBonus, Y_SetNightsBonus, Y_SetLinkBonus, - Y_SetNullBonus, + Y_SetLapBonus, }, }; From fcd6b16646f9fa02dc439540790ae90b574fac11 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 20:08:17 -0400 Subject: [PATCH 068/573] Make lap bonus more valuable --- src/y_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index f34bc06c0..9c0cc758d 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1771,7 +1771,7 @@ static void Y_SetLapBonus(player_t *player, y_bonus_t *bstruct) { strncpy(bstruct->patch, "YB_LAP", sizeof(bstruct->patch)); bstruct->display = true; - bstruct->points = max(0, (player->totalmarebonuslap) * 100); + bstruct->points = max(0, player->totalmarebonuslap * 1000); } // From 89f57cb111a9fc6043a8db98ecf4ce728f863219 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 20:25:35 -0400 Subject: [PATCH 069/573] Have just one NiGHTS bonus option: NIGHTS and LINK together --- src/dehacked.c | 4 +--- src/y_inter.c | 14 +------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 41d41405c..70a19eadc 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1197,10 +1197,8 @@ static void readlevelheader(MYFILE *f, INT32 num) else if (fastcmp(word2, "BOSS")) i = 1; else if (fastcmp(word2, "ERZ3")) i = 2; else if (fastcmp(word2, "NIGHTS")) i = 3; - else if (fastcmp(word2, "NIGHTSLINK")) i = 4; - else if (fastcmp(word2, "NIGHTSALL")) i = 5; - if (i >= -1 && i <= 5) // -1 for no bonus. Max is 2. + if (i >= -1 && i <= 3) // -1 for no bonus. Max is 3. mapheaderinfo[num-1]->bonustype = (SINT8)i; else deh_warning("Level header %d: invalid bonus type number %d", num, i); diff --git a/src/y_inter.c b/src/y_inter.c index de0335523..2cafed8ca 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1825,7 +1825,7 @@ static void Y_SetPerfectBonus(player_t *player, y_bonus_t *bstruct) // This list can be extended in the future with SOC/Lua, perhaps. typedef void (*bonus_f)(player_t *, y_bonus_t *); -bonus_f bonuses_list[7][4] = { +bonus_f bonuses_list[5][4] = { { Y_SetNullBonus, Y_SetNullBonus, @@ -1850,18 +1850,6 @@ bonus_f bonuses_list[7][4] = { Y_SetRingBonus, Y_SetPerfectBonus, }, - { - Y_SetNullBonus, - Y_SetNullBonus, - Y_SetNightsBonus, - Y_SetNullBonus, - }, - { - Y_SetNullBonus, - Y_SetNullBonus, - Y_SetLinkBonus, - Y_SetNullBonus, - }, { Y_SetNullBonus, Y_SetNightsBonus, From 54343bc05f257e236de6fc92f51f61e7688c5ae6 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 20:36:53 -0400 Subject: [PATCH 070/573] Change special stage bonus to NiGHTS in-level score, per MB --- src/y_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index 2cafed8ca..915d6b810 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1930,7 +1930,7 @@ static void Y_AwardSpecialStageBonus(void) if (!playeringame[i] || players[i].lives < 1) // not active or game over Y_SetNullBonus(&players[i], &localbonus); else if (maptol & TOL_NIGHTS) // Link instead of Rings - Y_SetLinkBonus(&players[i], &localbonus); + Y_SetNightsBonus(&players[i], &localbonus); else Y_SetRingBonus(&players[i], &localbonus); players[i].score += localbonus.points; From c3e02670294954f2b6ba220f7c4b03fb446d7e71 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 12 Aug 2018 23:03:12 -0400 Subject: [PATCH 071/573] Fix attraction bug on non-NiGHTS and Nightopian Helper * Switch from mo->movecount to mo->movefactor for type compat * Adjust timings for regular and paraloop attraction --- src/p_inter.c | 4 ++-- src/p_mobj.c | 14 +++++++------- src/p_user.c | 5 ++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index f93a190af..46c7aeb7a 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -946,7 +946,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Yay! The thing's in reach! Pull it in! mo2->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; mo2->flags2 |= MF2_NIGHTSPULL; - mo2->movecount = 24*FRACUNIT; // initialize the NightsItemChase timer + mo2->movefactor = 32*FRACUNIT; // initialize the NightsItemChase timer P_SetTarget(&mo2->tracer, toucher); } } @@ -2127,7 +2127,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget if (target->flags2 & MF2_NIGHTSPULL) { P_SetTarget(&target->tracer, NULL); - target->movecount = 0; // reset NightsItemChase timer + target->movefactor = 0; // reset NightsItemChase timer } // dead target is no more shootable diff --git a/src/p_mobj.c b/src/p_mobj.c index d80d967a8..ac6091dc7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6120,11 +6120,11 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y if (dist < 1) dist = 1; - if (nightsgrab && dest->player->powers[pw_carry] == CR_NIGHTSMODE) + if (nightsgrab && source->movefactor) { - source->movecount += FRACUNIT/2; + source->movefactor += FRACUNIT/2; - if (dist < source->movecount) + if (dist < source->movefactor) { source->momx = source->momy = source->momz = 0; P_TeleportMove(source, tx, ty, tz); @@ -6133,9 +6133,9 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y { vangle = R_PointToAngle2(source->z, 0, tz, xydist); - source->momx = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINECOSINE(source->angle >> ANGLETOFINESHIFT), source->movecount)); - source->momy = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINESINE(source->angle >> ANGLETOFINESHIFT), source->movecount)); - source->momz = FixedMul(FINECOSINE(vangle >> ANGLETOFINESHIFT), source->movecount); + source->momx = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINECOSINE(source->angle >> ANGLETOFINESHIFT), source->movefactor)); + source->momy = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINESINE(source->angle >> ANGLETOFINESHIFT), source->movefactor)); + source->momz = FixedMul(FINECOSINE(vangle >> ANGLETOFINESHIFT), source->movefactor); } } else @@ -6173,7 +6173,7 @@ static void P_NightsItemChase(mobj_t *thing) { P_SetTarget(&thing->tracer, NULL); thing->flags2 &= ~MF2_NIGHTSPULL; - //thing->movecount = 0; + thing->movefactor = 0; return; } diff --git a/src/p_user.c b/src/p_user.c index b363cb930..2962ca5ad 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9770,13 +9770,16 @@ void P_PlayerThink(player_t *player) || mo2->type == MT_NIGHTSCHIP || mo2->type == MT_NIGHTSSTAR)) continue; + if (mo2->flags2 & MF2_NIGHTSPULL) + continue; + if (P_AproxDistance(P_AproxDistance(mo2->x - x, mo2->y - y), mo2->z - z) > FixedMul(128*FRACUNIT, player->mo->scale)) continue; // Yay! The thing's in reach! Pull it in! mo2->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; mo2->flags2 |= MF2_NIGHTSPULL; - mo2->movecount = 24*FRACUNIT; // initialize NightsItemChase timer + mo2->movefactor = 40*FRACUNIT; // initialize the NightsItemChase timer P_SetTarget(&mo2->tracer, player->mo); } } From f1fc205b31248e40179b61b27ac8e634583fd247 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 13 Aug 2018 11:12:53 -0400 Subject: [PATCH 072/573] Deduct marescore when player hits ground * ~~For speedrunning~~: Land on the Drone, keep your points! --- src/p_inter.c | 10 ++++------ src/p_user.c | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index ce8bba6b6..120f17569 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -3311,12 +3311,10 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da } else if (player->powers[pw_carry] == CR_NIGHTSFALL) { - if (player->spheres > 0) - { - damage = player->spheres; - P_RingDamage(player, inflictor, source, damage, damagetype, true); - damage = 0; - } + // always damage so we can recoil upon losing points + damage = player->spheres; + P_RingDamage(player, inflictor, source, damage, damagetype, true); + damage = 0; } else if (player->rings > 0) // No shield but have rings. { diff --git a/src/p_user.c b/src/p_user.c index fd09b0847..140c60acd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -590,10 +590,6 @@ static void P_DeNightserizePlayer(player_t *player) else if (player == &players[secondarydisplayplayer]) localaiming2 = 0; - // If you screwed up, kiss your score and ring bonus goodbye. - player->marescore = 0; - player->rings = 0; - P_SetPlayerMobjState(player->mo, S_PLAY_FALL); // If in a special stage, add some preliminary exit time. @@ -605,6 +601,11 @@ static void P_DeNightserizePlayer(player_t *player) players[i].nightstime = 1; // force everyone else to fall too. player->exiting = 3*TICRATE; stagefailed = true; // NIGHT OVER + + // If you screwed up, kiss your score and ring bonus goodbye. + // But don't do this yet if not in special stage! Wait til we hit the ground. + player->marescore = 0; + player->rings = 0; } // Check to see if the player should be killed. @@ -7030,8 +7031,14 @@ static void P_MovePlayer(player_t *player) if (playeringame[i]) players[i].exiting = (14*TICRATE)/5 + 1; } - else if (player->spheres > 0) + else { + // Damage whether or not we have spheres, as player should recoil upon losing points P_DamageMobj(player->mo, NULL, NULL, 1, 0); + + // Now deduct our mare score! + player->marescore = 0; + player->rings = 0; + } player->powers[pw_carry] = CR_NONE; } } From 004cbe6a3d90b6391d38537bb144da51c0818168 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 13 Aug 2018 22:10:16 -0400 Subject: [PATCH 073/573] Whitespace --- src/p_spec.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index ea09bfe04..06bc55c50 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -105,10 +105,10 @@ static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t * static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); static void P_ResetFading(line_t *line, fade_t *data); #define P_RemoveFading(l) P_ResetFading(l, NULL); -static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, +static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, boolean dofadeinonly, INT32 line); -static void P_AddMasterFader(INT16 destvalue, INT16 speed, +static void P_AddMasterFader(INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, boolean dofadeinonly, INT32 line); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); @@ -3109,8 +3109,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) { if (sides[line->sidenum[0]].rowoffset>>FRACBITS > 0) - P_AddMasterFader(sides[line->sidenum[0]].textureoffset>>FRACBITS, - sides[line->sidenum[0]].rowoffset>>FRACBITS, + P_AddMasterFader(sides[line->sidenum[0]].textureoffset>>FRACBITS, + sides[line->sidenum[0]].rowoffset>>FRACBITS, (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT (line->flags & ML_BOUNCY), // handle FF_SOLID @@ -3120,8 +3120,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) else { P_RemoveFading(&lines[(INT32)(sectors[s].lines[j]-lines)]); - P_FindFakeFloorsDoAlpha(sides[line->sidenum[0]].textureoffset>>FRACBITS, - 0, // set alpha immediately + P_FindFakeFloorsDoAlpha(sides[line->sidenum[0]].textureoffset>>FRACBITS, + 0, // set alpha immediately (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT (line->flags & ML_BOUNCY), // handle FF_SOLID @@ -3132,7 +3132,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } break; } - + case 453: // Stop fading FOF { INT32 s, j; @@ -7145,7 +7145,7 @@ void T_Disappear(disappear_t *d) } /** Removes fadingdata from FOF control sector - * + * * \param line line to search for target faders * \param data pointer to set new fadingdata to. Can be NULL to erase. */ @@ -7161,7 +7161,7 @@ static void P_ResetFading(line_t *line, fade_t *data) { if (rover->master != line) continue; - + if(((fade_t *)rover->master->frontsector->fadingdata) != data) { if(&((fade_t *)rover->master->frontsector->fadingdata)->thinker) @@ -7253,7 +7253,7 @@ static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, if (speed < 1 || rover->alpha + speed >= destvalue - speed) { rover->alpha = destvalue; - + if (doexists) { if (rover->alpha <= 1) @@ -7289,7 +7289,7 @@ static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, else // continue fading in { rover->alpha += speed; - + if (doexists) rover->flags |= FF_EXISTS; @@ -7316,7 +7316,7 @@ static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, return result; } -static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, +static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, boolean dofadeinonly, INT32 line) { @@ -7349,7 +7349,7 @@ static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, * \param dofadeinonly enable flags when fade-in is finished; never on fade-out * \param line line to target FOF */ -static void P_AddMasterFader(INT16 destvalue, INT16 speed, +static void P_AddMasterFader(INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, boolean dofadeinonly, INT32 line) { @@ -7378,7 +7378,7 @@ static void P_AddMasterFader(INT16 destvalue, INT16 speed, */ void T_Fade(fade_t *d) { - INT32 affectedffloors = P_FindFakeFloorsDoAlpha(d->destvalue, d->speed, + INT32 affectedffloors = P_FindFakeFloorsDoAlpha(d->destvalue, d->speed, d->doexists, d->dotranslucent, d->dosolid, d->dospawnflags, d->dofadeinonly, d->affectee); From 841c31a6ba9fc81a418abf14c0d00536b237d4e2 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 13 Aug 2018 22:17:58 -0400 Subject: [PATCH 074/573] Attach fade_t thinker to proper control sector upon savegame load --- src/p_saveg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 50d636280..a1ce9c4b5 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2577,9 +2577,9 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->dospawnflags = READUINT8(save_p); ht->dofadeinonly = READUINT8(save_p); - sector_t *ffloorsector = LoadSector(ht->affectee); - if (ffloorsector) - ffloorsector->fadingdata = ht; + line_t *ffloorline = LoadLine(ht->affectee); + if (ffloorline && ffloorline->frontsector) + ffloorline->frontsector->fadingdata = ht; P_AddThinker(&ht->thinker); } From d53582596febe96b8413fa498f0b1b80e84853ab Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 14 Aug 2018 10:20:56 -0400 Subject: [PATCH 075/573] Preproc comment out Y_SetLinkBonus because unused --- src/y_inter.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/y_inter.c b/src/y_inter.c index d2fa2e668..3fdf5f7a9 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1774,6 +1774,7 @@ static void Y_SetLapBonus(player_t *player, y_bonus_t *bstruct) bstruct->points = max(0, player->totalmarebonuslap * 1000); } +#if 0 // // Y_SetLinkBonus // @@ -1783,6 +1784,7 @@ static void Y_SetLinkBonus(player_t *player, y_bonus_t *bstruct) bstruct->display = true; bstruct->points = max(0, (player->maxlink - 1) * 100); } +#endif // // Y_SetGuardBonus From 62a6fe845dc92fd89962da4bcae6c6f1a5676b29 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 14 Aug 2018 10:48:50 -0400 Subject: [PATCH 076/573] Add ML_BOUNCY flag to Bonus Time executor to execute BEFORE the capsule is destroyed and player has enough spheres --- src/p_spec.c | 14 ++++++++------ src/p_spec.h | 2 +- src/p_user.c | 5 ++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index d4a2b45ce..3ea021bce 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1420,13 +1420,15 @@ void P_RunNightsLapExecutors(mobj_t *actor) // // P_RunNightsBonusTimeExecutors // -void P_RunNightsBonusTimeExecutors(mobj_t *actor) +void P_RunNightsBonusTimeExecutors(mobj_t *actor, boolean preblowup) { size_t i; for (i = 0; i < numlines; i++) { - if (lines[i].special == 329 || lines[i].special == 330) + if ((lines[i].special == 329 || lines[i].special == 330) + && ((preblowup && (lines[i].flags & ML_BOUNCY)) + || (!preblowup && !(lines[i].flags & ML_BOUNCY)))) P_RunTriggerLinedef(&lines[i], actor, NULL); } } @@ -1574,8 +1576,8 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) } // Get current mare and lap (and check early return for DeNightserize) - if (perglobal || perglobalinverse - || (specialtype >= 325 && specialtype <= 326 && (fromnonights || fromnights))) + if (perglobal || perglobalinverse + || (specialtype >= 325 && specialtype <= 326 && (fromnonights || fromnights))) { UINT8 playersarenights = 0; @@ -1604,7 +1606,7 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) currentmare = players[i].mare; currentlap = UINT8_MAX; } - if (players[i].mare == currentmare + if (players[i].mare == currentmare && (lap > currentlap || currentlap == UINT8_MAX)) currentlap = lap; } @@ -1616,7 +1618,7 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) currentmare = players[i].mare; currentlap = UINT8_MAX; } - if (players[i].mare == currentmare + if (players[i].mare == currentmare && (lap < currentlap || currentlap == UINT8_MAX)) currentlap = lap; } diff --git a/src/p_spec.h b/src/p_spec.h index 5bcf25b7b..0767851e1 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -69,7 +69,7 @@ void P_ChangeSectorTag(UINT32 sector, INT16 newtag); void P_RunNightserizeExecutors(mobj_t *actor); void P_RunDeNightserizeExecutors(mobj_t *actor); void P_RunNightsLapExecutors(mobj_t *actor); -void P_RunNightsBonusTimeExecutors(mobj_t *actor); +void P_RunNightsBonusTimeExecutors(mobj_t *actor, boolean preblowup); ffloor_t *P_GetFFloorByID(sector_t *sec, UINT16 id); diff --git a/src/p_user.c b/src/p_user.c index 6b8901ac7..018387284 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6014,6 +6014,9 @@ static void P_DoNiGHTSCapsule(player_t *player) { if (player->spheres > 0) { + if (player->capsule->extravalue1 <= 0 && player->spheres >= player->capsule->health) + P_RunNightsBonusTimeExecutors(player->mo, true); + player->spheres--; player->capsule->health--; player->capsule->extravalue1++; @@ -6099,7 +6102,7 @@ static void P_DoNiGHTSCapsule(player_t *player) P_SetTarget(&players[i].capsule, NULL); // Remove capsule from everyone now that it is dead! S_StartScreamSound(player->mo, sfx_ngdone); P_SwitchSpheresBonusMode(true); - P_RunNightsBonusTimeExecutors(player->mo); + P_RunNightsBonusTimeExecutors(player->mo, false); } } else From 8c57218027734564e459c743f57b29174489349d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 14 Aug 2018 11:06:09 -0400 Subject: [PATCH 077/573] Alternate take on pre-blowup: Do it on first touching tic, instead of first ring pop * Use MT_EGGCAPSULE extravalue2 for tic timer --- src/p_mobj.c | 3 ++- src/p_user.c | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 4353e67c3..b88692d76 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8751,7 +8751,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) nummaprings = -1; // no perfect bonus, rings are free break; case MT_EGGCAPSULE: - mobj->extravalue1 = -1; // timer for how long a player has been at the capsule + mobj->extravalue1 = -1; // sphere timer for how long a player has been at the capsule + mobj->extravalue2 = -1; // tic timer for how long a player has been at the capsule break; case MT_REDTEAMRING: mobj->color = skincolor_redteam; diff --git a/src/p_user.c b/src/p_user.c index 018387284..e3b6f2261 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5946,6 +5946,8 @@ static void P_DoNiGHTSCapsule(player_t *player) { INT32 i; + player->capsule->extravalue2++; // tic counter + if (abs(player->mo->x-player->capsule->x) <= 2*FRACUNIT) { P_UnsetThingPosition(player->mo); @@ -6007,6 +6009,9 @@ static void P_DoNiGHTSCapsule(player_t *player) } } + if (player->capsule->extravalue2 <= 0 && player->spheres >= player->capsule->health) + P_RunNightsBonusTimeExecutors(player->mo, true); // run pre-blowup executors + // Time to blow it up! if (player->mo->x == player->capsule->x && player->mo->y == player->capsule->y @@ -6014,9 +6019,6 @@ static void P_DoNiGHTSCapsule(player_t *player) { if (player->spheres > 0) { - if (player->capsule->extravalue1 <= 0 && player->spheres >= player->capsule->health) - P_RunNightsBonusTimeExecutors(player->mo, true); - player->spheres--; player->capsule->health--; player->capsule->extravalue1++; @@ -6033,7 +6035,7 @@ static void P_DoNiGHTSCapsule(player_t *player) player->capsule->flags &= ~MF_NOGRAVITY; player->capsule->momz = 5*FRACUNIT; player->capsule->reactiontime = 0; - player->capsule->extravalue1 = -1; + player->capsule->extravalue1 = player->capsule->extravalue2 = -1; for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && !player->exiting && players[i].mare == player->mare) @@ -6102,7 +6104,7 @@ static void P_DoNiGHTSCapsule(player_t *player) P_SetTarget(&players[i].capsule, NULL); // Remove capsule from everyone now that it is dead! S_StartScreamSound(player->mo, sfx_ngdone); P_SwitchSpheresBonusMode(true); - P_RunNightsBonusTimeExecutors(player->mo, false); + P_RunNightsBonusTimeExecutors(player->mo, false); // run post blow-up executors } } else @@ -6111,11 +6113,11 @@ static void P_DoNiGHTSCapsule(player_t *player) player->texttimer = 4*TICRATE; player->textvar = 3; // Get more rings! player->capsule->reactiontime = 0; - player->capsule->extravalue1 = -1; + player->capsule->extravalue1 = player->capsule->extravalue2 = -1; } } else - player->capsule->extravalue1 = -1; + player->capsule->extravalue1 = player->capsule->extravalue2 = -1; } // From 3f312ce114afbc5aabdbd5c52a8016bfd5dc9376 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 14 Aug 2018 12:00:37 -0400 Subject: [PATCH 078/573] Make Bonus Time Start executor into a general Egg Capsule Touch executor * Entrance/exit flags * Enough/not-enough-rings flags (with "doesn't matter" line option) --- src/p_spec.c | 11 +++++++---- src/p_spec.h | 2 +- src/p_user.c | 7 ++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 3ea021bce..617625fc1 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1418,17 +1418,20 @@ void P_RunNightsLapExecutors(mobj_t *actor) } // -// P_RunNightsBonusTimeExecutors +// P_RunNightsCapsuleTouchExecutors // -void P_RunNightsBonusTimeExecutors(mobj_t *actor, boolean preblowup) +void P_RunNightsCapsuleTouchExecutors(mobj_t *actor, boolean entering, boolean enoughspheres) { size_t i; for (i = 0; i < numlines; i++) { if ((lines[i].special == 329 || lines[i].special == 330) - && ((preblowup && (lines[i].flags & ML_BOUNCY)) - || (!preblowup && !(lines[i].flags & ML_BOUNCY)))) + && ((entering && (lines[i].flags & ML_TFERLINE)) + || (!entering && !(lines[i].flags & ML_TFERLINE))) + && ((lines[i].flags & ML_DONTPEGTOP) + || (enoughspheres && !(lines[i].flags & ML_BOUNCY)) + || (!enoughspheres && (lines[i].flags & ML_BOUNCY)))) P_RunTriggerLinedef(&lines[i], actor, NULL); } } diff --git a/src/p_spec.h b/src/p_spec.h index 0767851e1..e0bcc18eb 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -69,7 +69,7 @@ void P_ChangeSectorTag(UINT32 sector, INT16 newtag); void P_RunNightserizeExecutors(mobj_t *actor); void P_RunDeNightserizeExecutors(mobj_t *actor); void P_RunNightsLapExecutors(mobj_t *actor); -void P_RunNightsBonusTimeExecutors(mobj_t *actor, boolean preblowup); +void P_RunNightsCapsuleTouchExecutors(mobj_t *actor, boolean entering, boolean enoughspheres); ffloor_t *P_GetFFloorByID(sector_t *sec, UINT16 id); diff --git a/src/p_user.c b/src/p_user.c index e3b6f2261..7e678fb61 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6009,8 +6009,8 @@ static void P_DoNiGHTSCapsule(player_t *player) } } - if (player->capsule->extravalue2 <= 0 && player->spheres >= player->capsule->health) - P_RunNightsBonusTimeExecutors(player->mo, true); // run pre-blowup executors + if (player->capsule->extravalue2 <= 0) + P_RunNightsCapsuleTouchExecutors(player->mo, true, player->spheres >= player->capsule->health); // run capsule entrance executors // Time to blow it up! if (player->mo->x == player->capsule->x @@ -6104,7 +6104,7 @@ static void P_DoNiGHTSCapsule(player_t *player) P_SetTarget(&players[i].capsule, NULL); // Remove capsule from everyone now that it is dead! S_StartScreamSound(player->mo, sfx_ngdone); P_SwitchSpheresBonusMode(true); - P_RunNightsBonusTimeExecutors(player->mo, false); // run post blow-up executors + P_RunNightsCapsuleTouchExecutors(player->mo, false, true); // run capsule exit executors, and we destroyed it } } else @@ -6114,6 +6114,7 @@ static void P_DoNiGHTSCapsule(player_t *player) player->textvar = 3; // Get more rings! player->capsule->reactiontime = 0; player->capsule->extravalue1 = player->capsule->extravalue2 = -1; + P_RunNightsCapsuleTouchExecutors(player->mo, false, false); // run capsule exit executors, and we lacked rings } } else From efdf68477091392c4aa3522f375cba14a2c16b41 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 14 Aug 2018 12:48:00 -0400 Subject: [PATCH 079/573] Fix Capsule Entrance exec firing repeatedly --- src/p_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 7e678fb61..f202ff97f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6009,7 +6009,7 @@ static void P_DoNiGHTSCapsule(player_t *player) } } - if (player->capsule->extravalue2 <= 0) + if (player->capsule->extravalue2 <= 0 && player->capsule->health > 0) P_RunNightsCapsuleTouchExecutors(player->mo, true, player->spheres >= player->capsule->health); // run capsule entrance executors // Time to blow it up! @@ -6118,7 +6118,7 @@ static void P_DoNiGHTSCapsule(player_t *player) } } else - player->capsule->extravalue1 = player->capsule->extravalue2 = -1; + player->capsule->extravalue1 = -1; } // From c3703cfc246adb62c2b4939869539448b0eaa2c5 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 14 Aug 2018 14:57:58 -0400 Subject: [PATCH 080/573] Comments --- src/p_spec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 617625fc1..66fedeab5 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1871,8 +1871,8 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller case 326: // denightserize - once case 327: // nights lap - each time case 328: // nights lap - once - case 329: // nights bonus time - each time - case 330: // nights bonus time - once + case 329: // nights egg capsule touch - each time + case 330: // nights egg capsule touch - once if (!P_CheckNightsTriggerLine(triggerline, actor)) return false; break; From 61c84be70445c61c8907ca5bc647f574a5623342 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 14 Aug 2018 16:08:21 -0400 Subject: [PATCH 081/573] Fix bonus time quirk where lines are run if player->marebonuslap is 0 * Bonus laps start at 1, so if a line is looking for bonus laps, they should only be run at >= 1. --- src/p_spec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index 66fedeab5..e70aec650 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1641,6 +1641,9 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) currentlap = lapfrombonustime ? actor->player->marebonuslap : actor->player->marelap; } + if (lapfrombonustime && !currentlap) + return false; // special case: player->marebonuslap is 0 until passing through on bonus time. Don't trigger lines looking for inputlap 0. + // Compare current mare/lap to input mare/lap based on rules if (!(specialtype >= 323 && specialtype <= 324 && donomares) // don't return false if donomares and we got this far && ((ltemare && currentmare > inputmare) From 931297e2d72d56f57d9179624f30f37f1606d3a9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 14 Aug 2018 10:18:08 -0400 Subject: [PATCH 082/573] Rename dofadeinonly to doghostfade * Ghost fading: when transitioning to/from alpha=0, don't set solid/tangibility until fade is finished --- src/p_saveg.c | 4 ++-- src/p_spec.c | 18 +++++++++--------- src/p_spec.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index a1ce9c4b5..70c6b411e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1573,7 +1573,7 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) WRITEUINT8(save_p, ht->dotranslucent); WRITEUINT8(save_p, ht->dosolid); WRITEUINT8(save_p, ht->dospawnflags); - WRITEUINT8(save_p, ht->dofadeinonly); + WRITEUINT8(save_p, ht->doghostfade); } // @@ -2575,7 +2575,7 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->dotranslucent = READUINT8(save_p); ht->dosolid = READUINT8(save_p); ht->dospawnflags = READUINT8(save_p); - ht->dofadeinonly = READUINT8(save_p); + ht->doghostfade = READUINT8(save_p); line_t *ffloorline = LoadLine(ht->affectee); if (ffloorline && ffloorline->frontsector) diff --git a/src/p_spec.c b/src/p_spec.c index 06bc55c50..0fa16f9f4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -107,10 +107,10 @@ static void P_ResetFading(line_t *line, fade_t *data); #define P_RemoveFading(l) P_ResetFading(l, NULL); static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, - boolean dofadeinonly, INT32 line); + boolean doghostfade, INT32 line); static void P_AddMasterFader(INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, - boolean dofadeinonly, INT32 line); + boolean doghostfade, INT32 line); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -7175,7 +7175,7 @@ static void P_ResetFading(line_t *line, fade_t *data) static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, - boolean dofadeinonly) + boolean doghostfade) { boolean result = false; @@ -7318,7 +7318,7 @@ static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, - boolean dofadeinonly, INT32 line) + boolean doghostfade, INT32 line) { ffloor_t *rover; register INT32 s; @@ -7331,7 +7331,7 @@ static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, if (rover->master != &lines[line]) continue; - affectedffloors += (INT32)P_DoFakeFloorAlpha(rover, destvalue, speed, doexists, dotranslucent, dosolid, dospawnflags, dofadeinonly); + affectedffloors += (INT32)P_DoFakeFloorAlpha(rover, destvalue, speed, doexists, dotranslucent, dosolid, dospawnflags, doghostfade); } } @@ -7346,12 +7346,12 @@ static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, * \param dotranslucent handle FF_TRANSLUCENT * \param dosolid handle FF_SOLID * \param dospawnflags handle spawnflags - * \param dofadeinonly enable flags when fade-in is finished; never on fade-out + * \param doghostfade enable flags when fade-in is finished; never on fade-out * \param line line to target FOF */ static void P_AddMasterFader(INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, - boolean dofadeinonly, INT32 line) + boolean doghostfade, INT32 line) { fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); @@ -7363,7 +7363,7 @@ static void P_AddMasterFader(INT16 destvalue, INT16 speed, d->dotranslucent = dotranslucent; d->dosolid = dosolid; d->dospawnflags = dospawnflags; - d->dofadeinonly = dofadeinonly; + d->doghostfade = doghostfade; // find any existing thinkers and remove them, then replace with new data P_ResetFading(&lines[d->affectee], d); @@ -7380,7 +7380,7 @@ void T_Fade(fade_t *d) { INT32 affectedffloors = P_FindFakeFloorsDoAlpha(d->destvalue, d->speed, d->doexists, d->dotranslucent, d->dosolid, d->dospawnflags, - d->dofadeinonly, d->affectee); + d->doghostfade, d->affectee); // no more ffloors to fade? remove myself if (affectedffloors == 0) diff --git a/src/p_spec.h b/src/p_spec.h index c8607f868..672b96f30 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -460,7 +460,7 @@ typedef struct boolean dotranslucent; ///< Handle FF_TRANSLUCENT handling boolean dosolid; ///< Handle FF_SOLID handling boolean dospawnflags; ///< Enable spawnflags handling - boolean dofadeinonly; ///< Set flags only when fade-in is finished; never during fade-out + boolean doghostfade; ///< Set flags only when fade-in is finished; never during fade-out } fade_t; void T_Fade(fade_t *d); From 52f5dbd52f1bec4eac3783c7b2a074989c4754b9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 17 Aug 2018 00:32:20 -0400 Subject: [PATCH 083/573] Checkpoint: Move fadingdata to line_t (or ffloor_t?) --- src/p_saveg.c | 4 +- src/p_spec.c | 110 +++++++++++++++++++++++++++++++++++--------------- 2 files changed, 80 insertions(+), 34 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 70c6b411e..eeb05d328 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2578,8 +2578,8 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->doghostfade = READUINT8(save_p); line_t *ffloorline = LoadLine(ht->affectee); - if (ffloorline && ffloorline->frontsector) - ffloorline->frontsector->fadingdata = ht; + if (ffloorline) + ffloorline->fadingdata = ht; P_AddThinker(&ht->thinker); } diff --git a/src/p_spec.c b/src/p_spec.c index 0fa16f9f4..89caf41f3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3103,43 +3103,89 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 452: // Fade FOF { - INT32 s, j; - for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;) - for (j = 0; (unsigned)j < sectors[s].linecount; j++) - if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) - { - if (sides[line->sidenum[0]].rowoffset>>FRACBITS > 0) - P_AddMasterFader(sides[line->sidenum[0]].textureoffset>>FRACBITS, - sides[line->sidenum[0]].rowoffset>>FRACBITS, - (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS - !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT - (line->flags & ML_BOUNCY), // handle FF_SOLID - (line->flags & ML_EFFECT1), // handle spawnflags - (line->flags & ML_EFFECT2), // enable flags on fade-in finish only - (INT32)(sectors[s].lines[j]-lines)); - else - { - P_RemoveFading(&lines[(INT32)(sectors[s].lines[j]-lines)]); - P_FindFakeFloorsDoAlpha(sides[line->sidenum[0]].textureoffset>>FRACBITS, - 0, // set alpha immediately - (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS - !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT - (line->flags & ML_BOUNCY), // handle FF_SOLID - (line->flags & ML_EFFECT1), // handle spawnflags - (line->flags & ML_EFFECT2), // enable flags on fade-in finish only - (INT32)(sectors[s].lines[j]-lines)); - } - } + INT16 destvalue = (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS); + INT16 speed = (INT16)(sides[line->sidenum[1]].rowoffset>>FRACBITS); + INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); + INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); + sector_t *sec; // Sector that the FOF is visible in + ffloor_t *rover; // FOF that we are going to crumble + + for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + { + sec = sectors + secnum; + + if (!sec->ffloors) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 452 Executor: Target sector #%d has no FOFs.\n", secnum); + return; + } + + for (rover = sec->ffloors; rover; rover = rover->next) + { + if (rover->master->frontsector->tag == foftag) + break; + } + + if (!rover) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 452 Executor: Can't find a FOF control sector with tag %d\n", foftag); + return; + } + + if (speed > 0) + P_AddMasterFader(destvalue, speed, + (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT + (line->flags & ML_BOUNCY), // handle FF_SOLID + (line->flags & ML_EFFECT1), // handle spawnflags + (line->flags & ML_EFFECT2), // enable flags on fade-in finish only + (INT32)(rover->master-lines)); + else + { + P_RemoveFading(&lines[(INT32)(sectors[s].lines[j]-lines)]); + P_FindFakeFloorsDoAlpha(destvalue, 0, // set alpha immediately + (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT + (line->flags & ML_BOUNCY), // handle FF_SOLID + (line->flags & ML_EFFECT1), // handle spawnflags + (line->flags & ML_EFFECT2), // enable flags on fade-in finish only + (INT32)(sectors[s].lines[j]-lines)); + } + } break; } case 453: // Stop fading FOF { - INT32 s, j; - for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;) - for (j = 0; (unsigned)j < sectors[s].linecount; j++) - if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) - P_RemoveFading(&lines[(INT32)(sectors[s].lines[j]-lines)]); + INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); + INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); + sector_t *sec; // Sector that the FOF is visible in + ffloor_t *rover; // FOF that we are going to crumble + + for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + { + sec = sectors + secnum; + + if (!sec->ffloors) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Target sector #%d has no FOFs.\n", secnum); + return; + } + + for (rover = sec->ffloors; rover; rover = rover->next) + { + if (rover->master->frontsector->tag == foftag) + break; + } + + if (!rover) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Can't find a FOF control sector with tag %d\n", foftag); + return; + } + + P_RemoveFading(&lines[(INT32)(sectors[s].lines[j]-lines)]); + } break; } From 2e252cb905c9e6db5c5537752e86f23fff26a5b8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 17 Aug 2018 00:32:20 -0400 Subject: [PATCH 084/573] Move fadingdata (fade_t thinker) to line_t --- src/p_saveg.c | 12 +++-- src/p_setup.c | 3 +- src/p_spec.c | 132 ++++++++++++++++++++++++++++++++------------------ src/r_defs.h | 3 +- 4 files changed, 97 insertions(+), 53 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 70c6b411e..f30c52bda 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2578,8 +2578,8 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->doghostfade = READUINT8(save_p); line_t *ffloorline = LoadLine(ht->affectee); - if (ffloorline && ffloorline->frontsector) - ffloorline->frontsector->fadingdata = ht; + if (ffloorline) + ffloorline->fadingdata = ht; P_AddThinker(&ht->thinker); } @@ -2770,7 +2770,13 @@ static void P_NetUnArchiveThinkers(void) // clear sector thinker pointers so they don't point to non-existant thinkers for all of eternity for (i = 0; i < numsectors; i++) { - sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = sectors[i].fadingdata = NULL; + sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = NULL; + } + + // same for line thinker pointers + for (i = 0; i < numlines; i++) + { + lines[i].fadingdata = NULL; } // read in saved thinkers diff --git a/src/p_setup.c b/src/p_setup.c index 67dbb8db7..5259394ee 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -693,7 +693,6 @@ static void P_LoadRawSectors(UINT8 *data, size_t i) ss->floordata = NULL; ss->ceilingdata = NULL; ss->lightingdata = NULL; - ss->fadingdata = NULL; ss->linecount = 0; ss->lines = NULL; @@ -1311,6 +1310,8 @@ static void P_LoadRawLineDefs(UINT8 *data, size_t i) #ifdef POLYOBJECTS ld->polyobj = NULL; #endif + + ld->fadingdata = NULL; } } diff --git a/src/p_spec.c b/src/p_spec.c index 0fa16f9f4..6f392bbfe 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3103,43 +3103,91 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 452: // Fade FOF { - INT32 s, j; - for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;) - for (j = 0; (unsigned)j < sectors[s].linecount; j++) - if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) - { - if (sides[line->sidenum[0]].rowoffset>>FRACBITS > 0) - P_AddMasterFader(sides[line->sidenum[0]].textureoffset>>FRACBITS, - sides[line->sidenum[0]].rowoffset>>FRACBITS, - (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS - !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT - (line->flags & ML_BOUNCY), // handle FF_SOLID - (line->flags & ML_EFFECT1), // handle spawnflags - (line->flags & ML_EFFECT2), // enable flags on fade-in finish only - (INT32)(sectors[s].lines[j]-lines)); - else - { - P_RemoveFading(&lines[(INT32)(sectors[s].lines[j]-lines)]); - P_FindFakeFloorsDoAlpha(sides[line->sidenum[0]].textureoffset>>FRACBITS, - 0, // set alpha immediately - (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS - !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT - (line->flags & ML_BOUNCY), // handle FF_SOLID - (line->flags & ML_EFFECT1), // handle spawnflags - (line->flags & ML_EFFECT2), // enable flags on fade-in finish only - (INT32)(sectors[s].lines[j]-lines)); - } - } + INT16 destvalue = (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS); + INT16 speed = (INT16)(sides[line->sidenum[1]].rowoffset>>FRACBITS); + INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); + INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); + sector_t *sec; // Sector that the FOF is visible in + ffloor_t *rover; // FOF that we are going to crumble + + for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + { + sec = sectors + secnum; + + if (!sec->ffloors) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 452 Executor: Target sector #%d has no FOFs.\n", secnum); + return; + } + + for (rover = sec->ffloors; rover; rover = rover->next) + { + if (rover->master->frontsector->tag == foftag) + break; + } + + if (!rover) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 452 Executor: Can't find a FOF control sector with tag %d\n", foftag); + return; + } + + if (speed > 0) + P_AddMasterFader(destvalue, speed, + (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT + (line->flags & ML_BOUNCY), // handle FF_SOLID + (line->flags & ML_EFFECT1), // handle spawnflags + (line->flags & ML_EFFECT2), // enable flags on fade-in finish only + (INT32)(rover->master-lines)); + else + { + P_RemoveFading(&lines[(INT32)(rover->master-lines)]); + P_FindFakeFloorsDoAlpha(destvalue, 0, // set alpha immediately + (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT + (line->flags & ML_BOUNCY), // handle FF_SOLID + (line->flags & ML_EFFECT1), // handle spawnflags + (line->flags & ML_EFFECT2), // enable flags on fade-in finish only + (INT32)(rover->master-lines)); + } + break; + } break; } case 453: // Stop fading FOF { - INT32 s, j; - for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;) - for (j = 0; (unsigned)j < sectors[s].linecount; j++) - if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) - P_RemoveFading(&lines[(INT32)(sectors[s].lines[j]-lines)]); + INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); + INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); + sector_t *sec; // Sector that the FOF is visible in + ffloor_t *rover; // FOF that we are going to crumble + + for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + { + sec = sectors + secnum; + + if (!sec->ffloors) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Target sector #%d has no FOFs.\n", secnum); + return; + } + + for (rover = sec->ffloors; rover; rover = rover->next) + { + if (rover->master->frontsector->tag == foftag) + break; + } + + if (!rover) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Can't find a FOF control sector with tag %d\n", foftag); + return; + } + + P_RemoveFading(&lines[(INT32)(rover->master-lines)]); + break; + } break; } @@ -7151,25 +7199,13 @@ void T_Disappear(disappear_t *d) */ static void P_ResetFading(line_t *line, fade_t *data) { - ffloor_t *rover; - register INT32 s; - // find any existing thinkers and remove them, then replace with new data - for (s = -1; (s = P_FindSectorFromLineTag(line, s)) >= 0 ;) + if(((fade_t *)line->fadingdata) != data) { - for (rover = sectors[s].ffloors; rover; rover = rover->next) - { - if (rover->master != line) - continue; + if(&((fade_t *)line->fadingdata)->thinker) + P_RemoveThinker(&((fade_t *)line->fadingdata)->thinker); - if(((fade_t *)rover->master->frontsector->fadingdata) != data) - { - if(&((fade_t *)rover->master->frontsector->fadingdata)->thinker) - P_RemoveThinker(&((fade_t *)rover->master->frontsector->fadingdata)->thinker); - - rover->master->frontsector->fadingdata = data; - } - } + line->fadingdata = data; } } diff --git a/src/r_defs.h b/src/r_defs.h index b4c7d2112..c425f3a3b 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -308,7 +308,6 @@ typedef struct sector_s void *floordata; // floor move thinker void *ceilingdata; // ceiling move thinker void *lightingdata; // lighting change thinker - void *fadingdata; // fading FOF thinker // floor and ceiling texture offsets fixed_t floor_xoffs, floor_yoffs; @@ -444,6 +443,8 @@ typedef struct line_s char *text; // a concatination of all front and back texture names, for linedef specials that require a string. INT16 callcount; // no. of calls left before triggering, for the "X calls" linedef specials, defaults to 0 + + void *fadingdata; // fading FOF thinker } line_t; // From 677f19ede6680bffc5e97253b48e70d55fd403f4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 17 Aug 2018 02:28:52 -0400 Subject: [PATCH 085/573] Move fading thinker to ffloor_t.fadingdata --- src/p_saveg.c | 31 ++++++++++------ src/p_setup.c | 2 - src/p_spec.c | 101 +++++++++++++++++++------------------------------- src/p_spec.h | 6 ++- src/r_defs.h | 4 +- 5 files changed, 65 insertions(+), 79 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index f30c52bda..daa6bb937 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1566,7 +1566,8 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) { const fade_t *ht = (const void *)th; WRITEUINT8(save_p, type); - WRITEINT32(save_p, ht->affectee); + WRITEINT32(save_p, ht->sectornum); + WRITEINT32(save_p, ht->ffloornum); WRITEINT16(save_p, ht->destvalue); WRITEINT16(save_p, ht->speed); WRITEUINT8(save_p, ht->doexists); @@ -2568,7 +2569,8 @@ static inline void LoadFadeThinker(actionf_p1 thinker) { fade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; - ht->affectee = READINT32(save_p); + ht->sectornum = READINT32(save_p); + ht->ffloornum = READINT32(save_p); ht->destvalue = READINT16(save_p); ht->speed = READINT16(save_p); ht->doexists = READUINT8(save_p); @@ -2577,9 +2579,22 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->dospawnflags = READUINT8(save_p); ht->doghostfade = READUINT8(save_p); - line_t *ffloorline = LoadLine(ht->affectee); - if (ffloorline) - ffloorline->fadingdata = ht; + sector_t *ss = LoadSector(ht->sectornum); + if (ss) + { + size_t j = 0; // ss->ffloors is saved as ffloor #0, ss->ffloors->next is #1, etc + ffloor_t *rover; + for (rover = ss->ffloors; rover; rover = rover->next) + { + if (j == ht->ffloornum) + { + ht->rover = rover; + rover->fadingdata = ht; + break; + } + j++; + } + } P_AddThinker(&ht->thinker); } @@ -2773,12 +2788,6 @@ static void P_NetUnArchiveThinkers(void) sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = NULL; } - // same for line thinker pointers - for (i = 0; i < numlines; i++) - { - lines[i].fadingdata = NULL; - } - // read in saved thinkers for (;;) { diff --git a/src/p_setup.c b/src/p_setup.c index 5259394ee..c62f281b3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1310,8 +1310,6 @@ static void P_LoadRawLineDefs(UINT8 *data, size_t i) #ifdef POLYOBJECTS ld->polyobj = NULL; #endif - - ld->fadingdata = NULL; } } diff --git a/src/p_spec.c b/src/p_spec.c index 6f392bbfe..20f034ac8 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -103,14 +103,15 @@ static void P_SpawnFriction(void); static void P_SpawnPushers(void); static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t *source, INT32 affectee, INT32 referrer, INT32 exclusive, INT32 slider); //SoM: 3/9/2000 static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); -static void P_ResetFading(line_t *line, fade_t *data); +static void P_ResetFading(ffloor_t *rover, fade_t *data); #define P_RemoveFading(l) P_ResetFading(l, NULL); -static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, +static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, - boolean doghostfade, INT32 line); -static void P_AddMasterFader(INT16 destvalue, INT16 speed, + boolean doghostfade); +static void P_AddMasterFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, + INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, - boolean doghostfade, INT32 line); + boolean doghostfade); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3109,6 +3110,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in ffloor_t *rover; // FOF that we are going to crumble + size_t j = 0; // sec->ffloors is saved as ffloor #0, ss->ffloors->next is #1, etc for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) { @@ -3124,6 +3126,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { if (rover->master->frontsector->tag == foftag) break; + j++; } if (!rover) @@ -3133,25 +3136,24 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } if (speed > 0) - P_AddMasterFader(destvalue, speed, - (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS - !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT - (line->flags & ML_BOUNCY), // handle FF_SOLID - (line->flags & ML_EFFECT1), // handle spawnflags - (line->flags & ML_EFFECT2), // enable flags on fade-in finish only - (INT32)(rover->master-lines)); + P_AddMasterFader(rover, secnum, j, + destvalue, speed, + (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT + (line->flags & ML_BOUNCY), // handle FF_SOLID + (line->flags & ML_EFFECT1), // handle spawnflags + (line->flags & ML_EFFECT2)); // enable flags on fade-in finish only else { - P_RemoveFading(&lines[(INT32)(rover->master-lines)]); - P_FindFakeFloorsDoAlpha(destvalue, 0, // set alpha immediately - (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS - !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT - (line->flags & ML_BOUNCY), // handle FF_SOLID - (line->flags & ML_EFFECT1), // handle spawnflags - (line->flags & ML_EFFECT2), // enable flags on fade-in finish only - (INT32)(rover->master-lines)); + P_RemoveFading(rover); + P_DoFakeFloorAlpha(rover, + destvalue, 0, // set alpha immediately + (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT + (line->flags & ML_BOUNCY), // handle FF_SOLID + (line->flags & ML_EFFECT1), // handle spawnflags + (line->flags & ML_EFFECT2)); // enable flags on fade-in finish only } - break; } break; } @@ -3185,8 +3187,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) return; } - P_RemoveFading(&lines[(INT32)(rover->master-lines)]); - break; + P_RemoveFading(rover); } break; } @@ -5036,7 +5037,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f ffloor->spawnflags = ffloor->flags = flags; ffloor->master = master; ffloor->norender = INFTICS; - + ffloor->fadingdata = NULL; // Scan the thinkers to check for special conditions applying to this FOF. // If we have thinkers sorted by sector, just check the relevant ones; @@ -7197,15 +7198,15 @@ void T_Disappear(disappear_t *d) * \param line line to search for target faders * \param data pointer to set new fadingdata to. Can be NULL to erase. */ -static void P_ResetFading(line_t *line, fade_t *data) +static void P_ResetFading(ffloor_t *rover, fade_t *data) { // find any existing thinkers and remove them, then replace with new data - if(((fade_t *)line->fadingdata) != data) + if(((fade_t *)rover->fadingdata) != data) { - if(&((fade_t *)line->fadingdata)->thinker) - P_RemoveThinker(&((fade_t *)line->fadingdata)->thinker); + if(&((fade_t *)rover->fadingdata)->thinker) + P_RemoveThinker(&((fade_t *)rover->fadingdata)->thinker); - line->fadingdata = data; + rover->fadingdata = data; } } @@ -7352,28 +7353,6 @@ static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, return result; } -static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, - boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, - boolean doghostfade, INT32 line) -{ - ffloor_t *rover; - register INT32 s; - INT32 affectedffloors = 0; - - for (s = -1; (s = P_FindSectorFromLineTag(&lines[line], s)) >= 0 ;) - { - for (rover = sectors[s].ffloors; rover; rover = rover->next) - { - if (rover->master != &lines[line]) - continue; - - affectedffloors += (INT32)P_DoFakeFloorAlpha(rover, destvalue, speed, doexists, dotranslucent, dosolid, dospawnflags, doghostfade); - } - } - - return affectedffloors; -} - /** Adds master fader thinker. * * \param destvalue transparency value to fade to @@ -7385,14 +7364,17 @@ static INT32 P_FindFakeFloorsDoAlpha(INT16 destvalue, INT16 speed, * \param doghostfade enable flags when fade-in is finished; never on fade-out * \param line line to target FOF */ -static void P_AddMasterFader(INT16 destvalue, INT16 speed, +static void P_AddMasterFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, + INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, - boolean doghostfade, INT32 line) + boolean doghostfade) { fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); d->thinker.function.acp1 = (actionf_p1)T_Fade; - d->affectee = line; + d->rover = rover; + d->sectornum = (INT32)sectornum; + d->ffloornum = (INT32)ffloornum; d->destvalue = max(1, min(256, destvalue)); // ffloor->alpha is 1-256 d->speed = max(1, speed); // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker d->doexists = doexists; @@ -7402,7 +7384,7 @@ static void P_AddMasterFader(INT16 destvalue, INT16 speed, d->doghostfade = doghostfade; // find any existing thinkers and remove them, then replace with new data - P_ResetFading(&lines[d->affectee], d); + P_ResetFading(rover, d); P_AddThinker(&d->thinker); } @@ -7414,13 +7396,8 @@ static void P_AddMasterFader(INT16 destvalue, INT16 speed, */ void T_Fade(fade_t *d) { - INT32 affectedffloors = P_FindFakeFloorsDoAlpha(d->destvalue, d->speed, - d->doexists, d->dotranslucent, d->dosolid, d->dospawnflags, - d->doghostfade, d->affectee); - - // no more ffloors to fade? remove myself - if (affectedffloors == 0) - P_RemoveFading(&lines[d->affectee]); + if (d->rover && !P_DoFakeFloorAlpha(d->rover, d->destvalue, d->speed, d->doexists, d->dotranslucent, d->dosolid, d->dospawnflags, d->doghostfade)) + P_RemoveFading(d->rover); } /* diff --git a/src/p_spec.h b/src/p_spec.h index 672b96f30..fcced9cea 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -453,14 +453,16 @@ void T_Disappear(disappear_t *d); typedef struct { thinker_t thinker; ///< Thinker structure for effect. - INT32 affectee; ///< Number of affected line + ffloor_t *rover; ///< Target ffloor + INT32 sectornum; ///< Number of ffloor target sector + INT32 ffloornum; ///< Number of ffloor of target sector INT16 destvalue; ///< Transparency value to fade to INT16 speed; ///< Speed to fade by boolean doexists; ///< Handle FF_EXISTS handling boolean dotranslucent; ///< Handle FF_TRANSLUCENT handling boolean dosolid; ///< Handle FF_SOLID handling boolean dospawnflags; ///< Enable spawnflags handling - boolean doghostfade; ///< Set flags only when fade-in is finished; never during fade-out + boolean doghostfade; ///< Set flags only when fade-in is finished; never during fade-out } fade_t; void T_Fade(fade_t *d); diff --git a/src/r_defs.h b/src/r_defs.h index c425f3a3b..ea5db3947 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -177,6 +177,8 @@ typedef struct ffloor_s // these are saved for netgames, so do not let Lua touch these! ffloortype_e spawnflags; // flags the 3D floor spawned with INT32 spawnalpha; // alpha the 3D floor spawned with + + void *fadingdata; // fading FOF thinker } ffloor_t; @@ -443,8 +445,6 @@ typedef struct line_s char *text; // a concatination of all front and back texture names, for linedef specials that require a string. INT16 callcount; // no. of calls left before triggering, for the "X calls" linedef specials, defaults to 0 - - void *fadingdata; // fading FOF thinker } line_t; // From 020b18b84ba668e0ee371205d019c1695ec204f1 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 17 Aug 2018 14:49:33 -0400 Subject: [PATCH 086/573] Revised and re-organized P_DoFakeFloorAlpha fading procedure * dosolid routine now refers to spawnflags --- src/p_spec.c | 203 +++++++++++++++++++++++++-------------------------- 1 file changed, 98 insertions(+), 105 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 20f034ac8..9fe25bcba 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7214,74 +7214,34 @@ static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, boolean doghostfade) { - boolean result = false; + boolean stillfading = false; + // routines specific to fade in and fade out if (rover->alpha == destvalue) - return result; - // fade out - else if (rover->alpha > destvalue) + return stillfading; + else if (rover->alpha > destvalue) // fade out { // finish fading out if (speed < 1 || rover->alpha - speed <= destvalue + speed) { rover->alpha = destvalue; - if (doexists) + if (dosolid) { - if (rover->alpha <= 1) - rover->flags &= ~FF_EXISTS; - else - rover->flags |= FF_EXISTS; - } - - if (dosolid - && !(rover->flags & FF_SWIMMABLE) - && !(rover->flags & FF_QUICKSAND)) - rover->flags &= ~FF_SOLID; // make intangible at end of fade-out - - if (dotranslucent) - { - if (rover->alpha >= 256) - { - rover->flags |= FF_CUTLEVEL; - rover->flags &= ~(FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA); - } - else - { - rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; - rover->flags &= ~FF_CUTLEVEL; - } - - if (rover->flags & FF_SOLID) - rover->flags &= ~FF_CUTSPRITES; - else - rover->flags |= FF_CUTSPRITES; + if (rover->spawnflags & FF_SOLID) + rover->flags &= ~FF_SOLID; + if (rover->spawnflags & FF_SWIMMABLE) + rover->flags &= ~FF_SWIMMABLE; + if (rover->spawnflags & FF_QUICKSAND) + rover->flags &= ~FF_QUICKSAND; + if (rover->spawnflags & FF_BUSTUP) + rover->flags &= ~FF_BUSTUP; } } else // continue fading out { rover->alpha -= speed; - - if (doexists) - rover->flags |= FF_EXISTS; - - if (dosolid - && !(rover->flags & FF_SWIMMABLE) - && !(rover->flags & FF_QUICKSAND)) - rover->flags |= FF_SOLID; // keep solid during fade - - if (dotranslucent) - { - rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; - rover->flags &= ~FF_CUTLEVEL; - - if (rover->flags & FF_SOLID) - rover->flags &= ~FF_CUTSPRITES; - else - rover->flags |= FF_CUTSPRITES; - } - - result = true; + stillfading = true; } } else // fade in @@ -7291,66 +7251,99 @@ static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, { rover->alpha = destvalue; - if (doexists) + if (dosolid) { - if (rover->alpha <= 1) - rover->flags &= ~FF_EXISTS; - else - rover->flags |= FF_EXISTS; - } - - if (dosolid - && !(rover->flags & FF_SWIMMABLE) - && !(rover->flags & FF_QUICKSAND)) - rover->flags |= FF_SOLID; // make solid at end of fade-in - - if (dotranslucent) - { - if (rover->alpha >= 256) - { - rover->flags |= FF_CUTLEVEL; - rover->flags &= ~(FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA); - } - else - { - rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; - rover->flags &= ~FF_CUTLEVEL; - } - - if (rover->flags & FF_SOLID) - rover->flags &= ~FF_CUTSPRITES; - else - rover->flags |= FF_CUTSPRITES; + if (rover->spawnflags & FF_SOLID) + rover->flags |= FF_SOLID; + if (rover->spawnflags & FF_SWIMMABLE) + rover->flags |= FF_SWIMMABLE; + if (rover->spawnflags & FF_QUICKSAND) + rover->flags |= FF_QUICKSAND; + if (rover->spawnflags & FF_BUSTUP) + rover->flags |= FF_BUSTUP; } } else // continue fading in { rover->alpha += speed; - - if (doexists) - rover->flags |= FF_EXISTS; - - if (dosolid - && !(rover->flags & FF_SWIMMABLE) - && !(rover->flags & FF_QUICKSAND)) - rover->flags |= FF_SOLID; // keep solid during fade - - if (dotranslucent) - { - rover->flags |= FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA; - rover->flags &= ~FF_CUTLEVEL; - - if (rover->flags & FF_SOLID) - rover->flags &= ~FF_CUTSPRITES; - else - rover->flags |= FF_CUTSPRITES; - } - - result = true; + stillfading = true; } } - return result; + // routines common to both fade in and fade out + if (!stillfading) + { + if (doexists) + { + if (rover->alpha <= 1) + rover->flags &= ~FF_EXISTS; + else + rover->flags |= FF_EXISTS; + } + + if (dotranslucent) + { + if (rover->alpha >= 256) + { + //rover->flags |= FF_CUTLEVEL; + rover->flags &= ~FF_TRANSLUCENT; + } + else + { + rover->flags |= FF_TRANSLUCENT; + //rover->flags &= ~FF_CUTLEVEL; + } + + // if (rover->flags & FF_SOLID) + // rover->flags &= ~FF_CUTSPRITES; + // else + // rover->flags |= FF_CUTSPRITES; + } + } + else + { + if (doexists) + rover->flags |= FF_EXISTS; + + if (dotranslucent) + { + rover->flags |= FF_TRANSLUCENT; + //rover->flags &= ~FF_CUTLEVEL; + + // if (rover->flags & FF_SOLID) + // rover->flags &= ~FF_CUTSPRITES; + // else + // rover->flags |= FF_CUTSPRITES; + } + + if (dosolid) + { + if (doghostfade) // remove interaction flags during fade + { + if (rover->spawnflags & FF_SOLID) + rover->flags &= ~FF_SOLID; + if (rover->spawnflags & FF_SWIMMABLE) + rover->flags &= ~FF_SWIMMABLE; + if (rover->spawnflags & FF_QUICKSAND) + rover->flags &= ~FF_QUICKSAND; + if (rover->spawnflags & FF_BUSTUP) + rover->flags &= ~FF_BUSTUP; + } + else // keep interaction during fade + { + if (rover->spawnflags & FF_SOLID) + rover->flags |= FF_SOLID; + if (rover->spawnflags & FF_SWIMMABLE) + rover->flags |= FF_SWIMMABLE; + if (rover->spawnflags & FF_QUICKSAND) + rover->flags |= FF_QUICKSAND; + if (rover->spawnflags & FF_BUSTUP) + rover->flags |= FF_BUSTUP; + } + } + } + + return stillfading; } /** Adds master fader thinker. From 45ae6efbadfc01d54d70081909573680472416a1 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 17 Aug 2018 15:13:05 -0400 Subject: [PATCH 087/573] Refactor function and variable names; change defaults for fake floor fader line flags --- src/p_saveg.c | 8 ++--- src/p_spec.c | 87 ++++++++++++++++++++++++--------------------------- src/p_spec.h | 10 +++--- 3 files changed, 50 insertions(+), 55 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index daa6bb937..c2158aa0d 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1572,9 +1572,9 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) WRITEINT16(save_p, ht->speed); WRITEUINT8(save_p, ht->doexists); WRITEUINT8(save_p, ht->dotranslucent); - WRITEUINT8(save_p, ht->dosolid); - WRITEUINT8(save_p, ht->dospawnflags); + WRITEUINT8(save_p, ht->docollision); WRITEUINT8(save_p, ht->doghostfade); + WRITEUINT8(save_p, ht->exactalpha); } // @@ -2575,9 +2575,9 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->speed = READINT16(save_p); ht->doexists = READUINT8(save_p); ht->dotranslucent = READUINT8(save_p); - ht->dosolid = READUINT8(save_p); - ht->dospawnflags = READUINT8(save_p); + ht->docollision = READUINT8(save_p); ht->doghostfade = READUINT8(save_p); + ht->exactalpha = READUINT8(save_p); sector_t *ss = LoadSector(ht->sectornum); if (ss) diff --git a/src/p_spec.c b/src/p_spec.c index 9fe25bcba..4694eb015 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -103,15 +103,13 @@ static void P_SpawnFriction(void); static void P_SpawnPushers(void); static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t *source, INT32 affectee, INT32 referrer, INT32 exclusive, INT32 slider); //SoM: 3/9/2000 static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); -static void P_ResetFading(ffloor_t *rover, fade_t *data); -#define P_RemoveFading(l) P_ResetFading(l, NULL); -static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, - boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, - boolean doghostfade); -static void P_AddMasterFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, +static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data); +#define P_RemoveFakeFloorFader(l) P_ResetFakeFloorFader(l, NULL); +static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, + boolean doexists, boolean dotranslucent, boolean docollision, boolean doghostfade, boolean exactalpha); +static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, INT16 destvalue, INT16 speed, - boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, - boolean doghostfade); + boolean doexists, boolean dotranslucent, boolean docollision, boolean doghostfade, boolean exactalpha); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3136,23 +3134,23 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } if (speed > 0) - P_AddMasterFader(rover, secnum, j, + P_AddFakeFloorFader(rover, secnum, j, destvalue, speed, - (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS + !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT - (line->flags & ML_BOUNCY), // handle FF_SOLID - (line->flags & ML_EFFECT1), // handle spawnflags - (line->flags & ML_EFFECT2)); // enable flags on fade-in finish only + !(line->flags & ML_BOUNCY), // do not handle interactive flags + (line->flags & ML_EFFECT1), // do ghost fade (no interactive flags during fade) + (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) else { - P_RemoveFading(rover); - P_DoFakeFloorAlpha(rover, - destvalue, 0, // set alpha immediately - (line->flags & ML_BLOCKMONSTERS), // handle FF_EXISTS + P_RemoveFakeFloorFader(rover); + P_FadeFakeFloor(rover, + destvalue, 0, // set alpha immediately + !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT - (line->flags & ML_BOUNCY), // handle FF_SOLID - (line->flags & ML_EFFECT1), // handle spawnflags - (line->flags & ML_EFFECT2)); // enable flags on fade-in finish only + !(line->flags & ML_BOUNCY), // do not handle interactive flags + (line->flags & ML_EFFECT1), // do ghost fade (no interactive flags during fade) + (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) } } break; @@ -3187,7 +3185,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) return; } - P_RemoveFading(rover); + P_RemoveFakeFloorFader(rover); } break; } @@ -7198,7 +7196,7 @@ void T_Disappear(disappear_t *d) * \param line line to search for target faders * \param data pointer to set new fadingdata to. Can be NULL to erase. */ -static void P_ResetFading(ffloor_t *rover, fade_t *data) +static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data) { // find any existing thinkers and remove them, then replace with new data if(((fade_t *)rover->fadingdata) != data) @@ -7210,9 +7208,8 @@ static void P_ResetFading(ffloor_t *rover, fade_t *data) } } -static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, - boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, - boolean doghostfade) +static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, + boolean doexists, boolean dotranslucent, boolean docollision, boolean doghostfade, boolean exactalpha) { boolean stillfading = false; @@ -7226,7 +7223,7 @@ static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, { rover->alpha = destvalue; - if (dosolid) + if (docollision) { if (rover->spawnflags & FF_SOLID) rover->flags &= ~FF_SOLID; @@ -7251,7 +7248,7 @@ static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, { rover->alpha = destvalue; - if (dosolid) + if (docollision) { if (rover->spawnflags & FF_SOLID) rover->flags |= FF_SOLID; @@ -7316,7 +7313,7 @@ static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, // rover->flags |= FF_CUTSPRITES; } - if (dosolid) + if (docollision) { if (doghostfade) // remove interaction flags during fade { @@ -7346,21 +7343,19 @@ static boolean P_DoFakeFloorAlpha(ffloor_t *rover, INT16 destvalue, INT16 speed, return stillfading; } -/** Adds master fader thinker. +/** Adds fake floor fader thinker. * - * \param destvalue transparency value to fade to - * \param speed speed to fade by - * \param doexists handle FF_EXISTS - * \param dotranslucent handle FF_TRANSLUCENT - * \param dosolid handle FF_SOLID - * \param dospawnflags handle spawnflags - * \param doghostfade enable flags when fade-in is finished; never on fade-out - * \param line line to target FOF + * \param destvalue transparency value to fade to + * \param speed speed to fade by + * \param doexists handle FF_EXISTS + * \param dotranslucent handle FF_TRANSLUCENT + * \param docollision handle interactive flags + * \param doghostfade no interactive flags during fading + * \param exactalpha use exact alpha values (opengl) */ -static void P_AddMasterFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, +static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, INT16 destvalue, INT16 speed, - boolean doexists, boolean dotranslucent, boolean dosolid, boolean dospawnflags, - boolean doghostfade) + boolean doexists, boolean dotranslucent, boolean docollision, boolean doghostfade, boolean exactalpha) { fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); @@ -7372,12 +7367,12 @@ static void P_AddMasterFader(ffloor_t *rover, size_t sectornum, size_t ffloornum d->speed = max(1, speed); // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker d->doexists = doexists; d->dotranslucent = dotranslucent; - d->dosolid = dosolid; - d->dospawnflags = dospawnflags; + d->docollision = docollision; d->doghostfade = doghostfade; + d->exactalpha = exactalpha; // find any existing thinkers and remove them, then replace with new data - P_ResetFading(rover, d); + P_ResetFakeFloorFader(rover, d); P_AddThinker(&d->thinker); } @@ -7385,12 +7380,12 @@ static void P_AddMasterFader(ffloor_t *rover, size_t sectornum, size_t ffloornum /** Makes a FOF fade * * \param d Fade thinker. - * \sa P_AddMasterFader + * \sa P_AddFakeFloorFader */ void T_Fade(fade_t *d) { - if (d->rover && !P_DoFakeFloorAlpha(d->rover, d->destvalue, d->speed, d->doexists, d->dotranslucent, d->dosolid, d->dospawnflags, d->doghostfade)) - P_RemoveFading(d->rover); + if (d->rover && !P_FadeFakeFloor(d->rover, d->destvalue, d->speed, d->doexists, d->dotranslucent, d->docollision, d->doghostfade, d->exactalpha)) + P_RemoveFakeFloorFader(d->rover); } /* diff --git a/src/p_spec.h b/src/p_spec.h index fcced9cea..b4e9594d2 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -458,11 +458,11 @@ typedef struct INT32 ffloornum; ///< Number of ffloor of target sector INT16 destvalue; ///< Transparency value to fade to INT16 speed; ///< Speed to fade by - boolean doexists; ///< Handle FF_EXISTS handling - boolean dotranslucent; ///< Handle FF_TRANSLUCENT handling - boolean dosolid; ///< Handle FF_SOLID handling - boolean dospawnflags; ///< Enable spawnflags handling - boolean doghostfade; ///< Set flags only when fade-in is finished; never during fade-out + boolean doexists; ///< Handle FF_EXISTS + boolean dotranslucent; ///< Handle FF_TRANSLUCENT + boolean docollision; ///< Handle interactive flags + boolean doghostfade; ///< No interactive flags during fading + boolean exactalpha; ///< Use exact alpha values (opengl) } fade_t; void T_Fade(fade_t *d); From bf5efe645778f71a496a8f884f23b3514cc1ba74 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 17 Aug 2018 15:59:34 -0400 Subject: [PATCH 088/573] Cleanup fade fake floor code --- src/p_spec.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 4694eb015..ec07003bd 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7282,19 +7282,14 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, { if (rover->alpha >= 256) { - //rover->flags |= FF_CUTLEVEL; + //rover->flags |= (FF_CUTLEVEL | FF_CUTEXTRA); rover->flags &= ~FF_TRANSLUCENT; } else { rover->flags |= FF_TRANSLUCENT; - //rover->flags &= ~FF_CUTLEVEL; + //rover->flags &= ~(FF_CUTLEVEL | FF_CUTEXTRA); } - - // if (rover->flags & FF_SOLID) - // rover->flags &= ~FF_CUTSPRITES; - // else - // rover->flags |= FF_CUTSPRITES; } } else @@ -7305,17 +7300,12 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, if (dotranslucent) { rover->flags |= FF_TRANSLUCENT; - //rover->flags &= ~FF_CUTLEVEL; - - // if (rover->flags & FF_SOLID) - // rover->flags &= ~FF_CUTSPRITES; - // else - // rover->flags |= FF_CUTSPRITES; + //rover->flags &= ~(FF_CUTLEVEL | FF_CUTEXTRA); } if (docollision) { - if (doghostfade) // remove interaction flags during fade + if (doghostfade) // remove collision flags during fade { if (rover->spawnflags & FF_SOLID) rover->flags &= ~FF_SOLID; @@ -7326,7 +7316,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, if (rover->spawnflags & FF_BUSTUP) rover->flags &= ~FF_BUSTUP; } - else // keep interaction during fade + else // keep collision during fade { if (rover->spawnflags & FF_SOLID) rover->flags |= FF_SOLID; From d94608fa101f56a2b1e5a22d34b8ff7184154282 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 17 Aug 2018 16:27:32 -0400 Subject: [PATCH 089/573] Add alpha clamping so OpenGL conforms to Software's translucent levels --- src/p_saveg.c | 2 ++ src/p_spec.c | 59 ++++++++++++++++++++++++++++++++++++++++++--------- src/p_spec.h | 1 + 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index c2158aa0d..c1af4167b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1568,6 +1568,7 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) WRITEUINT8(save_p, type); WRITEINT32(save_p, ht->sectornum); WRITEINT32(save_p, ht->ffloornum); + WRITEINT32(save_p, ht->alpha); WRITEINT16(save_p, ht->destvalue); WRITEINT16(save_p, ht->speed); WRITEUINT8(save_p, ht->doexists); @@ -2571,6 +2572,7 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->thinker.function.acp1 = thinker; ht->sectornum = READINT32(save_p); ht->ffloornum = READINT32(save_p); + ht->alpha = READINT32(save_p); ht->destvalue = READINT16(save_p); ht->speed = READINT16(save_p); ht->doexists = READUINT8(save_p); diff --git a/src/p_spec.c b/src/p_spec.c index ec07003bd..50cf049ff 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7212,16 +7212,23 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean docollision, boolean doghostfade, boolean exactalpha) { boolean stillfading = false; + INT32 alpha; + fade_t *fadingdata = (fade_t *)rover->fadingdata; + + if (fadingdata) + alpha = fadingdata->alpha; + else + alpha = rover->alpha; // routines specific to fade in and fade out - if (rover->alpha == destvalue) + if (alpha == destvalue) return stillfading; - else if (rover->alpha > destvalue) // fade out + else if (alpha > destvalue) // fade out { // finish fading out - if (speed < 1 || rover->alpha - speed <= destvalue + speed) + if (speed < 1 || alpha - speed <= destvalue + speed) { - rover->alpha = destvalue; + alpha = destvalue; if (docollision) { @@ -7237,16 +7244,16 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, } else // continue fading out { - rover->alpha -= speed; + alpha -= speed; stillfading = true; } } else // fade in { // finish fading in - if (speed < 1 || rover->alpha + speed >= destvalue - speed) + if (speed < 1 || alpha + speed >= destvalue - speed) { - rover->alpha = destvalue; + alpha = destvalue; if (docollision) { @@ -7262,7 +7269,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, } else // continue fading in { - rover->alpha += speed; + alpha += speed; stillfading = true; } } @@ -7272,7 +7279,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, { if (doexists) { - if (rover->alpha <= 1) + if (alpha <= 1) rover->flags &= ~FF_EXISTS; else rover->flags |= FF_EXISTS; @@ -7280,7 +7287,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, if (dotranslucent) { - if (rover->alpha >= 256) + if (alpha >= 256) { //rover->flags |= (FF_CUTLEVEL | FF_CUTEXTRA); rover->flags &= ~FF_TRANSLUCENT; @@ -7330,6 +7337,37 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, } } + if (!stillfading || exactalpha) + rover->alpha = alpha; + else // clamp fadingdata->alpha to software's alpha levels + { + if (alpha < 12) + rover->alpha = destvalue < 12 ? destvalue : 1; // Don't even draw it + else if (alpha < 38) + rover->alpha = destvalue >= 12 && destvalue < 38 ? destvalue : 25; + else if (alpha < 64) + rover->alpha = destvalue >=38 && destvalue < 64 ? destvalue : 51; + else if (alpha < 89) + rover->alpha = destvalue >= 64 && destvalue < 89 ? destvalue : 76; + else if (alpha < 115) + rover->alpha = destvalue >= 89 && destvalue < 115 ? destvalue : 102; + else if (alpha < 140) + rover->alpha = destvalue >= 115 && destvalue < 140 ? destvalue : 128; + else if (alpha < 166) + rover->alpha = destvalue >= 140 && destvalue < 166 ? destvalue : 154; + else if (alpha < 192) + rover->alpha = destvalue >= 166 && destvalue < 192 ? destvalue : 179; + else if (alpha < 217) + rover->alpha = destvalue >= 192 && destvalue < 217 ? destvalue : 204; + else if (alpha < 243) + rover->alpha = destvalue >= 217 && destvalue < 243 ? destvalue : 230; + else // Opaque + rover->alpha = destvalue >= 243 ? destvalue : 256; + } + + if (fadingdata) + fadingdata->alpha = alpha; + return stillfading; } @@ -7353,6 +7391,7 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor d->rover = rover; d->sectornum = (INT32)sectornum; d->ffloornum = (INT32)ffloornum; + d->alpha = rover->alpha; d->destvalue = max(1, min(256, destvalue)); // ffloor->alpha is 1-256 d->speed = max(1, speed); // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker d->doexists = doexists; diff --git a/src/p_spec.h b/src/p_spec.h index b4e9594d2..dc2ab0e6a 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -456,6 +456,7 @@ typedef struct ffloor_t *rover; ///< Target ffloor INT32 sectornum; ///< Number of ffloor target sector INT32 ffloornum; ///< Number of ffloor of target sector + INT32 alpha; ///< Internal alpha counter INT16 destvalue; ///< Transparency value to fade to INT16 speed; ///< Speed to fade by boolean doexists; ///< Handle FF_EXISTS From 773d8bdb8d076d689fa4a3c662a849270ec3475a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 18 Aug 2018 05:31:41 -0400 Subject: [PATCH 090/573] P_ResetFakeFloorFader: Unclamp rover->alpha from software levels --- src/p_spec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 50cf049ff..8ad69d872 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7199,10 +7199,13 @@ void T_Disappear(disappear_t *d) static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data) { // find any existing thinkers and remove them, then replace with new data - if(((fade_t *)rover->fadingdata) != data) + if (((fade_t *)rover->fadingdata) != data) { - if(&((fade_t *)rover->fadingdata)->thinker) + if (&((fade_t *)rover->fadingdata)->thinker) + { + rover->alpha = ((fade_t *)rover->fadingdata)->alpha; // unclamp from software levels P_RemoveThinker(&((fade_t *)rover->fadingdata)->thinker); + } rover->fadingdata = data; } From 4b07246565f4a9eca7efd304eccfb6daec430252 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 18 Aug 2018 05:55:49 -0400 Subject: [PATCH 091/573] Add "finalize" flag to Type 453 Stop Fade --- src/p_spec.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 8ad69d872..687ebdbba 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -103,8 +103,8 @@ static void P_SpawnFriction(void); static void P_SpawnPushers(void); static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t *source, INT32 affectee, INT32 referrer, INT32 exclusive, INT32 slider); //SoM: 3/9/2000 static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); -static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data); -#define P_RemoveFakeFloorFader(l) P_ResetFakeFloorFader(l, NULL); +static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finalize); +#define P_RemoveFakeFloorFader(l) P_ResetFakeFloorFader(l, NULL, false); static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean docollision, boolean doghostfade, boolean exactalpha); static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, @@ -3107,7 +3107,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover; // FOF that we are going to crumble + ffloor_t *rover; // FOF that we are going to operate size_t j = 0; // sec->ffloors is saved as ffloor #0, ss->ffloors->next is #1, etc for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) @@ -3161,7 +3161,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover; // FOF that we are going to crumble + ffloor_t *rover; // FOF that we are going to operate for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) { @@ -3185,7 +3185,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) return; } - P_RemoveFakeFloorFader(rover); + P_ResetFakeFloorFader(rover, NULL, + !(line->flags & ML_BLOCKMONSTERS)); // do not finalize collision flags } break; } @@ -7196,15 +7197,28 @@ void T_Disappear(disappear_t *d) * \param line line to search for target faders * \param data pointer to set new fadingdata to. Can be NULL to erase. */ -static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data) +static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finalize) { + fade_t *fadingdata = (fade_t *)rover->fadingdata; // find any existing thinkers and remove them, then replace with new data - if (((fade_t *)rover->fadingdata) != data) + if (fadingdata != data) { - if (&((fade_t *)rover->fadingdata)->thinker) + if (&fadingdata->thinker) { - rover->alpha = ((fade_t *)rover->fadingdata)->alpha; // unclamp from software levels - P_RemoveThinker(&((fade_t *)rover->fadingdata)->thinker); + if (finalize) + P_FadeFakeFloor(rover, + fadingdata->alpha >= fadingdata->destvalue ? + fadingdata->alpha - 1 : // trigger fade-out finish + fadingdata->alpha + 1, // trigger fade-in finish + 0, + fadingdata->doexists, + fadingdata->dotranslucent, + fadingdata->docollision, + fadingdata->doghostfade, + fadingdata->exactalpha); + rover->alpha = fadingdata->alpha; + + P_RemoveThinker(&fadingdata->thinker); } rover->fadingdata = data; @@ -7404,7 +7418,7 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor d->exactalpha = exactalpha; // find any existing thinkers and remove them, then replace with new data - P_ResetFakeFloorFader(rover, d); + P_ResetFakeFloorFader(rover, d, false); P_AddThinker(&d->thinker); } From dae37e2749a6df0b876666b5fb44eaca11729996 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 30 Aug 2018 09:09:19 -0400 Subject: [PATCH 092/573] Drill mash penalty fix --- src/p_user.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 76842b161..12383c423 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6668,12 +6668,16 @@ static void P_NiGHTSMovement(player_t *player) } else if (player->drilltimer == 32) { + // drill mash penalty player->drilltimer = 31; player->drillmeter -= TICRATE/2; if (player->drillmeter <= 0) player->drillmeter = TICRATE/10; } - else if (--player->drilltimer <= 0) + else if (--player->drilltimer == 11) + // give that drill mash penalty back (after 0.6 seconds) + player->drillmeter += TICRATE/2; + else if (player->drilltimer <= 0) { player->drilltimer = 10; S_StartSound(player->mo, sfx_drill2); From fed72c344adc02a828924fb379be2e62dcd21bac Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 30 Aug 2018 10:50:03 -0400 Subject: [PATCH 093/573] Dummy out NiGHTS item faster attract --- src/p_inter.c | 4 +++- src/p_user.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 500018fd9..9a05bae28 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -946,7 +946,9 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Yay! The thing's in reach! Pull it in! mo2->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; mo2->flags2 |= MF2_NIGHTSPULL; - mo2->movefactor = 32*FRACUNIT; // initialize the NightsItemChase timer + // New NiGHTS attract speed dummied out because the older behavior + // is exploited as a mechanic. Uncomment to enable. + mo2->movefactor = 0; // 32*FRACUNIT; // initialize the NightsItemChase timer P_SetTarget(&mo2->tracer, toucher); } } diff --git a/src/p_user.c b/src/p_user.c index 12383c423..ffb48f27c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9807,7 +9807,9 @@ void P_PlayerThink(player_t *player) // Yay! The thing's in reach! Pull it in! mo2->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; mo2->flags2 |= MF2_NIGHTSPULL; - mo2->movefactor = 40*FRACUNIT; // initialize the NightsItemChase timer + // New NiGHTS attract speed dummied out because the older behavior + // is exploited as a mechanic. Uncomment to enable. + mo2->movefactor = 0; // 40*FRACUNIT; // initialize the NightsItemChase timer P_SetTarget(&mo2->tracer, player->mo); } } From 0f5d685d1f61c3db55b820dc56f3c46f4b2fecc8 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 30 Aug 2018 18:32:26 -0400 Subject: [PATCH 094/573] Only do this if the admin player isn't the server host also. --- src/d_netcmd.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index bf26ca61a..742124000 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2697,6 +2697,12 @@ static void Command_Login_f(void) XBOXSTATIC UINT8 finalmd5[16]; const char *pw; + if (!netgame) + { + CONS_Printf(M_GetText("This only works in a netgame.\n")); + return; + } + // If the server uses login, it will effectively just remove admin privileges // from whoever has them. This is good. if (COM_Argc() != 2) @@ -2764,6 +2770,12 @@ static void Command_Verify_f(void) return; } + if (!netgame) + { + CONS_Printf(M_GetText("This only works in a netgame.\n")); + return; + } + if (COM_Argc() != 2) { CONS_Printf(M_GetText("verify : give admin privileges to a node\n")); @@ -3075,7 +3087,7 @@ static void Command_Addfile(void) WRITEMEM(buf_p, md5sum, 16); } - if (adminplayer == consoleplayer) // Request to add file + if (adminplayer == consoleplayer && (!server)) // Request to add file SendNetXCmd(XD_REQADDFILE, buf, buf_p - buf); else SendNetXCmd(XD_ADDFILE, buf, buf_p - buf); From 322da62b3c1eb9bbab46adc344100b13b8fa602b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 31 Aug 2018 17:14:44 +0100 Subject: [PATCH 095/573] Fix HOM removal not working properly for non-green resolutions --- src/r_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index e50e80013..f2a0c8894 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1235,9 +1235,9 @@ void R_RenderPlayerView(player_t *player) if (cv_homremoval.value && player == &players[displayplayer]) // if this is display player 1 { if (cv_homremoval.value == 1) - V_DrawFill(0, 0, vid.width, vid.height, 31); // No HOM effect! + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // No HOM effect! else //'development' HOM removal -- makes it blindingly obvious if HOM is spotted. - V_DrawFill(0, 0, vid.width, vid.height, 128+(timeinmap&15)); + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 128+(timeinmap&15)); } // load previous saved value of skyVisible for the player From 24aafa6dacaa03a73674ef049ceeae102693438f Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 3 Sep 2018 15:43:36 +0100 Subject: [PATCH 096/573] UDP_Socket: Add missing limit checks for s, for client and broadcast addresses --- src/i_tcp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 6488e9845..5c6606668 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1044,7 +1044,7 @@ static boolean UDP_Socket(void) if (gaie == 0) { runp = ai; - while (runp != NULL) + while (runp != NULL && s < MAXNETNODES+1) { memcpy(&clientaddress[s], runp->ai_addr, runp->ai_addrlen); s++; @@ -1064,7 +1064,7 @@ static boolean UDP_Socket(void) if (gaie == 0) { runp = ai; - while (runp != NULL) + while (runp != NULL && s < MAXNETNODES+1) { memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen); s++; @@ -1087,7 +1087,7 @@ static boolean UDP_Socket(void) if (gaie == 0) { runp = ai; - while (runp != NULL) + while (runp != NULL && s < MAXNETNODES+1) { memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen); s++; From 846bddfdcf9514e8164bd1157c58ab2ac614ae8a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 3 Sep 2018 15:52:22 +0100 Subject: [PATCH 097/573] SOCK_Send: Fix what appears to be a mistaken use of i instead of j --- src/i_tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 5c6606668..3b609914d 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -707,10 +707,10 @@ static void SOCK_Send(void) { if (myfamily[i] == broadcastaddress[j].any.sa_family) { - if (broadcastaddress[i].any.sa_family == AF_INET) + if (broadcastaddress[j].any.sa_family == AF_INET) d = d4; #ifdef HAVE_IPV6 - else if (broadcastaddress[i].any.sa_family == AF_INET6) + else if (broadcastaddress[j].any.sa_family == AF_INET6) d = d6; #endif else From 7b083f07cd306ca8790427b0257ca1f06f7d3a3e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 3 Sep 2018 15:56:02 +0100 Subject: [PATCH 098/573] UDP_Socket: I doubt client addresses are meant to be included in the total for broadcast addresses --- src/i_tcp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/i_tcp.c b/src/i_tcp.c index 3b609914d..d11be4285 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1059,6 +1059,9 @@ static boolean UDP_Socket(void) clientaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); //GetLocalAddress(); // my own ip s++; } + + s = 0; + // setup broadcast adress to BROADCASTADDR entry gaie = I_getaddrinfo("255.255.255.255", "0", &hints, &ai); if (gaie == 0) From ea06e8a62b42d4e85112742ca668a7a6495beaf9 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 3 Sep 2018 20:53:40 +0100 Subject: [PATCH 099/573] SOCK_Send: Split the actual sending data parts into a new function, SOCK_SendToAddr, to make everything look a bit neater in general --- src/i_tcp.c | 59 ++++++++++++++++++----------------------------------- 1 file changed, 20 insertions(+), 39 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index d11be4285..16e7bf2f6 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -686,14 +686,29 @@ static boolean SOCK_CanGet(void) #endif #ifndef NONET -static void SOCK_Send(void) +static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr) { - ssize_t c = ERRSOCKET; socklen_t d4 = (socklen_t)sizeof(struct sockaddr_in); #ifdef HAVE_IPV6 socklen_t d6 = (socklen_t)sizeof(struct sockaddr_in6); #endif socklen_t d, da = (socklen_t)sizeof(mysockaddr_t); + + switch (sockaddr->any.sa_family) + { + case AF_INET: d = d4; break; +#ifdef HAVE_IPV6 + case AF_INET6: d = d6; break; +#endif + default: d = da; break; + } + + return sendto(socket, (char *)&doomcom->data, doomcom->datalength, 0, &sockaddr->any, d); +} + +static void SOCK_Send(void) +{ + ssize_t c = ERRSOCKET; size_t i, j; if (!nodeconnected[doomcom->remotenode]) @@ -706,19 +721,7 @@ static void SOCK_Send(void) for (j = 0; j < broadcastaddresses; j++) { if (myfamily[i] == broadcastaddress[j].any.sa_family) - { - if (broadcastaddress[j].any.sa_family == AF_INET) - d = d4; -#ifdef HAVE_IPV6 - else if (broadcastaddress[j].any.sa_family == AF_INET6) - d = d6; -#endif - else - d = da; - - c = sendto(mysockets[i], (char *)&doomcom->data, doomcom->datalength, 0, - &broadcastaddress[j].any, d); - } + SOCK_SendToAddr(mysockets[i], &broadcastaddress[j]); } } return; @@ -728,35 +731,13 @@ static void SOCK_Send(void) for (i = 0; i < mysocketses; i++) { if (myfamily[i] == clientaddress[doomcom->remotenode].any.sa_family) - { - if (clientaddress[doomcom->remotenode].any.sa_family == AF_INET) - d = d4; -#ifdef HAVE_IPV6 - else if (clientaddress[doomcom->remotenode].any.sa_family == AF_INET6) - d = d6; -#endif - else - d = da; - - sendto(mysockets[i], (char *)&doomcom->data, doomcom->datalength, 0, - &clientaddress[doomcom->remotenode].any, d); - } + SOCK_SendToAddr(mysockets[i], &clientaddress[doomcom->remotenode]); } return; } else { - if (clientaddress[doomcom->remotenode].any.sa_family == AF_INET) - d = d4; -#ifdef HAVE_IPV6 - else if (clientaddress[doomcom->remotenode].any.sa_family == AF_INET6) - d = d6; -#endif - else - d = da; - - c = sendto(nodesocket[doomcom->remotenode], (char *)&doomcom->data, doomcom->datalength, 0, - &clientaddress[doomcom->remotenode].any, d); + c = SOCK_SendToAddr(nodesocket[doomcom->remotenode], &clientaddress[doomcom->remotenode]); } if (c == ERRSOCKET && errno != ECONNREFUSED && errno != EWOULDBLOCK) From aba9bd13bbfaa52754a6b54fcc5bf6523c73958a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 4 Sep 2018 16:58:49 +0100 Subject: [PATCH 100/573] Add "tutorialmode" var to help the game know when we're in a tutorial or not, add placeholder for tutorial HUD to test it works --- src/d_main.c | 3 +++ src/d_netcmd.c | 2 ++ src/doomstat.h | 1 + src/g_game.c | 1 + src/m_menu.c | 2 ++ src/st_stuff.c | 11 +++++++++++ 6 files changed, 20 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index 95af1f754..c6dd9dc46 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -714,6 +714,9 @@ void D_StartTitle(void) // reset modeattacking modeattacking = ATTACKING_NONE; + // The title screen is obviously not a tutorial! (Unless I'm mistaken) + tutorialmode = false; + // empty maptol so mario/etc sounds don't play in sound test when they shouldn't maptol = 0; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f9f960a70..e96d98f11 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1815,6 +1815,8 @@ static void Command_Map_f(void) else fromlevelselect = ((netgame || multiplayer) && ((gametype == newgametype) && (newgametype == GT_COOP))); + tutorialmode = false; // warping takes us out of tutorial mode + D_MapChange(newmapnum, newgametype, false, newresetplayers, 0, false, fromlevelselect); } diff --git a/src/doomstat.h b/src/doomstat.h index 1f78710e2..9a3bff7c0 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -133,6 +133,7 @@ extern boolean hidetitlepics; extern INT16 bootmap; //bootmap for loading a map on startup extern INT16 tutorialmap; // map to load for tutorial +extern boolean tutorialmode; // are we in a tutorial right now? extern boolean looptitle; diff --git a/src/g_game.c b/src/g_game.c index 4b2877f95..38289bcb2 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -128,6 +128,7 @@ boolean hidetitlepics = false; INT16 bootmap; //bootmap for loading a map on startup INT16 tutorialmap = 0; // map to load for tutorial +boolean tutorialmode = false; // are we in a tutorial right now? boolean looptitle = false; diff --git a/src/m_menu.c b/src/m_menu.c index 103e629de..41fb1319d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6139,6 +6139,8 @@ static void M_StartTutorial(INT32 choice) if (!tutorialmap) return; // no map to go to, don't bother + tutorialmode = true; // turn on tutorial mode + emeralds = 0; M_ClearMenus(true); gamecomplete = false; diff --git a/src/st_stuff.c b/src/st_stuff.c index fa13e008a..246bae8bc 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2465,6 +2465,13 @@ static void ST_overlayDrawer(void) ST_drawDebugInfo(); } +static void ST_drawTutorial(void) +{ + // Nothing, ...yet + // Except this for now, just to check it works + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, "Tutorial placeholder"); +} + void ST_Drawer(void) { #ifdef SEENAMES @@ -2538,4 +2545,8 @@ void ST_Drawer(void) ST_overlayDrawer(); } } + + // Draw tutorial text over everything else + if (tutorialmode) + ST_drawTutorial(); } From 2b0ce807c752e435c6eaf5a127732808ff0fe9f1 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 4 Sep 2018 17:04:24 +0100 Subject: [PATCH 101/573] Fix mixed d+c in NiGHTS trigger code, fix stray "INT8" in A_ConnectToGround --- src/p_enemy.c | 2 +- src/p_spec.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 9235a1d0f..52044dfae 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -11378,7 +11378,7 @@ void A_ConnectToGround(mobj_t *actor) mobj_t *work; fixed_t workz; fixed_t workh; - INT8 dir; + SINT8 dir; angle_t ang; INT32 locvar1 = var1; INT32 locvar2 = var2; diff --git a/src/p_spec.c b/src/p_spec.c index e5c48dcaa..6c359c9cc 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1586,6 +1586,7 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) for (i = 0; i < MAXPLAYERS; i++) { + UINT8 lap; if (!playeringame[i] || players[i].spectator) continue; @@ -1599,7 +1600,7 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) && players[i].powers[pw_carry] == CR_NIGHTSMODE) playersarenights++; - UINT8 lap = lapfrombonustime ? players[i].marebonuslap : players[i].marelap; + lap = lapfrombonustime ? players[i].marebonuslap : players[i].marelap; // get highest mare/lap of players if (perglobal) From bffaafd61ed98eb31e357b5c2a9c9a188528318b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 4 Sep 2018 19:21:58 +0100 Subject: [PATCH 102/573] Add V_DrawTutorialBack for drawing a console-like background box, add Lorem ipsum as filler test --- src/st_stuff.c | 8 +++++++- src/v_video.c | 19 +++++++++++++++++++ src/v_video.h | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 246bae8bc..1adc6596c 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2467,9 +2467,15 @@ static void ST_overlayDrawer(void) static void ST_drawTutorial(void) { + INT32 charheight = 8; + INT32 y = BASEVIDHEIGHT - ((charheight * 4) + (charheight/2)*5); + INT32 i; // Nothing, ...yet // Except this for now, just to check it works - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, "Tutorial placeholder"); + //V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, "Tutorial placeholder"); + V_DrawTutorialBack(); + for (i = 0; i < 4; i++, y += 12) + V_DrawString(0, y, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"); } void ST_Drawer(void) diff --git a/src/v_video.c b/src/v_video.c index 765965ffd..05401ce56 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1480,6 +1480,25 @@ void V_DrawFadeConsBack(INT32 plines) *buf = consolebgmap[*buf]; } +// Very similar to F_DrawFadeConsBack, except we draw from the middle(-ish) of the screen to the bottom. +void V_DrawTutorialBack(void) +{ + INT32 charheight = 8*vid.dupy; + UINT8 *deststop, *buf; + +#ifdef HWRENDER + if (rendermode != render_soft) // no support for OpenGL yet + return; +#endif + + // heavily simplified -- we don't need to know x or y position, + // just the start and stop positions + deststop = screens[0] + vid.rowbytes * vid.height; + buf = deststop - vid.rowbytes * ((charheight * 4) + (charheight/2)*5); // 4 lines of space plus gaps between and some leeway + for (; buf < deststop; ++buf) + *buf = consolebgmap[*buf]; +} + // Gets string colormap, used for 0x80 color codes // static const UINT8 *V_GetStringColormap(INT32 colorflags) diff --git a/src/v_video.h b/src/v_video.h index 6113d08ec..850206816 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -158,6 +158,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum); void V_DrawFadeScreen(UINT16 color, UINT8 strength); void V_DrawFadeConsBack(INT32 plines); +void V_DrawTutorialBack(void); // draw a single character void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed); From 16c7c264a5b099e880b4469e044466e602775ca1 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 4 Sep 2018 19:52:50 +0100 Subject: [PATCH 103/573] Wrap the text and snap to bottom --- src/st_stuff.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 1adc6596c..d4c710e97 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2468,14 +2468,16 @@ static void ST_overlayDrawer(void) static void ST_drawTutorial(void) { INT32 charheight = 8; - INT32 y = BASEVIDHEIGHT - ((charheight * 4) + (charheight/2)*5); - INT32 i; + INT32 y = BASEVIDHEIGHT - ((charheight * 4) + (charheight/2)*4); + char *test; + //INT32 i; // Nothing, ...yet // Except this for now, just to check it works //V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, "Tutorial placeholder"); V_DrawTutorialBack(); - for (i = 0; i < 4; i++, y += 12) - V_DrawString(0, y, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"); + //for (i = 0; i < 4; i++, y += 12) + test = V_WordWrap(4, BASEVIDWIDTH-4, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"); + V_DrawString(4, y, V_SNAPTOBOTTOM, test); } void ST_Drawer(void) From e5dd74eb45f5b981c746206d9063e391d62ba11d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 07:24:46 -0400 Subject: [PATCH 104/573] Change flicky thing #s to 2200s --- src/info.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/info.c b/src/info.c index 36a6b510e..110879741 100644 --- a/src/info.c +++ b/src/info.c @@ -13777,7 +13777,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_01_CENTER - 570, // doomednum + 2200, // doomednum S_FLICKY_01_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13831,7 +13831,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_02_CENTER - 571, // doomednum + 2201, // doomednum S_FLICKY_02_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13885,7 +13885,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_03_CENTER - 572, // doomednum + 2202, // doomednum S_FLICKY_03_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13939,7 +13939,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_04_CENTER - 573, // doomednum + 2203, // doomednum S_FLICKY_04_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -13993,7 +13993,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_05_CENTER - 574, // doomednum + 2204, // doomednum S_FLICKY_05_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14047,7 +14047,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_06_CENTER - 575, // doomednum + 2205, // doomednum S_FLICKY_06_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14101,7 +14101,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_07_CENTER - 576, // doomednum + 2206, // doomednum S_FLICKY_07_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14155,7 +14155,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_08_CENTER - 577, // doomednum + 2207, // doomednum S_FLICKY_08_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14209,7 +14209,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_09_CENTER - 578, // doomednum + 2208, // doomednum S_FLICKY_09_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14263,7 +14263,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_10_CENTER - 579, // doomednum + 2209, // doomednum S_FLICKY_10_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14317,7 +14317,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_11_CENTER - 580, // doomednum + 2210, // doomednum S_FLICKY_11_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14371,7 +14371,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_12_CENTER - 581, // doomednum + 2211, // doomednum S_FLICKY_12_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14425,7 +14425,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_13_CENTER - 582, // doomednum + 2212, // doomednum S_FLICKY_13_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14479,7 +14479,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_14_CENTER - 583, // doomednum + 2213, // doomednum S_FLICKY_14_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14533,7 +14533,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_15_CENTER - 584, // doomednum + 2214, // doomednum S_FLICKY_15_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14587,7 +14587,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_FLICKY_16_CENTER - 585, // doomednum + 2215, // doomednum S_FLICKY_16_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14641,7 +14641,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_SECRETFLICKY_01_CENTER - 586, // doomednum + 2216, // doomednum S_SECRETFLICKY_01_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate @@ -14695,7 +14695,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = }, { // MT_SECRETFLICKY_02_CENTER - 587, // doomednum + 2217, // doomednum S_SECRETFLICKY_02_CENTER, // spawnstate 1000, // spawnhealth S_NULL, // seestate From 956b83729b8d36ffae6205fab1a2ef1ae2fc1279 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 07:55:15 -0400 Subject: [PATCH 105/573] Store extravalue1 (home radius) immediately in A_FlickyCenter, not during player look routine --- src/p_enemy.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 6d074e5f8..9c4276800 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10845,7 +10845,7 @@ void A_FlickyCenter(mobj_t *actor) | ((actor->spawnpoint->options & MTF_OBJECTSPECIAL) ? MF_GRENADEBOUNCE : 0) | ((actor->spawnpoint->options & MTF_AMBUSH) ? MF_NOCLIPTHING : 0) ); - actor->extravalue1 = actor->spawnpoint->angle; + actor->extravalue1 = abs(actor->spawnpoint->angle) * FRACUNIT; actor->extravalue2 = actor->spawnpoint->extrainfo; actor->friction = actor->spawnpoint->x*FRACUNIT; actor->movefactor = actor->spawnpoint->y*FRACUNIT; @@ -10859,7 +10859,7 @@ void A_FlickyCenter(mobj_t *actor) | ((flickyflags & 2) ? MF_GRENADEBOUNCE : 0) | ((flickyflags & 4) ? MF_NOCLIPTHING : 0) ); - actor->extravalue1 = 0; // move sign from var1 bit 24, distance from var2 + actor->extravalue1 = locvar2; // don't abs() yet, for movedir actor->extravalue2 = flickycolor; actor->friction = actor->x; actor->movefactor = actor->y; @@ -10895,6 +10895,10 @@ void A_FlickyCenter(mobj_t *actor) P_InternalFlickySetColor(actor->tracer, actor->extravalue2); actor->extravalue2 = 0; + + // Now abs() extravalue1 (home radius) + if (!actor->spawnpoint) + actor->extravalue1 = abs(actor->extravalue1); } if (!(actor->flags & MF_SLIDEME) && !(actor->flags & MF_NOCLIPTHING)) @@ -10905,12 +10909,9 @@ void A_FlickyCenter(mobj_t *actor) actor->tracer->fuse = FRACUNIT; - if (actor->extravalue1) - locvar2 = abs(actor->extravalue1)*FRACUNIT; - P_LookForPlayers(actor, true, false, locvar2); - if (actor->target && P_AproxDistance(actor->target->x - originx, actor->target->y - originy) < locvar2) + if (actor->target && P_AproxDistance(actor->target->x - originx, actor->target->y - originy) < actor->extravalue1) { actor->extravalue2 = 1; P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z); From 21a55a4702458b2abbaf3b3b20bcf55d732de24b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 08:07:13 -0400 Subject: [PATCH 106/573] Make default behavior: aimless flying flickies stay at Z height --- src/p_enemy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 9c4276800..5e85dae72 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10819,6 +10819,7 @@ void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo) // var2 = maximum default distance away from spawn the flickies are allowed to travel. If angle != 0, then that's the radius. // // If MTF_EXTRA (MF_SLIDEME) is flagged, Flickies move independently of a target. Else, move around the target. +// If MTF_EXTRA (MF_SLIDEME) and MTF_OBJECTSPECIAL (MF_GRENADEBOUNCE) are both flagged, Flying flickies sink from gravity. By default, they stay at constant Z height. // If MTF_OBJECTSPECIAL (MF_GRENADEBOUNCE) and NOT MTF_EXTRA (MF_SLIDEME) are flagged, Angle sign determines direction of circular movement. // If MTF_AMBUSH (MF_NOCLIPTHING) is flagged, Flickies hop in-place. // If MTF_AMBUSH (MF_NOCLIPTHING) and MTF_OBJECTSPECIAL (MF_GRENADEBOUNCE) is flagged, Flickies stand in-place without gravity. @@ -11036,8 +11037,8 @@ void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fi if (actor->target && P_IsFlickyCenter(actor->target->type) - && (actor->target->flags & MF_GRENADEBOUNCE) - && (actor->target->flags & MF_SLIDEME)) + && !((actor->target->flags & MF_GRENADEBOUNCE) + && (actor->target->flags & MF_SLIDEME))) vertangle = 0; else vertangle = (R_PointToAngle2(0, actor->z, targetdist, chasez) >> ANGLETOFINESHIFT) & FINEMASK; From f000a68150e30fa4fb7538fe02a8887c66433d4a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 08:08:53 -0400 Subject: [PATCH 107/573] Impose default radius for orbiting flickies --- src/p_enemy.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_enemy.c b/src/p_enemy.c index 5e85dae72..45761749d 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10900,6 +10900,10 @@ void A_FlickyCenter(mobj_t *actor) // Now abs() extravalue1 (home radius) if (!actor->spawnpoint) actor->extravalue1 = abs(actor->extravalue1); + + // Impose default home radius if flicky orbits around player + if (!(actor->flags & MF_SLIDEME) && !actor->extravalue1) + actor->extravalue1 = 512 * FRACUNIT; } if (!(actor->flags & MF_SLIDEME) && !(actor->flags & MF_NOCLIPTHING)) From 2cfd941778344343ee2440b67cb8bb2d747c4545 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 09:18:56 -0400 Subject: [PATCH 108/573] Re-organize flags for FLICKY_CENTER * Flickies can be in-place with just one flag (MF_GRENADEBOUNCE) * Flickies can now hop whether orbiting, aimless, or in-place * Removed ability to customize movedir for orbit; will always be random * Removed ability to customize gravity sink for aimless flying flickies * Misc: Use P_SetTarget to set actor->tracer for flicky center --- src/p_enemy.c | 63 +++++++++++++++++++-------------------------------- src/p_mobj.c | 4 +--- 2 files changed, 24 insertions(+), 43 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 273672987..72f68b2e5 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10812,17 +10812,14 @@ void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo) // Bit 21 = Flag MF_SLIDEME (see below) // Bit 22 = Flag MF_GRENADEBOUNCE (see below) // Bit 23 = Flag MF_NOCLIPTHING (see below) -// Bit 24 = Flicky movedir, 0 or 1 // // If actor is placed from a spawnpoint (map Thing), the Thing's properties take precedence. // // var2 = maximum default distance away from spawn the flickies are allowed to travel. If angle != 0, then that's the radius. // -// If MTF_EXTRA (MF_SLIDEME) is flagged, Flickies move independently of a target. Else, move around the target. -// If MTF_EXTRA (MF_SLIDEME) and MTF_OBJECTSPECIAL (MF_GRENADEBOUNCE) are both flagged, Flying flickies sink from gravity. By default, they stay at constant Z height. -// If MTF_OBJECTSPECIAL (MF_GRENADEBOUNCE) and NOT MTF_EXTRA (MF_SLIDEME) are flagged, Angle sign determines direction of circular movement. -// If MTF_AMBUSH (MF_NOCLIPTHING) is flagged, Flickies hop in-place. -// If MTF_AMBUSH (MF_NOCLIPTHING) and MTF_OBJECTSPECIAL (MF_GRENADEBOUNCE) is flagged, Flickies stand in-place without gravity. +// If MTF_EXTRA (MF_SLIDEME): is flagged, Flickies move aimlessly. Else, orbit around the target. +// If MTF_OBJECTSPECIAL (MF_GRENADEBOUNCE): Flickies stand in-place without gravity (unless they hop, then gravity is applied.) +// If MTF_AMBUSH (MF_NOCLIPTHING): is flagged, Flickies hop. // void A_FlickyCenter(mobj_t *actor) { @@ -10838,6 +10835,10 @@ void A_FlickyCenter(mobj_t *actor) if (!actor->tracer) { + mobj_t *flicky = P_InternalFlickySpawn(actor, locvar1, 1, false); + P_SetTarget(&flicky->target, actor); + P_SetTarget(&actor->tracer, flicky); + if (actor->spawnpoint) { actor->flags &= ~(MF_SLIDEME|MF_GRENADEBOUNCE|MF_NOCLIPTHING); @@ -10860,7 +10861,7 @@ void A_FlickyCenter(mobj_t *actor) | ((flickyflags & 2) ? MF_GRENADEBOUNCE : 0) | ((flickyflags & 4) ? MF_NOCLIPTHING : 0) ); - actor->extravalue1 = locvar2; // don't abs() yet, for movedir + actor->extravalue1 = abs(locvar2); actor->extravalue2 = flickycolor; actor->friction = actor->x; actor->movefactor = actor->y; @@ -10868,45 +10869,28 @@ void A_FlickyCenter(mobj_t *actor) locvar1 = flickytype; } - if (actor->flags & MF_SLIDEME) + if (actor->flags & MF_GRENADEBOUNCE) // in-place + actor->tracer->fuse = 0; + else if (actor->flags & MF_SLIDEME) // aimless { - actor->tracer = P_InternalFlickySpawn(actor, locvar1, 1, false); - P_SetTarget(&actor->tracer->target, actor); - actor->tracer->fuse = 0; // < 2*TICRATE means move aimlessly. - - if (!(actor->flags & MF_NOCLIPTHING)) - actor->tracer->angle = P_RandomKey(180)*ANG2; + actor->tracer->fuse = 0; // less than 2*TICRATE means move aimlessly. + actor->tracer->angle = P_RandomKey(180)*ANG2; } - else + else //orbit { - actor->tracer = P_InternalFlickySpawn(actor, locvar1, 1, false); - P_SetTarget(&actor->tracer->target, actor); actor->tracer->fuse = FRACUNIT; - - if ((actor->flags & MF_GRENADEBOUNCE) && !(actor->flags & MF_SLIDEME)) - { - if (!actor->spawnpoint) - actor->tracer->movedir = (flickyflags & 8) ? 1 : -1; - else - actor->tracer->movedir = actor->extravalue1 >= 0 ? 1 : -1; - } + // Impose default home radius if flicky orbits around player + if (!actor->extravalue1) + actor->extravalue1 = 512 * FRACUNIT; } if (locvar1 == MT_FLICKY_08) P_InternalFlickySetColor(actor->tracer, actor->extravalue2); actor->extravalue2 = 0; - - // Now abs() extravalue1 (home radius) - if (!actor->spawnpoint) - actor->extravalue1 = abs(actor->extravalue1); - - // Impose default home radius if flicky orbits around player - if (!(actor->flags & MF_SLIDEME) && !actor->extravalue1) - actor->extravalue1 = 512 * FRACUNIT; } - if (!(actor->flags & MF_SLIDEME) && !(actor->flags & MF_NOCLIPTHING)) + if (!(actor->flags & MF_SLIDEME) && !(actor->flags & MF_GRENADEBOUNCE)) { fixed_t originx = actor->friction; fixed_t originy = actor->movefactor; @@ -11041,8 +11025,7 @@ void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fi if (actor->target && P_IsFlickyCenter(actor->target->type) - && !((actor->target->flags & MF_GRENADEBOUNCE) - && (actor->target->flags & MF_SLIDEME))) + && (actor->target->flags & MF_SLIDEME)) vertangle = 0; else vertangle = (R_PointToAngle2(0, actor->z, targetdist, chasez) >> ANGLETOFINESHIFT) & FINEMASK; @@ -11204,9 +11187,9 @@ void A_FlickyCheck(mobj_t *actor) #endif if (actor->target && P_IsFlickyCenter(actor->target->type) - && (actor->target->flags & MF_NOCLIPTHING)) + && (actor->target->flags & MF_GRENADEBOUNCE)) { - if (actor->target->flags & MF_GRENADEBOUNCE) + if (!(actor->target->flags & MF_NOCLIPTHING)) // no hopping { actor->momz = 0; actor->flags |= MF_NOGRAVITY; @@ -11241,9 +11224,9 @@ void A_FlickyHeightCheck(mobj_t *actor) #endif if (actor->target && P_IsFlickyCenter(actor->target->type) - && (actor->target->flags & MF_NOCLIPTHING)) + && (actor->target->flags & MF_GRENADEBOUNCE)) { - if (actor->target->flags & MF_GRENADEBOUNCE) + if (!(actor->target->flags & MF_NOCLIPTHING)) // no hopping { actor->momz = 0; actor->flags |= MF_NOGRAVITY; diff --git a/src/p_mobj.c b/src/p_mobj.c index 894304491..d55fdf9c3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7137,9 +7137,7 @@ void P_MobjThinker(mobj_t *mobj) case MT_FLICKY_16_CENTER: case MT_SECRETFLICKY_01_CENTER: case MT_SECRETFLICKY_02_CENTER: - if (mobj->tracer - && (mobj->flags & MF_NOCLIPTHING) - && !(mobj->flags & MF_GRENADEBOUNCE)) + if (mobj->tracer && (mobj->flags & MF_NOCLIPTHING)) { if (!(mobj->tracer->flags2 & MF2_OBJECTFLIP) && mobj->tracer->z <= mobj->tracer->floorz) mobj->tracer->momz = 7*FRACUNIT; From 7d834ff894526ec808d47ed7a3456727a8de252d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 10:18:42 -0400 Subject: [PATCH 109/573] Erase default home radius from states and impose default on home check --- src/info.c | 36 ++++++++++++++++++------------------ src/p_enemy.c | 9 ++++----- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/info.c b/src/info.c index 0a90f2413..948a8830a 100644 --- a/src/info.c +++ b/src/info.c @@ -2642,7 +2642,7 @@ state_t states[NUMSTATES] = {SPR_FL01, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP3}, // S_FLICKY_01_FLAP2 {SPR_FL01, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP1}, // S_FLICKY_01_FLAP3 {SPR_FL01, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_01_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_01, 320*FRACUNIT, S_FLICKY_01_CENTER}, // S_FLICKY_01_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_01, 0, S_FLICKY_01_CENTER}, // S_FLICKY_01_CENTER // Rabbit {SPR_FL02, 0, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_OUT}, // S_FLICKY_02_OUT @@ -2651,7 +2651,7 @@ state_t states[NUMSTATES] = {SPR_FL02, 2, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, S_FLICKY_02_DOWN, S_FLICKY_02_UP}, // S_FLICKY_02_UP {SPR_FL02, 3, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_DOWN}, // S_FLICKY_02_DOWN {SPR_FL02, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_02_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_02, 320*FRACUNIT, S_FLICKY_02_CENTER}, // S_FLICKY_02_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_02, 0, S_FLICKY_02_CENTER}, // S_FLICKY_02_CENTER // Chicken {SPR_FL03, 0, 2, {A_FlickyCheck}, S_FLICKY_03_AIM, S_FLICKY_03_FLAP1, S_FLICKY_03_OUT}, // S_FLICKY_03_OUT @@ -2661,7 +2661,7 @@ state_t states[NUMSTATES] = {SPR_FL03, 3, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP2}, // S_FLICKY_03_FLAP1 {SPR_FL03, 4, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP1}, // S_FLICKY_03_FLAP2 {SPR_FL03, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_03_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_03, 320*FRACUNIT, S_FLICKY_03_CENTER}, // S_FLICKY_03_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_03, 0, S_FLICKY_03_CENTER}, // S_FLICKY_03_CENTER // Seal {SPR_FL04, 0, 2, {A_FlickyCheck}, S_FLICKY_04_AIM, 0, S_FLICKY_04_OUT}, // S_FLICKY_04_OUT @@ -2674,7 +2674,7 @@ state_t states[NUMSTATES] = {SPR_FL04, 3, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM4}, // S_FLICKY_04_SWIM3 {SPR_FL04, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM1}, // S_FLICKY_04_SWIM4 {SPR_FL04, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_04_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_04, 320*FRACUNIT, S_FLICKY_04_CENTER}, // S_FLICKY_04_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_04, 0, S_FLICKY_04_CENTER}, // S_FLICKY_04_CENTER // Pig {SPR_FL05, 0, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_OUT}, // S_FLICKY_05_OUT @@ -2683,7 +2683,7 @@ state_t states[NUMSTATES] = {SPR_FL05, 2, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, S_FLICKY_05_DOWN, S_FLICKY_05_UP}, // S_FLICKY_05_UP {SPR_FL05, 3, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_DOWN}, // S_FLICKY_05_DOWN {SPR_FL05, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_05_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_05, 320*FRACUNIT, S_FLICKY_05_CENTER}, // S_FLICKY_05_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_05, 0, S_FLICKY_05_CENTER}, // S_FLICKY_05_CENTER // Chipmunk {SPR_FL06, 0, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_OUT}, // S_FLICKY_06_OUT @@ -2692,7 +2692,7 @@ state_t states[NUMSTATES] = {SPR_FL06, 2, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, S_FLICKY_06_DOWN, S_FLICKY_06_UP}, // S_FLICKY_06_UP {SPR_FL06, 3, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_DOWN}, // S_FLICKY_06_DOWN {SPR_FL06, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_06_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_06, 320*FRACUNIT, S_FLICKY_06_CENTER}, // S_FLICKY_06_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_06, 0, S_FLICKY_06_CENTER}, // S_FLICKY_06_CENTER // Penguin {SPR_FL07, 0, 2, {A_FlickyCheck}, S_FLICKY_07_AIML, 0, S_FLICKY_07_OUT}, // S_FLICKY_07_OUT @@ -2708,7 +2708,7 @@ state_t states[NUMSTATES] = {SPR_FL07, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM2 {SPR_FL07, 6, 4, {A_FlickyCoast}, 2*FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM3 {SPR_FL07, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_07_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_07, 320*FRACUNIT, S_FLICKY_07_CENTER}, // S_FLICKY_07_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_07, 0, S_FLICKY_07_CENTER}, // S_FLICKY_07_CENTER // Fish {SPR_FL08, 0, 2, {A_FlickyCheck}, S_FLICKY_08_AIM, 0, S_FLICKY_08_OUT}, // S_FLICKY_08_OUT @@ -2723,7 +2723,7 @@ state_t states[NUMSTATES] = {SPR_FL08, 0, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_08_SWIM1, S_FLICKY_08_SWIM4}, // S_FLICKY_08_SWIM3 {SPR_FL08, 2, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_08_SWIM1, S_FLICKY_08_SWIM4}, // S_FLICKY_08_SWIM4 {SPR_FL08, FF_ANIMATE, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_08_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_08, 320*FRACUNIT, S_FLICKY_08_CENTER}, // S_FLICKY_08_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_08, 0, S_FLICKY_08_CENTER}, // S_FLICKY_08_CENTER // Ram {SPR_FL09, 0, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, 0, S_FLICKY_09_OUT}, // S_FLICKY_09_OUT @@ -2732,14 +2732,14 @@ state_t states[NUMSTATES] = {SPR_FL09, 2, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, S_FLICKY_09_DOWN, S_FLICKY_09_UP}, // S_FLICKY_09_UP {SPR_FL09, 3, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, 0, S_FLICKY_09_DOWN}, // S_FLICKY_09_DOWN {SPR_FL09, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_09_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_09, 320*FRACUNIT, S_FLICKY_09_CENTER}, // S_FLICKY_09_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_09, 0, S_FLICKY_09_CENTER}, // S_FLICKY_09_CENTER // Puffin {SPR_FL10, 0, 2, {A_FlickyCheck}, S_FLICKY_10_FLAP1, S_FLICKY_10_FLAP1, S_FLICKY_10_OUT}, // S_FLICKY_10_OUT {SPR_FL10, 1, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP2}, // S_FLICKY_10_FLAP1 {SPR_FL10, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP1}, // S_FLICKY_10_FLAP2 {SPR_FL10, FF_ANIMATE|1, -1, {NULL}, 1, 3, S_NULL}, // S_FLICKY_10_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_10, 320*FRACUNIT, S_FLICKY_10_CENTER}, // S_FLICKY_10_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_10, 0, S_FLICKY_10_CENTER}, // S_FLICKY_10_CENTER // Cow {SPR_FL11, 0, 2, {A_FlickyCheck}, S_FLICKY_11_AIM, 0, S_FLICKY_11_OUT}, // S_FLICKY_11_OUT @@ -2748,7 +2748,7 @@ state_t states[NUMSTATES] = {SPR_FL11, 2, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_RUN3}, // S_FLICKY_11_RUN2 {SPR_FL11, 3, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_AIM}, // S_FLICKY_11_RUN3 {SPR_FL11, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_11_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_11, 320*FRACUNIT, S_FLICKY_11_CENTER}, // S_FLICKY_11_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_11, 0, S_FLICKY_11_CENTER}, // S_FLICKY_11_CENTER // Rat {SPR_FL12, 0, 2, {A_FlickyCheck}, S_FLICKY_12_AIM, 0, S_FLICKY_12_OUT}, // S_FLICKY_12_OUT @@ -2757,7 +2757,7 @@ state_t states[NUMSTATES] = {SPR_FL12, 2, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_RUN3}, // S_FLICKY_12_RUN2 {SPR_FL12, 3, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_AIM}, // S_FLICKY_12_RUN3 {SPR_FL12, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_12_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_12, 320*FRACUNIT, S_FLICKY_12_CENTER}, // S_FLICKY_12_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_12, 0, S_FLICKY_12_CENTER}, // S_FLICKY_12_CENTER // Bear {SPR_FL13, 0, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_OUT}, // S_FLICKY_13_OUT @@ -2766,7 +2766,7 @@ state_t states[NUMSTATES] = {SPR_FL13, 2, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, S_FLICKY_13_DOWN, S_FLICKY_13_UP}, // S_FLICKY_13_UP {SPR_FL13, 3, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_DOWN}, // S_FLICKY_13_DOWN {SPR_FL13, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_13_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_13, 320*FRACUNIT, S_FLICKY_13_CENTER}, // S_FLICKY_13_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_13, 0, S_FLICKY_13_CENTER}, // S_FLICKY_13_CENTER // Dove {SPR_FL14, 0, 2, {A_FlickyCheck}, S_FLICKY_14_FLAP1, S_FLICKY_14_FLAP1, S_FLICKY_14_OUT}, // S_FLICKY_14_OUT @@ -2774,7 +2774,7 @@ state_t states[NUMSTATES] = {SPR_FL14, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP3}, // S_FLICKY_14_FLAP2 {SPR_FL14, 3, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP1}, // S_FLICKY_14_FLAP3 {SPR_FL14, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_14_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_14, 320*FRACUNIT, S_FLICKY_14_CENTER}, // S_FLICKY_14_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_14, 0, S_FLICKY_14_CENTER}, // S_FLICKY_14_CENTER // Cat {SPR_FL15, 0, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_OUT}, // S_FLICKY_15_OUT @@ -2783,7 +2783,7 @@ state_t states[NUMSTATES] = {SPR_FL15, 2, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, S_FLICKY_15_DOWN, S_FLICKY_15_UP}, // S_FLICKY_15_UP {SPR_FL15, 3, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_DOWN}, // S_FLICKY_15_DOWN {SPR_FL15, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_15_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_15, 320*FRACUNIT, S_FLICKY_15_CENTER}, // S_FLICKY_15_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_15, 0, S_FLICKY_15_CENTER}, // S_FLICKY_15_CENTER // Canary {SPR_FL16, 0, 2, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_OUT}, // S_FLICKY_16_OUT @@ -2791,7 +2791,7 @@ state_t states[NUMSTATES] = {SPR_FL16, 2, 3, {A_SetObjectFlags}, MF_NOGRAVITY, 1, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP2 {SPR_FL16, 3, 3, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP3 {SPR_FL16, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_16_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_16, 320*FRACUNIT, S_FLICKY_16_CENTER}, // S_FLICKY_16_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_16, 0, S_FLICKY_16_CENTER}, // S_FLICKY_16_CENTER // Spider {SPR_FS01, 0, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_OUT}, // S_SECRETFLICKY_01_OUT @@ -2800,7 +2800,7 @@ state_t states[NUMSTATES] = {SPR_FS01, 2, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, S_SECRETFLICKY_01_DOWN, S_SECRETFLICKY_01_UP}, // S_SECRETFLICKY_01_UP {SPR_FS01, 3, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_DOWN}, // S_SECRETFLICKY_01_DOWN {SPR_FS01, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_SECRETFLICKY_01_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_01, 320*FRACUNIT, S_SECRETFLICKY_01_CENTER}, // S_SECRETFLICKY_01_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_01, 0, S_SECRETFLICKY_01_CENTER}, // S_SECRETFLICKY_01_CENTER // Bat {SPR_FS02, 0, 2, {A_FlickyHeightCheck}, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_OUT}, // S_SECRETFLICKY_02_OUT @@ -2808,7 +2808,7 @@ state_t states[NUMSTATES] = {SPR_FS02, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP3}, // S_SECRETFLICKY_02_FLAP2 {SPR_FS02, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP1}, // S_SECRETFLICKY_02_FLAP3 {SPR_FS02, FF_ANIMATE|1, -1, {NULL}, 2, 2, S_NULL}, // S_SECRETFLICKY_02_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_02, 320*FRACUNIT, S_SECRETFLICKY_02_CENTER}, // S_SECRETFLICKY_02_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_02, 0, S_SECRETFLICKY_02_CENTER}, // S_SECRETFLICKY_02_CENTER // Fan {SPR_FANS, 0, 1, {A_FanBubbleSpawn}, 2048, 0, S_FAN2}, // S_FAN diff --git a/src/p_enemy.c b/src/p_enemy.c index 72f68b2e5..79e75bb28 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10877,12 +10877,7 @@ void A_FlickyCenter(mobj_t *actor) actor->tracer->angle = P_RandomKey(180)*ANG2; } else //orbit - { actor->tracer->fuse = FRACUNIT; - // Impose default home radius if flicky orbits around player - if (!actor->extravalue1) - actor->extravalue1 = 512 * FRACUNIT; - } if (locvar1 == MT_FLICKY_08) P_InternalFlickySetColor(actor->tracer, actor->extravalue2); @@ -10898,6 +10893,10 @@ void A_FlickyCenter(mobj_t *actor) actor->tracer->fuse = FRACUNIT; + // Impose default home radius if flicky orbits around player + if (!actor->extravalue1) + actor->extravalue1 = 512 * FRACUNIT; + P_LookForPlayers(actor, true, false, locvar2); if (actor->target && P_AproxDistance(actor->target->x - originx, actor->target->y - originy) < actor->extravalue1) From f8d260b0441da0dd2f9297b7c95038036ad845da Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 10:32:26 -0400 Subject: [PATCH 110/573] Only allow flicky bounce (MF_NOCLIPTHING) if also in-place (MF_GRENADEBOUNCE) --- src/p_mobj.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index d55fdf9c3..7b588645b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7137,7 +7137,9 @@ void P_MobjThinker(mobj_t *mobj) case MT_FLICKY_16_CENTER: case MT_SECRETFLICKY_01_CENTER: case MT_SECRETFLICKY_02_CENTER: - if (mobj->tracer && (mobj->flags & MF_NOCLIPTHING)) + if (mobj->tracer && (mobj->flags & MF_NOCLIPTHING) + && (mobj->flags & MF_GRENADEBOUNCE)) + // for now: only do this bounce routine if flicky is in-place. \todo allow in all movements { if (!(mobj->tracer->flags2 & MF2_OBJECTFLIP) && mobj->tracer->z <= mobj->tracer->floorz) mobj->tracer->momz = 7*FRACUNIT; From 0c2340b0bcd54f746a4fdc8f3e0f46e7d1342b2d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 11:17:08 -0400 Subject: [PATCH 111/573] Impose home radius on aimless flickies; improve randomness of flickyhitwall angle --- src/p_enemy.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 79e75bb28..f6e42f23e 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10954,7 +10954,10 @@ void A_FlickyAim(mobj_t *actor) return; #endif - if (actor->momx == actor->momy && actor->momy == 0) + if ((actor->momx == actor->momy && actor->momy == 0) + || (actor->target && P_IsFlickyCenter(actor->target->type) + && actor->target->extravalue1 && (actor->target->flags & MF_SLIDEME) + && P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) >= actor->target->extravalue1)) flickyhitwall = true; P_InternalFlickyBubble(actor); @@ -10986,7 +10989,10 @@ void A_FlickyAim(mobj_t *actor) } else if (flickyhitwall) { - actor->angle += ANGLE_180; + if (actor->target && P_IsFlickyCenter(actor->target->type)) + actor->angle = R_PointToAngle2(actor->target->x, actor->target->y, actor->x, actor->y) + P_RandomRange(112, 248) * ANG1; + else + actor->angle += P_RandomRange(112, 248)*ANG1; //P_RandomRange(160, 200) * ANG1;//ANGLE_180; actor->threshold = 0; } } From f15bb2dfbafe677e54654a5867fa42ce609ac4ec Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 11:54:06 -0400 Subject: [PATCH 112/573] Change default radius to 448 * Put default radius back in FLICKY_CENTER states --- src/info.c | 36 ++++++++++++++++++------------------ src/p_enemy.c | 7 ++++--- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/info.c b/src/info.c index 948a8830a..7b4995539 100644 --- a/src/info.c +++ b/src/info.c @@ -2642,7 +2642,7 @@ state_t states[NUMSTATES] = {SPR_FL01, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP3}, // S_FLICKY_01_FLAP2 {SPR_FL01, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP1}, // S_FLICKY_01_FLAP3 {SPR_FL01, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_01_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_01, 0, S_FLICKY_01_CENTER}, // S_FLICKY_01_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_01, 448*FRACUNIT, S_FLICKY_01_CENTER}, // S_FLICKY_01_CENTER // Rabbit {SPR_FL02, 0, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_OUT}, // S_FLICKY_02_OUT @@ -2651,7 +2651,7 @@ state_t states[NUMSTATES] = {SPR_FL02, 2, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, S_FLICKY_02_DOWN, S_FLICKY_02_UP}, // S_FLICKY_02_UP {SPR_FL02, 3, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_DOWN}, // S_FLICKY_02_DOWN {SPR_FL02, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_02_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_02, 0, S_FLICKY_02_CENTER}, // S_FLICKY_02_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_02, 448*FRACUNIT, S_FLICKY_02_CENTER}, // S_FLICKY_02_CENTER // Chicken {SPR_FL03, 0, 2, {A_FlickyCheck}, S_FLICKY_03_AIM, S_FLICKY_03_FLAP1, S_FLICKY_03_OUT}, // S_FLICKY_03_OUT @@ -2661,7 +2661,7 @@ state_t states[NUMSTATES] = {SPR_FL03, 3, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP2}, // S_FLICKY_03_FLAP1 {SPR_FL03, 4, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP1}, // S_FLICKY_03_FLAP2 {SPR_FL03, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_03_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_03, 0, S_FLICKY_03_CENTER}, // S_FLICKY_03_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_03, 448*FRACUNIT, S_FLICKY_03_CENTER}, // S_FLICKY_03_CENTER // Seal {SPR_FL04, 0, 2, {A_FlickyCheck}, S_FLICKY_04_AIM, 0, S_FLICKY_04_OUT}, // S_FLICKY_04_OUT @@ -2674,7 +2674,7 @@ state_t states[NUMSTATES] = {SPR_FL04, 3, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM4}, // S_FLICKY_04_SWIM3 {SPR_FL04, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM1}, // S_FLICKY_04_SWIM4 {SPR_FL04, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_04_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_04, 0, S_FLICKY_04_CENTER}, // S_FLICKY_04_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_04, 448*FRACUNIT, S_FLICKY_04_CENTER}, // S_FLICKY_04_CENTER // Pig {SPR_FL05, 0, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_OUT}, // S_FLICKY_05_OUT @@ -2683,7 +2683,7 @@ state_t states[NUMSTATES] = {SPR_FL05, 2, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, S_FLICKY_05_DOWN, S_FLICKY_05_UP}, // S_FLICKY_05_UP {SPR_FL05, 3, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_DOWN}, // S_FLICKY_05_DOWN {SPR_FL05, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_05_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_05, 0, S_FLICKY_05_CENTER}, // S_FLICKY_05_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_05, 448*FRACUNIT, S_FLICKY_05_CENTER}, // S_FLICKY_05_CENTER // Chipmunk {SPR_FL06, 0, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_OUT}, // S_FLICKY_06_OUT @@ -2692,7 +2692,7 @@ state_t states[NUMSTATES] = {SPR_FL06, 2, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, S_FLICKY_06_DOWN, S_FLICKY_06_UP}, // S_FLICKY_06_UP {SPR_FL06, 3, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_DOWN}, // S_FLICKY_06_DOWN {SPR_FL06, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_06_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_06, 0, S_FLICKY_06_CENTER}, // S_FLICKY_06_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_06, 448*FRACUNIT, S_FLICKY_06_CENTER}, // S_FLICKY_06_CENTER // Penguin {SPR_FL07, 0, 2, {A_FlickyCheck}, S_FLICKY_07_AIML, 0, S_FLICKY_07_OUT}, // S_FLICKY_07_OUT @@ -2708,7 +2708,7 @@ state_t states[NUMSTATES] = {SPR_FL07, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM2 {SPR_FL07, 6, 4, {A_FlickyCoast}, 2*FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM3 {SPR_FL07, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_07_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_07, 0, S_FLICKY_07_CENTER}, // S_FLICKY_07_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_07, 448*FRACUNIT, S_FLICKY_07_CENTER}, // S_FLICKY_07_CENTER // Fish {SPR_FL08, 0, 2, {A_FlickyCheck}, S_FLICKY_08_AIM, 0, S_FLICKY_08_OUT}, // S_FLICKY_08_OUT @@ -2723,7 +2723,7 @@ state_t states[NUMSTATES] = {SPR_FL08, 0, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_08_SWIM1, S_FLICKY_08_SWIM4}, // S_FLICKY_08_SWIM3 {SPR_FL08, 2, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_08_SWIM1, S_FLICKY_08_SWIM4}, // S_FLICKY_08_SWIM4 {SPR_FL08, FF_ANIMATE, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_08_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_08, 0, S_FLICKY_08_CENTER}, // S_FLICKY_08_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_08, 448*FRACUNIT, S_FLICKY_08_CENTER}, // S_FLICKY_08_CENTER // Ram {SPR_FL09, 0, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, 0, S_FLICKY_09_OUT}, // S_FLICKY_09_OUT @@ -2732,14 +2732,14 @@ state_t states[NUMSTATES] = {SPR_FL09, 2, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, S_FLICKY_09_DOWN, S_FLICKY_09_UP}, // S_FLICKY_09_UP {SPR_FL09, 3, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, 0, S_FLICKY_09_DOWN}, // S_FLICKY_09_DOWN {SPR_FL09, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_09_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_09, 0, S_FLICKY_09_CENTER}, // S_FLICKY_09_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_09, 448*FRACUNIT, S_FLICKY_09_CENTER}, // S_FLICKY_09_CENTER // Puffin {SPR_FL10, 0, 2, {A_FlickyCheck}, S_FLICKY_10_FLAP1, S_FLICKY_10_FLAP1, S_FLICKY_10_OUT}, // S_FLICKY_10_OUT {SPR_FL10, 1, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP2}, // S_FLICKY_10_FLAP1 {SPR_FL10, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP1}, // S_FLICKY_10_FLAP2 {SPR_FL10, FF_ANIMATE|1, -1, {NULL}, 1, 3, S_NULL}, // S_FLICKY_10_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_10, 0, S_FLICKY_10_CENTER}, // S_FLICKY_10_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_10, 448*FRACUNIT, S_FLICKY_10_CENTER}, // S_FLICKY_10_CENTER // Cow {SPR_FL11, 0, 2, {A_FlickyCheck}, S_FLICKY_11_AIM, 0, S_FLICKY_11_OUT}, // S_FLICKY_11_OUT @@ -2748,7 +2748,7 @@ state_t states[NUMSTATES] = {SPR_FL11, 2, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_RUN3}, // S_FLICKY_11_RUN2 {SPR_FL11, 3, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_AIM}, // S_FLICKY_11_RUN3 {SPR_FL11, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_11_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_11, 0, S_FLICKY_11_CENTER}, // S_FLICKY_11_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_11, 448*FRACUNIT, S_FLICKY_11_CENTER}, // S_FLICKY_11_CENTER // Rat {SPR_FL12, 0, 2, {A_FlickyCheck}, S_FLICKY_12_AIM, 0, S_FLICKY_12_OUT}, // S_FLICKY_12_OUT @@ -2757,7 +2757,7 @@ state_t states[NUMSTATES] = {SPR_FL12, 2, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_RUN3}, // S_FLICKY_12_RUN2 {SPR_FL12, 3, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_AIM}, // S_FLICKY_12_RUN3 {SPR_FL12, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_12_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_12, 0, S_FLICKY_12_CENTER}, // S_FLICKY_12_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_12, 448*FRACUNIT, S_FLICKY_12_CENTER}, // S_FLICKY_12_CENTER // Bear {SPR_FL13, 0, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_OUT}, // S_FLICKY_13_OUT @@ -2766,7 +2766,7 @@ state_t states[NUMSTATES] = {SPR_FL13, 2, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, S_FLICKY_13_DOWN, S_FLICKY_13_UP}, // S_FLICKY_13_UP {SPR_FL13, 3, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_DOWN}, // S_FLICKY_13_DOWN {SPR_FL13, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_13_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_13, 0, S_FLICKY_13_CENTER}, // S_FLICKY_13_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_13, 448*FRACUNIT, S_FLICKY_13_CENTER}, // S_FLICKY_13_CENTER // Dove {SPR_FL14, 0, 2, {A_FlickyCheck}, S_FLICKY_14_FLAP1, S_FLICKY_14_FLAP1, S_FLICKY_14_OUT}, // S_FLICKY_14_OUT @@ -2774,7 +2774,7 @@ state_t states[NUMSTATES] = {SPR_FL14, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP3}, // S_FLICKY_14_FLAP2 {SPR_FL14, 3, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP1}, // S_FLICKY_14_FLAP3 {SPR_FL14, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_14_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_14, 0, S_FLICKY_14_CENTER}, // S_FLICKY_14_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_14, 448*FRACUNIT, S_FLICKY_14_CENTER}, // S_FLICKY_14_CENTER // Cat {SPR_FL15, 0, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_OUT}, // S_FLICKY_15_OUT @@ -2783,7 +2783,7 @@ state_t states[NUMSTATES] = {SPR_FL15, 2, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, S_FLICKY_15_DOWN, S_FLICKY_15_UP}, // S_FLICKY_15_UP {SPR_FL15, 3, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_DOWN}, // S_FLICKY_15_DOWN {SPR_FL15, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_15_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_15, 0, S_FLICKY_15_CENTER}, // S_FLICKY_15_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_15, 448*FRACUNIT, S_FLICKY_15_CENTER}, // S_FLICKY_15_CENTER // Canary {SPR_FL16, 0, 2, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_OUT}, // S_FLICKY_16_OUT @@ -2791,7 +2791,7 @@ state_t states[NUMSTATES] = {SPR_FL16, 2, 3, {A_SetObjectFlags}, MF_NOGRAVITY, 1, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP2 {SPR_FL16, 3, 3, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP3 {SPR_FL16, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_16_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_16, 0, S_FLICKY_16_CENTER}, // S_FLICKY_16_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_16, 448*FRACUNIT, S_FLICKY_16_CENTER}, // S_FLICKY_16_CENTER // Spider {SPR_FS01, 0, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_OUT}, // S_SECRETFLICKY_01_OUT @@ -2800,7 +2800,7 @@ state_t states[NUMSTATES] = {SPR_FS01, 2, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, S_SECRETFLICKY_01_DOWN, S_SECRETFLICKY_01_UP}, // S_SECRETFLICKY_01_UP {SPR_FS01, 3, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_DOWN}, // S_SECRETFLICKY_01_DOWN {SPR_FS01, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_SECRETFLICKY_01_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_01, 0, S_SECRETFLICKY_01_CENTER}, // S_SECRETFLICKY_01_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_01, 448*FRACUNIT, S_SECRETFLICKY_01_CENTER}, // S_SECRETFLICKY_01_CENTER // Bat {SPR_FS02, 0, 2, {A_FlickyHeightCheck}, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_OUT}, // S_SECRETFLICKY_02_OUT @@ -2808,7 +2808,7 @@ state_t states[NUMSTATES] = {SPR_FS02, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP3}, // S_SECRETFLICKY_02_FLAP2 {SPR_FS02, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP1}, // S_SECRETFLICKY_02_FLAP3 {SPR_FS02, FF_ANIMATE|1, -1, {NULL}, 2, 2, S_NULL}, // S_SECRETFLICKY_02_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_02, 0, S_SECRETFLICKY_02_CENTER}, // S_SECRETFLICKY_02_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_02, 448*FRACUNIT, S_SECRETFLICKY_02_CENTER}, // S_SECRETFLICKY_02_CENTER // Fan {SPR_FANS, 0, 1, {A_FanBubbleSpawn}, 2048, 0, S_FAN2}, // S_FAN diff --git a/src/p_enemy.c b/src/p_enemy.c index f6e42f23e..a574e047e 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10847,7 +10847,8 @@ void A_FlickyCenter(mobj_t *actor) | ((actor->spawnpoint->options & MTF_OBJECTSPECIAL) ? MF_GRENADEBOUNCE : 0) | ((actor->spawnpoint->options & MTF_AMBUSH) ? MF_NOCLIPTHING : 0) ); - actor->extravalue1 = abs(actor->spawnpoint->angle) * FRACUNIT; + actor->extravalue1 = actor->spawnpoint->angle ? abs(actor->spawnpoint->angle) * FRACUNIT + : locvar2 ? abs(locvar2) : 448 * FRACUNIT; actor->extravalue2 = actor->spawnpoint->extrainfo; actor->friction = actor->spawnpoint->x*FRACUNIT; actor->movefactor = actor->spawnpoint->y*FRACUNIT; @@ -10895,9 +10896,9 @@ void A_FlickyCenter(mobj_t *actor) // Impose default home radius if flicky orbits around player if (!actor->extravalue1) - actor->extravalue1 = 512 * FRACUNIT; + actor->extravalue1 = locvar2 ? abs(locvar2) : 448 * FRACUNIT; - P_LookForPlayers(actor, true, false, locvar2); + P_LookForPlayers(actor, true, false, actor->extravalue1); if (actor->target && P_AproxDistance(actor->target->x - originx, actor->target->y - originy) < actor->extravalue1) { From e75213b14de6478868dc1645e86212ccbf092415 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 11:56:55 -0400 Subject: [PATCH 113/573] Limit random fish color to SRB2's defaults --- src/p_enemy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index a574e047e..8e2faa602 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10797,7 +10797,8 @@ void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo) }; if (extrainfo == 0) - actor->color = flickycolors[P_RandomKey(sizeof(flickycolors))]; + // until we can customize flicky colors by level header, just stick to SRB2's defaults + actor->color = flickycolors[P_RandomKey(2)]; //flickycolors[P_RandomKey(sizeof(flickycolors))]; else if (extrainfo-1 < sizeof(flickycolors)) actor->color = flickycolors[extrainfo-1]; } From 1c273cdcc895115280bdd805730ac45228b278a6 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 11:59:50 -0400 Subject: [PATCH 114/573] Make default flicky home radius 384 --- src/info.c | 36 ++++++++++++++++++------------------ src/p_enemy.c | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/info.c b/src/info.c index 7b4995539..728fb13c0 100644 --- a/src/info.c +++ b/src/info.c @@ -2642,7 +2642,7 @@ state_t states[NUMSTATES] = {SPR_FL01, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP3}, // S_FLICKY_01_FLAP2 {SPR_FL01, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_01_FLAP1}, // S_FLICKY_01_FLAP3 {SPR_FL01, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_01_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_01, 448*FRACUNIT, S_FLICKY_01_CENTER}, // S_FLICKY_01_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_01, 384*FRACUNIT, S_FLICKY_01_CENTER}, // S_FLICKY_01_CENTER // Rabbit {SPR_FL02, 0, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_OUT}, // S_FLICKY_02_OUT @@ -2651,7 +2651,7 @@ state_t states[NUMSTATES] = {SPR_FL02, 2, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, S_FLICKY_02_DOWN, S_FLICKY_02_UP}, // S_FLICKY_02_UP {SPR_FL02, 3, 2, {A_FlickyCheck}, S_FLICKY_02_AIM, 0, S_FLICKY_02_DOWN}, // S_FLICKY_02_DOWN {SPR_FL02, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_02_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_02, 448*FRACUNIT, S_FLICKY_02_CENTER}, // S_FLICKY_02_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_02, 384*FRACUNIT, S_FLICKY_02_CENTER}, // S_FLICKY_02_CENTER // Chicken {SPR_FL03, 0, 2, {A_FlickyCheck}, S_FLICKY_03_AIM, S_FLICKY_03_FLAP1, S_FLICKY_03_OUT}, // S_FLICKY_03_OUT @@ -2661,7 +2661,7 @@ state_t states[NUMSTATES] = {SPR_FL03, 3, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP2}, // S_FLICKY_03_FLAP1 {SPR_FL03, 4, 2, {A_FlickyFlutter}, S_FLICKY_03_HOP, 0, S_FLICKY_03_FLAP1}, // S_FLICKY_03_FLAP2 {SPR_FL03, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_03_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_03, 448*FRACUNIT, S_FLICKY_03_CENTER}, // S_FLICKY_03_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_03, 384*FRACUNIT, S_FLICKY_03_CENTER}, // S_FLICKY_03_CENTER // Seal {SPR_FL04, 0, 2, {A_FlickyCheck}, S_FLICKY_04_AIM, 0, S_FLICKY_04_OUT}, // S_FLICKY_04_OUT @@ -2674,7 +2674,7 @@ state_t states[NUMSTATES] = {SPR_FL04, 3, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM4}, // S_FLICKY_04_SWIM3 {SPR_FL04, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_04_SWIM1, S_FLICKY_04_SWIM1}, // S_FLICKY_04_SWIM4 {SPR_FL04, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_04_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_04, 448*FRACUNIT, S_FLICKY_04_CENTER}, // S_FLICKY_04_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_04, 384*FRACUNIT, S_FLICKY_04_CENTER}, // S_FLICKY_04_CENTER // Pig {SPR_FL05, 0, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_OUT}, // S_FLICKY_05_OUT @@ -2683,7 +2683,7 @@ state_t states[NUMSTATES] = {SPR_FL05, 2, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, S_FLICKY_05_DOWN, S_FLICKY_05_UP}, // S_FLICKY_05_UP {SPR_FL05, 3, 2, {A_FlickyCheck}, S_FLICKY_05_AIM, 0, S_FLICKY_05_DOWN}, // S_FLICKY_05_DOWN {SPR_FL05, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_05_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_05, 448*FRACUNIT, S_FLICKY_05_CENTER}, // S_FLICKY_05_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_05, 384*FRACUNIT, S_FLICKY_05_CENTER}, // S_FLICKY_05_CENTER // Chipmunk {SPR_FL06, 0, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_OUT}, // S_FLICKY_06_OUT @@ -2692,7 +2692,7 @@ state_t states[NUMSTATES] = {SPR_FL06, 2, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, S_FLICKY_06_DOWN, S_FLICKY_06_UP}, // S_FLICKY_06_UP {SPR_FL06, 3, 2, {A_FlickyCheck}, S_FLICKY_06_AIM, 0, S_FLICKY_06_DOWN}, // S_FLICKY_06_DOWN {SPR_FL06, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_06_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_06, 448*FRACUNIT, S_FLICKY_06_CENTER}, // S_FLICKY_06_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_06, 384*FRACUNIT, S_FLICKY_06_CENTER}, // S_FLICKY_06_CENTER // Penguin {SPR_FL07, 0, 2, {A_FlickyCheck}, S_FLICKY_07_AIML, 0, S_FLICKY_07_OUT}, // S_FLICKY_07_OUT @@ -2708,7 +2708,7 @@ state_t states[NUMSTATES] = {SPR_FL07, 5, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM2 {SPR_FL07, 6, 4, {A_FlickyCoast}, 2*FRACUNIT, S_FLICKY_07_SWIM1, S_FLICKY_07_SWIM3}, // S_FLICKY_07_SWIM3 {SPR_FL07, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_07_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_07, 448*FRACUNIT, S_FLICKY_07_CENTER}, // S_FLICKY_07_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_07, 384*FRACUNIT, S_FLICKY_07_CENTER}, // S_FLICKY_07_CENTER // Fish {SPR_FL08, 0, 2, {A_FlickyCheck}, S_FLICKY_08_AIM, 0, S_FLICKY_08_OUT}, // S_FLICKY_08_OUT @@ -2723,7 +2723,7 @@ state_t states[NUMSTATES] = {SPR_FL08, 0, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_08_SWIM1, S_FLICKY_08_SWIM4}, // S_FLICKY_08_SWIM3 {SPR_FL08, 2, 4, {A_FlickyCoast}, FRACUNIT, S_FLICKY_08_SWIM1, S_FLICKY_08_SWIM4}, // S_FLICKY_08_SWIM4 {SPR_FL08, FF_ANIMATE, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_08_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_08, 448*FRACUNIT, S_FLICKY_08_CENTER}, // S_FLICKY_08_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_08, 384*FRACUNIT, S_FLICKY_08_CENTER}, // S_FLICKY_08_CENTER // Ram {SPR_FL09, 0, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, 0, S_FLICKY_09_OUT}, // S_FLICKY_09_OUT @@ -2732,14 +2732,14 @@ state_t states[NUMSTATES] = {SPR_FL09, 2, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, S_FLICKY_09_DOWN, S_FLICKY_09_UP}, // S_FLICKY_09_UP {SPR_FL09, 3, 2, {A_FlickyCheck}, S_FLICKY_09_AIM, 0, S_FLICKY_09_DOWN}, // S_FLICKY_09_DOWN {SPR_FL09, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_09_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_09, 448*FRACUNIT, S_FLICKY_09_CENTER}, // S_FLICKY_09_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_09, 384*FRACUNIT, S_FLICKY_09_CENTER}, // S_FLICKY_09_CENTER // Puffin {SPR_FL10, 0, 2, {A_FlickyCheck}, S_FLICKY_10_FLAP1, S_FLICKY_10_FLAP1, S_FLICKY_10_OUT}, // S_FLICKY_10_OUT {SPR_FL10, 1, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP2}, // S_FLICKY_10_FLAP1 {SPR_FL10, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 16*FRACUNIT, S_FLICKY_10_FLAP1}, // S_FLICKY_10_FLAP2 {SPR_FL10, FF_ANIMATE|1, -1, {NULL}, 1, 3, S_NULL}, // S_FLICKY_10_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_10, 448*FRACUNIT, S_FLICKY_10_CENTER}, // S_FLICKY_10_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_10, 384*FRACUNIT, S_FLICKY_10_CENTER}, // S_FLICKY_10_CENTER // Cow {SPR_FL11, 0, 2, {A_FlickyCheck}, S_FLICKY_11_AIM, 0, S_FLICKY_11_OUT}, // S_FLICKY_11_OUT @@ -2748,7 +2748,7 @@ state_t states[NUMSTATES] = {SPR_FL11, 2, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_RUN3}, // S_FLICKY_11_RUN2 {SPR_FL11, 3, 4, {A_FlickyHop}, FRACUNIT/2, 2*FRACUNIT, S_FLICKY_11_AIM}, // S_FLICKY_11_RUN3 {SPR_FL11, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_11_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_11, 448*FRACUNIT, S_FLICKY_11_CENTER}, // S_FLICKY_11_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_11, 384*FRACUNIT, S_FLICKY_11_CENTER}, // S_FLICKY_11_CENTER // Rat {SPR_FL12, 0, 2, {A_FlickyCheck}, S_FLICKY_12_AIM, 0, S_FLICKY_12_OUT}, // S_FLICKY_12_OUT @@ -2757,7 +2757,7 @@ state_t states[NUMSTATES] = {SPR_FL12, 2, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_RUN3}, // S_FLICKY_12_RUN2 {SPR_FL12, 3, 3, {A_FlickyHop}, 1, 12*FRACUNIT, S_FLICKY_12_AIM}, // S_FLICKY_12_RUN3 {SPR_FL12, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_12_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_12, 448*FRACUNIT, S_FLICKY_12_CENTER}, // S_FLICKY_12_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_12, 384*FRACUNIT, S_FLICKY_12_CENTER}, // S_FLICKY_12_CENTER // Bear {SPR_FL13, 0, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_OUT}, // S_FLICKY_13_OUT @@ -2766,7 +2766,7 @@ state_t states[NUMSTATES] = {SPR_FL13, 2, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, S_FLICKY_13_DOWN, S_FLICKY_13_UP}, // S_FLICKY_13_UP {SPR_FL13, 3, 2, {A_FlickyCheck}, S_FLICKY_13_AIM, 0, S_FLICKY_13_DOWN}, // S_FLICKY_13_DOWN {SPR_FL13, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_13_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_13, 448*FRACUNIT, S_FLICKY_13_CENTER}, // S_FLICKY_13_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_13, 384*FRACUNIT, S_FLICKY_13_CENTER}, // S_FLICKY_13_CENTER // Dove {SPR_FL14, 0, 2, {A_FlickyCheck}, S_FLICKY_14_FLAP1, S_FLICKY_14_FLAP1, S_FLICKY_14_OUT}, // S_FLICKY_14_OUT @@ -2774,7 +2774,7 @@ state_t states[NUMSTATES] = {SPR_FL14, 2, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP3}, // S_FLICKY_14_FLAP2 {SPR_FL14, 3, 3, {A_FlickySoar}, 4*FRACUNIT, 32*FRACUNIT, S_FLICKY_14_FLAP1}, // S_FLICKY_14_FLAP3 {SPR_FL14, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_14_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_14, 448*FRACUNIT, S_FLICKY_14_CENTER}, // S_FLICKY_14_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_14, 384*FRACUNIT, S_FLICKY_14_CENTER}, // S_FLICKY_14_CENTER // Cat {SPR_FL15, 0, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_OUT}, // S_FLICKY_15_OUT @@ -2783,7 +2783,7 @@ state_t states[NUMSTATES] = {SPR_FL15, 2, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, S_FLICKY_15_DOWN, S_FLICKY_15_UP}, // S_FLICKY_15_UP {SPR_FL15, 3, 2, {A_FlickyCheck}, S_FLICKY_15_AIM, 0, S_FLICKY_15_DOWN}, // S_FLICKY_15_DOWN {SPR_FL15, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_FLICKY_15_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_15, 448*FRACUNIT, S_FLICKY_15_CENTER}, // S_FLICKY_15_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_15, 384*FRACUNIT, S_FLICKY_15_CENTER}, // S_FLICKY_15_CENTER // Canary {SPR_FL16, 0, 2, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_OUT}, // S_FLICKY_16_OUT @@ -2791,7 +2791,7 @@ state_t states[NUMSTATES] = {SPR_FL16, 2, 3, {A_SetObjectFlags}, MF_NOGRAVITY, 1, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP2 {SPR_FL16, 3, 3, {A_FlickyHeightCheck}, S_FLICKY_16_FLAP1, 0, S_FLICKY_16_FLAP3}, // S_FLICKY_16_FLAP3 {SPR_FL16, FF_ANIMATE|1, -1, {NULL}, 2, 3, S_NULL}, // S_FLICKY_16_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_16, 448*FRACUNIT, S_FLICKY_16_CENTER}, // S_FLICKY_16_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_FLICKY_16, 384*FRACUNIT, S_FLICKY_16_CENTER}, // S_FLICKY_16_CENTER // Spider {SPR_FS01, 0, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_OUT}, // S_SECRETFLICKY_01_OUT @@ -2800,7 +2800,7 @@ state_t states[NUMSTATES] = {SPR_FS01, 2, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, S_SECRETFLICKY_01_DOWN, S_SECRETFLICKY_01_UP}, // S_SECRETFLICKY_01_UP {SPR_FS01, 3, 2, {A_FlickyCheck}, S_SECRETFLICKY_01_AIM, 0, S_SECRETFLICKY_01_DOWN}, // S_SECRETFLICKY_01_DOWN {SPR_FS01, FF_ANIMATE|1, -1, {NULL}, 2, 4, S_NULL}, // S_SECRETFLICKY_01_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_01, 448*FRACUNIT, S_SECRETFLICKY_01_CENTER}, // S_SECRETFLICKY_01_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_01, 384*FRACUNIT, S_SECRETFLICKY_01_CENTER}, // S_SECRETFLICKY_01_CENTER // Bat {SPR_FS02, 0, 2, {A_FlickyHeightCheck}, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_FLAP1, S_SECRETFLICKY_02_OUT}, // S_SECRETFLICKY_02_OUT @@ -2808,7 +2808,7 @@ state_t states[NUMSTATES] = {SPR_FS02, 2, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP3}, // S_SECRETFLICKY_02_FLAP2 {SPR_FS02, 3, 3, {A_FlickyFly}, 4*FRACUNIT, 16*FRACUNIT, S_SECRETFLICKY_02_FLAP1}, // S_SECRETFLICKY_02_FLAP3 {SPR_FS02, FF_ANIMATE|1, -1, {NULL}, 2, 2, S_NULL}, // S_SECRETFLICKY_02_STAND - {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_02, 448*FRACUNIT, S_SECRETFLICKY_02_CENTER}, // S_SECRETFLICKY_02_CENTER + {SPR_NULL, 0, 15, {A_FlickyCenter}, MT_SECRETFLICKY_02, 384*FRACUNIT, S_SECRETFLICKY_02_CENTER}, // S_SECRETFLICKY_02_CENTER // Fan {SPR_FANS, 0, 1, {A_FanBubbleSpawn}, 2048, 0, S_FAN2}, // S_FAN diff --git a/src/p_enemy.c b/src/p_enemy.c index 8e2faa602..dbea394b9 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10849,7 +10849,7 @@ void A_FlickyCenter(mobj_t *actor) | ((actor->spawnpoint->options & MTF_AMBUSH) ? MF_NOCLIPTHING : 0) ); actor->extravalue1 = actor->spawnpoint->angle ? abs(actor->spawnpoint->angle) * FRACUNIT - : locvar2 ? abs(locvar2) : 448 * FRACUNIT; + : locvar2 ? abs(locvar2) : 384 * FRACUNIT; actor->extravalue2 = actor->spawnpoint->extrainfo; actor->friction = actor->spawnpoint->x*FRACUNIT; actor->movefactor = actor->spawnpoint->y*FRACUNIT; @@ -10897,7 +10897,7 @@ void A_FlickyCenter(mobj_t *actor) // Impose default home radius if flicky orbits around player if (!actor->extravalue1) - actor->extravalue1 = locvar2 ? abs(locvar2) : 448 * FRACUNIT; + actor->extravalue1 = locvar2 ? abs(locvar2) : 384 * FRACUNIT; P_LookForPlayers(actor, true, false, actor->extravalue1); From bd6bc368a3906e4c51978edc60a13f3088e07508 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 12:13:03 -0400 Subject: [PATCH 115/573] Stray comments --- src/p_enemy.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index dbea394b9..07f3139b1 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10994,7 +10994,7 @@ void A_FlickyAim(mobj_t *actor) if (actor->target && P_IsFlickyCenter(actor->target->type)) actor->angle = R_PointToAngle2(actor->target->x, actor->target->y, actor->x, actor->y) + P_RandomRange(112, 248) * ANG1; else - actor->angle += P_RandomRange(112, 248)*ANG1; //P_RandomRange(160, 200) * ANG1;//ANGLE_180; + actor->angle += P_RandomRange(112, 248)*ANG1; actor->threshold = 0; } } @@ -11048,8 +11048,6 @@ void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fi // var1 = how fast to fly // var2 = how far ahead the target should be considered // -// If MTF_EXTRA and MTF_OBJECTSPECIAL are flagged, Flicky will always fly at same Z height. -// void A_FlickyFly(mobj_t *actor) { INT32 locvar1 = var1; @@ -11070,8 +11068,6 @@ void A_FlickyFly(mobj_t *actor) // var1 = how fast to fly // var2 = how far ahead the target should be considered // -// If MTF_EXTRA and MTF_OBJECTSPECIAL are flagged, Flicky will always fly at same Z height. -// void A_FlickySoar(mobj_t *actor) { INT32 locvar1 = var1; From 956d48b5e0352910953a87e374b639b00f33f978 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 13:09:45 -0400 Subject: [PATCH 116/573] Compiler errors --- src/p_enemy.c | 2 +- src/p_local.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 07f3139b1..850d13524 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10799,7 +10799,7 @@ void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo) if (extrainfo == 0) // until we can customize flicky colors by level header, just stick to SRB2's defaults actor->color = flickycolors[P_RandomKey(2)]; //flickycolors[P_RandomKey(sizeof(flickycolors))]; - else if (extrainfo-1 < sizeof(flickycolors)) + else if (extrainfo-1 < 15) //sizeof(flickycolors)) actor->color = flickycolors[extrainfo-1]; } diff --git a/src/p_local.h b/src/p_local.h index d2537aa37..2676fb030 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -311,6 +311,7 @@ void P_NewChaseDir(mobj_t *actor); boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed_t dist); mobj_t *P_InternalFlickySpawn(mobj_t *actor, mobjtype_t flickytype, fixed_t momz, boolean lookforplayers); +void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo); #define P_IsFlickyCenter(type) (type > MT_FLICKY_01 && type < MT_SEED && (type - MT_FLICKY_01) % 2 ? 1 : 0) void P_InternalFlickyBubble(mobj_t *actor); void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fixed_t chasez); From 9e5b9ac50e00d69cac47b2d079b4f118949a000c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 6 Sep 2018 13:20:55 -0400 Subject: [PATCH 117/573] Flicky colors indexing fix --- src/p_enemy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 850d13524..8088c20a8 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10799,8 +10799,8 @@ void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo) if (extrainfo == 0) // until we can customize flicky colors by level header, just stick to SRB2's defaults actor->color = flickycolors[P_RandomKey(2)]; //flickycolors[P_RandomKey(sizeof(flickycolors))]; - else if (extrainfo-1 < 15) //sizeof(flickycolors)) - actor->color = flickycolors[extrainfo-1]; + else + actor->color = flickycolors[min(extrainfo-1, 14)]; // sizeof(flickycolors)-1 } // Function: A_FlickyCenter From 49b27fc1243e1d663032c80f9f0adfd726d8fbd5 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 7 Sep 2018 08:19:22 -0400 Subject: [PATCH 118/573] Deduct marescore immediately on instakill * Deduct player->spheres too, missed that one --- src/p_user.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index e1480a47d..806fc5da0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -609,9 +609,9 @@ static void P_DeNightserizePlayer(player_t *player) stagefailed = true; // NIGHT OVER // If you screwed up, kiss your score and ring bonus goodbye. - // But don't do this yet if not in special stage! Wait til we hit the ground. - player->marescore = 0; - player->rings = 0; + // But only do this in special stage (and instakill!) In regular stages, wait til we hit the ground. + player->marescore = player->spheres =\ + player->rings = 0; } // Check to see if the player should be killed. @@ -625,7 +625,11 @@ static void P_DeNightserizePlayer(player_t *player) continue; if (mo2->flags2 & MF2_AMBUSH) + { + player->marescore = player->spheres =\ + player->rings = 0; P_DamageMobj(player->mo, NULL, NULL, 1, DMG_INSTAKILL); + } break; } @@ -7083,8 +7087,8 @@ static void P_MovePlayer(player_t *player) P_DamageMobj(player->mo, NULL, NULL, 1, 0); // Now deduct our mare score! - player->marescore = 0; - player->rings = 0; + player->marescore = player->spheres =\ + player->rings = 0; } player->powers[pw_carry] = CR_NONE; } From 0b365d0d08df2922d92512267f85462b08e97475 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 7 Sep 2018 15:27:18 -0400 Subject: [PATCH 119/573] Initial polyobj fade skeleton --- src/p_polyobj.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ src/p_polyobj.h | 17 +++++++++++++ src/p_saveg.c | 24 ++++++++++++++++++ src/p_spec.c | 32 ++++++++++++++++++++++++ 4 files changed, 138 insertions(+) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index fd3237c9d..d943a0bfe 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2853,6 +2853,71 @@ INT32 EV_DoPolyObjFlag(line_t *pfdata) return 1; } +void T_PolyObjFade(polyfade_t *th) +{ + polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); + size_t i; + + if (!po) +#ifdef RANGECHECK + I_Error("T_PolyObjFade: thinker has invalid id %d\n", th->polyObjNum); +#else + { + CONS_Debug(DBG_POLYOBJ, "T_PolyObjFade: thinker with invalid id %d removed.\n", th->polyObjNum); + P_RemoveThinkerDelayed(&th->thinker); + return; + } +#endif + + // check for displacement due to override and reattach when possible + if (po->thinker == NULL) + po->thinker = &th->thinker; + + // \todo logic +} + +INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) +{ + polyobj_t *po; + polyobj_t *oldpo; + polyfade_t *th; + INT32 start; + + if (!(po = Polyobj_GetForNum(prdata->polyObjNum))) + { + CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjRotate: bad polyobj %d\n", prdata->polyObjNum); + return 0; + } + + // don't allow line actions to affect bad polyobjects + if (po->isBad) + return 0; + + // create a new thinker + th = Z_Malloc(sizeof(polyfade_t), PU_LEVSPEC, NULL); + th->thinker.function.acp1 = (actionf_p1)T_PolyObjFade; + PolyObj_AddThinker(&th->thinker); + po->thinker = &th->thinker; + + // set fields + th->polyObjNum = pfdata->tag; + + // \todo polyfade fields + + oldpo = po; + + // apply action to mirroring polyobjects as well + start = 0; + while ((po = Polyobj_GetChild(oldpo, &start))) + { + pfdata->tag = po->id; + EV_DoPolyObjFade(pfdata); + } + + // action was successful + return 1; +} + #endif // ifdef POLYOBJECTS // EOF diff --git a/src/p_polyobj.h b/src/p_polyobj.h index c9838a922..0bd94a636 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -207,6 +207,15 @@ typedef struct polydisplace_s fixed_t oldHeights; } polydisplace_t; +typedef struct polyfade_s +{ + thinker_t thinker; // must be first + + INT32 polyObjNum; + + // \todo polyfade fields +} polyfade_t; + // // Line Activation Data Structures // @@ -266,6 +275,12 @@ typedef struct polydisplacedata_s fixed_t dy; } polydisplacedata_t; +typedef struct polyfadedata_s +{ + INT32 polyObjNum; + // \todo polyfadedata fields +} polyfadedata_t; + // // Functions // @@ -287,6 +302,7 @@ void T_PolyDoorSlide(polyslidedoor_t *); void T_PolyDoorSwing(polyswingdoor_t *); void T_PolyObjDisplace (polydisplace_t *); void T_PolyObjFlag (polymove_t *); +void T_PolyObjFade (polyfade_t *); INT32 EV_DoPolyDoor(polydoordata_t *); INT32 EV_DoPolyObjMove(polymovedata_t *); @@ -294,6 +310,7 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *); INT32 EV_DoPolyObjRotate(polyrotdata_t *); INT32 EV_DoPolyObjDisplace(polydisplacedata_t *); INT32 EV_DoPolyObjFlag(struct line_s *); +INT32 EV_DoPolyObjFade(polyfadedata_t *); // diff --git a/src/p_saveg.c b/src/p_saveg.c index 22d43f358..3cc061ebb 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1019,6 +1019,7 @@ typedef enum tc_polyswingdoor, tc_polyflag, tc_polydisplace, + tc_polyfade, #endif tc_end } specials_e; @@ -1918,6 +1919,11 @@ static void P_NetArchiveThinkers(void) SavePolydisplaceThinker(th, tc_polydisplace); continue; } + else if (th->function.acp1 == (actionf_p1)T_PolyObjFade) + { + SavePolyfadeThinker(th, tc_polyfade); + continue; + } #endif #ifdef PARANOIA else if (th->function.acv != P_RemoveThinkerDelayed) // wait garbage collection @@ -2689,6 +2695,20 @@ static inline void LoadPolydisplaceThinker(actionf_p1 thinker) ht->oldHeights = READFIXED(save_p); P_AddThinker(&ht->thinker); } + +// +// LoadPolyfadeThinker +// +// Loads a polyfadet_t thinker +// +static void LoadPolyfadeThinker(actionf_p1 thinker) +{ + polyfade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); + ht->thinker.function.acp1 = thinker; + ht->polyObjNum = READINT32(save_p); + // \todo polyfade thinker fields + P_AddThinker(&ht->thinker); +} #endif /* @@ -2886,6 +2906,10 @@ static void P_NetUnArchiveThinkers(void) case tc_polydisplace: LoadPolydisplaceThinker((actionf_p1)T_PolyObjDisplace); break; + + case tc_polyfade: + LoadPolyfadeThinker((actionf_p1)T_PolyObjFade); + break; #endif case tc_scroll: LoadScrollThinker((actionf_p1)T_Scroll); diff --git a/src/p_spec.c b/src/p_spec.c index 6c359c9cc..fd2c312fb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1245,6 +1245,35 @@ static void PolyTranslucency(line_t *line) po->translucency = (line->frontsector->floorheight >> FRACBITS) / 100; } +// +// PolyFade +// +// Makes a polyobject translucency fade and applies tangibility +// +static void PolyFade(line_t *line) +{ + INT32 polyObjNum = line->tag; + polyobj_t *po; + + if (!(po = Polyobj_GetForNum(polyObjNum))) + { + CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjWaypoint: bad polyobj %d\n", polyObjNum); + return; + } + + // don't allow line actions to affect bad polyobjects + if (po->isBad) + return; + + polyfadedata_t pfd; + + pfd.polyObjNum = line->tag; + + // \todo polyfadedata fields + + return EV_DoPolyObjFade(&pfd); +} + // // PolyWaypoint // @@ -3337,6 +3366,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 491: PolyTranslucency(line); break; + case 492: + PolyFade(line); + break; #endif default: From f52f72256bd7abbd36876f42a213ca2e02121634 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 7 Sep 2018 18:14:52 -0400 Subject: [PATCH 120/573] Thwomp fix: Don't trigger (look for players) when ~FF_EXISTS --- src/p_floor.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index 0e28b831f..bb6bf8d16 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1839,6 +1839,7 @@ void T_ThwompSector(levelspecthink_t *thwomp) #define ceilingwasheight vars[5] fixed_t thwompx, thwompy; sector_t *actionsector; + ffloor_t *rover = NULL; INT32 secnum; // If you just crashed down, wait a second before coming back up. @@ -1853,7 +1854,16 @@ void T_ThwompSector(levelspecthink_t *thwomp) secnum = P_FindSectorFromTag((INT16)thwomp->vars[0], -1); if (secnum > 0) + { actionsector = §ors[secnum]; + + // Look for thwomp FFloor + for (rover = actionsector->ffloors; rover; rover = rover->next) + { + if (rover->master == thwomp->sourceline) + break; + } + } else return; // Bad bad bad! @@ -1942,10 +1952,13 @@ void T_ThwompSector(levelspecthink_t *thwomp) { mobj_t *mp = (void *)&actionsector->soundorg; - if (thwomp->sourceline->flags & ML_EFFECT4) - S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); - else - S_StartSound(mp, sfx_thwomp); + if (!rover || (rover->flags & FF_EXISTS)) + { + if (thwomp->sourceline->flags & ML_EFFECT4) + S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); + else + S_StartSound(mp, sfx_thwomp); + } thwomp->direction = 1; // start heading back up thwomp->distance = TICRATE; // but only after a small delay @@ -1959,18 +1972,21 @@ void T_ThwompSector(levelspecthink_t *thwomp) thinker_t *th; mobj_t *mo; - // scan the thinkers to find players! - for (th = thinkercap.next; th != &thinkercap; th = th->next) + if (!rover || (rover->flags & FF_EXISTS)) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo = (mobj_t *)th; - if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight - && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + // scan the thinkers to find players! + for (th = thinkercap.next; th != &thinkercap; th = th->next) { - thwomp->direction = -1; - break; + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + mo = (mobj_t *)th; + if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight + && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + { + thwomp->direction = -1; + break; + } } } From 76d7a54b2b5e1c4a125f3bfbfb5b4336cf50688c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 00:34:56 -0400 Subject: [PATCH 121/573] Fix player Z snap to floor on moving platform ~FF_EXISTS * Track player's old floorz by mo->floor_sectornum and floor_ffloornum * Track tmfloorz by tmfloorrover, tmfloor_sectornum, tmfloor_rovernum * Ceiling variants of the above --- src/p_map.c | 100 +++++++++++++++++++++++++++++++++++++++++++++----- src/p_mobj.h | 4 ++ src/p_saveg.c | 13 +++++++ 3 files changed, 108 insertions(+), 9 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index f951621e2..8d0a7aeb1 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -52,6 +52,8 @@ fixed_t tmfloorz, tmceilingz; static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) +ffloor_t *tmfloorrover, *tmceilingrover; +size_t tmfloor_sectornum, tmfloor_rovernum, tmceiling_sectornum, tmceiling_rovernum; #ifdef ESLOPE pslope_t *tmfloorslope, *tmceilingslope; #endif @@ -1417,6 +1419,8 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z + thing->height > tmfloorz) { tmfloorz = thing->z + thing->height; + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1437,6 +1441,8 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1445,6 +1451,8 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1461,6 +1469,8 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z < tmceilingz) { tmceilingz = thing->z; + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1481,6 +1491,8 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1489,6 +1501,8 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1640,6 +1654,8 @@ static boolean PIT_CheckLine(line_t *ld) { tmceilingz = opentop; ceilingline = ld; + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = opentopslope; #endif @@ -1648,6 +1664,8 @@ static boolean PIT_CheckLine(line_t *ld) if (openbottom > tmfloorz) { tmfloorz = openbottom; + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = openbottomslope; #endif @@ -1729,6 +1747,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // will adjust them. tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmfloorslope = newsubsec->sector->f_slope; tmceilingslope = newsubsec->sector->c_slope; @@ -1738,6 +1760,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) if (newsubsec->sector->ffloors) { ffloor_t *rover; + size_t rovernum = 0; fixed_t delta1, delta2; INT32 thingtop = thing->z + thing->height; @@ -1746,7 +1769,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) fixed_t topheight, bottomheight; if (!(rover->flags & FF_EXISTS)) + { + rovernum++; continue; + } topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL); bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL); @@ -1772,6 +1798,9 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < topheight - sinklevel) { tmfloorz = topheight - sinklevel; + tmfloorrover = rover; + tmfloor_sectornum = newsubsec->sector - sectors; + tmfloor_rovernum = rovernum; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1781,12 +1810,16 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmceilingz > bottomheight + sinklevel) { tmceilingz = bottomheight + sinklevel; + tmceilingrover = rover; + tmceiling_sectornum = newsubsec->sector - sectors; + tmceiling_rovernum = rovernum; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif } } } + rovernum++; continue; } @@ -1797,7 +1830,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) else if (!((rover->flags & FF_BLOCKPLAYER && thing->player) || (rover->flags & FF_BLOCKOTHERS && !thing->player) || rover->flags & FF_QUICKSAND)) + { + rovernum++; continue; + } if (rover->flags & FF_QUICKSAND) { @@ -1805,12 +1841,16 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < thing->z) { tmfloorz = thing->z; + tmfloorrover = rover; + tmfloor_sectornum = newsubsec->sector - sectors; + tmfloor_rovernum = rovernum; #ifdef ESLOPE tmfloorslope = NULL; #endif } } // Quicksand blocks never change heights otherwise. + rovernum++; continue; } @@ -1823,6 +1863,9 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(rover->flags & FF_REVERSEPLATFORM)) { tmfloorz = tmdropoffz = topheight; + tmfloorrover = rover; + tmfloor_sectornum = newsubsec->sector - sectors; + tmfloor_rovernum = rovernum; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1832,10 +1875,14 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE))) { tmceilingz = tmdrpoffceilz = bottomheight; + tmceilingrover = rover; + tmceiling_sectornum = newsubsec->sector - sectors; + tmceiling_rovernum = rovernum; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif } + rovernum++; } } @@ -2328,6 +2375,12 @@ boolean PIT_PushableMoved(mobj_t *thing) mobj_t *oldthing = tmthing; line_t *oldceilline = ceilingline; line_t *oldblockline = blockingline; + ffloor_t *oldflrrover = tmfloorrover; + ffloor_t *oldceilrover = tmceilingrover; + size_t oldflrrover_sectornum = tmfloor_sectornum; + size_t oldflrrover_ffloornum = tmfloor_rovernum; + size_t oldceilrover_sectornum = tmceiling_sectornum; + size_t oldceilrover_ffloornum = tmceiling_rovernum; #ifdef ESLOPE pslope_t *oldfslope = tmfloorslope; pslope_t *oldcslope = tmceilingslope; @@ -2344,6 +2397,12 @@ boolean PIT_PushableMoved(mobj_t *thing) P_SetTarget(&tmthing, oldthing); ceilingline = oldceilline; blockingline = oldblockline; + tmfloorrover = oldflrrover; + tmceilingrover = oldceilrover; + tmfloor_sectornum = oldflrrover_sectornum; + tmfloor_rovernum = oldflrrover_ffloornum; + tmceiling_sectornum = oldceilrover_sectornum; + tmceiling_rovernum = oldceilrover_ffloornum; #ifdef ESLOPE tmfloorslope = oldfslope; tmceilingslope = oldcslope; @@ -2663,7 +2722,9 @@ static boolean P_ThingHeightClip(mobj_t *thing) { boolean floormoved; fixed_t oldfloorz = thing->floorz; + size_t oldfloor_sectornum = thing->floor_sectornum, oldfloor_rovernum = thing->floor_rovernum; boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz); + ffloor_t *rover = NULL; if (thing->flags & MF_NOCLIPHEIGHT) return true; @@ -2678,6 +2739,10 @@ static boolean P_ThingHeightClip(mobj_t *thing) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floor_sectornum = tmfloor_sectornum; + thing->floor_rovernum = tmfloor_rovernum; + thing->ceiling_sectornum = tmceiling_sectornum; + thing->ceiling_rovernum = tmceiling_rovernum; // Ugly hack?!?! As long as just ceilingz is the lowest, // you'll still get crushed, right? @@ -2686,16 +2751,33 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved) { - if (thing->eflags & MFE_VERTICALFLIP) - thing->pmomz = thing->ceilingz - (thing->z + thing->height); - else - thing->pmomz = thing->floorz - thing->z; - thing->eflags |= MFE_APPLYPMOMZ; + // Find FOF referenced by floorz + if (oldfloor_sectornum) + { + size_t rovernum = 0; + for (rover = sectors[oldfloor_sectornum].ffloors; rover; rover = rover->next) + { + if (rovernum == oldfloor_rovernum) + break; + rovernum++; + } + } - if (thing->eflags & MFE_VERTICALFLIP) - thing->z = thing->ceilingz - thing->height; - else - thing->z = thing->floorz; + // Match the Thing's old floorz to an FOF and check for FF_EXISTS + // If ~FF_EXISTS, don't set mobj Z. + if (!rover || (rover->flags & FF_EXISTS)) + { + if (thing->eflags & MFE_VERTICALFLIP) + thing->pmomz = thing->ceilingz - (thing->z + thing->height); + else + thing->pmomz = thing->floorz - thing->z; + thing->eflags |= MFE_APPLYPMOMZ; + + if (thing->eflags & MFE_VERTICALFLIP) + thing->z = thing->ceilingz - thing->height; + else + thing->z = thing->floorz; + } } else if (!tmfloorthing) { diff --git a/src/p_mobj.h b/src/p_mobj.h index afab6fda6..3a83a0f58 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -282,6 +282,10 @@ typedef struct mobj_s // The closest interval over all contacted sectors (or things). fixed_t floorz; // Nearest floor below. fixed_t ceilingz; // Nearest ceiling above. + size_t floor_sectornum; // FOF referred by floorz + size_t floor_rovernum; // FOF referred by floorz + size_t ceiling_sectornum; // FOF referred by ceilingz + size_t ceiling_rovernum; // FOF referred by ceilingz // For movement checking. fixed_t radius; diff --git a/src/p_saveg.c b/src/p_saveg.c index 22d43f358..33dfd1424 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1192,6 +1192,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->z); // Force this so 3dfloor problems don't arise. WRITEFIXED(save_p, mobj->floorz); WRITEFIXED(save_p, mobj->ceilingz); + WRITEUINT32(save_p, (UINT32)mobj->floor_sectornum); + WRITEUINT32(save_p, (UINT32)mobj->floor_rovernum); + WRITEUINT32(save_p, (UINT32)mobj->ceiling_sectornum); + WRITEUINT32(save_p, (UINT32)mobj->ceiling_rovernum); if (diff & MD_SPAWNPOINT) { @@ -1989,6 +1993,7 @@ static void LoadMobjThinker(actionf_p1 thinker) UINT16 diff2; INT32 i; fixed_t z, floorz, ceilingz; + size_t floor_sectornum, floor_rovernum, ceiling_sectornum, ceiling_rovernum; diff = READUINT32(save_p); if (diff & MD_MORE) @@ -2001,6 +2006,10 @@ static void LoadMobjThinker(actionf_p1 thinker) z = READFIXED(save_p); // Force this so 3dfloor problems don't arise. floorz = READFIXED(save_p); ceilingz = READFIXED(save_p); + floor_sectornum = (size_t)READUINT32(save_p); + floor_rovernum = (size_t)READUINT32(save_p); + ceiling_sectornum = (size_t)READUINT32(save_p); + ceiling_rovernum = (size_t)READUINT32(save_p); if (diff & MD_SPAWNPOINT) { @@ -2026,6 +2035,10 @@ static void LoadMobjThinker(actionf_p1 thinker) mobj->z = z; mobj->floorz = floorz; mobj->ceilingz = ceilingz; + mobj->floor_sectornum = floor_sectornum; + mobj->floor_rovernum = floor_rovernum; + mobj->ceiling_sectornum = ceiling_sectornum; + mobj->ceiling_rovernum = ceiling_rovernum; if (diff & MD_TYPE) mobj->type = READUINT32(save_p); From 7e3d5cd3734c5b2194dca7fb8875c9cfeca97dc4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 00:36:43 -0400 Subject: [PATCH 122/573] Comment out tmfloorrover and tmceilingrover because unused --- src/p_map.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 8d0a7aeb1..62f64922c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -52,7 +52,7 @@ fixed_t tmfloorz, tmceilingz; static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) -ffloor_t *tmfloorrover, *tmceilingrover; +//ffloor_t *tmfloorrover, *tmceilingrover; // unused for now size_t tmfloor_sectornum, tmfloor_rovernum, tmceiling_sectornum, tmceiling_rovernum; #ifdef ESLOPE pslope_t *tmfloorslope, *tmceilingslope; @@ -1419,7 +1419,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z + thing->height > tmfloorz) { tmfloorz = thing->z + thing->height; - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; @@ -1441,7 +1441,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; @@ -1451,7 +1451,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; @@ -1469,7 +1469,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z < tmceilingz) { tmceilingz = thing->z; - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; @@ -1491,7 +1491,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; @@ -1501,7 +1501,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; @@ -1654,7 +1654,7 @@ static boolean PIT_CheckLine(line_t *ld) { tmceilingz = opentop; ceilingline = ld; - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = opentopslope; @@ -1664,7 +1664,7 @@ static boolean PIT_CheckLine(line_t *ld) if (openbottom > tmfloorz) { tmfloorz = openbottom; - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = openbottomslope; @@ -1747,9 +1747,9 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // will adjust them. tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmfloorslope = newsubsec->sector->f_slope; @@ -1798,7 +1798,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < topheight - sinklevel) { tmfloorz = topheight - sinklevel; - tmfloorrover = rover; + // tmfloorrover = rover; tmfloor_sectornum = newsubsec->sector - sectors; tmfloor_rovernum = rovernum; #ifdef ESLOPE @@ -1810,7 +1810,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmceilingz > bottomheight + sinklevel) { tmceilingz = bottomheight + sinklevel; - tmceilingrover = rover; + // tmceilingrover = rover; tmceiling_sectornum = newsubsec->sector - sectors; tmceiling_rovernum = rovernum; #ifdef ESLOPE @@ -1841,7 +1841,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < thing->z) { tmfloorz = thing->z; - tmfloorrover = rover; + // tmfloorrover = rover; tmfloor_sectornum = newsubsec->sector - sectors; tmfloor_rovernum = rovernum; #ifdef ESLOPE @@ -1863,7 +1863,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(rover->flags & FF_REVERSEPLATFORM)) { tmfloorz = tmdropoffz = topheight; - tmfloorrover = rover; + // tmfloorrover = rover; tmfloor_sectornum = newsubsec->sector - sectors; tmfloor_rovernum = rovernum; #ifdef ESLOPE @@ -1875,7 +1875,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE))) { tmceilingz = tmdrpoffceilz = bottomheight; - tmceilingrover = rover; + // tmceilingrover = rover; tmceiling_sectornum = newsubsec->sector - sectors; tmceiling_rovernum = rovernum; #ifdef ESLOPE @@ -2375,8 +2375,8 @@ boolean PIT_PushableMoved(mobj_t *thing) mobj_t *oldthing = tmthing; line_t *oldceilline = ceilingline; line_t *oldblockline = blockingline; - ffloor_t *oldflrrover = tmfloorrover; - ffloor_t *oldceilrover = tmceilingrover; + // ffloor_t *oldflrrover = tmfloorrover; + // ffloor_t *oldceilrover = tmceilingrover; size_t oldflrrover_sectornum = tmfloor_sectornum; size_t oldflrrover_ffloornum = tmfloor_rovernum; size_t oldceilrover_sectornum = tmceiling_sectornum; @@ -2397,8 +2397,8 @@ boolean PIT_PushableMoved(mobj_t *thing) P_SetTarget(&tmthing, oldthing); ceilingline = oldceilline; blockingline = oldblockline; - tmfloorrover = oldflrrover; - tmceilingrover = oldceilrover; + // tmfloorrover = oldflrrover; + // tmceilingrover = oldceilrover; tmfloor_sectornum = oldflrrover_sectornum; tmfloor_rovernum = oldflrrover_ffloornum; tmceiling_sectornum = oldceilrover_sectornum; From b629104197ada81d27c84c023430749965ed5dc6 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 01:02:17 -0400 Subject: [PATCH 123/573] Also check for FF_SOLID --- src/p_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index 62f64922c..c275ba0be 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2765,7 +2765,7 @@ static boolean P_ThingHeightClip(mobj_t *thing) // Match the Thing's old floorz to an FOF and check for FF_EXISTS // If ~FF_EXISTS, don't set mobj Z. - if (!rover || (rover->flags & FF_EXISTS)) + if (!rover || ((rover->flags & FF_EXISTS) && (rover->flags & FF_SOLID))) { if (thing->eflags & MFE_VERTICALFLIP) thing->pmomz = thing->ceilingz - (thing->z + thing->height); From 66dc84509a2d16c44cad27d74bb185532484df85 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 01:12:34 -0400 Subject: [PATCH 124/573] Fix Mario block triggering during ghost fade --- src/p_spec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index 6ba73f98d..1a0fa91b0 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7485,6 +7485,8 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, rover->flags &= ~FF_QUICKSAND; if (rover->spawnflags & FF_BUSTUP) rover->flags &= ~FF_BUSTUP; + if (rover->spawnflags & FF_MARIO) + rover->flags &= ~FF_MARIO; } } else // continue fading out @@ -7510,6 +7512,8 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, rover->flags |= FF_QUICKSAND; if (rover->spawnflags & FF_BUSTUP) rover->flags |= FF_BUSTUP; + if (rover->spawnflags & FF_MARIO) + rover->flags |= FF_MARIO; } } else // continue fading in @@ -7567,6 +7571,8 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, rover->flags &= ~FF_QUICKSAND; if (rover->spawnflags & FF_BUSTUP) rover->flags &= ~FF_BUSTUP; + if (rover->spawnflags & FF_MARIO) + rover->flags &= ~FF_MARIO; } else // keep collision during fade { @@ -7578,6 +7584,8 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, rover->flags |= FF_QUICKSAND; if (rover->spawnflags & FF_BUSTUP) rover->flags |= FF_BUSTUP; + if (rover->spawnflags & FF_MARIO) + rover->flags |= FF_MARIO; } } } From dc964738eb8939888c5a988cdf41a294a029e505 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 01:23:15 -0400 Subject: [PATCH 125/573] Never handle FF_EXISTS if FF_BUSTUP --- src/p_spec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 1a0fa91b0..9a1ed4e9f 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7526,7 +7526,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, // routines common to both fade in and fade out if (!stillfading) { - if (doexists) + if (doexists && !(rover->spawnflags & FF_BUSTUP)) { if (alpha <= 1) rover->flags &= ~FF_EXISTS; @@ -7550,7 +7550,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, } else { - if (doexists) + if (doexists && !(rover->spawnflags & FF_BUSTUP)) rover->flags |= FF_EXISTS; if (dotranslucent) From 47c9bf2ebc9e7b95af4b3c1731c2c6999e994501 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 01:33:12 -0400 Subject: [PATCH 126/573] Disable FadeFakeFloor for laser block --- src/p_spec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index 9a1ed4e9f..307cca05f 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7460,6 +7460,9 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, INT32 alpha; fade_t *fadingdata = (fade_t *)rover->fadingdata; + if (rover->master->special == 258) // Laser block + return false; + if (fadingdata) alpha = fadingdata->alpha; else From fcc7180d5c01c22026aee2f1c26a82b32717b449 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 08:46:56 -0400 Subject: [PATCH 127/573] Enable FF_CUTSOLIDS handling and updating by sector->moved --- src/p_spec.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 307cca05f..78c78d5e0 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7541,13 +7541,23 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, { if (alpha >= 256) { - //rover->flags |= (FF_CUTLEVEL | FF_CUTEXTRA); + if (!(rover->flags & FF_CUTSOLIDS) && + (rover->spawnflags & FF_CUTSOLIDS)) + { + rover->flags |= FF_CUTSOLIDS; + rover->target->moved = true; + } rover->flags &= ~FF_TRANSLUCENT; } else { rover->flags |= FF_TRANSLUCENT; - //rover->flags &= ~(FF_CUTLEVEL | FF_CUTEXTRA); + if ((rover->flags & FF_CUTSOLIDS) && + (rover->spawnflags & FF_CUTSOLIDS)) + { + rover->flags &= ~FF_CUTSOLIDS; + rover->target->moved = true; + } } } } @@ -7559,7 +7569,12 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, if (dotranslucent) { rover->flags |= FF_TRANSLUCENT; - //rover->flags &= ~(FF_CUTLEVEL | FF_CUTEXTRA); + if ((rover->flags & FF_CUTSOLIDS) && + (rover->spawnflags & FF_CUTSOLIDS)) + { + rover->flags &= ~FF_CUTSOLIDS; + rover->target->moved = true; + } } if (docollision) From fa0918c2f150ea77b322dd3e22d181c5c9fbe1e0 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 09:08:32 -0400 Subject: [PATCH 128/573] Handle rendering flags for invisible FOFs --- src/p_spec.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index 78c78d5e0..62959dcce 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7547,11 +7547,13 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, rover->flags |= FF_CUTSOLIDS; rover->target->moved = true; } + rover->flags &= ~FF_TRANSLUCENT; } else { rover->flags |= FF_TRANSLUCENT; + if ((rover->flags & FF_CUTSOLIDS) && (rover->spawnflags & FF_CUTSOLIDS)) { @@ -7559,6 +7561,15 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, rover->target->moved = true; } } + + if (!(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES)) + { + if (rover->alpha > 1) + rover->flags |= FF_RENDERALL; + else + rover->flags &= ~FF_RENDERALL; + } } } else @@ -7569,12 +7580,17 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, if (dotranslucent) { rover->flags |= FF_TRANSLUCENT; + if ((rover->flags & FF_CUTSOLIDS) && (rover->spawnflags & FF_CUTSOLIDS)) { rover->flags &= ~FF_CUTSOLIDS; rover->target->moved = true; } + + if (!(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES)) + rover->flags |= FF_RENDERALL; } if (docollision) From 3858a93cfadaa9c6807998a4a35c20eefd8bfe95 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 09:31:23 -0400 Subject: [PATCH 129/573] Initialize invisible FOF alpha to 1 on first fade --- src/p_spec.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index 62959dcce..88506f0fe 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7463,6 +7463,14 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, if (rover->master->special == 258) // Laser block return false; + // If fading an invisible FOF whose render flags we did not yet set, + // initialize its alpha to 1 + if (dotranslucent && + !(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES) && + !(rover->flags & FF_RENDERALL)) + rover->alpha = 1; + if (fadingdata) alpha = fadingdata->alpha; else @@ -7678,6 +7686,15 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor d->rover = rover; d->sectornum = (INT32)sectornum; d->ffloornum = (INT32)ffloornum; + + // If fading an invisible FOF whose render flags we did not yet set, + // initialize its alpha to 1 + if (dotranslucent && + !(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES) && + !(rover->flags & FF_RENDERALL)) + rover->alpha = 1; + d->alpha = rover->alpha; d->destvalue = max(1, min(256, destvalue)); // ffloor->alpha is 1-256 d->speed = max(1, speed); // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker From 3eb7c3931e93c4cd4d39c71867bf85f8d7dae5c8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 20:06:48 -0400 Subject: [PATCH 130/573] When detecting invisible FOFs, don't include light blocks --- src/p_spec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 88506f0fe..bf3f58697 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7466,6 +7466,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, // If fading an invisible FOF whose render flags we did not yet set, // initialize its alpha to 1 if (dotranslucent && + (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE !(rover->spawnflags & FF_RENDERSIDES) && !(rover->spawnflags & FF_RENDERPLANES) && !(rover->flags & FF_RENDERALL)) @@ -7570,7 +7571,8 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, } } - if (!(rover->spawnflags & FF_RENDERSIDES) && + if ((rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE + !(rover->spawnflags & FF_RENDERSIDES) && !(rover->spawnflags & FF_RENDERPLANES)) { if (rover->alpha > 1) @@ -7596,7 +7598,8 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, rover->target->moved = true; } - if (!(rover->spawnflags & FF_RENDERSIDES) && + if ((rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE + !(rover->spawnflags & FF_RENDERSIDES) && !(rover->spawnflags & FF_RENDERPLANES)) rover->flags |= FF_RENDERALL; } @@ -7690,6 +7693,7 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor // If fading an invisible FOF whose render flags we did not yet set, // initialize its alpha to 1 if (dotranslucent && + (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE !(rover->spawnflags & FF_RENDERSIDES) && !(rover->spawnflags & FF_RENDERPLANES) && !(rover->flags & FF_RENDERALL)) From 069cc480c1f217968ef7ebe58503527092323148 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 20:41:45 -0400 Subject: [PATCH 131/573] Add dolighting flag to FadeFakeFloor thinker --- src/p_saveg.c | 2 ++ src/p_spec.c | 14 +++++++++----- src/p_spec.h | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 3b726b97d..05501ccc0 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1592,6 +1592,7 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) WRITEUINT8(save_p, ht->doexists); WRITEUINT8(save_p, ht->dotranslucent); WRITEUINT8(save_p, ht->docollision); + WRITEUINT8(save_p, ht->dolighting); WRITEUINT8(save_p, ht->doghostfade); WRITEUINT8(save_p, ht->exactalpha); } @@ -2596,6 +2597,7 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->doexists = READUINT8(save_p); ht->dotranslucent = READUINT8(save_p); ht->docollision = READUINT8(save_p); + ht->dolighting = READUINT8(save_p); ht->doghostfade = READUINT8(save_p); ht->exactalpha = READUINT8(save_p); diff --git a/src/p_spec.c b/src/p_spec.c index bf3f58697..c73118515 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -106,10 +106,10 @@ static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t o static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finalize); #define P_RemoveFakeFloorFader(l) P_ResetFakeFloorFader(l, NULL, false); static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, - boolean doexists, boolean dotranslucent, boolean docollision, boolean doghostfade, boolean exactalpha); + boolean doexists, boolean dotranslucent, boolean docollision, boolean dolighting, boolean doghostfade, boolean exactalpha); static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, INT16 destvalue, INT16 speed, - boolean doexists, boolean dotranslucent, boolean docollision, boolean doghostfade, boolean exactalpha); + boolean doexists, boolean dotranslucent, boolean docollision, boolean dolighting, boolean doghostfade, boolean exactalpha); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3356,6 +3356,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT !(line->flags & ML_BOUNCY), // do not handle interactive flags + !(line->flags & ML_EFFECT2), // do not handle lighting (line->flags & ML_EFFECT1), // do ghost fade (no interactive flags during fade) (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) else @@ -3366,6 +3367,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT !(line->flags & ML_BOUNCY), // do not handle interactive flags + !(line->flags & ML_EFFECT2), // do not handle lighting (line->flags & ML_EFFECT1), // do ghost fade (no interactive flags during fade) (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) } @@ -7442,6 +7444,7 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz fadingdata->doexists, fadingdata->dotranslucent, fadingdata->docollision, + fadingdata->dolighting, fadingdata->doghostfade, fadingdata->exactalpha); rover->alpha = fadingdata->alpha; @@ -7454,7 +7457,7 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz } static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, - boolean doexists, boolean dotranslucent, boolean docollision, boolean doghostfade, boolean exactalpha) + boolean doexists, boolean dotranslucent, boolean docollision, boolean dolighting, boolean doghostfade, boolean exactalpha) { boolean stillfading = false; INT32 alpha; @@ -7681,7 +7684,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, */ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, INT16 destvalue, INT16 speed, - boolean doexists, boolean dotranslucent, boolean docollision, boolean doghostfade, boolean exactalpha) + boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha) { fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); @@ -7705,6 +7708,7 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor d->doexists = doexists; d->dotranslucent = dotranslucent; d->docollision = docollision; + d->dolighting = dolighting; d->doghostfade = doghostfade; d->exactalpha = exactalpha; @@ -7721,7 +7725,7 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor */ void T_Fade(fade_t *d) { - if (d->rover && !P_FadeFakeFloor(d->rover, d->destvalue, d->speed, d->doexists, d->dotranslucent, d->docollision, d->doghostfade, d->exactalpha)) + if (d->rover && !P_FadeFakeFloor(d->rover, d->destvalue, d->speed, d->doexists, d->dotranslucent, d->docollision, d->dolighting, d->doghostfade, d->exactalpha)) P_RemoveFakeFloorFader(d->rover); } diff --git a/src/p_spec.h b/src/p_spec.h index f00a1cdbd..df400fac1 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -466,6 +466,7 @@ typedef struct boolean doexists; ///< Handle FF_EXISTS boolean dotranslucent; ///< Handle FF_TRANSLUCENT boolean docollision; ///< Handle interactive flags + boolean dolighting; ///< Handle shadows and light blocks boolean doghostfade; ///< No interactive flags during fading boolean exactalpha; ///< Use exact alpha values (opengl) } fade_t; From 81acf82e99a6112f4c4fe34c5528219b234f3960 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 20:49:32 -0400 Subject: [PATCH 132/573] Re-render lighting when setting FF_EXISTS --- src/p_spec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index c73118515..7ee047afb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7547,6 +7547,10 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, rover->flags &= ~FF_EXISTS; else rover->flags |= FF_EXISTS; + + // Re-render lighting at end of fade + if (dolighting && !(rover->spawnflags & FF_NOSHADE) && !(rover->flags & FF_EXISTS)) + rover->target->moved = true; } if (dotranslucent) @@ -7588,7 +7592,13 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, else { if (doexists && !(rover->spawnflags & FF_BUSTUP)) + { + // Re-render lighting if we haven't yet set FF_EXISTS (beginning of fade) + if (dolighting && !(rover->spawnflags & FF_NOSHADE) && !(rover->flags & FF_EXISTS)) + rover->target->moved = true; + rover->flags |= FF_EXISTS; + } if (dotranslucent) { From 1e1b01c1572f8dcb941e06ba0e914ef881ed1643 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 22:10:51 -0400 Subject: [PATCH 133/573] Implemented tic-based light fading * ML_BLOCKMONSTERS specifies destvalue and speed by texture offsets * ML_NOCLIMB toggles tic-based logic * Added props `duration`, `interval`, and `firsttic` to `lightlevel_t` --- src/lua_baselib.c | 3 ++- src/p_lights.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- src/p_saveg.c | 6 ++++++ src/p_spec.c | 5 ++++- src/p_spec.h | 7 ++++++- 5 files changed, 60 insertions(+), 8 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c1fd87af3..840863eb0 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1809,9 +1809,10 @@ static int lib_pFadeLight(lua_State *L) INT16 tag = (INT16)luaL_checkinteger(L, 1); INT32 destvalue = (INT32)luaL_checkinteger(L, 2); INT32 speed = (INT32)luaL_checkinteger(L, 3); + boolean ticbased = lua_optboolean(L, 4); NOHUD INLEVEL - P_FadeLight(tag, destvalue, speed); + P_FadeLight(tag, destvalue, speed, ticbased); return 0; } diff --git a/src/p_lights.c b/src/p_lights.c index 8aa2eedca..e37eda5fb 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -13,6 +13,7 @@ /// Fire flicker, light flash, strobe flash, lightning flash, glow, and fade. #include "doomdef.h" +#include "doomstat.h" // gametic #include "p_local.h" #include "r_state.h" #include "z_zone.h" @@ -329,12 +330,10 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, * \param destvalue The final light value in these sectors. * \param speed Speed of the fade; the change to the ligh * level in each sector per tic. - * \todo Calculate speed better so that it is possible to specify - * the time for completion of the fade, and all lights fade - * in this time regardless of initial values. + * \param ticbased Use a specific duration for the fade, defined by speed * \sa T_LightFade */ -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed) +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) { INT32 i; lightlevel_t *ll; @@ -346,6 +345,13 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed) sector = §ors[i]; P_RemoveLighting(sector); // remove the old lighting effect first + + if ((ticbased && !speed) || sector->lightlevel == destvalue) // set immediately + { + sector->lightlevel = destvalue; + continue; + } + ll = Z_Calloc(sizeof (*ll), PU_LEVSPEC, NULL); ll->thinker.function.acp1 = (actionf_p1)T_LightFade; sector->lightingdata = ll; // set it to the lightlevel_t @@ -354,7 +360,21 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed) ll->sector = sector; ll->destlevel = destvalue; - ll->speed = speed; + + if (ticbased) + { + ll->duration = abs(speed); + ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->duration))/FRACUNIT; + if (!ll->speed) + ll->speed = (destvalue < sector->lightlevel) ? -1 : 1; + ll->interval = max(FixedFloor(FixedDiv(ll->duration, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1); + ll->firsttic = gametic; + } + else + { + ll->duration = -1; + ll->speed = abs(speed); + } } } @@ -365,6 +385,23 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed) */ void T_LightFade(lightlevel_t *ll) { + if (ll->duration >= 0) // tic-based + { + if (gametic - ll->firsttic >= ll->duration) + { + ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker + } + else if (!((gametic - ll->firsttic) % ll->interval)) + { + if (ll->speed < 0) + ll->sector->lightlevel = max(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + else + ll->sector->lightlevel = min(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + } + return; + } + if (ll->sector->lightlevel < ll->destlevel) { // increase the lightlevel diff --git a/src/p_saveg.c b/src/p_saveg.c index 22d43f358..8ec5b5ea8 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1539,6 +1539,9 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, SaveSector(ht->sector)); WRITEINT32(save_p, ht->destlevel); WRITEINT32(save_p, ht->speed); + WRITEINT32(save_p, ht->duration); + WRITEUINT32(save_p, ht->interval); + WRITEUINT32(save_p, (UINT32)ht->firsttic); } // @@ -2512,6 +2515,9 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) ht->sector = LoadSector(READUINT32(save_p)); ht->destlevel = READINT32(save_p); ht->speed = READINT32(save_p); + ht->duration = READINT32(save_p); + ht->interval = READUINT32(save_p); + ht->firsttic = (tic_t)READUINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; P_AddThinker(&ht->thinker); diff --git a/src/p_spec.c b/src/p_spec.c index 6c359c9cc..a894dcbfb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2778,7 +2778,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 420: // Fade light levels in tagged sectors to new value - P_FadeLight(line->tag, line->frontsector->lightlevel, P_AproxDistance(line->dx, line->dy)>>FRACBITS); + P_FadeLight(line->tag, + (line->flags & ML_BLOCKMONSTERS) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, + (line->flags & ML_BLOCKMONSTERS) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, + (line->flags & ML_NOCLIMB)); break; case 421: // Stop lighting effect in tagged sectors diff --git a/src/p_spec.h b/src/p_spec.h index e0bcc18eb..8e296891b 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -138,6 +138,11 @@ typedef struct sector_t *sector; ///< Sector where action is taking place. INT32 destlevel; ///< Light level we're fading to. INT32 speed; ///< Speed at which to change light level. + + // Tic-based behavior + INT32 duration; ///< If <0, do not use tic-based behavior. If 0, set instantly. If >0, fade lasts this duration. + UINT32 interval; ///< Interval to deduct light level + tic_t firsttic; ///< First gametic to count from } lightlevel_t; #define GLOWSPEED 8 @@ -156,7 +161,7 @@ strobe_t * P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector void T_Glow(glow_t *g); glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length); -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed); +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased); void T_LightFade(lightlevel_t *ll); typedef enum From 68e67917f1b345633151e3315ffd061d4fde5837 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 22:14:49 -0400 Subject: [PATCH 134/573] Split P_FadeLight into P_FadeLightBySector --- src/p_lights.c | 80 +++++++++++++++++++++++++------------------------- src/p_spec.h | 1 + 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/p_lights.c b/src/p_lights.c index e37eda5fb..8be3d793c 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -323,59 +323,59 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, return g; } -/** Fades all the lights in sectors with a particular tag to a new +/** Fades all the lights in specified sector to a new * value. * - * \param tag Tag to look for sectors by. + * \param sector Target sector * \param destvalue The final light value in these sectors. * \param speed Speed of the fade; the change to the ligh * level in each sector per tic. * \param ticbased Use a specific duration for the fade, defined by speed * \sa T_LightFade */ +void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased) +{ + lightlevel_t *ll; + + P_RemoveLighting(sector); // remove the old lighting effect first + + if ((ticbased && !speed) || sector->lightlevel == destvalue) // set immediately + { + sector->lightlevel = destvalue; + return; + } + + ll = Z_Calloc(sizeof (*ll), PU_LEVSPEC, NULL); + ll->thinker.function.acp1 = (actionf_p1)T_LightFade; + sector->lightingdata = ll; // set it to the lightlevel_t + + P_AddThinker(&ll->thinker); // add thinker + + ll->sector = sector; + ll->destlevel = destvalue; + + if (ticbased) + { + ll->duration = abs(speed); + ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->duration))/FRACUNIT; + if (!ll->speed) + ll->speed = (destvalue < sector->lightlevel) ? -1 : 1; + ll->interval = max(FixedFloor(FixedDiv(ll->duration, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1); + ll->firsttic = gametic; + } + else + { + ll->duration = -1; + ll->speed = abs(speed); + } +} + void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) { INT32 i; - lightlevel_t *ll; - sector_t *sector; - // search all sectors for ones with tag for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0 ;) - { - sector = §ors[i]; - - P_RemoveLighting(sector); // remove the old lighting effect first - - if ((ticbased && !speed) || sector->lightlevel == destvalue) // set immediately - { - sector->lightlevel = destvalue; - continue; - } - - ll = Z_Calloc(sizeof (*ll), PU_LEVSPEC, NULL); - ll->thinker.function.acp1 = (actionf_p1)T_LightFade; - sector->lightingdata = ll; // set it to the lightlevel_t - - P_AddThinker(&ll->thinker); // add thinker - - ll->sector = sector; - ll->destlevel = destvalue; - - if (ticbased) - { - ll->duration = abs(speed); - ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->duration))/FRACUNIT; - if (!ll->speed) - ll->speed = (destvalue < sector->lightlevel) ? -1 : 1; - ll->interval = max(FixedFloor(FixedDiv(ll->duration, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1); - ll->firsttic = gametic; - } - else - { - ll->duration = -1; - ll->speed = abs(speed); - } - } + P_FadeLightBySector(§ors[i], destvalue, speed, ticbased); } /** Fades the light level in a sector to a new value. diff --git a/src/p_spec.h b/src/p_spec.h index 8e296891b..c2c4c8976 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -161,6 +161,7 @@ strobe_t * P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector void T_Glow(glow_t *g); glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length); +void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased); void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased); void T_LightFade(lightlevel_t *ll); From cc26d03c93c91d6209b2b51acc63758c837b2cf4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 23:01:35 -0400 Subject: [PATCH 135/573] Snap light level to software values (32 levels) * New properties `exactlightlevel` and `lightlevel` in `lightlevel_t` --- src/lua_baselib.c | 3 +- src/p_lights.c | 75 +++++++++++++++++++++++++++++++---------------- src/p_saveg.c | 4 +++ src/p_spec.c | 3 +- src/p_spec.h | 8 +++-- 5 files changed, 63 insertions(+), 30 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 840863eb0..74b842e2a 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1810,9 +1810,10 @@ static int lib_pFadeLight(lua_State *L) INT32 destvalue = (INT32)luaL_checkinteger(L, 2); INT32 speed = (INT32)luaL_checkinteger(L, 3); boolean ticbased = lua_optboolean(L, 4); + boolean exactlightlevel = lua_optboolean(L, 5); NOHUD INLEVEL - P_FadeLight(tag, destvalue, speed, ticbased); + P_FadeLight(tag, destvalue, speed, ticbased, exactlightlevel); return 0; } diff --git a/src/p_lights.c b/src/p_lights.c index 8be3d793c..b2934b792 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -15,6 +15,7 @@ #include "doomdef.h" #include "doomstat.h" // gametic #include "p_local.h" +#include "r_main.h" // LIGHTSEGSHIFT #include "r_state.h" #include "z_zone.h" #include "m_random.h" @@ -331,9 +332,10 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, * \param speed Speed of the fade; the change to the ligh * level in each sector per tic. * \param ticbased Use a specific duration for the fade, defined by speed + * \param exactlightlevel Do not snap to software values (for OpenGL) * \sa T_LightFade */ -void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased) +void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel) { lightlevel_t *ll; @@ -353,6 +355,8 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ll->sector = sector; ll->destlevel = destvalue; + ll->exactlightlevel = exactlightlevel; + ll->lightlevel = sector->lightlevel; if (ticbased) { @@ -370,12 +374,12 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean } } -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel) { INT32 i; // search all sectors for ones with tag for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0 ;) - P_FadeLightBySector(§ors[i], destvalue, speed, ticbased); + P_FadeLightBySector(§ors[i], destvalue, speed, ticbased, exactlightlevel); } /** Fades the light level in a sector to a new value. @@ -385,47 +389,66 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) */ void T_LightFade(lightlevel_t *ll) { + boolean stillfading = false; + INT16 lightlevel = ll->lightlevel; + if (ll->duration >= 0) // tic-based { + stillfading = !(gametic - ll->firsttic >= ll->duration); if (gametic - ll->firsttic >= ll->duration) { - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + lightlevel = (INT16)ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } else if (!((gametic - ll->firsttic) % ll->interval)) { if (ll->speed < 0) - ll->sector->lightlevel = max(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + lightlevel = max(lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); else - ll->sector->lightlevel = min(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + lightlevel = min(lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); } - return; } - - if (ll->sector->lightlevel < ll->destlevel) + else // x/tic speed-based { - // increase the lightlevel - if (ll->sector->lightlevel + ll->speed >= ll->destlevel) + if (lightlevel < ll->destlevel) { - // stop changing light level - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + // increase the lightlevel + if (lightlevel + ll->speed >= ll->destlevel) + { + // stop changing light level + lightlevel = (INT16)ll->destlevel; // set to dest lightlevel - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker + P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker + } + else + { + stillfading = true; + lightlevel = (INT16)(lightlevel + (INT16)ll->speed); // move lightlevel + } } else - ll->sector->lightlevel = (INT16)(ll->sector->lightlevel + (INT16)ll->speed); // move lightlevel + { + // decrease lightlevel + if (lightlevel - ll->speed <= ll->destlevel) + { + // stop changing light level + lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + + P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker + } + else + { + stillfading = true; + lightlevel = (INT16)(lightlevel - (INT16)ll->speed); // move lightlevel + } + } } + + // Snap light level to software values + if (!stillfading || ll->exactlightlevel) + ll->sector->lightlevel = lightlevel; else - { - // decrease lightlevel - if (ll->sector->lightlevel - ll->speed <= ll->destlevel) - { - // stop changing light level - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + ll->sector->lightlevel = (lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - ll->sector->lightlevel = (INT16)(ll->sector->lightlevel - (INT16)ll->speed); // move lightlevel - } + ll->lightlevel = lightlevel; } diff --git a/src/p_saveg.c b/src/p_saveg.c index 8ec5b5ea8..95d073fc9 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1542,6 +1542,8 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->duration); WRITEUINT32(save_p, ht->interval); WRITEUINT32(save_p, (UINT32)ht->firsttic); + WRITEUINT8(save_p, (UINT8)ht->exactlightlevel); + WRITEINT16(save_p, ht->lightlevel); } // @@ -2518,6 +2520,8 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) ht->duration = READINT32(save_p); ht->interval = READUINT32(save_p); ht->firsttic = (tic_t)READUINT32(save_p); + ht->exactlightlevel = (boolean)READUINT8(save_p); + ht->lightlevel = READINT16(save_p); if (ht->sector) ht->sector->lightingdata = ht; P_AddThinker(&ht->thinker); diff --git a/src/p_spec.c b/src/p_spec.c index a894dcbfb..707e19f08 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2781,7 +2781,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_FadeLight(line->tag, (line->flags & ML_BLOCKMONSTERS) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, (line->flags & ML_BLOCKMONSTERS) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, - (line->flags & ML_NOCLIMB)); + (line->flags & ML_NOCLIMB), + (line->flags & ML_TFERLINE)); break; case 421: // Stop lighting effect in tagged sectors diff --git a/src/p_spec.h b/src/p_spec.h index c2c4c8976..b354e6772 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -143,6 +143,10 @@ typedef struct INT32 duration; ///< If <0, do not use tic-based behavior. If 0, set instantly. If >0, fade lasts this duration. UINT32 interval; ///< Interval to deduct light level tic_t firsttic; ///< First gametic to count from + + // Snap to software values + boolean exactlightlevel; ///< Use exact values for OpenGL + INT16 lightlevel; ///< Internal counter for fading } lightlevel_t; #define GLOWSPEED 8 @@ -161,8 +165,8 @@ strobe_t * P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector void T_Glow(glow_t *g); glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length); -void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased); -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased); +void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel); +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel); void T_LightFade(lightlevel_t *ll); typedef enum From 0049f904c09dc3b87c8e7ed8f317219dd80d12a5 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 23:44:29 -0400 Subject: [PATCH 136/573] Add light fading to FadeFakeFloor * Declare P_RemoveLighting in header for p_spec.c use --- src/p_lights.c | 2 +- src/p_spec.c | 13 +++++++++++++ src/p_spec.h | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/p_lights.c b/src/p_lights.c index b2934b792..02221d197 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -25,7 +25,7 @@ * * \param sector The sector to remove effects from. */ -static void P_RemoveLighting(sector_t *sector) +void P_RemoveLighting(sector_t *sector) { if (sector->lightingdata) { diff --git a/src/p_spec.c b/src/p_spec.c index 1f8f1c2b0..a1465b0e7 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7453,6 +7453,12 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz fadingdata->exactalpha); rover->alpha = fadingdata->alpha; + if (fadingdata->dolighting) + { + P_RemoveLighting(§ors[rover->secnum]); + §ors[rover->secnum].lightlevel = rover->target->lightlevel; // \todo get fade light level destvalue + } + P_RemoveThinker(&fadingdata->thinker); } @@ -7729,6 +7735,13 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor // find any existing thinkers and remove them, then replace with new data P_ResetFakeFloorFader(rover, d, false); + // Set a separate thinker for shadow fading + if (dolighting && !(rover->flags & FF_NOSHADE)) + P_FadeLightBySector(§ors[rover->secnum], + rover->target->lightlevel, // (shadowlight - targetlight) * destvalue/256 // \todo get fade light level destvalue + FixedFloor(FixedDiv(abs(d->destvalue - d->alpha), d->speed))/FRACUNIT, + true, exactalpha); + P_AddThinker(&d->thinker); } diff --git a/src/p_spec.h b/src/p_spec.h index ec1911df3..0d118168b 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -154,6 +154,8 @@ typedef struct #define FASTDARK 15 #define SLOWDARK 35 +void P_RemoveLighting(sector_t *sector); + void T_FireFlicker(fireflicker_t *flick); fireflicker_t *P_SpawnAdjustableFireFlicker(sector_t *minsector, sector_t *maxsector, INT32 length); void T_LightningFlash(lightflash_t *flash); From eb590910b2ee7f1678c4699235d5f1076d5764a1 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 01:13:02 -0400 Subject: [PATCH 137/573] Added NIGHTSLINK bonus type for the 2.1 Link Bonus --- src/dehacked.c | 3 ++- src/y_inter.c | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 70a19eadc..1f56210ac 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1197,8 +1197,9 @@ static void readlevelheader(MYFILE *f, INT32 num) else if (fastcmp(word2, "BOSS")) i = 1; else if (fastcmp(word2, "ERZ3")) i = 2; else if (fastcmp(word2, "NIGHTS")) i = 3; + else if (fastcmp(word2, "NIGHTSLINK")) i = 4; - if (i >= -1 && i <= 3) // -1 for no bonus. Max is 3. + if (i >= -1 && i <= 4) // -1 for no bonus. Max is 3. mapheaderinfo[num-1]->bonustype = (SINT8)i; else deh_warning("Level header %d: invalid bonus type number %d", num, i); diff --git a/src/y_inter.c b/src/y_inter.c index 3fdf5f7a9..2c77a577a 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1774,7 +1774,6 @@ static void Y_SetLapBonus(player_t *player, y_bonus_t *bstruct) bstruct->points = max(0, player->totalmarebonuslap * 1000); } -#if 0 // // Y_SetLinkBonus // @@ -1784,7 +1783,6 @@ static void Y_SetLinkBonus(player_t *player, y_bonus_t *bstruct) bstruct->display = true; bstruct->points = max(0, (player->maxlink - 1) * 100); } -#endif // // Y_SetGuardBonus @@ -1837,7 +1835,7 @@ static void Y_SetPerfectBonus(player_t *player, y_bonus_t *bstruct) // This list can be extended in the future with SOC/Lua, perhaps. typedef void (*bonus_f)(player_t *, y_bonus_t *); -bonus_f bonuses_list[5][4] = { +bonus_f bonuses_list[6][4] = { { Y_SetNullBonus, Y_SetNullBonus, @@ -1868,6 +1866,12 @@ bonus_f bonuses_list[5][4] = { Y_SetLapBonus, Y_SetNullBonus, }, + { + Y_SetNullBonus, + Y_SetLinkBonus, + Y_SetLapBonus, + Y_SetNullBonus, + }, }; From 3f4656e57ee2f97b6dc86e9e817eabc449cfb515 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 01:08:02 -0400 Subject: [PATCH 138/573] Polyobject Fade logic --- src/p_polyobj.c | 85 ++++++++++++++++++++++++++++++++++++++++++++----- src/p_polyobj.h | 17 ++++++++-- src/p_saveg.c | 22 ++++++++++++- src/p_spec.c | 22 ++++++++++--- 4 files changed, 129 insertions(+), 17 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index d943a0bfe..9e5cdf90e 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2855,8 +2855,8 @@ INT32 EV_DoPolyObjFlag(line_t *pfdata) void T_PolyObjFade(polyfade_t *th) { + boolean stillfading = false; polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); - size_t i; if (!po) #ifdef RANGECHECK @@ -2873,7 +2873,67 @@ void T_PolyObjFade(polyfade_t *th) if (po->thinker == NULL) po->thinker = &th->thinker; - // \todo logic + stillfading = !(gametic - th->firsttic >= th->duration); + + if (gametic - th->firsttic >= th->duration) + { + po->translucency = th->destvalue; // set to dest translucency + + // remove thinker + if (po->thinker == &th->thinker) + po->thinker = NULL; + P_RemoveThinker(&th->thinker); + } + else if (!((gametic - th->firsttic) % th->interval)) + { + if (th->speed <= 0) + po->translucency = max(po->translucency + th->speed, th->destvalue); + else + po->translucency = min(po->translucency + th->speed, th->destvalue); + } + + if (!stillfading) + { + // set render flags + if (po->translucency >= NUMTRANSMAPS) // invisible + po->flags &= ~POF_RENDERALL; + else + po->flags |= POF_RENDERALL; + + // set collision + if (th->docollision && th->speed) + { + if (th->speed > 0) // faded out + { + po->flags &= ~POF_SOLID; + po->flags |= POF_NOSPECIALS; + } + else + { + po->flags |= POF_SOLID; + po->flags &= ~POF_NOSPECIALS; + } + } + } + else + { + po->flags |= POF_RENDERALL; + + // set collision + if (th->docollision && th->speed) + { + if (th->doghostfade) + { + po->flags &= ~POF_SOLID; + po->flags |= POF_NOSPECIALS; + } + else + { + po->flags |= POF_SOLID; + po->flags &= ~POF_NOSPECIALS; + } + } + } } INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) @@ -2883,9 +2943,9 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) polyfade_t *th; INT32 start; - if (!(po = Polyobj_GetForNum(prdata->polyObjNum))) + if (!(po = Polyobj_GetForNum(pfdata->polyObjNum))) { - CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjRotate: bad polyobj %d\n", prdata->polyObjNum); + CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjFade: bad polyobj %d\n", pfdata->polyObjNum); return 0; } @@ -2893,6 +2953,10 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) if (po->isBad) return 0; + // already equal, nothing to do + if (po->translucency == pfdata->destvalue) + return 1; + // create a new thinker th = Z_Malloc(sizeof(polyfade_t), PU_LEVSPEC, NULL); th->thinker.function.acp1 = (actionf_p1)T_PolyObjFade; @@ -2900,9 +2964,14 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) po->thinker = &th->thinker; // set fields - th->polyObjNum = pfdata->tag; - - // \todo polyfade fields + th->polyObjNum = pfdata->polyObjNum; + th->destvalue = pfdata->destvalue; + th->docollision = pfdata->docollision; + th->doghostfade = pfdata->doghostfade; + th->duration = pfdata->duration; + th->speed = pfdata->speed; + th->interval = pfdata->interval; + th->firsttic = pfdata->firsttic; oldpo = po; @@ -2910,7 +2979,7 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) start = 0; while ((po = Polyobj_GetChild(oldpo, &start))) { - pfdata->tag = po->id; + pfdata->polyObjNum = po->id; EV_DoPolyObjFade(pfdata); } diff --git a/src/p_polyobj.h b/src/p_polyobj.h index 0bd94a636..cf00d64ba 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -212,8 +212,13 @@ typedef struct polyfade_s thinker_t thinker; // must be first INT32 polyObjNum; - - // \todo polyfade fields + INT32 destvalue; + boolean docollision; + boolean doghostfade; + UINT32 duration; + INT32 speed; + UINT32 interval; + tic_t firsttic; } polyfade_t; // @@ -278,7 +283,13 @@ typedef struct polydisplacedata_s typedef struct polyfadedata_s { INT32 polyObjNum; - // \todo polyfadedata fields + INT32 destvalue; + boolean docollision; + boolean doghostfade; + UINT32 duration; + INT32 speed; + UINT32 interval; + tic_t firsttic; } polyfadedata_t; // diff --git a/src/p_saveg.c b/src/p_saveg.c index 3cc061ebb..fc9382233 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1700,6 +1700,20 @@ static void SavePolydisplaceThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, ht->oldHeights); } +static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type) +{ + const polyfade_t *ht = (const void *)th; + WRITEUINT8(save_p, type); + WRITEINT32(save_p, ht->polyObjNum); + WRITEINT32(save_p, ht->destvalue); + WRITEUINT8(save_p, (UINT8)ht->docollision); + WRITEUINT8(save_p, (UINT8)ht->doghostfade); + WRITEUINT32(save_p, ht->duration); + WRITEINT32(save_p, ht->speed); + WRITEUINT32(save_p, ht->interval); + WRITEUINT32(save_p, (UINT32)ht->firsttic); +} + #endif /* // @@ -2706,7 +2720,13 @@ static void LoadPolyfadeThinker(actionf_p1 thinker) polyfade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->polyObjNum = READINT32(save_p); - // \todo polyfade thinker fields + ht->destvalue = READINT32(save_p); + ht->docollision = (boolean)READUINT8(save_p); + ht->doghostfade = (boolean)READUINT8(save_p); + ht->duration = READUINT32(save_p); + ht->speed = READINT32(save_p); + ht->interval = READUINT32(save_p); + ht->firsttic = (tic_t)READUINT32(save_p); P_AddThinker(&ht->thinker); } #endif diff --git a/src/p_spec.c b/src/p_spec.c index fd2c312fb..6d746f670 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1250,7 +1250,7 @@ static void PolyTranslucency(line_t *line) // // Makes a polyobject translucency fade and applies tangibility // -static void PolyFade(line_t *line) +static boolean PolyFade(line_t *line) { INT32 polyObjNum = line->tag; polyobj_t *po; @@ -1258,18 +1258,30 @@ static void PolyFade(line_t *line) if (!(po = Polyobj_GetForNum(polyObjNum))) { CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjWaypoint: bad polyobj %d\n", polyObjNum); - return; + return 0; } // don't allow line actions to affect bad polyobjects if (po->isBad) - return; + return 0; + + // already equal, nothing to do + if (po->translucency == max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0)) + return 1; polyfadedata_t pfd; - pfd.polyObjNum = line->tag; + pfd.polyObjNum = polyObjNum; + pfd.destvalue = max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0); + pfd.docollision = !(line->flags & ML_BOUNCY), // do not handle collision flags + pfd.doghostfade = (line->flags & ML_EFFECT1), // do ghost fade (no collision flags during fade) - // \todo polyfadedata fields + pfd.duration = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.duration))/FRACUNIT; + if (!pfd.speed) + pfd.speed = (pfd.destvalue < po->translucency) ? -1 : 1; + pfd.interval = max(FixedFloor(FixedDiv(pfd.duration, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1); + pfd.firsttic = gametic; return EV_DoPolyObjFade(&pfd); } From 5032f783d783fefacbe694dc120065bb22e20f13 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 08:10:45 -0400 Subject: [PATCH 139/573] Don't add a thinker if alpha is already equal --- src/p_spec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index a1465b0e7..d33ad873c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7706,6 +7706,10 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor INT16 destvalue, INT16 speed, boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha) { + // already equal, nothing to do + if (rover->alpha == max(1, min(256, destvalue))) + return; + fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); d->thinker.function.acp1 = (actionf_p1)T_Fade; From 675f69afea115c284383dde25d54fac17b9c81c8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 09:29:18 -0400 Subject: [PATCH 140/573] Flag re-organization * Change alternate param flag from BLOCKMONSTERS to DONTPEGBOTTOM * Change tic-based flag from NOCLIMB to EFFECT5 --- src/p_spec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 707e19f08..87f5676bb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2779,9 +2779,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 420: // Fade light levels in tagged sectors to new value P_FadeLight(line->tag, - (line->flags & ML_BLOCKMONSTERS) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, - (line->flags & ML_BLOCKMONSTERS) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, - (line->flags & ML_NOCLIMB), + (line->flags & ML_DONTPEGBOTTOM) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, + (line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, + (line->flags & ML_EFFECT5), (line->flags & ML_TFERLINE)); break; From baababcf0b7646d00696780b3d80879528617462 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 12:44:35 -0400 Subject: [PATCH 141/573] Add spawn_lightlevel to sector_t --- src/p_setup.c | 1 + src/r_defs.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index 2361d1efd..0119e6584 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -678,6 +678,7 @@ static void P_LoadRawSectors(UINT8 *data, size_t i) ss->ceilingpic = P_AddLevelFlat(ms->ceilingpic, foundflats); ss->lightlevel = SHORT(ms->lightlevel); + ss->spawn_lightlevel = SHORT(ms->lightlevel); ss->special = SHORT(ms->special); ss->tag = SHORT(ms->tag); ss->nexttag = ss->firsttag = -1; diff --git a/src/r_defs.h b/src/r_defs.h index ea5db3947..65f8ee5c6 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -385,6 +385,9 @@ typedef struct sector_s boolean hasslope; // The sector, or one of its visible FOFs, contains a slope #endif + // for fade thinker + INT16 spawn_lightlevel; + // these are saved for netgames, so do not let Lua touch these! INT32 spawn_nexttag, spawn_firsttag; // the actual nexttag/firsttag values may differ if the sector's tag was changed From aeb45132c5d86e64a641f3311fff7f70e163af36 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 13:43:00 -0400 Subject: [PATCH 142/573] Revert "Snap light level to software values (32 levels)" This reverts commit cc26d03c93c91d6209b2b51acc63758c837b2cf4. --- src/lua_baselib.c | 3 +- src/p_lights.c | 79 +++++++++++++++++------------------------------ src/p_saveg.c | 4 --- src/p_spec.c | 3 +- src/p_spec.h | 8 ++--- 5 files changed, 32 insertions(+), 65 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 74b842e2a..840863eb0 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1810,10 +1810,9 @@ static int lib_pFadeLight(lua_State *L) INT32 destvalue = (INT32)luaL_checkinteger(L, 2); INT32 speed = (INT32)luaL_checkinteger(L, 3); boolean ticbased = lua_optboolean(L, 4); - boolean exactlightlevel = lua_optboolean(L, 5); NOHUD INLEVEL - P_FadeLight(tag, destvalue, speed, ticbased, exactlightlevel); + P_FadeLight(tag, destvalue, speed, ticbased); return 0; } diff --git a/src/p_lights.c b/src/p_lights.c index b2934b792..8be3d793c 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -15,7 +15,6 @@ #include "doomdef.h" #include "doomstat.h" // gametic #include "p_local.h" -#include "r_main.h" // LIGHTSEGSHIFT #include "r_state.h" #include "z_zone.h" #include "m_random.h" @@ -332,10 +331,9 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, * \param speed Speed of the fade; the change to the ligh * level in each sector per tic. * \param ticbased Use a specific duration for the fade, defined by speed - * \param exactlightlevel Do not snap to software values (for OpenGL) * \sa T_LightFade */ -void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel) +void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased) { lightlevel_t *ll; @@ -355,8 +353,6 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ll->sector = sector; ll->destlevel = destvalue; - ll->exactlightlevel = exactlightlevel; - ll->lightlevel = sector->lightlevel; if (ticbased) { @@ -374,12 +370,12 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean } } -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel) +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) { INT32 i; // search all sectors for ones with tag for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0 ;) - P_FadeLightBySector(§ors[i], destvalue, speed, ticbased, exactlightlevel); + P_FadeLightBySector(§ors[i], destvalue, speed, ticbased); } /** Fades the light level in a sector to a new value. @@ -389,66 +385,47 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, bool */ void T_LightFade(lightlevel_t *ll) { - boolean stillfading = false; - INT16 lightlevel = ll->lightlevel; - if (ll->duration >= 0) // tic-based { - stillfading = !(gametic - ll->firsttic >= ll->duration); if (gametic - ll->firsttic >= ll->duration) { - lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } else if (!((gametic - ll->firsttic) % ll->interval)) { if (ll->speed < 0) - lightlevel = max(lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + ll->sector->lightlevel = max(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); else - lightlevel = min(lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + ll->sector->lightlevel = min(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); } + return; } - else // x/tic speed-based - { - if (lightlevel < ll->destlevel) - { - // increase the lightlevel - if (lightlevel + ll->speed >= ll->destlevel) - { - // stop changing light level - lightlevel = (INT16)ll->destlevel; // set to dest lightlevel - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - { - stillfading = true; - lightlevel = (INT16)(lightlevel + (INT16)ll->speed); // move lightlevel - } + if (ll->sector->lightlevel < ll->destlevel) + { + // increase the lightlevel + if (ll->sector->lightlevel + ll->speed >= ll->destlevel) + { + // stop changing light level + ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + + P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } else - { - // decrease lightlevel - if (lightlevel - ll->speed <= ll->destlevel) - { - // stop changing light level - lightlevel = (INT16)ll->destlevel; // set to dest lightlevel - - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - { - stillfading = true; - lightlevel = (INT16)(lightlevel - (INT16)ll->speed); // move lightlevel - } - } + ll->sector->lightlevel = (INT16)(ll->sector->lightlevel + (INT16)ll->speed); // move lightlevel } - - // Snap light level to software values - if (!stillfading || ll->exactlightlevel) - ll->sector->lightlevel = lightlevel; else - ll->sector->lightlevel = (lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; + { + // decrease lightlevel + if (ll->sector->lightlevel - ll->speed <= ll->destlevel) + { + // stop changing light level + ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel - ll->lightlevel = lightlevel; + P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker + } + else + ll->sector->lightlevel = (INT16)(ll->sector->lightlevel - (INT16)ll->speed); // move lightlevel + } } diff --git a/src/p_saveg.c b/src/p_saveg.c index 95d073fc9..8ec5b5ea8 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1542,8 +1542,6 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->duration); WRITEUINT32(save_p, ht->interval); WRITEUINT32(save_p, (UINT32)ht->firsttic); - WRITEUINT8(save_p, (UINT8)ht->exactlightlevel); - WRITEINT16(save_p, ht->lightlevel); } // @@ -2520,8 +2518,6 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) ht->duration = READINT32(save_p); ht->interval = READUINT32(save_p); ht->firsttic = (tic_t)READUINT32(save_p); - ht->exactlightlevel = (boolean)READUINT8(save_p); - ht->lightlevel = READINT16(save_p); if (ht->sector) ht->sector->lightingdata = ht; P_AddThinker(&ht->thinker); diff --git a/src/p_spec.c b/src/p_spec.c index 87f5676bb..917ad68d4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2781,8 +2781,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_FadeLight(line->tag, (line->flags & ML_DONTPEGBOTTOM) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, (line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, - (line->flags & ML_EFFECT5), - (line->flags & ML_TFERLINE)); + (line->flags & ML_EFFECT5)); break; case 421: // Stop lighting effect in tagged sectors diff --git a/src/p_spec.h b/src/p_spec.h index b354e6772..c2c4c8976 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -143,10 +143,6 @@ typedef struct INT32 duration; ///< If <0, do not use tic-based behavior. If 0, set instantly. If >0, fade lasts this duration. UINT32 interval; ///< Interval to deduct light level tic_t firsttic; ///< First gametic to count from - - // Snap to software values - boolean exactlightlevel; ///< Use exact values for OpenGL - INT16 lightlevel; ///< Internal counter for fading } lightlevel_t; #define GLOWSPEED 8 @@ -165,8 +161,8 @@ strobe_t * P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector void T_Glow(glow_t *g); glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length); -void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel); -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel); +void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased); +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased); void T_LightFade(lightlevel_t *ll); typedef enum From 368f96e6058aa57b41c7beae0db1821a22f15cea Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 15:41:30 -0400 Subject: [PATCH 143/573] Fade FOF lighting fixes; properly calculate destlightvalue --- src/p_spec.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index d4b60c70c..5c171c3d6 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3358,8 +3358,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) destvalue, speed, !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT - !(line->flags & ML_BOUNCY), // do not handle interactive flags !(line->flags & ML_EFFECT2), // do not handle lighting + !(line->flags & ML_BOUNCY), // do not handle interactive flags (line->flags & ML_EFFECT1), // do ghost fade (no interactive flags during fade) (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) else @@ -3369,8 +3369,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) destvalue, 0, // set alpha immediately !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT - !(line->flags & ML_BOUNCY), // do not handle interactive flags !(line->flags & ML_EFFECT2), // do not handle lighting + !(line->flags & ML_BOUNCY), // do not handle interactive flags (line->flags & ML_EFFECT1), // do ghost fade (no interactive flags during fade) (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) } @@ -7453,10 +7453,7 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz rover->alpha = fadingdata->alpha; if (fadingdata->dolighting) - { P_RemoveLighting(§ors[rover->secnum]); - §ors[rover->secnum].lightlevel = rover->target->lightlevel; // \todo get fade light level destvalue - } P_RemoveThinker(&fadingdata->thinker); } @@ -7697,6 +7694,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, * \param speed speed to fade by * \param doexists handle FF_EXISTS * \param dotranslucent handle FF_TRANSLUCENT + * \param dolighting fade FOF light * \param docollision handle interactive flags * \param doghostfade no interactive flags during fading * \param exactalpha use exact alpha values (opengl) @@ -7740,10 +7738,24 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor // Set a separate thinker for shadow fading if (dolighting && !(rover->flags & FF_NOSHADE)) + { + UINT16 lightdelta = abs(sectors[rover->secnum].spawn_lightlevel - rover->target->lightlevel); + fixed_t alphapercent = FixedDiv(d->destvalue, rover->spawnalpha); + fixed_t adjustedlightdelta = FixedMul(lightdelta, alphapercent); + INT16 destlightvalue; + + if (rover->target->lightlevel >= sectors[rover->secnum].spawn_lightlevel) // fading out, get lighter + destlightvalue = rover->target->lightlevel - adjustedlightdelta; + else // fading in, get darker + destlightvalue = rover->target->lightlevel + adjustedlightdelta; + + //CONS_Printf("%d| LightDelta %d> AlphaPct %d> AdjLiDel %d> DestLight %d\n", gametic, lightdelta, FixedMul(alphapercent, 100), adjustedlightdelta, destlightvalue); + P_FadeLightBySector(§ors[rover->secnum], - rover->target->lightlevel, // (shadowlight - targetlight) * destvalue/256 // \todo get fade light level destvalue + destlightvalue, FixedFloor(FixedDiv(abs(d->destvalue - d->alpha), d->speed))/FRACUNIT, - true, exactalpha); + true); + } P_AddThinker(&d->thinker); } From 80a4a03f8e253f672a4651b4e556e609571b1944 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 17:19:49 -0400 Subject: [PATCH 144/573] Finalize light level on fade finish (not forced stop) * Added destlightlevel property to fade_t * Fixed dotranslucent, dolighting, docollision order weirdness in function calls --- src/p_saveg.c | 6 ++++-- src/p_spec.c | 35 ++++++++++++++++++++--------------- src/p_spec.h | 3 ++- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index be0363d05..334279a9a 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1591,11 +1591,12 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->ffloornum); WRITEINT32(save_p, ht->alpha); WRITEINT16(save_p, ht->destvalue); + WRITEINT16(save_p, ht->destlightlevel); WRITEINT16(save_p, ht->speed); WRITEUINT8(save_p, ht->doexists); WRITEUINT8(save_p, ht->dotranslucent); - WRITEUINT8(save_p, ht->docollision); WRITEUINT8(save_p, ht->dolighting); + WRITEUINT8(save_p, ht->docollision); WRITEUINT8(save_p, ht->doghostfade); WRITEUINT8(save_p, ht->exactalpha); } @@ -2599,11 +2600,12 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->ffloornum = READINT32(save_p); ht->alpha = READINT32(save_p); ht->destvalue = READINT16(save_p); + ht->destlightlevel = READINT16(save_p); ht->speed = READINT16(save_p); ht->doexists = READUINT8(save_p); ht->dotranslucent = READUINT8(save_p); - ht->docollision = READUINT8(save_p); ht->dolighting = READUINT8(save_p); + ht->docollision = READUINT8(save_p); ht->doghostfade = READUINT8(save_p); ht->exactalpha = READUINT8(save_p); diff --git a/src/p_spec.c b/src/p_spec.c index 5c171c3d6..d291d1e3b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -106,10 +106,10 @@ static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t o static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finalize); #define P_RemoveFakeFloorFader(l) P_ResetFakeFloorFader(l, NULL, false); static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, - boolean doexists, boolean dotranslucent, boolean docollision, boolean dolighting, boolean doghostfade, boolean exactalpha); + boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha); static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, INT16 destvalue, INT16 speed, - boolean doexists, boolean dotranslucent, boolean docollision, boolean dolighting, boolean doghostfade, boolean exactalpha); + boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3359,8 +3359,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT !(line->flags & ML_EFFECT2), // do not handle lighting - !(line->flags & ML_BOUNCY), // do not handle interactive flags - (line->flags & ML_EFFECT1), // do ghost fade (no interactive flags during fade) + !(line->flags & ML_BOUNCY), // do not handle collision + (line->flags & ML_EFFECT1), // do ghost fade (no collision during fade) (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) else { @@ -3370,8 +3370,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT !(line->flags & ML_EFFECT2), // do not handle lighting - !(line->flags & ML_BOUNCY), // do not handle interactive flags - (line->flags & ML_EFFECT1), // do ghost fade (no interactive flags during fade) + !(line->flags & ML_BOUNCY), // do not handle collision + (line->flags & ML_EFFECT1), // do ghost fade (no collision during fade) (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) } } @@ -7463,7 +7463,7 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz } static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, - boolean doexists, boolean dotranslucent, boolean docollision, boolean dolighting, boolean doghostfade, boolean exactalpha) + boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha) { boolean stillfading = false; INT32 alpha; @@ -7728,8 +7728,8 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor d->speed = max(1, speed); // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker d->doexists = doexists; d->dotranslucent = dotranslucent; - d->docollision = docollision; d->dolighting = dolighting; + d->docollision = docollision; d->doghostfade = doghostfade; d->exactalpha = exactalpha; @@ -7742,20 +7742,19 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor UINT16 lightdelta = abs(sectors[rover->secnum].spawn_lightlevel - rover->target->lightlevel); fixed_t alphapercent = FixedDiv(d->destvalue, rover->spawnalpha); fixed_t adjustedlightdelta = FixedMul(lightdelta, alphapercent); - INT16 destlightvalue; if (rover->target->lightlevel >= sectors[rover->secnum].spawn_lightlevel) // fading out, get lighter - destlightvalue = rover->target->lightlevel - adjustedlightdelta; + d->destlightlevel = rover->target->lightlevel - adjustedlightdelta; else // fading in, get darker - destlightvalue = rover->target->lightlevel + adjustedlightdelta; - - //CONS_Printf("%d| LightDelta %d> AlphaPct %d> AdjLiDel %d> DestLight %d\n", gametic, lightdelta, FixedMul(alphapercent, 100), adjustedlightdelta, destlightvalue); + d->destlightlevel = rover->target->lightlevel + adjustedlightdelta; P_FadeLightBySector(§ors[rover->secnum], - destlightvalue, + d->destlightlevel, FixedFloor(FixedDiv(abs(d->destvalue - d->alpha), d->speed))/FRACUNIT, true); } + else + d->destlightlevel = -1; P_AddThinker(&d->thinker); } @@ -7767,8 +7766,14 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor */ void T_Fade(fade_t *d) { - if (d->rover && !P_FadeFakeFloor(d->rover, d->destvalue, d->speed, d->doexists, d->dotranslucent, d->docollision, d->dolighting, d->doghostfade, d->exactalpha)) + if (d->rover && !P_FadeFakeFloor(d->rover, d->destvalue, d->speed, d->doexists, d->dotranslucent, d->dolighting, d->docollision, d->doghostfade, d->exactalpha)) + { + // Finalize lighting, copypasta from P_AddFakeFloorFader + if (d->dolighting && !(d->rover->flags & FF_NOSHADE) && d->destlightlevel > -1) + sectors[d->rover->secnum].lightlevel = d->destlightlevel; + P_RemoveFakeFloorFader(d->rover); + } } /* diff --git a/src/p_spec.h b/src/p_spec.h index aefb024af..461ae876b 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -470,11 +470,12 @@ typedef struct INT32 ffloornum; ///< Number of ffloor of target sector INT32 alpha; ///< Internal alpha counter INT16 destvalue; ///< Transparency value to fade to + INT16 destlightlevel; ///< Light level to fade to INT16 speed; ///< Speed to fade by boolean doexists; ///< Handle FF_EXISTS boolean dotranslucent; ///< Handle FF_TRANSLUCENT - boolean docollision; ///< Handle interactive flags boolean dolighting; ///< Handle shadows and light blocks + boolean docollision; ///< Handle interactive flags boolean doghostfade; ///< No interactive flags during fading boolean exactalpha; ///< Use exact alpha values (opengl) } fade_t; From c0bf79ad8e8230bb315035f6be7d93d137d3d176 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 9 Sep 2018 22:48:09 +0100 Subject: [PATCH 145/573] R_CreateColormap2 and R_MakeColormaps have been made obsolete, it's just R_CreateColormap now, like it used to be! With that, I moved R_CreateColormap2's exclusive software colormap malloc code to R_CreateColormap, and merged the two software-only blocks of code into one. I also disabled any unneeded variables and fixed a preprocessor-related goofup --- src/p_setup.c | 2 +- src/r_data.c | 88 +++++++++++++++++++++++++++++++++++++++------------ src/r_data.h | 4 +-- 3 files changed, 71 insertions(+), 23 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index d8c913e0f..58170e262 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2673,7 +2673,7 @@ boolean P_SetupLevel(boolean skipprecip) P_CreateBlockMap(); // Graue 02-29-2004 P_LoadSideDefs2(lastloadedmaplumpnum + ML_SIDEDEFS); - R_MakeColormaps(); + //R_MakeColormaps(); P_LoadLineDefs2(); P_LoadSubsectors(lastloadedmaplumpnum + ML_SSECTORS); P_LoadNodes(lastloadedmaplumpnum + ML_NODES); diff --git a/src/r_data.c b/src/r_data.c index e1d4b8935..2551a2946 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1038,8 +1038,8 @@ void R_ReInitColormaps(UINT16 num) static lumpnum_t foundcolormaps[MAXCOLORMAPS]; -static char colormapFixingArray[MAXCOLORMAPS][3][9]; -static size_t carrayindex; +//static char colormapFixingArray[MAXCOLORMAPS][3][9]; +//static size_t carrayindex; // // R_ClearColormaps @@ -1052,7 +1052,7 @@ void R_ClearColormaps(void) num_extra_colormaps = 0; - carrayindex = 0; + //carrayindex = 0; for (i = 0; i < MAXCOLORMAPS; i++) foundcolormaps[i] = LUMPERROR; @@ -1110,7 +1110,7 @@ static int RoundUp(double number); INT32 R_CreateColormap(char *p1, char *p2, char *p3) { double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; - double r, g, b, cbrightness, maskamt = 0, othermask = 0; + double maskamt = 0, othermask = 0; int mask, fog = 0; size_t mapnum = num_extra_colormaps; size_t i; @@ -1163,7 +1163,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) fadedist = fadeend - fadestart; fog = NUMFROMCHAR(p2[1]); } -#undef getnum +#undef NUMFROMCHAR if (p3[0] == '#') { @@ -1194,14 +1194,35 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) if (num_extra_colormaps == MAXCOLORMAPS) I_Error("R_CreateColormap: Too many colormaps! the limit is %d\n", MAXCOLORMAPS); - strncpy(colormapFixingArray[num_extra_colormaps][0], p1, 8); - strncpy(colormapFixingArray[num_extra_colormaps][1], p2, 8); - strncpy(colormapFixingArray[num_extra_colormaps][2], p3, 8); + //strncpy(colormapFixingArray[num_extra_colormaps][0], p1, 8); + //strncpy(colormapFixingArray[num_extra_colormaps][1], p2, 8); + //strncpy(colormapFixingArray[num_extra_colormaps][2], p3, 8); num_extra_colormaps++; + foundcolormaps[mapnum] = LUMPERROR; + + // aligned on 8 bit for asm code + extra_colormaps[mapnum].colormap = NULL; + extra_colormaps[mapnum].maskcolor = (UINT16)maskcolor; + extra_colormaps[mapnum].fadecolor = (UINT16)fadecolor; + extra_colormaps[mapnum].maskamt = maskamt; + extra_colormaps[mapnum].fadestart = (UINT16)fadestart; + extra_colormaps[mapnum].fadeend = (UINT16)fadeend; + extra_colormaps[mapnum].fog = fog; + + // This code creates the colormap array used by software renderer if (rendermode == render_soft) { + double r, g, b, cbrightness; + int p; + char *colormap_p; + + // Initialise the map and delta arrays + // map[i] stores an RGB color (as double) for index i, + // which is then converted to SRB2's palette later + // deltas[i] stores a corresponding fade delta between the RGB color and the final fade color; + // map[i]'s values are decremented by after each use for (i = 0; i < 256; i++) { r = pLocalPalette[i].s.red; @@ -1224,22 +1245,48 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) map[i][2] = 255.0l; deltas[i][2] = (map[i][2] - cdestb) / (double)fadedist; } + + // Now allocate memory for the actual colormap array itself! + colormap_p = Z_MallocAlign((256 * 34) + 10, PU_LEVEL, NULL, 8); + extra_colormaps[mapnum].colormap = (UINT8 *)colormap_p; + + // Calculate the palette index for each palette index, for each light level + // (as well as the two unused colormap lines we inherited from Doom) + for (p = 0; p < 34; p++) + { + for (i = 0; i < 256; i++) + { + *colormap_p = NearestColor((UINT8)RoundUp(map[i][0]), + (UINT8)RoundUp(map[i][1]), + (UINT8)RoundUp(map[i][2])); + colormap_p++; + + if ((UINT32)p < fadestart) + continue; +#define ABS2(x) ((x) < 0 ? -(x) : (x)) + if (ABS2(map[i][0] - cdestr) > ABS2(deltas[i][0])) + map[i][0] -= deltas[i][0]; + else + map[i][0] = cdestr; + + if (ABS2(map[i][1] - cdestg) > ABS2(deltas[i][1])) + map[i][1] -= deltas[i][1]; + else + map[i][1] = cdestg; + + if (ABS2(map[i][2] - cdestb) > ABS2(deltas[i][1])) + map[i][2] -= deltas[i][2]; + else + map[i][2] = cdestb; +#undef ABS2 + } + } } - foundcolormaps[mapnum] = LUMPERROR; - - // aligned on 8 bit for asm code - extra_colormaps[mapnum].colormap = NULL; - extra_colormaps[mapnum].maskcolor = (UINT16)maskcolor; - extra_colormaps[mapnum].fadecolor = (UINT16)fadecolor; - extra_colormaps[mapnum].maskamt = maskamt; - extra_colormaps[mapnum].fadestart = (UINT16)fadestart; - extra_colormaps[mapnum].fadeend = (UINT16)fadeend; - extra_colormaps[mapnum].fog = fog; - return (INT32)mapnum; } +/* void R_MakeColormaps(void) { size_t i; @@ -1310,7 +1357,7 @@ void R_CreateColormap2(char *p1, char *p2, char *p3) fadedist = fadeend - fadestart; fog = NUMFROMCHAR(p2[1]); } -#undef getnum +#undef NUMFROMCHAR if (p3[0] == '#') { @@ -1419,6 +1466,7 @@ void R_CreateColormap2(char *p1, char *p2, char *p3) return; } +*/ // Thanks to quake2 source! // utils3/qdata/images.c diff --git a/src/r_data.h b/src/r_data.h index 1e9e0eb5e..c1f2a73da 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -93,8 +93,8 @@ void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); INT32 R_ColormapNumForName(char *name); INT32 R_CreateColormap(char *p1, char *p2, char *p3); -void R_CreateColormap2(char *p1, char *p2, char *p3); -void R_MakeColormaps(void); +//void R_CreateColormap2(char *p1, char *p2, char *p3); +//void R_MakeColormaps(void); const char *R_ColormapNameForNum(INT32 num); extern INT32 numtextures; From c3c4a251f1d547d430c8551d2a7cecf5af6f9db0 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 19:31:32 -0400 Subject: [PATCH 146/573] Added tic-based logic to FOF fade (ML_EFFECT5) --- src/p_saveg.c | 6 ++++++ src/p_spec.c | 53 ++++++++++++++++++++++++++++++++++++++++----------- src/p_spec.h | 3 +++ 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 334279a9a..162241573 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1593,6 +1593,9 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) WRITEINT16(save_p, ht->destvalue); WRITEINT16(save_p, ht->destlightlevel); WRITEINT16(save_p, ht->speed); + WRITEINT32(save_p, ht->duration); + WRITEUINT32(save_p, ht->interval); + WRITEUINT32(save_p, (UINT32)ht->firsttic); WRITEUINT8(save_p, ht->doexists); WRITEUINT8(save_p, ht->dotranslucent); WRITEUINT8(save_p, ht->dolighting); @@ -2602,6 +2605,9 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->destvalue = READINT16(save_p); ht->destlightlevel = READINT16(save_p); ht->speed = READINT16(save_p); + ht->duration = READINT32(save_p); + ht->interval = READUINT32(save_p); + ht->firsttic = (tic_t)READUINT32(save_p); ht->doexists = READUINT8(save_p); ht->dotranslucent = READUINT8(save_p); ht->dolighting = READUINT8(save_p); diff --git a/src/p_spec.c b/src/p_spec.c index d291d1e3b..8d1f4f295 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -105,10 +105,10 @@ static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t * static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finalize); #define P_RemoveFakeFloorFader(l) P_ResetFakeFloorFader(l, NULL, false); -static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, +static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, INT32 duration, UINT32 interval, tic_t firsttic, boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha); static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, - INT16 destvalue, INT16 speed, + INT16 destvalue, INT16 speed, boolean ticbased, boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); @@ -3356,6 +3356,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (speed > 0) P_AddFakeFloorFader(rover, secnum, j, destvalue, speed, + (line->flags & ML_EFFECT5), // tic-based logic !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT !(line->flags & ML_EFFECT2), // do not handle lighting @@ -3367,6 +3368,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_RemoveFakeFloorFader(rover); P_FadeFakeFloor(rover, destvalue, 0, // set alpha immediately + -1, 0, 0, // tic-based logic !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT !(line->flags & ML_EFFECT2), // do not handle lighting @@ -7444,6 +7446,9 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz fadingdata->alpha - 1 : // trigger fade-out finish fadingdata->alpha + 1, // trigger fade-in finish 0, + fadingdata->duration, + fadingdata->interval, + fadingdata->firsttic, fadingdata->doexists, fadingdata->dotranslucent, fadingdata->docollision, @@ -7462,9 +7467,10 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz } } -static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, +static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, INT32 duration, UINT32 interval, tic_t firsttic, boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha) { + boolean ticbased = (duration > -1); boolean stillfading = false; INT32 alpha; fade_t *fadingdata = (fade_t *)rover->fadingdata; @@ -7492,7 +7498,8 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, else if (alpha > destvalue) // fade out { // finish fading out - if (speed < 1 || alpha - speed <= destvalue + speed) + if (speed < 1 || (!ticbased && alpha - speed <= destvalue + speed) || + (ticbased && (gametic - firsttic >= duration || alpha <= destvalue))) { alpha = destvalue; @@ -7512,14 +7519,18 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, } else // continue fading out { - alpha -= speed; + if (!ticbased) + alpha -= speed; + else if (ticbased && !((gametic - firsttic) % interval)) + alpha = max(alpha - speed, destvalue); stillfading = true; } } else // fade in { // finish fading in - if (speed < 1 || alpha + speed >= destvalue - speed) + if (speed < 1 || (!ticbased && alpha + speed >= destvalue - speed) || + (ticbased && (gametic - firsttic >= duration || alpha >= destvalue))) { alpha = destvalue; @@ -7539,7 +7550,10 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, } else // continue fading in { - alpha += speed; + if (!ticbased) + alpha += speed; + else if (ticbased && !((gametic - firsttic) % interval)) + alpha = min(alpha + speed, destvalue); stillfading = true; } } @@ -7692,6 +7706,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, * * \param destvalue transparency value to fade to * \param speed speed to fade by + * \param ticbased tic-based logic, speed = duration * \param doexists handle FF_EXISTS * \param dotranslucent handle FF_TRANSLUCENT * \param dolighting fade FOF light @@ -7700,7 +7715,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, * \param exactalpha use exact alpha values (opengl) */ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, - INT16 destvalue, INT16 speed, + INT16 destvalue, INT16 speed, boolean ticbased, boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha) { // already equal, nothing to do @@ -7725,7 +7740,21 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor d->alpha = rover->alpha; d->destvalue = max(1, min(256, destvalue)); // ffloor->alpha is 1-256 - d->speed = max(1, speed); // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker + + if (ticbased) + { + d->duration = abs(speed); + d->speed = max(abs(FixedFloor(FixedDiv(d->destvalue - d->alpha, d->duration))/FRACUNIT), 1); + d->interval = max(FixedFloor(FixedDiv(d->duration, abs(d->destvalue - d->alpha)))/FRACUNIT, 1); + d->firsttic = gametic; + } + else + { + d->speed = max(1, speed); // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker + d->duration = -1; + d->interval = d->firsttic = 0; + } + d->doexists = doexists; d->dotranslucent = dotranslucent; d->dolighting = dolighting; @@ -7750,7 +7779,8 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor P_FadeLightBySector(§ors[rover->secnum], d->destlightlevel, - FixedFloor(FixedDiv(abs(d->destvalue - d->alpha), d->speed))/FRACUNIT, + ticbased ? d->duration : + FixedFloor(FixedDiv(abs(d->destvalue - d->alpha), d->speed))/FRACUNIT, true); } else @@ -7766,7 +7796,8 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor */ void T_Fade(fade_t *d) { - if (d->rover && !P_FadeFakeFloor(d->rover, d->destvalue, d->speed, d->doexists, d->dotranslucent, d->dolighting, d->docollision, d->doghostfade, d->exactalpha)) + if (d->rover && !P_FadeFakeFloor(d->rover, d->destvalue, d->speed, d->duration, d->interval, d->firsttic, + d->doexists, d->dotranslucent, d->dolighting, d->docollision, d->doghostfade, d->exactalpha)) { // Finalize lighting, copypasta from P_AddFakeFloorFader if (d->dolighting && !(d->rover->flags & FF_NOSHADE) && d->destlightlevel > -1) diff --git a/src/p_spec.h b/src/p_spec.h index 461ae876b..93d113be3 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -472,6 +472,9 @@ typedef struct INT16 destvalue; ///< Transparency value to fade to INT16 destlightlevel; ///< Light level to fade to INT16 speed; ///< Speed to fade by + INT32 duration; ///< Duration for tic-based logic, > -1 means use tic-based + UINT32 interval; ///< Skip interval for tic-based logic + tic_t firsttic; ///< First tic for tic-based logic boolean doexists; ///< Handle FF_EXISTS boolean dotranslucent; ///< Handle FF_TRANSLUCENT boolean dolighting; ///< Handle shadows and light blocks From 43ae628adc746bcb8d11dbe4d4f383d79cff076e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 19:44:35 -0400 Subject: [PATCH 147/573] Cap lightlevel fading at spawn_lightlevel (don't make darker) --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 8d1f4f295..de61064fd 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7769,7 +7769,7 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor if (dolighting && !(rover->flags & FF_NOSHADE)) { UINT16 lightdelta = abs(sectors[rover->secnum].spawn_lightlevel - rover->target->lightlevel); - fixed_t alphapercent = FixedDiv(d->destvalue, rover->spawnalpha); + fixed_t alphapercent = min(FixedDiv(d->destvalue, rover->spawnalpha), 1*FRACUNIT); // don't make darker than spawn_lightlevel fixed_t adjustedlightdelta = FixedMul(lightdelta, alphapercent); if (rover->target->lightlevel >= sectors[rover->secnum].spawn_lightlevel) // fading out, get lighter From ea2276eb07539f2d3369233eb02030d66ff6ab37 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 19:57:41 -0400 Subject: [PATCH 148/573] Fix tic-based bug returning early --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index de61064fd..8b5b0c1c4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7493,7 +7493,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, IN alpha = rover->alpha; // routines specific to fade in and fade out - if (alpha == destvalue) + if (!ticbased && alpha == destvalue) return stillfading; else if (alpha > destvalue) // fade out { From 3d5f225702bbb9cae9a52ec00ff1a32304d8eb71 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 20:18:43 -0400 Subject: [PATCH 149/573] Replace firsttic with decrement timer --- src/p_lights.c | 16 ++++++++-------- src/p_saveg.c | 8 ++++---- src/p_spec.h | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/p_lights.c b/src/p_lights.c index 8be3d793c..77d05dad3 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -356,16 +356,16 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean if (ticbased) { - ll->duration = abs(speed); - ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->duration))/FRACUNIT; + ll->ticbased = ticbased; + ll->timer = abs(speed); + ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->timer))/FRACUNIT; if (!ll->speed) ll->speed = (destvalue < sector->lightlevel) ? -1 : 1; - ll->interval = max(FixedFloor(FixedDiv(ll->duration, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1); - ll->firsttic = gametic; + ll->interval = max(FixedFloor(FixedDiv(ll->timer, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1); } else { - ll->duration = -1; + ll->timer = -1; ll->speed = abs(speed); } } @@ -385,14 +385,14 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) */ void T_LightFade(lightlevel_t *ll) { - if (ll->duration >= 0) // tic-based + if (ll->ticbased) { - if (gametic - ll->firsttic >= ll->duration) + if (--ll->timer <= 0) { ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } - else if (!((gametic - ll->firsttic) % ll->interval)) + else if (!(ll->timer % ll->interval)) { if (ll->speed < 0) ll->sector->lightlevel = max(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); diff --git a/src/p_saveg.c b/src/p_saveg.c index 8ec5b5ea8..eefee072d 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1539,9 +1539,9 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, SaveSector(ht->sector)); WRITEINT32(save_p, ht->destlevel); WRITEINT32(save_p, ht->speed); - WRITEINT32(save_p, ht->duration); + WRITEUINT8(save_p, (UINT8)ht->ticbased); + WRITEINT32(save_p, ht->timer); WRITEUINT32(save_p, ht->interval); - WRITEUINT32(save_p, (UINT32)ht->firsttic); } // @@ -2515,9 +2515,9 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) ht->sector = LoadSector(READUINT32(save_p)); ht->destlevel = READINT32(save_p); ht->speed = READINT32(save_p); - ht->duration = READINT32(save_p); + ht->ticbased = (boolean)READUINT8(save_p); + ht->timer = READINT32(save_p); ht->interval = READUINT32(save_p); - ht->firsttic = (tic_t)READUINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; P_AddThinker(&ht->thinker); diff --git a/src/p_spec.h b/src/p_spec.h index c2c4c8976..1e327c5f2 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -140,9 +140,9 @@ typedef struct INT32 speed; ///< Speed at which to change light level. // Tic-based behavior - INT32 duration; ///< If <0, do not use tic-based behavior. If 0, set instantly. If >0, fade lasts this duration. + boolean ticbased; ///< Tic-based logic + INT32 timer; ///< Tic-based timer UINT32 interval; ///< Interval to deduct light level - tic_t firsttic; ///< First gametic to count from } lightlevel_t; #define GLOWSPEED 8 From 0202bbcfd325165760915710c1e0a768c335d822 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 20:45:12 -0400 Subject: [PATCH 150/573] Replace firsttic with timer increment --- src/p_saveg.c | 8 ++++---- src/p_spec.c | 36 ++++++++++++++++++------------------ src/p_spec.h | 4 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 8ec35a0d6..a3790d6f0 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1593,9 +1593,9 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) WRITEINT16(save_p, ht->destvalue); WRITEINT16(save_p, ht->destlightlevel); WRITEINT16(save_p, ht->speed); - WRITEINT32(save_p, ht->duration); + WRITEUINT8(save_p, (UINT8)ht->ticbased); + WRITEINT32(save_p, ht->timer); WRITEUINT32(save_p, ht->interval); - WRITEUINT32(save_p, (UINT32)ht->firsttic); WRITEUINT8(save_p, ht->doexists); WRITEUINT8(save_p, ht->dotranslucent); WRITEUINT8(save_p, ht->dolighting); @@ -2605,9 +2605,9 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->destvalue = READINT16(save_p); ht->destlightlevel = READINT16(save_p); ht->speed = READINT16(save_p); - ht->duration = READINT32(save_p); + ht->ticbased = (boolean)READUINT8(save_p); + ht->timer = READINT32(save_p); ht->interval = READUINT32(save_p); - ht->firsttic = (tic_t)READUINT32(save_p); ht->doexists = READUINT8(save_p); ht->dotranslucent = READUINT8(save_p); ht->dolighting = READUINT8(save_p); diff --git a/src/p_spec.c b/src/p_spec.c index 8b5b0c1c4..1bc60cc71 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -105,7 +105,7 @@ static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t * static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finalize); #define P_RemoveFakeFloorFader(l) P_ResetFakeFloorFader(l, NULL, false); -static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, INT32 duration, UINT32 interval, tic_t firsttic, +static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, boolean ticbased, INT32 *timer, UINT32 interval, boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha); static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, INT16 destvalue, INT16 speed, boolean ticbased, @@ -3368,7 +3368,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_RemoveFakeFloorFader(rover); P_FadeFakeFloor(rover, destvalue, 0, // set alpha immediately - -1, 0, 0, // tic-based logic + false, NULL, 0, // tic-based logic !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT !(line->flags & ML_EFFECT2), // do not handle lighting @@ -7446,9 +7446,9 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz fadingdata->alpha - 1 : // trigger fade-out finish fadingdata->alpha + 1, // trigger fade-in finish 0, - fadingdata->duration, + fadingdata->ticbased, + &fadingdata->timer, fadingdata->interval, - fadingdata->firsttic, fadingdata->doexists, fadingdata->dotranslucent, fadingdata->docollision, @@ -7467,10 +7467,9 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz } } -static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, INT32 duration, UINT32 interval, tic_t firsttic, +static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, boolean ticbased, INT32 *timer, UINT32 interval, boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha) { - boolean ticbased = (duration > -1); boolean stillfading = false; INT32 alpha; fade_t *fadingdata = (fade_t *)rover->fadingdata; @@ -7499,7 +7498,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, IN { // finish fading out if (speed < 1 || (!ticbased && alpha - speed <= destvalue + speed) || - (ticbased && (gametic - firsttic >= duration || alpha <= destvalue))) + (ticbased && (--(*timer) <= 0 || alpha <= destvalue))) { alpha = destvalue; @@ -7521,7 +7520,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, IN { if (!ticbased) alpha -= speed; - else if (ticbased && !((gametic - firsttic) % interval)) + else if (ticbased && !((*timer) % interval)) alpha = max(alpha - speed, destvalue); stillfading = true; } @@ -7530,7 +7529,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, IN { // finish fading in if (speed < 1 || (!ticbased && alpha + speed >= destvalue - speed) || - (ticbased && (gametic - firsttic >= duration || alpha >= destvalue))) + (ticbased && (--(*timer) <= 0|| alpha >= destvalue))) { alpha = destvalue; @@ -7552,7 +7551,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, IN { if (!ticbased) alpha += speed; - else if (ticbased && !((gametic - firsttic) % interval)) + else if (ticbased && !((*timer) % interval)) alpha = min(alpha + speed, destvalue); stillfading = true; } @@ -7743,16 +7742,17 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor if (ticbased) { - d->duration = abs(speed); - d->speed = max(abs(FixedFloor(FixedDiv(d->destvalue - d->alpha, d->duration))/FRACUNIT), 1); - d->interval = max(FixedFloor(FixedDiv(d->duration, abs(d->destvalue - d->alpha)))/FRACUNIT, 1); - d->firsttic = gametic; + d->ticbased = true; + d->timer = abs(speed); + d->speed = max(abs(FixedFloor(FixedDiv(d->destvalue - d->alpha, d->timer))/FRACUNIT), 1); + d->interval = max(FixedFloor(FixedDiv(d->timer, abs(d->destvalue - d->alpha)))/FRACUNIT, 1); } else { d->speed = max(1, speed); // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker - d->duration = -1; - d->interval = d->firsttic = 0; + d->ticbased = false; + d->timer = -1; + d->interval = 0; } d->doexists = doexists; @@ -7779,7 +7779,7 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor P_FadeLightBySector(§ors[rover->secnum], d->destlightlevel, - ticbased ? d->duration : + ticbased ? d->timer : FixedFloor(FixedDiv(abs(d->destvalue - d->alpha), d->speed))/FRACUNIT, true); } @@ -7796,7 +7796,7 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor */ void T_Fade(fade_t *d) { - if (d->rover && !P_FadeFakeFloor(d->rover, d->destvalue, d->speed, d->duration, d->interval, d->firsttic, + if (d->rover && !P_FadeFakeFloor(d->rover, d->destvalue, d->speed, d->ticbased, &d->timer, d->interval, d->doexists, d->dotranslucent, d->dolighting, d->docollision, d->doghostfade, d->exactalpha)) { // Finalize lighting, copypasta from P_AddFakeFloorFader diff --git a/src/p_spec.h b/src/p_spec.h index 2499ddcba..9e602b192 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -472,9 +472,9 @@ typedef struct INT16 destvalue; ///< Transparency value to fade to INT16 destlightlevel; ///< Light level to fade to INT16 speed; ///< Speed to fade by - INT32 duration; ///< Duration for tic-based logic, > -1 means use tic-based + boolean ticbased; ///< Tic-based logic toggle + INT32 timer; ///< Timer for tic-based logic UINT32 interval; ///< Skip interval for tic-based logic - tic_t firsttic; ///< First tic for tic-based logic boolean doexists; ///< Handle FF_EXISTS boolean dotranslucent; ///< Handle FF_TRANSLUCENT boolean dolighting; ///< Handle shadows and light blocks From 573e1d00173d373bf0a6e72b7800c9925c209441 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 21:01:00 -0400 Subject: [PATCH 151/573] Replace firsttic with timer increment --- src/p_polyobj.c | 9 ++++----- src/p_polyobj.h | 6 ++---- src/p_saveg.c | 6 ++---- src/p_spec.c | 7 +++---- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 9e5cdf90e..a8616dba1 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2873,9 +2873,9 @@ void T_PolyObjFade(polyfade_t *th) if (po->thinker == NULL) po->thinker = &th->thinker; - stillfading = !(gametic - th->firsttic >= th->duration); + stillfading = !(--(th->timer) <= 0); - if (gametic - th->firsttic >= th->duration) + if (th->timer <= 0) { po->translucency = th->destvalue; // set to dest translucency @@ -2884,7 +2884,7 @@ void T_PolyObjFade(polyfade_t *th) po->thinker = NULL; P_RemoveThinker(&th->thinker); } - else if (!((gametic - th->firsttic) % th->interval)) + else if (!(th->timer % th->interval)) { if (th->speed <= 0) po->translucency = max(po->translucency + th->speed, th->destvalue); @@ -2968,10 +2968,9 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) th->destvalue = pfdata->destvalue; th->docollision = pfdata->docollision; th->doghostfade = pfdata->doghostfade; - th->duration = pfdata->duration; + th->timer = pfdata->timer; th->speed = pfdata->speed; th->interval = pfdata->interval; - th->firsttic = pfdata->firsttic; oldpo = po; diff --git a/src/p_polyobj.h b/src/p_polyobj.h index cf00d64ba..d5c07cb5b 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -215,10 +215,9 @@ typedef struct polyfade_s INT32 destvalue; boolean docollision; boolean doghostfade; - UINT32 duration; + INT32 timer; INT32 speed; UINT32 interval; - tic_t firsttic; } polyfade_t; // @@ -286,10 +285,9 @@ typedef struct polyfadedata_s INT32 destvalue; boolean docollision; boolean doghostfade; - UINT32 duration; + INT32 timer; INT32 speed; UINT32 interval; - tic_t firsttic; } polyfadedata_t; // diff --git a/src/p_saveg.c b/src/p_saveg.c index fc9382233..403f05b00 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1708,10 +1708,9 @@ static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->destvalue); WRITEUINT8(save_p, (UINT8)ht->docollision); WRITEUINT8(save_p, (UINT8)ht->doghostfade); - WRITEUINT32(save_p, ht->duration); + WRITEINT32(save_p, ht->timer); WRITEINT32(save_p, ht->speed); WRITEUINT32(save_p, ht->interval); - WRITEUINT32(save_p, (UINT32)ht->firsttic); } #endif @@ -2723,10 +2722,9 @@ static void LoadPolyfadeThinker(actionf_p1 thinker) ht->destvalue = READINT32(save_p); ht->docollision = (boolean)READUINT8(save_p); ht->doghostfade = (boolean)READUINT8(save_p); - ht->duration = READUINT32(save_p); + ht->timer = READINT32(save_p); ht->speed = READINT32(save_p); ht->interval = READUINT32(save_p); - ht->firsttic = (tic_t)READUINT32(save_p); P_AddThinker(&ht->thinker); } #endif diff --git a/src/p_spec.c b/src/p_spec.c index 6d746f670..a20a339ed 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1276,12 +1276,11 @@ static boolean PolyFade(line_t *line) pfd.docollision = !(line->flags & ML_BOUNCY), // do not handle collision flags pfd.doghostfade = (line->flags & ML_EFFECT1), // do ghost fade (no collision flags during fade) - pfd.duration = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); - pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.duration))/FRACUNIT; + pfd.timer = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.timer))/FRACUNIT; if (!pfd.speed) pfd.speed = (pfd.destvalue < po->translucency) ? -1 : 1; - pfd.interval = max(FixedFloor(FixedDiv(pfd.duration, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1); - pfd.firsttic = gametic; + pfd.interval = max(FixedFloor(FixedDiv(pfd.timer, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1); return EV_DoPolyObjFade(&pfd); } From 231f19aaabb28bfc40b0a5e25546da8df186372d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 21:02:43 -0400 Subject: [PATCH 152/573] Revert "Merge branch 'random-fof-fixes' into fof-fixes-movingplatexists" This reverts commit cc114590548cb1b7f099d12499d556af2da2c993, reversing changes made to 7e3d5cd3734c5b2194dca7fb8875c9cfeca97dc4. --- src/p_floor.c | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index bb6bf8d16..0e28b831f 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1839,7 +1839,6 @@ void T_ThwompSector(levelspecthink_t *thwomp) #define ceilingwasheight vars[5] fixed_t thwompx, thwompy; sector_t *actionsector; - ffloor_t *rover = NULL; INT32 secnum; // If you just crashed down, wait a second before coming back up. @@ -1854,16 +1853,7 @@ void T_ThwompSector(levelspecthink_t *thwomp) secnum = P_FindSectorFromTag((INT16)thwomp->vars[0], -1); if (secnum > 0) - { actionsector = §ors[secnum]; - - // Look for thwomp FFloor - for (rover = actionsector->ffloors; rover; rover = rover->next) - { - if (rover->master == thwomp->sourceline) - break; - } - } else return; // Bad bad bad! @@ -1952,13 +1942,10 @@ void T_ThwompSector(levelspecthink_t *thwomp) { mobj_t *mp = (void *)&actionsector->soundorg; - if (!rover || (rover->flags & FF_EXISTS)) - { - if (thwomp->sourceline->flags & ML_EFFECT4) - S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); - else - S_StartSound(mp, sfx_thwomp); - } + if (thwomp->sourceline->flags & ML_EFFECT4) + S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); + else + S_StartSound(mp, sfx_thwomp); thwomp->direction = 1; // start heading back up thwomp->distance = TICRATE; // but only after a small delay @@ -1972,21 +1959,18 @@ void T_ThwompSector(levelspecthink_t *thwomp) thinker_t *th; mobj_t *mo; - if (!rover || (rover->flags & FF_EXISTS)) + // scan the thinkers to find players! + for (th = thinkercap.next; th != &thinkercap; th = th->next) { - // scan the thinkers to find players! - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; - mo = (mobj_t *)th; - if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight - && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) - { - thwomp->direction = -1; - break; - } + mo = (mobj_t *)th; + if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight + && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + { + thwomp->direction = -1; + break; } } From d01193df80d3164d437ceb02e9e75cbe304248e9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 21:59:41 -0400 Subject: [PATCH 153/573] Apply ~FF_EXISTS moving plat fix for VERTICALFLIP --- src/p_map.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index c275ba0be..ab6c03da0 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2723,6 +2723,7 @@ static boolean P_ThingHeightClip(mobj_t *thing) boolean floormoved; fixed_t oldfloorz = thing->floorz; size_t oldfloor_sectornum = thing->floor_sectornum, oldfloor_rovernum = thing->floor_rovernum; + size_t oldceil_sectornum = thing->ceiling_sectornum, oldceil_rovernum = thing->ceiling_rovernum; boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz); ffloor_t *rover = NULL; @@ -2751,13 +2752,15 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved) { + size_t old_sectornum = (thing->eflags & MFE_VERTICALFLIP) ? oldceil_sectornum : oldfloor_sectornum; + size_t old_rovernum = (thing->eflags & MFE_VERTICALFLIP) ? oldceil_rovernum : oldfloor_rovernum; // Find FOF referenced by floorz - if (oldfloor_sectornum) + if (old_sectornum) { size_t rovernum = 0; - for (rover = sectors[oldfloor_sectornum].ffloors; rover; rover = rover->next) + for (rover = sectors[old_sectornum].ffloors; rover; rover = rover->next) { - if (rovernum == oldfloor_rovernum) + if (rovernum == old_rovernum) break; rovernum++; } From 9cc186441b6703e7ab8a6e62abadb2cc118e7210 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 22:14:24 -0400 Subject: [PATCH 154/573] Fix fog visual glitch with fading --- src/p_spec.c | 58 ++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 1bc60cc71..0346bdd3d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7481,6 +7481,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, bo // initialize its alpha to 1 if (dotranslucent && (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE + !(rover->flags & FF_FOG) && // do not include fog !(rover->spawnflags & FF_RENDERSIDES) && !(rover->spawnflags & FF_RENDERPLANES) && !(rover->flags & FF_RENDERALL)) @@ -7572,7 +7573,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, bo rover->target->moved = true; } - if (dotranslucent) + if (dotranslucent && !(rover->flags & FF_FOG)) { if (alpha >= 256) { @@ -7619,7 +7620,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, bo rover->flags |= FF_EXISTS; } - if (dotranslucent) + if (dotranslucent && !(rover->flags & FF_FOG)) { rover->flags |= FF_TRANSLUCENT; @@ -7667,32 +7668,35 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, bo } } - if (!stillfading || exactalpha) - rover->alpha = alpha; - else // clamp fadingdata->alpha to software's alpha levels + if (!(rover->flags & FF_FOG)) // don't set FOG alpha { - if (alpha < 12) - rover->alpha = destvalue < 12 ? destvalue : 1; // Don't even draw it - else if (alpha < 38) - rover->alpha = destvalue >= 12 && destvalue < 38 ? destvalue : 25; - else if (alpha < 64) - rover->alpha = destvalue >=38 && destvalue < 64 ? destvalue : 51; - else if (alpha < 89) - rover->alpha = destvalue >= 64 && destvalue < 89 ? destvalue : 76; - else if (alpha < 115) - rover->alpha = destvalue >= 89 && destvalue < 115 ? destvalue : 102; - else if (alpha < 140) - rover->alpha = destvalue >= 115 && destvalue < 140 ? destvalue : 128; - else if (alpha < 166) - rover->alpha = destvalue >= 140 && destvalue < 166 ? destvalue : 154; - else if (alpha < 192) - rover->alpha = destvalue >= 166 && destvalue < 192 ? destvalue : 179; - else if (alpha < 217) - rover->alpha = destvalue >= 192 && destvalue < 217 ? destvalue : 204; - else if (alpha < 243) - rover->alpha = destvalue >= 217 && destvalue < 243 ? destvalue : 230; - else // Opaque - rover->alpha = destvalue >= 243 ? destvalue : 256; + if (!stillfading || exactalpha) + rover->alpha = alpha; + else // clamp fadingdata->alpha to software's alpha levels + { + if (alpha < 12) + rover->alpha = destvalue < 12 ? destvalue : 1; // Don't even draw it + else if (alpha < 38) + rover->alpha = destvalue >= 12 && destvalue < 38 ? destvalue : 25; + else if (alpha < 64) + rover->alpha = destvalue >=38 && destvalue < 64 ? destvalue : 51; + else if (alpha < 89) + rover->alpha = destvalue >= 64 && destvalue < 89 ? destvalue : 76; + else if (alpha < 115) + rover->alpha = destvalue >= 89 && destvalue < 115 ? destvalue : 102; + else if (alpha < 140) + rover->alpha = destvalue >= 115 && destvalue < 140 ? destvalue : 128; + else if (alpha < 166) + rover->alpha = destvalue >= 140 && destvalue < 166 ? destvalue : 154; + else if (alpha < 192) + rover->alpha = destvalue >= 166 && destvalue < 192 ? destvalue : 179; + else if (alpha < 217) + rover->alpha = destvalue >= 192 && destvalue < 217 ? destvalue : 204; + else if (alpha < 243) + rover->alpha = destvalue >= 217 && destvalue < 243 ? destvalue : 230; + else // Opaque + rover->alpha = destvalue >= 243 ? destvalue : 256; + } } if (fadingdata) From f33f9dd284f67a1a0cf4c1b8a3b671ce3bd30249 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 23:12:37 -0400 Subject: [PATCH 155/573] Replace sectornum/rovernum index vars with ffloor pointers --- src/p_map.c | 93 ++++++++++++++------------------------------------- src/p_mobj.h | 6 ++-- src/p_saveg.c | 48 +++++++++++++++++++------- 3 files changed, 62 insertions(+), 85 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index ab6c03da0..4bf06fa4b 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -52,8 +52,7 @@ fixed_t tmfloorz, tmceilingz; static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) -//ffloor_t *tmfloorrover, *tmceilingrover; // unused for now -size_t tmfloor_sectornum, tmfloor_rovernum, tmceiling_sectornum, tmceiling_rovernum; +ffloor_t *tmfloorrover, *tmceilingrover; #ifdef ESLOPE pslope_t *tmfloorslope, *tmceilingslope; #endif @@ -1419,8 +1418,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z + thing->height > tmfloorz) { tmfloorz = thing->z + thing->height; - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1441,8 +1439,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1451,8 +1448,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1469,8 +1465,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z < tmceilingz) { tmceilingz = thing->z; - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1491,8 +1486,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1501,8 +1495,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1654,8 +1647,7 @@ static boolean PIT_CheckLine(line_t *ld) { tmceilingz = opentop; ceilingline = ld; - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = opentopslope; #endif @@ -1664,8 +1656,7 @@ static boolean PIT_CheckLine(line_t *ld) if (openbottom > tmfloorz) { tmfloorz = openbottom; - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = openbottomslope; #endif @@ -1747,10 +1738,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // will adjust them. tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmfloorrover = NULL; + tmceilingrover = NULL; #ifdef ESLOPE tmfloorslope = newsubsec->sector->f_slope; tmceilingslope = newsubsec->sector->c_slope; @@ -1798,9 +1787,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < topheight - sinklevel) { tmfloorz = topheight - sinklevel; - // tmfloorrover = rover; - tmfloor_sectornum = newsubsec->sector - sectors; - tmfloor_rovernum = rovernum; + tmfloorrover = rover; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1810,9 +1797,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmceilingz > bottomheight + sinklevel) { tmceilingz = bottomheight + sinklevel; - // tmceilingrover = rover; - tmceiling_sectornum = newsubsec->sector - sectors; - tmceiling_rovernum = rovernum; + tmceilingrover = rover; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif @@ -1841,9 +1826,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < thing->z) { tmfloorz = thing->z; - // tmfloorrover = rover; - tmfloor_sectornum = newsubsec->sector - sectors; - tmfloor_rovernum = rovernum; + tmfloorrover = rover; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1863,9 +1846,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(rover->flags & FF_REVERSEPLATFORM)) { tmfloorz = tmdropoffz = topheight; - // tmfloorrover = rover; - tmfloor_sectornum = newsubsec->sector - sectors; - tmfloor_rovernum = rovernum; + tmfloorrover = rover; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1875,9 +1856,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE))) { tmceilingz = tmdrpoffceilz = bottomheight; - // tmceilingrover = rover; - tmceiling_sectornum = newsubsec->sector - sectors; - tmceiling_rovernum = rovernum; + tmceilingrover = rover; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif @@ -2375,12 +2354,8 @@ boolean PIT_PushableMoved(mobj_t *thing) mobj_t *oldthing = tmthing; line_t *oldceilline = ceilingline; line_t *oldblockline = blockingline; - // ffloor_t *oldflrrover = tmfloorrover; - // ffloor_t *oldceilrover = tmceilingrover; - size_t oldflrrover_sectornum = tmfloor_sectornum; - size_t oldflrrover_ffloornum = tmfloor_rovernum; - size_t oldceilrover_sectornum = tmceiling_sectornum; - size_t oldceilrover_ffloornum = tmceiling_rovernum; + ffloor_t *oldflrrover = tmfloorrover; + ffloor_t *oldceilrover = tmceilingrover; #ifdef ESLOPE pslope_t *oldfslope = tmfloorslope; pslope_t *oldcslope = tmceilingslope; @@ -2397,12 +2372,8 @@ boolean PIT_PushableMoved(mobj_t *thing) P_SetTarget(&tmthing, oldthing); ceilingline = oldceilline; blockingline = oldblockline; - // tmfloorrover = oldflrrover; - // tmceilingrover = oldceilrover; - tmfloor_sectornum = oldflrrover_sectornum; - tmfloor_rovernum = oldflrrover_ffloornum; - tmceiling_sectornum = oldceilrover_sectornum; - tmceiling_rovernum = oldceilrover_ffloornum; + tmfloorrover = oldflrrover; + tmceilingrover = oldceilrover; #ifdef ESLOPE tmfloorslope = oldfslope; tmceilingslope = oldcslope; @@ -2722,8 +2693,8 @@ static boolean P_ThingHeightClip(mobj_t *thing) { boolean floormoved; fixed_t oldfloorz = thing->floorz; - size_t oldfloor_sectornum = thing->floor_sectornum, oldfloor_rovernum = thing->floor_rovernum; - size_t oldceil_sectornum = thing->ceiling_sectornum, oldceil_rovernum = thing->ceiling_rovernum; + ffloor_t *oldfloorrover = thing->floorrover; + ffloor_t *oldceilingrover = thing->ceilingrover; boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz); ffloor_t *rover = NULL; @@ -2740,10 +2711,8 @@ static boolean P_ThingHeightClip(mobj_t *thing) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; - thing->floor_sectornum = tmfloor_sectornum; - thing->floor_rovernum = tmfloor_rovernum; - thing->ceiling_sectornum = tmceiling_sectornum; - thing->ceiling_rovernum = tmceiling_rovernum; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; // Ugly hack?!?! As long as just ceilingz is the lowest, // you'll still get crushed, right? @@ -2752,19 +2721,7 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved) { - size_t old_sectornum = (thing->eflags & MFE_VERTICALFLIP) ? oldceil_sectornum : oldfloor_sectornum; - size_t old_rovernum = (thing->eflags & MFE_VERTICALFLIP) ? oldceil_rovernum : oldfloor_rovernum; - // Find FOF referenced by floorz - if (old_sectornum) - { - size_t rovernum = 0; - for (rover = sectors[old_sectornum].ffloors; rover; rover = rover->next) - { - if (rovernum == old_rovernum) - break; - rovernum++; - } - } + rover = (thing->eflags & MFE_VERTICALFLIP) ? oldceilingrover : oldfloorrover; // Match the Thing's old floorz to an FOF and check for FF_EXISTS // If ~FF_EXISTS, don't set mobj Z. diff --git a/src/p_mobj.h b/src/p_mobj.h index 3a83a0f58..90394c70d 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -282,10 +282,8 @@ typedef struct mobj_s // The closest interval over all contacted sectors (or things). fixed_t floorz; // Nearest floor below. fixed_t ceilingz; // Nearest ceiling above. - size_t floor_sectornum; // FOF referred by floorz - size_t floor_rovernum; // FOF referred by floorz - size_t ceiling_sectornum; // FOF referred by ceilingz - size_t ceiling_rovernum; // FOF referred by ceilingz + struct ffloor_s *floorrover; // FOF referred by floorz + struct ffloor_s *ceilingrover; // FOF referred by ceilingz // For movement checking. fixed_t radius; diff --git a/src/p_saveg.c b/src/p_saveg.c index 33dfd1424..d0ca0a873 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1192,10 +1192,13 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->z); // Force this so 3dfloor problems don't arise. WRITEFIXED(save_p, mobj->floorz); WRITEFIXED(save_p, mobj->ceilingz); - WRITEUINT32(save_p, (UINT32)mobj->floor_sectornum); - WRITEUINT32(save_p, (UINT32)mobj->floor_rovernum); - WRITEUINT32(save_p, (UINT32)mobj->ceiling_sectornum); - WRITEUINT32(save_p, (UINT32)mobj->ceiling_rovernum); + + // \todo netsync for floorrover + + // WRITEUINT32(save_p, (UINT32)mobj->floor_sectornum); + // WRITEUINT32(save_p, (UINT32)mobj->floor_rovernum); + // WRITEUINT32(save_p, (UINT32)mobj->ceiling_sectornum); + // WRITEUINT32(save_p, (UINT32)mobj->ceiling_rovernum); if (diff & MD_SPAWNPOINT) { @@ -1993,7 +1996,7 @@ static void LoadMobjThinker(actionf_p1 thinker) UINT16 diff2; INT32 i; fixed_t z, floorz, ceilingz; - size_t floor_sectornum, floor_rovernum, ceiling_sectornum, ceiling_rovernum; + //size_t floor_sectornum, floor_rovernum, ceiling_sectornum, ceiling_rovernum; diff = READUINT32(save_p); if (diff & MD_MORE) @@ -2006,10 +2009,26 @@ static void LoadMobjThinker(actionf_p1 thinker) z = READFIXED(save_p); // Force this so 3dfloor problems don't arise. floorz = READFIXED(save_p); ceilingz = READFIXED(save_p); - floor_sectornum = (size_t)READUINT32(save_p); - floor_rovernum = (size_t)READUINT32(save_p); - ceiling_sectornum = (size_t)READUINT32(save_p); - ceiling_rovernum = (size_t)READUINT32(save_p); + + // \todo netsync for floorrover +#if 0 + // Find FOF referenced by floorz + if (old_sectornum) + { + size_t rovernum = 0; + for (rover = sectors[old_sectornum].ffloors; rover; rover = rover->next) + { + if (rovernum == old_rovernum) + break; + rovernum++; + } + } +#endif + + // floor_sectornum = (size_t)READUINT32(save_p); + // floor_rovernum = (size_t)READUINT32(save_p); + // ceiling_sectornum = (size_t)READUINT32(save_p); + // ceiling_rovernum = (size_t)READUINT32(save_p); if (diff & MD_SPAWNPOINT) { @@ -2035,10 +2054,13 @@ static void LoadMobjThinker(actionf_p1 thinker) mobj->z = z; mobj->floorz = floorz; mobj->ceilingz = ceilingz; - mobj->floor_sectornum = floor_sectornum; - mobj->floor_rovernum = floor_rovernum; - mobj->ceiling_sectornum = ceiling_sectornum; - mobj->ceiling_rovernum = ceiling_rovernum; + + // \todo netsync for floorrover + + // mobj->floor_sectornum = floor_sectornum; + // mobj->floor_rovernum = floor_rovernum; + // mobj->ceiling_sectornum = ceiling_sectornum; + // mobj->ceiling_rovernum = ceiling_rovernum; if (diff & MD_TYPE) mobj->type = READUINT32(save_p); From dd35871699cef6f77d05435c1aecdb2ae594f92f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 23:48:14 -0400 Subject: [PATCH 156/573] Savegame netsync for mobj->floorrover and ceilingrrover --- src/p_saveg.c | 100 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 27 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index d0ca0a873..4c9e17b4f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -972,11 +972,13 @@ typedef enum MD2_EXTVAL1 = 1<<5, MD2_EXTVAL2 = 1<<6, MD2_HNEXT = 1<<7, -#ifdef ESLOPE MD2_HPREV = 1<<8, - MD2_SLOPE = 1<<9 + MD2_FLOORROVER = 1<<9, +#ifdef ESLOPE + MD2_CEILINGROVER = 1<<10, + MD2_SLOPE = 1<<11 #else - MD2_HPREV = 1<<8 + MD2_CEILINGROVER = 1<<10 #endif } mobj_diff2_t; @@ -1170,6 +1172,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_HNEXT; if (mobj->hprev) diff2 |= MD2_HPREV; + if (mobj->floorrover) + diff2 |= MD2_FLOORROVER; + if (mobj->ceilingrover) + diff2 |= MD2_CEILINGROVER; #ifdef ESLOPE if (mobj->standingslope) diff2 |= MD2_SLOPE; @@ -1193,12 +1199,45 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->floorz); WRITEFIXED(save_p, mobj->ceilingz); - // \todo netsync for floorrover + if (diff & MD2_FLOORROVER) + { + ffloor_t *rover; + size_t i = 0; + INT32 roverindex = -1; - // WRITEUINT32(save_p, (UINT32)mobj->floor_sectornum); - // WRITEUINT32(save_p, (UINT32)mobj->floor_rovernum); - // WRITEUINT32(save_p, (UINT32)mobj->ceiling_sectornum); - // WRITEUINT32(save_p, (UINT32)mobj->ceiling_rovernum); + for (rover = mobj->floorrover->target->ffloors; rover; rover = rover->next) + { + if (rover == mobj->floorrover) + { + roverindex = i; + break; + } + i++; + } + + WRITEUINT32(save_p, (UINT32)(mobj->floorrover->target - sectors)); + WRITEUINT32(save_p, (UINT32)roverindex); + } + + if (diff & MD2_CEILINGROVER) + { + ffloor_t *rover; + size_t i = 0; + INT32 roverindex = -1; + + for (rover = mobj->ceilingrover->target->ffloors; rover; rover = rover->next) + { + if (rover == mobj->ceilingrover) + { + roverindex = i; + break; + } + i++; + } + + WRITEUINT32(save_p, mobj->ceilingrover->target - sectors); + WRITEUINT32(save_p, roverindex); + } if (diff & MD_SPAWNPOINT) { @@ -1996,7 +2035,7 @@ static void LoadMobjThinker(actionf_p1 thinker) UINT16 diff2; INT32 i; fixed_t z, floorz, ceilingz; - //size_t floor_sectornum, floor_rovernum, ceiling_sectornum, ceiling_rovernum; + ffloor_t *floorrover = NULL, *ceilingrover = NULL; diff = READUINT32(save_p); if (diff & MD_MORE) @@ -2010,25 +2049,37 @@ static void LoadMobjThinker(actionf_p1 thinker) floorz = READFIXED(save_p); ceilingz = READFIXED(save_p); - // \todo netsync for floorrover -#if 0 - // Find FOF referenced by floorz - if (old_sectornum) + if (diff2 & MD2_FLOORROVER) { + size_t floor_sectornum = (size_t)READUINT32(save_p); + size_t floor_rovernum = (size_t)READUINT32(save_p); + ffloor_t *rover = NULL; size_t rovernum = 0; - for (rover = sectors[old_sectornum].ffloors; rover; rover = rover->next) + + for (rover = sectors[floor_sectornum].ffloors; rover; rover = rover->next) { - if (rovernum == old_rovernum) + if (rovernum == floor_rovernum) break; rovernum++; } + floorrover = rover; } -#endif - // floor_sectornum = (size_t)READUINT32(save_p); - // floor_rovernum = (size_t)READUINT32(save_p); - // ceiling_sectornum = (size_t)READUINT32(save_p); - // ceiling_rovernum = (size_t)READUINT32(save_p); + if (diff2 & MD2_CEILINGROVER) + { + size_t ceiling_sectornum = (size_t)READUINT32(save_p); + size_t ceiling_rovernum = (size_t)READUINT32(save_p); + ffloor_t *rover = NULL; + size_t rovernum = 0; + + for (rover = sectors[ceiling_sectornum].ffloors; rover; rover = rover->next) + { + if (rovernum == ceiling_rovernum) + break; + rovernum++; + } + ceilingrover = rover; + } if (diff & MD_SPAWNPOINT) { @@ -2054,13 +2105,8 @@ static void LoadMobjThinker(actionf_p1 thinker) mobj->z = z; mobj->floorz = floorz; mobj->ceilingz = ceilingz; - - // \todo netsync for floorrover - - // mobj->floor_sectornum = floor_sectornum; - // mobj->floor_rovernum = floor_rovernum; - // mobj->ceiling_sectornum = ceiling_sectornum; - // mobj->ceiling_rovernum = ceiling_rovernum; + mobj->floorrover = floorrover; + mobj->ceilingrover = ceilingrover; if (diff & MD_TYPE) mobj->type = READUINT32(save_p); From 5136293f62ecf8d8b2532648b8858b217ba9f3e4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 23:52:36 -0400 Subject: [PATCH 157/573] Store sectornum/ffloornum as UINT32, not INT32 --- src/p_saveg.c | 8 ++++---- src/p_spec.c | 4 ++-- src/p_spec.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index a3790d6f0..24d0d699b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1587,8 +1587,8 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) { const fade_t *ht = (const void *)th; WRITEUINT8(save_p, type); - WRITEINT32(save_p, ht->sectornum); - WRITEINT32(save_p, ht->ffloornum); + WRITEUINT32(save_p, ht->sectornum); + WRITEUINT32(save_p, ht->ffloornum); WRITEINT32(save_p, ht->alpha); WRITEINT16(save_p, ht->destvalue); WRITEINT16(save_p, ht->destlightlevel); @@ -2599,8 +2599,8 @@ static inline void LoadFadeThinker(actionf_p1 thinker) { fade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; - ht->sectornum = READINT32(save_p); - ht->ffloornum = READINT32(save_p); + ht->sectornum = READUINT32(save_p); + ht->ffloornum = READUINT32(save_p); ht->alpha = READINT32(save_p); ht->destvalue = READINT16(save_p); ht->destlightlevel = READINT16(save_p); diff --git a/src/p_spec.c b/src/p_spec.c index 0346bdd3d..4cd9e5cb8 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7729,8 +7729,8 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor d->thinker.function.acp1 = (actionf_p1)T_Fade; d->rover = rover; - d->sectornum = (INT32)sectornum; - d->ffloornum = (INT32)ffloornum; + d->sectornum = (UINT32)sectornum; + d->ffloornum = (UINT32)ffloornum; // If fading an invisible FOF whose render flags we did not yet set, // initialize its alpha to 1 diff --git a/src/p_spec.h b/src/p_spec.h index 9e602b192..b4577ff88 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -466,8 +466,8 @@ typedef struct { thinker_t thinker; ///< Thinker structure for effect. ffloor_t *rover; ///< Target ffloor - INT32 sectornum; ///< Number of ffloor target sector - INT32 ffloornum; ///< Number of ffloor of target sector + UINT32 sectornum; ///< Number of ffloor target sector + UINT32 ffloornum; ///< Number of ffloor of target sector INT32 alpha; ///< Internal alpha counter INT16 destvalue; ///< Transparency value to fade to INT16 destlightlevel; ///< Light level to fade to From 03d1baf422434b87f7e1c842f89f9fa3ab7236fa Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:07:22 -0400 Subject: [PATCH 158/573] Savegame floorrover fixes --- src/p_saveg.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 4c9e17b4f..c73df0cc9 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1199,11 +1199,11 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->floorz); WRITEFIXED(save_p, mobj->ceilingz); - if (diff & MD2_FLOORROVER) + if (diff2 & MD2_FLOORROVER) { ffloor_t *rover; size_t i = 0; - INT32 roverindex = -1; + UINT32 roverindex = 0; for (rover = mobj->floorrover->target->ffloors; rover; rover = rover->next) { @@ -1216,14 +1216,14 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) } WRITEUINT32(save_p, (UINT32)(mobj->floorrover->target - sectors)); - WRITEUINT32(save_p, (UINT32)roverindex); + WRITEUINT32(save_p, rover ? roverindex : i); // store max index to denote invalid ffloor ref } - if (diff & MD2_CEILINGROVER) + if (diff2 & MD2_CEILINGROVER) { ffloor_t *rover; size_t i = 0; - INT32 roverindex = -1; + UINT32 roverindex = 0; for (rover = mobj->ceilingrover->target->ffloors; rover; rover = rover->next) { @@ -1235,8 +1235,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) i++; } - WRITEUINT32(save_p, mobj->ceilingrover->target - sectors); - WRITEUINT32(save_p, roverindex); + WRITEUINT32(save_p, (UINT32)(mobj->ceilingrover->target - sectors)); + WRITEUINT32(save_p, rover ? roverindex : i); // store max index to denote invalid ffloor ref } if (diff & MD_SPAWNPOINT) From 832f891cbbacb5f8c1dbb96436753c7472cdce86 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:13:32 -0400 Subject: [PATCH 159/573] Remove rovernum increment from P_CheckPosition because unused --- src/p_map.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 4bf06fa4b..0726084d5 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1749,7 +1749,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) if (newsubsec->sector->ffloors) { ffloor_t *rover; - size_t rovernum = 0; fixed_t delta1, delta2; INT32 thingtop = thing->z + thing->height; @@ -1758,10 +1757,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) fixed_t topheight, bottomheight; if (!(rover->flags & FF_EXISTS)) - { - rovernum++; continue; - } topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL); bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL); @@ -1804,7 +1800,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) } } } - rovernum++; continue; } @@ -1815,10 +1810,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) else if (!((rover->flags & FF_BLOCKPLAYER && thing->player) || (rover->flags & FF_BLOCKOTHERS && !thing->player) || rover->flags & FF_QUICKSAND)) - { - rovernum++; continue; - } if (rover->flags & FF_QUICKSAND) { @@ -1833,7 +1825,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) } } // Quicksand blocks never change heights otherwise. - rovernum++; continue; } @@ -1861,7 +1852,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) tmceilingslope = *rover->b_slope; #endif } - rovernum++; } } From 943dc9412d3e3f39ceb906f379786ac285c533da Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:20:51 -0400 Subject: [PATCH 160/573] Initialize floorrover and ceilingrover on SpawnMobj --- src/p_mobj.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index 7b588645b..d433561ae 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8627,6 +8627,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) #endif mobj->subsector->sector->ceilingheight; + mobj->floorrover = NULL; + mobj->ceilingrover = NULL; + // Tells MobjCheckWater that the water height was not set. mobj->watertop = INT32_MAX; @@ -8890,6 +8893,9 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype #endif mobj->subsector->sector->ceilingheight; + mobj->floorrover = NULL; + mobj->ceilingrover = NULL; + mobj->z = z; mobj->momz = mobjinfo[type].speed; From 0d88f31bbd22b8893503f7d6719bc72923947970 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:23:23 -0400 Subject: [PATCH 161/573] Add floorrover and ceilingrover to precipmobj_t --- src/p_mobj.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_mobj.h b/src/p_mobj.h index 90394c70d..630600b54 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -400,6 +400,8 @@ typedef struct precipmobj_s // The closest interval over all contacted sectors (or things). fixed_t floorz; // Nearest floor below. fixed_t ceilingz; // Nearest ceiling above. + struct ffloor_s *floorrover; // FOF referred by floorz + struct ffloor_s *ceilingrover; // FOF referred by ceilingz // For movement checking. fixed_t radius; // Fixed at 2*FRACUNIT From a6f959ba21c9f599b4823d0adce9bc9d7c355b65 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:35:40 -0400 Subject: [PATCH 162/573] Set mobj->floorrover and ceilingrover in appropriate places --- src/lua_mobjlib.c | 6 ++++++ src/p_local.h | 1 + src/p_map.c | 10 ++++++++++ src/p_mobj.c | 4 ++++ src/p_polyobj.c | 2 ++ 5 files changed, 23 insertions(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 1583bd3c4..6efbeff8e 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -396,6 +396,8 @@ static int mobj_set(lua_State *L) P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; P_SetTarget(&tmthing, ptmthing); break; } @@ -439,6 +441,8 @@ static int mobj_set(lua_State *L) P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; P_SetTarget(&tmthing, ptmthing); break; } @@ -451,6 +455,8 @@ static int mobj_set(lua_State *L) P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; P_SetTarget(&tmthing, ptmthing); break; } diff --git a/src/p_local.h b/src/p_local.h index 2676fb030..b98eeae1c 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -326,6 +326,7 @@ void P_InternalFlickyHop(mobj_t *actor, fixed_t momz, fixed_t momh, angle_t angl extern boolean floatok; extern fixed_t tmfloorz; extern fixed_t tmceilingz; +extern ffloor_t *tmfloorrover, *tmceilingrover; extern mobj_t *tmfloorthing, *tmhitthing, *tmthing; extern camera_t *mapcampointer; extern fixed_t tmx; diff --git a/src/p_map.c b/src/p_map.c index 0726084d5..648bb2bcc 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -102,6 +102,8 @@ boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; return true; } @@ -2485,6 +2487,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep) { thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; + thing->ceilingrover = tmceilingrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #ifdef ESLOPE @@ -2492,6 +2495,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (tmceilingslope && tmceilingz < thingtop && thingtop - tmceilingz <= maxstep) { thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; + thing->ceilingrover = tmceilingrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #endif @@ -2499,6 +2503,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep) { thing->z = thing->floorz = tmfloorz; + thing->floorrover = tmfloorrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #ifdef ESLOPE @@ -2506,6 +2511,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (tmfloorslope && tmfloorz > thing->z && tmfloorz - thing->z <= maxstep) { thing->z = thing->floorz = tmfloorz; + thing->floorrover = tmfloorrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #endif @@ -2577,6 +2583,8 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; #ifdef ESLOPE if (!(thing->flags & MF_NOCLIPHEIGHT)) @@ -2657,6 +2665,8 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; thing->x = x; thing->y = y; diff --git a/src/p_mobj.c b/src/p_mobj.c index d433561ae..7c9baf0f1 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8027,6 +8027,8 @@ void P_MobjThinker(mobj_t *mobj) return; mobj->floorz = tmfloorz; mobj->ceilingz = tmceilingz; + mobj->floorrover = tmfloorrover; + mobj->ceilingrover = tmceilingrover; if ((mobj->eflags & MFE_UNDERWATER) && mobj->health > 0) { @@ -8545,6 +8547,8 @@ void P_SceneryThinker(mobj_t *mobj) return; mobj->floorz = tmfloorz; mobj->ceilingz = tmceilingz; + mobj->floorrover = tmfloorrover; + mobj->ceilingrover = tmceilingrover; } else { diff --git a/src/p_polyobj.c b/src/p_polyobj.c index fd3237c9d..23e799d06 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -985,6 +985,8 @@ static void Polyobj_pushThing(polyobj_t *po, line_t *line, mobj_t *mo) P_CheckPosition(mo, mo->x + momx, mo->y + momy); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; } } From 002f1bad8fe8741590b362f62a3a092ce77e0e49 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 12:01:50 -0400 Subject: [PATCH 163/573] Savegame netsync for sector colormaps; add spawn_midmap and co for comparison --- src/p_saveg.c | 74 ++++++++++++++++++++++++++++++++++++++------------- src/p_setup.c | 5 ++-- src/p_spec.c | 2 +- src/r_defs.h | 1 + 4 files changed, 60 insertions(+), 22 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 22d43f358..1c9589e8f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -487,10 +487,16 @@ static void P_NetUnArchivePlayers(void) #define SD_FYOFFS 0x02 #define SD_CXOFFS 0x04 #define SD_CYOFFS 0x08 -#define SD_TAG 0x10 -#define SD_FLOORANG 0x20 -#define SD_CEILANG 0x40 -#define SD_TAGLIST 0x80 +#define SD_FLOORANG 0x10 +#define SD_CEILANG 0x20 +#define SD_TAG 0x40 +#define SD_DIFF3 0x80 + +// diff3 flags +#define SD_TAGLIST 0x01 +#define SD_BOTTOMMAP 0x02 +#define SD_MIDMAP 0x04 +#define SD_TOPMAP 0x08 #define LD_FLAG 0x01 #define LD_SPECIAL 0x02 @@ -523,7 +529,7 @@ static void P_NetArchiveWorld(void) mapsidedef_t *msd; maplinedef_t *mld; const sector_t *ss = sectors; - UINT8 diff, diff2; + UINT8 diff, diff2, diff3; WRITEUINT32(save_p, ARCHIVEBLOCK_WORLD); put = save_p; @@ -550,7 +556,7 @@ static void P_NetArchiveWorld(void) for (i = 0; i < numsectors; i++, ss++, ms++) { - diff = diff2 = 0; + diff = diff2 = diff3 = 0; if (ss->floorheight != SHORT(ms->floorheight)<ceilingheight != SHORT(ms->ceilingheight)<tag != SHORT(ms->tag)) diff2 |= SD_TAG; if (ss->nexttag != ss->spawn_nexttag || ss->firsttag != ss->spawn_firsttag) - diff2 |= SD_TAGLIST; + diff3 |= SD_TAGLIST; + if (ss->bottommap != ss->spawn_bottommap) + diff3 |= SD_BOTTOMMAP; + if (ss->midmap != ss->spawn_midmap) + diff3 |= SD_MIDMAP; + if (ss->topmap != ss->spawn_topmap) + diff3 |= SD_TOPMAP; // Check if any of the sector's FOFs differ from how they spawned if (ss->ffloors) @@ -601,6 +613,9 @@ static void P_NetArchiveWorld(void) } } + if (diff3) + diff2 |= SD_DIFF3; + if (diff2) diff |= SD_DIFF2; @@ -612,6 +627,8 @@ static void P_NetArchiveWorld(void) WRITEUINT8(put, diff); if (diff & SD_DIFF2) WRITEUINT8(put, diff2); + if (diff2 & SD_DIFF3) + WRITEUINT8(put, diff3); if (diff & SD_FLOORHT) WRITEFIXED(put, ss->floorheight); if (diff & SD_CEILHT) @@ -632,17 +649,23 @@ static void P_NetArchiveWorld(void) WRITEFIXED(put, ss->ceiling_xoffs); if (diff2 & SD_CYOFFS) WRITEFIXED(put, ss->ceiling_yoffs); - if (diff2 & SD_TAG) // save only the tag - WRITEINT16(put, ss->tag); if (diff2 & SD_FLOORANG) WRITEANGLE(put, ss->floorpic_angle); if (diff2 & SD_CEILANG) WRITEANGLE(put, ss->ceilingpic_angle); - if (diff2 & SD_TAGLIST) // save both firsttag and nexttag + if (diff2 & SD_TAG) // save only the tag + WRITEINT16(put, ss->tag); + if (diff3 & SD_TAGLIST) // save both firsttag and nexttag { // either of these could be changed even if tag isn't WRITEINT32(put, ss->firsttag); WRITEINT32(put, ss->nexttag); } + if (diff3 & SD_BOTTOMMAP) + WRITEINT32(put, ss->bottommap); + if (diff3 & SD_MIDMAP) + WRITEINT32(put, ss->midmap); + if (diff3 & SD_TOPMAP) + WRITEINT32(put, ss->topmap); // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed @@ -680,7 +703,7 @@ static void P_NetArchiveWorld(void) // do lines for (i = 0; i < numlines; i++, mld++, li++) { - diff = diff2 = 0; + diff = diff2 = diff3 = 0; if (li->special != SHORT(mld->special)) diff |= LD_SPECIAL; @@ -772,7 +795,7 @@ static void P_NetUnArchiveWorld(void) line_t *li; side_t *si; UINT8 *get; - UINT8 diff, diff2; + UINT8 diff, diff2, diff3; if (READUINT32(save_p) != ARCHIVEBLOCK_WORLD) I_Error("Bad $$$.sav at archive block World"); @@ -794,6 +817,10 @@ static void P_NetUnArchiveWorld(void) diff2 = READUINT8(get); else diff2 = 0; + if (diff2 & SD_DIFF3) + diff3 = READUINT8(get); + else + diff3 = 0; if (diff & SD_FLOORHT) sectors[i].floorheight = READFIXED(get); @@ -822,17 +849,23 @@ static void P_NetUnArchiveWorld(void) sectors[i].ceiling_xoffs = READFIXED(get); if (diff2 & SD_CYOFFS) sectors[i].ceiling_yoffs = READFIXED(get); - if (diff2 & SD_TAG) - sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag - if (diff2 & SD_TAGLIST) - { - sectors[i].firsttag = READINT32(get); - sectors[i].nexttag = READINT32(get); - } if (diff2 & SD_FLOORANG) sectors[i].floorpic_angle = READANGLE(get); if (diff2 & SD_CEILANG) sectors[i].ceilingpic_angle = READANGLE(get); + if (diff2 & SD_TAG) + sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag + if (diff3 & SD_TAGLIST) + { + sectors[i].firsttag = READINT32(get); + sectors[i].nexttag = READINT32(get); + } + if (diff3 & SD_BOTTOMMAP) + sectors[i].bottommap = READINT32(get); + if (diff3 & SD_MIDMAP) + sectors[i].midmap = READINT32(get); + if (diff3 & SD_TOPMAP) + sectors[i].topmap = READINT32(get); if (diff & SD_FFLOORS) { @@ -891,6 +924,9 @@ static void P_NetUnArchiveWorld(void) diff2 = READUINT8(get); else diff2 = 0; + + diff3 = 0; + if (diff & LD_FLAG) li->flags = READINT16(get); if (diff & LD_SPECIAL) diff --git a/src/p_setup.c b/src/p_setup.c index 92a618b98..50b2e8eda 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -719,6 +719,7 @@ static void P_LoadRawSectors(UINT8 *data, size_t i) ss->floorpic_angle = ss->ceilingpic_angle = 0; ss->spawn_flrpic_angle = ss->spawn_ceilpic_angle = 0; ss->bottommap = ss->midmap = ss->topmap = -1; + ss->spawn_bottommap = ss->spawn_midmap = ss->spawn_topmap = -1; ss->gravity = NULL; ss->cullheight = NULL; ss->verticalflip = false; @@ -1477,7 +1478,7 @@ static void P_LoadRawSideDefs2(void *data) { if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#') { - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, + sec->midmap = sec->spawn_midmap = R_CreateColormap(msd->toptexture, msd->midtexture, msd->bottomtexture); sd->toptexture = sd->bottomtexture = 0; } @@ -1507,7 +1508,7 @@ static void P_LoadRawSideDefs2(void *data) { char *col; - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, + sec->midmap = sec->spawn_midmap = R_CreateColormap(msd->toptexture, msd->midtexture, msd->bottomtexture); sd->toptexture = sd->bottomtexture = 0; #define HEX2INT(x) (x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) diff --git a/src/p_spec.c b/src/p_spec.c index 87a0bae9c..40be3c7fb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6769,7 +6769,7 @@ void P_SpawnSpecials(INT32 fromnetsave) case 606: // HACK! Copy colormaps. Just plain colormaps. for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - sectors[s].midmap = lines[i].frontsector->midmap; + sectors[s].midmap = sectors[s].spawn_midmap = lines[i].frontsector->midmap; break; #ifdef ESLOPE // Slope copy specials. Handled here for sanity. diff --git a/src/r_defs.h b/src/r_defs.h index 7c8f2a73f..f219f0f9e 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -385,6 +385,7 @@ typedef struct sector_s // these are saved for netgames, so do not let Lua touch these! INT32 spawn_nexttag, spawn_firsttag; // the actual nexttag/firsttag values may differ if the sector's tag was changed + INT32 spawn_bottommap, spawn_midmap, spawn_topmap; // offsets sector spawned with (via linedef type 7) fixed_t spawn_flr_xoffs, spawn_flr_yoffs; From e171e565ceb794ac50109f8687b77a5609c1c5fb Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 09:03:58 -0400 Subject: [PATCH 164/573] Remove bottommap and topmap from savegame because unused --- src/p_saveg.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 1c9589e8f..42757faf2 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -494,9 +494,7 @@ static void P_NetUnArchivePlayers(void) // diff3 flags #define SD_TAGLIST 0x01 -#define SD_BOTTOMMAP 0x02 -#define SD_MIDMAP 0x04 -#define SD_TOPMAP 0x08 +#define SD_MIDMAP 0x02 #define LD_FLAG 0x01 #define LD_SPECIAL 0x02 @@ -591,12 +589,8 @@ static void P_NetArchiveWorld(void) diff2 |= SD_TAG; if (ss->nexttag != ss->spawn_nexttag || ss->firsttag != ss->spawn_firsttag) diff3 |= SD_TAGLIST; - if (ss->bottommap != ss->spawn_bottommap) - diff3 |= SD_BOTTOMMAP; if (ss->midmap != ss->spawn_midmap) diff3 |= SD_MIDMAP; - if (ss->topmap != ss->spawn_topmap) - diff3 |= SD_TOPMAP; // Check if any of the sector's FOFs differ from how they spawned if (ss->ffloors) @@ -660,12 +654,8 @@ static void P_NetArchiveWorld(void) WRITEINT32(put, ss->firsttag); WRITEINT32(put, ss->nexttag); } - if (diff3 & SD_BOTTOMMAP) - WRITEINT32(put, ss->bottommap); if (diff3 & SD_MIDMAP) WRITEINT32(put, ss->midmap); - if (diff3 & SD_TOPMAP) - WRITEINT32(put, ss->topmap); // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed @@ -860,12 +850,8 @@ static void P_NetUnArchiveWorld(void) sectors[i].firsttag = READINT32(get); sectors[i].nexttag = READINT32(get); } - if (diff3 & SD_BOTTOMMAP) - sectors[i].bottommap = READINT32(get); if (diff3 & SD_MIDMAP) sectors[i].midmap = READINT32(get); - if (diff3 & SD_TOPMAP) - sectors[i].topmap = READINT32(get); if (diff & SD_FFLOORS) { From b8da218b6113255f6788953b4e5345afdcb7aabd Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 09:48:24 -0400 Subject: [PATCH 165/573] Add relative destvalue calc (ML_EFFECT4) * rover->alpha init fixes with invisible FOFs --- src/p_spec.c | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 4cd9e5cb8..713291e15 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -108,7 +108,7 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, boolean ticbased, INT32 *timer, UINT32 interval, boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha); static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, - INT16 destvalue, INT16 speed, boolean ticbased, + INT16 destvalue, INT16 speed, boolean ticbased, boolean relative, boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); @@ -3357,6 +3357,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_AddFakeFloorFader(rover, secnum, j, destvalue, speed, (line->flags & ML_EFFECT5), // tic-based logic + (line->flags & ML_EFFECT4), // Relative destvalue !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT !(line->flags & ML_EFFECT2), // do not handle lighting @@ -3365,10 +3366,20 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) else { + // If fading an invisible FOF whose render flags we did not yet set, + // initialize its alpha to 1 + if (!(line->flags & ML_NOCLIMB) && // do translucent + (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE + !(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES) && + !(rover->flags & FF_RENDERALL)) + rover->alpha = 1; + P_RemoveFakeFloorFader(rover); P_FadeFakeFloor(rover, - destvalue, 0, // set alpha immediately - false, NULL, 0, // tic-based logic + max(1, min(256, (line->flags & ML_EFFECT4) ? rover->alpha + destvalue : destvalue)), + 0, // set alpha immediately + false, NULL, 0, // tic-based logic !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT !(line->flags & ML_EFFECT2), // do not handle lighting @@ -7710,6 +7721,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, bo * \param destvalue transparency value to fade to * \param speed speed to fade by * \param ticbased tic-based logic, speed = duration + * \param relative Destvalue is relative to rover->alpha * \param doexists handle FF_EXISTS * \param dotranslucent handle FF_TRANSLUCENT * \param dolighting fade FOF light @@ -7718,20 +7730,9 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, bo * \param exactalpha use exact alpha values (opengl) */ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, - INT16 destvalue, INT16 speed, boolean ticbased, + INT16 destvalue, INT16 speed, boolean ticbased, boolean relative, boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha) { - // already equal, nothing to do - if (rover->alpha == max(1, min(256, destvalue))) - return; - - fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); - - d->thinker.function.acp1 = (actionf_p1)T_Fade; - d->rover = rover; - d->sectornum = (UINT32)sectornum; - d->ffloornum = (UINT32)ffloornum; - // If fading an invisible FOF whose render flags we did not yet set, // initialize its alpha to 1 if (dotranslucent && @@ -7741,8 +7742,19 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor !(rover->flags & FF_RENDERALL)) rover->alpha = 1; + // already equal, nothing to do + if (rover->alpha == max(1, min(256, relative ? rover->alpha + destvalue : destvalue))) + return; + + fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); + + d->thinker.function.acp1 = (actionf_p1)T_Fade; + d->rover = rover; + d->sectornum = (UINT32)sectornum; + d->ffloornum = (UINT32)ffloornum; + d->alpha = rover->alpha; - d->destvalue = max(1, min(256, destvalue)); // ffloor->alpha is 1-256 + d->destvalue = max(1, min(256, relative ? rover->alpha + destvalue : destvalue)); // ffloor->alpha is 1-256 if (ticbased) { From 02a94dc9415948be143b5509cbefa10dde56d4e5 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 09:49:52 -0400 Subject: [PATCH 166/573] Add distance-based params and make default (ML_DONTPEGBOTTOM to use back offsets) --- src/p_spec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 713291e15..0afb267df 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3322,8 +3322,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 452: // Fade FOF { - INT16 destvalue = (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS); - INT16 speed = (INT16)(sides[line->sidenum[1]].rowoffset>>FRACBITS); + INT16 destvalue = (line->flags & ML_DONTPEGBOTTOM) && line->sidenum[1] != 0xffff ? + (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(line->dx>>FRACBITS); + INT16 speed = (line->flags & ML_DONTPEGBOTTOM) && line->sidenum[1] != 0xffff ? + (INT16)(sides[line->sidenum[1]].rowoffset>>FRACBITS) : (INT16)(abs(line->dy)>>FRACBITS); INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in @@ -3355,7 +3357,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (speed > 0) P_AddFakeFloorFader(rover, secnum, j, - destvalue, speed, + destvalue, + speed, (line->flags & ML_EFFECT5), // tic-based logic (line->flags & ML_EFFECT4), // Relative destvalue !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS From da5a7a013d584cd76b5ff9465a86b13d401789c3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 10:09:02 -0400 Subject: [PATCH 167/573] Add type 452 Set FOF Alpha * Fade FOF moved to type 453 * Stop Fade FOF moved to type 454 --- src/p_spec.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 6 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 0afb267df..fe742457e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3320,7 +3320,63 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; } - case 452: // Fade FOF + case 452: // Set FOF alpha + { + INT16 destvalue = (line->flags & ML_DONTPEGBOTTOM) && line->sidenum[1] != 0xffff ? + (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(line->dx>>FRACBITS); + INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); + INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); + sector_t *sec; // Sector that the FOF is visible in + ffloor_t *rover; // FOF that we are going to operate + + for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + { + sec = sectors + secnum; + + if (!sec->ffloors) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 452 Executor: Target sector #%d has no FOFs.\n", secnum); + return; + } + + for (rover = sec->ffloors; rover; rover = rover->next) + { + if (rover->master->frontsector->tag == foftag) + break; + } + + if (!rover) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 452 Executor: Can't find a FOF control sector with tag %d\n", foftag); + return; + } + + // If fading an invisible FOF whose render flags we did not yet set, + // initialize its alpha to 1 + // for relative alpha calc + if (!(line->flags & ML_NOCLIMB) && // do translucent + (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE + !(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES) && + !(rover->flags & FF_RENDERALL)) + rover->alpha = 1; + + P_RemoveFakeFloorFader(rover); + P_FadeFakeFloor(rover, + max(1, min(256, (line->flags & ML_EFFECT4) ? rover->alpha + destvalue : destvalue)), + 0, // set alpha immediately + false, NULL, 0, // tic-based logic + false, // do not handle FF_EXISTS + true, // handle FF_TRANSLUCENT + false, // do not handle lighting + false, // do not handle collision + false, // do not do ghost fade (no collision during fade) + true); // use exact alpha values (for opengl) + } + break; + } + + case 453: // Fade FOF { INT16 destvalue = (line->flags & ML_DONTPEGBOTTOM) && line->sidenum[1] != 0xffff ? (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(line->dx>>FRACBITS); @@ -3338,7 +3394,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (!sec->ffloors) { - CONS_Debug(DBG_GAMELOGIC, "Line type 452 Executor: Target sector #%d has no FOFs.\n", secnum); + CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Target sector #%d has no FOFs.\n", secnum); return; } @@ -3351,7 +3407,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (!rover) { - CONS_Debug(DBG_GAMELOGIC, "Line type 452 Executor: Can't find a FOF control sector with tag %d\n", foftag); + CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Can't find a FOF control sector with tag %d\n", foftag); return; } @@ -3371,6 +3427,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { // If fading an invisible FOF whose render flags we did not yet set, // initialize its alpha to 1 + // for relative alpha calc if (!(line->flags & ML_NOCLIMB) && // do translucent (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE !(rover->spawnflags & FF_RENDERSIDES) && @@ -3394,7 +3451,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; } - case 453: // Stop fading FOF + case 454: // Stop fading FOF { INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); @@ -3407,7 +3464,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (!sec->ffloors) { - CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Target sector #%d has no FOFs.\n", secnum); + CONS_Debug(DBG_GAMELOGIC, "Line type 454 Executor: Target sector #%d has no FOFs.\n", secnum); return; } @@ -3419,7 +3476,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (!rover) { - CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Can't find a FOF control sector with tag %d\n", foftag); + CONS_Debug(DBG_GAMELOGIC, "Line type 454 Executor: Can't find a FOF control sector with tag %d\n", foftag); return; } From 8e75fe50db1333fdf0b7c7b02ce16eefe3e094be Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 10:11:27 -0400 Subject: [PATCH 168/573] Default to using back offset params if back linedef exists; else fallback to distance-based params --- src/p_spec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index fe742457e..f5915b4d6 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3322,8 +3322,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 452: // Set FOF alpha { - INT16 destvalue = (line->flags & ML_DONTPEGBOTTOM) && line->sidenum[1] != 0xffff ? - (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(line->dx>>FRACBITS); + INT16 destvalue = line->sidenum[1] != 0xffff ? + (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(P_AproxDistance(line->dx, line->dy)>>FRACBITS); INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in @@ -3378,9 +3378,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 453: // Fade FOF { - INT16 destvalue = (line->flags & ML_DONTPEGBOTTOM) && line->sidenum[1] != 0xffff ? + INT16 destvalue = line->sidenum[1] != 0xffff ? (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(line->dx>>FRACBITS); - INT16 speed = (line->flags & ML_DONTPEGBOTTOM) && line->sidenum[1] != 0xffff ? + INT16 speed = line->sidenum[1] != 0xffff ? (INT16)(sides[line->sidenum[1]].rowoffset>>FRACBITS) : (INT16)(abs(line->dy)>>FRACBITS); INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); From 148e3ff538061c8e20e5e657ea622ad9c86387bf Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 10:17:39 -0400 Subject: [PATCH 169/573] Use ML_NOCLIMB for FF_TRANSLUCENT handling in type 452 --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index f5915b4d6..f397f5b75 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3367,7 +3367,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) 0, // set alpha immediately false, NULL, 0, // tic-based logic false, // do not handle FF_EXISTS - true, // handle FF_TRANSLUCENT + !(line->flags & ML_NOCLIMB), // handle FF_TRANSLUCENT false, // do not handle lighting false, // do not handle collision false, // do not do ghost fade (no collision during fade) From 40ff43682971987413b56721d03b5bd8a2daba9a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 10 Sep 2018 15:49:21 +0100 Subject: [PATCH 170/573] Remove commented out stuff, now I've confirmed everything works fine without them --- src/p_setup.c | 1 - src/r_data.c | 191 -------------------------------------------------- src/r_data.h | 2 - 3 files changed, 194 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 58170e262..17a6797f4 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2673,7 +2673,6 @@ boolean P_SetupLevel(boolean skipprecip) P_CreateBlockMap(); // Graue 02-29-2004 P_LoadSideDefs2(lastloadedmaplumpnum + ML_SIDEDEFS); - //R_MakeColormaps(); P_LoadLineDefs2(); P_LoadSubsectors(lastloadedmaplumpnum + ML_SSECTORS); P_LoadNodes(lastloadedmaplumpnum + ML_NODES); diff --git a/src/r_data.c b/src/r_data.c index 2551a2946..f2c9b1466 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1038,9 +1038,6 @@ void R_ReInitColormaps(UINT16 num) static lumpnum_t foundcolormaps[MAXCOLORMAPS]; -//static char colormapFixingArray[MAXCOLORMAPS][3][9]; -//static size_t carrayindex; - // // R_ClearColormaps // @@ -1052,8 +1049,6 @@ void R_ClearColormaps(void) num_extra_colormaps = 0; - //carrayindex = 0; - for (i = 0; i < MAXCOLORMAPS; i++) foundcolormaps[i] = LUMPERROR; @@ -1194,10 +1189,6 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) if (num_extra_colormaps == MAXCOLORMAPS) I_Error("R_CreateColormap: Too many colormaps! the limit is %d\n", MAXCOLORMAPS); - //strncpy(colormapFixingArray[num_extra_colormaps][0], p1, 8); - //strncpy(colormapFixingArray[num_extra_colormaps][1], p2, 8); - //strncpy(colormapFixingArray[num_extra_colormaps][2], p3, 8); - num_extra_colormaps++; foundcolormaps[mapnum] = LUMPERROR; @@ -1286,188 +1277,6 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) return (INT32)mapnum; } -/* -void R_MakeColormaps(void) -{ - size_t i; - - carrayindex = num_extra_colormaps; - num_extra_colormaps = 0; - - for (i = 0; i < carrayindex; i++) - R_CreateColormap2(colormapFixingArray[i][0], colormapFixingArray[i][1], - colormapFixingArray[i][2]); -} - -void R_CreateColormap2(char *p1, char *p2, char *p3) -{ - double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; - double r, g, b, cbrightness; - double maskamt = 0, othermask = 0; - int mask, p, fog = 0; - size_t mapnum = num_extra_colormaps; - size_t i; - char *colormap_p; - UINT32 cr, cg, cb, maskcolor, fadecolor; - UINT32 fadestart = 0, fadeend = 31, fadedist = 31; - -#define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) - if (p1[0] == '#') - { - cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); - cmaskr = cr; - cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); - cmaskg = cg; - cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); - cmaskb = cb; - // Create a rough approximation of the color (a 16 bit color) - maskcolor = ((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11); - if (p1[7] >= 'a' && p1[7] <= 'z') - mask = (p1[7] - 'a'); - else if (p1[7] >= 'A' && p1[7] <= 'Z') - mask = (p1[7] - 'A'); - else - mask = 24; - - maskamt = (double)(mask/24.0l); - - othermask = 1 - maskamt; - maskamt /= 0xff; - cmaskr *= maskamt; - cmaskg *= maskamt; - cmaskb *= maskamt; - } - else - { - cmaskr = cmaskg = cmaskb = 0xff; - maskamt = 0; - maskcolor = ((0xff) >> 3) + (((0xff) >> 2) << 5) + (((0xff) >> 3) << 11); - } - -#define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0) - if (p2[0] == '#') - { - // Get parameters like fadestart, fadeend, and the fogflag - fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); - fadeend = NUMFROMCHAR(p2[5]) + (NUMFROMCHAR(p2[4]) * 10); - if (fadestart > 30) - fadestart = 0; - if (fadeend > 31 || fadeend < 1) - fadeend = 31; - fadedist = fadeend - fadestart; - fog = NUMFROMCHAR(p2[1]); - } -#undef NUMFROMCHAR - - if (p3[0] == '#') - { - cdestr = cr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); - cdestg = cg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); - cdestb = cb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); - fadecolor = (((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11)); - } - else - cdestr = cdestg = cdestb = fadecolor = 0; -#undef HEX2INT - - for (i = 0; i < num_extra_colormaps; i++) - { - if (foundcolormaps[i] != LUMPERROR) - continue; - if (maskcolor == extra_colormaps[i].maskcolor - && fadecolor == extra_colormaps[i].fadecolor - && (float)maskamt == (float)extra_colormaps[i].maskamt - && fadestart == extra_colormaps[i].fadestart - && fadeend == extra_colormaps[i].fadeend - && fog == extra_colormaps[i].fog) - { - return; - } - } - - if (num_extra_colormaps == MAXCOLORMAPS) - I_Error("R_CreateColormap: Too many colormaps! the limit is %d\n", MAXCOLORMAPS); - - num_extra_colormaps++; - - if (rendermode == render_soft) - { - for (i = 0; i < 256; i++) - { - r = pLocalPalette[i].s.red; - g = pLocalPalette[i].s.green; - b = pLocalPalette[i].s.blue; - cbrightness = sqrt((r*r) + (g*g) + (b*b)); - - map[i][0] = (cbrightness * cmaskr) + (r * othermask); - if (map[i][0] > 255.0l) - map[i][0] = 255.0l; - deltas[i][0] = (map[i][0] - cdestr) / (double)fadedist; - - map[i][1] = (cbrightness * cmaskg) + (g * othermask); - if (map[i][1] > 255.0l) - map[i][1] = 255.0l; - deltas[i][1] = (map[i][1] - cdestg) / (double)fadedist; - - map[i][2] = (cbrightness * cmaskb) + (b * othermask); - if (map[i][2] > 255.0l) - map[i][2] = 255.0l; - deltas[i][2] = (map[i][2] - cdestb) / (double)fadedist; - } - } - - foundcolormaps[mapnum] = LUMPERROR; - - // aligned on 8 bit for asm code - extra_colormaps[mapnum].colormap = NULL; - extra_colormaps[mapnum].maskcolor = (UINT16)maskcolor; - extra_colormaps[mapnum].fadecolor = (UINT16)fadecolor; - extra_colormaps[mapnum].maskamt = maskamt; - extra_colormaps[mapnum].fadestart = (UINT16)fadestart; - extra_colormaps[mapnum].fadeend = (UINT16)fadeend; - extra_colormaps[mapnum].fog = fog; - -#define ABS2(x) ((x) < 0 ? -(x) : (x)) - if (rendermode == render_soft) - { - colormap_p = Z_MallocAlign((256 * 34) + 10, PU_LEVEL, NULL, 8); - extra_colormaps[mapnum].colormap = (UINT8 *)colormap_p; - - for (p = 0; p < 34; p++) - { - for (i = 0; i < 256; i++) - { - *colormap_p = NearestColor((UINT8)RoundUp(map[i][0]), - (UINT8)RoundUp(map[i][1]), - (UINT8)RoundUp(map[i][2])); - colormap_p++; - - if ((UINT32)p < fadestart) - continue; - - if (ABS2(map[i][0] - cdestr) > ABS2(deltas[i][0])) - map[i][0] -= deltas[i][0]; - else - map[i][0] = cdestr; - - if (ABS2(map[i][1] - cdestg) > ABS2(deltas[i][1])) - map[i][1] -= deltas[i][1]; - else - map[i][1] = cdestg; - - if (ABS2(map[i][2] - cdestb) > ABS2(deltas[i][1])) - map[i][2] -= deltas[i][2]; - else - map[i][2] = cdestb; - } - } - } -#undef ABS2 - - return; -} -*/ - // Thanks to quake2 source! // utils3/qdata/images.c static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b) diff --git a/src/r_data.h b/src/r_data.h index c1f2a73da..a656e5db7 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -93,8 +93,6 @@ void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); INT32 R_ColormapNumForName(char *name); INT32 R_CreateColormap(char *p1, char *p2, char *p3); -//void R_CreateColormap2(char *p1, char *p2, char *p3); -//void R_MakeColormaps(void); const char *R_ColormapNameForNum(INT32 num); extern INT32 numtextures; From acea0bfd68532524437b096f58d0c50f5cebb315 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 12:00:15 -0400 Subject: [PATCH 171/573] Move tic-based to EFFECT4, relative calc to EFFECT3 --- src/p_spec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index f397f5b75..3a27cd987 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3363,7 +3363,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_RemoveFakeFloorFader(rover); P_FadeFakeFloor(rover, - max(1, min(256, (line->flags & ML_EFFECT4) ? rover->alpha + destvalue : destvalue)), + max(1, min(256, (line->flags & ML_EFFECT3) ? rover->alpha + destvalue : destvalue)), 0, // set alpha immediately false, NULL, 0, // tic-based logic false, // do not handle FF_EXISTS @@ -3415,8 +3415,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_AddFakeFloorFader(rover, secnum, j, destvalue, speed, - (line->flags & ML_EFFECT5), // tic-based logic - (line->flags & ML_EFFECT4), // Relative destvalue + (line->flags & ML_EFFECT4), // tic-based logic + (line->flags & ML_EFFECT3), // Relative destvalue !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT !(line->flags & ML_EFFECT2), // do not handle lighting @@ -3437,7 +3437,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_RemoveFakeFloorFader(rover); P_FadeFakeFloor(rover, - max(1, min(256, (line->flags & ML_EFFECT4) ? rover->alpha + destvalue : destvalue)), + max(1, min(256, (line->flags & ML_EFFECT3) ? rover->alpha + destvalue : destvalue)), 0, // set alpha immediately false, NULL, 0, // tic-based logic !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS From 88d9da79e6433164336663f3df6f66b64662d9ba Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 12:00:44 -0400 Subject: [PATCH 172/573] Move tic-based to EFFECT4 --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 917ad68d4..aa3a81f23 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2781,7 +2781,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_FadeLight(line->tag, (line->flags & ML_DONTPEGBOTTOM) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, (line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, - (line->flags & ML_EFFECT5)); + (line->flags & ML_EFFECT4)); break; case 421: // Stop lighting effect in tagged sectors From d26ba2ee5451bb53bf15384b1ad7af12ecd665ff Mon Sep 17 00:00:00 2001 From: PrisimaTheFox Date: Sun, 9 Sep 2018 23:16:28 -0500 Subject: [PATCH 173/573] Update m_anigif.c More accurate GIF delay. --- src/m_anigif.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index 2540665ad..5c7cfbd68 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -492,7 +492,9 @@ static void GIF_framewrite(void) // screen regions are handled in GIF_lzw { - UINT16 delay = 3; // todo + int d1 = (int)((100.0/NEWTICRATE)*gif_frames); + int d2 = (int)((100.0/NEWTICRATE)*(gif_frames-1)); + UINT16 delay = d1-d2; INT32 startline; WRITEMEM(p, gifframe_gchead, 4); From 4ada0b0a9e42f5b3b71cf509bc66f7881104b4aa Mon Sep 17 00:00:00 2001 From: PrisimaTheFox Date: Sun, 9 Sep 2018 23:33:51 -0500 Subject: [PATCH 174/573] Update m_anigif.c Remember gif_frames starts at 0 --- src/m_anigif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index 5c7cfbd68..d46d889bb 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -492,8 +492,8 @@ static void GIF_framewrite(void) // screen regions are handled in GIF_lzw { - int d1 = (int)((100.0/NEWTICRATE)*gif_frames); - int d2 = (int)((100.0/NEWTICRATE)*(gif_frames-1)); + int d1 = (int)((100.0/NEWTICRATE)*gif_frames+1); + int d2 = (int)((100.0/NEWTICRATE)*(gif_frames)); UINT16 delay = d1-d2; INT32 startline; From e33ed45b7b774a819812d4f7887bd93c107206cc Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 15:59:31 -0400 Subject: [PATCH 175/573] Colormap overhaul in r_data.c * Split R_CreateColormap to R_CreateLightTable * Replace extra_colormaps array with next/prev pointer chain * Remove foundcolormaps; instead store lumpnum in extracolormap_t * Add properties to extracolormap_t for portability --- src/r_data.c | 333 ++++++++++++++++++++++++++++++++------------------ src/r_data.h | 3 +- src/r_defs.h | 12 +- src/r_state.h | 3 +- 4 files changed, 226 insertions(+), 125 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 18c93787c..1c964993f 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1311,8 +1311,6 @@ void R_ReInitColormaps(UINT16 num) R_ClearColormaps(); } -static lumpnum_t foundcolormaps[MAXCOLORMAPS]; - // // R_ClearColormaps // @@ -1320,48 +1318,73 @@ static lumpnum_t foundcolormaps[MAXCOLORMAPS]; // void R_ClearColormaps(void) { - size_t i; + extracolormap_t *exc, *exc_next; - num_extra_colormaps = 0; + for (exc = extra_colormaps; exc; exc = exc_next) + { + exc_next = exc->next; + memset(exc, 0, sizeof(exc)); + } - for (i = 0; i < MAXCOLORMAPS; i++) - foundcolormaps[i] = LUMPERROR; + extra_colormaps = NULL; +} - memset(extra_colormaps, 0, sizeof (extra_colormaps)); +// +// R_AddColormapToList +// +// Sets prev/next chain for extra_colormaps var +// Copypasta from P_AddFFloorToList +// +void R_AddColormapToList(extracolormap_t *extra_colormap) +{ + extracolormap_t *exc; + + if (!extra_colormaps) + { + extra_colormaps = extra_colormap; + extra_colormap->next = 0; + extra_colormap->prev = 0; + return; + } + + for (exc = extra_colormaps; exc->next; exc = exc->next); + + exc->next = extra_colormap; + extra_colormap->prev = exc; + extra_colormap->next = 0; } INT32 R_ColormapNumForName(char *name) { - lumpnum_t lump, i; - - if (num_extra_colormaps == MAXCOLORMAPS) - I_Error("R_ColormapNumForName: Too many colormaps! the limit is %d\n", MAXCOLORMAPS); + lumpnum_t lump; + extracolormap_t *exc; lump = R_CheckNumForNameList(name, colormaplumps, numcolormaplumps); if (lump == LUMPERROR) I_Error("R_ColormapNumForName: Cannot find colormap lump %.8s\n", name); - for (i = 0; i < num_extra_colormaps; i++) - if (lump == foundcolormaps[i]) - return i; + for (exc = extra_colormaps; exc; exc = exc->next) + if (lump == exc->lump) + return exc; - foundcolormaps[num_extra_colormaps] = lump; + exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + + exc->lump = lump; // aligned on 8 bit for asm code - extra_colormaps[num_extra_colormaps].colormap = Z_MallocAlign(W_LumpLength(lump), PU_LEVEL, NULL, 16); - W_ReadLump(lump, extra_colormaps[num_extra_colormaps].colormap); + exc->colormap = Z_MallocAlign(W_LumpLength(lump), PU_LEVEL, NULL, 16); + W_ReadLump(lump, exc->colormap); // We set all params of the colormap to normal because there // is no real way to tell how GL should handle a colormap lump anyway.. - extra_colormaps[num_extra_colormaps].maskcolor = 0xffff; - extra_colormaps[num_extra_colormaps].fadecolor = 0x0; - extra_colormaps[num_extra_colormaps].maskamt = 0x0; - extra_colormaps[num_extra_colormaps].fadestart = 0; - extra_colormaps[num_extra_colormaps].fadeend = 31; - extra_colormaps[num_extra_colormaps].fog = 0; + exc->maskcolor = 0xffff; + exc->fadecolor = 0x0; + exc->maskamt = 0x0; + exc->fadestart = 0; + exc->fadeend = 31; + exc->fog = 0; - num_extra_colormaps++; - return (INT32)num_extra_colormaps - 1; + return exc; } // @@ -1377,105 +1400,30 @@ static double deltas[256][3], map[256][3]; static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b); static int RoundUp(double number); -INT32 R_CreateColormap(char *p1, char *p2, char *p3) +lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) { - double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; - double maskamt = 0, othermask = 0; - int mask, fog = 0; - size_t mapnum = num_extra_colormaps; - size_t i; - UINT32 cr, cg, cb, maskcolor, fadecolor; - UINT32 fadestart = 0, fadeend = 31, fadedist = 31; + // "Unpackage" our variables for ease of reading below + UINT32 maskcolor = (UINT32)extra_colormap->maskcolor, + fadecolor = (UINT32)extra_colormap->fadecolor, + fadestart = (UINT16)extra_colormap->fadestart, + fadeend = (UINT16)extra_colormap->fadeend, + fadedist = extra_colormap->fadedist; -#define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) - if (p1[0] == '#') - { - cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); - cmaskr = cr; - cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); - cmaskg = cg; - cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); - cmaskb = cb; - // Create a rough approximation of the color (a 16 bit color) - maskcolor = ((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11); - if (p1[7] >= 'a' && p1[7] <= 'z') - mask = (p1[7] - 'a'); - else if (p1[7] >= 'A' && p1[7] <= 'Z') - mask = (p1[7] - 'A'); - else - mask = 24; + double maskamt = extra_colormap->maskamt, + othermask = extra_colormap->othermask, + cmaskr = extra_colormap->cmaskr, + cmaskg = extra_colormap->cmaskg, + cmaskb = extra_colormap->cmaskb, + cdestr = extra_colormap->cdestr, + cdestg = extra_colormap->cdestg, + cdestb = extra_colormap->cdestb; - maskamt = (double)(mask/24.0l); + int fog = extra_colormap->fog; - othermask = 1 - maskamt; - maskamt /= 0xff; - cmaskr *= maskamt; - cmaskg *= maskamt; - cmaskb *= maskamt; - } - else - { - cmaskr = cmaskg = cmaskb = 0xff; - maskamt = 0; - maskcolor = ((0xff) >> 3) + (((0xff) >> 2) << 5) + (((0xff) >> 3) << 11); - } + INT32 rgba = extra_colormap->rgba, + fadergba = extra_colormap->fadergba; -#define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0) - if (p2[0] == '#') - { - // Get parameters like fadestart, fadeend, and the fogflag - fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); - fadeend = NUMFROMCHAR(p2[5]) + (NUMFROMCHAR(p2[4]) * 10); - if (fadestart > 30) - fadestart = 0; - if (fadeend > 31 || fadeend < 1) - fadeend = 31; - fadedist = fadeend - fadestart; - fog = NUMFROMCHAR(p2[1]); - } -#undef NUMFROMCHAR - - if (p3[0] == '#') - { - cdestr = cr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); - cdestg = cg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); - cdestb = cb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); - fadecolor = (((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11)); - } - else - cdestr = cdestg = cdestb = fadecolor = 0; -#undef HEX2INT - - for (i = 0; i < num_extra_colormaps; i++) - { - if (foundcolormaps[i] != LUMPERROR) - continue; - if (maskcolor == extra_colormaps[i].maskcolor - && fadecolor == extra_colormaps[i].fadecolor - && (float)maskamt == (float)extra_colormaps[i].maskamt - && fadestart == extra_colormaps[i].fadestart - && fadeend == extra_colormaps[i].fadeend - && fog == extra_colormaps[i].fog) - { - return (INT32)i; - } - } - - if (num_extra_colormaps == MAXCOLORMAPS) - I_Error("R_CreateColormap: Too many colormaps! the limit is %d\n", MAXCOLORMAPS); - - num_extra_colormaps++; - - foundcolormaps[mapnum] = LUMPERROR; - - // aligned on 8 bit for asm code - extra_colormaps[mapnum].colormap = NULL; - extra_colormaps[mapnum].maskcolor = (UINT16)maskcolor; - extra_colormaps[mapnum].fadecolor = (UINT16)fadecolor; - extra_colormaps[mapnum].maskamt = maskamt; - extra_colormaps[mapnum].fadestart = (UINT16)fadestart; - extra_colormaps[mapnum].fadeend = (UINT16)fadeend; - extra_colormaps[mapnum].fog = fog; + lighttable_t *lighttable; // This code creates the colormap array used by software renderer if (rendermode == render_soft) @@ -1513,8 +1461,9 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) } // Now allocate memory for the actual colormap array itself! + // aligned on 8 bit for asm code colormap_p = Z_MallocAlign((256 * 34) + 10, PU_LEVEL, NULL, 8); - extra_colormaps[mapnum].colormap = (UINT8 *)colormap_p; + lighttable = (UINT8 *)colormap_p; // Calculate the palette index for each palette index, for each light level // (as well as the two unused colormap lines we inherited from Doom) @@ -1549,7 +1498,149 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) } } - return (INT32)mapnum; + return lighttable; +} + +extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) +{ + double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; + double maskamt = 0, othermask = 0; + int mask, fog = 0; + extracolormap_t *extra_colormap, *exc; + + UINT32 cr, cg, cb, maskcolor, fadecolor; + UINT32 fadestart = 0, fadeend = 31, fadedist = 31; + + INT32 rgba, fadergba; + +#define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) + if (p1[0] == '#') + { + cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); + cmaskr = cr; + cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); + cmaskg = cg; + cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); + cmaskb = cb; + // Create a rough approximation of the color (a 16 bit color) + maskcolor = ((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11); + if (p1[7] >= 'a' && p1[7] <= 'z') + mask = (p1[7] - 'a'); + else if (p1[7] >= 'A' && p1[7] <= 'Z') + mask = (p1[7] - 'A'); + else + mask = 24; + + maskamt = (double)(mask/24.0l); + + othermask = 1 - maskamt; + maskamt /= 0xff; + cmaskr *= maskamt; + cmaskg *= maskamt; + cmaskb *= maskamt; + + // package up cmask vars for passing around + maskrgba = + + // for opengl; generate on software too for netsync + rgba = (HEX2INT(p1[1]) << 4) + (HEX2INT(p1[2]) << 0) + + (HEX2INT(p1[3]) << 12) + (HEX2INT(p1[4]) << 8) + + (HEX2INT(p1[5]) << 20) + (HEX2INT(p1[6]) << 16); + + if (p1[7] >= 'a' && p1[7] <= 'z' || p1[7] >= 'A' && p1[7] <= 'Z') + rgba += (ALPHA2INT(p1[7]) << 24); + else + rgba += (25 << 24); + } + else + { + cmaskr = cmaskg = cmaskb = 0xff; + maskamt = 0; + maskcolor = ((0xff) >> 3) + (((0xff) >> 2) << 5) + (((0xff) >> 3) << 11); + rgba = 0; + } + +#define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0) + if (p2[0] == '#') + { + // Get parameters like fadestart, fadeend, and the fogflag + fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); + fadeend = NUMFROMCHAR(p2[5]) + (NUMFROMCHAR(p2[4]) * 10); + if (fadestart > 30) + fadestart = 0; + if (fadeend > 31 || fadeend < 1) + fadeend = 31; + fadedist = fadeend - fadestart; + fog = NUMFROMCHAR(p2[1]); + } +#undef NUMFROMCHAR + + if (p3[0] == '#') + { + cdestr = cr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); + cdestg = cg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); + cdestb = cb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); + fadecolor = (((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11)); + + // for opengl; generate on software too for netsync + fadergba = (HEX2INT(p3[1]) << 4) + (HEX2INT(p3[2]) << 0) + + (HEX2INT(p3[3]) << 12) + (HEX2INT(p3[4]) << 8) + + (HEX2INT(p3[5]) << 20) + (HEX2INT(p3[6]) << 16); + + if (p3[7] >= 'a' && p3[7] <= 'z' || p3[7] >= 'A' && p3[7] <= 'Z') + fadergba += (ALPHA2INT(p3[7]) << 24); + else + fadergba += (25 << 24); + } + else + { + cdestr = cdestg = cdestb = fadecolor = 0; + fadergba = 0x19000000; // default alpha for fade, (25 << 24) + } +#undef HEX2INT + + for (exc = extra_colormaps; exc; exc = exc->next) + { + if (exc->lump) + continue; + if (maskcolor == exc->maskcolor + && fadecolor == exc->fadecolor + && (float)maskamt == (float)exc->maskamt + && fadestart == exc->fadestart + && fadeend == exc->fadeend + && fog == exc->fog) + return exc; + } + + extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL); + + extra_colormap->maskcolor = (UINT16)maskcolor; + extra_colormap->fadecolor = (UINT16)fadecolor; + extra_colormap->maskamt = maskamt; + extra_colormap->othermask = othermask; + extra_colormap->fadestart = (UINT16)fadestart; + extra_colormap->fadeend = (UINT16)fadeend; + extra_colormap->fadedist = fadedist; + extra_colormap->fog = fog; + + extra_colormap->cmaskr = cmaskr; + extra_colormap->cmaskg = cmaskg; + extra_colormap->cmaskb = cmaskb; + extra_colormap->cdestr = cdestr; + extra_colormap->cdestg = cdestg; + extra_colormap->cdestb = cdestb; + + extra_colormap->rgba = rgba; + extra_colormap->fadergba = fadergba; + + extra_colormap->lump = LUMPERROR; + extra_colormap->next = extra_colormap->prev = NULL; + + extra_colormap->colormap = R_CreateLightTable(extra_colormap); + + R_AddColormapToList(extra_colormap); + + return extra_colormap; } // Thanks to quake2 source! diff --git a/src/r_data.h b/src/r_data.h index 250f4d7c2..612c184e4 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -99,7 +99,8 @@ INT32 R_CheckTextureNumForName(const char *name); void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); INT32 R_ColormapNumForName(char *name); -INT32 R_CreateColormap(char *p1, char *p2, char *p3); +lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); +extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); const char *R_ColormapNameForNum(INT32 num); extern INT32 numtextures; diff --git a/src/r_defs.h b/src/r_defs.h index 7c8f2a73f..15312114a 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -53,15 +53,25 @@ typedef UINT8 lighttable_t; typedef struct { UINT16 maskcolor, fadecolor; - double maskamt; + double maskamt, othermask; UINT16 fadestart, fadeend; + UINT32 fadedist; INT32 fog; + // mask rgb for colormap table generation + double cmaskr, cmaskg, cmaskb; + double cdestr, cdestg, cdestb; + // rgba is used in hw mode for colored sector lighting INT32 rgba; // similar to maskcolor in sw mode INT32 fadergba; // The colour the colourmaps fade to lighttable_t *colormap; + + lumpnum_t lump; // for colormap lump matching, init to LUMPERROR + + extracolormap_t *next; + extracolormap_t *prev; } extracolormap_t; // diff --git a/src/r_state.h b/src/r_state.h index ac3e1fa42..effa4e36c 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -43,8 +43,7 @@ extern lighttable_t *colormaps; // Had to put a limit on colormaps :( #define MAXCOLORMAPS 60 -extern size_t num_extra_colormaps; -extern extracolormap_t extra_colormaps[MAXCOLORMAPS]; +extern extracolormap_t *extra_colormaps; // for global animation extern INT32 *texturetranslation; From 574a591d434bc1574e54479a443b15b315e422b2 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 16:08:43 -0400 Subject: [PATCH 176/573] P_LoadRawSideDefs2 colormap cleanup (merge ogl and software to one block) --- src/p_setup.c | 82 +++++---------------------------------------------- 1 file changed, 7 insertions(+), 75 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 5cc7279c5..a29a6080a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1474,82 +1474,17 @@ static void P_LoadRawSideDefs2(void *data) // Perhaps we should just call it instead of doing the calculations here. if (rendermode == render_soft || rendermode == render_none) { - if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#') - { - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } - break; - } + if ( + ((rendermode == render_soft || rendermode == render_none) && (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#')) #ifdef HWRENDER - else - { - // for now, full support of toptexture only - if ((msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6])) + || (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) + || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) +#endif + ) { - char *col; - - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, + sec->extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, msd->bottomtexture); sd->toptexture = sd->bottomtexture = 0; -#define HEX2INT(x) (x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) -#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) - sec->extra_colormap = &extra_colormaps[sec->midmap]; - - if (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - { - col = msd->toptexture; - - sec->extra_colormap->rgba = - (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0) + - (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8) + - (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16); - - // alpha - if (msd->toptexture[7]) - sec->extra_colormap->rgba += (ALPHA2INT(col[7]) << 24); - else - sec->extra_colormap->rgba += (25 << 24); - } - else - sec->extra_colormap->rgba = 0; - - if (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) - { - col = msd->bottomtexture; - - sec->extra_colormap->fadergba = - (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0) + - (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8) + - (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16); - - // alpha - if (msd->bottomtexture[7]) - sec->extra_colormap->fadergba += (ALPHA2INT(col[7]) << 24); - else - sec->extra_colormap->fadergba += (25 << 24); - } - else - sec->extra_colormap->fadergba = 0x19000000; // default alpha, (25 << 24) -#undef ALPHA2INT -#undef HEX2INT } else { @@ -1557,12 +1492,10 @@ static void P_LoadRawSideDefs2(void *data) sd->toptexture = 0; else sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) sd->midtexture = 0; else sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) sd->bottomtexture = 0; else @@ -1570,7 +1503,6 @@ static void P_LoadRawSideDefs2(void *data) } break; } -#endif case 413: // Change music { From e0d8a6eec0807afe4dc93fcb65e80e82d2131a73 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 16:16:04 -0400 Subject: [PATCH 177/573] Get rid of bottommap, midmap, topmap --- src/p_setup.c | 1 - src/p_spec.c | 2 +- src/r_bsp.c | 25 ++++--------------------- src/r_defs.h | 2 -- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index a29a6080a..eb8489726 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -718,7 +718,6 @@ static void P_LoadRawSectors(UINT8 *data, size_t i) ss->spawn_flr_xoffs = ss->spawn_ceil_xoffs = ss->spawn_flr_yoffs = ss->spawn_ceil_yoffs = 0; ss->floorpic_angle = ss->ceilingpic_angle = 0; ss->spawn_flrpic_angle = ss->spawn_ceilpic_angle = 0; - ss->bottommap = ss->midmap = ss->topmap = -1; ss->gravity = NULL; ss->cullheight = NULL; ss->verticalflip = false; diff --git a/src/p_spec.c b/src/p_spec.c index 6c359c9cc..698c8f4b1 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6760,7 +6760,7 @@ void P_SpawnSpecials(INT32 fromnetsave) case 606: // HACK! Copy colormaps. Just plain colormaps. for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - sectors[s].midmap = lines[i].frontsector->midmap; + sectors[s].extra_colormap = lines[i].frontsector->extra_colormap; break; #ifdef ESLOPE // Slope copy specials. Handled here for sanity. diff --git a/src/r_bsp.c b/src/r_bsp.c index 183def25a..512aab696 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -234,8 +234,6 @@ static INT32 R_DoorClosed(void) sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, INT32 *ceilinglightlevel, boolean back) { - INT32 mapnum = -1; - if (floorlightlevel) *floorlightlevel = sec->floorlightsec == -1 ? sec->lightlevel : sectors[sec->floorlightsec].lightlevel; @@ -244,10 +242,10 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, *ceilinglightlevel = sec->ceilinglightsec == -1 ? sec->lightlevel : sectors[sec->ceilinglightsec].lightlevel; - // If the sector has a midmap, it's probably from 280 type - if (sec->midmap != -1) - mapnum = sec->midmap; - else if (sec->heightsec != -1) + // if (sec->midmap != -1) + // mapnum = sec->midmap; + // In original colormap code, this block did not run if sec->midmap was set + if (!sec->extra_colormap && sec->heightsec != -1) { const sector_t *s = §ors[sec->heightsec]; mobj_t *viewmobj = viewplayer->mo; @@ -271,8 +269,6 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, tempsec->floorheight = s->floorheight; tempsec->ceilingheight = s->ceilingheight; - mapnum = s->midmap; - if ((underwater && (tempsec-> floorheight = sec->floorheight, tempsec->ceilingheight = s->floorheight - 1, !back)) || viewz <= s->floorheight) { // head-below-floor hack @@ -298,7 +294,6 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, tempsec->ceiling_yoffs = s->ceiling_yoffs; tempsec->ceilingpic_angle = s->ceilingpic_angle; } - mapnum = s->bottommap; } tempsec->lightlevel = s->lightlevel; @@ -322,8 +317,6 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, tempsec->floor_yoffs = tempsec->ceiling_yoffs = s->ceiling_yoffs; tempsec->floorpic_angle = tempsec->ceilingpic_angle = s->ceilingpic_angle; - mapnum = s->topmap; - if (s->floorpic == skyflatnum) // SKYFIX? { tempsec->ceilingheight = tempsec->floorheight-1; @@ -354,11 +347,6 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, sec = tempsec; } - if (mapnum >= 0 && (size_t)mapnum < num_extra_colormaps) - sec->extra_colormap = &extra_colormaps[mapnum]; - else - sec->extra_colormap = NULL; - return sec; } @@ -1342,11 +1330,6 @@ void R_Prep3DFloors(sector_t *sector) sector->lightlist[i].slope = bestslope; #endif sec = §ors[best->secnum]; - mapnum = sec->midmap; - if (mapnum >= 0 && (size_t)mapnum < num_extra_colormaps) - sec->extra_colormap = &extra_colormaps[mapnum]; - else - sec->extra_colormap = NULL; if (best->flags & FF_NOSHADE) { diff --git a/src/r_defs.h b/src/r_defs.h index 15312114a..257e36147 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -333,8 +333,6 @@ typedef struct sector_s INT32 floorlightsec, ceilinglightsec; INT32 crumblestate; // used for crumbling and bobbing - INT32 bottommap, midmap, topmap; // dynamic colormaps - // list of mobjs that are at least partially in the sector // thinglist is a subset of touching_thinglist struct msecnode_s *touching_thinglist; From 2701976ba39124f1687da05018c30644c821f30e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 16:28:39 -0400 Subject: [PATCH 178/573] Compiler fixes --- src/r_bsp.c | 2 +- src/r_data.c | 43 +++++++++++++++---------------------------- src/r_data.h | 2 +- src/r_defs.h | 6 +++--- src/r_main.c | 3 +-- 5 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index 512aab696..01676572e 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1225,7 +1225,7 @@ void R_Prep3DFloors(sector_t *sector) ffloor_t *rover; ffloor_t *best; fixed_t bestheight, maxheight; - INT32 count, i, mapnum; + INT32 count, i; sector_t *sec; #ifdef ESLOPE pslope_t *bestslope = NULL; diff --git a/src/r_data.c b/src/r_data.c index 1c964993f..eb5e27b0b 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1323,7 +1323,7 @@ void R_ClearColormaps(void) for (exc = extra_colormaps; exc; exc = exc_next) { exc_next = exc->next; - memset(exc, 0, sizeof(exc)); + memset(exc, 0, sizeof(*exc)); } extra_colormaps = NULL; @@ -1354,14 +1354,14 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) extra_colormap->next = 0; } -INT32 R_ColormapNumForName(char *name) +extracolormap_t *R_ColormapForName(char *name) { lumpnum_t lump; extracolormap_t *exc; lump = R_CheckNumForNameList(name, colormaplumps, numcolormaplumps); if (lump == LUMPERROR) - I_Error("R_ColormapNumForName: Cannot find colormap lump %.8s\n", name); + I_Error("R_ColormapForName: Cannot find colormap lump %.8s\n", name); for (exc = extra_colormaps; exc; exc = exc->next) if (lump == exc->lump) @@ -1402,15 +1402,10 @@ static int RoundUp(double number); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) { - // "Unpackage" our variables for ease of reading below - UINT32 maskcolor = (UINT32)extra_colormap->maskcolor, - fadecolor = (UINT32)extra_colormap->fadecolor, - fadestart = (UINT16)extra_colormap->fadestart, - fadeend = (UINT16)extra_colormap->fadeend, + UINT32 fadestart = (UINT16)extra_colormap->fadestart, fadedist = extra_colormap->fadedist; - double maskamt = extra_colormap->maskamt, - othermask = extra_colormap->othermask, + double othermask = extra_colormap->othermask, cmaskr = extra_colormap->cmaskr, cmaskg = extra_colormap->cmaskg, cmaskb = extra_colormap->cmaskb, @@ -1418,12 +1413,8 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) cdestg = extra_colormap->cdestg, cdestb = extra_colormap->cdestb; - int fog = extra_colormap->fog; - - INT32 rgba = extra_colormap->rgba, - fadergba = extra_colormap->fadergba; - - lighttable_t *lighttable; + lighttable_t *lighttable = NULL; + size_t i; // This code creates the colormap array used by software renderer if (rendermode == render_soft) @@ -1514,6 +1505,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) INT32 rgba, fadergba; #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) +#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) if (p1[0] == '#') { cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); @@ -1539,15 +1531,12 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) cmaskg *= maskamt; cmaskb *= maskamt; - // package up cmask vars for passing around - maskrgba = - // for opengl; generate on software too for netsync rgba = (HEX2INT(p1[1]) << 4) + (HEX2INT(p1[2]) << 0) + (HEX2INT(p1[3]) << 12) + (HEX2INT(p1[4]) << 8) + (HEX2INT(p1[5]) << 20) + (HEX2INT(p1[6]) << 16); - if (p1[7] >= 'a' && p1[7] <= 'z' || p1[7] >= 'A' && p1[7] <= 'Z') + if ((p1[7] >= 'a' && p1[7] <= 'z') || (p1[7] >= 'A' && p1[7] <= 'Z')) rgba += (ALPHA2INT(p1[7]) << 24); else rgba += (25 << 24); @@ -1587,7 +1576,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) (HEX2INT(p3[3]) << 12) + (HEX2INT(p3[4]) << 8) + (HEX2INT(p3[5]) << 20) + (HEX2INT(p3[6]) << 16); - if (p3[7] >= 'a' && p3[7] <= 'z' || p3[7] >= 'A' && p3[7] <= 'Z') + if ((p3[7] >= 'a' && p3[7] <= 'z') || (p3[7] >= 'A' && p3[7] <= 'Z')) fadergba += (ALPHA2INT(p3[7]) << 24); else fadergba += (25 << 24); @@ -1597,6 +1586,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) cdestr = cdestg = cdestb = fadecolor = 0; fadergba = 0x19000000; // default alpha for fade, (25 << 24) } +#undef ALPHA2INT #undef HEX2INT for (exc = extra_colormaps; exc; exc = exc->next) @@ -1683,18 +1673,15 @@ static int RoundUp(double number) return (int)number; } -const char *R_ColormapNameForNum(INT32 num) +const char *R_ColormapNameForColormap(extracolormap_t *extra_colormap) { - if (num == -1) + if (!extra_colormap) return "NONE"; - if (num < 0 || num > MAXCOLORMAPS) - I_Error("R_ColormapNameForNum: num %d is invalid!\n", num); - - if (foundcolormaps[num] == LUMPERROR) + if (extra_colormap->lump == LUMPERROR) return "INLEVEL"; - return W_CheckNameForNum(foundcolormaps[num]); + return W_CheckNameForNum(extra_colormap->lump); } diff --git a/src/r_data.h b/src/r_data.h index 612c184e4..db2749834 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -98,7 +98,7 @@ INT32 R_CheckTextureNumForName(const char *name); void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); -INT32 R_ColormapNumForName(char *name); +extracolormap_t *R_ColormapForName(char *name); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); const char *R_ColormapNameForNum(INT32 num); diff --git a/src/r_defs.h b/src/r_defs.h index 257e36147..d8915cab8 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -50,7 +50,7 @@ typedef struct typedef UINT8 lighttable_t; // ExtraColormap type. Use for extra_colormaps from now on. -typedef struct +typedef struct extracolormap_s { UINT16 maskcolor, fadecolor; double maskamt, othermask; @@ -70,8 +70,8 @@ typedef struct lumpnum_t lump; // for colormap lump matching, init to LUMPERROR - extracolormap_t *next; - extracolormap_t *prev; + struct extracolormap_s *next; + struct extracolormap_s *prev; } extracolormap_t; // diff --git a/src/r_main.c b/src/r_main.c index 8e58906d4..281058362 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -118,8 +118,7 @@ lighttable_t *scalelightfixed[MAXLIGHTSCALE]; lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; // Hack to support extra boom colormaps. -size_t num_extra_colormaps; -extracolormap_t extra_colormaps[MAXCOLORMAPS]; +extracolormap_t *extra_colormaps; static CV_PossibleValue_t drawdist_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, From 53733ddf76440a70cf414c67b8ff5c58e93fe1f3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 16:32:54 -0400 Subject: [PATCH 179/573] Type 606 renderer check allow OGL again --- src/p_setup.c | 53 ++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index eb8489726..09ba553bf 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1471,37 +1471,34 @@ static void P_LoadRawSideDefs2(void *data) case 606: //SoM: 4/4/2000: Just colormap transfer // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. - if (rendermode == render_soft || rendermode == render_none) - { - if ( - ((rendermode == render_soft || rendermode == render_none) && (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#')) + if ( + ((rendermode == render_soft || rendermode == render_none) && (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#')) #ifdef HWRENDER - || (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) + || (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) + || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) #endif - ) - { - sec->extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } - break; + ) + { + sec->extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, + msd->bottomtexture); + sd->toptexture = sd->bottomtexture = 0; } + else + { + if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) + sd->toptexture = 0; + else + sd->toptexture = num; + if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) + sd->midtexture = 0; + else + sd->midtexture = num; + if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) + sd->bottomtexture = 0; + else + sd->bottomtexture = num; + } + break; case 413: // Change music { From 7608583c6fbe134d6f9ef6677cd2d1b3c26c6cd5 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 16:42:07 -0400 Subject: [PATCH 180/573] Fix shared colormap matching --- src/r_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index eb5e27b0b..eef6434b0 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1591,7 +1591,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) for (exc = extra_colormaps; exc; exc = exc->next) { - if (exc->lump) + if (exc->lump != LUMPERROR) continue; if (maskcolor == exc->maskcolor && fadecolor == exc->fadecolor From 7e9297d06e0fbfe104b8749c44d7aa54fa11ce86 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 12:01:50 -0400 Subject: [PATCH 181/573] Savegame netsync for sector colormaps; add spawn_midmap and co for comparison --- src/p_saveg.c | 74 ++++++++++++++++++++++++++++++++++++++------------- src/p_setup.c | 3 ++- src/p_spec.c | 2 +- src/r_defs.h | 3 +++ 4 files changed, 61 insertions(+), 21 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 22d43f358..1c9589e8f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -487,10 +487,16 @@ static void P_NetUnArchivePlayers(void) #define SD_FYOFFS 0x02 #define SD_CXOFFS 0x04 #define SD_CYOFFS 0x08 -#define SD_TAG 0x10 -#define SD_FLOORANG 0x20 -#define SD_CEILANG 0x40 -#define SD_TAGLIST 0x80 +#define SD_FLOORANG 0x10 +#define SD_CEILANG 0x20 +#define SD_TAG 0x40 +#define SD_DIFF3 0x80 + +// diff3 flags +#define SD_TAGLIST 0x01 +#define SD_BOTTOMMAP 0x02 +#define SD_MIDMAP 0x04 +#define SD_TOPMAP 0x08 #define LD_FLAG 0x01 #define LD_SPECIAL 0x02 @@ -523,7 +529,7 @@ static void P_NetArchiveWorld(void) mapsidedef_t *msd; maplinedef_t *mld; const sector_t *ss = sectors; - UINT8 diff, diff2; + UINT8 diff, diff2, diff3; WRITEUINT32(save_p, ARCHIVEBLOCK_WORLD); put = save_p; @@ -550,7 +556,7 @@ static void P_NetArchiveWorld(void) for (i = 0; i < numsectors; i++, ss++, ms++) { - diff = diff2 = 0; + diff = diff2 = diff3 = 0; if (ss->floorheight != SHORT(ms->floorheight)<ceilingheight != SHORT(ms->ceilingheight)<tag != SHORT(ms->tag)) diff2 |= SD_TAG; if (ss->nexttag != ss->spawn_nexttag || ss->firsttag != ss->spawn_firsttag) - diff2 |= SD_TAGLIST; + diff3 |= SD_TAGLIST; + if (ss->bottommap != ss->spawn_bottommap) + diff3 |= SD_BOTTOMMAP; + if (ss->midmap != ss->spawn_midmap) + diff3 |= SD_MIDMAP; + if (ss->topmap != ss->spawn_topmap) + diff3 |= SD_TOPMAP; // Check if any of the sector's FOFs differ from how they spawned if (ss->ffloors) @@ -601,6 +613,9 @@ static void P_NetArchiveWorld(void) } } + if (diff3) + diff2 |= SD_DIFF3; + if (diff2) diff |= SD_DIFF2; @@ -612,6 +627,8 @@ static void P_NetArchiveWorld(void) WRITEUINT8(put, diff); if (diff & SD_DIFF2) WRITEUINT8(put, diff2); + if (diff2 & SD_DIFF3) + WRITEUINT8(put, diff3); if (diff & SD_FLOORHT) WRITEFIXED(put, ss->floorheight); if (diff & SD_CEILHT) @@ -632,17 +649,23 @@ static void P_NetArchiveWorld(void) WRITEFIXED(put, ss->ceiling_xoffs); if (diff2 & SD_CYOFFS) WRITEFIXED(put, ss->ceiling_yoffs); - if (diff2 & SD_TAG) // save only the tag - WRITEINT16(put, ss->tag); if (diff2 & SD_FLOORANG) WRITEANGLE(put, ss->floorpic_angle); if (diff2 & SD_CEILANG) WRITEANGLE(put, ss->ceilingpic_angle); - if (diff2 & SD_TAGLIST) // save both firsttag and nexttag + if (diff2 & SD_TAG) // save only the tag + WRITEINT16(put, ss->tag); + if (diff3 & SD_TAGLIST) // save both firsttag and nexttag { // either of these could be changed even if tag isn't WRITEINT32(put, ss->firsttag); WRITEINT32(put, ss->nexttag); } + if (diff3 & SD_BOTTOMMAP) + WRITEINT32(put, ss->bottommap); + if (diff3 & SD_MIDMAP) + WRITEINT32(put, ss->midmap); + if (diff3 & SD_TOPMAP) + WRITEINT32(put, ss->topmap); // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed @@ -680,7 +703,7 @@ static void P_NetArchiveWorld(void) // do lines for (i = 0; i < numlines; i++, mld++, li++) { - diff = diff2 = 0; + diff = diff2 = diff3 = 0; if (li->special != SHORT(mld->special)) diff |= LD_SPECIAL; @@ -772,7 +795,7 @@ static void P_NetUnArchiveWorld(void) line_t *li; side_t *si; UINT8 *get; - UINT8 diff, diff2; + UINT8 diff, diff2, diff3; if (READUINT32(save_p) != ARCHIVEBLOCK_WORLD) I_Error("Bad $$$.sav at archive block World"); @@ -794,6 +817,10 @@ static void P_NetUnArchiveWorld(void) diff2 = READUINT8(get); else diff2 = 0; + if (diff2 & SD_DIFF3) + diff3 = READUINT8(get); + else + diff3 = 0; if (diff & SD_FLOORHT) sectors[i].floorheight = READFIXED(get); @@ -822,17 +849,23 @@ static void P_NetUnArchiveWorld(void) sectors[i].ceiling_xoffs = READFIXED(get); if (diff2 & SD_CYOFFS) sectors[i].ceiling_yoffs = READFIXED(get); - if (diff2 & SD_TAG) - sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag - if (diff2 & SD_TAGLIST) - { - sectors[i].firsttag = READINT32(get); - sectors[i].nexttag = READINT32(get); - } if (diff2 & SD_FLOORANG) sectors[i].floorpic_angle = READANGLE(get); if (diff2 & SD_CEILANG) sectors[i].ceilingpic_angle = READANGLE(get); + if (diff2 & SD_TAG) + sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag + if (diff3 & SD_TAGLIST) + { + sectors[i].firsttag = READINT32(get); + sectors[i].nexttag = READINT32(get); + } + if (diff3 & SD_BOTTOMMAP) + sectors[i].bottommap = READINT32(get); + if (diff3 & SD_MIDMAP) + sectors[i].midmap = READINT32(get); + if (diff3 & SD_TOPMAP) + sectors[i].topmap = READINT32(get); if (diff & SD_FFLOORS) { @@ -891,6 +924,9 @@ static void P_NetUnArchiveWorld(void) diff2 = READUINT8(get); else diff2 = 0; + + diff3 = 0; + if (diff & LD_FLAG) li->flags = READINT16(get); if (diff & LD_SPECIAL) diff --git a/src/p_setup.c b/src/p_setup.c index 09ba553bf..b503b6a58 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -713,6 +713,7 @@ static void P_LoadRawSectors(UINT8 *data, size_t i) ss->moved = true; ss->extra_colormap = NULL; + ss->spawn_extra_colormap = NULL; ss->floor_xoffs = ss->ceiling_xoffs = ss->floor_yoffs = ss->ceiling_yoffs = 0; ss->spawn_flr_xoffs = ss->spawn_ceil_xoffs = ss->spawn_flr_yoffs = ss->spawn_ceil_yoffs = 0; @@ -1479,7 +1480,7 @@ static void P_LoadRawSideDefs2(void *data) #endif ) { - sec->extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, + sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, msd->bottomtexture); sd->toptexture = sd->bottomtexture = 0; } diff --git a/src/p_spec.c b/src/p_spec.c index 698c8f4b1..5135676ab 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6760,7 +6760,7 @@ void P_SpawnSpecials(INT32 fromnetsave) case 606: // HACK! Copy colormaps. Just plain colormaps. for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - sectors[s].extra_colormap = lines[i].frontsector->extra_colormap; + sectors[s].extra_colormap = sectors[s].spawn_extra_colormap = lines[i].frontsector->extra_colormap; break; #ifdef ESLOPE // Slope copy specials. Handled here for sanity. diff --git a/src/r_defs.h b/src/r_defs.h index d8915cab8..e81631eb9 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -401,6 +401,9 @@ typedef struct sector_s // flag angles sector spawned with (via linedef type 7) angle_t spawn_flrpic_angle; angle_t spawn_ceilpic_angle; + + // colormap structure + extracolormap_t *spawn_extra_colormap; } sector_t; // From c92226890e002cee36d5b5700b59724a851ae445 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 09:03:58 -0400 Subject: [PATCH 182/573] Remove bottommap and topmap from savegame because unused --- src/p_saveg.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 1c9589e8f..42757faf2 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -494,9 +494,7 @@ static void P_NetUnArchivePlayers(void) // diff3 flags #define SD_TAGLIST 0x01 -#define SD_BOTTOMMAP 0x02 -#define SD_MIDMAP 0x04 -#define SD_TOPMAP 0x08 +#define SD_MIDMAP 0x02 #define LD_FLAG 0x01 #define LD_SPECIAL 0x02 @@ -591,12 +589,8 @@ static void P_NetArchiveWorld(void) diff2 |= SD_TAG; if (ss->nexttag != ss->spawn_nexttag || ss->firsttag != ss->spawn_firsttag) diff3 |= SD_TAGLIST; - if (ss->bottommap != ss->spawn_bottommap) - diff3 |= SD_BOTTOMMAP; if (ss->midmap != ss->spawn_midmap) diff3 |= SD_MIDMAP; - if (ss->topmap != ss->spawn_topmap) - diff3 |= SD_TOPMAP; // Check if any of the sector's FOFs differ from how they spawned if (ss->ffloors) @@ -660,12 +654,8 @@ static void P_NetArchiveWorld(void) WRITEINT32(put, ss->firsttag); WRITEINT32(put, ss->nexttag); } - if (diff3 & SD_BOTTOMMAP) - WRITEINT32(put, ss->bottommap); if (diff3 & SD_MIDMAP) WRITEINT32(put, ss->midmap); - if (diff3 & SD_TOPMAP) - WRITEINT32(put, ss->topmap); // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed @@ -860,12 +850,8 @@ static void P_NetUnArchiveWorld(void) sectors[i].firsttag = READINT32(get); sectors[i].nexttag = READINT32(get); } - if (diff3 & SD_BOTTOMMAP) - sectors[i].bottommap = READINT32(get); if (diff3 & SD_MIDMAP) sectors[i].midmap = READINT32(get); - if (diff3 & SD_TOPMAP) - sectors[i].topmap = READINT32(get); if (diff & SD_FFLOORS) { From 8d78c2219474f91b8741854e1ecb67e486dd63c4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 20:36:34 -0400 Subject: [PATCH 183/573] extracolormap_t refinement and netsyncing * Store raw values per rgba in extracolormap_t (no maskcolor or fadecolor) * Crunched some UINT16/32 into UINT8 * Calculate mask values in R_CreateLightTable * ifdef out EXTRACOLORMAPLUMPS --- src/p_saveg.c | 116 +++++++++++++++++++++++++++++++++--- src/r_data.c | 160 ++++++++++++++++++++++++++++++++------------------ src/r_data.h | 11 +++- src/r_defs.h | 16 ++--- 4 files changed, 228 insertions(+), 75 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 42757faf2..68d00a42c 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -21,6 +21,7 @@ #include "p_local.h" #include "p_setup.h" #include "p_saveg.h" +#include "r_data.h" #include "r_things.h" #include "r_state.h" #include "w_wad.h" @@ -494,7 +495,7 @@ static void P_NetUnArchivePlayers(void) // diff3 flags #define SD_TAGLIST 0x01 -#define SD_MIDMAP 0x02 +#define SD_COLORMAP 0x02 #define LD_FLAG 0x01 #define LD_SPECIAL 0x02 @@ -589,8 +590,8 @@ static void P_NetArchiveWorld(void) diff2 |= SD_TAG; if (ss->nexttag != ss->spawn_nexttag || ss->firsttag != ss->spawn_firsttag) diff3 |= SD_TAGLIST; - if (ss->midmap != ss->spawn_midmap) - diff3 |= SD_MIDMAP; + if (ss->extra_colormap != ss->spawn_extra_colormap) + diff3 |= SD_COLORMAP; // Check if any of the sector's FOFs differ from how they spawned if (ss->ffloors) @@ -654,8 +655,30 @@ static void P_NetArchiveWorld(void) WRITEINT32(put, ss->firsttag); WRITEINT32(put, ss->nexttag); } - if (diff3 & SD_MIDMAP) - WRITEINT32(put, ss->midmap); + + if (diff3 & SD_COLORMAP) + { + WRITEUINT8(put, ss->extra_colormap->fadestart); + WRITEUINT8(put, ss->extra_colormap->fadeend); + WRITEUINT8(put, ss->extra_colormap->fadedist); + WRITEUINT8(put, (UINT8)ss->extra_colormap->fog); + + WRITEUINT8(put, ss->extra_colormap->cr); + WRITEUINT8(put, ss->extra_colormap->cg); + WRITEUINT8(put, ss->extra_colormap->cb); + WRITEUINT8(put, ss->extra_colormap->ca); + WRITEUINT8(put, ss->extra_colormap->cfr); + WRITEUINT8(put, ss->extra_colormap->cfg); + WRITEUINT8(put, ss->extra_colormap->cfb); + WRITEUINT8(put, ss->extra_colormap->cfa); + + WRITEINT32(put, ss->extra_colormap->rgba); + WRITEINT32(put, ss->extra_colormap->fadergba); + +#ifdef EXTRACOLORMAPLUMPS + WRITESTRINGN(put, ss->extra_colormap->lumpname, 9); +#endif + } // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed @@ -850,8 +873,87 @@ static void P_NetUnArchiveWorld(void) sectors[i].firsttag = READINT32(get); sectors[i].nexttag = READINT32(get); } - if (diff3 & SD_MIDMAP) - sectors[i].midmap = READINT32(get); + + if (diff3 & SD_COLORMAP) + { + extracolormap_t *exc; + + UINT8 fadestart = READUINT8(get), + fadeend = READUINT8(get), + fadedist = READUINT8(get); + + boolean fog = (boolean)READUINT8(get); + + UINT8 cr = READUINT8(get), + cg = READUINT8(get), + cb = READUINT8(get), + ca = READUINT8(get), + cfr = READUINT8(get), + cfg = READUINT8(get), + cfb = READUINT8(get), + cfa = READUINT8(get); + + INT32 rgba = READINT32(get), + fadergba = READINT32(get); + +#ifdef EXTRACOLORMAPLUMPS + char lumpname[9]; + READSTRINGN(get, lumpname, 9); + + if (lumpname[0]) + sectors[i].extra_colormap = R_ColormapForName(lumpname); + else + { +#endif + + for (exc = extra_colormaps; exc; exc = exc->next) + { +#ifdef EXTRACOLORMAPLUMPS + if (exc->lump != LUMPERROR) + continue; +#endif + if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca + && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa + && fadestart == exc->fadestart + && fadeend == exc->fadeend + && fog == exc->fog) + break; + } + + if (!exc) + { + exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + + exc->fadestart = fadestart; + exc->fadeend = fadeend; + exc->fadedist = fadedist; + exc->fog = fog; + + exc->cr = cr; + exc->cg = cg; + exc->cb = cb; + exc->ca = ca; + exc->cfr = cfr; + exc->cfg = cfg; + exc->cfb = cfb; + exc->cfa = cfa; + + exc->rgba = rgba; + exc->fadergba = fadergba; + + exc->colormap = R_CreateLightTable(exc); + + R_AddColormapToList(exc); + + sectors[i].extra_colormap = exc; + +#ifdef EXTRACOLORMAPLUMPS + exc->lump = LUMPERROR; + exc->lumpname[0] = 0; + } // if (!exc) // if (!lumpname[0] || !R_ColormapForName(lumpname)) +#endif + } + } if (diff & SD_FFLOORS) { diff --git a/src/r_data.c b/src/r_data.c index eef6434b0..32cf17fa9 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1160,6 +1160,7 @@ static inline lumpnum_t R_CheckNumForNameList(const char *name, lumplist_t *list return LUMPERROR; } +#ifdef EXTRACOLORMAPLUMPS static lumplist_t *colormaplumps = NULL; ///\todo free leak static size_t numcolormaplumps = 0; @@ -1195,6 +1196,7 @@ static void R_InitExtraColormaps(void) } CONS_Printf(M_GetText("Number of Extra Colormaps: %s\n"), sizeu1(numcolormaplumps)); } +#endif // Search for flat name through all lumpnum_t R_GetFlatNumForName(const char *name) @@ -1291,7 +1293,9 @@ static void R_InitColormaps(void) // Init Boom colormaps. R_ClearColormaps(); +#ifdef EXTRACOLORMAPLUMPS R_InitExtraColormaps(); +#endif } void R_ReInitColormaps(UINT16 num) @@ -1354,6 +1358,7 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) extra_colormap->next = 0; } +#ifdef EXTRACOLORMAPLUMPS extracolormap_t *R_ColormapForName(char *name) { lumpnum_t lump; @@ -1370,6 +1375,8 @@ extracolormap_t *R_ColormapForName(char *name) exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); exc->lump = lump; + strncpy(exc->lumpname, name, 9); + exc->lumpname[8] = 0; // aligned on 8 bit for asm code exc->colormap = Z_MallocAlign(W_LumpLength(lump), PU_LEVEL, NULL, 16); @@ -1377,15 +1384,21 @@ extracolormap_t *R_ColormapForName(char *name) // We set all params of the colormap to normal because there // is no real way to tell how GL should handle a colormap lump anyway.. - exc->maskcolor = 0xffff; - exc->fadecolor = 0x0; - exc->maskamt = 0x0; + exc->cr = exc->cg = exc->cb = 0xff; + exc->ca = 0; + exc->cfr = exc->cfg = exc->cfb = 0; + exc->cfa = 18; exc->fadestart = 0; exc->fadeend = 31; exc->fog = 0; + exc->rgba = 0; + exc->fadergba = 0x19000000; + + R_AddColormapToList(exc); return exc; } +#endif // // R_CreateColormap @@ -1402,21 +1415,58 @@ static int RoundUp(double number); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) { + double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; + double maskamt = 0, othermask = 0; + + UINT8 cr = extra_colormap->cr, + cg = extra_colormap->cg, + cb = extra_colormap->cb, + ca = extra_colormap->ca, + cfr = extra_colormap->cfr, + cfg = extra_colormap->cfg, + cfb = extra_colormap->cfb; +// cfa = extra_colormap->cfa; // unused in software + UINT32 fadestart = (UINT16)extra_colormap->fadestart, fadedist = extra_colormap->fadedist; - double othermask = extra_colormap->othermask, - cmaskr = extra_colormap->cmaskr, - cmaskg = extra_colormap->cmaskg, - cmaskb = extra_colormap->cmaskb, - cdestr = extra_colormap->cdestr, - cdestg = extra_colormap->cdestg, - cdestb = extra_colormap->cdestb; - lighttable_t *lighttable = NULL; size_t i; + ///////////////////// + // Calc the RGBA mask + ///////////////////// + cmaskr = cr; + cmaskg = cg; + cmaskb = cb; + + maskamt = (double)(ca/24.0l); + othermask = 1 - maskamt; + maskamt /= 0xff; + + cmaskr *= maskamt; + cmaskg *= maskamt; + cmaskb *= maskamt; + + ///////////////////// + // Calc the RGBA fade mask + ///////////////////// + cdestr = cfr; + cdestg = cfg; + cdestb = cfb; + + // fade alpha unused in software + // maskamt = (double)(cfa/24.0l); + // othermask = 1 - maskamt; + // maskamt /= 0xff; + + // cdestr *= maskamt; + // cdestg *= maskamt; + // cdestb *= maskamt; + + ///////////////////// // This code creates the colormap array used by software renderer + ///////////////////// if (rendermode == render_soft) { double r, g, b, cbrightness; @@ -1494,12 +1544,10 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) { - double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; - double maskamt = 0, othermask = 0; - int mask, fog = 0; + boolean fog = false; extracolormap_t *extra_colormap, *exc; - UINT32 cr, cg, cb, maskcolor, fadecolor; + UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; UINT32 fadestart = 0, fadeend = 31, fadedist = 31; INT32 rgba, fadergba; @@ -1509,27 +1557,15 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) if (p1[0] == '#') { cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); - cmaskr = cr; cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); - cmaskg = cg; cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); - cmaskb = cb; - // Create a rough approximation of the color (a 16 bit color) - maskcolor = ((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11); + if (p1[7] >= 'a' && p1[7] <= 'z') - mask = (p1[7] - 'a'); + ca = (p1[7] - 'a'); else if (p1[7] >= 'A' && p1[7] <= 'Z') - mask = (p1[7] - 'A'); + ca = (p1[7] - 'A'); else - mask = 24; - - maskamt = (double)(mask/24.0l); - - othermask = 1 - maskamt; - maskamt /= 0xff; - cmaskr *= maskamt; - cmaskg *= maskamt; - cmaskb *= maskamt; + ca = 24; // for opengl; generate on software too for netsync rgba = (HEX2INT(p1[1]) << 4) + (HEX2INT(p1[2]) << 0) + @@ -1543,9 +1579,8 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) } else { - cmaskr = cmaskg = cmaskb = 0xff; - maskamt = 0; - maskcolor = ((0xff) >> 3) + (((0xff) >> 2) << 5) + (((0xff) >> 3) << 11); + cr = cg = cb = 0xff; + ca = 0; rgba = 0; } @@ -1560,16 +1595,22 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) if (fadeend > 31 || fadeend < 1) fadeend = 31; fadedist = fadeend - fadestart; - fog = NUMFROMCHAR(p2[1]); + fog = (boolean)NUMFROMCHAR(p2[1]); } #undef NUMFROMCHAR if (p3[0] == '#') { - cdestr = cr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); - cdestg = cg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); - cdestb = cb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); - fadecolor = (((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11)); + cfr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); + cfg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); + cfb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); + + if (p1[7] >= 'a' && p1[7] <= 'z') + cfa = (p1[7] - 'a'); + else if (p1[7] >= 'A' && p1[7] <= 'Z') + cfa = (p1[7] - 'A'); + else + cfa = 18; // for opengl; generate on software too for netsync fadergba = (HEX2INT(p3[1]) << 4) + (HEX2INT(p3[2]) << 0) + @@ -1583,7 +1624,8 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) } else { - cdestr = cdestg = cdestb = fadecolor = 0; + cfr = cfg = cfb = 0; + cfa = 18; fadergba = 0x19000000; // default alpha for fade, (25 << 24) } #undef ALPHA2INT @@ -1591,40 +1633,41 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) for (exc = extra_colormaps; exc; exc = exc->next) { +#ifdef EXTRACOLORMAPLUMPS if (exc->lump != LUMPERROR) continue; - if (maskcolor == exc->maskcolor - && fadecolor == exc->fadecolor - && (float)maskamt == (float)exc->maskamt +#endif + if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca + && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa && fadestart == exc->fadestart && fadeend == exc->fadeend && fog == exc->fog) - return exc; + break; } extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL); - extra_colormap->maskcolor = (UINT16)maskcolor; - extra_colormap->fadecolor = (UINT16)fadecolor; - extra_colormap->maskamt = maskamt; - extra_colormap->othermask = othermask; extra_colormap->fadestart = (UINT16)fadestart; extra_colormap->fadeend = (UINT16)fadeend; extra_colormap->fadedist = fadedist; extra_colormap->fog = fog; - extra_colormap->cmaskr = cmaskr; - extra_colormap->cmaskg = cmaskg; - extra_colormap->cmaskb = cmaskb; - extra_colormap->cdestr = cdestr; - extra_colormap->cdestg = cdestg; - extra_colormap->cdestb = cdestb; + extra_colormap->cr = cr; + extra_colormap->cg = cg; + extra_colormap->cb = cb; + extra_colormap->ca = ca; + extra_colormap->cfr = cfr; + extra_colormap->cfg = cfg; + extra_colormap->cfb = cfb; + extra_colormap->cfa = cfa; extra_colormap->rgba = rgba; extra_colormap->fadergba = fadergba; +#ifdef EXTRACOLORMAPLUMPS extra_colormap->lump = LUMPERROR; - extra_colormap->next = extra_colormap->prev = NULL; + extra_colormap->lumpname[0] = 0; +#endif extra_colormap->colormap = R_CreateLightTable(extra_colormap); @@ -1673,7 +1716,8 @@ static int RoundUp(double number) return (int)number; } -const char *R_ColormapNameForColormap(extracolormap_t *extra_colormap) +#ifdef EXTRACOLORMAPLUMPS +const char *R_NameForColormap(extracolormap_t *extra_colormap) { if (!extra_colormap) return "NONE"; @@ -1681,9 +1725,9 @@ const char *R_ColormapNameForColormap(extracolormap_t *extra_colormap) if (extra_colormap->lump == LUMPERROR) return "INLEVEL"; - return W_CheckNameForNum(extra_colormap->lump); + return extra_colormap->lumpname; } - +#endif // // build a table for quick conversion from 8bpp to 15bpp diff --git a/src/r_data.h b/src/r_data.h index db2749834..5600d36dc 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -96,12 +96,19 @@ void R_ClearTextureNumCache(boolean btell); INT32 R_TextureNumForName(const char *name); INT32 R_CheckTextureNumForName(const char *name); +// Extra Colormap lumps (C_START/C_END) are not used anywhere +// Uncomment to enable +//#define EXTRACOLORMAPLUMPS + void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); -extracolormap_t *R_ColormapForName(char *name); +void R_AddColormapToList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); -const char *R_ColormapNameForNum(INT32 num); +#ifdef EXTRACOLORMAPLUMPS +extracolormap_t *R_ColormapForName(char *name); +const char *R_NameForColormap(extracolormap_t *extra_colormap); +#endif extern INT32 numtextures; diff --git a/src/r_defs.h b/src/r_defs.h index e81631eb9..8dd34cd15 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -52,15 +52,12 @@ typedef UINT8 lighttable_t; // ExtraColormap type. Use for extra_colormaps from now on. typedef struct extracolormap_s { - UINT16 maskcolor, fadecolor; - double maskamt, othermask; - UINT16 fadestart, fadeend; - UINT32 fadedist; - INT32 fog; + UINT8 fadestart, fadeend; + UINT8 fadedist; + boolean fog; - // mask rgb for colormap table generation - double cmaskr, cmaskg, cmaskb; - double cdestr, cdestg, cdestb; + // rgba for colormap table generation + UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; // rgba is used in hw mode for colored sector lighting INT32 rgba; // similar to maskcolor in sw mode @@ -68,7 +65,10 @@ typedef struct extracolormap_s lighttable_t *colormap; +#ifdef EXTRACOLORMAPLUMPS lumpnum_t lump; // for colormap lump matching, init to LUMPERROR + char lumpname[9]; // for netsyncing +#endif struct extracolormap_s *next; struct extracolormap_s *prev; From 1e4f5e8d45db305297c3f23088b8eec91d4d6274 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 20:41:12 -0400 Subject: [PATCH 184/573] Remove MAXCOLORMAPS --- src/r_state.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/r_state.h b/src/r_state.h index effa4e36c..91c2092e9 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -40,9 +40,6 @@ extern sprcache_t *spritecachedinfo; extern lighttable_t *colormaps; // Boom colormaps. -// Had to put a limit on colormaps :( -#define MAXCOLORMAPS 60 - extern extracolormap_t *extra_colormaps; // for global animation From 3da38f2a9be36ab980a61fae3a0b18dc58a7d1c0 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 20:52:37 -0400 Subject: [PATCH 185/573] Fixed colormap matching code again * Added debug messages for matching code --- src/p_saveg.c | 26 ++++++++++++++++++++++++++ src/r_data.c | 15 ++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 68d00a42c..137b4ffd0 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -877,6 +877,7 @@ static void P_NetUnArchiveWorld(void) if (diff3 & SD_COLORMAP) { extracolormap_t *exc; + size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), fadeend = READUINT8(get), @@ -920,8 +921,33 @@ static void P_NetUnArchiveWorld(void) break; } + for (exc = extra_colormaps; exc; exc = exc->next) + { +#ifdef EXTRACOLORMAPLUMPS + if (exc->lump != LUMPERROR) + { + dbg_i++; + continue; + } +#endif + if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca + && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa + && fadestart == exc->fadestart + && fadeend == exc->fadeend + && fog == exc->fog) + { + CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + break; + } + dbg_i++; + } + if (!exc) { + CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); exc->fadestart = fadestart; diff --git a/src/r_data.c b/src/r_data.c index 32cf17fa9..e51eb32e9 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1552,6 +1552,8 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) INT32 rgba, fadergba; + size_t dbg_i = 0; + #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) #define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) if (p1[0] == '#') @@ -1635,16 +1637,27 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) { #ifdef EXTRACOLORMAPLUMPS if (exc->lump != LUMPERROR) + { + dbg_i++; continue; + } #endif if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa && fadestart == exc->fadestart && fadeend == exc->fadeend && fog == exc->fog) - break; + { + CONS_Debug(DBG_RENDER, "R_CreateColormap: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + return exc; + } + dbg_i++; } + CONS_Debug(DBG_RENDER, "R_CreateColormap: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL); extra_colormap->fadestart = (UINT16)fadestart; From c007dfacecb8b392e2c063f1f73373d78a29322b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 21:12:56 -0400 Subject: [PATCH 186/573] Savegame fixes --- src/p_saveg.c | 18 +++++++++--------- src/r_defs.h | 1 - 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index eb49e9730..33923551d 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -655,8 +655,6 @@ static void P_NetArchiveWorld(void) WRITEINT32(put, ss->firsttag); WRITEINT32(put, ss->nexttag); } - if (diff3 & SD_MIDMAP) - WRITEINT32(put, ss->midmap); if (diff3 & SD_COLORMAP) { @@ -938,8 +936,8 @@ static void P_NetUnArchiveWorld(void) && fadeend == exc->fadeend && fog == exc->fog) { - CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); break; } dbg_i++; @@ -947,8 +945,8 @@ static void P_NetUnArchiveWorld(void) if (!exc) { - CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); @@ -973,14 +971,16 @@ static void P_NetUnArchiveWorld(void) R_AddColormapToList(exc); - sectors[i].extra_colormap = exc; - #ifdef EXTRACOLORMAPLUMPS exc->lump = LUMPERROR; exc->lumpname[0] = 0; - } // if (!exc) // if (!lumpname[0] || !R_ColormapForName(lumpname)) #endif } + + sectors[i].extra_colormap = exc; +#ifdef EXTRACOLORMAPLUMPS + } +#endif } if (diff & SD_FFLOORS) diff --git a/src/r_defs.h b/src/r_defs.h index 77b56bd30..8dd34cd15 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -393,7 +393,6 @@ typedef struct sector_s // these are saved for netgames, so do not let Lua touch these! INT32 spawn_nexttag, spawn_firsttag; // the actual nexttag/firsttag values may differ if the sector's tag was changed - INT32 spawn_bottommap, spawn_midmap, spawn_topmap; // offsets sector spawned with (via linedef type 7) fixed_t spawn_flr_xoffs, spawn_flr_yoffs; From 22746c1d9140446edc1bac8b0a9358b273a43fd7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 21:12:56 -0400 Subject: [PATCH 187/573] Savegame fixes --- src/p_saveg.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 137b4ffd0..66db8a383 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -877,7 +877,7 @@ static void P_NetUnArchiveWorld(void) if (diff3 & SD_COLORMAP) { extracolormap_t *exc; - size_t dbg_i = 0; + //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), fadeend = READUINT8(get), @@ -926,7 +926,7 @@ static void P_NetUnArchiveWorld(void) #ifdef EXTRACOLORMAPLUMPS if (exc->lump != LUMPERROR) { - dbg_i++; + //dbg_i++; continue; } #endif @@ -936,17 +936,17 @@ static void P_NetUnArchiveWorld(void) && fadeend == exc->fadeend && fog == exc->fog) { - CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); break; } - dbg_i++; + //dbg_i++; } if (!exc) { - CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); @@ -971,14 +971,16 @@ static void P_NetUnArchiveWorld(void) R_AddColormapToList(exc); - sectors[i].extra_colormap = exc; - #ifdef EXTRACOLORMAPLUMPS exc->lump = LUMPERROR; exc->lumpname[0] = 0; - } // if (!exc) // if (!lumpname[0] || !R_ColormapForName(lumpname)) #endif } + + sectors[i].extra_colormap = exc; +#ifdef EXTRACOLORMAPLUMPS + } +#endif } if (diff & SD_FFLOORS) From 53b92a16011a2e235c9f158c321886017956b080 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 21:56:09 -0400 Subject: [PATCH 188/573] Make default extracolormap on init * Calc fadedist in R_CreateLightTable --- src/p_saveg.c | 5 +---- src/r_data.c | 28 ++++++++++++++++++++++------ src/r_defs.h | 1 - 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 66db8a383..7ee41dffd 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -660,7 +660,6 @@ static void P_NetArchiveWorld(void) { WRITEUINT8(put, ss->extra_colormap->fadestart); WRITEUINT8(put, ss->extra_colormap->fadeend); - WRITEUINT8(put, ss->extra_colormap->fadedist); WRITEUINT8(put, (UINT8)ss->extra_colormap->fog); WRITEUINT8(put, ss->extra_colormap->cr); @@ -880,8 +879,7 @@ static void P_NetUnArchiveWorld(void) //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), - fadeend = READUINT8(get), - fadedist = READUINT8(get); + fadeend = READUINT8(get); boolean fog = (boolean)READUINT8(get); @@ -952,7 +950,6 @@ static void P_NetUnArchiveWorld(void) exc->fadestart = fadestart; exc->fadeend = fadeend; - exc->fadedist = fadedist; exc->fog = fog; exc->cr = cr; diff --git a/src/r_data.c b/src/r_data.c index e51eb32e9..f1f04b2d2 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1330,7 +1330,25 @@ void R_ClearColormaps(void) memset(exc, 0, sizeof(*exc)); } - extra_colormaps = NULL; + // make a default extra_colormap + exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + exc->cr = exc->cg = exc->cb = 0xff; + exc->ca = 0; + exc->cfr = exc->cfg = exc->cfb = 0; + exc->cfa = 18; + exc->fadestart = 0; + exc->fadeend = 31; + exc->fog = 0; + exc->rgba = 0; + exc->fadergba = 0x19000000; + exc->colormap = R_CreateLightTable(exc); +#ifdef EXTRACOLORMAPLUMPS + exc->lump = LUMPERROR; + exc->lumpname[0] = 0; +#endif + exc->next = exc->prev = NULL; + + extra_colormaps = exc; } // @@ -1427,8 +1445,8 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) cfb = extra_colormap->cfb; // cfa = extra_colormap->cfa; // unused in software - UINT32 fadestart = (UINT16)extra_colormap->fadestart, - fadedist = extra_colormap->fadedist; + UINT8 fadestart = extra_colormap->fadestart, + fadedist = extra_colormap->fadeend - extra_colormap->fadestart; lighttable_t *lighttable = NULL; size_t i; @@ -1548,7 +1566,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extracolormap_t *extra_colormap, *exc; UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; - UINT32 fadestart = 0, fadeend = 31, fadedist = 31; + UINT32 fadestart = 0, fadeend = 31; INT32 rgba, fadergba; @@ -1596,7 +1614,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) fadestart = 0; if (fadeend > 31 || fadeend < 1) fadeend = 31; - fadedist = fadeend - fadestart; fog = (boolean)NUMFROMCHAR(p2[1]); } #undef NUMFROMCHAR @@ -1662,7 +1679,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extra_colormap->fadestart = (UINT16)fadestart; extra_colormap->fadeend = (UINT16)fadeend; - extra_colormap->fadedist = fadedist; extra_colormap->fog = fog; extra_colormap->cr = cr; diff --git a/src/r_defs.h b/src/r_defs.h index 8dd34cd15..22d4fdf14 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -53,7 +53,6 @@ typedef UINT8 lighttable_t; typedef struct extracolormap_s { UINT8 fadestart, fadeend; - UINT8 fadedist; boolean fog; // rgba for colormap table generation From 43ae25c4fd3b0e912e6ff433701aaa0c19f35224 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 21:56:09 -0400 Subject: [PATCH 189/573] Make default extracolormap on init * Calc fadedist in R_CreateLightTable --- src/p_saveg.c | 5 +---- src/r_data.c | 28 ++++++++++++++++++++++------ src/r_defs.h | 1 - 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 66db8a383..7ee41dffd 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -660,7 +660,6 @@ static void P_NetArchiveWorld(void) { WRITEUINT8(put, ss->extra_colormap->fadestart); WRITEUINT8(put, ss->extra_colormap->fadeend); - WRITEUINT8(put, ss->extra_colormap->fadedist); WRITEUINT8(put, (UINT8)ss->extra_colormap->fog); WRITEUINT8(put, ss->extra_colormap->cr); @@ -880,8 +879,7 @@ static void P_NetUnArchiveWorld(void) //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), - fadeend = READUINT8(get), - fadedist = READUINT8(get); + fadeend = READUINT8(get); boolean fog = (boolean)READUINT8(get); @@ -952,7 +950,6 @@ static void P_NetUnArchiveWorld(void) exc->fadestart = fadestart; exc->fadeend = fadeend; - exc->fadedist = fadedist; exc->fog = fog; exc->cr = cr; diff --git a/src/r_data.c b/src/r_data.c index e51eb32e9..f1f04b2d2 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1330,7 +1330,25 @@ void R_ClearColormaps(void) memset(exc, 0, sizeof(*exc)); } - extra_colormaps = NULL; + // make a default extra_colormap + exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + exc->cr = exc->cg = exc->cb = 0xff; + exc->ca = 0; + exc->cfr = exc->cfg = exc->cfb = 0; + exc->cfa = 18; + exc->fadestart = 0; + exc->fadeend = 31; + exc->fog = 0; + exc->rgba = 0; + exc->fadergba = 0x19000000; + exc->colormap = R_CreateLightTable(exc); +#ifdef EXTRACOLORMAPLUMPS + exc->lump = LUMPERROR; + exc->lumpname[0] = 0; +#endif + exc->next = exc->prev = NULL; + + extra_colormaps = exc; } // @@ -1427,8 +1445,8 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) cfb = extra_colormap->cfb; // cfa = extra_colormap->cfa; // unused in software - UINT32 fadestart = (UINT16)extra_colormap->fadestart, - fadedist = extra_colormap->fadedist; + UINT8 fadestart = extra_colormap->fadestart, + fadedist = extra_colormap->fadeend - extra_colormap->fadestart; lighttable_t *lighttable = NULL; size_t i; @@ -1548,7 +1566,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extracolormap_t *extra_colormap, *exc; UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; - UINT32 fadestart = 0, fadeend = 31, fadedist = 31; + UINT32 fadestart = 0, fadeend = 31; INT32 rgba, fadergba; @@ -1596,7 +1614,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) fadestart = 0; if (fadeend > 31 || fadeend < 1) fadeend = 31; - fadedist = fadeend - fadestart; fog = (boolean)NUMFROMCHAR(p2[1]); } #undef NUMFROMCHAR @@ -1662,7 +1679,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extra_colormap->fadestart = (UINT16)fadestart; extra_colormap->fadeend = (UINT16)fadeend; - extra_colormap->fadedist = fadedist; extra_colormap->fog = fog; extra_colormap->cr = cr; diff --git a/src/r_defs.h b/src/r_defs.h index 8dd34cd15..22d4fdf14 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -53,7 +53,6 @@ typedef UINT8 lighttable_t; typedef struct extracolormap_s { UINT8 fadestart, fadeend; - UINT8 fadedist; boolean fog; // rgba for colormap table generation From 9038ba4d9c941d4ae0d06c418d115cbb7b3ffe75 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 22:35:03 -0400 Subject: [PATCH 190/573] Add COLORMAPREVERSELIST ifdef to toggle Newest -> Oldest extra_colormaps order --- src/r_data.c | 7 +++++++ src/r_data.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index f1f04b2d2..160539437 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1369,11 +1369,18 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) return; } +#ifdef COLORMAPREVERSELIST + extra_colormaps->prev = extra_colormap; + extra_colormap->next = extra_colormaps; + extra_colormaps = extra_colormap; + extra_colormap->prev = 0; +#else for (exc = extra_colormaps; exc->next; exc = exc->next); exc->next = extra_colormap; extra_colormap->prev = exc; extra_colormap->next = 0; +#endif } #ifdef EXTRACOLORMAPLUMPS diff --git a/src/r_data.h b/src/r_data.h index 5600d36dc..e6eec41b4 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -100,6 +100,9 @@ INT32 R_CheckTextureNumForName(const char *name); // Uncomment to enable //#define EXTRACOLORMAPLUMPS +// Uncomment to make extra_colormaps order Newest -> Oldest +//#define COLORMAPREVERSELIST + void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); void R_AddColormapToList(extracolormap_t *extra_colormap); From 17e101a24b81f8baaa8382b4ae26f28842330d2f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 22:35:03 -0400 Subject: [PATCH 191/573] Add COLORMAPREVERSELIST ifdef to toggle Newest -> Oldest extra_colormaps order --- src/r_data.c | 7 +++++++ src/r_data.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index f1f04b2d2..160539437 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1369,11 +1369,18 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) return; } +#ifdef COLORMAPREVERSELIST + extra_colormaps->prev = extra_colormap; + extra_colormap->next = extra_colormaps; + extra_colormaps = extra_colormap; + extra_colormap->prev = 0; +#else for (exc = extra_colormaps; exc->next; exc = exc->next); exc->next = extra_colormap; extra_colormap->prev = exc; extra_colormap->next = 0; +#endif } #ifdef EXTRACOLORMAPLUMPS diff --git a/src/r_data.h b/src/r_data.h index 5600d36dc..e6eec41b4 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -100,6 +100,9 @@ INT32 R_CheckTextureNumForName(const char *name); // Uncomment to enable //#define EXTRACOLORMAPLUMPS +// Uncomment to make extra_colormaps order Newest -> Oldest +//#define COLORMAPREVERSELIST + void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); void R_AddColormapToList(extracolormap_t *extra_colormap); From b7a216c78b6121642a9a9dafc501cfe565ac2ca3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 22:35:03 -0400 Subject: [PATCH 192/573] Add COLORMAPREVERSELIST ifdef to toggle Newest -> Oldest extra_colormaps order --- src/r_data.c | 9 +++++++++ src/r_data.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index f1f04b2d2..ffc6cc7fd 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1359,7 +1359,9 @@ void R_ClearColormaps(void) // void R_AddColormapToList(extracolormap_t *extra_colormap) { +#ifndef COLORMAPREVERSELIST extracolormap_t *exc; +#endif if (!extra_colormaps) { @@ -1369,11 +1371,18 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) return; } +#ifdef COLORMAPREVERSELIST + extra_colormaps->prev = extra_colormap; + extra_colormap->next = extra_colormaps; + extra_colormaps = extra_colormap; + extra_colormap->prev = 0; +#else for (exc = extra_colormaps; exc->next; exc = exc->next); exc->next = extra_colormap; extra_colormap->prev = exc; extra_colormap->next = 0; +#endif } #ifdef EXTRACOLORMAPLUMPS diff --git a/src/r_data.h b/src/r_data.h index 5600d36dc..e6eec41b4 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -100,6 +100,9 @@ INT32 R_CheckTextureNumForName(const char *name); // Uncomment to enable //#define EXTRACOLORMAPLUMPS +// Uncomment to make extra_colormaps order Newest -> Oldest +//#define COLORMAPREVERSELIST + void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); void R_AddColormapToList(extracolormap_t *extra_colormap); From 36923ae7b0ae7da2459af0ecee5cf231b0419369 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 10:05:25 -0400 Subject: [PATCH 193/573] Use percentage calc instead of interval decrement for tic-based timing --- src/p_lights.c | 32 ++++++++++++++++---------------- src/p_saveg.c | 12 ++++++------ src/p_spec.h | 8 ++++---- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/p_lights.c b/src/p_lights.c index 77d05dad3..95171155e 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -352,19 +352,17 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean P_AddThinker(&ll->thinker); // add thinker ll->sector = sector; + ll->sourcelevel = sector->lightlevel; ll->destlevel = destvalue; if (ticbased) { - ll->ticbased = ticbased; - ll->timer = abs(speed); - ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->timer))/FRACUNIT; - if (!ll->speed) - ll->speed = (destvalue < sector->lightlevel) ? -1 : 1; - ll->interval = max(FixedFloor(FixedDiv(ll->timer, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1); + ll->ticbased = true; + ll->timer = ll->speed = abs(speed); // use ll->speed for total duration } else { + ll->ticbased = false; ll->timer = -1; ll->speed = abs(speed); } @@ -389,15 +387,17 @@ void T_LightFade(lightlevel_t *ll) { if (--ll->timer <= 0) { - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } - else if (!(ll->timer % ll->interval)) + else { - if (ll->speed < 0) - ll->sector->lightlevel = max(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); - else - ll->sector->lightlevel = min(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + INT16 delta = abs(ll->destlevel - ll->sourcelevel); + fixed_t factor = min(FixedDiv(ll->speed - ll->timer, ll->speed), 1*FRACUNIT); + if (ll->destlevel < ll->sourcelevel) + ll->sector->lightlevel = max(min(ll->sector->lightlevel, ll->sourcelevel - (INT16)FixedMul(delta, factor)), ll->destlevel); + else if (ll->destlevel > ll->sourcelevel) + ll->sector->lightlevel = min(max(ll->sector->lightlevel, ll->sourcelevel + (INT16)FixedMul(delta, factor)), ll->destlevel); } return; } @@ -408,12 +408,12 @@ void T_LightFade(lightlevel_t *ll) if (ll->sector->lightlevel + ll->speed >= ll->destlevel) { // stop changing light level - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } else - ll->sector->lightlevel = (INT16)(ll->sector->lightlevel + (INT16)ll->speed); // move lightlevel + ll->sector->lightlevel += ll->speed; // move lightlevel } else { @@ -421,11 +421,11 @@ void T_LightFade(lightlevel_t *ll) if (ll->sector->lightlevel - ll->speed <= ll->destlevel) { // stop changing light level - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } else - ll->sector->lightlevel = (INT16)(ll->sector->lightlevel - (INT16)ll->speed); // move lightlevel + ll->sector->lightlevel -= ll->speed; // move lightlevel } } diff --git a/src/p_saveg.c b/src/p_saveg.c index eefee072d..e9f07de4c 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1537,11 +1537,11 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) const lightlevel_t *ht = (const void *)th; WRITEUINT8(save_p, type); WRITEUINT32(save_p, SaveSector(ht->sector)); - WRITEINT32(save_p, ht->destlevel); - WRITEINT32(save_p, ht->speed); + WRITEINT16(save_p, ht->sourcelevel); + WRITEINT16(save_p, ht->destlevel); + WRITEINT16(save_p, ht->speed); WRITEUINT8(save_p, (UINT8)ht->ticbased); WRITEINT32(save_p, ht->timer); - WRITEUINT32(save_p, ht->interval); } // @@ -2513,11 +2513,11 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) lightlevel_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->sector = LoadSector(READUINT32(save_p)); - ht->destlevel = READINT32(save_p); - ht->speed = READINT32(save_p); + ht->sourcelevel = READINT16(save_p); + ht->destlevel = READINT16(save_p); + ht->speed = READINT16(save_p); ht->ticbased = (boolean)READUINT8(save_p); ht->timer = READINT32(save_p); - ht->interval = READUINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; P_AddThinker(&ht->thinker); diff --git a/src/p_spec.h b/src/p_spec.h index 1e327c5f2..69087d6c4 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -136,13 +136,13 @@ typedef struct { thinker_t thinker; ///< Thinker in use for the effect. sector_t *sector; ///< Sector where action is taking place. - INT32 destlevel; ///< Light level we're fading to. - INT32 speed; ///< Speed at which to change light level. + INT16 sourcelevel; ///< Light level we're fading from. + INT16 destlevel; ///< Light level we're fading to. + INT16 speed; ///< Speed at which to change light level. OR: Tic-based duration // Tic-based behavior boolean ticbased; ///< Tic-based logic - INT32 timer; ///< Tic-based timer - UINT32 interval; ///< Interval to deduct light level + INT32 timer; ///< Tic-based timer } lightlevel_t; #define GLOWSPEED 8 From 9a52816cb494a67ba45ecb6ddb50dcd36808c79b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 10:28:24 -0400 Subject: [PATCH 194/573] Use percentage calc instead of interval decrement for tic-based fading --- src/p_saveg.c | 4 ++-- src/p_spec.c | 41 ++++++++++++++++++++++++----------------- src/p_spec.h | 2 +- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index cafd05ea3..5550c7a8b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1590,12 +1590,12 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, ht->sectornum); WRITEUINT32(save_p, ht->ffloornum); WRITEINT32(save_p, ht->alpha); + WRITEINT16(save_p, ht->sourcevalue); WRITEINT16(save_p, ht->destvalue); WRITEINT16(save_p, ht->destlightlevel); WRITEINT16(save_p, ht->speed); WRITEUINT8(save_p, (UINT8)ht->ticbased); WRITEINT32(save_p, ht->timer); - WRITEUINT32(save_p, ht->interval); WRITEUINT8(save_p, ht->doexists); WRITEUINT8(save_p, ht->dotranslucent); WRITEUINT8(save_p, ht->dolighting); @@ -2602,12 +2602,12 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->sectornum = READUINT32(save_p); ht->ffloornum = READUINT32(save_p); ht->alpha = READINT32(save_p); + ht->sourcevalue = READINT16(save_p); ht->destvalue = READINT16(save_p); ht->destlightlevel = READINT16(save_p); ht->speed = READINT16(save_p); ht->ticbased = (boolean)READUINT8(save_p); ht->timer = READINT32(save_p); - ht->interval = READUINT32(save_p); ht->doexists = READUINT8(save_p); ht->dotranslucent = READUINT8(save_p); ht->dolighting = READUINT8(save_p); diff --git a/src/p_spec.c b/src/p_spec.c index 8d42ef575..cd63191c9 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -105,7 +105,7 @@ static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t * static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finalize); #define P_RemoveFakeFloorFader(l) P_ResetFakeFloorFader(l, NULL, false); -static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, boolean ticbased, INT32 *timer, UINT32 interval, +static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destvalue, INT16 speed, boolean ticbased, INT32 *timer, boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha); static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, INT16 destvalue, INT16 speed, boolean ticbased, boolean relative, @@ -3363,9 +3363,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_RemoveFakeFloorFader(rover); P_FadeFakeFloor(rover, + rover->alpha, max(1, min(256, (line->flags & ML_EFFECT3) ? rover->alpha + destvalue : destvalue)), 0, // set alpha immediately - false, NULL, 0, // tic-based logic + false, NULL, // tic-based logic false, // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // handle FF_TRANSLUCENT false, // do not handle lighting @@ -3437,9 +3438,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_RemoveFakeFloorFader(rover); P_FadeFakeFloor(rover, + rover->alpha, max(1, min(256, (line->flags & ML_EFFECT3) ? rover->alpha + destvalue : destvalue)), 0, // set alpha immediately - false, NULL, 0, // tic-based logic + false, NULL, // tic-based logic !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT !(line->flags & ML_EFFECT2), // do not handle lighting @@ -7513,13 +7515,13 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz { if (finalize) P_FadeFakeFloor(rover, + fadingdata->sourcevalue, fadingdata->alpha >= fadingdata->destvalue ? fadingdata->alpha - 1 : // trigger fade-out finish fadingdata->alpha + 1, // trigger fade-in finish 0, fadingdata->ticbased, &fadingdata->timer, - fadingdata->interval, fadingdata->doexists, fadingdata->dotranslucent, fadingdata->docollision, @@ -7538,7 +7540,7 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz } } -static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, boolean ticbased, INT32 *timer, UINT32 interval, +static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destvalue, INT16 speed, boolean ticbased, INT32 *timer, boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha) { boolean stillfading = false; @@ -7592,8 +7594,12 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, bo { if (!ticbased) alpha -= speed; - else if (ticbased && !((*timer) % interval)) - alpha = max(alpha - speed, destvalue); + else + { + INT16 delta = abs(destvalue - sourcevalue); + fixed_t factor = min(FixedDiv(speed - (*timer), speed), 1*FRACUNIT); + alpha = max(min(alpha, sourcevalue - (INT16)FixedMul(delta, factor)), destvalue); + } stillfading = true; } } @@ -7601,7 +7607,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, bo { // finish fading in if (speed < 1 || (!ticbased && alpha + speed >= destvalue - speed) || - (ticbased && (--(*timer) <= 0|| alpha >= destvalue))) + (ticbased && (--(*timer) <= 0 || alpha >= destvalue))) { alpha = destvalue; @@ -7623,8 +7629,12 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 destvalue, INT16 speed, bo { if (!ticbased) alpha += speed; - else if (ticbased && !((*timer) % interval)) - alpha = min(alpha + speed, destvalue); + else + { + INT16 delta = abs(destvalue - sourcevalue); + fixed_t factor = min(FixedDiv(speed - (*timer), speed), 1*FRACUNIT); + alpha = min(max(alpha, sourcevalue + (INT16)FixedMul(delta, factor)), destvalue); + } stillfading = true; } } @@ -7813,22 +7823,19 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor d->sectornum = (UINT32)sectornum; d->ffloornum = (UINT32)ffloornum; - d->alpha = rover->alpha; + d->alpha = d->sourcevalue = rover->alpha; d->destvalue = max(1, min(256, relative ? rover->alpha + destvalue : destvalue)); // ffloor->alpha is 1-256 if (ticbased) { d->ticbased = true; - d->timer = abs(speed); - d->speed = max(abs(FixedFloor(FixedDiv(d->destvalue - d->alpha, d->timer))/FRACUNIT), 1); - d->interval = max(FixedFloor(FixedDiv(d->timer, abs(d->destvalue - d->alpha)))/FRACUNIT, 1); + d->timer = d->speed = abs(speed); // use d->speed as total duration } else { - d->speed = max(1, speed); // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker d->ticbased = false; + d->speed = max(1, speed); // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker d->timer = -1; - d->interval = 0; } d->doexists = doexists; @@ -7872,7 +7879,7 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor */ void T_Fade(fade_t *d) { - if (d->rover && !P_FadeFakeFloor(d->rover, d->destvalue, d->speed, d->ticbased, &d->timer, d->interval, + if (d->rover && !P_FadeFakeFloor(d->rover, d->sourcevalue, d->destvalue, d->speed, d->ticbased, &d->timer, d->doexists, d->dotranslucent, d->dolighting, d->docollision, d->doghostfade, d->exactalpha)) { // Finalize lighting, copypasta from P_AddFakeFloorFader diff --git a/src/p_spec.h b/src/p_spec.h index 25f6218dd..1970aeb6b 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -469,12 +469,12 @@ typedef struct UINT32 sectornum; ///< Number of ffloor target sector UINT32 ffloornum; ///< Number of ffloor of target sector INT32 alpha; ///< Internal alpha counter + INT16 sourcevalue; ///< Transparency value to fade from INT16 destvalue; ///< Transparency value to fade to INT16 destlightlevel; ///< Light level to fade to INT16 speed; ///< Speed to fade by boolean ticbased; ///< Tic-based logic toggle INT32 timer; ///< Timer for tic-based logic - UINT32 interval; ///< Skip interval for tic-based logic boolean doexists; ///< Handle FF_EXISTS boolean dotranslucent; ///< Handle FF_TRANSLUCENT boolean dolighting; ///< Handle shadows and light blocks From 56b947ae95afe2ea1767ef3a82aac3fb4197e2e7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 13:10:14 -0400 Subject: [PATCH 195/573] Remove cr/cg/cb/ca in favor of rgba * Change default colormap values to be in sync with rgba/fadergba --- src/p_saveg.c | 51 +++++---------------------------------- src/r_data.c | 66 +++++++++++++-------------------------------------- src/r_defs.h | 6 ++--- 3 files changed, 24 insertions(+), 99 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 7ee41dffd..710c24821 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -662,15 +662,6 @@ static void P_NetArchiveWorld(void) WRITEUINT8(put, ss->extra_colormap->fadeend); WRITEUINT8(put, (UINT8)ss->extra_colormap->fog); - WRITEUINT8(put, ss->extra_colormap->cr); - WRITEUINT8(put, ss->extra_colormap->cg); - WRITEUINT8(put, ss->extra_colormap->cb); - WRITEUINT8(put, ss->extra_colormap->ca); - WRITEUINT8(put, ss->extra_colormap->cfr); - WRITEUINT8(put, ss->extra_colormap->cfg); - WRITEUINT8(put, ss->extra_colormap->cfb); - WRITEUINT8(put, ss->extra_colormap->cfa); - WRITEINT32(put, ss->extra_colormap->rgba); WRITEINT32(put, ss->extra_colormap->fadergba); @@ -883,15 +874,6 @@ static void P_NetUnArchiveWorld(void) boolean fog = (boolean)READUINT8(get); - UINT8 cr = READUINT8(get), - cg = READUINT8(get), - cb = READUINT8(get), - ca = READUINT8(get), - cfr = READUINT8(get), - cfg = READUINT8(get), - cfb = READUINT8(get), - cfa = READUINT8(get); - INT32 rgba = READINT32(get), fadergba = READINT32(get); @@ -905,20 +887,6 @@ static void P_NetUnArchiveWorld(void) { #endif - for (exc = extra_colormaps; exc; exc = exc->next) - { -#ifdef EXTRACOLORMAPLUMPS - if (exc->lump != LUMPERROR) - continue; -#endif - if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca - && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa - && fadestart == exc->fadestart - && fadeend == exc->fadeend - && fog == exc->fog) - break; - } - for (exc = extra_colormaps; exc; exc = exc->next) { #ifdef EXTRACOLORMAPLUMPS @@ -928,14 +896,15 @@ static void P_NetUnArchiveWorld(void) continue; } #endif - if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca - && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa + if (rgba == exc->rgba + && fadergba == exc->fadergba && fadestart == exc->fadestart && fadeend == exc->fadeend && fog == exc->fog) { // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); break; } //dbg_i++; @@ -944,7 +913,8 @@ static void P_NetUnArchiveWorld(void) if (!exc) { // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); @@ -952,15 +922,6 @@ static void P_NetUnArchiveWorld(void) exc->fadeend = fadeend; exc->fog = fog; - exc->cr = cr; - exc->cg = cg; - exc->cb = cb; - exc->ca = ca; - exc->cfr = cfr; - exc->cfg = cfg; - exc->cfb = cfb; - exc->cfa = cfa; - exc->rgba = rgba; exc->fadergba = fadergba; diff --git a/src/r_data.c b/src/r_data.c index ffc6cc7fd..005056ec0 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1332,10 +1332,6 @@ void R_ClearColormaps(void) // make a default extra_colormap exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); - exc->cr = exc->cg = exc->cb = 0xff; - exc->ca = 0; - exc->cfr = exc->cfg = exc->cfb = 0; - exc->cfa = 18; exc->fadestart = 0; exc->fadeend = 31; exc->fog = 0; @@ -1411,10 +1407,6 @@ extracolormap_t *R_ColormapForName(char *name) // We set all params of the colormap to normal because there // is no real way to tell how GL should handle a colormap lump anyway.. - exc->cr = exc->cg = exc->cb = 0xff; - exc->ca = 0; - exc->cfr = exc->cfg = exc->cfb = 0; - exc->cfa = 18; exc->fadestart = 0; exc->fadeend = 31; exc->fog = 0; @@ -1445,14 +1437,14 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; double maskamt = 0, othermask = 0; - UINT8 cr = extra_colormap->cr, - cg = extra_colormap->cg, - cb = extra_colormap->cb, - ca = extra_colormap->ca, - cfr = extra_colormap->cfr, - cfg = extra_colormap->cfg, - cfb = extra_colormap->cfb; -// cfa = extra_colormap->cfa; // unused in software + UINT8 cr = (extra_colormap->rgba) & 0xFF, + cg = (extra_colormap->rgba >> 8) & 0xFF, + cb = (extra_colormap->rgba >> 16) & 0xFF, + ca = (extra_colormap->rgba >> 24) & 0xFF, + cfr = (extra_colormap->fadergba) & 0xFF, + cfg = (extra_colormap->fadergba >> 8) & 0xFF, + cfb = (extra_colormap->fadergba >> 16) & 0xFF; +// cfa = (extra_colormap->fadergba >> 24) & 0xFF; // unused in software UINT8 fadestart = extra_colormap->fadestart, fadedist = extra_colormap->fadeend - extra_colormap->fadestart; @@ -1594,22 +1586,13 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) else if (p1[7] >= 'A' && p1[7] <= 'Z') ca = (p1[7] - 'A'); else - ca = 24; + ca = 25; - // for opengl; generate on software too for netsync - rgba = (HEX2INT(p1[1]) << 4) + (HEX2INT(p1[2]) << 0) + - (HEX2INT(p1[3]) << 12) + (HEX2INT(p1[4]) << 8) + - (HEX2INT(p1[5]) << 20) + (HEX2INT(p1[6]) << 16); - - if ((p1[7] >= 'a' && p1[7] <= 'z') || (p1[7] >= 'A' && p1[7] <= 'Z')) - rgba += (ALPHA2INT(p1[7]) << 24); - else - rgba += (25 << 24); + rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); } else { - cr = cg = cb = 0xff; - ca = 0; + cr = cg = cb = ca = 0; rgba = 0; } @@ -1638,22 +1621,14 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) else if (p1[7] >= 'A' && p1[7] <= 'Z') cfa = (p1[7] - 'A'); else - cfa = 18; + cfa = 25; - // for opengl; generate on software too for netsync - fadergba = (HEX2INT(p3[1]) << 4) + (HEX2INT(p3[2]) << 0) + - (HEX2INT(p3[3]) << 12) + (HEX2INT(p3[4]) << 8) + - (HEX2INT(p3[5]) << 20) + (HEX2INT(p3[6]) << 16); - - if ((p3[7] >= 'a' && p3[7] <= 'z') || (p3[7] >= 'A' && p3[7] <= 'Z')) - fadergba += (ALPHA2INT(p3[7]) << 24); - else - fadergba += (25 << 24); + fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); } else { cfr = cfg = cfb = 0; - cfa = 18; + cfa = 25; fadergba = 0x19000000; // default alpha for fade, (25 << 24) } #undef ALPHA2INT @@ -1668,8 +1643,8 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) continue; } #endif - if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca - && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa + if (rgba == exc->rgba + && fadergba == exc->fadergba && fadestart == exc->fadestart && fadeend == exc->fadeend && fog == exc->fog) @@ -1690,15 +1665,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extra_colormap->fadeend = (UINT16)fadeend; extra_colormap->fog = fog; - extra_colormap->cr = cr; - extra_colormap->cg = cg; - extra_colormap->cb = cb; - extra_colormap->ca = ca; - extra_colormap->cfr = cfr; - extra_colormap->cfg = cfg; - extra_colormap->cfb = cfb; - extra_colormap->cfa = cfa; - extra_colormap->rgba = rgba; extra_colormap->fadergba = fadergba; diff --git a/src/r_defs.h b/src/r_defs.h index 22d4fdf14..99fad2b44 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -55,10 +55,8 @@ typedef struct extracolormap_s UINT8 fadestart, fadeend; boolean fog; - // rgba for colormap table generation - UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; - - // rgba is used in hw mode for colored sector lighting + // store rgba values in combined bitwise + // also used in OpenGL instead lighttables INT32 rgba; // similar to maskcolor in sw mode INT32 fadergba; // The colour the colourmaps fade to From a818b9a1dc0598e88eb24d912979f0cfcff0c06d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 13:10:14 -0400 Subject: [PATCH 196/573] Remove cr/cg/cb/ca in favor of rgba * Change default colormap values to be in sync with rgba/fadergba --- src/p_saveg.c | 51 +++++---------------------------------- src/r_data.c | 66 +++++++++++++-------------------------------------- src/r_defs.h | 6 ++--- 3 files changed, 24 insertions(+), 99 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 7ee41dffd..710c24821 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -662,15 +662,6 @@ static void P_NetArchiveWorld(void) WRITEUINT8(put, ss->extra_colormap->fadeend); WRITEUINT8(put, (UINT8)ss->extra_colormap->fog); - WRITEUINT8(put, ss->extra_colormap->cr); - WRITEUINT8(put, ss->extra_colormap->cg); - WRITEUINT8(put, ss->extra_colormap->cb); - WRITEUINT8(put, ss->extra_colormap->ca); - WRITEUINT8(put, ss->extra_colormap->cfr); - WRITEUINT8(put, ss->extra_colormap->cfg); - WRITEUINT8(put, ss->extra_colormap->cfb); - WRITEUINT8(put, ss->extra_colormap->cfa); - WRITEINT32(put, ss->extra_colormap->rgba); WRITEINT32(put, ss->extra_colormap->fadergba); @@ -883,15 +874,6 @@ static void P_NetUnArchiveWorld(void) boolean fog = (boolean)READUINT8(get); - UINT8 cr = READUINT8(get), - cg = READUINT8(get), - cb = READUINT8(get), - ca = READUINT8(get), - cfr = READUINT8(get), - cfg = READUINT8(get), - cfb = READUINT8(get), - cfa = READUINT8(get); - INT32 rgba = READINT32(get), fadergba = READINT32(get); @@ -905,20 +887,6 @@ static void P_NetUnArchiveWorld(void) { #endif - for (exc = extra_colormaps; exc; exc = exc->next) - { -#ifdef EXTRACOLORMAPLUMPS - if (exc->lump != LUMPERROR) - continue; -#endif - if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca - && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa - && fadestart == exc->fadestart - && fadeend == exc->fadeend - && fog == exc->fog) - break; - } - for (exc = extra_colormaps; exc; exc = exc->next) { #ifdef EXTRACOLORMAPLUMPS @@ -928,14 +896,15 @@ static void P_NetUnArchiveWorld(void) continue; } #endif - if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca - && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa + if (rgba == exc->rgba + && fadergba == exc->fadergba && fadestart == exc->fadestart && fadeend == exc->fadeend && fog == exc->fog) { // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); break; } //dbg_i++; @@ -944,7 +913,8 @@ static void P_NetUnArchiveWorld(void) if (!exc) { // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); @@ -952,15 +922,6 @@ static void P_NetUnArchiveWorld(void) exc->fadeend = fadeend; exc->fog = fog; - exc->cr = cr; - exc->cg = cg; - exc->cb = cb; - exc->ca = ca; - exc->cfr = cfr; - exc->cfg = cfg; - exc->cfb = cfb; - exc->cfa = cfa; - exc->rgba = rgba; exc->fadergba = fadergba; diff --git a/src/r_data.c b/src/r_data.c index ffc6cc7fd..005056ec0 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1332,10 +1332,6 @@ void R_ClearColormaps(void) // make a default extra_colormap exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); - exc->cr = exc->cg = exc->cb = 0xff; - exc->ca = 0; - exc->cfr = exc->cfg = exc->cfb = 0; - exc->cfa = 18; exc->fadestart = 0; exc->fadeend = 31; exc->fog = 0; @@ -1411,10 +1407,6 @@ extracolormap_t *R_ColormapForName(char *name) // We set all params of the colormap to normal because there // is no real way to tell how GL should handle a colormap lump anyway.. - exc->cr = exc->cg = exc->cb = 0xff; - exc->ca = 0; - exc->cfr = exc->cfg = exc->cfb = 0; - exc->cfa = 18; exc->fadestart = 0; exc->fadeend = 31; exc->fog = 0; @@ -1445,14 +1437,14 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; double maskamt = 0, othermask = 0; - UINT8 cr = extra_colormap->cr, - cg = extra_colormap->cg, - cb = extra_colormap->cb, - ca = extra_colormap->ca, - cfr = extra_colormap->cfr, - cfg = extra_colormap->cfg, - cfb = extra_colormap->cfb; -// cfa = extra_colormap->cfa; // unused in software + UINT8 cr = (extra_colormap->rgba) & 0xFF, + cg = (extra_colormap->rgba >> 8) & 0xFF, + cb = (extra_colormap->rgba >> 16) & 0xFF, + ca = (extra_colormap->rgba >> 24) & 0xFF, + cfr = (extra_colormap->fadergba) & 0xFF, + cfg = (extra_colormap->fadergba >> 8) & 0xFF, + cfb = (extra_colormap->fadergba >> 16) & 0xFF; +// cfa = (extra_colormap->fadergba >> 24) & 0xFF; // unused in software UINT8 fadestart = extra_colormap->fadestart, fadedist = extra_colormap->fadeend - extra_colormap->fadestart; @@ -1594,22 +1586,13 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) else if (p1[7] >= 'A' && p1[7] <= 'Z') ca = (p1[7] - 'A'); else - ca = 24; + ca = 25; - // for opengl; generate on software too for netsync - rgba = (HEX2INT(p1[1]) << 4) + (HEX2INT(p1[2]) << 0) + - (HEX2INT(p1[3]) << 12) + (HEX2INT(p1[4]) << 8) + - (HEX2INT(p1[5]) << 20) + (HEX2INT(p1[6]) << 16); - - if ((p1[7] >= 'a' && p1[7] <= 'z') || (p1[7] >= 'A' && p1[7] <= 'Z')) - rgba += (ALPHA2INT(p1[7]) << 24); - else - rgba += (25 << 24); + rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); } else { - cr = cg = cb = 0xff; - ca = 0; + cr = cg = cb = ca = 0; rgba = 0; } @@ -1638,22 +1621,14 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) else if (p1[7] >= 'A' && p1[7] <= 'Z') cfa = (p1[7] - 'A'); else - cfa = 18; + cfa = 25; - // for opengl; generate on software too for netsync - fadergba = (HEX2INT(p3[1]) << 4) + (HEX2INT(p3[2]) << 0) + - (HEX2INT(p3[3]) << 12) + (HEX2INT(p3[4]) << 8) + - (HEX2INT(p3[5]) << 20) + (HEX2INT(p3[6]) << 16); - - if ((p3[7] >= 'a' && p3[7] <= 'z') || (p3[7] >= 'A' && p3[7] <= 'Z')) - fadergba += (ALPHA2INT(p3[7]) << 24); - else - fadergba += (25 << 24); + fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); } else { cfr = cfg = cfb = 0; - cfa = 18; + cfa = 25; fadergba = 0x19000000; // default alpha for fade, (25 << 24) } #undef ALPHA2INT @@ -1668,8 +1643,8 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) continue; } #endif - if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca - && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa + if (rgba == exc->rgba + && fadergba == exc->fadergba && fadestart == exc->fadestart && fadeend == exc->fadeend && fog == exc->fog) @@ -1690,15 +1665,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extra_colormap->fadeend = (UINT16)fadeend; extra_colormap->fog = fog; - extra_colormap->cr = cr; - extra_colormap->cg = cg; - extra_colormap->cb = cb; - extra_colormap->ca = ca; - extra_colormap->cfr = cfr; - extra_colormap->cfg = cfg; - extra_colormap->cfb = cfb; - extra_colormap->cfa = cfa; - extra_colormap->rgba = rgba; extra_colormap->fadergba = fadergba; diff --git a/src/r_defs.h b/src/r_defs.h index 22d4fdf14..99fad2b44 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -55,10 +55,8 @@ typedef struct extracolormap_s UINT8 fadestart, fadeend; boolean fog; - // rgba for colormap table generation - UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; - - // rgba is used in hw mode for colored sector lighting + // store rgba values in combined bitwise + // also used in OpenGL instead lighttables INT32 rgba; // similar to maskcolor in sw mode INT32 fadergba; // The colour the colourmaps fade to From 506ce43627c2d954da8f12bb1c76b2828a116189 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 13:31:09 -0400 Subject: [PATCH 197/573] Initialize extra_colormaps to NULL on program start --- src/r_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index 281058362..bfca180d0 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -118,7 +118,7 @@ lighttable_t *scalelightfixed[MAXLIGHTSCALE]; lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; // Hack to support extra boom colormaps. -extracolormap_t *extra_colormaps; +extracolormap_t *extra_colormaps = NULL; static CV_PossibleValue_t drawdist_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, From 4ef016e40fe9fdb5b0abb9fd3e101e0efd2f7a98 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 13:46:34 -0400 Subject: [PATCH 198/573] Clear colormaps properly (resolve sigsegv crash) --- src/r_data.c | 23 +++++++++++------------ src/r_data.h | 1 + 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 005056ec0..4358f7536 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1322,29 +1322,28 @@ void R_ReInitColormaps(UINT16 num) // void R_ClearColormaps(void) { - extracolormap_t *exc, *exc_next; + // Purged by PU_LEVEL, just overwrite the pointer + extra_colormaps = R_CreateDefaultColormap(true); +} - for (exc = extra_colormaps; exc; exc = exc_next) - { - exc_next = exc->next; - memset(exc, 0, sizeof(*exc)); - } - - // make a default extra_colormap - exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); +// +// R_CreateDefaultColormap() +// +extracolormap_t *R_CreateDefaultColormap(boolean lighttable) +{ + extracolormap_t *exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); exc->fadestart = 0; exc->fadeend = 31; exc->fog = 0; exc->rgba = 0; exc->fadergba = 0x19000000; - exc->colormap = R_CreateLightTable(exc); + exc->colormap = lighttable ? R_CreateLightTable(exc) : NULL; #ifdef EXTRACOLORMAPLUMPS exc->lump = LUMPERROR; exc->lumpname[0] = 0; #endif exc->next = exc->prev = NULL; - - extra_colormaps = exc; + return exc; } // diff --git a/src/r_data.h b/src/r_data.h index e6eec41b4..718abeccc 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -105,6 +105,7 @@ INT32 R_CheckTextureNumForName(const char *name); void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); +extracolormap_t *R_CreateDefaultColormap(boolean lighttable); void R_AddColormapToList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); From ba88f8ebb66a55bf6d4966e72649f5151195e258 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 15:01:05 -0400 Subject: [PATCH 199/573] Smarter string digit parsing; allow alpha-only values * GetDefaultColormap and CheckDefaultColormapValues methods --- src/p_setup.c | 11 ++- src/r_data.c | 182 +++++++++++++++++++++++++++++++++++++++----------- src/r_data.h | 2 + 3 files changed, 149 insertions(+), 46 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index b503b6a58..77d53812c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1472,12 +1472,11 @@ static void P_LoadRawSideDefs2(void *data) case 606: //SoM: 4/4/2000: Just colormap transfer // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. - if ( - ((rendermode == render_soft || rendermode == render_none) && (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#')) -#ifdef HWRENDER - || (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) -#endif + if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#' + || (msd->toptexture[0] >= 'a' && msd->toptexture[0] <= 'z' && !msd->toptexture[1]) + || (msd->toptexture[0] >= 'A' && msd->toptexture[0] <= 'Z' && !msd->toptexture[1]) + || (msd->bottomtexture[0] >= 'a' && msd->bottomtexture[0] <= 'z' && !msd->bottomtexture[1]) + || (msd->bottomtexture[0] >= 'A' && msd->bottomtexture[0] <= 'Z' && !msd->bottomtexture[1]) ) { sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, diff --git a/src/r_data.c b/src/r_data.c index 4358f7536..958eeeb37 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1346,6 +1346,49 @@ extracolormap_t *R_CreateDefaultColormap(boolean lighttable) return exc; } +// +// R_GetDefaultColormap() +// +extracolormap_t *R_GetDefaultColormap(void) +{ +#ifdef COLORMAPREVERSELIST + extracolormap_t *exc; +#endif + + if (!extra_colormaps) + return (extra_colormaps = R_CreateDefaultColormap(true)); + +#ifdef COLORMAPREVERSELIST + for (exc = extra_colormaps; exc->next; exc = exc->next); + return exc; +#else + return extra_colormaps; +#endif +} + +// +// R_CheckDefaultColormap() +// +boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) +{ + if (!extra_colormap) + return true; + else + return ( + (!checkparams ? true : + (extra_colormap->fadestart == 0 + && extra_colormap->fadeend == 31 + && !extra_colormap->fog) + ) + && (!checkrgba ? true : extra_colormap->rgba == 0) + && (!checkfadergba ? true : extra_colormap->fadergba == 0x19000000) +#ifdef EXTRACOLORMAPLUMPS + && extra_colormap->lump == LUMPERROR + && extra_colormap->lumpname[0] == 0 +#endif + ); +} + // // R_AddColormapToList // @@ -1562,77 +1605,133 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) { - boolean fog = false; extracolormap_t *extra_colormap, *exc; - UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; + // default values + UINT8 cr = 0, cg = 0, cb = 0, ca = 0, cfr = 0, cfg = 0, cfb = 0, cfa = 25; UINT32 fadestart = 0, fadeend = 31; - - INT32 rgba, fadergba; + boolean fog = false; + INT32 rgba = 0, fadergba = 0x19000000; size_t dbg_i = 0; #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) #define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) - if (p1[0] == '#') - { - cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); - cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); - cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); - if (p1[7] >= 'a' && p1[7] <= 'z') - ca = (p1[7] - 'a'); - else if (p1[7] >= 'A' && p1[7] <= 'Z') - ca = (p1[7] - 'A'); + // Get base colormap value + // First alpha-only, then full value + if (p1[0] >= 'a' && p1[0] <= 'z' && !p1[1]) + ca = (p1[0] - 'a'); + else if (p1[0] == '#' && p1[1] >= 'a' && p1[1] <= 'z' && !p1[2]) + ca = (p1[1] - 'a'); + else if (p1[0] >= 'A' && p1[0] <= 'Z' && !p1[1]) + ca = (p1[0] - 'A'); + else if (p1[0] == '#' && p1[1] >= 'A' && p1[1] <= 'Z' && !p1[2]) + ca = (p1[1] - 'A'); + else if (p1[0] == '#') + { + // For each subsequent value, the value before it must exist + // If we don't get every value, then set alpha to max + if (p1[1] && p1[2]) + { + cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); + if (p1[3] && p1[4]) + { + cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); + if (p1[5] && p1[6]) + { + cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); + + if (p1[7] >= 'a' && p1[7] <= 'z') + ca = (p1[7] - 'a'); + else if (p1[7] >= 'A' && p1[7] <= 'Z') + ca = (p1[7] - 'A'); + else + ca = 25; + } + else + ca = 25; + } + else + ca = 25; + } else ca = 25; - - rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); - } - else - { - cr = cg = cb = ca = 0; - rgba = 0; } #define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0) + + // Get parameters like fadestart, fadeend, and the fogflag if (p2[0] == '#') { - // Get parameters like fadestart, fadeend, and the fogflag - fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); - fadeend = NUMFROMCHAR(p2[5]) + (NUMFROMCHAR(p2[4]) * 10); + if (p2[1]) + { + fog = (boolean)NUMFROMCHAR(p2[1]); + if (p2[2] && p2[3]) + { + fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); + if (p2[4] && p2[5]) + fadeend = NUMFROMCHAR(p2[5]) + (NUMFROMCHAR(p2[4]) * 10); + } + } + if (fadestart > 30) fadestart = 0; if (fadeend > 31 || fadeend < 1) fadeend = 31; - fog = (boolean)NUMFROMCHAR(p2[1]); } + #undef NUMFROMCHAR - if (p3[0] == '#') + // Get fade (dark) colormap value + // First alpha-only, then full value + if (p3[0] >= 'a' && p3[0] <= 'z' && !p3[1]) + cfa = (p3[0] - 'a'); + else if (p3[0] == '#' && p3[1] >= 'a' && p3[1] <= 'z' && !p3[2]) + cfa = (p3[1] - 'a'); + else if (p3[0] >= 'A' && p3[0] <= 'Z' && !p3[1]) + cfa = (p3[0] - 'A'); + else if (p3[0] == '#' && p3[1] >= 'A' && p3[1] <= 'Z' && !p3[2]) + cfa = (p3[1] - 'A'); + else if (p3[0] == '#') { - cfr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); - cfg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); - cfb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); + // For each subsequent value, the value before it must exist + // If we don't get every value, then set alpha to max + if (p3[1] && p3[2]) + { + cfr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); + if (p3[3] && p3[4]) + { + cfg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); + if (p3[5] && p3[6]) + { + cfb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); - if (p1[7] >= 'a' && p1[7] <= 'z') - cfa = (p1[7] - 'a'); - else if (p1[7] >= 'A' && p1[7] <= 'Z') - cfa = (p1[7] - 'A'); + if (p3[7] >= 'a' && p3[7] <= 'z') + cfa = (p3[7] - 'a'); + else if (p3[7] >= 'A' && p3[7] <= 'Z') + cfa = (p3[7] - 'A'); + else + cfa = 25; + } + else + cfa = 25; + } + else + cfa = 25; + } else cfa = 25; - - fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); - } - else - { - cfr = cfg = cfb = 0; - cfa = 25; - fadergba = 0x19000000; // default alpha for fade, (25 << 24) } #undef ALPHA2INT #undef HEX2INT + // Pack rgba values into combined var + // OpenGL also uses this instead of lighttables for rendering + rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); + fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); + + // Look for existing colormaps for (exc = extra_colormaps; exc; exc = exc->next) { #ifdef EXTRACOLORMAPLUMPS @@ -1672,6 +1771,9 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extra_colormap->lumpname[0] = 0; #endif + // Having lighttables for alpha-only entries is kind of pointless, + // but if there happens to be a matching rgba entry that is NOT alpha-only (but has same rgb values), + // then it needs this lighttable because we share matching entries. extra_colormap->colormap = R_CreateLightTable(extra_colormap); R_AddColormapToList(extra_colormap); diff --git a/src/r_data.h b/src/r_data.h index 718abeccc..95ea44a83 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -106,6 +106,8 @@ INT32 R_CheckTextureNumForName(const char *name); void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); extracolormap_t *R_CreateDefaultColormap(boolean lighttable); +extracolormap_t *R_GetDefaultColormap(void); +boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); void R_AddColormapToList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); From 85d89287de8521fe320275716b1e924b177e3a6d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 15:20:30 -0400 Subject: [PATCH 200/573] Add R_CopyColormap --- src/r_data.c | 62 +++++++++++++++++++++++++++++++++++++++------------- src/r_data.h | 3 ++- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 958eeeb37..ad27b442f 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1367,26 +1367,35 @@ extracolormap_t *R_GetDefaultColormap(void) } // -// R_CheckDefaultColormap() +// R_CopyColormap() // -boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) +extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable) { + extracolormap_t *exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + if (!extra_colormap) - return true; - else - return ( - (!checkparams ? true : - (extra_colormap->fadestart == 0 - && extra_colormap->fadeend == 31 - && !extra_colormap->fog) - ) - && (!checkrgba ? true : extra_colormap->rgba == 0) - && (!checkfadergba ? true : extra_colormap->fadergba == 0x19000000) + extra_colormap = R_GetDefaultColormap(); + + *exc = *extra_colormap; + exc->next = exc->prev = NULL; + #ifdef EXTRACOLORMAPLUMPS - && extra_colormap->lump == LUMPERROR - && extra_colormap->lumpname[0] == 0 + strncpy(exc->lumpname, extra_colormap->lumpname, 9); + + if (exc->lump != LUMPERROR && lighttable) + { + // aligned on 8 bit for asm code + exc->colormap = Z_MallocAlign(W_LumpLength(lump), PU_LEVEL, NULL, 16); + W_ReadLump(lump, exc->colormap); + } + else #endif - ); + if (lighttable) + exc->colormap = R_CreateLightTable(exc); + else + exc->colormap = NULL; + + return exc; } // @@ -1423,6 +1432,29 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) #endif } +// +// R_CheckDefaultColormap() +// +boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) +{ + if (!extra_colormap) + return true; + else + return ( + (!checkparams ? true : + (extra_colormap->fadestart == 0 + && extra_colormap->fadeend == 31 + && !extra_colormap->fog) + ) + && (!checkrgba ? true : extra_colormap->rgba == 0) + && (!checkfadergba ? true : extra_colormap->fadergba == 0x19000000) +#ifdef EXTRACOLORMAPLUMPS + && extra_colormap->lump == LUMPERROR + && extra_colormap->lumpname[0] == 0 +#endif + ); +} + #ifdef EXTRACOLORMAPLUMPS extracolormap_t *R_ColormapForName(char *name) { diff --git a/src/r_data.h b/src/r_data.h index 95ea44a83..fc6d71299 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -107,8 +107,9 @@ void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); extracolormap_t *R_CreateDefaultColormap(boolean lighttable); extracolormap_t *R_GetDefaultColormap(void); -boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); +extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable); void R_AddColormapToList(extracolormap_t *extra_colormap); +boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); #ifdef EXTRACOLORMAPLUMPS From 78aefc05cf8c871392ddb03ff7cc4b955202ce71 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 15:50:12 -0400 Subject: [PATCH 201/573] Consolidate colormap matching into R_GetExistingColormap --- src/p_saveg.c | 30 +++---------------- src/r_data.c | 82 +++++++++++++++++++++++++++++++++++---------------- src/r_data.h | 5 ++++ 3 files changed, 65 insertions(+), 52 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 710c24821..d9158d99c 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -886,35 +886,13 @@ static void P_NetUnArchiveWorld(void) else { #endif - - for (exc = extra_colormaps; exc; exc = exc->next) - { -#ifdef EXTRACOLORMAPLUMPS - if (exc->lump != LUMPERROR) - { - //dbg_i++; - continue; - } -#endif - if (rgba == exc->rgba - && fadergba == exc->fadergba - && fadestart == exc->fadestart - && fadeend == exc->fadeend - && fog == exc->fog) - { - // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); - break; - } - //dbg_i++; - } + exc = R_GetExistingColormapByValues(rgba, fadergba, fadestart, fadeend, fog); if (!exc) { - // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); diff --git a/src/r_data.c b/src/r_data.c index ad27b442f..0e4a67e2d 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1328,6 +1328,7 @@ void R_ClearColormaps(void) // // R_CreateDefaultColormap() +// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself! // extracolormap_t *R_CreateDefaultColormap(boolean lighttable) { @@ -1368,6 +1369,7 @@ extracolormap_t *R_GetDefaultColormap(void) // // R_CopyColormap() +// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself! // extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable) { @@ -1455,6 +1457,50 @@ boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean ch ); } +// +// R_GetExistingColormapByValues() +// NOTE: Returns NULL if no match is found +// +#ifdef EXTRACOLORMAPLUMPS +extracolormap_t *R_GetExistingColormapByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump) +#else +extracolormap_t *R_GetExistingColormapByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog) +#endif +{ + extracolormap_t *exc; + size_t dbg_i = 0; + + for (exc = extra_colormaps; exc; exc = exc->next) + { + if (rgba == exc->rgba + && fadergba == exc->fadergba + && fadestart == exc->fadestart + && fadeend == exc->fadeend + && fog == exc->fog +#ifdef EXTRACOLORMAPLUMPS + && (lump != LUMPERROR && lump == exc->lump) +#endif + ) + { + CONS_Debug(DBG_RENDER, "Found Colormap %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + return exc; + } + dbg_i++; + } + return NULL; +} + +extracolormap_t *R_GetExistingColormap(extracolormap_t *extra_colormap) +{ +#ifdef EXTRACOLORMAPLUMPS + return R_GetExistingColormapByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); +else + return R_GetExistingColormapByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); +#endif +} + #ifdef EXTRACOLORMAPLUMPS extracolormap_t *R_ColormapForName(char *name) { @@ -1465,9 +1511,9 @@ extracolormap_t *R_ColormapForName(char *name) if (lump == LUMPERROR) I_Error("R_ColormapForName: Cannot find colormap lump %.8s\n", name); - for (exc = extra_colormaps; exc; exc = exc->next) - if (lump == exc->lump) - return exc; + exc = R_GetExistingColormapByValues(0, 0x19000000, 0, 31, 0, lump); + if (exc) + return exc; exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); @@ -1645,8 +1691,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) boolean fog = false; INT32 rgba = 0, fadergba = 0x19000000; - size_t dbg_i = 0; - #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) #define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) @@ -1764,30 +1808,16 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); // Look for existing colormaps - for (exc = extra_colormaps; exc; exc = exc->next) - { #ifdef EXTRACOLORMAPLUMPS - if (exc->lump != LUMPERROR) - { - dbg_i++; - continue; - } + exc = R_GetExistingColormapByValues(rgba, fadergba, fadestart, fadeend, fog, LUMPERROR); +#else + exc = R_GetExistingColormapByValues(rgba, fadergba, fadestart, fadeend, fog); #endif - if (rgba == exc->rgba - && fadergba == exc->fadergba - && fadestart == exc->fadestart - && fadeend == exc->fadeend - && fog == exc->fog) - { - CONS_Debug(DBG_RENDER, "R_CreateColormap: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); - return exc; - } - dbg_i++; - } + if (exc) + return exc; - CONS_Debug(DBG_RENDER, "R_CreateColormap: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + cr, cg, cb, ca, cfr, cfg, cfb, cfa); extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL); diff --git a/src/r_data.h b/src/r_data.h index fc6d71299..a2db8ba5c 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -110,6 +110,11 @@ extracolormap_t *R_GetDefaultColormap(void); extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable); void R_AddColormapToList(extracolormap_t *extra_colormap); boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); +#ifdef EXTRACOLORMAPLUMPS +extracolormap_t *R_GetExistingColormapByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); +#else +extracolormap_t *R_GetExistingColormapByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); +#endif lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); #ifdef EXTRACOLORMAPLUMPS From c920827032429c013e410881f12102c7179b5e6e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 15:50:12 -0400 Subject: [PATCH 202/573] Consolidate colormap matching into R_GetColormapFromList --- src/p_saveg.c | 30 +++---------------- src/r_data.c | 82 +++++++++++++++++++++++++++++++++++---------------- src/r_data.h | 6 ++++ 3 files changed, 66 insertions(+), 52 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 710c24821..b887b8a73 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -886,35 +886,13 @@ static void P_NetUnArchiveWorld(void) else { #endif - - for (exc = extra_colormaps; exc; exc = exc->next) - { -#ifdef EXTRACOLORMAPLUMPS - if (exc->lump != LUMPERROR) - { - //dbg_i++; - continue; - } -#endif - if (rgba == exc->rgba - && fadergba == exc->fadergba - && fadestart == exc->fadestart - && fadeend == exc->fadeend - && fog == exc->fog) - { - // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); - break; - } - //dbg_i++; - } + exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); if (!exc) { - // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); diff --git a/src/r_data.c b/src/r_data.c index ad27b442f..e679f27ba 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1328,6 +1328,7 @@ void R_ClearColormaps(void) // // R_CreateDefaultColormap() +// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself! // extracolormap_t *R_CreateDefaultColormap(boolean lighttable) { @@ -1368,6 +1369,7 @@ extracolormap_t *R_GetDefaultColormap(void) // // R_CopyColormap() +// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself! // extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable) { @@ -1455,6 +1457,50 @@ boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean ch ); } +// +// R_GetColormapFromListByValues() +// NOTE: Returns NULL if no match is found +// +#ifdef EXTRACOLORMAPLUMPS +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump) +#else +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog) +#endif +{ + extracolormap_t *exc; + size_t dbg_i = 0; + + for (exc = extra_colormaps; exc; exc = exc->next) + { + if (rgba == exc->rgba + && fadergba == exc->fadergba + && fadestart == exc->fadestart + && fadeend == exc->fadeend + && fog == exc->fog +#ifdef EXTRACOLORMAPLUMPS + && (lump != LUMPERROR && lump == exc->lump) +#endif + ) + { + CONS_Debug(DBG_RENDER, "Found Colormap %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + return exc; + } + dbg_i++; + } + return NULL; +} + +extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap) +{ +#ifdef EXTRACOLORMAPLUMPS + return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); +else + return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); +#endif +} + #ifdef EXTRACOLORMAPLUMPS extracolormap_t *R_ColormapForName(char *name) { @@ -1465,9 +1511,9 @@ extracolormap_t *R_ColormapForName(char *name) if (lump == LUMPERROR) I_Error("R_ColormapForName: Cannot find colormap lump %.8s\n", name); - for (exc = extra_colormaps; exc; exc = exc->next) - if (lump == exc->lump) - return exc; + exc = R_GetColormapFromListByValues(0, 0x19000000, 0, 31, 0, lump); + if (exc) + return exc; exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); @@ -1645,8 +1691,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) boolean fog = false; INT32 rgba = 0, fadergba = 0x19000000; - size_t dbg_i = 0; - #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) #define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) @@ -1764,30 +1808,16 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); // Look for existing colormaps - for (exc = extra_colormaps; exc; exc = exc->next) - { #ifdef EXTRACOLORMAPLUMPS - if (exc->lump != LUMPERROR) - { - dbg_i++; - continue; - } + exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog, LUMPERROR); +#else + exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); #endif - if (rgba == exc->rgba - && fadergba == exc->fadergba - && fadestart == exc->fadestart - && fadeend == exc->fadeend - && fog == exc->fog) - { - CONS_Debug(DBG_RENDER, "R_CreateColormap: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); - return exc; - } - dbg_i++; - } + if (exc) + return exc; - CONS_Debug(DBG_RENDER, "R_CreateColormap: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + cr, cg, cb, ca, cfr, cfg, cfb, cfa); extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL); diff --git a/src/r_data.h b/src/r_data.h index fc6d71299..17d85fd8b 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -110,6 +110,12 @@ extracolormap_t *R_GetDefaultColormap(void); extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable); void R_AddColormapToList(extracolormap_t *extra_colormap); boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); +#ifdef EXTRACOLORMAPLUMPS +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); +#else +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); +#endif +extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); #ifdef EXTRACOLORMAPLUMPS From fb7ac4ccae6a345da7f716cbddde1eea737b06d1 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 15:59:13 -0400 Subject: [PATCH 203/573] Ifdef typo --- src/r_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index e679f27ba..e08600cae 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1496,7 +1496,7 @@ extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap) { #ifdef EXTRACOLORMAPLUMPS return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); -else +#else return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); #endif } From 71ade23739a6eddce5b4c1c2d1b4210b4103a25d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 15:59:13 -0400 Subject: [PATCH 204/573] Ifdef typo --- src/r_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index e679f27ba..e08600cae 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1496,7 +1496,7 @@ extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap) { #ifdef EXTRACOLORMAPLUMPS return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); -else +#else return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); #endif } From bb6cf6a807f6946de1a8cfcc6b848fcec2daf351 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 16:50:35 -0400 Subject: [PATCH 205/573] Added alpha-only, relative calc, and offset params to 447 Change Colormap --- src/p_spec.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 21380584b..8d17c6de3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3256,7 +3256,43 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // This could even override existing colormaps I believe // -- Monster Iestyn 14/06/18 for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) - sectors[secnum].extra_colormap = line->frontsector->extra_colormap; + { + if (line->flags & ML_NOCLIMB) // set alpha only + { + if (sectors[secnum].extra_colormap) // does nothing without an existing colormap + { + extracolormap_t *dest_colormap = R_CopyColormap(sectors[secnum].extra_colormap, false); + INT16 alpha; + + // base rgba + alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? + (sides[line->sidenum[1]].textureoffset >> FRACBITS) + : R_GetRgbaA(line->frontsector->extra_colormap->rgba); + if (line->flags & ML_EFFECT3) // relative calc + alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->rgba) + alpha, 25), 0); + dest_colormap->rgba = (dest_colormap->rgba & 0xFFFFFF) + (alpha << 24); + + // fade rgba + alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? + (sides[line->sidenum[1]].rowoffset >> FRACBITS) + : R_GetRgbaA(line->frontsector->extra_colormap->fadergba); + if (line->flags & ML_EFFECT3) // relative calc + alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->fadergba) + alpha, 25), 0); + dest_colormap->fadergba = (dest_colormap->fadergba & 0xFFFFFF) + (alpha << 24); + + if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(dest_colormap))) + { + dest_colormap->colormap = R_CreateLightTable(dest_colormap); + R_AddColormapToList(dest_colormap); + sectors[secnum].extra_colormap = dest_colormap; + } + else + memset(dest_colormap, 0, sizeof(*dest_colormap)); + } + } + else + sectors[secnum].extra_colormap = line->frontsector->extra_colormap; + } break; case 448: // Change skybox viewpoint/centerpoint From f703c195027c4c5c6b798ffb043ba5a50c591998 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 17:06:44 -0400 Subject: [PATCH 206/573] Don't set sector's extra_colormap if we just made a default clone * Allow colormap parsing to proceed in p_setup always * Add R_CheckDefaultColormap * Add R_GetRgbaR/G/B/A macros --- src/p_setup.c | 30 +++-------------------- src/r_data.c | 68 ++++++++++++++++++++++++++++++++++----------------- src/r_data.h | 13 +++++++++- 3 files changed, 61 insertions(+), 50 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 0f4a267ad..498b9cb61 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1438,7 +1438,6 @@ static inline void P_LoadSideDefs(lumpnum_t lumpnum) static void P_LoadRawSideDefs2(void *data) { UINT16 i; - INT32 num; for (i = 0; i < numsides; i++) { @@ -1473,32 +1472,9 @@ static void P_LoadRawSideDefs2(void *data) case 447: // Change colormap of tagged sectors! -- Monster Iestyn 14/06/18 // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. - if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#' - || (msd->toptexture[0] >= 'a' && msd->toptexture[0] <= 'z' && !msd->toptexture[1]) - || (msd->toptexture[0] >= 'A' && msd->toptexture[0] <= 'Z' && !msd->toptexture[1]) - || (msd->bottomtexture[0] >= 'a' && msd->bottomtexture[0] <= 'z' && !msd->bottomtexture[1]) - || (msd->bottomtexture[0] >= 'A' && msd->bottomtexture[0] <= 'Z' && !msd->bottomtexture[1]) - ) - { - sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } + sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, + msd->bottomtexture); + sd->toptexture = sd->midtexture = sd->bottomtexture = 0; break; case 413: // Change music diff --git a/src/r_data.c b/src/r_data.c index e08600cae..529507e9a 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1435,26 +1435,41 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) } // -// R_CheckDefaultColormap() +// R_CheckDefaultColormapByValues() // -boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) +#ifdef EXTRACOLORMAPLUMPS +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump) +#else +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog) +#endif +{ + return ( + (!checkparams ? true : + (fadestart == 0 + && fadeend == 31 + && !fog) + ) + && (!checkrgba ? true : rgba == 0) + && (!checkfadergba ? true : fadergba == 0x19000000) +#ifdef EXTRACOLORMAPLUMPS + && lump == LUMPERROR + && extra_colormap->lumpname[0] == 0 +#endif + ); +} + +boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) { if (!extra_colormap) return true; - else - return ( - (!checkparams ? true : - (extra_colormap->fadestart == 0 - && extra_colormap->fadeend == 31 - && !extra_colormap->fog) - ) - && (!checkrgba ? true : extra_colormap->rgba == 0) - && (!checkfadergba ? true : extra_colormap->fadergba == 0x19000000) + #ifdef EXTRACOLORMAPLUMPS - && extra_colormap->lump == LUMPERROR - && extra_colormap->lumpname[0] == 0 + return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); +#else + return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); #endif - ); } // @@ -1557,14 +1572,14 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; double maskamt = 0, othermask = 0; - UINT8 cr = (extra_colormap->rgba) & 0xFF, - cg = (extra_colormap->rgba >> 8) & 0xFF, - cb = (extra_colormap->rgba >> 16) & 0xFF, - ca = (extra_colormap->rgba >> 24) & 0xFF, - cfr = (extra_colormap->fadergba) & 0xFF, - cfg = (extra_colormap->fadergba >> 8) & 0xFF, - cfb = (extra_colormap->fadergba >> 16) & 0xFF; -// cfa = (extra_colormap->fadergba >> 24) & 0xFF; // unused in software + UINT8 cr = R_GetRgbaR(extra_colormap->rgba), + cg = R_GetRgbaG(extra_colormap->rgba), + cb = R_GetRgbaB(extra_colormap->rgba), + ca = R_GetRgbaA(extra_colormap->rgba), + cfr = R_GetRgbaR(extra_colormap->fadergba), + cfg = R_GetRgbaG(extra_colormap->fadergba), + cfb = R_GetRgbaB(extra_colormap->fadergba); +// cfa = R_GetRgbaA(extra_colormap->fadergba); // unused in software UINT8 fadestart = extra_colormap->fadestart, fadedist = extra_colormap->fadeend - extra_colormap->fadestart; @@ -1807,6 +1822,15 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); + // Did we just make a default colormap? +#ifdef EXTRACOLORMAPLUMPS + if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog, LUMPERROR)) + return NULL; +#else + if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog)) + return NULL; +#endif + // Look for existing colormaps #ifdef EXTRACOLORMAPLUMPS exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog, LUMPERROR); diff --git a/src/r_data.h b/src/r_data.h index 17d85fd8b..ee497d155 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -109,13 +109,19 @@ extracolormap_t *R_CreateDefaultColormap(boolean lighttable); extracolormap_t *R_GetDefaultColormap(void); extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable); void R_AddColormapToList(extracolormap_t *extra_colormap); -boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); + #ifdef EXTRACOLORMAPLUMPS +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); #else +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); #endif +boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); + lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); #ifdef EXTRACOLORMAPLUMPS @@ -123,6 +129,11 @@ extracolormap_t *R_ColormapForName(char *name); const char *R_NameForColormap(extracolormap_t *extra_colormap); #endif +#define R_GetRgbaR(rgba) (rgba & 0xFF) +#define R_GetRgbaG(rgba) ((rgba >> 8) & 0xFF) +#define R_GetRgbaB(rgba) ((rgba >> 16) & 0xFF) +#define R_GetRgbaA(rgba) ((rgba >> 24) & 0xFF) + extern INT32 numtextures; #endif From 5523fc3a8d43e69dcc77f55b4d762c3c738c6931 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 17:07:50 -0400 Subject: [PATCH 207/573] Account for NULL colormaps in alpha-only code 447 --- src/p_spec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 8d17c6de3..adcd46462 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3267,7 +3267,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // base rgba alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? (sides[line->sidenum[1]].textureoffset >> FRACBITS) - : R_GetRgbaA(line->frontsector->extra_colormap->rgba); + : line->frontsector->extra_colormap ? + R_GetRgbaA(line->frontsector->extra_colormap->rgba) + : 0; if (line->flags & ML_EFFECT3) // relative calc alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->rgba) + alpha, 25), 0); dest_colormap->rgba = (dest_colormap->rgba & 0xFFFFFF) + (alpha << 24); @@ -3275,7 +3277,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // fade rgba alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? (sides[line->sidenum[1]].rowoffset >> FRACBITS) - : R_GetRgbaA(line->frontsector->extra_colormap->fadergba); + : line->frontsector->extra_colormap ? + R_GetRgbaA(line->frontsector->extra_colormap->fadergba) + : 0; if (line->flags & ML_EFFECT3) // relative calc alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->fadergba) + alpha, 25), 0); dest_colormap->fadergba = (dest_colormap->fadergba & 0xFFFFFF) + (alpha << 24); From 5975f261773418cd6eba4247582798e7d11ce0ec Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 17:06:44 -0400 Subject: [PATCH 208/573] Don't set sector's extra_colormap if we just made a default clone * Allow colormap parsing to proceed in p_setup always * Add R_CheckDefaultColormap * Add R_GetRgbaR/G/B/A macros --- src/p_setup.c | 30 +++-------------------- src/r_data.c | 68 ++++++++++++++++++++++++++++++++++----------------- src/r_data.h | 13 +++++++++- 3 files changed, 61 insertions(+), 50 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 77d53812c..edde5e701 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1438,7 +1438,6 @@ static inline void P_LoadSideDefs(lumpnum_t lumpnum) static void P_LoadRawSideDefs2(void *data) { UINT16 i; - INT32 num; for (i = 0; i < numsides; i++) { @@ -1472,32 +1471,9 @@ static void P_LoadRawSideDefs2(void *data) case 606: //SoM: 4/4/2000: Just colormap transfer // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. - if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#' - || (msd->toptexture[0] >= 'a' && msd->toptexture[0] <= 'z' && !msd->toptexture[1]) - || (msd->toptexture[0] >= 'A' && msd->toptexture[0] <= 'Z' && !msd->toptexture[1]) - || (msd->bottomtexture[0] >= 'a' && msd->bottomtexture[0] <= 'z' && !msd->bottomtexture[1]) - || (msd->bottomtexture[0] >= 'A' && msd->bottomtexture[0] <= 'Z' && !msd->bottomtexture[1]) - ) - { - sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } + sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, + msd->bottomtexture); + sd->toptexture = sd->midtexture = sd->bottomtexture = 0; break; case 413: // Change music diff --git a/src/r_data.c b/src/r_data.c index e08600cae..529507e9a 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1435,26 +1435,41 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) } // -// R_CheckDefaultColormap() +// R_CheckDefaultColormapByValues() // -boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) +#ifdef EXTRACOLORMAPLUMPS +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump) +#else +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog) +#endif +{ + return ( + (!checkparams ? true : + (fadestart == 0 + && fadeend == 31 + && !fog) + ) + && (!checkrgba ? true : rgba == 0) + && (!checkfadergba ? true : fadergba == 0x19000000) +#ifdef EXTRACOLORMAPLUMPS + && lump == LUMPERROR + && extra_colormap->lumpname[0] == 0 +#endif + ); +} + +boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) { if (!extra_colormap) return true; - else - return ( - (!checkparams ? true : - (extra_colormap->fadestart == 0 - && extra_colormap->fadeend == 31 - && !extra_colormap->fog) - ) - && (!checkrgba ? true : extra_colormap->rgba == 0) - && (!checkfadergba ? true : extra_colormap->fadergba == 0x19000000) + #ifdef EXTRACOLORMAPLUMPS - && extra_colormap->lump == LUMPERROR - && extra_colormap->lumpname[0] == 0 + return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); +#else + return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); #endif - ); } // @@ -1557,14 +1572,14 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; double maskamt = 0, othermask = 0; - UINT8 cr = (extra_colormap->rgba) & 0xFF, - cg = (extra_colormap->rgba >> 8) & 0xFF, - cb = (extra_colormap->rgba >> 16) & 0xFF, - ca = (extra_colormap->rgba >> 24) & 0xFF, - cfr = (extra_colormap->fadergba) & 0xFF, - cfg = (extra_colormap->fadergba >> 8) & 0xFF, - cfb = (extra_colormap->fadergba >> 16) & 0xFF; -// cfa = (extra_colormap->fadergba >> 24) & 0xFF; // unused in software + UINT8 cr = R_GetRgbaR(extra_colormap->rgba), + cg = R_GetRgbaG(extra_colormap->rgba), + cb = R_GetRgbaB(extra_colormap->rgba), + ca = R_GetRgbaA(extra_colormap->rgba), + cfr = R_GetRgbaR(extra_colormap->fadergba), + cfg = R_GetRgbaG(extra_colormap->fadergba), + cfb = R_GetRgbaB(extra_colormap->fadergba); +// cfa = R_GetRgbaA(extra_colormap->fadergba); // unused in software UINT8 fadestart = extra_colormap->fadestart, fadedist = extra_colormap->fadeend - extra_colormap->fadestart; @@ -1807,6 +1822,15 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); + // Did we just make a default colormap? +#ifdef EXTRACOLORMAPLUMPS + if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog, LUMPERROR)) + return NULL; +#else + if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog)) + return NULL; +#endif + // Look for existing colormaps #ifdef EXTRACOLORMAPLUMPS exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog, LUMPERROR); diff --git a/src/r_data.h b/src/r_data.h index 17d85fd8b..ee497d155 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -109,13 +109,19 @@ extracolormap_t *R_CreateDefaultColormap(boolean lighttable); extracolormap_t *R_GetDefaultColormap(void); extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable); void R_AddColormapToList(extracolormap_t *extra_colormap); -boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); + #ifdef EXTRACOLORMAPLUMPS +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); #else +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); #endif +boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); + lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); #ifdef EXTRACOLORMAPLUMPS @@ -123,6 +129,11 @@ extracolormap_t *R_ColormapForName(char *name); const char *R_NameForColormap(extracolormap_t *extra_colormap); #endif +#define R_GetRgbaR(rgba) (rgba & 0xFF) +#define R_GetRgbaG(rgba) ((rgba >> 8) & 0xFF) +#define R_GetRgbaB(rgba) ((rgba >> 16) & 0xFF) +#define R_GetRgbaA(rgba) ((rgba >> 24) & 0xFF) + extern INT32 numtextures; #endif From 548f02eea14ab963fa2e4519740c927bef2ae3f5 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 17:30:43 -0400 Subject: [PATCH 209/573] Extra macros R_GetRgbaRGB; R_PutRgbaR/G/B/A/RGB/RGBA --- src/r_data.c | 4 ++-- src/r_data.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 529507e9a..e0899e4cf 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1819,8 +1819,8 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) // Pack rgba values into combined var // OpenGL also uses this instead of lighttables for rendering - rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); - fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); + rgba = R_PutRgbaRGBA(cr, cg, cb, ca); + fadergba = R_PutRgbaRGBA(cfr, cfg, cfb, cfa); // Did we just make a default colormap? #ifdef EXTRACOLORMAPLUMPS diff --git a/src/r_data.h b/src/r_data.h index ee497d155..d980e9c56 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -133,6 +133,13 @@ const char *R_NameForColormap(extracolormap_t *extra_colormap); #define R_GetRgbaG(rgba) ((rgba >> 8) & 0xFF) #define R_GetRgbaB(rgba) ((rgba >> 16) & 0xFF) #define R_GetRgbaA(rgba) ((rgba >> 24) & 0xFF) +#define R_GetRgbaRGB(rgba) (rgba & 0xFFFFFF) +#define R_PutRgbaR(r) (r) +#define R_PutRgbaG(g) (g << 8) +#define R_PutRgbaB(b) (b << 16) +#define R_PutRgbaA(a) (a << 24) +#define R_PutRgbaRGB(r, g, b) (R_PutRgbaR(r) + R_PutRgbaG(g) + R_PutRgbaB(b)) +#define R_PutRgbaRGBA(r, g, b, a) (R_PutRgbaRGB(r, g, b) + R_PutRgbaA(a)) extern INT32 numtextures; From b9e4cd40ca45936428467dcf7eaa7eb31679d946 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 17:32:43 -0400 Subject: [PATCH 210/573] Use RGB/RGBA macros in 447 code --- src/p_spec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index adcd46462..f119c3e2f 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3272,7 +3272,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) : 0; if (line->flags & ML_EFFECT3) // relative calc alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->rgba) + alpha, 25), 0); - dest_colormap->rgba = (dest_colormap->rgba & 0xFFFFFF) + (alpha << 24); + dest_colormap->rgba = R_GetRgbaRGB(dest_colormap->rgba) + R_PutRgbaA(alpha); // fade rgba alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? @@ -3282,7 +3282,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) : 0; if (line->flags & ML_EFFECT3) // relative calc alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->fadergba) + alpha, 25), 0); - dest_colormap->fadergba = (dest_colormap->fadergba & 0xFFFFFF) + (alpha << 24); + dest_colormap->fadergba = R_GetRgbaRGB(dest_colormap->fadergba) + R_PutRgbaA(alpha); if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(dest_colormap))) { From a1a05c99721eb65da73ec822f3e32de97dd23112 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 19:11:50 -0400 Subject: [PATCH 211/573] Add relative color change to 447 --- src/p_spec.c | 85 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 24 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index f119c3e2f..4a23902c7 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3257,41 +3257,78 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // -- Monster Iestyn 14/06/18 for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) { - if (line->flags & ML_NOCLIMB) // set alpha only + if (line->flags & ML_EFFECT3) // relative calc { if (sectors[secnum].extra_colormap) // does nothing without an existing colormap { - extracolormap_t *dest_colormap = R_CopyColormap(sectors[secnum].extra_colormap, false); - INT16 alpha; + extracolormap_t *target_colormap = R_CopyColormap(sectors[secnum].extra_colormap, false); + extracolormap_t *source_colormap = line->frontsector->extra_colormap ? line->frontsector->extra_colormap + : R_GetDefaultColormap(); + + INT16 red, green, blue, alpha; // base rgba - alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? - (sides[line->sidenum[1]].textureoffset >> FRACBITS) - : line->frontsector->extra_colormap ? - R_GetRgbaA(line->frontsector->extra_colormap->rgba) - : 0; - if (line->flags & ML_EFFECT3) // relative calc - alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->rgba) + alpha, 25), 0); - dest_colormap->rgba = R_GetRgbaRGB(dest_colormap->rgba) + R_PutRgbaA(alpha); + red = max(min( + R_GetRgbaR(target_colormap->rgba) + + ((line->flags & ML_EFFECT1) ? -1 : 1) // subtract R + * R_GetRgbaR(source_colormap->rgba) + , 255), 0); + + green = max(min( + R_GetRgbaG(target_colormap->rgba) + + ((line->flags & ML_NOCLIMB) ? -1 : 1) // subtract G + * R_GetRgbaG(source_colormap->rgba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(target_colormap->rgba) + + ((line->flags & ML_EFFECT2) ? -1 : 1) // subtract B + * R_GetRgbaB(source_colormap->rgba) + , 255), 0); + + alpha = (line->flags & ML_DONTPEGBOTTOM) ? // front (or back!) X offset; needed to subtract A + (sides[line->sidenum[line->sidenum[1] != 0xFFFF ? 1 : 0]].textureoffset >> FRACBITS) + : R_GetRgbaA(source_colormap->rgba); + alpha = max(min(R_GetRgbaA(target_colormap->rgba) + alpha, 25), 0); + + target_colormap->rgba = R_PutRgbaRGBA(red, green, blue, alpha); // fade rgba - alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? - (sides[line->sidenum[1]].rowoffset >> FRACBITS) - : line->frontsector->extra_colormap ? - R_GetRgbaA(line->frontsector->extra_colormap->fadergba) - : 0; - if (line->flags & ML_EFFECT3) // relative calc - alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->fadergba) + alpha, 25), 0); - dest_colormap->fadergba = R_GetRgbaRGB(dest_colormap->fadergba) + R_PutRgbaA(alpha); + red = max(min( + R_GetRgbaR(target_colormap->fadergba) + + ((line->flags & ML_EFFECT1) ? -1 : 1) // subtract R + * R_GetRgbaR(source_colormap->fadergba) + , 255), 0); - if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(dest_colormap))) + green = max(min( + R_GetRgbaG(target_colormap->fadergba) + + ((line->flags & ML_NOCLIMB) ? -1 : 1) // subtract G + * R_GetRgbaG(source_colormap->fadergba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(target_colormap->fadergba) + + ((line->flags & ML_EFFECT2) ? -1 : 1) // subtract B + * R_GetRgbaB(source_colormap->fadergba) + , 255), 0); + + alpha = (line->flags & ML_DONTPEGBOTTOM) ? // front (or back!) Y offset; needed to subtract A + (sides[line->sidenum[line->sidenum[1] != 0xFFFF ? 1 : 0]].rowoffset >> FRACBITS) + : R_GetRgbaA(source_colormap->fadergba); + if (alpha == 25) + alpha = 0; // HACK: fadergba A defaults at 25, so don't add anything in this case + alpha = max(min(R_GetRgbaA(target_colormap->fadergba) + alpha, 25), 0); + + target_colormap->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); + + if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(target_colormap))) { - dest_colormap->colormap = R_CreateLightTable(dest_colormap); - R_AddColormapToList(dest_colormap); - sectors[secnum].extra_colormap = dest_colormap; + target_colormap->colormap = R_CreateLightTable(target_colormap); + R_AddColormapToList(target_colormap); + sectors[secnum].extra_colormap = target_colormap; } else - memset(dest_colormap, 0, sizeof(*dest_colormap)); + memset(target_colormap, 0, sizeof(*target_colormap)); } } else From 0fb594ad5829274ddff998cb393d2c1af07bd403 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 21:02:58 -0400 Subject: [PATCH 212/573] R_AddColormaps method --- src/r_data.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/r_data.h | 5 +++ 2 files changed, 91 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index 949a842cc..03de15d85 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1876,6 +1876,92 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) return extra_colormap; } +// +// R_AddColormaps() +// NOTE: The result colormap DOES get added to the extra_colormaps chain! +// +extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, + boolean subR, boolean subG, boolean subB, boolean subA, + boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, + boolean lighttable) +{ + extracolormap_t *exc; + + // exc_augend is added (or subtracted) onto by exc_addend + // In Rennaisance times, the first number was considered the augend, the second number the addend + // But since the commutative property was discovered, today they're both called addends! + // So let's be Olde English for a hot second. + + exc_augend = R_CopyColormap(exc_augend, false); + if(!exc_addend) + exc_addend = R_GetDefaultColormap(); + + INT16 red, green, blue, alpha; + + // base rgba + red = max(min( + R_GetRgbaR(exc_augend->rgba) + + (subR ? -1 : 1) // subtract R + * R_GetRgbaR(exc_addend->rgba) + , 255), 0); + + green = max(min( + R_GetRgbaG(exc_augend->rgba) + + (subG ? -1 : 1) // subtract G + * R_GetRgbaG(exc_addend->rgba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(exc_augend->rgba) + + (subB ? -1 : 1) // subtract B + * R_GetRgbaB(exc_addend->rgba) + , 255), 0); + + alpha = useAltAlpha ? altAlpha : R_GetRgbaA(exc_addend->rgba); + alpha = max(min(R_GetRgbaA(exc_augend->rgba) + (subA ? -1 : 1) * alpha, 25), 0); + + exc_augend->rgba = R_PutRgbaRGBA(red, green, blue, alpha); + + // fade rgba + red = max(min( + R_GetRgbaR(exc_augend->fadergba) + + (subFadeR ? -1 : 1) // subtract R + * R_GetRgbaR(exc_addend->fadergba) + , 255), 0); + + green = max(min( + R_GetRgbaG(exc_augend->fadergba) + + (subFadeG ? -1 : 1) // subtract G + * R_GetRgbaG(exc_addend->fadergba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(exc_augend->fadergba) + + (subFadeB ? -1 : 1) // subtract B + * R_GetRgbaB(exc_addend->fadergba) + , 255), 0); + + alpha = useAltAlpha ? altFadeAlpha : R_GetRgbaA(exc_addend->fadergba); + if (alpha == 25) + alpha = 0; // HACK: fadergba A defaults at 25, so don't add anything in this case + alpha = max(min(R_GetRgbaA(exc_augend->fadergba) + (subFadeA ? -1 : 1) * alpha, 25), 0); + + exc_augend->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); + + if (!(exc = R_GetColormapFromList(exc_augend))) + { + exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; + R_AddColormapToList(exc_augend); + return exc_augend; + } + else + { + Z_Free(exc_augend); + return exc; + } +} + // Thanks to quake2 source! // utils3/qdata/images.c static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b) diff --git a/src/r_data.h b/src/r_data.h index d980e9c56..6f8d08120 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -124,6 +124,11 @@ extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); +extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, + boolean subR, boolean subG, boolean subB, boolean subA, + boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, + boolean lighttable); #ifdef EXTRACOLORMAPLUMPS extracolormap_t *R_ColormapForName(char *name); const char *R_NameForColormap(extracolormap_t *extra_colormap); From 54669a6cc83fca0b8793e867113cc16e3bb8ee40 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 21:03:13 -0400 Subject: [PATCH 213/573] Use R_AddColormaps method in 447 relative calc --- src/p_spec.c | 87 +++++++++------------------------------------------- 1 file changed, 14 insertions(+), 73 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 4a23902c7..2c607f74e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3258,79 +3258,20 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) { if (line->flags & ML_EFFECT3) // relative calc - { - if (sectors[secnum].extra_colormap) // does nothing without an existing colormap - { - extracolormap_t *target_colormap = R_CopyColormap(sectors[secnum].extra_colormap, false); - extracolormap_t *source_colormap = line->frontsector->extra_colormap ? line->frontsector->extra_colormap - : R_GetDefaultColormap(); - - INT16 red, green, blue, alpha; - - // base rgba - red = max(min( - R_GetRgbaR(target_colormap->rgba) - + ((line->flags & ML_EFFECT1) ? -1 : 1) // subtract R - * R_GetRgbaR(source_colormap->rgba) - , 255), 0); - - green = max(min( - R_GetRgbaG(target_colormap->rgba) - + ((line->flags & ML_NOCLIMB) ? -1 : 1) // subtract G - * R_GetRgbaG(source_colormap->rgba) - , 255), 0); - - blue = max(min( - R_GetRgbaB(target_colormap->rgba) - + ((line->flags & ML_EFFECT2) ? -1 : 1) // subtract B - * R_GetRgbaB(source_colormap->rgba) - , 255), 0); - - alpha = (line->flags & ML_DONTPEGBOTTOM) ? // front (or back!) X offset; needed to subtract A - (sides[line->sidenum[line->sidenum[1] != 0xFFFF ? 1 : 0]].textureoffset >> FRACBITS) - : R_GetRgbaA(source_colormap->rgba); - alpha = max(min(R_GetRgbaA(target_colormap->rgba) + alpha, 25), 0); - - target_colormap->rgba = R_PutRgbaRGBA(red, green, blue, alpha); - - // fade rgba - red = max(min( - R_GetRgbaR(target_colormap->fadergba) - + ((line->flags & ML_EFFECT1) ? -1 : 1) // subtract R - * R_GetRgbaR(source_colormap->fadergba) - , 255), 0); - - green = max(min( - R_GetRgbaG(target_colormap->fadergba) - + ((line->flags & ML_NOCLIMB) ? -1 : 1) // subtract G - * R_GetRgbaG(source_colormap->fadergba) - , 255), 0); - - blue = max(min( - R_GetRgbaB(target_colormap->fadergba) - + ((line->flags & ML_EFFECT2) ? -1 : 1) // subtract B - * R_GetRgbaB(source_colormap->fadergba) - , 255), 0); - - alpha = (line->flags & ML_DONTPEGBOTTOM) ? // front (or back!) Y offset; needed to subtract A - (sides[line->sidenum[line->sidenum[1] != 0xFFFF ? 1 : 0]].rowoffset >> FRACBITS) - : R_GetRgbaA(source_colormap->fadergba); - if (alpha == 25) - alpha = 0; // HACK: fadergba A defaults at 25, so don't add anything in this case - alpha = max(min(R_GetRgbaA(target_colormap->fadergba) + alpha, 25), 0); - - target_colormap->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); - - if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(target_colormap))) - { - target_colormap->colormap = R_CreateLightTable(target_colormap); - R_AddColormapToList(target_colormap); - sectors[secnum].extra_colormap = target_colormap; - } - else - memset(target_colormap, 0, sizeof(*target_colormap)); - } - } + sectors[secnum].extra_colormap = R_AddColormaps( + sectors[secnum].extra_colormap, line->frontsector->extra_colormap, + line->flags & ML_EFFECT1, // subtract R + line->flags & ML_NOCLIMB, // subtract G + line->flags & ML_EFFECT2, // subtract B + false, // subtract A (no flag for this, just pass negative alpha) + line->flags & ML_EFFECT1, // subtract FadeR + line->flags & ML_NOCLIMB, // subtract FadeG + line->flags & ML_EFFECT2, // subtract FadeB + false, // subtract FadeA (no flag for this, just pass negative alpha) + line->flags & ML_DONTPEGBOTTOM, + (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].textureoffset >> FRACBITS) : 0, + (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].rowoffset >> FRACBITS) : 0, + true); else sectors[secnum].extra_colormap = line->frontsector->extra_colormap; } From f0c11eb13572e041b1f7762d569f9e821c336d10 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 21:02:58 -0400 Subject: [PATCH 214/573] R_AddColormaps method --- src/r_data.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/r_data.h | 5 +++ 2 files changed, 91 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index e0899e4cf..c84e61fce 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1867,6 +1867,92 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) return extra_colormap; } +// +// R_AddColormaps() +// NOTE: The result colormap DOES get added to the extra_colormaps chain! +// +extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, + boolean subR, boolean subG, boolean subB, boolean subA, + boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, + boolean lighttable) +{ + extracolormap_t *exc; + + // exc_augend is added (or subtracted) onto by exc_addend + // In Rennaisance times, the first number was considered the augend, the second number the addend + // But since the commutative property was discovered, today they're both called addends! + // So let's be Olde English for a hot second. + + exc_augend = R_CopyColormap(exc_augend, false); + if(!exc_addend) + exc_addend = R_GetDefaultColormap(); + + INT16 red, green, blue, alpha; + + // base rgba + red = max(min( + R_GetRgbaR(exc_augend->rgba) + + (subR ? -1 : 1) // subtract R + * R_GetRgbaR(exc_addend->rgba) + , 255), 0); + + green = max(min( + R_GetRgbaG(exc_augend->rgba) + + (subG ? -1 : 1) // subtract G + * R_GetRgbaG(exc_addend->rgba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(exc_augend->rgba) + + (subB ? -1 : 1) // subtract B + * R_GetRgbaB(exc_addend->rgba) + , 255), 0); + + alpha = useAltAlpha ? altAlpha : R_GetRgbaA(exc_addend->rgba); + alpha = max(min(R_GetRgbaA(exc_augend->rgba) + (subA ? -1 : 1) * alpha, 25), 0); + + exc_augend->rgba = R_PutRgbaRGBA(red, green, blue, alpha); + + // fade rgba + red = max(min( + R_GetRgbaR(exc_augend->fadergba) + + (subFadeR ? -1 : 1) // subtract R + * R_GetRgbaR(exc_addend->fadergba) + , 255), 0); + + green = max(min( + R_GetRgbaG(exc_augend->fadergba) + + (subFadeG ? -1 : 1) // subtract G + * R_GetRgbaG(exc_addend->fadergba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(exc_augend->fadergba) + + (subFadeB ? -1 : 1) // subtract B + * R_GetRgbaB(exc_addend->fadergba) + , 255), 0); + + alpha = useAltAlpha ? altFadeAlpha : R_GetRgbaA(exc_addend->fadergba); + if (alpha == 25) + alpha = 0; // HACK: fadergba A defaults at 25, so don't add anything in this case + alpha = max(min(R_GetRgbaA(exc_augend->fadergba) + (subFadeA ? -1 : 1) * alpha, 25), 0); + + exc_augend->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); + + if (!(exc = R_GetColormapFromList(exc_augend))) + { + exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; + R_AddColormapToList(exc_augend); + return exc_augend; + } + else + { + Z_Free(exc_augend); + return exc; + } +} + // Thanks to quake2 source! // utils3/qdata/images.c static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b) diff --git a/src/r_data.h b/src/r_data.h index d980e9c56..6f8d08120 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -124,6 +124,11 @@ extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); +extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, + boolean subR, boolean subG, boolean subB, boolean subA, + boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, + boolean lighttable); #ifdef EXTRACOLORMAPLUMPS extracolormap_t *R_ColormapForName(char *name); const char *R_NameForColormap(extracolormap_t *extra_colormap); From ead14becd7184340102fbf5d5fc0d72a8be85053 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 22:34:29 -0400 Subject: [PATCH 215/573] Add R_CheckEqualColormaps comparison method --- src/r_data.c | 27 +++++++++++++++++++++++++++ src/r_data.h | 1 + 2 files changed, 28 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index c84e61fce..1de51fedd 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1472,6 +1472,33 @@ boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgb #endif } +boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams) +{ + // Treat NULL as default colormap + // We need this because what if one exc is a default colormap, and the other is NULL? They're really both equal. + if (!exc_a) + exc_a = R_GetDefaultColormap(); + if (!exc_b) + exc_b = R_GetDefaultColormap(); + + if (exc_a == exc_b) + return true; + + return ( + (!checkparams ? true : + (exc_a->fadestart == exc_b->fadestart + && exc_a->fadeend == exc_b->fadeend + && exc_a->fog == exc_b->fog) + ) + && (!checkrgba ? true : exc_a->rgba == exc_b->rgba) + && (!checkfadergba ? true : exc_a->fadergba == exc_b->fadergba) +#ifdef EXTRACOLORMAPLUMPS + && exc_a->lump == exc_b->lump + && !strncmp(exc_a->lumpname, exc_b->lumpname, 9) +#endif + ); +} + // // R_GetColormapFromListByValues() // NOTE: Returns NULL if no match is found diff --git a/src/r_data.h b/src/r_data.h index 6f8d08120..f6db2953d 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -120,6 +120,7 @@ boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); #endif boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); +boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b); extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); From 90aeac5058bae5cdc6c7097ce13bc1f4dd688df3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 22:34:29 -0400 Subject: [PATCH 216/573] Add R_CheckEqualColormaps comparison method --- src/r_data.c | 27 +++++++++++++++++++++++++++ src/r_data.h | 1 + 2 files changed, 28 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index c84e61fce..1de51fedd 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1472,6 +1472,33 @@ boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgb #endif } +boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams) +{ + // Treat NULL as default colormap + // We need this because what if one exc is a default colormap, and the other is NULL? They're really both equal. + if (!exc_a) + exc_a = R_GetDefaultColormap(); + if (!exc_b) + exc_b = R_GetDefaultColormap(); + + if (exc_a == exc_b) + return true; + + return ( + (!checkparams ? true : + (exc_a->fadestart == exc_b->fadestart + && exc_a->fadeend == exc_b->fadeend + && exc_a->fog == exc_b->fog) + ) + && (!checkrgba ? true : exc_a->rgba == exc_b->rgba) + && (!checkfadergba ? true : exc_a->fadergba == exc_b->fadergba) +#ifdef EXTRACOLORMAPLUMPS + && exc_a->lump == exc_b->lump + && !strncmp(exc_a->lumpname, exc_b->lumpname, 9) +#endif + ); +} + // // R_GetColormapFromListByValues() // NOTE: Returns NULL if no match is found diff --git a/src/r_data.h b/src/r_data.h index 6f8d08120..df0fe75b3 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -120,6 +120,7 @@ boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); #endif boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); +boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams); extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); From 92a97fb1a64ec3e2b88203011a5ca11abfeacef8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 22:44:31 -0400 Subject: [PATCH 217/573] Split colormap netsync to Load/SaveExtraColormap methods --- src/p_saveg.c | 131 +++++++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 65 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index b887b8a73..fc767d9cf 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -474,6 +474,70 @@ static void P_NetUnArchivePlayers(void) } } +static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) +{ + WRITEUINT8(put, exc->fadestart); + WRITEUINT8(put, exc->fadeend); + WRITEUINT8(put, (UINT8)exc->fog); + + WRITEINT32(put, exc->rgba); + WRITEINT32(put, exc->fadergba); + +#ifdef EXTRACOLORMAPLUMPS + WRITESTRINGN(put, exc->lumpname, 9); +#endif +} + +static extracolormap_t *LoadExtraColormap(UINT8 *get) +{ + extracolormap_t *exc; + //size_t dbg_i = 0; + + UINT8 fadestart = READUINT8(get), + fadeend = READUINT8(get); + + boolean fog = (boolean)READUINT8(get); + + INT32 rgba = READINT32(get), + fadergba = READINT32(get); + +#ifdef EXTRACOLORMAPLUMPS + char lumpname[9]; + READSTRINGN(get, lumpname, 9); + + if (lumpname[0]) + return R_ColormapForName(lumpname); +#endif + exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); + + if (!exc) + { + // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + + exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + + exc->fadestart = fadestart; + exc->fadeend = fadeend; + exc->fog = fog; + + exc->rgba = rgba; + exc->fadergba = fadergba; + + exc->colormap = R_CreateLightTable(exc); + + R_AddColormapToList(exc); + +#ifdef EXTRACOLORMAPLUMPS + exc->lump = LUMPERROR; + exc->lumpname[0] = 0; +#endif + } + + return exc; +} + #define SD_FLOORHT 0x01 #define SD_CEILHT 0x02 #define SD_FLOORPIC 0x04 @@ -657,18 +721,7 @@ static void P_NetArchiveWorld(void) } if (diff3 & SD_COLORMAP) - { - WRITEUINT8(put, ss->extra_colormap->fadestart); - WRITEUINT8(put, ss->extra_colormap->fadeend); - WRITEUINT8(put, (UINT8)ss->extra_colormap->fog); - - WRITEINT32(put, ss->extra_colormap->rgba); - WRITEINT32(put, ss->extra_colormap->fadergba); - -#ifdef EXTRACOLORMAPLUMPS - WRITESTRINGN(put, ss->extra_colormap->lumpname, 9); -#endif - } + SaveExtraColormap(put, ss->extra_colormap); // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed @@ -865,59 +918,7 @@ static void P_NetUnArchiveWorld(void) } if (diff3 & SD_COLORMAP) - { - extracolormap_t *exc; - //size_t dbg_i = 0; - - UINT8 fadestart = READUINT8(get), - fadeend = READUINT8(get); - - boolean fog = (boolean)READUINT8(get); - - INT32 rgba = READINT32(get), - fadergba = READINT32(get); - -#ifdef EXTRACOLORMAPLUMPS - char lumpname[9]; - READSTRINGN(get, lumpname, 9); - - if (lumpname[0]) - sectors[i].extra_colormap = R_ColormapForName(lumpname); - else - { -#endif - exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); - - if (!exc) - { - // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); - - exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); - - exc->fadestart = fadestart; - exc->fadeend = fadeend; - exc->fog = fog; - - exc->rgba = rgba; - exc->fadergba = fadergba; - - exc->colormap = R_CreateLightTable(exc); - - R_AddColormapToList(exc); - -#ifdef EXTRACOLORMAPLUMPS - exc->lump = LUMPERROR; - exc->lumpname[0] = 0; -#endif - } - - sectors[i].extra_colormap = exc; -#ifdef EXTRACOLORMAPLUMPS - } -#endif - } + sectors[i].extra_colormap = LoadExtraColormap(get); if (diff & SD_FFLOORS) { From 5e59b8c55af1e79c1f5bf10ceb52676ed9b2624d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 22:49:32 -0400 Subject: [PATCH 218/573] Duplicate lines --- src/r_data.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 5598dafcd..1de51fedd 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1849,15 +1849,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) rgba = R_PutRgbaRGBA(cr, cg, cb, ca); fadergba = R_PutRgbaRGBA(cfr, cfg, cfb, cfa); - // Did we just make a default colormap? -#ifdef EXTRACOLORMAPLUMPS - if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog, LUMPERROR)) - return NULL; -#else - if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog)) - return NULL; -#endif - // Did we just make a default colormap? #ifdef EXTRACOLORMAPLUMPS if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog, LUMPERROR)) From 8754268abe34f70a3b71be70808c39351aed3f64 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:06:45 -0400 Subject: [PATCH 219/573] Add fadestart/fadeend/fog to R_AddColormaps --- src/r_data.c | 32 +++++++++++++++++++++++++++++++- src/r_data.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index 1de51fedd..53044bc2e 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1901,6 +1901,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFog, boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable) { @@ -1917,7 +1918,10 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex INT16 red, green, blue, alpha; + /////////////////// // base rgba + /////////////////// + red = max(min( R_GetRgbaR(exc_augend->rgba) + (subR ? -1 : 1) // subtract R @@ -1941,7 +1945,10 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex exc_augend->rgba = R_PutRgbaRGBA(red, green, blue, alpha); - // fade rgba + /////////////////// + // fade/dark rgba + /////////////////// + red = max(min( R_GetRgbaR(exc_augend->fadergba) + (subFadeR ? -1 : 1) // subtract R @@ -1967,6 +1974,29 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex exc_augend->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); + /////////////////// + // parameters + /////////////////// + + exc_augend->fadestart = max(min( + exc_augend->fadestart + + (subFadeStart ? -1 : 1) // subtract fadestart + * exc_addend->fadestart + , 31), 0); + + exc_augend->fadeend = max(min( + exc_augend->fadeend + + (subFadeEnd ? -1 : 1) // subtract fadeend + * exc_addend->fadeend + , 31), 0); + + if (!ignoreFog) // overwrite fog with new value + exc_augend->fog = exc_addend->fog; + + /////////////////// + // put it together + /////////////////// + if (!(exc = R_GetColormapFromList(exc_augend))) { exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; diff --git a/src/r_data.h b/src/r_data.h index df0fe75b3..3a7740c96 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -128,6 +128,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFog, boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable); #ifdef EXTRACOLORMAPLUMPS From 6059b8edc909b1ac5cbbf65c6b821852c69f53cf Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:06:58 -0400 Subject: [PATCH 220/573] 447: Extra params for R_AddColormaps --- src/p_spec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index 2c607f74e..41756423a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3268,6 +3268,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) line->flags & ML_NOCLIMB, // subtract FadeG line->flags & ML_EFFECT2, // subtract FadeB false, // subtract FadeA (no flag for this, just pass negative alpha) + false, // subtract FadeStart (we ran out of flags) + false, // subtract FadeEnd (we ran out of flags) + false, // ignore Fog (we ran out of flags) line->flags & ML_DONTPEGBOTTOM, (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].textureoffset >> FRACBITS) : 0, (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].rowoffset >> FRACBITS) : 0, From 133c3598a79828bbf140f844e306517a9aa79725 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:06:45 -0400 Subject: [PATCH 221/573] Add fadestart/fadeend/fog to R_AddColormaps --- src/r_data.c | 32 +++++++++++++++++++++++++++++++- src/r_data.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index 1de51fedd..53044bc2e 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1901,6 +1901,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFog, boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable) { @@ -1917,7 +1918,10 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex INT16 red, green, blue, alpha; + /////////////////// // base rgba + /////////////////// + red = max(min( R_GetRgbaR(exc_augend->rgba) + (subR ? -1 : 1) // subtract R @@ -1941,7 +1945,10 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex exc_augend->rgba = R_PutRgbaRGBA(red, green, blue, alpha); - // fade rgba + /////////////////// + // fade/dark rgba + /////////////////// + red = max(min( R_GetRgbaR(exc_augend->fadergba) + (subFadeR ? -1 : 1) // subtract R @@ -1967,6 +1974,29 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex exc_augend->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); + /////////////////// + // parameters + /////////////////// + + exc_augend->fadestart = max(min( + exc_augend->fadestart + + (subFadeStart ? -1 : 1) // subtract fadestart + * exc_addend->fadestart + , 31), 0); + + exc_augend->fadeend = max(min( + exc_augend->fadeend + + (subFadeEnd ? -1 : 1) // subtract fadeend + * exc_addend->fadeend + , 31), 0); + + if (!ignoreFog) // overwrite fog with new value + exc_augend->fog = exc_addend->fog; + + /////////////////// + // put it together + /////////////////// + if (!(exc = R_GetColormapFromList(exc_augend))) { exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; diff --git a/src/r_data.h b/src/r_data.h index df0fe75b3..3a7740c96 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -128,6 +128,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFog, boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable); #ifdef EXTRACOLORMAPLUMPS From 87ad2a87f79cb9fbfabee5a8dc8550c1f3305f2e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:14:23 -0400 Subject: [PATCH 222/573] Smarter default fadergbaA and fadeend for relative calc --- src/r_data.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 53044bc2e..5a642f1b2 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1968,7 +1968,7 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex , 255), 0); alpha = useAltAlpha ? altFadeAlpha : R_GetRgbaA(exc_addend->fadergba); - if (alpha == 25) + if (alpha == 25 && !useAltAlpha && !R_GetRgbaRGB(exc_addend->fadergba)) alpha = 0; // HACK: fadergba A defaults at 25, so don't add anything in this case alpha = max(min(R_GetRgbaA(exc_augend->fadergba) + (subFadeA ? -1 : 1) * alpha, 25), 0); @@ -1987,7 +1987,8 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex exc_augend->fadeend = max(min( exc_augend->fadeend + (subFadeEnd ? -1 : 1) // subtract fadeend - * exc_addend->fadeend + * (exc_addend->fadeend == 31 && !exc_addend->fadestart ? 0 : exc_addend->fadeend) + // HACK: fadeend defaults to 31, so don't add anything in this case , 31), 0); if (!ignoreFog) // overwrite fog with new value From 55c43a2161201ae4382565f3fd4616c0faddbca1 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:24:22 -0400 Subject: [PATCH 223/573] R_AddColormap will not return an existing colormap, and new colormap is not added to chain --- src/r_data.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 5a642f1b2..c8a648a0f 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1896,7 +1896,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) // // R_AddColormaps() -// NOTE: The result colormap DOES get added to the extra_colormaps chain! +// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself! // extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, @@ -1998,17 +1998,9 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex // put it together /////////////////// - if (!(exc = R_GetColormapFromList(exc_augend))) - { - exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; - R_AddColormapToList(exc_augend); - return exc_augend; - } - else - { - Z_Free(exc_augend); - return exc; - } + exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; + exc_augend->next = exc_augend->prev = NULL; + return exc_augend; } // Thanks to quake2 source! From 9a388af8ec6a38e6f3e90b3dee0b6b153612278b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:31:10 -0400 Subject: [PATCH 224/573] 447: AddColormap no longer returns chained colormap, so chain it ourselves --- src/p_spec.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 41756423a..2742f1b44 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3258,7 +3258,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) { if (line->flags & ML_EFFECT3) // relative calc - sectors[secnum].extra_colormap = R_AddColormaps( + { + extracolormap_t *exc = R_AddColormaps( sectors[secnum].extra_colormap, line->frontsector->extra_colormap, line->flags & ML_EFFECT1, // subtract R line->flags & ML_NOCLIMB, // subtract G @@ -3274,7 +3275,17 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) line->flags & ML_DONTPEGBOTTOM, (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].textureoffset >> FRACBITS) : 0, (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].rowoffset >> FRACBITS) : 0, - true); + false); + + if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + sectors[secnum].extra_colormap = exc; + } + else + Z_Free(exc); + } else sectors[secnum].extra_colormap = line->frontsector->extra_colormap; } From 6f0b28c48f0256c6194dee11d7714a31f51eff59 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:38:51 -0400 Subject: [PATCH 225/573] 447: Allow alternate alpha without relative calc --- src/p_spec.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 2742f1b44..637f90af8 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3287,7 +3287,25 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) Z_Free(exc); } else - sectors[secnum].extra_colormap = line->frontsector->extra_colormap; + { + if (line->flags & ML_DONTPEGBOTTOM) // alternate alpha (by texture offsets) + { + extracolormap_t *exc = R_CopyColormap(line->frontsector->extra_colormap, false); + exc->rgba = R_GetRgbaRGB(exc->rgba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].textureoffset >> FRACBITS, 25), 0)); + exc->fadergba = R_GetRgbaRGB(exc->fadergba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].rowoffset >> FRACBITS, 25), 0)); + + if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + sectors[secnum].extra_colormap = exc; + } + else + Z_Free(exc); + } + else + sectors[secnum].extra_colormap = line->frontsector->extra_colormap; + } } break; From 4d26cf63304005ac745909ace8b85bbde6fa1425 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:55:47 -0400 Subject: [PATCH 226/573] 447: Allow relative calc from backside colormap (ML_TFERLINE) --- src/p_spec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 637f90af8..914c9821e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3260,7 +3260,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (line->flags & ML_EFFECT3) // relative calc { extracolormap_t *exc = R_AddColormaps( - sectors[secnum].extra_colormap, line->frontsector->extra_colormap, + (line->flags & ML_TFERLINE) ? line->backsector->extra_colormap : sectors[secnum].extra_colormap, // use back colormap instead of target sector + line->frontsector->extra_colormap, line->flags & ML_EFFECT1, // subtract R line->flags & ML_NOCLIMB, // subtract G line->flags & ML_EFFECT2, // subtract B From cb2ac9b4d3943ab9c569afcb52a9d4a76a75edc1 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 08:06:44 -0400 Subject: [PATCH 227/573] Formatting --- src/p_spec.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 914c9821e..fd02803cc 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3287,26 +3287,23 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) else Z_Free(exc); } - else + else if (line->flags & ML_DONTPEGBOTTOM) // alternate alpha (by texture offsets) { - if (line->flags & ML_DONTPEGBOTTOM) // alternate alpha (by texture offsets) - { - extracolormap_t *exc = R_CopyColormap(line->frontsector->extra_colormap, false); - exc->rgba = R_GetRgbaRGB(exc->rgba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].textureoffset >> FRACBITS, 25), 0)); - exc->fadergba = R_GetRgbaRGB(exc->fadergba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].rowoffset >> FRACBITS, 25), 0)); + extracolormap_t *exc = R_CopyColormap(line->frontsector->extra_colormap, false); + exc->rgba = R_GetRgbaRGB(exc->rgba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].textureoffset >> FRACBITS, 25), 0)); + exc->fadergba = R_GetRgbaRGB(exc->fadergba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].rowoffset >> FRACBITS, 25), 0)); - if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(exc))) - { - exc->colormap = R_CreateLightTable(exc); - R_AddColormapToList(exc); - sectors[secnum].extra_colormap = exc; - } - else - Z_Free(exc); + if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + sectors[secnum].extra_colormap = exc; } else - sectors[secnum].extra_colormap = line->frontsector->extra_colormap; + Z_Free(exc); } + else + sectors[secnum].extra_colormap = line->frontsector->extra_colormap; } break; From 9a6a8b0b8255a34c6b85d31887cc2390a640c500 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 08:07:34 -0400 Subject: [PATCH 228/573] Outdated comment; unused var --- src/p_setup.c | 3 --- src/r_data.c | 2 -- 2 files changed, 5 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index edde5e701..c08c2ac58 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1459,9 +1459,6 @@ static void P_LoadRawSideDefs2(void *data) sd->sector = sec = §ors[sector_num]; } - // refined to allow colormaps to work as wall textures if invalid as colormaps - // but valid as textures. - sd->sector = sec = §ors[SHORT(msd->sector)]; // Colormaps! diff --git a/src/r_data.c b/src/r_data.c index c8a648a0f..c2e28fe9f 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1905,8 +1905,6 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable) { - extracolormap_t *exc; - // exc_augend is added (or subtracted) onto by exc_addend // In Rennaisance times, the first number was considered the augend, the second number the addend // But since the commutative property was discovered, today they're both called addends! From 14b71bdbc574c9255fb7a2eca5cfca3ba24ad36b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 09:06:38 -0400 Subject: [PATCH 229/573] Fade colormap special 455! And stop fade colormap 456 * Added T_FadeColormap thinker and netsync * Added sector_t fadecolormapdata property --- src/p_saveg.c | 47 ++++++++++++- src/p_setup.c | 1 + src/p_spec.c | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/p_spec.h | 14 ++++ src/r_defs.h | 1 + 5 files changed, 251 insertions(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index fc767d9cf..b3953c53c 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1099,6 +1099,7 @@ typedef enum tc_noenemies, tc_eachtime, tc_disappear, + tc_fadecolormap, tc_planedisplace, #ifdef POLYOBJECTS tc_polyrotate, // haleyjd 03/26/06: polyobjects @@ -1663,6 +1664,22 @@ static void SaveDisappearThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->exists); } +// +// SaveFadeColormapThinker +// +// Saves a fadecolormap_t thinker +// +static void SaveFadeColormapThinker(const thinker_t *th, const UINT8 type) +{ + const fadecolormap_t *ht = (const void *)th; + WRITEUINT8(save_p, type); + WRITEUINT32(save_p, SaveSector(ht->sector)); + SaveExtraColormap(save_p, ht->source_exc); + SaveExtraColormap(save_p, ht->dest_exc); + WRITEINT32(save_p, ht->duration); + WRITEINT32(save_p, ht->timer); +} + // // SavePlaneDisplaceThinker // @@ -1965,6 +1982,11 @@ static void P_NetArchiveThinkers(void) SaveDisappearThinker(th, tc_disappear); continue; } + else if (th->function.acp1 == (actionf_p1)T_FadeColormap) + { + SaveFadeColormapThinker(th, tc_fadecolormap); + continue; + } else if (th->function.acp1 == (actionf_p1)T_PlaneDisplace) { @@ -2641,6 +2663,25 @@ static inline void LoadDisappearThinker(actionf_p1 thinker) P_AddThinker(&ht->thinker); } +// +// LoadFadeColormapThinker +// +// Loads a fadecolormap_t from a save game +// +static inline void LoadFadeColormapThinker(actionf_p1 thinker) +{ + fadecolormap_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); + ht->thinker.function.acp1 = thinker; + ht->sector = LoadSector(READUINT32(save_p)); + ht->source_exc = LoadExtraColormap(save_p); + ht->dest_exc = LoadExtraColormap(save_p); + ht->duration = READINT32(save_p); + ht->timer = READINT32(save_p); + if (ht->sector) + ht->sector->fadecolormapdata = ht; + P_AddThinker(&ht->thinker); +} + // // LoadPlaneDisplaceThinker // @@ -2827,7 +2868,7 @@ static void P_NetUnArchiveThinkers(void) // clear sector thinker pointers so they don't point to non-existant thinkers for all of eternity for (i = 0; i < numsectors; i++) { - sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = NULL; + sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = sectors[i].fadecolormapdata = NULL; } // read in saved thinkers @@ -2944,6 +2985,10 @@ static void P_NetUnArchiveThinkers(void) LoadDisappearThinker((actionf_p1)T_Disappear); break; + case tc_fadecolormap: + LoadFadeColormapThinker((actionf_p1)T_FadeColormap); + break; + case tc_planedisplace: LoadPlaneDisplaceThinker((actionf_p1)T_PlaneDisplace); break; diff --git a/src/p_setup.c b/src/p_setup.c index c08c2ac58..b26459759 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1466,6 +1466,7 @@ static void P_LoadRawSideDefs2(void *data) { case 63: // variable colormap via 242 linedef case 606: //SoM: 4/4/2000: Just colormap transfer + case 455: // Fade colormaps! mazmazz 9/12/2018 (:flag_us:) // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, diff --git a/src/p_spec.c b/src/p_spec.c index 5135676ab..e20d85af6 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -103,6 +103,9 @@ static void P_SpawnFriction(void); static void P_SpawnPushers(void); static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t *source, INT32 affectee, INT32 referrer, INT32 exclusive, INT32 slider); //SoM: 3/9/2000 static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); +static void P_ResetColormapFader(sector_t *sector); +static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, extracolormap_t *dest_exc, + INT32 duration); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3310,6 +3313,82 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; } + case 455: // Fade colormap + for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + { + extracolormap_t *source_exc, *dest_exc, *exc; + + exc = (line->flags & ML_TFERLINE) ? line->backsector->extra_colormap // TFERLINE: use back colormap instead of target sector + : sectors[secnum].extra_colormap; + + if (!(line->flags & ML_BOUNCY) // BOUNCY: Do not override fade from default rgba + && !R_CheckDefaultColormap(line->frontsector->extra_colormap, true, false, false) + && R_CheckDefaultColormap(exc, true, false, false)) + { + exc = R_CopyColormap(exc, false); + exc->rgba = R_GetRgbaRGB(line->frontsector->extra_colormap->rgba) + R_PutRgbaA(R_GetRgbaA(exc->rgba)); + exc->fadergba = R_GetRgbaRGB(line->frontsector->extra_colormap->rgba) + R_PutRgbaA(R_GetRgbaA(exc->fadergba)); + + if (!(source_exc = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + source_exc = exc; + } + else + Z_Free(exc); + } + else + source_exc = exc; + + if (line->flags & ML_EFFECT3) // relative calc + { + exc = R_AddColormaps( + source_exc, + line->frontsector->extra_colormap, + line->flags & ML_EFFECT1, // subtract R + line->flags & ML_NOCLIMB, // subtract G + line->flags & ML_EFFECT2, // subtract B + false, // subtract A (no flag for this, just pass negative alpha) + line->flags & ML_EFFECT1, // subtract FadeR + line->flags & ML_NOCLIMB, // subtract FadeG + line->flags & ML_EFFECT2, // subtract FadeB + false, // subtract FadeA (no flag for this, just pass negative alpha) + false, // subtract FadeStart (we ran out of flags) + false, // subtract FadeEnd (we ran out of flags) + false, // ignore Fog (we ran out of flags) + line->flags & ML_DONTPEGBOTTOM, + (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].textureoffset >> FRACBITS) : 0, + (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].rowoffset >> FRACBITS) : 0, + false); + } + else if (line->flags & ML_DONTPEGBOTTOM) // alternate alpha (by texture offsets) + { + exc = R_CopyColormap(line->frontsector->extra_colormap, false); + exc->rgba = R_GetRgbaRGB(exc->rgba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].textureoffset >> FRACBITS, 25), 0)); + exc->fadergba = R_GetRgbaRGB(exc->fadergba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].rowoffset >> FRACBITS, 25), 0)); + } + else + exc = R_CopyColormap(line->frontsector->extra_colormap, false); + + if (!(dest_exc = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + dest_exc = exc; + } + else + Z_Free(exc); + + Add_ColormapFader(§ors[secnum], source_exc, dest_exc, + (line->sidenum[1] != 0xFFFF ? abs(sides[line->sidenum[1]].rowoffset >> FRACBITS) : abs(P_AproxDistance(line->dx, line->dy) >> FRACBITS))); + } + break; + + case 456: // Stop fade colormap + for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + P_ResetColormapFader(§ors[secnum]); + #ifdef POLYOBJECTS case 480: // Polyobj_DoorSlide case 481: // Polyobj_DoorSwing @@ -7322,6 +7401,116 @@ void T_Disappear(disappear_t *d) } } +static void P_ResetColormapFader(sector_t *sector) +{ + if (sector->fadecolormapdata) + { + // The thinker is the first member in all the action structs, + // so just let the thinker get freed, and that will free the whole + // structure. + P_RemoveThinker(&((elevator_t *)sector->fadecolormapdata)->thinker); + sector->fadecolormapdata = NULL; + } +} + +static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, extracolormap_t *dest_exc, + INT32 duration) +{ + P_ResetColormapFader(sector); + + // nothing to do, set immediately + if (!duration || R_CheckEqualColormaps(source_exc, dest_exc, true, true, true)) + { + sector->extra_colormap = dest_exc; + return; + } + + fadecolormap_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); + d->thinker.function.acp1 = (actionf_p1)T_FadeColormap; + d->sector = sector; + d->source_exc = source_exc; + d->dest_exc = dest_exc; + d->duration = d->timer = duration; + + sector->fadecolormapdata = d; + P_AddThinker(&d->thinker); // add thinker +} + +void T_FadeColormap(fadecolormap_t *d) +{ + if (--d->timer <= 0) + { + d->sector->extra_colormap = d->dest_exc; + P_ResetColormapFader(d->sector); + } + else + { + extracolormap_t *exc; + fixed_t factor = min(FixedDiv(d->duration - d->timer, d->duration), 1*FRACUNIT); + INT16 cr, cg, cb, ca, fadestart, fadeend, fog; + INT32 rgba, fadergba; + + // For each var (rgba + fadergba + params = 11 vars), we apply + // percentage fading: currentval = sourceval + (delta * percent of duration elapsed) + // delta is negative when fading out (destval is lower) + // max/min are used to ensure progressive calcs don't go backwards and to cap values to dest. + +#define APPLYFADE(dest, src, cur) (\ +(dest-src < 0) ? \ + max(\ + min(cur,\ + src + (UINT8)FixedMul(dest-src, factor)),\ + dest)\ +: (dest-src > 0) ? \ + min(\ + max(cur,\ + src + (UINT8)FixedMul(dest-src, factor)),\ + dest)\ +: \ + dest\ +) + + cr = APPLYFADE(R_GetRgbaR(d->dest_exc->rgba), R_GetRgbaR(d->source_exc->rgba), R_GetRgbaR(d->sector->extra_colormap->rgba)); + cg = APPLYFADE(R_GetRgbaG(d->dest_exc->rgba), R_GetRgbaG(d->source_exc->rgba), R_GetRgbaG(d->sector->extra_colormap->rgba)); + cb = APPLYFADE(R_GetRgbaB(d->dest_exc->rgba), R_GetRgbaB(d->source_exc->rgba), R_GetRgbaB(d->sector->extra_colormap->rgba)); + ca = APPLYFADE(R_GetRgbaA(d->dest_exc->rgba), R_GetRgbaA(d->source_exc->rgba), R_GetRgbaA(d->sector->extra_colormap->rgba)); + + rgba = R_PutRgbaRGBA(cr, cg, cb, ca); + + cr = APPLYFADE(R_GetRgbaR(d->dest_exc->fadergba), R_GetRgbaR(d->source_exc->fadergba), R_GetRgbaR(d->sector->extra_colormap->fadergba)); + cg = APPLYFADE(R_GetRgbaG(d->dest_exc->fadergba), R_GetRgbaG(d->source_exc->fadergba), R_GetRgbaG(d->sector->extra_colormap->fadergba)); + cb = APPLYFADE(R_GetRgbaB(d->dest_exc->fadergba), R_GetRgbaB(d->source_exc->fadergba), R_GetRgbaB(d->sector->extra_colormap->fadergba)); + ca = APPLYFADE(R_GetRgbaA(d->dest_exc->fadergba), R_GetRgbaA(d->source_exc->fadergba), R_GetRgbaA(d->sector->extra_colormap->fadergba)); + + fadergba = R_PutRgbaRGBA(cr, cg, cb, ca); + + fadestart = APPLYFADE(d->dest_exc->fadestart, d->source_exc->fadestart, d->sector->extra_colormap->fadestart); + fadeend = APPLYFADE(d->dest_exc->fadeend, d->source_exc->fadeend, d->sector->extra_colormap->fadeend); + // fog: essentially we're switching from source_exc->fog to dest_exc->fog with a delta + // of 1 or -1, and hoping the factor rounds appropriately in the timing. + fog = APPLYFADE(d->dest_exc->fog, d->source_exc->fog, d->sector->extra_colormap->fog); + +#undef APPLYFADE + + ////////////////// + // setup new colormap + ////////////////// + + if (!(d->sector->extra_colormap = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog))) + { + exc = R_CreateDefaultColormap(false); + exc->fadestart = fadestart; + exc->fadeend = fadeend; + exc->fog = (boolean)fog; + exc->rgba = rgba; + exc->fadergba = fadergba; + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + d->sector->extra_colormap = exc; + } + } +} + /* SoM: 3/8/2000: Friction functions start. Add_Friction, diff --git a/src/p_spec.h b/src/p_spec.h index e0bcc18eb..9e0b7d5c4 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -453,6 +453,20 @@ typedef struct void T_Disappear(disappear_t *d); +// Model for fading colormaps + +typedef struct +{ + thinker_t thinker; ///< Thinker structure for effect. + sector_t *sector; ///< Sector where action is taking place. + extracolormap_t *source_exc; + extracolormap_t *dest_exc; + INT32 duration; ///< Total duration for tic-based logic + INT32 timer; ///< Timer for tic-based logic +} fadecolormap_t; + +void T_FadeColormap(fadecolormap_t *d); + // Prototype functions for pushers void T_Pusher(pusher_t *p); mobj_t *P_GetPushThing(UINT32 s); diff --git a/src/r_defs.h b/src/r_defs.h index 99fad2b44..8c610cd4d 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -315,6 +315,7 @@ typedef struct sector_s void *floordata; // floor move thinker void *ceilingdata; // ceiling move thinker void *lightingdata; // lighting change thinker + void *fadecolormapdata; // fade colormap thinker // floor and ceiling texture offsets fixed_t floor_xoffs, floor_yoffs; From 4d9925e8cf2459d8a4e8e81fddd3761dff914aab Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 09:09:10 -0400 Subject: [PATCH 230/573] 447: ResetColormapFader when changing colormap explicitly --- src/p_spec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index 7d6ffaf2a..b38fa37c4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3260,6 +3260,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // -- Monster Iestyn 14/06/18 for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) { + P_ResetColormapFader(§ors[secnum]); + if (line->flags & ML_EFFECT3) // relative calc { extracolormap_t *exc = R_AddColormaps( From 8190433b71fdf258280bb99724d5287259674c45 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 09:42:51 -0400 Subject: [PATCH 231/573] 456: Missing break --- src/p_spec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_spec.c b/src/p_spec.c index b38fa37c4..e8f1c3cb8 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3447,6 +3447,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 456: // Stop fade colormap for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) P_ResetColormapFader(§ors[secnum]); + break; #ifdef POLYOBJECTS case 480: // Polyobj_DoorSlide From e95cd0f962f2567bc060ff981a6f01d1fe81f6fd Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 11:01:12 -0400 Subject: [PATCH 232/573] Colormap savegame failsafe - Handle NULL (default colormap) --- src/p_saveg.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index b3953c53c..c18837e17 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -476,6 +476,9 @@ static void P_NetUnArchivePlayers(void) static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) { + if (!exc) // Just give it default values, we done goofed. (or sector->extra_colormap was intentionally set to default (NULL)) + exc = R_GetDefaultColormap(); + WRITEUINT8(put, exc->fadestart); WRITEUINT8(put, exc->fadeend); WRITEUINT8(put, (UINT8)exc->fog); @@ -490,7 +493,7 @@ static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) static extracolormap_t *LoadExtraColormap(UINT8 *get) { - extracolormap_t *exc; + extracolormap_t *exc, *exc_exist; //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), @@ -525,14 +528,21 @@ static extracolormap_t *LoadExtraColormap(UINT8 *get) exc->rgba = rgba; exc->fadergba = fadergba; - exc->colormap = R_CreateLightTable(exc); - - R_AddColormapToList(exc); - #ifdef EXTRACOLORMAPLUMPS exc->lump = LUMPERROR; exc->lumpname[0] = 0; #endif + + if (!(exc_exist = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + } + else + { + Z_Free(exc); + exc = R_CheckDefaultColormap(exc_exist, true, true, true) ? NULL : exc_exist; + } } return exc; From d85019b4e4db8b9e2806b5a859a12b8ed325a6e7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 11:11:22 -0400 Subject: [PATCH 233/573] More NULL failsafes --- src/p_spec.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index e8f1c3cb8..7ae3c7871 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3396,9 +3396,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } else Z_Free(exc); + + sectors[secnum].extra_colormap = source_exc; } else - source_exc = exc; + source_exc = exc ? exc : R_GetDefaultColormap(); if (line->flags & ML_EFFECT3) // relative calc { @@ -7510,6 +7512,16 @@ void T_FadeColormap(fadecolormap_t *d) INT16 cr, cg, cb, ca, fadestart, fadeend, fog; INT32 rgba, fadergba; + // NULL failsafes (or intentionally set to signify default) + if (!d->sector->extra_colormap) + d->sector->extra_colormap = R_GetDefaultColormap(); + + if (!d->source_exc) + d->source_exc = R_GetDefaultColormap(); + + if (!d->dest_exc) + d->dest_exc = R_GetDefaultColormap(); + // For each var (rgba + fadergba + params = 11 vars), we apply // percentage fading: currentval = sourceval + (delta * percent of duration elapsed) // delta is negative when fading out (destval is lower) From 92c5cb82334a3066fd38c6881b236478611eca36 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 11:01:12 -0400 Subject: [PATCH 234/573] Colormap savegame failsafe - Handle NULL (default colormap) --- src/p_saveg.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index fc767d9cf..4084d8c13 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -476,6 +476,9 @@ static void P_NetUnArchivePlayers(void) static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) { + if (!exc) // Just give it default values, we done goofed. (or sector->extra_colormap was intentionally set to default (NULL)) + exc = R_GetDefaultColormap(); + WRITEUINT8(put, exc->fadestart); WRITEUINT8(put, exc->fadeend); WRITEUINT8(put, (UINT8)exc->fog); @@ -490,7 +493,7 @@ static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) static extracolormap_t *LoadExtraColormap(UINT8 *get) { - extracolormap_t *exc; + extracolormap_t *exc, *exc_exist; //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), @@ -525,14 +528,21 @@ static extracolormap_t *LoadExtraColormap(UINT8 *get) exc->rgba = rgba; exc->fadergba = fadergba; - exc->colormap = R_CreateLightTable(exc); - - R_AddColormapToList(exc); - #ifdef EXTRACOLORMAPLUMPS exc->lump = LUMPERROR; exc->lumpname[0] = 0; #endif + + if (!(exc_exist = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + } + else + { + Z_Free(exc); + exc = R_CheckDefaultColormap(exc_exist, true, true, true) ? NULL : exc_exist; + } } return exc; From 51a298222649e6e5f7b4564c20c45b57663b0e8e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 11:21:49 -0400 Subject: [PATCH 235/573] 455: TFERLINE - Set target sector's colormap first to control backsector's colormap --- src/p_spec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 7ae3c7871..9e4d38f97 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3377,8 +3377,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { extracolormap_t *source_exc, *dest_exc, *exc; - exc = (line->flags & ML_TFERLINE) ? line->backsector->extra_colormap // TFERLINE: use back colormap instead of target sector - : sectors[secnum].extra_colormap; + if (line->flags & ML_TFERLINE) // use back colormap instead of target sector + sectors[secnum].extra_colormap = line->backsector->extra_colormap; + + exc = sectors[secnum].extra_colormap; if (!(line->flags & ML_BOUNCY) // BOUNCY: Do not override fade from default rgba && !R_CheckDefaultColormap(line->frontsector->extra_colormap, true, false, false) From d2f636d5a2fcc678bbd0018dad00ca235a6f2fb6 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 11:33:44 -0400 Subject: [PATCH 236/573] T_FadeColormap: Fade subtraction error --- src/p_spec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 9e4d38f97..3e428c1f6 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7533,12 +7533,12 @@ void T_FadeColormap(fadecolormap_t *d) (dest-src < 0) ? \ max(\ min(cur,\ - src + (UINT8)FixedMul(dest-src, factor)),\ + src + (INT16)FixedMul(dest-src, factor)),\ dest)\ : (dest-src > 0) ? \ min(\ max(cur,\ - src + (UINT8)FixedMul(dest-src, factor)),\ + src + (INT16)FixedMul(dest-src, factor)),\ dest)\ : \ dest\ From 42f1f0acdb3b3c7ed4152cac3ff66b5910a3d13e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 12:40:56 -0400 Subject: [PATCH 237/573] P_ResetFakeFloorFader: Argument order error with dolighting --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index cd63191c9..56c10a4a1 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7524,8 +7524,8 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz &fadingdata->timer, fadingdata->doexists, fadingdata->dotranslucent, - fadingdata->docollision, fadingdata->dolighting, + fadingdata->docollision, fadingdata->doghostfade, fadingdata->exactalpha); rover->alpha = fadingdata->alpha; From 7d36aae7c404b29f71dafacce4f09355e9a30de0 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 16:06:56 -0400 Subject: [PATCH 238/573] Make lightlists react to control sector colormap changes (double pointer) --- src/r_bsp.c | 14 +++++++------- src/r_defs.h | 2 +- src/r_segs.c | 6 +++--- src/r_things.c | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index 01676572e..cbb012b28 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -925,11 +925,11 @@ static void R_Subsector(size_t num) light = R_GetPlaneLight(frontsector, floorcenterz, false); if (frontsector->floorlightsec == -1) floorlightlevel = *frontsector->lightlist[light].lightlevel; - floorcolormap = frontsector->lightlist[light].extra_colormap; + floorcolormap = *frontsector->lightlist[light].extra_colormap; light = R_GetPlaneLight(frontsector, ceilingcenterz, false); if (frontsector->ceilinglightsec == -1) ceilinglightlevel = *frontsector->lightlist[light].lightlevel; - ceilingcolormap = frontsector->lightlist[light].extra_colormap; + ceilingcolormap = *frontsector->lightlist[light].extra_colormap; } sub->sector->extra_colormap = frontsector->extra_colormap; @@ -1026,7 +1026,7 @@ static void R_Subsector(size_t num) ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic, *frontsector->lightlist[light].lightlevel, *rover->bottomxoffs, - *rover->bottomyoffs, *rover->bottomangle, frontsector->lightlist[light].extra_colormap, rover + *rover->bottomyoffs, *rover->bottomangle, *frontsector->lightlist[light].extra_colormap, rover #ifdef POLYOBJECTS_PLANES , NULL #endif @@ -1072,7 +1072,7 @@ static void R_Subsector(size_t num) ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic, *frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle, - frontsector->lightlist[light].extra_colormap, rover + *frontsector->lightlist[light].extra_colormap, rover #ifdef POLYOBJECTS_PLANES , NULL #endif @@ -1264,7 +1264,7 @@ void R_Prep3DFloors(sector_t *sector) #endif sector->lightlist[0].lightlevel = §or->lightlevel; sector->lightlist[0].caster = NULL; - sector->lightlist[0].extra_colormap = sector->extra_colormap; + sector->lightlist[0].extra_colormap = §or->extra_colormap; sector->lightlist[0].flags = 0; maxheight = INT32_MAX; @@ -1339,12 +1339,12 @@ void R_Prep3DFloors(sector_t *sector) else if (best->flags & FF_COLORMAPONLY) { sector->lightlist[i].lightlevel = sector->lightlist[i-1].lightlevel; - sector->lightlist[i].extra_colormap = sec->extra_colormap; + sector->lightlist[i].extra_colormap = &sec->extra_colormap; } else { sector->lightlist[i].lightlevel = best->toplightlevel; - sector->lightlist[i].extra_colormap = sec->extra_colormap; + sector->lightlist[i].extra_colormap = &sec->extra_colormap; } if (best->flags & FF_DOUBLESHADOW) diff --git a/src/r_defs.h b/src/r_defs.h index 99fad2b44..63ca29aa1 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -194,7 +194,7 @@ typedef struct lightlist_s { fixed_t height; INT16 *lightlevel; - extracolormap_t *extra_colormap; + extracolormap_t **extra_colormap; // pointer-to-a-pointer, so we can react to colormap changes INT32 flags; ffloor_t *caster; #ifdef ESLOPE diff --git a/src/r_segs.c b/src/r_segs.c index a52b7cb61..cde019f66 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -413,7 +413,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) #endif rlight->startheight = rlight->height; // keep starting value here to reset for each repeat rlight->lightlevel = *light->lightlevel; - rlight->extra_colormap = light->extra_colormap; + rlight->extra_colormap = *light->extra_colormap; rlight->flags = light->flags; if (rlight->flags & FF_FOG || (rlight->extra_colormap && rlight->extra_colormap->fog)) @@ -944,7 +944,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) } rlight->lightlevel = *light->lightlevel; - rlight->extra_colormap = light->extra_colormap; + rlight->extra_colormap = *light->extra_colormap; // Check if the current light effects the colormap/lightlevel if (pfloor->flags & FF_FOG) @@ -2808,7 +2808,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) } rlight->lightlevel = *light->lightlevel; - rlight->extra_colormap = light->extra_colormap; + rlight->extra_colormap = *light->extra_colormap; p++; } diff --git a/src/r_things.c b/src/r_things.c index fb4664d90..f4a0fd28c 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -981,7 +981,7 @@ static void R_SplitSprite(vissprite_t *sprite) else spritelights = scalelight[lightnum]; - newsprite->extra_colormap = sector->lightlist[i].extra_colormap; + newsprite->extra_colormap = *sector->lightlist[i].extra_colormap; if (!((newsprite->cut & SC_FULLBRIGHT) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) @@ -1360,7 +1360,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->sz = (INT16)((centeryfrac - FixedMul(vis->gz - viewz, sortscale))>>FRACBITS); vis->cut = cut; if (thing->subsector->sector->numlights) - vis->extra_colormap = thing->subsector->sector->lightlist[light].extra_colormap; + vis->extra_colormap = *thing->subsector->sector->lightlist[light].extra_colormap; else vis->extra_colormap = thing->subsector->sector->extra_colormap; From 62b6950e3324e550a63234ef9c7aed5ef798b5e2 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 16:28:55 -0400 Subject: [PATCH 239/573] Use lightlist.extra_colormap double pointers in OpenGL --- src/hardware/hw_main.c | 30 +++++++++++++++--------------- src/hardware/hw_md2.c | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 119be6b46..50399dbd6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1126,7 +1126,7 @@ static void HWR_SplitWall(sector_t *sector, wallVert3D *wallVerts, INT32 texnum, else { lightnum = *list[i].lightlevel; - colormap = list[i].extra_colormap; + colormap = *list[i].extra_colormap; } } @@ -3486,12 +3486,12 @@ static void HWR_Subsector(size_t num) light = R_GetPlaneLight(gr_frontsector, locFloorHeight, false); if (gr_frontsector->floorlightsec == -1) floorlightlevel = *gr_frontsector->lightlist[light].lightlevel; - floorcolormap = gr_frontsector->lightlist[light].extra_colormap; + floorcolormap = *gr_frontsector->lightlist[light].extra_colormap; light = R_GetPlaneLight(gr_frontsector, locCeilingHeight, false); if (gr_frontsector->ceilinglightsec == -1) ceilinglightlevel = *gr_frontsector->lightlist[light].lightlevel; - ceilingcolormap = gr_frontsector->lightlist[light].extra_colormap; + ceilingcolormap = *gr_frontsector->lightlist[light].extra_colormap; } sub->sector->extra_colormap = gr_frontsector->extra_colormap; @@ -3617,7 +3617,7 @@ static void HWR_Subsector(size_t num) *rover->bottomheight, *gr_frontsector->lightlist[light].lightlevel, rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, PF_Translucent, - false, gr_frontsector->lightlist[light].extra_colormap); + false, *gr_frontsector->lightlist[light].extra_colormap); #endif } else @@ -3625,7 +3625,7 @@ static void HWR_Subsector(size_t num) HWR_GetFlat(levelflats[*rover->bottompic].lumpnum); light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); HWR_RenderPlane(NULL, &extrasubsectors[num], false, *rover->bottomheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, - rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap); + rover->master->frontsector, 255, false, *gr_frontsector->lightlist[light].extra_colormap); } } @@ -3680,7 +3680,7 @@ static void HWR_Subsector(size_t num) *rover->topheight, *gr_frontsector->lightlist[light].lightlevel, rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, PF_Translucent, - false, gr_frontsector->lightlist[light].extra_colormap); + false, *gr_frontsector->lightlist[light].extra_colormap); #endif } @@ -3689,7 +3689,7 @@ static void HWR_Subsector(size_t num) HWR_GetFlat(levelflats[*rover->toppic].lumpnum); light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); HWR_RenderPlane(NULL, &extrasubsectors[num], true, *rover->topheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, - rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap); + rover->master->frontsector, 255, false, *gr_frontsector->lightlist[light].extra_colormap); } } } @@ -4200,8 +4200,8 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *sector->lightlist[light].lightlevel; - if (sector->lightlist[light].extra_colormap) - colormap = sector->lightlist[light].extra_colormap; + if (*sector->lightlist[light].extra_colormap) + colormap = *sector->lightlist[light].extra_colormap; } else { @@ -4362,7 +4362,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // Start with the lightlevel and colormap from the top of the sprite lightlevel = *list[sector->numlights - 1].lightlevel; - colormap = list[sector->numlights - 1].extra_colormap; + colormap = *list[sector->numlights - 1].extra_colormap; i = 0; temp = FLOAT_TO_FIXED(realtop); @@ -4378,7 +4378,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *list[i-1].lightlevel; - colormap = list[i-1].extra_colormap; + colormap = *list[i-1].extra_colormap; break; } } @@ -4386,7 +4386,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) i = R_GetPlaneLight(sector, temp, false); if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *list[i].lightlevel; - colormap = list[i].extra_colormap; + colormap = *list[i].extra_colormap; #endif for (i = 0; i < sector->numlights; i++) @@ -4402,7 +4402,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *list[i].lightlevel; - colormap = list[i].extra_colormap; + colormap = *list[i].extra_colormap; } #ifdef ESLOPE @@ -4734,8 +4734,8 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *sector->lightlist[light].lightlevel; - if (sector->lightlist[light].extra_colormap) - colormap = sector->lightlist[light].extra_colormap; + if (*sector->lightlist[light].extra_colormap) + colormap = *sector->lightlist[light].extra_colormap; } else { diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index bfb2638ee..d69233a9b 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1194,8 +1194,8 @@ void HWR_DrawMD2(gr_vissprite_t *spr) if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *sector->lightlist[light].lightlevel; - if (sector->lightlist[light].extra_colormap) - colormap = sector->lightlist[light].extra_colormap; + if (*sector->lightlist[light].extra_colormap) + colormap = *sector->lightlist[light].extra_colormap; } else { From 9fb9b4438319b06f5ea8ecfc6977294b30f005d9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 16:57:35 -0400 Subject: [PATCH 240/573] Fade FOF colormap support --- src/p_saveg.c | 4 +++ src/p_spec.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++---- src/p_spec.h | 2 ++ 3 files changed, 78 insertions(+), 5 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 5550c7a8b..0f81da5ac 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1587,6 +1587,7 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) { const fade_t *ht = (const void *)th; WRITEUINT8(save_p, type); + SaveExtraColormap(save_p, ht->dest_exc); WRITEUINT32(save_p, ht->sectornum); WRITEUINT32(save_p, ht->ffloornum); WRITEINT32(save_p, ht->alpha); @@ -1599,6 +1600,7 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) WRITEUINT8(save_p, ht->doexists); WRITEUINT8(save_p, ht->dotranslucent); WRITEUINT8(save_p, ht->dolighting); + WRITEUINT8(save_p, ht->docolormap); WRITEUINT8(save_p, ht->docollision); WRITEUINT8(save_p, ht->doghostfade); WRITEUINT8(save_p, ht->exactalpha); @@ -2599,6 +2601,7 @@ static inline void LoadFadeThinker(actionf_p1 thinker) { fade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; + ht->dest_exc = LoadExtraColormap(save_p); ht->sectornum = READUINT32(save_p); ht->ffloornum = READUINT32(save_p); ht->alpha = READINT32(save_p); @@ -2611,6 +2614,7 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->doexists = READUINT8(save_p); ht->dotranslucent = READUINT8(save_p); ht->dolighting = READUINT8(save_p); + ht->docolormap = READUINT8(save_p); ht->docollision = READUINT8(save_p); ht->doghostfade = READUINT8(save_p); ht->exactalpha = READUINT8(save_p); diff --git a/src/p_spec.c b/src/p_spec.c index 56c10a4a1..c37ee954c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -106,10 +106,15 @@ static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t o static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finalize); #define P_RemoveFakeFloorFader(l) P_ResetFakeFloorFader(l, NULL, false); static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destvalue, INT16 speed, boolean ticbased, INT32 *timer, - boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha); + boolean doexists, boolean dotranslucent, boolean dolighting, boolean docolormap, + boolean docollision, boolean doghostfade, boolean exactalpha); static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, INT16 destvalue, INT16 speed, boolean ticbased, boolean relative, - boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha); + boolean doexists, boolean dotranslucent, boolean dolighting, boolean docolormap, + boolean docollision, boolean doghostfade, boolean exactalpha); +static void P_ResetColormapFader(sector_t *sector); +static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, extracolormap_t *dest_exc, + INT32 duration); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3370,6 +3375,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) false, // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // handle FF_TRANSLUCENT false, // do not handle lighting + false, // do not handle colormap false, // do not handle collision false, // do not do ghost fade (no collision during fade) true); // use exact alpha values (for opengl) @@ -3421,6 +3427,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT !(line->flags & ML_EFFECT2), // do not handle lighting + !(line->flags & ML_EFFECT2), // do not handle colormap (ran out of flags) !(line->flags & ML_BOUNCY), // do not handle collision (line->flags & ML_EFFECT1), // do ghost fade (no collision during fade) (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) @@ -3445,6 +3452,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT !(line->flags & ML_EFFECT2), // do not handle lighting + !(line->flags & ML_EFFECT2), // do not handle colormap (ran out of flags) !(line->flags & ML_BOUNCY), // do not handle collision (line->flags & ML_EFFECT1), // do ghost fade (no collision during fade) (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) @@ -7525,6 +7533,7 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz fadingdata->doexists, fadingdata->dotranslucent, fadingdata->dolighting, + fadingdata->docolormap, fadingdata->docollision, fadingdata->doghostfade, fadingdata->exactalpha); @@ -7533,6 +7542,9 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz if (fadingdata->dolighting) P_RemoveLighting(§ors[rover->secnum]); + if (fadingdata->docolormap) + P_ResetColormapFader(§ors[rover->secnum]); + P_RemoveThinker(&fadingdata->thinker); } @@ -7541,7 +7553,8 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz } static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destvalue, INT16 speed, boolean ticbased, INT32 *timer, - boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha) + boolean doexists, boolean dotranslucent, boolean dolighting, boolean docolormap, + boolean docollision, boolean doghostfade, boolean exactalpha) { boolean stillfading = false; INT32 alpha; @@ -7801,7 +7814,8 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destval */ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, INT16 destvalue, INT16 speed, boolean ticbased, boolean relative, - boolean doexists, boolean dotranslucent, boolean dolighting, boolean docollision, boolean doghostfade, boolean exactalpha) + boolean doexists, boolean dotranslucent, boolean dolighting, boolean docolormap, + boolean docollision, boolean doghostfade, boolean exactalpha) { // If fading an invisible FOF whose render flags we did not yet set, // initialize its alpha to 1 @@ -7841,6 +7855,7 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor d->doexists = doexists; d->dotranslucent = dotranslucent; d->dolighting = dolighting; + d->docolormap = docolormap; d->docollision = docollision; d->doghostfade = doghostfade; d->exactalpha = exactalpha; @@ -7869,6 +7884,54 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor else d->destlightlevel = -1; + // Set a separate thinker for colormap fading + if (docolormap && !(rover->flags & FF_NOSHADE) && sectors[rover->secnum].spawn_extra_colormap) + { + extracolormap_t *dest_exc, + *source_exc = sectors[rover->secnum].extra_colormap ? sectors[rover->secnum].extra_colormap : R_GetDefaultColormap(); + + INT32 colordelta = R_GetRgbaA(sectors[rover->secnum].spawn_extra_colormap->rgba); // alpha is from 0 + fixed_t alphapercent = min(FixedDiv(d->destvalue, rover->spawnalpha), 1*FRACUNIT); // don't make darker than spawn_lightlevel + fixed_t adjustedcolordelta = FixedMul(colordelta, alphapercent); + INT32 coloralpha; + + coloralpha = adjustedcolordelta; + + dest_exc = R_CopyColormap(sectors[rover->secnum].spawn_extra_colormap, false); + dest_exc->rgba = R_GetRgbaRGB(dest_exc->rgba) + R_PutRgbaA(coloralpha); + + if (!(d->dest_exc = R_GetColormapFromList(dest_exc))) + { + dest_exc->colormap = R_CreateLightTable(dest_exc); + R_AddColormapToList(dest_exc); + d->dest_exc = dest_exc; + } + else + Z_Free(dest_exc); + + // If fading from 0, set source_exc rgb same to dest_exc + if (!R_CheckDefaultColormap(d->dest_exc, true, false, false) + && R_CheckDefaultColormap(source_exc, true, false, false)) + { + extracolormap_t *exc = R_CopyColormap(source_exc, false); + exc->rgba = R_GetRgbaRGB(d->dest_exc->rgba) + R_PutRgbaA(R_GetRgbaA(source_exc->rgba)); + exc->fadergba = R_GetRgbaRGB(d->dest_exc->rgba) + R_PutRgbaA(R_GetRgbaA(source_exc->fadergba)); + + if (!(source_exc = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + source_exc = exc; + } + else + Z_Free(exc); + } + + Add_ColormapFader(§ors[rover->secnum], source_exc, d->dest_exc, + ticbased ? d->timer : + FixedFloor(FixedDiv(abs(d->destvalue - d->alpha), d->speed))/FRACUNIT); + } + P_AddThinker(&d->thinker); } @@ -7880,12 +7943,16 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor void T_Fade(fade_t *d) { if (d->rover && !P_FadeFakeFloor(d->rover, d->sourcevalue, d->destvalue, d->speed, d->ticbased, &d->timer, - d->doexists, d->dotranslucent, d->dolighting, d->docollision, d->doghostfade, d->exactalpha)) + d->doexists, d->dotranslucent, d->dolighting, d->docolormap, d->docollision, d->doghostfade, d->exactalpha)) { // Finalize lighting, copypasta from P_AddFakeFloorFader if (d->dolighting && !(d->rover->flags & FF_NOSHADE) && d->destlightlevel > -1) sectors[d->rover->secnum].lightlevel = d->destlightlevel; + // Finalize colormap + if (d->docolormap && !(d->rover->flags & FF_NOSHADE) && sectors[d->rover->secnum].spawn_extra_colormap) + sectors[d->rover->secnum].extra_colormap = d->dest_exc; + P_RemoveFakeFloorFader(d->rover); } } diff --git a/src/p_spec.h b/src/p_spec.h index 1970aeb6b..189823435 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -466,6 +466,7 @@ typedef struct { thinker_t thinker; ///< Thinker structure for effect. ffloor_t *rover; ///< Target ffloor + extracolormap_t *dest_exc; ///< Colormap to fade to UINT32 sectornum; ///< Number of ffloor target sector UINT32 ffloornum; ///< Number of ffloor of target sector INT32 alpha; ///< Internal alpha counter @@ -478,6 +479,7 @@ typedef struct boolean doexists; ///< Handle FF_EXISTS boolean dotranslucent; ///< Handle FF_TRANSLUCENT boolean dolighting; ///< Handle shadows and light blocks + boolean docolormap; ///< Handle colormaps boolean docollision; ///< Handle interactive flags boolean doghostfade; ///< No interactive flags during fading boolean exactalpha; ///< Use exact alpha values (opengl) From ad9ef5d59316246b647d456c170da6d98293914a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 17:39:30 -0400 Subject: [PATCH 241/573] Merge errors --- src/p_saveg.c | 2 -- src/p_spec.c | 2 +- src/r_defs.h | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index f2e8dcdb7..c9b474b1d 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -730,8 +730,6 @@ static void P_NetArchiveWorld(void) WRITEINT32(put, ss->firsttag); WRITEINT32(put, ss->nexttag); } - if (diff3 & SD_MIDMAP) - WRITEINT32(put, ss->midmap); if (diff3 & SD_COLORMAP) SaveExtraColormap(put, ss->extra_colormap); diff --git a/src/p_spec.c b/src/p_spec.c index b5e862749..21380584b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3256,7 +3256,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // This could even override existing colormaps I believe // -- Monster Iestyn 14/06/18 for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) - sectors[secnum].midmap = line->frontsector->midmap; + sectors[secnum].extra_colormap = line->frontsector->extra_colormap; break; case 448: // Change skybox viewpoint/centerpoint diff --git a/src/r_defs.h b/src/r_defs.h index 1d1d471e5..63ca29aa1 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -390,7 +390,6 @@ typedef struct sector_s // these are saved for netgames, so do not let Lua touch these! INT32 spawn_nexttag, spawn_firsttag; // the actual nexttag/firsttag values may differ if the sector's tag was changed - INT32 spawn_bottommap, spawn_midmap, spawn_topmap; // offsets sector spawned with (via linedef type 7) fixed_t spawn_flr_xoffs, spawn_flr_yoffs; From f7ff440250ddaf9ee1a03a254cfad0834d6514e3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 20:43:48 -0400 Subject: [PATCH 242/573] Add colormap_data to side_t and store colormaps there on setup --- src/p_setup.c | 2 +- src/p_spec.c | 4 ++-- src/r_defs.h | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 5d7fd3179..cc5ee3cc8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1469,7 +1469,7 @@ static void P_LoadRawSideDefs2(void *data) case 447: // Change colormap of tagged sectors! -- Monster Iestyn 14/06/18 // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. - sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, + sd->colormap_data = R_CreateColormap(msd->toptexture, msd->midtexture, msd->bottomtexture); sd->toptexture = sd->midtexture = sd->bottomtexture = 0; break; diff --git a/src/p_spec.c b/src/p_spec.c index 21380584b..8e5a612c3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3256,7 +3256,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // This could even override existing colormaps I believe // -- Monster Iestyn 14/06/18 for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) - sectors[secnum].extra_colormap = line->frontsector->extra_colormap; + sectors[secnum].extra_colormap = sides[line->sidenum[0]].colormap_data; break; case 448: // Change skybox viewpoint/centerpoint @@ -6769,7 +6769,7 @@ void P_SpawnSpecials(INT32 fromnetsave) case 606: // HACK! Copy colormaps. Just plain colormaps. for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - sectors[s].extra_colormap = sectors[s].spawn_extra_colormap = lines[i].frontsector->extra_colormap; + sectors[s].extra_colormap = sectors[s].spawn_extra_colormap = sides[lines[i].sidenum[0]].colormap_data; break; #ifdef ESLOPE // Slope copy specials. Handled here for sanity. diff --git a/src/r_defs.h b/src/r_defs.h index 63ca29aa1..1f2afdb99 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -476,6 +476,8 @@ typedef struct INT16 repeatcnt; // # of times to repeat midtexture char *text; // a concatination of all top, bottom, and mid texture names, for linedef specials that require a string. + + extracolormap_t *colormap_data; // storage for colormaps; not applied to sectors. } side_t; // From 05c91f1f81aea11738269d84e5cf5816b56bfe46 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 20:52:05 -0400 Subject: [PATCH 243/573] 455: Change to side->colormap_data --- src/p_spec.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 8797200c2..491671c40 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3379,17 +3379,18 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) extracolormap_t *source_exc, *dest_exc, *exc; if (line->flags & ML_TFERLINE) // use back colormap instead of target sector - sectors[secnum].extra_colormap = line->backsector->extra_colormap; + sectors[secnum].extra_colormap = (line->sidenum[1] != 0xFFFF) ? + sides[line->sidenum[1]].colormap_data : NULL; exc = sectors[secnum].extra_colormap; if (!(line->flags & ML_BOUNCY) // BOUNCY: Do not override fade from default rgba - && !R_CheckDefaultColormap(line->frontsector->extra_colormap, true, false, false) + && !R_CheckDefaultColormap(sides[line->sidenum[0]].colormap_data, true, false, false) && R_CheckDefaultColormap(exc, true, false, false)) { exc = R_CopyColormap(exc, false); - exc->rgba = R_GetRgbaRGB(line->frontsector->extra_colormap->rgba) + R_PutRgbaA(R_GetRgbaA(exc->rgba)); - exc->fadergba = R_GetRgbaRGB(line->frontsector->extra_colormap->rgba) + R_PutRgbaA(R_GetRgbaA(exc->fadergba)); + exc->rgba = R_GetRgbaRGB(sides[line->sidenum[0]].colormap_data->rgba) + R_PutRgbaA(R_GetRgbaA(exc->rgba)); + exc->fadergba = R_GetRgbaRGB(sides[line->sidenum[0]].colormap_data->rgba) + R_PutRgbaA(R_GetRgbaA(exc->fadergba)); if (!(source_exc = R_GetColormapFromList(exc))) { @@ -3409,7 +3410,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { exc = R_AddColormaps( source_exc, - line->frontsector->extra_colormap, + sides[line->sidenum[0]].colormap_data, line->flags & ML_EFFECT1, // subtract R line->flags & ML_NOCLIMB, // subtract G line->flags & ML_EFFECT2, // subtract B @@ -3428,12 +3429,12 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } else if (line->flags & ML_DONTPEGBOTTOM) // alternate alpha (by texture offsets) { - exc = R_CopyColormap(line->frontsector->extra_colormap, false); + exc = R_CopyColormap(sides[line->sidenum[0]].colormap_data, false); exc->rgba = R_GetRgbaRGB(exc->rgba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].textureoffset >> FRACBITS, 25), 0)); exc->fadergba = R_GetRgbaRGB(exc->fadergba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].rowoffset >> FRACBITS, 25), 0)); } else - exc = R_CopyColormap(line->frontsector->extra_colormap, false); + exc = R_CopyColormap(sides[line->sidenum[0]].colormap_data, false); if (!(dest_exc = R_GetColormapFromList(exc))) { From 0b2caa948fb89ab5a7d25d2164c01b01091237fa Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 21:05:50 -0400 Subject: [PATCH 244/573] Init side->colormap_data pointer to NULL (for paranoia) --- src/p_setup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index cc5ee3cc8..f0ce69598 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1461,6 +1461,8 @@ static void P_LoadRawSideDefs2(void *data) sd->sector = sec = §ors[SHORT(msd->sector)]; + sd->colormap_data = NULL; + // Colormaps! switch (sd->special) { From 41fe080a68b36df41d0a6161e570e59ad0bb037a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 21:32:12 -0400 Subject: [PATCH 245/573] 420: Allow Back Y Offset for timing parameter --- src/p_spec.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index aa3a81f23..eed083cd9 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2779,8 +2779,14 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 420: // Fade light levels in tagged sectors to new value P_FadeLight(line->tag, - (line->flags & ML_DONTPEGBOTTOM) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, - (line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, + (line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].textureoffset>>FRACBITS, 0) : line->frontsector->lightlevel, + // failsafe: if user specifies Back Y Offset and NOT Front Y Offset, use the Back Offset + // to be consistent with other light and fade specials + (line->flags & ML_DONTPEGBOTTOM) ? + ((line->sidenum[1] != 0xFFFF && !(sides[line->sidenum[0]].rowoffset>>FRACBITS)) ? + max(min(sides[line->sidenum[1]].rowoffset>>FRACBITS, 255), 0) + : max(min(sides[line->sidenum[0]].rowoffset>>FRACBITS, 255), 0)) + : abs(P_AproxDistance(line->dx, line->dy))>>FRACBITS), (line->flags & ML_EFFECT4)); break; From 63a3125df2a5f12fcecc28d7d4ccbcd4b6252b2b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 21:47:53 -0400 Subject: [PATCH 246/573] 420: A parenthesis --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 85790041f..5ccdca671 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2786,7 +2786,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ((line->sidenum[1] != 0xFFFF && !(sides[line->sidenum[0]].rowoffset>>FRACBITS)) ? max(min(sides[line->sidenum[1]].rowoffset>>FRACBITS, 255), 0) : max(min(sides[line->sidenum[0]].rowoffset>>FRACBITS, 255), 0)) - : abs(P_AproxDistance(line->dx, line->dy))>>FRACBITS), + : abs(P_AproxDistance(line->dx, line->dy))>>FRACBITS, (line->flags & ML_EFFECT4)); break; From 2f9e014aab5b41f078914114bd32524ce60f1a8b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 21:58:20 -0400 Subject: [PATCH 247/573] 490 PolyVisible: Set proper spawn render flags instead of RENDERALL --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index a20a339ed..65f7fcd67 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1218,7 +1218,7 @@ static void PolyVisible(line_t *line) po->flags |= POF_SOLID; po->flags &= ~POF_NOSPECIALS; - po->flags |= POF_RENDERALL; + po->flags |= (po->spawnflags & POF_RENDERALL); } // From 0697a1b90a6fa7763a9472d21e7e1e5e872f0f0e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 22:08:07 -0400 Subject: [PATCH 248/573] PolyObjFade: Apply RENDER, SOLID, and NOSPECIALS flags according to spawnflags --- src/p_polyobj.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index a8616dba1..b47afed27 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2898,7 +2898,7 @@ void T_PolyObjFade(polyfade_t *th) if (po->translucency >= NUMTRANSMAPS) // invisible po->flags &= ~POF_RENDERALL; else - po->flags |= POF_RENDERALL; + po->flags |= (po->spawnflags & POF_RENDERALL); // set collision if (th->docollision && th->speed) @@ -2910,14 +2910,15 @@ void T_PolyObjFade(polyfade_t *th) } else { - po->flags |= POF_SOLID; - po->flags &= ~POF_NOSPECIALS; + po->flags |= (po->spawnflags & POF_SOLID); + if (!(po->spawnflags & POF_NOSPECIALS)) + po->flags &= ~POF_NOSPECIALS; } } } else { - po->flags |= POF_RENDERALL; + po->flags |= (po->spawnflags & POF_RENDERALL); // set collision if (th->docollision && th->speed) @@ -2929,8 +2930,9 @@ void T_PolyObjFade(polyfade_t *th) } else { - po->flags |= POF_SOLID; - po->flags &= ~POF_NOSPECIALS; + po->flags |= (po->spawnflags & POF_SOLID); + if (!(po->spawnflags & POF_NOSPECIALS)) + po->flags &= ~POF_NOSPECIALS; } } } From 4ab3a986f319ec7632e4d0d0fde3f2e325f1704c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 00:04:50 -0400 Subject: [PATCH 249/573] 492 PolyObj Fade, 491 PolyObj Translucency, 490 PolyObj changes * 490: Set proper render flags according to spawnflags * 491: Add relative calc (EFFECT3) and Front X alpha param (DONTPEGTOP) * 492: * Tic-based (EFFECT4) and speed timing * Add relative calc (EFFECT3) and Front X alpha param (DONTPEGTOP) * Set proper render flags according to spawnflags * Fix OpenGL >= NUMTRANSMAPS render bug --- src/p_polyobj.c | 85 +++++++++++++++++++++++++++++++++++++------------ src/p_polyobj.h | 6 ++-- src/p_saveg.c | 6 ++-- src/p_spec.c | 57 +++++++++++++++++++++++++-------- 4 files changed, 116 insertions(+), 38 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index b47afed27..f7545e5bd 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2873,23 +2873,54 @@ void T_PolyObjFade(polyfade_t *th) if (po->thinker == NULL) po->thinker = &th->thinker; - stillfading = !(--(th->timer) <= 0); - - if (th->timer <= 0) + if (th->ticbased) { - po->translucency = th->destvalue; // set to dest translucency + stillfading = !(--(th->timer) <= 0); - // remove thinker - if (po->thinker == &th->thinker) - po->thinker = NULL; - P_RemoveThinker(&th->thinker); - } - else if (!(th->timer % th->interval)) - { - if (th->speed <= 0) - po->translucency = max(po->translucency + th->speed, th->destvalue); + if (th->timer <= 0) + { + po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); + + // remove thinker + if (po->thinker == &th->thinker) + po->thinker = NULL; + P_RemoveThinker(&th->thinker); + } else - po->translucency = min(po->translucency + th->speed, th->destvalue); + { + INT16 delta = abs(th->destvalue - th->sourcevalue); + fixed_t factor = min(FixedDiv(th->speed - th->timer, th->speed), 1*FRACUNIT); + if (th->destvalue < th->sourcevalue) + po->translucency = max(min(po->translucency, th->sourcevalue - (INT16)FixedMul(delta, factor)), th->destvalue); + else if (th->destvalue > th->sourcevalue) + po->translucency = min(max(po->translucency, th->sourcevalue + (INT16)FixedMul(delta, factor)), th->destvalue); + } + } + else + { + fixed_t timerdest = FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS-th->destvalue); + + if (th->destvalue > th->sourcevalue) // fading out, destvalue is higher + { + // for timer, lower is transparent, higher is opaque + stillfading = (th->timer > timerdest); + th->timer = max(timerdest, th->timer - th->speed); + } + else if (th->destvalue < th->sourcevalue) // fading in, destvalue is lower + { stillfading = (th->timer < timerdest); + th->timer = min(timerdest, th->timer + th->speed); + } + + if (!stillfading) + { + po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); + // remove thinker + if (po->thinker == &th->thinker) + po->thinker = NULL; + P_RemoveThinker(&th->thinker); + } + else + po->translucency = FixedDiv(256-th->timer, FixedDiv(256, NUMTRANSMAPS)); } if (!stillfading) @@ -2901,9 +2932,9 @@ void T_PolyObjFade(polyfade_t *th) po->flags |= (po->spawnflags & POF_RENDERALL); // set collision - if (th->docollision && th->speed) + if (th->docollision) { - if (th->speed > 0) // faded out + if (th->destvalue > th->sourcevalue) // faded out { po->flags &= ~POF_SOLID; po->flags |= POF_NOSPECIALS; @@ -2918,10 +2949,14 @@ void T_PolyObjFade(polyfade_t *th) } else { + if (po->translucency >= NUMTRANSMAPS) + // HACK: OpenGL renders fully opaque when >= NUMTRANSMAPS + po->translucency = NUMTRANSMAPS-1; + po->flags |= (po->spawnflags & POF_RENDERALL); // set collision - if (th->docollision && th->speed) + if (th->docollision) { if (th->doghostfade) { @@ -2967,12 +3002,22 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) // set fields th->polyObjNum = pfdata->polyObjNum; + th->sourcevalue = po->translucency; th->destvalue = pfdata->destvalue; th->docollision = pfdata->docollision; th->doghostfade = pfdata->doghostfade; - th->timer = pfdata->timer; - th->speed = pfdata->speed; - th->interval = pfdata->interval; + + if (pfdata->ticbased) + { + th->ticbased = true; + th->timer = th->speed = abs(pfdata->speed); // use th->speed for total duration + } + else + { + th->ticbased = false; + th->timer = FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - po->translucency); // use as internal counter + th->speed = pfdata->speed; + } oldpo = po; diff --git a/src/p_polyobj.h b/src/p_polyobj.h index d5c07cb5b..61404112c 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -212,12 +212,13 @@ typedef struct polyfade_s thinker_t thinker; // must be first INT32 polyObjNum; + INT32 sourcevalue; INT32 destvalue; boolean docollision; boolean doghostfade; + boolean ticbased; INT32 timer; INT32 speed; - UINT32 interval; } polyfade_t; // @@ -285,9 +286,8 @@ typedef struct polyfadedata_s INT32 destvalue; boolean docollision; boolean doghostfade; - INT32 timer; + boolean ticbased; INT32 speed; - UINT32 interval; } polyfadedata_t; // diff --git a/src/p_saveg.c b/src/p_saveg.c index 403f05b00..2bfc5859a 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1705,12 +1705,13 @@ static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type) const polyfade_t *ht = (const void *)th; WRITEUINT8(save_p, type); WRITEINT32(save_p, ht->polyObjNum); + WRITEINT32(save_p, ht->sourcevalue); WRITEINT32(save_p, ht->destvalue); WRITEUINT8(save_p, (UINT8)ht->docollision); WRITEUINT8(save_p, (UINT8)ht->doghostfade); + WRITEUINT8(save_p, (UINT8)ht->ticbased); WRITEINT32(save_p, ht->timer); WRITEINT32(save_p, ht->speed); - WRITEUINT32(save_p, ht->interval); } #endif @@ -2719,12 +2720,13 @@ static void LoadPolyfadeThinker(actionf_p1 thinker) polyfade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->polyObjNum = READINT32(save_p); + ht->sourcevalue = READINT32(save_p); ht->destvalue = READINT32(save_p); ht->docollision = (boolean)READUINT8(save_p); ht->doghostfade = (boolean)READUINT8(save_p); + ht->ticbased = (boolean)READUINT8(save_p); ht->timer = READINT32(save_p); ht->speed = READINT32(save_p); - ht->interval = READUINT32(save_p); P_AddThinker(&ht->thinker); } #endif diff --git a/src/p_spec.c b/src/p_spec.c index 65f7fcd67..49d266f99 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1242,7 +1242,21 @@ static void PolyTranslucency(line_t *line) if (po->isBad) return; - po->translucency = (line->frontsector->floorheight >> FRACBITS) / 100; + // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset + // else, take it out of 1000. If Front X Offset is specified, use that. Else, use floorheight. + if (line->flags & ML_EFFECT3) // relative calc + po->translucency = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), + NUMTRANSMAPS), 0); + else + po->translucency = (line->flags & ML_DONTPEGBOTTOM) ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); } // @@ -1265,22 +1279,39 @@ static boolean PolyFade(line_t *line) if (po->isBad) return 0; - // already equal, nothing to do - if (po->translucency == max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0)) - return 1; - polyfadedata_t pfd; pfd.polyObjNum = polyObjNum; - pfd.destvalue = max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0); - pfd.docollision = !(line->flags & ML_BOUNCY), // do not handle collision flags - pfd.doghostfade = (line->flags & ML_EFFECT1), // do ghost fade (no collision flags during fade) - pfd.timer = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); - pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.timer))/FRACUNIT; - if (!pfd.speed) - pfd.speed = (pfd.destvalue < po->translucency) ? -1 : 1; - pfd.interval = max(FixedFloor(FixedDiv(pfd.timer, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1); + // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset + // else, take it out of 1000 like type 491. If Front X Offset is specified, use that. Else, use floorheight. + if (line->flags & ML_EFFECT3) + pfd.destvalue = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), + NUMTRANSMAPS), 0); + else + pfd.destvalue = (line->flags & ML_DONTPEGBOTTOM) ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); + + // already equal, nothing to do + if (po->translucency == pfd.destvalue) + return 1; + + pfd.docollision = !(line->flags & ML_BOUNCY); // do not handle collision flags + pfd.doghostfade = (line->flags & ML_EFFECT1); // do ghost fade (no collision flags during fade) + pfd.ticbased = (line->flags & ML_EFFECT4); // Speed = Tic Duration + + // allow Back Y Offset to be consistent with other fade specials + pfd.speed = (line->sidenum[1] != 0xFFFF && !sides[line->sidenum[0]].rowoffset) ? + abs(sides[line->sidenum[1]].rowoffset>>FRACBITS) + : abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + return EV_DoPolyObjFade(&pfd); } From 539092bec5a173c4a78b24e90df66a6498843966 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 00:26:24 -0400 Subject: [PATCH 250/573] 491, 492: Allow BLOCKMONSTERS raw translucency value in floorheight --- src/p_spec.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 49d266f99..0502b5638 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1246,14 +1246,18 @@ static void PolyTranslucency(line_t *line) // else, take it out of 1000. If Front X Offset is specified, use that. Else, use floorheight. if (line->flags & ML_EFFECT3) // relative calc po->translucency = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? - max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS)) : (sides[line->sidenum[0]].textureoffset ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), NUMTRANSMAPS), 0); else po->translucency = (line->flags & ML_DONTPEGBOTTOM) ? - max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), 0)) : (sides[line->sidenum[0]].textureoffset ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); @@ -1284,17 +1288,21 @@ static boolean PolyFade(line_t *line) pfd.polyObjNum = polyObjNum; // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset - // else, take it out of 1000 like type 491. If Front X Offset is specified, use that. Else, use floorheight. - if (line->flags & ML_EFFECT3) + // else, take it out of 1000. If Front X Offset is specified, use that. Else, use floorheight. + if (line->flags & ML_EFFECT3) // relative calc pfd.destvalue = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? - max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS)) : (sides[line->sidenum[0]].textureoffset ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), NUMTRANSMAPS), 0); else pfd.destvalue = (line->flags & ML_DONTPEGBOTTOM) ? - max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), 0)) : (sides[line->sidenum[0]].textureoffset ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); From 5aa66f887270733ebfe4bb3452fc58c8f4453995 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 10:38:15 -0400 Subject: [PATCH 251/573] 455: Add speed increment timing (~EFFECT4) to FadeColormap --- src/p_saveg.c | 2 ++ src/p_spec.c | 25 +++++++++++++++++++------ src/p_spec.h | 5 +++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 1c8d46aa1..e0d3f1e94 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1687,6 +1687,7 @@ static void SaveFadeColormapThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, SaveSector(ht->sector)); SaveExtraColormap(save_p, ht->source_exc); SaveExtraColormap(save_p, ht->dest_exc); + WRITEUINT8(save_p, (UINT8)ht->ticbased); WRITEINT32(save_p, ht->duration); WRITEINT32(save_p, ht->timer); } @@ -2686,6 +2687,7 @@ static inline void LoadFadeColormapThinker(actionf_p1 thinker) ht->sector = LoadSector(READUINT32(save_p)); ht->source_exc = LoadExtraColormap(save_p); ht->dest_exc = LoadExtraColormap(save_p); + ht->ticbased = (boolean)READUINT8(save_p); ht->duration = READINT32(save_p); ht->timer = READINT32(save_p); if (ht->sector) diff --git a/src/p_spec.c b/src/p_spec.c index 491671c40..bed5a89b4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -105,7 +105,7 @@ static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t * static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); static void P_ResetColormapFader(sector_t *sector); static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, extracolormap_t *dest_exc, - INT32 duration); + boolean ticbased, INT32 duration); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3445,7 +3445,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) else Z_Free(exc); - Add_ColormapFader(§ors[secnum], source_exc, dest_exc, + Add_ColormapFader(§ors[secnum], source_exc, dest_exc, (line->flags & ML_EFFECT4), // tic-based timing (line->sidenum[1] != 0xFFFF ? abs(sides[line->sidenum[1]].rowoffset >> FRACBITS) : abs(P_AproxDistance(line->dx, line->dy) >> FRACBITS))); } break; @@ -7480,7 +7480,7 @@ static void P_ResetColormapFader(sector_t *sector) } static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, extracolormap_t *dest_exc, - INT32 duration) + boolean ticbased, INT32 duration) { P_ResetColormapFader(sector); @@ -7496,7 +7496,18 @@ static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, ext d->sector = sector; d->source_exc = source_exc; d->dest_exc = dest_exc; - d->duration = d->timer = duration; + + if (ticbased) + { + d->ticbased = true; + d->duration = d->timer = duration; + } + else + { + d->ticbased = false; + d->timer = 256; + d->duration = duration; // use as speed + } sector->fadecolormapdata = d; P_AddThinker(&d->thinker); // add thinker @@ -7504,7 +7515,8 @@ static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, ext void T_FadeColormap(fadecolormap_t *d) { - if (--d->timer <= 0) + if ((d->ticbased && --d->timer <= 0) + || (!d->ticbased && (d->timer -= d->duration) <= 0)) // d->duration used as speed decrement { d->sector->extra_colormap = d->dest_exc; P_ResetColormapFader(d->sector); @@ -7512,7 +7524,8 @@ void T_FadeColormap(fadecolormap_t *d) else { extracolormap_t *exc; - fixed_t factor = min(FixedDiv(d->duration - d->timer, d->duration), 1*FRACUNIT); + INT32 duration = d->ticbased ? d->duration : 256; + fixed_t factor = min(FixedDiv(duration - d->timer, duration), 1*FRACUNIT); INT16 cr, cg, cb, ca, fadestart, fadeend, fog; INT32 rgba, fadergba; diff --git a/src/p_spec.h b/src/p_spec.h index 9e0b7d5c4..0a798ffcc 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -461,8 +461,9 @@ typedef struct sector_t *sector; ///< Sector where action is taking place. extracolormap_t *source_exc; extracolormap_t *dest_exc; - INT32 duration; ///< Total duration for tic-based logic - INT32 timer; ///< Timer for tic-based logic + boolean ticbased; ///< Tic-based timing + INT32 duration; ///< Total duration for tic-based logic (OR: speed increment) + INT32 timer; ///< Timer for tic-based logic (OR: internal speed counter) } fadecolormap_t; void T_FadeColormap(fadecolormap_t *d); From 94939f661357bdf1c6c20b9894cf9d4aee33637b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 10:41:22 -0400 Subject: [PATCH 252/573] 455: Don't override fadergba on default/no colormap init (~BOUNCY) --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index bed5a89b4..72b215163 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3390,7 +3390,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { exc = R_CopyColormap(exc, false); exc->rgba = R_GetRgbaRGB(sides[line->sidenum[0]].colormap_data->rgba) + R_PutRgbaA(R_GetRgbaA(exc->rgba)); - exc->fadergba = R_GetRgbaRGB(sides[line->sidenum[0]].colormap_data->rgba) + R_PutRgbaA(R_GetRgbaA(exc->fadergba)); + //exc->fadergba = R_GetRgbaRGB(sides[line->sidenum[0]].colormap_data->rgba) + R_PutRgbaA(R_GetRgbaA(exc->fadergba)); if (!(source_exc = R_GetColormapFromList(exc))) { From 3fc8ed5a9f05d8a387517ae657f7e224cdddb196 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 10:53:03 -0400 Subject: [PATCH 253/573] 455: Set timing by either Back Y or Front Y, but not line length --- src/p_spec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 72b215163..1d213b63e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3446,7 +3446,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) Z_Free(exc); Add_ColormapFader(§ors[secnum], source_exc, dest_exc, (line->flags & ML_EFFECT4), // tic-based timing - (line->sidenum[1] != 0xFFFF ? abs(sides[line->sidenum[1]].rowoffset >> FRACBITS) : abs(P_AproxDistance(line->dx, line->dy) >> FRACBITS))); + ((line->flags & ML_DONTPEGBOTTOM) || !sides[line->sidenum[0]].rowoffset) && line->sidenum[1] != 0xFFFF ? + abs(sides[line->sidenum[1]].rowoffset >> FRACBITS) + : abs(sides[line->sidenum[0]].rowoffset >> FRACBITS)); } break; From c32c72c401b16d15184b1821cb52ff9e80717910 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 7 Sep 2018 18:14:52 -0400 Subject: [PATCH 254/573] Thwomp fix: Don't trigger (look for players) when ~FF_EXISTS --- src/p_floor.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index f30637659..f3dda23bf 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1818,6 +1818,7 @@ void T_ThwompSector(levelspecthink_t *thwomp) #define ceilingwasheight vars[5] fixed_t thwompx, thwompy; sector_t *actionsector; + ffloor_t *rover = NULL; INT32 secnum; // If you just crashed down, wait a second before coming back up. @@ -1832,7 +1833,16 @@ void T_ThwompSector(levelspecthink_t *thwomp) secnum = P_FindSectorFromTag((INT16)thwomp->vars[0], -1); if (secnum > 0) + { actionsector = §ors[secnum]; + + // Look for thwomp FFloor + for (rover = actionsector->ffloors; rover; rover = rover->next) + { + if (rover->master == thwomp->sourceline) + break; + } + } else return; // Bad bad bad! @@ -1921,10 +1931,13 @@ void T_ThwompSector(levelspecthink_t *thwomp) { mobj_t *mp = (void *)&actionsector->soundorg; - if (thwomp->sourceline->flags & ML_EFFECT4) - S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); - else - S_StartSound(mp, sfx_thwomp); + if (!rover || (rover->flags & FF_EXISTS)) + { + if (thwomp->sourceline->flags & ML_EFFECT4) + S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); + else + S_StartSound(mp, sfx_thwomp); + } thwomp->direction = 1; // start heading back up thwomp->distance = TICRATE; // but only after a small delay @@ -1938,18 +1951,21 @@ void T_ThwompSector(levelspecthink_t *thwomp) thinker_t *th; mobj_t *mo; - // scan the thinkers to find players! - for (th = thinkercap.next; th != &thinkercap; th = th->next) + if (!rover || (rover->flags & FF_EXISTS)) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo = (mobj_t *)th; - if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight - && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + // scan the thinkers to find players! + for (th = thinkercap.next; th != &thinkercap; th = th->next) { - thwomp->direction = -1; - break; + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + mo = (mobj_t *)th; + if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight + && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + { + thwomp->direction = -1; + break; + } } } From 89a6694d6743375e3dbaaabfec48f7e12d1f9cfb Mon Sep 17 00:00:00 2001 From: Digiku Date: Thu, 13 Sep 2018 11:30:00 -0400 Subject: [PATCH 255/573] Don't trigger thwomp on spectators --- src/p_floor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_floor.c b/src/p_floor.c index f3dda23bf..e613b5ed4 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1960,7 +1960,8 @@ void T_ThwompSector(levelspecthink_t *thwomp) continue; mo = (mobj_t *)th; - if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight + if (mo->type == MT_PLAYER && mo->health && mo->player && !mo->player->spectator + && mo->z <= thwomp->sector->ceilingheight && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) { thwomp->direction = -1; From 6824e6a3596031a11e78b9c1d4706deee592c83c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 12:08:46 -0400 Subject: [PATCH 256/573] Make extracolormap_t->fog UINT8; it's not boolean, but categorical --- src/p_saveg.c | 7 +++---- src/r_data.c | 10 +++++----- src/r_data.h | 8 ++++---- src/r_defs.h | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index c9b474b1d..2d39ccfa2 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -481,7 +481,7 @@ static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) WRITEUINT8(put, exc->fadestart); WRITEUINT8(put, exc->fadeend); - WRITEUINT8(put, (UINT8)exc->fog); + WRITEUINT8(put, exc->fog); WRITEINT32(put, exc->rgba); WRITEINT32(put, exc->fadergba); @@ -497,9 +497,8 @@ static extracolormap_t *LoadExtraColormap(UINT8 *get) //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), - fadeend = READUINT8(get); - - boolean fog = (boolean)READUINT8(get); + fadeend = READUINT8(get), + fog = READUINT8(get); INT32 rgba = READINT32(get), fadergba = READINT32(get); diff --git a/src/r_data.c b/src/r_data.c index c2e28fe9f..e987da066 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1439,10 +1439,10 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) // #ifdef EXTRACOLORMAPLUMPS boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, - INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump) + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog, lumpnum_t lump) #else boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, - INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog) + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog) #endif { return ( @@ -1504,9 +1504,9 @@ boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, bo // NOTE: Returns NULL if no match is found // #ifdef EXTRACOLORMAPLUMPS -extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump) +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog, lumpnum_t lump) #else -extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog) +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog) #endif { extracolormap_t *exc; @@ -1730,7 +1730,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) // default values UINT8 cr = 0, cg = 0, cb = 0, ca = 0, cfr = 0, cfg = 0, cfb = 0, cfa = 25; UINT32 fadestart = 0, fadeend = 31; - boolean fog = false; + UINT8 fog = 0; INT32 rgba = 0, fadergba = 0x19000000; #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) diff --git a/src/r_data.h b/src/r_data.h index 3a7740c96..54857661a 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -112,12 +112,12 @@ void R_AddColormapToList(extracolormap_t *extra_colormap); #ifdef EXTRACOLORMAPLUMPS boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, - INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); -extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog, lumpnum_t lump); +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog, lumpnum_t lump); #else boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, - INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); -extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog); +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog); #endif boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams); diff --git a/src/r_defs.h b/src/r_defs.h index 1f2afdb99..b9c6fd7dc 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -53,7 +53,7 @@ typedef UINT8 lighttable_t; typedef struct extracolormap_s { UINT8 fadestart, fadeend; - boolean fog; + UINT8 fog; // 1 = disable sprite fullbright, 2 = force planes fullbright, see public gitlab !268 // store rgba values in combined bitwise // also used in OpenGL instead lighttables From 761150b12d3b0fcf1a7f392d609b4a43e75ae982 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 12:18:10 -0400 Subject: [PATCH 257/573] 455: Fog flag fix for fading --- src/p_spec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 1d213b63e..88a046b37 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7577,9 +7577,7 @@ void T_FadeColormap(fadecolormap_t *d) fadestart = APPLYFADE(d->dest_exc->fadestart, d->source_exc->fadestart, d->sector->extra_colormap->fadestart); fadeend = APPLYFADE(d->dest_exc->fadeend, d->source_exc->fadeend, d->sector->extra_colormap->fadeend); - // fog: essentially we're switching from source_exc->fog to dest_exc->fog with a delta - // of 1 or -1, and hoping the factor rounds appropriately in the timing. - fog = APPLYFADE(d->dest_exc->fog, d->source_exc->fog, d->sector->extra_colormap->fog); + fog = abs(factor) > FRACUNIT/2 ? d->dest_exc->fog : d->source_exc->fog; // set new fog flag halfway through fade #undef APPLYFADE From 07af82aa8495101c8170a44b7f92cb5c3dc7eb69 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 12:18:53 -0400 Subject: [PATCH 258/573] Missed fog boolean -> integer --- src/r_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index e987da066..f1cd519e0 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1784,7 +1784,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) { if (p2[1]) { - fog = (boolean)NUMFROMCHAR(p2[1]); + fog = NUMFROMCHAR(p2[1]); if (p2[2] && p2[3]) { fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); From 714464993ef49e8f6beb3133dce03380e0289c36 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 08:26:52 -0400 Subject: [PATCH 259/573] 420: Removed unnecessary include (gametic no longer needed) --- src/p_lights.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_lights.c b/src/p_lights.c index 95171155e..8bcdd8ce0 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -13,7 +13,6 @@ /// Fire flicker, light flash, strobe flash, lightning flash, glow, and fade. #include "doomdef.h" -#include "doomstat.h" // gametic #include "p_local.h" #include "r_state.h" #include "z_zone.h" From f8834b02019b03c9bead2414a28f790d6ce933f9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 25 Mar 2018 19:07:21 -0400 Subject: [PATCH 260/573] 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 261/573] 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 b59aa2710433ca89744f4f9a91eb1e0dba727c6f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 09:37:02 -0400 Subject: [PATCH 262/573] Loose ends other targets (cherry picked from commit 9a5fc5f66a31baf713c6f32f7a696b933da6907b) --- src/android/i_sound.c | 22 ++++----- src/djgppdos/i_sound.c | 28 +---------- src/dummy/i_sound.c | 15 ++---- src/sdl/sdl_sound.c | 6 +-- src/win32/win_main.c | 4 +- src/win32/win_snd.c | 106 +++++++++++++++++++++-------------------- 6 files changed, 74 insertions(+), 107 deletions(-) diff --git a/src/android/i_sound.c b/src/android/i_sound.c index ecf96f2f0..1011dbb6a 100644 --- a/src/android/i_sound.c +++ b/src/android/i_sound.c @@ -64,12 +64,12 @@ void I_InitMusic(void){} void I_ShutdownMusic(void){} -void I_PauseSong(INT32 handle) +void I_PauseSong(void) { (void)handle; } -void I_ResumeSong(INT32 handle) +void I_ResumeSong(void) { (void)handle; } @@ -80,23 +80,19 @@ void I_ResumeSong(INT32 handle) UINT8 midimusic_started = 0; -void I_InitMIDIMusic(void){} - -void I_ShutdownMIDIMusic(void){} - -void I_SetMIDIMusicVolume(INT32 volume) -{ - (void)volume; -} - -INT32 I_RegisterSong(void *data, size_t len) +boolean I_LoadSong(char *data, size_t len) { (void)data; (void)len; return -1; } -boolean I_PlaySong(INT32 handle, INT32 looping) +void I_SetMIDIMusicVolume(INT32 volume) +{ + (void)volume; +} + +boolean I_PlaySong(boolean looping) { (void)handle; (void)looping; diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index 88fc807f4..105e8d67a 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -408,31 +408,7 @@ void I_ShutdownMIDIMusic(void) music_started=false; } -void I_InitDigMusic(void) -{ -// CONS_Printf("Digital music not yet supported under DOS.\n"); -} - -void I_ShutdownDigMusic(void) -{ -// CONS_Printf("Digital music not yet supported under DOS.\n"); -} - -void I_InitMusic(void) -{ - if (!nodigimusic) - I_InitDigMusic(); - if (!nomidimusic) - I_InitMIDIMusic(); -} - -void I_ShutdownMusic(void) -{ - I_ShutdownMIDIMusic(); - I_ShutdownDigMusic(); -} - -boolean I_PlaySong(INT32 handle, INT32 looping) +boolean I_PlaySong(boolean looping) { handle = 0; if (nomidimusic) @@ -495,7 +471,7 @@ void I_UnRegisterSong(INT32 handle) //destroy_midi(currsong); } -INT32 I_RegisterSong(void *data, size_t len) +boolean I_LoadSong(char *data, size_t len) { int e = len; //Alam: For error if (nomidimusic) diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c index 51dbb610d..2f6f0001c 100644 --- a/src/dummy/i_sound.c +++ b/src/dummy/i_sound.c @@ -70,7 +70,7 @@ void I_PauseSong(INT32 handle) (void)handle; } -void I_ResumeSong(INT32 handle) +void I_ResumeSong(void) { (void)handle; } @@ -79,23 +79,14 @@ void I_ResumeSong(INT32 handle) // MIDI I/O // -void I_InitMIDIMusic(void){} - -void I_ShutdownMIDIMusic(void){} - -void I_SetMIDIMusicVolume(UINT8 volume) -{ - (void)volume; -} - -INT32 I_RegisterSong(void *data, size_t len) +boolean I_LoadSong(char *data, size_t len) { (void)data; (void)len; return -1; } -boolean I_PlaySong(INT32 handle, boolean looping) +boolean I_PlaySong(boolean looping) { (void)handle; (void)looping; diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 6c70c163b..c714f675b 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1605,7 +1605,7 @@ static void I_PauseGME(void) #endif } -void I_PauseSong(INT32 handle) +void I_PauseSong(void) { (void)handle; I_PauseGME(); @@ -1625,7 +1625,7 @@ static void I_ResumeGME(void) #endif } -void I_ResumeSong(INT32 handle) +void I_ResumeSong(void) { (void)handle; I_ResumeGME(); @@ -1669,7 +1669,7 @@ void I_UnRegisterSong(INT32 handle) #endif } -INT32 I_RegisterSong(void *data, size_t len) +boolean I_LoadSong(char *data, size_t len) { #ifdef HAVE_MIXER if (nomidimusic || !musicStarted) diff --git a/src/win32/win_main.c b/src/win32/win_main.c index 6c774f557..bfe620a43 100644 --- a/src/win32/win_main.c +++ b/src/win32/win_main.c @@ -110,9 +110,9 @@ static LRESULT CALLBACK MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPAR // pause music when alt-tab if (appActive && !paused) - I_ResumeSong(0); + I_ResumeSong(); else if (!paused) - I_PauseSong(0); + I_PauseSong(); { HANDLE ci = GetStdHandle(STD_INPUT_HANDLE); DWORD mode; diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index f168f1fe3..18c88d267 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -456,14 +456,14 @@ void I_ShutdownMusic(void) I_ShutdownMIDIMusic(); } -void I_PauseSong(INT32 handle) +void I_PauseSong(void) { UNREFERENCED_PARAMETER(handle); if (music_stream) FMR_MUSIC(FMOD_Channel_SetPaused(music_channel, true)); } -void I_ResumeSong(INT32 handle) +void I_ResumeSong(void) { UNREFERENCED_PARAMETER(handle); if (music_stream) @@ -644,60 +644,64 @@ boolean I_StartDigSong(const char *musicname, boolean looping) current_track = 0; // Try to find a loop point in streaming music formats (ogg, mp3) - if (looping) - { - FMOD_RESULT e; - FMOD_TAG tag; - unsigned int loopstart, loopend; + FMOD_RESULT e; + FMOD_TAG tag; + unsigned int loopstart, loopend; - // A proper LOOPPOINT is its own tag, stupid. - e = FMOD_Sound_GetTag(music_stream, "LOOPPOINT", 0, &tag); - if (e != FMOD_ERR_TAGNOTFOUND) + // A proper LOOPPOINT is its own tag, stupid. + e = FMOD_Sound_GetTag(music_stream, "LOOPPOINT", 0, &tag); + if (e != FMOD_ERR_TAGNOTFOUND) + { + FMR(e); + loopstart = atoi((char *)tag.data); // assumed to be a string data tag. + FMR(FMOD_Sound_GetLoopPoints(music_stream, NULL, FMOD_TIMEUNIT_PCM, &loopend, FMOD_TIMEUNIT_PCM)); + if (loopstart > 0) + FMR(FMOD_Sound_SetLoopPoints(music_stream, loopstart, FMOD_TIMEUNIT_PCM, loopend, FMOD_TIMEUNIT_PCM)); + return true; + } + + // todo + // if(music type == MIDI) + // { + // FMR(FMOD_Sound_SetMode(music_stream, FMOD_LOOP_NORMAL)); + // return true; + // } + + // Use LOOPMS for time in miliseconds. + e = FMOD_Sound_GetTag(music_stream, "LOOPMS", 0, &tag); + if (e != FMOD_ERR_TAGNOTFOUND) + { + FMR(e); + loopstart = atoi((char *)tag.data); // assumed to be a string data tag. + FMR(FMOD_Sound_GetLoopPoints(music_stream, NULL, FMOD_TIMEUNIT_MS, &loopend, FMOD_TIMEUNIT_PCM)); + if (loopstart > 0) + FMR(FMOD_Sound_SetLoopPoints(music_stream, loopstart, FMOD_TIMEUNIT_MS, loopend, FMOD_TIMEUNIT_PCM)); + return true; + } + + // Try to fetch it from the COMMENT tag, like A.J. Freda + e = FMOD_Sound_GetTag(music_stream, "COMMENT", 0, &tag); + if (e != FMOD_ERR_TAGNOTFOUND) + { + char *loopText; + // Handle any errors that arose, first + FMR(e); + // Figure out where the number starts + loopText = strstr((char *)tag.data,"LOOPPOINT="); + if (loopText != NULL) { - FMR(e); - loopstart = atoi((char *)tag.data); // assumed to be a string data tag. + // Skip the "LOOPPOINT=" part. + loopText += 10; + // Convert it to our looppoint + // FMOD seems to ensure the tag is properly NULL-terminated. + // atoi will stop when it reaches anything that's not a number. + loopstart = atoi(loopText); + // Now do the rest like above FMR(FMOD_Sound_GetLoopPoints(music_stream, NULL, FMOD_TIMEUNIT_PCM, &loopend, FMOD_TIMEUNIT_PCM)); if (loopstart > 0) FMR(FMOD_Sound_SetLoopPoints(music_stream, loopstart, FMOD_TIMEUNIT_PCM, loopend, FMOD_TIMEUNIT_PCM)); - return true; - } - - // Use LOOPMS for time in miliseconds. - e = FMOD_Sound_GetTag(music_stream, "LOOPMS", 0, &tag); - if (e != FMOD_ERR_TAGNOTFOUND) - { - FMR(e); - loopstart = atoi((char *)tag.data); // assumed to be a string data tag. - FMR(FMOD_Sound_GetLoopPoints(music_stream, NULL, FMOD_TIMEUNIT_MS, &loopend, FMOD_TIMEUNIT_PCM)); - if (loopstart > 0) - FMR(FMOD_Sound_SetLoopPoints(music_stream, loopstart, FMOD_TIMEUNIT_MS, loopend, FMOD_TIMEUNIT_PCM)); - return true; - } - - // Try to fetch it from the COMMENT tag, like A.J. Freda - e = FMOD_Sound_GetTag(music_stream, "COMMENT", 0, &tag); - if (e != FMOD_ERR_TAGNOTFOUND) - { - char *loopText; - // Handle any errors that arose, first - FMR(e); - // Figure out where the number starts - loopText = strstr((char *)tag.data,"LOOPPOINT="); - if (loopText != NULL) - { - // Skip the "LOOPPOINT=" part. - loopText += 10; - // Convert it to our looppoint - // FMOD seems to ensure the tag is properly NULL-terminated. - // atoi will stop when it reaches anything that's not a number. - loopstart = atoi(loopText); - // Now do the rest like above - FMR(FMOD_Sound_GetLoopPoints(music_stream, NULL, FMOD_TIMEUNIT_PCM, &loopend, FMOD_TIMEUNIT_PCM)); - if (loopstart > 0) - FMR(FMOD_Sound_SetLoopPoints(music_stream, loopstart, FMOD_TIMEUNIT_PCM, loopend, FMOD_TIMEUNIT_PCM)); - } - return true; } + return true; } // No special loop point, but we're playing so it's all good. @@ -825,7 +829,7 @@ void I_SetMIDIMusicVolume(UINT8 volume) FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, volume / 31.0)); } -INT32 I_RegisterSong(void *data, size_t len) +boolean I_PlaySong(boolean looping) { FMOD_CREATESOUNDEXINFO fmt; memset(&fmt, 0, sizeof(FMOD_CREATESOUNDEXINFO)); From 06b73679414f3c52755ee407833b0d965f0ab761 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 10:18:38 -0400 Subject: [PATCH 263/573] Added I_GetMusicType and removed midimode variable * Revised S_PlayMusic arguments * Now music plays again! (cherry picked from commit 55f3803e4b9f8104c90cc6c769d54121e5bac0b8) --- src/i_sound.h | 18 +++++++++++++++ src/s_sound.c | 16 +++++++------ src/sdl/mixer_sound.c | 54 +++++++++++++++++++++++++++++++++---------- 3 files changed, 69 insertions(+), 19 deletions(-) diff --git a/src/i_sound.h b/src/i_sound.h index 084479ee1..0fe62d5eb 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -18,6 +18,21 @@ #include "sounds.h" #include "command.h" +// copied from SDL mixer, plus GME +typedef enum { + MU_NONE, + MU_CMD, + MU_WAV, + MU_MOD, + MU_MID, + MU_OGG, + MU_MP3, + MU_MP3_MAD_UNUSED, // use MU_MP3 instead + MU_FLAC, + MU_MODPLUG_UNUSED, // use MU_MOD instead + MU_GME +} musictype_t; + /** \brief Sound subsystem runing and waiting */ extern UINT8 sound_started; @@ -108,6 +123,9 @@ void I_SetSfxVolume(UINT8 volume); // // MUSIC I/O // + +musictype_t I_GetMusicType(void); + /** \brief Init the music systems */ void I_InitMusic(void); diff --git a/src/s_sound.c b/src/s_sound.c index 76ee4c649..279f0dc6d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1227,7 +1227,7 @@ static boolean S_MIDIMusic(const char *mname, boolean looping) return true; } -static boolean S_DigMusic(const char *mname, boolean looping) +static boolean S_PlayMusic(boolean looping) { if (nodigimusic || digital_disabled) return false; // try midi @@ -1235,11 +1235,6 @@ static boolean S_DigMusic(const char *mname, boolean looping) if (!I_StartDigSong(mname, looping)) return false; - strncpy(music_name, mname, 7); - music_name[6] = 0; - music_lumpnum = LUMPERROR; - music_data = NULL; - music_handle = 0; return true; } @@ -1262,11 +1257,18 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) if (strncmp(music_name, mmusic, 6)) { S_StopMusic(); // shutdown old music - if (!S_DigMusic(mmusic, looping) && !S_MIDIMusic(mmusic, looping)) + + if (!S_LoadMusic(mmusic)) { CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), mmusic); return; } + + if (!S_PlayMusic(looping)) + { + CONS_Alert(CONS_ERROR, "Music cannot be played!\n"); + return; + } } I_SetSongTrack(mflags & MUSIC_TRACKMASK); } diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 5211efe0a..0888d5d31 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -62,7 +62,6 @@ UINT8 sound_started = false; -static boolean midimode; static Mix_Music *music; static UINT8 music_volume, midi_volume, sfx_volume; static float loop_point; @@ -87,7 +86,6 @@ void I_StartupSound(void) return; } - midimode = false; music = NULL; music_volume = midi_volume = sfx_volume = 0; @@ -436,6 +434,25 @@ void I_SetSfxVolume(UINT8 volume) // Music // +musictype_t I_GetMusicType(void) +{ +#ifdef HAVE_LIBGME + if (gme) + return MU_GME; + else +#endif + if (!music) + return MU_NONE; + else if (Mix_GetMusicType(music) == MUS_MID) + return MU_MID; + else if (Mix_GetMusicType(music) == MUS_MOD || Mix_GetMusicType(music) == MUS_MODPLUG_UNUSED) + return MU_MOD; + else if (Mix_GetMusicType(music) == MUS_MP3 || Mix_GetMusicType(music) == MUS_MP3_MAD_UNUSED) + return MU_MP3; + else + return (musictype_t)Mix_GetMusicType(music); +} + // Music hooks static void music_loop(void) { @@ -470,8 +487,19 @@ FUNCMATH void I_InitMusic(void) void I_ShutdownMusic(void) { - I_ShutdownDigMusic(); - I_ShutdownMIDIMusic(); +#ifdef HAVE_LIBGME + if (gme) + { + Mix_HookMusic(NULL, NULL); + gme_delete(gme); + gme = NULL; + } +#endif + if (!music) + return; + Mix_HookMusicFinished(NULL); + Mix_FreeMusic(music); + music = NULL; } void I_PauseSong(INT32 handle) @@ -492,7 +520,15 @@ void I_ResumeSong(INT32 handle) // Digital Music // -void I_InitDigMusic(void) +void I_SetDigMusicVolume(UINT8 volume) +{ + music_volume = volume; + if (I_GetMusicType() == MU_MID || !music) + return; + Mix_VolumeMusic((UINT32)volume*128/31); +} + +boolean I_SetSongSpeed(float speed) { #ifdef HAVE_LIBGME gme = NULL; @@ -691,8 +727,6 @@ boolean I_StartDigSong(const char *musicname, boolean looping) void I_StopDigSong(void) { - if (midimode) - return; #ifdef HAVE_LIBGME if (gme) { @@ -791,7 +825,7 @@ void I_SetMIDIMusicVolume(UINT8 volume) midi_volume = 31; //midi_volume = volume; - if (!midimode || !music) + if (I_GetMusicType() != MU_MID || !music) return; Mix_VolumeMusic((UINT32)midi_volume*128/31); } @@ -834,10 +868,6 @@ void I_StopSong(INT32 handle) void I_UnRegisterSong(INT32 handle) { - if (!midimode || !music) - return; - - (void)handle; Mix_FreeMusic(music); music = NULL; } From 46b53e8baeede0df6c75d93697301a027aeb8a70 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 10:19:04 -0400 Subject: [PATCH 264/573] Added I_GetMusicType and removed midimode variable: other targets (cherry picked from commit 14b393ab16736bb44dab6fd4a90b7bdd8ff782e0) --- src/android/i_sound.c | 24 ++---- src/djgppdos/i_sound.c | 33 ++++----- src/dummy/i_sound.c | 31 ++++---- src/sdl/sdl_sound.c | 98 +++++++++++-------------- src/win32/win_snd.c | 162 +++++++++++++++++++---------------------- 5 files changed, 155 insertions(+), 193 deletions(-) diff --git a/src/android/i_sound.c b/src/android/i_sound.c index 1011dbb6a..c3fc038e5 100644 --- a/src/android/i_sound.c +++ b/src/android/i_sound.c @@ -60,6 +60,11 @@ void I_SetSfxVolume(INT32 volume) // UINT8 music_started = 0; +musictype_t I_GetMusicType(void) +{ + return MU_NONE; +} + void I_InitMusic(void){} void I_ShutdownMusic(void){} @@ -99,12 +104,12 @@ boolean I_PlaySong(boolean looping) return false; } -void I_StopSong(INT32 handle) +void I_StopSong(void) { (void)handle; } -void I_UnRegisterSong(INT32 handle) +void I_UnloadSong(void) { (void)handle; } @@ -115,19 +120,6 @@ void I_UnRegisterSong(INT32 handle) UINT8 digmusic_started = 0; -void I_InitDigMusic(void){} - -void I_ShutdownDigMusic(void){} - -boolean I_StartDigSong(const char *musicname, INT32 looping) -{ - (void)musicname; - (void)looping; - return false; -} - -void I_StopDigSong(void){} - void I_SetDigMusicVolume(INT32 volume) { (void)volume; @@ -137,4 +129,4 @@ boolean I_SetSongSpeed(float speed) { (void)speed; return false; -} +} \ No newline at end of file diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index 105e8d67a..4c8ceb20c 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -322,6 +322,13 @@ static int islooping=0; static int musicdies=-1; UINT8 music_started=0; +musictype_t I_GetMusicType(void) +{ + if (currsong) + return MU_MID; + else + return MU_NONE; +} /* load_midi_mem: * Loads a standard MIDI file from memory, returning a pointer to @@ -389,7 +396,7 @@ static MIDI *load_midi_mem(char *mempointer,int *e) return midi; } -void I_InitMIDIMusic(void) +void I_InitMusic(void) { if (nomidimusic) return; @@ -398,12 +405,12 @@ void I_InitMIDIMusic(void) music_started = true; } -void I_ShutdownMIDIMusic(void) +void I_ShutdownMusic(void) { if ( !music_started ) return; - I_StopSong(1); + I_StopSong(); music_started=false; } @@ -439,7 +446,7 @@ void I_ResumeSong (INT32 handle) midi_resume(); } -void I_StopSong(INT32 handle) +void I_StopSong(void) { handle = 0; if (nomidimusic) @@ -462,7 +469,7 @@ int I_QrySongPlaying(int handle) } #endif -void I_UnRegisterSong(INT32 handle) +void I_UnloadSong(void) { handle = 0; if (nomidimusic) @@ -496,20 +503,6 @@ boolean I_LoadSong(char *data, size_t len) return 1; } -/// \todo Add OGG/MP3 support for dos -boolean I_StartDigSong(const char *musicname, INT32 looping) -{ - musicname = NULL; - looping = 0; - //CONS_Printf("I_StartDigSong: Not yet supported under DOS.\n"); - return false; -} - -void I_StopDigSong(void) -{ -// CONS_Printf("I_StopDigSong: Not yet supported under DOS.\n"); -} - void I_SetDigMusicVolume(INT32 volume) { volume = 0; @@ -524,4 +517,4 @@ boolean I_SetSongSpeed(float speed) { (void)speed; return false; -} +} \ No newline at end of file diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c index 2f6f0001c..60cf51f73 100644 --- a/src/dummy/i_sound.c +++ b/src/dummy/i_sound.c @@ -61,11 +61,21 @@ void I_SetSfxVolume(UINT8 volume) // MUSIC I/O // +musictype_t I_GetMusicType(void) +{ + return MU_NONE; +} + void I_InitMusic(void){} void I_ShutdownMusic(void){} -void I_PauseSong(INT32 handle) +void I_SetMIDIMusicVolume(UINT8 volume) +{ + (void)volume; +} + +void I_PauseSong(void) { (void)handle; } @@ -93,12 +103,12 @@ boolean I_PlaySong(boolean looping) return false; } -void I_StopSong(INT32 handle) +void I_StopSong(void) { (void)handle; } -void I_UnRegisterSong(INT32 handle) +void I_UnloadSong(void) { (void)handle; } @@ -107,19 +117,6 @@ void I_UnRegisterSong(INT32 handle) // DIGMUSIC I/O // -void I_InitDigMusic(void){} - -void I_ShutdownDigMusic(void){} - -boolean I_StartDigSong(const char *musicname, boolean looping) -{ - (void)musicname; - (void)looping; - return false; -} - -void I_StopDigSong(void){} - void I_SetDigMusicVolume(UINT8 volume) { (void)volume; @@ -135,4 +132,4 @@ boolean I_SetSongTrack(int track) { (void)track; return false; -} +} \ No newline at end of file diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index c714f675b..b729d4d89 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1313,10 +1313,27 @@ void I_StartupSound(void) // MUSIC API. // -void I_ShutdownMIDIMusic(void) +musictype_t I_GetMusicType(void) { - nomidimusic = false; - if (nodigimusic) I_ShutdownMusic(); +#ifdef HAVE_MIXER +#ifdef HAVE_LIBGME + if (gme) + return MU_GME; + else +#endif + if (!music) + return MU_NONE; + else if (Mix_GetMusicType(music) == MUS_MID) + return MU_MID; + else if (Mix_GetMusicType(music) == MUS_MOD || Mix_GetMusicType(music) == MUS_MODPLUG_UNUSED) + return MU_MOD; + else if (Mix_GetMusicType(music) == MUS_MP3 || Mix_GetMusicType(music) == MUS_MP3_MAD_UNUSED) + return MU_MP3; + else + return (musictype_t)Mix_GetMusicType(music); +#else + return MU_NONE +#endif } #ifdef HAVE_LIBGME @@ -1330,12 +1347,6 @@ static void I_ShutdownGMEMusic(void) } #endif -void I_ShutdownDigMusic(void) -{ - nodigimusic = false; - if (nomidimusic) I_ShutdownMusic(); -} - #ifdef HAVE_MIXER static boolean LoadSong(void *data, size_t lumplength, size_t selectpos) { @@ -1436,8 +1447,8 @@ void I_ShutdownMusic(void) CONS_Printf("%s", M_GetText("I_ShutdownMusic: ")); - I_UnRegisterSong(0); - I_StopDigSong(); + I_UnloadSong(); + I_StopSong(); Mix_CloseAudio(); #ifdef MIX_INIT Mix_Quit(); @@ -1450,16 +1461,6 @@ void I_ShutdownMusic(void) #endif } -void I_InitMIDIMusic(void) -{ - if (nodigimusic) I_InitMusic(); -} - -void I_InitDigMusic(void) -{ - if (nomidimusic) I_InitMusic(); -} - void I_InitMusic(void) { #ifdef HAVE_MIXER @@ -1639,17 +1640,29 @@ void I_ResumeSong(void) #endif } -void I_StopSong(INT32 handle) +void I_StopSong(void) { - (void)handle; + I_StopGME(); #ifdef HAVE_MIXER - if (nomidimusic || !musicStarted) + if (nodigimusic) return; - Mix_FadeOutMusic(MIDIfade); + +#ifdef MIXER_POS + if (canlooping) + Mix_HookMusicFinished(NULL); #endif + + Mix_HaltMusic(); + while (Mix_PlayingMusic()) + ; + + if (music[1]) + Mix_FreeMusic(music[1]); + music[1] = NULL; + LoadSong(NULL, 0, 1); } -void I_UnRegisterSong(INT32 handle) +void I_UnloadSong(void) { #ifdef HAVE_MIXER @@ -1714,7 +1727,7 @@ static void I_CleanupGME(void *userdata) static boolean I_StartGMESong(const char *musicname, boolean looping) { #ifdef HAVE_LIBGME - XBOXSTATIC char filename[9]; + char filename[9]; void *data; lumpnum_t lumpnum; size_t lumplength; @@ -1769,7 +1782,7 @@ static boolean I_StartGMESong(const char *musicname, boolean looping) boolean I_StartDigSong(const char *musicname, boolean looping) { #ifdef HAVE_MIXER - XBOXSTATIC char filename[9]; + char filename[9]; void *data; lumpnum_t lumpnum; size_t lumplength; @@ -1786,7 +1799,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping) lumpnum = W_CheckNumForName(filename); - I_StopDigSong(); + I_StopSong(); if (lumpnum == LUMPERROR) { @@ -1811,7 +1824,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping) { size_t scan; const char *dataum = data; - XBOXSTATIC char looplength[64]; + char looplength[64]; UINT32 loopstart = 0; UINT8 newcount = 0; @@ -1938,29 +1951,6 @@ static void I_StopGME(void) #endif } -void I_StopDigSong(void) -{ - I_StopGME(); -#ifdef HAVE_MIXER - if (nodigimusic) - return; - -#ifdef MIXER_POS - if (canlooping) - Mix_HookMusicFinished(NULL); -#endif - - Mix_HaltMusic(); - while (Mix_PlayingMusic()) - ; - - if (music[1]) - Mix_FreeMusic(music[1]); - music[1] = NULL; - LoadSong(NULL, 0, 1); -#endif -} - void I_SetDigMusicVolume(UINT8 volume) { I_SetMIDIMusicVolume(volume); @@ -1995,4 +1985,4 @@ static void SDLCALL I_FinishMusic(void) if (Msc_Mutex) SDL_UnlockMutex(Msc_Mutex); } #endif -#endif //HAVE_SDL +#endif //HAVE_SDL \ No newline at end of file diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 18c88d267..295d68680 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -22,12 +22,10 @@ #define HAVE_ZLIB #ifndef _MSC_VER -#ifndef _WII #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif #endif -#endif #ifndef _LFS64_LARGEFILE #define _LFS64_LARGEFILE @@ -44,7 +42,6 @@ static FMOD_SYSTEM *fsys; static FMOD_SOUND *music_stream; static FMOD_CHANNEL *music_channel; -static boolean midimode; static UINT8 music_volume, midi_volume, sfx_volume; static INT32 current_track; @@ -446,14 +443,48 @@ void I_SetSfxVolume(UINT8 volume) // MUSIC // +musictype_t I_GetMusicType(void) +{ +#ifdef HAVE_LIBGME + if (gme) + return MU_GME; +#endif + + if (!music_stream) + return MU_NONE; + + FMOD_SOUND_TYPE type; + if (FMOD_Sound_GetFormat(music_stream, &type, NULL, NULL, NULL) == FMOD_OK) + { + switch(type) + { + case FMOD_SOUND_TYPE_WAV: + return MU_WAV; + case FMOD_SOUND_TYPE_MOD: + return MU_MOD; + case FMOD_SOUND_TYPE_MID: + return MU_MID; + case FMOD_SOUND_TYPE_OGGVORBIS: + return MU_OGG; + case FMOD_SOUND_TYPE_MP3: + return MU_MP3; + case FMOD_SOUND_TYPE_FLAC: + return MU_FLAC; + default: + return MU_NONE; + } + } + else + return MU_NONE; +} + void I_InitMusic(void) { } void I_ShutdownMusic(void) { - I_ShutdownDigMusic(); - I_ShutdownMIDIMusic(); + I_StopSong(); } void I_PauseSong(void) @@ -470,17 +501,7 @@ void I_ResumeSong(void) FMR_MUSIC(FMOD_Channel_SetPaused(music_channel, false)); } -void I_InitDigMusic(void) -{ -} - -void I_ShutdownDigMusic(void) -{ - if (!midimode) - I_StopDigSong(); -} - -boolean I_StartDigSong(const char *musicname, boolean looping) +boolean I_LoadSong(char *data, size_t len) { char *data; size_t len; @@ -492,10 +513,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping) lumpnum = W_CheckNumForName(va("D_%s",musicname)); if (lumpnum == LUMPERROR) return false; - midimode = true; } - else - midimode = false; data = (char *)W_CacheLumpNum(lumpnum, PU_MUSIC); len = W_LumpLength(lumpnum); @@ -605,8 +623,6 @@ boolean I_StartDigSong(const char *musicname, boolean looping) { gme_equalizer_t gmeq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; Z_Free(data); // We don't need this anymore. - gme_start_track(gme, 0); - current_track = 0; gme_set_equalizer(gme,&gmeq); fmt.format = FMOD_SOUND_FORMAT_PCM16; fmt.defaultfrequency = 44100; @@ -616,32 +632,21 @@ boolean I_StartDigSong(const char *musicname, boolean looping) fmt.pcmreadcallback = GMEReadCallback; fmt.userdata = gme; FMR(FMOD_System_CreateStream(fsys, NULL, FMOD_OPENUSER | (looping ? FMOD_LOOP_NORMAL : 0), &fmt, &music_stream)); - FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel)); - FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); - FMR(FMOD_Channel_SetPriority(music_channel, 0)); return true; } #endif fmt.length = len; + + FMOD_RESULT e = FMOD_System_CreateStream(fsys, data, FMOD_OPENMEMORY_POINT|(looping ? FMOD_LOOP_NORMAL : 0), &fmt, &music_stream); + if (e != FMOD_OK) { - FMOD_RESULT e = FMOD_System_CreateStream(fsys, data, FMOD_OPENMEMORY_POINT|(looping ? FMOD_LOOP_NORMAL : 0), &fmt, &music_stream); - if (e != FMOD_OK) - { - if (e == FMOD_ERR_FORMAT) - CONS_Alert(CONS_WARNING, "Failed to play music lump %s due to invalid format.\n", W_CheckNameForNum(lumpnum)); - else - FMR(e); - return false; - } + if (e == FMOD_ERR_FORMAT) + CONS_Alert(CONS_WARNING, "Failed to play music lump %s due to invalid format.\n", W_CheckNameForNum(lumpnum)); + else + FMR(e); + return false; } - FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel)); - if (midimode) - FMR(FMOD_Channel_SetVolume(music_channel, midi_volume / 31.0)); - else - FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); - FMR(FMOD_Channel_SetPriority(music_channel, 0)); - current_track = 0; // Try to find a loop point in streaming music formats (ogg, mp3) FMOD_RESULT e; @@ -704,28 +709,15 @@ boolean I_StartDigSong(const char *musicname, boolean looping) return true; } - // No special loop point, but we're playing so it's all good. + // No special loop point return true; } -void I_StopDigSong(void) -{ - if (music_stream) - FMR(FMOD_Sound_Release(music_stream)); - music_stream = NULL; -#ifdef HAVE_LIBGME - if (gme) - gme_delete(gme); - gme = NULL; -#endif - current_track = -1; -} - void I_SetDigMusicVolume(UINT8 volume) { // volume is 0 to 31. music_volume = volume; - if (!midimode && music_stream) + if (I_GetMusicType() != MU_MID && music_stream) FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, volume / 31.0)); } @@ -811,57 +803,55 @@ boolean I_SetSongTrack(INT32 track) // Fuck MIDI. ... Okay fine, you can have your silly D_-only mode. // -void I_InitMIDIMusic(void) -{ -} - -void I_ShutdownMIDIMusic(void) -{ - if (midimode) - I_StopSong(0); -} - void I_SetMIDIMusicVolume(UINT8 volume) { // volume is 0 to 31. midi_volume = volume; - if (midimode && music_stream) + if (I_GetMusicType() != MU_MID && music_stream) FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, volume / 31.0)); } boolean I_PlaySong(boolean looping) { - FMOD_CREATESOUNDEXINFO fmt; - memset(&fmt, 0, sizeof(FMOD_CREATESOUNDEXINFO)); - fmt.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); - fmt.length = len; - FMR(FMOD_System_CreateStream(fsys, (char *)data, FMOD_OPENMEMORY_POINT, &fmt, &music_stream)); - return 1337; -} - -boolean I_PlaySong(INT32 handle, boolean looping) -{ - if (1337 == handle) +#ifdef HAVE_LIBGME + if (gme) { - midimode = true; - if (looping) - FMR(FMOD_Sound_SetMode(music_stream, FMOD_LOOP_NORMAL)); + gme_start_track(gme, 0); + current_track = 0; FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel)); - FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, midi_volume / 31.0)); - FMR_MUSIC(FMOD_Channel_SetPriority(music_channel, 0)); + FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); + FMR(FMOD_Channel_SetPriority(music_channel, 0)); + return true; } +#endif + + FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel)); + if (I_GetMusicType() != MU_MID) + FMR(FMOD_Channel_SetVolume(music_channel, midi_volume / 31.0)); + else + FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); + FMR(FMOD_Channel_SetPriority(music_channel, 0)); + current_track = 0; + return true; } -void I_StopSong(INT32 handle) +void I_StopSong(void) { - I_UnRegisterSong(handle); +#ifdef HAVE_LIBGME + if (gme) + gme_delete(gme); + gme = NULL; +#endif + current_track = -1; + + I_UnloadSong(); } -void I_UnRegisterSong(INT32 handle) +void I_UnloadSong(void) { UNREFERENCED_PARAMETER(handle); if (music_stream) FMR(FMOD_Sound_Release(music_stream)); music_stream = NULL; -} +} \ No newline at end of file From a7ed7b2c90e5dcc2b342adca4227a33a1432d38d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 11:51:23 -0400 Subject: [PATCH 265/573] Consolidate I_SetDigMusicVolume and I_SetMIDIMusicVolume into one method * In s_sound, they are merged to one method as well, but there are still two separate digvolume and seqvolume variables * Simplified Dig/MidiMusicDisabled in s_sound * Method reordering (cherry picked from commit 701cc5a7dd1dfead87a42ec7558c9fa6a1deb193) --- src/d_netcmd.c | 4 +- src/i_sound.h | 47 ++----- src/s_sound.c | 161 +++++++++++++++-------- src/s_sound.h | 28 +++- src/sdl/mixer_sound.c | 298 +++++++++++++++--------------------------- 5 files changed, 242 insertions(+), 296 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index bf26ca61a..ab3201c5c 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3963,11 +3963,9 @@ static void Command_RestartAudio_f(void) // 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); + S_SetMusicVolume(cv_digmusicvolume.value, 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/i_sound.h b/src/i_sound.h index 0fe62d5eb..1d4d6ff72 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -140,7 +140,7 @@ void I_ShutdownMusic(void); \return void */ -void I_PauseSong(INT32 handle); +void I_PauseSong(void); /** \brief RESUME game handling @@ -148,20 +148,12 @@ void I_PauseSong(INT32 handle); \return void */ -void I_ResumeSong(INT32 handle); +void I_ResumeSong(void); // // MIDI I/O // -/** \brief Startup the MIDI music system -*/ -void I_InitMIDIMusic(void); - -/** \brief Shutdown the MIDI music system -*/ -void I_ShutdownMIDIMusic(void); - /** \brief The I_SetMIDIMusicVolume function \param volume volume to set at @@ -179,7 +171,7 @@ void I_SetMIDIMusicVolume(UINT8 volume); \todo Remove this */ -INT32 I_RegisterSong(void *data, size_t len); +boolean I_LoadSong(char *data, size_t len); /** \brief Called by anything that wishes to start music @@ -190,7 +182,7 @@ INT32 I_RegisterSong(void *data, size_t len); \todo pass music name, not handle */ -boolean I_PlaySong(INT32 handle, boolean looping); +boolean I_PlaySong(boolean looping); /** \brief Stops a song over 3 seconds @@ -199,46 +191,25 @@ boolean I_PlaySong(INT32 handle, boolean looping); /todo drop handle */ -void I_StopSong(INT32 handle); +void I_StopSong(void); -/** \brief See ::I_RegisterSong, then think backwards +/** \brief See ::I_LoadSong, then think backwards \param handle song handle - \sa I_RegisterSong + \sa I_LoadSong \todo remove midi handle */ -void I_UnRegisterSong(INT32 handle); +void I_UnloadSong(void); // // DIGMUSIC I/O // -/** \brief Startup the music system -*/ -void I_InitDigMusic(void); - -/** \brief Shutdown the music system -*/ -void I_ShutdownDigMusic(void); - boolean I_SetSongSpeed(float speed); boolean I_SetSongTrack(INT32 track); -/** \brief The I_StartDigSong function - - \param musicname music lump name - \param looping if true, loop the song - - \return if true, song playing -*/ -boolean I_StartDigSong(const char *musicname, boolean looping); - -/** \brief stop non-MIDI song -*/ -void I_StopDigSong(void); - /** \brief The I_SetDigMusicVolume function \param volume volume to set at @@ -297,4 +268,4 @@ void I_PlayCD(UINT8 track, UINT8 looping); */ boolean I_SetVolumeCD(INT32 volume); -#endif +#endif \ No newline at end of file diff --git a/src/s_sound.c b/src/s_sound.c index 279f0dc6d..a1c53acd2 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1180,28 +1180,71 @@ const char *compat_special_music_slots[16] = #define music_playing (music_name[0]) // String is empty if no music is playing static char music_name[7]; // up to 6-character name -static lumpnum_t music_lumpnum; // lump number of music (used??) -static void *music_data; // music raw data -static INT32 music_handle; // once registered, the handle for the music +static boolean mus_paused = 0; // whether songs are mus_paused -static boolean mus_paused = 0; // whether songs are mus_paused +/// ------------------------ +/// Music Status +/// ------------------------ -static boolean S_MIDIMusic(const char *mname, boolean looping) +boolean S_DigMusicDisabled() +{ + return (nodigimusic || digital_disabled); +} + +boolean S_MIDIMusicDisabled() +{ + return (nomidimusic || music_disabled); +} + +boolean S_MusicDisabled() +{ + return ( + (nodigimusic && nomidimusic) || + (music_disabled && digital_disabled) || + (nodigimusic && music_disabled) || + (nomidimusic && digital_disabled) + ); +} + +/// ------------------------ +/// Music Properties +/// ------------------------ + +boolean S_SpeedMusic(float speed) +{ + return I_SetSongSpeed(speed); +} + +/// ------------------------ +/// Music Routines +/// ------------------------ + +static boolean S_LoadMusic(const char *mname) { lumpnum_t mlumpnum; void *mdata; - INT32 mhandle; - if (nomidimusic || music_disabled) - return false; // didn't search. - - if (W_CheckNumForName(va("d_%s", mname)) == LUMPERROR) + if (S_MusicDisabled()) return false; - mlumpnum = W_GetNumForName(va("d_%s", mname)); + + if (S_DigMusicDisabled()) + { + if (W_CheckNumForName(va("d_%s", mname)) == LUMPERROR) + return false; + mlumpnum = W_GetNumForName(va("d_%s", mname)); + } + else + { + if (W_CheckNumForName(va("o_%s", mname)) != LUMPERROR) + mlumpnum = W_GetNumForName(va("o_%s", mname)); + else if (W_CheckNumForName(va("d_%s", mname)) != LUMPERROR) + mlumpnum = W_GetNumForName(va("d_%s", mname)); + else + return false; + } // load & register it mdata = W_CacheLumpNum(mlumpnum, PU_MUSIC); - mhandle = I_RegisterSong(mdata, W_LumpLength(mlumpnum)); #ifdef MUSSERV if (msg_id != -1) @@ -1215,16 +1258,20 @@ static boolean S_MIDIMusic(const char *mname, boolean looping) } #endif - // play it - if (!I_PlaySong(mhandle, looping)) + if (I_LoadSong(mdata, W_LumpLength(mlumpnum))) + { + strncpy(music_name, mname, 7); + music_name[6] = 0; + return true; + } + else return false; +} - strncpy(music_name, mname, 7); - music_name[6] = 0; - music_lumpnum = mlumpnum; - music_data = mdata; - music_handle = mhandle; - return true; +static void S_UnloadMusic(void) +{ + I_UnloadSong(); + music_name[0] = 0; } static boolean S_PlayMusic(boolean looping) @@ -1232,9 +1279,13 @@ static boolean S_PlayMusic(boolean looping) if (nodigimusic || digital_disabled) return false; // try midi - if (!I_StartDigSong(mname, looping)) + if (!I_PlaySong(looping)) + { + S_UnloadMusic(); return false; + } + S_InitMusicVolume(); // switch between digi and sequence volume return true; } @@ -1244,7 +1295,7 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) S_ClearSfx(); #endif - if ((nomidimusic || music_disabled) && (nodigimusic || digital_disabled)) + if (S_MusicDisabled()) return; // No Music (empty string) @@ -1273,60 +1324,55 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) I_SetSongTrack(mflags & MUSIC_TRACKMASK); } -boolean S_SpeedMusic(float speed) -{ - return I_SetSongSpeed(speed); -} - void S_StopMusic(void) { if (!music_playing) return; if (mus_paused) - I_ResumeSong(music_handle); - - if (!nodigimusic) - I_StopDigSong(); + I_ResumeSong(); S_SpeedMusic(1.0f); - I_StopSong(music_handle); - I_UnRegisterSong(music_handle); + I_StopSong(); + I_UnloadSong(); #ifndef HAVE_SDL //SDL uses RWOPS Z_ChangeTag(music_data, PU_CACHE); #endif - music_data = NULL; music_name[0] = 0; } -void S_SetDigMusicVolume(INT32 volume) +void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) { - if (volume < 0 || volume > 31) - CONS_Alert(CONS_WARNING, "musicvolume should be between 0-31\n"); + if (digvolume < 0) + digvolume = cv_digmusicvolume.value; + if (seqvolume < 0) + seqvolume = cv_midimusicvolume.value; - CV_SetValue(&cv_digmusicvolume, volume&31); + if (digvolume < 0 || digvolume > 31) + CONS_Alert(CONS_WARNING, "digmusicvolume should be between 0-31\n"); + CV_SetValue(&cv_digmusicvolume, digvolume&31); actualdigmusicvolume = cv_digmusicvolume.value; //check for change of var -#ifdef DJGPPDOS - I_SetDigMusicVolume(31); // Trick for buggy dos drivers. Win32 doesn't need this. -#endif - I_SetDigMusicVolume(volume&31); -} - -void S_SetMIDIMusicVolume(INT32 volume) -{ - if (volume < 0 || volume > 31) - CONS_Alert(CONS_WARNING, "musicvolume should be between 0-31\n"); - - CV_SetValue(&cv_midimusicvolume, volume&0x1f); + if (digvolume < 0 || digvolume > 31) + CONS_Alert(CONS_WARNING, "midimusicvolume should be between 0-31\n"); + CV_SetValue(&cv_midimusicvolume, seqvolume&31); actualmidimusicvolume = cv_midimusicvolume.value; //check for change of var #ifdef DJGPPDOS - I_SetMIDIMusicVolume(31); // Trick for buggy dos drivers. Win32 doesn't need this. + digvolume = seqvolume = 31; #endif - I_SetMIDIMusicVolume(volume&0x1f); + + switch(I_GetMusicType()) + { + case MU_MID: + case MU_MOD: + case MU_GME: + I_SetMusicVolume(seqvolume&31); + default: + I_SetMusicVolume(digvolume&31); + } } /// ------------------------ @@ -1346,8 +1392,7 @@ void S_Init(INT32 sfxVolume, INT32 digMusicVolume, INT32 midiMusicVolume) return; S_SetSfxVolume(sfxVolume); - S_SetDigMusicVolume(digMusicVolume); - S_SetMIDIMusicVolume(midiMusicVolume); + S_SetMusicVolume(digMusicVolume, midiMusicVolume); SetChannelsNum(); @@ -1403,11 +1448,11 @@ void S_Start(void) void S_PauseAudio(void) { if (!nodigimusic) - I_PauseSong(0); + I_PauseSong(); if (music_playing && !mus_paused) { - I_PauseSong(music_handle); + I_PauseSong(); mus_paused = true; } @@ -1422,11 +1467,11 @@ void S_PauseAudio(void) void S_ResumeAudio(void) { if (!nodigimusic) - I_ResumeSong(0); + I_ResumeSong(); else if (music_playing && mus_paused) { - I_ResumeSong(music_handle); + I_ResumeSong(); mus_paused = false; } diff --git a/src/s_sound.h b/src/s_sound.h index 39ec769a6..bce3ab8bb 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -97,6 +97,25 @@ void S_StartSoundAtVolume(const void *origin, sfxenum_t sound_id, INT32 volume); // Stop sound for thing at void S_StopSound(void *origin); +// +// Music Status +// + +boolean S_DigMusicDisabled(); +boolean S_MIDIMusicDisabled(); +boolean S_MusicDisabled(); + +// +// Music Properties +// + +// Set Speed of Music +boolean S_SpeedMusic(float speed); + +// +// Music Routines +// + // Start music track, arbitrary, given its name, and set whether looping // note: music flags 12 bits for tracknum (gme, other formats with more than one track) // 13-15 aren't used yet @@ -104,9 +123,6 @@ void S_StopSound(void *origin); #define S_ChangeMusicInternal(a,b) S_ChangeMusic(a,0,b) void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping); -// Set Speed of Music -boolean S_SpeedMusic(float speed); - // Stops the music. void S_StopMusic(void); @@ -121,9 +137,11 @@ void S_UpdateSounds(void); FUNCMATH fixed_t S_CalculateSoundDistance(fixed_t px1, fixed_t py1, fixed_t pz1, fixed_t px2, fixed_t py2, fixed_t pz2); -void S_SetDigMusicVolume(INT32 volume); -void S_SetMIDIMusicVolume(INT32 volume); void S_SetSfxVolume(INT32 volume); +void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume); +#define S_SetDigMusicVolume(a) S_SetMusicVolume(a,-1) +#define S_SetMIDIMusicVolume(a) S_SetMusicVolume(-1,a) +#define S_InitMusicVolume() S_SetMusicVolume(-1,-1) INT32 S_OriginPlaying(void *origin); INT32 S_IdPlaying(sfxenum_t id); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 0888d5d31..457f74f95 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -483,6 +483,10 @@ static void mix_gme(void *udata, Uint8 *stream, int len) FUNCMATH void I_InitMusic(void) { +#ifdef HAVE_LIBGME + gme = NULL; + current_track = -1; +#endif } void I_ShutdownMusic(void) @@ -502,16 +506,14 @@ void I_ShutdownMusic(void) music = NULL; } -void I_PauseSong(INT32 handle) +void I_PauseSong(void) { - (void)handle; Mix_PauseMusic(); songpaused = true; } -void I_ResumeSong(INT32 handle) +void I_ResumeSong(void) { - (void)handle; Mix_ResumeMusic(); songpaused = false; } @@ -520,59 +522,66 @@ void I_ResumeSong(INT32 handle) // Digital Music // -void I_SetDigMusicVolume(UINT8 volume) -{ - music_volume = volume; - if (I_GetMusicType() == MU_MID || !music) - return; - Mix_VolumeMusic((UINT32)volume*128/31); -} - boolean I_SetSongSpeed(float speed) { -#ifdef HAVE_LIBGME - gme = NULL; - current_track = -1; -#endif -} - -void I_ShutdownDigMusic(void) -{ - if (midimode) - return; + if (speed > 250.0f) + speed = 250.0f; //limit speed up to 250x #ifdef HAVE_LIBGME if (gme) { - Mix_HookMusic(NULL, NULL); - gme_delete(gme); - gme = NULL; + SDL_LockAudio(); + gme_set_tempo(gme, speed); + SDL_UnlockAudio(); + return true; } +#else + (void)speed; #endif - if (!music) - return; - Mix_HookMusicFinished(NULL); - Mix_FreeMusic(music); - music = NULL; + return false; } -boolean I_StartDigSong(const char *musicname, boolean looping) +boolean I_SetSongTrack(int track) { - char *data; - size_t len; - lumpnum_t lumpnum = W_CheckNumForName(va("O_%s",musicname)); +#ifdef HAVE_LIBGME + if (current_track == track) + return false; + // If the specified track is within the number of tracks playing, then change it + if (gme) + { + SDL_LockAudio(); + if (track >= 0 + && track < gme_track_count(gme)) + { + gme_err_t gme_e = gme_start_track(gme, track); + if (gme_e != NULL) + { + CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e); + return false; + } + current_track = track; + SDL_UnlockAudio(); + return true; + } + SDL_UnlockAudio(); + return false; + } +#endif + (void)track; + return false; +} + +// +// MIDI Music +// + +boolean I_LoadSong(char *data, size_t len) +{ I_Assert(!music); #ifdef HAVE_LIBGME I_Assert(!gme); #endif - if (lumpnum == LUMPERROR) - return false; - midimode = false; - - data = (char *)W_CacheLumpNum(lumpnum, PU_MUSIC); - len = W_LumpLength(lumpnum); - #ifdef HAVE_LIBGME if ((UINT8)data[0] == 0x1F && (UINT8)data[1] == 0x8B) @@ -663,8 +672,6 @@ boolean I_StartDigSong(const char *musicname, boolean looping) else if (!gme_open_data(data, len, &gme, 44100)) { gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; - gme_start_track(gme, 0); - current_track = 0; gme_set_equalizer(gme, &eq); Mix_HookMusic(mix_gme, gme); return true; @@ -675,48 +682,62 @@ boolean I_StartDigSong(const char *musicname, boolean looping) if (!music) { CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError()); - return true; + return false; } // Find the OGG loop point. loop_point = 0.0f; - if (looping) + + const char *key1 = "LOOP"; + const char *key2 = "POINT="; + const char *key3 = "MS="; + const size_t key1len = strlen(key1); + const size_t key2len = strlen(key2); + const size_t key3len = strlen(key3); + char *p = data; + while ((UINT32)(p - data) < len) { - const char *key1 = "LOOP"; - const char *key2 = "POINT="; - const char *key3 = "MS="; - const size_t key1len = strlen(key1); - const size_t key2len = strlen(key2); - const size_t key3len = strlen(key3); - char *p = data; - while ((UINT32)(p - data) < len) + if (strncmp(p++, key1, key1len)) + continue; + p += key1len-1; // skip OOP (the L was skipped in strncmp) + if (!strncmp(p, key2, key2len)) // is it LOOPPOINT=? { - if (strncmp(p++, key1, key1len)) - continue; - p += key1len-1; // skip OOP (the L was skipped in strncmp) - if (!strncmp(p, key2, key2len)) // is it LOOPPOINT=? - { - p += key2len; // skip POINT= - loop_point = (float)((44.1L+atoi(p)) / 44100.0L); // LOOPPOINT works by sample count. - // because SDL_Mixer is USELESS and can't even tell us - // something simple like the frequency of the streaming music, - // we are unfortunately forced to assume that ALL MUSIC is 44100hz. - // This means a lot of tracks that are only 22050hz for a reasonable downloadable file size will loop VERY badly. - } - else if (!strncmp(p, key3, key3len)) // is it LOOPMS=? - { - p += key3len; // skip MS= - loop_point = (float)(atoi(p) / 1000.0L); // LOOPMS works by real time, as miliseconds. - // Everything that uses LOOPMS will work perfectly with SDL_Mixer. - } - // Neither?! Continue searching. + p += key2len; // skip POINT= + loop_point = (float)((44.1L+atoi(p)) / 44100.0L); // LOOPPOINT works by sample count. + // because SDL_Mixer is USELESS and can't even tell us + // something simple like the frequency of the streaming music, + // we are unfortunately forced to assume that ALL MUSIC is 44100hz. + // This means a lot of tracks that are only 22050hz for a reasonable downloadable file size will loop VERY badly. } + else if (!strncmp(p, key3, key3len)) // is it LOOPMS=? + { + p += key3len; // skip MS= + loop_point = (float)(atoi(p) / 1000.0L); // LOOPMS works by real time, as miliseconds. + // Everything that uses LOOPMS will work perfectly with SDL_Mixer. + } + // Neither?! Continue searching. } + return true; +} + +boolean I_PlaySong(boolean looping) +{ + if (!music) + return false; +#ifdef HAVE_GME + if (gme) + { + gme_start_track(gme, 0); + current_track = 0; + return true; + } +#endif + if (Mix_PlayMusic(music, looping && loop_point == 0.0f ? -1 : 0) == -1) { CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); - return true; + return false; } Mix_VolumeMusic((UINT32)music_volume*128/31); @@ -725,7 +746,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping) return true; } -void I_StopDigSong(void) +void I_StopSong(void) { #ifdef HAVE_LIBGME if (gme) @@ -744,132 +765,25 @@ void I_StopDigSong(void) music = NULL; } -void I_SetDigMusicVolume(UINT8 volume) +void I_SetMusicVolume(UINT8 volume) { - music_volume = volume; - if (midimode || !music) - return; - Mix_VolumeMusic((UINT32)volume*128/31); -} - -boolean I_SetSongSpeed(float speed) -{ - if (speed > 250.0f) - speed = 250.0f; //limit speed up to 250x -#ifdef HAVE_LIBGME - if (gme) - { - SDL_LockAudio(); - gme_set_tempo(gme, speed); - SDL_UnlockAudio(); - return true; - } -#else - (void)speed; -#endif - return false; -} - -boolean I_SetSongTrack(int track) -{ -#ifdef HAVE_LIBGME - if (current_track == track) - return false; - - // If the specified track is within the number of tracks playing, then change it - if (gme) - { - SDL_LockAudio(); - if (track >= 0 - && track < gme_track_count(gme)) - { - gme_err_t gme_e = gme_start_track(gme, track); - if (gme_e != NULL) - { - CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e); - return false; - } - current_track = track; - SDL_UnlockAudio(); - return true; - } - SDL_UnlockAudio(); - return false; - } -#endif - (void)track; - return false; -} - -// -// MIDI Music -// - -FUNCMATH void I_InitMIDIMusic(void) -{ -} - -void I_ShutdownMIDIMusic(void) -{ - if (!midimode || !music) - return; - Mix_FreeMusic(music); - music = NULL; -} - -void I_SetMIDIMusicVolume(UINT8 volume) -{ - // HACK: Until we stop using native MIDI, - // disable volume changes - (void)volume; - midi_volume = 31; - //midi_volume = volume; - - if (I_GetMusicType() != MU_MID || !music) - return; - Mix_VolumeMusic((UINT32)midi_volume*128/31); -} - -INT32 I_RegisterSong(void *data, size_t len) -{ - music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len), SDL_FALSE); if (!music) - { - CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError()); - return -1; - } - return 1337; -} - -boolean I_PlaySong(INT32 handle, boolean looping) -{ - (void)handle; - - midimode = true; - - if (Mix_PlayMusic(music, looping ? -1 : 0) == -1) - { - CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); - return false; - } - - Mix_VolumeMusic((UINT32)midi_volume*128/31); - return true; -} - -void I_StopSong(INT32 handle) -{ - if (!midimode || !music) return; - (void)handle; - Mix_HaltMusic(); + if (I_GetMusicType() == MU_MID) + // HACK: Until we stop using native MIDI, + // disable volume changes + music_volume = 31; + else + music_volume = volume; + + Mix_VolumeMusic((UINT32)music_volume*128/31); } -void I_UnRegisterSong(INT32 handle) +void I_UnloadSong(void) { Mix_FreeMusic(music); music = NULL; } -#endif +#endif \ No newline at end of file From e58a8f4fe18609531a5eb06e1d1b302b6cf6c197 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 11:54:58 -0400 Subject: [PATCH 266/573] Consolidate I_SetDigMusicVolume and I_SetMIDIMusicVolume other targets (cherry picked from commit 9fb9386f84b3739fe765a78bcb9683eb7e98bc36) --- src/android/i_sound.c | 7 +------ src/djgppdos/i_sound.c | 12 +----------- src/dummy/i_sound.c | 7 +------ src/sdl/sdl_sound.c | 7 +------ src/win32/win_snd.c | 22 ++++++++++------------ 5 files changed, 14 insertions(+), 41 deletions(-) diff --git a/src/android/i_sound.c b/src/android/i_sound.c index c3fc038e5..80b90d2f7 100644 --- a/src/android/i_sound.c +++ b/src/android/i_sound.c @@ -92,7 +92,7 @@ boolean I_LoadSong(char *data, size_t len) return -1; } -void I_SetMIDIMusicVolume(INT32 volume) +void I_SetMusicVolume(INT32 volume) { (void)volume; } @@ -120,11 +120,6 @@ void I_UnloadSong(void) UINT8 digmusic_started = 0; -void I_SetDigMusicVolume(INT32 volume) -{ - (void)volume; -} - boolean I_SetSongSpeed(float speed) { (void)speed; diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index 4c8ceb20c..e66bf8e23 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -140,7 +140,7 @@ void I_SetSfxVolume(INT32 volume) set_volume (Volset(volume),-1); } -void I_SetMIDIMusicVolume(INT32 volume) +void I_SetMusicVolume(INT32 volume) { if (nomidimusic) return; @@ -503,16 +503,6 @@ boolean I_LoadSong(char *data, size_t len) return 1; } -void I_SetDigMusicVolume(INT32 volume) -{ - volume = 0; - if (nodigimusic) - return; - - // Now set volume on output device. -// CONS_Printf("Digital music not yet supported under DOS.\n"); -} - boolean I_SetSongSpeed(float speed) { (void)speed; diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c index 60cf51f73..f82bf00da 100644 --- a/src/dummy/i_sound.c +++ b/src/dummy/i_sound.c @@ -70,7 +70,7 @@ void I_InitMusic(void){} void I_ShutdownMusic(void){} -void I_SetMIDIMusicVolume(UINT8 volume) +void I_SetMusicVolume(UINT8 volume) { (void)volume; } @@ -117,11 +117,6 @@ void I_UnloadSong(void) // DIGMUSIC I/O // -void I_SetDigMusicVolume(UINT8 volume) -{ - (void)volume; -} - boolean I_SetSongSpeed(float speed) { (void)speed; diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index b729d4d89..5f92cde10 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1702,7 +1702,7 @@ boolean I_LoadSong(char *data, size_t len) return false; } -void I_SetMIDIMusicVolume(UINT8 volume) +void I_SetMusicVolume(UINT8 volume) { #ifdef HAVE_MIXER if ((nomidimusic && nodigimusic) || !musicStarted) @@ -1951,11 +1951,6 @@ static void I_StopGME(void) #endif } -void I_SetDigMusicVolume(UINT8 volume) -{ - I_SetMIDIMusicVolume(volume); -} - boolean I_SetSongSpeed(float speed) { diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 295d68680..bfa43d087 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -713,14 +713,6 @@ boolean I_LoadSong(char *data, size_t len) return true; } -void I_SetDigMusicVolume(UINT8 volume) -{ - // volume is 0 to 31. - music_volume = volume; - if (I_GetMusicType() != MU_MID && music_stream) - FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, volume / 31.0)); -} - boolean I_SetSongSpeed(float speed) { FMOD_RESULT e; @@ -803,12 +795,18 @@ boolean I_SetSongTrack(INT32 track) // Fuck MIDI. ... Okay fine, you can have your silly D_-only mode. // -void I_SetMIDIMusicVolume(UINT8 volume) +void I_SetMusicVolume(UINT8 volume) { + if (!music_stream) + return; + // volume is 0 to 31. - midi_volume = volume; - if (I_GetMusicType() != MU_MID && music_stream) - FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, volume / 31.0)); + if (I_GetMusicType() == MU_MID) + music_volume = 31; // windows bug hack + else + music_volume = volume; + + FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); } boolean I_PlaySong(boolean looping) From 011a043dbaaa5706be45f3e900a3d2f031239217 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 12:30:47 -0400 Subject: [PATCH 267/573] Refactoring, music statues * S_Init -> S_InitSfxChannels because it did mostly SFX anyway * S_MusicPlaying, S_MusicPaused, S_MusicName, S_MusicExists new status methods * I_MusicPlaying, I_MusicPaused (cherry picked from commit f5f0b5e76c2fd405c8cc895dde653c5ed2652622) --- src/d_main.c | 4 +- src/i_sound.h | 2 + src/m_menu.c | 6 +- src/s_sound.c | 182 +++++++++++++++++++++--------------------- src/s_sound.h | 17 ++-- src/sdl/mixer_sound.c | 10 +++ 6 files changed, 121 insertions(+), 100 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index df3398752..f2da8586c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1217,7 +1217,7 @@ void D_SRB2Main(void) } else { - CONS_Printf("S_Init(): Setting up sound.\n"); + CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n"); } if (M_CheckParm("-nosound")) nosound = true; @@ -1232,7 +1232,7 @@ void D_SRB2Main(void) } I_StartupSound(); I_InitMusic(); - S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value); + S_InitSfxChannels(cv_soundvolume.value); CONS_Printf("ST_Init(): Init status bar.\n"); ST_Init(); diff --git a/src/i_sound.h b/src/i_sound.h index 1d4d6ff72..901e6c284 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -125,6 +125,8 @@ void I_SetSfxVolume(UINT8 volume); // musictype_t I_GetMusicType(void); +boolean I_MusicPlaying(void); +boolean I_MusicPaused(void); /** \brief Init the music systems */ diff --git a/src/m_menu.c b/src/m_menu.c index 79ac6800b..82242c0c1 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6955,7 +6955,7 @@ static void M_ToggleSFX(void) nosound = false; I_StartupSound(); if (nosound) return; - S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value); + S_InitSfxChannels(cv_soundvolume.value); M_StartMessage(M_GetText("SFX Enabled\n"), NULL, MM_NOTHING); } else @@ -6981,7 +6981,7 @@ static void M_ToggleDigital(void) nodigimusic = false; I_InitDigMusic(); if (nodigimusic) return; - S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value); + S_InitSfxChannels(cv_soundvolume.value); S_StopMusic(); S_ChangeMusicInternal("lclear", false); M_StartMessage(M_GetText("Digital Music Enabled\n"), NULL, MM_NOTHING); @@ -7009,7 +7009,7 @@ static void M_ToggleMIDI(void) nomidimusic = false; I_InitMIDIMusic(); if (nomidimusic) return; - S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value); + S_InitSfxChannels(cv_soundvolume.value); S_ChangeMusicInternal("lclear", false); M_StartMessage(M_GetText("MIDI Music Enabled\n"), NULL, MM_NOTHING); } diff --git a/src/s_sound.c b/src/s_sound.c index a1c53acd2..e035c4192 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1151,6 +1151,43 @@ void S_StartSoundName(void *mo, const char *soundname) S_StartSound(mo, soundnum); } +// +// Initializes sound stuff, including volume +// Sets channels, SFX volume, +// allocates channel buffer, sets S_sfx lookup. +// +void S_InitSfxChannels(INT32 sfxVolume) +{ + INT32 i; + + if (dedicated) + return; + + S_SetSfxVolume(sfxVolume); + + SetChannelsNum(); + + // Note that sounds have not been cached (yet). + for (i = 1; i < NUMSFX; i++) + { + S_sfx[i].usefulness = -1; // for I_GetSfx() + S_sfx[i].lumpnum = LUMPERROR; + } + + // precache sounds if requested by cmdline, or precachesound var true + if (!nosound && (M_CheckParm("-precachesound") || precachesound.value)) + { + // Initialize external data (all sounds) at start, keep static. + CONS_Printf(M_GetText("Loading sounds... ")); + + for (i = 1; i < NUMSFX; i++) + if (S_sfx[i].name) + S_sfx[i].data = I_GetSfx(&S_sfx[i]); + + CONS_Printf(M_GetText(" pre-cached all sound data\n")); + } +} + /// ------------------------ /// Music /// ------------------------ @@ -1177,10 +1214,7 @@ const char *compat_special_music_slots[16] = }; #endif -#define music_playing (music_name[0]) // String is empty if no music is playing - static char music_name[7]; // up to 6-character name -static boolean mus_paused = 0; // whether songs are mus_paused /// ------------------------ /// Music Status @@ -1206,6 +1240,29 @@ boolean S_MusicDisabled() ); } +boolean S_MusicPlaying(void) +{ + return I_MusicPlaying(); +} + +boolean S_MusicPaused(void) +{ + return I_MusicPaused(); +} + +const char *S_MusicName(void) +{ + return music_name; +} + +boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi) +{ + return ( + (checkDigi ? W_CheckNumForName(va("O_%s", mname)) != LUMPERROR : false) + || (checkMIDI ? W_CheckNumForName(va("D_%s", mname)) != LUMPERROR : false) + ); +} + /// ------------------------ /// Music Properties /// ------------------------ @@ -1229,15 +1286,15 @@ static boolean S_LoadMusic(const char *mname) if (S_DigMusicDisabled()) { - if (W_CheckNumForName(va("d_%s", mname)) == LUMPERROR) + if (!S_MIDIExists(mname)) return false; mlumpnum = W_GetNumForName(va("d_%s", mname)); } else { - if (W_CheckNumForName(va("o_%s", mname)) != LUMPERROR) + if (S_DigExists(mname)) mlumpnum = W_GetNumForName(va("o_%s", mname)); - else if (W_CheckNumForName(va("d_%s", mname)) != LUMPERROR) + else if (S_MIDIExists(mname)) mlumpnum = W_GetNumForName(va("d_%s", mname)); else return false; @@ -1326,10 +1383,10 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) void S_StopMusic(void) { - if (!music_playing) + if (!I_MusicPlaying()) return; - if (mus_paused) + if (I_MusicPaused()) I_ResumeSong(); S_SpeedMusic(1.0f); @@ -1343,6 +1400,31 @@ void S_StopMusic(void) music_name[0] = 0; } +// +// Stop and resume music, during game PAUSE. +// +void S_PauseAudio(void) +{ + if (I_MusicPlaying() && !I_MusicPaused()) + I_PauseSong(); + + // pause cd music +#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) + I_PauseCD(); +#else + I_StopCD(); +#endif +} + +void S_ResumeAudio(void) +{ + if (I_MusicPlaying() && I_MusicPaused()) + I_ResumeSong(); + + // resume cd music + I_ResumeCD(); +} + void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) { if (digvolume < 0) @@ -1355,7 +1437,7 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) CV_SetValue(&cv_digmusicvolume, digvolume&31); actualdigmusicvolume = cv_digmusicvolume.value; //check for change of var - if (digvolume < 0 || digvolume > 31) + if (seqvolume < 0 || seqvolume > 31) CONS_Alert(CONS_WARNING, "midimusicvolume should be between 0-31\n"); CV_SetValue(&cv_midimusicvolume, seqvolume&31); actualmidimusicvolume = cv_midimusicvolume.value; //check for change of var @@ -1375,52 +1457,11 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) } } + /// ------------------------ /// Init & Others /// ------------------------ -// -// Initializes sound stuff, including volume -// Sets channels, SFX and music volume, -// allocates channel buffer, sets S_sfx lookup. -// -void S_Init(INT32 sfxVolume, INT32 digMusicVolume, INT32 midiMusicVolume) -{ - INT32 i; - - if (dedicated) - return; - - S_SetSfxVolume(sfxVolume); - S_SetMusicVolume(digMusicVolume, midiMusicVolume); - - SetChannelsNum(); - - // no sounds are playing, and they are not mus_paused - mus_paused = 0; - - // Note that sounds have not been cached (yet). - for (i = 1; i < NUMSFX; i++) - { - S_sfx[i].usefulness = -1; // for I_GetSfx() - S_sfx[i].lumpnum = LUMPERROR; - } - - // precache sounds if requested by cmdline, or precachesound var true - if (!nosound && (M_CheckParm("-precachesound") || precachesound.value)) - { - // Initialize external data (all sounds) at start, keep static. - CONS_Printf(M_GetText("Loading sounds... ")); - - for (i = 1; i < NUMSFX; i++) - if (S_sfx[i].name) - S_sfx[i].data = I_GetSfx(&S_sfx[i]); - - CONS_Printf(M_GetText(" pre-cached all sound data\n")); - } -} - - // // Per level startup code. // Kills playing sounds at start of level, @@ -1435,46 +1476,7 @@ void S_Start(void) mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); } - mus_paused = 0; - if (cv_resetmusic.value) S_StopMusic(); S_ChangeMusic(mapmusname, mapmusflags, true); } - -// -// Stop and resume music, during game PAUSE. -// -void S_PauseAudio(void) -{ - if (!nodigimusic) - I_PauseSong(); - - if (music_playing && !mus_paused) - { - I_PauseSong(); - mus_paused = true; - } - - // pause cd music -#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) - I_PauseCD(); -#else - I_StopCD(); -#endif -} - -void S_ResumeAudio(void) -{ - if (!nodigimusic) - I_ResumeSong(); - else - if (music_playing && mus_paused) - { - I_ResumeSong(); - mus_paused = false; - } - - // resume cd music - I_ResumeCD(); -} diff --git a/src/s_sound.h b/src/s_sound.h index bce3ab8bb..9a3f2805c 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -69,9 +69,9 @@ void S_RegisterSoundStuff(void); // // Initializes sound stuff, including volume -// Sets channels, SFX and music volume, allocates channel buffer, sets S_sfx lookup. +// Sets channels, SFX, allocates channel buffer, sets S_sfx lookup. // -void S_Init(INT32 sfxVolume, INT32 digMusicVolume, INT32 midiMusicVolume); +void S_InitSfxChannels(INT32 sfxVolume); // // Per level startup code. @@ -101,9 +101,16 @@ void S_StopSound(void *origin); // Music Status // -boolean S_DigMusicDisabled(); -boolean S_MIDIMusicDisabled(); -boolean S_MusicDisabled(); +boolean S_DigMusicDisabled(void); +boolean S_MIDIMusicDisabled(void); +boolean S_MusicDisabled(void); +boolean S_MusicPlaying(void); +boolean S_MusicPaused(void); +const char *S_MusicName(void); +boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi); +#define S_DigExists(a) S_MusicExists(a, false, true) +#define S_MIDIExists(a) S_MusicExists(a, true, false) + // // Music Properties diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 457f74f95..1384f1da0 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -453,6 +453,16 @@ musictype_t I_GetMusicType(void) return (musictype_t)Mix_GetMusicType(music); } +boolean I_MusicPlaying(void) +{ + return (boolean)music; +} + +boolean I_MusicPaused(void) +{ + return songpaused; +} + // Music hooks static void music_loop(void) { From 44557d9c9d6b6ea3df722987bf778f847193db90 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 12:31:01 -0400 Subject: [PATCH 268/573] I_MusicPlaying, I_MusicPaused other targets (cherry picked from commit d5ec38815968e267aceb59a48a6cb6d3292c0b69) --- src/android/i_sound.c | 10 ++++++++++ src/djgppdos/i_sound.c | 17 +++++++++++++++-- src/dummy/i_sound.c | 10 ++++++++++ src/sdl/sdl_sound.c | 10 ++++++++++ src/win32/win_snd.c | 13 +++++++++++++ 5 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/android/i_sound.c b/src/android/i_sound.c index 80b90d2f7..1cbc53fab 100644 --- a/src/android/i_sound.c +++ b/src/android/i_sound.c @@ -65,6 +65,16 @@ musictype_t I_GetMusicType(void) return MU_NONE; } +boolean I_MusicPlaying(void) +{ + return false; +} + +boolean I_MusicPaused(void) +{ + return false; +} + void I_InitMusic(void){} void I_ShutdownMusic(void){} diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index e66bf8e23..6e351b523 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -321,6 +321,7 @@ static MIDI* currsong; //im assuming only 1 song will be played at once static int islooping=0; static int musicdies=-1; UINT8 music_started=0; +boolean songpaused=false; musictype_t I_GetMusicType(void) { @@ -330,6 +331,16 @@ musictype_t I_GetMusicType(void) return MU_NONE; } +boolean I_MusicPlaying() +{ + return (boolean)currsong; +} + +boolean I_MusicPaused() +{ + return songpaused; +} + /* load_midi_mem: * Loads a standard MIDI file from memory, returning a pointer to * a MIDI structure, * or NULL on error. @@ -403,6 +414,7 @@ void I_InitMusic(void) I_AddExitFunc(I_ShutdownMusic); music_started = true; + songpaused = false; } void I_ShutdownMusic(void) @@ -433,8 +445,8 @@ void I_PauseSong (INT32 handle) handle = 0; if (nomidimusic) return; - midi_pause(); + songpaused = true; } void I_ResumeSong (INT32 handle) @@ -442,8 +454,8 @@ void I_ResumeSong (INT32 handle) handle = 0; if (nomidimusic) return; - midi_resume(); + songpaused = false; } void I_StopSong(void) @@ -455,6 +467,7 @@ void I_StopSong(void) islooping = 0; musicdies = 0; stop_midi(); + songpaused = false; } // Is the song playing? diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c index f82bf00da..ca90a7da3 100644 --- a/src/dummy/i_sound.c +++ b/src/dummy/i_sound.c @@ -66,6 +66,16 @@ musictype_t I_GetMusicType(void) return MU_NONE; } +boolean I_MusicPlaying(void) +{ + return false; +} + +boolean I_MusicPaused(void) +{ + return false; +} + void I_InitMusic(void){} void I_ShutdownMusic(void){} diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 5f92cde10..d8d3e0a95 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1336,6 +1336,16 @@ musictype_t I_GetMusicType(void) #endif } +boolean I_MusicPlaying(void) +{ + return music_started; +} + +boolean I_MusicPaused(void) +{ + return Mix_PausedMusic(); +} + #ifdef HAVE_LIBGME static void I_ShutdownGMEMusic(void) { diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index bfa43d087..c6a74d999 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -478,6 +478,19 @@ musictype_t I_GetMusicType(void) return MU_NONE; } +boolean I_MusicPlaying(void) +{ + return (boolean)music_stream; +} + +boolean I_MusicPaused(void) +{ + boolean fmpaused = false; + if (music_stream) + FMOD_Channel_GetPaused(music_channel, &fmpaused); + return fmpaused; +} + void I_InitMusic(void) { } From a414ccf24ae6b59b1945cb0b9177bfaebbfb334e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 12:42:15 -0400 Subject: [PATCH 269/573] nodigimusic nomusic nosound -> digital_disabled midi_disabled sound_disabled (cherry picked from commit 07738fb0bcf640a4349337373f451fe68e024b2a) --- src/d_main.c | 26 ++++++++++----------- src/doomstat.h | 5 +--- src/m_menu.c | 62 ++++++++++++++++++++------------------------------ src/p_mobj.c | 2 +- src/s_sound.c | 27 +++++++++------------- 5 files changed, 51 insertions(+), 71 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index f2da8586c..ed1b44684 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -122,17 +122,17 @@ postimg_t postimgtype2 = postimg_none; INT32 postimgparam2; #ifdef _XBOX -boolean nomidimusic = true, nosound = true; -boolean nodigimusic = true; +boolean midi_disabled = true, sound_disabled = true; +boolean digital_disabled = true; #else -boolean nomidimusic = false, nosound = false; -boolean nodigimusic = false; // No fmod-based music +boolean midi_disabled = false, sound_disabled = false; +boolean digital_disabled = false; // No fmod-based music #endif // These variables are only true if -// the respective sound system is initialized -// and active, but no sounds/music should play. -boolean music_disabled = false; +// whether the respective sound system is disabled +// or they're init'ed, but the player just toggled them +boolean midi_disabled = false; boolean sound_disabled = false; boolean digital_disabled = false; @@ -1212,23 +1212,23 @@ void D_SRB2Main(void) // setting up sound if (dedicated) { - nosound = true; - nomidimusic = nodigimusic = true; + sound_disabled = true; + midi_disabled = digital_disabled = true; } else { CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n"); } if (M_CheckParm("-nosound")) - nosound = true; + sound_disabled = true; if (M_CheckParm("-nomusic")) // combines -nomidimusic and -nodigmusic - nomidimusic = nodigimusic = true; + midi_disabled = digital_disabled = true; else { if (M_CheckParm("-nomidimusic")) - nomidimusic = true; ; // WARNING: DOS version initmusic in I_StartupSound + midi_disabled = true; ; // WARNING: DOS version initmusic in I_StartupSound if (M_CheckParm("-nodigmusic")) - nodigimusic = true; // WARNING: DOS version initmusic in I_StartupSound + digital_disabled = true; // WARNING: DOS version initmusic in I_StartupSound } I_StartupSound(); I_InitMusic(); diff --git a/src/doomstat.h b/src/doomstat.h index 8072a1552..27bd3fa19 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -85,10 +85,7 @@ extern boolean fromlevelselect; // Internal parameters for sound rendering. // ======================================== -extern boolean nomidimusic; // defined in d_main.c -extern boolean nosound; -extern boolean nodigimusic; -extern boolean music_disabled; +extern boolean midi_disabled; extern boolean sound_disabled; extern boolean digital_disabled; diff --git a/src/m_menu.c b/src/m_menu.c index 82242c0c1..7a5e78a7b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6950,11 +6950,11 @@ static void M_ChangeControl(INT32 choice) // Toggles sound systems in-game. static void M_ToggleSFX(void) { - if (nosound) + if (sound_disabled) { - nosound = false; + sound_disabled = false; I_StartupSound(); - if (nosound) return; + if (sound_disabled) return; S_InitSfxChannels(cv_soundvolume.value); M_StartMessage(M_GetText("SFX Enabled\n"), NULL, MM_NOTHING); } @@ -6976,56 +6976,44 @@ static void M_ToggleSFX(void) static void M_ToggleDigital(void) { - if (nodigimusic) + if (digital_disabled) { - nodigimusic = false; - I_InitDigMusic(); - if (nodigimusic) return; - S_InitSfxChannels(cv_soundvolume.value); + digital_disabled = false; + I_InitMusic(); + if (digital_disabled) return; S_StopMusic(); - S_ChangeMusicInternal("lclear", false); + if (Playing()) + P_RestoreMusic(&players[consoleplayer]); + else + S_ChangeMusicInternal("lclear", false); M_StartMessage(M_GetText("Digital Music Enabled\n"), NULL, MM_NOTHING); } else { - if (digital_disabled) - { - digital_disabled = false; - M_StartMessage(M_GetText("Digital Music Enabled\n"), NULL, MM_NOTHING); - } - else - { - digital_disabled = true; - S_StopMusic(); - M_StartMessage(M_GetText("Digital Music Disabled\n"), NULL, MM_NOTHING); - } + digital_disabled = true; + S_StopMusic(); + M_StartMessage(M_GetText("Digital Music Disabled\n"), NULL, MM_NOTHING); } } static void M_ToggleMIDI(void) { - if (nomidimusic) + if (midi_disabled) { - nomidimusic = false; - I_InitMIDIMusic(); - if (nomidimusic) return; - S_InitSfxChannels(cv_soundvolume.value); - S_ChangeMusicInternal("lclear", false); + midi_disabled = false; + I_InitMusic(); + if (midi_disabled) return; + if (Playing()) + P_RestoreMusic(&players[consoleplayer]); + else + S_ChangeMusicInternal("lclear", false); M_StartMessage(M_GetText("MIDI Music Enabled\n"), NULL, MM_NOTHING); } else { - if (music_disabled) - { - music_disabled = false; - M_StartMessage(M_GetText("MIDI Music Enabled\n"), NULL, MM_NOTHING); - } - else - { - music_disabled = true; - S_StopMusic(); - M_StartMessage(M_GetText("MIDI Music Disabled\n"), NULL, MM_NOTHING); - } + midi_disabled = true; + S_StopMusic(); + M_StartMessage(M_GetText("MIDI Music Disabled\n"), NULL, MM_NOTHING); } } diff --git a/src/p_mobj.c b/src/p_mobj.c index 5f85474c6..a55e5de26 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8228,7 +8228,7 @@ void P_PrecipitationEffects(void) if (!playeringame[displayplayer] || !players[displayplayer].mo) return; - if (nosound || sound_disabled) + if (sound_disabled) return; // Sound off? D'aw, no fun. if (players[displayplayer].mo->subsector->sector->ceilingpic == skyflatnum) diff --git a/src/s_sound.c b/src/s_sound.c index e035c4192..d1993bc87 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -226,7 +226,7 @@ void S_RegisterSoundStuff(void) { if (dedicated) { - nosound = true; + sound_disabled = true; return; } @@ -400,7 +400,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) mobj_t *listenmobj = players[displayplayer].mo; mobj_t *listenmobj2 = NULL; - if (sound_disabled || !sound_started || nosound) + if (sound_disabled || !sound_started) return; // Don't want a sound? Okay then... @@ -716,7 +716,7 @@ void S_UpdateSounds(void) return; } - if (dedicated || nosound) + if (dedicated || sound_disabled) return; if (players[displayplayer].awayviewtics) @@ -1175,7 +1175,7 @@ void S_InitSfxChannels(INT32 sfxVolume) } // precache sounds if requested by cmdline, or precachesound var true - if (!nosound && (M_CheckParm("-precachesound") || precachesound.value)) + if (!sound_disabled && (M_CheckParm("-precachesound") || precachesound.value)) { // Initialize external data (all sounds) at start, keep static. CONS_Printf(M_GetText("Loading sounds... ")); @@ -1220,24 +1220,19 @@ static char music_name[7]; // up to 6-character name /// Music Status /// ------------------------ -boolean S_DigMusicDisabled() +boolean S_DigMusicDisabled(void) { - return (nodigimusic || digital_disabled); + return digital_disabled; } -boolean S_MIDIMusicDisabled() +boolean S_MIDIMusicDisabled(void) { - return (nomidimusic || music_disabled); + return midi_disabled; } -boolean S_MusicDisabled() +boolean S_MusicDisabled(void) { - return ( - (nodigimusic && nomidimusic) || - (music_disabled && digital_disabled) || - (nodigimusic && music_disabled) || - (nomidimusic && digital_disabled) - ); + return (midi_disabled && digital_disabled); } boolean S_MusicPlaying(void) @@ -1333,7 +1328,7 @@ static void S_UnloadMusic(void) static boolean S_PlayMusic(boolean looping) { - if (nodigimusic || digital_disabled) + if (S_DigMusicDisabled()) return false; // try midi if (!I_PlaySong(looping)) From 17cf310b84ebeaa096b2172f55bb9a2fb5494e08 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 12:43:38 -0400 Subject: [PATCH 270/573] nodigimusic nomusic nosound refactor other targets (cherry picked from commit 86f151db654beb14e8d6893cdff2adaa965e8e4b) --- src/djgppdos/i_sound.c | 38 +++++++++++++++++----------------- src/hardware/hw3sound.c | 2 +- src/sdl/sdl_sound.c | 46 ++++++++++++++++++++--------------------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index 6e351b523..d998016a2 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -134,7 +134,7 @@ FUNCINLINE static ATTRINLINE int Volset(int vol) void I_SetSfxVolume(INT32 volume) { - if (nosound) + if (sound_disabled) return; set_volume (Volset(volume),-1); @@ -142,7 +142,7 @@ void I_SetSfxVolume(INT32 volume) void I_SetMusicVolume(INT32 volume) { - if (nomidimusic) + if (midi_disabled) return; // Now set volume on output device. @@ -169,7 +169,7 @@ INT32 I_StartSound ( sfxenum_t id, { int voice; - if (nosound) + if (sound_disabled) return 0; // UNUSED @@ -190,7 +190,7 @@ void I_StopSound (INT32 handle) // an setting the channel to zero. int voice=handle & (VIRTUAL_VOICES-1); - if (nosound) + if (sound_disabled) return; if (voice_check(voice)==S_sfx[handle>>VOICESSHIFT].data) @@ -199,7 +199,7 @@ void I_StopSound (INT32 handle) INT32 I_SoundIsPlaying(INT32 handle) { - if (nosound) + if (sound_disabled) return FALSE; if (voice_check(handle & (VIRTUAL_VOICES-1))==S_sfx[handle>>VOICESSHIFT].data) @@ -229,7 +229,7 @@ void I_UpdateSoundParams( INT32 handle, int voice=handle & (VIRTUAL_VOICES-1); int numsfx=handle>>VOICESSHIFT; - if (nosound) + if (sound_disabled) return; if (voice_check(voice)==S_sfx[numsfx].data) @@ -270,17 +270,17 @@ void I_StartupSound(void) char err[255]; #endif - if (nosound) + if (sound_disabled) sfxcard=DIGI_NONE; else sfxcard=DIGI_AUTODETECT; - if (nomidimusic) + if (midi_disabled) midicard=MIDI_NONE; else midicard=MIDI_AUTODETECT; //DetectMusicCard(); - nodigimusic=true; //Alam: No OGG/MP3/IT/MOD support + digital_disabled=true; //Alam: No OGG/MP3/IT/MOD support // Secure and configure sound device first. CONS_Printf("I_StartupSound: "); @@ -293,8 +293,8 @@ void I_StartupSound(void) { sprintf (err,"Sound init error : %s\n",allegro_error); CONS_Error (err); - nosound=true; - nomidimusic=true; + sound_disabled=true; + midi_disabled=true; } else { @@ -409,7 +409,7 @@ static MIDI *load_midi_mem(char *mempointer,int *e) void I_InitMusic(void) { - if (nomidimusic) + if (midi_disabled) return; I_AddExitFunc(I_ShutdownMusic); @@ -430,7 +430,7 @@ void I_ShutdownMusic(void) boolean I_PlaySong(boolean looping) { handle = 0; - if (nomidimusic) + if (midi_disabled) return false; islooping = looping; @@ -443,7 +443,7 @@ boolean I_PlaySong(boolean looping) void I_PauseSong (INT32 handle) { handle = 0; - if (nomidimusic) + if (midi_disabled) return; midi_pause(); songpaused = true; @@ -452,7 +452,7 @@ void I_PauseSong (INT32 handle) void I_ResumeSong (INT32 handle) { handle = 0; - if (nomidimusic) + if (midi_disabled) return; midi_resume(); songpaused = false; @@ -461,7 +461,7 @@ void I_ResumeSong (INT32 handle) void I_StopSong(void) { handle = 0; - if (nomidimusic) + if (midi_disabled) return; islooping = 0; @@ -474,7 +474,7 @@ void I_StopSong(void) #if 0 int I_QrySongPlaying(int handle) { - if (nomidimusic) + if (midi_disabled) return 0; //return islooping || musicdies > gametic; @@ -485,7 +485,7 @@ int I_QrySongPlaying(int handle) void I_UnloadSong(void) { handle = 0; - if (nomidimusic) + if (midi_disabled) return; //destroy_midi(currsong); @@ -494,7 +494,7 @@ void I_UnloadSong(void) boolean I_LoadSong(char *data, size_t len) { int e = len; //Alam: For error - if (nomidimusic) + if (midi_disabled) return 0; if (memcmp(data,"MThd",4)==0) // support mid file in WAD !!! diff --git a/src/hardware/hw3sound.c b/src/hardware/hw3sound.c index c68430921..f7c6e1da0 100644 --- a/src/hardware/hw3sound.c +++ b/src/hardware/hw3sound.c @@ -361,7 +361,7 @@ INT32 HW3S_I_StartSound(const void *origin_p, source3D_data_t *source_parm, chan if (splitscreen) listenmobj2 = players[secondarydisplayplayer].mo; - if (nosound) + if (sound_disabled) return -1; sfx = &S_sfx[sfx_id]; diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index d8d3e0a95..cf54d7d05 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -194,8 +194,8 @@ static srb2audio_t localdata; static void Snd_LockAudio(void) //Alam: Lock audio data and uninstall audio callback { if (Snd_Mutex) SDL_LockMutex(Snd_Mutex); - else if (nosound) return; - else if (nomidimusic && nodigimusic + else if (sound_disabled) return; + else if (midi_disabled && digital_disabled #ifdef HW3SOUND && hws_mode == HWS_DEFAULT_MODE #endif @@ -208,8 +208,8 @@ static void Snd_LockAudio(void) //Alam: Lock audio data and uninstall audio call static void Snd_UnlockAudio(void) //Alam: Unlock audio data and reinstall audio callback { if (Snd_Mutex) SDL_UnlockMutex(Snd_Mutex); - else if (nosound) return; - else if (nomidimusic && nodigimusic + else if (sound_disabled) return; + else if (midi_disabled && digital_disabled #ifdef HW3SOUND && hws_mode == HWS_DEFAULT_MODE #endif @@ -493,7 +493,7 @@ static inline void I_SetChannels(void) INT32 *steptablemid = steptable + 128; - if (nosound) + if (sound_disabled) return; // This table provides step widths for pitch parameters. @@ -609,7 +609,7 @@ INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priori (void)priority; (void)pitch; - if (nosound) + if (sound_disabled) return 0; if (S_sfx[id].data == NULL) return -1; @@ -1136,7 +1136,7 @@ static INT32 Init3DSDriver(const char *soName) void I_ShutdownSound(void) { - if (nosound || !sound_started) + if (sound_disabled || !sound_started) return; CONS_Printf("I_ShutdownSound: "); @@ -1150,7 +1150,7 @@ void I_ShutdownSound(void) } #endif - if (nomidimusic && nodigimusic) + if (midi_disabled && digital_disabled) SDL_CloseAudio(); CONS_Printf("%s", M_GetText("shut down\n")); sound_started = false; @@ -1170,7 +1170,7 @@ void I_StartupSound(void) const char *sdrv_name = NULL; #endif #ifndef HAVE_MIXER - nomidimusic = nodigimusic = true; + midi_disabled = digital_disabled = true; #endif memset(channels, 0, sizeof (channels)); //Alam: Clean it @@ -1213,7 +1213,7 @@ void I_StartupSound(void) audio.samples /= 2; } - if (nosound) + if (sound_disabled) return; #ifdef HW3SOUND @@ -1261,7 +1261,7 @@ void I_StartupSound(void) { snddev_t snddev; - //nosound = true; + //sound_disabled = true; //I_AddExitFunc(I_ShutdownSound); snddev.bps = 16; snddev.sample_rate = audio.freq; @@ -1288,7 +1288,7 @@ void I_StartupSound(void) if (!musicStarted && SDL_OpenAudio(&audio, &audio) < 0) { CONS_Printf("%s", M_GetText(" couldn't open audio with desired format\n")); - nosound = true; + sound_disabled = true; return; } else @@ -1452,7 +1452,7 @@ static boolean LoadSong(void *data, size_t lumplength, size_t selectpos) void I_ShutdownMusic(void) { #ifdef HAVE_MIXER - if ((nomidimusic && nodigimusic) || !musicStarted) + if ((midi_disabled && digital_disabled) || !musicStarted) return; CONS_Printf("%s", M_GetText("I_ShutdownMusic: ")); @@ -1543,7 +1543,7 @@ void I_InitMusic(void) if (Mix_OpenAudio(audio.freq, audio.format, audio.channels, audio.samples) < 0) //open_music(&audio) { CONS_Printf(M_GetText(" Unable to open music: %s\n"), Mix_GetError()); - nomidimusic = nodigimusic = true; + midi_disabled = digital_disabled = true; if (sound_started #ifdef HW3SOUND && hws_mode == HWS_DEFAULT_MODE @@ -1553,7 +1553,7 @@ void I_InitMusic(void) if (SDL_OpenAudio(&audio, NULL) < 0) //retry { CONS_Printf("%s", M_GetText(" couldn't open audio with desired format\n")); - nosound = true; + sound_disabled = true; sound_started = false; } else @@ -1588,7 +1588,7 @@ boolean I_PlaySong(INT32 handle, boolean looping) { (void)handle; #ifdef HAVE_MIXER - if (nomidimusic || !musicStarted || !music[handle]) + if (midi_disabled || !musicStarted || !music[handle]) return false; #ifdef MIXER_POS @@ -1621,7 +1621,7 @@ void I_PauseSong(void) (void)handle; I_PauseGME(); #ifdef HAVE_MIXER - if ((nomidimusic && nodigimusic) || !musicStarted) + if ((midi_disabled && digital_disabled) || !musicStarted) return; Mix_PauseMusic(); @@ -1641,7 +1641,7 @@ void I_ResumeSong(void) (void)handle; I_ResumeGME(); #ifdef HAVE_MIXER - if ((nomidimusic && nodigimusic) || !musicStarted) + if ((midi_disabled && digital_disabled) || !musicStarted) return; Mix_VolumeMusic(musicvol); @@ -1654,7 +1654,7 @@ void I_StopSong(void) { I_StopGME(); #ifdef HAVE_MIXER - if (nodigimusic) + if (digital_disabled) return; #ifdef MIXER_POS @@ -1676,7 +1676,7 @@ void I_UnloadSong(void) { #ifdef HAVE_MIXER - if (nomidimusic || !musicStarted) + if (midi_disabled || !musicStarted) return; Mix_HaltMusic(); @@ -1695,7 +1695,7 @@ void I_UnloadSong(void) boolean I_LoadSong(char *data, size_t len) { #ifdef HAVE_MIXER - if (nomidimusic || !musicStarted) + if (midi_disabled || !musicStarted) return false; if (!LoadSong(data, len, 0)) @@ -1715,7 +1715,7 @@ boolean I_LoadSong(char *data, size_t len) void I_SetMusicVolume(UINT8 volume) { #ifdef HAVE_MIXER - if ((nomidimusic && nodigimusic) || !musicStarted) + if ((midi_disabled && digital_disabled) || !musicStarted) return; if (Msc_Mutex) SDL_LockMutex(Msc_Mutex); @@ -1802,7 +1802,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping) return true; #ifdef HAVE_MIXER - if (nodigimusic) + if (digital_disabled) return false; snprintf(filename, sizeof filename, "o_%s", musicname); From 7e7899ae831e2203e0cf28b09b8178e66037c554 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 12:51:45 -0400 Subject: [PATCH 271/573] Toggle Digi/MIDI music in menu accurately; add S_MusicType (cherry picked from commit 4aa100aa575cc7fc14a743085222c806ba2c714a) --- src/m_menu.c | 6 ++++-- src/s_sound.c | 36 +++++++++++++++++++++--------------- src/s_sound.h | 2 ++ 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 7a5e78a7b..2c82bf84f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6991,7 +6991,8 @@ static void M_ToggleDigital(void) else { digital_disabled = true; - S_StopMusic(); + if (S_MusicType() != MU_MID) + S_StopMusic(); M_StartMessage(M_GetText("Digital Music Disabled\n"), NULL, MM_NOTHING); } } @@ -7012,7 +7013,8 @@ static void M_ToggleMIDI(void) else { midi_disabled = true; - S_StopMusic(); + if (S_MusicType() == MU_MID) + S_StopMusic(); M_StartMessage(M_GetText("MIDI Music Disabled\n"), NULL, MM_NOTHING); } } diff --git a/src/s_sound.c b/src/s_sound.c index d1993bc87..54ffffc4c 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1245,6 +1245,11 @@ boolean S_MusicPaused(void) return I_MusicPaused(); } +musictype_t S_MusicType(void) +{ + return I_GetMusicType(); +} + const char *S_MusicName(void) { return music_name; @@ -1279,20 +1284,24 @@ static boolean S_LoadMusic(const char *mname) if (S_MusicDisabled()) return false; - if (S_DigMusicDisabled()) - { - if (!S_MIDIExists(mname)) - return false; + if (!S_DigMusicDisabled() && S_DigExists(mname)) + mlumpnum = W_GetNumForName(va("o_%s", mname)); + else if (!S_MIDIMusicDisabled() && S_MIDIExists(mname)) mlumpnum = W_GetNumForName(va("d_%s", mname)); + else if (S_DigMusicDisabled() && S_DigExists(mname)) + { + CONS_Alert(CONS_NOTICE, "Digital music is disabled!\n"); + return false; + } + else if (S_MIDIMusicDisabled() && S_MIDIExists(mname)) + { + CONS_Alert(CONS_NOTICE, "MIDI music is disabled!\n"); + return false; } else { - if (S_DigExists(mname)) - mlumpnum = W_GetNumForName(va("o_%s", mname)); - else if (S_MIDIExists(mname)) - mlumpnum = W_GetNumForName(va("d_%s", mname)); - else - return false; + CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), mname); + return false; } // load & register it @@ -1328,8 +1337,8 @@ static void S_UnloadMusic(void) static boolean S_PlayMusic(boolean looping) { - if (S_DigMusicDisabled()) - return false; // try midi + if (S_MusicDisabled()) + return false; if (!I_PlaySong(looping)) { @@ -1362,10 +1371,7 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) S_StopMusic(); // shutdown old music if (!S_LoadMusic(mmusic)) - { - CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), mmusic); return; - } if (!S_PlayMusic(looping)) { diff --git a/src/s_sound.h b/src/s_sound.h index 9a3f2805c..a0ac6c158 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -14,6 +14,7 @@ #ifndef __S_SOUND__ #define __S_SOUND__ +#include "i_sound.h" // musictype_t #include "sounds.h" #include "m_fixed.h" #include "command.h" @@ -106,6 +107,7 @@ boolean S_MIDIMusicDisabled(void); boolean S_MusicDisabled(void); boolean S_MusicPlaying(void); boolean S_MusicPaused(void); +musictype_t S_MusicType(void); const char *S_MusicName(void); boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi); #define S_DigExists(a) S_MusicExists(a, false, true) From 8c78d86c3641675e6c5803afab052cf91055af03 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 16:46:40 -0400 Subject: [PATCH 272/573] Play the opposite type music (Digital/MIDI) when toggling between them in menu * S_MusicInfo method to retrieve name, flags, and looping (cherry picked from commit f6ec93198f0dcfa1d053cca88172c3e3c7ba310c) --- src/m_menu.c | 38 ++++++++++++++++++++++++++++++++++++-- src/s_sound.c | 19 +++++++++++++++++-- src/s_sound.h | 2 +- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 2c82bf84f..6a6875aad 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6992,7 +6992,24 @@ static void M_ToggleDigital(void) { digital_disabled = true; if (S_MusicType() != MU_MID) - S_StopMusic(); + { + if (midi_disabled) + S_StopMusic(); + else + { + char mmusic[7]; + UINT16 mflags; + boolean looping; + + if (S_MusicInfo(mmusic, &mflags, &looping) && S_MIDIExists(mmusic)) + { + S_StopMusic(); + S_ChangeMusic(mmusic, mflags, looping); + } + else + S_StopMusic(); + } + } M_StartMessage(M_GetText("Digital Music Disabled\n"), NULL, MM_NOTHING); } } @@ -7014,7 +7031,24 @@ static void M_ToggleMIDI(void) { midi_disabled = true; if (S_MusicType() == MU_MID) - S_StopMusic(); + { + if (digital_disabled) + S_StopMusic(); + else + { + char mmusic[7]; + UINT16 mflags; + boolean looping; + + if (S_MusicInfo(mmusic, &mflags, &looping) && S_DigExists(mmusic)) + { + S_StopMusic(); + S_ChangeMusic(mmusic, mflags, looping); + } + else + S_StopMusic(); + } + } M_StartMessage(M_GetText("MIDI Music Disabled\n"), NULL, MM_NOTHING); } } diff --git a/src/s_sound.c b/src/s_sound.c index 54ffffc4c..32d9c7b06 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1215,6 +1215,8 @@ const char *compat_special_music_slots[16] = #endif static char music_name[7]; // up to 6-character name +static UINT16 music_flags; +static boolean music_looping; /// ------------------------ /// Music Status @@ -1250,9 +1252,17 @@ musictype_t S_MusicType(void) return I_GetMusicType(); } -const char *S_MusicName(void) +boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping) { - return music_name; + if (!I_MusicPlaying()) + return false; + + strncpy(mname, music_name, 7); + mname[6] = 0; + *mflags = music_flags; + *looping = music_looping; + + return (boolean)mname[0]; } boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi) @@ -1333,6 +1343,8 @@ static void S_UnloadMusic(void) { I_UnloadSong(); music_name[0] = 0; + music_flags = 0; + music_looping = false; } static boolean S_PlayMusic(boolean looping) @@ -1373,6 +1385,9 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) if (!S_LoadMusic(mmusic)) return; + music_flags = mflags; + music_looping = looping; + if (!S_PlayMusic(looping)) { CONS_Alert(CONS_ERROR, "Music cannot be played!\n"); diff --git a/src/s_sound.h b/src/s_sound.h index a0ac6c158..a2d51a59b 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -108,7 +108,7 @@ boolean S_MusicDisabled(void); boolean S_MusicPlaying(void); boolean S_MusicPaused(void); musictype_t S_MusicType(void); -const char *S_MusicName(void); +boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping); boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi); #define S_DigExists(a) S_MusicExists(a, false, true) #define S_MIDIExists(a) S_MusicExists(a, true, false) From 5bac836d4c805e37c1bf7d9d75cfa23c0933538f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 17:05:37 -0400 Subject: [PATCH 273/573] Minor refactoring and reordering * I_GetMusicType() -> I_MusicType() * Wrap MIDI volume hack in #ifdef _WIN32 (cherry picked from commit a7d51bf81030c228937a8e759f8f43b85817fce6) --- src/i_sound.h | 89 ++++++++-------- src/s_sound.c | 8 +- src/sdl/mixer_sound.c | 238 +++++++++++++++++++++++------------------- 3 files changed, 174 insertions(+), 161 deletions(-) diff --git a/src/i_sound.h b/src/i_sound.h index 901e6c284..15126d695 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -66,9 +66,9 @@ void I_StartupSound(void); */ void I_ShutdownSound(void); -// -// SFX I/O -// +/// ------------------------ +/// SFX I/O +/// ------------------------ /** \brief Starts a sound in a particular sound channel. \param id sfxid @@ -120,13 +120,9 @@ void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch); */ void I_SetSfxVolume(UINT8 volume); -// -// MUSIC I/O -// - -musictype_t I_GetMusicType(void); -boolean I_MusicPlaying(void); -boolean I_MusicPaused(void); +/// ------------------------ +// MUSIC SYSTEM +/// ------------------------ /** \brief Init the music systems */ @@ -136,33 +132,23 @@ void I_InitMusic(void); */ void I_ShutdownMusic(void); -/** \brief PAUSE game handling. +/// ------------------------ +// MUSIC PROPERTIES +/// ------------------------ - \param handle song handle +musictype_t I_MusicType(void); +boolean I_MusicPlaying(void); +boolean I_MusicPaused(void); - \return void -*/ -void I_PauseSong(void); +/// ------------------------ +// MUSIC EFFECTS +/// ------------------------ -/** \brief RESUME game handling +boolean I_SetSongSpeed(float speed); - \param handle song handle - - \return void -*/ -void I_ResumeSong(void); - -// -// MIDI I/O -// - -/** \brief The I_SetMIDIMusicVolume function - - \param volume volume to set at - - \return void -*/ -void I_SetMIDIMusicVolume(UINT8 volume); +/// ------------------------ +// MUSIC PLAYBACK +/// ------------------------ /** \brief Registers a song handle to song data. @@ -175,6 +161,15 @@ void I_SetMIDIMusicVolume(UINT8 volume); */ boolean I_LoadSong(char *data, size_t len); +/** \brief See ::I_LoadSong, then think backwards + + \param handle song handle + + \sa I_LoadSong + \todo remove midi handle +*/ +void I_UnloadSong(void); + /** \brief Called by anything that wishes to start music \param handle Song handle @@ -195,35 +190,35 @@ boolean I_PlaySong(boolean looping); */ void I_StopSong(void); -/** \brief See ::I_LoadSong, then think backwards +/** \brief PAUSE game handling. \param handle song handle - \sa I_LoadSong - \todo remove midi handle + \return void */ -void I_UnloadSong(void); +void I_PauseSong(void); -// -// DIGMUSIC I/O -// +/** \brief RESUME game handling -boolean I_SetSongSpeed(float speed); + \param handle song handle -boolean I_SetSongTrack(INT32 track); + \return void +*/ +void I_ResumeSong(void); -/** \brief The I_SetDigMusicVolume function +/** \brief The I_SetMusicVolume function \param volume volume to set at \return void */ -void I_SetDigMusicVolume(UINT8 volume); +void I_SetMusicVolume(UINT8 volume); -// -// CD MUSIC I/O -// +boolean I_SetSongTrack(INT32 track); +/// ------------------------ +// CD MUSIC I/O +/// ------------------------ /** \brief cd music interface */ diff --git a/src/s_sound.c b/src/s_sound.c index 32d9c7b06..bd6022dfb 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1249,7 +1249,7 @@ boolean S_MusicPaused(void) musictype_t S_MusicType(void) { - return I_GetMusicType(); + return I_MusicType(); } boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping) @@ -1274,7 +1274,7 @@ boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi) } /// ------------------------ -/// Music Properties +/// Music Effects /// ------------------------ boolean S_SpeedMusic(float speed) @@ -1283,7 +1283,7 @@ boolean S_SpeedMusic(float speed) } /// ------------------------ -/// Music Routines +/// Music Playback /// ------------------------ static boolean S_LoadMusic(const char *mname) @@ -1462,7 +1462,7 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) digvolume = seqvolume = 31; #endif - switch(I_GetMusicType()) + switch(I_MusicType()) { case MU_MID: case MU_MOD: diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 1384f1da0..9c46625fc 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -72,6 +72,10 @@ static Music_Emu *gme; static INT32 current_track; #endif +/// ------------------------ +/// Audio System +/// ------------------------ + void I_StartupSound(void) { I_Assert(!sound_started); @@ -128,6 +132,10 @@ FUNCMATH void I_UpdateSound(void) { } +/// ------------------------ +/// SFX +/// ------------------------ + // this is as fast as I can possibly make it. // sorry. more asm needed. static Mix_Chunk *ds2chunk(void *stream) @@ -430,11 +438,72 @@ void I_SetSfxVolume(UINT8 volume) sfx_volume = volume; } -// -// Music -// +/// ------------------------ +/// Music Hooks +/// ------------------------ -musictype_t I_GetMusicType(void) +static void music_loop(void) +{ + Mix_PlayMusic(music, 0); + Mix_SetMusicPosition(loop_point); +} + +#ifdef HAVE_LIBGME +static void mix_gme(void *udata, Uint8 *stream, int len) +{ + int i; + short *p; + + (void)udata; + + // no gme? no music. + if (!gme || gme_track_ended(gme) || songpaused) + return; + + // play gme into stream + gme_play(gme, len/2, (short *)stream); + + // apply volume to stream + for (i = 0, p = (short *)stream; i < len/2; i++, p++) + *p = ((INT32)*p) * music_volume*2 / 42; +} +#endif + + +/// ------------------------ +/// Music System +/// ------------------------ + +FUNCMATH void I_InitMusic(void) +{ +#ifdef HAVE_LIBGME + gme = NULL; + current_track = -1; +#endif +} + +void I_ShutdownMusic(void) +{ +#ifdef HAVE_LIBGME + if (gme) + { + Mix_HookMusic(NULL, NULL); + gme_delete(gme); + gme = NULL; + } +#endif + if (!music) + return; + Mix_HookMusicFinished(NULL); + Mix_FreeMusic(music); + music = NULL; +} + +/// ------------------------ +/// Music Properties +/// ------------------------ + +musictype_t I_MusicType(void) { #ifdef HAVE_LIBGME if (gme) @@ -463,74 +532,9 @@ boolean I_MusicPaused(void) return songpaused; } -// Music hooks -static void music_loop(void) -{ - Mix_PlayMusic(music, 0); - Mix_SetMusicPosition(loop_point); -} - -#ifdef HAVE_LIBGME -static void mix_gme(void *udata, Uint8 *stream, int len) -{ - int i; - short *p; - - (void)udata; - - // no gme? no music. - if (!gme || gme_track_ended(gme) || songpaused) - return; - - // play gme into stream - gme_play(gme, len/2, (short *)stream); - - // apply volume to stream - for (i = 0, p = (short *)stream; i < len/2; i++, p++) - *p = ((INT32)*p) * music_volume*2 / 42; -} -#endif - -FUNCMATH void I_InitMusic(void) -{ -#ifdef HAVE_LIBGME - gme = NULL; - current_track = -1; -#endif -} - -void I_ShutdownMusic(void) -{ -#ifdef HAVE_LIBGME - if (gme) - { - Mix_HookMusic(NULL, NULL); - gme_delete(gme); - gme = NULL; - } -#endif - if (!music) - return; - Mix_HookMusicFinished(NULL); - Mix_FreeMusic(music); - music = NULL; -} - -void I_PauseSong(void) -{ - Mix_PauseMusic(); - songpaused = true; -} - -void I_ResumeSong(void) -{ - Mix_ResumeMusic(); - songpaused = false; -} - -// -// Digital Music -// +/// ------------------------ +/// Music Effects +/// ------------------------ boolean I_SetSongSpeed(float speed) { @@ -550,40 +554,9 @@ boolean I_SetSongSpeed(float speed) return false; } -boolean I_SetSongTrack(int track) -{ -#ifdef HAVE_LIBGME - if (current_track == track) - return false; - - // If the specified track is within the number of tracks playing, then change it - if (gme) - { - SDL_LockAudio(); - if (track >= 0 - && track < gme_track_count(gme)) - { - gme_err_t gme_e = gme_start_track(gme, track); - if (gme_e != NULL) - { - CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e); - return false; - } - current_track = track; - SDL_UnlockAudio(); - return true; - } - SDL_UnlockAudio(); - return false; - } -#endif - (void)track; - return false; -} - -// -// MIDI Music -// +/// ------------------------ +/// Music Playback +/// ------------------------ boolean I_LoadSong(char *data, size_t len) { @@ -731,6 +704,12 @@ boolean I_LoadSong(char *data, size_t len) return true; } +void I_UnloadSong(void) +{ + Mix_FreeMusic(music); + music = NULL; +} + boolean I_PlaySong(boolean looping) { if (!music) @@ -775,25 +754,64 @@ void I_StopSong(void) music = NULL; } +void I_PauseSong(void) +{ + Mix_PauseMusic(); + songpaused = true; +} + +void I_ResumeSong(void) +{ + Mix_ResumeMusic(); + songpaused = false; +} + void I_SetMusicVolume(UINT8 volume) { if (!music) return; - if (I_GetMusicType() == MU_MID) +#ifdef _WIN32 + if (I_MusicType() == MU_MID) // HACK: Until we stop using native MIDI, // disable volume changes music_volume = 31; else +#endif music_volume = volume; Mix_VolumeMusic((UINT32)music_volume*128/31); } -void I_UnloadSong(void) +boolean I_SetSongTrack(int track) { - Mix_FreeMusic(music); - music = NULL; +#ifdef HAVE_LIBGME + if (current_track == track) + return false; + + // If the specified track is within the number of tracks playing, then change it + if (gme) + { + SDL_LockAudio(); + if (track >= 0 + && track < gme_track_count(gme)) + { + gme_err_t gme_e = gme_start_track(gme, track); + if (gme_e != NULL) + { + CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e); + return false; + } + current_track = track; + SDL_UnlockAudio(); + return true; + } + SDL_UnlockAudio(); + return false; + } +#endif + (void)track; + return false; } #endif \ No newline at end of file From d535c14fc6b8d5fb25af05075c6804aaae68270c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 17:05:47 -0400 Subject: [PATCH 274/573] Refactoring and reordering other targets (cherry picked from commit cf065e106f68fb8af3b0568eba188c8235b1656e) --- src/android/i_sound.c | 66 ++++++------ src/djgppdos/i_sound.c | 198 +++++++++++++++++++--------------- src/dummy/i_sound.c | 64 +++++------ src/sdl/sdl_sound.c | 237 +++++++++++++++++++++++------------------ src/win32/win_snd.c | 218 +++++++++++++++++++------------------ 5 files changed, 428 insertions(+), 355 deletions(-) diff --git a/src/android/i_sound.c b/src/android/i_sound.c index 1cbc53fab..bf54c9ff0 100644 --- a/src/android/i_sound.c +++ b/src/android/i_sound.c @@ -55,12 +55,22 @@ void I_SetSfxVolume(INT32 volume) (void)volume; } -// -// MUSIC I/O -// -UINT8 music_started = 0; +/// ------------------------ +// MUSIC SYSTEM +/// ------------------------ -musictype_t I_GetMusicType(void) +UINT8 music_started = 0; +UINT8 digmusic_started = 0; + +void I_InitMusic(void){} + +void I_ShutdownMusic(void){} + +/// ------------------------ +// MUSIC PROPERTIES +/// ------------------------ + +musictype_t I_MusicType(void) { return MU_NONE; } @@ -75,23 +85,19 @@ boolean I_MusicPaused(void) return false; } -void I_InitMusic(void){} +/// ------------------------ +// MUSIC EFFECTS +/// ------------------------ -void I_ShutdownMusic(void){} - -void I_PauseSong(void) +boolean I_SetSongSpeed(float speed) { - (void)handle; + (void)speed; + return false; } -void I_ResumeSong(void) -{ - (void)handle; -} - -// -// MIDI I/O -// +/// ------------------------ +// MUSIC PLAYBACK +/// ------------------------ UINT8 midimusic_started = 0; @@ -102,9 +108,9 @@ boolean I_LoadSong(char *data, size_t len) return -1; } -void I_SetMusicVolume(INT32 volume) +void I_UnloadSong() { - (void)volume; + } boolean I_PlaySong(boolean looping) @@ -119,19 +125,17 @@ void I_StopSong(void) (void)handle; } -void I_UnloadSong(void) +void I_PauseSong(void) { (void)handle; } -// -// DIGMUSIC I/O -// - -UINT8 digmusic_started = 0; - -boolean I_SetSongSpeed(float speed) +void I_ResumeSong(void) { - (void)speed; - return false; -} \ No newline at end of file + (void)handle; +} + +void I_SetMusicVolume(INT32 volume) +{ + (void)volume; +} diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index d998016a2..339b469d3 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -140,15 +140,6 @@ void I_SetSfxVolume(INT32 volume) set_volume (Volset(volume),-1); } -void I_SetMusicVolume(INT32 volume) -{ - if (midi_disabled) - return; - - // Now set volume on output device. - set_volume (-1, Volset(volume)); -} - // // Starting a sound means adding it // to the current list of active sounds @@ -323,23 +314,9 @@ static int musicdies=-1; UINT8 music_started=0; boolean songpaused=false; -musictype_t I_GetMusicType(void) -{ - if (currsong) - return MU_MID; - else - return MU_NONE; -} - -boolean I_MusicPlaying() -{ - return (boolean)currsong; -} - -boolean I_MusicPaused() -{ - return songpaused; -} +/// ------------------------ +// MUSIC SYSTEM +/// ------------------------ /* load_midi_mem: * Loads a standard MIDI file from memory, returning a pointer to @@ -427,69 +404,41 @@ void I_ShutdownMusic(void) music_started=false; } -boolean I_PlaySong(boolean looping) -{ - handle = 0; - if (midi_disabled) - return false; +/// ------------------------ +// MUSIC PROPERTIES +/// ------------------------ - islooping = looping; - musicdies = gametic + NEWTICRATE*30; - if (play_midi(currsong,looping)==0) - return true; +musictype_t I_MusicType(void) +{ + if (currsong) + return MU_MID; + else + return MU_NONE; +} + +boolean I_MusicPlaying() +{ + return (boolean)currsong; +} + +boolean I_MusicPaused() +{ + return songpaused; +} + +/// ------------------------ +// MUSIC EFFECTS +/// ------------------------ + +boolean I_SetSongSpeed(float speed) +{ + (void)speed; return false; } -void I_PauseSong (INT32 handle) -{ - handle = 0; - if (midi_disabled) - return; - midi_pause(); - songpaused = true; -} - -void I_ResumeSong (INT32 handle) -{ - handle = 0; - if (midi_disabled) - return; - midi_resume(); - songpaused = false; -} - -void I_StopSong(void) -{ - handle = 0; - if (midi_disabled) - return; - - islooping = 0; - musicdies = 0; - stop_midi(); - songpaused = false; -} - -// Is the song playing? -#if 0 -int I_QrySongPlaying(int handle) -{ - if (midi_disabled) - return 0; - - //return islooping || musicdies > gametic; - return (midi_pos==-1); -} -#endif - -void I_UnloadSong(void) -{ - handle = 0; - if (midi_disabled) - return; - - //destroy_midi(currsong); -} +/// ------------------------ +// MUSIC PLAYBACK +/// ------------------------ boolean I_LoadSong(char *data, size_t len) { @@ -516,8 +465,81 @@ boolean I_LoadSong(char *data, size_t len) return 1; } -boolean I_SetSongSpeed(float speed) +void I_UnloadSong(void) { - (void)speed; + handle = 0; + if (midi_disabled) + return; + + //destroy_midi(currsong); +} + +boolean I_PlaySong(boolean looping) +{ + handle = 0; + if (midi_disabled) + return false; + + islooping = looping; + musicdies = gametic + NEWTICRATE*30; + if (play_midi(currsong,looping)==0) + return true; return false; -} \ No newline at end of file +} + +void I_StopSong(void) +{ + handle = 0; + if (midi_disabled) + return; + + islooping = 0; + musicdies = 0; + stop_midi(); + songpaused = false; +} + +void I_PauseSong (INT32 handle) +{ + handle = 0; + if (midi_disabled) + return; + midi_pause(); + songpaused = true; +} + +void I_ResumeSong (INT32 handle) +{ + handle = 0; + if (midi_disabled) + return; + midi_resume(); + songpaused = false; +} + +void I_SetMusicVolume(INT32 volume) +{ + if (midi_disabled) + return; + + // Now set volume on output device. + set_volume (-1, Volset(volume)); +} + +boolean I_SetSongTrack(INT32 track) +{ + (void)track; + return false; +} + +// Is the song playing? +#if 0 +int I_QrySongPlaying(int handle) +{ + if (midi_disabled) + return 0; + + //return islooping || musicdies > gametic; + return (midi_pos==-1); +} +#endif diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c index ca90a7da3..fb325c59e 100644 --- a/src/dummy/i_sound.c +++ b/src/dummy/i_sound.c @@ -57,11 +57,19 @@ void I_SetSfxVolume(UINT8 volume) (void)volume; } -// -// MUSIC I/O -// +/// ------------------------ +// MUSIC SYSTEM +/// ------------------------ -musictype_t I_GetMusicType(void) +void I_InitMusic(void){} + +void I_ShutdownMusic(void){} + +/// ------------------------ +// MUSIC PROPERTIES +/// ------------------------ + +musictype_t I_MusicType(void) { return MU_NONE; } @@ -76,28 +84,19 @@ boolean I_MusicPaused(void) return false; } -void I_InitMusic(void){} +/// ------------------------ +// MUSIC EFFECTS +/// ------------------------ -void I_ShutdownMusic(void){} - -void I_SetMusicVolume(UINT8 volume) +boolean I_SetSongSpeed(float speed) { - (void)volume; + (void)speed; + return false; } -void I_PauseSong(void) -{ - (void)handle; -} - -void I_ResumeSong(void) -{ - (void)handle; -} - -// -// MIDI I/O -// +/// ------------------------ +// MUSIC PLAYBACK +/// ------------------------ boolean I_LoadSong(char *data, size_t len) { @@ -106,6 +105,11 @@ boolean I_LoadSong(char *data, size_t len) return -1; } +void I_UnloadSong(void) +{ + (void)handle; +} + boolean I_PlaySong(boolean looping) { (void)handle; @@ -118,19 +122,19 @@ void I_StopSong(void) (void)handle; } -void I_UnloadSong(void) +void I_PauseSong(void) { (void)handle; } -// -// DIGMUSIC I/O -// - -boolean I_SetSongSpeed(float speed) +void I_ResumeSong(void) { - (void)speed; - return false; + (void)handle; +} + +void I_SetMusicVolume(UINT8 volume) +{ + (void)volume; } boolean I_SetSongTrack(int track) diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index cf54d7d05..6a79220c2 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1313,7 +1313,7 @@ void I_StartupSound(void) // MUSIC API. // -musictype_t I_GetMusicType(void) +musictype_t I_MusicType(void) { #ifdef HAVE_MIXER #ifdef HAVE_LIBGME @@ -1448,28 +1448,9 @@ static boolean LoadSong(void *data, size_t lumplength, size_t selectpos) } #endif - -void I_ShutdownMusic(void) -{ -#ifdef HAVE_MIXER - if ((midi_disabled && digital_disabled) || !musicStarted) - return; - - CONS_Printf("%s", M_GetText("I_ShutdownMusic: ")); - - I_UnloadSong(); - I_StopSong(); - Mix_CloseAudio(); -#ifdef MIX_INIT - Mix_Quit(); -#endif - CONS_Printf("%s", M_GetText("shut down\n")); - musicStarted = SDL_FALSE; - if (Msc_Mutex) - SDL_DestroyMutex(Msc_Mutex); - Msc_Mutex = NULL; -#endif -} +/// ------------------------ +// MUSIC SYSTEM +/// ------------------------ void I_InitMusic(void) { @@ -1584,11 +1565,106 @@ void I_InitMusic(void) #endif } -boolean I_PlaySong(INT32 handle, boolean looping) +void I_ShutdownMusic(void) { - (void)handle; #ifdef HAVE_MIXER - if (midi_disabled || !musicStarted || !music[handle]) + if ((midi_disabled && digital_disabled) || !musicStarted) + return; + + CONS_Printf("%s", M_GetText("I_ShutdownMusic: ")); + + I_UnloadSong(); + I_StopSong(); + Mix_CloseAudio(); +#ifdef MIX_INIT + Mix_Quit(); +#endif + CONS_Printf("%s", M_GetText("shut down\n")); + musicStarted = SDL_FALSE; + if (Msc_Mutex) + SDL_DestroyMutex(Msc_Mutex); + Msc_Mutex = NULL; +#endif +} + +/// ------------------------ +// MUSIC PROPERTIES +/// ------------------------ + +musictype_t I_MusicType(void) +{ + return MU_NONE; +} + +boolean I_MusicPlaying(void) +{ + return false; +} + +boolean I_MusicPaused(void) +{ + return false; +} + +/// ------------------------ +// MUSIC EFFECTS +/// ------------------------ + +boolean I_SetSongSpeed(float speed) +{ + (void)speed; + return false; +} + +/// ------------------------ +// MUSIC PLAYBACK +// \todo Merge Digital and MIDI +/// ------------------------ + +boolean I_LoadSong(char *data, size_t len) +{ +#ifdef HAVE_MIXER + if (midi_disabled || !musicStarted) + return false; + + if (!LoadSong(data, len, 0)) + return false; + + if (music[0]) + return true; + + CONS_Printf(M_GetText("Couldn't load MIDI: %s\n"), Mix_GetError()); +#else + (void)len; + (void)data; +#endif + return false; +} + +void I_UnloadSong(void) +{ +#ifdef HAVE_MIXER + + if (midi_disabled || !musicStarted) + return; + + Mix_HaltMusic(); + while (Mix_PlayingMusic()) + ; + + if (music[handle]) + Mix_FreeMusic(music[handle]); + music[handle] = NULL; + LoadSong(NULL, 0, handle); +#else + (void)handle; +#endif +} + +boolean I_PlaySong(boolean looping) +{ +#ifdef HAVE_MIXER + if (!musicStarted || !music[handle]) return false; #ifdef MIXER_POS @@ -1609,6 +1685,28 @@ boolean I_PlaySong(INT32 handle, boolean looping) return false; } +void I_StopSong(void) +{ + I_StopGME(); +#ifdef HAVE_MIXER + if (digital_disabled) + return; + +#ifdef MIXER_POS + if (canlooping) + Mix_HookMusicFinished(NULL); +#endif + + Mix_HaltMusic(); + while (Mix_PlayingMusic()) + ; + + if (music[1]) + Mix_FreeMusic(music[1]); + music[1] = NULL; + LoadSong(NULL, 0, 1); +} + static void I_PauseGME(void) { #ifdef HAVE_LIBGME @@ -1650,68 +1748,6 @@ void I_ResumeSong(void) #endif } -void I_StopSong(void) -{ - I_StopGME(); -#ifdef HAVE_MIXER - if (digital_disabled) - return; - -#ifdef MIXER_POS - if (canlooping) - Mix_HookMusicFinished(NULL); -#endif - - Mix_HaltMusic(); - while (Mix_PlayingMusic()) - ; - - if (music[1]) - Mix_FreeMusic(music[1]); - music[1] = NULL; - LoadSong(NULL, 0, 1); -} - -void I_UnloadSong(void) -{ -#ifdef HAVE_MIXER - - if (midi_disabled || !musicStarted) - return; - - Mix_HaltMusic(); - while (Mix_PlayingMusic()) - ; - - if (music[handle]) - Mix_FreeMusic(music[handle]); - music[handle] = NULL; - LoadSong(NULL, 0, handle); -#else - (void)handle; -#endif -} - -boolean I_LoadSong(char *data, size_t len) -{ -#ifdef HAVE_MIXER - if (midi_disabled || !musicStarted) - return false; - - if (!LoadSong(data, len, 0)) - return false; - - if (music[0]) - return true; - - CONS_Printf(M_GetText("Couldn't load MIDI: %s\n"), Mix_GetError()); -#else - (void)len; - (void)data; -#endif - return false; -} - void I_SetMusicVolume(UINT8 volume) { #ifdef HAVE_MIXER @@ -1727,6 +1763,18 @@ void I_SetMusicVolume(UINT8 volume) #endif } +boolean I_SetSongTrack(int track) +{ + (void)track; + return false; +} + +/// ------------------------ +// MUSIC LOADING AND CLEANUP +// \todo Split logic between loading and playing, +// then move to Playback section +/// ------------------------ + #ifdef HAVE_LIBGME static void I_CleanupGME(void *userdata) { @@ -1961,19 +2009,6 @@ static void I_StopGME(void) #endif } -boolean I_SetSongSpeed(float speed) -{ - - (void)speed; - return false; -} - -boolean I_SetSongTrack(int track) -{ - (void)track; - return false; -} - #ifdef MIXER_POS static void SDLCALL I_FinishMusic(void) { diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index c6a74d999..3dbe6c572 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -439,11 +439,24 @@ void I_SetSfxVolume(UINT8 volume) sfx_volume = volume; } -// -// MUSIC -// +/// ------------------------ +// MUSIC SYSTEM +/// ------------------------ -musictype_t I_GetMusicType(void) +void I_InitMusic(void) +{ +} + +void I_ShutdownMusic(void) +{ + I_StopSong(); +} + +/// ------------------------ +// MUSIC PROPERTIES +/// ------------------------ + +musictype_t I_MusicType(void) { #ifdef HAVE_LIBGME if (gme) @@ -491,28 +504,46 @@ boolean I_MusicPaused(void) return fmpaused; } -void I_InitMusic(void) +/// ------------------------ +// MUSIC EFFECTS +/// ------------------------ + +boolean I_SetSongSpeed(float speed) { + FMOD_RESULT e; + float frequency; + if (!music_stream) + return false; + if (speed > 250.0f) + speed = 250.0f; //limit speed up to 250x + +#ifdef HAVE_LIBGME + // Try to set GME speed + if (gme) + { + gme_set_tempo(gme, speed); + return true; + } +#endif + + // Try to set Mod/Midi speed + e = FMOD_Sound_SetMusicSpeed(music_stream, speed); + + if (e == FMOD_ERR_FORMAT) + { + // Just change pitch instead for Ogg/etc. + FMR(FMOD_Sound_GetDefaults(music_stream, &frequency, NULL, NULL, NULL)); + FMR_MUSIC(FMOD_Channel_SetFrequency(music_channel, speed*frequency)); + } + else + FMR_MUSIC(e); + + return true; } -void I_ShutdownMusic(void) -{ - I_StopSong(); -} - -void I_PauseSong(void) -{ - UNREFERENCED_PARAMETER(handle); - if (music_stream) - FMR_MUSIC(FMOD_Channel_SetPaused(music_channel, true)); -} - -void I_ResumeSong(void) -{ - UNREFERENCED_PARAMETER(handle); - if (music_stream) - FMR_MUSIC(FMOD_Channel_SetPaused(music_channel, false)); -} +/// ------------------------ +// MUSIC PLAYBACK +/// ------------------------ boolean I_LoadSong(char *data, size_t len) { @@ -726,39 +757,79 @@ boolean I_LoadSong(char *data, size_t len) return true; } -boolean I_SetSongSpeed(float speed) +void I_UnloadSong(void) { - FMOD_RESULT e; - float frequency; - if (!music_stream) - return false; - if (speed > 250.0f) - speed = 250.0f; //limit speed up to 250x + UNREFERENCED_PARAMETER(handle); + if (music_stream) + FMR(FMOD_Sound_Release(music_stream)); + music_stream = NULL; +} +boolean I_PlaySong(boolean looping) +{ #ifdef HAVE_LIBGME - // Try to set GME speed if (gme) { - gme_set_tempo(gme, speed); + gme_start_track(gme, 0); + current_track = 0; + FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel)); + FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); + FMR(FMOD_Channel_SetPriority(music_channel, 0)); return true; } #endif - // Try to set Mod/Midi speed - e = FMOD_Sound_SetMusicSpeed(music_stream, speed); - - if (e == FMOD_ERR_FORMAT) - { - // Just change pitch instead for Ogg/etc. - FMR(FMOD_Sound_GetDefaults(music_stream, &frequency, NULL, NULL, NULL)); - FMR_MUSIC(FMOD_Channel_SetFrequency(music_channel, speed*frequency)); - } + FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel)); + if (I_MusicType() != MU_MID) + FMR(FMOD_Channel_SetVolume(music_channel, midi_volume / 31.0)); else - FMR_MUSIC(e); + FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); + FMR(FMOD_Channel_SetPriority(music_channel, 0)); + current_track = 0; return true; } +void I_StopSong(void) +{ +#ifdef HAVE_LIBGME + if (gme) + gme_delete(gme); + gme = NULL; +#endif + current_track = -1; + + I_UnloadSong(); +} + +void I_PauseSong(void) +{ + UNREFERENCED_PARAMETER(handle); + if (music_stream) + FMR_MUSIC(FMOD_Channel_SetPaused(music_channel, true)); +} + +void I_ResumeSong(void) +{ + UNREFERENCED_PARAMETER(handle); + if (music_stream) + FMR_MUSIC(FMOD_Channel_SetPaused(music_channel, false)); +} + +void I_SetMusicVolume(UINT8 volume) +{ + if (!music_stream) + return; + + // volume is 0 to 31. + if (I_MusicType() == MU_MID) + music_volume = 31; // windows bug hack + else + music_volume = volume; + + FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); +} + boolean I_SetSongTrack(INT32 track) { if (track != current_track) // If the track's already playing, then why bother? @@ -803,66 +874,3 @@ boolean I_SetSongTrack(INT32 track) } return false; } - -// -// Fuck MIDI. ... Okay fine, you can have your silly D_-only mode. -// - -void I_SetMusicVolume(UINT8 volume) -{ - if (!music_stream) - return; - - // volume is 0 to 31. - if (I_GetMusicType() == MU_MID) - music_volume = 31; // windows bug hack - else - music_volume = volume; - - FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); -} - -boolean I_PlaySong(boolean looping) -{ -#ifdef HAVE_LIBGME - if (gme) - { - gme_start_track(gme, 0); - current_track = 0; - FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel)); - FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); - FMR(FMOD_Channel_SetPriority(music_channel, 0)); - return true; - } -#endif - - FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel)); - if (I_GetMusicType() != MU_MID) - FMR(FMOD_Channel_SetVolume(music_channel, midi_volume / 31.0)); - else - FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); - FMR(FMOD_Channel_SetPriority(music_channel, 0)); - current_track = 0; - - return true; -} - -void I_StopSong(void) -{ -#ifdef HAVE_LIBGME - if (gme) - gme_delete(gme); - gme = NULL; -#endif - current_track = -1; - - I_UnloadSong(); -} - -void I_UnloadSong(void) -{ - UNREFERENCED_PARAMETER(handle); - if (music_stream) - FMR(FMOD_Sound_Release(music_stream)); - music_stream = NULL; -} \ No newline at end of file From eacf0ba00bc88eeff112b29fbf18f0a8d6ba2b52 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 20:14:46 -0400 Subject: [PATCH 275/573] Refactor I_MusicType MusicPlaying and MusicPaused -> I_SongType ... (cherry picked from commit 4b82de9e540d6dc0651bbe8db8e5e15cba39f650) --- src/i_sound.h | 6 +++--- src/s_sound.c | 18 +++++++++--------- src/sdl/mixer_sound.c | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/i_sound.h b/src/i_sound.h index 15126d695..1be970d2e 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -136,9 +136,9 @@ void I_ShutdownMusic(void); // MUSIC PROPERTIES /// ------------------------ -musictype_t I_MusicType(void); -boolean I_MusicPlaying(void); -boolean I_MusicPaused(void); +musictype_t I_SongType(void); +boolean I_SongPlaying(void); +boolean I_SongPaused(void); /// ------------------------ // MUSIC EFFECTS diff --git a/src/s_sound.c b/src/s_sound.c index bd6022dfb..723401fb2 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1239,22 +1239,22 @@ boolean S_MusicDisabled(void) boolean S_MusicPlaying(void) { - return I_MusicPlaying(); + return I_SongPlaying(); } boolean S_MusicPaused(void) { - return I_MusicPaused(); + return I_SongPaused(); } musictype_t S_MusicType(void) { - return I_MusicType(); + return I_SongType(); } boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping) { - if (!I_MusicPlaying()) + if (!I_SongPlaying()) return false; strncpy(mname, music_name, 7); @@ -1399,10 +1399,10 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) void S_StopMusic(void) { - if (!I_MusicPlaying()) + if (!I_SongPlaying()) return; - if (I_MusicPaused()) + if (I_SongPaused()) I_ResumeSong(); S_SpeedMusic(1.0f); @@ -1421,7 +1421,7 @@ void S_StopMusic(void) // void S_PauseAudio(void) { - if (I_MusicPlaying() && !I_MusicPaused()) + if (I_SongPlaying() && !I_SongPaused()) I_PauseSong(); // pause cd music @@ -1434,7 +1434,7 @@ void S_PauseAudio(void) void S_ResumeAudio(void) { - if (I_MusicPlaying() && I_MusicPaused()) + if (I_SongPlaying() && I_SongPaused()) I_ResumeSong(); // resume cd music @@ -1462,7 +1462,7 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) digvolume = seqvolume = 31; #endif - switch(I_MusicType()) + switch(I_SongType()) { case MU_MID: case MU_MOD: diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 9c46625fc..521bcd033 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -503,7 +503,7 @@ void I_ShutdownMusic(void) /// Music Properties /// ------------------------ -musictype_t I_MusicType(void) +musictype_t I_SongType(void) { #ifdef HAVE_LIBGME if (gme) @@ -522,12 +522,12 @@ musictype_t I_MusicType(void) return (musictype_t)Mix_GetMusicType(music); } -boolean I_MusicPlaying(void) +boolean I_SongPlaying(void) { return (boolean)music; } -boolean I_MusicPaused(void) +boolean I_SongPaused(void) { return songpaused; } @@ -772,7 +772,7 @@ void I_SetMusicVolume(UINT8 volume) return; #ifdef _WIN32 - if (I_MusicType() == MU_MID) + if (I_SongType() == MU_MID) // HACK: Until we stop using native MIDI, // disable volume changes music_volume = 31; From 4d61f00b865033a36af0ad246189345a4fa776f8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 23 Aug 2018 20:14:56 -0400 Subject: [PATCH 276/573] Refactor I_MusicType MusicPlaying and MusicPaused other targets (cherry picked from commit 9e6eebeb8d6b4119d87e9678bb6b0687e3dc5217) --- src/android/i_sound.c | 6 +++--- src/djgppdos/i_sound.c | 6 +++--- src/dummy/i_sound.c | 6 +++--- src/sdl/mixer_sound.c | 4 ++-- src/sdl/sdl_sound.c | 12 ++++++------ src/win32/win_snd.c | 10 +++++----- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/android/i_sound.c b/src/android/i_sound.c index bf54c9ff0..1d16e4df3 100644 --- a/src/android/i_sound.c +++ b/src/android/i_sound.c @@ -70,17 +70,17 @@ void I_ShutdownMusic(void){} // MUSIC PROPERTIES /// ------------------------ -musictype_t I_MusicType(void) +musictype_t I_SongType(void) { return MU_NONE; } -boolean I_MusicPlaying(void) +boolean I_SongPlaying(void) { return false; } -boolean I_MusicPaused(void) +boolean I_SongPaused(void) { return false; } diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index 339b469d3..5403aef17 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -408,7 +408,7 @@ void I_ShutdownMusic(void) // MUSIC PROPERTIES /// ------------------------ -musictype_t I_MusicType(void) +musictype_t I_SongType(void) { if (currsong) return MU_MID; @@ -416,12 +416,12 @@ musictype_t I_MusicType(void) return MU_NONE; } -boolean I_MusicPlaying() +boolean I_SongPlaying() { return (boolean)currsong; } -boolean I_MusicPaused() +boolean I_SongPaused() { return songpaused; } diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c index fb325c59e..4bace7a41 100644 --- a/src/dummy/i_sound.c +++ b/src/dummy/i_sound.c @@ -69,17 +69,17 @@ void I_ShutdownMusic(void){} // MUSIC PROPERTIES /// ------------------------ -musictype_t I_MusicType(void) +musictype_t I_SongType(void) { return MU_NONE; } -boolean I_MusicPlaying(void) +boolean I_SongPlaying(void) { return false; } -boolean I_MusicPaused(void) +boolean I_SongPaused(void) { return false; } diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 521bcd033..9b84a1247 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -63,7 +63,7 @@ UINT8 sound_started = false; static Mix_Music *music; -static UINT8 music_volume, midi_volume, sfx_volume; +static UINT8 music_volume, sfx_volume; static float loop_point; static boolean songpaused; @@ -91,7 +91,7 @@ void I_StartupSound(void) } music = NULL; - music_volume = midi_volume = sfx_volume = 0; + music_volume = sfx_volume = 0; #if SDL_MIXER_VERSION_ATLEAST(1,2,11) Mix_Init(MIX_INIT_FLAC|MIX_INIT_MOD|MIX_INIT_MP3|MIX_INIT_OGG); diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 6a79220c2..887726ebb 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1313,7 +1313,7 @@ void I_StartupSound(void) // MUSIC API. // -musictype_t I_MusicType(void) +musictype_t I_SongType(void) { #ifdef HAVE_MIXER #ifdef HAVE_LIBGME @@ -1336,12 +1336,12 @@ musictype_t I_MusicType(void) #endif } -boolean I_MusicPlaying(void) +boolean I_SongPlaying(void) { return music_started; } -boolean I_MusicPaused(void) +boolean I_SongPaused(void) { return Mix_PausedMusic(); } @@ -1591,17 +1591,17 @@ void I_ShutdownMusic(void) // MUSIC PROPERTIES /// ------------------------ -musictype_t I_MusicType(void) +musictype_t I_SongType(void) { return MU_NONE; } -boolean I_MusicPlaying(void) +boolean I_SongPlaying(void) { return false; } -boolean I_MusicPaused(void) +boolean I_SongPaused(void) { return false; } diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 3dbe6c572..2960ff7d2 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -456,7 +456,7 @@ void I_ShutdownMusic(void) // MUSIC PROPERTIES /// ------------------------ -musictype_t I_MusicType(void) +musictype_t I_SongType(void) { #ifdef HAVE_LIBGME if (gme) @@ -491,12 +491,12 @@ musictype_t I_MusicType(void) return MU_NONE; } -boolean I_MusicPlaying(void) +boolean I_SongPlaying(void) { return (boolean)music_stream; } -boolean I_MusicPaused(void) +boolean I_SongPaused(void) { boolean fmpaused = false; if (music_stream) @@ -780,7 +780,7 @@ boolean I_PlaySong(boolean looping) #endif FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel)); - if (I_MusicType() != MU_MID) + if (I_SongType() != MU_MID) FMR(FMOD_Channel_SetVolume(music_channel, midi_volume / 31.0)); else FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); @@ -822,7 +822,7 @@ void I_SetMusicVolume(UINT8 volume) return; // volume is 0 to 31. - if (I_MusicType() == MU_MID) + if (I_SongType() == MU_MID) music_volume = 31; // windows bug hack else music_volume = volume; From b0c47e2fb12a234a1fa5c41eab54a5b72e734a43 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 24 Aug 2018 13:12:14 -0400 Subject: [PATCH 277/573] GME fix: play song in I_PlaySong, not I_LoadSong (cherry picked from commit 5f21bf230d9716b7cc5b52e4bf3591ebe01e9f3a) --- src/sdl/mixer_sound.c | 8 ++++---- src/win32/win_snd.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 9b84a1247..ca22724b6 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -656,7 +656,6 @@ boolean I_LoadSong(char *data, size_t len) { gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; gme_set_equalizer(gme, &eq); - Mix_HookMusic(mix_gme, gme); return true; } #endif @@ -712,16 +711,17 @@ void I_UnloadSong(void) boolean I_PlaySong(boolean looping) { - if (!music) - return false; -#ifdef HAVE_GME +#ifdef HAVE_LIBGME if (gme) { gme_start_track(gme, 0); current_track = 0; + Mix_HookMusic(mix_gme, gme); return true; } #endif + else if (!music) + return false; if (Mix_PlayMusic(music, looping && loop_point == 0.0f ? -1 : 0) == -1) { diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 2960ff7d2..2e05c4f72 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -675,7 +675,6 @@ boolean I_LoadSong(char *data, size_t len) fmt.decodebuffersize = (44100 * 2) / 35; fmt.pcmreadcallback = GMEReadCallback; fmt.userdata = gme; - FMR(FMOD_System_CreateStream(fsys, NULL, FMOD_OPENUSER | (looping ? FMOD_LOOP_NORMAL : 0), &fmt, &music_stream)); return true; } #endif @@ -772,6 +771,7 @@ boolean I_PlaySong(boolean looping) { gme_start_track(gme, 0); current_track = 0; + FMR(FMOD_System_CreateStream(fsys, NULL, FMOD_OPENUSER | (looping ? FMOD_LOOP_NORMAL : 0), &fmt, &music_stream)); FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel)); FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); FMR(FMOD_Channel_SetPriority(music_channel, 0)); From 2fbe206ecb6c978f088f7398e970ecbad8b4b90b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 24 Aug 2018 13:41:26 -0400 Subject: [PATCH 278/573] A word (cherry picked from commit fb6f8c8a0752c229f5b7369729437c8fecb54d45) --- src/sdl/mixer_sound.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index ca22724b6..927065924 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -719,8 +719,9 @@ boolean I_PlaySong(boolean looping) Mix_HookMusic(mix_gme, gme); return true; } + else #endif - else if (!music) + if (!music) return false; if (Mix_PlayMusic(music, looping && loop_point == 0.0f ? -1 : 0) == -1) From 5f22b7d973002eb873551dff56a07a034c564a61 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 24 Aug 2018 18:01:57 -0400 Subject: [PATCH 279/573] Volume fixes # Conflicts: # src/sdl/mixer_sound.c (cherry picked from commit d39b7011c5b12e5b7abe3e493971e003469a1f3d) --- src/s_sound.c | 6 ++++-- src/sdl/mixer_sound.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 723401fb2..6b632687b 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1465,11 +1465,13 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) switch(I_SongType()) { case MU_MID: - case MU_MOD: - case MU_GME: + //case MU_MOD: + //case MU_GME: I_SetMusicVolume(seqvolume&31); + break; default: I_SetMusicVolume(digvolume&31); + break; } } diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 927065924..49905efd7 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -769,7 +769,7 @@ void I_ResumeSong(void) void I_SetMusicVolume(UINT8 volume) { - if (!music) + if (!I_SongPlaying()) return; #ifdef _WIN32 From d94f7e3cb095b14bad42dc14e39fc40848ed86ee Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 24 Aug 2018 18:02:46 -0400 Subject: [PATCH 280/573] Stub I_UnloadSong because we already unload in I_StopMusic * Stop-gap for now. Ideally the logic would be in the respective places. # Conflicts: # src/sdl/mixer_sound.c (cherry picked from commit eae5d3333f5001512c82f22f2b1433a955b3a6c3) --- src/sdl/mixer_sound.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 49905efd7..676bfc4db 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -705,8 +705,11 @@ boolean I_LoadSong(char *data, size_t len) void I_UnloadSong(void) { - Mix_FreeMusic(music); - music = NULL; + // \todo unhook looper + //var_cleanup(); + //Mix_FreeMusic(music); + //music = NULL; + I_StopSong(); } boolean I_PlaySong(boolean looping) From 8541963c613cfaaff38feef1e00b00a0d5c9ddbc Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 24 Aug 2018 18:00:18 -0400 Subject: [PATCH 281/573] I_SongPlaying detect GME properly (cherry picked from commit e88d1477616ca66472ecb50d371e37dc79c77c0f) --- src/sdl/mixer_sound.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 676bfc4db..dd00d78f7 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -524,7 +524,12 @@ musictype_t I_SongType(void) boolean I_SongPlaying(void) { - return (boolean)music; + return ( +#ifdef HAVE_LIBGME + (I_SongType() == MU_GME && gme) || +#endif + (boolean)music + ); } boolean I_SongPaused(void) From fac7d19637dd29e09622493281744fbfaa045dc0 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 25 Aug 2018 21:42:39 -0400 Subject: [PATCH 282/573] Case-insensitive music_name comparison (cherry picked from commit a7ae059949b320723727aea4468a370bc63c3910) --- src/s_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index 6b632687b..53b8a9628 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1378,7 +1378,7 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) return; } - if (strncmp(music_name, mmusic, 6)) + if (strnicmp(music_name, newmusic, 6)) { S_StopMusic(); // shutdown old music From 4b1bc53db13198c4746102cff6a0a90eab2e4d88 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 10:58:41 -0400 Subject: [PATCH 283/573] Compile fixes --- src/d_main.c | 11 ++++------- src/s_sound.c | 2 +- src/sdl/i_video.c | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index ed1b44684..9d2e1bccc 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -121,20 +121,17 @@ INT32 postimgparam; postimg_t postimgtype2 = postimg_none; INT32 postimgparam2; +// These variables are only true if +// whether the respective sound system is disabled +// or they're init'ed, but the player just toggled them #ifdef _XBOX boolean midi_disabled = true, sound_disabled = true; boolean digital_disabled = true; #else -boolean midi_disabled = false, sound_disabled = false; -boolean digital_disabled = false; // No fmod-based music -#endif - -// These variables are only true if -// whether the respective sound system is disabled -// or they're init'ed, but the player just toggled them boolean midi_disabled = false; boolean sound_disabled = false; boolean digital_disabled = false; +#endif boolean advancedemo; #ifdef DEBUGFILE diff --git a/src/s_sound.c b/src/s_sound.c index 53b8a9628..969d9fdee 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1378,7 +1378,7 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) return; } - if (strnicmp(music_name, newmusic, 6)) + if (strnicmp(music_name, mmusic, 6)) { S_StopMusic(); // shutdown old music diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index ce84e86a6..30ef1b27b 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -566,7 +566,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) // Tell game we got focus back, resume music if necessary window_notinfocus = false; if (!paused) - I_ResumeSong(0); //resume it + I_ResumeSong(); //resume it if (!firsttimeonmouse) { @@ -578,7 +578,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) { // Tell game we lost focus, pause music window_notinfocus = true; - I_PauseSong(0); + I_PauseSong(); if (!disable_mouse) { From 691de18fbbe502fe15fa30854a09c028897cc312 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 11:10:38 -0400 Subject: [PATCH 284/573] Menu sound toggle fixes (and add starpost sfx to menu) --- src/m_menu.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 6a6875aad..63794c529 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6954,23 +6954,15 @@ static void M_ToggleSFX(void) { sound_disabled = false; I_StartupSound(); - if (sound_disabled) return; S_InitSfxChannels(cv_soundvolume.value); + S_StartSound(NULL, sfx_strpst); M_StartMessage(M_GetText("SFX Enabled\n"), NULL, MM_NOTHING); } else { - if (sound_disabled) - { - sound_disabled = false; - M_StartMessage(M_GetText("SFX Enabled\n"), NULL, MM_NOTHING); - } - else - { - sound_disabled = true; - S_StopSounds(); - M_StartMessage(M_GetText("SFX Disabled\n"), NULL, MM_NOTHING); - } + sound_disabled = true; + S_StopSounds(); + M_StartMessage(M_GetText("SFX Disabled\n"), NULL, MM_NOTHING); } } @@ -6980,7 +6972,6 @@ static void M_ToggleDigital(void) { digital_disabled = false; I_InitMusic(); - if (digital_disabled) return; S_StopMusic(); if (Playing()) P_RestoreMusic(&players[consoleplayer]); @@ -7020,7 +7011,6 @@ static void M_ToggleMIDI(void) { midi_disabled = false; I_InitMusic(); - if (midi_disabled) return; if (Playing()) P_RestoreMusic(&players[consoleplayer]); else From 8e05de17f07e599ebb0e3030cb6d74a0b1f76e02 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 12:29:58 -0400 Subject: [PATCH 285/573] Bring back music_data handle, for srb2dd --- src/s_sound.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/s_sound.c b/src/s_sound.c index 969d9fdee..13b8beac1 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1215,6 +1215,7 @@ const char *compat_special_music_slots[16] = #endif static char music_name[7]; // up to 6-character name +static void *music_data; static UINT16 music_flags; static boolean music_looping; @@ -1333,6 +1334,7 @@ static boolean S_LoadMusic(const char *mname) { strncpy(music_name, mname, 7); music_name[6] = 0; + music_data = mdata; return true; } else @@ -1343,6 +1345,10 @@ static void S_UnloadMusic(void) { I_UnloadSong(); music_name[0] = 0; +#ifndef HAVE_SDL //SDL uses RWOPS + Z_ChangeTag(music_data, PU_CACHE); +#endif + music_data = NULL; music_flags = 0; music_looping = false; } From e72610a3dc0e7e1d18deb6375daa8bd5ef1e420f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 12:47:33 -0400 Subject: [PATCH 286/573] Separate StopMusic and UnloadMusic --- src/s_sound.c | 12 ++++------- src/sdl/mixer_sound.c | 50 ++++++++++++++++++------------------------- 2 files changed, 25 insertions(+), 37 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 13b8beac1..2b8e8e721 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1344,11 +1344,13 @@ static boolean S_LoadMusic(const char *mname) static void S_UnloadMusic(void) { I_UnloadSong(); - music_name[0] = 0; + #ifndef HAVE_SDL //SDL uses RWOPS Z_ChangeTag(music_data, PU_CACHE); #endif music_data = NULL; + + music_name[0] = 0; music_flags = 0; music_looping = false; } @@ -1413,13 +1415,7 @@ void S_StopMusic(void) S_SpeedMusic(1.0f); I_StopSong(); - I_UnloadSong(); - -#ifndef HAVE_SDL //SDL uses RWOPS - Z_ChangeTag(music_data, PU_CACHE); -#endif - - music_name[0] = 0; + S_UnloadMusic(); // for now, stopping also means you unload the song } // diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index dd00d78f7..99a379ea2 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -484,19 +484,7 @@ FUNCMATH void I_InitMusic(void) void I_ShutdownMusic(void) { -#ifdef HAVE_LIBGME - if (gme) - { - Mix_HookMusic(NULL, NULL); - gme_delete(gme); - gme = NULL; - } -#endif - if (!music) - return; - Mix_HookMusicFinished(NULL); - Mix_FreeMusic(music); - music = NULL; + I_UnloadSong(); } /// ------------------------ @@ -565,10 +553,8 @@ boolean I_SetSongSpeed(float speed) boolean I_LoadSong(char *data, size_t len) { - I_Assert(!music); -#ifdef HAVE_LIBGME - I_Assert(!gme); -#endif + if (music || gme) + I_UnloadSong(); #ifdef HAVE_LIBGME if ((UINT8)data[0] == 0x1F @@ -710,11 +696,20 @@ boolean I_LoadSong(char *data, size_t len) void I_UnloadSong(void) { - // \todo unhook looper - //var_cleanup(); - //Mix_FreeMusic(music); - //music = NULL; I_StopSong(); + +#ifdef HAVE_LIBGME + if (gme) + { + gme_delete(gme); + gme = NULL; + } +#endif + if (music) + { + Mix_FreeMusic(music); + music = NULL; + } } boolean I_PlaySong(boolean looping) @@ -750,17 +745,14 @@ void I_StopSong(void) if (gme) { Mix_HookMusic(NULL, NULL); - gme_delete(gme); - gme = NULL; current_track = -1; - return; } #endif - if (!music) - return; - Mix_HookMusicFinished(NULL); - Mix_FreeMusic(music); - music = NULL; + if (music) + { + Mix_HookMusicFinished(NULL); + Mix_HaltMusic(); + } } void I_PauseSong(void) From 0999b0f8a8044eae0d8109ba3f0df102bb32c246 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 13:24:15 -0400 Subject: [PATCH 287/573] srb2dd music cleanup fixes --- src/win32/win_cd.c | 2 +- src/win32/win_snd.c | 76 +++++++++++++++++---------------------------- 2 files changed, 29 insertions(+), 49 deletions(-) diff --git a/src/win32/win_cd.c b/src/win32/win_cd.c index f6c430748..2586b8440 100644 --- a/src/win32/win_cd.c +++ b/src/win32/win_cd.c @@ -471,7 +471,7 @@ void I_PlayCD(UINT8 nTrack, UINT8 bLooping) //faB: stop MIDI music, MIDI music will restart if volume is upped later cv_digmusicvolume.value = 0; cv_midimusicvolume.value = 0; - I_StopSong (0); + I_StopSong(); //faB: I don't use the notify message, I'm trying to minimize the delay mciPlay.dwCallback = (DWORD)((size_t)hWndMain); diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 2e05c4f72..36a5904a5 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -475,11 +475,11 @@ musictype_t I_SongType(void) return MU_WAV; case FMOD_SOUND_TYPE_MOD: return MU_MOD; - case FMOD_SOUND_TYPE_MID: + case FMOD_SOUND_TYPE_MIDI: return MU_MID; case FMOD_SOUND_TYPE_OGGVORBIS: return MU_OGG; - case FMOD_SOUND_TYPE_MP3: + case FMOD_SOUND_TYPE_MPEG: return MU_MP3; case FMOD_SOUND_TYPE_FLAC: return MU_FLAC; @@ -547,20 +547,13 @@ boolean I_SetSongSpeed(float speed) boolean I_LoadSong(char *data, size_t len) { - char *data; - size_t len; FMOD_CREATESOUNDEXINFO fmt; - lumpnum_t lumpnum = W_CheckNumForName(va("O_%s",musicname)); + FMOD_RESULT e; + FMOD_TAG tag; + unsigned int loopstart, loopend; - if (lumpnum == LUMPERROR) - { - lumpnum = W_CheckNumForName(va("D_%s",musicname)); - if (lumpnum == LUMPERROR) - return false; - } - - data = (char *)W_CacheLumpNum(lumpnum, PU_MUSIC); - len = W_LumpLength(lumpnum); + if (gme || music_stream) + I_UnloadSong(); memset(&fmt, 0, sizeof(FMOD_CREATESOUNDEXINFO)); fmt.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); @@ -595,8 +588,6 @@ boolean I_LoadSong(char *data, size_t len) gme_equalizer_t gmeq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; Z_Free(inflatedData); // GME supposedly makes a copy for itself, so we don't need this lying around Z_Free(data); // We don't need this, either. - gme_start_track(gme, 0); - current_track = 0; gme_set_equalizer(gme,&gmeq); fmt.format = FMOD_SOUND_FORMAT_PCM16; fmt.defaultfrequency = 44100; @@ -605,10 +596,7 @@ boolean I_LoadSong(char *data, size_t len) fmt.decodebuffersize = (44100 * 2) / 35; fmt.pcmreadcallback = GMEReadCallback; fmt.userdata = gme; - FMR(FMOD_System_CreateStream(fsys, NULL, FMOD_OPENUSER | (looping ? FMOD_LOOP_NORMAL : 0), &fmt, &music_stream)); - FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel)); - FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); - FMR(FMOD_Channel_SetPriority(music_channel, 0)); + FMR(FMOD_System_CreateStream(fsys, NULL, FMOD_OPENUSER, &fmt, &music_stream)); return true; } } @@ -675,26 +663,24 @@ boolean I_LoadSong(char *data, size_t len) fmt.decodebuffersize = (44100 * 2) / 35; fmt.pcmreadcallback = GMEReadCallback; fmt.userdata = gme; + FMR(FMOD_System_CreateStream(fsys, NULL, FMOD_OPENUSER, &fmt, &music_stream)); return true; } #endif fmt.length = len; - FMOD_RESULT e = FMOD_System_CreateStream(fsys, data, FMOD_OPENMEMORY_POINT|(looping ? FMOD_LOOP_NORMAL : 0), &fmt, &music_stream); + e = FMOD_System_CreateStream(fsys, data, FMOD_OPENMEMORY_POINT, &fmt, &music_stream); if (e != FMOD_OK) { if (e == FMOD_ERR_FORMAT) - CONS_Alert(CONS_WARNING, "Failed to play music lump %s due to invalid format.\n", W_CheckNameForNum(lumpnum)); + CONS_Alert(CONS_WARNING, "Failed to play music lump due to invalid format.\n"); else FMR(e); return false; } // Try to find a loop point in streaming music formats (ogg, mp3) - FMOD_RESULT e; - FMOD_TAG tag; - unsigned int loopstart, loopend; // A proper LOOPPOINT is its own tag, stupid. e = FMOD_Sound_GetTag(music_stream, "LOOPPOINT", 0, &tag); @@ -708,13 +694,6 @@ boolean I_LoadSong(char *data, size_t len) return true; } - // todo - // if(music type == MIDI) - // { - // FMR(FMOD_Sound_SetMode(music_stream, FMOD_LOOP_NORMAL)); - // return true; - // } - // Use LOOPMS for time in miliseconds. e = FMOD_Sound_GetTag(music_stream, "LOOPMS", 0, &tag); if (e != FMOD_ERR_TAGNOTFOUND) @@ -758,10 +737,19 @@ boolean I_LoadSong(char *data, size_t len) void I_UnloadSong(void) { - UNREFERENCED_PARAMETER(handle); + I_StopSong(); +#ifdef HAVE_LIBGME + if (gme) + { + gme_delete(gme); + gme = NULL; + } +#endif if (music_stream) + { FMR(FMOD_Sound_Release(music_stream)); - music_stream = NULL; + music_stream = NULL; + } } boolean I_PlaySong(boolean looping) @@ -771,7 +759,6 @@ boolean I_PlaySong(boolean looping) { gme_start_track(gme, 0); current_track = 0; - FMR(FMOD_System_CreateStream(fsys, NULL, FMOD_OPENUSER | (looping ? FMOD_LOOP_NORMAL : 0), &fmt, &music_stream)); FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel)); FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); FMR(FMOD_Channel_SetPriority(music_channel, 0)); @@ -779,6 +766,7 @@ boolean I_PlaySong(boolean looping) } #endif + FMR(FMOD_Sound_SetMode(music_stream, (looping ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF))); FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel)); if (I_SongType() != MU_MID) FMR(FMOD_Channel_SetVolume(music_channel, midi_volume / 31.0)); @@ -792,33 +780,25 @@ boolean I_PlaySong(boolean looping) void I_StopSong(void) { -#ifdef HAVE_LIBGME - if (gme) - gme_delete(gme); - gme = NULL; -#endif - current_track = -1; - - I_UnloadSong(); + if (music_channel) + FMR_MUSIC(FMOD_Channel_Stop(music_channel)); } void I_PauseSong(void) { - UNREFERENCED_PARAMETER(handle); - if (music_stream) + if (music_channel) FMR_MUSIC(FMOD_Channel_SetPaused(music_channel, true)); } void I_ResumeSong(void) { - UNREFERENCED_PARAMETER(handle); - if (music_stream) + if (music_channel) FMR_MUSIC(FMOD_Channel_SetPaused(music_channel, false)); } void I_SetMusicVolume(UINT8 volume) { - if (!music_stream) + if (!music_channel) return; // volume is 0 to 31. From cb4e075137857a391005cfb12c25b294c4e96031 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 13:36:01 -0400 Subject: [PATCH 288/573] I_InitMusic SDL2: Don't unload GME indiscriminately --- src/sdl/mixer_sound.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 99a379ea2..f39d375ef 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -476,10 +476,6 @@ static void mix_gme(void *udata, Uint8 *stream, int len) FUNCMATH void I_InitMusic(void) { -#ifdef HAVE_LIBGME - gme = NULL; - current_track = -1; -#endif } void I_ShutdownMusic(void) From 76be77b93a2a655cd28983c1709fe058c5878859 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 14:52:24 -0400 Subject: [PATCH 289/573] Rip out SDL Mixer code from sdl_sound.c because superfluous * Mixer code has been in mixer_sound.c; this file is not invoked unless compiling with NOMIXER=1 * Remove everything under #ifdef HAVE_MIXER because this is never triggered * Comment out #ifdef HAVE_LIBGME because we don't support playing music anyway (but theoretically, it could have worked separately from Mixer) * Stub new music calls --- src/sdl/sdl_sound.c | 611 +++----------------------------------------- 1 file changed, 42 insertions(+), 569 deletions(-) diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 887726ebb..e29ac080b 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -989,7 +989,7 @@ FUNCINLINE static ATTRINLINE void I_UpdateStream16M(Uint8 *stream, int len) if (Snd_Mutex) SDL_UnlockMutex(Snd_Mutex); } -#ifdef HAVE_LIBGME +#if 0 //#ifdef HAVE_LIBGME static void I_UpdateSteamGME(Music_Emu *emu, INT16 *stream, int len, UINT8 looping) { #define GME_BUFFER_LEN 44100*2048 @@ -1049,14 +1049,16 @@ static void SDLCALL I_UpdateStream(void *userdata, Uint8 *stream, int len) else if (audio.channels == 2 && audio.format == AUDIO_S16SYS) { I_UpdateStream16S(stream, len); -#ifdef HAVE_LIBGME - if (userdata) - { - srb2audio_t *sa_userdata = userdata; - if (!sa_userdata->gme_pause) - I_UpdateSteamGME(sa_userdata->gme_emu, (INT16 *)stream, len/4, sa_userdata->gme_loop); - } -#endif + + // Crashes! But no matter; this build doesn't play music anyway... +// #ifdef HAVE_LIBGME +// if (userdata) +// { +// srb2audio_t *sa_userdata = userdata; +// if (!sa_userdata->gme_pause) +// I_UpdateSteamGME(sa_userdata->gme_emu, (INT16 *)stream, len/4, sa_userdata->gme_loop); +// } +// #endif } } @@ -1313,40 +1315,11 @@ void I_StartupSound(void) // MUSIC API. // -musictype_t I_SongType(void) -{ -#ifdef HAVE_MIXER -#ifdef HAVE_LIBGME - if (gme) - return MU_GME; - else -#endif - if (!music) - return MU_NONE; - else if (Mix_GetMusicType(music) == MUS_MID) - return MU_MID; - else if (Mix_GetMusicType(music) == MUS_MOD || Mix_GetMusicType(music) == MUS_MODPLUG_UNUSED) - return MU_MOD; - else if (Mix_GetMusicType(music) == MUS_MP3 || Mix_GetMusicType(music) == MUS_MP3_MAD_UNUSED) - return MU_MP3; - else - return (musictype_t)Mix_GetMusicType(music); -#else - return MU_NONE -#endif -} +/// ------------------------ +// MUSIC SYSTEM +/// ------------------------ -boolean I_SongPlaying(void) -{ - return music_started; -} - -boolean I_SongPaused(void) -{ - return Mix_PausedMusic(); -} - -#ifdef HAVE_LIBGME +#if 0 //#ifdef HAVE_LIBGME static void I_ShutdownGMEMusic(void) { Snd_LockAudio(); @@ -1357,235 +1330,14 @@ static void I_ShutdownGMEMusic(void) } #endif -#ifdef HAVE_MIXER -static boolean LoadSong(void *data, size_t lumplength, size_t selectpos) -{ - FILE *midfile; - const char *tempname; -#ifdef USE_RWOPS - if (canuseRW) - { - SDL_RWops *SDLRW; - void *olddata = Smidi[selectpos]; //quick shortcut to set - - Z_Free(olddata); //free old memory - Smidi[selectpos] = NULL; - - if (!data) - return olddata != NULL; //was there old data? - - SDLRW = SDL_RWFromConstMem(data, (int)lumplength); //new RWops from Z_zone - if (!SDLRW) //ERROR while making RWops! - { - CONS_Printf(M_GetText("Couldn't load music lump: %s\n"), SDL_GetError()); - Z_Free(data); - return false; - } - - music[selectpos] = Mix_LoadMUS_RW(SDLRW); // new Mix_Chuck from RWops - if (music[selectpos]) - Smidi[selectpos] = data; //all done - else //ERROR while making Mix_Chuck - { - CONS_Printf(M_GetText("Couldn't load music data: %s\n"), Mix_GetError()); - Z_Free(data); - SDL_RWclose(SDLRW); - Smidi[selectpos] = NULL; - } - return true; - } -#endif - tempname = va("%s/%s", MIDI_PATH, fmidi[selectpos]); - - if (!data) - { - if (FIL_FileExists(tempname)) - return unlink(tempname)+1; -#ifdef MIDI_PATH2 - else if (FIL_FileExists(tempname = va("%s/%s", MIDI_PATH2, fmidi[selectpos]))) - return unlink(tempname)+1; -#endif - else - return false; - } - - midfile = fopen(tempname, "wb"); - -#ifdef MIDI_PATH2 - if (!midfile) - { - tempname = va("%s/%s", MIDI_PATH2, fmidi[selectpos]); - midfile = fopen(tempname, "wb"); - } -#endif - - if (!midfile) - { - CONS_Printf(M_GetText("Couldn't open file %s to write music in\n"), tempname); - Z_Free(data); - return false; - } - - if (fwrite(data, lumplength, 1, midfile) == 0) - { - CONS_Printf(M_GetText("Couldn't write music into file %s because %s\n"), tempname, strerror(ferror(midfile))); - Z_Free(data); - fclose(midfile); - return false; - } - - fclose(midfile); - - Z_Free(data); - - music[selectpos] = Mix_LoadMUS(tempname); - if (!music[selectpos]) //ERROR while making Mix_Chuck - { - CONS_Printf(M_GetText("Couldn't load music file %s: %s\n"), tempname, Mix_GetError()); - return false; - } - return true; -} -#endif - -/// ------------------------ -// MUSIC SYSTEM -/// ------------------------ - void I_InitMusic(void) { -#ifdef HAVE_MIXER - char ad[100]; - SDL_version MIXcompiled; - const SDL_version *MIXlinked; -#ifdef MIXER_INIT - const int mixstart = MIX_INIT_OGG; - int mixflags; -#endif -#endif -#ifdef HAVE_LIBGME +#if 0 //#ifdef HAVE_LIBGME I_AddExitFunc(I_ShutdownGMEMusic); #endif - -#ifdef HAVE_MIXER - MIX_VERSION(&MIXcompiled) - MIXlinked = Mix_Linked_Version(); - I_OutputMsg("Compiled for SDL_mixer version: %d.%d.%d\n", - MIXcompiled.major, MIXcompiled.minor, MIXcompiled.patch); -#ifdef MIXER_POS - if (MIXlinked->major == 1 && MIXlinked->minor == 2 && MIXlinked->patch < 7) - canlooping = SDL_FALSE; -#endif -#ifdef USE_RWOPS - if (M_CheckParm("-noRW")) - canuseRW = SDL_FALSE; -#endif - I_OutputMsg("Linked with SDL_mixer version: %d.%d.%d\n", - MIXlinked->major, MIXlinked->minor, MIXlinked->patch); - if (audio.freq < 44100 && !M_CheckParm ("-freq")) //I want atleast 44Khz - { - audio.samples = (Uint16)(audio.samples*(INT32)(44100/audio.freq)); - audio.freq = 44100; //Alam: to keep it around the same XX ms - } - - if (sound_started -#ifdef HW3SOUND - && hws_mode == HWS_DEFAULT_MODE -#endif - ) - { - I_OutputMsg("Temp Shutdown of SDL Audio System"); - SDL_CloseAudio(); - I_OutputMsg(" Done\n"); - } - - CONS_Printf("%s", M_GetText("I_InitMusic:")); - -#ifdef MIXER_INIT - mixflags = Mix_Init(mixstart); - if ((mixstart & MIX_INIT_FLAC) != (mixflags & MIX_INIT_FLAC)) - { - CONS_Printf("%s", M_GetText(" Unable to load FLAC support\n")); - } - if ((mixstart & MIX_INIT_MOD ) != (mixflags & MIX_INIT_MOD )) - { - CONS_Printf("%s", M_GetText(" Unable to load MOD support\n")); - } - if ((mixstart & MIX_INIT_MP3 ) != (mixflags & MIX_INIT_MP3 )) - { - CONS_Printf("%s", M_GetText(" Unable to load MP3 support\n")); - } - if ((mixstart & MIX_INIT_OGG ) != (mixflags & MIX_INIT_OGG )) - { - CONS_Printf("%s", M_GetText(" Unable to load OGG support\n")); - } -#endif - - if (Mix_OpenAudio(audio.freq, audio.format, audio.channels, audio.samples) < 0) //open_music(&audio) - { - CONS_Printf(M_GetText(" Unable to open music: %s\n"), Mix_GetError()); - midi_disabled = digital_disabled = true; - if (sound_started -#ifdef HW3SOUND - && hws_mode == HWS_DEFAULT_MODE -#endif - ) - { - if (SDL_OpenAudio(&audio, NULL) < 0) //retry - { - CONS_Printf("%s", M_GetText(" couldn't open audio with desired format\n")); - sound_disabled = true; - sound_started = false; - } - else - { - CONS_Printf(M_GetText(" Starting with audio driver : %s\n"), SDL_AudioDriverName(ad, (int)sizeof ad)); - } - } - return; - } - else - CONS_Printf(M_GetText(" Starting up with audio driver : %s with SDL_Mixer\n"), SDL_AudioDriverName(ad, (int)sizeof ad)); - - samplecount = audio.samples; - CV_SetValue(&cv_samplerate, audio.freq); - if (sound_started -#ifdef HW3SOUND - && hws_mode == HWS_DEFAULT_MODE -#endif - ) - I_OutputMsg(" Reconfigured SDL Audio System"); - else I_OutputMsg(" Configured SDL_Mixer System"); - I_OutputMsg(" with %d samples/slice at %ikhz(%dms buffer)\n", samplecount, audio.freq/1000, (INT32) ((audio.samples * 1000.0f) / audio.freq)); - Mix_SetPostMix(audio.callback, audio.userdata); // after mixing music, add sound effects - Mix_Resume(-1); - CONS_Printf("%s", M_GetText("Music initialized\n")); - musicStarted = SDL_TRUE; - Msc_Mutex = SDL_CreateMutex(); -#endif } -void I_ShutdownMusic(void) -{ -#ifdef HAVE_MIXER - if ((midi_disabled && digital_disabled) || !musicStarted) - return; - - CONS_Printf("%s", M_GetText("I_ShutdownMusic: ")); - - I_UnloadSong(); - I_StopSong(); - Mix_CloseAudio(); -#ifdef MIX_INIT - Mix_Quit(); -#endif - CONS_Printf("%s", M_GetText("shut down\n")); - musicStarted = SDL_FALSE; - if (Msc_Mutex) - SDL_DestroyMutex(Msc_Mutex); - Msc_Mutex = NULL; -#endif -} +void I_ShutdownMusic(void) { } /// ------------------------ // MUSIC PROPERTIES @@ -1618,149 +1370,64 @@ boolean I_SetSongSpeed(float speed) /// ------------------------ // MUSIC PLAYBACK -// \todo Merge Digital and MIDI /// ------------------------ +#if 0 //#ifdef HAVE_LIBGME +static void I_StopGME(void) +{ + Snd_LockAudio(); + gme_seek(localdata.gme_emu, 0); + Snd_UnlockAudio(); +} + +static void I_PauseGME(void) +{ + localdata.gme_pause = true; +} + +static void I_ResumeGME(void) +{ + localdata.gme_pause = false; +} +#endif + boolean I_LoadSong(char *data, size_t len) { -#ifdef HAVE_MIXER - if (midi_disabled || !musicStarted) - return false; - - if (!LoadSong(data, len, 0)) - return false; - - if (music[0]) - return true; - - CONS_Printf(M_GetText("Couldn't load MIDI: %s\n"), Mix_GetError()); -#else - (void)len; - (void)data; -#endif return false; } -void I_UnloadSong(void) -{ -#ifdef HAVE_MIXER - - if (midi_disabled || !musicStarted) - return; - - Mix_HaltMusic(); - while (Mix_PlayingMusic()) - ; - - if (music[handle]) - Mix_FreeMusic(music[handle]); - music[handle] = NULL; - LoadSong(NULL, 0, handle); -#else - (void)handle; -#endif -} +void I_UnloadSong(void) { } boolean I_PlaySong(boolean looping) { -#ifdef HAVE_MIXER - if (!musicStarted || !music[handle]) - return false; - -#ifdef MIXER_POS - if (canlooping) - Mix_HookMusicFinished(NULL); -#endif - - if (Mix_FadeInMusic(music[handle], looping ? -1 : 0, MIDIfade) == -1) - CONS_Printf(M_GetText("Couldn't play song because %s\n"), Mix_GetError()); - else - { - Mix_VolumeMusic(musicvol); - return true; - } -#else (void)looping; -#endif return false; } void I_StopSong(void) { +#if 0 //#ifdef HAVE_LIBGME I_StopGME(); -#ifdef HAVE_MIXER - if (digital_disabled) - return; - -#ifdef MIXER_POS - if (canlooping) - Mix_HookMusicFinished(NULL); -#endif - - Mix_HaltMusic(); - while (Mix_PlayingMusic()) - ; - - if (music[1]) - Mix_FreeMusic(music[1]); - music[1] = NULL; - LoadSong(NULL, 0, 1); -} - -static void I_PauseGME(void) -{ -#ifdef HAVE_LIBGME - localdata.gme_pause = true; #endif } void I_PauseSong(void) { - (void)handle; +#if 0 //#ifdef HAVE_LIBGME I_PauseGME(); -#ifdef HAVE_MIXER - if ((midi_disabled && digital_disabled) || !musicStarted) - return; - - Mix_PauseMusic(); - //I_StopSong(handle); -#endif -} - -static void I_ResumeGME(void) -{ -#ifdef HAVE_LIBGME - localdata.gme_pause = false; #endif } void I_ResumeSong(void) { - (void)handle; +#if 0 I_ResumeGME(); -#ifdef HAVE_MIXER - if ((midi_disabled && digital_disabled) || !musicStarted) - return; - - Mix_VolumeMusic(musicvol); - Mix_ResumeMusic(); - //I_PlaySong(handle, true); #endif } void I_SetMusicVolume(UINT8 volume) { -#ifdef HAVE_MIXER - if ((midi_disabled && digital_disabled) || !musicStarted) - return; - - if (Msc_Mutex) SDL_LockMutex(Msc_Mutex); - musicvol = volume * 2; - if (Msc_Mutex) SDL_UnlockMutex(Msc_Mutex); - Mix_VolumeMusic(musicvol); -#else (void)volume; -#endif } boolean I_SetSongTrack(int track) @@ -1775,16 +1442,14 @@ boolean I_SetSongTrack(int track) // then move to Playback section /// ------------------------ -#ifdef HAVE_LIBGME +#if 0 //#ifdef HAVE_LIBGME static void I_CleanupGME(void *userdata) { Z_Free(userdata); } -#endif static boolean I_StartGMESong(const char *musicname, boolean looping) { -#ifdef HAVE_LIBGME char filename[9]; void *data; lumpnum_t lumpnum; @@ -1830,199 +1495,7 @@ static boolean I_StartGMESong(const char *musicname, boolean looping) Snd_UnlockAudio(); return true; -#else - (void)musicname; - (void)looping; -#endif - return false; -} - -boolean I_StartDigSong(const char *musicname, boolean looping) -{ -#ifdef HAVE_MIXER - char filename[9]; - void *data; - lumpnum_t lumpnum; - size_t lumplength; -#endif - - if(I_StartGMESong(musicname, looping)) - return true; - -#ifdef HAVE_MIXER - if (digital_disabled) - return false; - - snprintf(filename, sizeof filename, "o_%s", musicname); - - lumpnum = W_CheckNumForName(filename); - - I_StopSong(); - - if (lumpnum == LUMPERROR) - { - // Alam_GBC: like in win32/win_snd.c: Graue 02-29-2004: don't worry about missing music, there might still be a MIDI - //I_OutputMsg("Music lump %s not found!\n", filename); - return false; // No music found. Oh well! - } - else - lumplength = W_LumpLength(lumpnum); - - data = W_CacheLumpNum(lumpnum, PU_MUSIC); - - if (Msc_Mutex) SDL_LockMutex(Msc_Mutex); - -#ifdef MIXER_POS - if (canlooping && (loopingDig = looping) == SDL_TRUE && strcmp(data, "OggS") == 0) - looping = false; // Only on looping Ogg files, will we will do our own looping - - // Scan the Ogg Vorbis file for the COMMENT= field for a custom - // loop point - if (!looping && loopingDig) - { - size_t scan; - const char *dataum = data; - char looplength[64]; - UINT32 loopstart = 0; - UINT8 newcount = 0; - - Mix_HookMusicFinished(I_FinishMusic); - - for (scan = 0; scan < lumplength; scan++) - { - if (*dataum++ == 'C'){ - if (*dataum++ == 'O'){ - if (*dataum++ == 'M'){ - if (*dataum++ == 'M'){ - if (*dataum++ == 'E'){ - if (*dataum++ == 'N'){ - if (*dataum++ == 'T'){ - if (*dataum++ == '='){ - if (*dataum++ == 'L'){ - if (*dataum++ == 'O'){ - if (*dataum++ == 'O'){ - if (*dataum++ == 'P'){ - if (*dataum++ == 'P'){ - if (*dataum++ == 'O'){ - if (*dataum++ == 'I'){ - if (*dataum++ == 'N'){ - if (*dataum++ == 'T'){ - if (*dataum++ == '=') - { - - while (*dataum != 1 && newcount != 63) - looplength[newcount++] = *dataum++; - - looplength[newcount] = '\0'; - - loopstart = atoi(looplength); - - } - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - } - - if (loopstart > 0) - { - loopstartDig = (double)((44.1l+loopstart) / 44100.0l); //8 PCM chucks off and PCM to secs -//#ifdef PARANOIA - //I_OutputMsg("I_StartDigSong: setting looping point to %ul PCMs(%f seconds)\n", loopstart, loopstartDig); -//#endif - } - else - { - looping = true; // loopingDig true, but couldn't find start loop point - } - } - else - loopstartDig = 0.0l; -#else - if (looping && strcmp(data, "OggS") == 0) - I_OutputMsg("I_StartDigSong: SRB2 was not compiled with looping music support(no Mix_FadeInMusicPos)\n"); -#endif - - if (!LoadSong(data, lumplength, 1)) - { - if (Msc_Mutex) SDL_UnlockMutex(Msc_Mutex); - return false; - } - - // Note: LoadSong() frees the data. Let's make sure - // we don't try to use the data again. - data = NULL; - - if (Mix_FadeInMusic(music[1], looping ? -1 : 0, Digfade) == -1) - { - if (Msc_Mutex) SDL_UnlockMutex(Msc_Mutex); - I_OutputMsg("I_StartDigSong: Couldn't play song %s because %s\n", musicname, Mix_GetError()); - return false; - } - Mix_VolumeMusic(musicvol); - - if (Msc_Mutex) SDL_UnlockMutex(Msc_Mutex); - return true; -#else - (void)looping; - (void)musicname; - return false; -#endif -} - -static void I_StopGME(void) -{ -#ifdef HAVE_LIBGME - Snd_LockAudio(); - gme_seek(localdata.gme_emu, 0); - Snd_UnlockAudio(); -#endif -} - -#ifdef MIXER_POS -static void SDLCALL I_FinishMusic(void) -{ - if (!music[1]) - return; - else if (Msc_Mutex) SDL_LockMutex(Msc_Mutex); -// I_OutputMsg("I_FinishMusic: Loopping song to %g seconds\n", loopstartDig); - - if (Mix_FadeInMusicPos(music[1], loopstartDig ? 0 : -1, Digfade, loopstartDig) == 0) - Mix_VolumeMusic(musicvol); - else - I_OutputMsg("I_FinishMusic: Couldn't loop song because %s\n", Mix_GetError()); - - if (Msc_Mutex) SDL_UnlockMutex(Msc_Mutex); } #endif + #endif //HAVE_SDL \ No newline at end of file From 546fa383c1c74499552e031b11020ed71a6d8561 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Sep 2018 21:01:07 +0100 Subject: [PATCH 290/573] Make sure that T_MarioBlockChecker is synced in netgames, so that the textures of Mario Blocks can change when there are no more items --- src/p_saveg.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index d1ec8e5ab..6e0c704f6 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -950,6 +950,7 @@ typedef enum tc_bouncecheese, tc_startcrumble, tc_marioblock, + tc_marioblockchecker, tc_spikesector, tc_floatsector, tc_bridgethinker, @@ -1774,6 +1775,11 @@ static void P_NetArchiveThinkers(void) SaveSpecialLevelThinker(th, tc_marioblock); continue; } + else if (th->function.acp1 == (actionf_p1)T_MarioBlockChecker) + { + SaveSpecialLevelThinker(th, tc_marioblockchecker); + continue; + } else if (th->function.acp1 == (actionf_p1)T_SpikeSector) { SaveSpecialLevelThinker(th, tc_spikesector); @@ -2730,6 +2736,10 @@ static void P_NetUnArchiveThinkers(void) LoadSpecialLevelThinker((actionf_p1)T_MarioBlock, 3); break; + case tc_marioblockchecker: + LoadSpecialLevelThinker((actionf_p1)T_MarioBlockChecker, 0); + break; + case tc_spikesector: LoadSpecialLevelThinker((actionf_p1)T_SpikeSector, 0); break; From b330dc23946ecfae91301ababebbfddc97560c7e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 16:39:10 -0400 Subject: [PATCH 291/573] Don't call I_StartupSound in SFX toggle * Mixer: make I_StartupSound return early if already set up * Restartaudio: Add StopSFX call --- src/d_netcmd.c | 1 + src/m_menu.c | 1 - src/sdl/mixer_sound.c | 5 ++++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ab3201c5c..a58aff3fe 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3955,6 +3955,7 @@ static void Command_RestartAudio_f(void) return; S_StopMusic(); + S_StopSounds(); I_ShutdownMusic(); I_ShutdownSound(); I_StartupSound(); diff --git a/src/m_menu.c b/src/m_menu.c index 63794c529..c9adbfb9c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6953,7 +6953,6 @@ static void M_ToggleSFX(void) if (sound_disabled) { sound_disabled = false; - I_StartupSound(); S_InitSfxChannels(cv_soundvolume.value); S_StartSound(NULL, sfx_strpst); M_StartMessage(M_GetText("SFX Enabled\n"), NULL, MM_NOTHING); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index f39d375ef..72217482f 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -82,7 +82,10 @@ void I_StartupSound(void) // EE inits audio first so we're following along. if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO) - CONS_Printf("SDL Audio already started\n"); + { + CONS_Debug(DBG_DETAILED, "SDL Audio already started\n"); + return; + } else if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { CONS_Alert(CONS_ERROR, "Error initializing SDL Audio: %s\n", SDL_GetError()); From fdbe3e80f6eac3659093a79f8dabfb92df0b1c10 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 17:07:13 -0400 Subject: [PATCH 292/573] Fix compile errors on buildbots * Check SDL Mixer 2.0.3 for MUS_MODPLUG_UNUSED, MUS_MP3_MAD_UNUSED * Mixed D+C in I_LoadSong --- src/sdl/mixer_sound.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 72217482f..d496aa666 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -501,9 +501,17 @@ musictype_t I_SongType(void) return MU_NONE; else if (Mix_GetMusicType(music) == MUS_MID) return MU_MID; - else if (Mix_GetMusicType(music) == MUS_MOD || Mix_GetMusicType(music) == MUS_MODPLUG_UNUSED) + else if (Mix_GetMusicType(music) == MUS_MOD +#if SDL_MIXER_VERSION_ATLEAST(2,0,3) + || Mix_GetMusicType(music) == MUS_MODPLUG_UNUSED +#endif + ) return MU_MOD; - else if (Mix_GetMusicType(music) == MUS_MP3 || Mix_GetMusicType(music) == MUS_MP3_MAD_UNUSED) + else if (Mix_GetMusicType(music) == MUS_MP3 +#if SDL_MIXER_VERSION_ATLEAST(2,0,3) + || Mix_GetMusicType(music) == MUS_MP3_MAD_UNUSED +#endif + ) return MU_MP3; else return (musictype_t)Mix_GetMusicType(music); @@ -552,6 +560,14 @@ boolean I_SetSongSpeed(float speed) boolean I_LoadSong(char *data, size_t len) { + const char *key1 = "LOOP"; + const char *key2 = "POINT="; + const char *key3 = "MS="; + const size_t key1len = strlen(key1); + const size_t key2len = strlen(key2); + const size_t key3len = strlen(key3); + char *p = data; + if (music || gme) I_UnloadSong(); @@ -660,13 +676,6 @@ boolean I_LoadSong(char *data, size_t len) // Find the OGG loop point. loop_point = 0.0f; - const char *key1 = "LOOP"; - const char *key2 = "POINT="; - const char *key3 = "MS="; - const size_t key1len = strlen(key1); - const size_t key2len = strlen(key2); - const size_t key3len = strlen(key3); - char *p = data; while ((UINT32)(p - data) < len) { if (strncmp(p++, key1, key1len)) From 17ec5d80220b472fe827e5e87b5c05f083a3cd24 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 17:27:00 -0400 Subject: [PATCH 293/573] Mixer: Better MODPLUG/MP3_MAD defines (cherry picked from commit 5b724e18b5268b0492b3f8b8980aadd2dd41e235) --- src/sdl/mixer_sound.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index d496aa666..e46da2755 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -34,6 +34,12 @@ (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) #endif +// thanks alam for making the buildbots happy! +#if SDL_MIXER_VERSION_ATLEAST(2,0,3) +#define MUS_MP3_MAD MUS_MP3_MAD_UNUSED +#define MUS_MODPLUG MUS_MODPLUG_UNUSED +#endif + #ifdef HAVE_LIBGME #include "gme/gme.h" #define GME_TREBLE 5.0 @@ -501,17 +507,9 @@ musictype_t I_SongType(void) return MU_NONE; else if (Mix_GetMusicType(music) == MUS_MID) return MU_MID; - else if (Mix_GetMusicType(music) == MUS_MOD -#if SDL_MIXER_VERSION_ATLEAST(2,0,3) - || Mix_GetMusicType(music) == MUS_MODPLUG_UNUSED -#endif - ) + else if (Mix_GetMusicType(music) == MUS_MOD || Mix_GetMusicType(music) == MUS_MODPLUG) return MU_MOD; - else if (Mix_GetMusicType(music) == MUS_MP3 -#if SDL_MIXER_VERSION_ATLEAST(2,0,3) - || Mix_GetMusicType(music) == MUS_MP3_MAD_UNUSED -#endif - ) + else if (Mix_GetMusicType(music) == MUS_MP3 || Mix_GetMusicType(music) == MUS_MP3_MAD) return MU_MP3; else return (musictype_t)Mix_GetMusicType(music); From 9a5eb024590d5b98afa878a6ebd49eef4fcb28ed Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 17:47:04 -0400 Subject: [PATCH 294/573] Fix Windows buildbot for MP3_MAD/MODPLUG define (the header we use is 2.0.2) --- src/sdl/mixer_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index e46da2755..7d11c32c6 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -35,7 +35,7 @@ #endif // thanks alam for making the buildbots happy! -#if SDL_MIXER_VERSION_ATLEAST(2,0,3) +#if SDL_MIXER_VERSION_ATLEAST(2,0,2) #define MUS_MP3_MAD MUS_MP3_MAD_UNUSED #define MUS_MODPLUG MUS_MODPLUG_UNUSED #endif From f85d1da54f700cfc88b1a4bcc56260c8141584a5 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 21:42:52 -0400 Subject: [PATCH 295/573] Lua support for floorrover/ceilingrover --- src/lua_mobjlib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 6efbeff8e..da0e99ab2 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -40,6 +40,8 @@ enum mobj_e { mobj_subsector, mobj_floorz, mobj_ceilingz, + mobj_floorrover, + mobj_ceilingrover, mobj_radius, mobj_height, mobj_momx, @@ -100,6 +102,8 @@ static const char *const mobj_opt[] = { "subsector", "floorz", "ceilingz", + "floorrover", + "ceilingrover", "radius", "height", "momx", @@ -208,6 +212,12 @@ static int mobj_get(lua_State *L) case mobj_ceilingz: lua_pushfixed(L, mo->ceilingz); break; + case mobj_floorrover: + LUA_PushUserdata(L, mo->floorrover, META_FFLOOR); + break; + case mobj_ceilingrover: + LUA_PushUserdata(L, mo->ceilingrover, META_FFLOOR); + break; case mobj_radius: lua_pushfixed(L, mo->radius); break; @@ -432,6 +442,10 @@ static int mobj_set(lua_State *L) return NOSETPOS; case mobj_ceilingz: return NOSETPOS; + case mobj_floorrover: + return NOSET; + case mobj_ceilingrover: + return NOSET; case mobj_radius: { mobj_t *ptmthing = tmthing; From 2f995f4cbeed00a5fb3646a4be8a086d0609fb5a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 22:35:08 -0400 Subject: [PATCH 296/573] Remove possibly wrong comment about extracolormap_t->fog --- src/r_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_defs.h b/src/r_defs.h index b9c6fd7dc..e1c1d45c2 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -53,7 +53,7 @@ typedef UINT8 lighttable_t; typedef struct extracolormap_s { UINT8 fadestart, fadeend; - UINT8 fog; // 1 = disable sprite fullbright, 2 = force planes fullbright, see public gitlab !268 + UINT8 fog; // categorical value, not boolean // store rgba values in combined bitwise // also used in OpenGL instead lighttables From 40a8c9c1ee4fc30e82a8ce3d84d309152a07a5a2 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 00:34:55 -0400 Subject: [PATCH 297/573] Mixer: HAVE_LIBGME ifdef in I_LoadSong --- src/sdl/mixer_sound.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 7d11c32c6..87f8fd671 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -566,7 +566,11 @@ boolean I_LoadSong(char *data, size_t len) const size_t key3len = strlen(key3); char *p = data; - if (music || gme) + if (music +#ifdef HAVE_LIBGME + || gme +#endif + ) I_UnloadSong(); #ifdef HAVE_LIBGME From 57959522e20b0bce603fa51ff1d9f76abf30dafe Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 00:48:34 -0400 Subject: [PATCH 298/573] Colormap overhaul r_data: Mixed D+C fix --- src/r_data.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index f1cd519e0..ce0213b36 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1905,6 +1905,8 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable) { + INT16 red, green, blue, alpha; + // exc_augend is added (or subtracted) onto by exc_addend // In Rennaisance times, the first number was considered the augend, the second number the addend // But since the commutative property was discovered, today they're both called addends! @@ -1914,8 +1916,6 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex if(!exc_addend) exc_addend = R_GetDefaultColormap(); - INT16 red, green, blue, alpha; - /////////////////// // base rgba /////////////////// From 1db8aee539dea8942dafa30a8281f29f2d8704c8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 00:51:55 -0400 Subject: [PATCH 299/573] 455: Mixed D+C fix --- src/p_spec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 88a046b37..a408b2140 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7484,6 +7484,8 @@ static void P_ResetColormapFader(sector_t *sector) static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, extracolormap_t *dest_exc, boolean ticbased, INT32 duration) { + fadecolormap_t *d; + P_ResetColormapFader(sector); // nothing to do, set immediately @@ -7493,7 +7495,7 @@ static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, ext return; } - fadecolormap_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); + d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); d->thinker.function.acp1 = (actionf_p1)T_FadeColormap; d->sector = sector; d->source_exc = source_exc; From ca4a94eca5ae9517b4d0d055d4a879b3dc45911e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 00:56:27 -0400 Subject: [PATCH 300/573] 492: Mixed D+C fix --- src/p_spec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 0502b5638..2583c24f3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1272,6 +1272,7 @@ static boolean PolyFade(line_t *line) { INT32 polyObjNum = line->tag; polyobj_t *po; + polyfadedata_t pfd; if (!(po = Polyobj_GetForNum(polyObjNum))) { @@ -1283,8 +1284,6 @@ static boolean PolyFade(line_t *line) if (po->isBad) return 0; - polyfadedata_t pfd; - pfd.polyObjNum = polyObjNum; // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset From 5585edf4599efccfafb3d5ae93c2b91466d0adf2 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 01:04:15 -0400 Subject: [PATCH 301/573] 453: Mixed D+C fixes; unused param cast in P_FadeFakeFloor --- src/p_saveg.c | 3 ++- src/p_spec.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 5b1cc5b27..7d6215643 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2621,6 +2621,7 @@ static inline void LoadDisappearThinker(actionf_p1 thinker) // static inline void LoadFadeThinker(actionf_p1 thinker) { + sector_t *ss; fade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->dest_exc = LoadExtraColormap(save_p); @@ -2641,7 +2642,7 @@ static inline void LoadFadeThinker(actionf_p1 thinker) ht->doghostfade = READUINT8(save_p); ht->exactalpha = READUINT8(save_p); - sector_t *ss = LoadSector(ht->sectornum); + ss = LoadSector(ht->sectornum); if (ss) { size_t j = 0; // ss->ffloors is saved as ffloor #0, ss->ffloors->next is #1, etc diff --git a/src/p_spec.c b/src/p_spec.c index 87146ab54..30eb393dd 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7574,6 +7574,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destval boolean stillfading = false; INT32 alpha; fade_t *fadingdata = (fade_t *)rover->fadingdata; + (void)docolormap; // *shrug* maybe we can use this in the future. For now, let's be consistent with our other function params if (rover->master->special == 258) // Laser block return false; @@ -7832,6 +7833,8 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor boolean doexists, boolean dotranslucent, boolean dolighting, boolean docolormap, boolean docollision, boolean doghostfade, boolean exactalpha) { + fade_t *d; + // If fading an invisible FOF whose render flags we did not yet set, // initialize its alpha to 1 if (dotranslucent && @@ -7845,7 +7848,7 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor if (rover->alpha == max(1, min(256, relative ? rover->alpha + destvalue : destvalue))) return; - fade_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); + d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); d->thinker.function.acp1 = (actionf_p1)T_Fade; d->rover = rover; From 6844ed37c5ae95dfb7294eaaaf84538cf45e6f27 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 01:47:56 -0400 Subject: [PATCH 302/573] Colormap overhaul: %d format size_t -> UINT32 fix --- src/p_saveg.c | 5 ++--- src/r_data.c | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 2d39ccfa2..f9841717e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -494,7 +494,6 @@ static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) static extracolormap_t *LoadExtraColormap(UINT8 *get) { extracolormap_t *exc, *exc_exist; - //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), fadeend = READUINT8(get), @@ -515,8 +514,8 @@ static extracolormap_t *LoadExtraColormap(UINT8 *get) if (!exc) { // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + // R_GetRgbaR(rgba), R_GetRgbaG(rgba), R_GetRgbaB(rgba), R_GetRgbaA(rgba), + // R_GetRgbaR(fadergba), R_GetRgbaG(fadergba), R_GetRgbaB(fadergba), R_GetRgbaA(fadergba)); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); diff --git a/src/r_data.c b/src/r_data.c index ce0213b36..cfc1a734e 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1510,7 +1510,7 @@ extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 #endif { extracolormap_t *exc; - size_t dbg_i = 0; + UINT32 dbg_i = 0; for (exc = extra_colormaps; exc; exc = exc->next) { @@ -1525,8 +1525,8 @@ extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 ) { CONS_Debug(DBG_RENDER, "Found Colormap %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + dbg_i, R_GetRgbaR(rgba), R_GetRgbaG(rgba), R_GetRgbaB(rgba), R_GetRgbaA(rgba), + R_GetRgbaR(fadergba), R_GetRgbaG(fadergba), R_GetRgbaB(fadergba), R_GetRgbaA(fadergba)); return exc; } dbg_i++; From efe0af960dd2d084f5a9ec8e9c56eda67ca57a65 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 02:10:17 -0400 Subject: [PATCH 303/573] Colormap overhaul: Wrap R_CheckNumForNameList under ifdef EXTRACOLORMAPLUMPS --- src/r_data.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index cfc1a734e..08e3d91b6 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1144,6 +1144,10 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex) Z_Free((void *)texturesText); } +#ifdef EXTRACOLORMAPLUMPS +static lumplist_t *colormaplumps = NULL; ///\todo free leak +static size_t numcolormaplumps = 0; + static inline lumpnum_t R_CheckNumForNameList(const char *name, lumplist_t *list, size_t listsize) { size_t i; @@ -1160,10 +1164,6 @@ static inline lumpnum_t R_CheckNumForNameList(const char *name, lumplist_t *list return LUMPERROR; } -#ifdef EXTRACOLORMAPLUMPS -static lumplist_t *colormaplumps = NULL; ///\todo free leak -static size_t numcolormaplumps = 0; - static void R_InitExtraColormaps(void) { lumpnum_t startnum, endnum; From a85953a9038c4aa3c7ad6237166962e64ae98601 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 02:15:37 -0400 Subject: [PATCH 304/573] 453: P_ResetFakeFloorFader stray & address if condition --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 30eb393dd..bb464c0dc 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7534,7 +7534,7 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz // find any existing thinkers and remove them, then replace with new data if (fadingdata != data) { - if (&fadingdata->thinker) + if (fadingdata->thinker) { if (finalize) P_FadeFakeFloor(rover, From 809646e7fe36ce05d388b59b0fbdb4011d9a7f47 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 02:24:44 -0400 Subject: [PATCH 305/573] 453: Try ResetFakeFloorFader if condition again --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index bb464c0dc..8cbe2e369 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7534,7 +7534,7 @@ static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finaliz // find any existing thinkers and remove them, then replace with new data if (fadingdata != data) { - if (fadingdata->thinker) + if (fadingdata) { if (finalize) P_FadeFakeFloor(rover, From ab4a825385bee6aa3fd4577d4744e3e1e1830134 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 19:00:50 -0400 Subject: [PATCH 306/573] 420: Combine speed and duration logic for fade lighting --- src/p_lights.c | 61 ++++++++++++++------------------------------------ src/p_saveg.c | 4 ++-- src/p_spec.h | 4 ++-- 3 files changed, 21 insertions(+), 48 deletions(-) diff --git a/src/p_lights.c b/src/p_lights.c index 8bcdd8ce0..6eb9b02ca 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -13,6 +13,7 @@ /// Fire flicker, light flash, strobe flash, lightning flash, glow, and fade. #include "doomdef.h" +#include "doomstat.h" #include "p_local.h" #include "r_state.h" #include "z_zone.h" @@ -327,7 +328,8 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, * * \param sector Target sector * \param destvalue The final light value in these sectors. - * \param speed Speed of the fade; the change to the ligh + * \param speed If tic-based: total duration of effect. + * If speed-based: Speed of the fade; the change to the ligh * level in each sector per tic. * \param ticbased Use a specific duration for the fade, defined by speed * \sa T_LightFade @@ -357,13 +359,13 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean if (ticbased) { ll->ticbased = true; - ll->timer = ll->speed = abs(speed); // use ll->speed for total duration + ll->timer = ll->duration = abs(speed); // speed means duration } else { ll->ticbased = false; - ll->timer = -1; - ll->speed = abs(speed); + ll->timer = abs(ll->destlevel - ll->sourcelevel); + ll->duration = abs(speed); // ll->duration is used as speed } } @@ -382,49 +384,20 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) */ void T_LightFade(lightlevel_t *ll) { - if (ll->ticbased) + if ((ll->ticbased && --ll->timer <= 0) + || (!ll->ticbased && (ll->timer -= ll->duration) <= 0)) { - if (--ll->timer <= 0) - { - ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - { - INT16 delta = abs(ll->destlevel - ll->sourcelevel); - fixed_t factor = min(FixedDiv(ll->speed - ll->timer, ll->speed), 1*FRACUNIT); - if (ll->destlevel < ll->sourcelevel) - ll->sector->lightlevel = max(min(ll->sector->lightlevel, ll->sourcelevel - (INT16)FixedMul(delta, factor)), ll->destlevel); - else if (ll->destlevel > ll->sourcelevel) - ll->sector->lightlevel = min(max(ll->sector->lightlevel, ll->sourcelevel + (INT16)FixedMul(delta, factor)), ll->destlevel); - } - return; - } - - if (ll->sector->lightlevel < ll->destlevel) - { - // increase the lightlevel - if (ll->sector->lightlevel + ll->speed >= ll->destlevel) - { - // stop changing light level - ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel - - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - ll->sector->lightlevel += ll->speed; // move lightlevel + ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel + P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } else { - // decrease lightlevel - if (ll->sector->lightlevel - ll->speed <= ll->destlevel) - { - // stop changing light level - ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel - - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - ll->sector->lightlevel -= ll->speed; // move lightlevel + INT16 delta = abs(ll->destlevel - ll->sourcelevel); + INT32 duration = ll->ticbased ? ll->duration : delta; // speed-based: timer's initial value is equal to delta + fixed_t factor = min(FixedDiv(duration - ll->timer, duration), 1*FRACUNIT); + if (ll->destlevel < ll->sourcelevel) + ll->sector->lightlevel = max(min(ll->sector->lightlevel, ll->sourcelevel - (INT16)FixedMul(delta, factor)), ll->destlevel); + else if (ll->destlevel > ll->sourcelevel) + ll->sector->lightlevel = min(max(ll->sector->lightlevel, ll->sourcelevel + (INT16)FixedMul(delta, factor)), ll->destlevel); } } diff --git a/src/p_saveg.c b/src/p_saveg.c index 574f871bb..b2d430d1e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1561,8 +1561,8 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, SaveSector(ht->sector)); WRITEINT16(save_p, ht->sourcelevel); WRITEINT16(save_p, ht->destlevel); - WRITEINT16(save_p, ht->speed); WRITEUINT8(save_p, (UINT8)ht->ticbased); + WRITEINT16(save_p, ht->duration); WRITEINT32(save_p, ht->timer); } @@ -2537,8 +2537,8 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) ht->sector = LoadSector(READUINT32(save_p)); ht->sourcelevel = READINT16(save_p); ht->destlevel = READINT16(save_p); - ht->speed = READINT16(save_p); ht->ticbased = (boolean)READUINT8(save_p); + ht->duration = READINT16(save_p); ht->timer = READINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; diff --git a/src/p_spec.h b/src/p_spec.h index 69087d6c4..daa6dd18a 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -138,11 +138,11 @@ typedef struct sector_t *sector; ///< Sector where action is taking place. INT16 sourcelevel; ///< Light level we're fading from. INT16 destlevel; ///< Light level we're fading to. - INT16 speed; ///< Speed at which to change light level. OR: Tic-based duration // Tic-based behavior boolean ticbased; ///< Tic-based logic - INT32 timer; ///< Tic-based timer + INT16 duration; ///< If tic-based: duration of effect. If speed-based: amount to increment + INT32 timer; ///< Internal timer } lightlevel_t; #define GLOWSPEED 8 From d939e597a5a5fa5a8e89c34edfcc12cce6e3fc2e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 20:03:43 -0400 Subject: [PATCH 307/573] 420: Unncessary include --- src/p_lights.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_lights.c b/src/p_lights.c index 6eb9b02ca..e4d7ebe9d 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -13,7 +13,6 @@ /// Fire flicker, light flash, strobe flash, lightning flash, glow, and fade. #include "doomdef.h" -#include "doomstat.h" #include "p_local.h" #include "r_state.h" #include "z_zone.h" From 350cd1435b55449a0ed9b6feee21cd8ba289fd19 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 15 Sep 2018 12:21:25 +0200 Subject: [PATCH 308/573] The thinker is entirely unified now, and there is no difference in the light levels between the "old" behavior and this one now. --- src/p_lights.c | 33 ++++++++++++++++----------------- src/p_saveg.c | 8 ++++---- src/p_spec.h | 16 ++++++++-------- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/p_lights.c b/src/p_lights.c index e4d7ebe9d..00c0e960f 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -355,17 +355,21 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ll->sourcelevel = sector->lightlevel; ll->destlevel = destvalue; + ll->fixedcurlevel = sector->lightlevel<ticbased = true; - ll->timer = ll->duration = abs(speed); // speed means duration + // Speed means duration. + ll->timer = abs(speed); + ll->fixedpertic = FixedDiv((destvalue<fixedcurlevel, speed<ticbased = false; - ll->timer = abs(ll->destlevel - ll->sourcelevel); - ll->duration = abs(speed); // ll->duration is used as speed + // Speed means increment per tic (literally speed). + ll->timer = FixedDiv((destvalue<fixedcurlevel, speed<>FRACBITS; + ll->fixedpertic = speed<sector->lightlevel, destvalue, ll->fixedpertic>>FRACBITS, ll->timer); } void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) @@ -383,20 +387,15 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) */ void T_LightFade(lightlevel_t *ll) { - if ((ll->ticbased && --ll->timer <= 0) - || (!ll->ticbased && (ll->timer -= ll->duration) <= 0)) + if (--ll->timer <= 0) { ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker + CONS_Printf("End tic, final light value: %d\n", ll->sector->lightlevel); + return; } - else - { - INT16 delta = abs(ll->destlevel - ll->sourcelevel); - INT32 duration = ll->ticbased ? ll->duration : delta; // speed-based: timer's initial value is equal to delta - fixed_t factor = min(FixedDiv(duration - ll->timer, duration), 1*FRACUNIT); - if (ll->destlevel < ll->sourcelevel) - ll->sector->lightlevel = max(min(ll->sector->lightlevel, ll->sourcelevel - (INT16)FixedMul(delta, factor)), ll->destlevel); - else if (ll->destlevel > ll->sourcelevel) - ll->sector->lightlevel = min(max(ll->sector->lightlevel, ll->sourcelevel + (INT16)FixedMul(delta, factor)), ll->destlevel); - } + + ll->fixedcurlevel = ll->fixedcurlevel + ll->fixedpertic; + ll->sector->lightlevel = (ll->fixedcurlevel)>>FRACBITS; + CONS_Printf("Light %d\n", ll->sector->lightlevel); } diff --git a/src/p_saveg.c b/src/p_saveg.c index b2d430d1e..c95a08361 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1561,8 +1561,8 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, SaveSector(ht->sector)); WRITEINT16(save_p, ht->sourcelevel); WRITEINT16(save_p, ht->destlevel); - WRITEUINT8(save_p, (UINT8)ht->ticbased); - WRITEINT16(save_p, ht->duration); + WRITEFIXED(save_p, ht->fixedcurlevel); + WRITEFIXED(save_p, ht->fixedpertic); WRITEINT32(save_p, ht->timer); } @@ -2537,8 +2537,8 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) ht->sector = LoadSector(READUINT32(save_p)); ht->sourcelevel = READINT16(save_p); ht->destlevel = READINT16(save_p); - ht->ticbased = (boolean)READUINT8(save_p); - ht->duration = READINT16(save_p); + ht->fixedcurlevel = READFIXED(save_p); + ht->fixedpertic = READFIXED(save_p); ht->timer = READINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; diff --git a/src/p_spec.h b/src/p_spec.h index daa6dd18a..2c9e986ce 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -134,15 +134,15 @@ typedef struct */ typedef struct { - thinker_t thinker; ///< Thinker in use for the effect. - sector_t *sector; ///< Sector where action is taking place. - INT16 sourcelevel; ///< Light level we're fading from. - INT16 destlevel; ///< Light level we're fading to. + thinker_t thinker; ///< Thinker in use for the effect. + sector_t *sector; ///< Sector where action is taking place. + INT16 sourcelevel; ///< Light level we're fading from. + INT16 destlevel; ///< Light level we're fading to. - // Tic-based behavior - boolean ticbased; ///< Tic-based logic - INT16 duration; ///< If tic-based: duration of effect. If speed-based: amount to increment - INT32 timer; ///< Internal timer + fixed_t fixedcurlevel; ///< Fixed point for current light level. + fixed_t fixedpertic; ///< Fixed point for increment per tic. + // The reason for those two above to be fixed point is to deal with decimal values that would otherwise get trimmed away. + INT32 timer; ///< Internal timer. } lightlevel_t; #define GLOWSPEED 8 From 17e23f55eb700a28d19029e6b5a4938acdd21473 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 20:00:04 -0400 Subject: [PATCH 309/573] 492: Merge speed and duration logic for fade polyobject --- src/p_polyobj.c | 68 ++++++++++++++++--------------------------------- src/p_polyobj.h | 2 +- src/p_saveg.c | 4 +-- 3 files changed, 25 insertions(+), 49 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index f7545e5bd..bbcf4f42a 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2873,54 +2873,29 @@ void T_PolyObjFade(polyfade_t *th) if (po->thinker == NULL) po->thinker = &th->thinker; - if (th->ticbased) + stillfading = th->ticbased ? !(--(th->timer) <= 0) + : !((th->timer -= th->duration) <= 0); + + if (th->timer <= 0) { - stillfading = !(--(th->timer) <= 0); + po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); - if (th->timer <= 0) - { - po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); - - // remove thinker - if (po->thinker == &th->thinker) - po->thinker = NULL; - P_RemoveThinker(&th->thinker); - } - else - { - INT16 delta = abs(th->destvalue - th->sourcevalue); - fixed_t factor = min(FixedDiv(th->speed - th->timer, th->speed), 1*FRACUNIT); - if (th->destvalue < th->sourcevalue) - po->translucency = max(min(po->translucency, th->sourcevalue - (INT16)FixedMul(delta, factor)), th->destvalue); - else if (th->destvalue > th->sourcevalue) - po->translucency = min(max(po->translucency, th->sourcevalue + (INT16)FixedMul(delta, factor)), th->destvalue); - } + // remove thinker + if (po->thinker == &th->thinker) + po->thinker = NULL; + P_RemoveThinker(&th->thinker); } else { - fixed_t timerdest = FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS-th->destvalue); - - if (th->destvalue > th->sourcevalue) // fading out, destvalue is higher - { - // for timer, lower is transparent, higher is opaque - stillfading = (th->timer > timerdest); - th->timer = max(timerdest, th->timer - th->speed); - } - else if (th->destvalue < th->sourcevalue) // fading in, destvalue is lower - { stillfading = (th->timer < timerdest); - th->timer = min(timerdest, th->timer + th->speed); - } - - if (!stillfading) - { - po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); - // remove thinker - if (po->thinker == &th->thinker) - po->thinker = NULL; - P_RemoveThinker(&th->thinker); - } - else - po->translucency = FixedDiv(256-th->timer, FixedDiv(256, NUMTRANSMAPS)); + INT16 delta = abs(th->destvalue - th->sourcevalue); + INT32 duration = th->ticbased ? th->duration + : abs(FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->destvalue) + - FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->sourcevalue)); // speed-based internal counter duration: delta in 256 scale + fixed_t factor = min(FixedDiv(duration - th->timer, duration), 1*FRACUNIT); + if (th->destvalue < th->sourcevalue) + po->translucency = max(min(po->translucency, th->sourcevalue - (INT16)FixedMul(delta, factor)), th->destvalue); + else if (th->destvalue > th->sourcevalue) + po->translucency = min(max(po->translucency, th->sourcevalue + (INT16)FixedMul(delta, factor)), th->destvalue); } if (!stillfading) @@ -3010,13 +2985,14 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) if (pfdata->ticbased) { th->ticbased = true; - th->timer = th->speed = abs(pfdata->speed); // use th->speed for total duration + th->timer = th->duration = abs(pfdata->speed); // pfdata->speed is duration } else { th->ticbased = false; - th->timer = FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - po->translucency); // use as internal counter - th->speed = pfdata->speed; + th->timer = abs(FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->destvalue) + - FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->sourcevalue)); // delta converted to 256 scale, use as internal counter + th->duration = abs(pfdata->speed); // use th->duration as speed decrement } oldpo = po; diff --git a/src/p_polyobj.h b/src/p_polyobj.h index 61404112c..524518f2a 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -217,8 +217,8 @@ typedef struct polyfade_s boolean docollision; boolean doghostfade; boolean ticbased; + INT32 duration; INT32 timer; - INT32 speed; } polyfade_t; // diff --git a/src/p_saveg.c b/src/p_saveg.c index 2bfc5859a..11c481be8 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1710,8 +1710,8 @@ static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type) WRITEUINT8(save_p, (UINT8)ht->docollision); WRITEUINT8(save_p, (UINT8)ht->doghostfade); WRITEUINT8(save_p, (UINT8)ht->ticbased); + WRITEINT32(save_p, ht->duration); WRITEINT32(save_p, ht->timer); - WRITEINT32(save_p, ht->speed); } #endif @@ -2725,8 +2725,8 @@ static void LoadPolyfadeThinker(actionf_p1 thinker) ht->docollision = (boolean)READUINT8(save_p); ht->doghostfade = (boolean)READUINT8(save_p); ht->ticbased = (boolean)READUINT8(save_p); + ht->duration = READINT32(save_p); ht->timer = READINT32(save_p); - ht->speed = READINT32(save_p); P_AddThinker(&ht->thinker); } #endif From 1321ab9d927868a565af6f0d0be1c31c5d023722 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 20:34:19 -0400 Subject: [PATCH 310/573] 453: Extra parameter for Add_ColormapFader --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 8cbe2e369..b5607e2b2 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7945,7 +7945,7 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor Z_Free(exc); } - Add_ColormapFader(§ors[rover->secnum], source_exc, d->dest_exc, + Add_ColormapFader(§ors[rover->secnum], source_exc, d->dest_exc, true, ticbased ? d->timer : FixedFloor(FixedDiv(abs(d->destvalue - d->alpha), d->speed))/FRACUNIT); } From d49f0be4ee11b57678c8ef1230063463d6c0c432 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 16 Sep 2018 08:20:14 -0400 Subject: [PATCH 311/573] 420: Strip test comments --- src/p_lights.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_lights.c b/src/p_lights.c index 00c0e960f..2ea93b796 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -369,7 +369,6 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ll->timer = FixedDiv((destvalue<fixedcurlevel, speed<>FRACBITS; ll->fixedpertic = speed<sector->lightlevel, destvalue, ll->fixedpertic>>FRACBITS, ll->timer); } void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) @@ -391,11 +390,9 @@ void T_LightFade(lightlevel_t *ll) { ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - CONS_Printf("End tic, final light value: %d\n", ll->sector->lightlevel); return; } ll->fixedcurlevel = ll->fixedcurlevel + ll->fixedpertic; ll->sector->lightlevel = (ll->fixedcurlevel)>>FRACBITS; - CONS_Printf("Light %d\n", ll->sector->lightlevel); } From 1b7b1f3f796eb08385f86e817b4486ec3a25361a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 16 Sep 2018 20:25:07 +0100 Subject: [PATCH 312/573] Fix order of operations messups by adding brackets --- src/m_anigif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index d46d889bb..e2af70095 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -492,7 +492,7 @@ static void GIF_framewrite(void) // screen regions are handled in GIF_lzw { - int d1 = (int)((100.0/NEWTICRATE)*gif_frames+1); + int d1 = (int)((100.0/NEWTICRATE)*(gif_frames+1)); int d2 = (int)((100.0/NEWTICRATE)*(gif_frames)); UINT16 delay = d1-d2; INT32 startline; From 4cdbc7249ff5a6af8d1b01994950359b16554c73 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 16 Sep 2018 20:02:29 -0400 Subject: [PATCH 313/573] Streamlined colormap netsyncing so duplicates are not saved to $$$.sav per sector --- src/p_saveg.c | 196 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 155 insertions(+), 41 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index f9841717e..a63ef1276 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -474,50 +474,144 @@ static void P_NetUnArchivePlayers(void) } } -static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) +/// +/// Colormaps +/// + +static extracolormap_t *net_colormaps = NULL; +static UINT32 num_net_colormaps = 0; + +// Copypasta from r_data.c AddColormapToList +// But also check for equality and return the matching index +static UINT32 CheckAddNetColormapToList(extracolormap_t *extra_colormap) { - if (!exc) // Just give it default values, we done goofed. (or sector->extra_colormap was intentionally set to default (NULL)) - exc = R_GetDefaultColormap(); + extracolormap_t *exc; + UINT32 i = 0; - WRITEUINT8(put, exc->fadestart); - WRITEUINT8(put, exc->fadeend); - WRITEUINT8(put, exc->fog); + if (!net_colormaps) + { + net_colormaps = extra_colormap; + net_colormaps->next = 0; + net_colormaps->prev = 0; + return i; + } - WRITEINT32(put, exc->rgba); - WRITEINT32(put, exc->fadergba); + for (exc = net_colormaps; exc->next; exc = exc->next) + { + if (R_CheckEqualColormaps(exc, extra_colormap, true, true, true)) + return i; + i++; + } -#ifdef EXTRACOLORMAPLUMPS - WRITESTRINGN(put, exc->lumpname, 9); -#endif + exc->next = extra_colormap; + extra_colormap->prev = exc; + extra_colormap->next = 0; + + num_net_colormaps = i; + return i; } -static extracolormap_t *LoadExtraColormap(UINT8 *get) +static extracolormap_t *GetNetColormapFromList(UINT32 index) { - extracolormap_t *exc, *exc_exist; + // For loading, we have to be tricky: + // We load the sectors BEFORE knowing the colormap values + // So if an index doesn't exist, fill our list with dummy colormaps + // until we get the index we want + // Then when we load the color data, we set up the dummy colormaps - UINT8 fadestart = READUINT8(get), - fadeend = READUINT8(get), - fog = READUINT8(get); + extracolormap_t *exc, *last_exc = NULL; + UINT32 i = 0; - INT32 rgba = READINT32(get), - fadergba = READINT32(get); + for (exc = net_colormaps; exc; last_exc = exc, exc = exc->next) + { + if (i++ == index) + return exc; + } + + // our index doesn't exist, so just make the entry + for (; i <= index && i < num_net_colormaps; i++) + { + exc = R_CreateDefaultColormap(false); + if (last_exc) + last_exc->next = exc; + exc->prev = last_exc; + exc->next = NULL; + last_exc = exc; + } + return exc; +} + +static void ClearNetColormaps(void) +{ + // We're actually Z_Freeing each entry here, + // so don't call this in P_NetUnArchiveColormaps (where entries will be used in-game) + extracolormap_t *exc, *exc_next; + + for (exc = net_colormaps; exc; exc = exc_next) + { + exc_next = exc->next; + Z_Free(exc); + } + num_net_colormaps = 0; + net_colormaps = NULL; +} + +static void P_NetArchiveColormaps() +{ + // We save and then we clean up our colormap mess + extracolormap_t *exc, *exc_next; + + WRITEUINT32(save_p, num_net_colormaps); // save for safety + + for (exc = net_colormaps; exc; exc = exc_next) + { + WRITEUINT8(save_p, exc->fadestart); + WRITEUINT8(save_p, exc->fadeend); + WRITEUINT8(save_p, exc->fog); + + WRITEINT32(save_p, exc->rgba); + WRITEINT32(save_p, exc->fadergba); #ifdef EXTRACOLORMAPLUMPS - char lumpname[9]; - READSTRINGN(get, lumpname, 9); - - if (lumpname[0]) - return R_ColormapForName(lumpname); + WRITESTRINGN(save_p, exc->lumpname, 9); #endif - exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); - if (!exc) + exc_next = exc->next; + Z_Free(exc); // don't need anymore + } + + num_net_colormaps = 0; +} + +static void P_NetUnArchiveColormaps() +{ + // When we reach this point, we already populated our list with + // dummy colormaps. Now that we are loading the color data, + // set up the dummies. + extracolormap_t *exc, *existing_exc; + num_net_colormaps = READUINT32(save_p); + + for (exc = net_colormaps; exc; exc = exc->next) { - // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // R_GetRgbaR(rgba), R_GetRgbaG(rgba), R_GetRgbaB(rgba), R_GetRgbaA(rgba), - // R_GetRgbaR(fadergba), R_GetRgbaG(fadergba), R_GetRgbaB(fadergba), R_GetRgbaA(fadergba)); + UINT8 fadestart = READUINT8(save_p), + fadeend = READUINT8(save_p), + fog = READUINT8(save_p); - exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + INT32 rgba = READINT32(save_p), + fadergba = READINT32(save_p); + +#ifdef EXTRACOLORMAPLUMPS + char lumpname[9]; + READSTRINGN(save_p, lumpname, 9); + + if (lumpname[0]) + { + existing_exc = R_ColormapForName(lumpname); + *exc = *existing_exc; + R_AddColormapToList(exc); // see HACK note below on why we're adding duplicates + continue; + } +#endif exc->fadestart = fadestart; exc->fadeend = fadeend; @@ -531,21 +625,32 @@ static extracolormap_t *LoadExtraColormap(UINT8 *get) exc->lumpname[0] = 0; #endif - if (!(exc_exist = R_GetColormapFromList(exc))) - { - exc->colormap = R_CreateLightTable(exc); - R_AddColormapToList(exc); - } + existing_exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); + + if (existing_exc) + exc->colormap = existing_exc->colormap; else - { - Z_Free(exc); - exc = R_CheckDefaultColormap(exc_exist, true, true, true) ? NULL : exc_exist; - } + // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // R_GetRgbaR(rgba), R_GetRgbaG(rgba), R_GetRgbaB(rgba), R_GetRgbaA(rgba), + // R_GetRgbaR(fadergba), R_GetRgbaG(fadergba), R_GetRgbaB(fadergba), R_GetRgbaA(fadergba)); + exc->colormap = R_CreateLightTable(exc); + + // HACK: If this dummy is a duplicate, we're going to add it + // to the extra_colormaps list anyway. I think this is faster + // than going through every loaded sector and correcting their + // colormap address to the pre-existing one, PER net_colormap entry + R_AddColormapToList(exc); } - return exc; + // Don't need these anymore + num_net_colormaps = 0; + net_colormaps = NULL; } +/// +/// World Archiving +/// + #define SD_FLOORHT 0x01 #define SD_CEILHT 0x02 #define SD_FLOORPIC 0x04 @@ -595,6 +700,9 @@ static void P_NetArchiveWorld(void) const side_t *si; UINT8 *put; + // initialize colormap vars because paranoia + ClearNetColormaps(); + // reload the map just to see difference mapsector_t *ms; mapsidedef_t *msd; @@ -730,7 +838,8 @@ static void P_NetArchiveWorld(void) } if (diff3 & SD_COLORMAP) - SaveExtraColormap(put, ss->extra_colormap); + WRITEUINT32(put, CheckAddNetColormapToList(ss->extra_colormap)); + // returns existing index if already added, or appends to net_colormaps and returns new index // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed @@ -865,6 +974,9 @@ static void P_NetUnArchiveWorld(void) if (READUINT32(save_p) != ARCHIVEBLOCK_WORLD) I_Error("Bad $$$.sav at archive block World"); + // initialize colormap vars because paranoia + ClearNetColormaps(); + get = save_p; for (;;) @@ -927,7 +1039,7 @@ static void P_NetUnArchiveWorld(void) } if (diff3 & SD_COLORMAP) - sectors[i].extra_colormap = LoadExtraColormap(get); + sectors[i].extra_colormap = GetNetColormapFromList(READUINT32(get)); if (diff & SD_FFLOORS) { @@ -3536,6 +3648,7 @@ void P_SaveNetGame(void) #endif P_NetArchiveThinkers(); P_NetArchiveSpecials(); + P_NetArchiveColormaps(); } #ifdef HAVE_BLUA LUA_Archive(); @@ -3578,6 +3691,7 @@ boolean P_LoadNetGame(void) #endif P_NetUnArchiveThinkers(); P_NetUnArchiveSpecials(); + P_NetUnArchiveColormaps(); P_RelinkPointers(); P_FinishMobjs(); } From d4a18fd456749c6d3db6c1055bf2e1972d60c460 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 16 Sep 2018 20:27:24 -0400 Subject: [PATCH 314/573] 455: Fade colormap netsync use new colormap saving --- src/p_saveg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index cea40a4e9..109102dfc 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1795,8 +1795,8 @@ static void SaveFadeColormapThinker(const thinker_t *th, const UINT8 type) const fadecolormap_t *ht = (const void *)th; WRITEUINT8(save_p, type); WRITEUINT32(save_p, SaveSector(ht->sector)); - SaveExtraColormap(save_p, ht->source_exc); - SaveExtraColormap(save_p, ht->dest_exc); + WRITEUINT32(save_p, CheckAddNetColormapToList(ht->source_exc)); + WRITEUINT32(save_p, CheckAddNetColormapToList(ht->dest_exc)); WRITEUINT8(save_p, (UINT8)ht->ticbased); WRITEINT32(save_p, ht->duration); WRITEINT32(save_p, ht->timer); @@ -2795,8 +2795,8 @@ static inline void LoadFadeColormapThinker(actionf_p1 thinker) fadecolormap_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->sector = LoadSector(READUINT32(save_p)); - ht->source_exc = LoadExtraColormap(save_p); - ht->dest_exc = LoadExtraColormap(save_p); + ht->source_exc = GetNetColormapFromList(READUINT32(save_p)); + ht->dest_exc = GetNetColormapFromList(READUINT32(save_p)); ht->ticbased = (boolean)READUINT8(save_p); ht->duration = READINT32(save_p); ht->timer = READINT32(save_p); From 0a998fec02a84981008fad81163d40765d979341 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 16 Sep 2018 22:41:08 -0400 Subject: [PATCH 315/573] New colormap netsync fixes --- src/p_saveg.c | 79 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 109102dfc..517211726 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -485,29 +485,30 @@ static UINT32 num_net_colormaps = 0; // But also check for equality and return the matching index static UINT32 CheckAddNetColormapToList(extracolormap_t *extra_colormap) { - extracolormap_t *exc; + extracolormap_t *exc, *exc_prev; UINT32 i = 0; if (!net_colormaps) { - net_colormaps = extra_colormap; + net_colormaps = R_CopyColormap(extra_colormap, false); net_colormaps->next = 0; net_colormaps->prev = 0; + num_net_colormaps = i+1; return i; } - for (exc = net_colormaps; exc->next; exc = exc->next) + for (exc = net_colormaps; exc; exc_prev = exc, exc = exc->next) { if (R_CheckEqualColormaps(exc, extra_colormap, true, true, true)) return i; i++; } - exc->next = extra_colormap; - extra_colormap->prev = exc; + exc_prev->next = R_CopyColormap(extra_colormap, false); + extra_colormap->prev = exc_prev; extra_colormap->next = 0; - num_net_colormaps = i; + num_net_colormaps = i+1; return i; } @@ -522,14 +523,24 @@ static extracolormap_t *GetNetColormapFromList(UINT32 index) extracolormap_t *exc, *last_exc = NULL; UINT32 i = 0; + if (!net_colormaps) // initialize our list + net_colormaps = R_CreateDefaultColormap(false); + for (exc = net_colormaps; exc; last_exc = exc, exc = exc->next) { if (i++ == index) return exc; } + + // LET'S HOPE that index is a sane value, because we create up to [index] + // entries in net_colormaps. At this point, we don't know + // what the total colormap count is + if (index >= numsectors*3) // if every sector had a unique colormap change AND a fade thinker which has two colormap entries + I_Error("Colormap %d from server is too high for sectors %d", index, numsectors); + // our index doesn't exist, so just make the entry - for (; i <= index && i < num_net_colormaps; i++) + for (; i <= index; i++) { exc = R_CreateDefaultColormap(false); if (last_exc) @@ -556,15 +567,20 @@ static void ClearNetColormaps(void) net_colormaps = NULL; } -static void P_NetArchiveColormaps() +static void P_NetArchiveColormaps(void) { // We save and then we clean up our colormap mess extracolormap_t *exc, *exc_next; - + UINT32 i = 0; WRITEUINT32(save_p, num_net_colormaps); // save for safety - for (exc = net_colormaps; exc; exc = exc_next) + for (exc = net_colormaps; i < num_net_colormaps; i++, exc = exc_next) { + // We must save num_net_colormaps worth of data + // So fill non-existent entries with default. + if (!exc) + exc = R_CreateDefaultColormap(false); + WRITEUINT8(save_p, exc->fadestart); WRITEUINT8(save_p, exc->fadeend); WRITEUINT8(save_p, exc->fog); @@ -581,31 +597,44 @@ static void P_NetArchiveColormaps() } num_net_colormaps = 0; + net_colormaps = NULL; } -static void P_NetUnArchiveColormaps() +static void P_NetUnArchiveColormaps(void) { // When we reach this point, we already populated our list with // dummy colormaps. Now that we are loading the color data, // set up the dummies. - extracolormap_t *exc, *existing_exc; + extracolormap_t *exc, *existing_exc, *exc_next = NULL; num_net_colormaps = READUINT32(save_p); + UINT32 i = 0; - for (exc = net_colormaps; exc; exc = exc->next) + for (exc = net_colormaps; i < num_net_colormaps; i++, exc = exc_next) { - UINT8 fadestart = READUINT8(save_p), - fadeend = READUINT8(save_p), - fog = READUINT8(save_p); - - INT32 rgba = READINT32(save_p), - fadergba = READINT32(save_p); - + UINT8 fadestart, fadeend, fog; + INT32 rgba, fadergba; #ifdef EXTRACOLORMAPLUMPS char lumpname[9]; +#endif + + fadestart = READUINT8(save_p); + fadeend = READUINT8(save_p); + fog = READUINT8(save_p); + + rgba = READINT32(save_p); + fadergba = READINT32(save_p); + +#ifdef EXTRACOLORMAPLUMPS READSTRINGN(save_p, lumpname, 9); if (lumpname[0]) { + if (!exc) + // no point making a new entry since nothing points to it, + // but we needed to read the data so now continue + continue; + + exc_next = exc->next; // this gets overwritten during our operations here, so get it now existing_exc = R_ColormapForName(lumpname); *exc = *existing_exc; R_AddColormapToList(exc); // see HACK note below on why we're adding duplicates @@ -613,6 +642,13 @@ static void P_NetUnArchiveColormaps() } #endif + if (!exc) + // no point making a new entry since nothing points to it, + // but we needed to read the data so now continue + continue; + + exc_next = exc->next; // this gets overwritten during our operations here, so get it now + exc->fadestart = fadestart; exc->fadeend = fadeend; exc->fog = fog; @@ -640,6 +676,9 @@ static void P_NetUnArchiveColormaps() // than going through every loaded sector and correcting their // colormap address to the pre-existing one, PER net_colormap entry R_AddColormapToList(exc); + + if (i < num_net_colormaps-1 && !exc_next) + exc_next = R_CreateDefaultColormap(false); } // Don't need these anymore From 4b55415add356e051d494cd5bc8d36c316f54456 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 16 Sep 2018 22:41:08 -0400 Subject: [PATCH 316/573] New colormap netsync fixes --- src/p_saveg.c | 79 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index a63ef1276..34d08d709 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -485,29 +485,30 @@ static UINT32 num_net_colormaps = 0; // But also check for equality and return the matching index static UINT32 CheckAddNetColormapToList(extracolormap_t *extra_colormap) { - extracolormap_t *exc; + extracolormap_t *exc, *exc_prev; UINT32 i = 0; if (!net_colormaps) { - net_colormaps = extra_colormap; + net_colormaps = R_CopyColormap(extra_colormap, false); net_colormaps->next = 0; net_colormaps->prev = 0; + num_net_colormaps = i+1; return i; } - for (exc = net_colormaps; exc->next; exc = exc->next) + for (exc = net_colormaps; exc; exc_prev = exc, exc = exc->next) { if (R_CheckEqualColormaps(exc, extra_colormap, true, true, true)) return i; i++; } - exc->next = extra_colormap; - extra_colormap->prev = exc; + exc_prev->next = R_CopyColormap(extra_colormap, false); + extra_colormap->prev = exc_prev; extra_colormap->next = 0; - num_net_colormaps = i; + num_net_colormaps = i+1; return i; } @@ -522,14 +523,24 @@ static extracolormap_t *GetNetColormapFromList(UINT32 index) extracolormap_t *exc, *last_exc = NULL; UINT32 i = 0; + if (!net_colormaps) // initialize our list + net_colormaps = R_CreateDefaultColormap(false); + for (exc = net_colormaps; exc; last_exc = exc, exc = exc->next) { if (i++ == index) return exc; } + + // LET'S HOPE that index is a sane value, because we create up to [index] + // entries in net_colormaps. At this point, we don't know + // what the total colormap count is + if (index >= numsectors*3) // if every sector had a unique colormap change AND a fade thinker which has two colormap entries + I_Error("Colormap %d from server is too high for sectors %d", index, numsectors); + // our index doesn't exist, so just make the entry - for (; i <= index && i < num_net_colormaps; i++) + for (; i <= index; i++) { exc = R_CreateDefaultColormap(false); if (last_exc) @@ -556,15 +567,20 @@ static void ClearNetColormaps(void) net_colormaps = NULL; } -static void P_NetArchiveColormaps() +static void P_NetArchiveColormaps(void) { // We save and then we clean up our colormap mess extracolormap_t *exc, *exc_next; - + UINT32 i = 0; WRITEUINT32(save_p, num_net_colormaps); // save for safety - for (exc = net_colormaps; exc; exc = exc_next) + for (exc = net_colormaps; i < num_net_colormaps; i++, exc = exc_next) { + // We must save num_net_colormaps worth of data + // So fill non-existent entries with default. + if (!exc) + exc = R_CreateDefaultColormap(false); + WRITEUINT8(save_p, exc->fadestart); WRITEUINT8(save_p, exc->fadeend); WRITEUINT8(save_p, exc->fog); @@ -581,31 +597,44 @@ static void P_NetArchiveColormaps() } num_net_colormaps = 0; + net_colormaps = NULL; } -static void P_NetUnArchiveColormaps() +static void P_NetUnArchiveColormaps(void) { // When we reach this point, we already populated our list with // dummy colormaps. Now that we are loading the color data, // set up the dummies. - extracolormap_t *exc, *existing_exc; + extracolormap_t *exc, *existing_exc, *exc_next = NULL; num_net_colormaps = READUINT32(save_p); + UINT32 i = 0; - for (exc = net_colormaps; exc; exc = exc->next) + for (exc = net_colormaps; i < num_net_colormaps; i++, exc = exc_next) { - UINT8 fadestart = READUINT8(save_p), - fadeend = READUINT8(save_p), - fog = READUINT8(save_p); - - INT32 rgba = READINT32(save_p), - fadergba = READINT32(save_p); - + UINT8 fadestart, fadeend, fog; + INT32 rgba, fadergba; #ifdef EXTRACOLORMAPLUMPS char lumpname[9]; +#endif + + fadestart = READUINT8(save_p); + fadeend = READUINT8(save_p); + fog = READUINT8(save_p); + + rgba = READINT32(save_p); + fadergba = READINT32(save_p); + +#ifdef EXTRACOLORMAPLUMPS READSTRINGN(save_p, lumpname, 9); if (lumpname[0]) { + if (!exc) + // no point making a new entry since nothing points to it, + // but we needed to read the data so now continue + continue; + + exc_next = exc->next; // this gets overwritten during our operations here, so get it now existing_exc = R_ColormapForName(lumpname); *exc = *existing_exc; R_AddColormapToList(exc); // see HACK note below on why we're adding duplicates @@ -613,6 +642,13 @@ static void P_NetUnArchiveColormaps() } #endif + if (!exc) + // no point making a new entry since nothing points to it, + // but we needed to read the data so now continue + continue; + + exc_next = exc->next; // this gets overwritten during our operations here, so get it now + exc->fadestart = fadestart; exc->fadeend = fadeend; exc->fog = fog; @@ -640,6 +676,9 @@ static void P_NetUnArchiveColormaps() // than going through every loaded sector and correcting their // colormap address to the pre-existing one, PER net_colormap entry R_AddColormapToList(exc); + + if (i < num_net_colormaps-1 && !exc_next) + exc_next = R_CreateDefaultColormap(false); } // Don't need these anymore From f3e1d280d07a234c7070384f6d514fba32085808 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 00:26:58 -0400 Subject: [PATCH 317/573] Colormap netsync: Mixed D+C fixes --- src/p_saveg.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 34d08d709..ec0ef2e7a 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -606,9 +606,10 @@ static void P_NetUnArchiveColormaps(void) // dummy colormaps. Now that we are loading the color data, // set up the dummies. extracolormap_t *exc, *existing_exc, *exc_next = NULL; - num_net_colormaps = READUINT32(save_p); UINT32 i = 0; + num_net_colormaps = READUINT32(save_p); + for (exc = net_colormaps; i < num_net_colormaps; i++, exc = exc_next) { UINT8 fadestart, fadeend, fog; @@ -739,9 +740,6 @@ static void P_NetArchiveWorld(void) const side_t *si; UINT8 *put; - // initialize colormap vars because paranoia - ClearNetColormaps(); - // reload the map just to see difference mapsector_t *ms; mapsidedef_t *msd; @@ -749,6 +747,9 @@ static void P_NetArchiveWorld(void) const sector_t *ss = sectors; UINT8 diff, diff2, diff3; + // initialize colormap vars because paranoia + ClearNetColormaps(); + WRITEUINT32(save_p, ARCHIVEBLOCK_WORLD); put = save_p; From 14339d651d970c9c382443200da62ffc321cf46d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 00:34:03 -0400 Subject: [PATCH 318/573] 453: Use new colormap netsync for fade FOF thinker --- src/p_saveg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index f57b44817..f4f698d4f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1609,7 +1609,7 @@ static void SaveFadeThinker(const thinker_t *th, const UINT8 type) { const fade_t *ht = (const void *)th; WRITEUINT8(save_p, type); - SaveExtraColormap(save_p, ht->dest_exc); + WRITEUINT32(save_p, CheckAddNetColormapToList(ht->dest_exc)); WRITEUINT32(save_p, ht->sectornum); WRITEUINT32(save_p, ht->ffloornum); WRITEINT32(save_p, ht->alpha); @@ -2624,7 +2624,7 @@ static inline void LoadFadeThinker(actionf_p1 thinker) sector_t *ss; fade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; - ht->dest_exc = LoadExtraColormap(save_p); + ht->dest_exc = GetNetColormapFromList(READUINT32(save_p)); ht->sectornum = READUINT32(save_p); ht->ffloornum = READUINT32(save_p); ht->alpha = READINT32(save_p); From 752a9630372d787625459050053ffae98a8a6689 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 08:05:51 -0400 Subject: [PATCH 319/573] Colormap netsync: String format numsectors to UINT32 (thanks buildbot) --- src/p_saveg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index ec0ef2e7a..b98a34436 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -537,7 +537,7 @@ static extracolormap_t *GetNetColormapFromList(UINT32 index) // entries in net_colormaps. At this point, we don't know // what the total colormap count is if (index >= numsectors*3) // if every sector had a unique colormap change AND a fade thinker which has two colormap entries - I_Error("Colormap %d from server is too high for sectors %d", index, numsectors); + I_Error("Colormap %d from server is too high for sectors %d", index, (UINT32)numsectors); // our index doesn't exist, so just make the entry for (; i <= index; i++) From d417f733e5b00c54233c36d8b61b69f14d5ba996 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 10:24:55 -0400 Subject: [PATCH 320/573] Colormap netsync: Handle unaccounted dummy colormaps properly --- src/p_saveg.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index b98a34436..c0f98d88b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -682,6 +682,20 @@ static void P_NetUnArchiveColormaps(void) exc_next = R_CreateDefaultColormap(false); } + // if we still have a valid net_colormap after iterating up to num_net_colormaps, + // some sector had a colormap index higher than num_net_colormaps. We done goofed or $$$ was corrupted. + // In any case, add them to the colormap list too so that at least the sectors' colormap + // addresses are valid and accounted properly + if (exc_next) + { + existing_exc = R_GetDefaultColormap(); + for (exc = exc_next; exc; exc = exc->next) + { + exc->colormap = existing_exc->colormap; // all our dummies are default values + R_AddColormapToList(exc); + } + } + // Don't need these anymore num_net_colormaps = 0; net_colormaps = NULL; From 69a4906911aa206ac0dffc10a5b5536e692edbb7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 10:38:09 -0400 Subject: [PATCH 321/573] Colormap netsync: Count ffloors for colormap loading upper limit --- src/p_saveg.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index c0f98d88b..b8af7cff6 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -480,6 +480,7 @@ static void P_NetUnArchivePlayers(void) static extracolormap_t *net_colormaps = NULL; static UINT32 num_net_colormaps = 0; +static UINT32 num_ffloors = 0; // for loading // Copypasta from r_data.c AddColormapToList // But also check for equality and return the matching index @@ -536,7 +537,9 @@ static extracolormap_t *GetNetColormapFromList(UINT32 index) // LET'S HOPE that index is a sane value, because we create up to [index] // entries in net_colormaps. At this point, we don't know // what the total colormap count is - if (index >= numsectors*3) // if every sector had a unique colormap change AND a fade thinker which has two colormap entries + if (index >= numsectors*3 + num_ffloors) + // if every sector had a unique colormap change AND a fade color thinker which has two colormap entries + // AND every ffloor had a fade FOF thinker with one colormap entry I_Error("Colormap %d from server is too high for sectors %d", index, (UINT32)numsectors); // our index doesn't exist, so just make the entry @@ -564,6 +567,7 @@ static void ClearNetColormaps(void) Z_Free(exc); } num_net_colormaps = 0; + num_ffloors = 0; net_colormaps = NULL; } @@ -597,6 +601,7 @@ static void P_NetArchiveColormaps(void) } num_net_colormaps = 0; + num_ffloors = 0; net_colormaps = NULL; } @@ -698,6 +703,7 @@ static void P_NetUnArchiveColormaps(void) // Don't need these anymore num_net_colormaps = 0; + num_ffloors = 0; net_colormaps = NULL; } @@ -1031,6 +1037,14 @@ static void P_NetUnArchiveWorld(void) // initialize colormap vars because paranoia ClearNetColormaps(); + // count the level's ffloors so that colormap loading can have an upper limit + for (i = 0; i < numsectors; i++) + { + ffloor_t *rover; + for (rover = sectors[i].ffloors; rover; rover = rover->next) + num_ffloors++; + } + get = save_p; for (;;) From 20c4702986f6f3f99d30bf3efe19a10bc13141cc Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 14:12:16 -0400 Subject: [PATCH 322/573] Line exec trigger netsync: Save var2s in addition to vars --- src/p_saveg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index 6e0c704f6..6010a1d24 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1260,7 +1260,10 @@ static void SaveSpecialLevelThinker(const thinker_t *th, const UINT8 type) size_t i; WRITEUINT8(save_p, type); for (i = 0; i < 16; i++) + { WRITEFIXED(save_p, ht->vars[i]); //var[16] + WRITEFIXED(save_p, ht->var2s[i]); //var[16] + } WRITEUINT32(save_p, SaveLine(ht->sourceline)); WRITEUINT32(save_p, SaveSector(ht->sector)); } @@ -2163,7 +2166,10 @@ static void LoadSpecialLevelThinker(actionf_p1 thinker, UINT8 floorOrCeiling) size_t i; ht->thinker.function.acp1 = thinker; for (i = 0; i < 16; i++) + { ht->vars[i] = READFIXED(save_p); //var[16] + ht->var2s[i] = READFIXED(save_p); //var[16] + } ht->sourceline = LoadLine(READUINT32(save_p)); ht->sector = LoadSector(READUINT32(save_p)); From 5b16590ba24bbe09e2bfe2f9abb58993e1023134 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 21:03:51 -0400 Subject: [PATCH 323/573] 453: Don't interrupt current FOF fade unless EFFECT5 --- src/p_spec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index b5607e2b2..e53d386cf 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3403,7 +3403,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 destvalue = line->sidenum[1] != 0xffff ? (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(line->dx>>FRACBITS); INT16 speed = line->sidenum[1] != 0xffff ? - (INT16)(sides[line->sidenum[1]].rowoffset>>FRACBITS) : (INT16)(abs(line->dy)>>FRACBITS); + (INT16)(abs(sides[line->sidenum[1]].rowoffset>>FRACBITS)) : (INT16)(abs(line->dy)>>FRACBITS); INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in @@ -3433,6 +3433,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) return; } + // Prevent continuous execs from interfering on an existing fade + if (!(line->flags & ML_EFFECT5) + && rover->fadingdata) + continue; + if (speed > 0) P_AddFakeFloorFader(rover, secnum, j, destvalue, From f5b25c91f50cea0c7a055898dbf803c558e0f9e7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 05:50:14 -0400 Subject: [PATCH 324/573] 453: Commented out, but allow existing fade overlap of 2 tics (or speed*2) --- src/p_spec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index e53d386cf..5a42cefed 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3436,7 +3436,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Prevent continuous execs from interfering on an existing fade if (!(line->flags & ML_EFFECT5) && rover->fadingdata) + //&& ((fade_t*)rover->fadingdata)->timer > (ticbased ? 2 : speed*2)) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Fade FOF thinker already exists, timer: %d", ((fade_t*)rover->fadingdata)->timer); continue; + } if (speed > 0) P_AddFakeFloorFader(rover, secnum, j, From 27aa35705323a3d9fabb8022f8245b2032aabc56 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 07:07:46 -0400 Subject: [PATCH 325/573] 453: A line break --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 5a42cefed..06ef4839b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3438,7 +3438,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) && rover->fadingdata) //&& ((fade_t*)rover->fadingdata)->timer > (ticbased ? 2 : speed*2)) { - CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Fade FOF thinker already exists, timer: %d", ((fade_t*)rover->fadingdata)->timer); + CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Fade FOF thinker already exists, timer: %d\n", ((fade_t*)rover->fadingdata)->timer); continue; } From 64b96c7192565b1f47561c9f4210ef2425e60b94 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 21:16:27 -0400 Subject: [PATCH 326/573] 455: Don't interrupt current color fading --- src/p_spec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index a408b2140..b855e9641 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3378,6 +3378,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { extracolormap_t *source_exc, *dest_exc, *exc; + // Prevent continuous execs from interfering on an existing fade + if (!(line->flags & ML_EFFECT5) + && sectors[secnum].fadecolormapdata) + continue; + if (line->flags & ML_TFERLINE) // use back colormap instead of target sector sectors[secnum].extra_colormap = (line->sidenum[1] != 0xFFFF) ? sides[line->sidenum[1]].colormap_data : NULL; From 56ee711f332daad06ecec3d612d0d8b84318be59 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 05:45:28 -0400 Subject: [PATCH 327/573] 455: Commented out, but allow existing fade overlap of 2 tics (or speed*2) --- src/p_spec.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index b855e9641..95119cfd3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3377,11 +3377,18 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) { extracolormap_t *source_exc, *dest_exc, *exc; + INT32 speed = (INT32)((line->flags & ML_DONTPEGBOTTOM) || !sides[line->sidenum[0]].rowoffset) && line->sidenum[1] != 0xFFFF ? + abs(sides[line->sidenum[1]].rowoffset >> FRACBITS) + : abs(sides[line->sidenum[0]].rowoffset >> FRACBITS); // Prevent continuous execs from interfering on an existing fade if (!(line->flags & ML_EFFECT5) && sectors[secnum].fadecolormapdata) + //&& ((fadecolormap_t*)sectors[secnum].fadecolormapdata)->timer > (ticbased ? 2 : speed*2)) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 455 Executor: Fade color thinker already exists, timer: %d", ((fadecolormap_t*)sectors[secnum].fadecolormapdata)->timer); continue; + } if (line->flags & ML_TFERLINE) // use back colormap instead of target sector sectors[secnum].extra_colormap = (line->sidenum[1] != 0xFFFF) ? @@ -3451,9 +3458,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) Z_Free(exc); Add_ColormapFader(§ors[secnum], source_exc, dest_exc, (line->flags & ML_EFFECT4), // tic-based timing - ((line->flags & ML_DONTPEGBOTTOM) || !sides[line->sidenum[0]].rowoffset) && line->sidenum[1] != 0xFFFF ? - abs(sides[line->sidenum[1]].rowoffset >> FRACBITS) - : abs(sides[line->sidenum[0]].rowoffset >> FRACBITS)); + speed); } break; From 9778cc2ad57bbc1c4c4a51a93b4aea4e88f91a38 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 07:07:30 -0400 Subject: [PATCH 328/573] 455: A line break --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 95119cfd3..80580403c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3386,7 +3386,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) && sectors[secnum].fadecolormapdata) //&& ((fadecolormap_t*)sectors[secnum].fadecolormapdata)->timer > (ticbased ? 2 : speed*2)) { - CONS_Debug(DBG_GAMELOGIC, "Line type 455 Executor: Fade color thinker already exists, timer: %d", ((fadecolormap_t*)sectors[secnum].fadecolormapdata)->timer); + CONS_Debug(DBG_GAMELOGIC, "Line type 455 Executor: Fade color thinker already exists, timer: %d\n", ((fadecolormap_t*)sectors[secnum].fadecolormapdata)->timer); continue; } From 6567872229cb3535c7dbf3e79027ca89a51aa947 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 07:06:59 -0400 Subject: [PATCH 329/573] 492: Don't interrupt existing polyobj fader unless EFFECT5 --- src/p_spec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 2583c24f3..481580b79 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1276,7 +1276,7 @@ static boolean PolyFade(line_t *line) if (!(po = Polyobj_GetForNum(polyObjNum))) { - CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjWaypoint: bad polyobj %d\n", polyObjNum); + CONS_Debug(DBG_POLYOBJ, "PolyFade: bad polyobj %d\n", polyObjNum); return 0; } @@ -1284,6 +1284,15 @@ static boolean PolyFade(line_t *line) if (po->isBad) return 0; + // Prevent continuous execs from interfering on an existing fade + if (!(line->flags & ML_EFFECT5) + && po->thinker + && po->thinker->function.acp1 == (actionf_p1)T_PolyObjFade) + { + CONS_Debug(DBG_POLYOBJ, "Line type 492 Executor: Fade PolyObject thinker already exists\n"); + return 0; + } + pfd.polyObjNum = polyObjNum; // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset From 5029c01c2b4e9ae9cfba49e76e805b0f73e817cf Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 07:11:31 -0400 Subject: [PATCH 330/573] 492: Remove pre-existing thinker when setting up new fade --- src/p_polyobj.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index bbcf4f42a..c2b3ba399 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2969,6 +2969,9 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) if (po->translucency == pfdata->destvalue) return 1; + if (po->thinker && po->thinker->function.acp1 == (actionf_p1)T_PolyObjFade) + P_RemoveThinker(po->thinker); + // create a new thinker th = Z_Malloc(sizeof(polyfade_t), PU_LEVSPEC, NULL); th->thinker.function.acp1 = (actionf_p1)T_PolyObjFade; From e7ecd84e80e5c57d64ff0827bb49d21b927bdc2c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 07:36:38 -0400 Subject: [PATCH 331/573] p_setup: Don't fudge texture offsets if EFFECT5 and a linedef exec --- src/p_setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index f0ce69598..ae44c4cea 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1331,7 +1331,8 @@ static void P_LoadLineDefs2(void) ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; // Repeat count for midtexture - if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff)) + if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff) + && !(ld->special >= 300 && ld->special < 500)) // exempt linedef exec specials { sides[ld->sidenum[0]].repeatcnt = (INT16)(((unsigned)sides[ld->sidenum[0]].textureoffset >> FRACBITS) >> 12); sides[ld->sidenum[0]].textureoffset = (((unsigned)sides[ld->sidenum[0]].textureoffset >> FRACBITS) & 2047) << FRACBITS; From 34e403afcb501ae5e456dc292b8a3632a7e5fab9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 08:32:34 -0400 Subject: [PATCH 332/573] S_ChangeMusic: More specific load/play fail messages --- src/s_sound.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index 2b8e8e721..ea129a109 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1391,14 +1391,17 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) S_StopMusic(); // shutdown old music if (!S_LoadMusic(mmusic)) + { + CONS_Alert(CONS_ERROR, "Music %.6s could not be loaded!\n", mmusic); return; + } music_flags = mflags; music_looping = looping; if (!S_PlayMusic(looping)) { - CONS_Alert(CONS_ERROR, "Music cannot be played!\n"); + CONS_Alert(CONS_ERROR, "Music %.6s could not be played!\n", mmusic); return; } } From c45d523e8f2e1505283e614695bfe05d71b1ff82 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 06:27:30 -0400 Subject: [PATCH 333/573] 420: Don't interrupt existing light fade on duration timing except EFFECT5 (cherry picked from commit 3b957c32517a8f5148940c0067af7e88a51d1fee) --- src/lua_baselib.c | 3 ++- src/p_lights.c | 12 +++++++++++- src/p_spec.c | 3 ++- src/p_spec.h | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 840863eb0..ce017620c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1810,9 +1810,10 @@ static int lib_pFadeLight(lua_State *L) INT32 destvalue = (INT32)luaL_checkinteger(L, 2); INT32 speed = (INT32)luaL_checkinteger(L, 3); boolean ticbased = lua_optboolean(L, 4); + boolean force = lua_optboolean(L, 5); NOHUD INLEVEL - P_FadeLight(tag, destvalue, speed, ticbased); + P_FadeLight(tag, destvalue, speed, ticbased, force); return 0; } diff --git a/src/p_lights.c b/src/p_lights.c index 2ea93b796..12abc9e05 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -371,12 +371,22 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean } } -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force) { INT32 i; // search all sectors for ones with tag for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0 ;) + { + if (!force && ticbased // always let speed fader execute + && sectors[i].lightingdata + && ((lightlevel_t*)sectors[i].lightingdata)->thinker.function.acp1 == (actionf_p1)T_LightFade) + // && ((lightlevel_t*)sectors[i].lightingdata)->timer > 2) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 420 Executor: Fade light thinker already exists, timer: %d\n", ((lightlevel_t*)sectors[i].lightingdata)->timer); + continue; + } P_FadeLightBySector(§ors[i], destvalue, speed, ticbased); + } } /** Fades the light level in a sector to a new value. diff --git a/src/p_spec.c b/src/p_spec.c index b0a976a10..42cff1282 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2877,7 +2877,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) max(min(sides[line->sidenum[1]].rowoffset>>FRACBITS, 255), 0) : max(min(sides[line->sidenum[0]].rowoffset>>FRACBITS, 255), 0)) : abs(P_AproxDistance(line->dx, line->dy))>>FRACBITS, - (line->flags & ML_EFFECT4)); + (line->flags & ML_EFFECT4), + (line->flags & ML_EFFECT5)); break; case 421: // Stop lighting effect in tagged sectors diff --git a/src/p_spec.h b/src/p_spec.h index 56684b496..848b80ecf 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -162,7 +162,7 @@ void T_Glow(glow_t *g); glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length); void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased); -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased); +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force); void T_LightFade(lightlevel_t *ll); typedef enum From 1dadee68040faf4f1e42f5c8c8bcae4e019a8c2e Mon Sep 17 00:00:00 2001 From: Digiku Date: Wed, 19 Sep 2018 10:45:51 -0400 Subject: [PATCH 334/573] Nights intermission dehacked: a comment --- src/dehacked.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index 1f56210ac..ae1be6da2 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1199,7 +1199,7 @@ static void readlevelheader(MYFILE *f, INT32 num) else if (fastcmp(word2, "NIGHTS")) i = 3; else if (fastcmp(word2, "NIGHTSLINK")) i = 4; - if (i >= -1 && i <= 4) // -1 for no bonus. Max is 3. + if (i >= -1 && i <= 4) // -1 for no bonus. Max is 4. mapheaderinfo[num-1]->bonustype = (SINT8)i; else deh_warning("Level header %d: invalid bonus type number %d", num, i); From e3ecb61173c671ee80d673b8985690539d6c4989 Mon Sep 17 00:00:00 2001 From: Digiku Date: Wed, 19 Sep 2018 10:53:11 -0400 Subject: [PATCH 335/573] Nights intermission bonus y_inter.c: A comment --- src/y_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index 2c77a577a..45ecd49e6 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1945,7 +1945,7 @@ static void Y_AwardSpecialStageBonus(void) if (!playeringame[i] || players[i].lives < 1) // not active or game over Y_SetNullBonus(&players[i], &localbonus); - else if (maptol & TOL_NIGHTS) // Link instead of Rings + else if (maptol & TOL_NIGHTS) // Mare score instead of Rings Y_SetNightsBonus(&players[i], &localbonus); else Y_SetRingBonus(&players[i], &localbonus); From 24938473a5ae66616b17c9c8d3e4b8c0a7961775 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 19 Sep 2018 17:49:03 -0400 Subject: [PATCH 336/573] Linedef exec FOF specials: Move logic into for (rover =...) block so procedure happens on every FOF match --- src/p_spec.c | 238 +++++++++++++++++++++++++++------------------------ 1 file changed, 125 insertions(+), 113 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index d152b59c1..e63ec4a92 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3090,7 +3090,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover; // FOF that we are going to crumble + ffloor_t *rover, *foundrover; // FOF that we are going to crumble for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) { @@ -3105,16 +3105,18 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { if (rover->master->frontsector->tag == foftag) - break; + { + foundrover = rover; // for debug, "Can't find a FOF" message below + + EV_CrumbleChain(sec, rover); + } } - if (!rover) + if (!foundrover) { CONS_Debug(DBG_GAMELOGIC, "Line type 436 Executor: Can't find a FOF control sector with tag %d\n", foftag); return; } - - EV_CrumbleChain(sec, rover); } } break; @@ -3274,7 +3276,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible (or not visible) in - ffloor_t *rover; // FOF to vanish/un-vanish + ffloor_t *rover, *foundrover; // FOF to vanish/un-vanish ffloortype_e oldflags; // store FOF's old flags for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) @@ -3290,26 +3292,28 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { if (rover->master->frontsector->tag == foftag) - break; + { + foundrover = rover; // for debug, "Can't find a FOF" message below + + oldflags = rover->flags; + + // Abracadabra! + if (line->flags & ML_NOCLIMB) + rover->flags |= FF_EXISTS; + else + rover->flags &= ~FF_EXISTS; + + // if flags changed, reset sector's light list + if (rover->flags != oldflags) + sec->moved = true; + } } - if (!rover) + if (!foundrover) { CONS_Debug(DBG_GAMELOGIC, "Line type 445 Executor: Can't find a FOF control sector with tag %d\n", foftag); return; } - - oldflags = rover->flags; - - // Abracadabra! - if (line->flags & ML_NOCLIMB) - rover->flags |= FF_EXISTS; - else - rover->flags &= ~FF_EXISTS; - - // if flags changed, reset sector's light list - if (rover->flags != oldflags) - sec->moved = true; } } break; @@ -3319,7 +3323,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover; // FOF that we are going to make fall down + ffloor_t *rover, *foundrover; // FOF that we are going to make fall down player_t *player = NULL; // player that caused FOF to fall boolean respawn = true; // should the fallen FOF respawn? @@ -3342,19 +3346,21 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { if (rover->master->frontsector->tag == foftag) - break; + { + foundrover = rover; // for debug, "Can't find a FOF" message below + + if (line->flags & ML_BLOCKMONSTERS) // FOF flags determine respawn ability instead? + respawn = !(rover->flags & FF_NORETURN) ^ !!(line->flags & ML_NOCLIMB); // no climb inverts + + EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), player, rover->alpha, respawn); + } } - if (!rover) + if (!foundrover) { CONS_Debug(DBG_GAMELOGIC, "Line type 446 Executor: Can't find a FOF control sector with tag %d\n", foftag); return; } - - if (line->flags & ML_BLOCKMONSTERS) // FOF flags determine respawn ability instead? - respawn = !(rover->flags & FF_NORETURN) ^ !!(line->flags & ML_NOCLIMB); // no climb inverts - - EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), player, rover->alpha, respawn); } } break; @@ -3486,7 +3492,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover; // FOF that we are going to operate + ffloor_t *rover, *foundrover; // FOF that we are going to operate for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) { @@ -3501,38 +3507,40 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { if (rover->master->frontsector->tag == foftag) - break; + { + foundrover = rover; // for debug, "Can't find a FOF" message below + + // If fading an invisible FOF whose render flags we did not yet set, + // initialize its alpha to 1 + // for relative alpha calc + if (!(line->flags & ML_NOCLIMB) && // do translucent + (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE + !(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES) && + !(rover->flags & FF_RENDERALL)) + rover->alpha = 1; + + P_RemoveFakeFloorFader(rover); + P_FadeFakeFloor(rover, + rover->alpha, + max(1, min(256, (line->flags & ML_EFFECT3) ? rover->alpha + destvalue : destvalue)), + 0, // set alpha immediately + false, NULL, // tic-based logic + false, // do not handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // handle FF_TRANSLUCENT + false, // do not handle lighting + false, // do not handle colormap + false, // do not handle collision + false, // do not do ghost fade (no collision during fade) + true); // use exact alpha values (for opengl) + } } - if (!rover) + if (!foundrover) { CONS_Debug(DBG_GAMELOGIC, "Line type 452 Executor: Can't find a FOF control sector with tag %d\n", foftag); return; } - - // If fading an invisible FOF whose render flags we did not yet set, - // initialize its alpha to 1 - // for relative alpha calc - if (!(line->flags & ML_NOCLIMB) && // do translucent - (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE - !(rover->spawnflags & FF_RENDERSIDES) && - !(rover->spawnflags & FF_RENDERPLANES) && - !(rover->flags & FF_RENDERALL)) - rover->alpha = 1; - - P_RemoveFakeFloorFader(rover); - P_FadeFakeFloor(rover, - rover->alpha, - max(1, min(256, (line->flags & ML_EFFECT3) ? rover->alpha + destvalue : destvalue)), - 0, // set alpha immediately - false, NULL, // tic-based logic - false, // do not handle FF_EXISTS - !(line->flags & ML_NOCLIMB), // handle FF_TRANSLUCENT - false, // do not handle lighting - false, // do not handle colormap - false, // do not handle collision - false, // do not do ghost fade (no collision during fade) - true); // use exact alpha values (for opengl) } break; } @@ -3546,7 +3554,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover; // FOF that we are going to operate + ffloor_t *rover, *foundrover; // FOF that we are going to operate size_t j = 0; // sec->ffloors is saved as ffloor #0, ss->ffloors->next is #1, etc for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) @@ -3562,64 +3570,66 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { if (rover->master->frontsector->tag == foftag) - break; + { + foundrover = rover; // for debug, "Can't find a FOF" message below + + // Prevent continuous execs from interfering on an existing fade + if (!(line->flags & ML_EFFECT5) + && rover->fadingdata) + //&& ((fade_t*)rover->fadingdata)->timer > (ticbased ? 2 : speed*2)) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Fade FOF thinker already exists, timer: %d\n", ((fade_t*)rover->fadingdata)->timer); + continue; + } + + if (speed > 0) + P_AddFakeFloorFader(rover, secnum, j, + destvalue, + speed, + (line->flags & ML_EFFECT4), // tic-based logic + (line->flags & ML_EFFECT3), // Relative destvalue + !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT + !(line->flags & ML_EFFECT2), // do not handle lighting + !(line->flags & ML_EFFECT2), // do not handle colormap (ran out of flags) + !(line->flags & ML_BOUNCY), // do not handle collision + (line->flags & ML_EFFECT1), // do ghost fade (no collision during fade) + (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) + else + { + // If fading an invisible FOF whose render flags we did not yet set, + // initialize its alpha to 1 + // for relative alpha calc + if (!(line->flags & ML_NOCLIMB) && // do translucent + (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE + !(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES) && + !(rover->flags & FF_RENDERALL)) + rover->alpha = 1; + + P_RemoveFakeFloorFader(rover); + P_FadeFakeFloor(rover, + rover->alpha, + max(1, min(256, (line->flags & ML_EFFECT3) ? rover->alpha + destvalue : destvalue)), + 0, // set alpha immediately + false, NULL, // tic-based logic + !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT + !(line->flags & ML_EFFECT2), // do not handle lighting + !(line->flags & ML_EFFECT2), // do not handle colormap (ran out of flags) + !(line->flags & ML_BOUNCY), // do not handle collision + (line->flags & ML_EFFECT1), // do ghost fade (no collision during fade) + (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) + } + } j++; } - if (!rover) + if (!foundrover) { CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Can't find a FOF control sector with tag %d\n", foftag); return; } - - // Prevent continuous execs from interfering on an existing fade - if (!(line->flags & ML_EFFECT5) - && rover->fadingdata) - //&& ((fade_t*)rover->fadingdata)->timer > (ticbased ? 2 : speed*2)) - { - CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Fade FOF thinker already exists, timer: %d\n", ((fade_t*)rover->fadingdata)->timer); - continue; - } - - if (speed > 0) - P_AddFakeFloorFader(rover, secnum, j, - destvalue, - speed, - (line->flags & ML_EFFECT4), // tic-based logic - (line->flags & ML_EFFECT3), // Relative destvalue - !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS - !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT - !(line->flags & ML_EFFECT2), // do not handle lighting - !(line->flags & ML_EFFECT2), // do not handle colormap (ran out of flags) - !(line->flags & ML_BOUNCY), // do not handle collision - (line->flags & ML_EFFECT1), // do ghost fade (no collision during fade) - (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) - else - { - // If fading an invisible FOF whose render flags we did not yet set, - // initialize its alpha to 1 - // for relative alpha calc - if (!(line->flags & ML_NOCLIMB) && // do translucent - (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE - !(rover->spawnflags & FF_RENDERSIDES) && - !(rover->spawnflags & FF_RENDERPLANES) && - !(rover->flags & FF_RENDERALL)) - rover->alpha = 1; - - P_RemoveFakeFloorFader(rover); - P_FadeFakeFloor(rover, - rover->alpha, - max(1, min(256, (line->flags & ML_EFFECT3) ? rover->alpha + destvalue : destvalue)), - 0, // set alpha immediately - false, NULL, // tic-based logic - !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS - !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT - !(line->flags & ML_EFFECT2), // do not handle lighting - !(line->flags & ML_EFFECT2), // do not handle colormap (ran out of flags) - !(line->flags & ML_BOUNCY), // do not handle collision - (line->flags & ML_EFFECT1), // do ghost fade (no collision during fade) - (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) - } } break; } @@ -3629,7 +3639,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover; // FOF that we are going to operate + ffloor_t *rover, *foundrover; // FOF that we are going to operate for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) { @@ -3644,17 +3654,19 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { if (rover->master->frontsector->tag == foftag) - break; + { + foundrover = rover; // for debug, "Can't find a FOF" message below + + P_ResetFakeFloorFader(rover, NULL, + !(line->flags & ML_BLOCKMONSTERS)); // do not finalize collision flags + } } - if (!rover) + if (!foundrover) { CONS_Debug(DBG_GAMELOGIC, "Line type 454 Executor: Can't find a FOF control sector with tag %d\n", foftag); return; } - - P_ResetFakeFloorFader(rover, NULL, - !(line->flags & ML_BLOCKMONSTERS)); // do not finalize collision flags } break; } From 5e1b4272c1c835b2d6cb074b5c00acc2dd26a5bb Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 19 Sep 2018 17:50:05 -0400 Subject: [PATCH 337/573] Initialize foundrover to NULL (for debug checking) --- src/p_spec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index e63ec4a92..dfc75a4e3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3090,7 +3090,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover, *foundrover; // FOF that we are going to crumble + ffloor_t *rover, *foundrover = NULL; // FOF that we are going to crumble for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) { @@ -3276,7 +3276,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible (or not visible) in - ffloor_t *rover, *foundrover; // FOF to vanish/un-vanish + ffloor_t *rover, *foundrover = NULL; // FOF to vanish/un-vanish ffloortype_e oldflags; // store FOF's old flags for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) @@ -3323,7 +3323,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover, *foundrover; // FOF that we are going to make fall down + ffloor_t *rover, *foundrover = NULL; // FOF that we are going to make fall down player_t *player = NULL; // player that caused FOF to fall boolean respawn = true; // should the fallen FOF respawn? @@ -3492,7 +3492,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover, *foundrover; // FOF that we are going to operate + ffloor_t *rover, *foundrover = NULL; // FOF that we are going to operate for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) { @@ -3554,7 +3554,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover, *foundrover; // FOF that we are going to operate + ffloor_t *rover, *foundrover = NULL; // FOF that we are going to operate size_t j = 0; // sec->ffloors is saved as ffloor #0, ss->ffloors->next is #1, etc for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) @@ -3639,7 +3639,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover, *foundrover; // FOF that we are going to operate + ffloor_t *rover, *foundrover = NULL; // FOF that we are going to operate for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) { From 31343be41be36f219630ff02001750ed9b6b3c51 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 19 Sep 2018 20:11:30 -0400 Subject: [PATCH 338/573] foundrover ffloor_t -> boolean --- src/p_spec.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index dfc75a4e3..2f6558175 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3090,7 +3090,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover, *foundrover = NULL; // FOF that we are going to crumble + ffloor_t *rover; // FOF that we are going to crumble + boolean foundrover = false; // for debug, "Can't find a FOF" message for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) { @@ -3106,7 +3107,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { if (rover->master->frontsector->tag == foftag) { - foundrover = rover; // for debug, "Can't find a FOF" message below + foundrover = true; EV_CrumbleChain(sec, rover); } @@ -3276,7 +3277,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible (or not visible) in - ffloor_t *rover, *foundrover = NULL; // FOF to vanish/un-vanish + ffloor_t *rover; // FOF to vanish/un-vanish + boolean foundrover = false; // for debug, "Can't find a FOF" message ffloortype_e oldflags; // store FOF's old flags for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) @@ -3293,7 +3295,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { if (rover->master->frontsector->tag == foftag) { - foundrover = rover; // for debug, "Can't find a FOF" message below + foundrover = true; oldflags = rover->flags; @@ -3323,7 +3325,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover, *foundrover = NULL; // FOF that we are going to make fall down + ffloor_t *rover; // FOF that we are going to make fall down + boolean foundrover = false; // for debug, "Can't find a FOF" message player_t *player = NULL; // player that caused FOF to fall boolean respawn = true; // should the fallen FOF respawn? @@ -3347,7 +3350,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { if (rover->master->frontsector->tag == foftag) { - foundrover = rover; // for debug, "Can't find a FOF" message below + foundrover = true; if (line->flags & ML_BLOCKMONSTERS) // FOF flags determine respawn ability instead? respawn = !(rover->flags & FF_NORETURN) ^ !!(line->flags & ML_NOCLIMB); // no climb inverts @@ -3492,7 +3495,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover, *foundrover = NULL; // FOF that we are going to operate + ffloor_t *rover; // FOF that we are going to operate + boolean foundrover = false; // for debug, "Can't find a FOF" message for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) { @@ -3508,7 +3512,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { if (rover->master->frontsector->tag == foftag) { - foundrover = rover; // for debug, "Can't find a FOF" message below + foundrover = true; // If fading an invisible FOF whose render flags we did not yet set, // initialize its alpha to 1 @@ -3554,7 +3558,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover, *foundrover = NULL; // FOF that we are going to operate + ffloor_t *rover; // FOF that we are going to operate + boolean foundrover = false; // for debug, "Can't find a FOF" message size_t j = 0; // sec->ffloors is saved as ffloor #0, ss->ffloors->next is #1, etc for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) @@ -3571,7 +3576,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { if (rover->master->frontsector->tag == foftag) { - foundrover = rover; // for debug, "Can't find a FOF" message below + foundrover = true; // Prevent continuous execs from interfering on an existing fade if (!(line->flags & ML_EFFECT5) @@ -3639,7 +3644,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in - ffloor_t *rover, *foundrover = NULL; // FOF that we are going to operate + ffloor_t *rover; // FOF that we are going to operate + boolean foundrover = false; // for debug, "Can't find a FOF" message for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) { @@ -3655,7 +3661,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { if (rover->master->frontsector->tag == foftag) { - foundrover = rover; // for debug, "Can't find a FOF" message below + foundrover = true; P_ResetFakeFloorFader(rover, NULL, !(line->flags & ML_BLOCKMONSTERS)); // do not finalize collision flags From a53f036149a4ff1d7c9371f9f082fbfe5b65a5b7 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 20 Sep 2018 18:26:59 -0400 Subject: [PATCH 339/573] Use MemAvailable instead --- src/sdl/i_system.c | 49 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index e86a39cab..984f6dd22 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -124,6 +124,10 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include "macosx/mac_resources.h" #endif +#ifndef errno +#include +#endif + // Locations for searching the srb2.srb #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #define DEFAULTWADLOCATION1 "/usr/local/share/games/SRB2" @@ -2712,9 +2716,31 @@ const char *I_LocateWad(void) #ifdef __linux__ #define MEMINFO_FILE "/proc/meminfo" #define MEMTOTAL "MemTotal:" +#define MEMAVAILABLE "MemAvailable:" #define MEMFREE "MemFree:" +#define CACHED "Cached:" +#define BUFFERS "Buffers:" +#define SHMEM "Shmem:" #endif +/* Parse the contents of /proc/meminfo (in buf), return value of "name" + * (example: MemTotal) */ +static long get_entry(const char* name, const char* buf) +{ + char* hit = strstr(buf, name); + if (hit == NULL) { + return -1; + } + + errno = 0; + long val = strtol(hit + strlen(name), NULL, 10); + if (errno != 0) { + CONS_Alert(CONS_ERROR, M_GetText("get_entry: strtol() failed: %s\n"), strerror(errno)); + return -1; + } + return val; +} + // quick fix for compil UINT32 I_GetFreeMem(UINT32 *total) { @@ -2809,7 +2835,17 @@ UINT32 I_GetFreeMem(UINT32 *total) memTag += sizeof (MEMTOTAL); totalKBytes = atoi(memTag); - if ((memTag = strstr(buf, MEMFREE)) == NULL) + if ((memTag = strstr(buf, MEMAVAILABLE)) == NULL) + { + Cached = get_entry(CACHED, buf); + MemFree = get_entry(MEMFREE, buf); + Buffers = get_entry(BUFFERS, buf); + Shmem = get_entry(SHMEM, buf); + MemAvailable = Cached + MemFree + Buffers - Shmem; + guessed = true; + } + + if (MemAvailable == -1 && guessed) { // Error if (total) @@ -2817,8 +2853,15 @@ UINT32 I_GetFreeMem(UINT32 *total) return 0; } - memTag += sizeof (MEMFREE); - freeKBytes = atoi(memTag); + if (guessed) + { + freeKBytes = MemAvailable; + } + else + { + memTag += sizeof (MEMAVAILABLE); + freeKBytes = atoi(memTag); + } if (total) *total = totalKBytes << 10; From 378495cb2b8337c37b6bfefc3f510cf9b6117e61 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 20 Sep 2018 18:33:50 -0400 Subject: [PATCH 340/573] Add some stuff --- src/sdl/i_system.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 984f6dd22..3610a534d 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2810,6 +2810,12 @@ UINT32 I_GetFreeMem(UINT32 *total) UINT32 totalKBytes; INT32 n; INT32 meminfo_fd = -1; + long Cached; + long MemFree; + long Buffers; + long Shmem; + long MemAvailable = -1; + boolean guessed = false; // Stupid way to verify if the amount was guessed or not. meminfo_fd = open(MEMINFO_FILE, O_RDONLY); n = read(meminfo_fd, buf, 1023); From be74b4e58b93974bc56a7f96f3f175b541b04230 Mon Sep 17 00:00:00 2001 From: Steel Date: Fri, 21 Sep 2018 07:16:54 -0400 Subject: [PATCH 341/573] Fix up errors with buildbots --- src/sdl/i_system.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 3610a534d..e9e1ae92d 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1,6 +1,6 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- -// +- // // Copyright (C) 1993-1996 by id Software, Inc. // Portions Copyright (C) 1998-2000 by DooM Legacy Team. // @@ -2095,7 +2095,6 @@ INT32 I_StartupSystem(void) return 0; } - // // I_Quit // @@ -2721,25 +2720,26 @@ const char *I_LocateWad(void) #define CACHED "Cached:" #define BUFFERS "Buffers:" #define SHMEM "Shmem:" -#endif /* Parse the contents of /proc/meminfo (in buf), return value of "name" * (example: MemTotal) */ static long get_entry(const char* name, const char* buf) { + long val; char* hit = strstr(buf, name); if (hit == NULL) { return -1; } errno = 0; - long val = strtol(hit + strlen(name), NULL, 10); + val = strtol(hit + strlen(name), NULL, 10); if (errno != 0) { CONS_Alert(CONS_ERROR, M_GetText("get_entry: strtol() failed: %s\n"), strerror(errno)); return -1; } return val; } +#endif // quick fix for compil UINT32 I_GetFreeMem(UINT32 *total) From af58ba9ae3fa661ea406bca3b134ae2ac6b76a2c Mon Sep 17 00:00:00 2001 From: Steel Date: Fri, 21 Sep 2018 07:21:49 -0400 Subject: [PATCH 342/573] Remove this that somehow slipped in. --- src/sdl/i_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index e9e1ae92d..b7326b066 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1,6 +1,6 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- -- // +// // Copyright (C) 1993-1996 by id Software, Inc. // Portions Copyright (C) 1998-2000 by DooM Legacy Team. // From 68ec8119096c3744e25115337fd03ea3e124df2a Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Fri, 21 Sep 2018 11:26:08 -0400 Subject: [PATCH 343/573] Rearrange the code. Thanks again MonsterIestyn! --- src/sdl/i_system.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index b7326b066..05d9e092f 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2815,7 +2815,6 @@ UINT32 I_GetFreeMem(UINT32 *total) long Buffers; long Shmem; long MemAvailable = -1; - boolean guessed = false; // Stupid way to verify if the amount was guessed or not. meminfo_fd = open(MEMINFO_FILE, O_RDONLY); n = read(meminfo_fd, buf, 1023); @@ -2848,26 +2847,21 @@ UINT32 I_GetFreeMem(UINT32 *total) Buffers = get_entry(BUFFERS, buf); Shmem = get_entry(SHMEM, buf); MemAvailable = Cached + MemFree + Buffers - Shmem; - guessed = true; - } - if (MemAvailable == -1 && guessed) - { - // Error - if (total) - *total = 0L; - return 0; - } - - if (guessed) - { + if (MemAvailable == -1) + { + // Error + if (total) + *total = 0L; + return 0; + } freeKBytes = MemAvailable; - } - else - { + } + else + { memTag += sizeof (MEMAVAILABLE); freeKBytes = atoi(memTag); - } + } if (total) *total = totalKBytes << 10; From f88708bb75810e5ef089b5cf5246d3a2f9154d02 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Fri, 21 Sep 2018 12:05:52 -0400 Subject: [PATCH 344/573] Fix the weird indentation --- src/sdl/i_system.c | 76 +++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 05d9e092f..f92cd4b6e 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1683,7 +1683,7 @@ static void I_ShutdownMouse2(void) EscapeCommFunction(mouse2filehandle, CLRRTS); PurgeComm(mouse2filehandle, PURGE_TXABORT | PURGE_RXABORT | - PURGE_TXCLEAR | PURGE_RXCLEAR); + PURGE_TXCLEAR | PURGE_RXCLEAR); CloseHandle(mouse2filehandle); @@ -1876,11 +1876,11 @@ void I_StartupMouse2(void) { // COM file handle mouse2filehandle = CreateFileA(cv_mouse2port.string, GENERIC_READ | GENERIC_WRITE, - 0, // exclusive access - NULL, // no security attrs - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); + 0, // exclusive access + NULL, // no security attrs + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); if (mouse2filehandle == INVALID_HANDLE_VALUE) { INT32 e = GetLastError(); @@ -1900,7 +1900,7 @@ void I_StartupMouse2(void) // purge buffers PurgeComm(mouse2filehandle, PURGE_TXABORT | PURGE_RXABORT - | PURGE_TXCLEAR | PURGE_RXCLEAR); + | PURGE_TXCLEAR | PURGE_RXCLEAR); // setup port to 1200 7N1 dcb.DCBlength = sizeof (DCB); @@ -2029,7 +2029,7 @@ static void I_ShutdownTimer(void) tic_t I_GetTime (void) { static Uint32 basetime = 0; - Uint32 ticks = SDL_GetTicks(); + Uint32 ticks = SDL_GetTicks(); if (!basetime) basetime = ticks; @@ -2373,7 +2373,7 @@ void I_GetDiskFreeSpace(INT64 *freespace) { DWORD SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, TotalNumberOfClusters; GetDiskFreeSpace(NULL, &SectorsPerCluster, &BytesPerSector, - &NumberOfFreeClusters, &TotalNumberOfClusters); + &NumberOfFreeClusters, &TotalNumberOfClusters); *freespace = BytesPerSector*SectorsPerCluster*NumberOfFreeClusters; } #else // Dummy for platform independent; 1GB should be enough @@ -2595,22 +2595,22 @@ static const char *locateWad(void) #ifdef CMAKECONFIG #ifndef NDEBUG - I_OutputMsg(","CMAKE_ASSETS_DIR); - strcpy(returnWadPath, CMAKE_ASSETS_DIR); - if (isWadPathOk(returnWadPath)) - { - return returnWadPath; - } + I_OutputMsg(","CMAKE_ASSETS_DIR); + strcpy(returnWadPath, CMAKE_ASSETS_DIR); + if (isWadPathOk(returnWadPath)) + { + return returnWadPath; + } #endif #endif #ifdef __APPLE__ - OSX_GetResourcesPath(returnWadPath); - I_OutputMsg(",%s", returnWadPath); - if (isWadPathOk(returnWadPath)) - { - return returnWadPath; - } + OSX_GetResourcesPath(returnWadPath); + I_OutputMsg(",%s", returnWadPath); + if (isWadPathOk(returnWadPath)) + { + return returnWadPath; + } #endif // examine default dirs @@ -2725,19 +2725,19 @@ const char *I_LocateWad(void) * (example: MemTotal) */ static long get_entry(const char* name, const char* buf) { - long val; - char* hit = strstr(buf, name); - if (hit == NULL) { - return -1; - } + long val; + char* hit = strstr(buf, name); + if (hit == NULL) { + return -1; + } - errno = 0; - val = strtol(hit + strlen(name), NULL, 10); - if (errno != 0) { - CONS_Alert(CONS_ERROR, M_GetText("get_entry: strtol() failed: %s\n"), strerror(errno)); - return -1; - } - return val; + errno = 0; + val = strtol(hit + strlen(name), NULL, 10); + if (errno != 0) { + CONS_Alert(CONS_ERROR, M_GetText("get_entry: strtol() failed: %s\n"), strerror(errno)); + return -1; + } + return val; } #endif @@ -2850,18 +2850,18 @@ UINT32 I_GetFreeMem(UINT32 *total) if (MemAvailable == -1) { - // Error + // Error if (total) *total = 0L; return 0; } freeKBytes = MemAvailable; - } - else - { + } + else + { memTag += sizeof (MEMAVAILABLE); freeKBytes = atoi(memTag); - } + } if (total) *total = totalKBytes << 10; From 872e2f82c154359ac5f8e33e5c9ffeeef5a84017 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 28 Sep 2018 17:02:02 +0100 Subject: [PATCH 345/573] Redo OpenGL skewing support, so that it now itself supports the lower unpegged effect for FOFs in OpenGL! --- src/hardware/hw_main.c | 46 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d7c73415a..92925c9bf 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2183,6 +2183,10 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) else if (drawtextured) { fixed_t texturevpeg; + boolean attachtobottom = false; +#ifdef ESLOPE + boolean slopeskew = false; // skew FOF walls with slopes? +#endif // Wow, how was this missing from OpenGL for so long? // ...Oh well, anyway, Lower Unpegged now changes pegging of FOFs like in software @@ -2190,24 +2194,50 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) if (newline) { texturevpeg = sides[newline->sidenum[0]].rowoffset; - if (newline->flags & ML_DONTPEGBOTTOM) - texturevpeg -= *rover->topheight - *rover->bottomheight; + attachtobottom = !!(newline->flags & ML_DONTPEGBOTTOM); +#ifdef ESLOPE + slopeskew = !!(newline->flags & ML_DONTPEGTOP); +#endif } else { texturevpeg = sides[rover->master->sidenum[0]].rowoffset; - if (gr_linedef->flags & ML_DONTPEGBOTTOM) - texturevpeg -= *rover->topheight - *rover->bottomheight; + attachtobottom = !!(gr_linedef->flags & ML_DONTPEGBOTTOM); +#ifdef ESLOPE + slopeskew = !!(rover->master->flags & ML_DONTPEGTOP); +#endif } grTex = HWR_GetTexture(texnum); #ifdef ESLOPE - wallVerts[3].t = (*rover->topheight - h + texturevpeg) * grTex->scaleY; - wallVerts[2].t = (*rover->topheight - hS + texturevpeg) * grTex->scaleY; - wallVerts[0].t = (*rover->topheight - l + texturevpeg) * grTex->scaleY; - wallVerts[1].t = (*rover->topheight - lS + texturevpeg) * grTex->scaleY; + if (!slopeskew) // no skewing + { + if (attachtobottom) + texturevpeg -= *rover->topheight - *rover->bottomheight; + wallVerts[3].t = (*rover->topheight - h + texturevpeg) * grTex->scaleY; + wallVerts[2].t = (*rover->topheight - hS + texturevpeg) * grTex->scaleY; + wallVerts[0].t = (*rover->topheight - l + texturevpeg) * grTex->scaleY; + wallVerts[1].t = (*rover->topheight - lS + texturevpeg) * grTex->scaleY; + } + else + { + if (!attachtobottom) // skew by top + { + wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; + wallVerts[0].t = (h - l + texturevpeg) * grTex->scaleY; + wallVerts[1].t = (hS - lS + texturevpeg) * grTex->scaleY; + } + else // skew by bottom + { + wallVerts[0].t = wallVerts[1].t = texturevpeg * grTex->scaleY; + wallVerts[3].t = wallVerts[0].t - (h - l) * grTex->scaleY; + wallVerts[2].t = wallVerts[1].t - (hS - lS) * grTex->scaleY; + } + } #else + if (attachtobottom) + texturevpeg -= *rover->topheight - *rover->bottomheight; wallVerts[3].t = wallVerts[2].t = (*rover->topheight - h + texturevpeg) * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (*rover->topheight - l + texturevpeg) * grTex->scaleY; #endif From 800b3bb2407f793730b88f2b6c70c583f3a2f8a8 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 30 Sep 2018 22:18:48 +0100 Subject: [PATCH 346/573] Move player + player mobj existence checks to top of P_MoveChaseCamera. This is the only place it makes sense to even check them tbh. While I'm at it, let's also use the "mo" variable instead of player->mo throughout the function (to be consistent) --- src/p_user.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index da8e19caa..91b5feb85 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7853,7 +7853,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall subsector_t *newsubsec; fixed_t f1, f2; - cameranoclip = (player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) || (player->mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)); // Noclipping player camera noclips too!! + // We probably shouldn't move the camera if there is no player or player mobj somehow + if (!player || !player->mo) + return true; + + mo = player->mo; + + cameranoclip = (player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)); // Noclipping player camera noclips too!! if (!(player->climbing || (player->pflags & PF_NIGHTSMODE) || player->playerstate == PST_DEAD)) { @@ -7874,7 +7880,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall else if (player == &players[secondarydisplayplayer]) focusangle = localangle2; else - focusangle = player->mo->angle; + focusangle = mo->angle; if (thiscam == &camera) camrotate = cv_cam_rotate.value; else if (thiscam == &camera2) @@ -7886,17 +7892,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall return true; } - if (!player || !player->mo) - return true; - - mo = player->mo; - thiscam->radius = FixedMul(20*FRACUNIT, mo->scale); thiscam->height = FixedMul(16*FRACUNIT, mo->scale); - if (!mo) - return true; - // Don't run while respawning from a starpost // Inu 4/8/13 Why not?! // if (leveltime > 0 && timeinmap <= 0) @@ -7904,7 +7902,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (player->pflags & PF_NIGHTSMODE) { - focusangle = player->mo->angle; + focusangle = mo->angle; focusaiming = 0; } else if (player == &players[consoleplayer]) @@ -7919,7 +7917,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } else { - focusangle = player->mo->angle; + focusangle = mo->angle; focusaiming = player->aiming; } @@ -7966,12 +7964,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall angle = R_PointToAngle2(player->axis1->x, player->axis1->y, player->axis2->x, player->axis2->y); angle += ANGLE_90; } - else if (player->mo->target) + else if (mo->target) { - if (player->mo->target->flags & MF_AMBUSH) - angle = R_PointToAngle2(player->mo->target->x, player->mo->target->y, player->mo->x, player->mo->y); + if (mo->target->flags & MF_AMBUSH) + angle = R_PointToAngle2(mo->target->x, mo->target->y, mo->x, mo->y); else - angle = R_PointToAngle2(player->mo->x, player->mo->y, player->mo->target->x, player->mo->target->y); + angle = R_PointToAngle2(mo->x, mo->y, mo->target->x, mo->target->y); } } else if (P_AnalogMove(player)) // Analog @@ -8066,7 +8064,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (twodlevel || (mo->flags2 & MF2_TWOD)) { // Camera doesn't ALWAYS need to move, only when running... - if (abs(player->mo->momx) > 10) + if (abs(mo->momx) > 10) { // Move the camera all smooth-like, not jerk it around... if (mo->momx > 0) @@ -8384,13 +8382,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall vy = thiscam->y; } - if (P_AproxDistance(vx - player->mo->x, vy - player->mo->y) < FixedMul(48*FRACUNIT, mo->scale)) - player->mo->flags2 |= MF2_SHADOW; + if (P_AproxDistance(vx - mo->x, vy - mo->y) < FixedMul(48*FRACUNIT, mo->scale)) + mo->flags2 |= MF2_SHADOW; else - player->mo->flags2 &= ~MF2_SHADOW; + mo->flags2 &= ~MF2_SHADOW; } else - player->mo->flags2 &= ~MF2_SHADOW; + mo->flags2 &= ~MF2_SHADOW; /* if (!resetcalled && (player->pflags & PF_NIGHTSMODE && player->exiting)) { From 79f5f4885c70e373cd6d4afc275c2141aa545736 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 4 Oct 2018 19:47:19 -0400 Subject: [PATCH 347/573] Split zlib and libpng --- src/Makefile | 22 +++++++++++++++------- src/sdl/mixer_sound.c | 17 ++++++++--------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/Makefile b/src/Makefile index dd250b0bc..7a67c3f02 100644 --- a/src/Makefile +++ b/src/Makefile @@ -66,6 +66,7 @@ # Compile without 3D sound support, add 'NOHS=1' # Compile with GDBstubs, add 'RDB=1' # Compile without PNG, add 'NOPNG=1' +# Compile without zlib, add 'NOZLIB=1' # # Addon for SDL: # To Cross-Compile, add 'SDL_CONFIG=/usr/*/bin/sdl-config' @@ -119,6 +120,7 @@ include Makefile.cfg ifdef DUMMY NOPNG=1 +NOZLIB=1 NONET=1 NOHW=1 NOHS=1 @@ -199,6 +201,7 @@ endif ifdef NDS NOPNG=1 +NOZLIB=1 NONET=1 #NOHW=1 NOHS=1 @@ -325,13 +328,6 @@ LIBS+=$(PNG_LDFLAGS) CFLAGS+=$(PNG_CFLAGS) endif -ZLIB_PKGCONFIG?=zlib -ZLIB_CFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --cflags) -ZLIB_LDFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --libs) - -LIBS+=$(ZLIB_LDFLAGS) -CFLAGS+=$(ZLIB_CFLAGS) - ifdef HAVE_LIBGME OPTS+=-DHAVE_LIBGME @@ -343,6 +339,18 @@ LIBS+=$(LIBGME_LDFLAGS) CFLAGS+=$(LIBGME_CFLAGS) endif +ifndef NOZLIB +OPTS+=-DHAVE_ZLIB +ZLIB_PKGCONFIG?=zlib +ZLIB_CFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --cflags) +ZLIB_LDFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --libs) + +LIBS+=$(ZLIB_LDFLAGS) +CFLAGS+=$(ZLIB_CFLAGS) +else +NOPNG=1 +endif + ifdef STATIC LIBS:=-static $(LIBS) endif diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 5211efe0a..362d7f264 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -38,9 +38,6 @@ #include "gme/gme.h" #define GME_TREBLE 5.0 #define GME_BASS 1.0 -#ifdef HAVE_PNG /// TODO: compile with zlib support without libpng - -#define HAVE_ZLIB #ifndef _MSC_VER #ifndef _LARGEFILE64_SOURCE @@ -56,10 +53,13 @@ #define _FILE_OFFSET_BITS 0 #endif -#include "zlib.h" #endif #endif +#ifdef HAVE_ZLIB +#include "zlib.h" +#endif + UINT8 sound_started = false; static boolean midimode; @@ -361,7 +361,7 @@ void *I_GetSfx(sfxinfo_t *sfx) } Z_Free(inflatedData); // GME didn't open jack, but don't let that stop us from freeing this up #else - //CONS_Alert(CONS_ERROR,"Cannot decompress VGZ; no zlib support\n"); + return NULL; // No zlib support #endif } // Try to read it as a GME sound @@ -621,7 +621,8 @@ boolean I_StartDigSong(const char *musicname, boolean looping) } Z_Free(inflatedData); // GME didn't open jack, but don't let that stop us from freeing this up #else - //CONS_Alert(CONS_ERROR,"Cannot decompress VGZ; no zlib support\n"); + CONS_Alert(CONS_ERROR,"Cannot decompress VGZ; no zlib support\n"); + return true; #endif } else if (!gme_open_data(data, len, &gme, 44100)) @@ -840,6 +841,4 @@ void I_UnRegisterSong(INT32 handle) (void)handle; Mix_FreeMusic(music); music = NULL; -} - -#endif +} \ No newline at end of file From 49cb1ffe9fb578f8abb29a3f45355ded6211dc03 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 4 Oct 2018 22:38:59 -0400 Subject: [PATCH 348/573] Restore deleted endif --- src/sdl/mixer_sound.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 362d7f264..d1083518a 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -51,8 +51,6 @@ #ifndef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 0 -#endif - #endif #endif @@ -841,4 +839,6 @@ void I_UnRegisterSong(INT32 handle) (void)handle; Mix_FreeMusic(music); music = NULL; -} \ No newline at end of file +} + +#endif \ No newline at end of file From fc5d969642f57f54c12acd137355473f14d84acd Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 4 Oct 2018 22:44:26 -0400 Subject: [PATCH 349/573] Fix DD compiling --- src/win32/win_snd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index f168f1fe3..c030eec5c 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -17,9 +17,6 @@ #include "gme/gme.h" #define GME_TREBLE 5.0 #define GME_BASS 1.0 -#ifdef HAVE_PNG /// TODO: compile with zlib support without libpng - -#define HAVE_ZLIB #ifndef _MSC_VER #ifndef _WII From b812a6a4abdf705d65c6f204291ec6645fe5d729 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 4 Oct 2018 22:56:11 -0400 Subject: [PATCH 350/573] Really fix DD compiling this time. --- src/win32/win_snd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index c030eec5c..bc04bd6df 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -34,6 +34,7 @@ #define _FILE_OFFSET_BITS 0 #endif +#ifdef HAVE_ZLIB #include "zlib.h" #endif #endif From 1ec601af6b989f7ebdc0fa89f4bc2452977ae209 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 5 Oct 2018 22:42:36 +0100 Subject: [PATCH 351/573] Draw a star for continues if invalid skin numbers are somehow supplied --- src/v_video.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index aa2852c01..802a4d388 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -653,14 +653,10 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ // void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT8 skincolor) { - if (skins[skinnum].flags & SF_HIRES -#ifdef HWRENDER -// || (rendermode != render_soft && rendermode != render_none) -#endif - ) - V_DrawScaledPatch(x - 10, y - 14, flags, W_CachePatchName("CONTINS", PU_CACHE)); + if (skinnum < 0 || skinnum >= numskins || (skins[skinnum].flags & SF_HIRES)) + V_DrawScaledPatch(x - 10, y - 14, flags, W_CachePatchName("CONTINS", PU_CACHE)); // Draw a star else - { + { // Find front angle of the first waiting frame of the character's actual sprites spriteframe_t *sprframe = &skins[skinnum].spritedef.spriteframes[2 & FF_FRAMEMASK]; patch_t *patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); const UINT8 *colormap = R_GetTranslationColormap(skinnum, skincolor, GTC_CACHE); From 725a65c1f7eff77e5632b6a7d7fdb11c47ee0c3f Mon Sep 17 00:00:00 2001 From: Sryder Date: Sat, 6 Oct 2018 21:44:40 +0100 Subject: [PATCH 352/573] Call SDL_RWclose after an SDL_RWFromMem call to close the RWops. --- src/sdl/mixer_sound.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 5211efe0a..e835a55ce 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -387,7 +387,15 @@ void *I_GetSfx(sfxinfo_t *sfx) #endif // Try to load it as a WAVE or OGG using Mixer. - return Mix_LoadWAV_RW(SDL_RWFromMem(lump, sfx->length), 1); + SDL_RWops *rw = SDL_RWFromMem(lump, sfx->length); + if (rw != NULL) + { + Mix_Chunk *chunk = Mix_LoadWAV_RW(rw, 1); + SDL_RWclose(rw); + return chunk; + } + + return NULL; // haven't been able to get anything } void I_FreeSfx(sfxinfo_t *sfx) @@ -635,7 +643,12 @@ boolean I_StartDigSong(const char *musicname, boolean looping) } #endif - music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len), SDL_FALSE); + SDL_RWops *rw = SDL_RWFromMem(data, len); + if (rw != NULL) + { + music = Mix_LoadMUS_RW(rw, SDL_FALSE); + SDL_RWclose(rw); + } if (!music) { CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError()); @@ -798,7 +811,12 @@ void I_SetMIDIMusicVolume(UINT8 volume) INT32 I_RegisterSong(void *data, size_t len) { - music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len), SDL_FALSE); + SDL_RWops *rw = SDL_RWFromMem(data, len); + if (rw != NULL) + { + music = Mix_LoadMUS_RW(rw, SDL_FALSE); + SDL_RWclose(rw); + } if (!music) { CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError()); From 7b417b573c61eeaeb325366196d78ace780f1b5a Mon Sep 17 00:00:00 2001 From: Sryder Date: Sat, 6 Oct 2018 23:59:39 +0100 Subject: [PATCH 353/573] Mix_QuickLoad_RAW sets a flag in the Mix_Chunk so that Mix_FreeChunk doesn't actually Free the sound. Checks for the flag when freeing, and if it's 0, we free the data manually after Mix_FreeChunk. I went back to Z_Malloc and Z_Free for this because they still work after this. --- src/sdl/mixer_sound.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index e835a55ce..15f1595ce 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -178,7 +178,7 @@ static Mix_Chunk *ds2chunk(void *stream) return NULL; // would and/or did wrap, can't store. break; } - sound = malloc(newsamples<<2); // samples * frequency shift * bytes per sample * channels + sound = Z_Malloc(newsamples<<2, PU_SOUND, 0); // samples * frequency shift * bytes per sample * channels s = (SINT8 *)stream; d = (INT16 *)sound; @@ -401,7 +401,22 @@ void *I_GetSfx(sfxinfo_t *sfx) void I_FreeSfx(sfxinfo_t *sfx) { if (sfx->data) + { + Mix_Chunk *chunk = (Mix_Chunk*)sfx->data; + UINT8 *abufdata = NULL; + if (chunk->allocated == 0) + { + // We allocated the data in this chunk, so get the abuf from mixer, then let it free the chunk, THEN we free the data + // I believe this should ensure the sound is not playing when we free it + abufdata = chunk->abuf; + } Mix_FreeChunk(sfx->data); + if (abufdata) + { + // I'm going to assume we used Z_Malloc to allocate this data. + Z_Free(abufdata); + } + } sfx->data = NULL; sfx->lumpnum = LUMPERROR; } From d072dd27254596c7c8925b4f6d08c151e57535f2 Mon Sep 17 00:00:00 2001 From: Sryder Date: Sun, 7 Oct 2018 00:22:23 +0100 Subject: [PATCH 354/573] I think that should be NULL, not 0 actually. --- src/sdl/mixer_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 15f1595ce..9fef16460 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -178,7 +178,7 @@ static Mix_Chunk *ds2chunk(void *stream) return NULL; // would and/or did wrap, can't store. break; } - sound = Z_Malloc(newsamples<<2, PU_SOUND, 0); // samples * frequency shift * bytes per sample * channels + sound = Z_Malloc(newsamples<<2, PU_SOUND, NULL); // samples * frequency shift * bytes per sample * channels s = (SINT8 *)stream; d = (INT16 *)sound; From 02597e0bf923c76cb1aed2bd15c285371bdd71ff Mon Sep 17 00:00:00 2001 From: Sryder Date: Sun, 7 Oct 2018 09:26:18 +0100 Subject: [PATCH 355/573] Fix compiler warnings. --- src/sdl/mixer_sound.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 9fef16460..ed15fcdaa 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -246,6 +246,7 @@ void *I_GetSfx(sfxinfo_t *sfx) { void *lump; Mix_Chunk *chunk; + SDL_RWops *rw; #ifdef HAVE_LIBGME Music_Emu *emu; gme_info_t *info; @@ -387,10 +388,10 @@ void *I_GetSfx(sfxinfo_t *sfx) #endif // Try to load it as a WAVE or OGG using Mixer. - SDL_RWops *rw = SDL_RWFromMem(lump, sfx->length); + rw = SDL_RWFromMem(lump, sfx->length); if (rw != NULL) { - Mix_Chunk *chunk = Mix_LoadWAV_RW(rw, 1); + chunk = Mix_LoadWAV_RW(rw, 1); SDL_RWclose(rw); return chunk; } @@ -547,6 +548,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping) char *data; size_t len; lumpnum_t lumpnum = W_CheckNumForName(va("O_%s",musicname)); + SDL_RWops *rw; I_Assert(!music); #ifdef HAVE_LIBGME @@ -658,7 +660,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping) } #endif - SDL_RWops *rw = SDL_RWFromMem(data, len); + rw = SDL_RWFromMem(data, len); if (rw != NULL) { music = Mix_LoadMUS_RW(rw, SDL_FALSE); From fb6c3298702e76ee8a167264cc7dc0e86936f862 Mon Sep 17 00:00:00 2001 From: Sryder Date: Sun, 7 Oct 2018 10:37:45 +0100 Subject: [PATCH 356/573] Fix the crashing bug hopefully A value of 1 in freesrc for Mix_LoadWAV_RW and Mix_LoadMus_RW calls SDL_RWclose on the RWops anyway. For Mix_LoadWAV_RW the RWops is freed right after the data is loaded (because it makes a copy of the data in memory) For Mix_LoadMUS_RW the RWops is freed when Mix_FreeMusic is called (because the data is not a copy) So setting 1 on freesrc doesn't actually free the RWops immediately on Mix_LoadMus_RW *unless* it failed to load any music. --- src/sdl/mixer_sound.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index ed15fcdaa..53a767dfb 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -392,7 +392,6 @@ void *I_GetSfx(sfxinfo_t *sfx) if (rw != NULL) { chunk = Mix_LoadWAV_RW(rw, 1); - SDL_RWclose(rw); return chunk; } @@ -663,8 +662,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping) rw = SDL_RWFromMem(data, len); if (rw != NULL) { - music = Mix_LoadMUS_RW(rw, SDL_FALSE); - SDL_RWclose(rw); + music = Mix_LoadMUS_RW(rw, 1); } if (!music) { @@ -831,8 +829,7 @@ INT32 I_RegisterSong(void *data, size_t len) SDL_RWops *rw = SDL_RWFromMem(data, len); if (rw != NULL) { - music = Mix_LoadMUS_RW(rw, SDL_FALSE); - SDL_RWclose(rw); + music = Mix_LoadMUS_RW(rw, 1); } if (!music) { From b1e02467bfc009d1b08d83a12181fde87869bae0 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 7 Oct 2018 15:00:58 +0100 Subject: [PATCH 357/573] Weather is already run client-side. What if we ran it render-side, for major performance gains? This commit will answer all your questions - and more! --- src/hardware/hw_main.c | 22 ++++++++++++++++++---- src/p_mobj.c | 37 ++++++++++++++++++++----------------- src/p_mobj.h | 4 ++++ src/p_saveg.c | 6 ++---- src/p_spec.c | 34 ++++++++++------------------------ src/p_tick.c | 24 ++++++++++++------------ src/r_things.c | 23 +++++++++++++++++++---- 7 files changed, 85 insertions(+), 65 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d7c73415a..871a6a493 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5140,8 +5140,10 @@ static void HWR_AddSprites(sector_t *sec) approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); - if (approx_dist <= limit_dist) - HWR_ProjectSprite(thing); + if (approx_dist > limit_dist) + continue; + + HWR_ProjectSprite(thing); } } else @@ -5163,8 +5165,10 @@ static void HWR_AddSprites(sector_t *sec) approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); - if (approx_dist <= limit_dist) - HWR_ProjectPrecipitationSprite(precipthing); + if (approx_dist > limit_dist) + continue; + + HWR_ProjectPrecipitationSprite(precipthing); } } else @@ -5449,6 +5453,16 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) x1 = tr_x + x1 * rightcos; x2 = tr_x - x2 * rightcos; + // okay, we can't return now... this is a hack, but weather isn't networked, so it should be ok + if (!(thing->precipflags & PCF_THUNK)) + { + if (thing->precipflags & PCF_RAIN) + P_RainThinker(thing); + else + P_SnowThinker(thing); + thing->precipflags |= PCF_THUNK; + } + // // store information in a vissprite // diff --git a/src/p_mobj.c b/src/p_mobj.c index 5f85474c6..bb9483d18 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3840,7 +3840,8 @@ void P_RecalcPrecipInSector(sector_t *sector) // void P_NullPrecipThinker(precipmobj_t *mobj) { - (void)mobj; + //(void)mobj; + mobj->precipflags &= ~PCF_THUNK; } void P_SnowThinker(precipmobj_t *mobj) @@ -3860,25 +3861,26 @@ void P_RainThinker(precipmobj_t *mobj) { // cycle through states, // calling action functions at transitions - if (mobj->tics > 0 && --mobj->tics == 0) - { - // you can cycle through multiple states in a tic - if (!P_SetPrecipMobjState(mobj, mobj->state->nextstate)) - return; // freed itself - } + if (mobj->tics <= 0) + return; + + if (--mobj->tics) + return; + + if (!P_SetPrecipMobjState(mobj, mobj->state->nextstate)) + return; + + if (mobj->state != &states[S_RAINRETURN]) + return; + + mobj->z = mobj->ceilingz; + P_SetPrecipMobjState(mobj, S_RAIN1); - if (mobj->state == &states[S_RAINRETURN]) - { - mobj->z = mobj->ceilingz; - P_SetPrecipMobjState(mobj, S_RAIN1); - } return; } // adjust height - mobj->z += mobj->momz; - - if (mobj->z <= mobj->floorz) + if ((mobj->z += mobj->momz) <= mobj->floorz) { // no splashes on sky or bottomless pits if (mobj->precipflags & PCF_PIT) @@ -7926,14 +7928,15 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype static inline precipmobj_t *P_SpawnRainMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type); - mo->thinker.function.acp1 = (actionf_p1)P_RainThinker; + mo->precipflags |= PCF_RAIN; + //mo->thinker.function.acp1 = (actionf_p1)P_RainThinker; return mo; } static inline precipmobj_t *P_SpawnSnowMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type); - mo->thinker.function.acp1 = (actionf_p1)P_SnowThinker; + //mo->thinker.function.acp1 = (actionf_p1)P_SnowThinker; return mo; } diff --git a/src/p_mobj.h b/src/p_mobj.h index 79cffae89..620028d81 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -252,6 +252,10 @@ typedef enum { PCF_FOF = 4, // Above MOVING FOF (this means we need to keep floorz up to date...) PCF_MOVINGFOF = 8, + // Is rain. + PCF_RAIN = 16, + // Ran the thinker this tic. + PCF_THUNK = 32, } precipflag_t; // Map Object definition. typedef struct mobj_s diff --git a/src/p_saveg.c b/src/p_saveg.c index d1ec8e5ab..17d28302e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1661,8 +1661,7 @@ static void P_NetArchiveThinkers(void) for (th = thinkercap.next; th != &thinkercap; th = th->next) { if (!(th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed - || th->function.acp1 == (actionf_p1)P_RainThinker - || th->function.acp1 == (actionf_p1)P_SnowThinker)) + || th->function.acp1 == (actionf_p1)P_NullPrecipThinker)) numsaved++; if (th->function.acp1 == (actionf_p1)P_MobjThinker) @@ -1671,8 +1670,7 @@ static void P_NetArchiveThinkers(void) continue; } #ifdef PARANOIA - else if (th->function.acp1 == (actionf_p1)P_RainThinker - || th->function.acp1 == (actionf_p1)P_SnowThinker); + else if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker); #endif else if (th->function.acp1 == (actionf_p1)T_MoveCeiling) { diff --git a/src/p_spec.c b/src/p_spec.c index c62c3b209..ff6691a99 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2039,8 +2039,7 @@ void P_SwitchWeather(INT32 weathernum) for (think = thinkercap.next; think != &thinkercap; think = think->next) { - if ((think->function.acp1 != (actionf_p1)P_SnowThinker) - && (think->function.acp1 != (actionf_p1)P_RainThinker)) + if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker precipmobj = (precipmobj_t *)think; @@ -2056,14 +2055,12 @@ void P_SwitchWeather(INT32 weathernum) for (think = thinkercap.next; think != &thinkercap; think = think->next) { + if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) + continue; // not a precipmobj thinker + precipmobj = (precipmobj_t *)think; + if (swap == PRECIP_RAIN) // Snow To Rain { - if (!(think->function.acp1 == (actionf_p1)P_SnowThinker - || think->function.acp1 == (actionf_p1)P_NullPrecipThinker)) - continue; // not a precipmobj thinker - - precipmobj = (precipmobj_t *)think; - precipmobj->flags = mobjinfo[MT_RAIN].flags; st = &states[mobjinfo[MT_RAIN].spawnstate]; precipmobj->state = st; @@ -2074,18 +2071,13 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->precipflags &= ~PCF_INVISIBLE; - think->function.acp1 = (actionf_p1)P_RainThinker; + precipmobj->precipflags |= PCF_RAIN; + //think->function.acp1 = (actionf_p1)P_RainThinker; } else if (swap == PRECIP_SNOW) // Rain To Snow { INT32 z; - if (!(think->function.acp1 == (actionf_p1)P_RainThinker - || think->function.acp1 == (actionf_p1)P_NullPrecipThinker)) - continue; // not a precipmobj thinker - - precipmobj = (precipmobj_t *)think; - precipmobj->flags = mobjinfo[MT_SNOWFLAKE].flags; z = M_RandomByte(); @@ -2103,19 +2095,13 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->frame = st->frame; precipmobj->momz = mobjinfo[MT_SNOWFLAKE].speed; - precipmobj->precipflags &= ~PCF_INVISIBLE; + precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_RAIN); - think->function.acp1 = (actionf_p1)P_SnowThinker; + //think->function.acp1 = (actionf_p1)P_SnowThinker; } else if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse. { - if (!(think->function.acp1 == (actionf_p1)P_RainThinker - || think->function.acp1 == (actionf_p1)P_SnowThinker)) - continue; - - precipmobj = (precipmobj_t *)think; - - think->function.acp1 = (actionf_p1)P_NullPrecipThinker; + //think->function.acp1 = (actionf_p1)P_NullPrecipThinker; precipmobj->precipflags |= PCF_INVISIBLE; } diff --git a/src/p_tick.c b/src/p_tick.c index f4bc59323..5ba747078 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -56,12 +56,12 @@ void Command_Numthinkers_f(void) CONS_Printf(M_GetText("numthinkers <#>: Count number of thinkers\n")); CONS_Printf( "\t1: P_MobjThinker\n" - "\t2: P_RainThinker\n" - "\t3: P_SnowThinker\n" - "\t4: P_NullPrecipThinker\n" - "\t5: T_Friction\n" - "\t6: T_Pusher\n" - "\t7: P_RemoveThinkerDelayed\n"); + /*"\t2: P_RainThinker\n" + "\t3: P_SnowThinker\n"*/ + "\t2: P_NullPrecipThinker\n" + "\t3: T_Friction\n" + "\t4: T_Pusher\n" + "\t5: P_RemoveThinkerDelayed\n"); return; } @@ -73,27 +73,27 @@ void Command_Numthinkers_f(void) action = (actionf_p1)P_MobjThinker; CONS_Printf(M_GetText("Number of %s: "), "P_MobjThinker"); break; - case 2: + /*case 2: action = (actionf_p1)P_RainThinker; CONS_Printf(M_GetText("Number of %s: "), "P_RainThinker"); break; case 3: action = (actionf_p1)P_SnowThinker; CONS_Printf(M_GetText("Number of %s: "), "P_SnowThinker"); - break; - case 4: + break;*/ + case 2: action = (actionf_p1)P_NullPrecipThinker; CONS_Printf(M_GetText("Number of %s: "), "P_NullPrecipThinker"); break; - case 5: + case 3: action = (actionf_p1)T_Friction; CONS_Printf(M_GetText("Number of %s: "), "T_Friction"); break; - case 6: + case 4: action = (actionf_p1)T_Pusher; CONS_Printf(M_GetText("Number of %s: "), "T_Pusher"); break; - case 7: + case 5: action = (actionf_p1)P_RemoveThinkerDelayed; CONS_Printf(M_GetText("Number of %s: "), "P_RemoveThinkerDelayed"); break; diff --git a/src/r_things.c b/src/r_things.c index 0b1764167..910a52b30 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1451,6 +1451,17 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) return; } + // okay, we can't return now except for vertical clipping... this is a hack, but weather isn't networked, so it should be ok + if (!(thing->precipflags & PCF_THUNK)) + { + if (thing->precipflags & PCF_RAIN) + P_RainThinker(thing); + else + P_SnowThinker(thing); + thing->precipflags |= PCF_THUNK; + } + + //SoM: 3/17/2000: Disregard sprites that are out of view.. gzt = thing->z + spritecachedinfo[lump].topoffset; gz = gzt - spritecachedinfo[lump].height; @@ -1569,8 +1580,10 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); - if (approx_dist <= limit_dist) - R_ProjectSprite(thing); + if (approx_dist > limit_dist) + continue; + + R_ProjectSprite(thing); } } else @@ -1591,8 +1604,10 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); - if (approx_dist <= limit_dist) - R_ProjectPrecipitationSprite(precipthing); + if (approx_dist > limit_dist) + continue; + + R_ProjectPrecipitationSprite(precipthing); } } else From def090c9f0245c148d2313c30c4ef398578d1738 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 7 Oct 2018 14:45:03 -0400 Subject: [PATCH 358/573] Move the ifdef --- src/sdl/mixer_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index d1083518a..1b0974b17 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -52,11 +52,11 @@ #ifndef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 0 #endif -#endif #ifdef HAVE_ZLIB #include "zlib.h" #endif +#endif UINT8 sound_started = false; From 232a7ae7b713c5c5854d0d0205a4fbd5dea9ee47 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 7 Oct 2018 14:52:25 -0400 Subject: [PATCH 359/573] Change order of the ifdef --- src/sdl/mixer_sound.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 1b0974b17..c4d2a8b08 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -39,6 +39,7 @@ #define GME_TREBLE 5.0 #define GME_BASS 1.0 +#ifdef HAVE_ZLIB #ifndef _MSC_VER #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE @@ -53,10 +54,9 @@ #define _FILE_OFFSET_BITS 0 #endif -#ifdef HAVE_ZLIB #include "zlib.h" -#endif -#endif +#endif // HAVE_ZLIB +#endif // HAVE_LIBGME UINT8 sound_started = false; From 027e6e8e3c91777efa302c63ab5eab23e315925d Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 7 Oct 2018 15:00:48 -0400 Subject: [PATCH 360/573] Change win_snd.c also --- src/win32/win_snd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index bc04bd6df..58644457a 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -18,13 +18,12 @@ #define GME_TREBLE 5.0 #define GME_BASS 1.0 +#ifdef HAVE_ZLIB #ifndef _MSC_VER -#ifndef _WII #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif #endif -#endif #ifndef _LFS64_LARGEFILE #define _LFS64_LARGEFILE @@ -34,10 +33,9 @@ #define _FILE_OFFSET_BITS 0 #endif -#ifdef HAVE_ZLIB #include "zlib.h" -#endif -#endif +#endif // HAVE_ZLIB +#endif // HAVE_LIBGME static FMOD_SYSTEM *fsys; static FMOD_SOUND *music_stream; From 1324e0bfcd945651a90c339042523d4f35e89a24 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 8 Oct 2018 18:50:17 +0100 Subject: [PATCH 361/573] * Fix a memory leak regarding implementation of SOC_ (improperly copypasted code from LUA_LoadLump!!) * Optimise the repeated strlen usage into a single call, which is stored for later. --- src/lua_script.c | 12 +++++++----- src/w_wad.c | 15 ++++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index ce96878bf..1c1b01f6c 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -182,19 +182,21 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump) { MYFILE f; char *name; + size_t len; f.wad = wad; f.size = W_LumpLengthPwad(wad, lump); f.data = Z_Malloc(f.size, PU_LUA, NULL); W_ReadLumpPwad(wad, lump, f.data); f.curpos = f.data; - name = malloc(strlen(wadfiles[wad]->filename)+10); + len = strlen(wadfiles[wad]->filename); + name = malloc(len+10); strcpy(name, wadfiles[wad]->filename); - if (!fasticmp(&name[strlen(name) - 4], ".lua")) { + if (!fasticmp(&name[len - 4], ".lua")) { // If it's not a .lua file, copy the lump name in too. - name[strlen(wadfiles[wad]->filename)] = '|'; - M_Memcpy(name+strlen(wadfiles[wad]->filename)+1, wadfiles[wad]->lumpinfo[lump].name, 8); - name[strlen(wadfiles[wad]->filename)+9] = '\0'; + name[len] = '|'; + M_Memcpy(name+len+1, wadfiles[wad]->lumpinfo[lump].name, 8); + name[len+9] = '\0'; } LUA_LoadFile(&f, name); diff --git a/src/w_wad.c b/src/w_wad.c index 3a8285593..3f0082a16 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -194,16 +194,21 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) for (lump = 0; lump < wadfiles[wadnum]->numlumps; lump++, lump_p++) if (memcmp(lump_p->name,"SOC_",4)==0) // Check for generic SOC lump { // shameless copy+paste of code from LUA_LoadLump - char *name = malloc(strlen(wadfiles[wadnum]->filename)+10); + size_t len = strlen(wadfiles[wadnum]->filename); + char *name = malloc(len+10); + strcpy(name, wadfiles[wadnum]->filename); - if (!fasticmp(&name[strlen(name) - 4], ".soc")) { + if (!fasticmp(&name[len - 4], ".soc")) { // If it's not a .soc file, copy the lump name in too. - name[strlen(wadfiles[wadnum]->filename)] = '|'; - M_Memcpy(name+strlen(wadfiles[wadnum]->filename)+1, lump_p->name, 8); - name[strlen(wadfiles[wadnum]->filename)+9] = '\0'; + name[len] = '|'; + M_Memcpy(name+len+1, lump_p->name, 8); + name[len+9] = '\0'; } + CONS_Printf(M_GetText("Loading SOC from %s\n"), name); DEH_LoadDehackedLumpPwad(wadnum, lump); + + free(name); } else if (memcmp(lump_p->name,"MAINCFG",8)==0) // Check for MAINCFG { From 497314fdc44551a46395f41cd579d845d92b270e Mon Sep 17 00:00:00 2001 From: Sryder Date: Tue, 9 Oct 2018 19:43:18 +0100 Subject: [PATCH 362/573] Tiny fix so that joystick2 being closed can let the JoystickSubSystem close before game close. No memory leak here, just a very tiny thing I noticed. --- src/sdl/i_system.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index f92cd4b6e..7b14f1f18 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1154,6 +1154,7 @@ static void I_ShutdownJoystick2(void) D_PostEvent(&event); } + joystick2_started = 0; JoyReset(&JoyInfo2); if (!joystick_started && !joystick2_started && SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) { From 77e85394d8fe59d70b96085f64062118ea261986 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 10 Oct 2018 14:59:44 +0100 Subject: [PATCH 363/573] 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 76eb58c0d..bda146546 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 b9b0a8110c307bdf8457fa66a83a193ad0008461 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 16 Nov 2016 18:43:25 +0000 Subject: [PATCH 364/573] 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 365/573] 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 366/573] 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 367/573] 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 368/573] 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 369/573] 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 370/573] 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 a4419abfdc21d0d0ec69e3d73528a4c9bb68205e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 25 Jan 2017 19:36:32 +0000 Subject: [PATCH 371/573] debugfile is only used by DEBUGFILE code, no need to declare/define it for anything else --- src/d_net.c | 2 ++ src/doomstat.h | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 643c41ac9..8de5cf088 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -49,7 +49,9 @@ doomcom_t *doomcom = NULL; /// \brief network packet data, points inside doomcom doomdata_t *netbuffer = NULL; +#ifdef DEBUGFILE FILE *debugfile = NULL; // put some net info in a file during the game +#endif #define MAXREBOUND 8 static doomdata_t reboundstore[MAXREBOUND]; diff --git a/src/doomstat.h b/src/doomstat.h index 8072a1552..341cc70a9 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -445,19 +445,17 @@ extern mapthing_t *redctfstarts[MAXPLAYERS]; // CTF #if defined (macintosh) #define DEBFILE(msg) I_OutputMsg(msg) -extern FILE *debugfile; #else #define DEBUGFILE #ifdef DEBUGFILE #define DEBFILE(msg) { if (debugfile) { fputs(msg, debugfile); fflush(debugfile); } } -extern FILE *debugfile; #else #define DEBFILE(msg) {} -extern FILE *debugfile; #endif #endif #ifdef DEBUGFILE +extern FILE *debugfile; extern INT32 debugload; #endif From 61a29bed853a737f79fb5aac2c1ceb4ddd758aeb Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Feb 2017 22:41:15 +0000 Subject: [PATCH 372/573] Remove unused sscount variable (it's only set to 0 in software, and only ++'d in OpenGL, what kind of sense does that make?) --- src/hardware/hw_bsp.c | 2 -- src/hardware/hw_main.c | 1 - src/r_main.c | 5 ----- src/r_state.h | 3 --- 4 files changed, 11 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 17eb8761c..a32609fc8 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -564,8 +564,6 @@ static inline void HWR_SubsecPoly(INT32 num, poly_t *poly) subsector_t *sub; seg_t *lseg; - sscount++; - sub = &subsectors[num]; count = sub->numlines; lseg = &segs[sub->firstline]; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 871a6a493..ecb70a0f9 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3264,7 +3264,6 @@ static void HWR_Subsector(size_t num) if (num < numsubsectors) { - sscount++; // subsector sub = &subsectors[num]; // sector diff --git a/src/r_main.c b/src/r_main.c index f2a0c8894..6c92983f4 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -60,7 +60,6 @@ fixed_t projectiony; // aspect ratio // just for profiling purposes size_t framecount; -size_t sscount; size_t loopcount; fixed_t viewx, viewy, viewz; @@ -964,8 +963,6 @@ void R_SkyboxFrame(player_t *player) viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - sscount = 0; - // recalc necessary stuff for mouseaiming // slopes are already calculated for the full possible view (which is 4*viewheight). @@ -1089,8 +1086,6 @@ void R_SetupFrame(player_t *player, boolean skybox) viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - sscount = 0; - // recalc necessary stuff for mouseaiming // slopes are already calculated for the full possible view (which is 4*viewheight). diff --git a/src/r_state.h b/src/r_state.h index 49d0457b2..ac3e1fa42 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -108,7 +108,4 @@ extern angle_t rw_normalangle; // angle to line origin extern angle_t rw_angle1; -// Segs count? -extern size_t sscount; - #endif From 07dd527e7e58e06ce621e80357bef7ae91424f76 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Feb 2017 22:56:08 +0000 Subject: [PATCH 373/573] Removed unused function prototypes in d_main.h Also corrected what appears to be a typo in some comments above? --- src/d_main.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/d_main.h b/src/d_main.h index 6dc273b15..d73b19d1f 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -34,7 +34,7 @@ void D_SRB2Loop(void) FUNCNORETURN; // D_SRB2Main() // Not a globally visible function, just included for source reference, // calls all startup code, parses command line options. -// If not overrided by user input, calls N_AdvanceDemo. +// If not overrided by user input, calls D_AdvanceDemo. // void D_SRB2Main(void); @@ -51,9 +51,6 @@ const char *D_Home(void); // // BASE LEVEL // -void D_PageTicker(void); -// pagename is lumpname of a 320x200 patch to fill the screen -void D_PageDrawer(const char *pagename); void D_AdvanceDemo(void); void D_StartTitle(void); From 91b2f5e570b1b3783b54ca014a11ed07d0570ef4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Feb 2017 23:24:12 +0000 Subject: [PATCH 374/573] "t" is not needed to take out fencepost cases from viewangletox --- src/r_main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 6c92983f4..d1cd71b3f 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -491,9 +491,6 @@ static void R_InitTextureMapping(void) // Take out the fencepost cases from viewangletox. for (i = 0; i < FINEANGLES/2; i++) { - t = FixedMul(FINETANGENT(i), focallength); - t = centerx - t; - if (viewangletox[i] == -1) viewangletox[i] = 0; else if (viewangletox[i] == viewwidth+1) From 49c5a6f7e474ff6aa30a726ae7cbcf9e224fb533 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 11 Feb 2017 23:28:42 +0000 Subject: [PATCH 375/573] Remove unused "runcount" variable from p_local.h --- src/p_local.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_local.h b/src/p_local.h index 1fd7ada04..b82bcf0ec 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -68,7 +68,6 @@ // both the head and tail of the thinker list extern thinker_t thinkercap; -extern INT32 runcount; void P_InitThinkers(void); void P_AddThinker(thinker_t *thinker); From ef78c942f798e0d736cc84de8b912889d9232fbc Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 15 Feb 2017 21:16:56 +0000 Subject: [PATCH 376/573] Remove unused ObjectPlace_OnChange prototype (from when Objectplace was a consvar, which it is not anymore) --- src/d_netcmd.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index d8fae72f7..023bbd094 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -212,7 +212,6 @@ void Command_ExitGame_f(void); void Command_Retry_f(void); void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore void D_MapChange(INT32 pmapnum, INT32 pgametype, boolean pultmode, boolean presetplayers, INT32 pdelay, boolean pskipprecutscene, boolean pfromlevelselect); -void ObjectPlace_OnChange(void); void ItemFinder_OnChange(void); void D_SetPassword(const char *pw); From 9c464742b7d0b10b35ef27dcdad2e72d33e4f8da Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 22 Feb 2017 21:07:29 +0000 Subject: [PATCH 377/573] Remove "playerdeadview" variable; it's not been used for its stated purpose for who knows how long now Besides rankings popping up when you die just sounds weird anyway, maybe I'm just used to SRB2 not doing it I guess --- src/d_clisrv.c | 2 -- src/d_main.c | 1 - src/f_finale.c | 6 ------ src/g_game.c | 1 - src/hu_stuff.h | 3 --- src/p_user.c | 9 --------- 6 files changed, 22 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 6e22dde23..950038237 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1568,8 +1568,6 @@ static void CL_LoadReceivedSavegame(void) automapactive = false; // load a base level - playerdeadview = false; - if (P_LoadNetGame()) { const INT32 actnum = mapheaderinfo[gamemap-1]->actnum; diff --git a/src/d_main.c b/src/d_main.c index df3398752..f807e3070 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -720,7 +720,6 @@ void D_StartTitle(void) maptol = 0; gameaction = ga_nothing; - playerdeadview = false; displayplayer = consoleplayer = 0; //demosequence = -1; gametype = GT_COOP; diff --git a/src/f_finale.c b/src/f_finale.c index a8b27bb80..fb1387c11 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -442,7 +442,6 @@ void F_StartIntro(void) G_SetGamestate(GS_INTRO); gameaction = ga_nothing; - playerdeadview = false; paused = false; CON_ToggleOff(); CON_ClearHUD(); @@ -1130,7 +1129,6 @@ void F_StartCredits(void) } gameaction = ga_nothing; - playerdeadview = false; paused = false; CON_ToggleOff(); CON_ClearHUD(); @@ -1277,7 +1275,6 @@ void F_StartGameEvaluation(void) G_SaveGame((UINT32)cursaveslot); gameaction = ga_nothing; - playerdeadview = false; paused = false; CON_ToggleOff(); CON_ClearHUD(); @@ -1388,7 +1385,6 @@ void F_StartGameEnd(void) G_SetGamestate(GS_GAMEEND); gameaction = ga_nothing; - playerdeadview = false; paused = false; CON_ToggleOff(); CON_ClearHUD(); @@ -1591,7 +1587,6 @@ void F_StartContinue(void) gameaction = ga_nothing; keypressed = false; - playerdeadview = false; paused = false; CON_ToggleOff(); CON_ClearHUD(); @@ -1760,7 +1755,6 @@ void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean reset G_SetGamestate(GS_CUTSCENE); gameaction = ga_nothing; - playerdeadview = false; paused = false; CON_ToggleOff(); diff --git a/src/g_game.c b/src/g_game.c index 4f1c49b42..0e8c14f6a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3616,7 +3616,6 @@ void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, boolean mapmusflags |= MUSIC_RELOADRESET; ultimatemode = pultmode; - playerdeadview = false; automapactive = false; imcontinuing = false; diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 7b22f33f1..5356ba8ac 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -78,9 +78,6 @@ extern boolean chat_on; // set true whenever the tab rankings are being shown for any reason extern boolean hu_showscores; -// P_DeathThink sets this true to show scores while dead, in multiplayer -extern boolean playerdeadview; - // init heads up data at game startup. void HU_Init(void); diff --git a/src/p_user.c b/src/p_user.c index 7abf85347..7e206930d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8648,8 +8648,6 @@ void P_DoPityCheck(player_t *player) // P_PlayerThink // -boolean playerdeadview; // show match/chaos/tag/capture the flag rankings while in death view - void P_PlayerThink(player_t *player) { ticcmd_t *cmd; @@ -8838,10 +8836,6 @@ void P_PlayerThink(player_t *player) if (player->playerstate == PST_DEAD) { player->mo->flags2 &= ~MF2_SHADOW; - // show the multiplayer rankings while dead - if (player == &players[displayplayer]) - playerdeadview = true; - P_DeathThink(player); return; @@ -8862,9 +8856,6 @@ void P_PlayerThink(player_t *player) player->lives = cv_startinglives.value; } - if (player == &players[displayplayer]) - playerdeadview = false; - if ((gametype == GT_RACE || gametype == GT_COMPETITION) && leveltime < 4*TICRATE) { cmd->buttons &= BT_USE; // Remove all buttons except BT_USE From c1d5c711a940fc2e66cbfe53571be01f8bee9420 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 19 Apr 2017 20:00:19 +0100 Subject: [PATCH 378/573] Be gone ye old texture hack --- src/r_data.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index f2c9b1466..ee9144b72 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -472,40 +472,22 @@ void R_LoadTextures(void) } else { - UINT16 patchcount = 1; //CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height); - if (SHORT(patchlump->width) == 64 - && SHORT(patchlump->height) == 64) - { // 64x64 patch - const column_t *column; - for (k = 0; k < SHORT(patchlump->width); k++) - { // Find use of transparency. - column = (const column_t *)((const UINT8 *)patchlump + LONG(patchlump->columnofs[k])); - if (column->length != SHORT(patchlump->height)) - break; - } - if (k == SHORT(patchlump->width)) - patchcount = 2; // No transparency? 64x128 texture. - } - texture = textures[i] = Z_Calloc(sizeof(texture_t) + (sizeof(texpatch_t) * patchcount), PU_STATIC, NULL); + texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); // Set texture properties. M_Memcpy(texture->name, W_CheckNameForNumPwad((UINT16)w, texstart + j), sizeof(texture->name)); texture->width = SHORT(patchlump->width); - texture->height = SHORT(patchlump->height)*patchcount; - texture->patchcount = patchcount; + texture->height = SHORT(patchlump->height); + texture->patchcount = 1; texture->holes = false; // Allocate information for the texture's patches. - for (k = 0; k < patchcount; k++) - { - patch = &texture->patches[k]; + patch = &texture->patches[0]; - patch->originx = 0; - patch->originy = (INT16)(k*patchlump->height); - patch->wad = (UINT16)w; - patch->lump = texstart + j; - } + patch->originx = patch->originy = 0; + patch->wad = (UINT16)w; + patch->lump = texstart + j; Z_Unlock(patchlump); From 31f3f8b8e787f41e4c22ac2d84130f0a02861912 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 18 May 2017 16:54:58 +0100 Subject: [PATCH 379/573] Moved Y_EndGame from y_inter.c/h to g_game.c/h, renamed it to G_EndGame --- src/f_finale.c | 4 ++-- src/g_game.c | 34 +++++++++++++++++++++++++++++++++- src/g_game.h | 1 + src/y_inter.c | 33 +-------------------------------- src/y_inter.h | 1 - 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index a8b27bb80..0a4486928 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1733,7 +1733,7 @@ static void F_AdvanceToNextScene(void) void F_EndCutScene(void) { - cutsceneover = true; // do this first, just in case Y_EndGame or something wants to turn it back false later + cutsceneover = true; // do this first, just in case G_EndGame or something wants to turn it back false later if (runningprecutscene) { if (server) @@ -1748,7 +1748,7 @@ void F_EndCutScene(void) else if (nextmap < 1100-1) G_NextLevel(); else - Y_EndGame(); + G_EndGame(); } } diff --git a/src/g_game.c b/src/g_game.c index 4f1c49b42..25730ce7d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2911,7 +2911,7 @@ void G_AfterIntermission(void) if (nextmap < 1100-1) G_NextLevel(); else - Y_EndGame(); + G_EndGame(); } } @@ -2997,6 +2997,38 @@ static void G_DoContinued(void) gameaction = ga_nothing; } +// +// G_EndGame (formerly Y_EndGame) +// Franky this function fits better in g_game.c than it does in y_inter.c +// +// ...Gee, (why) end the game? +// Because Y_FollowIntermission and F_EndCutscene would +// both do this exact same thing *in different ways* otherwise, +// which made it so that you could only unlock Ultimate mode +// if you had a cutscene after the final level and crap like that. +// This function simplifies it so only one place has to be updated +// when something new is added. +void G_EndGame(void) +{ + // Only do evaluation and credits in coop games. + if (gametype == GT_COOP) + { + if (nextmap == 1102-1) // end game with credits + { + F_StartCredits(); + return; + } + if (nextmap == 1101-1) // end game with evaluation + { + F_StartGameEvaluation(); + return; + } + } + + // 1100 or competitive multiplayer, so go back to title screen. + D_StartTitle(); +} + // // G_LoadGameSettings // diff --git a/src/g_game.h b/src/g_game.h index ada82404c..196ba2ea1 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -171,6 +171,7 @@ void G_NextLevel(void); void G_Continue(void); void G_UseContinue(void); void G_AfterIntermission(void); +void G_EndGame(void); // moved from y_inter.c/h and renamed void G_Ticker(boolean run); boolean G_Responder(event_t *ev); diff --git a/src/y_inter.c b/src/y_inter.c index e7df165bf..37c597305 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1794,37 +1794,6 @@ void Y_EndIntermission(void) usebuffer = false; } -// -// Y_EndGame -// -// Why end the game? -// Because Y_FollowIntermission and F_EndCutscene would -// both do this exact same thing *in different ways* otherwise, -// which made it so that you could only unlock Ultimate mode -// if you had a cutscene after the final level and crap like that. -// This function simplifies it so only one place has to be updated -// when something new is added. -void Y_EndGame(void) -{ - // Only do evaluation and credits in coop games. - if (gametype == GT_COOP) - { - if (nextmap == 1102-1) // end game with credits - { - F_StartCredits(); - return; - } - if (nextmap == 1101-1) // end game with evaluation - { - F_StartGameEvaluation(); - return; - } - } - - // 1100 or competitive multiplayer, so go back to title screen. - D_StartTitle(); -} - // // Y_FollowIntermission // @@ -1850,7 +1819,7 @@ static void Y_FollowIntermission(void) return; } - Y_EndGame(); + G_EndGame(); } #define UNLOAD(x) Z_ChangeTag(x, PU_CACHE); x = NULL diff --git a/src/y_inter.h b/src/y_inter.h index 9fe95fcc4..26f7dc390 100644 --- a/src/y_inter.h +++ b/src/y_inter.h @@ -15,7 +15,6 @@ void Y_IntermissionDrawer(void); void Y_Ticker(void); void Y_StartIntermission(void); void Y_EndIntermission(void); -void Y_EndGame(void); typedef enum { From 2bb7df5f49d90ac9f8c4d80ec5bbfeb11c9a064e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 18 May 2017 17:10:44 +0100 Subject: [PATCH 380/573] G_ExitLevel tweak: Use HU_ClearCEcho() instead of HU_DoCEcho(""), the latter causes an empty line to appear in log.txt --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 25730ce7d..d145fcbef 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2615,7 +2615,7 @@ void G_ExitLevel(void) CONS_Printf(M_GetText("The round has ended.\n")); // Remove CEcho text on round end. - HU_DoCEcho(""); + HU_ClearCEcho(); } } From feceaf6d30144e19ef64e773705b637b242c7b05 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 18 May 2017 17:23:19 +0100 Subject: [PATCH 381/573] Removed all code in Y_FollowIntermission that's already handled in G_AfterIntermission Only real difference here is that CEcho messages will always be cleared when going to credits/evaluation, but that's hardly a loss tbh. --- src/g_game.c | 4 ++-- src/y_inter.c | 19 ++++--------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index d145fcbef..b8df32f90 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2999,10 +2999,10 @@ static void G_DoContinued(void) // // G_EndGame (formerly Y_EndGame) -// Franky this function fits better in g_game.c than it does in y_inter.c +// Frankly this function fits better in g_game.c than it does in y_inter.c // // ...Gee, (why) end the game? -// Because Y_FollowIntermission and F_EndCutscene would +// Because G_AfterIntermission and F_EndCutscene would // both do this exact same thing *in different ways* otherwise, // which made it so that you could only unlock Ultimate mode // if you had a cutscene after the final level and crap like that. diff --git a/src/y_inter.c b/src/y_inter.c index 37c597305..9d41caf36 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1805,21 +1805,10 @@ static void Y_FollowIntermission(void) return; } - if (nextmap < 1100-1) - { - // normal level - G_AfterIntermission(); - return; - } - - // Start a custom cutscene if there is one. - if (mapheaderinfo[gamemap-1]->cutscenenum && !modeattacking) - { - F_StartCustomCutscene(mapheaderinfo[gamemap-1]->cutscenenum-1, false, false); - return; - } - - G_EndGame(); + // This handles whether to play a post-level cutscene, end the game, + // or simply go to the next level. + // No need to duplicate the code here! + G_AfterIntermission(); } #define UNLOAD(x) Z_ChangeTag(x, PU_CACHE); x = NULL From b3faed190b4838ee88f88d75524ad228b690f195 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 11 Oct 2018 16:29:43 -0400 Subject: [PATCH 382/573] 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 8ab4915b5bf83cc336e0666301b84e41807623e8 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 11 Oct 2018 21:44:25 +0100 Subject: [PATCH 383/573] Whoops these should be L not gL here (not that it makes much difference normally though) --- src/dehacked.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index f6288f487..6c39fc197 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8869,17 +8869,17 @@ static int lib_getActionName(lua_State *L) { lua_settop(L, 1); // set top of stack to 1 (removing any extra args, which there shouldn't be) // get the name for this action, if possible. - lua_getfield(gL, LUA_REGISTRYINDEX, LREG_ACTIONS); - lua_pushnil(gL); + lua_getfield(L, LUA_REGISTRYINDEX, LREG_ACTIONS); + lua_pushnil(L); // Lua stack at this point: // 1 ... -2 -1 // arg ... LREG_ACTIONS nil - while (lua_next(gL, -2)) + while (lua_next(L, -2)) { // Lua stack at this point: // 1 ... -3 -2 -1 // arg ... LREG_ACTIONS "A_ACTION" function - if (lua_rawequal(gL, -1, 1)) // is this the same as the arg? + if (lua_rawequal(L, -1, 1)) // is this the same as the arg? { // make sure the key (i.e. "A_ACTION") is a string first // (note: we don't use lua_isstring because it also returns true for numbers) @@ -8888,12 +8888,12 @@ static int lib_getActionName(lua_State *L) lua_pushvalue(L, -2); // push "A_ACTION" string to top of stack return 1; } - lua_pop(gL, 2); // pop the name and function + lua_pop(L, 2); // pop the name and function break; // probably should have succeeded but we didn't, so end the loop } - lua_pop(gL, 1); + lua_pop(L, 1); } - lua_pop(gL, 1); // pop LREG_ACTIONS + lua_pop(L, 1); // pop LREG_ACTIONS return 0; // return nothing (don't error) } From 450b536147b6bf36f879ee0a5ae9164d32f15c72 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 11 Oct 2018 20:11:37 -0400 Subject: [PATCH 384/573] 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 bedfed2f000a65476dece41cfedadfeb4b72d04c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 13 Oct 2018 15:37:11 +0100 Subject: [PATCH 385/573] Move shared code here instead of duplicating it for both dc_numlights and non-dc_numlights rendering code Also added a few comments, and include the out of range check in the "shared code" above --- src/r_segs.c | 97 +++++++++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 54 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 502ff3304..d2600681f 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1039,6 +1039,45 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) { if (maskedtexturecol[dc_x] != INT16_MAX) { + // Calculate bounds + // clamp the values if necessary to avoid overflows and rendering glitches caused by them +#ifdef ESLOPE + if (top_frac > (INT64)CLAMPMAX) sprtopscreen = windowtop = CLAMPMAX; + else if (top_frac > (INT64)CLAMPMIN) sprtopscreen = windowtop = (fixed_t)top_frac; + else sprtopscreen = windowtop = CLAMPMIN; + if (bottom_frac > (INT64)CLAMPMAX) sprbotscreen = windowbottom = CLAMPMAX; + else if (bottom_frac > (INT64)CLAMPMIN) sprbotscreen = windowbottom = (fixed_t)bottom_frac; + else sprbotscreen = windowbottom = CLAMPMIN; + + top_frac += top_step; + bottom_frac += bottom_step; +#else + sprtopscreen = windowtop = (centeryfrac - FixedMul((dc_texturemid - offsetvalue), spryscale)); + sprbotscreen = windowbottom = FixedMul(*pfloor->topheight - *pfloor->bottomheight, spryscale) + sprtopscreen; +#endif + + // SoM: If column is out of range, why bother with it?? + if (windowbottom < topbounds || windowtop > bottombounds) + { + if (dc_numlights) + { + for (i = 0; i < dc_numlights; i++) + { + rlight = &dc_lightlist[i]; + rlight->height += rlight->heightstep; + if (rlight->flags & FF_CUTLEVEL) + rlight->botheight += rlight->botheightstep; + } + } + spryscale += rw_scalestep; + continue; + } + + dc_iscale = 0xffffffffu / (unsigned)spryscale; + + // Get data for the column + col = (column_t *)((UINT8 *)R_GetColumn(texnum,maskedtexturecol[dc_x]) - 3); + // SoM: New code does not rely on R_DrawColumnShadowed_8 which // will (hopefully) put less strain on the stack. if (dc_numlights) @@ -1049,40 +1088,6 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) INT32 solid = 0; INT32 lighteffect = 0; -#ifdef ESLOPE - if (top_frac > (INT64)CLAMPMAX) sprtopscreen = windowtop = CLAMPMAX; - else if (top_frac > (INT64)CLAMPMIN) sprtopscreen = windowtop = (fixed_t)top_frac; - else sprtopscreen = windowtop = CLAMPMIN; - if (bottom_frac > (INT64)CLAMPMAX) sprbotscreen = windowbottom = CLAMPMAX; - else if (bottom_frac > (INT64)CLAMPMIN) sprbotscreen = windowbottom = (fixed_t)bottom_frac; - else sprbotscreen = windowbottom = CLAMPMIN; - - top_frac += top_step; - bottom_frac += bottom_step; -#else - sprtopscreen = windowtop = (centeryfrac - FixedMul((dc_texturemid - offsetvalue), spryscale)); - sprbotscreen = windowbottom = FixedMul(*pfloor->topheight - *pfloor->bottomheight, spryscale) + sprtopscreen; -#endif - - // SoM: If column is out of range, why bother with it?? - if (windowbottom < topbounds || windowtop > bottombounds) - { - for (i = 0; i < dc_numlights; i++) - { - rlight = &dc_lightlist[i]; - rlight->height += rlight->heightstep; - if (rlight->flags & FF_CUTLEVEL) - rlight->botheight += rlight->botheightstep; - } - spryscale += rw_scalestep; - continue; - } - - dc_iscale = 0xffffffffu / (unsigned)spryscale; - - // draw the texture - col = (column_t *)((UINT8 *)R_GetColumn(texnum,maskedtexturecol[dc_x]) - 3); - for (i = 0; i < dc_numlights; i++) { // Check if the current light effects the colormap/lightlevel @@ -1101,7 +1106,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; - if (pindex >= MAXLIGHTSCALE) + if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; if (pfloor->flags & FF_FOG) @@ -1162,6 +1167,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (windowbottom >= sprbotscreen) { windowbottom = sprbotscreen; + // draw the texture colfunc_2s (col); for (i++; i < dc_numlights; i++) { @@ -1172,6 +1178,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) } continue; } + // draw the texture colfunc_2s (col); if (solid) windowtop = bheight; @@ -1181,6 +1188,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) dc_colormap = rlight->rcolormap; } windowbottom = sprbotscreen; + // draw the texture, if there is any space left if (windowtop < windowbottom) colfunc_2s (col); @@ -1200,26 +1208,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (pfloor->flags & FF_FOG && pfloor->master->frontsector->extra_colormap) dc_colormap = pfloor->master->frontsector->extra_colormap->colormap + (dc_colormap - colormaps); -#ifdef ESLOPE - if (top_frac > (INT64)CLAMPMAX) sprtopscreen = windowtop = CLAMPMAX; - else if (top_frac > (INT64)CLAMPMIN) sprtopscreen = windowtop = (fixed_t)top_frac; - else sprtopscreen = windowtop = CLAMPMIN; - if (bottom_frac > (INT64)CLAMPMAX) sprbotscreen = windowbottom = CLAMPMAX; - else if (bottom_frac > (INT64)CLAMPMIN) sprbotscreen = windowbottom = (fixed_t)bottom_frac; - else sprbotscreen = windowbottom = CLAMPMIN; - - top_frac += top_step; - bottom_frac += bottom_step; -#else - sprtopscreen = windowtop = (centeryfrac - FixedMul((dc_texturemid - offsetvalue), spryscale)); - sprbotscreen = windowbottom = FixedMul(*pfloor->topheight - *pfloor->bottomheight, spryscale) + sprtopscreen; -#endif - - dc_iscale = 0xffffffffu / (unsigned)spryscale; - // draw the texture - col = (column_t *)((UINT8 *)R_GetColumn(texnum,maskedtexturecol[dc_x]) - 3); - colfunc_2s (col); spryscale += rw_scalestep; } From 80cbad61c0bbdc9b6c37e3774fae67a7bcf958a7 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 13 Oct 2018 18:57:40 +0100 Subject: [PATCH 386/573] Do lightlist height stepping *after* the heights are used by the FOF rendering code, not before (yes, I caught that they remove a heightstep beforehand for FOFs, but that wasn't done for midtextures it seems?) Additionally add some macros for repeated slope end assignments and overflow tests --- src/r_segs.c | 87 ++++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 54 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index d2600681f..58d8a968e 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -590,8 +590,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) else rlight->rcolormap = xwalllights[pindex]; - rlight->height += rlight->heightstep; height = rlight->height; + rlight->height += rlight->heightstep; if (height <= windowtop) { @@ -827,26 +827,21 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) light = &frontsector->lightlist[i]; rlight = &dc_lightlist[p]; #ifdef ESLOPE - if (light->slope) { - leftheight = P_GetZAt(light->slope, ds->leftpos.x, ds->leftpos.y); - rightheight = P_GetZAt(light->slope, ds->rightpos.x, ds->rightpos.y); - } else - leftheight = rightheight = light->height; - if (*pfloor->b_slope) { - pfloorleft = P_GetZAt(*pfloor->b_slope, ds->leftpos.x, ds->leftpos.y); - pfloorright = P_GetZAt(*pfloor->b_slope, ds->rightpos.x, ds->rightpos.y); - } else - pfloorleft = pfloorright = *pfloor->bottomheight; +#define SLOPEPARAMS(slope, end1, end2, normalheight) \ + if (slope) { \ + end1 = P_GetZAt(slope, ds->leftpos.x, ds->leftpos.y); \ + end2 = P_GetZAt(slope, ds->rightpos.x, ds->rightpos.y); \ + } else \ + end1 = end2 = normalheight; + + SLOPEPARAMS(light->slope, leftheight, rightheight, light->height) + SLOPEPARAMS(*pfloor->b_slope, pfloorleft, pfloorright, *pfloor->bottomheight) if (leftheight < pfloorleft && rightheight < pfloorright) continue; - if (*pfloor->t_slope) { - pfloorleft = P_GetZAt(*pfloor->t_slope, ds->leftpos.x, ds->leftpos.y); - pfloorright = P_GetZAt(*pfloor->t_slope, ds->rightpos.x, ds->rightpos.y); - } else - pfloorleft = pfloorright = *pfloor->topheight; + SLOPEPARAMS(*pfloor->t_slope, pfloorleft, pfloorright, *pfloor->topheight) if (leftheight > pfloorleft && rightheight > pfloorright && i+1 < dc_numlights) { @@ -859,17 +854,17 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) leftheight -= viewz; rightheight -= viewz; - overflow_test = (INT64)centeryfrac - (((INT64)leftheight*ds->scale1)>>FRACBITS); - if (overflow_test < 0) overflow_test = -overflow_test; - if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) continue; - overflow_test = (INT64)centeryfrac - (((INT64)rightheight*ds->scale2)>>FRACBITS); - if (overflow_test < 0) overflow_test = -overflow_test; - if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) continue; +#define OVERFLOWTEST(height, scale) \ + overflow_test = (INT64)centeryfrac - (((INT64)height*scale)>>FRACBITS); \ + if (overflow_test < 0) overflow_test = -overflow_test; \ + if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) continue; + + OVERFLOWTEST(leftheight, ds->scale1) + OVERFLOWTEST(rightheight, ds->scale2) rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1); rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); rlight->heightstep = (rlight->heightstep-rlight->height)/(range); - rlight->height -= rlight->heightstep; #else if (light->height < *pfloor->bottomheight) continue; @@ -879,36 +874,28 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) lheight = light->height;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : light->height; rlight->heightstep = -FixedMul (rw_scalestep, (lheight - viewz)); - rlight->height = (centeryfrac) - FixedMul((lheight - viewz), spryscale) - rlight->heightstep; + rlight->height = (centeryfrac) - FixedMul((lheight - viewz), spryscale); #endif rlight->flags = light->flags; if (light->flags & FF_CUTLEVEL) { #ifdef ESLOPE - if (*light->caster->b_slope) { - leftheight = P_GetZAt(*light->caster->b_slope, ds->leftpos.x, ds->leftpos.y); - rightheight = P_GetZAt(*light->caster->b_slope, ds->rightpos.x, ds->rightpos.y); - } else - leftheight = rightheight = *light->caster->bottomheight; + SLOPEPARAMS(*light->caster->b_slope, leftheight, rightheight, *light->caster->bottomheight) leftheight -= viewz; rightheight -= viewz; - overflow_test = (INT64)centeryfrac - (((INT64)leftheight*ds->scale1)>>FRACBITS); - if (overflow_test < 0) overflow_test = -overflow_test; - if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) continue; - overflow_test = (INT64)centeryfrac - (((INT64)rightheight*ds->scale2)>>FRACBITS); - if (overflow_test < 0) overflow_test = -overflow_test; - if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) continue; + OVERFLOWTEST(leftheight, ds->scale1) + OVERFLOWTEST(rightheight, ds->scale2) +#undef OVERFLOWTEST rlight->botheight = (centeryfrac) - FixedMul(leftheight, ds->scale1); rlight->botheightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range); - rlight->botheight -= rlight->botheightstep; #else lheight = *light->caster->bottomheight;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : *light->caster->bottomheight; rlight->botheightstep = -FixedMul (rw_scalestep, (lheight - viewz)); - rlight->botheight = (centeryfrac) - FixedMul((lheight - viewz), spryscale) - rlight->botheightstep; + rlight->botheight = (centeryfrac) - FixedMul((lheight - viewz), spryscale); #endif } @@ -1001,21 +988,13 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) { fixed_t left_top, right_top, left_bottom, right_bottom; - if (*pfloor->t_slope) - { - left_top = P_GetZAt(*pfloor->t_slope, ds->leftpos.x, ds->leftpos.y) - viewz; - right_top = P_GetZAt(*pfloor->t_slope, ds->rightpos.x, ds->rightpos.y) - viewz; - } - else - left_top = right_top = *pfloor->topheight - viewz; - - if (*pfloor->b_slope) - { - left_bottom = P_GetZAt(*pfloor->b_slope, ds->leftpos.x, ds->leftpos.y) - viewz; - right_bottom = P_GetZAt(*pfloor->b_slope, ds->rightpos.x, ds->rightpos.y) - viewz; - } - else - left_bottom = right_bottom = *pfloor->bottomheight - viewz; + SLOPEPARAMS(*pfloor->t_slope, left_top, right_top, *pfloor->topheight) + SLOPEPARAMS(*pfloor->b_slope, left_bottom, right_bottom, *pfloor->bottomheight) +#undef SLOPEPARAMS + left_top -= viewz; + right_top -= viewz; + left_bottom -= viewz; + right_bottom -= viewz; // using INT64 to avoid 32bit overflow top_frac = (INT64)centeryfrac - (((INT64)left_top * ds->scale1) >> FRACBITS); @@ -1145,13 +1124,13 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else solid = 0; - rlight->height += rlight->heightstep; height = rlight->height; + rlight->height += rlight->heightstep; if (solid) { - rlight->botheight += rlight->botheightstep; bheight = rlight->botheight - (FRACUNIT >> 1); + rlight->botheight += rlight->botheightstep; } if (height <= windowtop) From 6184f91dd3bd82164282c7379d457ffcea5e5a8c Mon Sep 17 00:00:00 2001 From: Sryder Date: Sat, 13 Oct 2018 23:01:11 +0100 Subject: [PATCH 387/573] Add an int to I_PlaySound to tell an interface which channel number SRB2 is using. I've voided this out on other sound interfaces than SDL Mixer ones because I'm both not sure whether they need it, and not sure how to make them work with it if they do. --- src/djgppdos/i_sound.c | 4 +++- src/dummy/i_sound.c | 3 ++- src/i_sound.h | 2 +- src/nds/i_sound.c | 3 ++- src/s_sound.c | 4 ++-- src/sdl/mixer_sound.c | 4 ++-- src/sdl/sdl_sound.c | 3 ++- src/sdl12/mixer_sound.c | 4 ++-- src/sdl12/sdl_sound.c | 3 ++- src/win32/win_snd.c | 3 ++- src/win32ce/win_snd.c | 4 +++- 11 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index 88fc807f4..f1e2ad2bf 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -165,9 +165,11 @@ INT32 I_StartSound ( sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, - INT32 priority ) + INT32 priority + INT32 channel) { int voice; + (void)channel; if (nosound) return 0; diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c index 51dbb610d..143da186c 100644 --- a/src/dummy/i_sound.c +++ b/src/dummy/i_sound.c @@ -23,13 +23,14 @@ void I_UpdateSound(void){}; // SFX I/O // -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority) +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) { (void)id; (void)vol; (void)sep; (void)pitch; (void)priority; + (void)channel; return -1; } diff --git a/src/i_sound.h b/src/i_sound.h index 084479ee1..098c9be17 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -64,7 +64,7 @@ void I_ShutdownSound(void); \return sfx handle */ -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority); +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel); /** \brief Stops a sound channel. diff --git a/src/nds/i_sound.c b/src/nds/i_sound.c index 8dea4ad7d..a17c7f66a 100644 --- a/src/nds/i_sound.c +++ b/src/nds/i_sound.c @@ -21,13 +21,14 @@ void I_ShutdownSound(void){} // SFX I/O // -INT32 I_StartSound(sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, INT32 priority) +INT32 I_StartSound(sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, INT32 priority, INT32 channel) { (void)id; (void)vol; (void)sep; (void)pitch; (void)priority; + (void)channel; return -1; } diff --git a/src/s_sound.c b/src/s_sound.c index 76ee4c649..3b35b36f6 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -529,7 +529,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) // Assigns the handle to one of the channels in the // mix/output buffer. - channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority); + channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority, cnum); } dontplay: @@ -579,7 +579,7 @@ dontplay: // Assigns the handle to one of the channels in the // mix/output buffer. - channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority); + channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority, cnum); } void S_StartSound(const void *origin, sfxenum_t sfx_id) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index cfdb32303..4b4ad3e62 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -419,10 +419,10 @@ void I_FreeSfx(sfxinfo_t *sfx) sfx->lumpnum = LUMPERROR; } -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority) +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) { UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127 - INT32 handle = Mix_PlayChannel(-1, S_sfx[id].data, 0); + INT32 handle = Mix_PlayChannel(channel, S_sfx[id].data, 0); Mix_Volume(handle, volume); Mix_SetPanning(handle, min((UINT16)(0xff-sep)<<1, 0xff), min((UINT16)(sep)<<1, 0xff)); (void)pitch; // Mixer can't handle pitch diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 6c70c163b..a7c8383a3 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -604,10 +604,11 @@ void I_FreeSfx(sfxinfo_t * sfx) // Pitching (that is, increased speed of playback) // is set, but currently not used by mixing. // -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority) +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) { (void)priority; (void)pitch; + (void)channel; if (nosound) return 0; diff --git a/src/sdl12/mixer_sound.c b/src/sdl12/mixer_sound.c index 542a67169..daf09ab91 100644 --- a/src/sdl12/mixer_sound.c +++ b/src/sdl12/mixer_sound.c @@ -376,10 +376,10 @@ void I_FreeSfx(sfxinfo_t *sfx) sfx->data = NULL; } -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority) +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) { UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127 - INT32 handle = Mix_PlayChannel(-1, S_sfx[id].data, 0); + INT32 handle = Mix_PlayChannel(channel, S_sfx[id].data, 0); Mix_Volume(handle, volume); Mix_SetPanning(handle, min((UINT16)(0xff-sep)<<1, 0xff), min((UINT16)(sep)<<1, 0xff)); (void)pitch; // Mixer can't handle pitch diff --git a/src/sdl12/sdl_sound.c b/src/sdl12/sdl_sound.c index 6ba83104e..01a27153e 100644 --- a/src/sdl12/sdl_sound.c +++ b/src/sdl12/sdl_sound.c @@ -621,10 +621,11 @@ void I_FreeSfx(sfxinfo_t * sfx) // Pitching (that is, increased speed of playback) // is set, but currently not used by mixing. // -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority) +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) { (void)priority; (void)pitch; + (void)channel; if (nosound) return 0; diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 58644457a..e50a4737e 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -353,12 +353,13 @@ void I_FreeSfx(sfxinfo_t *sfx) sfx->data = NULL; } -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority) +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) { FMOD_SOUND *sound; FMOD_CHANNEL *chan; INT32 i; float frequency; + (void)channel; sound = (FMOD_SOUND *)S_sfx[id].data; I_Assert(sound != NULL); diff --git a/src/win32ce/win_snd.c b/src/win32ce/win_snd.c index f9c652178..a58bbc3ce 100644 --- a/src/win32ce/win_snd.c +++ b/src/win32ce/win_snd.c @@ -538,7 +538,8 @@ INT32 I_StartSound (sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, - INT32 priority) + INT32 priority + INT32 channel) { HRESULT hr; LPDIRECTSOUNDBUFFER dsbuffer; @@ -549,6 +550,7 @@ INT32 I_StartSound (sfxenum_t id, #ifdef SURROUND LPDIRECTSOUNDBUFFER dssurround; #endif + (void)channel; if (nosound) return -1; From 3886888b3014da650aa2ae5bd843b8ef7dcea28f Mon Sep 17 00:00:00 2001 From: Sryder Date: Sun, 14 Oct 2018 10:14:07 +0100 Subject: [PATCH 388/573] Fix missing commas and missed interface --- src/android/i_sound.c | 3 ++- src/djgppdos/i_sound.c | 2 +- src/win32ce/win_snd.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/android/i_sound.c b/src/android/i_sound.c index ecf96f2f0..77f8e6a55 100644 --- a/src/android/i_sound.c +++ b/src/android/i_sound.c @@ -21,13 +21,14 @@ void I_ShutdownSound(void){} // SFX I/O // -INT32 I_StartSound(sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, INT32 priority) +INT32 I_StartSound(sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, INT32 priority, INT32 channel) { (void)id; (void)vol; (void)sep; (void)pitch; (void)priority; + (void)channel; return -1; } diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index f1e2ad2bf..ec6f4412f 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -165,7 +165,7 @@ INT32 I_StartSound ( sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, - INT32 priority + INT32 priority, INT32 channel) { int voice; diff --git a/src/win32ce/win_snd.c b/src/win32ce/win_snd.c index a58bbc3ce..14ce4add4 100644 --- a/src/win32ce/win_snd.c +++ b/src/win32ce/win_snd.c @@ -538,7 +538,7 @@ INT32 I_StartSound (sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, - INT32 priority + INT32 priority, INT32 channel) { HRESULT hr; From 7d612011949d117f568f99c6012084bb6056f67a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 20 Oct 2018 12:54:40 +0100 Subject: [PATCH 389/573] Fix slipup from when the smashing spikeballs from HHZ were hardcoded --- src/info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/info.c b/src/info.c index 728fb13c0..3140bd7de 100644 --- a/src/info.c +++ b/src/info.c @@ -3458,8 +3458,8 @@ state_t states[NUMSTATES] = {SPR_FMCE, 0, 20, {NULL}, 0, 0, S_SMASHSPIKE_EASE1}, // S_SMASHSPIKE_FLOAT {SPR_FMCE, 0, 4, {A_ZThrust}, 4, (1<<16)|1, S_SMASHSPIKE_EASE2}, // S_SMASHSPIKE_EASE1 - {SPR_FMCE, 0, 4, {A_ZThrust}, 0, (1<<16)|1, S_SMASHSPIKE_FALL}, // S_SMASHSPIKE_EASE1 - {SPR_FMCE, 0, 2, {A_ZThrust}, -6, (1<<16)|1, S_SMASHSPIKE_FALL}, // S_SMASHSPIKE_FALL + {SPR_FMCE, 0, 4, {A_ZThrust}, 0, (1<<16)|1, S_SMASHSPIKE_FALL}, // S_SMASHSPIKE_EASE2 + {SPR_FMCE, 0, 2, {A_ZThrust}, -6, 1, S_SMASHSPIKE_FALL}, // S_SMASHSPIKE_FALL {SPR_FMCE, 1, 2, {A_MultiShotDist}, (MT_DUST<<16)|10, -48, S_SMASHSPIKE_STOMP2}, // S_SMASHSPIKE_STOMP1 {SPR_FMCE, 2, 14, {NULL}, 0, 0, S_SMASHSPIKE_RISE1}, // S_SMASHSPIKE_STOMP2 {SPR_FMCE, 1, 2, {NULL}, 0, 0, S_SMASHSPIKE_RISE2}, // S_SMASHSPIKE_RISE1 From 61fa7026a107e30688bf836e0fc7c6a7c9f77861 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 20 Oct 2018 19:00:37 +0100 Subject: [PATCH 390/573] 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 391/573] 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 392/573] 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 393/573] 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 394/573] 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 395/573] 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 396/573] 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 397/573] 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 398/573] 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 399/573] 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 400/573] 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 401/573] 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 402/573] 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 403/573] 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 404/573] 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 405/573] 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 406/573] 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 407/573] 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 408/573] 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 409/573] 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 410/573] 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 411/573] 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 412/573] 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 413/573] 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 414/573] 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 415/573] 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 3d0daf220282bf88673894d42b537e1a6a21c3ee Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Mon, 29 Oct 2018 00:49:23 +0100 Subject: [PATCH 416/573] Fix desynch when toggling analog mode or flipcam Special thanks to Lat' for asking weird questions --- src/d_clisrv.c | 12 ------------ src/d_netcmd.c | 8 ++++---- src/g_game.c | 10 ---------- src/r_main.c | 10 ---------- 4 files changed, 4 insertions(+), 36 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7d0e44b45..fc80e56b4 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3097,12 +3097,6 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) displayplayer = newplayernum; secondarydisplayplayer = newplayernum; DEBFILE("spawning me\n"); - // Apply player flags as soon as possible! - players[newplayernum].pflags &= ~(PF_FLIPCAM|PF_ANALOGMODE); - if (cv_flipcam.value) - players[newplayernum].pflags |= PF_FLIPCAM; - if (cv_analog.value) - players[newplayernum].pflags |= PF_ANALOGMODE; } else { @@ -3110,12 +3104,6 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) DEBFILE("spawning my brother\n"); if (botingame) players[newplayernum].bot = 1; - // Same goes for player 2 when relevant - players[newplayernum].pflags &= ~(PF_FLIPCAM|PF_ANALOGMODE); - if (cv_flipcam2.value) - players[newplayernum].pflags |= PF_FLIPCAM; - if (cv_analog2.value) - players[newplayernum].pflags |= PF_ANALOGMODE; } D_SendPlayerConfig(); addedtogame = true; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 673d64fd8..e4ac8d9b8 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1369,9 +1369,9 @@ void SendWeaponPref(void) XBOXSTATIC UINT8 buf[1]; buf[0] = 0; - if (players[consoleplayer].pflags & PF_FLIPCAM) + if (cv_flipcam.value) buf[0] |= 1; - if (players[consoleplayer].pflags & PF_ANALOGMODE) + if (cv_analog.value) buf[0] |= 2; SendNetXCmd(XD_WEAPONPREF, buf, 1); } @@ -1381,9 +1381,9 @@ void SendWeaponPref2(void) XBOXSTATIC UINT8 buf[1]; buf[0] = 0; - if (players[secondarydisplayplayer].pflags & PF_FLIPCAM) + if (cv_flipcam2.value) buf[0] |= 1; - if (players[secondarydisplayplayer].pflags & PF_ANALOGMODE) + if (cv_analog2.value) buf[0] |= 2; SendNetXCmd2(XD_WEAPONPREF, buf, 1); } diff --git a/src/g_game.c b/src/g_game.c index d3c55e0cc..e2f35ad13 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1575,11 +1575,6 @@ static void Analog_OnChange(void) return; } - if (cv_analog.value) - players[consoleplayer].pflags |= PF_ANALOGMODE; - else - players[consoleplayer].pflags &= ~PF_ANALOGMODE; - SendWeaponPref(); } @@ -1600,11 +1595,6 @@ static void Analog2_OnChange(void) return; } - if (cv_analog2.value) - players[secondarydisplayplayer].pflags |= PF_ANALOGMODE; - else - players[secondarydisplayplayer].pflags &= ~PF_ANALOGMODE; - SendWeaponPref2(); } diff --git a/src/r_main.c b/src/r_main.c index e50e80013..7d5d16994 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -222,21 +222,11 @@ static void ChaseCam2_OnChange(void) static void FlipCam_OnChange(void) { - if (cv_flipcam.value) - players[consoleplayer].pflags |= PF_FLIPCAM; - else - players[consoleplayer].pflags &= ~PF_FLIPCAM; - SendWeaponPref(); } static void FlipCam2_OnChange(void) { - if (cv_flipcam2.value) - players[secondarydisplayplayer].pflags |= PF_FLIPCAM; - else - players[secondarydisplayplayer].pflags &= ~PF_FLIPCAM; - SendWeaponPref2(); } From 834a5e6b3530a5ed3cc89b3528b8f35ea8689b55 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 29 Oct 2018 12:06:22 +0000 Subject: [PATCH 417/573] 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 418/573] 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 419/573] 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 420/573] 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 421/573] 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 422/573] 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 423/573] 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 424/573] 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 425/573] 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 426/573] 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 427/573] 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 428/573] 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 15020ae01d1819e27af1a39f5eed434f8dd8cf71 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 10:57:43 -0400 Subject: [PATCH 429/573] Removed TextPrompt-specific code for `text-prompt` branch --- src/st_stuff.c | 19 ------------------- src/v_video.c | 19 ------------------- src/v_video.h | 1 - 3 files changed, 39 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index d4c710e97..fa13e008a 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2465,21 +2465,6 @@ static void ST_overlayDrawer(void) ST_drawDebugInfo(); } -static void ST_drawTutorial(void) -{ - INT32 charheight = 8; - INT32 y = BASEVIDHEIGHT - ((charheight * 4) + (charheight/2)*4); - char *test; - //INT32 i; - // Nothing, ...yet - // Except this for now, just to check it works - //V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, "Tutorial placeholder"); - V_DrawTutorialBack(); - //for (i = 0; i < 4; i++, y += 12) - test = V_WordWrap(4, BASEVIDWIDTH-4, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"); - V_DrawString(4, y, V_SNAPTOBOTTOM, test); -} - void ST_Drawer(void) { #ifdef SEENAMES @@ -2553,8 +2538,4 @@ void ST_Drawer(void) ST_overlayDrawer(); } } - - // Draw tutorial text over everything else - if (tutorialmode) - ST_drawTutorial(); } diff --git a/src/v_video.c b/src/v_video.c index 05401ce56..765965ffd 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1480,25 +1480,6 @@ void V_DrawFadeConsBack(INT32 plines) *buf = consolebgmap[*buf]; } -// Very similar to F_DrawFadeConsBack, except we draw from the middle(-ish) of the screen to the bottom. -void V_DrawTutorialBack(void) -{ - INT32 charheight = 8*vid.dupy; - UINT8 *deststop, *buf; - -#ifdef HWRENDER - if (rendermode != render_soft) // no support for OpenGL yet - return; -#endif - - // heavily simplified -- we don't need to know x or y position, - // just the start and stop positions - deststop = screens[0] + vid.rowbytes * vid.height; - buf = deststop - vid.rowbytes * ((charheight * 4) + (charheight/2)*5); // 4 lines of space plus gaps between and some leeway - for (; buf < deststop; ++buf) - *buf = consolebgmap[*buf]; -} - // Gets string colormap, used for 0x80 color codes // static const UINT8 *V_GetStringColormap(INT32 colorflags) diff --git a/src/v_video.h b/src/v_video.h index 850206816..6113d08ec 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -158,7 +158,6 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum); void V_DrawFadeScreen(UINT16 color, UINT8 strength); void V_DrawFadeConsBack(INT32 plines); -void V_DrawTutorialBack(void); // draw a single character void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed); From cf6a6991cbd9f1710bef5ac70739a1efa4745ab2 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 4 Nov 2018 16:28:25 -0500 Subject: [PATCH 430/573] Trigger line exec by whether mobj is facing its tracer * MFE_TRACERANGLE * Thing 758 MT_ANGLEMAN * mobj thinker behavior * Line Exec 457/458 Enable/Disable --- src/dehacked.c | 1 + src/info.c | 27 +++++++++++++++++++++++++++ src/info.h | 1 + src/p_mobj.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/p_mobj.h | 3 +++ src/p_spec.c | 35 +++++++++++++++++++++++++++++++++++ 6 files changed, 107 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index 6c39fc197..9ccefa9ce 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -6937,6 +6937,7 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s "MT_PULL", "MT_GHOST", "MT_OVERLAY", + "MT_ANGLEMAN", "MT_POLYANCHOR", "MT_POLYSPAWN", "MT_POLYSPAWNCRUSH", diff --git a/src/info.c b/src/info.c index 3140bd7de..72abcede1 100644 --- a/src/info.c +++ b/src/info.c @@ -17814,6 +17814,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_ANGLEMAN + 758, // doomednum + S_INVISIBLE, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 8, // radius + 8, // height + 0, // display offset + 10, // mass + 0, // damage + sfx_None, // activesound + MF_NOTHINK|MF_NOBLOCKMAP|MF_NOGRAVITY, // flags + S_NULL // raisestate + }, + { // MT_POLYANCHOR 760, // doomednum S_INVISIBLE, // spawnstate diff --git a/src/info.h b/src/info.h index b757deec0..c9de82541 100644 --- a/src/info.h +++ b/src/info.h @@ -4305,6 +4305,7 @@ typedef enum mobj_type MT_PULL, MT_GHOST, MT_OVERLAY, + MT_ANGLEMAN, MT_POLYANCHOR, MT_POLYSPAWN, MT_POLYSPAWNCRUSH, diff --git a/src/p_mobj.c b/src/p_mobj.c index 717bb92b6..45a26cbc5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7435,6 +7435,46 @@ void P_MobjThinker(mobj_t *mobj) if ((mobj->flags & MF_ENEMY) && (mobj->state->nextstate == mobj->info->spawnstate && mobj->tics == 1)) mobj->flags2 &= ~MF2_FRET; + // Angle-to-tracer to trigger a linedef exec + // See Linedef Exec 457 (Track mobj angle to point) + if ((mobj->eflags & MFE_TRACERANGLE) && mobj->tracer && mobj->extravalue2) + { + // mobj->lastlook - Don't disable behavior after first failure + // mobj->extravalue1 - Angle tolerance + // mobj->extravalue2 - Exec tag upon failure + // mobj->cvval - Allowable failure delay + // mobj->cvmem - Failure timer + + angle_t ang = mobj->angle - R_PointToAngle2(mobj->x, mobj->y, mobj->tracer->x, mobj->tracer->y); + + // \todo account for distance between mobj and tracer + // Because closer mobjs can be facing beyond the angle tolerance + // yet tracer is still in the camera view + + // failure state: mobj is not facing tracer + // Reasaonable defaults: ANGLE_67h, ANGLE_292h + if (ang >= mobj->extravalue1 && ang <= ANGLE_MAX - mobj->extravalue1) + { + if (mobj->cvmem) + mobj->cvmem--; + else + { + P_LinedefExecute(mobj->extravalue2, mobj, NULL); + + if (mobj->lastlook) + mobj->cvmem = mobj->cusval; // reset timer for next failure + else + { + // disable after first failure + mobj->eflags &= ~MFE_TRACERANGLE; + mobj->lastlook = mobj->extravalue1 = mobj->extravalue2 = mobj->cvmem = mobj->cusval = 0; + } + } + } + else + mobj->cvmem = mobj->cusval; // reset failure timer + } + switch (mobj->type) { case MT_WALLSPIKEBASE: diff --git a/src/p_mobj.h b/src/p_mobj.h index 5c0408e1b..b80080674 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -239,6 +239,9 @@ typedef enum MFE_SPRUNG = 1<<8, // Platform movement MFE_APPLYPMOMZ = 1<<9, + // Compute and trigger on mobj angle relative to tracer + // See Linedef Exec 457 (Track mobj angle to point) + MFE_TRACERANGLE = 1<<10, // free: to and including 1<<15 } mobjeflag_t; diff --git a/src/p_spec.c b/src/p_spec.c index 9f9e80ecc..6bf20283e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3757,6 +3757,41 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_ResetColormapFader(§ors[secnum]); break; + case 457: // Track mobj angle to point + if (mo) + { + INT32 failureangle = min(max(abs(sides[line->sidenum[0]].textureoffset>>FRACBITS), 0), 360) * ANG1; + INT32 failuredelay = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + INT32 failureexectag = line->sidenum[1] != 0xffff ? + (INT32)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : 0; + boolean persist = (line->flags & ML_EFFECT2); + mobj_t *anchormo; + + if ((secnum = P_FindSectorFromLineTag(line, -1)) < 0) + return; + + anchormo = P_GetObjectTypeInSectorNum(MT_ANGLEMAN, secnum); + if (!anchormo) + return; + + mo->eflags |= MFE_TRACERANGLE; + P_SetTarget(&mo->tracer, anchormo); + mo->lastlook = persist; // don't disable behavior after first failure + mo->extravalue1 = failureangle; // angle to exceed for failure state + mo->extravalue2 = failureexectag; // exec tag for failure state (angle is not within range) + mo->cusval = mo->cvmem = failuredelay; // cusval = tics to allow failure before line trigger; cvmem = decrement timer + } + break; + + case 458: // Stop tracking mobj angle to point + if (mo) + { + mo->eflags &= ~MFE_TRACERANGLE; + P_SetTarget(&mo->tracer, NULL); + mo->lastlook = mo->cvmem = mo->cusval = mo->extravalue1 = mo->extravalue2 = 0; + } + break; + #ifdef POLYOBJECTS case 480: // Polyobj_DoorSlide case 481: // Polyobj_DoorSwing From 4fc335a26b16b7290dc274181264436ff4799d67 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 4 Nov 2018 16:48:18 -0500 Subject: [PATCH 431/573] Line 458: Only do disable operation if MFE_TRACERANGLE is set --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 6bf20283e..965e0cbe0 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3784,7 +3784,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 458: // Stop tracking mobj angle to point - if (mo) + if (mo && (mo->eflags & MFE_TRACERANGLE)) { mo->eflags &= ~MFE_TRACERANGLE; P_SetTarget(&mo->tracer, NULL); From eaf89cf7b919422d0b033c54a53297026fcfd9bc Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 4 Nov 2018 17:34:00 -0500 Subject: [PATCH 432/573] TRACERANGLE: Run exec *after* resetting mobj values --- src/p_mobj.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 45a26cbc5..c9cacb444 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7459,7 +7459,7 @@ void P_MobjThinker(mobj_t *mobj) mobj->cvmem--; else { - P_LinedefExecute(mobj->extravalue2, mobj, NULL); + INT32 exectag = mobj->extravalue2; // remember this before we erase the values if (mobj->lastlook) mobj->cvmem = mobj->cusval; // reset timer for next failure @@ -7469,6 +7469,8 @@ void P_MobjThinker(mobj_t *mobj) mobj->eflags &= ~MFE_TRACERANGLE; mobj->lastlook = mobj->extravalue1 = mobj->extravalue2 = mobj->cvmem = mobj->cusval = 0; } + + P_LinedefExecute(exectag, mobj, NULL); } } else From b7c6661c76db66d4158875c60bdf37525b080d86 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 4 Nov 2018 20:16:33 -0500 Subject: [PATCH 433/573] Add MTF_EXTRA flag to monitors, to run linedef exec by Angle (Tag + 16384) upon pop --- src/p_enemy.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_enemy.c b/src/p_enemy.c index 8088c20a8..15608f57f 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3324,6 +3324,11 @@ void A_MonitorPop(mobj_t *actor) newmobj->sprite = SPR_TV1P; } } + + // Run a linedef executor immediately upon popping + // You may want to delay your effects by 18 tics to sync with the reward giving + if (actor->spawnpoint && (actor->spawnpoint->options & MTF_EXTRA) && (actor->spawnpoint->angle & 16384)) + P_LinedefExecute((actor->spawnpoint->angle & 16383), actor->target, NULL); } // Function: A_GoldMonitorPop From 77447492ecf02bf3b487c9a24bf624b270b80ab5 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 4 Sep 2018 19:21:58 +0100 Subject: [PATCH 434/573] Add V_DrawTutorialBack for drawing a console-like background box, add Lorem ipsum as filler test --- src/v_video.c | 19 +++++++++++++++++++ src/v_video.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/v_video.c b/src/v_video.c index 2f84d4c7e..06f96a605 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1480,6 +1480,25 @@ void V_DrawFadeConsBack(INT32 plines) *buf = consolebgmap[*buf]; } +// Very similar to F_DrawFadeConsBack, except we draw from the middle(-ish) of the screen to the bottom. +void V_DrawTutorialBack(void) +{ + INT32 charheight = 8*vid.dupy; + UINT8 *deststop, *buf; + +#ifdef HWRENDER + if (rendermode != render_soft) // no support for OpenGL yet + return; +#endif + + // heavily simplified -- we don't need to know x or y position, + // just the start and stop positions + deststop = screens[0] + vid.rowbytes * vid.height; + buf = deststop - vid.rowbytes * ((charheight * 4) + (charheight/2)*5); // 4 lines of space plus gaps between and some leeway + for (; buf < deststop; ++buf) + *buf = consolebgmap[*buf]; +} + // Gets string colormap, used for 0x80 color codes // static const UINT8 *V_GetStringColormap(INT32 colorflags) diff --git a/src/v_video.h b/src/v_video.h index 6113d08ec..850206816 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -158,6 +158,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum); void V_DrawFadeScreen(UINT16 color, UINT8 strength); void V_DrawFadeConsBack(INT32 plines); +void V_DrawTutorialBack(void); // draw a single character void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed); From 95c68c331a79e1837efc41e208c87d0079deaa1f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 01:27:32 -0400 Subject: [PATCH 435/573] TextPrompt/Page freeslots; SOC Prompt/Page parsing --- src/dehacked.c | 222 +++++++++++++++++++++++++++++++++++++++++++++++++ src/doomstat.h | 22 +++++ src/g_game.c | 1 + 3 files changed, 245 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index 6c39fc197..9f48b5f57 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1545,6 +1545,218 @@ static void readcutscene(MYFILE *f, INT32 num) Z_Free(s); } +static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) +{ + char *s = Z_Calloc(MAXLINELEN, PU_STATIC, NULL); + char *word; + char *word2; + INT32 i; + UINT16 usi; + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + word = strtok(s, " "); + if (word) + strupr(word); + else + break; + + if (fastcmp(word, "PAGETEXT")) + { + char *pagetext = NULL; + char *buffer; + const int bufferlen = 4096; + + for (i = 0; i < MAXLINELEN; i++) + { + if (s[i] == '=') + { + pagetext = &s[i+2]; + break; + } + } + + if (!pagetext) + { + Z_Free(textprompts[num]->page[pagenum].text); + textprompts[num]->page[pagenum].text = NULL; + continue; + } + + for (i = 0; i < MAXLINELEN; i++) + { + if (s[i] == '\0') + { + s[i] = '\n'; + s[i+1] = '\0'; + break; + } + } + + buffer = Z_Malloc(4096, PU_STATIC, NULL); + strcpy(buffer, pagetext); + + strcat(buffer, + myhashfgets(pagetext, bufferlen + - strlen(buffer) - 1, f)); + + // A text prompt overwriting another one... + Z_Free(textprompts[num]->page[pagenum].text); + + textprompts[num]->page[pagenum].text = Z_StrDup(buffer); + + Z_Free(buffer); + + continue; + } + + word2 = strtok(NULL, " = "); + if (word2) + strupr(word2); + else + break; + + if (word2[strlen(word2)-1] == '\n') + word2[strlen(word2)-1] = '\0'; + i = atoi(word2); + usi = (UINT16)i; + + + if (fastcmp(word, "NAME")) + strncpy(textprompts[num]->page[pagenum].name, word2, 32); + else if (fastcmp(word, "ICON")) + strncpy(textprompts[num]->page[pagenum].iconname, word2, 8); + else if (fastcmp(word, "ICONALIGN")) + textprompts[num]->page[pagenum].rightside = (i || word2[0] == 'R'); + else if (fastcmp(word, "LINES")) + textprompts[num]->page[pagenum].lines = usi; + else if (fastcmp(word, "BACKCOLOR")) + { + UINT8 backcolor; + if (usi == 0 || fastcmp(word2, "WHITE")) backcolor = 0; + else if (usi == 1 || fastcmp(word2, "GRAY") || fastcmp(word2, "GREY")) backcolor = 1; + else if (usi == 2 || fastcmp(word2, "BROWN")) backcolor = 2; + else if (usi == 3 || fastcmp(word2, "RED")) backcolor = 3; + else if (usi == 4 || fastcmp(word2, "ORANGE")) backcolor = 4; + else if (usi == 5 || fastcmp(word2, "YELLOW")) backcolor = 5; + else if (usi == 6 || fastcmp(word2, "GREEN")) backcolor = 6; + else if (usi == 7 || fastcmp(word2, "BLUE")) backcolor = 7; + else if (usi == 8 || fastcmp(word2, "PURPLE")) backcolor = 8; + else if (usi == 9 || fastcmp(word2, "MAGENTA")) backcolor = 9; + else if (usi == 10 || fastcmp(word2, "AQUA")) backcolor = 10; + else if (usi < 0) backcolor = UINT8_MAX; // CONS_BACKCOLOR user-configured + else backcolor = 11; // default green + textprompts[num]->page[pagenum].backcolor = backcolor; + } + else if (fastcmp(word, "ALIGN")) + { + UINT8 align = 0; // left + if (usi == 1 || word2[0] == 'R') align = 1; + else if (usi == 2 || word2[0] == 'C' || word2[0] == 'M') align = 2; + textprompts[num]->page[pagenum].align = align; + } + else if (fastcmp(word, "VERTICALALIGN")) + { + UINT8 align = 0; // top + if (usi == 1 || word2[0] == 'B') align = 1; + else if (usi == 2 || word2[0] == 'C' || word2[0] == 'M') align = 2; + textprompts[num]->page[pagenum].verticalalign = align; + } + else if (fastcmp(word, "TEXTSPEED")) + textprompts[num]->page[pagenum].textspeed = min(max(0, usi), 15); + else if (fastcmp(word, "TEXTSFX")) + textprompts[num]->page[pagenum].textsfx = get_number(word2); + else if (fastcmp(word, "METAPAGE")) + { + if (usi <= textprompts[num]->numpages) + { + strncpy(textprompts[num]->page[pagenum].name, textprompts[num]->page[usi].name, 32); + strncpy(textprompts[num]->page[pagenum].iconname, textprompts[num]->page[usi].iconname, 8); + textprompts[num]->page[pagenum].rightside = textprompts[num]->page[usi].rightside; + textprompts[num]->page[pagenum].lines = textprompts[num]->page[usi].lines; + textprompts[num]->page[pagenum].backcolor = textprompts[num]->page[usi].backcolor; + textprompts[num]->page[pagenum].align = textprompts[num]->page[usi].align; + textprompts[num]->page[pagenum].verticalalign = textprompts[num]->page[usi].verticalalign; + textprompts[num]->page[pagenum].textspeed = textprompts[num]->page[usi].textspeed; + textprompts[num]->page[pagenum].textsfx = textprompts[num]->page[usi].textsfx; + } + } + else + deh_warning("PromptPage %d: unknown word '%s'", num, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + +static void readtextprompt(MYFILE *f, INT32 num) +{ + char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); + char *word; + char *word2; + char *tmp; + INT32 value; + + // Allocate memory for this prompt if we don't yet have any + if (!textprompts[num]) + textprompts[num] = Z_Calloc(sizeof (textprompt_t), PU_STATIC, NULL); + + do + { + if (myfgets(s, MAXLINELEN, f)) + { + if (s[0] == '\n') + break; + + tmp = strchr(s, '#'); + if (tmp) + *tmp = '\0'; + if (s == tmp) + continue; // Skip comment lines, but don't break. + + word = strtok(s, " "); + if (word) + strupr(word); + else + break; + + word2 = strtok(NULL, " "); + if (word2) + value = atoi(word2); + else + { + deh_warning("No value for token %s", word); + continue; + } + + if (fastcmp(word, "NUMPAGES")) + { + textprompts[num]->numpages = value; + } + else if (fastcmp(word, "PAGE")) + { + if (1 <= value && value <= 128) + { + textprompts[num]->page[value - 1].backcolor = UINT8_MAX; // non-zero default + readtextpromptpage(f, num, value - 1); + } + else + deh_warning("Page number %d out of range (1 - 128)", value); + + } + else + deh_warning("Prompt %d: unknown word '%s', Page expected.", num, word); + } + } while (!myfeof(f)); // finish when the line is empty + + Z_Free(s); +} + static void readhuditem(MYFILE *f, INT32 num) { char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); @@ -3214,6 +3426,16 @@ static void DEH_LoadDehackedFile(MYFILE *f) ignorelines(f); } } + else if (fastcmp(word, "PROMPT")) + { + if (i > 0 && i < 257) + readtextprompt(f, i - 1); + else + { + deh_warning("Prompt number %d out of range (1 - 256)", i); + ignorelines(f); + } + } else if (fastcmp(word, "FRAME") || fastcmp(word, "STATE")) { if (i == 0 && word2[0] != '0') // If word2 isn't a number diff --git a/src/doomstat.h b/src/doomstat.h index 7678c86b7..d737ef451 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -166,6 +166,28 @@ typedef struct extern cutscene_t *cutscenes[128]; +typedef struct +{ + char name[32]; // narrator name + char iconname[8]; // narrator icon lump + boolean rightside; // narrator side, false = left, true = right + UINT8 lines; // # of lines to show. If name is specified, name takes one of the lines. If 0, defaults to 4. + UINT8 backcolor; // see CON_SetupBackColormap: 0-10, 11 for default, UINT8_MAX for user-defined (CONS_BACKCOLOR) + UINT8 align; // text alignment, 0 = left, 1 = right, 2 = center + UINT8 verticalalign; // vertical text alignment, 0 = top, 1 = bottom, 2 = middle + UINT8 textspeed; // text speed 0-15, makes it slower. See f_finale.c F_WriteText + sfxenum_t textsfx; // sfx_ id for printing text + char *text; +} textpage_t; + +typedef struct +{ + textpage_t page[128]; // 128 pages per prompt. + INT32 numpages; // Number of pages in this prompt +} textprompt_t; + +extern textprompt_t *textprompts[256]; + // For the Custom Exit linedef. extern INT16 nextmapoverride; extern boolean skipstats; diff --git a/src/g_game.c b/src/g_game.c index 0a392fa85..df8e0fd79 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -138,6 +138,7 @@ tic_t countdowntimer = 0; boolean countdowntimeup = false; cutscene_t *cutscenes[128]; +textprompt_t *textprompts[256]; INT16 nextmapoverride; boolean skipstats; From ef241b4521fb4ece6eae1f6e46756adebbb5194c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 04:38:16 -0400 Subject: [PATCH 436/573] Broken attempt at supporting linebreaks for PageText, like cutscenes --- src/dehacked.c | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 9f48b5f57..963285cff 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -146,7 +146,7 @@ char *myfgets(char *buf, size_t bufsize, MYFILE *f) return buf; } -static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f) +static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f, boolean trim) { size_t i = 0; if (myfeof(f)) @@ -165,11 +165,34 @@ static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f) if (c == '\n') // Ensure debug line is right... dbg_line++; if (c == '#') + { + if (i > 0) + i--; // don't include the hash in our string break; + } } - i++; - buf[i] = '\0'; + // HACK: BS code to make sure i doesn't wrap past 0 + // and put the terminator char AFTER the first non-whitespace char + // OR at position 0 if the first char is whitespace OR a hash + if (trim) // trailing whitespace only + { + if (i > 0) + i--; // current char may be '#', so skip that + while (i < bufsize && i > 0 && !myfeof(f)) + { + char c = buf[i]; + if (i > 0) + i--; + if ((c != '\r' && c != '\n' && c != ' ') || i == 0) + break; + } + if (buf[i] != '\r' && buf[i] != '\n' && buf[i] != ' ' && buf[i] != '#') + i++; // put the null character after the first non-whitespace char + } + + buf[i] = '\0'; + CONS_Printf("%s", buf); return buf; } @@ -352,7 +375,7 @@ static void readPlayer(MYFILE *f, INT32 num) if (playertext) { strcpy(description[num].notes, playertext); - strcat(description[num].notes, myhashfgets(playertext, sizeof (description[num].notes), f)); + strcat(description[num].notes, myhashfgets(playertext, sizeof (description[num].notes), f, false)); } else strcpy(description[num].notes, ""); @@ -1368,7 +1391,7 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) strcat(buffer, myhashfgets(scenetext, bufferlen - - strlen(buffer) - 1, f)); + - strlen(buffer) - 1, f, false)); // A cutscene overwriting another one... Z_Free(cutscenes[num]->scene[scenenum].text); @@ -1603,7 +1626,7 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) strcat(buffer, myhashfgets(pagetext, bufferlen - - strlen(buffer) - 1, f)); + - strlen(buffer) - 1, f, true)); // A text prompt overwriting another one... Z_Free(textprompts[num]->page[pagenum].text); @@ -1628,7 +1651,16 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) if (fastcmp(word, "NAME")) - strncpy(textprompts[num]->page[pagenum].name, word2, 32); + { + // HACK: Add yellow control char now + // so the drawing function doesn't call it repeatedly + char name[32]; + name[0] = '\x82'; // color yellow + name[1] = 0; + strncat(name, word2, 31); + name[31] = 0; + strncpy(textprompts[num]->page[pagenum].name, name, 32); + } else if (fastcmp(word, "ICON")) strncpy(textprompts[num]->page[pagenum].iconname, word2, 8); else if (fastcmp(word, "ICONALIGN")) From a3d000a37ecf21c93994252e1d4370cc9eb35161 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 05:04:09 -0400 Subject: [PATCH 437/573] Kind of support line breaks with PAGETEXT. Can't trim trailing whitespace yet. --- src/dehacked.c | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 963285cff..b439f43de 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -146,7 +146,7 @@ char *myfgets(char *buf, size_t bufsize, MYFILE *f) return buf; } -static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f, boolean trim) +static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f) { size_t i = 0; if (myfeof(f)) @@ -166,33 +166,15 @@ static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f, boolean trim) dbg_line++; if (c == '#') { - if (i > 0) - i--; // don't include the hash in our string + if (i > 0) // don't let i wrap past 0 + i--; // don't include hash char in string break; } } - - // HACK: BS code to make sure i doesn't wrap past 0 - // and put the terminator char AFTER the first non-whitespace char - // OR at position 0 if the first char is whitespace OR a hash - if (trim) // trailing whitespace only - { - if (i > 0) - i--; // current char may be '#', so skip that - while (i < bufsize && i > 0 && !myfeof(f)) - { - char c = buf[i]; - if (i > 0) - i--; - if ((c != '\r' && c != '\n' && c != ' ') || i == 0) - break; - } - if (buf[i] != '\r' && buf[i] != '\n' && buf[i] != ' ' && buf[i] != '#') - i++; // put the null character after the first non-whitespace char - } - + if (buf[i] != '#') // don't include hash char in string + i++; buf[i] = '\0'; - CONS_Printf("%s", buf); + return buf; } @@ -375,7 +357,7 @@ static void readPlayer(MYFILE *f, INT32 num) if (playertext) { strcpy(description[num].notes, playertext); - strcat(description[num].notes, myhashfgets(playertext, sizeof (description[num].notes), f, false)); + strcat(description[num].notes, myhashfgets(playertext, sizeof (description[num].notes), f)); } else strcpy(description[num].notes, ""); @@ -1391,7 +1373,7 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) strcat(buffer, myhashfgets(scenetext, bufferlen - - strlen(buffer) - 1, f, false)); + - strlen(buffer) - 1, f)); // A cutscene overwriting another one... Z_Free(cutscenes[num]->scene[scenenum].text); @@ -1624,9 +1606,12 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) buffer = Z_Malloc(4096, PU_STATIC, NULL); strcpy(buffer, pagetext); + // \todo trim trailing whitespace before the # + // and also support # at the end of a PAGETEXT with no line break + strcat(buffer, myhashfgets(pagetext, bufferlen - - strlen(buffer) - 1, f, true)); + - strlen(buffer) - 1, f)); // A text prompt overwriting another one... Z_Free(textprompts[num]->page[pagenum].text); From cbcb6a0d6c7d072540931043603ebbf853e33832 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 05:05:15 -0400 Subject: [PATCH 438/573] Text prompt features: Name, Icon, IconAlign, Lines --- src/st_stuff.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/v_video.c | 7 ++++--- src/v_video.h | 2 +- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index fa13e008a..2a9d25cc7 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2465,6 +2465,49 @@ static void ST_overlayDrawer(void) ST_drawDebugInfo(); } +static void ST_drawTutorial(INT32 promptnum, INT32 pagenum) +{ + lumpnum_t iconlump = W_CheckNumForName(textprompts[promptnum]->page[pagenum].iconname); + UINT8 pagelines = textprompts[promptnum]->page[pagenum].lines ? textprompts[promptnum]->page[pagenum].lines : 4; + + // Vertical calculations + INT32 boxh = pagelines*2; + INT32 texth = textprompts[promptnum]->page[pagenum].name[0] ? (pagelines-1)*2 : pagelines*2; // name takes up first line if it exists + INT32 texty = BASEVIDHEIGHT - ((texth * 4) + (texth/2)*4); + INT32 namey = BASEVIDHEIGHT - ((boxh * 4) + (boxh/2)*4); + + // Horizontal calculations + // Shift text to the right if we have a character icon on the left side + // Add 4 margin against icon + INT32 textx = iconlump != LUMPERROR && !textprompts[promptnum]->page[pagenum].rightside ? ((boxh * 4) + (boxh/2)*4) + 4 : 4; + INT32 textr = textprompts[promptnum]->page[pagenum].rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4) + 4) : BASEVIDWIDTH-4; + + // Data + patch_t *patch; + char *text; + + // Draw background + V_DrawTutorialBack(boxh); + + // Draw narrator icon + if (iconlump != LUMPERROR) + { + INT32 iconx = textprompts[promptnum]->page[pagenum].rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4)) : 4; + patch = W_CachePatchName(textprompts[promptnum]->page[pagenum].iconname, PU_CACHE); + V_DrawFixedPatch(iconx<width), 0, patch, NULL); + W_UnlockCachedPatch(patch); + } + + // Draw text + // \todo Char-by-char printing, see f_finale.c F_WriteText + text = V_WordWrap(textx, textr, 0, textprompts[promptnum]->page[pagenum].text); + V_DrawString(textx, texty, V_SNAPTOBOTTOM, text); + + // Draw name + if (textprompts[promptnum]->page[pagenum].name[0]) + V_DrawString(textx, namey, V_SNAPTOBOTTOM, textprompts[promptnum]->page[pagenum].name); +} + void ST_Drawer(void) { #ifdef SEENAMES @@ -2538,4 +2581,8 @@ void ST_Drawer(void) ST_overlayDrawer(); } } + + // Draw tutorial text over everything else + //if (tutorialmode) + ST_drawTutorial(0, 0); } diff --git a/src/v_video.c b/src/v_video.c index 06f96a605..a628b1a8b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1481,11 +1481,12 @@ void V_DrawFadeConsBack(INT32 plines) } // Very similar to F_DrawFadeConsBack, except we draw from the middle(-ish) of the screen to the bottom. -void V_DrawTutorialBack(void) +void V_DrawTutorialBack(INT32 boxheight) { - INT32 charheight = 8*vid.dupy; UINT8 *deststop, *buf; + boxheight *= vid.dupy; + #ifdef HWRENDER if (rendermode != render_soft) // no support for OpenGL yet return; @@ -1494,7 +1495,7 @@ void V_DrawTutorialBack(void) // heavily simplified -- we don't need to know x or y position, // just the start and stop positions deststop = screens[0] + vid.rowbytes * vid.height; - buf = deststop - vid.rowbytes * ((charheight * 4) + (charheight/2)*5); // 4 lines of space plus gaps between and some leeway + buf = deststop - vid.rowbytes * ((boxheight * 4) + (boxheight/2)*5); // 4 lines of space plus gaps between and some leeway for (; buf < deststop; ++buf) *buf = consolebgmap[*buf]; } diff --git a/src/v_video.h b/src/v_video.h index 850206816..ee958c2fa 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -158,7 +158,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum); void V_DrawFadeScreen(UINT16 color, UINT8 strength); void V_DrawFadeConsBack(INT32 plines); -void V_DrawTutorialBack(void); +void V_DrawTutorialBack(INT32 boxheight); // draw a single character void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed); From 63e5cfecffd2cc3266cbce002ce6b9ddc722d9ba Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 05:06:18 -0400 Subject: [PATCH 439/573] Linedef Exec 449 Control Text Prompt - beginnings --- src/p_spec.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index 9f9e80ecc..571e6277f 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3455,6 +3455,29 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } break; + case 449: // Control Text Prompt +#if 0 + // console player only unless NOCLIMB is set + if ((line->flags & ML_NOCLIMB) || (mo && mo->player && P_IsLocalPlayer(mo->player))) + { + INT32 promptnum = abs(sides[line->sidenum[0]].textureoffset>>FRACBITS); + INT32 pagenum = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + INT32 postexectag = (line->sidenum[1] != 0xFFFF) ? abs(sides[line->sidenum[1]].textureoffset>>FRACBITS) : 0; + INT32 closedelay = (line->sidenum[1] != 0xFFFF) ? abs(sides[line->sidenum[1]].rowoffset>>FRACBITS) : 0; + + boolean blockcontrols = !(line->flags & ML_BLOCKMONSTERS); + boolean closetextprompt = (line->flags & ML_EFFECT2); + boolean runpostexec = (line->flags & ML_EFFECT1); + boolean freezethinkers = (line->flags & ML_TFERLINE); + + // if (closetextprompt && !promptnum) + // P_CloseTextPromptEx(closedelay, runpostexec ? postexectag : 0, mo); + // else + // P_ControlTextPromptEx(promptnum, pagenum, closetextprompt ? closedelay : 0, runpostexec ? postexectag : 0, mo, blockcontrols, freezethinkers); + } +#endif + break; + case 450: // Execute Linedef Executor - for recursion P_LinedefExecute(line->tag, mo, NULL); break; From edcdf79b60d23ad4dc97377a40674c6a988bbe82 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 09:13:17 -0400 Subject: [PATCH 440/573] Text prompt: Fix V_DrawFixedPatch call for non-green resos --- src/st_stuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 2a9d25cc7..ce5042971 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2494,7 +2494,7 @@ static void ST_drawTutorial(INT32 promptnum, INT32 pagenum) { INT32 iconx = textprompts[promptnum]->page[pagenum].rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4)) : 4; patch = W_CachePatchName(textprompts[promptnum]->page[pagenum].iconname, PU_CACHE); - V_DrawFixedPatch(iconx<width), 0, patch, NULL); + V_DrawFixedPatch(iconx<width), V_SNAPTOBOTTOM, patch, NULL); W_UnlockCachedPatch(patch); } From 1855359ac0a167091a1ad5dd70ef64361564f618 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 10:54:30 -0400 Subject: [PATCH 441/573] Moved TextPrompt logic to f_finale.c * Added basic TextPrompt ticker and drawer functions * Added chevron animation --- src/d_main.c | 1 + src/f_finale.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/f_finale.h | 5 +++ src/g_game.c | 1 + src/st_stuff.c | 47 -------------------------- 5 files changed, 99 insertions(+), 47 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 6cd6aaba6..6f9d46f36 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -424,6 +424,7 @@ static void D_Display(void) if (gamestate == GS_LEVEL) { ST_Drawer(); + F_TextPromptDrawer(); HU_Drawer(); } else diff --git a/src/f_finale.c b/src/f_finale.c index 151889c4c..c25dd9eca 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -48,6 +48,7 @@ static INT32 timetonext; // Delay between screen changes static INT32 continuetime; // Short delay when continuing static tic_t animtimer; // Used for some animation timings +static INT16 skullAnimCounter; // Chevron animation static INT32 roidtics; // Asteroid spinning static INT32 deplete; @@ -78,6 +79,8 @@ static patch_t *ttspop7; static void F_SkyScroll(INT32 scrollspeed); +static boolean promptactive = false; + // // CUTSCENE TEXT WRITING // @@ -2015,3 +2018,92 @@ boolean F_CutsceneResponder(event_t *event) return false; } + +void F_EndTextPrompt(void) +{ + promptactive = false; +} + +void F_StartTextPrompt(INT32 promptnum, INT32 pagenum) +{ + // We share vars, so no starting text prompts over cutscenes or title screens! + keypressed = false; + finalecount = 0; + timetonext = 0; + animtimer = 0; + stoptimer = 0; + skullAnimCounter = 0; + + cutnum = promptnum; + scenenum = pagenum; + promptactive = true; +} + +void F_TextPromptDrawer(void) +{ + // reuse: + // cutnum -> promptnum + // scenenum -> pagenum + + if (!promptactive) + return; + + lumpnum_t iconlump = W_CheckNumForName(textprompts[cutnum]->page[scenenum].iconname); + UINT8 pagelines = textprompts[cutnum]->page[scenenum].lines ? textprompts[cutnum]->page[scenenum].lines : 4; + + // Vertical calculations + INT32 boxh = pagelines*2; + INT32 texth = textprompts[cutnum]->page[scenenum].name[0] ? (pagelines-1)*2 : pagelines*2; // name takes up first line if it exists + INT32 texty = BASEVIDHEIGHT - ((texth * 4) + (texth/2)*4); + INT32 namey = BASEVIDHEIGHT - ((boxh * 4) + (boxh/2)*4); + INT32 chevrony = BASEVIDHEIGHT - (((1*2) * 4) + ((1*2)/2)*4); // force on last line + + // Horizontal calculations + // Shift text to the right if we have a character icon on the left side + // Add 4 margin against icon + INT32 textx = iconlump != LUMPERROR && !textprompts[cutnum]->page[scenenum].rightside ? ((boxh * 4) + (boxh/2)*4) + 4 : 4; + INT32 textr = textprompts[cutnum]->page[scenenum].rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4) + 4) : BASEVIDWIDTH-4; + + // Data + patch_t *patch; + char *text; + + // Draw background + V_DrawTutorialBack(boxh); + + // Draw narrator icon + if (iconlump != LUMPERROR) + { + INT32 iconx = textprompts[cutnum]->page[scenenum].rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4)) : 4; + patch = W_CachePatchName(textprompts[cutnum]->page[scenenum].iconname, PU_CACHE); + V_DrawFixedPatch(iconx<width), V_SNAPTOBOTTOM, patch, NULL); + W_UnlockCachedPatch(patch); + } + + // Draw text + // \todo Char-by-char printing, see f_finale.c F_WriteText + text = V_WordWrap(textx, textr, 0, textprompts[cutnum]->page[scenenum].text); + V_DrawString(textx, texty, V_SNAPTOBOTTOM, text); + + // Draw name + // Don't use V_YELLOWMAP here so that the name color can be changed with control codes + if (textprompts[cutnum]->page[scenenum].name[0]) + V_DrawString(textx, namey, V_SNAPTOBOTTOM, textprompts[cutnum]->page[scenenum].name); + + // Draw chevron + V_DrawString(textr-8, chevrony + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); // down arrow +} + +void F_TextPromptTicker(void) +{ + if (!promptactive) + return; + + // advance animation + finalecount++; + cutscene_boostspeed = 0; + + // for the chevron + if (--skullAnimCounter <= 0) + skullAnimCounter = 8; +} diff --git a/src/f_finale.h b/src/f_finale.h index aadc64ad0..eb5872fca 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -33,6 +33,7 @@ void F_IntroTicker(void); void F_TitleScreenTicker(boolean run); void F_CutsceneTicker(void); void F_TitleDemoTicker(void); +void F_TextPromptTicker(void); // Called by main loop. FUNCMATH void F_GameEndDrawer(void); @@ -50,6 +51,10 @@ void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean reset void F_CutsceneDrawer(void); void F_EndCutScene(void); +void F_StartTextPrompt(INT32 promptnum, INT32 pagenum); +void F_TextPromptDrawer(void); +void F_EndTextPrompt(void); + void F_StartGameEnd(void); void F_StartIntro(void); void F_StartTitleScreen(void); diff --git a/src/g_game.c b/src/g_game.c index df8e0fd79..d72a1961b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1934,6 +1934,7 @@ void G_Ticker(boolean run) F_TitleDemoTicker(); P_Ticker(run); // tic the game ST_Ticker(); + F_TextPromptTicker(); AM_Ticker(); HU_Ticker(); break; diff --git a/src/st_stuff.c b/src/st_stuff.c index ce5042971..fa13e008a 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2465,49 +2465,6 @@ static void ST_overlayDrawer(void) ST_drawDebugInfo(); } -static void ST_drawTutorial(INT32 promptnum, INT32 pagenum) -{ - lumpnum_t iconlump = W_CheckNumForName(textprompts[promptnum]->page[pagenum].iconname); - UINT8 pagelines = textprompts[promptnum]->page[pagenum].lines ? textprompts[promptnum]->page[pagenum].lines : 4; - - // Vertical calculations - INT32 boxh = pagelines*2; - INT32 texth = textprompts[promptnum]->page[pagenum].name[0] ? (pagelines-1)*2 : pagelines*2; // name takes up first line if it exists - INT32 texty = BASEVIDHEIGHT - ((texth * 4) + (texth/2)*4); - INT32 namey = BASEVIDHEIGHT - ((boxh * 4) + (boxh/2)*4); - - // Horizontal calculations - // Shift text to the right if we have a character icon on the left side - // Add 4 margin against icon - INT32 textx = iconlump != LUMPERROR && !textprompts[promptnum]->page[pagenum].rightside ? ((boxh * 4) + (boxh/2)*4) + 4 : 4; - INT32 textr = textprompts[promptnum]->page[pagenum].rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4) + 4) : BASEVIDWIDTH-4; - - // Data - patch_t *patch; - char *text; - - // Draw background - V_DrawTutorialBack(boxh); - - // Draw narrator icon - if (iconlump != LUMPERROR) - { - INT32 iconx = textprompts[promptnum]->page[pagenum].rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4)) : 4; - patch = W_CachePatchName(textprompts[promptnum]->page[pagenum].iconname, PU_CACHE); - V_DrawFixedPatch(iconx<width), V_SNAPTOBOTTOM, patch, NULL); - W_UnlockCachedPatch(patch); - } - - // Draw text - // \todo Char-by-char printing, see f_finale.c F_WriteText - text = V_WordWrap(textx, textr, 0, textprompts[promptnum]->page[pagenum].text); - V_DrawString(textx, texty, V_SNAPTOBOTTOM, text); - - // Draw name - if (textprompts[promptnum]->page[pagenum].name[0]) - V_DrawString(textx, namey, V_SNAPTOBOTTOM, textprompts[promptnum]->page[pagenum].name); -} - void ST_Drawer(void) { #ifdef SEENAMES @@ -2581,8 +2538,4 @@ void ST_Drawer(void) ST_overlayDrawer(); } } - - // Draw tutorial text over everything else - //if (tutorialmode) - ST_drawTutorial(0, 0); } From 7778507a703679e20ae1f0f5fcbbbfac15a43f46 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 10:54:47 -0400 Subject: [PATCH 442/573] Basic TextPrompt line action implemented --- src/p_spec.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 571e6277f..8f93b84a1 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -35,6 +35,7 @@ #include "m_misc.h" #include "m_cond.h" //unlock triggers #include "lua_hook.h" // LUAh_LinedefExecute +#include "f_finale.h" // control text prompt #ifdef HW3SOUND #include "hardware/hw3sound.h" @@ -3456,26 +3457,33 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 449: // Control Text Prompt -#if 0 // console player only unless NOCLIMB is set if ((line->flags & ML_NOCLIMB) || (mo && mo->player && P_IsLocalPlayer(mo->player))) { - INT32 promptnum = abs(sides[line->sidenum[0]].textureoffset>>FRACBITS); - INT32 pagenum = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + INT32 promptnum = max(0, (sides[line->sidenum[0]].textureoffset>>FRACBITS)-1); + INT32 pagenum = max(0, (sides[line->sidenum[0]].rowoffset>>FRACBITS)-1); + + boolean closetextprompt = (line->flags & ML_EFFECT2); + + if (closetextprompt) + F_EndTextPrompt(); + else + F_StartTextPrompt(promptnum, pagenum); +#if 0 + INT32 postexectag = (line->sidenum[1] != 0xFFFF) ? abs(sides[line->sidenum[1]].textureoffset>>FRACBITS) : 0; INT32 closedelay = (line->sidenum[1] != 0xFFFF) ? abs(sides[line->sidenum[1]].rowoffset>>FRACBITS) : 0; boolean blockcontrols = !(line->flags & ML_BLOCKMONSTERS); - boolean closetextprompt = (line->flags & ML_EFFECT2); boolean runpostexec = (line->flags & ML_EFFECT1); boolean freezethinkers = (line->flags & ML_TFERLINE); // if (closetextprompt && !promptnum) - // P_CloseTextPromptEx(closedelay, runpostexec ? postexectag : 0, mo); + // F_EndTextPrompt(closedelay, runpostexec ? postexectag : 0, mo); // else - // P_ControlTextPromptEx(promptnum, pagenum, closetextprompt ? closedelay : 0, runpostexec ? postexectag : 0, mo, blockcontrols, freezethinkers); - } + // F_StartTextPrompt(promptnum, pagenum, closetextprompt ? closedelay : 0, runpostexec ? postexectag : 0, mo, blockcontrols, freezethinkers); #endif + } break; case 450: // Execute Linedef Executor - for recursion From 5f1052729c5db69c51bb6abc75919564e4ea4f86 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 11:12:27 -0400 Subject: [PATCH 443/573] Line 449 param rearranging --- src/p_spec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 8f93b84a1..2771c85f7 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3463,7 +3463,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT32 promptnum = max(0, (sides[line->sidenum[0]].textureoffset>>FRACBITS)-1); INT32 pagenum = max(0, (sides[line->sidenum[0]].rowoffset>>FRACBITS)-1); - boolean closetextprompt = (line->flags & ML_EFFECT2); + boolean closetextprompt = (line->flags & ML_BLOCKMONSTERS); if (closetextprompt) F_EndTextPrompt(); @@ -3474,9 +3474,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT32 postexectag = (line->sidenum[1] != 0xFFFF) ? abs(sides[line->sidenum[1]].textureoffset>>FRACBITS) : 0; INT32 closedelay = (line->sidenum[1] != 0xFFFF) ? abs(sides[line->sidenum[1]].rowoffset>>FRACBITS) : 0; - boolean blockcontrols = !(line->flags & ML_BLOCKMONSTERS); boolean runpostexec = (line->flags & ML_EFFECT1); - boolean freezethinkers = (line->flags & ML_TFERLINE); + boolean blockcontrols = !(line->flags & ML_EFFECT2); + boolean freezetimer = !(line->flags & ML_EFFECT3); + boolean freezethinkers = (line->flags & ML_EFFECT4); // if (closetextprompt && !promptnum) // F_EndTextPrompt(closedelay, runpostexec ? postexectag : 0, mo); From 971151ab836590126e7c6ba5e957fe03c5d01252 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 13:06:05 -0400 Subject: [PATCH 444/573] Fixes: MetaPage, AdvanceToNextPage, center/scale icons, button handling --- src/dehacked.c | 25 +++++++----- src/doomstat.h | 2 + src/f_finale.c | 107 +++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 116 insertions(+), 18 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index b439f43de..2b466fab7 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1690,19 +1690,24 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) textprompts[num]->page[pagenum].textsfx = get_number(word2); else if (fastcmp(word, "METAPAGE")) { - if (usi <= textprompts[num]->numpages) + if (usi && usi <= textprompts[num]->numpages) { - strncpy(textprompts[num]->page[pagenum].name, textprompts[num]->page[usi].name, 32); - strncpy(textprompts[num]->page[pagenum].iconname, textprompts[num]->page[usi].iconname, 8); - textprompts[num]->page[pagenum].rightside = textprompts[num]->page[usi].rightside; - textprompts[num]->page[pagenum].lines = textprompts[num]->page[usi].lines; - textprompts[num]->page[pagenum].backcolor = textprompts[num]->page[usi].backcolor; - textprompts[num]->page[pagenum].align = textprompts[num]->page[usi].align; - textprompts[num]->page[pagenum].verticalalign = textprompts[num]->page[usi].verticalalign; - textprompts[num]->page[pagenum].textspeed = textprompts[num]->page[usi].textspeed; - textprompts[num]->page[pagenum].textsfx = textprompts[num]->page[usi].textsfx; + UINT8 metapagenum = usi - 1; + strncpy(textprompts[num]->page[pagenum].name, textprompts[num]->page[metapagenum].name, 32); + strncpy(textprompts[num]->page[pagenum].iconname, textprompts[num]->page[metapagenum].iconname, 8); + textprompts[num]->page[pagenum].rightside = textprompts[num]->page[metapagenum].rightside; + textprompts[num]->page[pagenum].lines = textprompts[num]->page[metapagenum].lines; + textprompts[num]->page[pagenum].backcolor = textprompts[num]->page[metapagenum].backcolor; + textprompts[num]->page[pagenum].align = textprompts[num]->page[metapagenum].align; + textprompts[num]->page[pagenum].verticalalign = textprompts[num]->page[metapagenum].verticalalign; + textprompts[num]->page[pagenum].textspeed = textprompts[num]->page[metapagenum].textspeed; + textprompts[num]->page[pagenum].textsfx = textprompts[num]->page[metapagenum].textsfx; } } + else if (fastcmp(word, "NEXTPROMPT")) + textprompts[num]->page[pagenum].nextprompt = usi; + else if (fastcmp(word, "NEXTPAGE")) + textprompts[num]->page[pagenum].nextpage = usi; else deh_warning("PromptPage %d: unknown word '%s'", num, word); } diff --git a/src/doomstat.h b/src/doomstat.h index d737ef451..eaa19e3d6 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -177,6 +177,8 @@ typedef struct UINT8 verticalalign; // vertical text alignment, 0 = top, 1 = bottom, 2 = middle UINT8 textspeed; // text speed 0-15, makes it slower. See f_finale.c F_WriteText sfxenum_t textsfx; // sfx_ id for printing text + UINT8 nextprompt; // next prompt to jump to, one-based. 0 = current prompt + UINT8 nextpage; // next page to jump to, one-based. 0 = next page within prompt->numpages char *text; } textpage_t; diff --git a/src/f_finale.c b/src/f_finale.c index c25dd9eca..baaad10b0 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2019,6 +2019,47 @@ boolean F_CutsceneResponder(event_t *event) return false; } +// ================== +// TEXT PROMPTS +// ================== + +static void F_AdvanceToNextPage(void) +{ + UINT8 nextprompt = textprompts[cutnum]->page[scenenum].nextprompt, + nextpage = textprompts[cutnum]->page[scenenum].nextpage, + oldcutnum = cutnum; + + // determine next prompt + if (nextprompt) + { + if (textprompts[nextprompt-1]) + cutnum = nextprompt-1; + else + cutnum = INT32_MAX; + } + + // determine next page + if (nextpage) + { + scenenum = nextpage-1; + if (scenenum > textprompts[cutnum]->numpages-1) + scenenum = INT32_MAX; + } + else + { + if (cutnum != oldcutnum) + scenenum = 0; + else if (scenenum < textprompts[cutnum]->numpages-1) + scenenum++; + else + scenenum = INT32_MAX; + } + + // close the prompt if either num is invalid + if (cutnum == INT32_MAX || scenenum == INT32_MAX) + F_EndTextPrompt(); +} + void F_EndTextPrompt(void) { promptactive = false; @@ -2034,9 +2075,9 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum) stoptimer = 0; skullAnimCounter = 0; - cutnum = promptnum; - scenenum = pagenum; - promptactive = true; + cutnum = (textprompts[promptnum]) ? promptnum : INT32_MAX; + scenenum = (pagenum <= textprompts[cutnum]->numpages-1) ? pagenum : INT32_MAX; + promptactive = (cutnum != INT32_MAX && scenenum != INT32_MAX); } void F_TextPromptDrawer(void) @@ -2050,6 +2091,7 @@ void F_TextPromptDrawer(void) lumpnum_t iconlump = W_CheckNumForName(textprompts[cutnum]->page[scenenum].iconname); UINT8 pagelines = textprompts[cutnum]->page[scenenum].lines ? textprompts[cutnum]->page[scenenum].lines : 4; + boolean rightside = (iconlump != LUMPERROR && textprompts[cutnum]->page[scenenum].rightside); // Vertical calculations INT32 boxh = pagelines*2; @@ -2061,8 +2103,8 @@ void F_TextPromptDrawer(void) // Horizontal calculations // Shift text to the right if we have a character icon on the left side // Add 4 margin against icon - INT32 textx = iconlump != LUMPERROR && !textprompts[cutnum]->page[scenenum].rightside ? ((boxh * 4) + (boxh/2)*4) + 4 : 4; - INT32 textr = textprompts[cutnum]->page[scenenum].rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4) + 4) : BASEVIDWIDTH-4; + INT32 textx = (iconlump != LUMPERROR && !rightside) ? ((boxh * 4) + (boxh/2)*4) + 4 : 4; + INT32 textr = rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4) + 4) : BASEVIDWIDTH-4; // Data patch_t *patch; @@ -2074,9 +2116,33 @@ void F_TextPromptDrawer(void) // Draw narrator icon if (iconlump != LUMPERROR) { - INT32 iconx = textprompts[cutnum]->page[scenenum].rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4)) : 4; + INT32 iconx, icony, scale, scaledsize; patch = W_CachePatchName(textprompts[cutnum]->page[scenenum].iconname, PU_CACHE); - V_DrawFixedPatch(iconx<width), V_SNAPTOBOTTOM, patch, NULL); + + // scale and center + if (patch->width > patch->height) + { + scale = FixedDiv(((boxh * 4) + (boxh/2)*4) - 4, patch->width); + scaledsize = FixedMul(patch->height, scale); + iconx = (rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4)) : 4) << FRACBITS; + icony = ((namey-4) << FRACBITS) + FixedDiv(BASEVIDHEIGHT - namey + 4 - scaledsize, 2); // account for 4 margin + } + else if (patch->height > patch->width) + { + scale = FixedDiv(((boxh * 4) + (boxh/2)*4) - 4, patch->height); + scaledsize = FixedMul(patch->width, scale); + iconx = (rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4)) : 4) << FRACBITS; + icony = namey << FRACBITS; + iconx += FixedDiv(FixedMul(patch->height, scale) - scaledsize, 2); + } + else + { + scale = FixedDiv(((boxh * 4) + (boxh/2)*4) - 4, patch->width); + iconx = (rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4)) : 4) << FRACBITS; + icony = namey << FRACBITS; + } + + V_DrawFixedPatch(iconx, icony, scale, V_SNAPTOBOTTOM, patch, NULL); W_UnlockCachedPatch(patch); } @@ -2091,11 +2157,13 @@ void F_TextPromptDrawer(void) V_DrawString(textx, namey, V_SNAPTOBOTTOM, textprompts[cutnum]->page[scenenum].name); // Draw chevron - V_DrawString(textr-8, chevrony + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); // down arrow + V_DrawString(textr-8, chevrony + (skullAnimCounter/5), (V_SNAPTOBOTTOM|V_YELLOWMAP), "\x1B"); // down arrow } void F_TextPromptTicker(void) { + INT32 i; + if (!promptactive) return; @@ -2106,4 +2174,27 @@ void F_TextPromptTicker(void) // for the chevron if (--skullAnimCounter <= 0) skullAnimCounter = 8; + + // button handling + for (i = 0; i < MAXPLAYERS; i++) + { + if (netgame && i != serverplayer && i != adminplayer) + continue; + + if ((players[i].cmd.buttons & BT_USE) || (players[i].cmd.buttons & BT_JUMP)) + { + if (keypressed) + return; + + cutscene_boostspeed = 1; + if (timetonext) + timetonext = 2; + F_AdvanceToNextPage(); + keypressed = true; // prevent repeat events + } + else if (!(players[i].cmd.buttons & BT_USE) && !(players[i].cmd.buttons & BT_JUMP)) + keypressed = false; + + break; + } } From 57d9e0aef6c1e61a03bfb4ecc16d43628aa9916b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 14:43:19 -0400 Subject: [PATCH 445/573] TextPrompt: Implement player blocked controls and post-close run line --- src/f_finale.c | 69 +++++++++++++++++++++++++++++++++++++------------- src/f_finale.h | 2 +- src/p_spec.c | 22 +++++----------- 3 files changed, 59 insertions(+), 34 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index baaad10b0..b30160b87 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -79,7 +79,13 @@ static patch_t *ttspop7; static void F_SkyScroll(INT32 scrollspeed); +// +// PROMPT STATE +// static boolean promptactive = false; +static mobj_t *promptmo; +static INT16 promptpostexectag; +static boolean promptblockcontrols; // // CUTSCENE TEXT WRITING @@ -2063,9 +2069,20 @@ static void F_AdvanceToNextPage(void) void F_EndTextPrompt(void) { promptactive = false; + + // \todo net safety, maybe loop all player thinkers? + if (promptpostexectag) + P_LinedefExecute(promptpostexectag, promptmo, NULL); + + // \todo reset blocked controls and frozen realtime? + + P_SetTarget(&promptmo, NULL); // \todo tmthing crash upon teleporting? see test map + + // \todo if !promptactive, block player jumping if BT_JUMP is set + // so player does not immediately jump upon prompt close } -void F_StartTextPrompt(INT32 promptnum, INT32 pagenum) +void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime) { // We share vars, so no starting text prompts over cutscenes or title screens! keypressed = false; @@ -2075,6 +2092,13 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum) stoptimer = 0; skullAnimCounter = 0; + // Set up state + P_SetTarget(&promptmo, mo); //promptmo = mo; + promptpostexectag = postexectag; + promptblockcontrols = blockcontrols; + (void)freezerealtime; // \todo freeze player->realtime, maybe this needs to cycle through player thinkers + + // Initialize current prompt and scene cutnum = (textprompts[promptnum]) ? promptnum : INT32_MAX; scenenum = (pagenum <= textprompts[cutnum]->numpages-1) ? pagenum : INT32_MAX; promptactive = (cutnum != INT32_MAX && scenenum != INT32_MAX); @@ -2157,7 +2181,8 @@ void F_TextPromptDrawer(void) V_DrawString(textx, namey, V_SNAPTOBOTTOM, textprompts[cutnum]->page[scenenum].name); // Draw chevron - V_DrawString(textr-8, chevrony + (skullAnimCounter/5), (V_SNAPTOBOTTOM|V_YELLOWMAP), "\x1B"); // down arrow + if (promptblockcontrols) // \todo if !CloseTimer + V_DrawString(textr-8, chevrony + (skullAnimCounter/5), (V_SNAPTOBOTTOM|V_YELLOWMAP), "\x1B"); // down arrow } void F_TextPromptTicker(void) @@ -2176,25 +2201,35 @@ void F_TextPromptTicker(void) skullAnimCounter = 8; // button handling - for (i = 0; i < MAXPLAYERS; i++) + if (promptblockcontrols) { - if (netgame && i != serverplayer && i != adminplayer) - continue; + // \todo loop through all players that have a text prompt + if (promptmo && promptmo->player) + promptmo->player->powers[pw_nocontrol] = 1; - if ((players[i].cmd.buttons & BT_USE) || (players[i].cmd.buttons & BT_JUMP)) + for (i = 0; i < MAXPLAYERS; i++) { - if (keypressed) - return; + if (netgame && i != serverplayer && i != adminplayer) + continue; - cutscene_boostspeed = 1; - if (timetonext) - timetonext = 2; - F_AdvanceToNextPage(); - keypressed = true; // prevent repeat events + if ((players[i].cmd.buttons & BT_USE) || (players[i].cmd.buttons & BT_JUMP)) + { + if (keypressed) + return; + + cutscene_boostspeed = 1; + if (timetonext) + timetonext = 2; + F_AdvanceToNextPage(); + keypressed = true; // prevent repeat events + + if (promptactive) + S_StartSound(NULL, sfx_menu1); + } + else if (!(players[i].cmd.buttons & BT_USE) && !(players[i].cmd.buttons & BT_JUMP)) + keypressed = false; + + break; } - else if (!(players[i].cmd.buttons & BT_USE) && !(players[i].cmd.buttons & BT_JUMP)) - keypressed = false; - - break; } } diff --git a/src/f_finale.h b/src/f_finale.h index eb5872fca..66b608e21 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -51,7 +51,7 @@ void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean reset void F_CutsceneDrawer(void); void F_EndCutScene(void); -void F_StartTextPrompt(INT32 promptnum, INT32 pagenum); +void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime); void F_TextPromptDrawer(void); void F_EndTextPrompt(void); diff --git a/src/p_spec.c b/src/p_spec.c index 2771c85f7..cd4dd76cf 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3462,28 +3462,18 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { INT32 promptnum = max(0, (sides[line->sidenum[0]].textureoffset>>FRACBITS)-1); INT32 pagenum = max(0, (sides[line->sidenum[0]].rowoffset>>FRACBITS)-1); + INT32 postexectag = (line->sidenum[1] != 0xFFFF) ? abs(sides[line->sidenum[1]].textureoffset>>FRACBITS) : 0; boolean closetextprompt = (line->flags & ML_BLOCKMONSTERS); + boolean runpostexec = (line->flags & ML_EFFECT1); + boolean blockcontrols = !(line->flags & ML_EFFECT2); + boolean freezerealtime = !(line->flags & ML_EFFECT3); + //boolean freezethinkers = (line->flags & ML_EFFECT4); if (closetextprompt) F_EndTextPrompt(); else - F_StartTextPrompt(promptnum, pagenum); -#if 0 - - INT32 postexectag = (line->sidenum[1] != 0xFFFF) ? abs(sides[line->sidenum[1]].textureoffset>>FRACBITS) : 0; - INT32 closedelay = (line->sidenum[1] != 0xFFFF) ? abs(sides[line->sidenum[1]].rowoffset>>FRACBITS) : 0; - - boolean runpostexec = (line->flags & ML_EFFECT1); - boolean blockcontrols = !(line->flags & ML_EFFECT2); - boolean freezetimer = !(line->flags & ML_EFFECT3); - boolean freezethinkers = (line->flags & ML_EFFECT4); - - // if (closetextprompt && !promptnum) - // F_EndTextPrompt(closedelay, runpostexec ? postexectag : 0, mo); - // else - // F_StartTextPrompt(promptnum, pagenum, closetextprompt ? closedelay : 0, runpostexec ? postexectag : 0, mo, blockcontrols, freezethinkers); -#endif + F_StartTextPrompt(promptnum, pagenum, mo, runpostexec ? postexectag : 0, blockcontrols, freezerealtime); } break; From 98d532f119e1a52b1193952c68fe1b3dffe00f00 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 15:07:02 -0400 Subject: [PATCH 446/573] EndTextPrompt: Fix tmthing crash with P_LinedefExecute --- src/f_finale.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index b30160b87..8d578c61f 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2072,11 +2072,15 @@ void F_EndTextPrompt(void) // \todo net safety, maybe loop all player thinkers? if (promptpostexectag) + { + P_MapStart(); P_LinedefExecute(promptpostexectag, promptmo, NULL); + P_MapEnd(); + } - // \todo reset blocked controls and frozen realtime? + // \todo reset frozen realtime? - P_SetTarget(&promptmo, NULL); // \todo tmthing crash upon teleporting? see test map + P_SetTarget(&promptmo, NULL); // \todo if !promptactive, block player jumping if BT_JUMP is set // so player does not immediately jump upon prompt close @@ -2093,7 +2097,7 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postex skullAnimCounter = 0; // Set up state - P_SetTarget(&promptmo, mo); //promptmo = mo; + P_SetTarget(&promptmo, mo); promptpostexectag = postexectag; promptblockcontrols = blockcontrols; (void)freezerealtime; // \todo freeze player->realtime, maybe this needs to cycle through player thinkers From d327f82e854ed62f532f5c40d7878bc5ad1f069a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 3 Nov 2018 21:13:44 +0000 Subject: [PATCH 447/573] Fix errors found when compiling --- src/dehacked.c | 26 +++++++++++++------------- src/f_finale.c | 45 +++++++++++++++++++++++++-------------------- src/f_finale.h | 1 + 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 2b466fab7..725a30b4e 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1655,18 +1655,18 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) else if (fastcmp(word, "BACKCOLOR")) { UINT8 backcolor; - if (usi == 0 || fastcmp(word2, "WHITE")) backcolor = 0; - else if (usi == 1 || fastcmp(word2, "GRAY") || fastcmp(word2, "GREY")) backcolor = 1; - else if (usi == 2 || fastcmp(word2, "BROWN")) backcolor = 2; - else if (usi == 3 || fastcmp(word2, "RED")) backcolor = 3; - else if (usi == 4 || fastcmp(word2, "ORANGE")) backcolor = 4; - else if (usi == 5 || fastcmp(word2, "YELLOW")) backcolor = 5; - else if (usi == 6 || fastcmp(word2, "GREEN")) backcolor = 6; - else if (usi == 7 || fastcmp(word2, "BLUE")) backcolor = 7; - else if (usi == 8 || fastcmp(word2, "PURPLE")) backcolor = 8; - else if (usi == 9 || fastcmp(word2, "MAGENTA")) backcolor = 9; - else if (usi == 10 || fastcmp(word2, "AQUA")) backcolor = 10; - else if (usi < 0) backcolor = UINT8_MAX; // CONS_BACKCOLOR user-configured + if (i == 0 || fastcmp(word2, "WHITE")) backcolor = 0; + else if (i == 1 || fastcmp(word2, "GRAY") || fastcmp(word2, "GREY")) backcolor = 1; + else if (i == 2 || fastcmp(word2, "BROWN")) backcolor = 2; + else if (i == 3 || fastcmp(word2, "RED")) backcolor = 3; + else if (i == 4 || fastcmp(word2, "ORANGE")) backcolor = 4; + else if (i == 5 || fastcmp(word2, "YELLOW")) backcolor = 5; + else if (i == 6 || fastcmp(word2, "GREEN")) backcolor = 6; + else if (i == 7 || fastcmp(word2, "BLUE")) backcolor = 7; + else if (i == 8 || fastcmp(word2, "PURPLE")) backcolor = 8; + else if (i == 9 || fastcmp(word2, "MAGENTA")) backcolor = 9; + else if (i == 10 || fastcmp(word2, "AQUA")) backcolor = 10; + else if (i < 0) backcolor = UINT8_MAX; // CONS_BACKCOLOR user-configured else backcolor = 11; // default green textprompts[num]->page[pagenum].backcolor = backcolor; } @@ -1685,7 +1685,7 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) textprompts[num]->page[pagenum].verticalalign = align; } else if (fastcmp(word, "TEXTSPEED")) - textprompts[num]->page[pagenum].textspeed = min(max(0, usi), 15); + textprompts[num]->page[pagenum].textspeed = min(max(0, i), 15); else if (fastcmp(word, "TEXTSFX")) textprompts[num]->page[pagenum].textsfx = get_number(word2); else if (fastcmp(word, "METAPAGE")) diff --git a/src/f_finale.c b/src/f_finale.c index 8d578c61f..5f6d8ce42 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2113,31 +2113,36 @@ void F_TextPromptDrawer(void) // reuse: // cutnum -> promptnum // scenenum -> pagenum - - if (!promptactive) - return; - - lumpnum_t iconlump = W_CheckNumForName(textprompts[cutnum]->page[scenenum].iconname); - UINT8 pagelines = textprompts[cutnum]->page[scenenum].lines ? textprompts[cutnum]->page[scenenum].lines : 4; - boolean rightside = (iconlump != LUMPERROR && textprompts[cutnum]->page[scenenum].rightside); - - // Vertical calculations - INT32 boxh = pagelines*2; - INT32 texth = textprompts[cutnum]->page[scenenum].name[0] ? (pagelines-1)*2 : pagelines*2; // name takes up first line if it exists - INT32 texty = BASEVIDHEIGHT - ((texth * 4) + (texth/2)*4); - INT32 namey = BASEVIDHEIGHT - ((boxh * 4) + (boxh/2)*4); - INT32 chevrony = BASEVIDHEIGHT - (((1*2) * 4) + ((1*2)/2)*4); // force on last line - - // Horizontal calculations - // Shift text to the right if we have a character icon on the left side - // Add 4 margin against icon - INT32 textx = (iconlump != LUMPERROR && !rightside) ? ((boxh * 4) + (boxh/2)*4) + 4 : 4; - INT32 textr = rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4) + 4) : BASEVIDWIDTH-4; + lumpnum_t iconlump; + UINT8 pagelines; + boolean rightside; + INT32 boxh, texth, texty, namey, chevrony; + INT32 textx, textr; // Data patch_t *patch; char *text; + if (!promptactive) + return; + + iconlump = W_CheckNumForName(textprompts[cutnum]->page[scenenum].iconname); + pagelines = textprompts[cutnum]->page[scenenum].lines ? textprompts[cutnum]->page[scenenum].lines : 4; + rightside = (iconlump != LUMPERROR && textprompts[cutnum]->page[scenenum].rightside); + + // Vertical calculations + boxh = pagelines*2; + texth = textprompts[cutnum]->page[scenenum].name[0] ? (pagelines-1)*2 : pagelines*2; // name takes up first line if it exists + texty = BASEVIDHEIGHT - ((texth * 4) + (texth/2)*4); + namey = BASEVIDHEIGHT - ((boxh * 4) + (boxh/2)*4); + chevrony = BASEVIDHEIGHT - (((1*2) * 4) + ((1*2)/2)*4); // force on last line + + // Horizontal calculations + // Shift text to the right if we have a character icon on the left side + // Add 4 margin against icon + textx = (iconlump != LUMPERROR && !rightside) ? ((boxh * 4) + (boxh/2)*4) + 4 : 4; + textr = rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4) + 4) : BASEVIDWIDTH-4; + // Draw background V_DrawTutorialBack(boxh); diff --git a/src/f_finale.h b/src/f_finale.h index 66b608e21..dfee247fb 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -17,6 +17,7 @@ #include "doomtype.h" #include "d_event.h" +#include "p_mobj.h" // // FINALE From 444462732b24a13c2142523bca7ac05e4d2b62e7 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 3 Nov 2018 21:14:17 +0000 Subject: [PATCH 448/573] added HWR_DrawTutorialBack for OpenGL --- src/hardware/hw_draw.c | 26 ++++++++++++++++++++++++++ src/hardware/hw_main.h | 1 + src/v_video.c | 20 +++++++++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 02608892e..6d4467439 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -705,6 +705,32 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height) HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); } +// Very similar to HWR_DrawConsoleBack, except we draw from the middle(-ish) of the screen to the bottom. +void HWR_DrawTutorialBack(UINT32 color, INT32 boxheight) +{ + FOutVector v[4]; + FSurfaceInfo Surf; + INT32 height = (boxheight * 4) + (boxheight/2)*5; // 4 lines of space plus gaps between and some leeway + + // setup some neat-o translucency effect + + v[0].x = v[3].x = -1.0f; + v[2].x = v[1].x = 1.0f; + v[0].y = v[1].y = -1.0f; + v[2].y = v[3].y = -1.0f+((height<<1)/(float)vid.height); + v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; + + v[0].sow = v[3].sow = 0.0f; + v[2].sow = v[1].sow = 1.0f; + v[0].tow = v[1].tow = 1.0f; + v[2].tow = v[3].tow = 0.0f; + + Surf.FlatColor.rgba = UINT2RGBA(color); + Surf.FlatColor.s.alpha = 0x80; + + HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); +} + // ========================================================================== // R_DRAW.C STUFF diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 1ae2d8fc3..f25720d1e 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -35,6 +35,7 @@ void HWR_clearAutomap(void); void HWR_drawAMline(const fline_t *fl, INT32 color); void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength); void HWR_DrawConsoleBack(UINT32 color, INT32 height); +void HWR_DrawTutorialBack(UINT32 color, INT32 boxheight); void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player); void HWR_RenderPlayerView(INT32 viewnumber, player_t *player); void HWR_DrawViewBorder(INT32 clearlines); diff --git a/src/v_video.c b/src/v_video.c index a628b1a8b..f8d0b392c 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1488,8 +1488,26 @@ void V_DrawTutorialBack(INT32 boxheight) boxheight *= vid.dupy; #ifdef HWRENDER - if (rendermode != render_soft) // no support for OpenGL yet + if (rendermode != render_soft && rendermode != render_none) + { + UINT32 hwcolor; + switch (cons_backcolor.value) + { + case 0: hwcolor = 0xffffff00; break; // White + case 1: hwcolor = 0x80808000; break; // Gray + case 2: hwcolor = 0x40201000; break; // Brown + case 3: hwcolor = 0xff000000; break; // Red + case 4: hwcolor = 0xff800000; break; // Orange + case 5: hwcolor = 0x80800000; break; // Yellow + case 6: hwcolor = 0x00800000; break; // Green + case 7: hwcolor = 0x0000ff00; break; // Blue + case 8: hwcolor = 0x4080ff00; break; // Cyan + // Default green + default: hwcolor = 0x00800000; break; + } + HWR_DrawTutorialBack(hwcolor, boxheight); return; + } #endif // heavily simplified -- we don't need to know x or y position, From 0a766dc93b53a587c6fa022135e767000b670e54 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 20:01:39 -0400 Subject: [PATCH 449/573] Implemented progressive text printing for TextPrompt --- src/f_finale.c | 107 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 80 insertions(+), 27 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 5f6d8ce42..29789c539 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -86,6 +86,7 @@ static boolean promptactive = false; static mobj_t *promptmo; static INT16 promptpostexectag; static boolean promptblockcontrols; +static char *promptpagetext = NULL; // // CUTSCENE TEXT WRITING @@ -2029,6 +2030,52 @@ boolean F_CutsceneResponder(event_t *event) // TEXT PROMPTS // ================== +static void F_GetPageTextGeometry(UINT8 *pagelines, boolean *rightside, INT32 *boxh, INT32 *texth, INT32 *texty, INT32 *namey, INT32 *chevrony, INT32 *textx, INT32 *textr) +{ + // reuse: + // cutnum -> promptnum + // scenenum -> pagenum + lumpnum_t iconlump = W_CheckNumForName(textprompts[cutnum]->page[scenenum].iconname); + + *pagelines = textprompts[cutnum]->page[scenenum].lines ? textprompts[cutnum]->page[scenenum].lines : 4; + *rightside = (iconlump != LUMPERROR && textprompts[cutnum]->page[scenenum].rightside); + + // Vertical calculations + *boxh = *pagelines*2; + *texth = textprompts[cutnum]->page[scenenum].name[0] ? (*pagelines-1)*2 : *pagelines*2; // name takes up first line if it exists + *texty = BASEVIDHEIGHT - ((*texth * 4) + (*texth/2)*4); + *namey = BASEVIDHEIGHT - ((*boxh * 4) + (*boxh/2)*4); + *chevrony = BASEVIDHEIGHT - (((1*2) * 4) + ((1*2)/2)*4); // force on last line + + // Horizontal calculations + // Shift text to the right if we have a character icon on the left side + // Add 4 margin against icon + *textx = (iconlump != LUMPERROR && !*rightside) ? ((*boxh * 4) + (*boxh/2)*4) + 4 : 4; + *textr = *rightside ? BASEVIDWIDTH - (((*boxh * 4) + (*boxh/2)*4) + 4) : BASEVIDWIDTH-4; +} + +static void F_PreparePageText(char *pagetext) +{ + UINT8 pagelines; + boolean rightside; + INT32 boxh, texth, texty, namey, chevrony; + INT32 textx, textr; + + F_GetPageTextGeometry(&pagelines, &rightside, &boxh, &texth, &texty, &namey, &chevrony, &textx, &textr); + + if (promptpagetext) + Z_Free(promptpagetext); + promptpagetext = V_WordWrap(textx, textr, 0, pagetext); + + F_NewCutscene(promptpagetext); + cutscene_textspeed = TICRATE/4; // \todo configurable speed by SOC + cutscene_textcount = 0; // no delay in beginning + cutscene_boostspeed = 0; // don't print 8 characters to start + + // \todo update control hot strings on re-config + // and somehow don't reset cutscene text counters +} + static void F_AdvanceToNextPage(void) { UINT8 nextprompt = textprompts[cutnum]->page[scenenum].nextprompt, @@ -2064,12 +2111,20 @@ static void F_AdvanceToNextPage(void) // close the prompt if either num is invalid if (cutnum == INT32_MAX || scenenum == INT32_MAX) F_EndTextPrompt(); + else + { + timetonext = 1; // on page-mode, delay before boosting // \todo timed mode set by SOC, enable different behavior for a legitimate timer + F_PreparePageText(textprompts[cutnum]->page[scenenum].text); + } } void F_EndTextPrompt(void) { promptactive = false; + if (promptmo && promptmo->player && promptblockcontrols) + promptmo->reactiontime = TICRATE/4; // prevent jumping right away // \todo account freeze realtime for this + // \todo net safety, maybe loop all player thinkers? if (promptpostexectag) { @@ -2106,6 +2161,12 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postex cutnum = (textprompts[promptnum]) ? promptnum : INT32_MAX; scenenum = (pagenum <= textprompts[cutnum]->numpages-1) ? pagenum : INT32_MAX; promptactive = (cutnum != INT32_MAX && scenenum != INT32_MAX); + + if (promptactive) + { + timetonext = 1; // on page-mode, delay before boosting // \todo timed mode set by SOC, enable different behavior for a legitimate timer + F_PreparePageText(textprompts[cutnum]->page[scenenum].text); + } } void F_TextPromptDrawer(void) @@ -2121,27 +2182,12 @@ void F_TextPromptDrawer(void) // Data patch_t *patch; - char *text; if (!promptactive) return; iconlump = W_CheckNumForName(textprompts[cutnum]->page[scenenum].iconname); - pagelines = textprompts[cutnum]->page[scenenum].lines ? textprompts[cutnum]->page[scenenum].lines : 4; - rightside = (iconlump != LUMPERROR && textprompts[cutnum]->page[scenenum].rightside); - - // Vertical calculations - boxh = pagelines*2; - texth = textprompts[cutnum]->page[scenenum].name[0] ? (pagelines-1)*2 : pagelines*2; // name takes up first line if it exists - texty = BASEVIDHEIGHT - ((texth * 4) + (texth/2)*4); - namey = BASEVIDHEIGHT - ((boxh * 4) + (boxh/2)*4); - chevrony = BASEVIDHEIGHT - (((1*2) * 4) + ((1*2)/2)*4); // force on last line - - // Horizontal calculations - // Shift text to the right if we have a character icon on the left side - // Add 4 margin against icon - textx = (iconlump != LUMPERROR && !rightside) ? ((boxh * 4) + (boxh/2)*4) + 4 : 4; - textr = rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4) + 4) : BASEVIDWIDTH-4; + F_GetPageTextGeometry(&pagelines, &rightside, &boxh, &texth, &texty, &namey, &chevrony, &textx, &textr); // Draw background V_DrawTutorialBack(boxh); @@ -2181,8 +2227,7 @@ void F_TextPromptDrawer(void) // Draw text // \todo Char-by-char printing, see f_finale.c F_WriteText - text = V_WordWrap(textx, textr, 0, textprompts[cutnum]->page[scenenum].text); - V_DrawString(textx, texty, V_SNAPTOBOTTOM, text); + V_DrawString(textx, texty, V_SNAPTOBOTTOM, cutscene_disptext); // Draw name // Don't use V_YELLOWMAP here so that the name color can be changed with control codes @@ -2190,7 +2235,7 @@ void F_TextPromptDrawer(void) V_DrawString(textx, namey, V_SNAPTOBOTTOM, textprompts[cutnum]->page[scenenum].name); // Draw chevron - if (promptblockcontrols) // \todo if !CloseTimer + if (promptblockcontrols && !timetonext) // \todo if !CloseTimer V_DrawString(textr-8, chevrony + (skullAnimCounter/5), (V_SNAPTOBOTTOM|V_YELLOWMAP), "\x1B"); // down arrow } @@ -2223,17 +2268,21 @@ void F_TextPromptTicker(void) if ((players[i].cmd.buttons & BT_USE) || (players[i].cmd.buttons & BT_JUMP)) { + if (timetonext > 1) + timetonext--; + else if (cutscene_baseptr) // don't set boost if we just reset the string + cutscene_boostspeed = 1; // only after a slight delay + if (keypressed) - return; + break; - cutscene_boostspeed = 1; - if (timetonext) - timetonext = 2; - F_AdvanceToNextPage(); + if (!timetonext) // is 0 when finished generating text + { + F_AdvanceToNextPage(); + if (promptactive) + S_StartSound(NULL, sfx_menu1); + } keypressed = true; // prevent repeat events - - if (promptactive) - S_StartSound(NULL, sfx_menu1); } else if (!(players[i].cmd.buttons & BT_USE) && !(players[i].cmd.buttons & BT_JUMP)) keypressed = false; @@ -2241,4 +2290,8 @@ void F_TextPromptTicker(void) break; } } + + // generate letter-by-letter text + if (!F_WriteText()) + timetonext = 0; } From 73ae27334899f3b737f9779b2cd4ef6e7faf21e3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 21:53:17 -0400 Subject: [PATCH 450/573] Implemented auto-advancing TextPrompts * Fixed TextSpeed * New TimeToNext * Other bugs --- src/dehacked.c | 4 +- src/doomstat.h | 3 +- src/f_finale.c | 119 ++++++++++++++++++++++++++++++------------------- 3 files changed, 78 insertions(+), 48 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 725a30b4e..9f819a665 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1685,7 +1685,7 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) textprompts[num]->page[pagenum].verticalalign = align; } else if (fastcmp(word, "TEXTSPEED")) - textprompts[num]->page[pagenum].textspeed = min(max(0, i), 15); + textprompts[num]->page[pagenum].textspeed = get_number(word2); else if (fastcmp(word, "TEXTSFX")) textprompts[num]->page[pagenum].textsfx = get_number(word2); else if (fastcmp(word, "METAPAGE")) @@ -1708,6 +1708,8 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) textprompts[num]->page[pagenum].nextprompt = usi; else if (fastcmp(word, "NEXTPAGE")) textprompts[num]->page[pagenum].nextpage = usi; + else if (fastcmp(word, "TIMETONEXT")) + textprompts[num]->page[pagenum].timetonext = get_number(word2); else deh_warning("PromptPage %d: unknown word '%s'", num, word); } diff --git a/src/doomstat.h b/src/doomstat.h index eaa19e3d6..73758a6a6 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -175,10 +175,11 @@ typedef struct UINT8 backcolor; // see CON_SetupBackColormap: 0-10, 11 for default, UINT8_MAX for user-defined (CONS_BACKCOLOR) UINT8 align; // text alignment, 0 = left, 1 = right, 2 = center UINT8 verticalalign; // vertical text alignment, 0 = top, 1 = bottom, 2 = middle - UINT8 textspeed; // text speed 0-15, makes it slower. See f_finale.c F_WriteText + UINT8 textspeed; // text speed, delay in tics between characters. sfxenum_t textsfx; // sfx_ id for printing text UINT8 nextprompt; // next prompt to jump to, one-based. 0 = current prompt UINT8 nextpage; // next page to jump to, one-based. 0 = next page within prompt->numpages + INT32 timetonext; // time in tics to jump to next page automatically. 0 = don't jump automatically char *text; } textpage_t; diff --git a/src/f_finale.c b/src/f_finale.c index 29789c539..05a77cedd 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2068,7 +2068,7 @@ static void F_PreparePageText(char *pagetext) promptpagetext = V_WordWrap(textx, textr, 0, pagetext); F_NewCutscene(promptpagetext); - cutscene_textspeed = TICRATE/4; // \todo configurable speed by SOC + cutscene_textspeed = textprompts[cutnum]->page[scenenum].textspeed ? textprompts[cutnum]->page[scenenum].textspeed : TICRATE/5; cutscene_textcount = 0; // no delay in beginning cutscene_boostspeed = 0; // don't print 8 characters to start @@ -2113,17 +2113,22 @@ static void F_AdvanceToNextPage(void) F_EndTextPrompt(); else { - timetonext = 1; // on page-mode, delay before boosting // \todo timed mode set by SOC, enable different behavior for a legitimate timer + // on page mode, number of tics before allowing boost + // on timer mode, number of tics until page advances + timetonext = textprompts[cutnum]->page[scenenum].timetonext ? textprompts[cutnum]->page[scenenum].timetonext : TICRATE/10; F_PreparePageText(textprompts[cutnum]->page[scenenum].text); } } void F_EndTextPrompt(void) { - promptactive = false; + if (promptactive) { + if (promptmo && promptmo->player && promptblockcontrols) + promptmo->reactiontime = TICRATE/4; // prevent jumping right away // \todo account freeze realtime for this) + // \todo reset frozen realtime? + } - if (promptmo && promptmo->player && promptblockcontrols) - promptmo->reactiontime = TICRATE/4; // prevent jumping right away // \todo account freeze realtime for this + promptactive = false; // \todo net safety, maybe loop all player thinkers? if (promptpostexectag) @@ -2132,13 +2137,6 @@ void F_EndTextPrompt(void) P_LinedefExecute(promptpostexectag, promptmo, NULL); P_MapEnd(); } - - // \todo reset frozen realtime? - - P_SetTarget(&promptmo, NULL); - - // \todo if !promptactive, block player jumping if BT_JUMP is set - // so player does not immediately jump upon prompt close } void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime) @@ -2152,21 +2150,25 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postex skullAnimCounter = 0; // Set up state - P_SetTarget(&promptmo, mo); + promptmo = mo; promptpostexectag = postexectag; promptblockcontrols = blockcontrols; (void)freezerealtime; // \todo freeze player->realtime, maybe this needs to cycle through player thinkers // Initialize current prompt and scene cutnum = (textprompts[promptnum]) ? promptnum : INT32_MAX; - scenenum = (pagenum <= textprompts[cutnum]->numpages-1) ? pagenum : INT32_MAX; + scenenum = (cutnum != INT32_MAX && pagenum <= textprompts[cutnum]->numpages-1) ? pagenum : INT32_MAX; promptactive = (cutnum != INT32_MAX && scenenum != INT32_MAX); if (promptactive) { - timetonext = 1; // on page-mode, delay before boosting // \todo timed mode set by SOC, enable different behavior for a legitimate timer + // on page mode, number of tics before allowing boost + // on timer mode, number of tics until page advances + timetonext = textprompts[cutnum]->page[scenenum].timetonext ? textprompts[cutnum]->page[scenenum].timetonext : TICRATE/10; F_PreparePageText(textprompts[cutnum]->page[scenenum].text); } + else + F_EndTextPrompt(); // run the post-effects immediately } void F_TextPromptDrawer(void) @@ -2255,43 +2257,68 @@ void F_TextPromptTicker(void) skullAnimCounter = 8; // button handling - if (promptblockcontrols) + if (textprompts[cutnum]->page[scenenum].timetonext) { - // \todo loop through all players that have a text prompt - if (promptmo && promptmo->player) - promptmo->player->powers[pw_nocontrol] = 1; - - for (i = 0; i < MAXPLAYERS; i++) + if (promptblockcontrols) // same procedure as below, just without the button handling { - if (netgame && i != serverplayer && i != adminplayer) - continue; - - if ((players[i].cmd.buttons & BT_USE) || (players[i].cmd.buttons & BT_JUMP)) + for (i = 0; i < MAXPLAYERS; i++) { - if (timetonext > 1) - timetonext--; - else if (cutscene_baseptr) // don't set boost if we just reset the string - cutscene_boostspeed = 1; // only after a slight delay + if (netgame && i != serverplayer && i != adminplayer) + continue; - if (keypressed) - break; - - if (!timetonext) // is 0 when finished generating text - { - F_AdvanceToNextPage(); - if (promptactive) - S_StartSound(NULL, sfx_menu1); - } - keypressed = true; // prevent repeat events + players[i].powers[pw_nocontrol] = 1; + break; } - else if (!(players[i].cmd.buttons & BT_USE) && !(players[i].cmd.buttons & BT_JUMP)) - keypressed = false; - - break; } + + if (timetonext >= 1) + timetonext--; + + if (!timetonext) + F_AdvanceToNextPage(); + + F_WriteText(); + } + else + { + if (promptblockcontrols) + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (netgame && i != serverplayer && i != adminplayer) + continue; + + players[i].powers[pw_nocontrol] = 1; + + if ((players[i].cmd.buttons & BT_USE) || (players[i].cmd.buttons & BT_JUMP)) + { + if (timetonext > 1) + timetonext--; + else if (cutscene_baseptr) // don't set boost if we just reset the string + cutscene_boostspeed = 1; // only after a slight delay + + if (keypressed) + break; + + if (!timetonext) // is 0 when finished generating text + { + F_AdvanceToNextPage(); + if (promptactive) + S_StartSound(NULL, sfx_menu1); + } + keypressed = true; // prevent repeat events + } + else if (!(players[i].cmd.buttons & BT_USE) && !(players[i].cmd.buttons & BT_JUMP)) + keypressed = false; + + break; + } + } + + // generate letter-by-letter text + if (!F_WriteText()) + timetonext = !promptblockcontrols; // never show the chevron if we can't toggle pages } - // generate letter-by-letter text - if (!F_WriteText()) - timetonext = 0; + } From 1ca8fca602ad376019b747ea88a2161c7f82e6ca Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 21:53:21 -0400 Subject: [PATCH 451/573] Changed Line 449 post exec tag to line tag --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index cd4dd76cf..e2c73a5a5 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3462,7 +3462,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { INT32 promptnum = max(0, (sides[line->sidenum[0]].textureoffset>>FRACBITS)-1); INT32 pagenum = max(0, (sides[line->sidenum[0]].rowoffset>>FRACBITS)-1); - INT32 postexectag = (line->sidenum[1] != 0xFFFF) ? abs(sides[line->sidenum[1]].textureoffset>>FRACBITS) : 0; + INT32 postexectag = line->tag; boolean closetextprompt = (line->flags & ML_BLOCKMONSTERS); boolean runpostexec = (line->flags & ML_EFFECT1); From 6356a6cf2ed19173009c121515d3cd6476805042 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Nov 2018 22:57:39 -0400 Subject: [PATCH 452/573] Lowercase font for body text; added ICONFLIP parameter --- src/dehacked.c | 3 +++ src/doomstat.h | 1 + src/f_finale.c | 9 ++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 9f819a665..7a89cadcf 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1650,6 +1650,8 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) strncpy(textprompts[num]->page[pagenum].iconname, word2, 8); else if (fastcmp(word, "ICONALIGN")) textprompts[num]->page[pagenum].rightside = (i || word2[0] == 'R'); + else if (fastcmp(word, "ICONFLIP")) + textprompts[num]->page[pagenum].iconflip = (i || word2[0] == 'T' || word2[0] == 'Y'); else if (fastcmp(word, "LINES")) textprompts[num]->page[pagenum].lines = usi; else if (fastcmp(word, "BACKCOLOR")) @@ -1696,6 +1698,7 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) strncpy(textprompts[num]->page[pagenum].name, textprompts[num]->page[metapagenum].name, 32); strncpy(textprompts[num]->page[pagenum].iconname, textprompts[num]->page[metapagenum].iconname, 8); textprompts[num]->page[pagenum].rightside = textprompts[num]->page[metapagenum].rightside; + textprompts[num]->page[pagenum].iconflip = textprompts[num]->page[metapagenum].iconflip; textprompts[num]->page[pagenum].lines = textprompts[num]->page[metapagenum].lines; textprompts[num]->page[pagenum].backcolor = textprompts[num]->page[metapagenum].backcolor; textprompts[num]->page[pagenum].align = textprompts[num]->page[metapagenum].align; diff --git a/src/doomstat.h b/src/doomstat.h index 73758a6a6..7bcf59946 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -171,6 +171,7 @@ typedef struct char name[32]; // narrator name char iconname[8]; // narrator icon lump boolean rightside; // narrator side, false = left, true = right + boolean iconflip; // narrator flip icon horizontally UINT8 lines; // # of lines to show. If name is specified, name takes one of the lines. If 0, defaults to 4. UINT8 backcolor; // see CON_SetupBackColormap: 0-10, 11 for default, UINT8_MAX for user-defined (CONS_BACKCOLOR) UINT8 align; // text alignment, 0 = left, 1 = right, 2 = center diff --git a/src/f_finale.c b/src/f_finale.c index 05a77cedd..1fae49e9d 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2223,18 +2223,21 @@ void F_TextPromptDrawer(void) icony = namey << FRACBITS; } - V_DrawFixedPatch(iconx, icony, scale, V_SNAPTOBOTTOM, patch, NULL); + if (textprompts[cutnum]->page[scenenum].iconflip) + iconx += FixedMul(patch->width, scale) << FRACBITS; + + V_DrawFixedPatch(iconx, icony, scale, (V_SNAPTOBOTTOM|(textprompts[cutnum]->page[scenenum].iconflip ? V_FLIP : 0)), patch, NULL); W_UnlockCachedPatch(patch); } // Draw text // \todo Char-by-char printing, see f_finale.c F_WriteText - V_DrawString(textx, texty, V_SNAPTOBOTTOM, cutscene_disptext); + V_DrawString(textx, texty, (V_SNAPTOBOTTOM|V_ALLOWLOWERCASE), cutscene_disptext); // Draw name // Don't use V_YELLOWMAP here so that the name color can be changed with control codes if (textprompts[cutnum]->page[scenenum].name[0]) - V_DrawString(textx, namey, V_SNAPTOBOTTOM, textprompts[cutnum]->page[scenenum].name); + V_DrawString(textx, namey, (V_SNAPTOBOTTOM|V_ALLOWLOWERCASE), textprompts[cutnum]->page[scenenum].name); // Draw chevron if (promptblockcontrols && !timetonext) // \todo if !CloseTimer From 722da815ea8b1ddb326f0abbace0590e102f7dae Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 4 Nov 2018 16:45:29 -0500 Subject: [PATCH 453/573] Move Line 449 to Line 459; allow post exec tag by either Back X offset or line tag --- src/p_spec.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index e2c73a5a5..edf9174d6 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3456,27 +3456,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } break; - case 449: // Control Text Prompt - // console player only unless NOCLIMB is set - if ((line->flags & ML_NOCLIMB) || (mo && mo->player && P_IsLocalPlayer(mo->player))) - { - INT32 promptnum = max(0, (sides[line->sidenum[0]].textureoffset>>FRACBITS)-1); - INT32 pagenum = max(0, (sides[line->sidenum[0]].rowoffset>>FRACBITS)-1); - INT32 postexectag = line->tag; - - boolean closetextprompt = (line->flags & ML_BLOCKMONSTERS); - boolean runpostexec = (line->flags & ML_EFFECT1); - boolean blockcontrols = !(line->flags & ML_EFFECT2); - boolean freezerealtime = !(line->flags & ML_EFFECT3); - //boolean freezethinkers = (line->flags & ML_EFFECT4); - - if (closetextprompt) - F_EndTextPrompt(); - else - F_StartTextPrompt(promptnum, pagenum, mo, runpostexec ? postexectag : 0, blockcontrols, freezerealtime); - } - break; - case 450: // Execute Linedef Executor - for recursion P_LinedefExecute(line->tag, mo, NULL); break; @@ -3779,6 +3758,27 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_ResetColormapFader(§ors[secnum]); break; + case 459: // Control Text Prompt + // console player only unless NOCLIMB is set + if ((line->flags & ML_NOCLIMB) || (mo && mo->player && P_IsLocalPlayer(mo->player))) + { + INT32 promptnum = max(0, (sides[line->sidenum[0]].textureoffset>>FRACBITS)-1); + INT32 pagenum = max(0, (sides[line->sidenum[0]].rowoffset>>FRACBITS)-1); + INT32 postexectag = abs((line->sidenum[1] != 0xFFFF) ? sides[line->sidenum[1]].textureoffset>>FRACBITS : line->tag); + + boolean closetextprompt = (line->flags & ML_BLOCKMONSTERS); + boolean runpostexec = (line->flags & ML_EFFECT1); + boolean blockcontrols = !(line->flags & ML_EFFECT2); + boolean freezerealtime = !(line->flags & ML_EFFECT3); + //boolean freezethinkers = (line->flags & ML_EFFECT4); + + if (closetextprompt) + F_EndTextPrompt(); + else + F_StartTextPrompt(promptnum, pagenum, mo, runpostexec ? postexectag : 0, blockcontrols, freezerealtime); + } + break; + #ifdef POLYOBJECTS case 480: // Polyobj_DoorSlide case 481: // Polyobj_DoorSwing From c16c59fd739b394464350947c397b062ee52a617 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 4 Nov 2018 21:14:22 -0500 Subject: [PATCH 454/573] Support underscores -> spaces in TextPrompt name --- src/dehacked.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index 7a89cadcf..dcd61bd31 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1637,6 +1637,8 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) if (fastcmp(word, "NAME")) { + INT32 i; + // HACK: Add yellow control char now // so the drawing function doesn't call it repeatedly char name[32]; @@ -1644,6 +1646,14 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) name[1] = 0; strncat(name, word2, 31); name[31] = 0; + + // Replace _ with ' ' + for (i = 0; i < 32 && name[i]; i++) + { + if (name[i] == '_') + name[i] = ' '; + } + strncpy(textprompts[num]->page[pagenum].name, name, 32); } else if (fastcmp(word, "ICON")) From 96e9b4143a7a63a35fa877b8212e4e06c221bad4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 4 Nov 2018 22:09:54 -0500 Subject: [PATCH 455/573] Pause TextPrompt when game is paused --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index 1fae49e9d..6ba9132cf 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2248,7 +2248,7 @@ void F_TextPromptTicker(void) { INT32 i; - if (!promptactive) + if (!promptactive || paused || P_AutoPause()) return; // advance animation From 311cb2781805668cbffb15b242d37527805ba032 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 4 Nov 2018 22:22:47 -0500 Subject: [PATCH 456/573] Close text prompt upon level load --- src/f_finale.c | 15 ++++++++------- src/f_finale.h | 2 +- src/p_setup.c | 3 +++ src/p_spec.c | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 6ba9132cf..8a6a8ce0c 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2110,7 +2110,7 @@ static void F_AdvanceToNextPage(void) // close the prompt if either num is invalid if (cutnum == INT32_MAX || scenenum == INT32_MAX) - F_EndTextPrompt(); + F_EndTextPrompt(false, false); else { // on page mode, number of tics before allowing boost @@ -2120,18 +2120,19 @@ static void F_AdvanceToNextPage(void) } } -void F_EndTextPrompt(void) +void F_EndTextPrompt(boolean forceexec, boolean noexec) { - if (promptactive) { + boolean promptwasactive = promptactive; + promptactive = false; + + if (promptwasactive) { if (promptmo && promptmo->player && promptblockcontrols) promptmo->reactiontime = TICRATE/4; // prevent jumping right away // \todo account freeze realtime for this) // \todo reset frozen realtime? } - promptactive = false; - // \todo net safety, maybe loop all player thinkers? - if (promptpostexectag) + if ((promptwasactive || forceexec) && !noexec && promptpostexectag) { P_MapStart(); P_LinedefExecute(promptpostexectag, promptmo, NULL); @@ -2168,7 +2169,7 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postex F_PreparePageText(textprompts[cutnum]->page[scenenum].text); } else - F_EndTextPrompt(); // run the post-effects immediately + F_EndTextPrompt(true, false); // run the post-effects immediately } void F_TextPromptDrawer(void) diff --git a/src/f_finale.h b/src/f_finale.h index dfee247fb..8ce7ac22e 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -54,7 +54,7 @@ void F_EndCutScene(void); void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime); void F_TextPromptDrawer(void); -void F_EndTextPrompt(void); +void F_EndTextPrompt(boolean forceexec, boolean noexec); void F_StartGameEnd(void); void F_StartIntro(void); diff --git a/src/p_setup.c b/src/p_setup.c index eb25c51c8..b2dfedb4e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2753,6 +2753,9 @@ boolean P_SetupLevel(boolean skipprecip) I_UpdateNoVsync(); } + // Close text prompt before freeing the old level + F_EndTextPrompt(false, true); + #ifdef HAVE_BLUA LUA_InvalidateLevel(); #endif diff --git a/src/p_spec.c b/src/p_spec.c index edf9174d6..42153b4bf 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3773,7 +3773,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) //boolean freezethinkers = (line->flags & ML_EFFECT4); if (closetextprompt) - F_EndTextPrompt(); + F_EndTextPrompt(false, false); else F_StartTextPrompt(promptnum, pagenum, mo, runpostexec ? postexectag : 0, blockcontrols, freezerealtime); } From eb204b6cc44a7d3bf9f16859274b186b2ad41847 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 5 Nov 2018 07:41:02 -0500 Subject: [PATCH 457/573] Add exec to GoldMonitorPop; transfer Angle tag to mobj->lastlook for Lua compat --- src/p_enemy.c | 9 +++++++-- src/p_mobj.c | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 15608f57f..6fee7d2f0 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3327,8 +3327,8 @@ void A_MonitorPop(mobj_t *actor) // Run a linedef executor immediately upon popping // You may want to delay your effects by 18 tics to sync with the reward giving - if (actor->spawnpoint && (actor->spawnpoint->options & MTF_EXTRA) && (actor->spawnpoint->angle & 16384)) - P_LinedefExecute((actor->spawnpoint->angle & 16383), actor->target, NULL); + if (actor->spawnpoint && actor->lastlook) + P_LinedefExecute(actor->lastlook, actor->target, NULL); } // Function: A_GoldMonitorPop @@ -3412,6 +3412,11 @@ void A_GoldMonitorPop(mobj_t *actor) newmobj->sprite = SPR_TV1P; } } + + // Run a linedef executor immediately upon popping + // You may want to delay your effects by 18 tics to sync with the reward giving + if (actor->spawnpoint && actor->lastlook) + P_LinedefExecute(actor->lastlook, actor->target, NULL); } // Function: A_GoldMonitorRestore diff --git a/src/p_mobj.c b/src/p_mobj.c index 717bb92b6..2450fb801 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10894,6 +10894,16 @@ ML_EFFECT4 : Don't clip inside the ground mobj->flags2 |= MF2_OBJECTFLIP; } + // Extra functionality + if (mthing->options & MTF_EXTRA) + { + if (mobj->flags & MF_MONITOR && (mthing->angle & 16384)) + { + // Store line exec tag to run upon popping + mobj->lastlook = (mthing->angle & 16383); + } + } + // Final set of not being able to draw nightsitems. if (mobj->flags & MF_NIGHTSITEM) mobj->flags2 |= MF2_DONTDRAW; From 1cc8619c9e155a06f39821473c84b25ff11b0fac Mon Sep 17 00:00:00 2001 From: MPC Date: Mon, 5 Nov 2018 20:40:51 -0200 Subject: [PATCH 458/573] 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 459/573] 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 f66979ba1a3f2b2ea8bb07bc7c31e09094c6e1ec Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 7 Nov 2018 21:00:38 +0000 Subject: [PATCH 460/573] P_NullPrecipThinker no longer should have FUNCMATH (though I'm not sure if it should have had it in the first place anyway) --- src/p_mobj.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.h b/src/p_mobj.h index 620028d81..56d9b6dae 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -445,7 +445,7 @@ boolean P_SupermanLook4Players(mobj_t *actor); void P_DestroyRobots(void); void P_SnowThinker(precipmobj_t *mobj); void P_RainThinker(precipmobj_t *mobj); -FUNCMATH void P_NullPrecipThinker(precipmobj_t *mobj); +void P_NullPrecipThinker(precipmobj_t *mobj); void P_RemovePrecipMobj(precipmobj_t *mobj); void P_SetScale(mobj_t *mobj, fixed_t newscale); void P_XYMovement(mobj_t *mo); From 4a4e07e1385ddb1c707e431e6be928cc16a1c724 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 7 Nov 2018 21:21:36 +0000 Subject: [PATCH 461/573] D_PostEvent_end is only used by Allegro (used by the DOS port) to help timers work, so check for PC_DOS in preprocessor code. Also remove FUNCMATH from said function. --- src/d_main.c | 2 +- src/d_main.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 170532675..037aeccf9 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -170,7 +170,7 @@ void D_PostEvent(const event_t *ev) eventhead = (eventhead+1) & (MAXEVENTS-1); } // just for lock this function -#ifndef DOXYGEN +#if defined (PC_DOS) && !defined (DOXYGEN) void D_PostEvent_end(void) {}; #endif diff --git a/src/d_main.h b/src/d_main.h index d73b19d1f..4c9c99ea5 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -40,8 +40,8 @@ void D_SRB2Main(void); // Called by IO functions when input is detected. void D_PostEvent(const event_t *ev); -#ifndef DOXYGEN -FUNCMATH void D_PostEvent_end(void); // delimiter for locking memory +#if defined (PC_DOS) && !defined (DOXYGEN) +void D_PostEvent_end(void); // delimiter for locking memory #endif void D_ProcessEvents(void); From b3e8a1ed88961acad8d45a59c3003af08ccb6b5c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 7 Nov 2018 21:37:42 +0000 Subject: [PATCH 462/573] HU_Start should not have FUNCMATH, it has side effects --- src/hu_stuff.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 5356ba8ac..a5c81e6e7 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -84,7 +84,7 @@ void HU_Init(void); void HU_LoadGraphics(void); // reset heads up when consoleplayer respawns. -FUNCMATH void HU_Start(void); +void HU_Start(void); boolean HU_Responder(event_t *ev); From c47f0045d6a60b41faceff3edd17be58b244c601 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 7 Nov 2018 21:45:27 +0000 Subject: [PATCH 463/573] ST_Ticker also should not have FUNCMATH, as it also has side effects --- src/st_stuff.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/st_stuff.h b/src/st_stuff.h index c11559d2b..6fafca404 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -24,7 +24,7 @@ // // Called by main loop. -FUNCMATH void ST_Ticker(void); +void ST_Ticker(void); // Called by main loop. void ST_Drawer(void); From 0bdbdd1b1ed1ffbb15b99664d037fd5f83b7ad12 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 8 Nov 2018 16:26:55 +0000 Subject: [PATCH 464/573] Remove FUNCMATH from functions with a void return value or args, or examine variables other than their args (which could be modified) --- src/dehacked.c | 2 +- src/f_finale.c | 1 + src/f_finale.h | 2 +- src/r_plane.h | 2 +- src/r_splats.h | 4 ---- src/screen.c | 4 ---- src/sdl/i_cdmus.c | 14 +++++++------- src/sdl/i_system.c | 16 ++++++++-------- src/sdl/i_video.c | 6 +++--- src/sdl/mixer_sound.c | 4 ++-- src/sdl/sdl_sound.c | 2 +- src/sdl12/sdl_sound.c | 2 +- 12 files changed, 26 insertions(+), 33 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index b7e874b16..2fed963f8 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7769,7 +7769,7 @@ fixed_t get_number(const char *word) #endif } -void FUNCMATH DEH_Check(void) +void DEH_Check(void) { #if defined(_DEBUG) || defined(PARANOIA) const size_t dehstates = sizeof(STATE_LIST)/sizeof(const char*); diff --git a/src/f_finale.c b/src/f_finale.c index fb1387c11..a50e4a5be 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1401,6 +1401,7 @@ void F_StartGameEnd(void) // void F_GameEndDrawer(void) { + // this function does nothing } // diff --git a/src/f_finale.h b/src/f_finale.h index 1f23643be..8ee02bdf3 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -35,7 +35,7 @@ void F_CutsceneTicker(void); void F_TitleDemoTicker(void); // Called by main loop. -FUNCMATH void F_GameEndDrawer(void); +void F_GameEndDrawer(void); void F_IntroDrawer(void); void F_TitleScreenDrawer(void); diff --git a/src/r_plane.h b/src/r_plane.h index 16c8c12a4..dff58669a 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -87,7 +87,7 @@ extern lighttable_t **planezlight; extern fixed_t *yslope; extern fixed_t distscale[MAXVIDWIDTH]; -FUNCMATH void R_InitPlanes(void); +void R_InitPlanes(void); void R_PortalStoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale); void R_PortalRestoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale); void R_ClearPlanes(void); diff --git a/src/r_splats.h b/src/r_splats.h index c0ba6881c..349d8fa7a 100644 --- a/src/r_splats.h +++ b/src/r_splats.h @@ -63,11 +63,7 @@ typedef struct floorsplat_s fixed_t P_SegLength(seg_t *seg); // call at P_SetupLevel() -#if !(defined (WALLSPLATS) || defined (FLOORSPLATS)) -FUNCMATH void R_ClearLevelSplats(void); -#else void R_ClearLevelSplats(void); -#endif #ifdef WALLSPLATS void R_AddWallSplat(line_t *wallline, INT16 sectorside, const char *patchname, fixed_t top, diff --git a/src/screen.c b/src/screen.c index 58c38993b..fdd8eb7bd 100644 --- a/src/screen.c +++ b/src/screen.c @@ -71,11 +71,7 @@ consvar_t cv_scr_depth = {"scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NUL #endif consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -#ifdef DIRECTFULLSCREEN -static FUNCMATH void SCR_ChangeFullscreen (void); -#else static void SCR_ChangeFullscreen (void); -#endif consvar_t cv_fullscreen = {"fullscreen", "Yes", CV_SAVE|CV_CALL, CV_YesNo, SCR_ChangeFullscreen, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/sdl/i_cdmus.c b/src/sdl/i_cdmus.c index 3105f5122..5d086e73a 100644 --- a/src/sdl/i_cdmus.c +++ b/src/sdl/i_cdmus.c @@ -12,19 +12,19 @@ consvar_t cd_volume = {"cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL, 0, NUL consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -FUNCMATH void I_InitCD(void){} +void I_InitCD(void){} -FUNCMATH void I_StopCD(void){} +void I_StopCD(void){} -FUNCMATH void I_PauseCD(void){} +void I_PauseCD(void){} -FUNCMATH void I_ResumeCD(void){} +void I_ResumeCD(void){} -FUNCMATH void I_ShutdownCD(void){} +void I_ShutdownCD(void){} -FUNCMATH void I_UpdateCD(void){} +void I_UpdateCD(void){} -FUNCMATH void I_PlayCD(UINT8 track, UINT8 looping) +void I_PlayCD(UINT8 track, UINT8 looping) { (void)track; (void)looping; diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 7b14f1f18..9a2baf31c 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1927,14 +1927,14 @@ void I_StartupMouse2(void) // // I_Tactile // -FUNCMATH void I_Tactile(FFType pFFType, const JoyFF_t *FFEffect) +void I_Tactile(FFType pFFType, const JoyFF_t *FFEffect) { // UNUSED. (void)pFFType; (void)FFEffect; } -FUNCMATH void I_Tactile2(FFType pFFType, const JoyFF_t *FFEffect) +void I_Tactile2(FFType pFFType, const JoyFF_t *FFEffect) { // UNUSED. (void)pFFType; @@ -1945,7 +1945,7 @@ FUNCMATH void I_Tactile2(FFType pFFType, const JoyFF_t *FFEffect) */ static ticcmd_t emptycmd; -FUNCMATH ticcmd_t *I_BaseTiccmd(void) +ticcmd_t *I_BaseTiccmd(void) { return &emptycmd; } @@ -1954,7 +1954,7 @@ FUNCMATH ticcmd_t *I_BaseTiccmd(void) */ static ticcmd_t emptycmd2; -FUNCMATH ticcmd_t *I_BaseTiccmd2(void) +ticcmd_t *I_BaseTiccmd2(void) { return &emptycmd2; } @@ -2048,7 +2048,7 @@ tic_t I_GetTime (void) // //I_StartupTimer // -FUNCMATH void I_StartupTimer(void) +void I_StartupTimer(void) { #ifdef _WIN32 // for win2k time bug @@ -2147,11 +2147,11 @@ void I_WaitVBL(INT32 count) SDL_Delay(count); } -FUNCMATH void I_BeginRead(void) +void I_BeginRead(void) { } -FUNCMATH void I_EndRead(void) +void I_EndRead(void) { } @@ -2939,5 +2939,5 @@ const CPUInfoFlags *I_CPUInfo(void) } // note CPUAFFINITY code used to reside here -FUNCMATH void I_RegisterSysCommands(void) {} +void I_RegisterSysCommands(void) {} #endif diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 30ef1b27b..db88f452a 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1053,7 +1053,7 @@ void I_SetPalette(RGBA_t *palette) } // return number of fullscreen + X11 modes -FUNCMATH INT32 VID_NumModes(void) +INT32 VID_NumModes(void) { if (USE_FULLSCREEN && numVidModes != -1) return numVidModes - firstEntry; @@ -1061,7 +1061,7 @@ FUNCMATH INT32 VID_NumModes(void) return MAXWINMODES; } -FUNCMATH const char *VID_GetModeName(INT32 modeNum) +const char *VID_GetModeName(INT32 modeNum) { #if 0 if (USE_FULLSCREEN && numVidModes != -1) // fullscreen modes @@ -1091,7 +1091,7 @@ FUNCMATH const char *VID_GetModeName(INT32 modeNum) return &vidModeName[modeNum][0]; } -FUNCMATH INT32 VID_GetModeForSize(INT32 w, INT32 h) +INT32 VID_GetModeForSize(INT32 w, INT32 h) { int i; for (i = 0; i < MAXWINMODES; i++) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 4d86d7a3c..f36f08695 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -135,7 +135,7 @@ void I_ShutdownSound(void) #endif } -FUNCMATH void I_UpdateSound(void) +void I_UpdateSound(void) { } @@ -504,7 +504,7 @@ static void mix_gme(void *udata, Uint8 *stream, int len) /// Music System /// ------------------------ -FUNCMATH void I_InitMusic(void) +void I_InitMusic(void) { } diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 9f8a3e29d..f4796cd80 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -219,7 +219,7 @@ static void Snd_UnlockAudio(void) //Alam: Unlock audio data and reinstall audio #endif } -FUNCMATH static inline Uint16 Snd_LowerRate(Uint16 sr) +static inline Uint16 Snd_LowerRate(Uint16 sr) { if (sr <= audio.freq) // already lowered rate? return sr; // good then diff --git a/src/sdl12/sdl_sound.c b/src/sdl12/sdl_sound.c index 01a27153e..ed1afd8e2 100644 --- a/src/sdl12/sdl_sound.c +++ b/src/sdl12/sdl_sound.c @@ -236,7 +236,7 @@ static void Snd_UnlockAudio(void) //Alam: Unlock audio data and reinstall audio #endif } -FUNCMATH static inline Uint16 Snd_LowerRate(Uint16 sr) +static inline Uint16 Snd_LowerRate(Uint16 sr) { if (sr <= audio.freq) // already lowered rate? return sr; // good then From 5c61c405514206b6e7b8b46f5322920519efa5f1 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 8 Nov 2018 16:31:20 +0000 Subject: [PATCH 465/573] Clean up doomtype.h a bit, add indenting and comments to make some preprocessor code more readable --- src/doomtype.h | 129 +++++++++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 59 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index a711b466d..3631eb518 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -44,12 +44,13 @@ typedef long ssize_t; /* Older Visual C++ headers don't have the Win64-compatible typedefs... */ -#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) -#define DWORD_PTR DWORD -#endif - -#if ((_MSC_VER <= 1200) && (!defined(PDWORD_PTR))) -#define PDWORD_PTR PDWORD +#if (_MSC_VER <= 1200) + #ifndef DWORD_PTR + #define DWORD_PTR DWORD + #endif + #ifndef PDWORD_PTR + #define PDWORD_PTR PDWORD + #endif #endif #elif defined (_arch_dreamcast) // KOS Dreamcast #include @@ -102,7 +103,7 @@ typedef long ssize_t; #ifdef _MSC_VER #if (_MSC_VER <= 1800) // MSVC 2013 and back #define snprintf _snprintf -#if (_MSC_VER <= 1200) // MSVC 2012 and back +#if (_MSC_VER <= 1200) // MSVC 6.0 and back #define vsnprintf _vsnprintf #endif #endif @@ -185,7 +186,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz); //faB: clean that up !! #if defined( _MSC_VER) && (_MSC_VER >= 1800) // MSVC 2013 and forward - #include "stdbool.h" + #include "stdbool.h" #elif (defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))) && !defined (_XBOX) #define false FALSE // use windows types #define true TRUE @@ -275,58 +276,68 @@ typedef UINT32 tic_t; #endif #ifdef __GNUC__ // __attribute__ ((X)) -#define FUNCNORETURN __attribute__ ((noreturn)) -#if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && defined (__MINGW32__) -#include "inttypes.h" -#if 0 //defined (__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO > 0 -#define FUNCPRINTF __attribute__ ((format(gnu_printf, 1, 2))) -#define FUNCDEBUG __attribute__ ((format(gnu_printf, 2, 3))) -#define FUNCIERROR __attribute__ ((format(gnu_printf, 1, 2),noreturn)) -#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) -#define FUNCPRINTF __attribute__ ((format(ms_printf, 1, 2))) -#define FUNCDEBUG __attribute__ ((format(ms_printf, 2, 3))) -#define FUNCIERROR __attribute__ ((format(ms_printf, 1, 2),noreturn)) -#else -#define FUNCPRINTF __attribute__ ((format(printf, 1, 2))) -#define FUNCDEBUG __attribute__ ((format(printf, 2, 3))) -#define FUNCIERROR __attribute__ ((format(printf, 1, 2),noreturn)) -#endif -#else -#define FUNCPRINTF __attribute__ ((format(printf, 1, 2))) -#define FUNCDEBUG __attribute__ ((format(printf, 2, 3))) -#define FUNCIERROR __attribute__ ((format(printf, 1, 2),noreturn)) -#endif -#ifndef FUNCIERROR -#define FUNCIERROR __attribute__ ((noreturn)) -#endif -#define FUNCMATH __attribute__((const)) -#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) -#define FUNCDEAD __attribute__ ((deprecated)) -#define FUNCINLINE __attribute__((always_inline)) -#define FUNCNONNULL __attribute__((nonnull)) -#endif -#define FUNCNOINLINE __attribute__((noinline)) -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) -#ifdef __i386__ // i386 only -#define FUNCTARGET(X) __attribute__ ((__target__ (X))) -#endif -#endif -#if defined (__MINGW32__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -#define ATTRPACK __attribute__((packed, gcc_struct)) -#else -#define ATTRPACK __attribute__((packed)) -#endif -#define ATTRUNUSED __attribute__((unused)) -#ifdef _XBOX -#define FILESTAMP I_OutputMsg("%s:%d\n",__FILE__,__LINE__); -#define XBOXSTATIC static -#endif + #define FUNCNORETURN __attribute__ ((noreturn)) + + #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && defined (__MINGW32__) // MinGW, >= GCC 4.1 + #include "inttypes.h" + #if 0 //defined (__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO > 0 + #define FUNCPRINTF __attribute__ ((format(gnu_printf, 1, 2))) + #define FUNCDEBUG __attribute__ ((format(gnu_printf, 2, 3))) + #define FUNCIERROR __attribute__ ((format(gnu_printf, 1, 2),noreturn)) + #elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) // >= GCC 4.4 + #define FUNCPRINTF __attribute__ ((format(ms_printf, 1, 2))) + #define FUNCDEBUG __attribute__ ((format(ms_printf, 2, 3))) + #define FUNCIERROR __attribute__ ((format(ms_printf, 1, 2),noreturn)) + #else + #define FUNCPRINTF __attribute__ ((format(printf, 1, 2))) + #define FUNCDEBUG __attribute__ ((format(printf, 2, 3))) + #define FUNCIERROR __attribute__ ((format(printf, 1, 2),noreturn)) + #endif + #else + #define FUNCPRINTF __attribute__ ((format(printf, 1, 2))) + #define FUNCDEBUG __attribute__ ((format(printf, 2, 3))) + #define FUNCIERROR __attribute__ ((format(printf, 1, 2),noreturn)) + #endif + + #ifndef FUNCIERROR + #define FUNCIERROR __attribute__ ((noreturn)) + #endif + + #define FUNCMATH __attribute__((const)) + + #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) // >= GCC 3.1 + #define FUNCDEAD __attribute__ ((deprecated)) + #define FUNCINLINE __attribute__((always_inline)) + #define FUNCNONNULL __attribute__((nonnull)) + #endif + + #define FUNCNOINLINE __attribute__((noinline)) + + #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) // >= GCC 4.4 + #ifdef __i386__ // i386 only + #define FUNCTARGET(X) __attribute__ ((__target__ (X))) + #endif + #endif + + #if defined (__MINGW32__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) // MinGW, >= GCC 3.4 + #define ATTRPACK __attribute__((packed, gcc_struct)) + #else + #define ATTRPACK __attribute__((packed)) + #endif + + #define ATTRUNUSED __attribute__((unused)) + + // Xbox-only macros + #ifdef _XBOX + #define FILESTAMP I_OutputMsg("%s:%d\n",__FILE__,__LINE__); + #define XBOXSTATIC static + #endif #elif defined (_MSC_VER) -#define ATTRNORETURN __declspec(noreturn) -#define ATTRINLINE __forceinline -#if _MSC_VER > 1200 -#define ATTRNOINLINE __declspec(noinline) -#endif + #define ATTRNORETURN __declspec(noreturn) + #define ATTRINLINE __forceinline + #if _MSC_VER > 1200 // >= MSVC 6.0 + #define ATTRNOINLINE __declspec(noinline) + #endif #endif #ifndef FUNCPRINTF From fd20bbb54e5882f43f006bcf60f653455f55ab11 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 8 Nov 2018 17:05:35 +0000 Subject: [PATCH 466/573] More doomtype.h cleaning up: * Move the misc types in the file to bottom, so that ATTRPACK at least is usable for RGBA_t * Include endian.h, so that UINT2RGBA can be defined correctly for big endian builds * Add more comments to make clear the main sections of the file --- src/doomtype.h | 77 ++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index 3631eb518..67c279aa9 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -98,6 +98,8 @@ typedef long ssize_t; #define NOIPX #endif +/* Strings and some misc platform specific stuff */ + #if defined (_MSC_VER) || defined (__OS2__) // Microsoft VisualC++ #ifdef _MSC_VER @@ -179,6 +181,8 @@ size_t strlcpy(char *dst, const char *src, size_t siz); // not the number of bytes in the buffer. #define STRBUFCPY(dst,src) strlcpy(dst, src, sizeof dst) +/* Boolean type definition */ + // \note __BYTEBOOL__ used to be set above if "macintosh" was defined, // if macintosh's version of boolean type isn't needed anymore, then isn't this macro pointless now? #ifndef __BYTEBOOL__ @@ -241,39 +245,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz); #define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */ #endif -union FColorRGBA -{ - UINT32 rgba; - struct - { - UINT8 red; - UINT8 green; - UINT8 blue; - UINT8 alpha; - } s; -} ATTRPACK; -typedef union FColorRGBA RGBA_t; - -typedef enum -{ - postimg_none, - postimg_water, - postimg_motion, - postimg_flip, - postimg_heat -} postimg_t; - -typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num) -#define LUMPERROR UINT32_MAX - -typedef UINT32 tic_t; -#define INFTICS UINT32_MAX - -#ifdef _BIG_ENDIAN -#define UINT2RGBA(a) a -#else -#define UINT2RGBA(a) (UINT32)((a&0xff)<<24)|((a&0xff00)<<8)|((a&0xff0000)>>8)|(((UINT32)a&0xff000000)>>24) -#endif +/* Compiler-specific attributes and other macros */ #ifdef __GNUC__ // __attribute__ ((X)) #define FUNCNORETURN __attribute__ ((noreturn)) @@ -391,4 +363,43 @@ typedef UINT32 tic_t; #ifndef FILESTAMP #define FILESTAMP #endif + +/* Miscellaneous types that don't fit anywhere else (Can this be changed?) */ + +union FColorRGBA +{ + UINT32 rgba; + struct + { + UINT8 red; + UINT8 green; + UINT8 blue; + UINT8 alpha; + } s; +} ATTRPACK; +typedef union FColorRGBA RGBA_t; + +typedef enum +{ + postimg_none, + postimg_water, + postimg_motion, + postimg_flip, + postimg_heat +} postimg_t; + +typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num) +#define LUMPERROR UINT32_MAX + +typedef UINT32 tic_t; +#define INFTICS UINT32_MAX + +#include "endian.h" // This is needed to make sure the below macro acts correctly in big endian builds + +#ifdef SRB2_BIG_ENDIAN +#define UINT2RGBA(a) a +#else +#define UINT2RGBA(a) (UINT32)((a&0xff)<<24)|((a&0xff00)<<8)|((a&0xff0000)>>8)|(((UINT32)a&0xff000000)>>24) +#endif + #endif //__DOOMTYPE__ From fa80d6179978b1d8c88eda73d1efde1f4194c2d4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 8 Nov 2018 17:16:54 +0000 Subject: [PATCH 467/573] byteptr.h: include endian.h to help define WRITE/READ macros correctly according to endianness --- src/byteptr.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/byteptr.h b/src/byteptr.h index 410d7c004..364e6520c 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -15,7 +15,9 @@ #define DEALIGNED #endif -#ifndef _BIG_ENDIAN +#include "endian.h" + +#ifndef SRB2_BIG_ENDIAN // // Little-endian machines // @@ -75,7 +77,7 @@ #define READANGLE(p) *((angle_t *)p)++ #endif -#else //_BIG_ENDIAN +#else //SRB2_BIG_ENDIAN // // definitions for big-endian machines with alignment constraints. // @@ -144,7 +146,7 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) #define READCHAR(p) ({ char *p_tmp = ( char *)p; char b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) #define READFIXED(p) ({ fixed_t *p_tmp = (fixed_t *)p; fixed_t b = readlong(p); p_tmp++; p = (void *)p_tmp; b; }) #define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = readulong(p); p_tmp++; p = (void *)p_tmp; b; }) -#endif //_BIG_ENDIAN +#endif //SRB2_BIG_ENDIAN #undef DEALIGNED From f50f10ef307fe2a09a2d2fb84cb368ea10b89567 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 8 Nov 2018 20:09:00 +0000 Subject: [PATCH 468/573] d_main.c: remove the _MAX_PATH define, the file hasn't used it since v2.0 --- src/d_main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 037aeccf9..15b144dda 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -761,10 +761,6 @@ static inline void D_CleanFile(void) } } -#ifndef _MAX_PATH -#define _MAX_PATH MAX_WADPATH -#endif - // ========================================================================== // Identify the SRB2 version, and IWAD file to use. // ========================================================================== From 82c738ea4b7ee4b1c03de261d26387107da9dd3c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 8 Nov 2018 21:13:58 +0000 Subject: [PATCH 469/573] 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 470/573] 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 471/573] 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) From b8897db3088e807f0866fb9f3b3fbd194dcf7b89 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 9 Nov 2018 21:55:14 -0500 Subject: [PATCH 472/573] Fix crash when page text is empty; add checks for MAX_PROMPTS and MAX_PAGES --- src/dehacked.c | 6 +++--- src/doomstat.h | 7 +++++-- src/f_finale.c | 17 ++++++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index dcd61bd31..0802fc49d 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1773,17 +1773,17 @@ static void readtextprompt(MYFILE *f, INT32 num) if (fastcmp(word, "NUMPAGES")) { - textprompts[num]->numpages = value; + textprompts[num]->numpages = min(max(value, 0), MAX_PAGES); } else if (fastcmp(word, "PAGE")) { - if (1 <= value && value <= 128) + if (1 <= value && value <= MAX_PAGES) { textprompts[num]->page[value - 1].backcolor = UINT8_MAX; // non-zero default readtextpromptpage(f, num, value - 1); } else - deh_warning("Page number %d out of range (1 - 128)", value); + deh_warning("Page number %d out of range (1 - %d)", value, MAX_PAGES); } else diff --git a/src/doomstat.h b/src/doomstat.h index 7bcf59946..eb1726e54 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -166,6 +166,9 @@ typedef struct extern cutscene_t *cutscenes[128]; +#define MAX_PROMPTS 256 +#define MAX_PAGES 128 + typedef struct { char name[32]; // narrator name @@ -186,11 +189,11 @@ typedef struct typedef struct { - textpage_t page[128]; // 128 pages per prompt. + textpage_t page[MAX_PAGES]; INT32 numpages; // Number of pages in this prompt } textprompt_t; -extern textprompt_t *textprompts[256]; +extern textprompt_t *textprompts[MAX_PROMPTS]; // For the Custom Exit linedef. extern INT16 nextmapoverride; diff --git a/src/f_finale.c b/src/f_finale.c index 8a6a8ce0c..f32e44b57 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2065,7 +2065,7 @@ static void F_PreparePageText(char *pagetext) if (promptpagetext) Z_Free(promptpagetext); - promptpagetext = V_WordWrap(textx, textr, 0, pagetext); + promptpagetext = (pagetext && pagetext[0]) ? V_WordWrap(textx, textr, 0, pagetext) : ""; F_NewCutscene(promptpagetext); cutscene_textspeed = textprompts[cutnum]->page[scenenum].textspeed ? textprompts[cutnum]->page[scenenum].textspeed : TICRATE/5; @@ -2085,7 +2085,7 @@ static void F_AdvanceToNextPage(void) // determine next prompt if (nextprompt) { - if (textprompts[nextprompt-1]) + if (nextprompt <= MAX_PROMPTS && textprompts[nextprompt-1]) cutnum = nextprompt-1; else cutnum = INT32_MAX; @@ -2095,14 +2095,14 @@ static void F_AdvanceToNextPage(void) if (nextpage) { scenenum = nextpage-1; - if (scenenum > textprompts[cutnum]->numpages-1) + if (scenenum >= MAX_PAGES || scenenum > textprompts[cutnum]->numpages-1) scenenum = INT32_MAX; } else { if (cutnum != oldcutnum) scenenum = 0; - else if (scenenum < textprompts[cutnum]->numpages-1) + else if (scenenum + 1 < MAX_PAGES && scenenum < textprompts[cutnum]->numpages-1) scenenum++; else scenenum = INT32_MAX; @@ -2157,8 +2157,8 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postex (void)freezerealtime; // \todo freeze player->realtime, maybe this needs to cycle through player thinkers // Initialize current prompt and scene - cutnum = (textprompts[promptnum]) ? promptnum : INT32_MAX; - scenenum = (cutnum != INT32_MAX && pagenum <= textprompts[cutnum]->numpages-1) ? pagenum : INT32_MAX; + cutnum = (promptnum < MAX_PROMPTS && textprompts[promptnum]) ? promptnum : INT32_MAX; + scenenum = (cutnum != INT32_MAX && pagenum < MAX_PAGES && pagenum <= textprompts[cutnum]->numpages-1) ? pagenum : INT32_MAX; promptactive = (cutnum != INT32_MAX && scenenum != INT32_MAX); if (promptactive) @@ -2320,7 +2320,10 @@ void F_TextPromptTicker(void) } // generate letter-by-letter text - if (!F_WriteText()) + if (scenenum >= MAX_PAGES || + !textprompts[cutnum]->page[scenenum].text || + !textprompts[cutnum]->page[scenenum].text[0] || + !F_WriteText()) timetonext = !promptblockcontrols; // never show the chevron if we can't toggle pages } From ae4c1e0e8242ed3e00cb5bb780532dcdf55d4846 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 9 Nov 2018 22:06:53 -0500 Subject: [PATCH 473/573] Fix tmthing crash in EndTextPrompt when loading an invalid prompt on level start --- src/f_finale.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index f32e44b57..f120cd756 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2125,7 +2125,8 @@ void F_EndTextPrompt(boolean forceexec, boolean noexec) boolean promptwasactive = promptactive; promptactive = false; - if (promptwasactive) { + if (promptwasactive) + { if (promptmo && promptmo->player && promptblockcontrols) promptmo->reactiontime = TICRATE/4; // prevent jumping right away // \todo account freeze realtime for this) // \todo reset frozen realtime? @@ -2134,9 +2135,14 @@ void F_EndTextPrompt(boolean forceexec, boolean noexec) // \todo net safety, maybe loop all player thinkers? if ((promptwasactive || forceexec) && !noexec && promptpostexectag) { - P_MapStart(); - P_LinedefExecute(promptpostexectag, promptmo, NULL); - P_MapEnd(); + if (tmthing) // edge case where starting an invalid prompt immediately on level load will make P_MapStart fail + P_LinedefExecute(promptpostexectag, promptmo, NULL); + else + { + P_MapStart(); + P_LinedefExecute(promptpostexectag, promptmo, NULL); + P_MapEnd(); + } } } @@ -2326,6 +2332,4 @@ void F_TextPromptTicker(void) !F_WriteText()) timetonext = !promptblockcontrols; // never show the chevron if we can't toggle pages } - - } From 7daf5d4727eadf2e196e57e0f4f5b8d4f1370096 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 9 Nov 2018 22:38:55 -0500 Subject: [PATCH 474/573] Set up separate background color for prompts vs. console --- src/console.c | 40 ++++++++++++++++++++++++++++++++-------- src/console.h | 2 ++ src/dehacked.c | 2 +- src/doomstat.h | 2 +- src/f_finale.c | 2 +- src/v_video.c | 11 ++++++++--- src/v_video.h | 2 +- 7 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/console.c b/src/console.c index 9bc01cf19..f4234d949 100644 --- a/src/console.c +++ b/src/console.c @@ -232,18 +232,20 @@ UINT8 *yellowmap, *magentamap, *lgreenmap, *bluemap, *graymap, *redmap, *orangem // Console BG color UINT8 *consolebgmap = NULL; +UINT8 *promptbgmap = NULL; +static UINT8 promptbgcolor = UINT8_MAX; -void CON_SetupBackColormap(void) +void CON_SetupBackColormapEx(INT32 color, boolean prompt) { UINT16 i, palsum; UINT8 j, palindex, shift; UINT8 *pal = W_CacheLumpName(GetPalette(), PU_CACHE); - if (!consolebgmap) - consolebgmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL); + if (color == INT32_MAX) + color = cons_backcolor.value; shift = 6; // 12 colors -- shift of 7 means 6 colors - switch (cons_backcolor.value) + switch (color) { case 0: palindex = 15; break; // White case 1: palindex = 31; break; // Gray @@ -257,20 +259,42 @@ void CON_SetupBackColormap(void) case 9: palindex = 187; break; // Magenta case 10: palindex = 139; break; // Aqua // Default green - default: palindex = 175; break; -} + default: palindex = 175; color = 11; break; + } + + if (prompt) + { + if (!promptbgmap) + promptbgmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL); + + if (color == promptbgcolor) + return; + else + promptbgcolor = color; + } + else if (!consolebgmap) + consolebgmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL); // setup background colormap for (i = 0, j = 0; i < 768; i += 3, j++) { palsum = (pal[i] + pal[i+1] + pal[i+2]) >> shift; - consolebgmap[j] = (UINT8)(palindex - palsum); + if (prompt) + promptbgmap[j] = (UINT8)(palindex - palsum); + else + consolebgmap[j] = (UINT8)(palindex - palsum); } } +void CON_SetupBackColormap(void) +{ + CON_SetupBackColormapEx(cons_backcolor.value, false); + CON_SetupBackColormapEx(1, true); // default to gray +} + static void CONS_backcolor_Change(void) { - CON_SetupBackColormap(); + CON_SetupBackColormapEx(cons_backcolor.value, false); } static void CON_SetupColormaps(void) diff --git a/src/console.h b/src/console.h index 970f841d0..c194f44bf 100644 --- a/src/console.h +++ b/src/console.h @@ -38,7 +38,9 @@ extern UINT8 *yellowmap, *magentamap, *lgreenmap, *bluemap, *graymap, *redmap, * // Console bg color (auto updated to match) extern UINT8 *consolebgmap; +extern UINT8 *promptbgmap; +void CON_SetupBackColormapEx(INT32 color, boolean prompt); void CON_SetupBackColormap(void); void CON_ClearHUD(void); // clear heads up messages diff --git a/src/dehacked.c b/src/dehacked.c index 0802fc49d..61dba24c8 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1779,7 +1779,7 @@ static void readtextprompt(MYFILE *f, INT32 num) { if (1 <= value && value <= MAX_PAGES) { - textprompts[num]->page[value - 1].backcolor = UINT8_MAX; // non-zero default + textprompts[num]->page[value - 1].backcolor = 1; // default to gray readtextpromptpage(f, num, value - 1); } else diff --git a/src/doomstat.h b/src/doomstat.h index eb1726e54..6ff32e95d 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -176,7 +176,7 @@ typedef struct boolean rightside; // narrator side, false = left, true = right boolean iconflip; // narrator flip icon horizontally UINT8 lines; // # of lines to show. If name is specified, name takes one of the lines. If 0, defaults to 4. - UINT8 backcolor; // see CON_SetupBackColormap: 0-10, 11 for default, UINT8_MAX for user-defined (CONS_BACKCOLOR) + INT32 backcolor; // see CON_SetupBackColormap: 0-11, INT32_MAX for user-defined (CONS_BACKCOLOR) UINT8 align; // text alignment, 0 = left, 1 = right, 2 = center UINT8 verticalalign; // vertical text alignment, 0 = top, 1 = bottom, 2 = middle UINT8 textspeed; // text speed, delay in tics between characters. diff --git a/src/f_finale.c b/src/f_finale.c index f120cd756..ad9fd26ce 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2199,7 +2199,7 @@ void F_TextPromptDrawer(void) F_GetPageTextGeometry(&pagelines, &rightside, &boxh, &texth, &texty, &namey, &chevrony, &textx, &textr); // Draw background - V_DrawTutorialBack(boxh); + V_DrawPromptBack(boxh, textprompts[cutnum]->page[scenenum].backcolor); // Draw narrator icon if (iconlump != LUMPERROR) diff --git a/src/v_video.c b/src/v_video.c index f8d0b392c..7296dc754 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1481,17 +1481,20 @@ void V_DrawFadeConsBack(INT32 plines) } // Very similar to F_DrawFadeConsBack, except we draw from the middle(-ish) of the screen to the bottom. -void V_DrawTutorialBack(INT32 boxheight) +void V_DrawPromptBack(INT32 boxheight, INT32 color) { UINT8 *deststop, *buf; boxheight *= vid.dupy; + if (color == INT32_MAX) + color = cons_backcolor.value; + #ifdef HWRENDER if (rendermode != render_soft && rendermode != render_none) { UINT32 hwcolor; - switch (cons_backcolor.value) + switch (color) { case 0: hwcolor = 0xffffff00; break; // White case 1: hwcolor = 0x80808000; break; // Gray @@ -1510,12 +1513,14 @@ void V_DrawTutorialBack(INT32 boxheight) } #endif + CON_SetupBackColormapEx(color, true); + // heavily simplified -- we don't need to know x or y position, // just the start and stop positions deststop = screens[0] + vid.rowbytes * vid.height; buf = deststop - vid.rowbytes * ((boxheight * 4) + (boxheight/2)*5); // 4 lines of space plus gaps between and some leeway for (; buf < deststop; ++buf) - *buf = consolebgmap[*buf]; + *buf = promptbgmap[*buf]; } // Gets string colormap, used for 0x80 color codes diff --git a/src/v_video.h b/src/v_video.h index ee958c2fa..84a027963 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -158,7 +158,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum); void V_DrawFadeScreen(UINT16 color, UINT8 strength); void V_DrawFadeConsBack(INT32 plines); -void V_DrawTutorialBack(INT32 boxheight); +void V_DrawPromptBack(INT32 boxheight, INT32 color); // draw a single character void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed); From 9ee894f7775f7c3e1b12e8e6614db929d1c8efc0 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 9 Nov 2018 22:47:42 -0500 Subject: [PATCH 475/573] Make gray/black text prompt backcolor darker in OpenGL --- src/dehacked.c | 9 +++++---- src/hardware/hw_draw.c | 2 +- src/v_video.c | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 61dba24c8..9130c3e40 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1666,9 +1666,10 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) textprompts[num]->page[pagenum].lines = usi; else if (fastcmp(word, "BACKCOLOR")) { - UINT8 backcolor; + INT32 backcolor; if (i == 0 || fastcmp(word2, "WHITE")) backcolor = 0; - else if (i == 1 || fastcmp(word2, "GRAY") || fastcmp(word2, "GREY")) backcolor = 1; + else if (i == 1 || fastcmp(word2, "GRAY") || fastcmp(word2, "GREY") || + fastcmp(word2, "BLACK")) backcolor = 1; else if (i == 2 || fastcmp(word2, "BROWN")) backcolor = 2; else if (i == 3 || fastcmp(word2, "RED")) backcolor = 3; else if (i == 4 || fastcmp(word2, "ORANGE")) backcolor = 4; @@ -1678,8 +1679,8 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) else if (i == 8 || fastcmp(word2, "PURPLE")) backcolor = 8; else if (i == 9 || fastcmp(word2, "MAGENTA")) backcolor = 9; else if (i == 10 || fastcmp(word2, "AQUA")) backcolor = 10; - else if (i < 0) backcolor = UINT8_MAX; // CONS_BACKCOLOR user-configured - else backcolor = 11; // default green + else if (i < 0) backcolor = INT32_MAX; // CONS_BACKCOLOR user-configured + else backcolor = 1; // default gray textprompts[num]->page[pagenum].backcolor = backcolor; } else if (fastcmp(word, "ALIGN")) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 6d4467439..4c6a29fa3 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -726,7 +726,7 @@ void HWR_DrawTutorialBack(UINT32 color, INT32 boxheight) v[2].tow = v[3].tow = 0.0f; Surf.FlatColor.rgba = UINT2RGBA(color); - Surf.FlatColor.s.alpha = 0x80; + Surf.FlatColor.s.alpha = (color == 0 ? 0xC0 : 0x80); // make black darker, like software HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); } diff --git a/src/v_video.c b/src/v_video.c index 7296dc754..3e2910df5 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1497,7 +1497,7 @@ void V_DrawPromptBack(INT32 boxheight, INT32 color) switch (color) { case 0: hwcolor = 0xffffff00; break; // White - case 1: hwcolor = 0x80808000; break; // Gray + case 1: hwcolor = 0x00000000; break; // Gray // Note this is different from V_DrawFadeConsBack case 2: hwcolor = 0x40201000; break; // Brown case 3: hwcolor = 0xff000000; break; // Red case 4: hwcolor = 0xff800000; break; // Orange From 7ac641450f07d25bd9fa8660562cdadcfe9bc346 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 9 Nov 2018 23:26:41 -0500 Subject: [PATCH 476/573] Text prompt Hide HUD dehacked --- src/dehacked.c | 10 ++++++++++ src/doomstat.h | 1 + src/f_finale.c | 9 +++++++++ src/f_finale.h | 1 + 4 files changed, 21 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index 9130c3e40..0fc3f905a 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1701,6 +1701,14 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) textprompts[num]->page[pagenum].textspeed = get_number(word2); else if (fastcmp(word, "TEXTSFX")) textprompts[num]->page[pagenum].textsfx = get_number(word2); + else if (fastcmp(word, "HIDEHUD")) + { + UINT8 hidehud = 0; + if (usi == 0 || (word2[0] == 'F' && (word2[1] == 'A' || !word2[1])) || word2[0] == 'N') hidehud = 1; // false + else if (usi == 1 || word2[0] == 'T' || word2[0] == 'Y') hidehud = 1; // true (hide appropriate HUD elements) + else if (usi == 2 || word2[0] == 'A' || (word2[0] == 'F' && word2[1] == 'O')) hidehud = 2; // force (hide all HUD elements) + textprompts[num]->page[pagenum].hidehud = hidehud; + } else if (fastcmp(word, "METAPAGE")) { if (usi && usi <= textprompts[num]->numpages) @@ -1716,6 +1724,7 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) textprompts[num]->page[pagenum].verticalalign = textprompts[num]->page[metapagenum].verticalalign; textprompts[num]->page[pagenum].textspeed = textprompts[num]->page[metapagenum].textspeed; textprompts[num]->page[pagenum].textsfx = textprompts[num]->page[metapagenum].textsfx; + textprompts[num]->page[pagenum].hidehud = textprompts[num]->page[metapagenum].hidehud; } } else if (fastcmp(word, "NEXTPROMPT")) @@ -1781,6 +1790,7 @@ static void readtextprompt(MYFILE *f, INT32 num) if (1 <= value && value <= MAX_PAGES) { textprompts[num]->page[value - 1].backcolor = 1; // default to gray + textprompts[num]->page[value - 1].hidehud = 1; // hide appropriate HUD elements readtextpromptpage(f, num, value - 1); } else diff --git a/src/doomstat.h b/src/doomstat.h index 6ff32e95d..a46711cc4 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -175,6 +175,7 @@ typedef struct char iconname[8]; // narrator icon lump boolean rightside; // narrator side, false = left, true = right boolean iconflip; // narrator flip icon horizontally + UINT8 hidehud; // hide hud, 0 = show all, 1 = hide depending on prompt position (top/bottom), 2 = hide all UINT8 lines; // # of lines to show. If name is specified, name takes one of the lines. If 0, defaults to 4. INT32 backcolor; // see CON_SetupBackColormap: 0-11, INT32_MAX for user-defined (CONS_BACKCOLOR) UINT8 align; // text alignment, 0 = left, 1 = right, 2 = center diff --git a/src/f_finale.c b/src/f_finale.c index ad9fd26ce..aec567123 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -33,6 +33,7 @@ #include "m_cond.h" #include "p_local.h" #include "p_setup.h" +#include "st_stuff.h" // hud hiding #ifdef HAVE_BLUA #include "lua_hud.h" @@ -2030,6 +2031,14 @@ boolean F_CutsceneResponder(event_t *event) // TEXT PROMPTS // ================== +INT32 F_GetPromptHideHud() +{ + if (cutnum == INT32_MAX || scenenum == INT32_MAX || !textprompts[cutnum] || scenenum >= textprompts[cutnum]->numpages) + return 0; + else + return textprompts[cutnum]->page[scenenum]->hidehud; +} + static void F_GetPageTextGeometry(UINT8 *pagelines, boolean *rightside, INT32 *boxh, INT32 *texth, INT32 *texty, INT32 *namey, INT32 *chevrony, INT32 *textx, INT32 *textr) { // reuse: diff --git a/src/f_finale.h b/src/f_finale.h index 8ce7ac22e..a6c962dea 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -55,6 +55,7 @@ void F_EndCutScene(void); void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime); void F_TextPromptDrawer(void); void F_EndTextPrompt(boolean forceexec, boolean noexec); +INT32 F_GetPromptHideHud(void); void F_StartGameEnd(void); void F_StartIntro(void); From 19a8b159128bb43ba24ca2d6da4c2e82de217431 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 10 Nov 2018 00:10:16 -0500 Subject: [PATCH 477/573] Actually fix empty prompt text crash --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index ad9fd26ce..0abee4b45 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2065,7 +2065,7 @@ static void F_PreparePageText(char *pagetext) if (promptpagetext) Z_Free(promptpagetext); - promptpagetext = (pagetext && pagetext[0]) ? V_WordWrap(textx, textr, 0, pagetext) : ""; + promptpagetext = (pagetext && pagetext[0]) ? V_WordWrap(textx, textr, 0, pagetext) : Z_StrDup(""); F_NewCutscene(promptpagetext); cutscene_textspeed = textprompts[cutnum]->page[scenenum].textspeed ? textprompts[cutnum]->page[scenenum].textspeed : TICRATE/5; From 33a94ba2b831f86763aa45dc327d3a5182521a26 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 10 Nov 2018 01:00:18 -0500 Subject: [PATCH 478/573] Prompt HUD hiding implementation --- src/f_finale.c | 62 +++++++++++++++++++++++++++++++++++++++++++------- src/f_finale.h | 3 ++- src/st_stuff.c | 35 +++++++++++++++++++++++++--- 3 files changed, 88 insertions(+), 12 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 64648fdda..8d3aaea67 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2031,14 +2031,6 @@ boolean F_CutsceneResponder(event_t *event) // TEXT PROMPTS // ================== -INT32 F_GetPromptHideHud() -{ - if (cutnum == INT32_MAX || scenenum == INT32_MAX || !textprompts[cutnum] || scenenum >= textprompts[cutnum]->numpages) - return 0; - else - return textprompts[cutnum]->page[scenenum]->hidehud; -} - static void F_GetPageTextGeometry(UINT8 *pagelines, boolean *rightside, INT32 *boxh, INT32 *texth, INT32 *texty, INT32 *namey, INT32 *chevrony, INT32 *textx, INT32 *textr) { // reuse: @@ -2063,6 +2055,60 @@ static void F_GetPageTextGeometry(UINT8 *pagelines, boolean *rightside, INT32 *b *textr = *rightside ? BASEVIDWIDTH - (((*boxh * 4) + (*boxh/2)*4) + 4) : BASEVIDWIDTH-4; } +static fixed_t F_GetPromptHideHudBound(void) +{ + UINT8 pagelines; + boolean rightside; + INT32 boxh, texth, texty, namey, chevrony; + INT32 textx, textr; + + if (cutnum == INT32_MAX || scenenum == INT32_MAX || !textprompts[cutnum] || scenenum >= textprompts[cutnum]->numpages || + !textprompts[cutnum]->page[scenenum].hidehud || + (splitscreen && textprompts[cutnum]->page[scenenum].hidehud != 2)) // don't hide on splitscreen, unless hide all is forced + return 0; + else if (textprompts[cutnum]->page[scenenum].hidehud == 2) // hide all + return BASEVIDHEIGHT; + + F_GetPageTextGeometry(&pagelines, &rightside, &boxh, &texth, &texty, &namey, &chevrony, &textx, &textr); + + // calc boxheight (see V_DrawPromptBack) + boxh *= vid.dupy; + boxh = (boxh * 4) + (boxh/2)*5; // 4 lines of space plus gaps between and some leeway + + // return a coordinate to check + // if negative: don't show hud elements below this coordinate (visually) + // if positive: don't show hud elements above this coordinate (visually) + return 0 - boxh; // \todo: if prompt at top of screen (someday), make this return positive +} + +boolean F_GetPromptHideHudAll(void) +{ + if (cutnum == INT32_MAX || scenenum == INT32_MAX || !textprompts[cutnum] || scenenum >= textprompts[cutnum]->numpages || + !textprompts[cutnum]->page[scenenum].hidehud || + (splitscreen && textprompts[cutnum]->page[scenenum].hidehud != 2)) // don't hide on splitscreen, unless hide all is forced + return false; + else if (textprompts[cutnum]->page[scenenum].hidehud == 2) // hide all + return true; + else + return false; +} + +boolean F_GetPromptHideHud(fixed_t y) +{ + INT32 ybound; + boolean fromtop; + fixed_t ytest; + + if (!promptactive) + return false; + + ybound = F_GetPromptHideHudBound(); + fromtop = (ybound >= 0); + ytest = (fromtop ? ybound : BASEVIDHEIGHT + ybound); + + return (fromtop ? y < ytest : y >= ytest); // true means hide +} + static void F_PreparePageText(char *pagetext) { UINT8 pagelines; diff --git a/src/f_finale.h b/src/f_finale.h index a6c962dea..0c9032ac2 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -55,7 +55,8 @@ void F_EndCutScene(void); void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime); void F_TextPromptDrawer(void); void F_EndTextPrompt(boolean forceexec, boolean noexec); -INT32 F_GetPromptHideHud(void); +boolean F_GetPromptHideHudAll(void); +boolean F_GetPromptHideHud(fixed_t y); void F_StartGameEnd(void); void F_StartIntro(void); diff --git a/src/st_stuff.c b/src/st_stuff.c index fa13e008a..26d9678a3 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -603,6 +603,9 @@ static void ST_drawDebugInfo(void) static void ST_drawScore(void) { + if (F_GetPromptHideHud(hudinfo[HUD_SCORE].y)) + return; + // SCORE: ST_DrawPatchFromHud(HUD_SCORE, sboscore, V_HUDTRANS); if (objectplacing) @@ -712,6 +715,9 @@ static void ST_drawTime(void) tictrn = G_TicsToCentiseconds(tics); } + if (F_GetPromptHideHud(hudinfo[HUD_TIME].y)) + return; + // TIME: ST_DrawPatchFromHud(HUD_TIME, ((downwards && (tics < 30*TICRATE) && (leveltime/5 & 1)) ? sboredtime : sbotime), V_HUDTRANS); @@ -738,6 +744,9 @@ static inline void ST_drawRings(void) { INT32 ringnum; + if (F_GetPromptHideHud(hudinfo[HUD_RINGS].y)) + return; + ST_DrawPatchFromHud(HUD_RINGS, ((!stplyr->spectator && stplyr->rings <= 0 && leveltime/5 & 1) ? sboredrings : sborings), ((stplyr->spectator) ? V_HUDTRANSHALF : V_HUDTRANS)); ringnum = ((objectplacing) ? op_currentdoomednum : max(stplyr->rings, 0)); @@ -756,6 +765,9 @@ static void ST_drawLivesArea(void) if (!stplyr->skincolor) return; // Just joined a server, skin isn't loaded yet! + if (F_GetPromptHideHud(hudinfo[HUD_LIVES].y)) + return; + // face background V_DrawSmallScaledPatch(hudinfo[HUD_LIVES].x, hudinfo[HUD_LIVES].y, hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANS, livesback); @@ -927,6 +939,9 @@ static void ST_drawInput(void) if (stplyr->powers[pw_carry] == CR_NIGHTSMODE) y -= 16; + if (F_GetPromptHideHud(y)) + return; + // O backing V_DrawFill(x, y-1, 16, 16, hudinfo[HUD_LIVES].f|20); V_DrawFill(x, y+15, 16, 1, hudinfo[HUD_LIVES].f|29); @@ -1202,6 +1217,9 @@ static void ST_drawPowerupHUD(void) static INT32 flagoffs[2] = {0, 0}, shieldoffs[2] = {0, 0}; #define ICONSEP (16+4) // matches weapon rings HUD + if (F_GetPromptHideHud(hudinfo[HUD_POWERUPS].y)) + return; + if (stplyr->spectator || stplyr->playerstate != PST_LIVE) return; @@ -1364,7 +1382,7 @@ static void ST_drawFirstPersonHUD(void) p = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); // Display the countdown drown numbers! - if (p) + if (p && !F_GetPromptHideHud(60 - SHORT(p->topoffset))) V_DrawScaledPatch((BASEVIDWIDTH/2) - (SHORT(p->width)/2) + SHORT(p->leftoffset), 60 - SHORT(p->topoffset), V_PERPLAYER|V_PERPLAYER|V_TRANSLUCENT, p); } @@ -1908,6 +1926,9 @@ static void ST_drawMatchHUD(void) const INT32 y = 176; // HUD_LIVES INT32 offset = (BASEVIDWIDTH / 2) - (NUM_WEAPONS * 10) - 6; + if (F_GetPromptHideHud(y)) + return; + if (!G_RingSlingerGametype()) return; @@ -1954,6 +1975,9 @@ static void ST_drawTextHUD(void) y -= 8;\ } + if (F_GetPromptHideHud(y)) + return; + if ((gametype == GT_TAG || gametype == GT_HIDEANDSEEK) && (!stplyr->spectator)) { if (leveltime < hidetime * TICRATE) @@ -2087,6 +2111,9 @@ static void ST_drawTeamHUD(void) patch_t *p; #define SEP 20 + if (F_GetPromptHideHud(0)) // y base is 0 + return; + if (gametype == GT_CTF) p = bflagico; else @@ -2200,7 +2227,8 @@ static INT32 ST_drawEmeraldHuntIcon(mobj_t *hunt, patch_t **patches, INT32 offse interval = 0; } - V_DrawScaledPatch(hudinfo[HUD_HUNTPICS].x+offset, hudinfo[HUD_HUNTPICS].y, hudinfo[HUD_HUNTPICS].f|V_PERPLAYER|V_HUDTRANS, patches[i]); + if (!F_GetPromptHideHud(hudinfo[HUD_HUNTPICS].y)) + V_DrawScaledPatch(hudinfo[HUD_HUNTPICS].x+offset, hudinfo[HUD_HUNTPICS].y, hudinfo[HUD_HUNTPICS].f|V_PERPLAYER|V_HUDTRANS, patches[i]); return interval; } @@ -2298,7 +2326,8 @@ static void ST_overlayDrawer(void) //hu_showscores = auto hide score/time/rings when tab rankings are shown if (!(hu_showscores && (netgame || multiplayer))) { - if (maptol & TOL_NIGHTS || G_IsSpecialStage(gamemap)) + if ((maptol & TOL_NIGHTS || G_IsSpecialStage(gamemap)) && + !F_GetPromptHideHudAll()) ST_drawNiGHTSHUD(); else { From a542006ae846a2ab87d08e8311e06d76747f3886 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 10 Nov 2018 01:17:11 -0500 Subject: [PATCH 479/573] Hide Tutorial menu option if no tutorialmap --- src/m_menu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 69c609db0..38ff3f998 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -732,7 +732,7 @@ static menuitem_t SR_EmblemHintMenu[] = // Single Player Main static menuitem_t SP_MainMenu[] = { - {IT_STRING, NULL, "Tutorial", M_StartTutorial, 84}, + {IT_CALL | IT_STRING, NULL, "Tutorial", M_StartTutorial, 84}, {IT_CALL | IT_STRING, NULL, "Start Game", M_LoadGame, 92}, {IT_SECRET, NULL, "Record Attack", M_TimeAttack, 100}, {IT_SECRET, NULL, "NiGHTS Mode", M_NightsAttack, 108}, @@ -6107,6 +6107,8 @@ static void M_CustomLevelSelect(INT32 choice) static void M_SinglePlayerMenu(INT32 choice) { (void)choice; + SP_MainMenu[sptutorial].status = + tutorialmap ? IT_CALL|IT_STRING : IT_NOTHING|IT_DISABLED; SP_MainMenu[sprecordattack].status = (M_SecretUnlocked(SECRET_RECORDATTACK)) ? IT_CALL|IT_STRING : IT_SECRET; SP_MainMenu[spnightsmode].status = From ffed9f4d20eaf77e75bef5588fd2ecc4b10f3126 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 10 Nov 2018 01:31:30 -0500 Subject: [PATCH 480/573] Force camera defaults during tutorialmode (doesn't work in all cases) --- src/p_user.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index dd2ddbc82..75712ff3a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8848,7 +8848,18 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (P_CameraThinker(player, thiscam, resetcalled)) return true; - if (thiscam == &camera) + if (tutorialmode) + { + // force defaults because we have a camera look section + // \todo would be nice to use cv_cam_*.defaultvalue directly, but string parsing + // is not separated from cv setting (see command.c Setvalue, CV_SetCVar) + camspeed = 0.3; + camstill = false; + camrotate = 0; + camdist = 160; + camheight = 25; + } + else if (thiscam == &camera) { camspeed = cv_cam_speed.value; camstill = cv_cam_still.value; From 28238c41dfd044a46f0624939a07f9fe250bc1c7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 10 Nov 2018 02:30:21 -0500 Subject: [PATCH 481/573] WIP: First-time tutorial prompt --- src/d_netcmd.c | 1 + src/g_game.h | 1 + src/m_menu.c | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 528d79f3b..dd9ced6c4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -719,6 +719,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_crosshair2); CV_RegisterVar(&cv_alwaysfreelook); CV_RegisterVar(&cv_alwaysfreelook2); + CV_RegisterVar(&cv_postfirsttime); // g_input.c CV_RegisterVar(&cv_sideaxis); diff --git a/src/g_game.h b/src/g_game.h index d6b41830e..00298c623 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -55,6 +55,7 @@ extern tic_t timeinmap; // Ticker for time spent in level (used for levelcard di extern INT16 rw_maximums[NUM_WEAPONS]; // used in game menu +extern consvar_t cv_postfirsttime; 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; diff --git a/src/m_menu.c b/src/m_menu.c index 38ff3f998..b61c6396a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -441,6 +441,9 @@ static CV_PossibleValue_t serversort_cons_t[] = { }; consvar_t cv_serversort = {"serversort", "Ping", CV_HIDEN | CV_CALL, serversort_cons_t, M_SortServerList, 0, NULL, NULL, 0, 0, NULL}; +// first time memory +consvar_t cv_postfirsttime = {"postfirsttime", "No", CV_HIDEN | CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + // autorecord demos for time attack static consvar_t cv_autorecord = {"autorecord", "Yes", 0, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -6141,6 +6144,8 @@ static void M_StartTutorial(INT32 choice) if (!tutorialmap) return; // no map to go to, don't bother + CV_SetValue(&cv_postfirsttime, 1); + tutorialmode = true; // turn on tutorial mode emeralds = 0; @@ -6757,6 +6762,20 @@ static void M_HandleLoadSave(INT32 choice) } } +static void M_TutorialResponse(INT32 ch) +{ + CV_SetValue(&cv_postfirsttime, 1); + if (ch != 'y' && ch != KEY_ENTER) + { + return; + // copypasta from M_LoadGame + M_ReadSaveStrings(); + M_SetupNextMenu(&SP_LoadDef); + } + else + M_StartTutorial(0); +} + // // Selected from SRB2 menu // @@ -6764,6 +6783,12 @@ static void M_LoadGame(INT32 choice) { (void)choice; + if (tutorialmap && !cv_postfirsttime.value) + { + M_StartMessage("Do you want to play a brief Tutorial?\n(Press 'Y' to go, or 'N' to skip)", M_TutorialResponse, MM_YESNO); + return; + } + M_ReadSaveStrings(); M_SetupNextMenu(&SP_LoadDef); } From 2da335a1c4cb9af38fbba79c4aadeeb4facf0093 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 10 Nov 2018 13:08:26 +0000 Subject: [PATCH 482/573] Place limit on the amount of alias recursion allowed, to prevent cycles or otherwise excessive recursion --- src/command.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/command.c b/src/command.c index f77fb5a4d..8971d42fc 100644 --- a/src/command.c +++ b/src/command.c @@ -63,6 +63,7 @@ CV_PossibleValue_t CV_Unsigned[] = {{0, "MIN"}, {999999999, "MAX"}, {0, NULL}}; CV_PossibleValue_t CV_Natural[] = {{1, "MIN"}, {999999999, "MAX"}, {0, NULL}}; #define COM_BUF_SIZE 8192 // command buffer size +#define MAX_ALIAS_RECURSION 100 // max recursion allowed for aliases static INT32 com_wait; // one command per frame (for cmd sequences) @@ -485,6 +486,7 @@ static void COM_ExecuteString(char *ptext) { xcommand_t *cmd; cmdalias_t *a; + static INT32 recursion = 0; // detects recursion and stops it if it goes too far COM_TokenizeString(ptext); @@ -497,6 +499,7 @@ static void COM_ExecuteString(char *ptext) { if (!stricmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase! { + recursion = 0; cmd->function(); return; } @@ -507,11 +510,20 @@ static void COM_ExecuteString(char *ptext) { if (!stricmp(com_argv[0], a->name)) { + if (recursion > MAX_ALIAS_RECURSION) + { + CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n")); + recursion = 0; + return; + } + recursion++; COM_BufInsertText(a->value); return; } } + recursion = 0; + // check cvars // Hurdler: added at Ebola's request ;) // (don't flood the console in software mode with bad gr_xxx command) From e1e94c3af2500fa60890a5d632c9a5759ed6005e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 10 Nov 2018 09:32:53 -0500 Subject: [PATCH 483/573] Added page tags and find page by tag * Added tutorial mode defines to this branch --- src/dehacked.c | 2 ++ src/doomstat.h | 4 ++++ src/f_finale.c | 30 ++++++++++++++++++++++++++++++ src/f_finale.h | 1 + src/g_game.c | 3 +++ src/p_setup.c | 1 + src/p_spec.c | 3 +++ 7 files changed, 44 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index 0fc3f905a..214d47a16 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1727,6 +1727,8 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) textprompts[num]->page[pagenum].hidehud = textprompts[num]->page[metapagenum].hidehud; } } + else if (fastcmp(word, "TAG")) + strncpy(textprompts[num]->page[pagenum].tag, word2, 25); else if (fastcmp(word, "NEXTPROMPT")) textprompts[num]->page[pagenum].nextprompt = usi; else if (fastcmp(word, "NEXTPAGE")) diff --git a/src/doomstat.h b/src/doomstat.h index a46711cc4..eb4ed7066 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -129,6 +129,9 @@ extern INT16 titlemap; extern boolean hidetitlepics; extern INT16 bootmap; //bootmap for loading a map on startup +extern INT16 tutorialmap; // map to load for tutorial +extern boolean tutorialmode; // are we in a tutorial right now? + extern boolean looptitle; // CTF colors. @@ -171,6 +174,7 @@ extern cutscene_t *cutscenes[128]; typedef struct { + char tag[25]; // page tag (24 chars due to texture concatenating) char name[32]; // narrator name char iconname[8]; // narrator icon lump boolean rightside; // narrator side, false = left, true = right diff --git a/src/f_finale.c b/src/f_finale.c index 8d3aaea67..9217ced68 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2233,6 +2233,36 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postex F_EndTextPrompt(true, false); // run the post-effects immediately } +void F_StartTextPromptByNamedTag(char *tag, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime) +{ + INT32 promptnum, pagenum; + char realtag[25]; + + strncpy(realtag, tag, 25); + realtag[24] = 0; + + // \todo hardcoded tutorial mode behavior: concat control mode (fps, platform, custom) to end of input tag + if (tutorialmode) + strncat(realtag, "FPS", 25); + + for (promptnum = 0; promptnum < MAX_PROMPTS; promptnum++) + { + if (!textprompts[promptnum]) + continue; + + for (pagenum = 0; pagenum < textprompts[promptnum]->numpages && pagenum < MAX_PAGES; pagenum++) + { + if (!strncmp(realtag, textprompts[promptnum]->page[pagenum].tag, 25)) + { + F_StartTextPrompt(promptnum, pagenum, mo, postexectag, blockcontrols, freezerealtime); + return; + } + } + } + + CONS_Debug(DBG_GAMELOGIC, "Text prompt: Can't find a page with named tag %s\n", realtag); +} + void F_TextPromptDrawer(void) { // reuse: diff --git a/src/f_finale.h b/src/f_finale.h index 0c9032ac2..093389c1f 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -53,6 +53,7 @@ void F_CutsceneDrawer(void); void F_EndCutScene(void); void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime); +void F_StartTextPromptByNamedTag(char *tag, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime); void F_TextPromptDrawer(void); void F_EndTextPrompt(boolean forceexec, boolean noexec); boolean F_GetPromptHideHudAll(void); diff --git a/src/g_game.c b/src/g_game.c index d72a1961b..2eecbe1b3 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -127,6 +127,9 @@ INT16 titlemap = 0; boolean hidetitlepics = false; INT16 bootmap; //bootmap for loading a map on startup +INT16 tutorialmap = 0; // map to load for tutorial +boolean tutorialmode = false; // are we in a tutorial right now? + boolean looptitle = false; UINT8 skincolor_redteam = SKINCOLOR_RED; diff --git a/src/p_setup.c b/src/p_setup.c index b2dfedb4e..c1e8c17e3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1541,6 +1541,7 @@ static void P_LoadRawSideDefs2(void *data) } case 443: // Calls a named Lua function + case 459: // Control text prompt (named tag) { char process[8*3+1]; memset(process,0,8*3+1); diff --git a/src/p_spec.c b/src/p_spec.c index 42153b4bf..76d7ac249 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3771,9 +3771,12 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) boolean blockcontrols = !(line->flags & ML_EFFECT2); boolean freezerealtime = !(line->flags & ML_EFFECT3); //boolean freezethinkers = (line->flags & ML_EFFECT4); + boolean callbynamedtag = (line->flags & ML_TFERLINE); if (closetextprompt) F_EndTextPrompt(false, false); + else if (callbynamedtag && sides[line->sidenum[0]].text && sides[line->sidenum[0]].text[0]) + F_StartTextPromptByNamedTag(sides[line->sidenum[0]].text, mo, runpostexec ? postexectag : 0, blockcontrols, freezerealtime); else F_StartTextPrompt(promptnum, pagenum, mo, runpostexec ? postexectag : 0, blockcontrols, freezerealtime); } From a197c197420df6687a4be16f4945e9f01307fe80 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 10 Nov 2018 09:38:32 -0500 Subject: [PATCH 484/573] Prompt page string field length adjustment; check empty named tag before prompt search --- src/dehacked.c | 8 ++++---- src/doomstat.h | 4 ++-- src/f_finale.c | 11 +++++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 214d47a16..c3323a6af 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1641,11 +1641,11 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) // HACK: Add yellow control char now // so the drawing function doesn't call it repeatedly - char name[32]; + char name[34]; name[0] = '\x82'; // color yellow name[1] = 0; - strncat(name, word2, 31); - name[31] = 0; + strncat(name, word2, 33); + name[33] = 0; // Replace _ with ' ' for (i = 0; i < 32 && name[i]; i++) @@ -1728,7 +1728,7 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) } } else if (fastcmp(word, "TAG")) - strncpy(textprompts[num]->page[pagenum].tag, word2, 25); + strncpy(textprompts[num]->page[pagenum].tag, word2, 33); else if (fastcmp(word, "NEXTPROMPT")) textprompts[num]->page[pagenum].nextprompt = usi; else if (fastcmp(word, "NEXTPAGE")) diff --git a/src/doomstat.h b/src/doomstat.h index eb4ed7066..432699d99 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -174,8 +174,8 @@ extern cutscene_t *cutscenes[128]; typedef struct { - char tag[25]; // page tag (24 chars due to texture concatenating) - char name[32]; // narrator name + char tag[33]; // page tag + char name[34]; // narrator name, extra char for color char iconname[8]; // narrator icon lump boolean rightside; // narrator side, false = left, true = right boolean iconflip; // narrator flip icon horizontally diff --git a/src/f_finale.c b/src/f_finale.c index 9217ced68..d706bf22e 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2236,14 +2236,17 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postex void F_StartTextPromptByNamedTag(char *tag, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime) { INT32 promptnum, pagenum; - char realtag[25]; + char realtag[33]; - strncpy(realtag, tag, 25); - realtag[24] = 0; + if (!tag || !tag[0]) + return; + + strncpy(realtag, tag, 33); + realtag[32] = 0; // \todo hardcoded tutorial mode behavior: concat control mode (fps, platform, custom) to end of input tag if (tutorialmode) - strncat(realtag, "FPS", 25); + strncat(realtag, "FPS", 33); for (promptnum = 0; promptnum < MAX_PROMPTS; promptnum++) { From 99a0831b0b053490664db7115faef5d7f62f1a25 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 10 Nov 2018 10:06:51 -0500 Subject: [PATCH 485/573] Hardcode tutorial prompt offset index --- src/doomstat.h | 6 +++++- src/f_finale.c | 3 ++- src/g_game.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 432699d99..b57098d52 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -169,7 +169,11 @@ typedef struct extern cutscene_t *cutscenes[128]; -#define MAX_PROMPTS 256 +// Reserve prompt space for tutorials +#define TUTORIAL_PROMPT 201 // one-based +#define TUTORIAL_AREAS 6 +#define TUTORIAL_AREA_PROMPTS 5 +#define MAX_PROMPTS (TUTORIAL_PROMPT+TUTORIAL_AREAS*TUTORIAL_AREA_PROMPTS*3) // 3 control modes #define MAX_PAGES 128 typedef struct diff --git a/src/f_finale.c b/src/f_finale.c index d706bf22e..0be8dd0bc 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2236,6 +2236,7 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postex void F_StartTextPromptByNamedTag(char *tag, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime) { INT32 promptnum, pagenum; + INT32 tutorialpromptnum = (tutorialmode) ? TUTORIAL_PROMPT-1 : 0; char realtag[33]; if (!tag || !tag[0]) @@ -2248,7 +2249,7 @@ void F_StartTextPromptByNamedTag(char *tag, mobj_t *mo, UINT16 postexectag, bool if (tutorialmode) strncat(realtag, "FPS", 33); - for (promptnum = 0; promptnum < MAX_PROMPTS; promptnum++) + for (promptnum = 0 + tutorialpromptnum; promptnum < MAX_PROMPTS; promptnum++) { if (!textprompts[promptnum]) continue; diff --git a/src/g_game.c b/src/g_game.c index 2eecbe1b3..12e9cc961 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -141,7 +141,7 @@ tic_t countdowntimer = 0; boolean countdowntimeup = false; cutscene_t *cutscenes[128]; -textprompt_t *textprompts[256]; +textprompt_t *textprompts[MAX_PROMPTS]; INT16 nextmapoverride; boolean skipstats; From 3d9ce630d2cbe9969b4c4fe35eed6b994cf9a1a6 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 10 Nov 2018 10:30:33 -0500 Subject: [PATCH 486/573] SOC for prompt gfx and music --- src/dehacked.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++- src/doomstat.h | 11 +++++++ 2 files changed, 98 insertions(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index c3323a6af..936a71777 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1557,6 +1557,7 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) char *word2; INT32 i; UINT16 usi; + UINT8 picid; do { @@ -1634,8 +1635,72 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) i = atoi(word2); usi = (UINT16)i; + // copypasta from readcutscenescene + if (fastcmp(word, "NUMBEROFPICS")) + { + textprompts[num]->page[pagenum].numpics = (UINT8)i; + } + else if (fastncmp(word, "PIC", 3)) + { + picid = (UINT8)atoi(word + 3); + if (picid > 8 || picid == 0) + { + deh_warning("textpromptscene %d: unknown word '%s'", num, word); + continue; + } + --picid; - if (fastcmp(word, "NAME")) + if (fastcmp(word+4, "NAME")) + { + strncpy(textprompts[num]->page[pagenum].picname[picid], word2, 8); + } + else if (fastcmp(word+4, "HIRES")) + { + textprompts[num]->page[pagenum].pichires[picid] = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); + } + else if (fastcmp(word+4, "DURATION")) + { + textprompts[num]->page[pagenum].picduration[picid] = usi; + } + else if (fastcmp(word+4, "XCOORD")) + { + textprompts[num]->page[pagenum].xcoord[picid] = usi; + } + else if (fastcmp(word+4, "YCOORD")) + { + textprompts[num]->page[pagenum].ycoord[picid] = usi; + } + else + deh_warning("textpromptscene %d: unknown word '%s'", num, word); + } + else if (fastcmp(word, "MUSIC")) + { + strncpy(textprompts[num]->page[pagenum].musswitch, word2, 7); + textprompts[num]->page[pagenum].musswitch[6] = 0; + } +#ifdef MUSICSLOT_COMPATIBILITY + else if (fastcmp(word, "MUSICSLOT")) + { + i = get_mus(word2, true); + if (i && i <= 1035) + snprintf(textprompts[num]->page[pagenum].musswitch, 7, "%sM", G_BuildMapName(i)); + else if (i && i <= 1050) + strncpy(textprompts[num]->page[pagenum].musswitch, compat_special_music_slots[i - 1036], 7); + else + textprompts[num]->page[pagenum].musswitch[0] = 0; // becomes empty string + textprompts[num]->page[pagenum].musswitch[6] = 0; + } +#endif + else if (fastcmp(word, "MUSICTRACK")) + { + textprompts[num]->page[pagenum].musswitchflags = ((UINT16)i) & MUSIC_TRACKMASK; + } + else if (fastcmp(word, "MUSICLOOP")) + { + textprompts[num]->page[pagenum].musicloop = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); + } + // end copypasta from readcutscenescene + else if (fastcmp(word, "NAME")) { INT32 i; @@ -1714,6 +1779,7 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) if (usi && usi <= textprompts[num]->numpages) { UINT8 metapagenum = usi - 1; + strncpy(textprompts[num]->page[pagenum].name, textprompts[num]->page[metapagenum].name, 32); strncpy(textprompts[num]->page[pagenum].iconname, textprompts[num]->page[metapagenum].iconname, 8); textprompts[num]->page[pagenum].rightside = textprompts[num]->page[metapagenum].rightside; @@ -1725,6 +1791,26 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) textprompts[num]->page[pagenum].textspeed = textprompts[num]->page[metapagenum].textspeed; textprompts[num]->page[pagenum].textsfx = textprompts[num]->page[metapagenum].textsfx; textprompts[num]->page[pagenum].hidehud = textprompts[num]->page[metapagenum].hidehud; + + // music: don't copy, else each page change may reset the music + } + } + if (fastcmp(word, "PICSMETAPAGE")) + { + if (usi && usi <= textprompts[num]->numpages) + { + UINT8 metapagenum = usi - 1; + UINT8 picid; + + for (picid = 0; picid < 8; picid++) + { + textprompts[num]->page[pagenum].numpics = textprompts[num]->page[metapagenum].numpics; + strncpy(textprompts[num]->page[pagenum].picname[picid], textprompts[num]->page[metapagenum].picname[picid], 8); + textprompts[num]->page[pagenum].pichires[picid] = textprompts[num]->page[metapagenum].pichires[picid]; + textprompts[num]->page[pagenum].picduration[picid] = textprompts[num]->page[metapagenum].picduration[picid]; + textprompts[num]->page[pagenum].xcoord[picid] = textprompts[num]->page[metapagenum].xcoord[picid]; + textprompts[num]->page[pagenum].ycoord[picid] = textprompts[num]->page[metapagenum].ycoord[picid]; + } } } else if (fastcmp(word, "TAG")) diff --git a/src/doomstat.h b/src/doomstat.h index b57098d52..a3428eb83 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -178,6 +178,17 @@ extern cutscene_t *cutscenes[128]; typedef struct { + UINT8 numpics; + char picname[8][8]; + UINT8 pichires[8]; + UINT16 xcoord[8]; // gfx + UINT16 ycoord[8]; // gfx + UINT16 picduration[8]; + + char musswitch[7]; + UINT16 musswitchflags; + UINT8 musicloop; + char tag[33]; // page tag char name[34]; // narrator name, extra char for color char iconname[8]; // narrator icon lump From a8291c122a106225a6c34aa22ea2eb1f67e39feb Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 10 Nov 2018 15:47:04 +0000 Subject: [PATCH 487/573] adding lua_maplib.c comments for new slope-related userdata types --- src/lua_maplib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 84bd73834..66fbb22b3 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1789,6 +1789,10 @@ static int ffloor_set(lua_State *L) } #ifdef ESLOPE +////////////// +// pslope_t // +////////////// + static int slope_get(lua_State *L) { pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE)); @@ -1925,6 +1929,10 @@ static int slope_set(lua_State *L) return 0; } +/////////////// +// vector*_t // +/////////////// + static int vector2_get(lua_State *L) { vector2_t *vec = *((vector2_t **)luaL_checkudata(L, 1, META_VECTOR2)); From d456a5362cec11899d70191176bc85c1909f705f Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 10 Nov 2018 15:55:09 +0000 Subject: [PATCH 488/573] Whoops, mucked up this part of the conflict resolving --- 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 a817e1f90..294e6bcd0 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -324,7 +324,7 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, if (pscale != FRACUNIT || (splitscreen && option & V_PERPLAYER)) { fwidth = (float)SHORT(gpatch->width) * fscalew * dupx; - fheight = (float)SHORT(gpatch->height) * fscalew * dupy; + fheight = (float)SHORT(gpatch->height) * fscaleh * dupy; } else { From 896de73c6007f462d3826088a84463f03a9972f6 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 10 Nov 2018 16:00:33 +0000 Subject: [PATCH 489/573] ....ow this slipup hurt me badly --- src/lua_hooklib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index bd95d4cbd..bb1f59729 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1209,6 +1209,10 @@ 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_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); LUA_Call(gL, 2); } From 631c6f93f5db684a71de1b23a888b4dd55bc3079 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 10 Nov 2018 11:05:33 -0500 Subject: [PATCH 490/573] Implement music switching for prompts --- src/f_finale.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/f_finale.c b/src/f_finale.c index 0be8dd0bc..b78bd14d9 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2172,6 +2172,11 @@ static void F_AdvanceToNextPage(void) // on timer mode, number of tics until page advances timetonext = textprompts[cutnum]->page[scenenum].timetonext ? textprompts[cutnum]->page[scenenum].timetonext : TICRATE/10; F_PreparePageText(textprompts[cutnum]->page[scenenum].text); + + if (textprompts[cutnum]->page[scenenum].musswitch[0]) + S_ChangeMusic(textprompts[cutnum]->page[scenenum].musswitch, + textprompts[cutnum]->page[scenenum].musswitchflags, + textprompts[cutnum]->page[scenenum].musicloop); } } @@ -2228,6 +2233,11 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postex // on timer mode, number of tics until page advances timetonext = textprompts[cutnum]->page[scenenum].timetonext ? textprompts[cutnum]->page[scenenum].timetonext : TICRATE/10; F_PreparePageText(textprompts[cutnum]->page[scenenum].text); + + if (textprompts[cutnum]->page[scenenum].musswitch[0]) + S_ChangeMusic(textprompts[cutnum]->page[scenenum].musswitch, + textprompts[cutnum]->page[scenenum].musswitchflags, + textprompts[cutnum]->page[scenenum].musicloop); } else F_EndTextPrompt(true, false); // run the post-effects immediately From a733a29f4c5889251192184870cc451cacd9dc96 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 9 Jan 2017 22:13:26 +0000 Subject: [PATCH 491/573] Starting work on porting hw_clip.c/h code, Makefiles and CMake can compile them at least Other notes: * Renamed all new functions to have HWR_ prefix instead of gld_, for consistency * HWR_FrustrumSetup and HWR_SphereInFrustum are disabled and require HAVE_SPHEREFRUSTRUM. This is because 1) SRB2CB did not need the code, so presumably neither will we, and 2) there are some OpenGL API functions used there that due to our way of using OpenGL we don't use outside of r_opengl.c, which makes dealing with HWR_FrustrumSetup complicated in theory * The new clipping functions are not added to OpenGL's "main" rendering code itself just yet, they're just available to use now once hw_clip.h is included --- src/CMakeLists.txt | 2 + src/Makefile | 12 +- src/hardware/hw_clip.c | 465 +++++++++++++++++++++++++++++++++++++++++ src/hardware/hw_clip.h | 24 +++ 4 files changed, 497 insertions(+), 6 deletions(-) create mode 100644 src/hardware/hw_clip.c create mode 100644 src/hardware/hw_clip.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 46a42a92c..0602de9de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -350,6 +350,7 @@ if(${SRB2_CONFIG_HWRENDER}) set(SRB2_HWRENDER_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c @@ -358,6 +359,7 @@ if(${SRB2_CONFIG_HWRENDER}) ) set (SRB2_HWRENDER_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h diff --git a/src/Makefile b/src/Makefile index 7a67c3f02..b159de3b8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -269,7 +269,7 @@ ifndef DC endif OPTS+=-DHWRENDER OBJS+=$(OBJDIR)/hw_bsp.o $(OBJDIR)/hw_draw.o $(OBJDIR)/hw_light.o \ - $(OBJDIR)/hw_main.o $(OBJDIR)/hw_md2.o $(OBJDIR)/hw_cache.o $(OBJDIR)/hw_trick.o + $(OBJDIR)/hw_main.o $(OBJDIR)/hw_clip.o $(OBJDIR)/hw_md2.o $(OBJDIR)/hw_cache.o $(OBJDIR)/hw_trick.o endif ifdef NOHS @@ -719,7 +719,7 @@ ifdef MINGW $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \ doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \ command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \ - hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h am_map.h \ + hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h am_map.h \ d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \ p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ @@ -727,7 +727,7 @@ else $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \ doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \ command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \ - hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h am_map.h \ + hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h am_map.h \ d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \ p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h $(CC) $(CFLAGS) $(WFLAGS) -I/usr/X11R6/include -c $< -o $@ @@ -880,7 +880,7 @@ ifndef NOHW $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \ doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \ command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \ - hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h am_map.h \ + hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h am_map.h \ d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \ p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h $(CC) $(CFLAGS) $(WFLAGS) -D_WINDOWS -mwindows -c $< -o $@ @@ -888,7 +888,7 @@ $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h $(OBJDIR)/ogl_win.o: hardware/r_opengl/ogl_win.c hardware/r_opengl/r_opengl.h \ doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \ command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \ - hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h am_map.h \ + hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h am_map.h \ d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \ p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h $(CC) $(CFLAGS) $(WFLAGS) -D_WINDOWS -mwindows -c $< -o $@ @@ -896,7 +896,7 @@ $(OBJDIR)/ogl_win.o: hardware/r_opengl/ogl_win.c hardware/r_opengl/r_opengl.h \ $(OBJDIR)/r_minigl.o: hardware/r_minigl/r_minigl.c hardware/r_opengl/r_opengl.h \ doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \ command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \ - hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h am_map.h \ + hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h am_map.h \ d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \ p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h $(CC) $(CFLAGS) $(WFLAGS) -D_WINDOWS -mwindows -c $< -o $@ diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c new file mode 100644 index 000000000..47cbbfa2b --- /dev/null +++ b/src/hardware/hw_clip.c @@ -0,0 +1,465 @@ +/* Emacs style mode select -*- C++ -*- + *----------------------------------------------------------------------------- + * + * + * PrBoom: a Doom port merged with LxDoom and LSDLDoom + * based on BOOM, a modified and improved DOOM engine + * Copyright (C) 1999 by + * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman + * Copyright (C) 1999-2000 by + * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze + * Copyright 2005, 2006 by + * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * DESCRIPTION: + * + *--------------------------------------------------------------------- + */ + +/* + * + ** gl_clipper.cpp + ** + ** Handles visibility checks. + ** Loosely based on the JDoom clipper. + ** + **--------------------------------------------------------------------------- + ** Copyright 2003 Tim Stump + ** All rights reserved. + ** + ** Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions + ** are met: + ** + ** 1. Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** 2. Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in the + ** documentation and/or other materials provided with the distribution. + ** 3. The name of the author may not be used to endorse or promote products + ** derived from this software without specific prior written permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + **--------------------------------------------------------------------------- + ** + */ + +#include +#include "../v_video.h" +#include "hw_clip.h" +#include "hw_glob.h" +#include "../r_state.h" +#include "../tables.h" +#include "r_opengl/r_opengl.h" + +#ifdef HAVE_SPHEREFRUSTRUM +static GLdouble viewMatrix[16]; +static GLdouble projMatrix[16]; +float frustum[6][4]; +#endif + +typedef struct clipnode_s + { + struct clipnode_s *prev, *next; + angle_t start, end; + } clipnode_t; + +clipnode_t *freelist; +clipnode_t *clipnodes; +clipnode_t *cliphead; + +static clipnode_t * HWR_clipnode_GetNew(void); +static clipnode_t * HWR_clipnode_NewRange(angle_t start, angle_t end); +static boolean HWR_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle); +static void HWR_clipper_AddClipRange(angle_t start, angle_t end); +static void HWR_clipper_RemoveRange(clipnode_t * range); +static void HWR_clipnode_Free(clipnode_t *node); + +static clipnode_t * HWR_clipnode_GetNew(void) +{ + if (freelist) + { + clipnode_t * p = freelist; + freelist = p->next; + return p; + } + else + { + return (clipnode_t*)malloc(sizeof(clipnode_t)); + } +} + +static clipnode_t * HWR_clipnode_NewRange(angle_t start, angle_t end) +{ + clipnode_t * c = HWR_clipnode_GetNew(); + c->start = start; + c->end = end; + c->next = c->prev=NULL; + return c; +} + +boolean HWR_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle) +{ + if(startAngle > endAngle) + { + return (HWR_clipper_IsRangeVisible(startAngle, ANGLE_MAX) || HWR_clipper_IsRangeVisible(0, endAngle)); + } + + return HWR_clipper_IsRangeVisible(startAngle, endAngle); +} + +static boolean HWR_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle) +{ + clipnode_t *ci; + ci = cliphead; + + if (endAngle == 0 && ci && ci->start == 0) + return false; + + while (ci != NULL && ci->start < endAngle) + { + if (startAngle >= ci->start && endAngle <= ci->end) + { + return false; + } + ci = ci->next; + } + + return true; +} + +static void HWR_clipnode_Free(clipnode_t *node) +{ + node->next = freelist; + freelist = node; +} + +static void HWR_clipper_RemoveRange(clipnode_t *range) +{ + if (range == cliphead) + { + cliphead = cliphead->next; + } + else + { + if (range->prev) + { + range->prev->next = range->next; + } + if (range->next) + { + range->next->prev = range->prev; + } + } + + HWR_clipnode_Free(range); +} + +void HWR_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle) +{ + if(startangle > endangle) + { + // The range has to added in two parts. + HWR_clipper_AddClipRange(startangle, ANGLE_MAX); + HWR_clipper_AddClipRange(0, endangle); + } + else + { + // Add the range as usual. + HWR_clipper_AddClipRange(startangle, endangle); + } +} + +static void HWR_clipper_AddClipRange(angle_t start, angle_t end) +{ + clipnode_t *node, *temp, *prevNode, *node2, *delnode; + + if (cliphead) + { + //check to see if range contains any old ranges + node = cliphead; + while (node != NULL && node->start < end) + { + if (node->start >= start && node->end <= end) + { + temp = node; + node = node->next; + HWR_clipper_RemoveRange(temp); + } + else + { + if (node->start <= start && node->end >= end) + { + return; + } + else + { + node = node->next; + } + } + } + + //check to see if range overlaps a range (or possibly 2) + node = cliphead; + while (node != NULL && node->start <= end) + { + if (node->end >= start) + { + // we found the first overlapping node + if (node->start > start) + { + // the new range overlaps with this node's start point + node->start = start; + } + if (node->end < end) + { + node->end = end; + } + + node2 = node->next; + while (node2 && node2->start <= node->end) + { + if (node2->end > node->end) + { + node->end = node2->end; + } + + delnode = node2; + node2 = node2->next; + HWR_clipper_RemoveRange(delnode); + } + return; + } + node = node->next; + } + + //just add range + node = cliphead; + prevNode = NULL; + temp = HWR_clipnode_NewRange(start, end); + while (node != NULL && node->start < end) + { + prevNode = node; + node = node->next; + } + temp->next = node; + if (node == NULL) + { + temp->prev = prevNode; + if (prevNode) + { + prevNode->next = temp; + } + if (!cliphead) + { + cliphead = temp; + } + } + else + { + if (node == cliphead) + { + cliphead->prev = temp; + cliphead = temp; + } + else + { + temp->prev = prevNode; + prevNode->next = temp; + node->prev = temp; + } + } + } + else + { + temp = HWR_clipnode_NewRange(start, end); + cliphead = temp; + return; + } +} + +void HWR_clipper_Clear(void) +{ + clipnode_t *node = cliphead; + clipnode_t *temp; + + while (node != NULL) + { + temp = node; + node = node->next; + HWR_clipnode_Free(temp); + } + + cliphead = NULL; +} + +#define RMUL (1.6f/1.333333f) + +angle_t HWR_FrustumAngle(void) +{ + double floatangle; + angle_t a1; + + float tilt = (float)fabs(((double)(int)aimingangle) / ANG1); + + // NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function + + float render_fov = FIXED_TO_FLOAT(cv_grfov.value); + float render_fovratio = (float)BASEVIDWIDTH / (float)BASEVIDHEIGHT; // SRB2CBTODO: NEWCLIPTODO: Is this right? + float render_multiplier = 64.0f / render_fovratio / RMUL; + + if (tilt > 90.0f) + { + tilt = 90.0f; + } + + // If the pitch is larger than this you can look all around at a FOV of 90 + if (abs(aimingangle) > 46 * ANG1) + return 0xffffffff; + + // ok, this is a gross hack that barely works... + // but at least it doesn't overestimate too much... + floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * (float)render_fov * 48.0f / render_multiplier / 90.0f; + a1 = ANG1 * (int)floatangle; + if (a1 >= ANGLE_180) + return 0xffffffff; + return a1; +} + +// SRB2CB I don't think used any of this stuff, let's disable for now since SRB2 probably doesn't want it either +// compiler complains about (p)glGetDoublev anyway, in case anyone wants this +// only r_opengl.c can use the base gl funcs as it turns out, that's a problem for whoever wants sphere frustum checks +// btw to renable define HAVE_SPHEREFRUSTRUM in hw_clip.h +#ifdef HAVE_SPHEREFRUSTRUM +// +// HWR_FrustrumSetup +// + +#define CALCMATRIX(a, b, c, d, e, f, g, h)\ +(float)(viewMatrix[a] * projMatrix[b] + \ +viewMatrix[c] * projMatrix[d] + \ +viewMatrix[e] * projMatrix[f] + \ +viewMatrix[g] * projMatrix[h]) + +#define NORMALIZE_PLANE(i)\ +t = (float)sqrt(\ +frustum[i][0] * frustum[i][0] + \ +frustum[i][1] * frustum[i][1] + \ +frustum[i][2] * frustum[i][2]); \ +frustum[i][0] /= t; \ +frustum[i][1] /= t; \ +frustum[i][2] /= t; \ +frustum[i][3] /= t + +void HWR_FrustrumSetup(void) +{ + float t; + float clip[16]; + + pglGetDoublev(GL_PROJECTION_MATRIX, projMatrix); + pglGetDoublev(GL_MODELVIEW_MATRIX, viewMatrix); + + clip[0] = CALCMATRIX(0, 0, 1, 4, 2, 8, 3, 12); + clip[1] = CALCMATRIX(0, 1, 1, 5, 2, 9, 3, 13); + clip[2] = CALCMATRIX(0, 2, 1, 6, 2, 10, 3, 14); + clip[3] = CALCMATRIX(0, 3, 1, 7, 2, 11, 3, 15); + + clip[4] = CALCMATRIX(4, 0, 5, 4, 6, 8, 7, 12); + clip[5] = CALCMATRIX(4, 1, 5, 5, 6, 9, 7, 13); + clip[6] = CALCMATRIX(4, 2, 5, 6, 6, 10, 7, 14); + clip[7] = CALCMATRIX(4, 3, 5, 7, 6, 11, 7, 15); + + clip[8] = CALCMATRIX(8, 0, 9, 4, 10, 8, 11, 12); + clip[9] = CALCMATRIX(8, 1, 9, 5, 10, 9, 11, 13); + clip[10] = CALCMATRIX(8, 2, 9, 6, 10, 10, 11, 14); + clip[11] = CALCMATRIX(8, 3, 9, 7, 10, 11, 11, 15); + + clip[12] = CALCMATRIX(12, 0, 13, 4, 14, 8, 15, 12); + clip[13] = CALCMATRIX(12, 1, 13, 5, 14, 9, 15, 13); + clip[14] = CALCMATRIX(12, 2, 13, 6, 14, 10, 15, 14); + clip[15] = CALCMATRIX(12, 3, 13, 7, 14, 11, 15, 15); + + // Right plane + frustum[0][0] = clip[ 3] - clip[ 0]; + frustum[0][1] = clip[ 7] - clip[ 4]; + frustum[0][2] = clip[11] - clip[ 8]; + frustum[0][3] = clip[15] - clip[12]; + NORMALIZE_PLANE(0); + + // Left plane + frustum[1][0] = clip[ 3] + clip[ 0]; + frustum[1][1] = clip[ 7] + clip[ 4]; + frustum[1][2] = clip[11] + clip[ 8]; + frustum[1][3] = clip[15] + clip[12]; + NORMALIZE_PLANE(1); + + // Bottom plane + frustum[2][0] = clip[ 3] + clip[ 1]; + frustum[2][1] = clip[ 7] + clip[ 5]; + frustum[2][2] = clip[11] + clip[ 9]; + frustum[2][3] = clip[15] + clip[13]; + NORMALIZE_PLANE(2); + + // Top plane + frustum[3][0] = clip[ 3] - clip[ 1]; + frustum[3][1] = clip[ 7] - clip[ 5]; + frustum[3][2] = clip[11] - clip[ 9]; + frustum[3][3] = clip[15] - clip[13]; + NORMALIZE_PLANE(3); + + // Far plane + frustum[4][0] = clip[ 3] - clip[ 2]; + frustum[4][1] = clip[ 7] - clip[ 6]; + frustum[4][2] = clip[11] - clip[10]; + frustum[4][3] = clip[15] - clip[14]; + NORMALIZE_PLANE(4); + + // Near plane + frustum[5][0] = clip[ 3] + clip[ 2]; + frustum[5][1] = clip[ 7] + clip[ 6]; + frustum[5][2] = clip[11] + clip[10]; + frustum[5][3] = clip[15] + clip[14]; + NORMALIZE_PLANE(5); +} + +boolean HWR_SphereInFrustum(float x, float y, float z, float radius) +{ + int p; + + for (p = 0; p < 4; p++) + { + if (frustum[p][0] * x + + frustum[p][1] * y + + frustum[p][2] * z + + frustum[p][3] <= -radius) + { + return false; + } + } + return true; +} +#endif diff --git a/src/hardware/hw_clip.h b/src/hardware/hw_clip.h new file mode 100644 index 000000000..c55041b7e --- /dev/null +++ b/src/hardware/hw_clip.h @@ -0,0 +1,24 @@ +/* + * hw_clip.h + * SRB2CB + * + * PrBoom's OpenGL clipping + * + * + */ + +// OpenGL BSP clipping +#include "../doomdef.h" +#include "../tables.h" +#include "../doomtype.h" + +//#define HAVE_SPHEREFRUSTRUM // enable if you want HWR_SphereInFrustum and related code + +boolean HWR_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle); +void HWR_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle); +void HWR_clipper_Clear(void); +angle_t HWR_FrustumAngle(void); +#ifdef HAVE_SPHEREFRUSTRUM +void HWR_FrustrumSetup(void); +boolean HWR_SphereInFrustum(float x, float y, float z, float radius); +#endif From 1e98e3b4f20ae9517a66e79f2a464cbcda9e28b7 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 10 Jan 2017 18:01:03 +0000 Subject: [PATCH 492/573] More progress, NEWCLIP added to doomdef.h, sadly it actually all lags the game so I've disabled it for now Other notes: * on second thought I'll keep the hw_clip functions' gld prefixes rather than HWR, not like it matters either way * despite the extra lag it does fix the issues with translucent walls and such when displayed at different vertical angles, such as with the GFZ1 waterfall --- src/doomdef.h | 7 ++ src/hardware/hw_clip.c | 62 +++++------ src/hardware/hw_clip.h | 14 +-- src/hardware/hw_main.c | 240 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 280 insertions(+), 43 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 7f641558f..e5fa3a482 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -502,4 +502,11 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// \note Required for proper collision with moving sloped surfaces that have sector specials on them. //#define SECTORSPECIALSAFTERTHINK +/// FINALLY some real clipping that doesn't make walls dissappear AND speeds the game up +/// (that was the original comment from SRB2CB, sadly it is a lie and actually slows game down) +/// on the bright side it fixes some weird issues with translucent walls +/// \note SRB2CB port. +/// SRB2CB itself ported this from PrBoom+ +//#define NEWCLIP + #endif // __DOOMDEF__ diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 47cbbfa2b..8b01cabd5 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -92,14 +92,14 @@ clipnode_t *freelist; clipnode_t *clipnodes; clipnode_t *cliphead; -static clipnode_t * HWR_clipnode_GetNew(void); -static clipnode_t * HWR_clipnode_NewRange(angle_t start, angle_t end); -static boolean HWR_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle); -static void HWR_clipper_AddClipRange(angle_t start, angle_t end); -static void HWR_clipper_RemoveRange(clipnode_t * range); -static void HWR_clipnode_Free(clipnode_t *node); +static clipnode_t * gld_clipnode_GetNew(void); +static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end); +static boolean gld_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle); +static void gld_clipper_AddClipRange(angle_t start, angle_t end); +static void gld_clipper_RemoveRange(clipnode_t * range); +static void gld_clipnode_Free(clipnode_t *node); -static clipnode_t * HWR_clipnode_GetNew(void) +static clipnode_t * gld_clipnode_GetNew(void) { if (freelist) { @@ -113,26 +113,26 @@ static clipnode_t * HWR_clipnode_GetNew(void) } } -static clipnode_t * HWR_clipnode_NewRange(angle_t start, angle_t end) +static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end) { - clipnode_t * c = HWR_clipnode_GetNew(); + clipnode_t * c = gld_clipnode_GetNew(); c->start = start; c->end = end; c->next = c->prev=NULL; return c; } -boolean HWR_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle) +boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle) { if(startAngle > endAngle) { - return (HWR_clipper_IsRangeVisible(startAngle, ANGLE_MAX) || HWR_clipper_IsRangeVisible(0, endAngle)); + return (gld_clipper_IsRangeVisible(startAngle, ANGLE_MAX) || gld_clipper_IsRangeVisible(0, endAngle)); } - return HWR_clipper_IsRangeVisible(startAngle, endAngle); + return gld_clipper_IsRangeVisible(startAngle, endAngle); } -static boolean HWR_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle) +static boolean gld_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle) { clipnode_t *ci; ci = cliphead; @@ -152,13 +152,13 @@ static boolean HWR_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle) return true; } -static void HWR_clipnode_Free(clipnode_t *node) +static void gld_clipnode_Free(clipnode_t *node) { node->next = freelist; freelist = node; } -static void HWR_clipper_RemoveRange(clipnode_t *range) +static void gld_clipper_RemoveRange(clipnode_t *range) { if (range == cliphead) { @@ -176,25 +176,25 @@ static void HWR_clipper_RemoveRange(clipnode_t *range) } } - HWR_clipnode_Free(range); + gld_clipnode_Free(range); } -void HWR_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle) +void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle) { if(startangle > endangle) { // The range has to added in two parts. - HWR_clipper_AddClipRange(startangle, ANGLE_MAX); - HWR_clipper_AddClipRange(0, endangle); + gld_clipper_AddClipRange(startangle, ANGLE_MAX); + gld_clipper_AddClipRange(0, endangle); } else { // Add the range as usual. - HWR_clipper_AddClipRange(startangle, endangle); + gld_clipper_AddClipRange(startangle, endangle); } } -static void HWR_clipper_AddClipRange(angle_t start, angle_t end) +static void gld_clipper_AddClipRange(angle_t start, angle_t end) { clipnode_t *node, *temp, *prevNode, *node2, *delnode; @@ -208,7 +208,7 @@ static void HWR_clipper_AddClipRange(angle_t start, angle_t end) { temp = node; node = node->next; - HWR_clipper_RemoveRange(temp); + gld_clipper_RemoveRange(temp); } else { @@ -250,7 +250,7 @@ static void HWR_clipper_AddClipRange(angle_t start, angle_t end) delnode = node2; node2 = node2->next; - HWR_clipper_RemoveRange(delnode); + gld_clipper_RemoveRange(delnode); } return; } @@ -260,7 +260,7 @@ static void HWR_clipper_AddClipRange(angle_t start, angle_t end) //just add range node = cliphead; prevNode = NULL; - temp = HWR_clipnode_NewRange(start, end); + temp = gld_clipnode_NewRange(start, end); while (node != NULL && node->start < end) { prevNode = node; @@ -296,13 +296,13 @@ static void HWR_clipper_AddClipRange(angle_t start, angle_t end) } else { - temp = HWR_clipnode_NewRange(start, end); + temp = gld_clipnode_NewRange(start, end); cliphead = temp; return; } } -void HWR_clipper_Clear(void) +void gld_clipper_Clear(void) { clipnode_t *node = cliphead; clipnode_t *temp; @@ -311,7 +311,7 @@ void HWR_clipper_Clear(void) { temp = node; node = node->next; - HWR_clipnode_Free(temp); + gld_clipnode_Free(temp); } cliphead = NULL; @@ -319,7 +319,7 @@ void HWR_clipper_Clear(void) #define RMUL (1.6f/1.333333f) -angle_t HWR_FrustumAngle(void) +angle_t gld_FrustumAngle(void) { double floatangle; angle_t a1; @@ -356,7 +356,7 @@ angle_t HWR_FrustumAngle(void) // btw to renable define HAVE_SPHEREFRUSTRUM in hw_clip.h #ifdef HAVE_SPHEREFRUSTRUM // -// HWR_FrustrumSetup +// gld_FrustrumSetup // #define CALCMATRIX(a, b, c, d, e, f, g, h)\ @@ -375,7 +375,7 @@ frustum[i][1] /= t; \ frustum[i][2] /= t; \ frustum[i][3] /= t -void HWR_FrustrumSetup(void) +void gld_FrustrumSetup(void) { float t; float clip[16]; @@ -446,7 +446,7 @@ void HWR_FrustrumSetup(void) NORMALIZE_PLANE(5); } -boolean HWR_SphereInFrustum(float x, float y, float z, float radius) +boolean gld_SphereInFrustum(float x, float y, float z, float radius) { int p; diff --git a/src/hardware/hw_clip.h b/src/hardware/hw_clip.h index c55041b7e..3ba26e5e5 100644 --- a/src/hardware/hw_clip.h +++ b/src/hardware/hw_clip.h @@ -12,13 +12,13 @@ #include "../tables.h" #include "../doomtype.h" -//#define HAVE_SPHEREFRUSTRUM // enable if you want HWR_SphereInFrustum and related code +//#define HAVE_SPHEREFRUSTRUM // enable if you want gld_SphereInFrustum and related code -boolean HWR_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle); -void HWR_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle); -void HWR_clipper_Clear(void); -angle_t HWR_FrustumAngle(void); +boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle); +void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle); +void gld_clipper_Clear(void); +angle_t gld_FrustumAngle(void); #ifdef HAVE_SPHEREFRUSTRUM -void HWR_FrustrumSetup(void); -boolean HWR_SphereInFrustum(float x, float y, float z, float radius); +void gld_FrustrumSetup(void); +boolean gld_SphereInFrustum(float x, float y, float z, float radius); #endif diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 7e8152583..c10f4bf12 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -44,6 +44,10 @@ #endif #include "hw_md2.h" +#ifdef NEWCLIP +#include "hw_clip.h" +#endif + #define R_FAKEFLOORS #define HWPRECIP #define SORTING @@ -99,8 +103,9 @@ CV_PossibleValue_t granisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NU boolean drawsky = true; // needs fix: walls are incorrectly clipped one column less +#ifndef NEWCLIP static consvar_t cv_grclipwalls = {"gr_clipwalls", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - +#endif //development variables for diverse uses static consvar_t cv_gralpha = {"gr_alpha", "160", 0, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; static consvar_t cv_grbeta = {"gr_beta", "0", 0, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1030,6 +1035,7 @@ static void HWR_ProjectWall(wallVert3D * wallVerts, // (in fact a clipping plane that has a constant, so can clip with simple 2d) // with the wall segment // +#ifndef NEWCLIP static float HWR_ClipViewSegment(INT32 x, polyvertex_t *v1, polyvertex_t *v2) { float num, den; @@ -1058,6 +1064,7 @@ static float HWR_ClipViewSegment(INT32 x, polyvertex_t *v1, polyvertex_t *v2) return num / den; } +#endif // // HWR_SplitWall @@ -1333,7 +1340,11 @@ static void HWR_DrawSkyWall(wallVert3D *wallVerts, FSurfaceInfo *Surf, fixed_t b // Anything between means the wall segment has been clipped with solidsegs, // reducing wall overdraw to a minimum // +#ifdef NEWCLIP +static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom +#else static void HWR_StoreWallRange(double startfrac, double endfrac) +#endif { wallVert3D wallVerts[4]; v2d_t vs, ve; // start, end vertices of 2d line (view from above) @@ -1358,8 +1369,10 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) extracolormap_t *colormap; FSurfaceInfo Surf; +#ifndef NEWCLIP if (startfrac > endfrac) return; +#endif gr_sidedef = gr_curline->sidedef; gr_linedef = gr_curline->linedef; @@ -1408,15 +1421,19 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) // x offset the texture fixed_t texturehpeg = gr_sidedef->textureoffset + gr_curline->offset; +#ifndef NEWCLIP // clip texture s start/end coords with solidsegs if (startfrac > 0.0f && startfrac < 1.0f) cliplow = (float)(texturehpeg + (gr_curline->flength*FRACUNIT) * startfrac); else +#endif cliplow = (float)texturehpeg; +#ifndef NEWCLIP if (endfrac > 0.0f && endfrac < 1.0f) cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT) * endfrac); else +#endif cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT)); } @@ -2325,6 +2342,135 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) //Hurdler: end of 3d-floors test } +// From PrBoom: +// +// e6y: Check whether the player can look beyond this line +// +#ifdef NEWCLIP +// Don't modify anything here, just check +// Kalaron: Modified for sloped linedefs +static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacksector) +{ + fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends + fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends + + // GZDoom method of sloped line clipping + +#ifdef ESLOPE + if (afrontsector->f_slope || afrontsector->c_slope || abacksector->f_slope || abacksector->c_slope) + { + fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t + 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); \ + end2 = P_GetZAt(slope, v2x, v2y); \ + } else \ + end1 = end2 = normalheight; + + SLOPEPARAMS(afrontsector->f_slope, frontf1, frontf2, afrontsector->floorheight) + SLOPEPARAMS(afrontsector->c_slope, frontc1, frontc2, afrontsector->ceilingheight) + SLOPEPARAMS( abacksector->f_slope, backf1, backf2, abacksector->floorheight) + SLOPEPARAMS( abacksector->c_slope, backc1, backc2, abacksector->ceilingheight) +#undef SLOPEPARAMS + } + else +#endif + { + frontf1 = frontf2 = afrontsector->floorheight; + frontc1 = frontc2 = afrontsector->ceilingheight; + backf1 = backf2 = abacksector->floorheight; + backc1 = backc2 = abacksector->ceilingheight; + } + + // now check for closed sectors! + if (backc1 <= frontf1 && backc2 <= frontf2) + { + if (!seg->sidedef->toptexture) + return false; + + if (abacksector->ceilingpic == skyflatnum && afrontsector->ceilingpic == skyflatnum) + return false; + + return true; + } + + if (backf1 >= frontc1 && backf2 >= frontc2) + { + if (!seg->sidedef->bottomtexture) + return false; + + // properly render skies (consider door "open" if both floors are sky): + if (abacksector->ceilingpic == skyflatnum && afrontsector->ceilingpic == skyflatnum) + return false; + + return true; + } + + if (backc1 <= backf1 && backc2 <= backf2) + { + // preserve a kind of transparent door/lift special effect: + if (backc1 < frontc1 || backc2 < frontc2) + { + if (!seg->sidedef->toptexture) + return false; + } + if (backf1 > frontf1 || backf2 > frontf2) + { + if (!seg->sidedef->bottomtexture) + return false; + } + if (abacksector->ceilingpic == skyflatnum && afrontsector->ceilingpic == skyflatnum) + return false; + + if (abacksector->floorpic == skyflatnum && afrontsector->floorpic == skyflatnum) + return false; + + return true; + } + + + // Reject empty lines used for triggers and special events. + // Identical floor and ceiling on both sides, + // identical light levels on both sides, + // and no middle texture. + if ( +#ifdef POLYOBJECTS + !seg->polyseg && +#endif + gr_backsector->ceilingpic == gr_frontsector->ceilingpic + && gr_backsector->floorpic == gr_frontsector->floorpic +#ifdef ESLOPE + && gr_backsector->f_slope == gr_frontsector->f_slope + && gr_backsector->c_slope == gr_frontsector->c_slope +#endif + && gr_backsector->lightlevel == gr_frontsector->lightlevel + && !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)) + { + return false; + } + + + return false; +} +#else //Hurdler: just like in r_bsp.c #if 1 #define MAXSEGS MAXVIDWIDTH/2+1 @@ -2610,6 +2756,7 @@ static void HWR_ClearClipSegs(void) gr_solidsegs[1].last = 0x7fffffff; hw_newend = gr_solidsegs+2; } +#endif // NEWCLIP // -----------------+ // HWR_AddLine : Clips the given segment and adds any visible pieces to the line list. @@ -2618,17 +2765,20 @@ static void HWR_ClearClipSegs(void) // -----------------+ static void HWR_AddLine(seg_t * line) { - INT32 x1, x2; angle_t angle1, angle2; +#ifndef NEWCLIP + INT32 x1, x2; angle_t span, tspan; +#endif // 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 - +#ifdef POLYOBJECTS if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES)) return; +#endif gr_curline = line; @@ -2641,6 +2791,18 @@ static void HWR_AddLine(seg_t * line) angle1 = R_PointToAngle(v1x, v1y); angle2 = R_PointToAngle(v2x, v2y); +#ifdef NEWCLIP + // PrBoom: Back side, i.e. backface culling - read: endAngle >= startAngle! + if (angle2 - angle1 < ANGLE_180) + return; + + // PrBoom: use REAL clipping math YAYYYYYYY!!! + + if (!gld_clipper_SafeCheckRange(angle2, angle1)) + { + return; + } +#else // Clip to view edges. span = angle1 - angle2; @@ -2719,8 +2881,35 @@ static void HWR_AddLine(seg_t * line) return; } */ +#endif + gr_backsector = line->backsector; +#ifdef NEWCLIP + if (!line->backsector) + { + gld_clipper_SafeAddClipRange(angle2, angle1); + } + else + { + gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); + if (line->frontsector == line->backsector) + { + if (!line->sidedef->midtexture) + { + //e6y: nothing to do here! + //return; + } + } + if (CheckClip(line, gr_frontsector, gr_backsector)) + { + gld_clipper_SafeAddClipRange(angle2, angle1); + } + } + + HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D + return; +#else // Single sided line? if (!gr_backsector) goto clipsolid; @@ -2835,6 +3024,7 @@ clipsolid: if (x1 == x2) goto clippass; HWR_ClipSolidWallSegment(x1, x2-1); +#endif } // HWR_CheckBBox @@ -2846,9 +3036,13 @@ clipsolid: static boolean HWR_CheckBBox(fixed_t *bspcoord) { - INT32 boxpos, sx1, sx2; + INT32 boxpos; fixed_t px1, py1, px2, py2; - angle_t angle1, angle2, span, tspan; + angle_t angle1, angle2; +#ifndef NEWCLIP + INT32 sx1, sx2; + angle_t span, tspan; +#endif // Find the corners of the box // that define the edges from current viewpoint. @@ -2874,6 +3068,11 @@ static boolean HWR_CheckBBox(fixed_t *bspcoord) px2 = bspcoord[checkcoord[boxpos][2]]; py2 = bspcoord[checkcoord[boxpos][3]]; +#ifdef NEWCLIP + angle1 = R_PointToAngle(px1, py1); + angle2 = R_PointToAngle(px2, py2); + return gld_clipper_SafeCheckRange(angle2, angle1); +#else // check clip list for an open space angle1 = R_PointToAngle2(dup_viewx>>1, dup_viewy>>1, px1>>1, py1>>1) - dup_viewangle; angle2 = R_PointToAngle2(dup_viewx>>1, dup_viewy>>1, px2>>1, py2>>1) - dup_viewangle; @@ -2921,6 +3120,7 @@ static boolean HWR_CheckBBox(fixed_t *bspcoord) return false; return HWR_ClipToSolidSegs(sx1, sx2 - 1); +#endif } #ifdef POLYOBJECTS @@ -5694,7 +5894,19 @@ if (0) #ifdef SORTING drawcount = 0; #endif +#ifdef NEWCLIP + if (rendermode == render_opengl) + { + angle_t a1 = gld_FrustumAngle(); + gld_clipper_Clear(); + gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1); +#ifdef HAVE_SPHEREFRUSTRUM + gld_FrustrumSetup(); +#endif + } +#else HWR_ClearClipSegs(); +#endif //04/01/2000: Hurdler: added for T&L // Actually it only works on Walls and Planes @@ -5704,6 +5916,7 @@ if (0) HWR_RenderBSPNode((INT32)numnodes-1); +#ifndef NEWCLIP // Make a viewangle int so we can render things based on mouselook if (player == &players[consoleplayer]) viewangle = localaiming; @@ -5730,6 +5943,7 @@ if (0) dup_viewangle += ANGLE_90; } +#endif // Check for new console commands. NetUpdate(); @@ -5901,7 +6115,19 @@ if (0) #ifdef SORTING drawcount = 0; #endif +#ifdef NEWCLIP + if (rendermode == render_opengl) + { + angle_t a1 = gld_FrustumAngle(); + gld_clipper_Clear(); + gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1); +#ifdef HAVE_SPHEREFRUSTRUM + gld_FrustrumSetup(); +#endif + } +#else HWR_ClearClipSegs(); +#endif //04/01/2000: Hurdler: added for T&L // Actually it only works on Walls and Planes @@ -5911,6 +6137,7 @@ if (0) HWR_RenderBSPNode((INT32)numnodes-1); +#ifndef NEWCLIP // Make a viewangle int so we can render things based on mouselook if (player == &players[consoleplayer]) viewangle = localaiming; @@ -5937,6 +6164,7 @@ if (0) dup_viewangle += ANGLE_90; } +#endif // Check for new console commands. NetUpdate(); @@ -6079,7 +6307,9 @@ static inline void HWR_AddEngineCommands(void) { // engine state variables //CV_RegisterVar(&cv_grzbuffer); +#ifndef NEWCLIP CV_RegisterVar(&cv_grclipwalls); +#endif // engine development mode variables // - usage may vary from version to version.. From c4569e61a8feab59eb5635daf536e9605048a176 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 10 Jan 2017 20:07:02 +0000 Subject: [PATCH 493/573] Made some efforts to improve efficiency of new code, hard to tell if I've made it better or worse though honestly R_IsEmptyLine is now a thing too btw --- src/hardware/hw_main.c | 94 +++++++++--------------------------------- src/r_bsp.c | 60 ++++++++++++++------------- src/r_bsp.h | 1 + 3 files changed, 52 insertions(+), 103 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c10f4bf12..c148e7c41 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2347,6 +2347,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) // e6y: Check whether the player can look beyond this line // #ifdef NEWCLIP +boolean checkforemptylines = true; // Don't modify anything here, just check // Kalaron: Modified for sloped linedefs static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacksector) @@ -2389,6 +2390,7 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks // now check for closed sectors! if (backc1 <= frontf1 && backc2 <= frontf2) { + checkforemptylines = false; if (!seg->sidedef->toptexture) return false; @@ -2400,6 +2402,7 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks if (backf1 >= frontc1 && backf2 >= frontc2) { + checkforemptylines = false; if (!seg->sidedef->bottomtexture) return false; @@ -2412,6 +2415,7 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks if (backc1 <= backf1 && backc2 <= backf2) { + checkforemptylines = false; // preserve a kind of transparent door/lift special effect: if (backc1 < frontc1 || backc2 < frontc2) { @@ -2432,41 +2436,12 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks return true; } - - // Reject empty lines used for triggers and special events. - // Identical floor and ceiling on both sides, - // identical light levels on both sides, - // and no middle texture. - if ( -#ifdef POLYOBJECTS - !seg->polyseg && -#endif - gr_backsector->ceilingpic == gr_frontsector->ceilingpic - && gr_backsector->floorpic == gr_frontsector->floorpic -#ifdef ESLOPE - && gr_backsector->f_slope == gr_frontsector->f_slope - && gr_backsector->c_slope == gr_frontsector->c_slope -#endif - && gr_backsector->lightlevel == gr_frontsector->lightlevel - && !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)) - { - return false; - } - + if (backc1 != frontc1 || backc2 != frontc2 + || backf1 != frontf1 || backf2 != frontf2) + { + checkforemptylines = false; + return false; + } return false; } @@ -2802,6 +2777,8 @@ static void HWR_AddLine(seg_t * line) { return; } + + checkforemptylines = true; #else // Clip to view edges. span = angle1 - angle2; @@ -2893,18 +2870,17 @@ static void HWR_AddLine(seg_t * line) else { gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); - if (line->frontsector == line->backsector) - { - if (!line->sidedef->midtexture) - { - //e6y: nothing to do here! - //return; - } - } if (CheckClip(line, gr_frontsector, gr_backsector)) { gld_clipper_SafeAddClipRange(angle2, angle1); + checkforemptylines = false; } + // Reject empty lines used for triggers and special events. + // Identical floor and ceiling on both sides, + // identical light levels on both sides, + // and no middle texture. + if (checkforemptylines && R_IsEmptyLine(line, gr_frontsector, gr_backsector)) + return; } HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D @@ -2981,38 +2957,8 @@ static void HWR_AddLine(seg_t * line) // Identical floor and ceiling on both sides, // identical light levels on both sides, // and no middle texture. - if ( -#ifdef POLYOBJECTS - !line->polyseg && -#endif - gr_backsector->ceilingpic == gr_frontsector->ceilingpic - && gr_backsector->floorpic == gr_frontsector->floorpic -#ifdef ESLOPE - && gr_backsector->f_slope == gr_frontsector->f_slope - && gr_backsector->c_slope == gr_frontsector->c_slope -#endif - && gr_backsector->lightlevel == gr_frontsector->lightlevel - && !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... - { + if (R_IsEmptyLine(curline, frontsector, backsector)) return; - } clippass: if (x1 == x2) diff --git a/src/r_bsp.c b/src/r_bsp.c index abb11204a..4ce89f009 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -365,6 +365,36 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, return sec; } +boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back) +{ + return ( +#ifdef POLYOBJECTS + !line->polyseg && +#endif + back->ceilingpic == front->ceilingpic + && back->floorpic == front->floorpic +#ifdef ESLOPE + && back->f_slope == front->f_slope + && back->c_slope == front->c_slope +#endif + && back->lightlevel == front->lightlevel + && !line->sidedef->midtexture + // Check offsets too! + && back->floor_xoffs == front->floor_xoffs + && back->floor_yoffs == front->floor_yoffs + && back->floorpic_angle == front->floorpic_angle + && back->ceiling_xoffs == front->ceiling_xoffs + && back->ceiling_yoffs == front->ceiling_yoffs + && back->ceilingpic_angle == front->ceilingpic_angle + // Consider altered lighting. + && back->floorlightsec == front->floorlightsec + && back->ceilinglightsec == front->ceilinglightsec + // Consider colormaps + && back->extra_colormap == front->extra_colormap + && ((!front->ffloors && !back->ffloors) + || front->tag == back->tag)); +} + // // R_AddLine // Clips the given segment and adds any visible pieces to the line list. @@ -526,36 +556,8 @@ static void R_AddLine(seg_t *line) // Identical floor and ceiling on both sides, identical light levels on both sides, // and no middle texture. - if ( -#ifdef POLYOBJECTS - !line->polyseg && -#endif - backsector->ceilingpic == frontsector->ceilingpic - && backsector->floorpic == frontsector->floorpic -#ifdef ESLOPE - && backsector->f_slope == frontsector->f_slope - && backsector->c_slope == frontsector->c_slope -#endif - && backsector->lightlevel == frontsector->lightlevel - && !curline->sidedef->midtexture - // Check offsets too! - && backsector->floor_xoffs == frontsector->floor_xoffs - && backsector->floor_yoffs == frontsector->floor_yoffs - && backsector->floorpic_angle == frontsector->floorpic_angle - && backsector->ceiling_xoffs == frontsector->ceiling_xoffs - && backsector->ceiling_yoffs == frontsector->ceiling_yoffs - && backsector->ceilingpic_angle == frontsector->ceilingpic_angle - // Consider altered lighting. - && backsector->floorlightsec == frontsector->floorlightsec - && backsector->ceilinglightsec == frontsector->ceilinglightsec - // Consider colormaps - && backsector->extra_colormap == frontsector->extra_colormap - && ((!frontsector->ffloors && !backsector->ffloors) - || frontsector->tag == backsector->tag)) - { + if (R_IsEmptyLine(line, frontsector, backsector)) return; - } - clippass: R_ClipPassWallSegment(x1, x2 - 1); diff --git a/src/r_bsp.h b/src/r_bsp.h index e871b5dde..80824831b 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -50,6 +50,7 @@ extern polyobj_t **po_ptrs; // temp ptr array to sort polyobject pointers sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, INT32 *ceilinglightlevel, boolean back); +boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back); INT32 R_GetPlaneLight(sector_t *sector, fixed_t planeheight, boolean underside); void R_Prep3DFloors(sector_t *sector); From 8ba0f2a177086a26313aac58eb8ff4b2ecc95c09 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 12 Jan 2017 21:44:27 +0000 Subject: [PATCH 494/573] clipping code didn't seem so bad this time (at least compared to without), let's enable it now? --- src/doomdef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doomdef.h b/src/doomdef.h index e5fa3a482..ff09144ed 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -507,6 +507,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// on the bright side it fixes some weird issues with translucent walls /// \note SRB2CB port. /// SRB2CB itself ported this from PrBoom+ -//#define NEWCLIP +#define NEWCLIP #endif // __DOOMDEF__ From 3608f73d39a60fe79c368691f8171a20691ea4ce Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 16 Jan 2017 15:48:07 +0000 Subject: [PATCH 495/573] Updated SRB2.cbp for hw_clip.c/h --- SRB2.cbp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/SRB2.cbp b/SRB2.cbp index 74ec96c6e..5aa623fa8 100644 --- a/SRB2.cbp +++ b/SRB2.cbp @@ -1174,6 +1174,39 @@ HW3SOUND for 3D hardware sound support