Make the gamelogic compile in C++

Involves a lot of casts, it could have been done in a smarter way, sometimes.