NovarunnerYesterday, I implemented weapon switching. It switches when the player strikes the key for it, as well as when you run out of ammo on a gun and try to fire it. This was relatively easy to do, although you can't really see the effects yet as the two guns mounted on my test ship are identical.
What's more important is that I took a long and hard look at my Inventory system and noticed that I'd be doing a lot of wholesale transfers of entire sets of cargo. Therefore, writing something to handle item cloning, item disposal and inventory serialization was a good idea.
So I wrote an Inventory class with a copy constructor that did cloning. Easy enough, right? Well, not really. Turns out the Apple CPlusTest seems to have a bug in it, and the test script for Inventory dies (without any indication of where it died, which required binary assertions and printf debugging... whoo) trying to execute a virtual method (in my case, Weapon::clone, which comes from the pure virtual method CargoItem::clone). I have no idea why this is, but suspect I've either made a stupid mistake or CPlusTest is trying to call the pure virtual method instead of the derived method. I'm leaning pretty heavily towards the latter, but aren't going to discount the former. If anyone wants to help out, I can bark the code up here and you can see if I'm doing something insane.
Edit Ok, jpetrie affirms me that the code is not defective. It's probably a fault in CPlusTest.
For the next project I'm certainly moving to Tut or CppUnit. The lack of debugging facility in CPlusTest test scripts is a glaring oversight. Using unit tests on this project has already saved me a ton of time from typos and the like, so I recommend it to anyone to use to test their controller objects properly.
Other than that, the inventory seems to work quite well and has trimmed hundreds of lines off of my serialization and transfer code. I liked it so much I added a rule to my coding standards that I should always use custom collections for stuff that needs to be copied.