From b975eedd9b1030815d7e6395d93b9edc7922cf6c Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 26 Apr 2021 14:00:34 -0700 Subject: [PATCH 1/9] Fix two bugs with Lua MIN, MAX Plus cvars 1) Any cvar without MIN, MAX would be disallowed; now check that at least one of those values is actually present. 2) Handle value index properly when shifting array. --- src/lua_consolelib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index e839d4e15..51e83d792 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -400,23 +400,23 @@ static int lib_cvRegisterVar(lua_State *L) { memmove(&cvpv[2], &cvpv[0], i * sizeof *cvpv); + i += 2; } cvpv[n].strvalue = MINMAX[n]; minmax_unset &= ~(1 << n); } else { - n = i; + n = i++; cvpv[n].strvalue = Z_StrDup(strval); } cvpv[n].value = (INT32)lua_tonumber(L, 6); - i++; lua_pop(L, 1); } - if (minmax_unset) + if (minmax_unset && minmax_unset != 3) FIELDERROR("PossibleValue", "custom PossibleValue table requires requires both MIN and MAX keys if one is present"); cvpv[i].value = 0; From 39869b4492d133f044b970826e5ee74782d3854d Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 31 May 2023 22:21:31 -0500 Subject: [PATCH 2/9] Expose P_TouchSpecialThing --- src/lua_baselib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 25fa38769..8409a8377 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2195,6 +2195,19 @@ static int lib_pDoMatchSuper(lua_State *L) return 0; } +static int lib_pTouchSpecialThing(lua_State *L) +{ + mobj_t *special = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *toucher = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + boolean heightcheck = lua_optboolean(L, 3); + NOHUD + INLEVEL + if (!special || !toucher) + return LUA_ErrInvalid(L, "mobj_t"); + P_TouchSpecialThing(special, toucher, heightcheck); + return 0; +} + // P_SPEC //////////// @@ -4133,6 +4146,7 @@ static luaL_Reg lib[] = { {"P_FloorzAtPos",lib_pFloorzAtPos}, {"P_CeilingzAtPos",lib_pCeilingzAtPos}, {"P_DoSpring",lib_pDoSpring}, + {"P_TouchSpecialThing",lib_pTouchSpecialThing}, {"P_TryCameraMove", lib_pTryCameraMove}, {"P_TeleportCameraMove", lib_pTeleportCameraMove}, From 16e44e1b6e4b61cbe2c7516ceb6dd13d03e138bb Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 31 May 2023 22:28:53 -0500 Subject: [PATCH 3/9] Expose FollowMobj-related functions --- src/lua_baselib.c | 45 ++++++++++++++++++++++++++++++++++++++++++ src/p_local.h | 4 ++++ src/p_user.c | 50 +++++++++++++++++++++++++---------------------- 3 files changed, 76 insertions(+), 23 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 25fa38769..7f64b7ddf 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1714,6 +1714,48 @@ static int lib_pSwitchShield(lua_State *L) return 0; } +static int lib_pDoTailsOverlay(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + mobj_t *tails = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + if (!tails) + return LUA_ErrInvalid(L, "mobj_t"); + P_DoTailsOverlay(player, tails); + return 0; +} + +static int lib_pDoMetalJetFume(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + mobj_t *fume = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + if (!fume) + return LUA_ErrInvalid(L, "mobj_t"); + P_DoMetalJetFume(player, fume); + return 0; +} + +static int lib_pDoFollowMobj(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + mobj_t *followmobj = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + if (!followmobj) + return LUA_ErrInvalid(L, "mobj_t"); + P_DoFollowMobj(player, followmobj); + return 0; +} + static int lib_pPlayerCanEnterSpinGaps(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -4115,6 +4157,9 @@ static luaL_Reg lib[] = { {"P_SpawnSpinMobj",lib_pSpawnSpinMobj}, {"P_Telekinesis",lib_pTelekinesis}, {"P_SwitchShield",lib_pSwitchShield}, + {"P_DoTailsOverlay",lib_pDoTailsOverlay}, + {"P_DoMetalJetFume",lib_pDoMetalJetFume}, + {"P_DoFollowMobj",lib_pDoFollowMobj}, {"P_PlayerCanEnterSpinGaps",lib_pPlayerCanEnterSpinGaps}, {"P_PlayerShouldUseSpinHeight",lib_pPlayerShouldUseSpinHeight}, diff --git a/src/p_local.h b/src/p_local.h index cc060e4ee..776e9e122 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -213,6 +213,10 @@ void P_SpawnThokMobj(player_t *player); void P_SpawnSpinMobj(player_t *player, mobjtype_t type); void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range); +void P_DoTailsOverlay(player_t *player, mobj_t *tails); +void P_DoMetalJetFume(player_t *player, mobj_t *fume); +void P_DoFollowMobj(player_t *player, mobj_t *followmobj); + void P_PlayLivesJingle(player_t *player); #define P_PlayRinglossSound(s) S_StartSound(s, (mariomode) ? sfx_mario8 : sfx_altow1 + P_RandomKey(4)); #define P_PlayDeathSound(s) S_StartSound(s, sfx_altdi1 + P_RandomKey(4)); diff --git a/src/p_user.c b/src/p_user.c index 0f3282da5..253161c04 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11103,7 +11103,7 @@ static void P_MinecartThink(player_t *player) } // Handle Tails' fluff -static void P_DoTailsOverlay(player_t *player, mobj_t *tails) +void P_DoTailsOverlay(player_t *player, mobj_t *tails) { // init... boolean smilesonground = P_IsObjectOnGround(player->mo); @@ -11308,7 +11308,7 @@ static void P_DoTailsOverlay(player_t *player, mobj_t *tails) } // Metal Sonic's jet fume -static void P_DoMetalJetFume(player_t *player, mobj_t *fume) +void P_DoMetalJetFume(player_t *player, mobj_t *fume) { static const UINT8 FUME_SKINCOLORS[] = { @@ -11439,6 +11439,30 @@ static void P_DoMetalJetFume(player_t *player, mobj_t *fume) P_SpawnGhostMobj(fume); } +// Handle Followmobj behavior +void P_DoFollowMobj(player_t *player, mobj_t *followmobj) +{ + if (LUAh_FollowMobj(player, followmobj) || P_MobjWasRemoved(followmobj)) + {;} + else + { + switch (followmobj->type) + { + case MT_TAILSOVERLAY: // c: + P_DoTailsOverlay(player, followmobj); + break; + case MT_METALJETFUME: + P_DoMetalJetFume(player, followmobj); + break; + default: + var1 = 1; + var2 = 0; + A_CapeChase(followmobj); + break; + } + } +} + // // P_PlayerThink // @@ -12894,27 +12918,7 @@ void P_PlayerAfterThink(player_t *player) } if (player->followmobj) - { - if (LUA_HookFollowMobj(player, player->followmobj) || P_MobjWasRemoved(player->followmobj)) - {;} - else - { - switch (player->followmobj->type) - { - case MT_TAILSOVERLAY: // c: - P_DoTailsOverlay(player, player->followmobj); - break; - case MT_METALJETFUME: - P_DoMetalJetFume(player, player->followmobj); - break; - default: - var1 = 1; - var2 = 0; - A_CapeChase(player->followmobj); - break; - } - } - } + P_DoFollowMobj(player, player->followmobj); } P_DoPlayerHeadSigns(player); // Spawn Tag/CTF signs over player's head From 84438ff8376391fee0cfb160fb637a23102963e2 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 31 May 2023 22:39:08 -0500 Subject: [PATCH 4/9] Expose P_GivePlayerSpheres to Lua --- src/lua_baselib.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 25fa38769..0ebb143ca 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1422,6 +1422,18 @@ static int lib_pGivePlayerRings(lua_State *L) return 0; } +static int lib_pGivePlayerSpheres(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + INT32 num_spheres = (INT32)luaL_checkinteger(L, 2); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + P_GivePlayerSpheres(player, num_spheres); + return 0; +} + static int lib_pGivePlayerLives(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -4091,6 +4103,7 @@ static luaL_Reg lib[] = { {"P_SpawnShieldOrb",lib_pSpawnShieldOrb}, {"P_SpawnGhostMobj",lib_pSpawnGhostMobj}, {"P_GivePlayerRings",lib_pGivePlayerRings}, + {"P_GivePlayerSpheres",lib_pGivePlayerSpheres}, {"P_GivePlayerLives",lib_pGivePlayerLives}, {"P_GiveCoopLives",lib_pGiveCoopLives}, {"P_ResetScore",lib_pResetScore}, From 34477133cc646e42441cde2679bb6ac580292e52 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 31 May 2023 22:49:30 -0500 Subject: [PATCH 5/9] Expose P_DoSpinDashDust to Lua --- src/lua_baselib.c | 12 ++++++++++++ src/p_local.h | 1 + src/p_user.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 25fa38769..090c1c371 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1664,6 +1664,17 @@ static int lib_pDoJump(lua_State *L) return 0; } +static int lib_pDoSpinDashDust(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + P_DoSpinDashDust(player); + return 0; +} + static int lib_pSpawnThokMobj(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -4111,6 +4122,7 @@ static luaL_Reg lib[] = { {"P_HomingAttack",lib_pHomingAttack}, {"P_SuperReady",lib_pSuperReady}, {"P_DoJump",lib_pDoJump}, + {"P_DoSpinDashDust",lib_pDoSpinDashDust}, {"P_SpawnThokMobj",lib_pSpawnThokMobj}, {"P_SpawnSpinMobj",lib_pSpawnSpinMobj}, {"P_Telekinesis",lib_pTelekinesis}, diff --git a/src/p_local.h b/src/p_local.h index cc060e4ee..c07b7029b 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -203,6 +203,7 @@ void P_Earthquake(mobj_t *inflictor, mobj_t *source, fixed_t radius); boolean P_HomingAttack(mobj_t *source, mobj_t *enemy); /// \todo doesn't belong in p_user boolean P_SuperReady(player_t *player); void P_DoJump(player_t *player, boolean soundandstate); +void P_DoSpinDashDust(player_t *player); #define P_AnalogMove(player) (P_ControlStyle(player) == CS_LMAOGALOG) boolean P_TransferToNextMare(player_t *player); UINT8 P_FindLowestMare(void); diff --git a/src/p_user.c b/src/p_user.c index 0f3282da5..22c2bd3a9 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4537,7 +4537,7 @@ void P_DoJump(player_t *player, boolean soundandstate) } } -static void P_DoSpinDashDust(player_t *player) +void P_DoSpinDashDust(player_t *player) { UINT32 i; mobj_t *particle; From 7a7cee7ca575246d2b01632977dd886484b589f3 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 31 May 2023 23:03:22 -0500 Subject: [PATCH 6/9] Expose P_CheckSkyHit to Lua --- src/lua_baselib.c | 15 +++++++++++++++ src/p_local.h | 1 + src/p_mobj.c | 21 +++++++++++---------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 25fa38769..1a189fabd 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1030,6 +1030,20 @@ static int lib_pRailThinker(lua_State *L) return 1; } +static int lib_pCheckSkyHit(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + line_t *line = *((line_t **)luaL_checkudata(L, 2, META_LINE)); + //HUDSAFE + INLEVEL + if (!mobj) + return LUA_ErrInvalid(L, "mobj_t"); + if (!line) + return LUA_ErrInvalid(L, "line_t"); + lua_pushboolean(L, P_CheckSkyHit(mobj, line)); + return 1; +} + static int lib_pXYMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -4059,6 +4073,7 @@ static luaL_Reg lib[] = { {"P_CreateFloorSpriteSlope",lib_pCreateFloorSpriteSlope}, {"P_RemoveFloorSpriteSlope",lib_pRemoveFloorSpriteSlope}, {"P_RailThinker",lib_pRailThinker}, + {"P_CheckSkyHit",lib_pCheckSkyHit}, {"P_XYMovement",lib_pXYMovement}, {"P_RingXYMovement",lib_pRingXYMovement}, {"P_SceneryXYMovement",lib_pSceneryXYMovement}, diff --git a/src/p_local.h b/src/p_local.h index cc060e4ee..91634e803 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -297,6 +297,7 @@ void P_RunOverlays(void); void P_HandleMinecartSegments(mobj_t *mobj); void P_MobjThinker(mobj_t *mobj); boolean P_RailThinker(mobj_t *mobj); +boolean P_CheckSkyHit(mobj_t *mo, line_t *line); void P_PushableThinker(mobj_t *mobj); void P_SceneryThinker(mobj_t *mobj); diff --git a/src/p_mobj.c b/src/p_mobj.c index eeaf54776..fad4f7743 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1753,14 +1753,15 @@ bustupdone: // // P_CheckSkyHit // -static boolean P_CheckSkyHit(mobj_t *mo) +boolean P_CheckSkyHit(mobj_t *mo, line_t *line) { - if (ceilingline && ceilingline->backsector - && ceilingline->backsector->ceilingpic == skyflatnum - && ceilingline->frontsector - && ceilingline->frontsector->ceilingpic == skyflatnum - && (mo->z >= ceilingline->frontsector->ceilingheight - || mo->z >= ceilingline->backsector->ceilingheight)) + if (line && (line->special == 41 || + (line->backsector + && line->backsector->ceilingpic == skyflatnum + && line->frontsector + && line->frontsector->ceilingpic == skyflatnum + && (mo->z >= line->frontsector->ceilingheight + || mo->z >= line->backsector->ceilingheight)))) return true; return false; } @@ -1867,7 +1868,7 @@ void P_XYMovement(mobj_t *mo) mo->fuse += ((5 - mo->threshold) * TICRATE); // Check for hit against sky here - if (P_CheckSkyHit(mo)) + if (P_CheckSkyHit(mo, ceilingline)) { // Hack to prevent missiles exploding // against the sky. @@ -1887,7 +1888,7 @@ void P_XYMovement(mobj_t *mo) mo->flags &= ~MF_STICKY; //Don't check again! // Check for hit against sky here - if (P_CheckSkyHit(mo)) + if (P_CheckSkyHit(mo, ceilingline)) { // Hack to prevent missiles exploding // against the sky. @@ -1946,7 +1947,7 @@ void P_XYMovement(mobj_t *mo) else if (mo->flags & MF_MISSILE) { // explode a missile - if (P_CheckSkyHit(mo)) + if (P_CheckSkyHit(mo, ceilingline)) { // Hack to prevent missiles exploding // against the sky. From 826a70323ccabcdce551b2b0e8e786dcd525f1d7 Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Fri, 9 Jun 2023 13:04:01 -0500 Subject: [PATCH 7/9] LUA_HookFollowMobj instead of LUAh_FollowMobj --- 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 253161c04..2200185ac 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11442,7 +11442,7 @@ void P_DoMetalJetFume(player_t *player, mobj_t *fume) // Handle Followmobj behavior void P_DoFollowMobj(player_t *player, mobj_t *followmobj) { - if (LUAh_FollowMobj(player, followmobj) || P_MobjWasRemoved(followmobj)) + if (LUA_HookFollowMobj(player, followmobj) || P_MobjWasRemoved(followmobj)) {;} else { From 2647b108406258aac6fcf8bf522cb2be8b68305c Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Sat, 1 Jul 2023 22:24:11 -0500 Subject: [PATCH 8/9] Require valid toucher.player --- src/lua_baselib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 8409a8377..1f8baedc2 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2204,6 +2204,8 @@ static int lib_pTouchSpecialThing(lua_State *L) INLEVEL if (!special || !toucher) return LUA_ErrInvalid(L, "mobj_t"); + if (!toucher->player) + return luaL_error(L, "P_TouchSpecialThing requires a valid toucher.player."); P_TouchSpecialThing(special, toucher, heightcheck); return 0; } From 7643ffadbc7887eab545e061674ab359e075a5c6 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Wed, 1 Nov 2023 15:13:40 +0000 Subject: [PATCH 9/9] Update .gitlab-ci.yml file Limit builds to just "Windows x86" and "Debian stable:amd64", all other builds can be started manually --- .gitlab-ci.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c61e181a5..ef2304410 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -159,6 +159,9 @@ stages: Debian testing GCC: stage: build + + when: manual + image: debian:testing-slim allow_failure: true @@ -198,6 +201,8 @@ Debian testing GCC: Windows x86: stage: build + when: on_success + artifacts: paths: - "bin/" @@ -228,6 +233,8 @@ Windows x86: Debian stable:amd64: stage: build + when: on_success + artifacts: paths: - "bin/" @@ -270,6 +277,8 @@ Debian stable:amd64: Debian stable:i386: stage: build + when: manual + artifacts: paths: - "bin/" @@ -311,6 +320,8 @@ Debian stable:i386: Debian stable:arm64: stage: build + when: manual + artifacts: paths: - "bin/" @@ -353,6 +364,8 @@ Debian stable:arm64: Windows x64: stage: build + when: manual + artifacts: paths: - "bin/" @@ -383,6 +396,8 @@ Windows x64: Debian stable Clang: stage: build + when: manual + allow_failure: true artifacts: @@ -422,6 +437,8 @@ Debian stable Clang: Debian stable musl: stage: build + when: manual + allow_failure: true artifacts: @@ -459,6 +476,8 @@ Debian stable musl: Debian testing Clang: extends: Debian stable Clang + when: manual + image: debian:testing-slim artifacts: @@ -473,6 +492,8 @@ Debian testing Clang: Debian testing musl: extends: Debian stable musl + when: manual + image: debian:testing-slim artifacts: