Converted many sprintf calls to snprintf.

Converted most of the easy calls of sprintf to snprintf. This is good, because most compilers including MSVC have sprintf deprecated. We have the warnings disabled with the pragmas:
#pragma warning(disable : 4996)

I was concerned that it would slow things down. But I tested it on Windows 8 and Ubuntu, with no difference in CPU or ram utilization.
Blindly replacing sprintf with snprintf doesn't actually fix the potential buffer overflow here.