Kolf: The future begins now

October 31, 2010

While I’m writing this, git-svn is pushing into KDE SVN what I have been working on (with interruptions) for over four months now. After efforts on Kolf 2 have never really lead to something that can be considered a playable game, I’ve now started the harder road, which is to fix Kolf 1. This is so hard because the code of Kolf 1 is structured like a pile of mashed potatoes (read: nearly no structure at all), which even a former maintainer admits.

I started by simplifying awkwardly complicated statements. After some time, code was such that I could actually try to understand what is going on in the big picture. I’m not there, yet; I understand only the graphics stuff and the physics engine at the moment. Another big problem of Kolf is that it has some awkwardly big classes: The central CanvasItem class has no less than 40 virtual methods, and I’m not yet at the point where my refactoring massively reduces this number. The KolfGame class is even worse: By now, it has 39 methods, 30 slots, 17 signals, and 78 private members (of which only some have a “m_” prefix). The central header “game.h” contained over 60 classes when I started the refactoring; I’m now down to about 30 classes by removing an unnecessary parallel object hierarchy.

The biggest problem about Kolf 1, however, is its awkward physics engine. Problems with balls tunneling through walls have been known since KDE 3 times. But no longer! I have ported Kolf 1 to use the Box2D physics engine (which I had previously experimented with in Kolf 2) instead. This kills among other things bug 46532 which has been with us since August 2002.

So, the whole diff weighs in at some +2600/-3000 lines, and has been committed as a series of 55 commits. Great times are coming for Kolf.

Advertisements

3 Responses to “Kolf: The future begins now”

  1. uniq Says:

    My friends love playing golf but are annoyed by the new bugs in Kolf 2 and wanted the older version back. Your news are great and they will look forward to the new good-old Kolf.
    Thanks a lot.

    • Stefan Majewsky Says:

      It’s not as easy as “want the older version back”. The old version (which BTW also had the same collision bugs, although not as bad as in the last releases) was based on KDE 3 rendering technologies. For KDE 4, it was ported to QGraphicsView, and that made some problematic bugs show up which were previously hidden by the combination with the KDE 3 rendering stuff.

      By the way, what ships with KDE 4.x is not Kolf 2, but Kolf 1 (version 1.9 in the 4.5 release). Kolf 2 was an attempt to rewrite Kolf 1 which, as I said, never reached maturity.


  2. Very happy to see this happening, Stefan. It is difficult to take the decision of not working on “your own stuff” and going back to the harder task of fixing someone’s else gigantic pile of code, which has defeated all the previous attempts of taming 🙂 I applaud you for that!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s