diff --git a/CMakeLists.txt b/CMakeLists.txt index e7182fa..29c341b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,7 +123,7 @@ endif() IF(NOT WIN32) target_link_libraries(${EXECUTABLE_NAME} voronoi noise imgui sw Threads::Threads stdc++fs) else() - target_link_libraries(${EXECUTABLE_NAME} voronoi "${PROJECT_BINARY_DIR}/include/libnoise.lib" imgui sw Threads::Threads stdc++fs) + target_link_libraries(${EXECUTABLE_NAME} voronoi "${PROJECT_BINARY_DIR}/include/libnoise.lib" imgui sw Threads::Threads) endif() target_compile_features(mapgen PRIVATE cxx_delegating_constructors) diff --git a/include/mapgen/Biom.hpp b/include/mapgen/Biom.hpp index 7f41103..8611e45 100644 --- a/include/mapgen/Biom.hpp +++ b/include/mapgen/Biom.hpp @@ -19,33 +19,33 @@ namespace biom { const float DEFAULT_HUMIDITY = 0.f; const float DEFAULT_TEMPERATURE = 30.f; - const Biom ABYSS = {-2.0000, sf::Color(23, 23, 40), "Abyss", 0}; - const Biom DEEP = {-1.0000, sf::Color(39, 39, 70), "Deep", 0}; - const Biom SHALLOW = {-0.2500, sf::Color(51, 51, 91), "Shallow", 0}; - const Biom SHORE = {0.0000, sf::Color(68, 99, 130), "Shore", 0}; + const Biom ABYSS = {-2.0000f, sf::Color(23, 23, 40), "Abyss", 0.f}; + const Biom DEEP = {-1.0000f, sf::Color(39, 39, 70), "Deep", 0.f}; + const Biom SHALLOW = {-0.2500f, sf::Color(51, 51, 91), "Shallow", 0.f}; + const Biom SHORE = {0.0000f, sf::Color(68, 99, 130), "Shore", 0.f}; // const Biom SAND = {0.0625, sf::Color(255,255,255), "Sand", 0}; - const Biom SAND = {0.0625, sf::Color(210, 185, 139), "Sand", 0}; - const Biom GRASS = {0.1250, sf::Color(136, 170, 85), "Grass", 0.8}; - const Biom FORREST = {0.3750, sf::Color(51, 119, 85), "Forrest", 0.6}; - const Biom ROCK = {0.7500, sf::Color(148, 148, 148), "Rock", 0}; - const Biom SNOW = {1.0000, sf::Color(240, 240, 240), "Snow", 0}; - const Biom ICE = {1.2000, sf::Color(220, 220, 255), "Ice", 0}; - const Biom PRAIRIE = {999.000, sf::Color(239, 220, 124), "Prairie", 0.6}; - const Biom MEADOW = {999.000, sf::Color(126, 190, 75), "Meadow", 1}; - const Biom DESERT = {999.000, sf::Color(244, 164, 96), "Desert", 0}; - const Biom CITY = {999.000, sf::Color(220, 220, 220), "City", 0}; + const Biom SAND = {0.0625f, sf::Color(210, 185, 139), "Sand", 0.f}; + const Biom GRASS = {0.1250f, sf::Color(136, 170, 85), "Grass", 0.8f}; + const Biom FORREST = {0.3750f, sf::Color(51, 119, 85), "Forrest", 0.6f}; + const Biom ROCK = {0.7500f, sf::Color(148, 148, 148), "Rock", 0.f}; + const Biom SNOW = {1.0000f, sf::Color(240, 240, 240), "Snow", 0.f}; + const Biom ICE = {1.2000f, sf::Color(220, 220, 255), "Ice", 0.f}; + const Biom PRAIRIE = {999.000f, sf::Color(239, 220, 124), "Prairie", 0.6f}; + const Biom MEADOW = {999.000f, sf::Color(126, 190, 75), "Meadow", 1.f}; + const Biom DESERT = {999.000f, sf::Color(244, 164, 96), "Desert", 0.f}; + const Biom CITY = {999.000f, sf::Color(220, 220, 220), "City", 0.f}; - const Biom RAIN_FORREST = {0.3750, sf::Color(51, 90, 75), "Rain forrest", 0.6}; + const Biom RAIN_FORREST = {0.3750f, sf::Color(51, 90, 75), "Rain forrest", 0.6f}; const std::vector BIOMS = { {ABYSS, DEEP, SHALLOW, SHORE, SAND, GRASS, FORREST, ROCK, SNOW, ICE}}; - const Biom LAKE = {999.000, sf::Color(51, 51, 91), "Lake", 0}; - const Biom MARK = {999.000, sf::Color::Red, "Mark"}; - const Biom MARK2 = {999.000, sf::Color::Black, "Mark"}; + const Biom LAKE = {999.000f, sf::Color(51, 51, 91), "Lake", 0.f}; + const Biom MARK = {999.000f, sf::Color::Red, "Mark"}; + const Biom MARK2 = {999.000f, sf::Color::Black, "Mark"}; - const Biom LAND = {0.500, sf::Color(136, 170, 85), "Land", 0}; - const Biom SEA = {-1.000, sf::Color(39, 39, 70), "Sea", 0}; + const Biom LAND = {0.500f, sf::Color(136, 170, 85), "Land", 0.f}; + const Biom SEA = {-1.000f, sf::Color(39, 39, 70), "Sea", 0.f}; const std::vector> BIOMS_BY_HEIGHT = {{ {ABYSS}, diff --git a/include/mapgen/Economy.hpp b/include/mapgen/Economy.hpp index 9316361..d6fc44c 100644 --- a/include/mapgen/Economy.hpp +++ b/include/mapgen/Economy.hpp @@ -2,28 +2,28 @@ #define ECONOMY_H_ namespace Economy { - const float POPULATION_GROWS = 0.04; - const float POPULATION_GROWS_WEALTH_MODIFIER = 0.1; + const float POPULATION_GROWS = 0.04f; + const float POPULATION_GROWS_WEALTH_MODIFIER = 0.1f; - const float PACKAGES_PER_NICE = 20; - const float PACKAGES_AGRO_POPULATION_MODIFIER = 0.04; + const float PACKAGES_PER_NICE = 20.f; + const float PACKAGES_AGRO_POPULATION_MODIFIER = 0.04f; - const float PACKAGES_PER_MINERALS = 15; - const float PACKAGES_MINERALS_POPULATION_MODIFIER = 0.03; + const float PACKAGES_PER_MINERALS = 15.f; + const float PACKAGES_MINERALS_POPULATION_MODIFIER = 0.03f; - const float CONSUME_AGRO_POPULATION_MODIFIER = 0.5; - const float CONSUME_MINERALS_POPULATION_MODIFIER = 0.5; + const float CONSUME_AGRO_POPULATION_MODIFIER = 0.5f; + const float CONSUME_MINERALS_POPULATION_MODIFIER = 0.5f; - const float CONSUME_AGRO_WEALTH_MODIFIER = 0.1; - const float CONSUME_MINERALS_WEALTH_MODIFIER = 0.1; + const float CONSUME_AGRO_WEALTH_MODIFIER = 0.1f; + const float CONSUME_MINERALS_WEALTH_MODIFIER = 0.1f; - const float CANT_BUY_AGRO = 0.3; - const float CANT_BUY_MINERALS = 0.3; + const float CANT_BUY_AGRO = 0.3f; + const float CANT_BUY_MINERALS = 0.3f; - const float MINERALS_POPULATION_PRODUCE = 0.3; - const float AGRO_POPULATION_PRODUCE = 0.4; + const float MINERALS_POPULATION_PRODUCE = 0.3f; + const float AGRO_POPULATION_PRODUCE = 0.4f; - const float PORT_FEE = 0.3; + const float PORT_FEE = 0.3f; } class EconomyVars { diff --git a/src/City.cpp b/src/City.cpp index 97c49be..bd21ede 100644 --- a/src/City.cpp +++ b/src/City.cpp @@ -63,7 +63,7 @@ int City::buyGoods(std::vector *goods) { int n = 0; auto p = agroCandidates[n]; unsigned int c = 0; - while (agroNeeded > 0 && n < agroCandidates.size()) { + while (agroNeeded > 0 && n < int(agroCandidates.size())) { p = agroCandidates[n]; c = std::min((int)agroNeeded, (int)p->count); agroNeeded -= c; @@ -77,7 +77,7 @@ int City::buyGoods(std::vector *goods) { int n = 0; auto p = mineralsCandidates[n]; unsigned int c = 0; - while (mineralsNeeded > 0 && n < mineralsCandidates.size()) { + while (mineralsNeeded > 0 && n < int(mineralsCandidates.size())) { p = mineralsCandidates[n]; c = std::min((int)mineralsNeeded, (int)p->count); mineralsNeeded -= c; diff --git a/src/Map.cpp b/src/Map.cpp index 83213db..38aa7cc 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -18,16 +18,16 @@ float Map::getRegionDistance(Region *r, Region *r2) { } } if (r2->hasRiver) { - d *= 0.6; + d *= 0.6f; } if (r2->state != r->state) { - d *= 1.2; + d *= 1.2f; } if (r2->hasRoad) { - d *= 0.2; + d *= 0.2f; } } else { - d *= 0.8; + d *= 0.8f; } return d; } diff --git a/src/MapGenerator.cpp b/src/MapGenerator.cpp index f471cd3..f7352da 100644 --- a/src/MapGenerator.cpp +++ b/src/MapGenerator.cpp @@ -279,11 +279,7 @@ void MapGenerator::simplifyRivers() { } void MapGenerator::makeRelax() { - try { - _diagram.reset(_vdg.relax()); - } catch (const std::exception &e) { - std::cout << "Relax failed" << std::endl << std::flush; - } + _diagram.reset(_vdg.relax()); } void MapGenerator::seed() { @@ -897,7 +893,7 @@ void MapGenerator::calcTemp() { for (auto n : c->getNeighbors()) { if (_cells[n]->biom == biom::LAKE) { r->temperature += 2; - r->biom.feritlity += 0.2; + r->biom.feritlity += 0.2f; } } } @@ -911,7 +907,7 @@ void MapGenerator::calcHumidity() { continue; } if (r->hasRiver) { - r->humidity += 0.2; + r->humidity += 0.2f; } } @@ -927,7 +923,7 @@ void MapGenerator::calcHumidity() { for (auto n : c->getNeighbors()) { Region *rn = _cells[n]; if (rn->hasRiver || rn->biom == biom::LAKE) { - r->humidity += 0.05; + r->humidity += 0.05f; } float hd = rn->getHeight(rn->site) - r->getHeight(r->site); if (rn->humidity > r->humidity && r->humidity != 1 && hd < 0.04) { diff --git a/src/Painter.cpp b/src/Painter.cpp index 559ba1f..0c3ecfc 100644 --- a/src/Painter.cpp +++ b/src/Painter.cpp @@ -106,7 +106,7 @@ class Painter { #endif auto path = fs::path(buff); std::cout << path << std::endl; - return path.parent_path(); + return path.parent_path().string(); } void initProgressBar() { @@ -128,14 +128,14 @@ class Painter { sprintf(path, "%s/images", dir.c_str()); for (auto &d : fs::directory_iterator(path)) { fs::path path = d.path(); - if (!ends_with(path, ".png")) { + if (!ends_with(path.string(), ".png")) { continue; } sf::Texture *icon = new sf::Texture(); mg::info("Loading image:", path); - icon->loadFromFile(path); + icon->loadFromFile(path.string()); icon->setSmooth(true); - images[path.stem()] = icon; + images[path.stem().string()] = icon; } for (auto pair : iconMap) { @@ -670,7 +670,7 @@ class Painter { if ((region->city != nullptr && cities) || (region->city == nullptr && locations)) { // auto texture = images["village"]; - auto texture = locationIcons[region->city->type]; + auto texture = locationIcons[region->location->type]; if (region->city != nullptr) { if (region->city->isCapital) { texture = locationIcons[CAPITAL]; diff --git a/src/Simulator.cpp b/src/Simulator.cpp index bdd920a..99f0ad4 100644 --- a/src/Simulator.cpp +++ b/src/Simulator.cpp @@ -156,7 +156,7 @@ void Simulator::simulateEconomy() { void Simulator::populationTick(int) { int p = 0.f; for (auto c : map->cities) { - c->population *= (float)(1 + + c->population *= (int)(1 + vars->POPULATION_GROWS * c->wealth * vars->POPULATION_GROWS_WEALTH_MODIFIER); c->population = std::max(c->population, 0); @@ -345,7 +345,7 @@ void Simulator::removeBadPorts() { std::copy_if(map->cities.begin(), map->cities.end(), std::back_inserter(cities), [&](City *c) { bool badPort = c->type == PORT && - c->region->traffic <= map->cities.size(); + c->region->traffic <= int(map->cities.size()); if (badPort) { c->region->city = nullptr; c->region->location = nullptr;