1.8 Technical Release

Today I released version 1.8. This is 100% backend release (meaning code changes but no new features) so you won’t notice anything when you’re using it. The aim for this update was to address several architectural issues which would allow future updates to be better implemented.

Warning: Because there aren’t any functional changes in this release, this post may be quite technical but I try to explain things the best I can.

So what has changed?

Game Architecture

This may be the complete wrong word but I’m going to use it anyway. Game architecture, what I’m calling the way games are stored, was done previously in a bit of a weird way. For whatever reason, I had decided to store some data on the database and some data in a separate file, called “gametitle-layout.json” (where gametitle is the actual title of the game). JSON is a format for storing key/value pairs a bit like a table.

I had stored the coordinates for the spaces in the game in the file as well as information about how many spaces forwards/backwards players move, the size of the spaces, shape of the spaces, the size of the screen the game was built on so it can be scaled properly and the URL to the background image. Everything else was stored on the database.

This isn’t ideal. There are several problems with this:

  1. The source files for Quiznetic are getting very large as the amount of users increases. Currently every user has their own directory on the server so this may become a problem as more and more directories are created.
  2. Because the game title is stored in the filename (which was a really terrible idea), it means that the title can’t contain certain characters because they are not permitted in a UNIX filename. For instance, you can’t have a dot in it which was kind of annoying.
  3. Really, everything for the game should be stored in one place (the database).

This release addresses issues 2 and 3. Unfortunately I can’t fix issue 1 quite yet because there is other stuff stored in the user directories (media uploads and colour files- I’ll get to this later).

I wrote some code which would transfer the data from the game file to the database whenever a game preview was loaded. I thought this would be better than trying to transfer all the games made on the site all at once as this would take a long time and may timeout eventually.

This means that when a game preview is loaded for the first time since version 1.7, it will take a while longer than usual because it is transferring the data from the file to theĀ  database. After this process is done however, it will be back to normal speed. So when you login to the game manager for the first time since 1.7, you may be greeted with a loading icon for a while depending on how many games you’ve made.

Once the transfer process is done, the game file is deleted. This fixes issue 3, however there is one other file which uses the game title in its name- the colour file. This file is created every time you launch a game and contains the possible colours for players joining the game so no player gets the same one. For now, I’ve just changed it so it uses the game ID in the filename rather than the title to fix issue 2. However, this approach with using a file to do this isn’t the best, so I’ll probably add an update in the future which will remove the need for this file entirely.

My goal is to remove the need for user directories so I don’t need to worry about making sure they’re backed up and getting some error about too many directories. It’s not a very scalable approach.

For the media uploads, I am thinking about using Amazon S3 which is a file storage service. This will completely offload the serving of image files from the server which could mean a performance boost, however it will add some complexity and I still need to look into what the options are so it may be a while before this is done.

The future

What’s in store for future updates? I have been experimenting with teleport spaces but I’m not definitive about adding them yet because I have no idea if people actually want them! I will be putting out a poll on twitter for suggestions on this. I will also be working on the following things:

  • Import questions from a CSV file
  • Toggle whether to show the question explanation when a player submits their answer

I haven’t been getting a lot of suggestions lately so I am mainly working on non functional changes. If you have a suggestion for something you’d like added or improved, then please let me know!