Quotation Marks & Apostrophes

Tutorial_Screenshot

15th September 2017 – Joseph

“The first symptom of the bug was that when trying to load the tutorial, none of the scripting events worked. They were present in the file, but when the game launched and the tutorial loaded, nothing event related happened.”

Hello again,

This week I’m away at a conference, not ideal when I’m trying to get some time to do a blog post, so I’m actually writing this much later than planned. I asked Martyn what I should blog about this time around and he suggested that I talk to you about a bug that we found hard to track down.

Warning it’s going to get technical. 

Something that comes immediately comes to mind was something that was quite difficult to track down and was just plain odd – the tutorial wouldn’t load on non-windows machines. Admittedly it’s an issue that would affect quite a small number of players, but it was an issue none the less.

The first symptom of the bug was that when trying to load the tutorial none of the scripting events worked. They were present in the file, but when the game launched and the tutorial loaded, nothing event related happened. Opening the tutorial in the editor showed no events, even though the events are present in the file (our map files are really just cleverly encoded text files). Strange.

In order to debug the issue, the first step was to check how the events were being parsed by the engine, the engine parsed the first event properly, but then stopped and wouldn’t load anymore. So we followed it back through the engine, the next most likely culprit was the map parser itself. We checked out what the parser was outputting and sure enough, the event didn’t come out of the parser. Ah, we’ve found the source of the problem then. We look at the parser code. Nope, all looks good – so we checked what the parser was being given. The parser was only being given half of the map data. We knew that the file contained the events, so why did the file not get loaded properly?

In Java, there are quite a few different ways of parsing text files. One of the most powerful ways to process them is using a scanner. Perry was using a scanner and it looked like the code wasn’t reading the whole file in. His file reading code looked correct though, so I created a simple program to read in the tutorial file and then output it line by line. In programming, we call this a minimum viable example. The example showed the same problem, processing of the level just ended, no explanation, it just stopped.

What.

I implemented an example program using a slightly more robust reader in place of the Scanner, and it worked! Our whole file was being read in and processed. Woot. We’re not sure why the scanner doesn’t work but we know how to work around the problem. We replaced the scanners with our new improved reading code and we could now play the tutorial again.

Still none the wiser as to what has caused the problem, we were looking through the files and noticed something a bit off about some of the quotation marks:

Screenshot from 2017-09-13 22-39-36

That little box is an unprintable character. It turns out that when Marytn had originally written the script, he’d written it in Word. Word had been `helpful’ and replaced some of his apostrophes with their own special pretty ones. Thanks for that Microsoft, your help is much appreciated.

In conclusion, our map loading code is now much better at dealing with this kind of thing. We’re checking Marytn’s magical quotes before they go into production in future and Microsoft Word likes to try and make things pretty. I wish it wouldn’t.

Anywho, sorry for such a tech-heavy post this time round. Hopefully it was interesting none the less. I’m going to go tidy up my slides for tomorrow.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s