Monday 7 August 2017

Game Engine 07/08/17 - Messaging System Overhaul Part 1

While working on enemy movement I found myself stuck with this engine's limitations. I have found lots of problems with my current design regarding game objects receiving info from other game objects, searching game objects and the physics wrapper, that is a mess.

For the reasons I've mentioned above, I've started remaking the skeleton of the engine.
I've already made some significant progress,  such as a Messaging system overhaul.

I remade the entirety of the messaging system. In my original engine the messages were classes with an enum identifying their type and a smart void pointer.I honestly didn't like this design really much as it was quite hard to show messages and create messages on the console, for example.

Now the Message class is derived of the class Serializable, containing two virtual functions (Serialize and Deserialize), so I can convert messages to strings and vice versa. The different types of messages are now derived classes of the base class Message, implementing different versions of the serialize functions.

Last but not least, I have created a MessagePool class, where messages are created without allocating new memory (way faster than before and prevents memory fragmentation). Now, instead of passing messages around with smart pointers, I use a MessageHandle class that destroys the message automatically when it was already processed by everyone.

(taken from the Game Programming Patterns book by Robert Nystrom)


Tomorrow I will make a new post going more into detail regarding the MessagePool class

No comments:

Post a Comment