Boost and Design

While I’ve been brushing up on the finer points of C++ before I start this endeavor, I’ve been putting some time into researching some architecture and design paterns I could use in this wingdom server.  I already have a version of this server in c# from when I put down wingdom, but now is the best time if any to make some improvements to it, not to mention some things I’m not exactly sure how to transfer to C++.  Two major things I looked into today were large static variables and the underlining network architecture that is multithreaded.

Multithreaded Network Architecture

Things were pretty easy in c#.  It had the TCP Client, and that was all I ever needed. (Note, I did and continue to want to use TCP over UDP.  This may change when I need the extra speed later, but I’m comfortable with sacrificing speed for packet delivery reliability.)  Now with C++, I really don’t have that luxury.  Furthermore I was spawning off a separate thread for each client that connected to the server which I learned today, although not completely surprising, does not scale horribly well.  After some searching I came across Boost, or more specifically the sub-package Boost.Asio that does the networking/threading/etc for me.  It looks to be using thread pooling instead of a separate thread for each client, which should help a whole lot with efficiency.  While I’d love to have something like this done with my own code, it’s silly to get held up here re-inventing the wheel when it has already been done for me, so I’m going to be looking into the boost documentation more in the coming days to see where I can use it even more.

Large Static Variables

Previously in the c# server (and even the current client) I was using a large static class that had multiple static variables to contain all information that I needed to access in one spot in memory.  This is of course a terrible idea, if not soley for breaking OOP so badly.  At the moment I still want to have all the information in one object for all client communication/server processes have the same copy of the data, but I am going to go for a more OOP approach.  I’m going to go with what I’ve found called Inversion of Control.  I’ll be basically creating an instance of a struct (note, not class) at the beginning of the program.  Then in the constructor of all objects that need access, I’ll pass a pointer to this global data object.  This way I’ll preserve OOP as much as possible, while still having the desired effect I had before.

Status Update

Well, it has been a while since the last update.  Wingdom ran into a few problems with bounding-boxes for tile-collision detection which made me take a break from it.  I’ve also decided to change the server from c# to C++.  I’ve merely read about C++ for a long time and never used it in a real project, so I figured this is the best of time as ever (since I’m already finishing my Jr. year of college).  The client will still stay as silverlight (through c#) like before.  I feel this will give me a real chance to see how it is to develop in C++ which of course will hopefully open up some doors for my future career if I have actual experience in the language.  I’m really hoping to turn this into a development blog for Wingdom (and other projects I do), talking about problems I run into, solution I come up with, etc, so hopefully I’ll have some more posts soon!

Wingdom Dev Started

A new project code-named ‘Wingdom’ has been started!  I will be sharing more as development proceeds.  So far the basic idea is implementing a 2D RPG that is all multiplayer based and provides players the ability to develop their own ‘zones’ that everyone in the game can explore.