Zynga pirate Tiny Tower
Zynga, as always, have stolen another game to call their own. After failing to acquire the small indie studio of 3, they decided that if can't beat them, steal their games join them.
I suppose being a company of 2700+, ideas are hard to come by.
Scammers are stealing my ideas
Last year I wrote a satirical piece about a single mom inventing cold fusion and defying the laws of physics.
Well apparently the same online scam artists have thought it was a great idea, and are now selling plans for a zero point energy device.
If you want to read the trash they've wrote this time, a Google of the Hojo Motor will surely bring it up. It is only a matter of time now before they start selling off pieces of dinosaur DNA claiming that you too can grow your own Jurassic Park, and Zoo Keepers don't want you to know about this.
Wikipedia Blackout of 2012
Historians in the future will one day look back on this day, and realise that the 18th January 2012, was the most productive day in human history.
The International Obfuscated C Code Contest
I got told about this brilliant bit of code recently. It is a magic eye. Supposedly it will compile with a GCC compiler, I was unable to get it to in Visual Studio.
More similar code is on the official IO CCC website.
SprintfCat
On the train to Cardiff yesterday, I was creating a fixed function shader generator for the Athena engine. I kept using strcat() with if statements, and in a lot of places I kept using sprintf() then copying that in with strcat().
So I decided to make SprintfCat(), all the wonderful joy of sprintf, with the ability to concatenate with a already existant string like strcat.
//
//
size_t ath::SprintfCat( char * inoutBuffer, const size_t inBufferSize, const char * inFormat, ... )
{
const size_t offset = StrLen( inoutBuffer );
size_t ret = 0;
va_list arg;
//
va_start( arg, inFormat );
{
ret = VSprintf( inoutBuffer + offset, inBufferSize - offset, inFormat, arg );
}
va_end( arg );
//
return offset + ret;
}I had already created my own wrappers around strlen() and vsprintf(), the reason being the fault of Microsoft. With their implementation of the standard library, they decided to deprecate non-safe versions complain at you until you either used their own _s variants, or defined a certain preprocessor.
//
//
size_t ath::VSprintf( char * outBuffer, const size_t inBufferSize, const char * inFormat, va_list inArgs )
{
#ifndef ATH_PLATFORM_WINDOWS
return vsnprintf( outBuffer, inBufferSize, inFormat, inArgs );
#else
return vsprintf_s( outBuffer, inBufferSize, inFormat, inArgs );
#endif
}
//
//
size_t ath::StrLen( const char * inString )
{
return strlen( inString );
}While I do prefer to have safe versions, their _s variants are not present in the standard and so it makes the code not portable.
I'm still not quite sure about my naming convention for a variable that is an input and an output. While I do like the in or out prefix, I don't think inout looks right, being slightly too long. I wasn't a fan of io either. I have however grown to like the truncation of Athena namespace to ath.
OpenGL Shader Debugging
One thing that always annoys me with using glGetShaderInfoLog(), is that when compiling OpenGL shaders multiple sources can be used. Because of this, the line numbers get shifted, and trying to find line 123 where a syntax error exists is a length process.
So I made a function that will take the sources list and output the lines with line numbers.
void OutputWithLineNumbers( const char ** inSources, const unsigned int inCount )
{
bool unendedLineNo = false;
int lineNumber = 1;
for( unsigned int i = 0; i < inCount; ++i )
{
const char * cur = inSources[i];
const char * next = NULL;
do
{
//
if( !unendedLineNo )
{
printf( "%04d: ", lineNumber );
}
//
next = strchr( cur, '\r' );
//
if( next )
{
size_t len = ( next - cur );
char * lineText = (char *)alloca( len );
memcpy( lineText, cur, len );
lineText[len] = 0;
printf( "%s\n", lineText );
unendedLineNo = false;
++lineNumber;
}
else
{
printf( "%s", cur );
unendedLineNo = true;
}
//
cur = next + 2;
} while( next );
}
if( unendedLineNo )
{
printf( "\n" );
}
}This code requires the source files to have a carriage return as well as a new line character.


