summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/network/rail.cpp2
-rw-r--r--game/objectives/freeroam.cpp2
-rw-r--r--game/objectives/goto.cpp2
-rw-r--r--game/terrain.cpp7
4 files changed, 6 insertions, 7 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index 0cb2725..1f432cb 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -155,7 +155,7 @@ RailLinkCurve::RailLinkCurve(const NodePtr & a, const NodePtr & b, glm::vec3 c,
const auto step {glm::vec3 {-arc_length(arc), e0p.y - e1p.y, slength} / segs};
const auto trans {glm::translate(centreBase)};
- int segCount = segs;
+ auto segCount = std::lround(segs);
std::vector<Vertex> vertices;
vertices.reserve((segCount + 1) * railCrossSection.size());
for (glm::vec3 swing = {arc.second, e1p.y - centreBase.y, 0.F}; segCount >= 0; swing += step, --segCount) {
diff --git a/game/objectives/freeroam.cpp b/game/objectives/freeroam.cpp
index 0721ef2..b569d36 100644
--- a/game/objectives/freeroam.cpp
+++ b/game/objectives/freeroam.cpp
@@ -17,6 +17,6 @@ Link::Next
FreeRoam::navigate(Link::Nexts::const_iterator begin, Link::Nexts::const_iterator end) const
{
static std::mt19937 gen(std::random_device {}());
- auto off = std::uniform_int_distribution<>(0, std::distance(begin, end) - 1)(gen);
+ auto off = std::uniform_int_distribution<long>(0, std::distance(begin, end) - 1)(gen);
return begin[off];
}
diff --git a/game/objectives/goto.cpp b/game/objectives/goto.cpp
index c089bc3..8581a2d 100644
--- a/game/objectives/goto.cpp
+++ b/game/objectives/goto.cpp
@@ -17,7 +17,7 @@ GoTo::GoTo(Orders * o, const Link::End & cp, float d, const NodePtr & dest) :
ActivityPtr
GoTo::createActivity() const
{
- return std::make_unique<Go>(std::accumulate(links.begin(), links.end(), 0,
+ return std::make_unique<Go>(std::accumulate(links.begin(), links.end(), 0.F,
[](auto p, const auto & l) {
return p += l.first.lock()->length;
})
diff --git a/game/terrain.cpp b/game/terrain.cpp
index bf16439..ddfa31b 100644
--- a/game/terrain.cpp
+++ b/game/terrain.cpp
@@ -1,13 +1,13 @@
#include "terrain.h"
#include "gfx/models/texture.h"
#include <cache.h>
-#include <cmath>
#include <gfx/gl/shader.h>
#include <gfx/image.h>
#include <gfx/models/mesh.h>
#include <gfx/models/vertex.hpp>
#include <glm/glm.hpp>
#include <location.hpp>
+#include <maths.h>
#include <random>
#include <stb_image.h>
@@ -41,14 +41,13 @@ Terrain::Terrain() : grass {Texture::cachedTexture.get("grass.png")}, water {Tex
const glm::ivec2 hsize {rsize(gen), rsize(gen)};
if (const auto lim1 = hpos - hsize; lim1.x > 0 && lim1.y > 0) {
if (const auto lim2 = hpos + hsize; lim2.x < size && lim2.y < size) {
- const float height = rheight(gen);
+ const auto height = (float)rheight(gen);
const glm::ivec2 hsizesqrd {hsize.x * hsize.x, hsize.y * hsize.y};
for (auto z = lim1.y; z < lim2.y; z += 1) {
for (auto x = lim1.x; x < lim2.x; x += 1) {
const auto dist {hpos - glm::ivec2 {x, z}};
const glm::ivec2 distsqrd {dist.x * dist.x, dist.y * dist.y};
- const auto out {
- (pow(x - hpos.x, 2) / pow(hsize.x, 2)) + (pow(z - hpos.y, 2) / pow(hsize.y, 2))};
+ const auto out {rdiv(sq(x - hpos.x), sq(hsize.x)) + rdiv(sq(z - hpos.y), sq(hsize.y))};
if (out <= 1.0) {
auto & vertex = vertices[x + (z * size)];
const auto m {1.F / (7.F * out - 8.F) + 1.F};