Fix an if statement getting moved into a loop it shouldn't have

Found by coverity code analysis.
Move assignment to before break, hopefully this doesn't break stuff
Initialize some stuff to 0 before taking their address
Some fixes found by coverity for things used before a null check

In the second case, we actually check the wrong variable.
Fix some compiler warnings for ShowMenu