Sunday 29 August 2010

Playtesting day 4

Almost all feature fixes are done, but there is one new bug. It appeared when I compiled the game with VC++. It was first complaining missing header for std::sort which is 'algorithm'. GCC didn't notice that, but it's older version that came with DevC++. It's impossible for humans to update GCC manually so I have to work with that older version. The actual bug is somehow related to std::sort which in VC++ seems to include a null pointer in the list, which should be impossible (only existing objects are added into the vector). Maybe the bug is in GCC too, but it doesn't catch it (wouldn't be a surprise..). I don't think the bug is actually in std::sort implementation of VC++, I guess they would have found out that.

There is a manual way to check this out. It's of course displaying the contents of the vector before and after the sort. That should.. sort it out.

Searching interweb revealed that the bug was caused by something called Strict Weak Ordering.  I have no idea what it is, but changing if (o<=co) return true; to if (o<co) return true; in the comparator functor seemed to fix it. Oh well, yet again one of those cryptic programming finesses that escape my limited intelligence.

No comments: