Friday, June 6, 2008

This week I focused on ships and fleets.

I had a slow start to the week as I was trying to decide how I wanted to implement ships and fleets. Ships are a very important part of this ruleset. They represent the "playing pieces" of the game and will most likely be the only objects to receive any orders. When I was initially planning the game, the ships seemed to be logically divided into different fleets: a fleet of colonists, a fleet of leaders, and a military fleet. So, I originally thought to split them into these three fleets and send orders to specific ships within each fleet. However, when I started to look at the implementation of ships, I realized it may not be possible to send an order to a specific ship within a fleet. I inquired about it in the tp-devel mailing list and found out that this was only possible in TP04. So I spent time planning out how I wanted to handle this and also how each ship type should be organized. I settled on having one ship per fleet to support TP03, and maybe later breaking it out into a separate TP04 implementation.

I started the coding by implementing a property, some components, and a ship. The property, passengers, has 8 possible values and handles the 4 colonist types and 4 leader types. The components, cargo bays, each had a different value of the passengers property. The ship, a transport ship, has a cargo bay outfitted to carry one type of passenger.

To test all this code this I added a couple functions to create fleets, and added code to create a simple test fleet with one passenger ship in it.

I ran into my first big bug here. I tried running the game and I would get a seg fault after joining the game. I spent some time enabling debugging on both the client and server, and adding debug statements to the server. I discovered the problem was that I had removed the "damage" parameter from the fleet object, but hadn't removed all the references to it. I finished removing it, which fixed the seg fault, but then the client yelled at me. So I ended up just adding damage back into the fleet object, which caused the fleet to be created successfully.

This is where I hit my second bug. The sample fleet was created, but it didn't have the ship I made in it. You can read about the problem and my solution in this thread.

While I was working on the missing ship problem, I went ahead and implemented the remaining properties, components, and ships (here and here).

Overall, this week went well. It wasn't as smooth as the past couple weeks. I felt like I didn't get as much done, but I did learn a lot and working through those first couple bugs will definitely help in the future.

For next week:
Start working on orders and maybe a basic turn structure. Some of these orders may require a good bit of extra code to check to make sure they're legal moves. So, I probably won't finish implementing all the orders by the end of next week, but it should be a good start.

0 comments:

Post a Comment