Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Snowman

Client/Server

This topic is 6912 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

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!