Fix crash when adding new building, solve warning

1>Fix the bug . Crash when adding new building.
2>Solve  most of the warning like
warning C4800: 'BOOL' : forcing value to bool 'true' or 'false'
(performance warning)
warning C4101: 'crc' : unreferenced local variable
warning C4552: '<' : operator has no effect; expected operator with
side-effect
warning C4018: '<' : signed/unsigned mismatch
and so on....