如何防止基于Cocos2dx的离线游戏的时间作弊? [英] How to prevent time-cheating on offline game based on Cocos2dx?

查看:189
本文介绍了如何防止基于Cocos2dx的离线游戏的时间作弊?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我正在开发基于Cocos2dx-lua的移动离线游戏.

Recently I'm working on a mobile offline game based on Cocos2dx-lua.

我在Google Play上找到了一个名为GameGuardian的应用,该应用可以设置时间速度.该应用程序可能会修改libc.so中的方法gettimeofday().我已经尝试了许多API,例如os.time()SystemClock.elapsedRealtime(),但是都失败了.

I found an app on Google Play called GameGuardian which can set the time speed. The app maybe modify the method gettimeofday() in libc.so. I've tried many APIs such as os.time(), SystemClock.elapsedRealtime(), but all failed.

有人可以给我一种避免应用程序影响的方法吗?

Could somebody please give me a way to avoid the effect of the app?

推荐答案

唯一确定的方法是使您的应用与游戏服务器联系以确保时间.许多android游戏都在这样做. 战斗猫"就是一个例子.
说,您可以在应用启动后立即检查时间有效性,如果没有可用的连接,则可以允许在一定的允许时间内生成资源.例如,自上次确认时间以来,不超过1小时的时间.

The only sure method is to make your app contact your game's server to ensure time. Many android games is doing that. "The Battle Cats" is one example.
Say, you can check time validity as soon as app starts, and if no connection available, you can allow resources generated for some allowed time. Not more than 1 hour worth since last confirmed time, for example.

其他想法可能是检查当前fps.硬件无法加速,因此启用VSync时,帧渲染的时间大致相同.如果您发现渲染单帧所花费的时间大大超过了原本应花费的时间,并且如果它发生在许多帧上,则可能表明存在作弊的可能性.但这不是一个稳定的解决方案,因为您必须确保fps通常不会在较弱的设备上下降,并且也不会告诉您游戏不运行所花费的时间.

Other idea might be checking current fps. Hardware can't speed up, so frame will be rendered in roughly same time when VSync enabled. If you find that rendering single frame takes significantly more time than it should be, and if it happens for many frames, then it might indicate cheating possibility. But this is not stable solution, since you'll have to be sure your fps normally doesn't drop on weak devices, and it doesn't tell you anything about time spent while game wasn't running.

如果您发现自上次保存未确认时间以来的时间跳回了大约1小时以上(以防用户调整DST等),则极端情况可能包括完整擦除应用程序的状态.

Extreme case might include complete erasing app's state if you find time jumped back since last saved unconfirmed time for more than ~1 hour (in case user adjust DST, etc).

但是通常您不能保护完全离线的游戏不受时间操纵.

But generally you can't protect completely offline game from time manipulations.

这篇关于如何防止基于Cocos2dx的离线游戏的时间作弊?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