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


Game entities and networking

Recommended Posts

No, this was not mistakenly posted in this forum. Its more about game code than networking. In my game, I will have entities. Entities are all interactive objects (or objects that perform an action) in the game. All entities will be derived from CBaseEntity, the base entity class, which will define some generic properties (serial number, position, angles, velocity, health, etc) and some generic virtual interface functions (Update(), Draw(), Die(), etc). I have been thinking that each entity should have a serial number, so that it can be referenced by its serial number over the network... The server should probably send a description of all entities in the game when the client connects, and then send updated everytime something changes. Now the complicated part. CBaseEntity does not have access to networking functions. That class is shared between the engine binary and the dynamic game library. How to send entities and their state changes accross the network without exposing too much of the engine''s architecture? Should the networking be done at the base entity class in the engine or at the intermediate entity level (specialised base classes like CBaseWeapon or CBaseItem) in the engine.

Looking for a serious game project?

Share this post

Link to post
Share on other sites
What about saving entities to disk?

You could perhaps write a mechanism that allows entities to convert themselves into byte-streams (or convert discrete ''change'' objects, or whatever). That way you could do whatever you want with the byte-stream - transmit it over the network, save it to disk, dump it for debugging.

Richard "Superpig" Fine
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Enginuity1 | Enginuity2 | Enginuity3 | Enginuity4
ry. .ibu cy. .y''ybu. .abu ry. dy. "sy. .ubu py. .ebu ry. py. .ibu gy." fy. .ibu ny. .ebu
OpenGL is a language

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
networking is a thorny issue. You want performance, but you dont want to break the encapsualtion of your design.

Anyways, a good approach is to create data accessors which allow you to bind a data element within an object. This data binding allows you to do several things :

-used as a general seralziaiton method read/write arbitary data elements within a class

-used to enumerate data elements within a class (return a key , which in my case is a string name)

The reason for this is 2 fold:

-Abstraction of data accessing
-Offload responsblity of data processing onto the external object

The object which does the binding is responsble for its behavior. That is you have a network binder object who only queries a small subset of the entity data such as position and velocity, while another seralization binder object queries and saves all the data elements within an eitity, etc..

So put your entites within a network maanger, which binds the data onto a stream and send it off to the clietns who do likewise but in reverse.

Simplifies alot of data access and design. Im using it now, and its pretty stable. Only thing you have to worry about is when data is written it might be nessecary to refresh the objects state, as external elements may need that event to correctly display the state change.

Good Luck!


Share this post

Link to post
Share on other sites