From a099f825a77c64ee61adb546d14b7e5b6eca62bd Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 06:42:50 +0200 Subject: [PATCH 01/12] missed removing this --- src/d_netcmd.c | 18 +++++++++--------- src/r_things.c | 1 - src/w_wad.c | 5 +++++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 3b53dd8c4..d3b9ca5b4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4591,7 +4591,7 @@ static void Command_GLocalSkin (void) char* fuck; // local skin name - if (!( first_option = COM_FirstOption() )) + if (!(first_option = COM_FirstOption())) first_option = COM_Argc(); if (first_option < 2) @@ -4599,14 +4599,14 @@ static void Command_GLocalSkin (void) /* holy fucking shit */ CONS_Printf("localskin [-player ] [-display ] [-all]:\n"); CONS_Printf(M_GetText("Set a localskin via its internal name (usually printed on the console).\n\n\ -* Using \"-player\" will set a localskin to a specified player.\n\ - Defaults to yourself.\n\ -* Using \"-display\" will set a localskin to the displayed player.\n\ - Defaults to 0, which is the first player displayed.\n\ - Can go up to 3 for splitscreen.\n\ -* Using \"-all\" will set a localskin to ALL players.\n\ -* \"localskin none\" removes the localskin, just like how\n\ - \"forceskin none\" does.\n")); + * Using \"-player\" will set a localskin to a specified player.\n\ + Defaults to yourself.\n\ + * Using \"-display\" will set a localskin to the displayed player.\n\ + Defaults to 0, which is the first player displayed.\n\ + Can go up to 3 for splitscreen.\n\ + * Using \"-all\" will set a localskin to ALL players.\n\ + * \"localskin none\" removes the localskin, just like how\n\ + \"forceskin none\" does.\n")); return; } diff --git a/src/r_things.c b/src/r_things.c index ddae1d7ec..44a2bfe84 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3700,7 +3700,6 @@ next_token: numallskins++; } -#undef lskin #undef lnumskins //sortSkinGrid(); diff --git a/src/w_wad.c b/src/w_wad.c index 6432c3223..3a9ab6c6c 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -898,8 +898,10 @@ INT32 W_InitMultipleFiles(char **filenames, boolean addons) //CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames); rc = W_InitFile(*filenames, false); + if (rc == INT16_MAX) CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames); + overallrc &= (rc != INT16_MAX) ? 1 : 0; } @@ -918,8 +920,10 @@ INT32 W_AddAutoloadedLocalFiles(char **filenames) for (; *filenames; filenames++) { rc = P_PartialAddWadFile(*filenames, true); + if (rc == UINT16_MAX) CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames); + overallrc &= (rc != UINT16_MAX) ? 1 : 0; } @@ -928,6 +932,7 @@ INT32 W_AddAutoloadedLocalFiles(char **filenames) if (P_PartialAddGetStage() >= 0) P_MultiSetupWadFiles(true); + return overallrc; } From f81488500c6f10d3416711f86d6deee3eda6acee Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 06:46:41 +0200 Subject: [PATCH 02/12] just mark it like this --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 44a2bfe84..aad15de15 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2856,7 +2856,7 @@ void R_ClipSprites(void) /* Check if thing may be drawn from our current view. */ boolean R_ThingVisible (mobj_t *thing) { - if (UNLIKELY(thing->sprite == SPR_NULL) || UNLIKELY((thing->flags2 & MF2_DONTDRAW))) + if (UNLIKELY((thing->sprite == SPR_NULL) || (thing->flags2 & MF2_DONTDRAW))) return false; if (splitscreen) From cf92df5faafaf1f267444c7d726a1fda3317d4a3 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 06:54:22 +0200 Subject: [PATCH 03/12] skip checking skin array if localskin was found in localskin array --- src/lua_mobjlib.c | 5 ++--- src/r_things.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 9498974d5..44c43297f 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -452,7 +452,7 @@ int mobj_localskin_setter(lua_State *L) strlcpy(skin, luaL_optstring(L, 2, "none"), sizeof skin); strlwr(skin); // all skin names are lowercase - if (strcasecmp(skin, "none")) + if (stricmp(skin, "none")) { // Try localskins for (i = 0; i < numlocalskins; i++) @@ -468,7 +468,7 @@ int mobj_localskin_setter(lua_State *L) // Try other skins for (i = 0; i < numskins; i++) { - if (fastcmp(skins[i].name, skin)) + if (stricmp(skins[i].name, skin) == 0) { mo->localskin = &skins[i]; mo->skinlocal = false; @@ -483,7 +483,6 @@ int mobj_localskin_setter(lua_State *L) } } - return 0; } diff --git a/src/r_things.c b/src/r_things.c index aad15de15..e2c3c2c76 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3163,11 +3163,11 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) INT32 i; player_t *player = &players[playernum]; - if (strcasecmp(skinname, "none")) + if (stricmp(skinname, "none")) { for (i = 0; i < numlocalskins; i++) { - // search in the skin list + // search in the localskin list if (stricmp(localskins[i].name, skinname) == 0) { player->localskin = 1 + i; @@ -3177,9 +3177,11 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) player->mo->localskin = &localskins[i]; player->mo->skinlocal = true; } - break; + + goto setcvar; } } + for (i = 0; i < numskins; i++) { // search in the skin list @@ -3192,7 +3194,8 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) player->mo->localskin = &skins[i]; player->mo->skinlocal = false; } - break; + + goto setcvar; } } } @@ -3207,6 +3210,7 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) } } +setcvar: if (cvar != NULL) { if (player->localskin > 0) From 7bb4b74c65e7db92d55417f0b0221b67579e6e45 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 06:56:57 +0200 Subject: [PATCH 04/12] fix potential crash on startup thx hanicef --- src/g_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_input.c b/src/g_input.c index f0121f37d..7adb4462a 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1022,7 +1022,7 @@ INT32 G_KeyStringtoNum(const char *keystr) if (!keystr[0]) return 0; - if (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z') + if (!keystr[0] || (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z')) return keystr[0]; if (!strncmp(keystr, "KEY", 3) && keystr[3] >= '0' && keystr[3] <= '9') From 987d18fe992418007891a837d15a9f00d0fa3a67 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 09:24:37 +0200 Subject: [PATCH 05/12] memset those --- src/doomstat.h | 4 ++-- src/p_setup.c | 26 ++++++++++++++++++++------ src/r_things.c | 7 ++++--- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index f6e708be6..54c6ae320 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -244,7 +244,7 @@ typedef struct INT16 nextlevel; ///< Map number of next level, or 1100-1102 to end. char musname[7]; ///< Music track to play. "" for no music. UINT16 mustrack; ///< Subsong to play. Only really relevant for music modules and specific formats supported by GME. 0 to ignore. - UINT32 muspos; ///< Music position to jump to. + UINT32 muspos; ///< Music position to jump to. char forcecharacter[17]; ///< (SKINNAMESIZE+1) Skin to switch to or "" to disable. UINT8 weather; ///< 0 = sunny day, 1 = storm, 2 = snow, 3 = rain, 4 = blank, 5 = thunder w/o rain, 6 = rain w/o lightning, 7 = heat wave. INT16 skynum; ///< Sky number to use. @@ -276,7 +276,7 @@ typedef struct // SRB2kart //boolean automap; ///< Displays a level's white map outline in modified games - fixed_t mobj_scale; ///< Replacement for TOL_ERZ3 + fixed_t mobj_scale; ///< Replacement for TOL_ERZ3 mapheader_lighting_t lighting; ///< Wall and sprite lighting mapheader_lighting_t lighting_encore; ///< Alternative lighting for Encore mode diff --git a/src/p_setup.c b/src/p_setup.c index e4c22f253..b51a8abce 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -296,6 +296,7 @@ static void P_ClearMapHeaderLighting(mapheader_lighting_t *lighting) static void P_ClearSingleMapHeaderInfo(INT16 i) { const INT16 num = (INT16)(i-1); + mapheaderinfo[num]->lvlttl[0] = '\0'; mapheaderinfo[num]->subttl[0] = '\0'; mapheaderinfo[num]->zonttl[0] = '\0'; @@ -329,8 +330,10 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->saveoverride = SAVE_DEFAULT; mapheaderinfo[num]->levelflags = 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 //mapheaderinfo[num]->automap = false; mapheaderinfo[num]->mobj_scale = FRACUNIT; @@ -752,7 +755,7 @@ INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat) // first scan through the already found flats // for (i = 0; i < numlevelflats; i++, levelflat++) - if (strnicmp(levelflat->name,flatname,8)==0) + if (strnicmp(levelflat->name,flatname,8) == 0) break; // that flat was already found in the level, return the id @@ -947,6 +950,7 @@ static void P_LoadRawNodes(UINT8 *data) no->y = SHORT(mn->y)<dx = SHORT(mn->dx)<dy = SHORT(mn->dy)<children[j] = SHORT(mn->children[j]); @@ -2376,10 +2380,14 @@ static INT32 P_MakeBufferMD5(const char *buffer, size_t len, void *resblock) return 1; #else tic_t t = I_GetTime(); + CONS_Debug(DBG_SETUP, "Making MD5\n"); + if (md5_buffer(buffer, len, resblock) == NULL) return 1; + CONS_Debug(DBG_SETUP, "MD5 calc took %f seconds\n", (float)(I_GetTime() - t)/NEWTICRATE); + return 0; #endif } @@ -2460,6 +2468,7 @@ static void P_RunLevelScript(const char *scriptname) { COM_BufAddText(va("exec %s\n", scriptname)); } + COM_BufExecute(); // Run it! } @@ -2760,7 +2769,7 @@ static boolean P_RunSpecialWipe(boolean reloadinggamestate) F_WipeEndScreen(); F_RunWipe(wipedefs[wipe_level_final], false); } - else //dedicated servers can call this now, to wait the appropriate amount of time for clients to wipe + else // dedicated servers can call this now, to wait the appropriate amount of time for clients to wipe { F_RunWipe(wipedefs[wipe_speclevel_towhite], false); F_RunWipe(wipedefs[wipe_level_final], false); @@ -2778,7 +2787,9 @@ static boolean P_RunSpecialWipe(boolean reloadinggamestate) I_Sleep(cv_sleep.value); I_UpdateTime(cv_timescale.value); } + lastwipetic = nowtime; + if (moviemode) // make sure we save frames for the white hold too M_SaveFrame(); @@ -2797,6 +2808,7 @@ static void P_SetupPlayer(void) INT32 i; for (i = 0; i < MAXPLAYERS; i++) + { if (playeringame[i]) { players[i].pflags &= ~PF_NIGHTSMODE; @@ -2821,6 +2833,7 @@ static void P_SetupPlayer(void) G_SpawnPlayer(i, false); } } + } if (modeattacking == ATTACKING_RECORD && !demo.playback) P_LoadRecordGhosts(); @@ -3077,10 +3090,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) numdmstarts = numredctfstarts = numbluectfstarts = 0; // reset the player starts - for (i = 0; i < MAXPLAYERS; i++) - playerstarts[i] = NULL; - for (i = 0; i < 2; i++) - skyboxmo[i] = NULL; + memset(playerstarts, 0, sizeof(playerstarts)); + memset(skyboxmo, 0, sizeof(skyboxmo)); P_ResetWaypoints(); @@ -3180,12 +3191,15 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) if (!fromnetsave) // uglier hack { // to make a newly loaded level start on the second frame. INT32 buf = gametic % TICQUEUE; + for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); } + P_PreTicker(2); + if (!reloadinggamestate) LUA_HookInt(gamemap, HOOK(MapLoad)); } diff --git a/src/r_things.c b/src/r_things.c index e2c3c2c76..45afd824d 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3096,7 +3096,7 @@ INT32 R_SkinAvailable(const char *name) for (i = 0; i < numskins; i++) { - if (stricmp(skins[i].name,name)==0) + if (stricmp(skins[i].name,name) == 0) return i; } return -1; @@ -3110,7 +3110,7 @@ INT32 R_AnySkinAvailable(const char *name) for (i = 0; i < numallskins; i++) { - if (stricmp(allskins[i].name,name)==0) + if (stricmp(allskins[i].name,name) == 0) return i; } return -1; @@ -3124,7 +3124,7 @@ INT32 R_LocalSkinAvailable(const char *name, boolean local) { for (i = 0; i < numlocalskins; i++) { - if (stricmp(localskins[i].name,name)==0) + if (stricmp(localskins[i].name,name) == 0) return i; } return -1; @@ -3258,6 +3258,7 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) CONS_Alert(CONS_WARNING, M_GetText("Skin %d not found\n"), skinnum); else if(server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); + SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin } From 5df33e070549ef0964f9aab5d3b39abca4aab242 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 08:58:05 +0200 Subject: [PATCH 06/12] cleanup G_Responder man --- src/g_game.c | 328 ++++++++++++++++++++------------------------------ src/g_input.c | 8 ++ src/g_input.h | 2 + 3 files changed, 141 insertions(+), 197 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 7acda852e..de290949b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1277,7 +1277,8 @@ static void G_DoLoadLevel(boolean resetplayer) // clear cmd building stuff memset(gamekeydown, 0, sizeof (gamekeydown)); - for (i = 0;i < JOYAXISSET; i++) + + for (i = 0; i < JOYAXISSET; i++) { joyxmove[i] = joyymove[i] = 0; joy2xmove[i] = joy2ymove[i] = 0; @@ -1298,91 +1299,10 @@ static INT32 pausedelay = 0; static INT32 camtoggledelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; static INT32 spectatedelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; -// -// G_Responder -// Get info needed to make ticcmd_ts for the players. -// -boolean G_Responder(event_t *ev) +static boolean G_LevelResponder(event_t *ev) { - // any other key pops up menu if in demos - if (gameaction == ga_nothing && !demo.quitafterplaying && - ((demo.playback && !modeattacking && !demo.title && !multiplayer) || gamestate == GS_TITLESCREEN)) - { - if (ev->type == ev_keydown && ev->data1 != 301) - { - M_StartControlPanel(); - return true; - } - return false; - } - else if (demo.playback && demo.title) - { - // Title demo uses intro responder - if (F_IntroResponder(ev)) - { - // stop the title demo - G_CheckDemoStatus(); - return true; - } - return false; - } - - if (gamestate == GS_LEVEL) - { - if (HU_Responder(ev)) - return true; // chat ate the event - if (AM_Responder(ev)) - return true; // automap ate it - // map the event (key/mouse/joy) to a gamecontrol - } - // Intro - else if (gamestate == GS_INTRO) - { - if (F_IntroResponder(ev)) - { - D_StartTitle(); - return true; - } - } - else if (gamestate == GS_CUTSCENE) - { - if (HU_Responder(ev)) - return true; // chat ate the event - - if (F_CutsceneResponder(ev)) - { - D_StartTitle(); - return true; - } - } - - else if (gamestate == GS_CREDITS) - { - if (HU_Responder(ev)) - return true; // chat ate the event - - if (F_CreditResponder(ev)) - { - F_StartGameEvaluation(); - return true; - } - } - - else if (gamestate == GS_CONTINUING) - { - if (F_ContinueResponder(ev)) - return true; - } - // Demo End - else if (gamestate == GS_GAMEEND || gamestate == GS_EVALUATION || gamestate == GS_CREDITS) - return true; - - else if (gamestate == GS_INTERMISSION || gamestate == GS_VOTING || gamestate == GS_WAITINGPLAYERS) - if (HU_Responder(ev)) - return true; // chat ate the event - // allow spy mode changes even during the demo - if (gamestate == GS_LEVEL && ev->type == ev_keydown + if (ev->type == ev_keydown && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) { if (!demo.playback && (splitscreen || !netgame)) @@ -1399,30 +1319,20 @@ boolean G_Responder(event_t *ev) } } - if (gamestate == GS_LEVEL && ev->type == ev_keydown && multiplayer && demo.playback) + if (ev->type == ev_keydown && multiplayer && demo.playback) { - if (ev->data1 == gamecontrolbis[gc_viewpoint][0] || ev->data1 == gamecontrolbis[gc_viewpoint][1]) + for (INT32 i = 1; i <= splitscreen; i++) { - G_AdjustView(2, 1, true); - - return true; - } - else if (ev->data1 == gamecontrol3[gc_viewpoint][0] || ev->data1 == gamecontrol3[gc_viewpoint][1]) - { - G_AdjustView(3, 1, true); - - return true; - } - else if (ev->data1 == gamecontrol4[gc_viewpoint][0] || ev->data1 == gamecontrol4[gc_viewpoint][1]) - { - G_AdjustView(4, 1, true); - - return true; + if (ev->data1 == gamecontrols[i][gc_viewpoint][0] + || ev->data1 == gamecontrols[i][gc_viewpoint][1]) + { + G_AdjustView(i+1, 1, true); + return true; + } } // Allow pausing - if ( - ev->data1 == gamecontrol[gc_pause][0] + if (ev->data1 == gamecontrol[gc_pause][0] || ev->data1 == gamecontrol[gc_pause][1] || ev->data1 == KEY_PAUSE ) @@ -1447,11 +1357,98 @@ boolean G_Responder(event_t *ev) if (ev->data1 == 32) { M_StartControlPanel(); - return true; } } + return false; +} + +// +// G_Responder +// Get info needed to make ticcmd_ts for the players. +// +boolean G_Responder(event_t *ev) +{ + if (demo.playback && demo.title) + { + // Title demo uses intro responder + if (F_IntroResponder(ev)) + { + // stop the title demo + G_CheckDemoStatus(); + return true; + } + + return false; + } + else if (gameaction == ga_nothing + && !demo.quitafterplaying + && ((demo.playback && !modeattacking && !multiplayer) || gamestate == GS_TITLESCREEN)) + { + // any other key pops up menu if in demos + if (ev->type == ev_keydown && ev->data1 != 301) + { + M_StartControlPanel(); + return true; + } + + return false; + } + + if (Playing()) + { + // If you're playing, chat is real. + // Neatly sidesteps a class of bugs where whenever we add a + // new gamestate accessible in netplay, chat was console-only. + if (HU_Responder(ev)) + { + return true; // chat ate the event + } + } + + switch (gamestate) + { + case GS_LEVEL: + if (AM_Responder(ev)) + return true; // automap ate it + // map the event (key/mouse/joy) to a gamecontrol + if (G_LevelResponder(ev)) + return true; + break; + case GS_INTRO: + if (F_IntroResponder(ev)) + { + D_StartTitle(); + return true; + } + break; + case GS_CUTSCENE: + if (F_CutsceneResponder(ev)) + { + D_StartTitle(); + return true; + } + break; + case GS_CREDITS: + if (F_CreditResponder(ev)) + { + F_StartGameEvaluation(); + return true; + } + break; + case GS_CONTINUING: + if (F_ContinueResponder(ev)) + return true; + break; + case GS_GAMEEND: + case GS_EVALUATION: + return true; // Demo End + break; + default: + break; + } + // update keys current state G_MapEventsToControls(ev); @@ -1474,121 +1471,58 @@ boolean G_Responder(event_t *ev) else pausedelay = NEWTICRATE/7; } - if (ev->data1 == gamecontrol[gc_camtoggle][0] - || ev->data1 == gamecontrol[gc_camtoggle][1]) - { - if (!camtoggledelay[0]) - { - camtoggledelay[0] = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam[0], cv_chasecam[0].value ? 0 : 1); - } - } - if (ev->data1 == gamecontrolbis[gc_camtoggle][0] - || ev->data1 == gamecontrolbis[gc_camtoggle][1]) - { - if (!camtoggledelay[1]) - { - camtoggledelay[1] = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam[1], cv_chasecam[1].value ? 0 : 1); - } - } - if (ev->data1 == gamecontrol3[gc_camtoggle][0] - || ev->data1 == gamecontrol3[gc_camtoggle][1]) - { - if (!camtoggledelay[2]) - { - camtoggledelay[2] = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam[2], cv_chasecam[2].value ? 0 : 1); - } - } - if (ev->data1 == gamecontrol4[gc_camtoggle][0] - || ev->data1 == gamecontrol4[gc_camtoggle][1]) - { - if (!camtoggledelay[3]) - { - camtoggledelay[3] = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam[3], cv_chasecam[3].value ? 0 : 1); - } - } - if (ev->data1 == gamecontrol[gc_spectate][0] - || ev->data1 == gamecontrol[gc_spectate][1]) - { - if (!spectatedelay[0]) - { - spectatedelay[0] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam spectator"); - } - } - if (ev->data1 == gamecontrolbis[gc_spectate][0] - || ev->data1 == gamecontrolbis[gc_spectate][1]) - { - if (!spectatedelay[1]) - { - spectatedelay[1] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam2 spectator"); - } - } - if (ev->data1 == gamecontrol3[gc_spectate][0] - || ev->data1 == gamecontrol3[gc_spectate][1]) - { - if (!spectatedelay[2]) - { - spectatedelay[2] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam3 spectator"); - } - } - if (ev->data1 == gamecontrol4[gc_spectate][0] - || ev->data1 == gamecontrol4[gc_spectate][1]) - { - if (!spectatedelay[3]) - { - spectatedelay[3] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam4 spectator"); - } - } - if (ev->data1 == gamecontrol[gc_director][0] || ev->data1 == gamecontrol[gc_director][1]) + // no splitscreen support for director here + if (ev->data1 == gamecontrol[gc_director][0] + || ev->data1 == gamecontrol[gc_director][1]) { K_ToggleDirector(); } - if (ev->data1 == gamecontrol[gc_freecam][0] || ev->data1 == gamecontrol[gc_freecam][1]) + // absolutely horrid + for (INT32 i = 0; i <= splitscreen; i++) { - P_ToggleDemoCamera(0); - } - else if (ev->data1 == gamecontrolbis[gc_freecam][0] || ev->data1 == gamecontrolbis[gc_freecam][1]) - { - P_ToggleDemoCamera(1); - } - else if (ev->data1 == gamecontrol3[gc_freecam][0] || ev->data1 == gamecontrol3[gc_freecam][1]) - { - P_ToggleDemoCamera(2); - } - else if (ev->data1 == gamecontrol4[gc_freecam][0] || ev->data1 == gamecontrol4[gc_freecam][1]) - { - P_ToggleDemoCamera(3); + if (ev->data1 == gamecontrols[i][gc_camtoggle][0] + || ev->data1 == gamecontrols[i][gc_camtoggle][1]) + { + if (!camtoggledelay[i]) + { + camtoggledelay[i] = NEWTICRATE / 7; + CV_SetValue(&cv_chasecam[i], (cv_chasecam[i].value ^ 1)); + } + } + + if (ev->data1 == gamecontrols[i][gc_spectate][0] + || ev->data1 == gamecontrols[i][gc_spectate][1]) + { + if (!spectatedelay[i]) + { + spectatedelay[i] = NEWTICRATE / 7; + COM_ImmedExecute("changeteam spectator"); + } + } + + if (ev->data1 == gamecontrols[i][gc_freecam][0] + || ev->data1 == gamecontrols[i][gc_freecam][1]) + { + P_ToggleDemoCamera(i); + } } return true; case ev_keyup: return false; // always let key up events filter down - case ev_mouse: return true; // eat events - case ev_joystick: return true; // eat events - case ev_joystick2: return true; // eat events - case ev_joystick3: return true; // eat events - case ev_joystick4: return true; // eat events - default: break; } diff --git a/src/g_input.c b/src/g_input.c index 7adb4462a..3c38cf192 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -136,6 +136,14 @@ INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player INT32 gamecontrol3[num_gamecontrols][2]; // tertiary splitscreen player INT32 gamecontrol4[num_gamecontrols][2]; // quarternary splitscreen player +// TODO: this is dumb as hell +INT32 (*gamecontrols[MAXSPLITSCREENPLAYERS])[2] = { + gamecontrol, + gamecontrolbis, + gamecontrol3, + gamecontrol4 +}; + typedef struct { UINT8 time; diff --git a/src/g_input.h b/src/g_input.h index 505d210f8..820e2cdbc 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -125,6 +125,8 @@ extern INT32 gamecontrol[num_gamecontrols][2]; extern INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player extern INT32 gamecontrol3[num_gamecontrols][2]; extern INT32 gamecontrol4[num_gamecontrols][2]; +extern INT32 (*gamecontrols[MAXSPLITSCREENPLAYERS])[2]; + #define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]]) #define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]]) #define PLAYER3INPUTDOWN(gc) (gamekeydown[gamecontrol3[gc][0]] || gamekeydown[gamecontrol3[gc][1]]) From c14c28ac1e35aac55da3b96589eae2fd91b270a4 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 09:13:14 +0200 Subject: [PATCH 07/12] attempt at cleaning up gamecontrol splitscreen shit --- src/console.c | 6 +- src/d_clisrv.c | 4 +- src/g_game.c | 32 +++---- src/g_input.c | 233 +++++++++++++++++++++---------------------------- src/g_input.h | 14 ++- src/hu_stuff.c | 14 +-- src/m_menu.c | 38 ++++---- src/m_misc.c | 4 +- src/st_stuff.c | 4 +- 9 files changed, 155 insertions(+), 194 deletions(-) diff --git a/src/console.c b/src/console.c index 3212521b0..f1c8efcc2 100644 --- a/src/console.c +++ b/src/console.c @@ -827,7 +827,7 @@ boolean CON_Responder(event_t *ev) // let go keyup events, don't eat them if (ev->type != ev_keydown && ev->type != ev_console) { - if (ev->data1 == gamecontrol[gc_console][0] || ev->data1 == gamecontrol[gc_console][1]) + if (ev->data1 == gamecontrol[0][gc_console][0] || ev->data1 == gamecontrol[0][gc_console][1]) consdown = false; return false; } @@ -845,7 +845,7 @@ boolean CON_Responder(event_t *ev) INT32 i; for (i = 0; i < num_gamecontrols; i++) { - if (gamecontrol[i][0] == ev->data1 || gamecontrol[i][1] == ev->data1) + if (gamecontrol[0][i][0] == ev->data1 || gamecontrol[0][i][1] == ev->data1) break; } @@ -853,7 +853,7 @@ boolean CON_Responder(event_t *ev) return false; } - if (key == gamecontrol[gc_console][0] || key == gamecontrol[gc_console][1]) + if (key == gamecontrol[0][gc_console][0] || key == gamecontrol[0][gc_console][1]) { if (consdown) // ignore repeat return true; diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4a2a0cc0f..d76e67e88 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2261,13 +2261,13 @@ static void M_ConfirmConnect(event_t *ev) #ifndef NONET if (ev->type == ev_keydown) { - if (ev->data1 == ' ' || ev->data1 == 'y' || ev->data1 == KEY_ENTER || ev->data1 == gamecontrol[gc_accelerate][0] || ev->data1 == gamecontrol[gc_accelerate][1]) + if (ev->data1 == ' ' || ev->data1 == 'y' || ev->data1 == KEY_ENTER || ev->data1 == gamecontrol[0][gc_accelerate][0] || ev->data1 == gamecontrol[0][gc_accelerate][1]) { CL_ConfirmConnect(); M_ClearMenus(true); } - else if (ev->data1 == 'n' || ev->data1 == KEY_ESCAPE|| ev->data1 == gamecontrol[gc_brake][0] || ev->data1 == gamecontrol[gc_brake][1]) + else if (ev->data1 == 'n' || ev->data1 == KEY_ESCAPE|| ev->data1 == gamecontrol[0][gc_brake][0] || ev->data1 == gamecontrol[0][gc_brake][1]) { cl_mode = CL_ABORTED; M_ClearMenus(true); diff --git a/src/g_game.c b/src/g_game.c index de290949b..eaec9e212 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1303,7 +1303,9 @@ static boolean G_LevelResponder(event_t *ev) { // allow spy mode changes even during the demo if (ev->type == ev_keydown - && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) + && (ev->data1 == KEY_F12 + || ev->data1 == gamecontrol[0][gc_viewpoint][0] + || ev->data1 == gamecontrol[0][gc_viewpoint][1])) { if (!demo.playback && (splitscreen || !netgame)) displayplayers[0] = consoleplayer; @@ -1323,8 +1325,8 @@ static boolean G_LevelResponder(event_t *ev) { for (INT32 i = 1; i <= splitscreen; i++) { - if (ev->data1 == gamecontrols[i][gc_viewpoint][0] - || ev->data1 == gamecontrols[i][gc_viewpoint][1]) + if (ev->data1 == gamecontrol[i][gc_viewpoint][0] + || ev->data1 == gamecontrol[i][gc_viewpoint][1]) { G_AdjustView(i+1, 1, true); return true; @@ -1332,8 +1334,8 @@ static boolean G_LevelResponder(event_t *ev) } // Allow pausing - if (ev->data1 == gamecontrol[gc_pause][0] - || ev->data1 == gamecontrol[gc_pause][1] + if (ev->data1 == gamecontrol[0][gc_pause][0] + || ev->data1 == gamecontrol[0][gc_pause][1] || ev->data1 == KEY_PAUSE ) { @@ -1455,8 +1457,8 @@ boolean G_Responder(event_t *ev) switch (ev->type) { case ev_keydown: - if (ev->data1 == gamecontrol[gc_pause][0] - || ev->data1 == gamecontrol[gc_pause][1] + if (ev->data1 == gamecontrol[0][gc_pause][0] + || ev->data1 == gamecontrol[0][gc_pause][1] || ev->data1 == KEY_PAUSE) { if (!pausedelay) @@ -1473,8 +1475,8 @@ boolean G_Responder(event_t *ev) } // no splitscreen support for director here - if (ev->data1 == gamecontrol[gc_director][0] - || ev->data1 == gamecontrol[gc_director][1]) + if (ev->data1 == gamecontrol[0][gc_director][0] + || ev->data1 == gamecontrol[0][gc_director][1]) { K_ToggleDirector(); } @@ -1482,8 +1484,8 @@ boolean G_Responder(event_t *ev) // absolutely horrid for (INT32 i = 0; i <= splitscreen; i++) { - if (ev->data1 == gamecontrols[i][gc_camtoggle][0] - || ev->data1 == gamecontrols[i][gc_camtoggle][1]) + if (ev->data1 == gamecontrol[i][gc_camtoggle][0] + || ev->data1 == gamecontrol[i][gc_camtoggle][1]) { if (!camtoggledelay[i]) { @@ -1492,8 +1494,8 @@ boolean G_Responder(event_t *ev) } } - if (ev->data1 == gamecontrols[i][gc_spectate][0] - || ev->data1 == gamecontrols[i][gc_spectate][1]) + if (ev->data1 == gamecontrol[i][gc_spectate][0] + || ev->data1 == gamecontrol[i][gc_spectate][1]) { if (!spectatedelay[i]) { @@ -1502,8 +1504,8 @@ boolean G_Responder(event_t *ev) } } - if (ev->data1 == gamecontrols[i][gc_freecam][0] - || ev->data1 == gamecontrols[i][gc_freecam][1]) + if (ev->data1 == gamecontrol[i][gc_freecam][0] + || ev->data1 == gamecontrol[i][gc_freecam][1]) { P_ToggleDemoCamera(i); } diff --git a/src/g_input.c b/src/g_input.c index 3c38cf192..f7ea83a75 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -131,18 +131,7 @@ joy3xmove[JOYAXISSET], joy3ymove[JOYAXISSET], joy4xmove[JOYAXISSET], joy4ymove[J UINT8 gamekeydown[NUMINPUTS]; // two key codes (or virtual key) per game control -INT32 gamecontrol[num_gamecontrols][2]; -INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player -INT32 gamecontrol3[num_gamecontrols][2]; // tertiary splitscreen player -INT32 gamecontrol4[num_gamecontrols][2]; // quarternary splitscreen player - -// TODO: this is dumb as hell -INT32 (*gamecontrols[MAXSPLITSCREENPLAYERS])[2] = { - gamecontrol, - gamecontrolbis, - gamecontrol3, - gamecontrol4 -}; +INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][2]; typedef struct { @@ -985,13 +974,14 @@ void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control) void G_ClearAllControlKeys(void) { - INT32 i; - for (i = 0; i < num_gamecontrols; i++) + INT32 i, k; + + for (k = 0; k < MAXSPLITSCREENPLAYERS; k++) { - G_ClearControlKeys(gamecontrol, i); - G_ClearControlKeys(gamecontrolbis, i); - G_ClearControlKeys(gamecontrol3, i); - G_ClearControlKeys(gamecontrol4, i); + for (i = 0; i < num_gamecontrols; i++) + { + G_ClearControlKeys(gamecontrol[k], i); + } } } @@ -1049,158 +1039,131 @@ void G_Controldefault(UINT8 player) if (player == 0 || player == 1) { // Main controls - gamecontrol[gc_aimforward ][0] = KEY_UPARROW; - gamecontrol[gc_aimbackward][0] = KEY_DOWNARROW; - gamecontrol[gc_turnleft ][0] = KEY_LEFTARROW; - gamecontrol[gc_turnright ][0] = KEY_RIGHTARROW; - gamecontrol[gc_accelerate ][0] = 'a'; - gamecontrol[gc_drift ][0] = 's'; - gamecontrol[gc_brake ][0] = 'd'; - gamecontrol[gc_fire ][0] = KEY_SPACE; - gamecontrol[gc_lookback ][0] = KEY_LSHIFT; + gamecontrol[0][gc_aimforward ][0] = KEY_UPARROW; + gamecontrol[0][gc_aimbackward][0] = KEY_DOWNARROW; + gamecontrol[0][gc_turnleft ][0] = KEY_LEFTARROW; + gamecontrol[0][gc_turnright ][0] = KEY_RIGHTARROW; + gamecontrol[0][gc_accelerate ][0] = 'a'; + gamecontrol[0][gc_drift ][0] = 's'; + gamecontrol[0][gc_brake ][0] = 'd'; + gamecontrol[0][gc_fire ][0] = KEY_SPACE; + gamecontrol[0][gc_lookback ][0] = KEY_LSHIFT; - gamecontrol[gc_accelerate ][1] = KEY_JOY1+0; // A - gamecontrol[gc_lookback ][1] = KEY_JOY1+2; // X - gamecontrol[gc_brake ][1] = KEY_JOY1+1; // B - gamecontrol[gc_fire ][1] = KEY_JOY1+9; // LB - gamecontrol[gc_drift ][1] = KEY_JOY1+10; // RB + gamecontrol[0][gc_accelerate ][1] = KEY_JOY1+0; // A + gamecontrol[0][gc_lookback ][1] = KEY_JOY1+2; // X + gamecontrol[0][gc_brake ][1] = KEY_JOY1+1; // B + gamecontrol[0][gc_fire ][1] = KEY_JOY1+9; // LB + gamecontrol[0][gc_drift ][1] = KEY_JOY1+10; // RB // Extra controls - gamecontrol[gc_pause ][0] = KEY_PAUSE; - gamecontrol[gc_console ][0] = KEY_CONSOLE; - gamecontrol[gc_screenshot ][0] = KEY_F8; - gamecontrol[gc_recordgif ][0] = KEY_F9; - gamecontrol[gc_viewpoint ][0] = KEY_F12; - gamecontrol[gc_talkkey ][0] = 't'; + gamecontrol[0][gc_pause ][0] = KEY_PAUSE; + gamecontrol[0][gc_console ][0] = KEY_CONSOLE; + gamecontrol[0][gc_screenshot ][0] = KEY_F8; + gamecontrol[0][gc_recordgif ][0] = KEY_F9; + gamecontrol[0][gc_viewpoint ][0] = KEY_F12; + gamecontrol[0][gc_talkkey ][0] = 't'; //gamecontrol[gc_teamkey ][0] = 'y'; - gamecontrol[gc_scores ][0] = KEY_TAB; - gamecontrol[gc_spectate ][0] = '\''; - gamecontrol[gc_lookup ][0] = KEY_PGUP; - gamecontrol[gc_lookdown ][0] = KEY_PGDN; - gamecontrol[gc_centerview ][0] = KEY_END; - gamecontrol[gc_camreset ][0] = KEY_HOME; - gamecontrol[gc_camtoggle ][0] = KEY_BACKSPACE; + gamecontrol[0][gc_scores ][0] = KEY_TAB; + gamecontrol[0][gc_spectate ][0] = '\''; + gamecontrol[0][gc_lookup ][0] = KEY_PGUP; + gamecontrol[0][gc_lookdown ][0] = KEY_PGDN; + gamecontrol[0][gc_centerview ][0] = KEY_END; + gamecontrol[0][gc_camreset ][0] = KEY_HOME; + gamecontrol[0][gc_camtoggle ][0] = KEY_BACKSPACE; - gamecontrol[gc_viewpoint ][1] = KEY_JOY1+3; // Y - gamecontrol[gc_pause ][1] = KEY_JOY1+4; // Back - gamecontrol[gc_systemmenu ][0] = KEY_JOY1+6; // Start - //gamecontrol[gc_camtoggle ][1] = KEY_HAT1+0; // D-Pad Up - //gamecontrol[gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down // absolutely fucking NOT - gamecontrol[gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down - gamecontrol[gc_scores ][1] = KEY_HAT1+0; // D-Pad Up + gamecontrol[0][gc_viewpoint ][1] = KEY_JOY1+3; // Y + gamecontrol[0][gc_pause ][1] = KEY_JOY1+4; // Back + gamecontrol[0][gc_systemmenu ][0] = KEY_JOY1+6; // Start + //gamecontrol[0][gc_camtoggle ][1] = KEY_HAT1+0; // D-Pad Up + //gamecontrol[0][gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down // absolutely fucking NOT + gamecontrol[0][gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down + gamecontrol[0][gc_scores ][1] = KEY_HAT1+0; // D-Pad Up } if (player == 0 || player == 2) { // Player 2 controls - gamecontrolbis[gc_accelerate ][0] = KEY_2JOY1+0; // A - gamecontrolbis[gc_lookback ][0] = KEY_2JOY1+2; // X - gamecontrolbis[gc_brake ][0] = KEY_2JOY1+1; // B - gamecontrolbis[gc_fire ][0] = KEY_2JOY1+9; // LB - gamecontrolbis[gc_drift ][0] = KEY_2JOY1+10; // RB + gamecontrol[1][gc_accelerate ][0] = KEY_2JOY1+0; // A + gamecontrol[1][gc_lookback ][0] = KEY_2JOY1+2; // X + gamecontrol[1][gc_brake ][0] = KEY_2JOY1+1; // B + gamecontrol[1][gc_fire ][0] = KEY_2JOY1+9; // LB + gamecontrol[1][gc_drift ][0] = KEY_2JOY1+10; // RB } if (player == 0 || player == 3) { // Player 3 controls - gamecontrol3[gc_accelerate ][0] = KEY_3JOY1+0; // A - gamecontrol3[gc_lookback ][0] = KEY_3JOY1+2; // X - gamecontrol3[gc_brake ][0] = KEY_3JOY1+1; // B - gamecontrol3[gc_fire ][0] = KEY_3JOY1+9; // LB - gamecontrol3[gc_drift ][0] = KEY_3JOY1+10; // RB + gamecontrol[2][gc_accelerate ][0] = KEY_3JOY1+0; // A + gamecontrol[2][gc_lookback ][0] = KEY_3JOY1+2; // X + gamecontrol[2][gc_brake ][0] = KEY_3JOY1+1; // B + gamecontrol[2][gc_fire ][0] = KEY_3JOY1+9; // LB + gamecontrol[2][gc_drift ][0] = KEY_3JOY1+10; // RB } if (player == 0 || player == 4) { // Player 4 controls - gamecontrol4[gc_accelerate ][0] = KEY_4JOY1+0; // A - gamecontrol4[gc_lookback ][0] = KEY_4JOY1+2; // X - gamecontrol4[gc_brake ][0] = KEY_4JOY1+1; // B - gamecontrol4[gc_fire ][0] = KEY_4JOY1+9; // LB - gamecontrol4[gc_drift ][0] = KEY_4JOY1+10; // RB + gamecontrol[3][gc_accelerate ][0] = KEY_4JOY1+0; // A + gamecontrol[3][gc_lookback ][0] = KEY_4JOY1+2; // X + gamecontrol[3][gc_brake ][0] = KEY_4JOY1+1; // B + gamecontrol[3][gc_fire ][0] = KEY_4JOY1+9; // LB + gamecontrol[3][gc_drift ][0] = KEY_4JOY1+10; // RB } } void G_SaveKeySetting(FILE *f) { - INT32 i; + INT32 i, k; - for (i = 1; i < num_gamecontrols; i++) + static const char *controltext[MAXSPLITSCREENPLAYERS] = { + "setcontrol", + "setcontrol2", + "setcontrol3", + "setcontrol4" + }; + + for (k = 0; k < MAXSPLITSCREENPLAYERS; k++) { - fprintf(f, "setcontrol \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrol[i][0])); + for (i = 1; i < num_gamecontrols; i++) + { + fprintf(f, "%s \"%s\" \"%s\"", controltext[k], gamecontrolname[i], + G_KeynumToString(gamecontrol[k][i][0])); - if (gamecontrol[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrol[i][1])); - else - fprintf(f, "\n"); - } - - for (i = 1; i < num_gamecontrols; i++) - { - fprintf(f, "setcontrol2 \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrolbis[i][0])); - - if (gamecontrolbis[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrolbis[i][1])); - else - fprintf(f, "\n"); - } - - for (i = 1; i < num_gamecontrols; i++) - { - fprintf(f, "setcontrol3 \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrol3[i][0])); - - if (gamecontrol3[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrol3[i][1])); - else - fprintf(f, "\n"); - } - - for (i = 1; i < num_gamecontrols; i++) - { - fprintf(f, "setcontrol4 \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrol4[i][0])); - - if (gamecontrol4[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrol4[i][1])); - else - fprintf(f, "\n"); + if (gamecontrol[k][i][1]) + fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrol[k][i][1])); + else + fprintf(f, "\n"); + } } } INT32 G_CheckDoubleUsage(INT32 keynum, boolean modify) { INT32 result = gc_null; + if (cv_controlperkey.value == 1) { - INT32 i, j; - for (i = 0; i < num_gamecontrols; i++) + INT32 i, j, k; + + for (k = 0; k < MAXSPLITSCREENPLAYERS; k++) { - for (j = 0; j < 2; j++) + for (i = 0; i < num_gamecontrols; i++) { - if (gamecontrol[i][j] == keynum) { - result = i; - if (modify) gamecontrol[i][j] = KEY_NULL; + for (j = 0; j < 2; j++) + { + if (gamecontrol[k][i][j] == keynum) + { + result = i; + if (modify) gamecontrol[k][i][j] = KEY_NULL; + } + + if (result && !modify) + return result; } - if (gamecontrolbis[i][j] == keynum) { - result = i; - if (modify) gamecontrolbis[i][j] = KEY_NULL; - } - if (gamecontrol3[i][j] == keynum) { - result = i; - if (modify) gamecontrol3[i][j] = KEY_NULL; - } - if (gamecontrol4[i][j] == keynum) { - result = i; - if (modify) gamecontrol4[i][j] = KEY_NULL; - } - if (result && !modify) - return result; } } } + return result; } @@ -1354,11 +1317,11 @@ static void setcontrol(INT32 (*gc)[2]) INT32 player; boolean nestedoverride = false; - if ((void*)gc == (void*)&gamecontrol4) + if ((void*)gc == (void*)&gamecontrol[3]) player = 3; - else if ((void*)gc == (void*)&gamecontrol3) + else if ((void*)gc == (void*)&gamecontrol[2]) player = 2; - else if ((void*)gc == (void*)&gamecontrolbis) + else if ((void*)gc == (void*)&gamecontrol[1]) player = 1; else player = 0; @@ -1421,7 +1384,7 @@ void Command_Setcontrol_f(void) return; } - setcontrol(gamecontrol); + setcontrol(gamecontrol[0]); } void Command_Setcontrol2_f(void) @@ -1436,7 +1399,7 @@ void Command_Setcontrol2_f(void) return; } - setcontrol(gamecontrolbis); + setcontrol(gamecontrol[1]); } void Command_Setcontrol3_f(void) @@ -1451,7 +1414,7 @@ void Command_Setcontrol3_f(void) return; } - setcontrol(gamecontrol3); + setcontrol(gamecontrol[2]); } void Command_Setcontrol4_f(void) @@ -1466,5 +1429,5 @@ void Command_Setcontrol4_f(void) return; } - setcontrol(gamecontrol4); + setcontrol(gamecontrol[3]); } diff --git a/src/g_input.h b/src/g_input.h index 820e2cdbc..b8e4cd8d8 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -121,16 +121,12 @@ extern INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], extern UINT8 gamekeydown[NUMINPUTS]; // two key codes (or virtual key) per game control -extern INT32 gamecontrol[num_gamecontrols][2]; -extern INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player -extern INT32 gamecontrol3[num_gamecontrols][2]; -extern INT32 gamecontrol4[num_gamecontrols][2]; -extern INT32 (*gamecontrols[MAXSPLITSCREENPLAYERS])[2]; +extern INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][2]; -#define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]]) -#define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]]) -#define PLAYER3INPUTDOWN(gc) (gamekeydown[gamecontrol3[gc][0]] || gamekeydown[gamecontrol3[gc][1]]) -#define PLAYER4INPUTDOWN(gc) (gamekeydown[gamecontrol4[gc][0]] || gamekeydown[gamecontrol4[gc][1]]) +#define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[0][gc][0]] || gamekeydown[gamecontrol[0][gc][1]]) +#define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrol[1][gc][0]] || gamekeydown[gamecontrol[1][gc][1]]) +#define PLAYER3INPUTDOWN(gc) (gamekeydown[gamecontrol[2][gc][0]] || gamekeydown[gamecontrol[2][gc][1]]) +#define PLAYER4INPUTDOWN(gc) (gamekeydown[gamecontrol[3][gc][0]] || gamekeydown[gamecontrol[3][gc][1]]) // peace to my little coder fingers! // check a gamecontrol being active or not diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 268059d06..feedf4039 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1315,7 +1315,7 @@ boolean HU_Responder(event_t *ev) INT32 i; for (i = 0; i < num_gamecontrols; i++) { - if (gamecontrol[i][0] == ev->data1 || gamecontrol[i][1] == ev->data1) + if (gamecontrol[0][i][0] == ev->data1 || gamecontrol[0][i][1] == ev->data1) break; } @@ -1327,7 +1327,7 @@ boolean HU_Responder(event_t *ev) if (!chat_on) { // enter chat mode - if ((ev->data1 == gamecontrol[gc_talkkey][0] || ev->data1 == gamecontrol[gc_talkkey][1]) + if ((ev->data1 == gamecontrol[0][gc_talkkey][0] || ev->data1 == gamecontrol[0][gc_talkkey][1]) && netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise. { chat_on = true; @@ -1338,7 +1338,7 @@ boolean HU_Responder(event_t *ev) typelines = 1; return true; } - if ((ev->data1 == gamecontrol[gc_teamkey][0] || ev->data1 == gamecontrol[gc_teamkey][1]) + if ((ev->data1 == gamecontrol[0][gc_teamkey][0] || ev->data1 == gamecontrol[0][gc_teamkey][1]) && netgame && !OLD_MUTE) { chat_on = true; @@ -1364,8 +1364,8 @@ boolean HU_Responder(event_t *ev) // Ignore non-keyboard keys, except when the talk key is bound if (ev->data1 >= KEY_MOUSE1 - && (ev->data1 != gamecontrol[gc_talkkey][0] - && ev->data1 != gamecontrol[gc_talkkey][1])) + && (ev->data1 != gamecontrol[0][gc_talkkey][0] + && ev->data1 != gamecontrol[0][gc_talkkey][1])) return false; M_TextInputHandle(&w_chat, c); @@ -1377,8 +1377,8 @@ boolean HU_Responder(event_t *ev) HU_SendChatMessage(); } else if (c == KEY_ESCAPE - || ((c == gamecontrol[gc_talkkey][0] || c == gamecontrol[gc_talkkey][1] - || c == gamecontrol[gc_teamkey][0] || c == gamecontrol[gc_teamkey][1]) + || ((c == gamecontrol[0][gc_talkkey][0] || c == gamecontrol[0][gc_talkkey][1] + || c == gamecontrol[0][gc_teamkey][0] || c == gamecontrol[0][gc_teamkey][1]) && c >= KEY_MOUSE1)) // If it's not a keyboard key, then the chat button is used as a toggle. { chat_on = false; diff --git a/src/m_menu.c b/src/m_menu.c index bcd406e4c..27902ce9c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3887,8 +3887,8 @@ boolean M_Responder(event_t *ev) { if (currentMenu == &MISC_ChangeLevelDef || currentMenu == &MP_OfflineServerDef || currentMenu == &MP_ServerDef) { - if (ch == gamecontrol[gc_fire][0] - || ch == gamecontrol[gc_fire][1]) + if (ch == gamecontrol[0][gc_fire][0] + || ch == gamecontrol[0][gc_fire][1]) { COM_ImmedExecute("add kartencore 1"); } @@ -4021,9 +4021,9 @@ boolean M_Responder(event_t *ev) if (ch == -1) return false; - else if (ch == gamecontrol[gc_systemmenu][0] || ch == gamecontrol[gc_systemmenu][1]) // allow remappable ESC key + else if (ch == gamecontrol[0][gc_systemmenu][0] || ch == gamecontrol[0][gc_systemmenu][1]) // allow remappable ESC key ch = KEY_ESCAPE; - else if ((ch == gamecontrol[gc_accelerate][0] || ch == gamecontrol[gc_accelerate][1]) && ch >= KEY_MOUSE1) + else if ((ch == gamecontrol[0][gc_accelerate][0] || ch == gamecontrol[0][gc_accelerate][1]) && ch >= KEY_MOUSE1) ch = KEY_ENTER; // F-Keys @@ -4099,7 +4099,7 @@ boolean M_Responder(event_t *ev) return false; } - if ((ch == gamecontrol[gc_brake][0] || ch == gamecontrol[gc_brake][1]) && ch >= KEY_MOUSE1) // do this here, otherwise brake opens the menu mid-game + if ((ch == gamecontrol[0][gc_brake][0] || ch == gamecontrol[0][gc_brake][1]) && ch >= KEY_MOUSE1) // do this here, otherwise brake opens the menu mid-game ch = KEY_ESCAPE; routine = currentMenu->menuitems[itemOn].itemaction; @@ -10097,7 +10097,7 @@ static void M_HandleMasterServerResetChoice(event_t *ev) if (ev->type == ev_keydown) { - if (choice == ' ' || choice == 'y' || choice == KEY_ENTER || choice == gamecontrol[gc_accelerate][0] || choice == gamecontrol[gc_accelerate][1]) + if (choice == ' ' || choice == 'y' || choice == KEY_ENTER || choice == gamecontrol[0][gc_accelerate][0] || choice == gamecontrol[0][gc_accelerate][1]) { CV_Set(&cv_masterserver, cv_masterserver.defaultvalue); CV_Set(&cv_masterserver_nagattempts, cv_masterserver_nagattempts.defaultvalue); @@ -10251,8 +10251,8 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) if (levellistmode != LLM_RECORDATTACK) // so it doesent show in record attack menu { char encoretoggle[32] = {0}; - const char *item1 = gamecontrol[gc_fire][0] != 0 ? G_KeynumToString(gamecontrol[gc_fire][0]) : NULL; - const char *item2 = gamecontrol[gc_fire][1] != 0 ? G_KeynumToString(gamecontrol[gc_fire][1]) : NULL; + const char *item1 = gamecontrol[0][gc_fire][0] != 0 ? G_KeynumToString(gamecontrol[0][gc_fire][0]) : NULL; + const char *item2 = gamecontrol[0][gc_fire][1] != 0 ? G_KeynumToString(gamecontrol[0][gc_fire][1]) : NULL; if (item1 != NULL && item2 != NULL) snprintf(encoretoggle, 32, "%s/%s - Toggle Encore", item1, item2); @@ -11445,7 +11445,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) boolean exitmenu = false; // exit to previous menu and send name change const boolean gridselect = (cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED); // menus with "grids" - if ((choice == gamecontrol[gc_fire][0] || choice == gamecontrol[gc_fire][1]) && (itemOn == 2 || (gridselect && itemOn == 1))) + if ((choice == gamecontrol[0][gc_fire][0] || choice == gamecontrol[0][gc_fire][1]) && (itemOn == 2 || (gridselect && itemOn == 1))) choice = KEY_BACKSPACE; // Hack to allow resetting prefcolor on controllers #define BREAKWHENLOCKED {\ @@ -11741,8 +11741,8 @@ static void M_HandleSetupMultiPlayer(INT32 choice) break; //c why????? - //case gamecontrol[gc_accelerate][0]: - //case gamecontrol[gc_accelerate][1]: + //case gamecontrol[0][gc_accelerate][0]: + //case gamecontrol[0][gc_accelerate][1]: case KEY_ENTER: if (cv_skinselectmenu.value == SKINMENUTYPE_2D) { @@ -12356,7 +12356,7 @@ static void M_Setup1PControlsMenu(INT32 choice) { (void)choice; setupcontrolplayer = 1; - setupcontrols = gamecontrol; // was called from main Options (for console player, then) + setupcontrols = gamecontrol[0]; // was called from main Options (for console player, then) currentMenu->lastOn = itemOn; // Set proper gamepad options @@ -12379,7 +12379,7 @@ static void M_Setup2PControlsMenu(INT32 choice) { (void)choice; setupcontrolplayer = 2; - setupcontrols = gamecontrolbis; + setupcontrols = gamecontrol[1]; currentMenu->lastOn = itemOn; // Set proper gamepad options @@ -12402,7 +12402,7 @@ static void M_Setup3PControlsMenu(INT32 choice) { (void)choice; setupcontrolplayer = 3; - setupcontrols = gamecontrol3; + setupcontrols = gamecontrol[2]; currentMenu->lastOn = itemOn; // Set proper gamepad options @@ -12425,7 +12425,7 @@ static void M_Setup4PControlsMenu(INT32 choice) { (void)choice; setupcontrolplayer = 4; - setupcontrols = gamecontrol4; + setupcontrols = gamecontrol[3]; currentMenu->lastOn = itemOn; // Set proper gamepad options @@ -12673,17 +12673,17 @@ static void M_ResetControlsResponse(INT32 ch) switch (setupcontrolplayer) { case 4: - G_ClearControlKeys(gamecontrol4, i); + G_ClearControlKeys(gamecontrol[3], i); break; case 3: - G_ClearControlKeys(gamecontrol3, i); + G_ClearControlKeys(gamecontrol[2], i); break; case 2: - G_ClearControlKeys(gamecontrolbis, i); + G_ClearControlKeys(gamecontrol[1], i); break; case 1: default: - G_ClearControlKeys(gamecontrol, i); + G_ClearControlKeys(gamecontrol[0], i); break; } } diff --git a/src/m_misc.c b/src/m_misc.c index ff9892464..6b9699243 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1577,9 +1577,9 @@ boolean M_ScreenshotResponder(event_t *ev) if (ch >= KEY_MOUSE1 && menuactive) // If it's not a keyboard key, then don't allow it in the menus! return false; - if (ch == KEY_F8 || ch == gamecontrol[gc_screenshot][0] || ch == gamecontrol[gc_screenshot][1]) // remappable F8 + if (ch == KEY_F8 || ch == gamecontrol[0][gc_screenshot][0] || ch == gamecontrol[0][gc_screenshot][1]) // remappable F8 M_ScreenShot(); - else if (ch == KEY_F9 || ch == gamecontrol[gc_recordgif][0] || ch == gamecontrol[gc_recordgif][1]) // remappable F9 + else if (ch == KEY_F9 || ch == gamecontrol[0][gc_recordgif][0] || ch == gamecontrol[0][gc_recordgif][1]) // remappable F9 ((moviemode) ? M_StopMovie : M_StartMovie)(); else return false; diff --git a/src/st_stuff.c b/src/st_stuff.c index 6e39661e7..aac9b7fa7 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -506,8 +506,8 @@ static void ST_drawLevelTitle(void) static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound, boolean gamectrl) { static char buttname[32] = ""; - const char *butt1 = (gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL); - const char *butt2 = (gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL); // alternative bind + const char *butt1 = (gamecontrol[0][control][0] != 0 ? G_KeynumToString(gamecontrol[0][control][0]) : NULL); + const char *butt2 = (gamecontrol[0][control][1] != 0 ? G_KeynumToString(gamecontrol[0][control][1]) : NULL); // alternative bind if (butt1 == NULL && butt2 == NULL) // not bound to a button snprintf(buttname, 32, (unbound ? "%s - %s" : (gamectrl ? "-%s - %s" : "%s - %s")), (unbound ? "Unbound" : ""), inputtext); From 58a9e17500296996f402e93da3ce26dc863d5d19 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 09:42:01 +0200 Subject: [PATCH 08/12] fix spectator key lel oopsie --- src/g_game.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index eaec9e212..18b7f94c0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1299,6 +1299,25 @@ static INT32 pausedelay = 0; static INT32 camtoggledelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; static INT32 spectatedelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; +static void G_ToggleSpectate(INT32 player) +{ + switch (player) + { + case 0: + COM_ImmedExecute("changeteam spectator"); + break; + case 1: + COM_ImmedExecute("changeteam2 spectator"); + break; + case 2: + COM_ImmedExecute("changeteam3 spectator"); + break; + case 3: + COM_ImmedExecute("changeteam4 spectator"); + break; + } +} + static boolean G_LevelResponder(event_t *ev) { // allow spy mode changes even during the demo @@ -1500,7 +1519,7 @@ boolean G_Responder(event_t *ev) if (!spectatedelay[i]) { spectatedelay[i] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam spectator"); + G_ToggleSpectate(i); } } From b6fd7a1e9675f6fa6513f3aea765a334e56672c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 13:02:26 +0200 Subject: [PATCH 09/12] put precip purge into a function to reduce code dupe and branching --- src/p_mobj.c | 20 ++++++-------------- src/p_saveg.c | 19 +------------------ src/p_spec.c | 44 +++++++++++++++----------------------------- src/p_spec.h | 1 + src/r_main.c | 22 +++------------------- 5 files changed, 26 insertions(+), 80 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index fb34b335d..364396ce8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10174,21 +10174,13 @@ void P_RemoveSavegameMobj(mobj_t *mobj) thinker_t *th = (thinker_t*)mobj; // unlink from sector and block lists - if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker) - { - P_UnsetPrecipThingPosition((precipmobj_t *)mobj); - } - else - { - // unlink from sector and block lists - P_UnsetThingPosition(mobj); + P_UnsetThingPosition(mobj); - // Remove touching_sectorlist from mobj. - if (sector_list) - { - P_DelSeclist(sector_list); - sector_list = NULL; - } + // Remove touching_sectorlist from mobj. + if (sector_list) + { + P_DelSeclist(sector_list); + sector_list = NULL; } // stop any playing sound diff --git a/src/p_saveg.c b/src/p_saveg.c index b5f11cedb..c63887b69 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2669,8 +2669,6 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) { thinker_t *currentthinker; thinker_t *next; - thinker_t *currentprecipthinker; - thinker_t *nextprecip; UINT8 tclass; UINT8 restoreNum = false; UINT32 i; @@ -2696,22 +2694,7 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) } // remove all the current precip thinkers - currentprecipthinker = precipcap.next; - for (currentprecipthinker = precipcap.next; currentprecipthinker != &precipcap; currentprecipthinker = nextprecip) - { - nextprecip = currentprecipthinker->next; - -#ifdef PARANOIA - if (currentprecipthinker->function.acp1 != (actionf_p1)P_NullPrecipThinker) - { - (next->prev = currentprecipthinker->prev)->next = nextprecip; - R_DestroyLevelInterpolators(currentprecipthinker); - Z_Free(currentprecipthinker); - } - else -#endif - P_RemoveSavegameMobj((mobj_t *)currentprecipthinker); // item isn't saved, don't remove it - } + P_PurgePrecipitation(); // we don't want the removed mobjs to come back iquetail = iquehead = 0; diff --git a/src/p_spec.c b/src/p_spec.c index 670289fcf..e14d09333 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1721,6 +1721,19 @@ static boolean is_rain_type (INT32 weathernum) } } +void P_PurgePrecipitation(void) +{ + thinker_t *think; + thinker_t *next; + + for (think = precipcap.next; think != NULL && think != &precipcap;) + { + next = think->next; + P_FreePrecipMobj((precipmobj_t *)think); + think = next; + } +} + // // P_SwitchWeather // @@ -1729,6 +1742,7 @@ static boolean is_rain_type (INT32 weathernum) void P_SwitchWeather(INT32 weathernum) { boolean purge = true; + boolean spawnprecip = false; if (weathernum == curWeather) return; @@ -1739,22 +1753,7 @@ void P_SwitchWeather(INT32 weathernum) if (purge) { - thinker_t *think; - thinker_t *next; - precipmobj_t *precipmobj; - - for (think = precipcap.next; think != &precipcap; think = next) - { - next = think->next; - -#ifdef PARANOIA - if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) - continue; // not a precipmobj thinker -#endif - - precipmobj = (precipmobj_t *)think; - P_FreePrecipMobj(precipmobj); - } + P_PurgePrecipitation(); } else // Rather than respawn all that crap, reuse it! { @@ -1764,11 +1763,6 @@ void P_SwitchWeather(INT32 weathernum) for (think = precipcap.next; think != &precipcap; think = think->next) { -#ifdef PARANOIA - if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) - continue; // not a precipmobj thinker -#endif - precipmobj = (precipmobj_t *)think; INT32 z = 0; @@ -1813,8 +1807,6 @@ void P_SwitchWeather(INT32 weathernum) } } - boolean spawnprecip = false; - switch (weathernum) { case PRECIP_SNOW: // snow @@ -1822,23 +1814,17 @@ void P_SwitchWeather(INT32 weathernum) spawnprecip = true; break; case PRECIP_RAIN: // rain - { curWeather = PRECIP_RAIN; spawnprecip = true; break; - } case PRECIP_STORM: // storm - { curWeather = PRECIP_STORM; spawnprecip = true; break; - } case PRECIP_STORM_NOSTRIKES: // storm w/o lightning - { curWeather = PRECIP_STORM_NOSTRIKES; spawnprecip = true; break; - } case PRECIP_STORM_NORAIN: // storm w/o rain curWeather = PRECIP_STORM_NORAIN; break; diff --git a/src/p_spec.h b/src/p_spec.h index c89d024d2..60b10a8f4 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -74,6 +74,7 @@ INT32 P_FindMinSurroundingLight(sector_t *sector, INT32 max); void P_SetupSignExit(player_t *player); boolean P_IsFlagAtBase(mobjtype_t flag); +void P_PurgePrecipitation(void); void P_SwitchWeather(INT32 weathernum); boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller); diff --git a/src/r_main.c b/src/r_main.c index 4ff9a96ff..b1b707d1d 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -295,27 +295,11 @@ static void FlipCam4_OnChange(void) static void Precipstuff_OnChange(void) { - if (gamestate != GS_LEVEL) - return; - - thinker_t *think; - thinker_t *next; - precipmobj_t *precipmobj; - - for (think = precipcap.next; think != &precipcap; think = next) + if (gamestate == GS_LEVEL) { - next = think->next; - -#ifdef PARANOIA - if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) - continue; // not a precipmobj thinker -#endif - - precipmobj = (precipmobj_t *)think; - P_FreePrecipMobj(precipmobj); + P_PurgePrecipitation(); + P_SpawnPrecipitation(); } - - P_SpawnPrecipitation(); } // From 45506b381e7c167c4c232622304e849917dc11f0 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 13:11:09 +0200 Subject: [PATCH 10/12] take mobjscale into account when skipping small sectors for precip spawn --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 364396ce8..3fd74f4a7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10244,7 +10244,7 @@ void P_SpawnPrecipitation(void) continue; // Exists, but is too small for reasonable precipitation. - if (!(precipsector->sector->floorheight <= precipsector->sector->ceilingheight - (32<sector->ceilingheight - precipsector->sector->floorheight, mapobjectscale) < 64< Date: Thu, 24 Apr 2025 06:56:35 +0200 Subject: [PATCH 11/12] deprecate "addskins" command "addskins" is an incredibly ambigous name since its main purpose was to add skins LOCALLY just prints a notice for now since there may be ppl that still use it --- src/d_netcmd.c | 35 +++-------------------------------- src/p_setup.c | 11 ----------- src/p_setup.h | 2 +- 3 files changed, 4 insertions(+), 44 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index d3b9ca5b4..cd9c354fe 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4449,7 +4449,7 @@ static void Command_Addfilelocal(void) // Add any wad file, ignoring checks for if it contains complex things like // lua. Great for complex but client-side customizations, like different // level cards or anything like that. - P_AddWadFileLocal(fn); + P_AddWadFile(fn, true); } @@ -4544,38 +4544,9 @@ static void Command_Addfile(void) /** Adds something at runtime. */ -static void -Command_Addskins (void) +static void Command_Addskins(void) { - if (COM_Argc() > 3) - { - CONS_Printf( - "addskins : Load a skin file.\n"); - return; - } - // no forcing? - /* - if (fasticmp(COM_Argv(2), "-force") || fasticmp(COM_Argv(2), "-f")) { - CONS_Alert(CONS_NOTICE, M_GetText("Adding file %s. May or may not be a skin.\n"), COM_Argv(1)); - P_AddWadFile(COM_Argv(1), 0, true); - } else { - if (DumbStartsWith("KC_", COM_Argv(1))) { - P_AddWadFile(COM_Argv(1), 0, true); - } else if (DumbStartsWith("KCL_", COM_Argv(1))) { - if (!demo.playback) { - CONS_Alert(CONS_ERROR, M_GetText("Cannot add file %s as it is a skin with lua. Include -force or -f to force it to load.\n"), COM_Argv(1)); - return; - } else { - */ - P_AddWadFile(COM_Argv(1), true); - /* - } - } else { - CONS_Alert(CONS_ERROR, M_GetText("Cannot add file %s as it is not a skin.\n"), COM_Argv(1)); - return; - } - } - */ + CONS_Printf("addskins has been deprecated\nuse addfilelocal instead!\n"); } static void Command_GLocalSkin (void) diff --git a/src/p_setup.c b/src/p_setup.c index b51a8abce..1ef81c3cb 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3252,17 +3252,6 @@ boolean P_AddWadFile(const char *wadfilename, boolean local) return true; } -boolean P_AddWadFileLocal(const char *wadfilename) -{ - UINT16 wadnum; - - if ((wadnum = P_PartialAddWadFile(wadfilename, true)) == UINT16_MAX) - return false; - - P_MultiSetupWadFiles(true); - return true; -} - // check for replacement votescreen backgrounds boolean wideracereplaced = false; boolean racereplaced = false; diff --git a/src/p_setup.h b/src/p_setup.h index 723b48d18..f0ae13e6c 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -65,8 +65,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate); #ifdef HWRENDER void HWR_LoadLevel(void); #endif + boolean P_AddWadFile(const char *wadfilename, boolean local); -boolean P_AddWadFileLocal(const char *wadfilename); extern boolean wideracereplaced; extern boolean racereplaced; From cd15c5d3803651b756a831ef39aae77a1acc6a07 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 09:21:11 +0200 Subject: [PATCH 12/12] oops didnt think addskins would be used here lel --- 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 27902ce9c..b78e72ee5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6719,7 +6719,7 @@ static void M_HandleAddons(INT32 choice) { if (DumbStartsWith("KC_", dirmenu[dir_on[menudepthleft]]+DIR_STRING) || DumbStartsWith("kc_", dirmenu[dir_on[menudepthleft]]+DIR_STRING)) { M_StartMessage(va("%c%s\x80\nYou are loading a local skin.\nLocal skins will not be usable\nafter going back from\nthe title screen.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING); - COM_BufAddText(va("addskins \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); + COM_BufAddText(va("addfilelocal \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); } else S_StartSound(NULL, sfx_s26d);