glob2-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [glob2-devel] the mess in GameGUI.cpp (was: Ugly code in glob2 hg)


From: Stéphane Magnenat
Subject: Re: [glob2-devel] the mess in GameGUI.cpp (was: Ugly code in glob2 hg)
Date: Wed, 4 Jul 2007 22:04:20 +0200
User-agent: KMail/1.9.7

> I'm happy to use whatever whitespace rules there are provided the
> rules are actually written down somewhere!  I could not find the
> whitespace rules written anywhere.

http://www.globulation2.org/wiki/CodingConventions

> The entire GameGUI.cpp file is a horrible mess.  For example, in
> addition to the complaints you made above, there are magic constants
> everywhere.  Just one example of this is all the places where numbers
> are shifted by 5 or 6 bits to convert between game cell positions and
> pixel positions.  And the number 1024 (the size of the unit and
> building arrays) is all over the place in this and other files
> (sometimes in the form of a bitmask 0x3FF).  And the pixel width of
> the control panel on the right is hard-coded everywhere, as well as
> the positions of all of the buttons in the panel.  And there are lots
> of other similar issues.  Why aren't these magic numbers (5, 6, 1024,
> etc.) abstracted away in (inline) methods or at least constant
> definitions?

You are totally correct, we should really clean this file :-)
GameGUI.cpp is like a garbage collector, which never throws garbage out ;-(
We could remove the "if"s by a map of keycode to pointers to member functions.

Have a nice day,

Steph

-- 
http://stephane.magnenat.net




reply via email to

[Prev in Thread] Current Thread [Next in Thread]