Skip to main content
GameDev.net gamedev.net
🔒 Locked

Extendable, scriptable multiplayer architecture

Started by bicubic Mar 31, 2011 at 1:17 PM 2 replies 2.3k views
Original Post
bicubic
bicubic
Hi all.

I have written some very basic network apps and multiplayer 'games' before. I am interested in writing something larger and one of my goals is to create a framework that makes it easy to introduce new entities into the game via Python or similar. I am looking for any useful information or resources regarding this subject.

My main concern is to minimize the amount of low level networking code that must be done when creating these scripted entities. Ideally they would just define some variables and events that are to be synchronized, and the synchronization rules for them. I am using C# and Python so reflection is certainly an option.

Problems that come to mind is that the server's representation of players is different than what other players receive, for example the server may keep track of health but not share this to other players. Does this mean I need two classes to represent the same entity and two sets of send/receive methods? That sounds very inefficient.

Another issue is entity 'ownership'. In a limited game you can assert that entities can only be manipulated by players they represent or the server, but in my game it can be the case that perhaps players p1 and p2 are on the same team and player p3 is an enemy. I want p1 to be able to create some entity that can be in a limited manner controlled by p2, and finally not be controlled by p3 at all and make less data available to him than p2 (say, data that only team members share). This is not only about having a clearly defined design but also about preventing hackers from manipulating things they shouldn't be able to.


hplus0603
hplus0603
Here is an article about component entity models in C#:
http://www.enchantedage.com/xna-world-entity-pattern

So, what does that have to do with Python?
Well, first of all, you can use the same design pattern in Python. Each object has components, and the data lives in the components.
Additionally, you can make a rule for decorating component attributes to support serialization/networking -- @decoration in Python, [Attribute] in C#.
enum Bool { True, False, FileNotFound };
bicubic
bicubic
I'm not entirely sure I understand how this addresses the issues I mentioned. I must admit that I shied away from XNAs notion of game components and frameworks that followed a similar approach. I don't see the value of them outside easing code reuse at the expense of potentially introducing data replication as components are limited to accessing only the public members of what they're dealing with.
hplus0603
hplus0603

I'm not entirely sure I understand how this addresses the issues I mentioned. I must admit that I shied away from XNAs notion of game components and frameworks that followed a similar approach. I don't see the value of them outside easing code reuse at the expense of potentially introducing data replication as components are limited to accessing only the public members of what they're dealing with.


The point is to build a data model of each entity.
The goal of the networking is to replicate the data model of the entity to each viewing client.
Note that viewing clients will generally have a different composition of data than a controlling client (or the server).
The entity/component model allows you to, for example, provide a "renderer" component for a viewed entity, without providing the "read user input" component.

There are of course other ways to do this, but you will need this kind of data abstraction for networking to make sense within your game.
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.