Cover
Cover

Reputation: 73

Will JIT protect my dicenumber variable from being manipulated?

I am making a basic game similar to a game called "Monopoly". You have to roll the dice and move the number of places the dice has rolled (1-6).

A code example would be something like this:

public function RollDice() : int
{
    return randRange(1, 6);
}

private function randRange(param1:int, param2:int) : int
{
    return Math.floor(Math.random() * (param2 - param1 + 1)) + param1;
}

But I'm worried if this code is safe enough against some possible manipulation (For example using Cheat Engine to change the number rolled). I've actually tried to "hack" my game, but only succeeded in changing the numbers of the randRange function, so I can make the dice roll, say, a particular number or a shorter range of numbers. But I could only do this before playing (pressing start button in my game). When I tried to change the values again, nothing has changed (well, i'm not much of a hacker...).

I did a little research and found out that Actionscript Virtual Machine's JIT Compiler could be the culprit of my failure as it compiles my game (the SWF) into machine code that's run on the CPU. And from what I know, the JIT compiler doesn't compile a function until it's first run, but once it's compiled, the SWF bytecode for that function never gets accessed again.

The question now is this: is there a way to change the number of the rolled dice after calling the function using programs such as Cheat Engine?

Upvotes: 0

Views: 89

Answers (1)

Senekis
Senekis

Reputation: 111

The question now is this: is there a way to change the number of the rolled dice after calling the function using programs such as Cheat Engine?

Yes. As a rule: if it's clientside, you can access it, and thus, manipulate it.

If you're really concerned about people cheating, all you can do is to try to make it harder for them, but it will always be possible to cheat.

If you really want to avoid it, then make it serverside.

Upvotes: 0

Related Questions