Hey all! As you might remember, my current planning for the next release is (1) making Olvand work with Glux, (2) fixing lots of bugs, and (3) implementing the beginning of the new lighting system. I've been stuck at (2) for weeks now, which is not because I work so slowly, but because for every bug I fix I discover three new ones. Because telling about bugfixing for weeks in a row isn't that interesting, I even stopped blogging temporarily, but I thought this week it would be nice to give you some insight in what kind of things I'm doing. Four examples of problems and their solutions:
The game no longer crashes when you wear undyed clothes on a scooter
The latest release included dyeing clothes, which is one of my favorite features in the game so far; it finally allows you to give a personal look to your character, and the fact that you 'crafted' this look yourself makes things even more satisfying. It didn't come without problems, however. The biggest one was that with adding the possibility to wear dyed hats on scooters, I accidently broke the possibility to wear undyed (=normal) clothes on a scooter; if you did so, the game crashed. And to make it worse: before crashing, the game almost always managed to quickly save the fact that you were wearing undyed clothes. This meant that the next time you logged in, the game immediately crashed again, forcing people to reinstall the game every time they accidently wore indyed clothes on scooters. I found the problem in less then a minute (simply a matter of creating a variable earlier), and wearing clothes is now safe again:
Painted roofs are now saved correctly
For houses on some places (it's still unclear to me which places exactly), the server didn't save any changes to the roof color. However, the server thought it DID save the changes. So when you painted a roof, you got a little message back saying everything was okay, while in fact no paint was saved. So when you later asked the server to reload the world, some random houses got unpainted roofs again. The solve this problem I decided to represent roof color a little bit different in the database, and this new representation method can handle ALL roofs, not just only some of them.
Putting stuff in chests or on construction sites no longer makes other people's games crash
The first time I introduced chests and construction sites, I forgot something really important: two or more people can of course open a chest (or construction site inventory) at the same time. If one person puts something in a chest another person is looking at, that other person should of course see that new object appear immediately. These 'live inventory updates' were added with the last release, and work as follows:
1. All changes to inventories (chests or construction sites) are sent to the server, along with the coordinates of the inventory.
2. The server forwards this message to all other clients.
3. All clients receive the message, and check whether they are looking at an inventory on these coordinates.
4. If so, the inventory is updated.
Problem was, the code assumed ALL players were looking at an inventory, or have at least looked at an inventory before. If you hadn't, other people changing stuff in an inventory made your game crash immediately. Fixing this fortunately was a matter of changing '==' into '!=', but it took quite something before I could pinpoint the problem exactly.
The server now tells the clients when it stops.
Olvand clients (a client = you, when you're playing the game) regularly check if the server is still alive by sending a message asking for a response. If they don't get this response within a few seconds, they assume the server has stopped; either because someone killed it, or because it crashed. This lead to the strange situation that if I stop my server while people are still playing, they all can go on for a few seconds, and then get a message 'Lost connection to the server'. Now, when it stops, the server sends a message which basically means 'I'm going to quit' to all clients before it actually stops, and the game then shows to the player 'The server has stopped. You will go back the main menu in a few seconds'. This not only is a little less abrupt and stops things from going out of sync, it's also much more clear for the player what's actually happening.
Okay, enough writing, back to bug fixing. I'm not sure if I will blog next week; depends a bit on how much interesting stuff I can find to talk about!