diff --git a/.vscode/settings.json b/.vscode/settings.json index bca914e0..bb14f73d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -102,7 +102,10 @@ "ranges": "cpp", "span": "cpp", "gsl": "cpp", - "pointers": "cpp" + "pointers": "cpp", + "stacktrace": "cpp", + "assert": "cpp", + "narrow": "cpp" }, "files.trimFinalNewlines": true, "files.insertFinalNewline": true, diff --git a/src/fovtool/main.cpp b/src/fovtool/main.cpp index 5a101150..446f84ba 100644 --- a/src/fovtool/main.cpp +++ b/src/fovtool/main.cpp @@ -43,11 +43,11 @@ static auto load_map(const std::filesystem::path& path) { auto map = MapInfo{ .data = {map_width, map_height}, }; - for (int y = 0; y < lines.size(); ++y) { + for (int y = 0; y < gsl::narrow(lines.size()); ++y) { const auto& line = lines.at(y); for (int x = 0; x < map_width; ++x) { static constexpr auto DEFAULT_CH = '.'; - const auto ch = (gsl::narrow(x) < line.size() ? line.at(x) : DEFAULT_CH); + const auto ch = (x < gsl::narrow(line.size()) ? line.at(x) : DEFAULT_CH); const bool transparent = ch != '#'; map.data.setProperties(x, y, transparent, false); if (ch == '@') { @@ -59,7 +59,7 @@ static auto load_map(const std::filesystem::path& path) { } static auto render_map(const MapInfo& map) { - auto stream = std::basic_ostringstream{}; + auto stream = std::ostringstream{}; for (int y = 0; y < map.data.getHeight(); ++y) { if (y) stream << '\n'; for (int x = 0; x < map.data.getWidth(); ++x) { @@ -72,7 +72,7 @@ static auto render_map(const MapInfo& map) { stream << (visible ? (transparent ? '.' : '#') : (transparent ? ' ' : ' ')); } } - return utf8::utf32to8(stream.rdbuf()->view()); + return stream.rdbuf()->str(); } int main(int argc, char** argv) {