Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
averrin committed Oct 13, 2017
1 parent db28a6d commit 51a5313
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 57 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
40 changes: 20 additions & 20 deletions include/mapgen/Biom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Biom> 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<std::vector<Biom>> BIOMS_BY_HEIGHT = {{
{ABYSS},
Expand Down
30 changes: 15 additions & 15 deletions include/mapgen/Economy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/City.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int City::buyGoods(std::vector<Package *> *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;
Expand All @@ -77,7 +77,7 @@ int City::buyGoods(std::vector<Package *> *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;
Expand Down
8 changes: 4 additions & 4 deletions src/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 4 additions & 8 deletions src/MapGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
}
}
}
Expand All @@ -911,7 +907,7 @@ void MapGenerator::calcHumidity() {
continue;
}
if (r->hasRiver) {
r->humidity += 0.2;
r->humidity += 0.2f;
}
}

Expand All @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions src/Painter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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) {
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions src/Simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 51a5313

Please sign in to comment.