From eac2ce116896d1b6801f64f60d07aa2ad6863b56 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Wed, 27 Jun 2018 16:46:26 -0700 Subject: [PATCH 1/3] Tweak this weird hack for the benefit of MSVC. MSVC wrongly complains about the old version: game.cpp(6802): error C2664: 'std::pair std::make_pair(_Ty1,_Ty2)': cannot convert argument 2 from 'hr::eItem' to 'hr::eItem &' with [ _Ty1=hr::cell *&, _Ty2=hr::eItem & ] And MSVC wrongly complains about this alternative: conformal::findhistory.emplace_back(c2, int(c2->item)); error: no matching function for call to 'std::pair::pair(hr::cell*&, int)' And MinGW wrongly complains about these alternatives: game.cpp:6801:49: error: cannot bind bitfield 'c2->hr::cell::.hr::gcell::item' to 'hr::eItem&' conformal::findhistory.emplace_back(c2, c2->item); ~~~~^~~~ game.cpp:6801:47: error: cannot bind bitfield 'c2->hr::cell::.hr::gcell::item' to 'hr::eItem&' conformal::findhistory.push_back({c2, c2->item}); ~~~~^~~~ --- game.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/game.cpp b/game.cpp index 93f68ac2..13dc3c34 100644 --- a/game.cpp +++ b/game.cpp @@ -6822,8 +6822,9 @@ bool collectItem(cell *c2, bool telekinesis) { if(dopickup && c2->item) { #ifdef HASLINEVIEW - // (eItem) to avoid the "cannot bind bitfield" problem in C++11 - conformal::findhistory.push_back(make_pair(c2, (eItem) c2->item)); + // temporary variable to avoid the "cannot bind bitfield" problem in C++11 + eItem dummy = c2->item; + conformal::findhistory.emplace_back(c2, dummy); #endif c2->item = itNone; } From f10f5a29b2f0925b82a28ce59ba7f4bb2a9a7dab Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 7 Jul 2018 10:24:11 -0700 Subject: [PATCH 2/3] Fix a couple of issues in MSVC related to `min` and `max`. MSVC apparently thinks that the result of arithmetic promotions on an `unsigned:4` bitfield is `unsigned`, not `int`; which then causes it to fail to deduce whether the `T` in `min` should be `unsigned` (the type of the LHS) or `int` (the type of the RHS). Clang and GCC agree that the result of arithmetic promotions on an `unsigned:4` bitfield should be `int`, so they don't see any ambiguity here. --- game.cpp | 2 +- sysconfig.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/game.cpp b/game.cpp index 13dc3c34..21d3573d 100644 --- a/game.cpp +++ b/game.cpp @@ -1848,7 +1848,7 @@ void stunMonster(cell *c2) { int newtime = ( c2->monst == moFatGuard ? 2 : c2->monst == moSkeleton && c2->land != laPalace && c2->land != laHalloween ? 7 : - c2->monst == moTerraWarrior ? min(c2->stuntime + 8 - c2->hitpoints, 7) : + c2->monst == moTerraWarrior ? min(int(c2->stuntime + 8 - c2->hitpoints), 7) : isMetalBeast(c2->monst) ? 7 : c2->monst == moTortoise ? 7 : c2->monst == moReptile ? 7 : diff --git a/sysconfig.h b/sysconfig.h index 9abf8826..30833d1d 100644 --- a/sysconfig.h +++ b/sysconfig.h @@ -253,6 +253,7 @@ #if ISWINDOWS #define hyper fake_hyper // avoid "hyper" typedef in <_mingw.h> #define WIN32_LEAN_AND_MEAN // avoid "rad1" macro in +#define NOMINMAX // avoid "min" and "max" macros in #endif #include From de8926ac5d2e8be628a1dd99a6954ee441ffe1ea Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Wed, 27 Jun 2018 17:49:26 -0700 Subject: [PATCH 3/3] Fix some truncation warnings for the benefit of MSVC. rug.cpp(1266): warning C4305: 'argument': truncation from 'double' to 'GLclampf' tour.cpp(629): warning C4305: '=': truncation from 'int' to 'bool' --- mapeditor.cpp | 2 +- rug.cpp | 2 +- tour.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mapeditor.cpp b/mapeditor.cpp index c5642248..6ccfc5fd 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -1601,7 +1601,7 @@ namespace mapeditor { mapeditor::paintwhat_str = "clear monster"; mapeditor::copysource.c = NULL; mapeditor::undo.clear(); - if(!cheater) patterns::displaycodes = 0; + if(!cheater) patterns::displaycodes = false; if(!cheater) patterns::whichShape = 0; modelcell.clear(); }) + diff --git a/rug.cpp b/rug.cpp index 34d86070..2a673e26 100644 --- a/rug.cpp +++ b/rug.cpp @@ -1263,7 +1263,7 @@ void drawRugScene() { glBindTexture( GL_TEXTURE_2D, alternate_texture); if(backcolor == 0) - glClearColor(0.05,0.05,0.05,1); + glClearColor(0.05f,0.05f,0.05f,1.0f); else glhr::colorClear(backcolor << 8 | 0xFF); #ifdef GLES_ONLY diff --git a/tour.cpp b/tour.cpp index e2f79472..16326493 100644 --- a/tour.cpp +++ b/tour.cpp @@ -626,10 +626,10 @@ slide default_slides[] = { [] (presmode mode) { setCanvas(mode, 't'); if(mode == 1) - patterns::displaycodes = 2, + patterns::displaycodes = true, patterns::whichPattern = 'z'; if(mode == 3) - patterns::displaycodes = 0, + patterns::displaycodes = false, patterns::whichPattern = 0; SHOWLAND ( l == laCanvas ); }