• Advertisement
Sign in to follow this  
  • entries
    201
  • comments
    88
  • views
    100608

Oh well...

Sign in to follow this  

117 views

I've been working on the TBS engine from friday to saturday night and I stumbled upon some problems with the command behavior I wanted to use for the command machine. In fact, I had some problems to pass around the different paramters that are needed.

Basically, a command is used on a receiver calling some kind of action that has to be done. Mostly this action is bound to some data whichs structure is only known to the invoker and the action itself.

Since I wanted to have a generic command which could handle all kind of unknown commands, I had to pass 4 parameters : the receiver, the action function to use, the data size and a pointer to the generic data (void*). Sooo... the first problem for me was that I always had to know the receiver. It's not possible for an invoker to start a command, if it doesn't pass the receiver to the command class. The second problem was the data itself. Since it was generic and had to be passed to the command class by the invoker, the creation of a command was quite ugly. I wanted to have it in the constructor because the execute function would be a stupid place to pass the data. And this made the CreateCommand function very ugly to use.

So, after a lot of thinking (of 5 hours of work I've only been programming for an hour or two), I decided to skip the command behavior and directly pass register an action function and a receiver for a given message within the command machine. This is as flexible as the command behaviour but has a lot less classes to implement and to manage.

Yesterday I had two hours to work. So I sat down and started to implement the database idea I had. Since I don't want to analyse for every call a "SELECT ... FROM ... WHERE ...", I implemented several functions in my entity management that are called GetEntitiesWhere( param, value ), GetEntitiesWith( param ), etc. Since the entities are all data driven, I can quickly find the entities that have a given value in a parameter ( ie "entitytype" and "building") or that have a given parameter ( ie "timedevents" ). The examples are just those who came into my mind right now.

I also implemented the entity management which contained some functions such as Add, Remove(Entity) and Remove(EntityList). Since the entities can be passed around, I have added reference counting through my libraries IBase class (AddRef, Release and GetInterface).

Basically I now have a complete entity management which will allow me to create the data tables and connections for a game.

One thing I have to think of is how to handle parameter lists within a parameter and template entities.

The same procedures can be used to manage landscape information such as the underground properties for a given landscape/tile/whatever.

I feel I am progressing here.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement