7

In the iphone game "Tiny Tower", I'm guessing it uses some kind of simulation based on the time spent between the last play and the current time, because you can set the current time forward and you will get the benefit from the fake elapsed time span.

Is there an algorithm that I can use to prevent this sort of thing? (Or at least make it difficult enough for the average user to pull off!)

Edit: thanks, I understand that, despite my wording, there's no way to prevent things you store on the client side, but I want to make it at least more difficult than "changing the time" to hack it!

Timmy
  • 12,468
  • 20
  • 77
  • 107
  • 3
    Any time correctness relies on a variable the user can change, there is potential for corruption. – corsiKa Jan 18 '12 at 22:46
  • Ya, I don't know the literature as to if there are at least ways to make things harder.. – Timmy Jan 18 '12 at 22:51

4 Answers4

4

The gamecube had a way to do this so it must be possible.

Is there an event triggered when the iphone time is set ? In that case you can react that.

Another solution is to require to be online when the game is launched, this way you can check time on a remote server.

You could has well check if you got an event on the phone login or wake up react to it, saving the time at that moment in your DB. You would have the last non modified time.

A last possible trick is to check for a file you know is going to be modified by an action prior to time change (such as login), and check the 'last modification' date.

You can investigate in the GPS direction as well. A GPS need to be synchronised with the satellite it contact, so it must keep track of time in some way, and maybe there is an API for that.

Unfortunatly you are on an iphone, which mean your possibilities are limited since applications got very few rights and are sandboxed.

EDIT:

Just though about it but, can you create event in the iphone calendar ? And check if it has been trigered ? Cause you could set a fake meeting or something for every day. Not clean, but creative.

EDIT 2: can you set a timer as a code for IOS to execute in 60 minutes ? If you can, set this timer, pass the time expected to be when this code run, then when the code run, compare and inform your program.

Bite code
  • 578,959
  • 113
  • 301
  • 329
2

One way to prevent it is to monitor time passing by checking timestamps for their logins in a database. It doesn't matter if the client's iPhone's time is off; the database on your end will still know how long it's been since the last login.

Almo
  • 15,538
  • 13
  • 67
  • 95
1

call a web service to get the time, rather than rely on the phone. There are several places you could get time from, google is your friend i'm sure, or create one yourself, and use the local time of the machine the service runs on for the time.

You could also use the Network Time Protocol (NTP) servers to get a consistent time

Sam Holder
  • 32,535
  • 13
  • 101
  • 181
1

I think if you have internet access you can take the time from a server.

A second solution : You can record the "datetime" and every time you see a "BIG" difference between the record datetime and the running datetime you know there might be a problem. but this is not elegant, i know.

You can also record a small ammount of datetimes that the application started and check the diffrence with the running datetime.

Also you can use "Activity"->"Datetime" so the "Updates" (levels etc) can't be retaken.

Because the system Datetime can be changed by user, there is potential for "hack".

Sanosay
  • 536
  • 5
  • 18
  • Ya, I'm not too worried about the game being hacked per se.. motivated users will do that.. just want to make it at least hard enough for most casual users! – Timmy Jan 18 '12 at 23:03
  • Hard enough for most casual users? By using the above method i think it is hard enough. (Second solution) – Sanosay Jan 18 '12 at 23:05