Skip to content

Commit

Permalink
Formatting: Set AlwaysBreakTemplateDeclarations to true
Browse files Browse the repository at this point in the history
  • Loading branch information
kantoniak committed Nov 24, 2018
1 parent bef5bbc commit cf8a398
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
Expand Down
3 changes: 2 additions & 1 deletion src/data/CameraState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ struct CameraState {
float rotationAroundX, rotationAroundY;
float distance;

template <class Archive> void serialize(Archive& archive) {
template <class Archive>
void serialize(Archive& archive) {
archive(lookAt);
archive(rotationAroundX, rotationAroundY);
archive(distance);
Expand Down
6 changes: 4 additions & 2 deletions src/data/Chunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ class Chunk {
void addBuilding(data::buildings::Building building);
bool removeBuilding(data::buildings::Building building);

template <class Archive> void save(Archive& archive) const {
template <class Archive>
void save(Archive& archive) const {
archive(position);
archive(roadGraph);
archive(residential);
}

template <class Archive> void load(Archive& archive) {
template <class Archive>
void load(Archive& archive) {
archive(position);
archive(roadGraph);
archive(residential);
Expand Down
9 changes: 6 additions & 3 deletions src/data/Layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

namespace data {

template <class T, unsigned int L> Layer<T, L>::Layer() : layerData(L * L, 0) {
template <class T, unsigned int L>
Layer<T, L>::Layer() : layerData(L * L, 0) {
}

template <class T, unsigned int L> Layer<T, L>::Layer(const Layer& layer) : layerData(layer.layerData) {
template <class T, unsigned int L>
Layer<T, L>::Layer(const Layer& layer) : layerData(layer.layerData) {
}

template <class T, unsigned int L> const std::vector<T>& Layer<T, L>::getLayerData() const {
template <class T, unsigned int L>
const std::vector<T>& Layer<T, L>::getLayerData() const {
return this->layerData;
}

Expand Down
3 changes: 2 additions & 1 deletion src/data/Layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

namespace data {

template <class T, unsigned int L> class Layer {
template <class T, unsigned int L>
class Layer {

public:
Layer();
Expand Down
3 changes: 2 additions & 1 deletion src/data/Position.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ struct Position {

namespace std {

template <> struct hash<data::Position> {
template <>
struct hash<data::Position> {
std::size_t operator()(const data::Position& p) const {
glm::ivec2 globalPos = p.getGlobal();
return std::hash<int>()(globalPos.x) ^ std::hash<int>()(globalPos.y);
Expand Down
36 changes: 24 additions & 12 deletions src/data/RoadGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,51 @@ RoadGraph<L>::RoadGraph(const RoadGraph& roadGraph)
neighborW(roadGraph.neighborW), neighborE(roadGraph.neighborE) {
}

template <unsigned int L> void RoadGraph<L>::setNeighborN(RoadGraph* neighborN) {
template <unsigned int L>
void RoadGraph<L>::setNeighborN(RoadGraph* neighborN) {
this->neighborN = neighborN;
}

template <unsigned int L> void RoadGraph<L>::setNeighborS(RoadGraph* neighborS) {
template <unsigned int L>
void RoadGraph<L>::setNeighborS(RoadGraph* neighborS) {
this->neighborS = neighborS;
}

template <unsigned int L> void RoadGraph<L>::setNeighborW(RoadGraph* neighborW) {
template <unsigned int L>
void RoadGraph<L>::setNeighborW(RoadGraph* neighborW) {
this->neighborW = neighborW;
}

template <unsigned int L> void RoadGraph<L>::setNeighborE(RoadGraph* neighborE) {
template <unsigned int L>
void RoadGraph<L>::setNeighborE(RoadGraph* neighborE) {
this->neighborE = neighborE;
}

template <unsigned int L> void RoadGraph<L>::addRoad(const data::Road road) {
template <unsigned int L>
void RoadGraph<L>::addRoad(const data::Road road) {
for (auto& tile : road.getTiles()) {
const unsigned int x = tile.getLocal().x;
const unsigned int y = tile.getLocal().y;
this->layerData[y * L + x] = 1;
}
}

template <unsigned int L> void RoadGraph<L>::update(const std::vector<data::Position>& tiles) {
template <unsigned int L>
void RoadGraph<L>::update(const std::vector<data::Position>& tiles) {
for (auto& tile : tiles) {
this->updateIndex(tile.getLocalIndex());
}
}

template <unsigned int L> void RoadGraph<L>::update() {
template <unsigned int L>
void RoadGraph<L>::update() {
for (unsigned int i = 0; i < L * L; i++) {
this->updateIndex(i);
}
}

template <unsigned int L> void RoadGraph<L>::updateIndex(unsigned int i) {
template <unsigned int L>
void RoadGraph<L>::updateIndex(unsigned int i) {
if (this->layerData[i] == NO_ROAD) {
return;
}
Expand All @@ -72,7 +80,8 @@ template <unsigned int L> void RoadGraph<L>::updateIndex(unsigned int i) {
this->layerData[i] = newValue;
}

template <unsigned int L> bool RoadGraph<L>::noRoadToN(unsigned int i) const {
template <unsigned int L>
bool RoadGraph<L>::noRoadToN(unsigned int i) const {
if (i < L) {
if (neighborN == nullptr) {
return true;
Expand All @@ -83,7 +92,8 @@ template <unsigned int L> bool RoadGraph<L>::noRoadToN(unsigned int i) const {
}
}

template <unsigned int L> bool RoadGraph<L>::noRoadToS(unsigned int i) const {
template <unsigned int L>
bool RoadGraph<L>::noRoadToS(unsigned int i) const {
if (i + L >= L * L) {
if (neighborS == nullptr) {
return true;
Expand All @@ -94,7 +104,8 @@ template <unsigned int L> bool RoadGraph<L>::noRoadToS(unsigned int i) const {
}
}

template <unsigned int L> bool RoadGraph<L>::noRoadToW(unsigned int i) const {
template <unsigned int L>
bool RoadGraph<L>::noRoadToW(unsigned int i) const {
if (i % L == 0) {
if (neighborW == nullptr) {
return true;
Expand All @@ -105,7 +116,8 @@ template <unsigned int L> bool RoadGraph<L>::noRoadToW(unsigned int i) const {
}
}

template <unsigned int L> bool RoadGraph<L>::noRoadToE(unsigned int i) const {
template <unsigned int L>
bool RoadGraph<L>::noRoadToE(unsigned int i) const {
if (i % L == L - 1) {
if (neighborE == nullptr) {
return true;
Expand Down
9 changes: 6 additions & 3 deletions src/data/RoadGraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

namespace data {

template <unsigned int L> class RoadGraph : public Layer<char, L> {
template <unsigned int L>
class RoadGraph : public Layer<char, L> {

public:
constexpr static char NO_ROAD = 0;
Expand Down Expand Up @@ -43,11 +44,13 @@ template <unsigned int L> class RoadGraph : public Layer<char, L> {
void addRoad(const data::Road road);
void update(const std::vector<data::Position>& tiles);

template <class Archive> void save(Archive& archive) const {
template <class Archive>
void save(Archive& archive) const {
archive(Layer<char, L>::layerData);
}

template <class Archive> void load(Archive& archive) {
template <class Archive>
void load(Archive& archive) {
archive(Layer<char, L>::layerData);
}

Expand Down
3 changes: 2 additions & 1 deletion src/data/buildings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ struct Building {
unsigned short length;
unsigned short level;

template <class Archive> void serialize(Archive& archive) {
template <class Archive>
void serialize(Archive& archive) {
archive(x, y);
archive(width, length, level);
}
Expand Down
18 changes: 12 additions & 6 deletions src/engine/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class Logger {
void error(std::string message);
void severe(std::string message);

template <typename... Args> void log(LoggingLevel level, const std::string& message, Args... args) {
template <typename... Args>
void log(LoggingLevel level, const std::string& message, Args... args) {
if (level < this->loggingLevel) {
return;
}
Expand All @@ -47,19 +48,24 @@ class Logger {
}

// Shortcuts
template <typename... Args> void debug(std::string message, Args... args) {
template <typename... Args>
void debug(std::string message, Args... args) {
this->log(DEBUG, message, args...);
};
template <typename... Args> void info(std::string message, Args... args) {
template <typename... Args>
void info(std::string message, Args... args) {
this->log(INFO, message, args...);
};
template <typename... Args> void warn(std::string message, Args... args) {
template <typename... Args>
void warn(std::string message, Args... args) {
this->log(WARN, message, args...);
};
template <typename... Args> void error(std::string message, Args... args) {
template <typename... Args>
void error(std::string message, Args... args) {
this->log(ERROR, message, args...);
};
template <typename... Args> void severe(std::string message, Args... args) {
template <typename... Args>
void severe(std::string message, Args... args) {
this->log(SEVERE, message, args...);
};

Expand Down
6 changes: 4 additions & 2 deletions src/io/serializers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
#include <glm/glm.hpp>

namespace glm {
template <typename Archive> void serialize(Archive& archive, glm::ivec2& v) {
template <typename Archive>
void serialize(Archive& archive, glm::ivec2& v) {
archive(cereal::make_nvp("x", v.x), cereal::make_nvp("y", v.y));
}

template <typename Archive> void serialize(Archive& archive, glm::vec3& v) {
template <typename Archive>
void serialize(Archive& archive, glm::vec3& v) {
archive(cereal::make_nvp("x", v.x), cereal::make_nvp("y", v.y), cereal::make_nvp("z", v.z));
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/rendering/Renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class Renderer {

GLuint compileShader(GLenum shaderType, std::string filename);

template <class T> void glBufferDataVector(GLenum target, const std::vector<T>& v, GLenum usage) {
template <class T>
void glBufferDataVector(GLenum target, const std::vector<T>& v, GLenum usage) {
glBufferData(target, v.size() * sizeof(T), &v[0], usage);
}
};
Expand Down

0 comments on commit cf8a398

Please sign in to comment.