Page 1 of 1

Detect if cheats are on

Posted: 17 Jun 2014, 11:34
by Jools
I want to make my games detect if cheatmode has been enabled, and in case it is maybe not send any replays to the spring replays site. Is this possible?

I know there's one Spring.IsCheatingEnabled function in synced read, but there must be a better way than to process that in each gameframe. Is there a specific callin that can be used to catch that cheating has been enabled?

Or is spads aware if this somehow?

Re: Detect if cheats are on

Posted: 17 Jun 2014, 11:39
by gajop
Don't think there is a callin. If you really want you could make your own in your widgethandler.
Don't know anything about spads.

Re: Detect if cheats are on

Posted: 17 Jun 2014, 12:18
by Silentwings
Just check Spring.IsCheatingEnabled when you need to know it? (In your case, at game over)

Re: Detect if cheats are on

Posted: 17 Jun 2014, 12:38
by Jools
What if someone enables cheats, gives 100 krogs and then disables cheats and continues to play?

Re: Detect if cheats are on

Posted: 17 Jun 2014, 12:46
by gajop
I don't see why you can't just do:

Code: Select all

local cheatingWasEnabled = false
function gadget:GameFrame()
    cheatingWasEnabled = cheatingWasEnabled or Spring.IsCheatingEnabled()
end
And then use it when you need to?
Stop premature optimization.

Re: Detect if cheats are on

Posted: 17 Jun 2014, 13:19
by Google_Frog
What if they cheat only while the game is paused? Then a game frame check would not detect cheats.

Re: Detect if cheats are on

Posted: 17 Jun 2014, 13:41
by Jools
I thought of checking if cheats are enabled after each time you press return. Is it possible to enable cheats without return? Maybe with new uikeys.txt it is with a keystroke.

Re: Detect if cheats are on

Posted: 17 Jun 2014, 14:16
by Silentwings
You can send a /cheat from lua, of course whether it works depends on if you have permission to enable cheats.

Re: Detect if cheats are on

Posted: 17 Jun 2014, 14:39
by Jools
So the most fool-proof way would be to check this in gadget:Update(), then send to synced via LuaRulesMsg?

Re: Detect if cheats are on

Posted: 17 Jun 2014, 14:44
by gajop
Hm, didn't know you could do that when paused, i thought all commands would happen in the next frame, but guess not.
I'm not sure there is a safe way to do that then, the player could always do /cheat /give all /cheat in sequence by using one widget.

Re: Detect if cheats are on

Posted: 17 Jun 2014, 17:14
by jK
Jools wrote:I know there's one Spring.IsCheatingEnabled function in synced read, but there must be a better way than to process that in each gameframe. Is there a specific callin that can be used to catch that cheating has been enabled?
Why check them in a fixed interval at all? You should ALWAYS check when you DO something.

Re: Detect if cheats are on

Posted: 17 Jun 2014, 17:24
by Jools
But in this case, the action is done after the game (upload replay, declare winner etc) and it is affected by what is done during the game. As others pointed out.

Re: Detect if cheats are on

Posted: 18 Jun 2014, 07:05
by CarRepairer
This sounds like a valid feature request. Perhaps if nothing comes of it, you can solve it on the autohost layer by disallowing cheating unless the user enables an option. If the option is enabled, the replay is not uploaded. It's not a perfect solution, but probably less stressful than dealing with polling spring in the gadget level.

Re: Detect if cheats are on

Posted: 18 Jun 2014, 13:06
by jK
In that case I would say catch the `/cheat` chat command. Problem is that, in contrast to mouse & key handling, Lua is not the first one who receives those. So make a feature request to make its handling consistent to the others.

Re: Detect if cheats are on

Posted: 23 Jun 2014, 16:05
by bibim
Jools wrote:Or is spads aware if this somehow?
SPADS isn't directly aware of the cheat mode. But if you consider that the !cheat command is always used to enable cheats, then it can easily be made aware of it using a plugin. This is done in SPADS ZeroK plugin for example to prevent reporting games where cheats have been enabled:

Code: Select all

sub new {
  my $class=shift;
  my $self = { isCheating => 0,
  [...]
}

sub onSpringStart {
  my $self=shift;
  $self->{isCheating}=0;
  [...]
}

sub postSpadsCommand {
  my ($self,$command,undef,undef,undef,$commandResult)=@_;
  $self->{isCheating}=1 if($command eq 'cheat' && (! defined $commandResult || $commandResult ne '0'));
}

There exist cases where cheats can be enabled without using the !cheat command (using "!send /cheat ..." or through a plugin for example), but they are negligible in my opinion since they require special access to the autohost.