diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index b1b4da836..5d4533061 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -1353,7 +1353,7 @@ void GameSave::readPSv(const std::vector &dataVec) if (p >= dataLength) throw ParseException(ParseException::Corrupt, "Not enough data at line " MTOS(__LINE__) " in " MTOS(__FILE__)); auto j=data[p++]; - if (j >= PT_NUM) { + if (int(j) >= PT_NUM) { // not possible these days since PMAPBITS >= 8 j = PT_DUST;//throw ParseException(ParseException::Corrupt, "Not enough data at line " MTOS(__LINE__) " in " MTOS(__FILE__)); } if (j) diff --git a/src/graphics/Graphics.cpp b/src/graphics/Graphics.cpp index 8b7828b71..47165091b 100644 --- a/src/graphics/Graphics.cpp +++ b/src/graphics/Graphics.cpp @@ -123,7 +123,7 @@ void VideoBuffer::Resize(Vec2 size, bool resample) void VideoBuffer::Resize(float factor, bool resample) { - Resize(Vec2(Size() * factor), resample); + Resize(Vec2{ int(Size().X * factor), int(Size().Y * factor) }, resample); } void VideoBuffer::ResizeToFit(Vec2 bound, bool resample) @@ -135,9 +135,9 @@ void VideoBuffer::ResizeToFit(Vec2 bound, bool resample) return a / b + ((a % b) ? 1 : 0); }; if (bound.X * size.Y < bound.Y * size.X) - size = { ceilDiv(size.X * bound.X, size.X), ceilDiv(size.Y * bound.X, size.X) }; + size = { bound.X, ceilDiv(size.Y * bound.X, size.X) }; else - size = { ceilDiv(size.X * bound.Y, size.Y), ceilDiv(size.Y * bound.Y, size.Y) }; + size = { ceilDiv(size.X * bound.Y, size.Y), bound.Y }; } Resize(size, resample); } @@ -165,7 +165,7 @@ std::vector VideoBuffer::ToPPM() const return format::PixelsToPPM(video); } -template class RasterDrawMethods; +template struct RasterDrawMethods; Graphics::Graphics() {} @@ -483,7 +483,7 @@ std::vector> Graphics::Gradient(std::vector stops, in auto &left = stops[stop]; auto &right = stops[stop + 1]; auto f = (point - left.point) / (right.point - left.point); - table[i] = left.color.Blend(right.color.WithAlpha(f * 0xFF)); + table[i] = left.color.Blend(right.color.WithAlpha(uint8_t(f * 0xFF))); } } return table; diff --git a/src/graphics/RasterGraphics.cpp b/src/graphics/RasterGraphics.cpp index eb50fe70b..22acce632 100644 --- a/src/graphics/RasterGraphics.cpp +++ b/src/graphics/RasterGraphics.cpp @@ -9,4 +9,4 @@ void Graphics::Finalise() } -template class RasterDrawMethods; +template struct RasterDrawMethods; diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index 513aff724..9e9a5742e 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -9,9 +9,6 @@ #include "simulation/gravity/Gravity.h" #include -constexpr auto VIDXRES = WINDOWW; -// constexpr auto VIDYRES = WINDOWH; // not actually used anywhere - std::unique_ptr Renderer::WallIcon(int wallID, Vec2 size) { auto wtypes = LoadWalls(); @@ -1191,8 +1188,8 @@ int HeatToColour(float temp) constexpr float min_temp = MIN_TEMP; constexpr float max_temp = MAX_TEMP; RGB color = Renderer::heatTableAt(int((temp - min_temp) / (max_temp - min_temp) * 1024)); - color.Red *= 0.7f; - color.Green *= 0.7f; - color.Blue *= 0.7f; + color.Red = uint8_t(color.Red * 0.7f); + color.Green = uint8_t(color.Green * 0.7f); + color.Blue = uint8_t(color.Blue * 0.7f); return color.Pack(); } diff --git a/src/graphics/RendererBasic.cpp b/src/graphics/RendererBasic.cpp index edf0c6568..c9013d73c 100644 --- a/src/graphics/RendererBasic.cpp +++ b/src/graphics/RendererBasic.cpp @@ -472,4 +472,4 @@ Renderer::~Renderer() delete[] graphicscache; } -template class RasterDrawMethods; +template struct RasterDrawMethods; diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index bdc1028c9..799801f53 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -572,7 +572,7 @@ bool GameController::TextEditing(String text) bool GameController::KeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) { - bool ret = commandInterface->HandleEvent(KeyPressEvent{ key, scan, repeat, shift, ctrl, alt }); + bool ret = commandInterface->HandleEvent(KeyPressEvent{ { key, scan, repeat, shift, ctrl, alt } }); if (repeat) return ret; if (ret) @@ -651,7 +651,7 @@ bool GameController::KeyPress(int key, int scan, bool repeat, bool shift, bool c bool GameController::KeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) { - bool ret = commandInterface->HandleEvent(KeyReleaseEvent{ key, scan, repeat, shift, ctrl, alt }); + bool ret = commandInterface->HandleEvent(KeyReleaseEvent{ { key, scan, repeat, shift, ctrl, alt } }); if (repeat) return ret; if (ret) diff --git a/src/gui/interface/Engine.cpp b/src/gui/interface/Engine.cpp index 431782cad..57b27900e 100644 --- a/src/gui/interface/Engine.cpp +++ b/src/gui/interface/Engine.cpp @@ -181,7 +181,7 @@ void Engine::Draw() if (frozen.fadeTicks <= maxFadeTicks) { // from 0x00 at 0 to about 0x54 at 20 - uint8_t alpha = (1 - std::pow(0.98, frozen.fadeTicks)) * 0xFF; + auto alpha = uint8_t((1 - std::pow(0.98, frozen.fadeTicks)) * 0xFF); g->BlendFilledRect(g->Size().OriginRect(), 0x000000_rgb .WithAlpha(alpha)); } // If this is the last frame in the fade, save what the faded image looks like diff --git a/src/lua/LuaLuna.h b/src/lua/LuaLuna.h index 39bbffe5a..9a7ec13be 100644 --- a/src/lua/LuaLuna.h +++ b/src/lua/LuaLuna.h @@ -151,7 +151,7 @@ private: char buff[32]; userdataType *ud = static_cast(lua_touserdata(L, 1)); T *obj = ud->pT; - sprintf(buff, "%p", obj); + snprintf(buff, sizeof(buff), "%p", obj); lua_pushfstring(L, "%s (%s)", T::className, buff); return 1; } diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index cde923fd8..311b1191a 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -1860,7 +1860,7 @@ int LuaScriptInterface::simulation_decoColor(lua_State * l) return 1; } else if (acount == 1) - color = RGBA::Unpack(luaL_optnumber(l, 1, 0xFFFF0000)); + color = RGBA::Unpack(pixel_rgba(luaL_optnumber(l, 1, 0xFFFF0000))); else { color.Red = std::clamp(luaL_optint(l, 1, 255), 0, 255); @@ -2277,7 +2277,7 @@ int LuaScriptInterface::simulation_brush(lua_State * l) std::vector points; std::copy(newBrush->begin(), newBrush->end(), std::back_inserter(points)); lua_pushnumber(l, 0); // index - lua_pushnumber(l, points.size()); + lua_pushnumber(l, int(points.size())); auto points_ud = reinterpret_cast(lua_newuserdata(l, points.size() * sizeof(ui::Point))); std::copy(points.begin(), points.end(), points_ud); diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index c852a2dfd..7524d5afb 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -765,7 +765,7 @@ bool Simulation::flood_water(int x, int y, int i) else if (!eval_move(parts[i].type, x, y - 1, nullptr)) continue; - move(i, originalX, originalY, x, y - 1); + move(i, originalX, originalY, float(x), float(y - 1)); return true; } @@ -2287,7 +2287,7 @@ void Simulation::delete_part(int x, int y)//calls kill_part with the particle lo void Simulation::UpdateParticles(int start, int end) { - int i, j, x, y, t, nx, ny, r, surround_space, s, rt, nt; + int i, j, x, y, t, r, surround_space, s, rt, nt; float mv, dx, dy, nrx, nry, dp, ctemph, ctempl, gravtot; int fin_x, fin_y, clear_x, clear_y, stagnant; float fin_xf, fin_yf, clear_xf, clear_yf; @@ -2406,8 +2406,8 @@ void Simulation::UpdateParticles(int start, int end) transitionOccurred = false; j = surround_space = nt = 0;//if nt is greater than 1 after this, then there is a particle around the current particle, that is NOT the current particle's type, for water movement. - for (nx=-1; nx<2; nx++) - for (ny=-1; ny<2; ny++) { + for (auto nx=-1; nx<2; nx++) + for (auto ny=-1; ny<2; ny++) { if (nx||ny) { surround[j] = r = pmap[y+ny][x+nx]; j++; @@ -2804,14 +2804,14 @@ void Simulation::UpdateParticles(int start, int end) //spark updates from walls if ((elements[t].Properties&PROP_CONDUCTS) || t==PT_SPRK) { - nx = x % CELL; + auto nx = x % CELL; if (nx == 0) nx = x/CELL - 1; else if (nx == CELL-1) nx = x/CELL + 1; else nx = x/CELL; - ny = y % CELL; + auto ny = y % CELL; if (ny == 0) ny = y/CELL - 1; else if (ny == CELL-1) @@ -3300,6 +3300,7 @@ killed: if (t==PT_GEL) rt = int(parts[i].tmp*0.20f+5.0f); + auto nx = -1, ny = -1; for (j=clear_x+r; j>=0 && j>=clear_x-rt && jfighters[(unsigned char)parts[i].tmp]; - int tarx, tary; + int tarx = 0, tary = 0; parts[i].tmp2 = 0; //0 - stay in place, 1 - seek a stick man diff --git a/src/simulation/elements/SING.cpp b/src/simulation/elements/SING.cpp index 69406656f..378527a69 100644 --- a/src/simulation/elements/SING.cpp +++ b/src/simulation/elements/SING.cpp @@ -49,7 +49,7 @@ void Element::Element_SING() static int update(UPDATE_FUNC_ARGS) { - int r, rx, ry, cry, crx, nb, spawncount; + int r, rx, ry, cry, crx, spawncount; int singularity = -parts[i].life; float angle, v; @@ -80,6 +80,7 @@ static int update(UPDATE_FUNC_ARGS) spawncount = (spawncount>255) ? 3019 : int(std::pow((double)(spawncount/8), 2)*TPT_PI_FLT); for (int j = 0;j < spawncount; j++) { + auto nb = -1; switch (sim->rng.gen() % 3) { case 0: