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

feature: command to disable checking for cheat cmds when viewing the demo #473

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SmileyAG
Copy link
Collaborator

@SmileyAG SmileyAG commented Nov 30, 2023

No description provided.

@YaLTeR
Copy link
Owner

YaLTeR commented Nov 30, 2023

So what does this do exactly?

@SmileyAG
Copy link
Collaborator Author

SmileyAG commented Nov 30, 2023

So what does this do exactly?

When playbacking demos that recorded in multiplayer, protected cvars would give the Can't set %s in multiplayer console message
To fix that, we have to fake our cls.state to pass through the Cvar_Command function and after we can restore it to original state

          if ((((*(byte *)&pcVar4->flags & 0x40) != 0) && (ca_disconnected < cls.state)) &&
             (1 < cl.maxclients)) {
            Con_Printf("Can\'t set %s in multiplayer\n",pcVar4->name);
            return 1;
          }

And, there is R_ForceCvars function which calling only if 1 < cl.maxclients and that forcing values to default for specific list of cvars:

r_lightmap
gl_clear
r_novis
r_fullbright
snd_show
chase_active
lambert
gl_monolights
gl_wireframe
r_dynamic
gl_alphamin
gl_max_size
gl_polyoffset
r_drawentities
lightgamma

To fix that, simply don't call that function, but it contains also the updating of changed gl_monolights in real-time, so you have to call GL_BuildLightmaps function for that reason

@SmileyAG SmileyAG force-pushed the 2023_cheat_cmds_in_mp_demo branch from eeba4c9 to eba65c6 Compare December 2, 2023 02:00
{
state = reinterpret_cast<int*>(cls);
orig_state = *state;
*state = 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cls.state is kind of an important variable. If you set it to 1, do commands like disconnect, changelevel, etc. still work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair point. It would be more rationally to replace it with set cl.maxclients to 1 instead.

I just didn’t want to make offsets for find that new variable through other functions before, but now I looked at the Cvar_Command code in more detail, and it actually calls a function for which the cls.state values will affect its code (Cvar_DirectSet)

In the case of cl.maxplayers I can't tell at first glance, but even if it may turn out to be the case later, it will be less harmful than changing cls.state

@SmileyAG SmileyAG marked this pull request as draft March 3, 2024 01:49
@SmileyAG SmileyAG changed the title Added bxt_disable_cheats_check_in_demo feature: command to disable checking for cheat cmds when viewing the demo Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants