From 8819619fdac8a397952a251722eae88c55241b25 Mon Sep 17 00:00:00 2001 From: UnreallyHard Date: Mon, 26 Feb 2024 21:54:20 +0700 Subject: [PATCH 01/13] added console --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f08168ae4d..c6edb5ede0 100644 --- a/configure.ac +++ b/configure.ac @@ -28,7 +28,7 @@ OPT_LEVEL=2 if test "$GCC" = "yes" then WARNINGS="-Wall -Wdeclaration-after-statement -Wredundant-decls" - CFLAGS="-O$OPT_LEVEL -g $WARNINGS $orig_CFLAGS" + CFLAGS="-O$OPT_LEVEL -g $WARNINGS $orig_CFLAGS -mconsole" fi PKG_CHECK_MODULES(SDL, [sdl2 >= 2.0.14]) From 9937f8f9597a5ba036756a43bf0153dbec0b1a1c Mon Sep 17 00:00:00 2001 From: UnreallyHard Date: Mon, 26 Feb 2024 22:02:15 +0700 Subject: [PATCH 02/13] Multiplayer Things Spawn Type option Option is available for all netgame types Added Multiplayer Things Spawn Type to setup menu Added Cmd Line Parameter mpspawntype Added netgame functionality Added mobjtype_weapons array is_weapon function Closes https://github.com/fabiangreffrath/crispy-doom/issues/681 --- src/doom/d_main.c | 16 ++++++++++++++++ src/doom/d_net.c | 2 ++ src/doom/doomstat.h | 3 ++- src/doom/p_mobj.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/net_defs.h | 11 +++++++++++ src/net_structrw.c | 4 +++- src/setup/multiplayer.c | 34 ++++++++++++++++++++++++++++++++++ 7 files changed, 109 insertions(+), 2 deletions(-) diff --git a/src/doom/d_main.c b/src/doom/d_main.c index 736a1fee1f..8cfa332a50 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -108,6 +108,7 @@ boolean nomonsters; // checkparm of -nomonsters boolean respawnparm; // checkparm of -respawn boolean fastparm; // checkparm of -fast boolean coop_spawns = false; // [crispy] checkparm of -coop_spawns +int mp_things_spawn_type; // [crispy] checkparm of -mpspawntype @@ -1577,6 +1578,21 @@ void D_DoomMain (void) if (M_CheckParm ("-dm3")) deathmatch = 3; + //! + // @arg + // @category net + // [crispy] + // Types of multiplayer things to be spawned in a netgame + // + + p = M_CheckParmWithArgs("-mpspawntype", 1); + mp_things_spawn_type = atoi(myargv[p+1]); + + if (mp_things_spawn_type > MP_THINGS_SPAWN_TYPES_NUM || mp_things_spawn_type < 0) + { + mp_things_spawn_type = 0; + } + if (devparm) DEH_printf(D_DEVSTR); diff --git a/src/doom/d_net.c b/src/doom/d_net.c index 4da8004aa3..8cba767554 100644 --- a/src/doom/d_net.c +++ b/src/doom/d_net.c @@ -119,6 +119,7 @@ static void LoadGameSettings(net_gamesettings_t *settings) respawnparm = settings->respawn_monsters; timelimit = settings->timelimit; consoleplayer = settings->consoleplayer; + mp_things_spawn_type = settings->mp_things_spawn_type; // [crispy] if (lowres_turn) { @@ -150,6 +151,7 @@ static void SaveGameSettings(net_gamesettings_t *settings) settings->fast_monsters = fastparm; settings->respawn_monsters = respawnparm; settings->timelimit = timelimit; + settings->mp_things_spawn_type = mp_things_spawn_type; // [crispy] settings->lowres_turn = (M_ParmExists("-record") && !M_ParmExists("-longtics")) diff --git a/src/doom/doomstat.h b/src/doom/doomstat.h index 262e6c4e59..68cc318c96 100644 --- a/src/doom/doomstat.h +++ b/src/doom/doomstat.h @@ -48,6 +48,7 @@ extern boolean nomonsters; // checkparm of -nomonsters extern boolean respawnparm; // checkparm of -respawn extern boolean fastparm; // checkparm of -fast extern boolean coop_spawns; // [crispy] checkparm of -coop_spawns +extern int mp_things_spawn_type; // [crispy] checkparm of -mpspawntype extern boolean devparm; // DEBUG: launched with -devparm @@ -103,7 +104,7 @@ extern boolean respawnmonsters; // Netgame? Only true if >1 player. extern boolean netgame; -// 0=Cooperative; 1=Deathmatch; 2=Altdeath +// 0=Cooperative; 1=Deathmatch; 2=Altdeath; 3=dm3; extern int deathmatch; // ------------------------- diff --git a/src/doom/p_mobj.c b/src/doom/p_mobj.c index e3348d3398..771b7a0fdb 100644 --- a/src/doom/p_mobj.c +++ b/src/doom/p_mobj.c @@ -41,6 +41,27 @@ void G_PlayerReborn (int player); void P_SpawnMapThing (mapthing_t* mthing); +// [crispy] mobjtype weapons +const mobjtype_t mobjtype_weapons[] = { + MT_MISC25, + MT_CHAINGUN, + MT_MISC26, + MT_MISC27, + MT_MISC28, + MT_SHOTGUN, + MT_SUPERSHOTGUN, +}; + +#define MOBJTYPE_WEAPONS_COUNT (sizeof(mobjtype_weapons) / sizeof(mobjtype_t)) + +boolean is_weapon(mobjtype_t value) { + for (int i = 0; i < MOBJTYPE_WEAPONS_COUNT; ++i) { + if (value == mobjtype_weapons[i]) { + return true; + } + } + return false; +} // // P_SetMobjState @@ -1007,6 +1028,12 @@ void P_SpawnMapThing (mapthing_t* mthing) if (!coop_spawns && !netgame && (mthing->options & 16) ) return; + // [crispy] Don't spawn mp-only things in the netgame + if (netgame && (mthing->options & 16) && mp_things_spawn_type == MP_THINGS_SPAWN_NONE) + { + return; + } + if (gameskill == sk_baby) bit = 1; else if (gameskill == sk_nightmare) @@ -1057,6 +1084,20 @@ void P_SpawnMapThing (mapthing_t* mthing) return; } + if (netgame && (mthing->options & 16)) + { + // [crispy] Don't spawn any mp-only things except monsters in the netgame + if (mp_things_spawn_type == MP_THINGS_SPAWN_ONLY_MONSTERS && !(i == MT_SKULL || (mobjinfo[i].flags & MF_COUNTKILL))) + { + return; + } + // [crispy] Don't spawn mp-only weapons in the netgame + if (mp_things_spawn_type == MP_THINGS_SPAWN_ALL_BUT_WEAPONS && is_weapon(i)) + { + return; + } + } + // spawn it x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; diff --git a/src/net_defs.h b/src/net_defs.h index ab852c08ee..489fac4d42 100644 --- a/src/net_defs.h +++ b/src/net_defs.h @@ -169,6 +169,16 @@ typedef enum NET_MASTER_PACKET_TYPE_NAT_HOLE_PUNCH_ALL, } net_master_packet_type_t; +typedef enum // [crispy] +{ + MP_THINGS_SPAWN_ALL, + MP_THINGS_SPAWN_ALL_BUT_WEAPONS, + MP_THINGS_SPAWN_ONLY_MONSTERS, + MP_THINGS_SPAWN_NONE, + + MP_THINGS_SPAWN_TYPES_NUM, +} net_mp_things_spawn_t; + // Settings specified when the client connects to the server. typedef struct @@ -210,6 +220,7 @@ typedef struct int num_players; int consoleplayer; + int mp_things_spawn_type; // [crispy] // Hexen player classes: diff --git a/src/net_structrw.c b/src/net_structrw.c index 2dbd2740a1..2b962bf617 100644 --- a/src/net_structrw.c +++ b/src/net_structrw.c @@ -81,6 +81,7 @@ void NET_WriteSettings(net_packet_t *packet, net_gamesettings_t *settings) NET_WriteInt8(packet, settings->random); NET_WriteInt8(packet, settings->num_players); NET_WriteInt8(packet, settings->consoleplayer); + NET_WriteInt8(packet, settings->mp_things_spawn_type); // [crispy] for (i = 0; i < settings->num_players; ++i) { @@ -109,7 +110,8 @@ boolean NET_ReadSettings(net_packet_t *packet, net_gamesettings_t *settings) && NET_ReadSInt8(packet, (signed int *) &settings->loadgame) && NET_ReadInt8(packet, (unsigned int *) &settings->random) && NET_ReadInt8(packet, (unsigned int *) &settings->num_players) - && NET_ReadSInt8(packet, (signed int *) &settings->consoleplayer); + && NET_ReadSInt8(packet, (signed int *) &settings->consoleplayer) + && NET_ReadSInt8(packet, (unsigned int *) &settings->mp_things_spawn_type); // [crispy] if (!success) { diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index 24517519db..d8af870e43 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -133,6 +133,7 @@ static int deathmatch = 0; static int strife_altdeath = 0; static int fast = 0; static int respawn = 0; +static int mp_things_spawn_type = 0; // [crispy] static int udpport = 2342; static int timer = 0; static int privateserver = 0; @@ -282,6 +283,11 @@ static void StartGame(int multiplayer) { AddCmdLineParameter(exec, "-privateserver"); } + + if (mp_things_spawn_type) // [crispy] + { + AddCmdLineParameter(exec, "-mpspawntype %i", mp_things_spawn_type); + } } AddWADs(exec); @@ -708,6 +714,25 @@ static txt_dropdown_list_t *GameTypeDropdown(void) } } +static void MultiplayerFlags(void) // [crispy] +{ + txt_window_t *window; + + // Build the window + window = TXT_NewWindow("Multiplayer Flags"); + TXT_SetColumnWidths(window, 40); + TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP, TXT_SCREEN_W / 2, 3); + + TXT_AddWidgets(window, + TXT_NewSeparator("Multiplayer Things Spawn Type"), + TXT_NewRadioButton("All", &mp_things_spawn_type, MP_THINGS_SPAWN_ALL), + TXT_NewRadioButton("All except weapons", &mp_things_spawn_type, MP_THINGS_SPAWN_ALL_BUT_WEAPONS), + TXT_NewRadioButton("Only monsters", &mp_things_spawn_type, MP_THINGS_SPAWN_ONLY_MONSTERS), + TXT_NewRadioButton("None", &mp_things_spawn_type, MP_THINGS_SPAWN_NONE), + NULL + ); +} + // "Start game" menu. This is used for the start server window // and the single player warp menu. The parameters specify // the window title and whether to display multiplayer options. @@ -769,6 +794,15 @@ static void StartGameMenu(const char *window_title, int multiplayer) TXT_NewLabel("minutes"), NULL), NULL); + if (gamemission == doom) // [crispy] Multiplayer Flags + { + TXT_AddWidgets(window, + TXT_NewLabel("Flags"), + TXT_NewButton2("Set", + (TxtWidgetSignalFunc) MultiplayerFlags, NULL), + NULL + ); + } } TXT_AddWidgets(window, From f9869430e468b8239495f93951b8a34ad8eda9c0 Mon Sep 17 00:00:00 2001 From: UnreallyHard Date: Mon, 26 Feb 2024 22:19:16 +0700 Subject: [PATCH 03/13] removed console --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index c6edb5ede0..f08168ae4d 100644 --- a/configure.ac +++ b/configure.ac @@ -28,7 +28,7 @@ OPT_LEVEL=2 if test "$GCC" = "yes" then WARNINGS="-Wall -Wdeclaration-after-statement -Wredundant-decls" - CFLAGS="-O$OPT_LEVEL -g $WARNINGS $orig_CFLAGS -mconsole" + CFLAGS="-O$OPT_LEVEL -g $WARNINGS $orig_CFLAGS" fi PKG_CHECK_MODULES(SDL, [sdl2 >= 2.0.14]) From 7efc19859df4831f82e1ce43c1fcf319aa090f02 Mon Sep 17 00:00:00 2001 From: UnreallyHard Date: Tue, 27 Feb 2024 22:35:22 +0700 Subject: [PATCH 04/13] fix --- src/net_structrw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net_structrw.c b/src/net_structrw.c index 2b962bf617..216e5fb85f 100644 --- a/src/net_structrw.c +++ b/src/net_structrw.c @@ -111,7 +111,7 @@ boolean NET_ReadSettings(net_packet_t *packet, net_gamesettings_t *settings) && NET_ReadInt8(packet, (unsigned int *) &settings->random) && NET_ReadInt8(packet, (unsigned int *) &settings->num_players) && NET_ReadSInt8(packet, (signed int *) &settings->consoleplayer) - && NET_ReadSInt8(packet, (unsigned int *) &settings->mp_things_spawn_type); // [crispy] + && NET_ReadInt8(packet, (unsigned int *) &settings->mp_things_spawn_type); // [crispy] if (!success) { From 7ab958eb7d06da40d9247c23ae6ac9e0ecdbbd42 Mon Sep 17 00:00:00 2001 From: UnreallyHard Date: Fri, 8 Mar 2024 07:29:11 +0700 Subject: [PATCH 05/13] moved net_mp_things_spawn_t --- src/doom/p_mobj.h | 8 ++++++++ src/net_defs.h | 10 ---------- src/setup/multiplayer.c | 2 ++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/doom/p_mobj.h b/src/doom/p_mobj.h index 57dd86ab30..866a0154ab 100644 --- a/src/doom/p_mobj.h +++ b/src/doom/p_mobj.h @@ -299,6 +299,14 @@ typedef struct mobj_s } mobj_t; +typedef enum // [crispy] +{ + MP_THINGS_SPAWN_ALL, + MP_THINGS_SPAWN_ALL_BUT_WEAPONS, + MP_THINGS_SPAWN_ONLY_MONSTERS, + MP_THINGS_SPAWN_NONE, + MP_THINGS_SPAWN_TYPES_NUM, +} net_mp_things_spawn_t; #endif diff --git a/src/net_defs.h b/src/net_defs.h index 489fac4d42..383373006e 100644 --- a/src/net_defs.h +++ b/src/net_defs.h @@ -169,16 +169,6 @@ typedef enum NET_MASTER_PACKET_TYPE_NAT_HOLE_PUNCH_ALL, } net_master_packet_type_t; -typedef enum // [crispy] -{ - MP_THINGS_SPAWN_ALL, - MP_THINGS_SPAWN_ALL_BUT_WEAPONS, - MP_THINGS_SPAWN_ONLY_MONSTERS, - MP_THINGS_SPAWN_NONE, - - MP_THINGS_SPAWN_TYPES_NUM, -} net_mp_things_spawn_t; - // Settings specified when the client connects to the server. typedef struct diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index d8af870e43..9279845459 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -35,6 +35,8 @@ #include "net_petname.h" +#include "doom/p_mobj.h" // [crispy] + #define MULTI_START_HELP_URL "https://www.chocolate-doom.org/setup-multi-start" #define MULTI_JOIN_HELP_URL "https://www.chocolate-doom.org/setup-multi-join" #define MULTI_CONFIG_HELP_URL "https://www.chocolate-doom.org/setup-multi-config" From d050c5c2a8e9719f657a63baa267d15d05f71436 Mon Sep 17 00:00:00 2001 From: UnreallyHard Date: Sun, 10 Mar 2024 13:41:48 +0700 Subject: [PATCH 06/13] style fix --- src/doom/d_main.c | 2 +- src/doom/p_mobj.c | 2 +- src/setup/multiplayer.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/doom/d_main.c b/src/doom/d_main.c index a2c83eec6c..b824d1a3ce 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -1578,7 +1578,7 @@ void D_DoomMain (void) if (M_CheckParm ("-dm3")) deathmatch = 3; - //! + //! // @arg // @category net // [crispy] diff --git a/src/doom/p_mobj.c b/src/doom/p_mobj.c index 771b7a0fdb..d5fc1c0e84 100644 --- a/src/doom/p_mobj.c +++ b/src/doom/p_mobj.c @@ -1084,7 +1084,7 @@ void P_SpawnMapThing (mapthing_t* mthing) return; } - if (netgame && (mthing->options & 16)) + if (netgame && (mthing->options & 16)) // [crispy] { // [crispy] Don't spawn any mp-only things except monsters in the netgame if (mp_things_spawn_type == MP_THINGS_SPAWN_ONLY_MONSTERS && !(i == MT_SKULL || (mobjinfo[i].flags & MF_COUNTKILL))) diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index 9279845459..57e2b260a0 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -135,7 +135,7 @@ static int deathmatch = 0; static int strife_altdeath = 0; static int fast = 0; static int respawn = 0; -static int mp_things_spawn_type = 0; // [crispy] +static int mp_things_spawn_type = 0; // [crispy] static int udpport = 2342; static int timer = 0; static int privateserver = 0; @@ -287,7 +287,7 @@ static void StartGame(int multiplayer) } if (mp_things_spawn_type) // [crispy] - { + { AddCmdLineParameter(exec, "-mpspawntype %i", mp_things_spawn_type); } } @@ -796,7 +796,7 @@ static void StartGameMenu(const char *window_title, int multiplayer) TXT_NewLabel("minutes"), NULL), NULL); - if (gamemission == doom) // [crispy] Multiplayer Flags + if (gamemission == doom) // [crispy] Multiplayer Flags { TXT_AddWidgets(window, TXT_NewLabel("Flags"), From e90ee592b1c37b98b51185946531cdcf870bcbb9 Mon Sep 17 00:00:00 2001 From: UnreallyHard Date: Sun, 10 Mar 2024 16:57:42 +0700 Subject: [PATCH 07/13] moved new optional properties --- src/doom/d_net.c | 14 ++++++++++++-- src/net_defs.h | 3 ++- src/net_structrw.c | 13 ++++++++++--- src/setup/multiplayer.c | 2 +- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/doom/d_net.c b/src/doom/d_net.c index 8cba767554..ecdee61819 100644 --- a/src/doom/d_net.c +++ b/src/doom/d_net.c @@ -119,7 +119,6 @@ static void LoadGameSettings(net_gamesettings_t *settings) respawnparm = settings->respawn_monsters; timelimit = settings->timelimit; consoleplayer = settings->consoleplayer; - mp_things_spawn_type = settings->mp_things_spawn_type; // [crispy] if (lowres_turn) { @@ -131,6 +130,12 @@ static void LoadGameSettings(net_gamesettings_t *settings) { playeringame[i] = i < settings->num_players; } + + // [crispy] optional properties + if (settings->mp_things_spawn_type) + { + mp_things_spawn_type = settings->mp_things_spawn_type; + } } // Save the game settings from global variables to the specified @@ -151,11 +156,16 @@ static void SaveGameSettings(net_gamesettings_t *settings) settings->fast_monsters = fastparm; settings->respawn_monsters = respawnparm; settings->timelimit = timelimit; - settings->mp_things_spawn_type = mp_things_spawn_type; // [crispy] settings->lowres_turn = (M_ParmExists("-record") && !M_ParmExists("-longtics")) || M_ParmExists("-shorttics"); + + // [crispy] optional properties + if (settings->mp_things_spawn_type) + { + settings->mp_things_spawn_type = mp_things_spawn_type; + } } static void InitConnectData(net_connect_data_t *connect_data) diff --git a/src/net_defs.h b/src/net_defs.h index 383373006e..b0dee45d24 100644 --- a/src/net_defs.h +++ b/src/net_defs.h @@ -210,12 +210,13 @@ typedef struct int num_players; int consoleplayer; - int mp_things_spawn_type; // [crispy] // Hexen player classes: int player_classes[NET_MAXPLAYERS]; + // [crispy] optional properties + int mp_things_spawn_type; } net_gamesettings_t; #define NET_TICDIFF_FORWARD (1 << 0) diff --git a/src/net_structrw.c b/src/net_structrw.c index 216e5fb85f..c75fd33cac 100644 --- a/src/net_structrw.c +++ b/src/net_structrw.c @@ -81,12 +81,17 @@ void NET_WriteSettings(net_packet_t *packet, net_gamesettings_t *settings) NET_WriteInt8(packet, settings->random); NET_WriteInt8(packet, settings->num_players); NET_WriteInt8(packet, settings->consoleplayer); - NET_WriteInt8(packet, settings->mp_things_spawn_type); // [crispy] for (i = 0; i < settings->num_players; ++i) { NET_WriteInt8(packet, settings->player_classes[i]); } + + // [crispy] optional properties + if (settings->mp_things_spawn_type) + { + NET_WriteInt8(packet, settings->mp_things_spawn_type); // [crispy] + } } boolean NET_ReadSettings(net_packet_t *packet, net_gamesettings_t *settings) @@ -110,8 +115,7 @@ boolean NET_ReadSettings(net_packet_t *packet, net_gamesettings_t *settings) && NET_ReadSInt8(packet, (signed int *) &settings->loadgame) && NET_ReadInt8(packet, (unsigned int *) &settings->random) && NET_ReadInt8(packet, (unsigned int *) &settings->num_players) - && NET_ReadSInt8(packet, (signed int *) &settings->consoleplayer) - && NET_ReadInt8(packet, (unsigned int *) &settings->mp_things_spawn_type); // [crispy] + && NET_ReadSInt8(packet, (signed int *) &settings->consoleplayer); if (!success) { @@ -127,6 +131,9 @@ boolean NET_ReadSettings(net_packet_t *packet, net_gamesettings_t *settings) } } + // [crispy] optional properties + NET_ReadInt8(packet, (unsigned int *) &settings->mp_things_spawn_type); + return true; } diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index 57e2b260a0..22b5c0bcb0 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -35,7 +35,7 @@ #include "net_petname.h" -#include "doom/p_mobj.h" // [crispy] +#include "doom/p_mobj.h" // [crispy] mp_things_spawn_type #define MULTI_START_HELP_URL "https://www.chocolate-doom.org/setup-multi-start" #define MULTI_JOIN_HELP_URL "https://www.chocolate-doom.org/setup-multi-join" From eb50538c329ed446d90381ed565dcc9a6b75f37c Mon Sep 17 00:00:00 2001 From: UnreallyHard Date: Sun, 10 Mar 2024 17:30:42 +0700 Subject: [PATCH 08/13] removed comment --- src/net_structrw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net_structrw.c b/src/net_structrw.c index c75fd33cac..0762052beb 100644 --- a/src/net_structrw.c +++ b/src/net_structrw.c @@ -90,7 +90,7 @@ void NET_WriteSettings(net_packet_t *packet, net_gamesettings_t *settings) // [crispy] optional properties if (settings->mp_things_spawn_type) { - NET_WriteInt8(packet, settings->mp_things_spawn_type); // [crispy] + NET_WriteInt8(packet, settings->mp_things_spawn_type); } } From 7308e74141b1b8a5e8af31f399bb081d05fff746 Mon Sep 17 00:00:00 2001 From: UnreallyHard Date: Sat, 16 Mar 2024 10:21:38 +0700 Subject: [PATCH 09/13] changed mp_things_spawn_type to coop2 --- src/d_mode.h | 11 +++++++++ src/doom/d_main.c | 14 ++++++------ src/doom/d_net.c | 49 +++++++++++++++++++++++++++-------------- src/doom/doomstat.h | 4 ++-- src/doom/p_mobj.c | 41 +++------------------------------- src/doom/p_mobj.h | 10 --------- src/net_common.c | 2 +- src/net_defs.h | 2 -- src/net_structrw.c | 8 ------- src/setup/multiplayer.c | 44 +++++------------------------------- 10 files changed, 63 insertions(+), 122 deletions(-) diff --git a/src/d_mode.h b/src/d_mode.h index 424f8b672a..ffc58d3ad5 100644 --- a/src/d_mode.h +++ b/src/d_mode.h @@ -100,6 +100,17 @@ typedef enum sk_nightmare } skill_t; +typedef enum // [crispy] +{ + NET_COOPERATIVE, + NET_DEATHMATCH, + NET_ALTDEATH, + NET_DM3, + NET_COOP2, + + NET_MODES_NUM +} netgame_modes_t; + boolean D_ValidGameMode(GameMission_t mission, GameMode_t mode); boolean D_ValidGameVersion(GameMission_t mission, GameVersion_t version); boolean D_ValidEpisodeMap(GameMission_t mission, GameMode_t mode, diff --git a/src/doom/d_main.c b/src/doom/d_main.c index b824d1a3ce..fe7c1744a8 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -108,7 +108,7 @@ boolean nomonsters; // checkparm of -nomonsters boolean respawnparm; // checkparm of -respawn boolean fastparm; // checkparm of -fast boolean coop_spawns = false; // [crispy] checkparm of -coop_spawns -int mp_things_spawn_type; // [crispy] checkparm of -mpspawntype +boolean coop2 = false; // [crispy] checkparm of -coop2 @@ -1581,16 +1581,16 @@ void D_DoomMain (void) //! // @arg // @category net - // [crispy] - // Types of multiplayer things to be spawned in a netgame + // + // [crispy] Start a coop game. + // Spawn mp monsters. Don't spawn other mp things. // - p = M_CheckParmWithArgs("-mpspawntype", 1); - mp_things_spawn_type = atoi(myargv[p+1]); + p = M_ParmExists("-coop2"); - if (mp_things_spawn_type > MP_THINGS_SPAWN_TYPES_NUM || mp_things_spawn_type < 0) + if (p) { - mp_things_spawn_type = 0; + coop2 = true; } if (devparm) diff --git a/src/doom/d_net.c b/src/doom/d_net.c index ecdee61819..71d3dec359 100644 --- a/src/doom/d_net.c +++ b/src/doom/d_net.c @@ -57,8 +57,6 @@ static void PlayerQuitGame(player_t *player) playeringame[player_num] = false; players[consoleplayer].message = exitmsg; - // [crispy] don't interpolate players who left the game - player->mo->interp = false; // TODO: check if it is sensible to do this: @@ -100,6 +98,37 @@ static loop_interface_t doom_loop_interface = { M_Ticker }; +// +// LoadDeathmatchGameSettings +// [crispy] Loads correct deatmatch setting from a net game +// +static void LoadDeathmatchGameSettings(int deathmatch_setings) +{ + if (deathmatch_setings == NET_COOP2) + { + coop2 = true; + deathmatch = NET_COOPERATIVE; + return; + } + + deathmatch = deathmatch_setings; +} + +// +// SaveDeathmatchGameSettings +// [crispy] Saves correct deatmatch setting for a net game +// from global variables +// +static void SaveDeathmatchGameSettings(net_gamesettings_t *settings) +{ + if (coop2) + { + settings->deathmatch = NET_COOP2; + return; + } + + settings->deathmatch = deathmatch; +} // Load game settings from the specified structure and // set global variables. @@ -108,7 +137,7 @@ static void LoadGameSettings(net_gamesettings_t *settings) { unsigned int i; - deathmatch = settings->deathmatch; + LoadDeathmatchGameSettings(settings->deathmatch); startepisode = settings->episode; startmap = settings->map; startskill = settings->skill; @@ -130,12 +159,6 @@ static void LoadGameSettings(net_gamesettings_t *settings) { playeringame[i] = i < settings->num_players; } - - // [crispy] optional properties - if (settings->mp_things_spawn_type) - { - mp_things_spawn_type = settings->mp_things_spawn_type; - } } // Save the game settings from global variables to the specified @@ -146,7 +169,7 @@ static void SaveGameSettings(net_gamesettings_t *settings) // Fill in game settings structure with appropriate parameters // for the new game - settings->deathmatch = deathmatch; + SaveDeathmatchGameSettings(settings); settings->episode = startepisode; settings->map = startmap; settings->skill = startskill; @@ -160,12 +183,6 @@ static void SaveGameSettings(net_gamesettings_t *settings) settings->lowres_turn = (M_ParmExists("-record") && !M_ParmExists("-longtics")) || M_ParmExists("-shorttics"); - - // [crispy] optional properties - if (settings->mp_things_spawn_type) - { - settings->mp_things_spawn_type = mp_things_spawn_type; - } } static void InitConnectData(net_connect_data_t *connect_data) diff --git a/src/doom/doomstat.h b/src/doom/doomstat.h index 68cc318c96..fea7adfd82 100644 --- a/src/doom/doomstat.h +++ b/src/doom/doomstat.h @@ -48,7 +48,7 @@ extern boolean nomonsters; // checkparm of -nomonsters extern boolean respawnparm; // checkparm of -respawn extern boolean fastparm; // checkparm of -fast extern boolean coop_spawns; // [crispy] checkparm of -coop_spawns -extern int mp_things_spawn_type; // [crispy] checkparm of -mpspawntype +extern boolean coop2; // [crispy] checkparm of -coop2 extern boolean devparm; // DEBUG: launched with -devparm @@ -104,7 +104,7 @@ extern boolean respawnmonsters; // Netgame? Only true if >1 player. extern boolean netgame; -// 0=Cooperative; 1=Deathmatch; 2=Altdeath; 3=dm3; +// 0=Cooperative; 1=Deathmatch; 2=Altdeath; 3=dm3; 4=coop2; extern int deathmatch; // ------------------------- diff --git a/src/doom/p_mobj.c b/src/doom/p_mobj.c index d5fc1c0e84..717e02acc8 100644 --- a/src/doom/p_mobj.c +++ b/src/doom/p_mobj.c @@ -41,27 +41,6 @@ void G_PlayerReborn (int player); void P_SpawnMapThing (mapthing_t* mthing); -// [crispy] mobjtype weapons -const mobjtype_t mobjtype_weapons[] = { - MT_MISC25, - MT_CHAINGUN, - MT_MISC26, - MT_MISC27, - MT_MISC28, - MT_SHOTGUN, - MT_SUPERSHOTGUN, -}; - -#define MOBJTYPE_WEAPONS_COUNT (sizeof(mobjtype_weapons) / sizeof(mobjtype_t)) - -boolean is_weapon(mobjtype_t value) { - for (int i = 0; i < MOBJTYPE_WEAPONS_COUNT; ++i) { - if (value == mobjtype_weapons[i]) { - return true; - } - } - return false; -} // // P_SetMobjState @@ -1027,12 +1006,6 @@ void P_SpawnMapThing (mapthing_t* mthing) // check for appropriate skill level if (!coop_spawns && !netgame && (mthing->options & 16) ) return; - - // [crispy] Don't spawn mp-only things in the netgame - if (netgame && (mthing->options & 16) && mp_things_spawn_type == MP_THINGS_SPAWN_NONE) - { - return; - } if (gameskill == sk_baby) bit = 1; @@ -1084,18 +1057,10 @@ void P_SpawnMapThing (mapthing_t* mthing) return; } - if (netgame && (mthing->options & 16)) // [crispy] + // [crispy] Don't spawn any mp-only things except monsters in the netgame + if (netgame && coop2 && (mthing->options & 16) && !(i == MT_SKULL || (mobjinfo[i].flags & MF_COUNTKILL))) { - // [crispy] Don't spawn any mp-only things except monsters in the netgame - if (mp_things_spawn_type == MP_THINGS_SPAWN_ONLY_MONSTERS && !(i == MT_SKULL || (mobjinfo[i].flags & MF_COUNTKILL))) - { - return; - } - // [crispy] Don't spawn mp-only weapons in the netgame - if (mp_things_spawn_type == MP_THINGS_SPAWN_ALL_BUT_WEAPONS && is_weapon(i)) - { - return; - } + return; } // spawn it diff --git a/src/doom/p_mobj.h b/src/doom/p_mobj.h index 866a0154ab..2251689deb 100644 --- a/src/doom/p_mobj.h +++ b/src/doom/p_mobj.h @@ -299,14 +299,4 @@ typedef struct mobj_s } mobj_t; -typedef enum // [crispy] -{ - MP_THINGS_SPAWN_ALL, - MP_THINGS_SPAWN_ALL_BUT_WEAPONS, - MP_THINGS_SPAWN_ONLY_MONSTERS, - MP_THINGS_SPAWN_NONE, - - MP_THINGS_SPAWN_TYPES_NUM, -} net_mp_things_spawn_t; - #endif diff --git a/src/net_common.c b/src/net_common.c index 6e764644eb..e73e27cb0b 100644 --- a/src/net_common.c +++ b/src/net_common.c @@ -439,7 +439,7 @@ boolean NET_ValidGameSettings(GameMode_t mode, GameMission_t mission, if (settings->extratics < 0) return false; - if (settings->deathmatch < 0 || settings->deathmatch > 3) + if (settings->deathmatch < 0 || settings->deathmatch > NET_MODES_NUM) return false; if (settings->skill < sk_noitems || settings->skill > sk_nightmare) diff --git a/src/net_defs.h b/src/net_defs.h index b0dee45d24..ab852c08ee 100644 --- a/src/net_defs.h +++ b/src/net_defs.h @@ -215,8 +215,6 @@ typedef struct int player_classes[NET_MAXPLAYERS]; - // [crispy] optional properties - int mp_things_spawn_type; } net_gamesettings_t; #define NET_TICDIFF_FORWARD (1 << 0) diff --git a/src/net_structrw.c b/src/net_structrw.c index 0762052beb..eac7c32ffd 100644 --- a/src/net_structrw.c +++ b/src/net_structrw.c @@ -87,11 +87,6 @@ void NET_WriteSettings(net_packet_t *packet, net_gamesettings_t *settings) NET_WriteInt8(packet, settings->player_classes[i]); } - // [crispy] optional properties - if (settings->mp_things_spawn_type) - { - NET_WriteInt8(packet, settings->mp_things_spawn_type); - } } boolean NET_ReadSettings(net_packet_t *packet, net_gamesettings_t *settings) @@ -131,9 +126,6 @@ boolean NET_ReadSettings(net_packet_t *packet, net_gamesettings_t *settings) } } - // [crispy] optional properties - NET_ReadInt8(packet, (unsigned int *) &settings->mp_things_spawn_type); - return true; } diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index 22b5c0bcb0..4822820d8d 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -35,8 +35,6 @@ #include "net_petname.h" -#include "doom/p_mobj.h" // [crispy] mp_things_spawn_type - #define MULTI_START_HELP_URL "https://www.chocolate-doom.org/setup-multi-start" #define MULTI_JOIN_HELP_URL "https://www.chocolate-doom.org/setup-multi-join" #define MULTI_CONFIG_HELP_URL "https://www.chocolate-doom.org/setup-multi-config" @@ -115,7 +113,7 @@ static const char *strife_skills[] = static const char *character_classes[] = { "Fighter", "Cleric", "Mage" }; -static const char *gamemodes[] = { "Co-operative", "Deathmatch", "Deathmatch 2.0", "Deathmatch 3.0" }; +static const char *gamemodes[] = { "Co-operative", "Deathmatch", "Deathmatch 2.0", "Deathmatch 3.0", "Coop 2" }; static const char *strife_gamemodes[] = { @@ -135,7 +133,6 @@ static int deathmatch = 0; static int strife_altdeath = 0; static int fast = 0; static int respawn = 0; -static int mp_things_spawn_type = 0; // [crispy] static int udpport = 2342; static int timer = 0; static int privateserver = 0; @@ -275,6 +272,10 @@ static void StartGame(int multiplayer) { AddCmdLineParameter(exec, "-dm3"); } + else if (deathmatch == 4) // [cripsy] Coop 2 + { + AddCmdLineParameter(exec, "-coop2"); + } if (timer > 0) { @@ -285,11 +286,6 @@ static void StartGame(int multiplayer) { AddCmdLineParameter(exec, "-privateserver"); } - - if (mp_things_spawn_type) // [crispy] - { - AddCmdLineParameter(exec, "-mpspawntype %i", mp_things_spawn_type); - } } AddWADs(exec); @@ -699,7 +695,7 @@ static txt_dropdown_list_t *GameTypeDropdown(void) { case doom: default: - return TXT_NewDropdownList(&deathmatch, gamemodes, 4); + return TXT_NewDropdownList(&deathmatch, gamemodes, NET_MODES_NUM); // Heretic and Hexen don't support Deathmatch II: @@ -716,25 +712,6 @@ static txt_dropdown_list_t *GameTypeDropdown(void) } } -static void MultiplayerFlags(void) // [crispy] -{ - txt_window_t *window; - - // Build the window - window = TXT_NewWindow("Multiplayer Flags"); - TXT_SetColumnWidths(window, 40); - TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP, TXT_SCREEN_W / 2, 3); - - TXT_AddWidgets(window, - TXT_NewSeparator("Multiplayer Things Spawn Type"), - TXT_NewRadioButton("All", &mp_things_spawn_type, MP_THINGS_SPAWN_ALL), - TXT_NewRadioButton("All except weapons", &mp_things_spawn_type, MP_THINGS_SPAWN_ALL_BUT_WEAPONS), - TXT_NewRadioButton("Only monsters", &mp_things_spawn_type, MP_THINGS_SPAWN_ONLY_MONSTERS), - TXT_NewRadioButton("None", &mp_things_spawn_type, MP_THINGS_SPAWN_NONE), - NULL - ); -} - // "Start game" menu. This is used for the start server window // and the single player warp menu. The parameters specify // the window title and whether to display multiplayer options. @@ -796,15 +773,6 @@ static void StartGameMenu(const char *window_title, int multiplayer) TXT_NewLabel("minutes"), NULL), NULL); - if (gamemission == doom) // [crispy] Multiplayer Flags - { - TXT_AddWidgets(window, - TXT_NewLabel("Flags"), - TXT_NewButton2("Set", - (TxtWidgetSignalFunc) MultiplayerFlags, NULL), - NULL - ); - } } TXT_AddWidgets(window, From 81276eb13286ce27f8e1fc26d5ff79ec0973c0e1 Mon Sep 17 00:00:00 2001 From: UnreallyHard Date: Sat, 16 Mar 2024 10:30:36 +0700 Subject: [PATCH 10/13] coop2 fixes --- src/doom/d_net.c | 3 ++- src/doom/p_mobj.c | 2 +- src/doom/p_mobj.h | 2 ++ src/net_structrw.c | 1 - 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/doom/d_net.c b/src/doom/d_net.c index 71d3dec359..13efa85036 100644 --- a/src/doom/d_net.c +++ b/src/doom/d_net.c @@ -57,7 +57,8 @@ static void PlayerQuitGame(player_t *player) playeringame[player_num] = false; players[consoleplayer].message = exitmsg; - + // [crispy] don't interpolate players who left the game + player->mo->interp = false; // TODO: check if it is sensible to do this: if (demorecording) diff --git a/src/doom/p_mobj.c b/src/doom/p_mobj.c index 717e02acc8..447b85d847 100644 --- a/src/doom/p_mobj.c +++ b/src/doom/p_mobj.c @@ -1006,7 +1006,7 @@ void P_SpawnMapThing (mapthing_t* mthing) // check for appropriate skill level if (!coop_spawns && !netgame && (mthing->options & 16) ) return; - + if (gameskill == sk_baby) bit = 1; else if (gameskill == sk_nightmare) diff --git a/src/doom/p_mobj.h b/src/doom/p_mobj.h index 2251689deb..57dd86ab30 100644 --- a/src/doom/p_mobj.h +++ b/src/doom/p_mobj.h @@ -299,4 +299,6 @@ typedef struct mobj_s } mobj_t; + + #endif diff --git a/src/net_structrw.c b/src/net_structrw.c index eac7c32ffd..2dbd2740a1 100644 --- a/src/net_structrw.c +++ b/src/net_structrw.c @@ -86,7 +86,6 @@ void NET_WriteSettings(net_packet_t *packet, net_gamesettings_t *settings) { NET_WriteInt8(packet, settings->player_classes[i]); } - } boolean NET_ReadSettings(net_packet_t *packet, net_gamesettings_t *settings) From f7ca547b3b1c527305d434132205673e702ec511 Mon Sep 17 00:00:00 2001 From: UnreallyHard Date: Sat, 16 Mar 2024 10:41:07 +0700 Subject: [PATCH 11/13] more style fixes --- src/doom/d_net.c | 7 ++++--- src/setup/multiplayer.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/doom/d_net.c b/src/doom/d_net.c index 13efa85036..84aa2abd47 100644 --- a/src/doom/d_net.c +++ b/src/doom/d_net.c @@ -59,6 +59,7 @@ static void PlayerQuitGame(player_t *player) players[consoleplayer].message = exitmsg; // [crispy] don't interpolate players who left the game player->mo->interp = false; + // TODO: check if it is sensible to do this: if (demorecording) @@ -118,7 +119,7 @@ static void LoadDeathmatchGameSettings(int deathmatch_setings) // // SaveDeathmatchGameSettings // [crispy] Saves correct deatmatch setting for a net game -// from global variables +// from global variables // static void SaveDeathmatchGameSettings(net_gamesettings_t *settings) { @@ -138,7 +139,7 @@ static void LoadGameSettings(net_gamesettings_t *settings) { unsigned int i; - LoadDeathmatchGameSettings(settings->deathmatch); + LoadDeathmatchGameSettings(settings->deathmatch); // [crispy] startepisode = settings->episode; startmap = settings->map; startskill = settings->skill; @@ -170,7 +171,7 @@ static void SaveGameSettings(net_gamesettings_t *settings) // Fill in game settings structure with appropriate parameters // for the new game - SaveDeathmatchGameSettings(settings); + SaveDeathmatchGameSettings(settings); // [crispy] settings->episode = startepisode; settings->map = startmap; settings->skill = startskill; diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index 4822820d8d..3e6e09fd65 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -272,7 +272,7 @@ static void StartGame(int multiplayer) { AddCmdLineParameter(exec, "-dm3"); } - else if (deathmatch == 4) // [cripsy] Coop 2 + else if (deathmatch == NET_COOP2) // [cripsy] Coop 2 { AddCmdLineParameter(exec, "-coop2"); } From c9b103548fe6a0129487d5d8d3bc381feefce76f Mon Sep 17 00:00:00 2001 From: UnreallyHard Date: Sun, 24 Mar 2024 15:56:26 +0700 Subject: [PATCH 12/13] removed netgame_modes_t enum --- src/d_mode.h | 10 ---------- src/doom/d_net.c | 6 +++--- src/doom/doomstat.h | 2 +- src/net_common.c | 2 +- src/setup/multiplayer.c | 4 ++-- 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/d_mode.h b/src/d_mode.h index ffc58d3ad5..f2f8058ec6 100644 --- a/src/d_mode.h +++ b/src/d_mode.h @@ -100,16 +100,6 @@ typedef enum sk_nightmare } skill_t; -typedef enum // [crispy] -{ - NET_COOPERATIVE, - NET_DEATHMATCH, - NET_ALTDEATH, - NET_DM3, - NET_COOP2, - - NET_MODES_NUM -} netgame_modes_t; boolean D_ValidGameMode(GameMission_t mission, GameMode_t mode); boolean D_ValidGameVersion(GameMission_t mission, GameVersion_t version); diff --git a/src/doom/d_net.c b/src/doom/d_net.c index 84aa2abd47..27c944ddd2 100644 --- a/src/doom/d_net.c +++ b/src/doom/d_net.c @@ -106,10 +106,10 @@ static loop_interface_t doom_loop_interface = { // static void LoadDeathmatchGameSettings(int deathmatch_setings) { - if (deathmatch_setings == NET_COOP2) + if (deathmatch_setings == 4) { coop2 = true; - deathmatch = NET_COOPERATIVE; + deathmatch = 0; return; } @@ -125,7 +125,7 @@ static void SaveDeathmatchGameSettings(net_gamesettings_t *settings) { if (coop2) { - settings->deathmatch = NET_COOP2; + settings->deathmatch = 4; return; } diff --git a/src/doom/doomstat.h b/src/doom/doomstat.h index fea7adfd82..09e5406b35 100644 --- a/src/doom/doomstat.h +++ b/src/doom/doomstat.h @@ -104,7 +104,7 @@ extern boolean respawnmonsters; // Netgame? Only true if >1 player. extern boolean netgame; -// 0=Cooperative; 1=Deathmatch; 2=Altdeath; 3=dm3; 4=coop2; +// 0=Cooperative; 1=Deathmatch; 2=Altdeath; extern int deathmatch; // ------------------------- diff --git a/src/net_common.c b/src/net_common.c index e73e27cb0b..1f47918798 100644 --- a/src/net_common.c +++ b/src/net_common.c @@ -439,7 +439,7 @@ boolean NET_ValidGameSettings(GameMode_t mode, GameMission_t mission, if (settings->extratics < 0) return false; - if (settings->deathmatch < 0 || settings->deathmatch > NET_MODES_NUM) + if (settings->deathmatch < 0 || settings->deathmatch > 4) return false; if (settings->skill < sk_noitems || settings->skill > sk_nightmare) diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index 3e6e09fd65..795595c5ff 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -272,7 +272,7 @@ static void StartGame(int multiplayer) { AddCmdLineParameter(exec, "-dm3"); } - else if (deathmatch == NET_COOP2) // [cripsy] Coop 2 + else if (deathmatch == 4) // [cripsy] Coop 2 { AddCmdLineParameter(exec, "-coop2"); } @@ -695,7 +695,7 @@ static txt_dropdown_list_t *GameTypeDropdown(void) { case doom: default: - return TXT_NewDropdownList(&deathmatch, gamemodes, NET_MODES_NUM); + return TXT_NewDropdownList(&deathmatch, gamemodes, 4); // Heretic and Hexen don't support Deathmatch II: From 313050baf881a6ad7d74f49b90163d3b96bffc0f Mon Sep 17 00:00:00 2001 From: UnreallyHard Date: Sun, 24 Mar 2024 15:59:18 +0700 Subject: [PATCH 13/13] style fix --- src/d_mode.h | 1 - src/doom/doomstat.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/d_mode.h b/src/d_mode.h index f2f8058ec6..424f8b672a 100644 --- a/src/d_mode.h +++ b/src/d_mode.h @@ -100,7 +100,6 @@ typedef enum sk_nightmare } skill_t; - boolean D_ValidGameMode(GameMission_t mission, GameMode_t mode); boolean D_ValidGameVersion(GameMission_t mission, GameVersion_t version); boolean D_ValidEpisodeMap(GameMission_t mission, GameMode_t mode, diff --git a/src/doom/doomstat.h b/src/doom/doomstat.h index 09e5406b35..ca91036f25 100644 --- a/src/doom/doomstat.h +++ b/src/doom/doomstat.h @@ -104,7 +104,7 @@ extern boolean respawnmonsters; // Netgame? Only true if >1 player. extern boolean netgame; -// 0=Cooperative; 1=Deathmatch; 2=Altdeath; +// 0=Cooperative; 1=Deathmatch; 2=Altdeath extern int deathmatch; // -------------------------