From 285f7acbed9346444cc496b32dd52c0b28506670 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Tue, 25 Jul 2023 14:18:36 -0500 Subject: [PATCH 01/13] Enable Pandora and Level Select with Devmode / Always allow Level Select if unlocked --- src/d_netcmd.c | 7 ++++--- src/m_cond.c | 3 ++- src/m_menu.c | 21 ++++++++++++++++----- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 72d020c22..f81a6abde 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1905,7 +1905,7 @@ static void Command_Map_f(void) return; } - option_force = COM_CheckPartialParm("-f"); + option_force = COM_CheckPartialParm("-f") || (cv_debug || devparm); option_gametype = COM_CheckPartialParm("-g"); newresetplayers = ! COM_CheckParm("-noresetplayers"); @@ -1913,7 +1913,8 @@ static void Command_Map_f(void) !( netgame || multiplayer ) && !( usedCheats ); - if (wouldSetCheats && !option_force) + if (wouldSetCheats && !option_force + && !M_SecretUnlocked(SECRET_LEVELSELECT, serverGamedata)) { /* May want to be more descriptive? */ CONS_Printf(M_GetText("Sorry, level change disabled in single player.\n")); @@ -1967,7 +1968,7 @@ static void Command_Map_f(void) return; } - if (wouldSetCheats && option_force) + if (wouldSetCheats) { G_SetUsedCheats(false); } diff --git a/src/m_cond.c b/src/m_cond.c index b21778c69..86bae4933 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -467,7 +467,8 @@ UINT8 M_SecretUnlocked(INT32 type, gamedata_t *data) UINT8 M_MapLocked(INT32 mapnum, gamedata_t *data) { - if (!mapheaderinfo[mapnum-1] || mapheaderinfo[mapnum-1]->unlockrequired < 0) + if (!mapheaderinfo[mapnum-1] || mapheaderinfo[mapnum-1]->unlockrequired < 0 + || cv_debug || devparm) { return false; } diff --git a/src/m_menu.c b/src/m_menu.c index 12003f945..7618a2c4a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3673,9 +3673,12 @@ void M_StartControlPanel(void) } else if (!(netgame || multiplayer)) // Single Player { + // Devmode unlocks Pandora's Box in the pause menu + boolean pandora = ((M_SecretUnlocked(SECRET_PANDORA, serverGamedata) || cv_debug || devparm) && !marathonmode); + if (gamestate != GS_LEVEL || ultimatemode) // intermission, so gray out stuff. { - SPauseMenu[spause_pandora].status = (M_SecretUnlocked(SECRET_PANDORA, serverGamedata)) ? (IT_GRAYEDOUT) : (IT_DISABLED); + SPauseMenu[spause_pandora].status = (pandora) ? (IT_GRAYEDOUT) : (IT_DISABLED); SPauseMenu[spause_retry].status = IT_GRAYEDOUT; } else @@ -3684,7 +3687,7 @@ void M_StartControlPanel(void) if (players[consoleplayer].playerstate != PST_LIVE) ++numlives; - SPauseMenu[spause_pandora].status = (M_SecretUnlocked(SECRET_PANDORA, serverGamedata) && !marathonmode) ? (IT_STRING | IT_CALL) : (IT_DISABLED); + SPauseMenu[spause_pandora].status = (pandora) ? (IT_STRING | IT_CALL) : (IT_DISABLED); // The list of things that can disable retrying is (was?) a little too complex // for me to want to use the short if statement syntax @@ -3695,7 +3698,11 @@ void M_StartControlPanel(void) } // We can always use level select though. :33 - SPauseMenu[spause_levelselect].status = (maplistoption != 0) ? (IT_STRING | IT_CALL) : (IT_DISABLED); + // Guarantee it if we have either it unlocked or devmode is enabled + if ((maplistoption != 0 || M_SecretUnlocked(SECRET_LEVELSELECT, serverGamedata) || cv_debug || devparm) && !marathonmode) + SPauseMenu[spause_levelselect].status = (IT_STRING | IT_CALL); + else + SPauseMenu[spause_levelselect].status = (IT_DISABLED); // And emblem hints. SPauseMenu[spause_hints].status = (M_SecretUnlocked(SECRET_EMBLEMHINTS, clientGamedata) && !marathonmode) ? (IT_STRING | IT_CALL) : (IT_DISABLED); @@ -5091,7 +5098,8 @@ static boolean M_CanShowLevelOnPlatter(INT32 mapnum, INT32 gt) return false; case LLM_LEVELSELECT: - if (!(mapheaderinfo[mapnum]->levelselect & maplistoption)) + if (!(mapheaderinfo[mapnum]->levelselect & maplistoption) + && !(cv_debug || devparm)) //Allow ALL levels in devmode! return false; return true; @@ -7655,9 +7663,12 @@ static void M_PauseLevelSelect(INT32 choice) SP_PauseLevelSelectDef.prevMenu = currentMenu; levellistmode = LLM_LEVELSELECT; - // maplistoption is NOT specified, so that this + // maplistoption is only specified if not set already + // and we have the level select unlocked so that it // transfers the level select list from the menu // used to enter the game to the pause menu. + if (maplistoption == 0 && M_SecretUnlocked(SECRET_LEVELSELECT, serverGamedata)) + maplistoption = 1; if (!M_PrepareLevelPlatter(-1, true)) { From 126fba4ddbe0e8c724dec690cb43315b276da90b Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Fri, 4 Aug 2023 15:10:25 -0300 Subject: [PATCH 02/13] Lua colorlib: color library --- src/lua_colorlib.c | 390 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 375 insertions(+), 15 deletions(-) diff --git a/src/lua_colorlib.c b/src/lua_colorlib.c index 1e6e82333..210d833df 100644 --- a/src/lua_colorlib.c +++ b/src/lua_colorlib.c @@ -13,10 +13,33 @@ #include "doomdef.h" #include "fastcmp.h" #include "r_data.h" +#include "v_video.h" #include "lua_script.h" #include "lua_libs.h" +#define COLORLIB_USE_LOOKUP + +#ifdef COLORLIB_USE_LOOKUP + static colorlookup_t colormix_lut; + #define GetNearestColor(r, g, b) GetColorLUT(&colormix_lut, r, g, b) +#else + #define GetNearestColor(r, g, b) NearestPaletteColor(r, g, b, pMasterPalette) +#endif + +//////////////// +// Color library +//////////////// + +static int lib_colorPaletteToRgb(lua_State *L) +{ + RGBA_t color = V_GetMasterColor((UINT8)luaL_checkinteger(L, 1)); + lua_pushinteger(L, color.s.red); + lua_pushinteger(L, color.s.green); + lua_pushinteger(L, color.s.blue); + return 3; +} + #define IS_HEX_CHAR(x) ((x >= '0' && x <= '9') || (x >= 'a' && x <= 'f') || (x >= 'A' && x <= 'F')) #define ARE_HEX_CHARS(str, i) IS_HEX_CHAR(str[i]) && IS_HEX_CHAR(str[i + 1]) @@ -32,6 +55,13 @@ static UINT32 hex2int(char x) return 0; } +static UINT8 GetHTMLColorLength(const char *str) +{ + if (str[0] == '#') + str++; + return strlen(str) >= 8 ? 4 : 3; +} + static UINT8 ParseHTMLColor(const char *str, UINT8 *rgba, size_t numc) { const char *hex = str; @@ -77,6 +107,348 @@ static UINT8 ParseHTMLColor(const char *str, UINT8 *rgba, size_t numc) return 0; } +static UINT8 GetPackedRGBA(UINT32 colors, UINT8 *rgba) +{ + if (colors > 0xFFFFFF) + { + rgba[0] = (colors >> 24) & 0xFF; + rgba[1] = (colors >> 16) & 0xFF; + rgba[2] = (colors >> 8) & 0xFF; + rgba[3] = colors & 0xFF; + return 4; + } + else + { + rgba[0] = (colors >> 16) & 0xFF; + rgba[1] = (colors >> 8) & 0xFF; + rgba[2] = colors & 0xFF; + rgba[3] = 0xFF; + return 3; + } +} + +static UINT8 GetArgsRGBA(lua_State *L, UINT8 index, INT32 *r, INT32 *g, INT32 *b, INT32 *a) +{ + UINT8 rgba[4] = { 0, 0, 0, 255 }; + UINT8 num = 0; + + if (lua_gettop(L) == 1 && lua_type(L, index) == LUA_TNUMBER) + { + num = GetPackedRGBA(luaL_checkinteger(L, 1), rgba); + + *r = rgba[0]; + *g = rgba[1]; + *b = rgba[2]; + if (a) + *a = rgba[3]; + } + else if (lua_type(L, index) == LUA_TSTRING) + { + const char *str = lua_tostring(L, index); + UINT8 parsed = ParseHTMLColor(str, rgba, GetHTMLColorLength(str)); + if (!parsed) + luaL_error(L, "Malformed HTML color '%s'", str); + + num = parsed == 8 ? 4 : 3; + + *r = rgba[0]; + *g = rgba[1]; + *b = rgba[2]; + if (a) + *a = rgba[3]; + } + else + { + INT32 temp; + +#define CHECKINT(i) luaL_checkinteger(L, i) +#define GETCOLOR(c, i, desc) { \ + temp = CHECKINT(i); \ + if (temp < 0 || temp > 255) \ + luaL_error(L, desc " channel %d out of range (0 - 255)", temp); \ + c = temp; \ + num++; \ + } + + GETCOLOR(*r, index + 0, "red color"); + GETCOLOR(*g, index + 1, "green color"); + GETCOLOR(*b, index + 2, "blue color"); +#undef CHECKINT +#define CHECKINT(i) luaL_optinteger(L, i, 255) + if (a) + GETCOLOR(*a, index + 3, "alpha"); +#undef CHECKINT +#undef GETCOLOR + + num = 3 + (lua_type(L, index + 3) == LUA_TNUMBER); + } + + return num; +} + +static int lib_colorRgbToPalette(lua_State *L) +{ + INT32 r, g, b; + GetArgsRGBA(L, 1, &r, &g, &b, NULL); + +#ifdef COLORLIB_USE_LOOKUP + InitColorLUT(&colormix_lut, pMasterPalette, false); +#endif + + lua_pushinteger(L, GetNearestColor(r, g, b)); + return 1; +} + +static void GetHSLFromTable(lua_State *L, UINT32 index, UINT8 *hsl) +{ + lua_pushnil(L); + + while (lua_next(L, index)) { + lua_Integer i = 0; + const char *field = NULL; + if (lua_isnumber(L, -2)) + i = lua_tointeger(L, -2); + else + field = luaL_checkstring(L, -2); + +#define CHECKFIELD(p, c) (i == p || (field && fastcmp(field, c))) +#define HSLSET(p, c) { \ + INT32 val = luaL_checkinteger(L, -1); \ + if (val < 0 || val > 255) \ + luaL_error(L, c " %d out of range (0 - 255)", val); \ + hsl[p] = (UINT8)val; \ + } + + if (CHECKFIELD(1, "h")) { + HSLSET(0, "hue"); + } else if (CHECKFIELD(2, "s")) { + HSLSET(1, "saturation"); + } else if (CHECKFIELD(3, "l")) { + HSLSET(2, "lightness"); + } + +#undef CHECKFIELD +#undef HSLSET + + lua_pop(L, 1); + } +} + +#define SCALE_UINT8_TO_FIXED(val) FixedDiv(val * FRACUNIT, 255 * FRACUNIT) +#define SCALE_FIXED_TO_UINT8(val) FixedRound(FixedMul(val, 255 * FRACUNIT)) / FRACUNIT + +static fixed_t hue2rgb(fixed_t p, fixed_t q, fixed_t t) +{ + if (t < 0) + t += FRACUNIT; + if (t > FRACUNIT) + t -= FRACUNIT; + + fixed_t out; + + if (t < FRACUNIT / 6) + out = p + FixedMul(FixedMul(q - p, 6 * FRACUNIT), t); + else if (t < FRACUNIT / 2) + out = q; + else if (t < 2 * FRACUNIT / 3) + out = p + FixedMul(FixedMul(q - p, 2 * FRACUNIT / 3 - t), 6 * FRACUNIT); + else + out = p; + + return out; +} + +static int lib_colorHslToRgb(lua_State *L) +{ + fixed_t h, s, l; + + if (lua_istable(L, 1)) + { + UINT8 hsl[3] = { 0, 0, 0 }; + GetHSLFromTable(L, 1, hsl); + h = hsl[0]; + s = hsl[1]; + l = hsl[2]; + } + else + { +#define GETHSL(c, i, desc) \ + c = luaL_checkinteger(L, i); \ + if (c < 0 || c > 255) \ + luaL_error(L, desc " %d out of range (0 - 255)", c) + + GETHSL(h, 1, "hue"); + GETHSL(s, 2, "saturation"); + GETHSL(l, 3, "value"); +#undef GETHSL + } + + if (!s) + { + lua_pushinteger(L, l); + lua_pushinteger(L, l); + lua_pushinteger(L, l); + } + else + { + h = SCALE_UINT8_TO_FIXED(h); + s = SCALE_UINT8_TO_FIXED(s); + l = SCALE_UINT8_TO_FIXED(l); + + fixed_t q, p; + + if (l < FRACUNIT/2) + q = FixedMul(l, FRACUNIT + s); + else + q = l + s - FixedMul(l, s); + + p = l * 2 - q; + + lua_pushinteger(L, SCALE_FIXED_TO_UINT8(hue2rgb(p, q, h + FRACUNIT/3))); + lua_pushinteger(L, SCALE_FIXED_TO_UINT8(hue2rgb(p, q, h))); + lua_pushinteger(L, SCALE_FIXED_TO_UINT8(hue2rgb(p, q, h - FRACUNIT/3))); + } + + return 3; +} + +static int lib_colorRgbToHsl(lua_State *L) +{ + INT32 ir, ig, ib; + GetArgsRGBA(L, 1, &ir, &ig, &ib, NULL); + + fixed_t r = SCALE_UINT8_TO_FIXED(ir); + fixed_t g = SCALE_UINT8_TO_FIXED(ig); + fixed_t b = SCALE_UINT8_TO_FIXED(ib); + + fixed_t cmin = min(min(r, g), b); + fixed_t cmax = max(max(r, g), b); + + fixed_t h, s, l = (cmax + cmin) / 2; + fixed_t delta = cmax - cmin; + + if (!delta) + h = s = 0; + else + { + if (l > FRACUNIT / 2) + s = FixedDiv(delta, (FRACUNIT * 2) - cmax - cmin); + else + s = FixedDiv(delta, cmax + cmin); + + if (r > g && r > b) + { + h = FixedDiv(g - b, delta); + + if (g < b) + h += FRACUNIT * 6; + } + else + { + h = FixedDiv(r - g, delta); + + if (g > b) + h += FRACUNIT * 2; + else + h += FRACUNIT * 4; + } + + h = FixedDiv(h, FRACUNIT * 6); + } + + lua_pushinteger(L, SCALE_FIXED_TO_UINT8(h)); + lua_pushinteger(L, SCALE_FIXED_TO_UINT8(s)); + lua_pushinteger(L, SCALE_FIXED_TO_UINT8(l)); + + return 3; +} + +static int lib_colorHexToRgb(lua_State *L) +{ + UINT8 rgba[4] = { 0, 0, 0, 255 }; + + const char *str = luaL_checkstring(L, 1); + UINT8 parsed = ParseHTMLColor(str, rgba, 4), num = 3; + if (!parsed) + luaL_error(L, "Malformed HTML color '%s'", str); + else if (parsed == 8) + num++; + + lua_pushinteger(L, rgba[0]); + lua_pushinteger(L, rgba[1]); + lua_pushinteger(L, rgba[2]); + if (num == 4) + lua_pushinteger(L, rgba[3]); + + return num; +} + +static int lib_colorRgbToHex(lua_State *L) +{ + INT32 r, g, b, a; + UINT8 num = GetArgsRGBA(L, 1, &r, &g, &b, &a); + + char buffer[10]; + if (num >= 4) + snprintf(buffer, sizeof buffer, "#%02X%02X%02X%02X", r, g, b, a); + else + snprintf(buffer, sizeof buffer, "#%02X%02X%02X", r, g, b); + + lua_pushstring(L, buffer); + return 1; +} + +static int lib_colorPackRgb(lua_State *L) +{ + INT32 r, g, b; + + GetArgsRGBA(L, 1, &r, &g, &b, NULL); + + UINT32 packed = ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF); + + lua_pushinteger(L, packed); + return 1; +} + +static int lib_colorPackRgba(lua_State *L) +{ + INT32 r, g, b, a; + + GetArgsRGBA(L, 1, &r, &g, &b, &a); + + UINT32 packed = ((r & 0xFF) << 24) | ((g & 0xFF) << 16) | ((b & 0xFF) << 8) | (a & 0xFF); + + lua_pushinteger(L, packed); + return 1; +} + +static int lib_colorUnpackRgba(lua_State *L) +{ + UINT8 rgba[4]; + + UINT8 num = GetPackedRGBA(lua_tointeger(L, 1), rgba); + + for (UINT8 i = 0; i < num; i++) + { + lua_pushinteger(L, rgba[i]); + } + + return num; +} + +static luaL_Reg color_lib[] = { + {"paletteToRgb", lib_colorPaletteToRgb}, + {"rgbToPalette", lib_colorRgbToPalette}, + {"hslToRgb", lib_colorHslToRgb}, + {"rgbToHsl", lib_colorRgbToHsl}, + {"hexToRgb", lib_colorHexToRgb}, + {"rgbToHex", lib_colorRgbToHex}, + {"packRgb", lib_colorPackRgb}, + {"packRgba", lib_colorPackRgba}, + {"unpackRgba", lib_colorUnpackRgba}, + {NULL, NULL} +}; + ///////////////////////// // extracolormap userdata ///////////////////////// @@ -180,21 +552,7 @@ static void GetExtraColormapRGBA(lua_State *L, UINT8 *rgba, int arg) } else { - UINT32 colors = lua_tointeger(L, arg); - if (colors > 0xFFFFFF) - { - rgba[0] = (colors >> 24) & 0xFF; - rgba[1] = (colors >> 16) & 0xFF; - rgba[2] = (colors >> 8) & 0xFF; - rgba[3] = colors & 0xFF; - } - else - { - rgba[0] = (colors >> 16) & 0xFF; - rgba[1] = (colors >> 8) & 0xFF; - rgba[2] = colors & 0xFF; - rgba[3] = 0xFF; - } + GetPackedRGBA(lua_tointeger(L, arg), rgba); } } @@ -328,5 +686,7 @@ int LUA_ColorLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); + luaL_register(L, "color", color_lib); + return 0; } From 2e820ca83dac3a5143e7e41bbd4e2bfb6c110ed0 Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Fri, 4 Aug 2023 15:26:12 -0300 Subject: [PATCH 03/13] Rename color.unpackRgba to color.unpackRgb --- src/lua_colorlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_colorlib.c b/src/lua_colorlib.c index 210d833df..931a45d37 100644 --- a/src/lua_colorlib.c +++ b/src/lua_colorlib.c @@ -422,7 +422,7 @@ static int lib_colorPackRgba(lua_State *L) return 1; } -static int lib_colorUnpackRgba(lua_State *L) +static int lib_colorUnpackRgb(lua_State *L) { UINT8 rgba[4]; @@ -445,7 +445,7 @@ static luaL_Reg color_lib[] = { {"rgbToHex", lib_colorRgbToHex}, {"packRgb", lib_colorPackRgb}, {"packRgba", lib_colorPackRgba}, - {"unpackRgba", lib_colorUnpackRgba}, + {"unpackRgb", lib_colorUnpackRgb}, {NULL, NULL} }; From 0c3aab9ac381db61a19678ecbdfd65876397c077 Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Fri, 4 Aug 2023 15:27:05 -0300 Subject: [PATCH 04/13] Remove table argument support from color.hslToRgb --- src/lua_colorlib.c | 58 +++++----------------------------------------- 1 file changed, 6 insertions(+), 52 deletions(-) diff --git a/src/lua_colorlib.c b/src/lua_colorlib.c index 931a45d37..1ef21a41c 100644 --- a/src/lua_colorlib.c +++ b/src/lua_colorlib.c @@ -199,41 +199,6 @@ static int lib_colorRgbToPalette(lua_State *L) return 1; } -static void GetHSLFromTable(lua_State *L, UINT32 index, UINT8 *hsl) -{ - lua_pushnil(L); - - while (lua_next(L, index)) { - lua_Integer i = 0; - const char *field = NULL; - if (lua_isnumber(L, -2)) - i = lua_tointeger(L, -2); - else - field = luaL_checkstring(L, -2); - -#define CHECKFIELD(p, c) (i == p || (field && fastcmp(field, c))) -#define HSLSET(p, c) { \ - INT32 val = luaL_checkinteger(L, -1); \ - if (val < 0 || val > 255) \ - luaL_error(L, c " %d out of range (0 - 255)", val); \ - hsl[p] = (UINT8)val; \ - } - - if (CHECKFIELD(1, "h")) { - HSLSET(0, "hue"); - } else if (CHECKFIELD(2, "s")) { - HSLSET(1, "saturation"); - } else if (CHECKFIELD(3, "l")) { - HSLSET(2, "lightness"); - } - -#undef CHECKFIELD -#undef HSLSET - - lua_pop(L, 1); - } -} - #define SCALE_UINT8_TO_FIXED(val) FixedDiv(val * FRACUNIT, 255 * FRACUNIT) #define SCALE_FIXED_TO_UINT8(val) FixedRound(FixedMul(val, 255 * FRACUNIT)) / FRACUNIT @@ -262,26 +227,15 @@ static int lib_colorHslToRgb(lua_State *L) { fixed_t h, s, l; - if (lua_istable(L, 1)) - { - UINT8 hsl[3] = { 0, 0, 0 }; - GetHSLFromTable(L, 1, hsl); - h = hsl[0]; - s = hsl[1]; - l = hsl[2]; - } - else - { #define GETHSL(c, i, desc) \ - c = luaL_checkinteger(L, i); \ - if (c < 0 || c > 255) \ - luaL_error(L, desc " %d out of range (0 - 255)", c) + c = luaL_checkinteger(L, i); \ + if (c < 0 || c > 255) \ + luaL_error(L, desc " %d out of range (0 - 255)", c) - GETHSL(h, 1, "hue"); - GETHSL(s, 2, "saturation"); - GETHSL(l, 3, "value"); + GETHSL(h, 1, "hue"); + GETHSL(s, 2, "saturation"); + GETHSL(l, 3, "value"); #undef GETHSL - } if (!s) { From a977fd607559ccb73a28b59bae5991215c2f8744 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Sun, 17 Sep 2023 18:45:57 -0500 Subject: [PATCH 05/13] Expose P_LineIsBlocking --- src/lua_baselib.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/p_local.h | 1 + src/p_map.c | 29 +++++++++++++++++------------ 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 4af5066ae..741f44bb6 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1840,6 +1840,45 @@ static int lib_pMoveOrigin(lua_State *L) return 2; } +static int lib_pLineIsBlocking(lua_State *L) +{ + mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + line_t *line = *((line_t **)luaL_checkudata(L, 2, META_LINE)); + NOHUD + INLEVEL + if (!mo) + return LUA_ErrInvalid(L, "mobj_t"); + if (!line) + return LUA_ErrInvalid(L, "line_t"); + + // P_LineOpening in P_LineIsBlocking sets these variables. + // We want to keep their old values after so that whatever + // map collision code uses them doesn't get messed up. + fixed_t oldopentop = opentop; + fixed_t oldopenbottom = openbottom; + fixed_t oldopenrange = openrange; + fixed_t oldlowfloor = lowfloor; + fixed_t oldhighceiling = highceiling; + pslope_t *oldopentopslope = opentopslope; + pslope_t *oldopenbottomslope = openbottomslope; + ffloor_t *oldopenfloorrover = openfloorrover; + ffloor_t *oldopenceilingrover = openceilingrover; + + lua_pushboolean(L, P_LineIsBlocking(mo, line)); + + opentop = oldopentop; + openbottom = oldopenbottom; + openrange = oldopenrange; + lowfloor = oldlowfloor; + highceiling = oldhighceiling; + opentopslope = oldopentopslope; + openbottomslope = oldopenbottomslope; + openfloorrover = oldopenfloorrover; + openceilingrover = oldopenceilingrover; + + return 1; +} + static int lib_pSlideMove(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -4147,6 +4186,7 @@ static luaL_Reg lib[] = { {"P_TeleportMove",lib_pTeleportMove}, {"P_SetOrigin",lib_pSetOrigin}, {"P_MoveOrigin",lib_pMoveOrigin}, + {"P_LineIsBlocking",lib_pLineIsBlocking}, {"P_SlideMove",lib_pSlideMove}, {"P_BounceMove",lib_pBounceMove}, {"P_CheckSight", lib_pCheckSight}, diff --git a/src/p_local.h b/src/p_local.h index 4b330184b..036636626 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -418,6 +418,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff); boolean P_Move(mobj_t *actor, fixed_t speed); boolean P_SetOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z); boolean P_MoveOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z); +boolean P_LineIsBlocking(mobj_t *mo, line_t *li); void P_SlideMove(mobj_t *mo); void P_BounceMove(mobj_t *mo); boolean P_CheckSight(mobj_t *t1, mobj_t *t2); diff --git a/src/p_map.c b/src/p_map.c index 80135db74..a69fa06e2 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3400,36 +3400,41 @@ static boolean P_IsClimbingValid(player_t *player, angle_t angle) return false; } -static boolean PTR_LineIsBlocking(line_t *li) +// +// P_LineIsBlocking +// +// Determines if line would block mo's movement +// +boolean P_LineIsBlocking(mobj_t *mo, line_t *li) { // one-sided linedefs are always solid to sliding movement. if (!li->backsector) - return !P_PointOnLineSide(slidemo->x, slidemo->y, li); + return !P_PointOnLineSide(mo->x, mo->y, li); - if (!(slidemo->flags & MF_MISSILE)) + if (!(mo->flags & MF_MISSILE)) { if (li->flags & ML_IMPASSIBLE) return true; - if ((slidemo->flags & (MF_ENEMY|MF_BOSS)) && li->flags & ML_BLOCKMONSTERS) + if ((mo->flags & (MF_ENEMY|MF_BOSS)) && li->flags & ML_BLOCKMONSTERS) return true; } // set openrange, opentop, openbottom - P_LineOpening(li, slidemo); + P_LineOpening(li, mo); - if (openrange < slidemo->height) + if (openrange < mo->height) return true; // doesn't fit - if (opentop - slidemo->z < slidemo->height) + if (opentop - mo->z < mo->height) return true; // mobj is too high - if (openbottom - slidemo->z > FixedMul(MAXSTEPMOVE, slidemo->scale)) + if (openbottom - mo->z > FixedMul(MAXSTEPMOVE, mo->scale)) return true; // too big a step up - if (slidemo->player - && openrange < P_GetPlayerHeight(slidemo->player) - && !P_PlayerCanEnterSpinGaps(slidemo->player)) + if (mo->player + && openrange < P_GetPlayerHeight(mo->player) + && !P_PlayerCanEnterSpinGaps(mo->player)) return true; // nonspin character should not take this path return false; @@ -3533,7 +3538,7 @@ static boolean PTR_SlideTraverse(intercept_t *in) li = in->d.line; - if (!PTR_LineIsBlocking(li)) + if (!P_LineIsBlocking(slidemo, li)) return true; // the line blocks movement, From fddcb5cfdce9f70f9afbf57365c13e30b1ecd1be Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Tue, 21 Nov 2023 21:15:09 -0300 Subject: [PATCH 06/13] Fix P_GetSectorColormapAt --- src/lua_baselib.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 97bc9319c..3074187a3 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2025,14 +2025,18 @@ static int lib_pCeilingzAtPos(lua_State *L) static int lib_pGetSectorColormapAt(lua_State *L) { + boolean has_sector = false; sector_t *sector = NULL; - if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + if (!lua_isnoneornil(L, 1)) + { + has_sector = true; sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + } fixed_t x = luaL_checkfixed(L, 2); fixed_t y = luaL_checkfixed(L, 3); fixed_t z = luaL_checkfixed(L, 4); INLEVEL - if (!sector) + if (has_sector && !sector) return LUA_ErrInvalid(L, "sector_t"); extracolormap_t *exc; if (sector) From efb1b491aa6bdae2f1eded559cda300a88c276ee Mon Sep 17 00:00:00 2001 From: Jisk Date: Mon, 8 Jan 2024 19:13:30 +0000 Subject: [PATCH 07/13] Expose chat_on to Lua as chatactive --- src/lua_script.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index f90db7bc3..d63f885f4 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -38,6 +38,8 @@ #include "doomstat.h" #include "g_state.h" +#include "hu_stuff.h" + lua_State *gL = NULL; // List of internal libraries to load from SRB2 @@ -432,6 +434,9 @@ int LUA_PushGlobals(lua_State *L, const char *word) return 0; LUA_PushUserdata(L, &camera2, META_CAMERA); return 1; + } else if (fastcmp(word, "chatactive")) { + lua_pushboolean(L, chat_on); + return 1; } return 0; } From 159307c552a66266c4a2f533baca192b94b801e7 Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Mon, 8 Jan 2024 22:03:31 -0300 Subject: [PATCH 08/13] Fix 3D floor side texture scale when there are multiple on the same line --- 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 62fea352f..16d6a1856 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -525,6 +525,9 @@ static boolean R_IsFFloorTranslucent(visffloor_t *pfloor) // // R_RenderThickSideRange // Renders all the thick sides in the given range. + +static fixed_t ffloortexturecolumn[MAXVIDWIDTH]; + void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) { size_t pindex; @@ -732,10 +735,10 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) wall_scalex = FixedDiv(FRACUNIT, sidedef->scalex_mid); wall_scaley = sidedef->scaley_mid; - thicksidecol = ds->thicksidecol; + thicksidecol = ffloortexturecolumn; for (INT32 x = x1; x <= x2; x++) - thicksidecol[x] = FixedDiv(thicksidecol[x], wall_scalex) + ds->offsetx; + thicksidecol[x] = FixedDiv(ds->thicksidecol[x], wall_scalex) + ds->offsetx; mfloorclip = ds->sprbottomclip; mceilingclip = ds->sprtopclip; From 28c30a9294e8aeadf0ecc685991ced1513ac7227 Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Mon, 8 Jan 2024 22:08:50 -0300 Subject: [PATCH 09/13] Optimize for when wall_scalex == 1.0 --- src/r_segs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 16d6a1856..6ca7bce28 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -737,8 +737,16 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) thicksidecol = ffloortexturecolumn; - for (INT32 x = x1; x <= x2; x++) - thicksidecol[x] = FixedDiv(ds->thicksidecol[x], wall_scalex) + ds->offsetx; + if (wall_scalex == FRACUNIT) + { + for (INT32 x = x1; x <= x2; x++) + thicksidecol[x] = ds->thicksidecol[x] + ds->offsetx; + } + else + { + for (INT32 x = x1; x <= x2; x++) + thicksidecol[x] = FixedDiv(ds->thicksidecol[x], wall_scalex) + ds->offsetx; + } mfloorclip = ds->sprbottomclip; mceilingclip = ds->sprtopclip; From 3e34c961658ba95f8308de12473a237c5be59bdb Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Tue, 9 Jan 2024 14:14:49 -0300 Subject: [PATCH 10/13] Fix 3D floor sides not using the correct set of line flags --- src/hardware/hw_main.c | 9 +++++++-- src/r_segs.c | 14 +++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d448aa55e..db4fb53c8 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1625,12 +1625,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom side_t *side = &sides[rover->master->sidenum[0]]; + INT16 lineflags; + if (rover->master->flags & ML_TFERLINE) { size_t linenum = gl_curline->linedef-gl_backsector->lines[0]; newline = rover->master->frontsector->lines[0] + linenum; side = &sides[newline->sidenum[0]]; + lineflags = newline->flags; } + else + lineflags = gl_curline->linedef->flags; texnum = R_GetTextureNum(side->midtexture); @@ -1669,13 +1674,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // ...Oh well, anyway, Lower Unpegged now changes pegging of FOFs like in software // -- Monster Iestyn 26/06/18 fixed_t texturevpeg = side->rowoffset + side->offsety_mid; - boolean attachtobottom = !!(rover->master->flags & ML_DONTPEGBOTTOM); + boolean attachtobottom = !!(lineflags & ML_DONTPEGBOTTOM); grTex = HWR_GetTexture(texnum); xscale = FixedToFloat(side->scalex_mid); yscale = FixedToFloat(side->scaley_mid); - if (!(rover->master->flags & ML_SKEWTD)) // no skewing + if (!(lineflags & ML_SKEWTD)) // no skewing { if (attachtobottom) texturevpeg -= (*rover->topheight - *rover->bottomheight) * yscale; diff --git a/src/r_segs.c b/src/r_segs.c index 6ca7bce28..bd4869bdc 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -553,7 +553,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) fixed_t left_top, left_bottom; // needed here for slope skewing pslope_t *skewslope = NULL; boolean do_texture_skew; - UINT32 lineflags; + INT16 lineflags; fixed_t wall_scalex, wall_scaley; void (*colfunc_2s) (column_t *); @@ -578,7 +578,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) lineflags = newline->flags; } else - lineflags = pfloor->master->flags; + lineflags = curline->linedef->flags; texnum = R_GetTextureNum(sidedef->midtexture); @@ -757,10 +757,12 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) left_bottom = P_GetFFloorBottomZAt(pfloor, ds->leftpos.x, ds->leftpos.y) - viewz; do_texture_skew = lineflags & ML_SKEWTD; - skewslope = *pfloor->t_slope; // skew using top slope by default if (do_texture_skew) + { + skewslope = *pfloor->t_slope; // skew using top slope by default dc_texturemid = FixedMul(left_top, wall_scaley); + } else dc_texturemid = FixedMul(*pfloor->topheight - viewz, wall_scaley); @@ -768,14 +770,16 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (lineflags & ML_DONTPEGBOTTOM) { - skewslope = *pfloor->b_slope; // skew using bottom slope if (do_texture_skew) + { + skewslope = *pfloor->b_slope; // skew using bottom slope dc_texturemid = FixedMul(left_bottom, wall_scaley); + } else offsetvalue -= FixedMul(*pfloor->topheight - *pfloor->bottomheight, wall_scaley); } - if (do_texture_skew && skewslope) + if (skewslope) { angle_t lineangle = R_PointToAngle2(curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y); ffloortextureslide = FixedMul(skewslope->zdelta, FINECOSINE((lineangle-skewslope->xydirection)>>ANGLETOFINESHIFT)); From 9d718bc6392c28bf242ca672d81a6630251c9e02 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Wed, 10 Jan 2024 21:26:04 +0100 Subject: [PATCH 11/13] Fix single-sided sloped midtextures in OpenGL --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index db4fb53c8..e0548e50d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1532,7 +1532,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[3].t += (gl_frontsector->ceilingheight - worldtop) * yscale * grTex->scaleY; wallVerts[2].t += (gl_frontsector->ceilingheight - worldtopslope) * yscale * grTex->scaleY; wallVerts[0].t += (gl_frontsector->floorheight - worldbottom) * yscale * grTex->scaleY; - wallVerts[1].t += (gl_frontsector->floorheight - worldbottomslope) * yscale * yscale; + wallVerts[1].t += (gl_frontsector->floorheight - worldbottomslope) * yscale * grTex->scaleY; } else if (gl_linedef->flags & ML_DONTPEGBOTTOM) { wallVerts[3].t = wallVerts[0].t + ((worldbottom - worldtop) * yscale) * grTex->scaleY; wallVerts[2].t = wallVerts[1].t + ((worldbottomslope - worldtopslope) * yscale) * grTex->scaleY; From 5a2a24b8688e8e9c91f6e09650e82d7e55b96534 Mon Sep 17 00:00:00 2001 From: Mari0shi Date: Thu, 11 Jan 2024 12:11:54 +0000 Subject: [PATCH 12/13] Draw Character in NiGHTS Attack --- src/lua_skinlib.c | 7 +++++- src/m_menu.c | 55 ++++++++++++++++++++++++++++++++++++++++++----- src/r_skins.c | 6 +++++- src/r_skins.h | 1 + 4 files changed, 62 insertions(+), 7 deletions(-) diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index 3debd3746..ee5be8d9e 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -54,7 +54,8 @@ enum skin { skin_contspeed, skin_contangle, skin_soundsid, - skin_sprites + skin_sprites, + skin_natkcolor }; static const char *const skin_opt[] = { @@ -94,6 +95,7 @@ static const char *const skin_opt[] = { "contangle", "soundsid", "sprites", + "natkcolor", NULL}; #define UNIMPLEMENTED luaL_error(L, LUA_QL("skin_t") " field " LUA_QS " is not implemented for Lua and cannot be accessed.", skin_opt[field]) @@ -218,6 +220,9 @@ static int skin_get(lua_State *L) case skin_sprites: LUA_PushUserdata(L, skin->sprites, META_SKINSPRITES); break; + case skin_natkcolor: + lua_pushinteger(L, skin->natkcolor); + break; } return 1; } diff --git a/src/m_menu.c b/src/m_menu.c index 9aae59445..78da84166 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5896,14 +5896,14 @@ static void M_DrawNightsAttackBackground(void) } // NiGHTS Attack floating Super Sonic. -static patch_t *ntssupersonic[2]; +/*static patch_t *ntssupersonic[2]; static void M_DrawNightsAttackSuperSonic(void) { const UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_YELLOW, GTC_CACHE); INT32 timer = FixedInt(ntsatkdrawtimer/4) % 2; angle_t fa = (FixedAngle((FixedInt(ntsatkdrawtimer * 4) % 360)<>ANGLETOFINESHIFT) & FINEMASK; V_DrawFixedPatch(235<spriteframes[spritetimer]; //Our animation frame is equal to the number on the timer + + NightsAttackSprite = W_CachePatchNum(sprframe->lumppat[6], PU_PATCH); //Draw the right facing angle + + if (skins[skinnumber].natkcolor) //If you set natkcolor use it + color = skins[skinnumber].natkcolor; + else if ((skins[skinnumber].flags & SF_SUPER) && !(skins[skinnumber].flags & SF_NONIGHTSSUPER)) //If you go super in NiGHTS, use supercolor + color = skins[skinnumber].supercolor+4; + else //If you don't go super in NiGHTS or at all, use prefcolor + color = skins[skinnumber].prefcolor; + + + + colormap = R_GetTranslationColormap(TC_BLINK, color, GTC_CACHE); //Make the sprite color be our prefcolor + + angle_t fa = (FixedAngle(((FixedInt(ntsatkdrawtimer * 4)) % 360)<>ANGLETOFINESHIFT) & FINEMASK; + + if (sprframe->flip & 1<<6) //If our sprite is supposed to be flipped + flags = V_FLIP; //Flip it + else + flags = 0; + + + V_DrawFixedPatch((270<width)*3)/2, 135, 0, ngradeletters[bestoverall]); @@ -10348,8 +10393,8 @@ static void M_NightsAttack(INT32 choice) // This is really just to make sure Sonic is the played character, just in case M_PatchSkinNameTable(); - ntssupersonic[0] = W_CachePatchName("NTSSONC1", PU_PATCH); - ntssupersonic[1] = W_CachePatchName("NTSSONC2", PU_PATCH); + //ntssupersonic[0] = W_CachePatchName("NTSSONC1", PU_PATCH); + //ntssupersonic[1] = W_CachePatchName("NTSSONC2", PU_PATCH); G_SetGamestate(GS_TIMEATTACK); // do this before M_SetupNextMenu so that menu meta state knows that we're switching titlemapinaction = TITLEMAP_OFF; // Nope don't give us HOMs please diff --git a/src/r_skins.c b/src/r_skins.c index fbc2a30e1..06da17be6 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -149,6 +149,8 @@ static void Sk_SetDefaultValue(skin_t *skin) skin->contspeed = 17; skin->contangle = 0; + skin->natkcolor = SKINCOLOR_NONE; + for (i = 0; i < sfx_skinsoundslot0; i++) if (S_sfx[i].skinsound != -1) skin->soundsid[S_sfx[i].skinsound] = i; @@ -603,7 +605,6 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) UINT16 color = R_GetSuperColorByName(value); skin->supercolor = (color ? color : SKINCOLOR_SUPERGOLD1); } - #define GETFLOAT(field) else if (!stricmp(stoken, #field)) skin->field = FLOAT_TO_FIXED(atof(value)); GETFLOAT(jumpfactor) GETFLOAT(highresscale) @@ -644,6 +645,9 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) GETFLAG(NOSHIELDABILITY) #undef GETFLAG + else if (!stricmp(stoken, "natkcolor")) + skin->natkcolor = R_GetColorByName(value); // SKINCOLOR_NONE is allowed here + else // let's check if it's a sound, otherwise error out { boolean found = false; diff --git a/src/r_skins.h b/src/r_skins.h index bf2275a49..5acb415fe 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -70,6 +70,7 @@ typedef struct UINT16 prefcolor; UINT16 supercolor; UINT16 prefoppositecolor; // if 0 use tables instead + UINT16 natkcolor; //Color for Nights Attack Menu fixed_t highresscale; // scale of highres, default is 0.5 UINT8 contspeed; // continue screen animation speed From 35b6b215623c8f1bb388707202153ce8688152c2 Mon Sep 17 00:00:00 2001 From: spherallic Date: Thu, 11 Jan 2024 13:18:32 +0100 Subject: [PATCH 13/13] Clean up NiGHTS attack character code, fix compile issues --- src/m_menu.c | 62 ++++++++++++++-------------------------------------- 1 file changed, 17 insertions(+), 45 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 6b6fa7ec9..504a5c6cb 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5979,16 +5979,6 @@ static void M_DrawNightsAttackBackground(void) if (ntsatkdrawtimer < 0) ntsatkdrawtimer = 0; } -// NiGHTS Attack floating Super Sonic. -/*static patch_t *ntssupersonic[2]; -static void M_DrawNightsAttackSuperSonic(void) -{ - const UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_YELLOW, GTC_CACHE); - INT32 timer = FixedInt(ntsatkdrawtimer/4) % 2; - angle_t fa = (FixedAngle((FixedInt(ntsatkdrawtimer * 4) % 360)<>ANGLETOFINESHIFT) & FINEMASK; - V_DrawFixedPatch(235<sprites[SPR2_NFLY].numframes == 0) //If we don't have NiGHTS sprites skinnumber = 0; //Default to Sonic else skinnumber = (cv_chooseskin.value-1); - spritedef_t *sprdef = &skins[skinnumber].sprites[SPR2_NFLY]; //Make our patch the selected character's NFLY sprite - spritetimer = FixedInt(ntsatkdrawtimer/2) % skins[skinnumber].sprites[SPR2_NFLY].numframes; //Make the sprite timer cycle though all the frames at 2 tics per frame + spritedef_t *sprdef = &skins[skinnumber]->sprites[SPR2_NFLY]; //Make our patch the selected character's NFLY sprite + spritetimer = FixedInt(ntsatkdrawtimer/2) % skins[skinnumber]->sprites[SPR2_NFLY].numframes; //Make the sprite timer cycle though all the frames at 2 tics per frame spriteframe_t *sprframe = &sprdef->spriteframes[spritetimer]; //Our animation frame is equal to the number on the timer - NightsAttackSprite = W_CachePatchNum(sprframe->lumppat[6], PU_PATCH); //Draw the right facing angle + natksprite = W_CachePatchNum(sprframe->lumppat[6], PU_PATCH); //Draw the right facing angle - if (skins[skinnumber].natkcolor) //If you set natkcolor use it - color = skins[skinnumber].natkcolor; - else if ((skins[skinnumber].flags & SF_SUPER) && !(skins[skinnumber].flags & SF_NONIGHTSSUPER)) //If you go super in NiGHTS, use supercolor - color = skins[skinnumber].supercolor+4; + if (skins[skinnumber]->natkcolor) //If you set natkcolor use it + color = skins[skinnumber]->natkcolor; + else if ((skins[skinnumber]->flags & SF_SUPER) && !(skins[skinnumber]->flags & SF_NONIGHTSSUPER)) //If you go super in NiGHTS, use supercolor + color = skins[skinnumber]->supercolor+4; else //If you don't go super in NiGHTS or at all, use prefcolor - color = skins[skinnumber].prefcolor; - - - - colormap = R_GetTranslationColormap(TC_BLINK, color, GTC_CACHE); //Make the sprite color be our prefcolor + color = skins[skinnumber]->prefcolor; angle_t fa = (FixedAngle(((FixedInt(ntsatkdrawtimer * 4)) % 360)<>ANGLETOFINESHIFT) & FINEMASK; - if (sprframe->flip & 1<<6) //If our sprite is supposed to be flipped - flags = V_FLIP; //Flip it - else - flags = 0; - - - V_DrawFixedPatch((270<highresscale, skins[skinnumber]->shieldscale), + (sprframe->flip & 1<<6) ? V_FLIP : 0, + natksprite, + R_GetTranslationColormap(TC_BLINK, color, GTC_CACHE)); //if (P_HasGrades(cv_nextmap.value, 0)) // V_DrawScaledPatch(235 - (((ngradeletters[bestoverall])->width)*3)/2, 135, 0, ngradeletters[bestoverall]); @@ -10483,9 +10458,6 @@ static void M_NightsAttack(INT32 choice) // This is really just to make sure Sonic is the played character, just in case M_PatchSkinNameTable(); - //ntssupersonic[0] = W_CachePatchName("NTSSONC1", PU_PATCH); - //ntssupersonic[1] = W_CachePatchName("NTSSONC2", PU_PATCH); - G_SetGamestate(GS_TIMEATTACK); // do this before M_SetupNextMenu so that menu meta state knows that we're switching titlemapinaction = TITLEMAP_OFF; // Nope don't give us HOMs please M_SetupNextMenu(&SP_NightsAttackDef);