• Advertisement
Sign in to follow this  

Interfacedesign and ENet

This topic is 4144 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Right now I'm working on a SinglePlayer FPS-like action game. Our next step is to implement a multiplayer mode. We decided to use ENet to have less work with the low level implementation for the network code. We wan't to implement a client/server architecture like it is done in Warcraft 3. So in the first step there will be no dedicated server. A client acts as a server too. I read several discussions in this board and several articles (1500 Archers, Source Network Protocol, Unreal etc.). Right now I think some kind of implementation of the Source Networkengine would fit to our project very well. I have some trouble designing the interface for our highlevel network code. Are there any more resources like books or articles I could read? How should I handle the case if a client is also a server? ClientMessageHandler and ServerMessageHandler in one loop? Or in two different threads? (I'd like to use no more threads than necessary) Also I'm not sure If I need to synchronize the network clocks in our network. Because of the very poor documentation of ENet I don't know if there are already some functions which may help me with this part? Regarding this, I read this article http://www.codewhore.com/howto1.html but it is not completly clear how it works. Isn't it a huge amount of overhead if each client send 32 to 64 pings to the server only to get the right network clock? (Maybe I missunderstood something?) Thanks for your help! Zerd [Edited by - Zerd on October 16, 2006 7:40:55 AM]

Share this post


Link to post
Share on other sites
Advertisement
When it comes to synchronizing the clock, you typically just accept the clock that comes from the server in the first packet, and then piggyback additional clock timesteps on further packets you send/receive, so you can continually fine-tune the estimate of the server clock vs your own.

When a player is also the host, the cleanest way to work that out is to run two copies of everything on that players computer. That means, actually run one server, and one client, in the same process. You can also make it so that the clients simulation is a server to the other players, but that gets uglier.

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
When a player is also the host, the cleanest way to work that out is to run two copies of everything on that players computer. That means, actually run one server, and one client, in the same process.


So I would technically do something like this on the client/server:
//gameLoop
while(..) {
...
server.handleMessages();

client.handleMessages();
...
}

with something like a different instances of the gamevariables?

Share this post


Link to post
Share on other sites
Quote:
Original post by Zerd
Quote:
Original post by hplus0603
When a player is also the host, the cleanest way to work that out is to run two copies of everything on that players computer. That means, actually run one server, and one client, in the same process.


So I would technically do something like this on the client/server:
//gameLoop
while(..) {
...
server.handleMessages();

client.handleMessages();
...
}
with something like a different instances of the gamevariables?


I would start two threads, one for the client and one for the server. Dual core systems are becomming more common and by using two threads you can use both cpus. Not to mention you can just run the 1st thread to run the client only and the 2nd to run the server only. The code becomes much cleaner this way.

Viktor

Share this post


Link to post
Share on other sites
@hplus0603:
Thank you for the link its a really nice article, and I'm sure I can use it at least for the game-debugging.

@kvp:
I also thought about that, but right now the single player mode of the game is completed, and we did not do any adjustment to dual cores. So I think if we only make the network component work fine with dual cores it will be no greater benefit. I think more than one thread is not the solution to get more effort. But currently we did't decide how we will design the interface finally.

I'm open for any more suggestions if there are some!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement