Преглед на файлове

clang-tidy

opengl-renderer-broken
Martin Dørum преди 4 години
родител
ревизия
362adf6171

+ 4
- 1
CMakeLists.txt Целия файл

@@ -3,7 +3,10 @@ project(swan)

find_package(SFML 2.5 COMPONENTS graphics system window REQUIRED)

message(STATUS "SFML is ${SFML_INCLUDE_PATH}")
set(CMAKE_CXX_CLANG_TIDY
clang-tidy;
-header-filter=.*
-checks=-*,-checks=bugprone-*,cert-*,performance-*,clang-analyzer-*,-cert-dcl16-c,-cert-err58-cpp,-clang-analyzer-optin.cplusplus.VirtualCall)

add_compile_options(-std=c++2a -Wall -Wextra -Wpedantic -Wno-unused-parameter)
if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL "")

+ 2
- 2
core.mod/src/WGDefault.cc Целия файл

@@ -1,8 +1,8 @@
#include "WGDefault.h"

void WGDefault::genChunk(Swan::WorldPlane &plane, Swan::Chunk &chunk) {
int height = perlin_.octaveNoise0_1(chunk.pos_.x / (64.0 / 16), 8) * 10;
int depth = perlin_.octaveNoise0_1(chunk.pos_.x / (64.0 / 9), 5) * 10 + 10;
int height = (int)(perlin_.octaveNoise0_1(chunk.pos_.x / (64.0 / 16), 8) * 10);
int depth = (int)(perlin_.octaveNoise0_1(chunk.pos_.x / (64.0 / 9), 5) * 10 + 10);

for (int cx = 0; cx < Swan::CHUNK_WIDTH; ++cx) {
for (int cy = 0; cy < Swan::CHUNK_HEIGHT; ++cy) {

+ 4
- 4
libswan/include/swan/Animation.h Целия файл

@@ -15,20 +15,20 @@ public:
};

Animation() = default;
Animation(int w, int h, double interval, const Asset &asset, int flags = 0) {
Animation(int w, int h, float interval, const Asset &asset, int flags = 0) {
init(w, h, interval, asset, flags);
}

void init(int w, int h, double interval, const Asset &asset, int flags = 0);
void init(int w, int h, float interval, const Asset &asset, int flags = 0);

void tick(double dt);
void tick(float dt);
void draw(Win &win);
void reset();

int width_, height_;

private:
double interval_;
float interval_;
const Asset *asset_;
int fcount_;
int frame_ = 0;

+ 1
- 1
libswan/include/swan/Asset.h Целия файл

@@ -7,7 +7,7 @@ namespace Swan {

class Asset {
public:
Asset(std::string path): path_(path) {}
Asset(const std::string &path): path_(path) {}

bool load(const std::string &pfx);


+ 1
- 1
libswan/include/swan/Chunk.h Целия файл

@@ -51,7 +51,7 @@ private:

ssize_t compressed_size_ = -1; // -1 if not compressed, a positive number if compressed
bool need_render_ = false;
int deactivate_timer_ = DEACTIVATE_TIME;
float deactivate_timer_ = DEACTIVATE_TIME;

struct Visuals {
sf::Texture tex_;

+ 1
- 1
libswan/include/swan/Entity.h Целия файл

@@ -39,7 +39,7 @@ public:

class PhysicsEntity: public Entity {
public:
PhysicsEntity(Vec2 size, double mass):
PhysicsEntity(Vec2 size, float mass):
body_(size, mass) {}

virtual std::optional<BoundingBox> getBounds() { return body_.getBounds(); }

+ 1
- 1
libswan/include/swan/Game.h Целия файл

@@ -19,7 +19,7 @@ public:
win_(win) {}

void loadMod(const std::string &path);
void createWorld(std::string worldgen);
void createWorld(const std::string &worldgen);

void onKeyPressed(sf::Keyboard::Key key) { keys_pressed_[(int)key] = true; }
void onKeyReleased(sf::Keyboard::Key key) { keys_pressed_[(int)key] = false; }

+ 5
- 5
libswan/include/swan/SRF.h Целия файл

@@ -119,7 +119,7 @@ struct SRFNone: SRF {
struct SRFByteArray: SRF {
SRFByteArray() = default;
SRFByteArray(std::initializer_list<uint8_t> lst): val(lst) {}
SRFByteArray(std::vector<uint8_t> v): val(v) {}
SRFByteArray(std::vector<uint8_t> &v): val(v) {}

void serialize(std::ostream &os) const override;
void parse(std::istream &os) override;
@@ -131,7 +131,7 @@ struct SRFByteArray: SRF {
struct SRFWordArray: SRF {
SRFWordArray() = default;
SRFWordArray(std::initializer_list<uint16_t> v): val(v) {}
SRFWordArray(std::vector<uint16_t> v): val(v) {}
SRFWordArray(std::vector<uint16_t> &v): val(v) {}

void serialize(std::ostream &os) const override;
void parse(std::istream &os) override;
@@ -143,7 +143,7 @@ struct SRFWordArray: SRF {
struct SRFIntArray: SRF {
SRFIntArray() = default;
SRFIntArray(std::initializer_list<int> v): val(v) {}
SRFIntArray(std::vector<int32_t> v): val(v) {}
SRFIntArray(std::vector<int32_t> &v): val(v) {}

void serialize(std::ostream &os) const override;
void parse(std::istream &os) override;
@@ -155,7 +155,7 @@ struct SRFIntArray: SRF {
struct SRFFloatArray: SRF {
SRFFloatArray() = default;
SRFFloatArray(std::initializer_list<float> v): val(v) {}
SRFFloatArray(std::vector<float> v): val(v) {}
SRFFloatArray(std::vector<float> &v): val(v) {}

void serialize(std::ostream &os) const override;
void parse(std::istream &os) override;
@@ -167,7 +167,7 @@ struct SRFFloatArray: SRF {
struct SRFDoubleArray: SRF {
SRFDoubleArray() = default;
SRFDoubleArray(std::initializer_list<double> v): val(v) {}
SRFDoubleArray(std::vector<double> v): val(v) {}
SRFDoubleArray(std::vector<double> &v): val(v) {}

void serialize(std::ostream &os) const override;
void parse(std::istream &os) override;

+ 1
- 1
libswan/include/swan/World.h Целия файл

@@ -20,7 +20,7 @@ class World {
public:
World(Game *game): game_(game) {}

WorldPlane &addPlane(std::string gen);
WorldPlane &addPlane(const std::string &gen);
WorldPlane &addPlane() { return addPlane(default_world_gen_); }
void setCurrentPlane(WorldPlane &plane);
void setWorldGen(const std::string &gen);

+ 1
- 1
libswan/include/swan/WorldPlane.h Целия файл

@@ -22,7 +22,7 @@ public:
using ID = uint16_t;

WorldPlane(ID id, World *world, std::shared_ptr<WorldGen> gen):
id_(id), world_(world), gen_(gen) {}
id_(id), world_(world), gen_(std::move(gen)) {}

Entity &spawnEntity(const std::string &name, const SRF &params);
void despawnEntity(Entity &ent);

+ 1
- 1
libswan/include/swan/common.h Целия файл

@@ -29,7 +29,7 @@ struct Win {
sf::RenderWindow *window_;
sf::Transform transform_;
Vec2 cam_;
double scale_ = 2;
float scale_ = 2;

Win(sf::RenderWindow *win): window_(win) {}


+ 3
- 3
libswan/src/Animation.cc Целия файл

@@ -2,12 +2,12 @@

namespace Swan {

void Animation::init(int w, int h, double interval, const Asset &asset, int flags) {
void Animation::init(int w, int h, float interval, const Asset &asset, int flags) {
width_ = w;
height_ = h;
interval_ = interval;
asset_ = &asset;
fcount_ = asset_->image_.getSize().y / height_;
fcount_ = (int)asset_->image_.getSize().y / height_;
sprite_.setTexture(asset_->tex_);
sprite_.setTextureRect(sf::IntRect(0, 0, width_, height_));

@@ -17,7 +17,7 @@ void Animation::init(int w, int h, double interval, const Asset &asset, int flag
}
}

void Animation::tick(double dt) {
void Animation::tick(float dt) {
timer_.tick(dt);
if (timer_.periodic(interval_)) {
dirty_ = true;

+ 2
- 2
libswan/src/Body.cc Целия файл

@@ -33,7 +33,7 @@ void Body::collide(WorldPlane &plane) {
startx = (int)floor(pos_.x);
} else if (x == endx && vel_.x > 0 && wall.is_solid) {
vel_.x = 0;
pos_.x = endx - size_.x - 0.001;
pos_.x = (float)endx - size_.x - 0.001;
endx = (int)floor(pos_.x + size_.x);
}
//plane.debugBox(TilePos(x, ry));
@@ -58,7 +58,7 @@ void Body::collide(WorldPlane &plane) {
for (int x = startx; x <= endx; ++x) {
Tile &ground = plane.getTile(TilePos(x, y));
if (ground.is_solid && vel_.y > 0) {
pos_.y = y - size_.y;
pos_.y = (float)y - size_.y;
vel_.y = 0;
on_ground_ = true;
}

+ 1
- 1
libswan/src/Game.cc Целия файл

@@ -28,7 +28,7 @@ void Game::loadMod(const std::string &path) {
mod_init(mod);
}

void Game::createWorld(std::string worldgen) {
void Game::createWorld(const std::string &worldgen) {
world_.reset(new World(this));
for (auto &mod: registered_mods_) {
world_->registerTile(std::shared_ptr<Tile>(Tile::createInvalid()));

+ 2
- 2
libswan/src/SRF.cc Целия файл

@@ -109,9 +109,9 @@ static std::string readString(std::istream &is) {

static char hexchr(uint8_t nibble) {
if (nibble < 10)
return '0' + nibble;
return (char)('0' + nibble);
else
return 'a' + (nibble - 10);
return (char)('a' + (nibble - 10));
}

SRF *SRF::read(std::istream &is) {

+ 6
- 6
libswan/src/World.cc Целия файл

@@ -48,24 +48,24 @@ void World::spawnPlayer() {

void World::registerTile(std::shared_ptr<Tile> t) {
Tile::ID id = tiles_.size();
tiles_.push_back(t);
tiles_map_[t->name] = id;
tiles_.push_back(std::move(t));
}

void World::registerItem(std::shared_ptr<Item> i) {
items_[i->name] = i;
items_[i->name] = std::move(i);
}

void World::registerWorldGen(std::shared_ptr<WorldGen::Factory> gen) {
worldgens_[gen->name_] = gen;
worldgens_[gen->name_] = std::move(gen);
}

void World::registerEntity(std::shared_ptr<Entity::Factory> ent) {
ents_[ent->name_] = ent;
ents_[ent->name_] = std::move(ent);
}

void World::registerAsset(std::shared_ptr<Asset> asset) {
assets_[asset->name_] = asset;
assets_[asset->name_] = std::move(asset);
}

Asset &World::getAsset(const std::string &name) {
@@ -107,7 +107,7 @@ Tile &World::getTile(const std::string &name) {
return getTileByID(id);
}

WorldPlane &World::addPlane(std::string gen) {
WorldPlane &World::addPlane(const std::string &gen) {
WorldPlane::ID id = planes_.size();
if (worldgens_.find(gen) == worldgens_.end()) {
fprintf(stderr, "Tried to add plane with non-existant world gen '%s'!\n",

Loading…
Отказ
Запис