Advertisement

Client/Server

Started by April 29, 2000 01:05 PM
4 comments, last by Snowman 24 years, 7 months ago
Hi! I''m currently working on designing the architecture of the code for my game. Since I am positive that multiplayer is going to be an option (already have the net engine), I wanted to take the Quake 2/Quake 3 route and make everything client/server based in terms of the internal design. I''ve always heard that if you want multiplayer, you have to plan for it from the beginning, so that''s what I''m doing. The problem is, I''m not sure how it''s supposed to be set up. Does anyone know the basic outline? Here''s some psuedo code for what I have thought of on my own: CGame::Update() { // Update Client // If we are playing single player, or are the server of the // multiplayer game, update the server } -- Already I know that''s wrong, it would be bad to update one after another like that because then the server is dependent on the client finishing. All in all it''s bad, but we''ll get back to that-- CClient::Update() { // Get user Input // Send input to Server // Retrieve updated positions for objects that have changed // Render the output } CServer::Update() { // Wait for input from a client // Calculate the input into the scene // Send changed user positions to the client } Now, looking at all the loops, we can tell right away that it won''t work. Why? Because the client waits for the Server to send stuff, but the server doesn''t get anything until the client''s done. One possible fix would be to send on one update, and receive on the next. Obviously, we wouldn''t want to Render on the send loop, as we would have nothing new to render. Any ideas? Is it at least halfway right? Thanks for any help in advance! -Snowman
Well, I don''t know if this is what you''re looking for, but there is an overview of Quake''s networking model at http://www.bluesnews.com/abrash/chap70.shtml
Regards,Laarz
Advertisement
That was really helpful, it proved that my psudeo code was right =) That means I''m at least on the right track. The only thing I have left is this:

"This is true even in single-player mode, but here the client and the server can’t actually be separate processes, because Quake has to run on non-multitasking DOS"

That''s a quote from the link you gave me. Since I am not working in DOS, I should be able to have them be seperate processes, and run parallel, right?

For anyone else who is curious, here''s how:

http://www.flipcode.com/tutorials/tut_mthreading.shtml

Hope that helps anyone who had the same problem as me!

-Snowman
Well, yes, but it would be a bit confusing to start a server when playing single player, wouldn't it?

I guess you mean have the server and client as separate threads, and that is very very possible, you even SHOULD do it that way, to get max network performance. Just be careful and watch out for all multithreading issues.

Edited by - Laarz on 5/2/00 4:24:03 PM
Regards,Laarz
Any specific multi threading issues that I should be careful to avoid, or is that just sort of a gerneral warning?

Thanks for all of the help so far!

-Snowman
I''m just going to assume that you mean making things thread safe (as discussed in the 2nd flipcode article).

Thanks for all of your help =)

-Snowman

This topic is closed to new replies.

Advertisement