## 1. Description of cheating methods

Some games make the player wait for a certain amount of time in certain situations, such as Candy Crush, where the game loses a little energy and loses a little energy every 30 minutes. When you run out of stamina, you can no longer play. At this point, you can change the system time, set it to a future time, and then return to the game, and your stamina will be full. This control of the game is broken. How it works: The game will record a moment T1 when the current moment is T1 +30 minutes. If you set the system time to half an hour later, there is no need to wait for direct recovery. #####1. Calculate startup time by startup running time ios and Android both provide a method: obtain the running time from startup to now. This is the way to do time check. By taking the current time (which is subject to modification) and the boot running time, you can calculate the boot time (the former minus the latter), which should be constant if the boot state is always maintained. If one startup time is calculated differently than the last one, you can tell that the timer is wrong. #####2. Record startup time When the game is run for the first time, the startup time will be recorded for comparison of subsequent calculations. #####3. Networking time correction When the user’s time is abnormal, for example, the time of starting up is calculated to be different from the last time, and the networking time needs to be corrected. Obtain the correct current time from the network, compare the user time (which may be modified), calculate the time difference of 1 hour, and record the time difference. After that, the time difference should be subtracted every time the user’s current time is obtained. The result can be regarded as the correct system time, and then the boot time can be calculated according to the method of 1. After time correction, the last boot time will be reset as a new reference value. When entering the game, get the current system time 8 o ‘clock, get 3 hours boot operation, calculate the boot time is 5 o ‘clock. A 30-minute timer was triggered at 9 o ‘clock and should have been completed by 9:30. At this time, the user cuts to the Settings and changes the system time to 10:00. After returning to the game, the timer will be checked. The system time is 10 o ‘clock, and the system starts to run for 4 hours. The startup time is calculated to be 6 o ‘clock, which is different from the 5 o ‘clock recorded before, and the timer is wrong. If the user does not perform network calibration, the operation cannot continue. After the user is connected to the Internet, the real time of the network is 9 o ‘clock, and the time difference of the user is calculated to be 1 hour (10-9). Then the time of the last startup is reset, and 5 o ‘clock is still unchanged (this value will change if the user is turned off and turned on again). After calibration, let the timer continue, take the user time will subtract the time difference, that is, the real time can be obtained, then the timer can run normally. If the user stays connected, the timer error is corrected instantly. For users who do not cheat, if they turn it on again and there is no Internet connection, they will judge that the timer is wrong and cannot continue to operate. Network calibration is required. Get the boot time

 NSProcessInfo *info = [NSProcessInfo processInfo];
    
    NSLog(@"%f", info.systemUptime);
    
    NSDate *now = [NSDate date];
    
    NSTimeInterval interval = [now timeIntervalSince1970];
    
    NSLog(@"start time: %@", [AppDelegate getDateStrFromTimeStep:interval - info.systemUptime]);
Copy the code
+(NSString *)getDateStrFromTimeStep:(long long)timestep{
    
    NSDate *timestepDate = [NSDate dateWithTimeIntervalSince1970:timestep];

    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];

    NSTimeZone* timeZone = [NSTimeZone systemTimeZone];
    
    [formatter setTimeZone:timeZone];

    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

    return [formatter stringFromDate:timestepDate];
}
Copy the code