From 8f686a5e021dcd46da4272b8912000baf8150173 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 28 Dec 2008 09:49:15 +0000 Subject: [PATCH] - Added Karate Chris's new DMFlags submission. SVN r1333 (trunk) --- docs/rh-log.txt | 3 ++ src/am_map.cpp | 8 ++++++ src/c_cmds.cpp | 3 +- src/d_main.cpp | 65 +++++++++++++++++++++++++++++++++++++++++-- src/d_netinfo.cpp | 22 ++++++++++++--- src/d_player.h | 1 + src/doomdef.h | 11 ++++++-- src/g_game.cpp | 4 +++ src/m_options.cpp | 8 ++++++ src/p_interaction.cpp | 4 +++ src/p_spec.cpp | 4 +++ 11 files changed, 123 insertions(+), 10 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 696c694efb..02a4ff0e5c 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,6 @@ +December 28, 2008 (Changes by Graf Zahl) +- Added Karate Chris's new DMFlags submission. + December 27, 2008 (Changes by Graf Zahl) - Fixed: The correct player class was not remembered when the menu had both a player class selection menu and an episode menu. diff --git a/src/am_map.cpp b/src/am_map.cpp index 29f42b006b..36c10d638b 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -863,6 +863,10 @@ void AM_ToggleMap () if (gamestate != GS_LEVEL) return; + // Don't activate the automap if we're not allowed to use it. + if (dmflags2 & DF2_NO_AUTOMAP) + return; + SB_state = screen->GetPageCount (); if (!automapactive) { @@ -1572,6 +1576,10 @@ void AM_drawPlayers () { continue; } + + // We don't always want to show allies on the automap. + if (dmflags2 & DF2_NO_AUTOMAP_ALLIES && i != consoleplayer) + continue; if (deathmatch && !demoplayback && !p->mo->IsTeammate (players[consoleplayer].mo) && diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index ca208e475a..e4197ce2d9 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -232,7 +232,8 @@ CCMD (chase) } else { - if (gamestate == GS_LEVEL && deathmatch && CheckCheatmode ()) + // Check if we're allowed to use chasecam. + if (gamestate != GS_LEVEL || (!(dmflags2 & DF2_CHASECAM) && CheckCheatmode ())) return; Net_WriteByte (DEM_GENERICCHEAT); diff --git a/src/d_main.cpp b/src/d_main.cpp index 2418e47e09..5cf9692d53 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -99,6 +99,7 @@ #include "d_event.h" #include "d_netinf.h" #include "v_palette.h" +#include "m_cheat.h" EXTERN_CVAR(Bool, hud_althud) void DrawHUD(); @@ -114,6 +115,7 @@ extern void M_SetDefaultMode (); extern void R_ExecuteSetViewSize (); extern void G_NewInit (); extern void SetupPlayerClasses (); +extern bool CheckCheatmode (); // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- @@ -139,6 +141,7 @@ EXTERN_CVAR (Float, m_yaw) EXTERN_CVAR (Bool, invertmouse) EXTERN_CVAR (Bool, lookstrafe) EXTERN_CVAR (Int, screenblocks) +EXTERN_CVAR (Bool, sv_cheats) extern gameinfo_t SharewareGameInfo; extern gameinfo_t RegisteredGameInfo; @@ -440,7 +443,58 @@ CVAR (Flag, sv_allowcrouch, dmflags, DF_YES_CROUCH); // //========================================================================== -CVAR (Int, dmflags2, 0, CVAR_SERVERINFO); +CUSTOM_CVAR (Int, dmflags2, 0, CVAR_SERVERINFO) +{ + // Stop the automap if we aren't allowed to use it. + if ((self & DF2_NO_AUTOMAP) && automapactive) + AM_Stop (); + + for (int i = 0; i < MAXPLAYERS; i++) + { + player_t *p = &players[i]; + + if (!playeringame[i]) + continue; + + // Revert our view to our own eyes if spying someone else. + if (self & DF2_DISALLOW_SPYING) + { + // The player isn't looking through its own eyes, so make it. + if (p->camera != p->mo) + { + p->camera = p->mo; + + S_UpdateSounds (p->camera); + StatusBar->AttachToPlayer (p); + + if (demoplayback || multiplayer) + StatusBar->ShowPlayerName (); + } + } + + // Come out of chasecam mode if we're not allowed to use chasecam. + if (!(dmflags2 & DF2_CHASECAM) && !G_SkillProperty (SKILLP_DisableCheats) && !sv_cheats) + { + // Take us out of chasecam mode only. + if (p->cheats & CF_CHASECAM) + cht_DoCheat (p, CHT_CHASECAM); + } + + // Change our autoaim settings if need be. + if (dmflags2 & DF2_NOAUTOAIM) + { + // Save our aimdist and set aimdist to 0. + p->userinfo.savedaimdist = p->userinfo.aimdist; + p->userinfo.aimdist = 0; + } + else + { + // Restore our aimdist. + p->userinfo.aimdist = p->userinfo.savedaimdist; + } + } +} + CVAR (Flag, sv_weapondrop, dmflags2, DF2_YES_WEAPONDROP); CVAR (Flag, sv_noteamswitch, dmflags2, DF2_NO_TEAM_SWITCH); CVAR (Flag, sv_doubleammo, dmflags2, DF2_YES_DOUBLEAMMO); @@ -452,7 +506,14 @@ CVAR (Flag, sv_norespawn, dmflags2, DF2_NO_RESPAWN); CVAR (Flag, sv_losefrag, dmflags2, DF2_YES_LOSEFRAG); CVAR (Flag, sv_respawnprotect, dmflags2, DF2_YES_RESPAWN_INVUL); CVAR (Flag, sv_samespawnspot, dmflags2, DF2_SAME_SPAWN_SPOT); -CVAR (Flag, sv_infiniteinventory, dmflags2, DF2_INFINITE_INVENTORY) +CVAR (Flag, sv_infiniteinventory, dmflags2, DF2_INFINITE_INVENTORY); +CVAR (Flag, sv_killallmonsters, dmflags2, DF2_KILL_MONSTERS); +CVAR (Flag, sv_noautomap, dmflags2, DF2_NO_AUTOMAP); +CVAR (Flag, sv_noautomapallies, dmflags2, DF2_NO_AUTOMAP_ALLIES); +CVAR (Flag, sv_disallowspying, dmflags2, DF2_DISALLOW_SPYING); +CVAR (Flag, sv_chasecam, dmflags2, DF2_CHASECAM); +CVAR (Flag, sv_disallowsuicide, dmflags2, DF2_NOSUICIDE); +CVAR (Flag, sv_noautoaim, dmflags2, DF2_NOAUTOAIM); //========================================================================== // diff --git a/src/d_netinfo.cpp b/src/d_netinfo.cpp index 6f22a2716b..6f5b331c39 100644 --- a/src/d_netinfo.cpp +++ b/src/d_netinfo.cpp @@ -370,11 +370,17 @@ void D_SetupUserInfo () } if (autoaim > 35.f || autoaim < 0.f) { - coninfo->aimdist = ANGLE_1*35; + if (dmflags & DF2_NOAUTOAIM) + coninfo->savedaimdist = ANGLE_1*35; + else + coninfo->aimdist = ANGLE_1*35; } else { - coninfo->aimdist = abs ((int)(autoaim * (float)ANGLE_1)); + if (dmflags & DF2_NOAUTOAIM) + coninfo->savedaimdist = abs ((int)(autoaim * (float)ANGLE_1)); + else + coninfo->aimdist = abs ((int)(autoaim * (float)ANGLE_1)); } coninfo->color = color; coninfo->skin = R_FindSkin (skin, 0); @@ -684,11 +690,17 @@ void D_ReadUserInfoStrings (int i, BYTE **stream, bool update) angles = atof (value); if (angles > 35.f || angles < 0.f) { - info->aimdist = ANGLE_1*35; + if (dmflags & DF2_NOAUTOAIM) + info->savedaimdist = ANGLE_1*35; + else + info->aimdist = ANGLE_1*35; } else { - info->aimdist = abs ((int)(angles * (float)ANGLE_1)); + if (dmflags & DF2_NOAUTOAIM) + info->savedaimdist = abs ((int)(angles * (float)ANGLE_1)); + else + info->aimdist = abs ((int)(angles * (float)ANGLE_1)); } } break; @@ -804,6 +816,8 @@ FArchive &operator<< (FArchive &arc, userinfo_t &info) arc.Read (&info.netname, sizeof(info.netname)); } arc << info.team << info.aimdist << info.color << info.skin << info.gender << info.neverswitch; + if (SaveVersion >= 1333) arc << info.savedaimdist; + else info.savedaimdist = info.aimdist; return arc; } diff --git a/src/d_player.h b/src/d_player.h index c277311c2d..e58eb9f3f4 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -195,6 +195,7 @@ struct userinfo_t { char netname[MAXPLAYERNAME+1]; BYTE team; + int savedaimdist; int aimdist; int color; int skin; diff --git a/src/doomdef.h b/src/doomdef.h index 0363519313..addad750a7 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -243,12 +243,17 @@ enum DF2_YES_RESPAWN_INVUL = 1 << 10, // Player is temporarily invulnerable when respawned // DF2_COOP_SHOTGUNSTART = 1 << 11, // All playres start with a shotgun when they respawn DF2_SAME_SPAWN_SPOT = 1 << 12, // Players respawn in the same place they died (co-op) - DF2_YES_KEEPFRAGS = 1 << 13, // Don't clear frags after each level DF2_NO_RESPAWN = 1 << 14, // Player cannot respawn - DF2_YES_LOSEFRAG = 1 << 15, // Lose a frag when killed. More incentive to try to -// // not get yerself killed + DF2_YES_LOSEFRAG = 1 << 15, // Lose a frag when killed. More incentive to try to not get yerself killed DF2_INFINITE_INVENTORY = 1 << 16, // Infinite inventory. + DF2_KILL_MONSTERS = 1 << 17, // All monsters must be killed before the level exits. + DF2_NO_AUTOMAP = 1 << 18, // Players are allowed to see the automap. + DF2_NO_AUTOMAP_ALLIES = 1 << 19, // Allies can been seen on the automap. + DF2_DISALLOW_SPYING = 1 << 20, // You can spy on your allies. + DF2_CHASECAM = 1 << 21, // Players can use the chasecam cheat. + DF2_NOSUICIDE = 1 << 22, // Players are allowed to suicide. + DF2_NOAUTOAIM = 1 << 23, // Players cannot use autoaim. }; // [RH] Compatibility flags. diff --git a/src/g_game.cpp b/src/g_game.cpp index 494a2fd202..7ca1b2420e 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -724,6 +724,10 @@ static void ChangeSpy (bool forward) return; } + // We may not be allowed to spy on anyone. + if (dmflags2 & DF2_DISALLOW_SPYING) + return; + // Otherwise, cycle to the next player. bool checkTeam = !demoplayback && deathmatch; int pnum = players[consoleplayer].camera->player - players; diff --git a/src/m_options.cpp b/src/m_options.cpp index 404dc9543b..7493a5517c 100644 --- a/src/m_options.cpp +++ b/src/m_options.cpp @@ -1028,17 +1028,25 @@ static menuitem_t DMFlagsItems[] = { { bitflag, "Infinite ammo", {&dmflags}, {0}, {0}, {0}, {(value_t *)DF_INFINITE_AMMO} }, { bitflag, "Infinite inventory", {&dmflags2}, {0}, {0}, {0}, {(value_t *)DF2_INFINITE_INVENTORY} }, { bitflag, "No monsters", {&dmflags}, {0}, {0}, {0}, {(value_t *)DF_NO_MONSTERS} }, + { bitflag, "No monsters to exit", {&dmflags2}, {0}, {0}, {0}, {(value_t *)DF2_KILL_MONSTERS} }, { bitflag, "Monsters respawn", {&dmflags}, {0}, {0}, {0}, {(value_t *)DF_MONSTERS_RESPAWN} }, { bitflag, "No respawn", {&dmflags2}, {0}, {0}, {0}, {(value_t *)DF2_NO_RESPAWN} }, { bitflag, "Items respawn", {&dmflags}, {0}, {0}, {0}, {(value_t *)DF_ITEMS_RESPAWN} }, { bitflag, "Big powerups respawn", {&dmflags}, {0}, {0}, {0}, {(value_t *)DF_RESPAWN_SUPER} }, { bitflag, "Fast monsters", {&dmflags}, {0}, {0}, {0}, {(value_t *)DF_FAST_MONSTERS} }, { bitflag, "Degeneration", {&dmflags2}, {0}, {0}, {0}, {(value_t *)DF2_YES_DEGENERATION} }, + { bitflag, "Allow Autoaim", {&dmflags2}, {1}, {0}, {0}, {(value_t *)DF2_NOAUTOAIM} }, + { bitflag, "Disallow Suicide", {&dmflags2}, {1}, {0}, {0}, {(value_t *)DF2_NOSUICIDE} }, { bitmask, "Allow jump", {&dmflags}, {3.0}, {DF_NO_JUMP|DF_YES_JUMP}, {0}, {DF_Jump} }, { bitmask, "Allow crouch", {&dmflags}, {3.0}, {DF_NO_CROUCH|DF_YES_CROUCH}, {0}, {DF_Crouch} }, { bitflag, "Allow freelook", {&dmflags}, {1}, {0}, {0}, {(value_t *)DF_NO_FREELOOK} }, { bitflag, "Allow FOV", {&dmflags}, {1}, {0}, {0}, {(value_t *)DF_NO_FOV} }, { bitflag, "Allow BFG aiming", {&dmflags2}, {1}, {0}, {0}, {(value_t *)DF2_NO_FREEAIMBFG} }, + { bitflag, "Allow automap", {&dmflags2}, {1}, {0}, {0}, {(value_t *)DF2_NO_AUTOMAP} }, + { bitflag, "Automap allies", {&dmflags2}, {1}, {0}, {0}, {(value_t *)DF2_NO_AUTOMAP_ALLIES} }, + { bitflag, "Allow spying", {&dmflags2}, {1}, {0}, {0}, {(value_t *)DF2_DISALLOW_SPYING} }, + { bitflag, "Chasecam cheat", {&dmflags2}, {0}, {0}, {0}, {(value_t *)DF2_CHASECAM} }, + { redtext, " ", {NULL}, {0}, {0}, {0}, {NULL} }, { whitetext,"Deathmatch Settings", {NULL}, {0}, {0}, {0}, {NULL} }, { bitflag, "Weapons stay", {&dmflags}, {0}, {0}, {0}, {(value_t *)DF_WEAPONS_STAY} }, diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 6d3767ce3e..5f594870d7 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1451,6 +1451,10 @@ CCMD (kill) } else { + // If suiciding is disabled, then don't do it. + if (dmflags2 & DF2_NOSUICIDE) + return; + // Kill the player Net_WriteByte (DEM_SUICIDE); } diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 252d4aae25..175c4e2141 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -135,6 +135,10 @@ bool CheckIfExitIsGood (AActor *self, level_info_t *info) if (self == NULL) return true; + // We must kill all monsters to exit the level. + if ((dmflags2 & DF2_KILL_MONSTERS) && level.killed_monsters != level.total_monsters) + return false; + // Is this a deathmatch game and we're not allowed to exit? if ((deathmatch || alwaysapplydmflags) && (dmflags & DF_NO_EXIT)) {