Fix various compiler warnings on MSVC
I tried to avoid casts whereever it was possible, but for some cases it wasn't.
This commit is contained in:
parent
fade10aa1b
commit
445071cad5
@ -142,8 +142,8 @@ public:
|
|||||||
NodeCoordHashed(const BlockPos &pos) : NodeCoord(pos) { rehash(); }
|
NodeCoordHashed(const BlockPos &pos) : NodeCoord(pos) { rehash(); }
|
||||||
NodeCoordHashed(const NodeCoord &coord) : NodeCoord(coord) { rehash(); }
|
NodeCoordHashed(const NodeCoord &coord) : NodeCoord(coord) { rehash(); }
|
||||||
void rehash(void) { m_hash = NodeCoord::hash(); }
|
void rehash(void) { m_hash = NodeCoord::hash(); }
|
||||||
unsigned hash(void) { rehash(); return m_hash; }
|
size_t hash(void) { rehash(); return m_hash; }
|
||||||
unsigned hash(void) const { return m_hash; }
|
size_t hash(void) const { return m_hash; }
|
||||||
bool operator==(const NodeCoordHashed &coord) const { if (m_hash != coord.m_hash) return false; return NodeCoord::operator==(coord); }
|
bool operator==(const NodeCoordHashed &coord) const { if (m_hash != coord.m_hash) return false; return NodeCoord::operator==(coord); }
|
||||||
void operator=(const NodeCoord &coord) { NodeCoord::operator=(coord); rehash(); }
|
void operator=(const NodeCoord &coord) { NodeCoord::operator=(coord); rehash(); }
|
||||||
bool operator<(const NodeCoordHashed &coord) { return m_hash < coord.m_hash; }
|
bool operator<(const NodeCoordHashed &coord) { return m_hash < coord.m_hash; }
|
||||||
|
@ -2214,8 +2214,8 @@ void TileGenerator::renderHeightScale()
|
|||||||
Color color = computeMapHeightColor(int(height + 0.5));
|
Color color = computeMapHeightColor(int(height + 0.5));
|
||||||
gdImageLine(m_image, xBorderOffset + x, yBorderOffset + 8, xBorderOffset + x, yBorderOffset + borderBottom() - 20, color.to_libgd());
|
gdImageLine(m_image, xBorderOffset + x, yBorderOffset + 8, xBorderOffset + x, yBorderOffset + borderBottom() - 20, color.to_libgd());
|
||||||
|
|
||||||
int iheight = int(height + (height > 0 ? 0.5 : -0.5));
|
int iheight = static_cast<int>(height + (height > 0 ? 0.5 : -0.5));
|
||||||
int iheightMaj = int(iheight / major + (height > 0 ? 0.5 : -0.5)) * major;
|
int iheightMaj = static_cast<int>(trunc(iheight / major + (height > 0 ? 0.5 : -0.5)) * major);
|
||||||
if (fabs(height - iheightMaj) <= height_step / 2 && (height - iheightMaj) > -height_step / 2) {
|
if (fabs(height - iheightMaj) <= height_step / 2 && (height - iheightMaj) > -height_step / 2) {
|
||||||
if (iheightMaj / int(major) % 2 == 1 && fabs(height) > 9999 && major / height_step < 56) {
|
if (iheightMaj / int(major) % 2 == 1 && fabs(height) > 9999 && major / height_step < 56) {
|
||||||
// Maybe not enough room for the number. Draw a tick mark instead
|
// Maybe not enough room for the number. Draw a tick mark instead
|
||||||
@ -2252,8 +2252,8 @@ void TileGenerator::renderPlayers(const std::string &inputPath)
|
|||||||
|
|
||||||
PlayerAttributes players(inputPath);
|
PlayerAttributes players(inputPath);
|
||||||
for (PlayerAttributes::Players::iterator player = players.begin(); player != players.end(); ++player) {
|
for (PlayerAttributes::Players::iterator player = players.begin(); player != players.end(); ++player) {
|
||||||
int imageX = worldX2ImageX(player->x / 10);
|
int imageX = worldX2ImageX(static_cast<int>(player->x / 10));
|
||||||
int imageY = worldZ2ImageY(player->z / 10);
|
int imageY = worldZ2ImageY(static_cast<int>(player->z / 10));
|
||||||
std::string displayName = m_gdStringConv->convert(player->name);
|
std::string displayName = m_gdStringConv->convert(player->name);
|
||||||
|
|
||||||
gdImageArc(m_image, imageX, imageY, 5, 5, 0, 360, color);
|
gdImageArc(m_image, imageX, imageY, 5, 5, 0, 360, color);
|
||||||
|
@ -46,7 +46,7 @@ ustring ZlibDecompressor::decompress()
|
|||||||
strm.zfree = Z_NULL;
|
strm.zfree = Z_NULL;
|
||||||
strm.opaque = Z_NULL;
|
strm.opaque = Z_NULL;
|
||||||
strm.next_in = Z_NULL;
|
strm.next_in = Z_NULL;
|
||||||
strm.avail_in = size;
|
strm.avail_in = static_cast<uInt>(size);
|
||||||
|
|
||||||
if (inflateInit(&strm) != Z_OK) {
|
if (inflateInit(&strm) != Z_OK) {
|
||||||
throw DecompressError(strm.msg);
|
throw DecompressError(strm.msg);
|
||||||
|
@ -49,6 +49,7 @@ using namespace std;
|
|||||||
#define DRAW_ARROW_LENGTH 10
|
#define DRAW_ARROW_LENGTH 10
|
||||||
#define DRAW_ARROW_ANGLE 30
|
#define DRAW_ARROW_ANGLE 30
|
||||||
|
|
||||||
|
|
||||||
// Will be replaced with the actual name and location of the executable (if found)
|
// Will be replaced with the actual name and location of the executable (if found)
|
||||||
string executableName = "minetestmapper";
|
string executableName = "minetestmapper";
|
||||||
string executablePath; // ONLY for use on windows
|
string executablePath; // ONLY for use on windows
|
||||||
@ -497,7 +498,7 @@ static void orderCoordinateDimensions(NodeCoord &coord1, NodeCoord &coord2, int
|
|||||||
// <x>,<y>@<angle>+<length>
|
// <x>,<y>@<angle>+<length>
|
||||||
static bool parseGeometry(istream &is, NodeCoord &coord1, NodeCoord &coord2, NodeCoord &dimensions, bool &legacy, bool ¢ered, int n, FuzzyBool expectDimensions, int wildcard = 0)
|
static bool parseGeometry(istream &is, NodeCoord &coord1, NodeCoord &coord2, NodeCoord &dimensions, bool &legacy, bool ¢ered, int n, FuzzyBool expectDimensions, int wildcard = 0)
|
||||||
{
|
{
|
||||||
int pos;
|
std::streamoff pos;
|
||||||
pos = is.tellg();
|
pos = is.tellg();
|
||||||
legacy = false;
|
legacy = false;
|
||||||
|
|
||||||
@ -871,7 +872,7 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case OPT_HEIGHTMAPYSCALE:
|
case OPT_HEIGHTMAPYSCALE:
|
||||||
if (isdigit(optarg[0]) || ((optarg[0]=='-' || optarg[0]=='+') && isdigit(optarg[1]))) {
|
if (isdigit(optarg[0]) || ((optarg[0]=='-' || optarg[0]=='+') && isdigit(optarg[1]))) {
|
||||||
float scale = atof(optarg);
|
float scale = static_cast<float>(atof(optarg));
|
||||||
generator.setHeightMapYScale(scale);
|
generator.setHeightMapYScale(scale);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -34,15 +34,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
static inline int unsigned_to_signed(unsigned i, unsigned max_positive)
|
static inline int unsigned_to_signed(unsigned i, unsigned max_positive)
|
||||||
{
|
{
|
||||||
if (i < max_positive) {
|
if (i < max_positive) {
|
||||||
return i;
|
return static_cast<int>(i);
|
||||||
} else {
|
} else {
|
||||||
return i - (max_positive * 2);
|
return static_cast<int>(i - (max_positive * 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Modulo of a negative number does not work consistently in C
|
// Modulo of a negative number does not work consistently in C
|
||||||
static inline int64_t pythonmodulo(int64_t i, int16_t mod)
|
static inline unsigned pythonmodulo(int64_t i, unsigned mod)
|
||||||
{
|
{
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
return i % mod;
|
return i % mod;
|
||||||
|
4
util.h
4
util.h
@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
inline std::string strlower(const std::string &s)
|
inline std::string strlower(const std::string &s)
|
||||||
{
|
{
|
||||||
int l = s.length();
|
size_t l = s.length();
|
||||||
std::string sl = s;
|
std::string sl = s;
|
||||||
for (int i = 0; i < l; i++)
|
for (size_t i = 0; i < l; i++)
|
||||||
sl[i] = tolower(sl[i]);
|
sl[i] = tolower(sl[i]);
|
||||||
return sl;
|
return sl;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user