Friday, June 22, 2007

Epic debug sessions

I'm currently busy with some epic debug to fix a some major bugs in the movement code. It suffered from units running over other units, where the unit that was being ran over disappeared. It still rendered, but it no long accepted orders, could be selected, etc. I also had units that would not clear tiles they occupied properly, so that in some cases, tiles were still used while the unit was half a map further, which led to other units behaving strangely when driving. And last, units sometimes 'jumped' to other tiles and started vibrating. Yes, vibrating... No idea what causes that.

I fixed in the past week the run overs, which is nice. By fixing this, I haven't seen units warp since I fixed that, nor vibrate. So it seems that I only need to fix the clean up. I made a nice function which runs a check on the entire map and shows which tiles are used by what unit, and if this unit is actually positioned on that tile. And if not, it shows a [ERROR] tag. In combination with the debug log I hope to find out where it goes wrong.

After this works, I'm gonna make units 'defend' themselfs from others. ie, if attacked, they'll start attacking their attacker.

Monday, June 11, 2007

Let the vehicle construction begin!

I got unit construction in. Wasn't a lot of difficult work. It basically was adding an additional check to the techtree retrieval function, and if a tech item was a unit, place the icon in the Unit strip, and otherwise the building strip.

The rest of the system is the same: The building asks the ConstructionManager if there's a job waiting for him, and if so, it takes the order and executes it. When done, it will now check what kind of object is done. If it's a unit, it will check if there's a free spot around the building, and if yes, it will deploy the vehicle there. When there are no more tiles free around the building, it will show a nice message in the debuglog telling me to implement carry-all's to pickup tanks from buildings(Which is actually really friendly).

I still have to implement showing a deployment animation when a unit is deployed, but that's not that difficult. It's a matter of minutes to implement the additional class(ConstructionBuilding) and the code to trigger the animation.

The next step is to give each unit / building a unique ID which is also linked to it's owner. I'm running into some nasty bugs, which makes debugging difficult if you got 20 units on the screen and 1 flips out...

Bugs I have at the moment: When a unit runs into an obstacle along it's path, it will try to find a new route. If it can't find one(Because the blocking object is the end-tile), it suddenly changes it's position to 1 tile back and starts vibrating... Very odd.

The other bug is related to units popping their states off the stack for no apparant reason. That only happens when moving in groups tho, so I need IDs to track them.

Units after their construction

To do for next time:
- Add IDs for units and buildings
- Fix movement bug
- Fix state popping bug
- Add deployment animation
- Add icon sorting to the construction bars. It's annoying to have the order change depending on how you build the buildings(Or if you lose your barracks half way) and the icons end up in the bottom.

Thursday, June 07, 2007

Bug fixes, loads of them!

While technically still in development I hunted down and squashed a load of bugs in the past few days. Having a laptop and being able to work in the train is awesome. Every now and then I see people take a peak at my screen to see what I'm doing. Earlier this week there was a guy who just kept looking at my screen, and back outside, back to the screen, etc. Esp. when I fixed a little thingy and ran the game again to see how the changes worked out.

First, the list of bugs I managed to strangle(For those not interested, skip down, there's imagery there).
  • Fixed bug where buildings would be placed 1 tile to the left and 1 tile up
  • Lowered scrolling threshold to be Tile.Size / 2(So scrolling only happens on the edges, instead of 1 complete tile)
  • Fixed bug where you could order buildings to move/attack(Would cause crash)
  • Dragselection rectangle / Building placement rect don't show up when hovering over UI components
  • Renamed Radar to Outpost(Needed for Reflection to work)
  • Fixed bug where placement rectangle would be rendered OVER UI components while while the mouse was outside the component
  • Buildings can no longer be added to the building manager of a different owner
  • Fixed debug log text
  • Added a little bit more debug output
  • Fixed an issue where the CheckMouseOver() function would read out of bounds
  • Fixed an issue where the mouse handling code would respond to mouse clicks in the UI
As for the new feature: I added concrete slabs. Not very special as you can see below, but still, it's in. I think the next step to this is to allow buildings to build units. After that I think it's time for refineries to 'order' a harvester reinforcement.


I also noticed that the revision number updates weirdly... I have a pre-compile step which runs an svn lookup batch file to determine the revision of the repository, turn that into a sexy class with getter and store it all. However, it doesn't always(read never) run when compiling. Pretty weird, and annoying. Probably only runs on a full re-compile, so I usually just run the batch file manually after commiting my code. Not the best solution, but it works.

I also started committing more often, since I used to do too much work between commits. If my laptop would either explode or get stolen, I would probably lose a week or 2 of work. Not really that appealing...

Wednesday, June 06, 2007

Building placement is in

In the past 2 days I put the code together for placing buildings on the map. While not completely done yet, I also found a few bugs in the code relating to writing to the debug console, finding items on the map and the techtree.

I'll be going to fix these issues before adding in the construction of vehicles and implementing the credits counter. But after I cleaned up the input handling code.

First some screenshots:

Debug console display we started building a new WOR. Note the 'built by' bug.

Placement of our new building not allowed here, see debug console for next error

And voila, our new building is placed, including sexy deployment animations(Not included)

The next step is moving all the input code into the LocalPlayer class. Hooray for .NET partial classes, since this will prevent my code from turning into a huge pile of steamy mess that could make even the most seasoned developer cry himself to sleep.

After that, I will first fix all the bugs I've found till so far and then I'll implement the placement of concrete(yay!), the penalty of placing a building without concrete and construction of vehicles. If those work, I'm considering implement a basic network framework(!!!) and then start polishing up basic features. When these features are implemented (Which will take a while), I have a basic playable RTS.

Friday, June 01, 2007

Construction is in... Now building placement

Over the past few weeks I've slowly implemented construction of buildings. It's possible to now select a build icon from the sidebar and add it to a construction queue. Each building checks every update cycle(But only when idle) if there's a queued up item, it takes from the queue and starts 'building' it.

When done, it informs the player object about it, which can then take the appropriate action. A human player will see a message / hear a sound and an AI will place it directly.

I'm currently working on implementing the building placement. However, I still don't know how to fully implement it. I currently have a GameInputHandler which handles that part of the input(Do the picking, context sensitive cursor, etc.). But, I need to change it around to be less, messy.

Also, I've been thinking about adding a feature for hearing impaired. One of my current projectmates for a college project is deaf, and one of his biggest issue with most RTS games is that he never gets a message about that his base is being raped. (He usually notices that he's getting his ass kicked when it's too late...) Well, there is a warning, but without working hearing, he can't hear it. So I want to add an optional screen message, which blinks in the middle of the screen. Simple to add, and usefull for those who can't use sounds or can't hear. Having people in your projectgroup which have a minor disability widens your view a bit.