Jump to content
  • Advertisement
Sign in to follow this  

Singleplayer / Multiplayer Approach

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

So, the game will have a singleplayer and a multiplayer.

I was thinking of making a client and a server and even in singleplayer you host a server and connect with your client to simplify the codebase.
The problem is that so many things are allot less efficient with this model and like twice the memory is used for some things...

I could make a special singleplayer 'client' that integrates the server and client but that seems like allot of maintenance work when something changes.

How would you guys do it?


Share this post

Link to post
Share on other sites
In singleplayer mode I only exchange the network components by using a direct in-memory approach instead of TCP or UDP.
The game's core with its client and server components stays the same.

Share this post

Link to post
Share on other sites
The only issue (that may be somewhat unavoidable) is that I have to store two instances of the same information (position of objects for example).

This can get bad if for example I was using dynamic terrain and had to store terrain data twice.

Share this post

Link to post
Share on other sites
These are your options:
1. Do nothing and ask your potential customers to upgrade their RAM.
2. Reduce the memory requirements of your software until you are happy with storing all necessary data as often as it is necessary.
3. Create a third mode of execution that calls the server- and client-subfunctions on one single set of data.

Regarding the third option:
The main server function does these things:
a) Receive user input from clients.
b) Apply game rules to the game state.
c) Broadcast changes of the game state to clients.

The main client function does these things:
a) Receive updates of the game state from the server.
b) Collect user input.
c) Send user input to the server.
d) Apply (local) game rules to the (local) game state.
e) Render the local game state.

(There are a few other things, but let's truncate that.)

The ServerClientMix-Thing is supposed to do the following:
a) Collect user input.
b) Apply game rules to the game state.
c) Render the game state.

If you reordered your main server- and client functions so that the three main sub-functions of the ServerClientMix-Thing were member functions of neither the client nor the server it'd be easy to create the ServerClientMix-Thing as a seperate entity.

Share this post

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

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!