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
Tags: array, boolean, bug, code, Collections, core classes, documention, equals, equals method, example, faction, generics, getName, instanceof, java, java collections, java generics, method, Object, star systems, structure, Trek, trekwar
Posted in Computers, General, programming | No Comments »
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()”
Tags: bug, code, debug, java, math, math.max(), poem, programming, rhyme, trivial bug
Posted in Computers, General, programming | No Comments »
March 11th, 2010
I just got the piece of gaming news I’ve gotten so far in my life:
Lucasarts is releasing a special edition of the best adventure game of all time (Monkey Island 2: Lechuck’s Revenge) this summer

http://www.lucasarts.com/games/monkeyisland2
Tags: adventure game, game, gaming, gaming news, lechuck, lechuck's revenge, lucasarts, monkey island, monkey island 2
Posted in Computers, Games, General | No Comments »
March 8th, 2010
I’ve always hated MSN (Windows Live Messenger) but “everyone” I know uses it. But today I decided to delete my MSN account, something I’ve wanted to do for years
Why?
- The default (microsoft) client is horrible, so you have to use a different client like pidgin
- My account was created way back when you had to use a hotmail account to do it, and having a hotmail account is actually quite embarrassing.
- It’s a closed format, so when Microsoft changes something, all the clients that does not sucks breaks, and closed formats are ideologically incompatible with the concept of a free and open Internet.
- I hate Microsoft, and by the laws of transitivity everything they make.
- By using the Live Messenger protocol, you can only talk to other users of MSN live messenger. Using Live Messenger is like having a Hotmail account that you can only use to send/receive emails from other Hotmail users. Nobody would use such a limited and retarded mail service, but for some reason people are OK with using a IM service that works like this.
The alternative

The only viable alternative was to go with XMPP, which is an open and standardized protocol which anyone can use. XMPP is pretty much like email, anyone can set up a server and anyone who has an XMPP account can contact anyone else who has a XMPP account no matter which server they use.
The choice of server was between jabber.org or Google (there are thousands of other XMPP servers you can use, but these are the largest ones), but since jabber.org’s registration page was down while they were moving their servers, and I already have a Google chat account (which uses XMPP), the choice was pretty simple
Tags: Chat, client, google, google chat, hotmail, hotmail account, ietf, im, instant messaging, Internet, jabber, Messenger, messenger protocol, microsoft, msn, msn account, open protocol, pidgin, transitivity, windows live messenger, xmpp
Posted in Computers, General | No Comments »
March 7th, 2010
Today I mostly finished the Trekwar Cargo system, so now it’s possible to collect resources and bring them back to your starsystems.
Also included 4 images from the design and implementation of the UI:




Read full devblog post at trekwar.org
Tags: cargo, cargo system, cargo transfer, design, deuterium, game, images, implementation, java, ore, programming, resource, ship, star trek, starship, starsystem, starsystems, strategy, the da vinci code, trekwar, ui
Posted in Computers, Games, General, programming | No Comments »
March 2nd, 2010
Damn, look at this messed up cereal box Stacy bought today.. It’s going to freak me out every morning for the next couple of weeks.

Tags: bear, breakfast, cereal, cereal box, funny, honni puffs, morning
Posted in General | No Comments »
March 1st, 2010
I recently moved all my php sites to a new server, about a month ago, and had previously used VPS.net for my jsp/svn/etc.. server for quite a few months.
Running tomcat and sql + a few other things have used up almost all the memory on my java server, so I was thrilled to find a mail from vps.net in my inbox today, stating that they will upgrade all nodes from 256 mb ram to 375, and add 200 mhz cpu

on VPS.net you create your own virtual server which is made up of 1-18 nodes (1 node = 256 mb ram, 400 mhz cpu, 10 gb disk). So it’s very easy to make new machines, or upgrade an existing one by adding more nodes (then just restart the virtual server).
The server has been extremely stable, fast (the site your on now runs on a single node) and only restarted once, the website it runs is being monitored and have not had any downtime. This is by FAR the best virtual (or even dedicated!) server solution I’ve ever tried, and I would absolutely recommend it for anyone who needs a virtual or dedicated server. 1 node is just 20$ per month, there are no sign up fees and you can cancel at any time (1 node will be able to host a good amount of http/php/mysql content).
And if anyone wonders, no I’m not getting paid by VPS to advertise for them
They’re just so awesome that I HAD to mention it, there are so many crappy hosting / virtual server companies but these guys really are awesome
Tags: 256 mb ram, cloud hosting, cpu, downtime, java, java server, jsp, memory, mysql, new server, php, php mysql, ram, server, server solution, shared hosting, svn, tomcat, virtual server, vps, vps.net, website
Posted in Computers, General | No Comments »
February 23rd, 2010
I was checking out Sven’s page, and found his awesome map of trails (“greenlanes”) in his neighborhood.
I have my own map, but this is on my google maps, so not really very user friendly or manageable, so today I decided to try and use the google maps API.

I’m pretty pleased with the result, a single .html file with almost only javascript. Now I can just export the paths and add a single line in the .html file and the new track will be added to the maps and menu. I’m going to add sorting of the tracks by difficulty, length and maybe based on their distance from Trondhiem sometimes later.
The page is very easy to use, and if you want to make a list of tracks (or any form of lines), just check out the page source code which has 3 simple instructions on how to get it working
I probably won’t be adding many tracks until around the start of May.
Tags: code, East Sussex, google, google maps, google maps api, Greenlanes, html, javascript, map, May, mc, motorcycle, Offroad, page, Sven, track, trondheim, Trondhiem
Posted in Computers, General, motorcycle, programming | No Comments »
February 21st, 2010
I’ve recently started a new hobby, which involves tiny plastic beads
Everyone used to make stuff with “Hama Perler” when they were kids, but now that I’m grown up, it’s actually way more fun.

I’m currently making all the main characters from Monkey Island 2 (Just Guybrush and Stan so far), but Elaine, Herman Toothrot, Lemon head and the others aren’t far behind.
I’ll be adding pictures of the stuff I make on this picasa album
Tags: art, Elaine, guybrush, Hama Perler, herman toothrot, lemon head, monkey island, perler, plastic beads, stan
Posted in Games, General | No Comments »
February 18th, 2010
I haven’t had much time working on Trekwar lately, but I’ve recently made a prototype of the sensor system:

I’ll have to add this, as well as fog of war when I’m done with the fleet management tools which are almost ready.
> Read the whole devblog post @ trekwar.org
Tags: blog, fleet, fog of war, game, map, programming, prototype, sensor system, sensors, star trek, Trek, trekwar
Posted in Computers, Games, General, programming | 1 Comment »