• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Darkbouncer4689

TCP - Keeping clients synchronized

5 posts in this topic

I'm working on a networked flash game using TCP sockets (forced to use TCP b/c of flash). The game is pretty simple as it is mostly a text based game. The only real synchronization that must be enforced is a countdown timer for each client. This timer will start at 60 seconds and countdown to 0 and at 0 some game state change will occur, so it is important that all clients get to 0 at a similar time.

I could send the "start countdown" command from my server to all clients and use the clients system clock, but if the packet is dropped or delayed then a client could get out of sync with the others. I could also enforce some client/server protocol where the client must "check in" with the server every second (or less) and the server enforces the sync of all clients. My concern with this is efficiency. My game is a slow paced text game so it is very possible that a client may not have any data to send to the server for up to 30 seconds at a time.

It may not be possible to avoid the "constantly checking in" situation, but I'm hoping someone can give me some pointers to an [b]efficient solution for keeping a timer in sync between multiple clients in a flash application[/b].

Thanks in advance.

P.S. I don't think NTP is possible with flash.
0

Share this post


Link to post
Share on other sites
What's stopping you from implementing NTP? I don't understand that limitation. If you can create arbitrary TCP conversations, you can do NTP. (Yes, it'll be potentially less reliable because of TCP's guaranteed delivery mechanisms, but there are ways to mitigate that.)
1

Share this post


Link to post
Share on other sites
What matters is that all clients see the same events in the same order. The exact timing doesn't matter as much. If you time-stamp events with "ticks" (where you define how long a tick is) then the game will be sufficiently synchronized.
2

Share this post


Link to post
Share on other sites
[quote]This timer will start at 60 seconds and countdown to 0 and at 0 some game state change will occur, so it is important that all clients get to 0 at a similar time.[/quote]


Start the timer on the server
Send start timer command to clients to do locally
When the server timer hits send your state change to the clients
The clients will be lagged behind by ms most likely but by the sounds that won't be a big deal

You see this often in games like World of Warcraft when crafting or gathering materials that run a progress bar. With high lag the progress bar is complete but the window doesn't come up yet. I can only imagine it's because my local timer for my progress bar completed (no lag locally) but the command from the server to open the loot window and show me my loot is taking longer to get to me. It doesn't screw things up just looks funny in high lag spikes. Then again most things do look funny in high lag spikes. The lowest lag person will always have an advantage in any game because they'll see data first. Most of the time this will be in MS so it won't be much of an advantage is slow paced games like your game sounds. If it was like 3 seconds it could mean a big difference however, but if someone has a 3 second lag that's pretty significant and shouldn't be playing online games anyway. :)
1

Share this post


Link to post
Share on other sites
Thanks guys. I'm thinking that rpiller's option may work as long as the server is smart enough to ignore client requests that happen past the end of the timer count down. I'm still not exactly sure what hplus0603 about using time stamps to keep everything in sync. If you wouldn't mind going into a bit more detail on that I would appreciate it!

Thanks all!
0

Share this post


Link to post
Share on other sites
The idea is simple: Each simulation "event" happens at a particular "tick number." If you run at 60 Hz, you have 60 ticks per second. If you run at 1 Hz, you have 1 tick per second. Events are tagged with the tick number they happen. Each client (and server) calculates the tick/time relation on their own. Clients that provide input tell the server "this was input for tick #N" and the server discards it if it's too old.

You can occasionally send the last tick number received, and what server tick number it was received at, from the server to the client. That way, the client knows how far to adjust the tick offset in relative terms, without needing to know what the clock is on the server.
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0