Core/Players: Prevent trading, taking gold from mail and withdrawing from guild bank if it would put the player over gold cap.

Closes #4015
Core/Misc: Fixed a few warning found by static analysis tools.