From 51ebae5c046ed6c36e925c904a29a4e754b9611a Mon Sep 17 00:00:00 2001 From: squishy Date: Mon, 1 Apr 2024 00:19:57 +0000 Subject: [PATCH] fixed clang warnings --- blooblib/src/draw/draw_image.cpp | 2 +- blooblib/src/draw/upscale.cpp | 4 ++++ blooblib/src/font.cpp | 4 +--- blooblib/src/game.cpp | 5 ++--- blooblib/src/image.cpp | 12 ++++++------ blooblib/src/ini.cpp | 3 ++- blooblib/src/stb_image.h | 1 + test/test.cpp | 2 +- 8 files changed, 18 insertions(+), 15 deletions(-) diff --git a/blooblib/src/draw/draw_image.cpp b/blooblib/src/draw/draw_image.cpp index a1f6534..f44a886 100644 --- a/blooblib/src/draw/draw_image.cpp +++ b/blooblib/src/draw/draw_image.cpp @@ -133,7 +133,7 @@ void image::draw_rot(image const* image, vec2i pos, recti src_rect, double rot) } for(int y = 0; y <= end.y - start.y; ++y) { - auto yf = static_cast(y) / crop.size.y * 2 - 1; + //auto yf = static_cast(y) / crop.size.y * 2 - 1; for(int x = 0; x <= end.x - start.x; ++x) { double xf, yf; int nx, ny; diff --git a/blooblib/src/draw/upscale.cpp b/blooblib/src/draw/upscale.cpp index b8e4477..cccf9b4 100644 --- a/blooblib/src/draw/upscale.cpp +++ b/blooblib/src/draw/upscale.cpp @@ -18,6 +18,8 @@ for(int y = 0; y < s.y; ++y) {\ color in_t, in_b, in_l, in_r, in_m;\ color in_tl, in_tr, in_bl, in_br;\ color out_tl, out_tr, out_bl, out_br;\ + (void)in_t; (void)in_b; (void)in_l; (void)in_r; (void)in_m;\ + (void)in_tl; (void)in_tr; (void)in_bl; (void)in_br;\ in_t = img->get_safe(vec2i(x, y - 1));\ in_b = img->get_safe(vec2i(x, y + 1));\ in_l = img->get_safe(vec2i(x - 1, y));\ @@ -44,6 +46,8 @@ for(int y = 0; y < s.y; ++y) {\ color in_tl, in_tr, in_bl, in_br;\ color out_t, out_b, out_l, out_r, out_m;\ color out_tl, out_tr, out_bl, out_br;\ + (void)in_t; (void)in_b; (void)in_l; (void)in_r; (void)in_m;\ + (void)in_tl; (void)in_tr; (void)in_bl; (void)in_br;\ in_t = img->get_safe(vec2i(x, y - 1));\ in_b = img->get_safe(vec2i(x, y + 1));\ in_l = img->get_safe(vec2i(x - 1, y));\ diff --git a/blooblib/src/font.cpp b/blooblib/src/font.cpp index 9762de8..06991e2 100644 --- a/blooblib/src/font.cpp +++ b/blooblib/src/font.cpp @@ -8,7 +8,7 @@ font::font(resource_manager& rm, ini_category const* ini, std::string const& pat throw std::runtime_error("font needs assets.ini"); if(ini->get("proportional")) { auto image = rm.get<::image>(path); - auto x = 0; + //auto x = 0; std::vector slices; for(int i = 0; i < image->size().x; ++i) { if(image->get(vec2i(i, 0)) & 0xff000000) @@ -28,8 +28,6 @@ font::font(resource_manager& rm, ini_category const* ini, std::string const& pat _glyphs.at(ch).draw(image, vec2i::zero, r); } } else { - int width = ini->get("tile_width"); - int height = ini->get("tile_height"); auto ts = rm.get(path); _lineheight = ts->_tile_size.y; for(int i = 0; i < 256; ++i) { diff --git a/blooblib/src/game.cpp b/blooblib/src/game.cpp index 6f40811..e59cdb5 100644 --- a/blooblib/src/game.cpp +++ b/blooblib/src/game.cpp @@ -17,7 +17,7 @@ LRESULT WINAPI wnd_proc(HWND window, UINT msg, WPARAM w, LPARAM l) { return ::DefWindowProc(window, msg, w, l); } -game::game(int argc, char** argv) : _cursor(0), _argc(argc), _argv(argv), _rm(argc, argv) { +game::game(int argc, char** argv) : _cursor(0), _rm(argc, argv), _argc(argc), _argv(argv) { std::cout << "a\n"; } @@ -36,7 +36,7 @@ void game::run() { .lpszClassName = title.c_str(), }; - auto atom = RegisterClass(&wc); + RegisterClass(&wc); auto window = CreateWindow( wc.lpszClassName, title.c_str(), @@ -196,7 +196,6 @@ void play_logo(HWND window, image const* logo, image const* logo_slime) { screen.blend_to(0x0, 2.0 - (frames / 30.0)); if(frames < 30) screen.clear(0); - auto p = screen.raw_pointer(); window_image.draw_upscaled(&screen, upscaler::scale3x); diff --git a/blooblib/src/image.cpp b/blooblib/src/image.cpp index a7c3559..3b61a1b 100644 --- a/blooblib/src/image.cpp +++ b/blooblib/src/image.cpp @@ -23,24 +23,24 @@ image::image(resource_manager& rm, ini_category const* ini, std::string const& p } image::image(vec2i size) : + _alpha(true), _borrowed_pointer(false), _data(new color[size.size()]), - _bounds(vec2i::zero, size), - _alpha(true) + _bounds(vec2i::zero, size) {} image::image(vec2i size, color* data) : + _alpha(true), _borrowed_pointer(true), _data(data), - _bounds(vec2i::zero, size), - _alpha(true) + _bounds(vec2i::zero, size) {} image::image(image const& other) : + _alpha(other._alpha), _borrowed_pointer(false), _data(new color[other.size().size()]), - _bounds(other.bounds()), - _alpha(other._alpha) + _bounds(other.bounds()) { std::memcpy(_data, other._data, size().size() * 4); } diff --git a/blooblib/src/ini.cpp b/blooblib/src/ini.cpp index eaf3b1a..d8a7599 100644 --- a/blooblib/src/ini.cpp +++ b/blooblib/src/ini.cpp @@ -2,12 +2,13 @@ #include "util.h" ini_category const ini_category::empty; +std::string empty_str(""); std::string const& ini_category::get_string(std::string const& entry) const { if(_data.contains(entry)) return _data.at(entry); - return std::string(""); + return empty_str; } ini::ini(resource_manager& rm, ini_category const* ini, std::string const& path, std::vector data) { diff --git a/blooblib/src/stb_image.h b/blooblib/src/stb_image.h index d1b34fa..b84a4b6 100644 --- a/blooblib/src/stb_image.h +++ b/blooblib/src/stb_image.h @@ -1,3 +1,4 @@ +#pragma clang system_header /* stb_image - v2.29 - public domain image loader - http://nothings.org/stb no warranty implied; use at your own risk diff --git a/test/test.cpp b/test/test.cpp index 12c6c8c..8872a67 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -51,7 +51,7 @@ void my_game::render(image& target) { //target.draw_rot(slime, vec2i(200, 200), time); //target.draw(slime, vec2i(40, 40)); //target.draw(tileset[0xda], vec2i(320, 180) + pos, 0xff00ff); - auto str = "Can only be played if\nthere are no card in\nyour draw pile.\nDeal 50 damage to ALL\nenemies."; + //auto str = "Can only be played if\nthere are no card in\nyour draw pile.\nDeal 50 damage to ALL\nenemies."; //target.draw(str, vec2i(100, 100) + pos, font, 0xffffff, 0); target.draw(bg, vec2i::zero); target.draw(std::format("FPS: {}", fps()), vec2i(10, 10), font1, 0xffffff, 0);