Wednesday, September 16, 2015

Not Dead

Project isn't dead.  Still have a very strong passion to build a game that has similar mechanics as that of Space Station 13.  Due to personal responsibilities that are more important then my own hobbies, progress on this project has slowed considerably.  Being a one man show doesn't help.  Posts will be few and far between but when there are posts made they will give information on techniques I learned that anyone with programming aptitude can apply to the mechanics that makeup SS13 as well as any highlights on progress or lack thereof.  Thank you for your time.


Those few who have visited this blog and probably don't know what this is about may want to read this.
My goal is to create a versatile 3D engine with 2D assets that incorporates SS13's atmospheric simulation and immersive qualities while maintaining a networking backbone that allows many players to be online and enjoy the game.  Assets will comprise of 2D textures with certain game objects, like walls, being 3D rectangles with two textures (side and top).  Player avatars will be 2D assets in 3D space, think like Paper Mario.  That is the goal.  Keep the asset pipeline simple to build upon while giving it a modern feel that can be pleasing on the eyes.

TL;DR A SS13 engine with networking that just works.

Wednesday, June 10, 2015

Custom Website Hosting

The framework now features a command line website hosting program with a backend supported by
It is surprisingly fast and easy to use.  I use a template engine called DotLiquid to quickly generate concise pages that conform to a style and the greatest part about it is I can make it all interconnected with the game!  Can even get server status and display it on the page since I use the same library the game uses with the web host program and communicate via UDP layer to ping the server status.

I plan to integrate some of the website services to be accessible from the game for admins.  For example, troubleshooting tickets will be able to be pulled from a storage and viewable in-game with the ability to setup to receive notifications via in-game message and email.  This should streamline the administration process and relieve a possible point of failure (although, we are all human) where a ticket gets overlooked and skipped.  There is nothing I hate more than a business with a process that is flawed.  I don't plan to have a business of this but I will incorporate the ideas that solidify a strong business modal with this game and the administrating portion.

Awesome shit.

Sunday, May 31, 2015


We all know Instances from popular MMORPGs out there.

I have developed a way I can handle them by having each EntityManager have a unique ID.
Each Entity transmitted has a EntityManager ID assigned to it.
Think of it like it is a game world and it is telling those entities which world they belong to.
Entities can change worlds at will and has no performance impact since it is a simple variable change.
This will likely be restricted to player's entities or NPC entities that traverse into the instance with the player.  Best part about it is I can restrict network traffic to a client based on their player character entity's EntityManager ID so that they only get the traffic for that world and it requires no changes to my existing network design.
I plan to have instances be like what BYOND uses as Z layers which are used for different regions, like the abandoned station.
You launch a shuttle out into space than an instance is created for you and I could have random events happen to you in your little instance while out in space, pack a lunch.

Very fun stuff.

This was already in the engine, just never posted about it... lots of things I have yet to post about.

Monday, May 25, 2015

C# Version Update: Networking & Encryption

Got the networking side working (again) as well as encrypting whole or part of packets.  Also, made it so that the server can update the encryption at will and I will probably have it set up where if a player is AFK for a period it will renew the encryption.  Every player's encryption is unique, so, no possibility of having your important data messed with.  When a player disconnects and reconnects they also get their encryption changed.  I could even set it up for when a player transitions to a new map they get new encryption.

I have a few further changes I plan to make to maintain integrity since when the server and client are going through the encryption renewal process, encrypted packets are dropped because they were using old data.  I already have an idea of how I will go about it in a secure way.

Another task I am planning is seeing how my Entity system works over the net.  I have it setup where if a component's property is changed, property notifications are automatic and not programmed, then that component is flagged as changed and will be sent on the next pass.  This can cause bandwidth problems, however, I also thought of a solution to that. Right now it is sending all the properties of that component even if only one property changed.  This is bad bandwidth usage.  The solution would be to only send the property of that component that did change.  This will be surprisingly easy with my new framework setup.

Update: Sending Entities works, tested the amount of bytes sent with Zone, Data, Health, Translation (position containing Vector3).  Came out to 47 bytes total.  I even have the capability to GZIP compress packets (even encrypted packets) if they get big (like sending a file).  I am very impressed with this beast.

"The arrival of a good clown exercises a more beneficial influence upon the health of a town than of twenty asses laden with drugs." -Thomas Sydenham

Friday, May 8, 2015

XDocumentation Class

Wrote up a Microsoft XML comment documentation file parser for the purpose of linking to scripting API documentation.  If you aren't familiar with XML doc comments they are what programmers use to better document what a method, property, class, or even a variable does.  It improves code readability and anyone using your framework won't have to guess what a method does if it is documented correctly.

The file is downloadable; here

This will help me having to avoid manually creating something like a Wiki that lists all the scripting functions available.  Now I can generate a CHM (help file) that can reside on your local computer.

