Skip to content

Commit

Permalink
cosmetic
Browse files Browse the repository at this point in the history
  • Loading branch information
averrin committed Sep 17, 2017
1 parent 7a39c97 commit 2a1bf61
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 27 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ endif()

project(mapgen)
set (mapgen_VERSION_MAJOR 0)
set (mapgen_VERSION_MINOR 1)
set (mapgen_VERSION_MINOR 4)
set (mapgen_VERSION_PATCH 1)

file(GLOB SOURCE "src/*.cpp" "include/mapgen/*.h")
file(COPY "font.ttf" DESTINATION "bin")
Expand Down
1 change: 1 addition & 0 deletions MapgenConfig.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#define Mapgen_VERSION_MAJOR
#define Mapgen_VERSION_MINOR
#define Mapgen_VERSION_PATCH
1 change: 1 addition & 0 deletions MapgenConfig.h.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#define Mapgen_VERSION_MAJOR @Mapgen_VERSION_MAJOR@
#define Mapgen_VERSION_MINOR @Mapgen_VERSION_MINOR@
#define Mapgen_VERSION_PATCH @Mapgen_VERSION_PATCH@
45 changes: 24 additions & 21 deletions src/Map.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#ifndef MAP_CPP_
#define MAP_CPP_
#include "micropather.h"
#include "mapgen/Region.hpp"
#include "mapgen/River.hpp"
#include "mapgen/City.hpp"
#include "mapgen/Location.hpp"
#include "mapgen/Region.hpp"
#include "mapgen/River.hpp"
#include "mapgen/Road.hpp"
#include "micropather.h"

class Map: public micropather::Graph {
class Map : public micropather::Graph {
public:
~Map(){};

std::vector<MegaCluster*> megaClusters;
std::vector<Cluster*> clusters;
std::vector<MegaCluster *> megaClusters;
std::vector<Cluster *> clusters;

std::vector<Region*> regions;
std::vector<River*> rivers;
std::vector<City*> cities;
std::vector<Location*> locations;
std::vector<Road*> roads;
std::vector<Region *> regions;
std::vector<River *> rivers;
std::vector<City *> cities;
std::vector<Location *> locations;
std::vector<Road *> roads;

float getRegionDistance(Region* r, Region* r2) {
float getRegionDistance(Region *r, Region *r2) {
Point p = r->site;
Point p2 = r2->site;
double distancex = (p2->x - p->x);
Expand All @@ -35,22 +35,24 @@ class Map: public micropather::Graph {
d -= 5000;
}
}
if (r->hasRiver) {
d *= 0.6;
}
} else {
d *= 0.8;
}
return d;
}


float LeastCostEstimate( void* stateStart, void* stateEnd ){
return getRegionDistance((Region*)stateStart, (Region*)stateEnd);
float LeastCostEstimate(void *stateStart, void *stateEnd) {
return getRegionDistance((Region *)stateStart, (Region *)stateEnd);
};

void AdjacentCost( void* state, MP_VECTOR< micropather::StateCost > *neighbors ){
auto r = ((Region*)state);
void AdjacentCost(void *state, MP_VECTOR<micropather::StateCost> *neighbors) {
auto r = ((Region *)state);
for (auto n : r->neighbors) {

if(n->biom.name == "Lake"){
if (n->biom.name == "Lake") {
continue;
}
if (r->megaCluster->isLand) {
Expand All @@ -67,11 +69,12 @@ class Map: public micropather::Graph {
}
}

micropather::StateCost nodeCost = { (void*)n, getRegionDistance((Region*)state, (Region*)n) };
neighbors->push_back( nodeCost );
micropather::StateCost nodeCost = {
(void *)n, getRegionDistance((Region *)state, (Region *)n)};
neighbors->push_back(nodeCost);
}
};
void PrintStateInfo( void* state ){};
void PrintStateInfo(void *state){};
};

#endif
13 changes: 9 additions & 4 deletions src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "objectsWindow.cpp"

class Application {
std::string VERSION;
std::vector<sf::ConvexShape> polygons;
std::vector<sf::CircleShape> poi;
std::vector<sf::ConvexShape> infoPolygons;
Expand Down Expand Up @@ -59,7 +60,7 @@ class Application {
bool lock = false;

public:
Application() {
Application(std::string v) : VERSION(v) {
sf::ContextSettings settings;
settings.antialiasingLevel = 8;

Expand Down Expand Up @@ -137,6 +138,8 @@ class Application {
if (generator.joinable())
generator.join();
generator = std::thread([&]() {
lockedRegion = nullptr;
lock = false;
ready = false;
mapgen->update();
seed = mapgen->getSeed();
Expand Down Expand Up @@ -387,7 +390,7 @@ class Application {
return;
}

if (currentRegion->location != nullptr) {
if (currentRegion->location != nullptr && !roads) {
for (auto r : mapgen->map->roads) {
if (r->regions[0] != currentRegion->location->region &&
r->regions.back() != currentRegion->location->region) {
Expand Down Expand Up @@ -612,10 +615,12 @@ class Application {
drawMap();

sf::Vector2u windowSize = window->getSize();
sf::Text mark("Mapgen by Averrin", sffont);
char mt[40];
sprintf(mt, "Mapgen [%s] by Averrin", VERSION.c_str());
sf::Text mark(mt, sffont);
mark.setCharacterSize(15);
mark.setColor(sf::Color::White);
mark.setPosition(sf::Vector2f(windowSize.x - 160, windowSize.y - 25));
mark.setPosition(sf::Vector2f(windowSize.x - 240, windowSize.y - 25));
window->draw(mark);

if (showUI) {
Expand Down
4 changes: 3 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "application.cpp"

std::string VERSION = "0.4.1";

int main()
{
Application app;
Application app(VERSION);
app.serve();
}

0 comments on commit 2a1bf61

Please sign in to comment.