Posts Tagged ‘bug’

Oups

Monday, March 15th, 2010

While cleaning up in the core classes of Trekwar yesterday (documenting functions, formatting/structuring code, minor improvements) I also saw lots of equals(Object o) methods. And in my infinite wisdom I decided to use generics since it is used pretty extensively throughout the code anyway, so I changed basically all the equals methods.

example:

public boolean equals(Object o) {
        if(o instanceof Structure)
            return equals((Structure)o);
        return false;
    }

was changed to:

public boolean equals(Structure s2) {
        return name.equals(s2.getName());
    }

Now this is not a problem when writing code, as you pretty much always compare objects of the same type. However, the code also uses the Java Collections contains() method a few places, and it always uses the equals(Object) version. So when my classes no longer provided this method, the default one inherited from java.lang.Object was used instead. This caused a strange array of bugs to appear (star systems on the map not shown with faction color/icon except for the Cardassians for some strange reason, users not having any technologies, unable to build any structures, generally erratic behavior, etc..). Luckily I discovered the cause pretty quickly and only wasted about an hour or so on this :)

I guess the lesson is that objects that needs to be compared, directly or indirectly by contains() or other methods, should always define an equals(Object) method that just passes the call along to the equals method written with generics.

public boolean equals(Object o) {
        if(o instanceof Structure) {
            return equals((Structure)o);
        }
        return false;
    }

And perhaps that you should not mess around with your code for hours on end without stopping to test if you broke it once in a while :)

Debug poem

Thursday, March 11th, 2010

Today I wasted two hours locating and fixing a trivial bug:

“Spent hours debugging my code, fixing hacks
but somehow mistook Math.min() for Math.max()”

Today I wasted 5 minutes trying to think of something that rhymes with “Math.max()”

Star Trek Online update

Sunday, February 14th, 2010

So, beta is over, and I’ve made it to Commander level (not had much time to play). So far the game is pretty fun, but I’ll reserve judgment until I’ve hit endgame.

So meanwhile I’ll post my two favorite bugs from the beta:

Ground avatar in space instead of spaceship

and of course.. The eyes popping out while doing the dance emote :D

Bye bye memoryleak

Monday, November 3rd, 2008

I finally got rid of that stupid memory leak in the Star Trek game I’m working on. It turns out when I optimized the use of JLabels I forgot about the action listeners, so the reference to the local copy of the game map was never removed from memory.

With a map update every 35 seconds, the client would go out of memory (200 MB) in 15 minutes, in where around 270’000 action listeners where in memory.

Memory leak

Now however the game can run smoothly for days:
NO memory leak :)

Currently I’m working on a major overhaul of the GUI, and the game looks much better now. I’m gonna release the new screenshots when I get the client stable again and re-integrate the map window in a new way (soon) :)

Goddamn memory leak

Wednesday, September 3rd, 2008

Still havent been able to localize that damn memory leak in the Trekwar client. At least the server  has no leaks :) and can run for days only using around 15-20 MB of memory (galaxy with 10’000 sectors):

The client however will crash after about 10 ticks if the galaxy is really big. Have stared at the code for hours, with no result. I’m going to have to start some methodical and very tedious debugging to get this thing fixed :(

Programming in Austria

Sunday, June 15th, 2008

I’ve had this post as a Draft ever since I came back from Austria (which is a weird-ass country by the way), mainly due to the fact that I managed to change ssh port on my server without changing the firewall :)

So I finally connected a keyboard and screen and set everything up the way they was, which meant I could commit the changes I did to the Trekwar game to the server, and get them on this computer and grab some screen shots.

Friday
It is now possible to move your fleets around the map, Client allows you to press the tile the fleet should move to and then tells the server to move the ships.

Saturyday

Fixed a bug where the local copy of the move orders where not updated properly, implemented the starsystem controll window:
Trekwar System View

Sunday
Implemented build orders, now possible to build structures on planets. Queue not implemented yet.

Airplane
On the airplane back home I implemented the asteroid belts (high-altitude programming is fun).
Notice the beautiful asteroids drawn in mspaint on my laptop’s touch pad :)

Trekwar galaxy map with asteroid belts and fleet movements

Boss Fight!

Wednesday, February 7th, 2007

farcry.jpg
Finally got past the Save Valerie bug in Farcry, so played 3 more levels today.. Nothing like running around on a sinking freighter shooting at a helicopter with a rocket launcher..

I came over a web comic I haven’t seen before today.. it has it all, Jack Thompson bashing, MS/Vista bashing and World of Warcraft references :)

Sledging was canceled.. it’s hard to motivate yourself to go outside when there is -12 c outside :(