var docs = new XDocumentation ("(Project Doc File).XML");
docs.FindAll (m => m.MemberType == XMember.XMemberType.Class).ForEach (Logger.Info);
using (var testFile = File.Open ("test.XML", FileMode.Create, FileAccess.Write)) {
   docs.Save (testFile);


Thursday, April 16, 2015

Patcher Done!

There are a LOT of ways you can choose to update a game.  You could have a installer that is downloaded every time there is a update available.  You could download a file with a version number that tells you if you need to update your version with the server's and then download all the necessary files.  OR you could use existing technologies that have proven reliable.  Subversion, or SVN, is a very very useful way to keep files updated.  It also allows you to revert a file to a previous revision in case mistakes were made.  SVN is what I chose to go with for a patcher because you can even create "patch" files with SVN.

To accomplish this I used a library called SharpSVN which is a .NET library written to use SVN simple and easily.  Best thing about it is you do not have to have SVN installed on your system.

An example is below to show you just how easily it is to get started.
using (var svn = new SvnClient ()) {
  svn.Configuration.LogMessageRequired = false;
  svn.Authentication.Clear ();
  svn.Authentication.AddConsoleHandlers ();
 svn.Authentication.DefaultCredentials = new NetworkCredential ("test_user", "abc123*");

  svn.CheckOut (remoteTarget, localPath);


Monday, March 9, 2015

Simple Script API Documentation

Script API Framework

Don't think I covered this so now is a good time!  I have implemented abstract script support that I can attach any .Net supported scripting language too.  Currently, I have support for Lua.  It is fairly easy to use.
            using (var script = new LuaScript())
                script.AddAPI(new LoggingAPI());
                script.AddAPI(new AddonAPI());
                script.AddAPI(new DocsAPI());
                script.AddAPI(new CsvAPI("csv/"));
function main()
    log.print('hello world');
    foreach a in addons.All do
        log.printf('Addon: {0}', a)
    log.print(docs.GetMethod(docs, 'GetMethod'))
 Showcased in that little script is also the recent addition of Documentation through the use of Attributes.  Makes life a little easier.  It prints out something like this.

Adding additional languages is easy.  Just create a class with the IScript interface and use it in a using statement.  Call the AddAPI methods to add functionality and Load a stream of code than call Run.  That easy.
public interface IScript : IDisposable
    bool Run(params object[] args);
    void Load(Stream sourceStream, string name = "chunk");
    // ReSharper disable once InconsistentNaming
    void AddAPI(IScriptAPI api);
    T GetVariable<T>(string name);
    void SetVariable(string name, object value);
I hope this has given someone some ideas about adding scripting support to their framework.  I know that there are questions about the logic of using a scripting language.  In a game it makes a whole lot of sense to use scripting for behaviors, user interface management, and even configuration.  That is enough reasoning for me.  I hope it is for you.

Tuesday, March 3, 2015

Dictionary - Lesson Learned

Sometimes what appears to be the right way to handle a Dictionary isn't always the"right" way.  In .NET a Dictionary is a key/value pair collection of objects that you can store and than later retrieve by key or iterating over the contents.  If you want to see if the key you want is even in the dictionary you call

If the dictionary has your key you can execute the contents of the "if" block. Is this the right way to do it?

Well, you could just catch the exception that is thrown when you try to add an entry.

But exceptions are costly because it forces the stack to be unwound so that you can trace the method hierarchy.

What I learned from a little research into Dictionary is that the "correct" way to do it is to use TryGetValue method.

TryGetValue attempts to get the value of a key in the Dictionary and returns a boolean (true/false) result. The above example tries to get the value of "myKey", which obviously won't work because the Dictionary had nothing added to it, fails and executes the dictionary.Add code.

TryGetValue is a much faster and safer approach then the other 2. To someone who gets caught up in the idea that ContainsKey shouldn't be expensive, you are wrong. TryGetValue method is the right way.

This lesson allowed me to trim a hefty bet of seconds off a big iteration of entities, allowing me to outperform the Java version.

Sunday, March 1, 2015

Asset Management!


Asset management is an important part of ensuring that your content is delivered to the client in a non-intrusive and professional way.  Asset management shouldn't be hard.  Going to introduce you to the way I handle it but not divulge my actual code, sorry.

The Worker Bee

It is important to have one central class that you can deal with to load assets.  An asset manager, although you do not need to call it that, that handles loading, unloading and caching of assets.  Caching is important because you do not want to load the same thing twice.  The design should be simple and easy.  You shouldn't have to extend your asset manager EVER.  Asset manager should be transparent to the components inside.

Something like...

It should be THAT easy.  I may come back to this and add more insight.

Thursday, January 29, 2015

CSharp and .Net

I have decided to switch to C# and .Net.  There are quite a few reasons:
  • Cross-platform through Mono
  • Better language features like delegates, lambdas, extensions, linq, var, dynamic (although linq and dynamic are slow and will not be used)
  • Raw ValueTypes like uint, ulong, decimal
  • Roslyn open source compiler will allow community additions and language features far faster than any language out there which once stable I will definitely use
  • MonoGame cross-platform which is similar to the XNA framework which I used back when it first came out
  • Easy to transfer Java classes to C#
  • Visual Studio Ultimate is a godsend.
  • Task Parallel Library makes doing asynchronous programming easy
  • Exceptions from third party libraries are optional to catch, like null pointers when you already did a check for null before the method is called
 I was very stubborn about Java and chose it over C#.  This is mostly due to the speed of Java.  But by sacrificing time to adhere to optimization standards that have developed for C# you can achieve speed close to Java.  Java accomplishes those fast speeds through what is called [Hotspot](  If .Net were to make something like that it would be even better than Java with the above reasons.

Already have networking and graphics with some cool utilities like Memory watching, logging, asset management, text-to-speech, controller support, and much more built in to the framework.