Singleplayer / Multiplayer Approach

Started by
2 comments, last by In.Vain 12 years, 7 months ago
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?

Thanks!
Advertisement
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.
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.
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.

This topic is closed to new replies.

Advertisement