Epic failures in the game development field.

This blog covers funny/weird issues and bugs from games that happened during development.

Send your own contributions to igetyourfail at repi.se (can be anonymous if specified)

Friday, July 3, 2009

isNumber - Special optimized version


bool isNumber(const char number)
{
std::string tmp;

tmp += number;

return std::string::npos != findIgnoreCase("0123456789", tmp);
}

4 comments:

grisom said...

*facepalm* Man, this is WAY too familiar. I can't get over the call to findIgnoreCase()!

poweld said...

This is easily the best post I've seen to date on this blog.

Whoever wrote that should never again be allowed near source code.

The whole thing (short as it is) is a menagerie of fail, but possibly my favorite mindfuck is is that the passed in character is being checked for being a number, yet the author got a little ahead of himself and called the character var "number".

I'll admit, that tripped up even me. I thought at first he/she was running the + operator on a string with RHS being an integer.

*brain melts, oozes out of skull*

xunter said...

I saw _better_ variant =)

bool IsDigit(char c)
{
String str("012345679"); // no '8' !!!
return str.SubstrIndex(String(c)) != -1;
}

xunter said...

I saw _better_ variant =)

bool IsDigit(char c)
{
String str("012345679"); // no '8' !!!
return str.SubstrIndex(String(c)) != -1;
}

Followers