Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Ironwail's nomonsters cvar #110

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Quake/host_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif

extern cvar_t pausable;
extern cvar_t nomonsters;

int current_skill;

Expand Down Expand Up @@ -1043,6 +1044,12 @@ static void Host_Savegame_f (void)
return;
}

if (sv.nomonsters)
{
Con_Printf ("Can't save when using \"nomonsters\".\n");
return;
}

if (cl.intermission)
{
Con_Printf ("Can't save in intermission.\n");
Expand Down Expand Up @@ -1149,6 +1156,12 @@ static void Host_Loadgame_f (void)
return;
}

if (nomonsters.value)
{
Con_Warning ("\"%s\" disabled automatically.\n", nomonsters.name);
Cvar_SetValueQuick (&nomonsters, 0.f);
}

cls.demonum = -1; // stop demo loop in case this fails

q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1));
Expand Down
23 changes: 22 additions & 1 deletion Quake/pr_edict.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ to call ED_CallSpawnFunctions () to let the objects initialize themselves.
*/
void ED_LoadFromFile (const char *data)
{
const char *classname;
dfunction_t *func;
edict_t *ent = NULL;
int inhibit = 0;
Expand Down Expand Up @@ -1045,8 +1046,16 @@ void ED_LoadFromFile (const char *data)
continue;
}

classname = PR_GetString (ent->v.classname);
if (sv.nomonsters && !Q_strncmp (classname, "monster_", 8))
{
ED_Free (ent);
inhibit++;
continue;
}

// look for the spawn function
func = ED_FindFunction ( PR_GetString(ent->v.classname) );
func = ED_FindFunction (classname);

if (!func)
{
Expand Down Expand Up @@ -1262,6 +1271,17 @@ void PR_LoadProgs (void)
pr_effects_mask = PR_FindSupportedEffects ();
}

/*
===============
ED_Nomonsters_f
===============
*/
static void ED_Nomonsters_f (cvar_t *cvar)
{
if (cvar->value)
Con_Warning ("\"%s\" can break gameplay.\n", cvar->name);
}


/*
===============
Expand All @@ -1275,6 +1295,7 @@ void PR_Init (void)
Cmd_AddCommand ("edictcount", ED_Count);
Cmd_AddCommand ("profile", PR_Profile_f);
Cvar_RegisterVariable (&nomonsters);
Cvar_SetCallback (&nomonsters, ED_Nomonsters_f);
Cvar_RegisterVariable (&gamecfg);
Cvar_RegisterVariable (&scratch1);
Cvar_RegisterVariable (&scratch2);
Expand Down
1 change: 1 addition & 0 deletions Quake/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef struct

qboolean paused;
qboolean loadgame; // handle connections specially
qboolean nomonsters; // server started with 'nomonsters' cvar active

double time;

Expand Down
3 changes: 3 additions & 0 deletions Quake/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ int sv_protocol = PROTOCOL_FITZQUAKE; //johnfitz
extern qboolean pr_alpha_supported; //johnfitz
extern int pr_effects_mask;

extern cvar_t nomonsters;

//============================================================================

/*
Expand Down Expand Up @@ -1537,6 +1539,7 @@ void SV_SpawnServer (const char *server)

sv.state = ss_loading;
sv.paused = false;
sv.nomonsters = (nomonsters.value != 0.f);

sv.time = 1.0;

Expand Down