The previous version [PATCHv4 1/6] conflicted with trunk r9739 ("Fixed some warnings found by Visual Studio's code analysis"). I fixed that and added [PATCHv5 2/8]. I also split [PATCHv4 1/6] into [PATCHv5 1/8] and [PATCHv5 3/8].

The first five patches in this series could be applied to boswars-1.6. The last three however will cause sync errors in network games with 1.6, so those should go in trunk only.