Crappy Code 1: Goto Hell!

Recently I found this little jewel in some commercial UI plug-in for the Unity3D engine:

Now don’t tell me you couldn’t do this in any other way, knowing that the Invoke jump label isn’t used anywhere else.

Fun fact: Visual Studio doesn’t even know how to deal with that – Find All References of Invoke returns a stumped “Search found no results.” 😉

Crappy Code 0: Display Resolution

Every programmer knows these moments. You come across those few lines of code that make you think: “Whoops…”. Or better: “Wat.” Most often this code is the result of crazy deadlines or massive refactoring of other parts of the application – or just simple stupidity.

Sometimes this code is your own.

In order to share these great moments with you, I decided to start a series I’d like to call Crappy Code. Should you ever run into any code that you think could fit this category, feel free to send me a mail to crappycode(at)npruehs(dot)de.

Let’s start right away with this little jewel: The first part of this series is about a piece of Python code that is ought to adapt the size of some buttons to the current display resolution.

 Wat.

This is the pure opposite of a resolution-independent UI. In fact this code has been taken from a game that was originally designed to be played with two resolutions, only: 1024×768 and 1280×800. Unfortunately, I got honored by the task to make the game look somehow good on laptops now, which – who’d have thought – includes other resolutions as well.

Second point: Where do all these strange numbers come from? What the frack is 0.352 * 0.95?

Ah. Yes. It’s 0.3344. I see 😉