From 922f80b22f394e5fb59b1032d5ae70de74cb3f02 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sat, 12 Jan 2019 04:30:41 -0500 Subject: [PATCH 01/58] Uncap player-count item distribution modifiers Was an idea I had in development to make 16P less chaotic, but decided against it due to lack of testing and that it could backfire badly... --- src/k_kart.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 8189cd0f..2c68440f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -631,15 +631,14 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed) } } - if (first != -1 && second != -1) // calculate 2nd's distance from 1st, for SPB + if (first != -1 && second != -1 && !G_BattleGametype()) // calculate 2nd's distance from 1st, for SPB { secondist = P_AproxDistance(P_AproxDistance(players[first].mo->x - players[second].mo->x, players[first].mo->y - players[second].mo->y), players[first].mo->z - players[second].mo->z) / mapheaderinfo[gamemap-1]->mobj_scale; if (franticitems) secondist = (15*secondist/14); - if (pingame < 8 && !G_BattleGametype()) - secondist = ((28+(8-pingame))*secondist/28); + secondist = ((28+(8-pingame))*secondist/28); } // POWERITEMODDS handles all of the "frantic item" related functionality, for all of our powerful items. @@ -647,14 +646,13 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed) // Then, it multiplies it further if there's less than 5 players in game. // This is done to make low player count races more fair & interesting. (1v1s are basically the same as franticitems false in a normal race) // Lastly, it *divides* it by your mashed value, which was determined in K_KartItemRoulette, to punish those who are impatient. - // The last two are very fractional and complicated, very sorry! #define POWERITEMODDS(odds) \ if (franticitems) \ - odds *= 2; \ - if (pingame < 8 && !G_BattleGametype()) \ - odds = FixedMul(odds*FRACUNIT, FRACUNIT+min((8-pingame)*(FRACUNIT/25), FRACUNIT))/FRACUNIT; \ + odds <<= 1; \ + if (!G_BattleGametype()) \ + odds = FixedMul(odds<> FRACBITS; \ if (mashed > 0) \ - odds = FixedDiv(odds*FRACUNIT, mashed+FRACUNIT)/FRACUNIT \ + odds = FixedDiv(odds<> FRACBITS \ switch (item) { @@ -837,8 +835,7 @@ static INT32 K_FindUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT3 if (franticitems) // Frantic items make the distances between everyone artifically higher, for crazier items pdis = (15*pdis/14); - if (pingame < 8 && !G_BattleGametype()) - pdis = ((28+(8-pingame))*pdis/28); + pdis = ((28+(8-pingame))*pdis/28); if (pingame == 1 && oddsvalid[0]) // Record Attack, or just alone useodds = 0; From 24a32c2f517b20ae0ecbad6df16ac2f9bf40f1fc Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sat, 12 Jan 2019 04:31:35 -0500 Subject: [PATCH 02/58] Allow player-count modifiers in Battle --- src/k_kart.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 2c68440f..b97a518f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -649,8 +649,7 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed) #define POWERITEMODDS(odds) \ if (franticitems) \ odds <<= 1; \ - if (!G_BattleGametype()) \ - odds = FixedMul(odds<> FRACBITS; \ + odds = FixedMul(odds<> FRACBITS; \ if (mashed > 0) \ odds = FixedDiv(odds<> FRACBITS \ From 650522fc59da39db4492095ddb0087cc0a21a500 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sat, 12 Jan 2019 04:43:43 -0500 Subject: [PATCH 03/58] Don't increment ingame count without bumpers --- src/k_kart.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index b97a518f..92aafad5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -613,21 +613,24 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed) { if (!playeringame[i] || players[i].spectator) continue; - - pingame++; + if (!G_BattleGametype() || players[i].kartstuff[k_bumper]) + pingame++; if (players[i].exiting) pexiting++; if (players[i].mo) { - if (players[i].kartstuff[k_position] == 1 && first == -1) - first = i; - if (players[i].kartstuff[k_position] == 2 && second == -1) - second = i; if (players[i].kartstuff[k_itemtype] == KITEM_INVINCIBILITY || players[i].kartstuff[k_itemtype] == KITEM_GROW || players[i].kartstuff[k_invincibilitytimer] || players[i].kartstuff[k_growshrinktimer] > 0) pinvin++; + if (!G_BattleGametype()) + { + if (players[i].kartstuff[k_position] == 1 && first == -1) + first = i; + if (players[i].kartstuff[k_position] == 2 && second == -1) + second = i; + } } } From 0ef5c2e388f86010da807ba8540eccb433a6d24c Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sat, 12 Jan 2019 05:01:36 -0500 Subject: [PATCH 04/58] Some house-cleaning --- src/k_kart.c | 126 ++++++++++++++++++++------------------------------- 1 file changed, 48 insertions(+), 78 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 92aafad5..049e3c54 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -603,6 +603,32 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed) UINT8 pingame = 0, pexiting = 0, pinvin = 0; SINT8 first = -1, second = -1; INT32 secondist = 0; + boolean itemenabled[NUMKARTRESULTS] = { + cv_sneaker.value, + cv_rocketsneaker.value, + cv_invincibility.value, + cv_banana.value, + cv_eggmanmonitor.value, + cv_orbinaut.value, + cv_jawz.value, + cv_mine.value, + cv_ballhog.value, + cv_selfpropelledbomb.value, + cv_grow.value, + cv_shrink.value, + cv_thundershield.value, + cv_hyudoro.value, + cv_kitchensink.value, + cv_triplesneaker.value, + cv_triplebanana.value, + cv_decabanana.value, + cv_tripleorbinaut.value, + cv_quadorbinaut.value, + cv_dualjawz.value + }; + + if (!itemenabled[item] && !modeattacking) + return 0; if (G_BattleGametype()) newodds = K_KartItemOddsBattle[item-1][pos]; @@ -634,14 +660,14 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed) } } - if (first != -1 && second != -1 && !G_BattleGametype()) // calculate 2nd's distance from 1st, for SPB + if (first != -1 && second != -1) // calculate 2nd's distance from 1st, for SPB { secondist = P_AproxDistance(P_AproxDistance(players[first].mo->x - players[second].mo->x, players[first].mo->y - players[second].mo->y), players[first].mo->z - players[second].mo->z) / mapheaderinfo[gamemap-1]->mobj_scale; if (franticitems) - secondist = (15*secondist/14); - secondist = ((28+(8-pingame))*secondist/28); + secondist = (15 * secondist) / 14; + secondist = ((28 + (8-pingame)) * secondist) / 28; } // POWERITEMODDS handles all of the "frantic item" related functionality, for all of our powerful items. @@ -658,97 +684,41 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed) switch (item) { - case KITEM_SNEAKER: - if ((!cv_sneaker.value) && (!modeattacking)) newodds = 0; - break; - case KITEM_ROCKETSNEAKER: - POWERITEMODDS(newodds); - if (!cv_rocketsneaker.value) newodds = 0; - break; case KITEM_INVINCIBILITY: - POWERITEMODDS(newodds); - if ((!cv_invincibility.value) || (pinvin >= 2)) newodds = 0; - break; - case KITEM_BANANA: - if (!cv_banana.value) newodds = 0; - break; - case KITEM_EGGMAN: - if (!cv_eggmanmonitor.value) newodds = 0; - break; - case KITEM_ORBINAUT: - if (!cv_orbinaut.value) newodds = 0; - break; + case KITEM_GROW: + if (pinvin >= 2) + newodds = 0; + else + /* FALLTHRU */ + case KITEM_ROCKETSNEAKER: case KITEM_JAWZ: - POWERITEMODDS(newodds); - if (!cv_jawz.value) newodds = 0; - break; case KITEM_MINE: - POWERITEMODDS(newodds); - if (!cv_mine.value) newodds = 0; - break; case KITEM_BALLHOG: + case KITEM_THUNDERSHIELD: + case KRITEM_TRIPLESNEAKER: + case KRITEM_TRIPLEBANANA: + case KRITEM_TENFOLDBANANA: + case KRITEM_TRIPLEORBINAUT: + case KRITEM_QUADORBINAUT: + case KRITEM_DUALJAWZ: POWERITEMODDS(newodds); - if (!cv_ballhog.value) newodds = 0; break; case KITEM_SPB: //POWERITEMODDS(newodds); - if ((!cv_selfpropelledbomb.value) - || (indirectitemcooldown > 0) - || (pexiting > 0) - || (secondist/distvar < (4+gamespeed))) + if ((indirectitemcooldown > 0) || (pexiting > 0) || (secondist/distvar < 5)) newodds = 0; - newodds *= min((secondist/distvar)-(3+gamespeed), 3); - break; - case KITEM_GROW: - POWERITEMODDS(newodds); - if ((!cv_grow.value) || (pinvin >= 2)) newodds = 0; + else + newodds *= min((secondist/distvar)-4, 3); break; case KITEM_SHRINK: POWERITEMODDS(newodds); - if ((!cv_shrink.value) - || (indirectitemcooldown > 0) - || (pingame-1 <= pexiting)) newodds = 0; - break; - case KITEM_THUNDERSHIELD: - POWERITEMODDS(newodds); - if (!cv_thundershield.value) newodds = 0; - break; - case KITEM_HYUDORO: - if (!cv_hyudoro.value) newodds = 0; - break; - case KITEM_POGOSPRING: - if (!cv_pogospring.value) newodds = 0; - break; - case KITEM_KITCHENSINK: - newodds = 0; // Not obtained via normal means. - break; - case KRITEM_TRIPLESNEAKER: - POWERITEMODDS(newodds); - if (!cv_triplesneaker.value) newodds = 0; - break; - case KRITEM_TRIPLEBANANA: - POWERITEMODDS(newodds); - if (!cv_triplebanana.value) newodds = 0; - break; - case KRITEM_TENFOLDBANANA: - POWERITEMODDS(newodds); - if (!cv_decabanana.value) newodds = 0; - break; - case KRITEM_TRIPLEORBINAUT: - POWERITEMODDS(newodds); - if (!cv_tripleorbinaut.value) newodds = 0; - break; - case KRITEM_QUADORBINAUT: - POWERITEMODDS(newodds); - if (!cv_quadorbinaut.value) newodds = 0; - break; - case KRITEM_DUALJAWZ: - POWERITEMODDS(newodds); - if (!cv_dualjawz.value) newodds = 0; + if ((indirectitemcooldown > 0) || (pingame-1 <= pexiting)) + newodds = 0; break; default: break; } + #undef POWERITEMODDS return newodds; From 5ed4d0256ee876cd352a2e38b7fc9764f422715e Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sat, 12 Jan 2019 05:03:05 -0500 Subject: [PATCH 05/58] spacing & () --- src/k_kart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 049e3c54..ffe30eb5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -806,8 +806,8 @@ static INT32 K_FindUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT3 if (oddsvalid[8]) SETUPDISTTABLE(8,1); if (franticitems) // Frantic items make the distances between everyone artifically higher, for crazier items - pdis = (15*pdis/14); - pdis = ((28+(8-pingame))*pdis/28); + pdis = (15 * pdis) / 14; + pdis = ((28 + (8-pingame)) * pdis) / 28; if (pingame == 1 && oddsvalid[0]) // Record Attack, or just alone useodds = 0; From 2416d7822409b69f6490e5c7d1df07d7654b528e Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sat, 12 Jan 2019 05:12:20 -0500 Subject: [PATCH 06/58] Update comment to be more accurate --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index ffe30eb5..63c9d454 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -673,7 +673,7 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed) // POWERITEMODDS handles all of the "frantic item" related functionality, for all of our powerful items. // First, it multiplies it by 2 if franticitems is true; easy-peasy. // Then, it multiplies it further if there's less than 5 players in game. - // This is done to make low player count races more fair & interesting. (1v1s are basically the same as franticitems false in a normal race) + // This is done to make low player count races more fair & interesting. (2P normal would be about halfway between 8P normal and 8P frantic) // Lastly, it *divides* it by your mashed value, which was determined in K_KartItemRoulette, to punish those who are impatient. #define POWERITEMODDS(odds) \ if (franticitems) \ From c2aa6d4de6f4919ac9d4218844d3cf154cadd4e5 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sun, 13 Jan 2019 14:40:48 +0100 Subject: [PATCH 07/58] Expose some more Kart functions, freeplay and rankings bumpers are now hud stuff you can toggle, + experimental playercmd hook --- src/g_game.c | 8 +++++ src/k_kart.c | 44 +++++++++++++++++--------- src/k_kart.h | 7 +++++ src/lua_baselib.c | 77 +++++++++++++++++++++++++++++++++++++++++++-- src/lua_hook.h | 6 ++++ src/lua_hooklib.c | 42 +++++++++++++++++++++++++ src/lua_hud.h | 2 ++ src/lua_hudlib.c | 17 ++++++++++ src/lua_infolib.c | 13 ++++++++ src/lua_maplib.c | 7 +++++ src/lua_mobjlib.c | 6 ++++ src/lua_playerlib.c | 8 +++++ 12 files changed, 221 insertions(+), 16 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 1e0c7e46..d93a2e9f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1612,10 +1612,18 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } } + // Lua: Allow this hook to overwrite ticcmd. + // Be aware that you can't actually write anything inside the player with this hook, only cmd may be altered. +#ifdef HAVE_BLUA + if (playeringame[consoleplayer]) // safe to assume we can't do anything if consoleplayer isn't in the game. + LUAh_PlayerCmd(player, cmd); +#endif + //Reset away view if a command is given. if ((cmd->forwardmove || cmd->sidemove || cmd->buttons) && displayplayer != consoleplayer && ssplayer == 1) displayplayer = consoleplayer; + } // User has designated that they want diff --git a/src/k_kart.c b/src/k_kart.c index 320105ef..bd4e1394 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1548,7 +1548,7 @@ static void K_RegularVoiceTimers(player_t *player) player->kartstuff[k_tauntvoices] = 4*TICRATE; } -static void K_PlayAttackTaunt(mobj_t *source) +void K_PlayAttackTaunt(mobj_t *source) { sfxenum_t pick = P_RandomKey(2); // Gotta roll the RNG every time this is called for sync reasons boolean tasteful = (!source->player || !source->player->kartstuff[k_tauntvoices]); @@ -1562,7 +1562,7 @@ static void K_PlayAttackTaunt(mobj_t *source) K_TauntVoiceTimers(source->player); } -static void K_PlayBoostTaunt(mobj_t *source) +void K_PlayBoostTaunt(mobj_t *source) { sfxenum_t pick = P_RandomKey(2); // Gotta roll the RNG every time this is called for sync reasons boolean tasteful = (!source->player || !source->player->kartstuff[k_tauntvoices]); @@ -1576,7 +1576,7 @@ static void K_PlayBoostTaunt(mobj_t *source) K_TauntVoiceTimers(source->player); } -static void K_PlayOvertakeSound(mobj_t *source) +void K_PlayOvertakeSound(mobj_t *source) { boolean tasteful = (!source->player || !source->player->kartstuff[k_voices]); @@ -1596,7 +1596,7 @@ static void K_PlayOvertakeSound(mobj_t *source) K_RegularVoiceTimers(source->player); } -static void K_PlayHitEmSound(mobj_t *source) +void K_PlayHitEmSound(mobj_t *source) { if (cv_kartvoices.value) S_StartSound(source, sfx_khitem); @@ -1606,7 +1606,7 @@ static void K_PlayHitEmSound(mobj_t *source) K_RegularVoiceTimers(source->player); } -static void K_PlayPowerGloatSound(mobj_t *source) +void K_PlayPowerGloatSound(mobj_t *source) { if (cv_kartvoices.value) S_StartSound(source, sfx_kgloat); @@ -4670,7 +4670,7 @@ static void K_KartDrift(player_t *player, boolean onground) player->kartstuff[k_driftend] = 0; } - + // Incease/decrease the drift value to continue drifting in that direction if (player->kartstuff[k_spinouttimer] == 0 && player->kartstuff[k_jmp] == 1 && onground && player->kartstuff[k_drift] != 0) @@ -6933,15 +6933,23 @@ static boolean K_drawKartPositionFaces(void) colormap = R_GetTranslationColormap(players[rankplayer[i]].skin, players[rankplayer[i]].mo->color, GTC_CACHE); V_DrawMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, facerankprefix[players[rankplayer[i]].skin], colormap); - if (G_BattleGametype() && players[rankplayer[i]].kartstuff[k_bumper] > 0) + +#ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_battlebumpers)) { - V_DrawMappedPatch(bumperx-2, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[0], colormap); - for (j = 1; j < players[rankplayer[i]].kartstuff[k_bumper]; j++) +#endif + if (G_BattleGametype() && players[rankplayer[i]].kartstuff[k_bumper] > 0) { - bumperx += 5; - V_DrawMappedPatch(bumperx, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[1], colormap); + V_DrawMappedPatch(bumperx-2, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[0], colormap); + for (j = 1; j < players[rankplayer[i]].kartstuff[k_bumper]; j++) + { + bumperx += 5; + V_DrawMappedPatch(bumperx, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[1], colormap); + } } - } +#ifdef HAVE_BLUA + } // A new level of stupidity: checking if lua is enabled to close a bracket. :Fascinating: +#endif } if (i == strank) @@ -7641,7 +7649,10 @@ static void K_drawBattleFullscreen(void) return; } - K_drawKartFreePlay(leveltime); +#ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_freeplay)) +#endif + K_drawKartFreePlay(leveltime); } } @@ -8263,7 +8274,12 @@ void K_drawKartHUD(void) // Draw FREE PLAY. if (isfreeplay && !stplyr->spectator && timeinmap > 113) - K_drawKartFreePlay(leveltime); + { +#ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_freeplay)) +#endif + K_drawKartFreePlay(leveltime); + } if (cv_kartdebugdistribution.value) K_drawDistributionDebugger(); diff --git a/src/k_kart.h b/src/k_kart.h index fed490db..aefc20bb 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -63,6 +63,13 @@ void K_CalculateBattleWanted(void); void K_CheckBumpers(void); void K_CheckSpectateStatus(void); +// sound stuff for lua +void K_PlayAttackTaunt(mobj_t *source); +void K_PlayBoostTaunt(mobj_t *source); +void K_PlayOvertakeSound(mobj_t *source); +void K_PlayHitEmSound(mobj_t *source); +void K_PlayPowerGloatSound(mobj_t *source); + const char *K_GetItemPatch(UINT8 item, boolean tiny); INT32 K_calcSplitFlags(INT32 snapflags); void K_LoadKartHUDGraphics(void); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c862ec26..b0231e39 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -31,9 +31,10 @@ #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors +#include "lua_hook.h" // hook_cmd_running -#define NOHUD if (hud_running) return luaL_error(L, "HUD rendering code should not call this function!"); - +#define NOHUD if (hud_running) return luaL_error(L, "HUD rendering code should not call this function!"); else if (hook_cmd_running) return luaL_error(L, "CMD Building code should not call this function!"); +// Yes technically cmd hook isn't a hud but whatever, this avoids having 2 defines for virtually the same thing. boolean luaL_checkboolean(lua_State *L, int narg) { luaL_checktype(L, narg, LUA_TBOOLEAN); @@ -2141,6 +2142,72 @@ static int lib_gTicsToMilliseconds(lua_State *L) // K_KART //////////// +// Seriously, why weren't those exposed before? +static int lib_kAttackSound(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + if (!mobj->player) + return luaL_error(L, "K_PlayAttackTaunt: mobj_t isn't a player object."); //Nothing bad would happen if we let it run the func, but telling why it ain't doing anything is helpful. + K_PlayAttackTaunt(mobj); + return 0; +} + +static int lib_kBoostSound(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + if (!mobj->player) + return luaL_error(L, "K_PlayBoostTaunt: mobj_t isn't a player object."); //Nothing bad would happen if we let it run the func, but telling why it ain't doing anything is helpful. + K_PlayBoostTaunt(mobj); + return 0; +} + +static int lib_kOvertakeSound(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + if (!mobj->player) + return luaL_error(L, "K_PlayOvertakeSound: mobj_t isn't a player object."); //Nothing bad would happen if we let it run the func, but telling why it ain't doing anything is helpful. + K_PlayOvertakeSound(mobj); + return 0; +} + +static int lib_kHitEmSound(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + if (!mobj->player) + return luaL_error(L, "K_PlayHitEmSound: mobj_t isn't a player object."); //Nothing bad would happen if we let it run the func, but telling why it ain't doing anything is helpful. + K_PlayHitEmSound(mobj); + return 0; +} + +static int lib_kGloatSound(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + if (!mobj->player) + return luaL_error(L, "K_PlayPowerGloatSound: mobj_t isn't a player object."); //Nothing bad would happen if we let it run the func, but telling why it ain't doing anything is helpful. + K_PlayPowerGloatSound(mobj); + return 0; +} + +static int lib_kLossSound(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); // let's require a mobj for consistency with the other functions + sfxenum_t sfx_id; + NOHUD + if (!mobj->player) + return luaL_error(L, "K_PlayLossSound: mobj_t isn't a player object."); + + sfx_id = ((skin_t *)mobj->skin)->soundsid[S_sfx[sfx_klose].skinsound]; + S_StartSound(mobj, sfx_id); + return 0; +} + +// Note: Pain, Death and Victory are already exposed. + static int lib_kGetKartColorByName(lua_State *L) { const char *name = luaL_checkstring(L, 1); @@ -2708,6 +2775,12 @@ static luaL_Reg lib[] = { {"G_TicsToMilliseconds",lib_gTicsToMilliseconds}, // k_kart + {"K_PlayAttackTaunt", lib_kAttackSound}, + {"K_PlayBoostTaunt", lib_kBoostSound}, + {"K_PlayPowerGloatSund", lib_kGloatSound}, + {"K_PlayOvertakeSound", lib_kOvertakeSound}, + {"K_PlayLossSound", lib_kLossSound}, + {"K_PlayHitEmSound", lib_kHitEmSound}, {"K_GetKartColorByName",lib_kGetKartColorByName}, {"K_IsPlayerLosing",lib_kIsPlayerLosing}, {"K_IsPlayerWanted",lib_kIsPlayerWanted}, diff --git a/src/lua_hook.h b/src/lua_hook.h index 2c9cd346..126e7e40 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -50,11 +50,14 @@ enum hook { hook_PlayerSpin, //SRB2KART hook_PlayerExplode, //SRB2KART hook_PlayerSquish, //SRB2KART + hook_PlayerCmd, //SRB2KART hook_MAX // last hook }; extern const char *const hookNames[]; +extern boolean hook_cmd_running; // This is used by PlayerCmd and lua_playerlib to prevent anything from being wirtten to player while we run PlayerCmd. + void LUAh_MapChange(INT16 mapnumber); // Hook for map change (before load) void LUAh_MapLoad(void); // Hook for map load void LUAh_PlayerJoin(int playernum); // Hook for Got_AddPlayer @@ -93,4 +96,7 @@ UINT8 LUAh_ShouldSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // boolean LUAh_PlayerSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SpinPlayer. Allows Lua to execute code and/or overwrite its behavior. boolean LUAh_PlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_ExplodePlayer. Allows Lua to execute code and/or overwrite its behavior. boolean LUAh_PlayerSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SquishPlayer. Allows Lua to execute code and/or overwrite its behavior. + +boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Allows to write to player cmd before the game does anything with them. + #endif diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 13ad03d3..1a1d4ed6 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -61,6 +61,7 @@ const char *const hookNames[hook_MAX+1] = { "PlayerSpin", "PlayerExplode", "PlayerSquish", + "PlayerCmd", NULL }; @@ -877,6 +878,47 @@ boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd) return hooked; } +// Hook for G_BuildTicCmd +boolean hook_cmd_running = false; +boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd) +{ + hook_p hookp; + boolean hooked = false; + if (!gL || !(hooksAvailable[hook_PlayerCmd/8] & (1<<(hook_PlayerCmd%8)))) + return false; + + lua_settop(gL, 0); + + for (hookp = roothook; hookp; hookp = hookp->next) + if (hookp->type == hook_PlayerCmd) + { + hook_cmd_running = true; + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, cmd, META_TICCMD); + } + 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); + hook_cmd_running = false; + } + + lua_settop(gL, 0); + return hooked; +} + // Hook for B_BuildTailsTiccmd by skin name boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) { diff --git a/src/lua_hud.h b/src/lua_hud.h index 3216ab15..4fbbbace 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -20,8 +20,10 @@ enum hud { hud_item, hud_position, hud_minirankings, // Rankings to the left + hud_battlebumpers, // mini rankings battle bumpers. hud_wanted, hud_speedometer, + hud_freeplay, hud_rankings, // Tab rankings hud_MAX diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 353aebb2..ca952a00 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -45,8 +45,10 @@ static const char *const hud_disable_options[] = { "item", "position", "minirankings", // Gametype rankings to the left + "battlerankingsbumpers", // bumper drawer for battle. Useful if you want to make a custom battle gamemode without bumpers being involved. "wanted", "speedometer", + "freeplay", "rankings", NULL}; @@ -482,6 +484,20 @@ static int libd_drawString(lua_State *L) return 0; } +static int libd_drawKartString(lua_State *L) +{ + fixed_t x = luaL_checkinteger(L, 1); + fixed_t y = luaL_checkinteger(L, 2); + const char *str = luaL_checkstring(L, 3); + INT32 flags = luaL_optinteger(L, 4, V_ALLOWLOWERCASE); + + flags &= ~V_PARAMMASK; // Don't let crashes happen. + + HUDONLY + V_DrawKartString(x, y, flags, str); + return 0; +} + static int libd_stringWidth(lua_State *L) { const char *str = luaL_checkstring(L, 1); @@ -593,6 +609,7 @@ static luaL_Reg lib_draw[] = { {"drawFill", libd_drawFill}, {"fadeScreen", libd_fadeScreen}, {"drawString", libd_drawString}, + {"drawKartString", libd_drawKartString}, {"stringWidth", libd_stringWidth}, {"getColormap", libd_getColormap}, {"width", libd_width}, diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 9b22170f..d8659a7e 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -22,6 +22,7 @@ #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors +#include "lua_hook.h" // cmd errors boolean LUA_CallAction(const char *action, mobj_t *actor); state_t *astate; @@ -169,6 +170,8 @@ static int lib_setState(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter states in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter states in BuildCMD code!"); // clear the state to start with, in case of missing table elements memset(state,0,sizeof(state_t)); @@ -378,6 +381,8 @@ static int state_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter states in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter states in BuildCMD code!"); if (fastcmp(field,"sprite")) { value = luaL_checknumber(L, 3); @@ -466,6 +471,8 @@ static int lib_setMobjInfo(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter mobjinfo in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter mobjinfo in BuildCMD code!"); // clear the mobjinfo to start with, in case of missing table elements memset(info,0,sizeof(mobjinfo_t)); @@ -633,6 +640,8 @@ static int mobjinfo_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter mobjinfo in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter mobjinfo in BuildCMD code!"); I_Assert(info != NULL); I_Assert(info >= mobjinfo); @@ -755,6 +764,8 @@ static int lib_setSfxInfo(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter sfxinfo in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter sfxinfo in BuildCMD code!"); lua_pushnil(L); while (lua_next(L, 1)) { @@ -830,6 +841,8 @@ static int sfxinfo_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter S_sfx in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter S_sfx in BuildCMD code!"); I_Assert(sfx != NULL); diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 7599b261..0bb9a99d 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -24,6 +24,7 @@ #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors +#include "lua_hook.h" // cmd errors #include "dehacked.h" #include "fastcmp.h" @@ -484,6 +485,8 @@ static int sector_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter sector_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter sector_t in BuildCMD code!"); switch(field) { @@ -1174,6 +1177,8 @@ static int ffloor_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter ffloor_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter ffloor_t in BuildCMD code!"); switch(field) { @@ -1303,6 +1308,8 @@ static int slope_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter pslope_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter pslope_t in BuildCMD code!"); switch(field) // todo: reorganize this shit { diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 34aba0a3..b56538d0 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -21,6 +21,7 @@ #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors +#include "lua_hook.h" // cmd errors static const char *const array_opt[] ={"iterate",NULL}; @@ -391,6 +392,9 @@ static int mobj_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter mobj_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter mobj_t in BuildCMD code!"); + switch(field) { case mobj_valid: @@ -756,6 +760,8 @@ static int mapthing_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter mapthing_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter mapthing_t in BuildCMD code!"); if(fastcmp(field,"x")) mt->x = (INT16)luaL_checkinteger(L, 3); diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 067124ba..5f136fc1 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -21,6 +21,7 @@ #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors +#include "lua_hook.h" // hook_cmd_running static int lib_iteratePlayers(lua_State *L) { @@ -356,6 +357,9 @@ static int player_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter player_t in BuildCMD code!"); + if (fastcmp(field,"mo")) { mobj_t *newmo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); plr->mo->player = NULL; // remove player pointer from old mobj @@ -667,6 +671,8 @@ static int power_set(lua_State *L) return luaL_error(L, LUA_QL("powertype_t") " cannot be %u", p); if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter player_t in BuildCMD code!"); powers[p] = i; return 0; } @@ -699,6 +705,8 @@ static int kartstuff_set(lua_State *L) return luaL_error(L, LUA_QL("kartstufftype_t") " cannot be %u", ks); if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); + if (hook_cmd_running) + return luaL_error(L, "Do not alter player_t in BuildCMD code!"); kartstuff[ks] = i; return 0; } From 148bd140c23906c5fe6f8666392ab7410d64b206 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sun, 13 Jan 2019 20:16:53 +0100 Subject: [PATCH 08/58] hook_cmd_running around the loop rather than inside --- 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 1a1d4ed6..5a95877e 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -889,10 +889,10 @@ boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd) lua_settop(gL, 0); + hook_cmd_running = true; for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_PlayerCmd) { - hook_cmd_running = true; if (lua_gettop(gL) == 0) { LUA_PushUserdata(gL, player, META_PLAYER); @@ -912,9 +912,9 @@ boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd) if (lua_toboolean(gL, -1)) hooked = true; lua_pop(gL, 1); - hook_cmd_running = false; } + hook_cmd_running = false; lua_settop(gL, 0); return hooked; } From 081872aa857cb57bf87670807597ee98b3009e91 Mon Sep 17 00:00:00 2001 From: toaster Date: Tue, 15 Jan 2019 19:01:55 +0000 Subject: [PATCH 09/58] First steps at implementing a mechanism that allows you to load non-cheaty good-faith mods such as custom characters with no Lua scripting, and play record attack with them. Features a few bad hacks and a few more areas of improvement; I'll try to iron them out before they hit `next` or `master`. --- src/d_main.c | 1 + src/d_netcmd.c | 7 +++++-- src/dehacked.c | 28 +++++++++++++++++++++++++++- src/doomstat.h | 3 +++ src/g_game.c | 44 ++++++++++++++++++++++++++++++++------------ src/lua_script.c | 3 +++ src/m_cheat.c | 1 + src/m_cond.c | 2 +- src/m_menu.c | 4 ++-- src/p_setup.c | 14 +++++++++++--- src/r_things.c | 5 +++-- src/r_things.h | 2 +- src/y_inter.c | 2 +- 13 files changed, 91 insertions(+), 25 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 29a91686..f3539df7 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1253,6 +1253,7 @@ void D_SRB2Main(void) #endif //ifndef DEVELOP mainwadstally = packetsizetally; + majormods = false; cht_Init(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e15ed9aa..d6e78c91 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2214,10 +2214,13 @@ static void Command_Map_f(void) return; } - if (!(netgame || multiplayer) && (!modifiedgame || savemoddata)) + if (!(netgame || multiplayer) && (!majormods || savemoddata)) { if (COM_CheckParm("-force")) + { G_SetGameModified(false); + majormods = true; + } else { CONS_Printf(M_GetText("Sorry, level change disabled in single player.\n")); @@ -4915,7 +4918,7 @@ static void Command_Isgamemodified_f(void) { if (savemoddata) CONS_Printf(M_GetText("modifiedgame is true, but you can save medal and record data in this mod.\n")); - else if (modifiedgame) + else if (/*modifiedgame*/ majormods) CONS_Printf(M_GetText("modifiedgame is true, extras will not be unlocked\n")); else CONS_Printf(M_GetText("modifiedgame is false, you can unlock extras\n")); diff --git a/src/dehacked.c b/src/dehacked.c index e7e1ae69..49d9d107 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -3417,18 +3417,21 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (fastcmp(word, "FREESLOT")) { readfreeslots(f); + majormods = true; continue; } else if (fastcmp(word, "MAINCFG")) { readmaincfg(f); DEH_WriteUndoline(word, "", UNDO_HEADER); + majormods = true; continue; } else if (fastcmp(word, "WIPES")) { readwipes(f); DEH_WriteUndoline(word, "", UNDO_HEADER); + //majormods = true; continue; } word2 = strtok(NULL, " "); @@ -3449,6 +3452,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); + //majormods = true; continue; } if (word2) @@ -3462,12 +3466,14 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) // Read texture from spec file. readtexture(f, word2); DEH_WriteUndoline(word, word2, UNDO_HEADER); + //majormods = true; } else if (fastcmp(word, "PATCH")) { // Read patch from spec file. readpatch(f, word2, wad); DEH_WriteUndoline(word, word2, UNDO_HEADER); + //majormods = true; } else if (fastcmp(word, "THING") || fastcmp(word, "MOBJ") || fastcmp(word, "OBJECT")) { @@ -3481,10 +3487,12 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); + majormods = true; } /* else if (fastcmp(word, "ANIMTEX")) { readAnimTex(f, i); + //majormods = true; }*/ else if (fastcmp(word, "LIGHT")) { @@ -3498,6 +3506,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); + //majormods = true; #endif } else if (fastcmp(word, "SPRITE")) @@ -3513,6 +3522,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); + //majormods = true; #endif } else if (fastcmp(word, "LEVEL")) @@ -3525,7 +3535,11 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) i = M_MapNumber(word2[0], word2[1]); if (i > 0 && i <= NUMMAPS) + { + if (mapheaderinfo[i]) + majormods = true; // only mark as a major mod if it replaces an already-existing mapheaderinfo readlevelheader(f, i); + } else { deh_warning("Level number %d out of range (1 - %d)", i, NUMMAPS); @@ -3543,6 +3557,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); + //majormods = true; -- might have to reconsider in a future update } else if (fastcmp(word, "FRAME") || fastcmp(word, "STATE")) { @@ -3556,6 +3571,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); + majormods = true; } // Added translations to this just in case its re-enabled /* else if (fastcmp(word, "POINTER")) @@ -3578,6 +3594,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) } else deh_warning("pointer (Frame %d) : missing ')'", i); + majormods = true; }*/ else if (fastcmp(word, "SOUND")) { @@ -3591,6 +3608,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); + //majormods = true; -- ...this won't bite me in the ass later, will it? } /* else if (fastcmp(word, "SPRITE")) { @@ -3611,6 +3629,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) } else deh_warning("Sprite %d doesn't exist",i); + //majormods = true; }*/ else if (fastcmp(word, "HUDITEM")) { @@ -3624,6 +3643,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); + //majormods = true; } else if (fastcmp(word, "EMBLEM")) { @@ -3644,6 +3664,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); + majormods = true; } else if (fastcmp(word, "EXTRAEMBLEM")) { @@ -3664,6 +3685,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); + majormods = true; } else if (fastcmp(word, "UNLOCKABLE")) { @@ -3680,6 +3702,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); + majormods = true; } else if (fastcmp(word, "CONDITIONSET")) { @@ -3697,6 +3720,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) } // no undo support for this insanity yet //DEH_WriteUndoline(word, word2, UNDO_HEADER); + majormods = true; } else if (fastcmp(word, "SRB2KART")) { @@ -3743,6 +3767,8 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (clearall || fastcmp(word2, "LEVELS")) clear_levels(); + + majormods = true; } else deh_warning("Unknown word: %s", word); @@ -9737,7 +9763,7 @@ static inline int lib_getenum(lua_State *L) lua_pushboolean(L, devparm); return 1; } else if (fastcmp(word,"modifiedgame")) { - lua_pushboolean(L, modifiedgame && !savemoddata); + lua_pushboolean(L, /*modifiedgame*/ majormods && !savemoddata); return 1; } else if (fastcmp(word,"menuactive")) { lua_pushboolean(L, menuactive); diff --git a/src/doomstat.h b/src/doomstat.h index 6d710e28..9ae2726d 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -54,6 +54,7 @@ extern boolean gamecomplete; // Set if homebrew PWAD stuff has been added. extern boolean modifiedgame; +extern boolean majormods; extern UINT16 mainwads; extern boolean savemoddata; // This mod saves time/emblem data. extern boolean disableSpeedAdjust; // Don't alter the duration of player states if true @@ -280,6 +281,8 @@ typedef struct #define LF2_NIGHTSATTACK 8 ///< Show this map in NiGHTS mode menu #define LF2_NOVISITNEEDED 16 ///< Available in time attack/nights mode without visiting the level +#define LF2_EXISTSHACK 128 ///< Map lump exists; as noted, a single-bit hack that can be freely movable to other variables without concern. + // Save override #define SAVE_NEVER -1 #define SAVE_DEFAULT 0 diff --git a/src/g_game.c b/src/g_game.c index 1e0c7e46..28171e75 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -86,7 +86,8 @@ INT16 lastmapsaved = 0; // Last map we auto-saved at boolean gamecomplete = false; UINT16 mainwads = 0; -boolean modifiedgame; // Set if homebrew PWAD stuff has been added. +boolean modifiedgame = false; // Set if homebrew PWAD stuff has been added. +boolean majormods = false; // Set if Lua/Gameplay SOC/replacement map has been added. boolean savemoddata = false; UINT8 paused; UINT8 modeattacking = ATTACKING_NONE; @@ -5918,6 +5919,19 @@ void G_DoPlayDemo(char *defdemoname) return; } + // Skin not loaded? + if (!SetPlayerSkin(0, skin)) + { + snprintf(msg, 1024, M_GetText("%s features a character that is not loaded.\n"), pdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + M_StartMessage(msg, NULL, MM_NOTHING); + Z_Free(pdemoname); + Z_Free(demobuffer); + demoplayback = false; + titledemo = false; + return; + } + Z_Free(pdemoname); memset(&oldcmd,0,sizeof(oldcmd)); @@ -5949,9 +5963,6 @@ void G_DoPlayDemo(char *defdemoname) P_SetRandSeed(randseed); G_InitNew(false, G_BuildMapName(gamemap), true, true); // Doesn't matter whether you reset or not here, given changes to resetplayer. - // Set skin - SetPlayerSkin(0, skin); - // Set color for (i = 0; i < MAXSKINCOLORS; i++) if (!stricmp(KartColor_Names[i],color)) // SRB2kart @@ -6146,6 +6157,22 @@ void G_AddGhost(char *defdemoname) return; } + gh->oldmo->skin = &skins[0]; + for (i = 0; i < numskins; i++) + if (!stricmp(skins[i].name,skin)) + { + gh->oldmo->skin = &skins[i]; + break; + } + + if (i == numskins) + { + CONS_Alert(CONS_NOTICE, M_GetText("Failed to add ghost %s: Invalid character.\n"), pdemoname); + Z_Free(pdemoname); + Z_Free(buffer); + return; + } + gh = Z_Calloc(sizeof(demoghost), PU_LEVEL, NULL); gh->next = ghosts; gh->buffer = buffer; @@ -6191,14 +6218,7 @@ void G_AddGhost(char *defdemoname) gh->oldmo.z = gh->mo->z; // Set skin - gh->mo->skin = &skins[0]; - for (i = 0; i < numskins; i++) - if (!stricmp(skins[i].name,skin)) - { - gh->mo->skin = &skins[i]; - break; - } - gh->oldmo.skin = gh->mo->skin; + gh->mo.skin = gh->oldmo->skin; // Set color gh->mo->color = ((skin_t*)gh->mo->skin)->prefcolor; diff --git a/src/lua_script.c b/src/lua_script.c index 34a26052..d7c4a160 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -212,6 +212,9 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump) LUA_LoadFile(&f, name); // actually load file! + // Okay, we've modified the game beyond the point of no return. + majormods = true; + free(name); Z_Free(f.data); } diff --git a/src/m_cheat.c b/src/m_cheat.c index 9c53f901..499dac28 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -1268,6 +1268,7 @@ void Command_ObjectPlace_f(void) REQUIRE_NOULTIMATE; G_SetGameModified(multiplayer); + majormods = true; // Entering objectplace? if (!objectplacing) diff --git a/src/m_cond.c b/src/m_cond.c index 35eccd1c..b0e49a68 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -385,7 +385,7 @@ UINT8 M_UpdateUnlockablesAndExtraEmblems(boolean force) char cechoText[992] = ""; UINT8 cechoLines = 0; - if (modifiedgame && !savemoddata + if (/*modifiedgame*/ majormods && !savemoddata && !force) // SRB2Kart: for enabling unlocks online in modified servers return false; diff --git a/src/m_menu.c b/src/m_menu.c index 8c0e6079..03cc8002 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2773,10 +2773,10 @@ boolean M_Responder(event_t *ev) || (currentMenu->menuitems[itemOn].status & IT_TYPE)==IT_SUBMENU) && (currentMenu->menuitems[itemOn].status & IT_CALLTYPE)) { - if (((currentMenu->menuitems[itemOn].status & IT_CALLTYPE) & IT_CALL_NOTMODIFIED) && modifiedgame && !savemoddata) + if (((currentMenu->menuitems[itemOn].status & IT_CALLTYPE) & IT_CALL_NOTMODIFIED) && /*modifiedgame*/ majormods && !savemoddata) { S_StartSound(NULL, sfx_menu1); - M_StartMessage(M_GetText("This cannot be done with add-ons\nor in a cheated game.\n\n(Press a key)\n"), NULL, MM_NOTHING); + M_StartMessage(M_GetText("This cannot be done with complex add-ons\nor in a cheated game.\n\n(Press a key)\n"), NULL, MM_NOTHING); return true; } } diff --git a/src/p_setup.c b/src/p_setup.c index 49b22184..0a59a2a9 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -234,7 +234,7 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) DEH_WriteUndoline("LEVELFLAGS", va("%d", mapheaderinfo[num]->levelflags), UNDO_NONE); mapheaderinfo[num]->levelflags = 0; DEH_WriteUndoline("MENUFLAGS", va("%d", mapheaderinfo[num]->menuflags), UNDO_NONE); - mapheaderinfo[num]->menuflags = 0; + mapheaderinfo[num]->menuflags = (mainwads ? 0 : LF2_EXISTSHACK); // see p_setup.c - prevents replacing maps in addons with easier versions // TODO grades support for delfile (pfft yeah right) P_DeleteGrades(num); // SRB2Kart @@ -1120,7 +1120,7 @@ static inline void P_SpawnEmblems(void) static void P_SpawnSecretItems(boolean loademblems) { // Now let's spawn those funky emblem things! Tails 12-08-2002 - if (netgame || multiplayer || (modifiedgame && !savemoddata)) // No cheating!! + if (netgame || multiplayer || (/*modifiedgame*/ majormods && !savemoddata)) // No cheating!! return; if (loademblems) @@ -3272,7 +3272,7 @@ boolean P_SetupLevel(boolean skipprecip) nextmapoverride = 0; skipstats = false; - if (!(netgame || multiplayer) && (!modifiedgame || savemoddata)) + if (!(netgame || multiplayer) && (/*!modifiedgame*/ !majormods || savemoddata)) mapvisited[gamemap-1] |= MV_VISITED; levelloading = false; @@ -3455,6 +3455,14 @@ boolean P_AddWadFile(const char *wadfilename) continue; num = (INT16)M_MapNumber(name[3], name[4]); + // we want to record whether this map exists. if it doesn't have a header, we can assume it's not relephant + if (num <= NUMMAPS && mapheaderinfo[num-1]) + { + if (mapheaderinfo[num-1]->menuflags & LF2_EXISTSHACK) + majormods = true; // oops, double-defined - no record attack privileges for you + mapheaderinfo[num-1]->menuflags |= LF2_EXISTSHACK; + } + //If you replaced the map you're on, end the level when done. if (num == gamemap) replacedcurrentmap = true; diff --git a/src/r_things.c b/src/r_things.c index 1825d2d9..a4720063 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2635,7 +2635,7 @@ INT32 R_SkinAvailable(const char *name) } // network code calls this when a 'skin change' is received -void SetPlayerSkin(INT32 playernum, const char *skinname) +boolean SetPlayerSkin(INT32 playernum, const char *skinname) { INT32 i; player_t *player = &players[playernum]; @@ -2646,7 +2646,7 @@ void SetPlayerSkin(INT32 playernum, const char *skinname) if (stricmp(skins[i].name, skinname) == 0) { SetPlayerSkinByNum(playernum, i); - return; + return true; } } @@ -2656,6 +2656,7 @@ void SetPlayerSkin(INT32 playernum, const char *skinname) CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); SetPlayerSkinByNum(playernum, 0); + return false; } // Same as SetPlayerSkin, but uses the skin #. diff --git a/src/r_things.h b/src/r_things.h index a8635034..bc51f711 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -194,7 +194,7 @@ typedef struct drawnode_s extern INT32 numskins; extern skin_t skins[MAXSKINS + 1]; -void SetPlayerSkin(INT32 playernum,const char *skinname); +boolean SetPlayerSkin(INT32 playernum,const char *skinname); void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002 INT32 R_SkinAvailable(const char *name); void R_AddSkins(UINT16 wadnum); diff --git a/src/y_inter.c b/src/y_inter.c index 021519e3..046d6d6d 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -786,7 +786,7 @@ void Y_StartIntermission(void) } case int_race: // (time-only race) { - if ((!modifiedgame || savemoddata) && !multiplayer && !demoplayback) // remove this once we have a proper time attack screen + if ((/*!modifiedgame*/ !majormods || savemoddata) && !multiplayer && !demoplayback) // remove this once we have a proper time attack screen { // Update visitation flags mapvisited[gamemap-1] |= MV_BEATEN; From a7445a7b71b70c51f17a0e5acedb5dd2125e3847 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 16 Jan 2019 15:27:23 +0000 Subject: [PATCH 10/58] Woops, didn't commit the most up-to-date g_game.c originally (old one didn't compile) --- src/g_game.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 28171e75..a1ca4e73 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -5922,7 +5922,7 @@ void G_DoPlayDemo(char *defdemoname) // Skin not loaded? if (!SetPlayerSkin(0, skin)) { - snprintf(msg, 1024, M_GetText("%s features a character that is not loaded.\n"), pdemoname); + snprintf(msg, 1024, M_GetText("%s features a character that is not currently loaded.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, NULL, MM_NOTHING); Z_Free(pdemoname); @@ -6157,11 +6157,11 @@ void G_AddGhost(char *defdemoname) return; } - gh->oldmo->skin = &skins[0]; + gh->oldmo.skin = &skins[0]; for (i = 0; i < numskins; i++) if (!stricmp(skins[i].name,skin)) { - gh->oldmo->skin = &skins[i]; + gh->oldmo.skin = &skins[i]; break; } @@ -6218,7 +6218,7 @@ void G_AddGhost(char *defdemoname) gh->oldmo.z = gh->mo->z; // Set skin - gh->mo.skin = gh->oldmo->skin; + gh->mo->skin = gh->oldmo.skin; // Set color gh->mo->color = ((skin_t*)gh->mo->skin)->prefcolor; From 2f2d3768d55c2551017fca4fc4ef57803d06f2ff Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 17 Jan 2019 20:51:41 +0000 Subject: [PATCH 11/58] * Increased leniency for SOC wrt "major mods". * If your file defines state and object freeslots in SOC, you are allowed to modify those freeslots IN ANY SOC SCRIPT IN THE SAME FILE without being marked as a "major mod". * If your file contains broken unlockables/emblems that don't actually have effect for any reason, it's not counted as a "major mod". * Added add-ons menu message for adding a "major mod". --- src/dehacked.c | 36 +++++++++++++++++++++++++++++------- src/dehacked.h | 2 ++ src/m_menu.c | 15 +++++++++++++-- src/w_wad.c | 2 ++ 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 49d9d107..2e8ce562 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -602,6 +602,14 @@ done: Z_Free(s); } +static int freeslotusage[2][2] = {{0, 0}, {0, 0}}; // [S_, MT_][max, previous .wad's max] + +void DEH_UpdateMaxFreeslots(void) +{ + freeslotusage[0][1] = freeslotusage[0][0]; + freeslotusage[1][1] = freeslotusage[1][0]; +} + // TODO: Figure out how to do undolines for this.... // TODO: Warnings for running out of freeslots static void readfreeslots(MYFILE *f) @@ -664,6 +672,7 @@ static void readfreeslots(MYFILE *f) if (!FREE_STATES[i]) { FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); strcpy(FREE_STATES[i],word); + freeslotusage[0][0]++; break; } } @@ -673,6 +682,7 @@ static void readfreeslots(MYFILE *f) if (!FREE_MOBJS[i]) { FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); strcpy(FREE_MOBJS[i],word); + freeslotusage[1][0]++; break; } } @@ -3417,7 +3427,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (fastcmp(word, "FREESLOT")) { readfreeslots(f); - majormods = true; + //majormods = true; continue; } else if (fastcmp(word, "MAINCFG")) @@ -3480,14 +3490,17 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_mobjtype(word2); // find a thing by name if (i < NUMMOBJTYPES && i >= 0) + { + if (i < (MT_FIRSTFREESLOT+freeslotusage[1][1])) + majormods = true; // affecting something earlier than the first freeslot allocated in this .wad? DENIED readthing(f, i); + } else { deh_warning("Thing %d out of range (0 - %d)", i, NUMMOBJTYPES-1); ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - majormods = true; } /* else if (fastcmp(word, "ANIMTEX")) { @@ -3564,14 +3577,17 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_state(word2); // find a state by name if (i < NUMSTATES && i >= 0) + { + if (i < (S_FIRSTFREESLOT+freeslotusage[0][1])) + majormods = true; // affecting something earlier than the first freeslot allocated in this .wad? DENIED readframe(f, i); + } else { deh_warning("Frame %d out of range (0 - %d)", i, NUMSTATES-1); ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - majormods = true; } // Added translations to this just in case its re-enabled /* else if (fastcmp(word, "POINTER")) @@ -3657,6 +3673,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (numemblems < i) numemblems = i; reademblemdata(f, i); + majormods = true; } else { @@ -3664,7 +3681,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - majormods = true; } else if (fastcmp(word, "EXTRAEMBLEM")) { @@ -3678,6 +3694,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (numextraemblems < i) numextraemblems = i; readextraemblemdata(f, i); + majormods = true; } else { @@ -3685,7 +3702,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - majormods = true; } else if (fastcmp(word, "UNLOCKABLE")) { @@ -3695,14 +3711,16 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } else if (i > 0 && i <= MAXUNLOCKABLES) + { readunlockable(f, i - 1); + majormods = true; + } else { deh_warning("Unlockable number %d out of range (1 - %d)", i, MAXUNLOCKABLES); ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - majormods = true; } else if (fastcmp(word, "CONDITIONSET")) { @@ -3712,7 +3730,10 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } else if (i > 0 && i <= MAXCONDITIONSETS) + { readconditionset(f, (UINT8)i); + majormods = true; + } else { deh_warning("Condition set number %d out of range (1 - %d)", i, MAXCONDITIONSETS); @@ -3720,7 +3741,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) } // no undo support for this insanity yet //DEH_WriteUndoline(word, word2, UNDO_HEADER); - majormods = true; } else if (fastcmp(word, "SRB2KART")) { @@ -9381,6 +9401,7 @@ static inline int lib_freeslot(lua_State *L) CONS_Printf("State S_%s allocated.\n",word); FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); strcpy(FREE_STATES[i],word); + freeslotusage[0][0]++; lua_pushinteger(L, i); r++; break; @@ -9396,6 +9417,7 @@ static inline int lib_freeslot(lua_State *L) CONS_Printf("MobjType MT_%s allocated.\n",word); FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); strcpy(FREE_MOBJS[i],word); + freeslotusage[1][0]++; lua_pushinteger(L, i); r++; break; diff --git a/src/dehacked.h b/src/dehacked.h index 683fe7d9..0d6cc902 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -37,6 +37,8 @@ void DEH_UnloadDehackedWad(UINT16 wad); void DEH_LoadDehackedLump(lumpnum_t lumpnum); void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump); +void DEH_UpdateMaxFreeslots(void); + void DEH_Check(void); fixed_t get_number(const char *word); diff --git a/src/m_menu.c b/src/m_menu.c index 03cc8002..e68027c6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4551,9 +4551,14 @@ static char *M_AddonsHeaderPath(void) #define CLEARNAME Z_Free(refreshdirname);\ refreshdirname = NULL +static boolean prevmajormods = false; + static void M_AddonsClearName(INT32 choice) { - CLEARNAME; + if (majormods == prevmajormods || savemoddata) + { + CLEARNAME; + } M_StopMessage(choice); } @@ -4566,7 +4571,7 @@ static boolean M_AddonsRefresh(void) return true; } - if (refreshdirmenu & REFRESHDIR_ADDFILE) + if ((refreshdirmenu & REFRESHDIR_ADDFILE) || (majormods != prevmajormods && !savemoddata)) { char *message = NULL; @@ -4583,6 +4588,12 @@ static boolean M_AddonsRefresh(void) S_StartSound(NULL, sfx_s224); message = va("%c%s\x80\nA file was loaded with %s.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname, ((refreshdirmenu & REFRESHDIR_ERROR) ? "errors" : "warnings")); } + else if (majormods != prevmajormods && !savemoddata) + { + S_StartSound(NULL, sfx_s221); + message = va("%c%s\x80\nGameplay has now been modified.\nIf you want to play record attack mode, restart the game to clear existing add-ons.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); + prevmajormods = majormods; + } if (message) { diff --git a/src/w_wad.c b/src/w_wad.c index 63bee97d..58a65191 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -799,6 +799,8 @@ UINT16 W_InitFile(const char *filename) break; } + DEH_UpdateMaxFreeslots(); + W_InvalidateLumpnumCache(); return wadfile->numlumps; } From 66273898b7233bb33ce6145563c2b93361643903 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 17 Jan 2019 22:01:28 +0000 Subject: [PATCH 12/58] * Refactor all instances of `majormods = true;` to route through G_SetGameModified, and catch a few spots I missed in the process. * Make G_SetGameModified only console-print for major mods. * Add amnesty to "major mod" detection while loading files with custom savedatas. * Improved the console prints for command `isgamemodified`. --- src/d_main.c | 4 +-- src/d_netcmd.c | 23 ++++++++--------- src/d_netfil.c | 2 +- src/dehacked.c | 66 +++++++++++++++++++++++------------------------- src/filesrch.h | 3 ++- src/g_game.c | 12 ++++++--- src/g_game.h | 2 +- src/lua_script.c | 2 +- src/m_cheat.c | 13 +++++----- src/m_menu.c | 14 ++++++---- src/p_setup.c | 4 ++- src/w_wad.c | 3 +++ 12 files changed, 80 insertions(+), 68 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index f3539df7..fd85770c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1162,7 +1162,7 @@ void D_SRB2Main(void) if (s) // Check for NULL? { if (!W_VerifyNMUSlumps(s)) - G_SetGameModified(true); + G_SetGameModified(true, false); D_AddFile(s); } } @@ -1189,7 +1189,7 @@ void D_SRB2Main(void) else { if (!M_CheckParm("-server")) - G_SetGameModified(true); + G_SetGameModified(true, true); autostart = true; } } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index d6e78c91..244e3058 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2218,8 +2218,7 @@ static void Command_Map_f(void) { if (COM_CheckParm("-force")) { - G_SetGameModified(false); - majormods = true; + G_SetGameModified(false, true); } else { @@ -3789,7 +3788,7 @@ static void Command_RunSOC(void) if (!P_RunSOC(fn)) CONS_Printf(M_GetText("Could not find SOC.\n")); else - G_SetGameModified(multiplayer); + G_SetGameModified(multiplayer, false); return; } @@ -3843,7 +3842,7 @@ static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum) } P_RunSOC(filename); - G_SetGameModified(true); + G_SetGameModified(true, false); } /** Adds a pwad at runtime. @@ -3880,7 +3879,7 @@ static void Command_Addfile(void) CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); return; } - G_SetGameModified(multiplayer); + G_SetGameModified(multiplayer, false); } // Add file on your client directly if it is trivial, or you aren't in a netgame. @@ -4126,7 +4125,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) return; } - G_SetGameModified(true); + G_SetGameModified(true, false); } static void Command_ListWADS_f(void) @@ -4483,7 +4482,7 @@ static void Ringslinger_OnChange(void) } if (cv_ringslinger.value) // Only if it's been turned on - G_SetGameModified(multiplayer); + G_SetGameModified(multiplayer, true); } static void Gravity_OnChange(void) @@ -4504,7 +4503,7 @@ static void Gravity_OnChange(void) #endif if (!CV_IsSetToDefault(&cv_gravity)) - G_SetGameModified(multiplayer); + G_SetGameModified(multiplayer, true); gravity = cv_gravity.value; } @@ -4900,7 +4899,7 @@ static void Fishcake_OnChange(void) // so don't make modifiedgame always on! if (cv_debug) { - G_SetGameModified(multiplayer); + G_SetGameModified(multiplayer, true); } else if (cv_debug != cv_fishcake.value) @@ -4917,11 +4916,11 @@ static void Fishcake_OnChange(void) static void Command_Isgamemodified_f(void) { if (savemoddata) - CONS_Printf(M_GetText("modifiedgame is true, but you can save medal and record data in this mod.\n")); + CONS_Printf(M_GetText("The game is modified, but you can save medal and record data in this add-on.\n")); else if (/*modifiedgame*/ majormods) - CONS_Printf(M_GetText("modifiedgame is true, extras will not be unlocked\n")); + CONS_Printf(M_GetText("Major add-ons have been loaded, so you cannot play record attack.\n")); else - CONS_Printf(M_GetText("modifiedgame is false, you can unlock extras\n")); + CONS_Printf(M_GetText("No major add-ons are loaded. You can play record attack, earn medals and unlock extras.\n")); } static void Command_Cheats_f(void) diff --git a/src/d_netfil.c b/src/d_netfil.c index c7cfdbc1..99a05840 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -426,7 +426,7 @@ void CL_LoadServerFiles(void) else if (fileneeded[i].status == FS_FOUND) { P_AddWadFile(fileneeded[i].filename); - G_SetGameModified(true); + G_SetGameModified(true, false); fileneeded[i].status = FS_OPEN; } else if (fileneeded[i].status == FS_MD5SUMBAD) diff --git a/src/dehacked.c b/src/dehacked.c index 2e8ce562..4edeb987 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -21,6 +21,7 @@ #include "w_wad.h" #include "m_menu.h" #include "m_misc.h" +#include "filesrch.h" // for refreshdirmenu #include "f_finale.h" #include "dehacked.h" #include "st_stuff.h" @@ -79,8 +80,6 @@ static powertype_t get_power(const char *word); boolean deh_loaded = false; static int dbg_line; -static boolean gamedataadded = false; - #ifdef DELFILE typedef struct undehacked_s { @@ -3149,6 +3148,7 @@ static void readmaincfg(MYFILE *f) strlcpy(gamedatafilename, word2, sizeof (gamedatafilename)); strlwr(gamedatafilename); savemoddata = true; + majormods = false; // Also save a time attack folder filenamelen = strlen(gamedatafilename)-4; // Strip off the extension @@ -3161,7 +3161,7 @@ static void readmaincfg(MYFILE *f) // can't use sprintf since there is %u in savegamename strcatbf(savegamename, srb2home, PATHSEP); - gamedataadded = true; + refreshdirmenu |= REFRESHDIR_GAMEDATA; } else if (fastcmp(word, "RESETDATA")) { @@ -3392,8 +3392,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) for (i = 0; i < NUMSFX; i++) savesfxnames[i] = S_sfx[i].name; - gamedataadded = false; - // it doesn't test the version of SRB2 and version of dehacked file dbg_line = -1; // start at -1 so the first line is 0. while (!myfeof(f)) @@ -3427,21 +3425,21 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (fastcmp(word, "FREESLOT")) { readfreeslots(f); - //majormods = true; + //G_SetGameModified(multiplayer, true); continue; } else if (fastcmp(word, "MAINCFG")) { + G_SetGameModified(multiplayer, true); readmaincfg(f); DEH_WriteUndoline(word, "", UNDO_HEADER); - majormods = true; continue; } else if (fastcmp(word, "WIPES")) { readwipes(f); DEH_WriteUndoline(word, "", UNDO_HEADER); - //majormods = true; + //G_SetGameModified(multiplayer, true); continue; } word2 = strtok(NULL, " "); @@ -3462,7 +3460,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - //majormods = true; + //G_SetGameModified(multiplayer, true); continue; } if (word2) @@ -3476,14 +3474,14 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) // Read texture from spec file. readtexture(f, word2); DEH_WriteUndoline(word, word2, UNDO_HEADER); - //majormods = true; + //G_SetGameModified(multiplayer, true); } else if (fastcmp(word, "PATCH")) { // Read patch from spec file. readpatch(f, word2, wad); DEH_WriteUndoline(word, word2, UNDO_HEADER); - //majormods = true; + //G_SetGameModified(multiplayer, true); } else if (fastcmp(word, "THING") || fastcmp(word, "MOBJ") || fastcmp(word, "OBJECT")) { @@ -3492,7 +3490,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (i < NUMMOBJTYPES && i >= 0) { if (i < (MT_FIRSTFREESLOT+freeslotusage[1][1])) - majormods = true; // affecting something earlier than the first freeslot allocated in this .wad? DENIED + G_SetGameModified(multiplayer, true); // affecting something earlier than the first freeslot allocated in this .wad? DENIED readthing(f, i); } else @@ -3505,7 +3503,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) /* else if (fastcmp(word, "ANIMTEX")) { readAnimTex(f, i); - //majormods = true; + //G_SetGameModified(multiplayer, true); }*/ else if (fastcmp(word, "LIGHT")) { @@ -3519,7 +3517,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - //majormods = true; + //G_SetGameModified(multiplayer, true); #endif } else if (fastcmp(word, "SPRITE")) @@ -3535,7 +3533,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - //majormods = true; + //G_SetGameModified(multiplayer, true); #endif } else if (fastcmp(word, "LEVEL")) @@ -3550,7 +3548,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (i > 0 && i <= NUMMAPS) { if (mapheaderinfo[i]) - majormods = true; // only mark as a major mod if it replaces an already-existing mapheaderinfo + G_SetGameModified(multiplayer, true); // only mark as a major mod if it replaces an already-existing mapheaderinfo readlevelheader(f, i); } else @@ -3570,7 +3568,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - //majormods = true; -- might have to reconsider in a future update + //G_SetGameModified(multiplayer, true); -- might have to reconsider in a future update } else if (fastcmp(word, "FRAME") || fastcmp(word, "STATE")) { @@ -3579,7 +3577,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (i < NUMSTATES && i >= 0) { if (i < (S_FIRSTFREESLOT+freeslotusage[0][1])) - majormods = true; // affecting something earlier than the first freeslot allocated in this .wad? DENIED + G_SetGameModified(multiplayer, true); // affecting something earlier than the first freeslot allocated in this .wad? DENIED readframe(f, i); } else @@ -3610,7 +3608,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) } else deh_warning("pointer (Frame %d) : missing ')'", i); - majormods = true; + G_SetGameModified(multiplayer, true); }*/ else if (fastcmp(word, "SOUND")) { @@ -3624,7 +3622,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - //majormods = true; -- ...this won't bite me in the ass later, will it? + //G_SetGameModified(multiplayer, true); -- ...this won't bite me in the ass later, will it? } /* else if (fastcmp(word, "SPRITE")) { @@ -3645,7 +3643,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) } else deh_warning("Sprite %d doesn't exist",i); - //majormods = true; + //G_SetGameModified(multiplayer, true); }*/ else if (fastcmp(word, "HUDITEM")) { @@ -3659,11 +3657,11 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - //majormods = true; + //G_SetGameModified(multiplayer, true); } else if (fastcmp(word, "EMBLEM")) { - if (!gamedataadded) + if (!(refreshdirmenu & REFRESHDIR_GAMEDATA)) { deh_warning("You must define a custom gamedata to use \"%s\"", word); ignorelines(f); @@ -3673,7 +3671,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (numemblems < i) numemblems = i; reademblemdata(f, i); - majormods = true; + G_SetGameModified(multiplayer, true); } else { @@ -3684,7 +3682,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) } else if (fastcmp(word, "EXTRAEMBLEM")) { - if (!gamedataadded) + if (!(refreshdirmenu & REFRESHDIR_GAMEDATA)) { deh_warning("You must define a custom gamedata to use \"%s\"", word); ignorelines(f); @@ -3694,7 +3692,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (numextraemblems < i) numextraemblems = i; readextraemblemdata(f, i); - majormods = true; + G_SetGameModified(multiplayer, true); } else { @@ -3705,7 +3703,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) } else if (fastcmp(word, "UNLOCKABLE")) { - if (!gamedataadded) + if (!(refreshdirmenu & REFRESHDIR_GAMEDATA)) { deh_warning("You must define a custom gamedata to use \"%s\"", word); ignorelines(f); @@ -3713,7 +3711,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) else if (i > 0 && i <= MAXUNLOCKABLES) { readunlockable(f, i - 1); - majormods = true; + G_SetGameModified(multiplayer, true); } else { @@ -3724,7 +3722,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) } else if (fastcmp(word, "CONDITIONSET")) { - if (!gamedataadded) + if (!(refreshdirmenu & REFRESHDIR_GAMEDATA)) { deh_warning("You must define a custom gamedata to use \"%s\"", word); ignorelines(f); @@ -3732,7 +3730,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) else if (i > 0 && i <= MAXCONDITIONSETS) { readconditionset(f, (UINT8)i); - majormods = true; + G_SetGameModified(multiplayer, true); } else { @@ -3761,7 +3759,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) { boolean clearall = (fastcmp(word2, "ALL")); - if (!gamedataadded) + if (!(refreshdirmenu & REFRESHDIR_GAMEDATA)) { deh_warning("You must define a custom gamedata to use \"%s\"", word); continue; @@ -3788,7 +3786,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (clearall || fastcmp(word2, "LEVELS")) clear_levels(); - majormods = true; + G_SetGameModified(multiplayer, true); } else deh_warning("Unknown word: %s", word); @@ -3800,8 +3798,8 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("No word in this line: %s", s); } // end while - if (gamedataadded) - G_LoadGameData(); + /*if (gamedataadded) -- REFRESHDIR_GAMEDATA murdered this + G_LoadGameData();*/ dbg_line = -1; if (deh_num_warning) diff --git a/src/filesrch.h b/src/filesrch.h index 4186271b..01a52848 100644 --- a/src/filesrch.h +++ b/src/filesrch.h @@ -88,7 +88,8 @@ typedef enum REFRESHDIR_WARNING = 4, REFRESHDIR_ERROR = 8, REFRESHDIR_NOTLOADED = 16, - REFRESHDIR_MAX = 32 + REFRESHDIR_MAX = 32, + REFRESHDIR_GAMEDATA = 64 } refreshdir_enum; void closefilemenu(boolean validsize); diff --git a/src/g_game.c b/src/g_game.c index a1ca4e73..789c5cc5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -16,6 +16,7 @@ #include "d_main.h" #include "d_player.h" #include "f_finale.h" +#include "filesrch.h" // for refreshdirmenu #include "p_setup.h" #include "p_saveg.h" #include "i_system.h" @@ -753,16 +754,21 @@ void G_SetNightsRecords(void) }*/ // for consistency among messages: this modifies the game and removes savemoddata. -void G_SetGameModified(boolean silent) +void G_SetGameModified(boolean silent, boolean major) { - if (modifiedgame && !savemoddata) + if ((majormods && modifiedgame && !savemoddata) || (refreshdirmenu & REFRESHDIR_GAMEDATA)) // new gamedata amnesty? return; modifiedgame = true; savemoddata = false; + if (!major) + return; + + majormods = true; + if (!silent) - CONS_Alert(CONS_NOTICE, M_GetText("Game must be restarted to record statistics.\n")); + CONS_Alert(CONS_NOTICE, M_GetText("Game must be restarted to play record attack.\n")); // If in record attack recording, cancel it. if (modeattacking) diff --git a/src/g_game.h b/src/g_game.h index 14dc12d0..793cfe95 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -227,7 +227,7 @@ boolean G_GetRetryFlag(void); void G_LoadGameData(void); void G_LoadGameSettings(void); -void G_SetGameModified(boolean silent); +void G_SetGameModified(boolean silent, boolean major); void G_SetGamestate(gamestate_t newstate); diff --git a/src/lua_script.c b/src/lua_script.c index d7c4a160..1f87d33e 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -213,7 +213,7 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump) LUA_LoadFile(&f, name); // actually load file! // Okay, we've modified the game beyond the point of no return. - majormods = true; + G_SetGameModified(multiplayer, true); free(name); Z_Free(f.data); diff --git a/src/m_cheat.c b/src/m_cheat.c index 499dac28..acb53b22 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -121,7 +121,7 @@ static UINT8 cheatf_devmode(void) S_StartSound(0, sfx_itemup); // Just unlock all the things and turn on -debug and console devmode. - G_SetGameModified(false); + G_SetGameModified(false, false); // might need to revist the latter later for (i = 0; i < MAXUNLOCKABLES; i++) unlockables[i].unlocked = true; devparm = true; @@ -295,7 +295,7 @@ void Command_CheatNoClip_f(void) plyr->pflags ^= PF_NOCLIP; CONS_Printf(M_GetText("No Clipping %s\n"), plyr->pflags & PF_NOCLIP ? M_GetText("On") : M_GetText("Off")); - G_SetGameModified(multiplayer); + G_SetGameModified(multiplayer, true); } void Command_CheatGod_f(void) @@ -310,7 +310,7 @@ void Command_CheatGod_f(void) plyr->pflags ^= PF_GODMODE; CONS_Printf(M_GetText("Sissy Mode %s\n"), plyr->pflags & PF_GODMODE ? M_GetText("On") : M_GetText("Off")); - G_SetGameModified(multiplayer); + G_SetGameModified(multiplayer, true); } void Command_CheatNoTarget_f(void) @@ -325,7 +325,7 @@ void Command_CheatNoTarget_f(void) plyr->pflags ^= PF_INVIS; CONS_Printf(M_GetText("SEP Field %s\n"), plyr->pflags & PF_INVIS ? M_GetText("On") : M_GetText("Off")); - G_SetGameModified(multiplayer); + G_SetGameModified(multiplayer, true); } void Command_Scale_f(void) @@ -727,7 +727,7 @@ void Command_Devmode_f(void) return; } - G_SetGameModified(multiplayer); + G_SetGameModified(multiplayer, true); } /*void Command_Setrings_f(void) @@ -1267,8 +1267,7 @@ void Command_ObjectPlace_f(void) REQUIRE_SINGLEPLAYER; REQUIRE_NOULTIMATE; - G_SetGameModified(multiplayer); - majormods = true; + G_SetGameModified(multiplayer, true); // Entering objectplace? if (!objectplacing) diff --git a/src/m_menu.c b/src/m_menu.c index e68027c6..b1d9ba09 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4555,7 +4555,7 @@ static boolean prevmajormods = false; static void M_AddonsClearName(INT32 choice) { - if (majormods == prevmajormods || savemoddata) + if (!majormods || prevmajormods) { CLEARNAME; } @@ -4568,10 +4568,14 @@ static boolean M_AddonsRefresh(void) if ((refreshdirmenu & REFRESHDIR_NORMAL) && !preparefilemenu(true)) { UNEXIST; + CLEARNAME; return true; } - if ((refreshdirmenu & REFRESHDIR_ADDFILE) || (majormods != prevmajormods && !savemoddata)) + if (!majormods && prevmajormods) + prevmajormods = false; + + if ((refreshdirmenu & REFRESHDIR_ADDFILE) || (majormods && !prevmajormods)) { char *message = NULL; @@ -4588,7 +4592,7 @@ static boolean M_AddonsRefresh(void) S_StartSound(NULL, sfx_s224); message = va("%c%s\x80\nA file was loaded with %s.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname, ((refreshdirmenu & REFRESHDIR_ERROR) ? "errors" : "warnings")); } - else if (majormods != prevmajormods && !savemoddata) + else if (majormods && !prevmajormods && !savemoddata) { S_StartSound(NULL, sfx_s221); message = va("%c%s\x80\nGameplay has now been modified.\nIf you want to play record attack mode, restart the game to clear existing add-ons.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); @@ -5141,7 +5145,7 @@ static void M_GetAllEmeralds(INT32 choice) emeralds = ((EMERALD7)*2)-1; M_StartMessage(M_GetText("You now have all 7 emeralds.\nUse them wisely.\nWith great power comes great ring drain.\n"),NULL,MM_NOTHING); - G_SetGameModified(multiplayer); + G_SetGameModified(multiplayer, true); } static void M_DestroyRobotsResponse(INT32 ch) @@ -5152,7 +5156,7 @@ static void M_DestroyRobotsResponse(INT32 ch) // Destroy all robots P_DestroyRobots(); - G_SetGameModified(multiplayer); + G_SetGameModified(multiplayer, true); } static void M_DestroyRobots(INT32 choice) diff --git a/src/p_setup.c b/src/p_setup.c index 0a59a2a9..fcb1ac78 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3459,7 +3459,7 @@ boolean P_AddWadFile(const char *wadfilename) if (num <= NUMMAPS && mapheaderinfo[num-1]) { if (mapheaderinfo[num-1]->menuflags & LF2_EXISTSHACK) - majormods = true; // oops, double-defined - no record attack privileges for you + G_SetGameModified(multiplayer, true); // oops, double-defined - no record attack privileges for you mapheaderinfo[num-1]->menuflags |= LF2_EXISTSHACK; } @@ -3489,6 +3489,8 @@ boolean P_AddWadFile(const char *wadfilename) SendNetXCmd(XD_EXITLEVEL, NULL, 0); } + refreshdirmenu &= ~REFRESHDIR_GAMEDATA; // Under usual circumstances we'd wait for REFRESHDIR_GAMEDATA to disappear the next frame, but it's a bit too dangerous for that... + return true; } diff --git a/src/w_wad.c b/src/w_wad.c index 58a65191..efa09ce4 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -34,6 +34,7 @@ #include "z_zone.h" #include "fastcmp.h" +#include "g_game.h" // G_LoadGameData #include "filesrch.h" #include "i_video.h" // rendermode @@ -799,6 +800,8 @@ UINT16 W_InitFile(const char *filename) break; } + if (refreshdirmenu & REFRESHDIR_GAMEDATA) + G_LoadGameData(); DEH_UpdateMaxFreeslots(); W_InvalidateLumpnumCache(); From dda94e4498321a2c5e70da0c51d52f706a361677 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 17 Jan 2019 22:12:59 +0000 Subject: [PATCH 13/58] Remove irrelevant attempts at majormod setting for SOC events which explicitly can only happen if a gamedata is created. --- src/dehacked.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 4edeb987..7820928d 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -3671,7 +3671,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (numemblems < i) numemblems = i; reademblemdata(f, i); - G_SetGameModified(multiplayer, true); } else { @@ -3692,7 +3691,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (numextraemblems < i) numextraemblems = i; readextraemblemdata(f, i); - G_SetGameModified(multiplayer, true); } else { @@ -3709,10 +3707,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } else if (i > 0 && i <= MAXUNLOCKABLES) - { readunlockable(f, i - 1); - G_SetGameModified(multiplayer, true); - } else { deh_warning("Unlockable number %d out of range (1 - %d)", i, MAXUNLOCKABLES); @@ -3728,10 +3723,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } else if (i > 0 && i <= MAXCONDITIONSETS) - { readconditionset(f, (UINT8)i); - G_SetGameModified(multiplayer, true); - } else { deh_warning("Condition set number %d out of range (1 - %d)", i, MAXCONDITIONSETS); @@ -3785,8 +3777,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (clearall || fastcmp(word2, "LEVELS")) clear_levels(); - - G_SetGameModified(multiplayer, true); } else deh_warning("Unknown word: %s", word); From 15aafb00a9f3ddf3156778f903698ae7d32cb5a9 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 18 Jan 2019 13:01:40 +0000 Subject: [PATCH 14/58] Turns out modifiedgame was getting set during startup because of making it use G_SetGameModified. Uh, woops? --- src/d_main.c | 1 - src/g_game.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index fd85770c..5cf95f4b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1253,7 +1253,6 @@ void D_SRB2Main(void) #endif //ifndef DEVELOP mainwadstally = packetsizetally; - majormods = false; cht_Init(); diff --git a/src/g_game.c b/src/g_game.c index 789c5cc5..1b583e17 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -756,7 +756,7 @@ void G_SetNightsRecords(void) // for consistency among messages: this modifies the game and removes savemoddata. void G_SetGameModified(boolean silent, boolean major) { - if ((majormods && modifiedgame && !savemoddata) || (refreshdirmenu & REFRESHDIR_GAMEDATA)) // new gamedata amnesty? + if ((majormods && modifiedgame && !savemoddata) || !mainwads || (refreshdirmenu & REFRESHDIR_GAMEDATA)) // new gamedata amnesty? return; modifiedgame = true; From 4b493b81a68b440f551598ce39394df4d874336d Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 18 Jan 2019 13:04:12 +0000 Subject: [PATCH 15/58] Add warning message when attempting to use the master server browser while `modifiedgame` is true. (We assume that if you're using an IP address connection, you're more of a power user.) --- src/m_menu.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index b1d9ba09..d0386887 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -274,14 +274,13 @@ static menu_t SP_TimeAttackDef, SP_ReplayDef, SP_GuestReplayDef, SP_GhostDef; #ifndef NONET static void M_StartServerMenu(INT32 choice); static void M_ConnectMenu(INT32 choice); -#endif -static void M_StartOfflineServerMenu(INT32 choice); -static void M_StartServer(INT32 choice); -#ifndef NONET +static void M_ConnectMenuModChecks(INT32 choice); static void M_Refresh(INT32 choice); static void M_Connect(INT32 choice); static void M_ChooseRoom(INT32 choice); #endif +static void M_StartOfflineServerMenu(INT32 choice); +static void M_StartServer(INT32 choice); static void M_SetupMultiPlayer(INT32 choice); static void M_SetupMultiPlayer2(INT32 choice); static void M_SetupMultiPlayer3(INT32 choice); @@ -969,11 +968,11 @@ static menuitem_t MP_MainMenu[] = {IT_HEADER, NULL, "Join a game", NULL, 132-24}, #ifndef NONET - {IT_STRING|IT_CALL, NULL, "Internet server browser...",M_ConnectMenu, 142-24}, + {IT_STRING|IT_CALL, NULL, "Internet server browser...",M_ConnectMenuModChecks, 142-24}, {IT_STRING|IT_KEYHANDLER, NULL, "Specify IPv4 address:", M_HandleConnectIP, 150-24}, #else - {IT_GRAYEDOUT, NULL, "Internet server browser...",M_ConnectMenu, 142-24}, - {IT_GRAYEDOUT, NULL, "Specify IPv4 address:", M_HandleConnectIP, 150-24}, + {IT_GRAYEDOUT, NULL, "Internet server browser...",NULL, 142-24}, + {IT_GRAYEDOUT, NULL, "Specify IPv4 address:", NULL, 150-24}, #endif //{IT_HEADER, NULL, "Player setup", NULL, 80}, //{IT_STRING|IT_CALL, NULL, "Name, character, color...", M_SetupMultiPlayer, 90}, @@ -4583,7 +4582,7 @@ static boolean M_AddonsRefresh(void) { S_StartSound(NULL, sfx_s26d); if (refreshdirmenu & REFRESHDIR_MAX) - message = va("%c%s\x80\nMaximum number of add-ons reached.\nA file could not be loaded.\nIf you want to play with this add-on, restart the game to clear existing ones.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); + message = va("%c%s\x80\nMaximum number of add-ons reached.\nA file could not be loaded.\nif you wish to play with this add-on, restart the game to clear existing ones.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); else message = va("%c%s\x80\nA file was not loaded.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); } @@ -4595,7 +4594,7 @@ static boolean M_AddonsRefresh(void) else if (majormods && !prevmajormods && !savemoddata) { S_StartSound(NULL, sfx_s221); - message = va("%c%s\x80\nGameplay has now been modified.\nIf you want to play record attack mode, restart the game to clear existing add-ons.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); + message = va("%c%s\x80\nGameplay has now been modified.\nif you wish to play record attack mode, restart the game to clear existing add-ons.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); prevmajormods = majormods; } @@ -7423,6 +7422,20 @@ static void M_ConnectMenu(INT32 choice) M_Refresh(0); } +static void M_ConnectMenuModChecks(INT32 choice) +{ + (void)choice; + // okay never mind we want to COMMUNICATE to the player pre-emptively instead of letting them try and then get confused when it doesn't work + + if (modifiedgame) + { + M_StartMessage(M_GetText("Add-ons are currently loaded.\nYou will only be able to join a server if\nit has the same ones loaded in the same order.\nIf you wish to play on other servers,\nrestart the game to clear existing add-ons.\n(Press a key)\n"),M_ConnectMenu,MM_EVENTHANDLER); + return; + } + + M_ConnectMenu(-1); +} + static UINT32 roomIds[NUM_LIST_ROOMS]; static void M_RoomMenu(INT32 choice) From d119c711e59fa345028a9a8e616dcb35c6802f5c Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 18 Jan 2019 14:11:59 +0000 Subject: [PATCH 16/58] Improve readability of server browser add-ons message. --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index d0386887..9534a456 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7429,7 +7429,7 @@ static void M_ConnectMenuModChecks(INT32 choice) if (modifiedgame) { - M_StartMessage(M_GetText("Add-ons are currently loaded.\nYou will only be able to join a server if\nit has the same ones loaded in the same order.\nIf you wish to play on other servers,\nrestart the game to clear existing add-ons.\n(Press a key)\n"),M_ConnectMenu,MM_EVENTHANDLER); + M_StartMessage(M_GetText("Add-ons are currently loaded.\n\nYou will only be able to join a server if\nit has the same ones loaded in the same order, which may be unlikely.\n\nIf you wish to play on other servers,\nrestart the game to clear existing add-ons.\n\n(Press a key)\n"),M_ConnectMenu,MM_EVENTHANDLER); return; } From f8229b9dad37480ffff2be430cd7e88aacdd52c1 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 18 Jan 2019 14:53:43 +0000 Subject: [PATCH 17/58] whoopsie doodle, forgot gh wasn't allocated until after this section --- src/g_game.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 1b583e17..327a96ba 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6018,6 +6018,7 @@ void G_AddGhost(char *defdemoname) UINT8 *buffer,*p; mapthing_t *mthing; UINT16 count, ghostversion; + skin_t *ghskin = &skins[0]; name[16] = '\0'; skin[16] = '\0'; @@ -6163,11 +6164,10 @@ void G_AddGhost(char *defdemoname) return; } - gh->oldmo.skin = &skins[0]; for (i = 0; i < numskins; i++) if (!stricmp(skins[i].name,skin)) { - gh->oldmo.skin = &skins[i]; + ghskin = &skins[i]; break; } @@ -6224,7 +6224,7 @@ void G_AddGhost(char *defdemoname) gh->oldmo.z = gh->mo->z; // Set skin - gh->mo->skin = gh->oldmo.skin; + gh->mo->skin = gh->oldmo.skin = ghskin; // Set color gh->mo->color = ((skin_t*)gh->mo->skin)->prefcolor; From 1850123f8bf49ad4fabb11e71d8ec5724b5e5fb7 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sun, 20 Jan 2019 18:50:07 +0100 Subject: [PATCH 18/58] Prevent the use of respawn to cheese SPB and other items --- src/d_netcmd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 41f88ab9..8272b75d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2489,6 +2489,12 @@ static void Command_Respawn(void) UINT8 *cp = buf; WRITEINT32(cp, consoleplayer); + + if (players[consoleplayer].kartstuff[k_spinouttimer]) // KART: Nice try, but no, you won't be cheesing spb anymore. + { + CONS_Printf(M_GetText("Cannot use this while hurt.\n")); + return; + } if (!(gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING)) { From e7d730e3b230d9072fc79543b4b1e725ab31298e Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sun, 20 Jan 2019 18:51:45 +0100 Subject: [PATCH 19/58] prevent the use of respawn to cheese items like SPB --- src/d_netcmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8272b75d..8bedb526 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2489,9 +2489,9 @@ static void Command_Respawn(void) UINT8 *cp = buf; WRITEINT32(cp, consoleplayer); - + if (players[consoleplayer].kartstuff[k_spinouttimer]) // KART: Nice try, but no, you won't be cheesing spb anymore. - { + { CONS_Printf(M_GetText("Cannot use this while hurt.\n")); return; } From fdbf750f48eb1849d54d49fc53ee9c5d55ebe73d Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 21 Jan 2019 21:48:52 +0000 Subject: [PATCH 20/58] Fix incorrect condition for setting savemoddata to false. --- 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 327a96ba..60fd56cb 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -760,11 +760,11 @@ void G_SetGameModified(boolean silent, boolean major) return; modifiedgame = true; - savemoddata = false; if (!major) return; + savemoddata = false; majormods = true; if (!silent) From e9d95f07c184f637078a664a39342718b2075ec5 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 21 Jan 2019 21:49:39 +0000 Subject: [PATCH 21/58] Fix everything Sal wanted changed. --- src/d_netcmd.c | 10 ++++++---- src/dehacked.c | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 244e3058..617ff78f 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4916,11 +4916,13 @@ static void Fishcake_OnChange(void) static void Command_Isgamemodified_f(void) { if (savemoddata) - CONS_Printf(M_GetText("The game is modified, but you can save medal and record data in this add-on.\n")); - else if (/*modifiedgame*/ majormods) - CONS_Printf(M_GetText("Major add-ons have been loaded, so you cannot play record attack.\n")); + CONS_Printf("The game has been modified with an add-on with its own save data, so you can play Record Attack and earn medals.\n"); + else if (majormods) + CONS_Printf("The game has been modified with major add-ons, so you cannot play Record Attack.\n"); + else if (modifiedgame) + CONS_Printf("The game has been modified with only minor add-ons. You can play Record Attack, earn medals and unlock extras.\n"); else - CONS_Printf(M_GetText("No major add-ons are loaded. You can play record attack, earn medals and unlock extras.\n")); + CONS_Printf("The game has not been modified. You can play Record Attack, earn medals and unlock extras.\n"); } static void Command_Cheats_f(void) diff --git a/src/dehacked.c b/src/dehacked.c index 7820928d..8bb2d567 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9773,7 +9773,10 @@ static inline int lib_getenum(lua_State *L) lua_pushboolean(L, devparm); return 1; } else if (fastcmp(word,"modifiedgame")) { - lua_pushboolean(L, /*modifiedgame*/ majormods && !savemoddata); + lua_pushboolean(L, modifiedgame && !savemoddata); + return 1; + } else if (fastcmp(word,"majormods")) { + lua_pushboolean(L, majormods); return 1; } else if (fastcmp(word,"menuactive")) { lua_pushboolean(L, menuactive); From 72133b74985f9862669ab8dab46ed80cd7b45343 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sat, 26 Jan 2019 16:55:26 +0100 Subject: [PATCH 22/58] No more ghetto check, and some more descriptive comments on the Hook --- src/g_game.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index d93a2e9f..58787495 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1612,10 +1612,18 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } } - // Lua: Allow this hook to overwrite ticcmd. - // Be aware that you can't actually write anything inside the player with this hook, only cmd may be altered. + /* Lua: Allow this hook to overwrite ticcmd. + We check if we're actually in a level because for some reason this Hook would run in menus and on the titlescreen otherwise. + Be aware that within this hook, nothing but this player's cmd can be edited (otherwise we'd run in some pretty bad synching problems since this is clientsided, or something) + + Possible usages for this are: + -Forcing the player to perform an action, which could otherwise require terrible, terrible hacking to replicate. + -Preventing the player to perform an action, which would ALSO require some weirdo hacks. + -Making some galaxy brain autopilot Lua if you're a masochist + -Making a Mario Kart 8 Deluxe tier baby mode that steers you away from walls and whatnot. You know what, do what you want! + */ #ifdef HAVE_BLUA - if (playeringame[consoleplayer]) // safe to assume we can't do anything if consoleplayer isn't in the game. + if (gamestate == GS_LEVEL) LUAh_PlayerCmd(player, cmd); #endif From 9028783190380b1084e6cbc63fbcd3285a9fec2a Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sat, 26 Jan 2019 17:40:05 +0100 Subject: [PATCH 23/58] Only prevent respawn if spun out in midair and added a Got_Respawn check to kick cheaters --- src/d_netcmd.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8bedb526..41886d70 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2490,18 +2490,18 @@ static void Command_Respawn(void) WRITEINT32(cp, consoleplayer); - if (players[consoleplayer].kartstuff[k_spinouttimer]) // KART: Nice try, but no, you won't be cheesing spb anymore. - { - CONS_Printf(M_GetText("Cannot use this while hurt.\n")); - return; - } - if (!(gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING)) { CONS_Printf(M_GetText("You must be in a level to use this.\n")); return; } + if (players[consoleplayer].kartstuff[k_spinouttimer] && !P_IsObjectOnGround(players[consoleplayer].mo)) // KART: Nice try, but no, you won't be cheesing spb anymore. + { + CONS_Printf(M_GetText("Cannot use this while hurt.\n")); + return; + } + /*if (!G_RaceGametype()) // srb2kart: not necessary, respawning makes you lose a bumper in battle, so it's not desirable to use as a way to escape a hit { CONS_Printf(M_GetText("You may only use this in co-op, race, and competition!\n")); @@ -2523,8 +2523,8 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum) { INT32 respawnplayer = READINT32(*cp); - // You can't respawn someone else. Nice try, there. - if (respawnplayer != playernum) // srb2kart: "|| (!G_RaceGametype())" + // You can't respawn someone else or cheat your way by removing the send checks above :) Nice try, there. + if ((respawnplayer != playernum) || (players[respawnplayer].mo && players[respawnplayer].kartstuff[k_spinouttimer] && !P_IsObjectOnGround(players[respawnplayer].mo))) // srb2kart: "|| (!G_RaceGametype())" { CONS_Alert(CONS_WARNING, M_GetText("Illegal respawn command received from %s\n"), player_names[playernum]); if (server) From 1a21c5efbec1328b28c51ccb0637124275336008 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 26 Jan 2019 16:58:45 +0000 Subject: [PATCH 24/58] Code cleanup as requested by Sal and Sryder. * majormods and savemoddata cannot coexist as true values, so going through and making situations that involve both only reference one. * Clean up comments in `dehacked.c`. --- src/d_netcmd.c | 2 +- src/dehacked.c | 22 +++++++++++----------- src/g_game.c | 2 +- src/m_cond.c | 3 +-- src/m_menu.c | 4 ++-- src/p_setup.c | 4 ++-- src/y_inter.c | 2 +- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1da2c523..67f8c3a2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2209,7 +2209,7 @@ static void Command_Map_f(void) return; } - if (!(netgame || multiplayer) && (!majormods || savemoddata)) + if (!(netgame || multiplayer) && !majormods) { if (COM_CheckParm("-force")) { diff --git a/src/dehacked.c b/src/dehacked.c index 83550282..0ad67ff0 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -3425,7 +3425,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (fastcmp(word, "FREESLOT")) { readfreeslots(f); - //G_SetGameModified(multiplayer, true); + // This is not a major mod. continue; } else if (fastcmp(word, "MAINCFG")) @@ -3439,7 +3439,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) { readwipes(f); DEH_WriteUndoline(word, "", UNDO_HEADER); - //G_SetGameModified(multiplayer, true); + // This is not a major mod. continue; } word2 = strtok(NULL, " "); @@ -3460,7 +3460,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - //G_SetGameModified(multiplayer, true); + // This is not a major mod. continue; } if (word2) @@ -3474,14 +3474,14 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) // Read texture from spec file. readtexture(f, word2); DEH_WriteUndoline(word, word2, UNDO_HEADER); - //G_SetGameModified(multiplayer, true); + // This is not a major mod. } else if (fastcmp(word, "PATCH")) { // Read patch from spec file. readpatch(f, word2, wad); DEH_WriteUndoline(word, word2, UNDO_HEADER); - //G_SetGameModified(multiplayer, true); + // This is not a major mod. } else if (fastcmp(word, "THING") || fastcmp(word, "MOBJ") || fastcmp(word, "OBJECT")) { @@ -3503,7 +3503,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) /* else if (fastcmp(word, "ANIMTEX")) { readAnimTex(f, i); - //G_SetGameModified(multiplayer, true); + // This is not a major mod. }*/ else if (fastcmp(word, "LIGHT")) { @@ -3517,7 +3517,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - //G_SetGameModified(multiplayer, true); + // This is not a major mod. #endif } else if (fastcmp(word, "SPRITE")) @@ -3533,7 +3533,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - //G_SetGameModified(multiplayer, true); + // This is not a major mod. #endif } else if (fastcmp(word, "LEVEL")) @@ -3622,7 +3622,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - //G_SetGameModified(multiplayer, true); -- ...this won't bite me in the ass later, will it? + // This is not a major mod. } /* else if (fastcmp(word, "SPRITE")) { @@ -3643,7 +3643,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) } else deh_warning("Sprite %d doesn't exist",i); - //G_SetGameModified(multiplayer, true); + // This is not a major mod. }*/ else if (fastcmp(word, "HUDITEM")) { @@ -3657,7 +3657,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) ignorelines(f); } DEH_WriteUndoline(word, word2, UNDO_HEADER); - //G_SetGameModified(multiplayer, true); + // This is not a major mod. } else if (fastcmp(word, "EMBLEM")) { diff --git a/src/g_game.c b/src/g_game.c index e347cf7c..1e0744f4 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -756,7 +756,7 @@ void G_SetNightsRecords(void) // for consistency among messages: this modifies the game and removes savemoddata. void G_SetGameModified(boolean silent, boolean major) { - if ((majormods && modifiedgame && !savemoddata) || !mainwads || (refreshdirmenu & REFRESHDIR_GAMEDATA)) // new gamedata amnesty? + if ((majormods && modifiedgame) || !mainwads || (refreshdirmenu & REFRESHDIR_GAMEDATA)) // new gamedata amnesty? return; modifiedgame = true; diff --git a/src/m_cond.c b/src/m_cond.c index b0e49a68..b777e7d2 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -385,8 +385,7 @@ UINT8 M_UpdateUnlockablesAndExtraEmblems(boolean force) char cechoText[992] = ""; UINT8 cechoLines = 0; - if (/*modifiedgame*/ majormods && !savemoddata - && !force) // SRB2Kart: for enabling unlocks online in modified servers + if (majormods && !force) // SRB2Kart: for enabling unlocks online in modified servers return false; M_CheckUnlockConditions(); diff --git a/src/m_menu.c b/src/m_menu.c index 1edb1cdf..2ea7234c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2738,7 +2738,7 @@ boolean M_Responder(event_t *ev) || (currentMenu->menuitems[itemOn].status & IT_TYPE)==IT_SUBMENU) && (currentMenu->menuitems[itemOn].status & IT_CALLTYPE)) { - if (((currentMenu->menuitems[itemOn].status & IT_CALLTYPE) & IT_CALL_NOTMODIFIED) && /*modifiedgame*/ majormods && !savemoddata) + if (((currentMenu->menuitems[itemOn].status & IT_CALLTYPE) & IT_CALL_NOTMODIFIED) && majormods) { S_StartSound(NULL, sfx_menu1); M_StartMessage(M_GetText("This cannot be done with complex add-ons\nor in a cheated game.\n\n(Press a key)\n"), NULL, MM_NOTHING); @@ -4567,7 +4567,7 @@ static boolean M_AddonsRefresh(void) S_StartSound(NULL, sfx_s224); message = va("%c%s\x80\nA file was loaded with %s.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname, ((refreshdirmenu & REFRESHDIR_ERROR) ? "errors" : "warnings")); } - else if (majormods && !prevmajormods && !savemoddata) + else if (majormods && !prevmajormods) { S_StartSound(NULL, sfx_s221); message = va("%c%s\x80\nGameplay has now been modified.\nif you wish to play record attack mode, restart the game to clear existing add-ons.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); diff --git a/src/p_setup.c b/src/p_setup.c index fcb1ac78..912791cf 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1120,7 +1120,7 @@ static inline void P_SpawnEmblems(void) static void P_SpawnSecretItems(boolean loademblems) { // Now let's spawn those funky emblem things! Tails 12-08-2002 - if (netgame || multiplayer || (/*modifiedgame*/ majormods && !savemoddata)) // No cheating!! + if (netgame || multiplayer || majormods) // No cheating!! return; if (loademblems) @@ -3272,7 +3272,7 @@ boolean P_SetupLevel(boolean skipprecip) nextmapoverride = 0; skipstats = false; - if (!(netgame || multiplayer) && (/*!modifiedgame*/ !majormods || savemoddata)) + if (!(netgame || multiplayer) && !majormods) mapvisited[gamemap-1] |= MV_VISITED; levelloading = false; diff --git a/src/y_inter.c b/src/y_inter.c index 046d6d6d..795f7f1b 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -786,7 +786,7 @@ void Y_StartIntermission(void) } case int_race: // (time-only race) { - if ((/*!modifiedgame*/ !majormods || savemoddata) && !multiplayer && !demoplayback) // remove this once we have a proper time attack screen + if (!majormods && !multiplayer && !demoplayback) // remove this once we have a proper time attack screen { // Update visitation flags mapvisited[gamemap-1] |= MV_BEATEN; From f8fd2c5190962f424fc0db84fabbc22f28104038 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sat, 26 Jan 2019 19:40:12 +0100 Subject: [PATCH 25/58] Changed condition to being mid-air, changed print and changed the kick to a return --- src/d_netcmd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 41886d70..a015b8e7 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2496,9 +2496,9 @@ static void Command_Respawn(void) return; } - if (players[consoleplayer].kartstuff[k_spinouttimer] && !P_IsObjectOnGround(players[consoleplayer].mo)) // KART: Nice try, but no, you won't be cheesing spb anymore. + if (players[consoleplayer].mo && !P_IsObjectOnGround(players[consoleplayer].mo)) // KART: Nice try, but no, you won't be cheesing spb anymore. { - CONS_Printf(M_GetText("Cannot use this while hurt.\n")); + CONS_Printf(M_GetText("You must be on the floor to use this.\n")); return; } @@ -2523,8 +2523,8 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum) { INT32 respawnplayer = READINT32(*cp); - // You can't respawn someone else or cheat your way by removing the send checks above :) Nice try, there. - if ((respawnplayer != playernum) || (players[respawnplayer].mo && players[respawnplayer].kartstuff[k_spinouttimer] && !P_IsObjectOnGround(players[respawnplayer].mo))) // srb2kart: "|| (!G_RaceGametype())" + // You can't respawn someone else. Nice try, there. + if (respawnplayer != playernum) // srb2kart: "|| (!G_RaceGametype())" { CONS_Alert(CONS_WARNING, M_GetText("Illegal respawn command received from %s\n"), player_names[playernum]); if (server) @@ -2538,6 +2538,10 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum) return; } + // incase the above checks were modified to allow sending a respawn on these occasions: + if (players[respawnplayer].mo && !P_IsObjectOnGround(players[respawnplayer].mo)) + return; + if (players[respawnplayer].mo) P_DamageMobj(players[respawnplayer].mo, NULL, NULL, 10000); } From ce09566e119525e6ee4fc7cef920d202a71e46e9 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 26 Jan 2019 19:12:53 +0000 Subject: [PATCH 26/58] Do a bit more cleanup. Notably, prevent skins setting a bunch of things in preperation for this branch hitting the mainstream. Also, make SF_RUNONWATER set off majormods. I was under strong pressure to remove it and almost did but honestly it's kind of endearing and I think like one character in Releases uses it..? --- src/p_map.c | 235 +------------------------------------------------ src/p_mobj.c | 3 +- src/p_spec.c | 19 ++-- src/p_user.c | 68 -------------- src/r_things.c | 29 +++--- 5 files changed, 24 insertions(+), 330 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index c307e572..051a1e6f 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3231,129 +3231,6 @@ isblocking: return false; // stop } -// -// P_IsClimbingValid -// -// Unlike P_DoClimbing, don't use when up against a one-sided linedef. -// -static boolean P_IsClimbingValid(player_t *player, angle_t angle) -{ - fixed_t platx, platy; - subsector_t *glidesector; - fixed_t floorz, ceilingz; - - platx = P_ReturnThrustX(player->mo, angle, player->mo->radius + FixedMul(8*FRACUNIT, player->mo->scale)); - platy = P_ReturnThrustY(player->mo, angle, player->mo->radius + FixedMul(8*FRACUNIT, player->mo->scale)); - - glidesector = R_PointInSubsector(player->mo->x + platx, player->mo->y + platy); - -#ifdef ESLOPE - floorz = glidesector->sector->f_slope ? P_GetZAt(glidesector->sector->f_slope, player->mo->x, player->mo->y) : glidesector->sector->floorheight; - ceilingz = glidesector->sector->c_slope ? P_GetZAt(glidesector->sector->c_slope, player->mo->x, player->mo->y) : glidesector->sector->ceilingheight; -#else - floorz = glidesector->sector->floorheight; - ceilingz = glidesector->sector->ceilingheight; -#endif - - if (glidesector->sector != player->mo->subsector->sector) - { - boolean floorclimb = false; - fixed_t topheight, bottomheight; - - if (glidesector->sector->ffloors) - { - ffloor_t *rover; - for (rover = glidesector->sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER)) - continue; - - topheight = *rover->topheight; - bottomheight = *rover->bottomheight; - -#ifdef ESLOPE - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y); - if (*rover->b_slope) - bottomheight = P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y); -#endif - - floorclimb = true; - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if ((topheight < player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) < topheight)) - { - floorclimb = true; - } - if (topheight < player->mo->z) // Waaaay below the ledge. - { - floorclimb = false; - } - if (bottomheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT,player->mo->scale)) - { - floorclimb = false; - } - } - else - { - if ((bottomheight > player->mo->z) && ((player->mo->z - player->mo->momz) > bottomheight)) - { - floorclimb = true; - } - if (bottomheight > player->mo->z + player->mo->height) // Waaaay below the ledge. - { - floorclimb = false; - } - if (topheight < player->mo->z + FixedMul(16*FRACUNIT,player->mo->scale)) - { - floorclimb = false; - } - } - - if (floorclimb) - break; - } - } - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if ((floorz <= player->mo->z + player->mo->height) - && ((player->mo->z + player->mo->height - player->mo->momz) <= floorz)) - floorclimb = true; - - if ((floorz > player->mo->z) - && glidesector->sector->floorpic == skyflatnum) - return false; - - if ((player->mo->z + player->mo->height - FixedMul(16*FRACUNIT,player->mo->scale) > ceilingz) - || (player->mo->z + player->mo->height <= floorz)) - floorclimb = true; - } - else - { - if ((ceilingz >= player->mo->z) - && ((player->mo->z - player->mo->momz) >= ceilingz)) - floorclimb = true; - - if ((ceilingz < player->mo->z+player->mo->height) - && glidesector->sector->ceilingpic == skyflatnum) - return false; - - if ((player->mo->z + FixedMul(16*FRACUNIT,player->mo->scale) < ceilingz) - || (player->mo->z >= ceilingz)) - floorclimb = true; - } - - if (!floorclimb) - return false; - - return true; - } - - return false; -} - // // PTR_SlideTraverse // @@ -3407,117 +3284,7 @@ isblocking: P_ProcessSpecialSector(slidemo->player, slidemo->subsector->sector, li->polyobj->lines[0]->backsector); } - if (slidemo->player && (slidemo->player->pflags & PF_GLIDING || slidemo->player->climbing) - && slidemo->player->charability == CA_GLIDEANDCLIMB) - { - line_t *checkline = li; - sector_t *checksector; - ffloor_t *rover; - fixed_t topheight, bottomheight; - boolean fofline = false; - INT32 side = P_PointOnLineSide(slidemo->x, slidemo->y, li); - - if (!side && li->backsector) - checksector = li->backsector; - else - checksector = li->frontsector; - - if (checksector->ffloors) - { - for (rover = checksector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) - continue; - - topheight = *rover->topheight; - bottomheight = *rover->bottomheight; - -#ifdef ESLOPE - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, slidemo->x, slidemo->y); - if (*rover->b_slope) - bottomheight = P_GetZAt(*rover->b_slope, slidemo->x, slidemo->y); -#endif - - if (topheight < slidemo->z) - continue; - - if (bottomheight > slidemo->z + slidemo->height) - continue; - - // Got this far, so I guess it's climbable. // TODO: Climbing check, also, better method to do this? - if (rover->master->flags & ML_TFERLINE) - { - size_t linenum = li-checksector->lines[0]; - checkline = rover->master->frontsector->lines[0] + linenum; - fofline = true; - } - - break; - } - } - - // see about climbing on the wall - if (!(checkline->flags & ML_NOCLIMB)) - { - boolean canclimb; - angle_t climbangle, climbline; - INT32 whichside = P_PointOnLineSide(slidemo->x, slidemo->y, li); - - climbangle = climbline = R_PointToAngle2(li->v1->x, li->v1->y, li->v2->x, li->v2->y); - - if (whichside) // on second side? - climbline += ANGLE_180; - - climbangle += (ANGLE_90 * (whichside ? -1 : 1)); - - canclimb = (li->backsector ? P_IsClimbingValid(slidemo->player, climbangle) : true); - - if (((!slidemo->player->climbing && abs((signed)(slidemo->angle - ANGLE_90 - climbline)) < ANGLE_45) - || (slidemo->player->climbing == 1 && abs((signed)(slidemo->angle - climbline)) < ANGLE_135)) - && canclimb) - { - slidemo->angle = climbangle; - if (!demoplayback || P_AnalogMove(slidemo->player)) - { - if (slidemo->player == &players[consoleplayer]) - localangle = slidemo->angle; - else if (slidemo->player == &players[secondarydisplayplayer]) - localangle2 = slidemo->angle; - else if (slidemo->player == &players[thirddisplayplayer]) - localangle3 = slidemo->angle; - else if (slidemo->player == &players[fourthdisplayplayer]) - localangle4 = slidemo->angle; - } - - if (!slidemo->player->climbing) - { - S_StartSound(slidemo->player->mo, sfx_s3k4a); - slidemo->player->climbing = 5; - } - - slidemo->player->pflags &= ~(PF_GLIDING|PF_SPINNING|PF_JUMPED|PF_THOKKED); - slidemo->player->glidetime = 0; - slidemo->player->secondjump = 0; - - if (slidemo->player->climbing > 1) - slidemo->momz = slidemo->momx = slidemo->momy = 0; - - if (fofline) - whichside = 0; - - if (!whichside) - { - slidemo->player->lastsidehit = checkline->sidenum[whichside]; - slidemo->player->lastlinehit = (INT16)(checkline - lines); - } - - P_Thrust(slidemo, slidemo->angle, FixedMul(5*FRACUNIT, slidemo->scale)); - } - } - } - - if (in->frac < bestslidefrac && (!slidemo->player || !slidemo->player->climbing)) + if (in->frac < bestslidefrac) { secondslidefrac = bestslidefrac; secondslideline = bestslideline; diff --git a/src/p_mobj.c b/src/p_mobj.c index f71ff209..d380b97a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3233,8 +3233,7 @@ boolean P_CanRunOnWater(player_t *player, ffloor_t *rover) #endif *rover->topheight; - if (!(player->pflags & PF_NIGHTSMODE) && !player->homing - && (((player->charability == CA_SWIM) || player->powers[pw_super] || player->charflags & SF_RUNONWATER) && player->mo->ceilingz-topheight >= player->mo->height) + if (((player->charflags & SF_RUNONWATER) && player->mo->ceilingz-topheight >= player->mo->height) && (rover->flags & FF_SWIMMABLE) && !(player->pflags & PF_SPINNING) && player->speed > FixedMul(player->runspeed, player->mo->scale) && !(player->pflags & PF_SLIDING) && abs(player->mo->z - topheight) < FixedMul(30*FRACUNIT, player->mo->scale)) diff --git a/src/p_spec.c b/src/p_spec.c index ca4967ce..24f56c43 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1758,12 +1758,12 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller switch (specialtype) { - case 305: // continuous + /*case 305: // continuous case 306: // each time case 307: // once if (!(actor && actor->player && actor->player->charability == dist/10)) return false; - break; + break;*/ case 309: // continuous case 310: // each time // Only red team members can activate this. @@ -3864,14 +3864,6 @@ DoneSection2: P_InstaThrust(player->mo, player->mo->angle, linespeed); - /*if (GETSECSPECIAL(sector->special, 3) == 6 && (player->charability2 == CA2_SPINDASH)) // SRB2kart - { - if (!(player->pflags & PF_SPINNING)) - player->pflags |= PF_SPINNING; - - //P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - }*/ - player->kartstuff[k_dashpadcooldown] = TICRATE/3; player->kartstuff[k_drift] = 0; player->kartstuff[k_driftcharge] = 0; @@ -5781,7 +5773,7 @@ void P_SpawnSpecials(INT32 fromnetsave) lines[i].special = 0; continue; } - /*else -- commented out because irrelevant to kart + /*else -- commented out because irrelevant to kart. keeping here because we can use these flags for something else now { if ((players[consoleplayer].charability == CA_THOK && (lines[i].flags & ML_NOSONIC)) || (players[consoleplayer].charability == CA_FLY && (lines[i].flags & ML_NOTAILS)) @@ -7997,12 +7989,13 @@ static void P_SearchForDisableLinedefs(void) } else if ((lines[i].flags & ML_NETONLY) == ML_NETONLY) continue; // Net-only never triggers in single player - else if (players[consoleplayer].charability == CA_THOK && (lines[i].flags & ML_NOSONIC)) + // commented out because irrelevant to kart. keeping here because we can use these flags for something else now + /*else if (players[consoleplayer].charability == CA_THOK && (lines[i].flags & ML_NOSONIC)) continue; else if (players[consoleplayer].charability == CA_FLY && (lines[i].flags & ML_NOTAILS)) continue; else if (players[consoleplayer].charability == CA_GLIDEANDCLIMB && (lines[i].flags & ML_NOKNUX)) - continue; + continue;*/ // Disable any linedef specials with our tag. for (j = -1; (j = P_FindLineFromLineTag(&lines[i], j)) >= 0;) diff --git a/src/p_user.c b/src/p_user.c index d7423d80..ce411d2d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7323,74 +7323,6 @@ static void P_MovePlayer(player_t *player) if (CheckForBustableBlocks) P_CheckBustableBlocks(player); - // Special handling for - // gliding in 2D mode - if ((twodlevel || player->mo->flags2 & MF2_TWOD) && player->pflags & PF_GLIDING && player->charability == CA_GLIDEANDCLIMB - && !(player->mo->flags & MF_NOCLIP)) - { - msecnode_t *node; // only place it's being used in P_MovePlayer now - fixed_t oldx; - fixed_t oldy; - fixed_t floorz, ceilingz; - - oldx = player->mo->x; - oldy = player->mo->y; - - P_UnsetThingPosition(player->mo); - player->mo->x += player->mo->momx; - player->mo->y += player->mo->momy; - P_SetThingPosition(player->mo); - - for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) - { - if (!node->m_sector) - break; - - if (node->m_sector->ffloors) - { - ffloor_t *rover; - fixed_t topheight, bottomheight; - - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER)) - continue; - - topheight = P_GetFOFTopZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); - bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); - if (topheight > player->mo->z && bottomheight < player->mo->z) - { - P_ResetPlayer(player); - S_StartSound(player->mo, sfx_s3k4a); - player->climbing = 5; - player->mo->momx = player->mo->momy = player->mo->momz = 0; - break; - } - } - } - - floorz = P_GetFloorZ(player->mo, node->m_sector, player->mo->x, player->mo->y, NULL); - ceilingz = P_GetCeilingZ(player->mo, node->m_sector, player->mo->x, player->mo->y, NULL); - - if (player->mo->z+player->mo->height > ceilingz - && node->m_sector->ceilingpic == skyflatnum) - continue; - - if (floorz > player->mo->z || ceilingz < player->mo->z) - { - P_ResetPlayer(player); - S_StartSound(player->mo, sfx_s3k4a); - player->climbing = 5; - player->mo->momx = player->mo->momy = player->mo->momz = 0; - break; - } - } - P_UnsetThingPosition(player->mo); - player->mo->x = oldx; - player->mo->y = oldy; - P_SetThingPosition(player->mo); - } - // Check for a BOUNCY sector! if (CheckForBouncySector) P_CheckBouncySectors(player); diff --git a/src/r_things.c b/src/r_things.c index c0a71b02..135ae6a2 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2895,27 +2895,27 @@ void R_AddSkins(UINT16 wadnum) #define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value); // character type identification FULLPROCESS(flags) - FULLPROCESS(ability) - FULLPROCESS(ability2) + //FULLPROCESS(ability) + //FULLPROCESS(ability2) - FULLPROCESS(thokitem) - FULLPROCESS(spinitem) - FULLPROCESS(revitem) + //FULLPROCESS(thokitem) + //FULLPROCESS(spinitem) + //FULLPROCESS(revitem) #undef FULLPROCESS #define GETSPEED(field) else if (!stricmp(stoken, #field)) skin->field = atoi(value)<field = atoi(value); +/*#define GETINT(field) else if (!stricmp(stoken, #field)) skin->field = atoi(value); GETINT(thrustfactor) GETINT(accelstart) GETINT(acceleration) -#undef GETINT +#undef GETINT*/ #define GETKARTSTAT(field) \ else if (!stricmp(stoken, #field)) \ @@ -2934,8 +2934,8 @@ void R_AddSkins(UINT16 wadnum) else if (!stricmp(stoken, "prefcolor")) skin->prefcolor = K_GetKartColorByName(value); - else if (!stricmp(stoken, "jumpfactor")) - skin->jumpfactor = FLOAT_TO_FIXED(atof(value)); + //else if (!stricmp(stoken, "jumpfactor")) + //skin->jumpfactor = FLOAT_TO_FIXED(atof(value)); else if (!stricmp(stoken, "highresscale")) skin->highresscale = FLOAT_TO_FIXED(atof(value)); else @@ -3045,6 +3045,9 @@ next_token: HWR_AddPlayerMD2(numskins); #endif + if (skin->flags & SF_RUNONWATER) // this is literally the only way a skin can be a major mod... this might be a bit heavy handed + G_SetGameModified(multiplayer, true); + numskins++; } return; From 55c6ab2581af730748bfcb0d7bbba5f777c470f4 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sun, 27 Jan 2019 17:51:46 -0500 Subject: [PATCH 27/58] Scale number of allowed invuln items w/ player count 0-5 players: 1 invincibility/grow allowed out at once 6-9 players: 2 invincibilities (how it was before) 10-13 players: 3 invincibilities 14+ players: 4 invincibilites --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 18165a7f..bc5e53ca 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -700,7 +700,7 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed) { case KITEM_INVINCIBILITY: case KITEM_GROW: - if (pinvin >= 2) + if (pinvin >= max(1, (pingame+2) / 4)) newodds = 0; else /* FALLTHRU */ From dd2b895e800951436f881e345ba76aa9e5b578fc Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sun, 27 Jan 2019 21:57:18 -0500 Subject: [PATCH 28/58] Remove offroad leniency bias Everyone now has flat, equal 1-second leniency --- src/k_kart.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f01f0d0b..5de534bb 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1264,7 +1264,6 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo, sector_t *sec) */ static void K_UpdateOffroad(player_t *player) { - fixed_t kartweight = player->kartweight; fixed_t offroad; sector_t *nextsector = R_PointInSubsector( player->mo->x + player->mo->momx*2, player->mo->y + player->mo->momy*2)->sector; @@ -1284,13 +1283,11 @@ static void K_UpdateOffroad(player_t *player) if (offroadstrength) { if (K_CheckOffroadCollide(player->mo, player->mo->subsector->sector) && player->kartstuff[k_offroad] == 0) - player->kartstuff[k_offroad] = 16; + player->kartstuff[k_offroad] = (TICRATE/2); if (player->kartstuff[k_offroad] > 0) { - // 1872 is the magic number - 35 frames adds up to approximately 65536. 1872/4 = 468/3 = 156 - // A higher kart weight means you can stay offroad for longer without losing speed - offroad = (1872 + 5*156 - kartweight*156)*offroadstrength; + offroad = (FRACUNIT * offroadstrength) / TICRATE; //if (player->kartstuff[k_growshrinktimer] > 1) // grow slows down half as fast // offroad /= 2; From 8a97b28936d3d8ace0b7bd03b367ad736f8589bb Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sun, 27 Jan 2019 21:58:17 -0500 Subject: [PATCH 29/58] Wipeout slowdown timer is set to 20 tics if below, instead of adding up per bump. --- src/k_kart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 5de534bb..b7029452 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1211,8 +1211,8 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid) mobj1->player->kartstuff[k_justbumped] = bumptime; if (mobj1->player->kartstuff[k_spinouttimer]) { - mobj1->player->kartstuff[k_wipeoutslow] += wipeoutslowtime+1; - mobj1->player->kartstuff[k_spinouttimer] += wipeoutslowtime+1; + mobj1->player->kartstuff[k_wipeoutslow] = wipeoutslowtime+1; + mobj1->player->kartstuff[k_spinouttimer] = max(wipeoutslowtime+1, mobj1->player->kartstuff[k_spinouttimer]); } } @@ -1223,8 +1223,8 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid) mobj2->player->kartstuff[k_justbumped] = bumptime; if (mobj2->player->kartstuff[k_spinouttimer]) { - mobj2->player->kartstuff[k_wipeoutslow] += wipeoutslowtime+1; - mobj2->player->kartstuff[k_spinouttimer] += wipeoutslowtime+1; + mobj2->player->kartstuff[k_wipeoutslow] = wipeoutslowtime+1; + mobj2->player->kartstuff[k_spinouttimer] = max(wipeoutslowtime+1, mobj2->player->kartstuff[k_spinouttimer]); } } } From c53144ecd67d296534a42930dbff003644285ee6 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sun, 27 Jan 2019 21:58:44 -0500 Subject: [PATCH 30/58] Wipeout slowdown is x2 strength --- src/k_kart.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index b7029452..12da394a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5429,6 +5429,8 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->mo->friction += 4608; if (player->speed > 0 && cmd->forwardmove < 0 && player->mo->friction == 59392) player->mo->friction += 1608; + + // Karma ice physics if (G_BattleGametype() && player->kartstuff[k_bumper] <= 0) { player->mo->friction += 1228; @@ -5448,11 +5450,13 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (player->mo->movefactor < 32) player->mo->movefactor = 32; } + + // Wipeout slowdown if (player->kartstuff[k_spinouttimer] && player->kartstuff[k_wipeoutslow]) { - player->mo->friction -= FixedMul(1228, player->kartstuff[k_offroad]); + player->mo->friction -= FixedMul(2456, player->kartstuff[k_offroad]); if (player->kartstuff[k_wipeoutslow] == 1) - player->mo->friction -= 4912; + player->mo->friction -= 9824; } K_KartDrift(player, onground); From 5518a19945f39533c5873219c224dfd06c62c024 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sun, 27 Jan 2019 22:28:44 -0500 Subject: [PATCH 31/58] Wipeout slowdown in offroad is static --- src/k_kart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 12da394a..d3685638 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5454,7 +5454,8 @@ void K_MoveKartPlayer(player_t *player, boolean onground) // Wipeout slowdown if (player->kartstuff[k_spinouttimer] && player->kartstuff[k_wipeoutslow]) { - player->mo->friction -= FixedMul(2456, player->kartstuff[k_offroad]); + if (player->kartstuff[k_offroad]) + player->mo->friction -= 4912; if (player->kartstuff[k_wipeoutslow] == 1) player->mo->friction -= 9824; } From 0ef442c004d81496ee480522c0c1106a40adfc02 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sun, 27 Jan 2019 23:18:40 -0500 Subject: [PATCH 32/58] Change offroad leniency from 1 second to 0.5 seconds, don't make friction more forgiving in offroad --- src/k_kart.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index d3685638..a54f8ef5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1287,7 +1287,7 @@ static void K_UpdateOffroad(player_t *player) if (player->kartstuff[k_offroad] > 0) { - offroad = (FRACUNIT * offroadstrength) / TICRATE; + offroad = (FRACUNIT * offroadstrength) / (TICRATE/2); //if (player->kartstuff[k_growshrinktimer] > 1) // grow slows down half as fast // offroad /= 2; @@ -5425,10 +5425,13 @@ void K_MoveKartPlayer(player_t *player, boolean onground) } // Friction - if (player->speed > 0 && cmd->forwardmove == 0 && player->mo->friction == 59392) - player->mo->friction += 4608; - if (player->speed > 0 && cmd->forwardmove < 0 && player->mo->friction == 59392) - player->mo->friction += 1608; + if (!player->kartstuff[k_offroad]) + { + if (player->speed > 0 && cmd->forwardmove == 0 && player->mo->friction == 59392) + player->mo->friction += 4608; + if (player->speed > 0 && cmd->forwardmove < 0 && player->mo->friction == 59392) + player->mo->friction += 1608; + } // Karma ice physics if (G_BattleGametype() && player->kartstuff[k_bumper] <= 0) From 38ca2ab98a1e595ff97a312e486b5c61e5097ca9 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sun, 27 Jan 2019 23:25:03 -0500 Subject: [PATCH 33/58] Sparks can't be started in offroad --- src/k_kart.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index a54f8ef5..118da2c5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4667,8 +4667,6 @@ static void K_KartDrift(player_t *player, boolean onground) player->kartstuff[k_driftend] = 0; } - - // Incease/decrease the drift value to continue drifting in that direction if (player->kartstuff[k_spinouttimer] == 0 && player->kartstuff[k_jmp] == 1 && onground && player->kartstuff[k_drift] != 0) { @@ -4700,7 +4698,7 @@ static void K_KartDrift(player_t *player, boolean onground) // Disable drift-sparks until you're going fast enough if (player->kartstuff[k_getsparks] == 0) driftadditive = 0; - if (player->speed > minspeed*2) + if (player->speed > minspeed*2 && !player->kartstuff[k_offroad]) player->kartstuff[k_getsparks] = 1; // This spawns the drift sparks From ada4ce622f793023b58b8132228e2e9040a7167b Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 28 Jan 2019 16:32:07 +0000 Subject: [PATCH 34/58] * Did some reviewing, turns out there's literally no reason to disable savemoddata when majormods gets tripped and it's just a stupid thing vanilla did for modifiedgame for some reason that we almost inherited with our new solution? * Adjusted the save system to acknowledge the new status quo. Instead of trying to save modifiedgame in the file like some sort of extremely boneheaded honour system everyone and their mothers hacks around, we just use it to determine whether the save is for a mod with savedata or not (this keeps backwards compatibility based on how we were using it, anyways, especially with the *force* parameter...) * Added a menu message for attempting to play a demo set on a map that isn't loaded, as opposed to letting it I_Error. * Minor tweaks to addons menu representing modded status. --- src/d_netcmd.c | 6 +++--- src/g_game.c | 25 ++++++++++++++++--------- src/m_menu.c | 7 +++++-- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 67f8c3a2..1c90d181 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4910,10 +4910,10 @@ static void Fishcake_OnChange(void) */ static void Command_Isgamemodified_f(void) { - if (savemoddata) - CONS_Printf("The game has been modified with an add-on with its own save data, so you can play Record Attack and earn medals.\n"); - else if (majormods) + if (majormods) CONS_Printf("The game has been modified with major add-ons, so you cannot play Record Attack.\n"); + else if (savemoddata) + CONS_Printf("The game has been modified with an add-on with its own save data, so you can play Record Attack and earn medals.\n"); else if (modifiedgame) CONS_Printf("The game has been modified with only minor add-ons. You can play Record Attack, earn medals and unlock extras.\n"); else diff --git a/src/g_game.c b/src/g_game.c index 1e0744f4..8dffb7d5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -764,7 +764,7 @@ void G_SetGameModified(boolean silent, boolean major) if (!major) return; - savemoddata = false; + //savemoddata = false; -- there is literally no reason to do this anymore. majormods = true; if (!silent) @@ -3933,7 +3933,6 @@ void G_LoadGameData(void) // Saves the main data file, which stores information such as emblems found, etc. void G_SaveGameData(boolean force) { - const boolean wasmodified = modifiedgame; size_t length; INT32 i, j; UINT8 btemp; @@ -3950,9 +3949,7 @@ void G_SaveGameData(boolean force) return; } - if (force) // SRB2Kart: for enabling unlocks online, even if the game is modified - modifiedgame = savemoddata; // L-let's just sort of... hack around the cheat protection, because I'm too worried about just removing it @@; - else if (modifiedgame && !savemoddata) + if (majormods && !force) { free(savebuffer); save_p = savebuffer = NULL; @@ -3965,7 +3962,7 @@ void G_SaveGameData(boolean force) WRITEUINT32(save_p, totalplaytime); WRITEUINT32(save_p, matchesplayed); - btemp = (UINT8)(savemoddata || modifiedgame); + btemp = (UINT8)(savemoddata); // what used to be here was profoundly dunderheaded WRITEUINT8(save_p, btemp); // TODO put another cipher on these things? meh, I don't care... @@ -4051,9 +4048,6 @@ void G_SaveGameData(boolean force) FIL_WriteFile(va(pandf, srb2home, gamedatafilename), savebuffer, length); free(savebuffer); save_p = savebuffer = NULL; - - if (force) // Eeeek, I'm sorry for my sins! - modifiedgame = wasmodified; } #define VERSIONSIZE 16 @@ -5925,6 +5919,19 @@ void G_DoPlayDemo(char *defdemoname) return; } + // ...*map* not loaded? + if (!gamemap || (gamemap > NUMMAPS) || !mapheaderinfo[gamemap-1] || !(mapheaderinfo[gamemap-1]->menuflags & LF2_EXISTSHACK)) + { + snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + M_StartMessage(msg, NULL, MM_NOTHING); + Z_Free(pdemoname); + Z_Free(demobuffer); + demoplayback = false; + titledemo = false; + return; + } + Z_Free(pdemoname); memset(&oldcmd,0,sizeof(oldcmd)); diff --git a/src/m_menu.c b/src/m_menu.c index 2ea7234c..9e51cb50 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4543,7 +4543,10 @@ static boolean M_AddonsRefresh(void) if ((refreshdirmenu & REFRESHDIR_NORMAL) && !preparefilemenu(true)) { UNEXIST; - CLEARNAME; + if (refreshdirname) + { + CLEARNAME; + } return true; } @@ -4723,7 +4726,7 @@ static void M_DrawAddons(void) V_DrawSmallScaledPatch(x, y + 4, (menusearch[0] ? 0 : V_TRANSLUCENT), addonsp[NUM_EXT+3]); x = BASEVIDWIDTH - x - 16; - V_DrawSmallScaledPatch(x, y + 4, ((!modifiedgame || savemoddata) ? 0 : V_TRANSLUCENT), addonsp[NUM_EXT+4]); + V_DrawSmallScaledPatch(x, y + 4, ((!majormods) ? 0 : V_TRANSLUCENT), addonsp[NUM_EXT+4]); if (modifiedgame) V_DrawSmallScaledPatch(x, y + 4, 0, addonsp[NUM_EXT+2]); From d3bf1d55ef1a3f28ace0ae159582ede647bff851 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 28 Jan 2019 17:28:15 +0000 Subject: [PATCH 35/58] You will never have Lua consoleplayer. (This is a quick, cheap hack to make splitscreen not almost impossible to support in major mods like Wipezones.) --- src/lua_hudlib.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index ca952a00..cd8e0392 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -34,6 +34,8 @@ static UINT8 hud_enabled[(hud_MAX/8)+1]; static UINT8 hudAvailable; // hud hooks field +static UINT8 camnum = 1; + // must match enum hud in lua_hud.h static const char *const hud_disable_options[] = { "stagetitle", @@ -134,7 +136,8 @@ enum cameraf { camera_height, camera_momx, camera_momy, - camera_momz + camera_momz, + camera_pnum }; @@ -153,6 +156,7 @@ static const char *const camera_opt[] = { "momx", "momy", "momz", + "pnum", NULL}; static int lib_getHudInfo(lua_State *L) @@ -308,6 +312,9 @@ static int camera_get(lua_State *L) case camera_momz: lua_pushinteger(L, cam->momz); break; + case camera_pnum: + lua_pushinteger(L, camnum); + break; } return 1; } @@ -772,13 +779,25 @@ void LUAh_GameHUD(player_t *stplayr) LUA_PushUserdata(gL, stplayr, META_PLAYER); if (splitscreen > 2 && stplayr == &players[fourthdisplayplayer]) + { LUA_PushUserdata(gL, &camera4, META_CAMERA); + camnum = 4; + } else if (splitscreen > 1 && stplayr == &players[thirddisplayplayer]) + { LUA_PushUserdata(gL, &camera3, META_CAMERA); + camnum = 3; + } else if (splitscreen && stplayr == &players[secondarydisplayplayer]) + { LUA_PushUserdata(gL, &camera2, META_CAMERA); + camnum = 2; + } else + { LUA_PushUserdata(gL, &camera, META_CAMERA); + camnum = 1; + } lua_pushnil(gL); while (lua_next(gL, -5) != 0) { From 80d1c303e3dc4612c84d3bdbeedd2cfadede03b0 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Mon, 28 Jan 2019 12:47:23 -0500 Subject: [PATCH 36/58] Reduce frequency of Eggman items, give some of those points to Orbinaut or Banana --- src/k_kart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index bc5e53ca..619f2b1e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -499,9 +499,9 @@ static INT32 K_KartItemOddsRace[NUMKARTRESULTS][10] = /*Sneaker*/ {20, 0, 0, 4, 6, 6, 0, 0, 0, 0 }, // Sneaker /*Rocket Sneaker*/ { 0, 0, 0, 0, 0, 1, 3, 5, 3, 0 }, // Rocket Sneaker /*Invincibility*/ { 0, 0, 0, 0, 0, 1, 4, 6,14, 0 }, // Invincibility - /*Banana*/ { 0, 9, 4, 2, 1, 0, 0, 0, 0, 0 }, // Banana - /*Eggman Monitor*/ { 0, 4, 3, 2, 0, 0, 0, 0, 0, 0 }, // Eggman Monitor - /*Orbinaut*/ { 0, 6, 5, 3, 2, 0, 0, 0, 0, 0 }, // Orbinaut + /*Banana*/ { 0,10, 4, 2, 1, 0, 0, 0, 0, 0 }, // Banana + /*Eggman Monitor*/ { 0, 3, 2, 1, 0, 0, 0, 0, 0, 0 }, // Eggman Monitor + /*Orbinaut*/ { 0, 8, 6, 4, 2, 0, 0, 0, 0, 0 }, // Orbinaut /*Jawz*/ { 0, 0, 3, 2, 1, 1, 0, 0, 0, 0 }, // Jawz /*Mine*/ { 0, 0, 2, 2, 1, 0, 0, 0, 0, 0 }, // Mine /*Ballhog*/ { 0, 0, 0, 2, 1, 0, 0, 0, 0, 0 }, // Ballhog From bc4832aa40d20838e92286f4b10f632cc6152de8 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Wed, 30 Jan 2019 14:14:24 -0500 Subject: [PATCH 37/58] Slower orbit, always have 1 orbit item deploy behind you, and higher gravity for Orbinaut/Jawz --- src/info.c | 4 ++-- src/k_kart.c | 6 +++--- src/p_mobj.c | 9 ++++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/info.c b/src/info.c index ea9eac9d..ccdfa3cf 100644 --- a/src/info.c +++ b/src/info.c @@ -15449,7 +15449,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_ORBINAUT_SHIELDDEAD, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound - 10*FRACUNIT, // speed + 4*FRACUNIT, // speed 16*FRACUNIT, // radius 32*FRACUNIT, // height 0, // display offset @@ -15530,7 +15530,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_JAWZ_DEAD1, // deathstate S_JAWZ_DEAD2, // xdeathstate sfx_None, // deathsound - 10*FRACUNIT, // speed + 4*FRACUNIT, // speed 16*FRACUNIT, // radius 32*FRACUNIT, // height 0, // display offset diff --git a/src/k_kart.c b/src/k_kart.c index dbc9b740..9d3a12c5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3646,7 +3646,7 @@ static void K_MoveHeldObjects(player_t *player) cur->angle += FixedAngle(cur->info->speed); if (cur->extravalue1 < radius) - cur->extravalue1 += FixedMul(P_AproxDistance(cur->extravalue1, radius), FRACUNIT/12); + cur->extravalue1 += P_AproxDistance(cur->extravalue1, radius) / 12; if (cur->extravalue1 > radius) cur->extravalue1 = radius; @@ -5109,7 +5109,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) for (moloop = 0; moloop < player->kartstuff[k_itemamount]; moloop++) { - newangle = FixedAngle(((360/player->kartstuff[k_itemamount])*moloop)*FRACUNIT) + ANGLE_90; + newangle = (player->mo->angle + ANGLE_157h) + FixedAngle(((360 / player->kartstuff[k_itemamount]) * moloop) << FRACBITS) + ANGLE_90; mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_ORBINAUT_SHIELD); if (!mo) { @@ -5150,7 +5150,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) for (moloop = 0; moloop < player->kartstuff[k_itemamount]; moloop++) { - newangle = FixedAngle(((360/player->kartstuff[k_itemamount])*moloop)*FRACUNIT) + ANGLE_90; + newangle = (player->mo->angle + ANGLE_157h) + FixedAngle(((360 / player->kartstuff[k_itemamount]) * moloop) << FRACBITS) + ANGLE_90; mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_JAWZ_SHIELD); if (!mo) { diff --git a/src/p_mobj.c b/src/p_mobj.c index d380b97a..ed53f647 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1354,7 +1354,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (wasflip == !(mo->eflags & MFE_VERTICALFLIP)) // note!! == ! is not equivalent to != here - turns numeric into bool this way P_PlayerFlip(mo); if (mo->player->kartstuff[k_pogospring]) - gravityadd = FixedMul(gravityadd, 5*FRACUNIT/2); + gravityadd = (5*gravityadd)/2; } else { @@ -1404,11 +1404,14 @@ fixed_t P_GetMobjGravity(mobj_t *mo) break; case MT_BANANA: case MT_EGGMANITEM: + case MT_ORBINAUT: + case MT_JAWZ: + case MT_JAWZ_DUD: case MT_SSMINE: - gravityadd = FixedMul(gravityadd, 5*FRACUNIT/2); + gravityadd = (5*gravityadd)/2; break; case MT_SINK: - gravityadd = FixedMul(gravityadd, 5*FRACUNIT); // Double gravity + gravityadd = (5*gravityadd); // Double gravity break; case MT_SIGN: gravityadd /= 8; From e63b6aee00d48d9f9d2f580fe86d6498a6811ad2 Mon Sep 17 00:00:00 2001 From: Sryder Date: Wed, 30 Jan 2019 19:18:51 +0000 Subject: [PATCH 38/58] Fix Connection Timeouts during Wipes Keep the connection alive with a specific packet to say we haven't timed out --- src/d_clisrv.c | 112 +++++++++++++++++++++++++++++++++++++++++-------- src/d_clisrv.h | 2 + src/d_net.c | 3 ++ src/f_wipe.c | 3 ++ 4 files changed, 103 insertions(+), 17 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c84faa72..71fdf6fb 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4083,6 +4083,21 @@ FILESTAMP else if (resynch_score[node]) --resynch_score[node]; break; + case PT_WIPETIME: + if (client) + break; + + // This should probably still timeout though, as the node should always have a player 1 number + if (netconsole == -1) + break; + + // If a client sends this it should mean they are done receiving the savegame + sendingsavegame[node] = false; + + // As long as clients send keep alives, the server can keep running, so reset the timeout + /// \todo Use a separate cvar for that kind of timeout? + freezetimeout[node] = I_GetTime() + connectiontimeout; + break; case PT_TEXTCMD: case PT_TEXTCMD2: case PT_TEXTCMD3: @@ -4586,6 +4601,15 @@ static INT16 Consistancy(void) return (INT16)(ret & 0xFFFF); } +// confusing, but this DOESN'T send PT_NODEKEEPALIVE, it sends PT_WIPETIME +// used during wipes to tell the server that a node is still connected +static void CL_SendClientKeepAlive(void) +{ + netbuffer->packettype = PT_WIPETIME; + + HSendPacket(servernode, false, 0, 0); +} + // send the client packet to the server static void CL_SendClientCmd(void) { @@ -5032,9 +5056,77 @@ static inline void PingUpdate(void) } #endif +static tic_t gametime = 0; + +#ifdef NEWPING +static void UpdatePingTable(void) +{ + INT32 i; + if (server) + { + if (netgame && !(gametime % 255)) + PingUpdate(); + // update node latency values so we can take an average later. + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i]) + realpingtable[i] += G_TicsToMilliseconds(GetLag(playernode[i])); + pingmeasurecount++; + } +} +#endif + +// Handle timeouts to prevent definitive freezes from happenning +static void HandleNodeTimeouts(void) +{ + INT32 i; + if (server) + for (i = 1; i < MAXNETNODES; i++) + if (nodeingame[i] && freezetimeout[i] < I_GetTime()) + Net_ConnectionTimeout(i); +} + +// Keep the network alive while not advancing tics! +void NetKeepAlive(void) +{ + tic_t nowtime; + INT32 realtics; + + nowtime = I_GetTime(); + realtics = nowtime - gametime; + + // return if there's no time passed since the last call + if (realtics <= 0) // nothing new to update + return; + +#ifdef NEWPING + UpdatePingTable(); +#endif + + if (server) + CL_SendClientKeepAlive(); + +// Sryder: What is FILESTAMP??? +FILESTAMP + GetPackets(); +FILESTAMP + + MasterClient_Ticker(); + + if (client) + { + // send keep alive + CL_SendClientKeepAlive(); + // No need to check for resynch because we aren't running any tics + } + // No else because no tics are being run and we can't resynch during this + + Net_AckTicker(); + HandleNodeTimeouts(); + SV_FileSendTicker(); +} + void NetUpdate(void) { - static tic_t gametime = 0; static tic_t resptime = 0; tic_t nowtime; INT32 i; @@ -5056,16 +5148,7 @@ void NetUpdate(void) gametime = nowtime; #ifdef NEWPING - if (server) - { - if (netgame && !(gametime % 255)) - PingUpdate(); - // update node latency values so we can take an average later. - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - realpingtable[i] += G_TicsToMilliseconds(GetLag(playernode[i])); - pingmeasurecount++; - } + UpdatePingTable(); #endif if (client) @@ -5133,12 +5216,7 @@ FILESTAMP } } Net_AckTicker(); - // Handle timeouts to prevent definitive freezes from happenning - if (server) - for (i = 1; i < MAXNETNODES; i++) - if (nodeingame[i] && freezetimeout[i] < I_GetTime()) - Net_ConnectionTimeout(i); - nowtime /= NEWTICRATERATIO; + HandleNodeTimeouts(); if (nowtime > resptime) { resptime = nowtime; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 39cb8c4d..af507739 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -71,6 +71,7 @@ typedef enum PT_CLIENT3MIS, PT_CLIENT4CMD, // 4P PT_CLIENT4MIS, + PT_WIPETIME, // Keep the network alive during wipes, as tics aren't advanced and NetUpdate isn't called PT_CANFAIL, // This is kind of a priority. Anything bigger than CANFAIL // allows HSendPacket(*, true, *, *) to return false. @@ -538,6 +539,7 @@ void SendNetXCmd3(netxcmd_t id, const void *param, size_t nparam); // splitsreen void SendNetXCmd4(netxcmd_t id, const void *param, size_t nparam); // splitsreen4 player // Create any new ticcmds and broadcast to other players. +void NetKeepAlive(void); void NetUpdate(void); void SV_StartSinglePlayerServer(void); diff --git a/src/d_net.c b/src/d_net.c index 62301dc1..7c8fc956 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -903,6 +903,9 @@ static void DebugPrintpacket(const char *header) (UINT32)ExpandTics(netbuffer->u.clientpak.client_tic), (UINT32)ExpandTics (netbuffer->u.clientpak.resendfrom)); break; + case PT_WIPETIME: + fprintf(debugfile, " wipetime\n"); + break; case PT_TEXTCMD: case PT_TEXTCMD2: case PT_TEXTCMD3: diff --git a/src/f_wipe.c b/src/f_wipe.c index f7a5992a..eaa5a013 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -26,6 +26,7 @@ #include "console.h" #include "d_main.h" #include "m_misc.h" // movie mode +#include "d_clisrv.h" // So the network state can be updated during the wipe #ifdef HWRENDER #include "hardware/hw_main.h" @@ -375,6 +376,8 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu) if (moviemode) M_SaveFrame(); + + NetKeepAlive(); // Update the network so we don't cause timeouts } WipeInAction = false; #endif From a81546177d9c1906707ecd4dc0d9921d96676d9d Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Wed, 30 Jan 2019 14:24:04 -0500 Subject: [PATCH 39/58] Speed updates based on number of orbiting items --- src/k_kart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 9d3a12c5..a9e1f9be 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3626,6 +3626,7 @@ static void K_MoveHeldObjects(player_t *player) case MT_JAWZ_SHIELD: { mobj_t *cur = player->mo->hnext; + fixed_t speed = ((8 - min(4, player->kartstuff[k_itemamount])) * cur->info->speed) / 7; player->kartstuff[k_bananadrag] = 0; // Just to make sure @@ -3643,7 +3644,7 @@ static void K_MoveHeldObjects(player_t *player) cur->color = player->skincolor; cur->angle -= ANGLE_90; - cur->angle += FixedAngle(cur->info->speed); + cur->angle += FixedAngle(speed); if (cur->extravalue1 < radius) cur->extravalue1 += P_AproxDistance(cur->extravalue1, radius) / 12; From 9d51ef8e82848b93f750a8f93c53425ed9cce28c Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Wed, 30 Jan 2019 14:42:24 -0500 Subject: [PATCH 40/58] Play hit confirm sound for shields --- src/p_map.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 051a1e6f..41e5a455 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -752,9 +752,7 @@ static boolean PIT_CheckThing(mobj_t *thing) // Player Damage P_DamageMobj(thing, tmthing, tmthing->target, 1); K_KartBouncing(thing, tmthing, false, false); - - if (tmthing->type == MT_ORBINAUT || tmthing->type == MT_JAWZ || tmthing->type == MT_JAWZ_DUD) - S_StartSound(thing, sfx_s3k7b); + S_StartSound(thing, sfx_s3k7b); // This Item Damage if (tmthing->eflags & MFE_VERTICALFLIP) @@ -1035,9 +1033,7 @@ static boolean PIT_CheckThing(mobj_t *thing) // Player Damage P_DamageMobj(tmthing, thing, thing->target, 1); K_KartBouncing(tmthing, thing, false, false); - - if (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ || thing->type == MT_JAWZ_DUD) - S_StartSound(tmthing, sfx_s3k7b); + S_StartSound(tmthing, sfx_s3k7b); // Other Item Damage if (thing->eflags & MFE_VERTICALFLIP) From a3cd1310171ac68472b23a636c669902445eabfc Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Wed, 30 Jan 2019 15:02:24 -0500 Subject: [PATCH 41/58] Don't bump while flashing --- src/k_kart.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/k_kart.c b/src/k_kart.c index a9e1f9be..d09e3b60 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1068,6 +1068,21 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid) || (mobj2->player && mobj2->player->kartstuff[k_respawn])) return; + // Don't bump if you're flashing + if (mobj1->player && mobj1->player->powers[pw_flashing] > 0 + && mobj1->player->powers[pw_flashing] < K_GetKartFlashing(mobj1->player)-1) + { + mobj1->player->powers[pw_flashing]++; + return; + } + + if (mobj2->player && mobj2->player->powers[pw_flashing] > 0 + && mobj2->player->powers[pw_flashing] < K_GetKartFlashing(mobj2->player)-1) + { + mobj2->player->powers[pw_flashing]++; + return; + } + // Don't bump if you've recently bumped if (mobj1->player && mobj1->player->kartstuff[k_justbumped]) { From 3cb468aec8ba403be14c445736a680ebc159b3bb Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Wed, 30 Jan 2019 15:39:29 -0500 Subject: [PATCH 42/58] Add delay to Jawz target switching, set Jawz target when fired --- src/d_player.h | 3 ++- src/dehacked.c | 3 ++- src/k_kart.c | 28 +++++++++++++++++++++++++--- src/p_enemy.c | 4 ++-- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 27fdef8d..5ce9066b 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -348,10 +348,11 @@ typedef enum k_wanted, // Timer for determining WANTED status, lowers when hitting people, prevents the game turning into Camp Lazlo k_yougotem, // "You Got Em" gfx when hitting someone as a karma player via a method that gets you back in the game instantly - // v1.0.2 vars + // v1.0.2+ vars k_itemblink, // Item flashing after roulette, prevents Hyudoro stealing AND serves as a mashing indicator k_itemblinkmode, // Type of flashing: 0 = white (normal), 1 = red (mashing), 2 = rainbow (enhanced items) k_getsparks, // Disable drift sparks at low speed, JUST enough to give acceleration the actual headstart above speed + k_jawztargetdelay, // Delay for Jawz target switching, to make it less twitchy NUMKARTSTUFF } kartstufftype_t; diff --git a/src/dehacked.c b/src/dehacked.c index 0ad67ff0..b03530a4 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8333,7 +8333,8 @@ static const char *const KARTSTUFF_LIST[] = { "ITEMBLINK", "ITEMBLINKMODE", - "GETSPARKS" + "GETSPARKS", + "JAWZTARGETDELAY" }; static const char *const HUDITEMS_LIST[] = { diff --git a/src/k_kart.c b/src/k_kart.c index d09e3b60..f2490c9b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2517,7 +2517,17 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I break; case MT_JAWZ: if (source && source->player) + { + INT32 lasttarg = source->player->kartstuff[k_lastjawztarget]; th->cvmem = source->player->skincolor; + if ((lasttarg >= 0 && lasttarg < MAXPLAYERS) + && playeringame[lasttarg] + && !players[lasttarg].spectator + && players[lasttarg].mo) + { + P_SetTarget(&th->tracer, players[lasttarg].mo); + } + } else th->cvmem = SKINCOLOR_KETCHUP; /* FALLTHRU */ @@ -4454,12 +4464,22 @@ void K_KartPlayerAfterThink(player_t *player) // Jawz reticule (seeking) if (player->kartstuff[k_itemtype] == KITEM_JAWZ && player->kartstuff[k_itemheld]) { - player_t *targ = K_FindJawzTarget(player->mo, player); + INT32 lasttarg = player->kartstuff[k_lastjawztarget]; + player_t *targ; mobj_t *ret; - if (!targ) + if (player->kartstuff[k_jawztargetdelay] && playeringame[lasttarg] && !players[lasttarg].spectator) + { + targ = &players[lasttarg]; + player->kartstuff[k_jawztargetdelay]--; + } + else + targ = K_FindJawzTarget(player->mo, player); + + if (!targ || !targ->mo || P_MobjWasRemoved(targ->mo)) { player->kartstuff[k_lastjawztarget] = -1; + player->kartstuff[k_jawztargetdelay] = 0; return; } @@ -4469,7 +4489,7 @@ void K_KartPlayerAfterThink(player_t *player) ret->tics = 1; ret->color = player->skincolor; - if (targ-players != player->kartstuff[k_lastjawztarget]) + if (targ-players != lasttarg) { if (P_IsLocalPlayer(player) || P_IsLocalPlayer(targ)) S_StartSound(NULL, sfx_s3k89); @@ -4477,11 +4497,13 @@ void K_KartPlayerAfterThink(player_t *player) S_StartSound(targ->mo, sfx_s3k89); player->kartstuff[k_lastjawztarget] = targ-players; + player->kartstuff[k_jawztargetdelay] = 5; } } else { player->kartstuff[k_lastjawztarget] = -1; + player->kartstuff[k_jawztargetdelay] = 0; } } diff --git a/src/p_enemy.c b/src/p_enemy.c index 8a6d7597..9d3aa951 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -8264,8 +8264,8 @@ void A_JawzChase(mobj_t *actor) if (actor->tracer) { - if (G_RaceGametype()) // Stop looking after first target in race - actor->extravalue1 = 1; + /*if (G_RaceGametype()) // Stop looking after first target in race + actor->extravalue1 = 1;*/ if (actor->tracer->health) { From f3644505bebfe07041ddd19495f37c51a0457e04 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Wed, 30 Jan 2019 15:41:15 -0500 Subject: [PATCH 43/58] Increase target cone for Race --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index f2490c9b..426ce2f6 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3932,7 +3932,7 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source) if (thisang > ANGLE_180) thisang = InvAngle(thisang); - if (thisang > ANGLE_45) // Don't go for people who are behind you + if (thisang > (G_RaceGametype() ? ANGLE_67h : ANGLE_45)) // Don't go for people who are behind you continue; // Jawz only go after the person directly ahead of you in race... sort of literally now! From 9984f0e217e632d3fcb6eb6e29e4fc9a753b880c Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Wed, 30 Jan 2019 15:43:45 -0500 Subject: [PATCH 44/58] Reorganize these checks --- src/k_kart.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 426ce2f6..9a8adb22 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3932,13 +3932,14 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source) if (thisang > ANGLE_180) thisang = InvAngle(thisang); - if (thisang > (G_RaceGametype() ? ANGLE_67h : ANGLE_45)) // Don't go for people who are behind you - continue; - // Jawz only go after the person directly ahead of you in race... sort of literally now! if (G_RaceGametype()) { - if (player->kartstuff[k_position] >= source->kartstuff[k_position]) // Don't pay attention to people behind you + // Don't go for people who are behind you + if (thisang > ANGLE_67h) + continue; + // Don't pay attention to people who aren't above your position + if (player->kartstuff[k_position] >= source->kartstuff[k_position]) continue; if ((best == -1) || (player->kartstuff[k_position] > best)) { @@ -3951,6 +3952,11 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source) fixed_t thisdist; fixed_t thisavg; + // Don't go for people who are behind you + if (thisang > ANGLE_45) + continue; + + // Don't pay attention to dead players if (player->kartstuff[k_bumper] <= 0) continue; From 34b027e8ba7457f595b685c695572a48f180e347 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Wed, 30 Jan 2019 15:57:46 -0500 Subject: [PATCH 45/58] Shift around flashing bump stuff --- src/k_kart.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 9a8adb22..850b703a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1068,19 +1068,24 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid) || (mobj2->player && mobj2->player->kartstuff[k_respawn])) return; - // Don't bump if you're flashing - if (mobj1->player && mobj1->player->powers[pw_flashing] > 0 - && mobj1->player->powers[pw_flashing] < K_GetKartFlashing(mobj1->player)-1) - { - mobj1->player->powers[pw_flashing]++; - return; - } + { // Don't bump if you're flashing + INT32 flash; - if (mobj2->player && mobj2->player->powers[pw_flashing] > 0 - && mobj2->player->powers[pw_flashing] < K_GetKartFlashing(mobj2->player)-1) - { - mobj2->player->powers[pw_flashing]++; - return; + flash = K_GetKartFlashing(mobj1->player); + if (mobj1->player && mobj1->player->powers[pw_flashing] > 0 && mobj1->player->powers[pw_flashing] < flash) + { + if (mobj1->player->powers[pw_flashing] < flash-1) + mobj1->player->powers[pw_flashing]++; + return; + } + + flash = K_GetKartFlashing(mobj2->player); + if (mobj2->player && mobj2->player->powers[pw_flashing] > 0 && mobj2->player->powers[pw_flashing] < flash) + { + if (mobj2->player->powers[pw_flashing] < flash-1) + mobj2->player->powers[pw_flashing]++; + return; + } } // Don't bump if you've recently bumped From b332a3e16355301fb4b12ceeab08d3fe09a13c8a Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 1 Feb 2019 18:51:15 -0500 Subject: [PATCH 46/58] Tweak incorrect capitalisation. --- src/m_menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index ee94ab3c..92318687 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4561,7 +4561,7 @@ static boolean M_AddonsRefresh(void) { S_StartSound(NULL, sfx_s26d); if (refreshdirmenu & REFRESHDIR_MAX) - message = va("%c%s\x80\nMaximum number of add-ons reached.\nA file could not be loaded.\nif you wish to play with this add-on, restart the game to clear existing ones.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); + message = va("%c%s\x80\nMaximum number of add-ons reached.\nA file could not be loaded.\nIf you wish to play with this add-on, restart the game to clear existing ones.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); else message = va("%c%s\x80\nA file was not loaded.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); } @@ -4573,7 +4573,7 @@ static boolean M_AddonsRefresh(void) else if (majormods && !prevmajormods) { S_StartSound(NULL, sfx_s221); - message = va("%c%s\x80\nGameplay has now been modified.\nif you wish to play record attack mode, restart the game to clear existing add-ons.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); + message = va("%c%s\x80\nGameplay has now been modified.\nIf you wish to play Record Attack mode, restart the game to clear existing add-ons.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); prevmajormods = majormods; } From 6a14d79cf01d2961f5d600d48857492e57fd8373 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sat, 2 Feb 2019 00:58:51 -0500 Subject: [PATCH 47/58] Offroad spark fix & sink --- src/k_kart.c | 10 ++++------ src/p_mobj.c | 4 +--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 850b703a..aa6a0cc3 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1637,10 +1637,8 @@ static void K_GetKartBoostPower(player_t *player) && player->kartstuff[k_offroad] >= 0) boostpower = FixedDiv(boostpower, player->kartstuff[k_offroad] + FRACUNIT); - if (player->kartstuff[k_itemtype] == KITEM_KITCHENSINK) - boostpower = max((TICRATE/2), (5*TICRATE)-(player->kartstuff[k_bananadrag]/2))*boostpower/(5*TICRATE); - else if (player->kartstuff[k_bananadrag] > TICRATE) - boostpower = 4*boostpower/5; + if (player->kartstuff[k_bananadrag] > TICRATE) + boostpower = (4*boostpower)/5; // Banana drag/offroad dust if (boostpower < FRACUNIT @@ -4716,9 +4714,9 @@ static void K_KartDrift(player_t *player, boolean onground) } // Disable drift-sparks until you're going fast enough - if (player->kartstuff[k_getsparks] == 0) + if (player->kartstuff[k_getsparks] == 0 || player->kartstuff[k_offroad]) driftadditive = 0; - if (player->speed > minspeed*2 && !player->kartstuff[k_offroad]) + if (player->speed > minspeed*2) player->kartstuff[k_getsparks] = 1; // This spawns the drift sparks diff --git a/src/p_mobj.c b/src/p_mobj.c index ed53f647..746fc1af 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1408,10 +1408,8 @@ fixed_t P_GetMobjGravity(mobj_t *mo) case MT_JAWZ: case MT_JAWZ_DUD: case MT_SSMINE: - gravityadd = (5*gravityadd)/2; - break; case MT_SINK: - gravityadd = (5*gravityadd); // Double gravity + gravityadd = (5*gravityadd)/2; break; case MT_SIGN: gravityadd /= 8; From d9f16d2aaf4249a30b0771a05051f2aecf39473c Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sat, 2 Feb 2019 01:43:32 -0500 Subject: [PATCH 48/58] Offroad code cleanup --- src/k_kart.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index aa6a0cc3..5a45d5ff 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1239,9 +1239,8 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo, sector_t *sec) for (i = 2; i < 5; i++) { if ((sec2 && GETSECSPECIAL(sec2->special, 1) == i) - || (P_IsObjectOnRealGround(mo, sec) - && GETSECSPECIAL(sec->special, 1) == i)) - return i; + || (P_IsObjectOnRealGround(mo, sec) && GETSECSPECIAL(sec->special, 1) == i)) + return i-1; } return 0; @@ -1258,19 +1257,9 @@ static void K_UpdateOffroad(player_t *player) fixed_t offroad; sector_t *nextsector = R_PointInSubsector( player->mo->x + player->mo->momx*2, player->mo->y + player->mo->momy*2)->sector; + UINT8 offroadstrength = K_CheckOffroadCollide(player->mo, nextsector); - fixed_t offroadstrength = 0; - - if (K_CheckOffroadCollide(player->mo, nextsector) == 2) // Weak Offroad - offroadstrength = 1; - else if (K_CheckOffroadCollide(player->mo, nextsector) == 3) // Mid Offroad - offroadstrength = 2; - else if (K_CheckOffroadCollide(player->mo, nextsector) == 4) // Strong Offroad - offroadstrength = 3; - - // If you are offroad, a timer starts. Depending on your weight value, the timer increments differently. - //if ((nextsector->special & 256) && nextsector->special != 768 - // && nextsector->special != 1024 && nextsector->special != 4864) + // If you are in offroad, a timer starts. if (offroadstrength) { if (K_CheckOffroadCollide(player->mo, player->mo->subsector->sector) && player->kartstuff[k_offroad] == 0) @@ -1278,7 +1267,7 @@ static void K_UpdateOffroad(player_t *player) if (player->kartstuff[k_offroad] > 0) { - offroad = (FRACUNIT * offroadstrength) / (TICRATE/2); + offroad = (offroadstrength << FRACBITS) / (TICRATE/2); //if (player->kartstuff[k_growshrinktimer] > 1) // grow slows down half as fast // offroad /= 2; @@ -1286,8 +1275,8 @@ static void K_UpdateOffroad(player_t *player) player->kartstuff[k_offroad] += offroad; } - if (player->kartstuff[k_offroad] > FRACUNIT*offroadstrength) - player->kartstuff[k_offroad] = FRACUNIT*offroadstrength; + if (player->kartstuff[k_offroad] > (offroadstrength << FRACBITS)) + player->kartstuff[k_offroad] = (offroadstrength << FRACBITS); } else player->kartstuff[k_offroad] = 0; From dff5cb049f221e474e8f4339bc3df8cb9b01e944 Mon Sep 17 00:00:00 2001 From: Sryder Date: Sat, 2 Feb 2019 21:53:27 +0000 Subject: [PATCH 49/58] rename PT_WIPETIME to PT_BASICKEEPALIVE to be more obvious what it does --- src/d_clisrv.c | 6 +++--- src/d_clisrv.h | 2 +- src/d_net.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 71fdf6fb..961c1e59 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4083,7 +4083,7 @@ FILESTAMP else if (resynch_score[node]) --resynch_score[node]; break; - case PT_WIPETIME: + case PT_BASICKEEPALIVE: if (client) break; @@ -4601,11 +4601,11 @@ static INT16 Consistancy(void) return (INT16)(ret & 0xFFFF); } -// confusing, but this DOESN'T send PT_NODEKEEPALIVE, it sends PT_WIPETIME +// confusing, but this DOESN'T send PT_NODEKEEPALIVE, it sends PT_BASICKEEPALIVE // used during wipes to tell the server that a node is still connected static void CL_SendClientKeepAlive(void) { - netbuffer->packettype = PT_WIPETIME; + netbuffer->packettype = PT_BASICKEEPALIVE; HSendPacket(servernode, false, 0, 0); } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index af507739..62bd8bc1 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -71,7 +71,7 @@ typedef enum PT_CLIENT3MIS, PT_CLIENT4CMD, // 4P PT_CLIENT4MIS, - PT_WIPETIME, // Keep the network alive during wipes, as tics aren't advanced and NetUpdate isn't called + PT_BASICKEEPALIVE,// Keep the network alive during wipes, as tics aren't advanced and NetUpdate isn't called PT_CANFAIL, // This is kind of a priority. Anything bigger than CANFAIL // allows HSendPacket(*, true, *, *) to return false. diff --git a/src/d_net.c b/src/d_net.c index 7c8fc956..7e16297b 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -903,7 +903,7 @@ static void DebugPrintpacket(const char *header) (UINT32)ExpandTics(netbuffer->u.clientpak.client_tic), (UINT32)ExpandTics (netbuffer->u.clientpak.resendfrom)); break; - case PT_WIPETIME: + case PT_BASICKEEPALIVE: fprintf(debugfile, " wipetime\n"); break; case PT_TEXTCMD: From 59730c5db61c763d75f8262bb4b755871e7fb552 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sun, 3 Feb 2019 16:43:11 -0500 Subject: [PATCH 50/58] In-game player cap & spectator queue Force everyone beyond a certain point to spectate -- spectators get to queue up. In response to me doing a 1v1 match, tons of people wanting to join to watch, and just relying on honor system to prevent mid-joiners. Spectators are prioritized by how long they've been waiting. I'm thinking of hijacking base SRB2's team scramble for a scramble option later. --- src/d_netcmd.c | 4 ++++ src/d_netcmd.h | 2 +- src/d_player.h | 1 + src/dehacked.c | 3 ++- src/k_kart.c | 64 +++++++++++++++++++++++++++++++++++++++++--------- src/p_user.c | 2 ++ src/st_stuff.c | 39 +++++++++++++++++------------- 7 files changed, 86 insertions(+), 29 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 775f2225..5773d590 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -236,6 +236,9 @@ static consvar_t cv_dummyconsvar = {"dummyconsvar", "Off", CV_CALL|CV_NOSHOWHELP consvar_t cv_restrictskinchange = {"restrictskinchange", "No", CV_NETVAR|CV_CHEAT, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowteamchange = {"allowteamchange", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t ingamecap_cons_t[] = {{0, "MIN"}, {MAXPLAYERS-1, "MAX"}, {0, NULL}}; +consvar_t cv_ingamecap = {"ingamecap", "0", CV_NETVAR, ingamecap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_startinglives = {"startinglives", "3", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, startingliveslimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t respawntime_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; @@ -642,6 +645,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_allowexitlevel); CV_RegisterVar(&cv_restrictskinchange); CV_RegisterVar(&cv_allowteamchange); + CV_RegisterVar(&cv_ingamecap); CV_RegisterVar(&cv_respawntime); CV_RegisterVar(&cv_killingdead); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 2269996f..c590eee6 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -93,7 +93,7 @@ extern consvar_t cv_mute; extern consvar_t cv_killingdead; extern consvar_t cv_pause; -extern consvar_t cv_restrictskinchange, cv_allowteamchange, cv_respawntime; +extern consvar_t cv_restrictskinchange, cv_allowteamchange, cv_ingamecap, cv_respawntime; /*extern consvar_t cv_teleporters, cv_superring, cv_supersneakers, cv_invincibility; extern consvar_t cv_jumpshield, cv_watershield, cv_ringshield, cv_forceshield, cv_bombshield; diff --git a/src/d_player.h b/src/d_player.h index 27fdef8d..58d2df4b 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -352,6 +352,7 @@ typedef enum k_itemblink, // Item flashing after roulette, prevents Hyudoro stealing AND serves as a mashing indicator k_itemblinkmode, // Type of flashing: 0 = white (normal), 1 = red (mashing), 2 = rainbow (enhanced items) k_getsparks, // Disable drift sparks at low speed, JUST enough to give acceleration the actual headstart above speed + k_spectatewait, // How long have you been waiting as a spectator NUMKARTSTUFF } kartstufftype_t; diff --git a/src/dehacked.c b/src/dehacked.c index b9e29bc4..67080bd7 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8299,7 +8299,8 @@ static const char *const KARTSTUFF_LIST[] = { "ITEMBLINK", "ITEMBLINKMODE", - "GETSPARKS" + "GETSPARKS", + "SPECTATEWAIT" }; static const char *const HUDITEMS_LIST[] = { diff --git a/src/k_kart.c b/src/k_kart.c index dde4849e..8cb0941e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5744,9 +5744,22 @@ void K_CheckBumpers(void) void K_CheckSpectateStatus(void) { UINT8 respawnlist[MAXPLAYERS]; - UINT8 i, numingame = 0, numjoiners = 0; + UINT8 i, j, numingame = 0, numjoiners = 0; - if (!cv_allowteamchange.value) return; + // Maintain spectate wait timer + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + if (players[i].spectator && (players[i].pflags & PF_WANTSTOJOIN)) + players[i].kartstuff[k_spectatewait]++; + else + players[i].kartstuff[k_spectatewait] = 0; + } + + // No one's allowed to join + if (!cv_allowteamchange.value) + return; // Get the number of players in game, and the players to be de-spectated. for (i = 0; i < MAXPLAYERS; i++) @@ -5757,16 +5770,18 @@ void K_CheckSpectateStatus(void) if (!players[i].spectator) { numingame++; + if (cv_ingamecap.value && numingame >= cv_ingamecap.value) // DON'T allow if you've hit the in-game player cap + return; if (gamestate != GS_LEVEL) // Allow if you're not in a level - continue; + continue; if (players[i].exiting) // DON'T allow if anyone's exiting return; if (numingame < 2 || leveltime < starttime || mapreset) // Allow if the match hasn't started yet - continue; + continue; if (leveltime > (starttime + 20*TICRATE)) // DON'T allow if the match is 20 seconds in - return; - if (G_RaceGametype() && players[i].laps) // DON'T allow if the race is at 2 laps - return; + return; + if (G_RaceGametype() && players[i].laps) // DON'T allow if the race is at 2 laps + return; continue; } else if (!(players[i].pflags & PF_WANTSTOJOIN)) @@ -5779,16 +5794,43 @@ void K_CheckSpectateStatus(void) if (!numjoiners) return; - // Reset the match if you're in an empty server - if (!mapreset && gamestate == GS_LEVEL && leveltime >= starttime && (numingame < 2 && numingame+numjoiners >= 2)) + // Organize by spectate wait timer { - S_ChangeMusicInternal("chalng", false); // COME ON - mapreset = 3*TICRATE; // Even though only the server uses this for game logic, set for everyone for HUD in the future + UINT8 oldrespawnlist[MAXPLAYERS]; + + for (i = 0; i < numjoiners; i++) // copy old table before modifying + oldrespawnlist[i] = respawnlist[i]; + + for (i = 0; i < numjoiners; i++) + { + UINT8 pos = 0; + + for (j = 0; j < numjoiners; j++) + { + if (j == i) + continue; + if (players[oldrespawnlist[j]].kartstuff[k_spectatewait] > players[oldrespawnlist[i]].kartstuff[k_spectatewait]) + pos++; + } + + respawnlist[pos] = oldrespawnlist[i]; + } } // Finally, we can de-spectate everyone! for (i = 0; i < numjoiners; i++) + { + if (cv_ingamecap.value && numingame+i >= cv_ingamecap.value) // Hit the in-game player cap while adding people? + break; P_SpectatorJoinGame(&players[respawnlist[i]]); + } + + // Reset the match if you're in an empty server + if (!mapreset && gamestate == GS_LEVEL && leveltime >= starttime && (numingame < 2 && numingame+i >= 2)) // use previous i value + { + S_ChangeMusicInternal("chalng", false); // COME ON + mapreset = 3*TICRATE; // Even though only the server uses this for game logic, set for everyone for HUD + } } //} diff --git a/src/p_user.c b/src/p_user.c index d7423d80..0978a0da 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8763,6 +8763,7 @@ boolean P_SpectatorJoinGame(player_t *player) } player->spectator = false; player->pflags &= ~PF_WANTSTOJOIN; + player->kartstuff[k_spectatewait] = 0; player->ctfteam = changeto; player->playerstate = PST_REBORN; @@ -8787,6 +8788,7 @@ boolean P_SpectatorJoinGame(player_t *player) } player->spectator = false; player->pflags &= ~PF_WANTSTOJOIN; + player->kartstuff[k_spectatewait] = 0; player->playerstate = PST_REBORN; //Reset away view diff --git a/src/st_stuff.c b/src/st_stuff.c index 8ebd2132..36a658ae 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1952,31 +1952,38 @@ static void ST_overlayDrawer(void) #endif ) { + const char *itemtxt = M_GetText("Item - Join Game"); + + if (stplyr->powers[pw_flashing]) + itemtxt = M_GetText("Item - . . ."); + else if (stplyr->pflags & PF_WANTSTOJOIN) + itemtxt = M_GetText("Item - Cancel Join"); + else if (G_GametypeHasTeams()) + itemtxt = M_GetText("Item - Join Team"); + + if (cv_ingamecap.value) + { + UINT8 numingame = 0; + UINT8 i; + + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i] && !players[i].spectator) + numingame++; + + itemtxt = va("%s (%s: %d)", itemtxt, M_GetText("Slots left"), max(0, cv_ingamecap.value - numingame)); + } + // SRB2kart: changed positions & text if (splitscreen) { INT32 splitflags = K_calcSplitFlags(0); V_DrawThinString(2, (BASEVIDHEIGHT/2)-20, V_YELLOWMAP|V_HUDTRANSHALF|splitflags, M_GetText("- SPECTATING -")); - if (stplyr->powers[pw_flashing]) - V_DrawThinString(2, (BASEVIDHEIGHT/2)-10, V_HUDTRANSHALF|splitflags, M_GetText("Item - . . .")); - else if (stplyr->pflags & PF_WANTSTOJOIN) - V_DrawThinString(2, (BASEVIDHEIGHT/2)-10, V_HUDTRANSHALF|splitflags, M_GetText("Item - Cancel Join")); - /*else if (G_GametypeHasTeams()) - V_DrawThinString(2, (BASEVIDHEIGHT/2)-10, V_HUDTRANSHALF|splitflags, M_GetText("Item - Join Team"));*/ - else - V_DrawThinString(2, (BASEVIDHEIGHT/2)-10, V_HUDTRANSHALF|splitflags, M_GetText("Item - Join Game")); + V_DrawThinString(2, (BASEVIDHEIGHT/2)-10, V_HUDTRANSHALF|splitflags, itemtxt); } else { V_DrawString(2, BASEVIDHEIGHT-40, V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); - if (stplyr->powers[pw_flashing]) - V_DrawString(2, BASEVIDHEIGHT-30, V_HUDTRANSHALF, M_GetText("Item - . . .")); - else if (stplyr->pflags & PF_WANTSTOJOIN) - V_DrawString(2, BASEVIDHEIGHT-30, V_HUDTRANSHALF, M_GetText("Item - Cancel Join")); - /*else if (G_GametypeHasTeams()) - V_DrawString(2, BASEVIDHEIGHT-30, V_HUDTRANSHALF, M_GetText("Item - Join Team"));*/ - else - V_DrawString(2, BASEVIDHEIGHT-30, V_HUDTRANSHALF, M_GetText("Item - Join Game")); + V_DrawString(2, BASEVIDHEIGHT-30, V_HUDTRANSHALF, itemtxt); V_DrawString(2, BASEVIDHEIGHT-20, V_HUDTRANSHALF, M_GetText("Accelerate - Float")); V_DrawString(2, BASEVIDHEIGHT-10, V_HUDTRANSHALF, M_GetText("Brake - Sink")); } From a6ac6ecdc57970a997a322e28eef93ef275143cf Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sun, 3 Feb 2019 17:15:33 -0500 Subject: [PATCH 51/58] Missed this --- src/k_kart.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/k_kart.c b/src/k_kart.c index 8cb0941e..d77c76fa 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5795,6 +5795,7 @@ void K_CheckSpectateStatus(void) return; // Organize by spectate wait timer + if (cv_ingamecap.value) { UINT8 oldrespawnlist[MAXPLAYERS]; From 068ee93422a8db4d037aeead2327ac2284e8f558 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 3 Feb 2019 23:09:09 +0000 Subject: [PATCH 52/58] gotta break a few eggboxes to fix a crash --- src/k_kart.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 37c70681..218e8c6f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3021,7 +3021,7 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map newz = player->mo->z; } - mo = P_SpawnMobj(newx, newy, newz, mapthing); + mo = P_SpawnMobj(newx, newy, newz, mapthing); // this will never return null because collision isn't processed here if (P_MobjFlip(player->mo) < 0) mo->z = player->mo->z + player->mo->height - mo->height; @@ -3033,7 +3033,9 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map { // floorz and ceilingz aren't properly set to account for FOFs and Polyobjects on spawn // This should set it for FOFs - P_TeleportMove(mo, mo->x, mo->y, mo->z); + P_TeleportMove(mo, mo->x, mo->y, mo->z); // however, THIS can fuck up your day. just absolutely ruin you. + if (P_MobjWasRemoved(mo)) + return NULL; if (P_MobjFlip(mo) > 0) { @@ -3051,11 +3053,8 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map } } - if (mo) - { - if (player->mo->eflags & MFE_VERTICALFLIP) - mo->eflags |= MFE_VERTICALFLIP; - } + if (player->mo->eflags & MFE_VERTICALFLIP) + mo->eflags |= MFE_VERTICALFLIP; } } From 503e4f977f231665cbd9891b05027f8a925346f2 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 3 Feb 2019 23:37:19 +0000 Subject: [PATCH 53/58] Show WANTED and minimap in battle splits even when p1 is nuked. --- src/k_kart.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 218e8c6f..755f3802 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8348,14 +8348,6 @@ void K_drawKartHUD(void) || ((splitscreen > 2 && stplyr == &players[fourthdisplayplayer]) && !camera4.chase)) K_drawKartFirstPerson(); -/* if (splitscreen == 2) // Player 4 in 3P is the minimap :p - { -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_minimap)) -#endif - K_drawKartMinimap(); - }*/ - // Draw full screen stuff that turns off the rest of the HUD if (mapreset && stplyr == &players[displayplayer]) { @@ -8371,7 +8363,9 @@ void K_drawKartHUD(void) && stplyr->playerstate == PST_LIVE))) { K_drawBattleFullscreen(); - return; + if (!splitscreen) + return; + isfreeplay = true; // variable reuse, since isfreeplay will not be otherwise set until after everything we want to happen } // Draw the CHECK indicator before the other items, so it's overlapped by everything else @@ -8392,10 +8386,12 @@ void K_drawKartHUD(void) #ifdef HAVE_BLUA if (LUA_HudEnabled(hud_minimap)) #endif - K_drawKartMinimap(); // 3P splitscreen is handled above - + K_drawKartMinimap(); } + if (isfreeplay) + return; + // Draw the item window #ifdef HAVE_BLUA if (LUA_HudEnabled(hud_item)) From 55bb82eae8ad1367580840c807792e50932baac1 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 3 Feb 2019 23:50:02 +0000 Subject: [PATCH 54/58] Change order of operations so that fullscreen stuff is done in front of minimap, to match other two/three players in 3/4p. --- src/k_kart.c | 59 ++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 755f3802..e59fbfc9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8336,6 +8336,7 @@ static void K_drawCheckpointDebugger(void) void K_drawKartHUD(void) { boolean isfreeplay = false; + boolean battlefullscreen = false; // Define the X and Y for each drawn object // This is handled by console/menu values @@ -8355,42 +8356,42 @@ void K_drawKartHUD(void) return; } - if ((G_BattleGametype()) + battlefullscreen = ((G_BattleGametype()) && (stplyr->exiting || (stplyr->kartstuff[k_bumper] <= 0 && stplyr->kartstuff[k_comebacktimer] && comeback - && stplyr->playerstate == PST_LIVE))) + && stplyr->playerstate == PST_LIVE))); + + if (!battlefullscreen || splitscreen) + { + // Draw the CHECK indicator before the other items, so it's overlapped by everything else + if (cv_kartcheck.value && !splitscreen && !players[displayplayer].exiting) + K_drawKartPlayerCheck(); + + // Draw WANTED status + if (G_BattleGametype()) + { +#ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_wanted)) +#endif + K_drawKartWanted(); + } + + if (cv_kartminimap.value && !titledemo) + { +#ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_minimap)) +#endif + K_drawKartMinimap(); + } + } + + if (battlefullscreen) { K_drawBattleFullscreen(); - if (!splitscreen) - return; - isfreeplay = true; // variable reuse, since isfreeplay will not be otherwise set until after everything we want to happen - } - - // Draw the CHECK indicator before the other items, so it's overlapped by everything else - if (cv_kartcheck.value && !splitscreen && !players[displayplayer].exiting) - K_drawKartPlayerCheck(); - - // Draw WANTED status - if (G_BattleGametype()) - { -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_wanted)) -#endif - K_drawKartWanted(); - } - - if (cv_kartminimap.value && !titledemo) - { -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_minimap)) -#endif - K_drawKartMinimap(); - } - - if (isfreeplay) return; + } // Draw the item window #ifdef HAVE_BLUA From fd529f93634252ed254c69d4c3439cfb34ba516e Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sun, 3 Feb 2019 23:23:41 -0500 Subject: [PATCH 55/58] fickle suggestions --- src/k_kart.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 51bbccbb..b877e13f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5808,19 +5808,20 @@ void K_CheckSpectateStatus(void) if (cv_ingamecap.value) { UINT8 oldrespawnlist[MAXPLAYERS]; - - for (i = 0; i < numjoiners; i++) // copy old table before modifying - oldrespawnlist[i] = respawnlist[i]; - + memcpy(oldrespawnlist, respawnlist, numjoiners); for (i = 0; i < numjoiners; i++) { UINT8 pos = 0; + INT32 ispecwait = players[oldrespawnlist[i]].kartstuff[k_spectatewait]; for (j = 0; j < numjoiners; j++) { + INT32 jspecwait = players[oldrespawnlist[j]].kartstuff[k_spectatewait]; if (j == i) continue; - if (players[oldrespawnlist[j]].kartstuff[k_spectatewait] > players[oldrespawnlist[i]].kartstuff[k_spectatewait]) + if (jspecwait > ispecwait) + pos++; + else if (jspecwait == ispecwait && j < i) pos++; } From caba5cb02e187aec46e4a8d5b18e7c0b2dfe801c Mon Sep 17 00:00:00 2001 From: Sryder Date: Mon, 4 Feb 2019 21:54:10 +0000 Subject: [PATCH 56/58] P_NetKeepAlive should also be here because it potentially pauses mid-game! --- src/p_setup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index 912791cf..58e13c2e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2857,6 +2857,9 @@ boolean P_SetupLevel(boolean skipprecip) lastwipetic = nowtime; if (moviemode) // make sure we save frames for the white hold too M_SaveFrame(); + + // Keep the network alive + NetKeepAlive(); } ranspecialwipe = 1; @@ -3435,7 +3438,7 @@ boolean P_AddWadFile(const char *wadfilename) // R_AddSkins(wadnum); // faB: wadfile index in wadfiles[] - // + // // edit music defs // S_LoadMusicDefs(wadnum); From 3b61cba1a762bfeb01bbb5899830d6ec97f5943a Mon Sep 17 00:00:00 2001 From: Sryder Date: Mon, 4 Feb 2019 22:02:40 +0000 Subject: [PATCH 57/58] The string that got away from my memory --- src/d_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_net.c b/src/d_net.c index 7e16297b..6702a60a 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -904,7 +904,7 @@ static void DebugPrintpacket(const char *header) (UINT32)ExpandTics (netbuffer->u.clientpak.resendfrom)); break; case PT_BASICKEEPALIVE: - fprintf(debugfile, " wipetime\n"); + fprintf(debugfile, " keep alive\n"); break; case PT_TEXTCMD: case PT_TEXTCMD2: From 8e41f09c59a05a57c2706356f8bf75de8cf8e5fa Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Mon, 4 Feb 2019 22:22:12 -0500 Subject: [PATCH 58/58] why does this trigger ERRORMODE now?! --- src/f_wipe.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/f_wipe.c b/src/f_wipe.c index eaa5a013..3c8713d1 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -97,7 +97,7 @@ static fixed_t paldiv; * \return fademask_t for lump */ static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) { - static char lumpname[10] = "FADEmmss"; + static char lumpname[9] = "FADEmmss"; static fademask_t fm = {NULL,0,0,0,0,0}; lumpnum_t lumpnum; UINT8 *lump, *mask; @@ -107,7 +107,14 @@ static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) { if (masknum > 99 || scrnnum > 99) goto freemask; - sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)masknum, (UINT16)scrnnum); + // SRB2Kart: This suddenly triggers ERRORMODE now + //sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)masknum, (UINT16)scrnnum); + + lumpname[4] = '0'+(masknum/10); + lumpname[5] = '0'+(masknum%10); + + lumpname[6] = '0'+(scrnnum/10); + lumpname[7] = '0'+(scrnnum%10); lumpnum = W_CheckNumForName(lumpname); if (lumpnum == LUMPERROR)