GSOC Update: Week 5

Continuing the work that I started last week, I have implmeneted most of the functionality in AI and Window, and mostly completed a new sub-system: Input.

The openning cinematic is completely running, all the input controls except the Quit Key and the Pause Key have been implemented, NPCs, Bots and objects like crates have been introduced, and the player can now talk to NPCs. Here it is:


While most of this week went according to plan, I ran into a few weird bugs that sev had to point out for me. Here are they:

The CineCommand Problem

Shortly after writing the previous blogpost, I ran into a bit of trouble. I noticed that Lua was loading the wrong string for the dialog text, and fixed that which directly caused the game to crash.

After a few hours going over why it was crashing(which among other things involved printing the Lua Stack), sev pointed out that I had been using a preallocated char arrays of 32 length, while trying to load messages as long as 80+ characters. This had led to a memory overwrite, and caused the crash. Changing the CineCommand struct to use a const char * fixed the crash.

Dialog Spacing

In a stupid blunder, I had been miscalulating the whitespace in the dialog messages. Instead of simply adding the designated number of pixels, I was multiplying them leading to a large amount of unnecessary whitespace.

Foreground and Background indices

If one recalls the previous blogpost, one would know I have a tendency to declare values as unsigned variables. This led to another problem recently, when I realized that certain tiles are designed to as to have a -1 index value. This type mismatch had to be corrected.

The Clock That Wouldn’t Disappear

In the openning cinematic, there is a clock that needs to vanish after it is thrown. However, it wasn’t disappearing. sev pointed out that I had been using the _cine[i]->x, _cine[i]->y positions rather than the _cineBlitList[i]->x, _cineBlitList[i]->y positions for the clock, hence its appearance.

The Copy/Paste Error

I had made a nasty copy/paste error. When making a nester for-loop, I had copy-pasted the outer-loop without changing the indices of the new loop. This didn’t show any problems at first, but would definitely cause trouble later.

Changing indice mid-loop

One of the slightly-inconvenient problems I have started to face involves altering an array while iterating over it. Doing so while using an iterator has caused to be trouble some, since it would lead to one or the other pointer error. The best approach seems to be to rewrite those loops without the use of iterators.


  1. Add Sound System
  2. Add the remaining Bots and NPC code
  3. Implement Pushing
  4. Find and patch Lua problems