Who’s been a naughty boy?

Me. First of all for a number of small line items that went in after feature freeze :( All of which seem to have worked, but that’s hindsight and thus not an excuse. Slaps own wrist.

Secondly… Firebases.

1.28 introduced a bug whereby one satchel on each half of a firebase is enough to destroy it. I had no idea -Wshadow wasn’t enabled by -Wall, so I thought the compiler was telling me when I shadowed a variable. In short, the code that calculates how much damage-tolerance (capacity) a firebase object has is always returning 0 because the variable being used to calculate it is shadowed.

UINT32 newCapacity = 0 ;
if ( ... )
    SINT32 newCapacity = ...capacityCalculation... ;

return newCapacity ; /* i.e. 0 */

Whoops.The second issue is that sometimes when a town is captured it is getting offensive rather than defensive firebases. This took a little longer to track down.When this source first became mine, I did a lot of work to clean up the capture system. I rewrote and re-encapsulated a ton of the code, but the underlying functions for a lot of it are just “tidier”. I didn’t rewrite the core of the facility’s ownership conversion. There were just too many quirks in the method, dependencies and ordering…

The many changes that a facility can impart on its environment have to happen in a particular order, so that various sub-routines can tell what effect is occurring. For instance, if this is the last facility in the town, it most uncontest the town before it determines who now owns the town. And more bizzarely, it must do both of those things before deciding that control has changed.

CP ownership is gained by holding all facilities at once. Control is gained by holding all the armybases at once. If you capture the armybase in a single-AB town, then control and ownership will change simultaneously. And the definition of control makes it kind of moot anywhere but a multi-AB town.

And frankly, with the introduction of TOEs, control is kind of moot and could probably go away.

Anyway, the root of this particular problem is that the firebases are being updated during the exit from contention or the change of control, and only when all of that has been done is the code checking whether or not brigades now need to be bounced from the town.

Which means that – as far as the FBs are concerned – any brigades that are about to get kicked are still there. And since the FBs can affect the retreat of any brigades present…

However, reversing the order of these two events is non-trivial. So I’m refactoring this code right now wrapped in a “CaptureEvent” structure which tracks the state changes being effected. Now I can isolate the various fragments and steps in the process and lay them out in a more logical order. Its still kind of intimidating because it creates an awful lot of code paths for me to test.

Writing a unit test for this is going to be a real pain in the butt.


Augh close-brakcets, my bane!!! *shakes fist angrily*

Someone should just make a language without brackets.

Oh, and without semicolons too. It should just *know* what I meant to do.

You have to think about human language. The semicolon exists primarily to allow numbers like “.05”. I think if you disallowed numbers like that, you could swap the semicolon (;) for the period (.) but honestly that might be harder to spot when its missing.

Take a look at Lua. It doesn’t *require* semicolons, instead if requires you to tell it when you want to continue something across lines, but its a little squiffy and there’s more than one occasion that I’ve had a coding issue which consisted of lua joining instructions on two lines because of a stray character on the end of a line.

Developer environments like Eclipse should be able to fill in the semicolons by now. Code completion is so much further than what I used 8 years ago…

Leave a Reply

Name and email address are required. Your email address will not be published.

Fill in your details below or click an icon to log in:

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 )


Connecting to %s

You may use these HTML tags and attributes:

<a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <pre> <q cite=""> <s> <strike> <strong> 

%d bloggers like this: