Jump to content

  • Log In with Google      Sign In   
  • Create Account


Dealing with latency in Farmville-type game


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 gfxgangsta   Members   -  Reputation: 564

Like
0Likes
Like

Posted 05 February 2014 - 12:27 PM

How would you deal with latency in a Farmville-type game? Specifically -> if you have farm land that produces items like grapes (every 60 seconds), and you have a visual timer on the client that starts at 60 seconds and counts down to 0 seconds... how do you make it so the client and server match up? I'm thinking the client can probably get to -1 or -2 seconds or so before the server tells the client the grapes are ready. Even if you keep displaying "0 seconds" on the client, people will know that it took an extra 1 or 2 seconds for the grapes to be ready.

 

My thoughts:
 
1. Trust the client (if the client is collecting grapes, they are ready even if the server doesn't think they are). I don't think this is a good idea. A hacked client could collect grapes whenever they wanted to.
 
2. The server sends the "grapes are available" message a few seconds ahead, but the client still waits for the full countdown to allow grape collection. This is better than #1, but a hacked client could still collect faster than a normal client.
 
3. Focus on reducing latency
 
I'm thinking a combination of #2 and #3 is the way to go, but please provide your insights.
 
Thanks!


Sponsor:

#2 Paragon123   Members   -  Reputation: 461

Like
2Likes
Like

Posted 05 February 2014 - 04:05 PM

I'd say don't worry about matching it up. Just do something like this

1) Player "plants" grapes and sends message about planting to server.

2) Server sets timestamp for when grapes should be ready and sends that timestamp back to client

3) Client calculates time left till ready based on time stamp.

4) Player "collects" grapes by clicking grapes initiating a message from client to server to collect grapes.

5) Server compares message received time to grapes ready timestamp.

6) If time past time stamp send "OK- Qnty picked" message to client else send "Too early" timestamp to client.

 

Using this method, the lag will occur on the front end, between when a player chooses to plant to grapes and when they actually start growing... yet the count down will still 

be displayed correctly on the client. Then, there may be a bit of lag between Collect grapes, got grapes... but a savy user, recognizing they have lag could click a second early and still collect properly... 

Basically, the client only sends Plz plant, and Plz collect... let the server decide  if it is ready or not.. and since you are sending the pre defined ending time rather than the time left you don't have to worry about them being out of sync b/c it isn't a time sensitive value any more.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS