Skip to content

Clang tidy #362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/audio/AudioEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ namespace Audio
{
void AudioEngine::enumerateDevices(std::vector<std::string>& enumerated)
{
if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT"))
if (alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT"))
{
size_t len = 0;
const ALCchar* devices = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
const ALCchar* devices = alcGetString(nullptr, ALC_DEVICE_SPECIFIER);
const ALCchar *device = devices, *next = devices + 1;

while (device && *device != '\0' && next && *next != '\0')
{
enumerated.push_back(device);
enumerated.emplace_back(device);

len = strlen(device);
device += (len + 1);
Expand All @@ -29,7 +29,7 @@ namespace Audio
}

if (enumerated.empty())
enumerated.push_back(std::string()); // empty string is default device
enumerated.emplace_back(); // empty string is default device
}

const char* AudioEngine::getErrorString(size_t errorCode)
Expand All @@ -54,7 +54,7 @@ namespace Audio

AudioEngine::AudioEngine(const std::string& name)
{
m_Device = alcOpenDevice(name.empty() ? NULL : name.c_str());
m_Device = alcOpenDevice(name.empty() ? nullptr : name.c_str());
if (!m_Device)
{
LogWarn() << "Could not open audio device '" << (name.empty() ? "default" : name) << "': "
Expand Down
10 changes: 4 additions & 6 deletions src/audio/AudioWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <adpcm/adpcm-lib.h>

#include <stdlib.h>
#include <cstdlib>
#include <daedalus/DATFile.h>
#include <daedalus/DaedalusGameState.h>
#include <daedalus/DaedalusVM.h>
Expand Down Expand Up @@ -149,12 +149,10 @@ namespace World
void AudioWorld::musicRenderFunction()
{
ALenum error;
std::int16_t buf[RE_MUSIC_BUFFER_LEN];
for (int i = 0; i < RE_MUSIC_BUFFER_LEN; i++) buf[i] = 0;
std::int16_t buf[RE_MUSIC_BUFFER_LEN]{};

for (int i = 0; i < RE_NUM_MUSIC_BUFFERS; i++)
{
alBufferData(m_musicBuffers[i], AL_FORMAT_STEREO16, buf, RE_MUSIC_BUFFER_LEN * 2, 44100);
for (unsigned int m_musicBuffer : m_musicBuffers) {
alBufferData(m_musicBuffer, AL_FORMAT_STEREO16, buf, RE_MUSIC_BUFFER_LEN * 2, 44100);
}

alSourceQueueBuffers(m_musicSource, RE_NUM_MUSIC_BUFFERS, m_musicBuffers);
Expand Down
12 changes: 2 additions & 10 deletions src/components/AnimHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ AnimHandler::AnimHandler()
m_pWorld = nullptr;
m_AnimationFrame = 0.0f;

for (unsigned i = 0; i < NUM_VELOCITY_AVERAGE_STEPS; i++)
{
m_AnimVelocityRingBuff[i] = Math::float3(0, 0, 0);
}
std::fill(std::begin(m_AnimVelocityRingBuff), std::end(m_AnimVelocityRingBuff), Math::float3(0, 0, 0));
}

/**
Expand Down Expand Up @@ -512,12 +509,7 @@ float AnimHandler::getActiveAnimationProgress()

Math::float3 AnimHandler::getRootNodeVelocityAvg()
{
Math::float3 avg(0, 0, 0);

for (unsigned i = 0; i < NUM_VELOCITY_AVERAGE_STEPS; i++)
{
avg += m_AnimVelocityRingBuff[i];
}
Math::float3 avg = std::accumulate(std::begin(m_AnimVelocityRingBuff), std::end(m_AnimVelocityRingBuff), Math::float3(0, 0, 0));

return avg / (float)NUM_VELOCITY_AVERAGE_STEPS;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Entities.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace Components

struct Component : public Handle::HandleTypeDescriptor<Handle::EntityHandle>
{
~Component(){};
~Component() = default;
};

/**
Expand Down
4 changes: 0 additions & 4 deletions src/content/GenericMeshAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ GenericMeshAllocator::GenericMeshAllocator(const VDFS::FileIndex* vdfidx)
{
}

GenericMeshAllocator::~GenericMeshAllocator()
{
}

Handle::MeshHandle GenericMeshAllocator::loadMeshVDF(const VDFS::FileIndex& idx, const std::string& name)
{
// Check if this was already loaded
Expand Down
2 changes: 1 addition & 1 deletion src/content/GenericMeshAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Meshes
{
public:
GenericMeshAllocator(const VDFS::FileIndex* vdfidx = nullptr);
virtual ~GenericMeshAllocator();
virtual ~GenericMeshAllocator() = default;

/**
* @brief Sets the VDFS-Index to use
Expand Down
2 changes: 1 addition & 1 deletion src/content/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bgfx::ProgramHandle Shader::loadProgram(const char* basePath, const char* _vsNam
{
bgfx::ShaderHandle vsh = loadShader(basePath, _vsName);
bgfx::ShaderHandle fsh = BGFX_INVALID_HANDLE;
if (NULL != _fsName)
if (nullptr != _fsName)
{
fsh = loadShader(basePath, _fsName);
}
Expand Down
5 changes: 1 addition & 4 deletions src/content/SkeletalMeshAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ Handle::MeshHandle SkeletalMeshAllocator::loadFromPacked(const ZenLoad::PackedSk
}

// Put all indices into one continuous chunk of memory
for (size_t i = 0, end = packed.subMeshes.size(); i < end; i++)
{
auto& m = packed.subMeshes[i];

for (const auto &m : packed.subMeshes) {
mesh.m_SubmeshStarts.push_back({static_cast<WorldSkeletalMeshIndex>(mesh.m_Indices.size()),
static_cast<WorldSkeletalMeshIndex>(m.indices.size())});

Expand Down
4 changes: 0 additions & 4 deletions src/content/Sky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ Sky::Sky(World::WorldInstance& world)
fillSkyStates();
}

Sky::~Sky()
{
}

void Sky::calculateLUT_ZenGin(const Math::float3& col0, const Math::float3& col1, Math::float4* pLut)
{
for (int i = 0; i < 256; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/content/Sky.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace Content
};

Sky(World::WorldInstance& world);
~Sky();
~Sky() = default;

/**
* Updates the sky and the colors
Expand Down
7 changes: 0 additions & 7 deletions src/content/SkyConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ SkyConfig::SkyConfig(const std::string& jsonString, SkyGametype gametype)
loadFromJson(jsonString);
}


SkyConfig::~SkyConfig()
{

}


void SkyConfig::addColorSet(const SkyConfig::SkyDayColorSet& set)
{
m_SkyDayColorsPerWorld[Utils::uppered(set.world)] = set;
Expand Down
2 changes: 1 addition & 1 deletion src/content/SkyConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Content
* @param gametype Which game we're currently in
*/
SkyConfig(const std::string& jsonString, SkyGametype gametype);
~SkyConfig();
~SkyConfig() = default;

/**
* @return Whether the loaded config was valid and this contains useful data
Expand Down
10 changes: 2 additions & 8 deletions src/content/StaticMeshAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ Handle::MeshHandle StaticMeshAllocator::loadFromPackedTriList(const ZenLoad::Pac
if (!triangles)
{
// Put all indices into one continuous chunk of memory
for (size_t i = 0, end = packed.subMeshes.size(); i < end; i++)
{
auto& m = packed.subMeshes[i];

for (const auto &m : packed.subMeshes) {
mesh.mesh.m_SubmeshStarts.push_back({static_cast<WorldStaticMeshIndex>(mesh.mesh.m_Indices.size()),
static_cast<WorldStaticMeshIndex>(m.indices.size())});

Expand All @@ -130,10 +127,7 @@ Handle::MeshHandle StaticMeshAllocator::loadFromPackedTriList(const ZenLoad::Pac
else
{
size_t idxStart = 0;
for (size_t i = 0, end = packed.subMeshes.size(); i < end; i++)
{
auto& m = packed.subMeshes[i];

for (const auto &m : packed.subMeshes) {
mesh.mesh.m_SubmeshMaterials.emplace_back();
mesh.mesh.m_SubmeshMaterials.back().m_TextureName = m.material.texture;
mesh.mesh.m_SubmeshMaterials.back().m_NoCollision = m.material.noCollDet;
Expand Down
3 changes: 2 additions & 1 deletion src/content/StaticMeshAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ namespace Meshes
{
public:
StaticMeshAllocator(Engine::BaseEngine& engine);
virtual ~StaticMeshAllocator();

~StaticMeshAllocator() override;

/**
* Allocates a mesh-instance and returns the handle to it.
Expand Down
2 changes: 1 addition & 1 deletion src/engine/BaseEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Engine
struct EngineArgs
{
EngineArgs()
: cmdline(0, NULL)
: cmdline(0, nullptr)
{
}

Expand Down
4 changes: 0 additions & 4 deletions src/engine/GameEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ GameEngine::GameEngine()
{
}

GameEngine::~GameEngine()
{
}

void GameEngine::initEngine(int argc, char** argv)
{
BaseEngine::initEngine(argc, argv);
Expand Down
2 changes: 1 addition & 1 deletion src/engine/GameEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Engine
{
public:
GameEngine();
~GameEngine();
~GameEngine() override = default;

/**
* @brief Initializes the Engine
Expand Down
2 changes: 1 addition & 1 deletion src/engine/JobManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ inline std::future<ReturnType> JobManager::executeInThread(JobType<ReturnType> j
{
std::future<void> keepAliveFuture = std::async(std::launch::async, std::move(wrappedJob), m_pEngine);
std::lock_guard<std::mutex> guard(m_AsyncJobsMutex);
m_AsyncJobs.push_back(std::move(keepAliveFuture));
m_AsyncJobs.emplace_back(std::move(keepAliveFuture));
}
break;
}
Expand Down
12 changes: 6 additions & 6 deletions src/engine/PlatformGLFW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ inline void glfwSetWindow(GLFWwindow* _window)
pd.nwh = (void*)(uintptr_t)glfwGetGLXWindow(_window);
pd.context = glfwGetGLXContext(_window);
#elif BX_PLATFORM_OSX
pd.ndt = NULL;
pd.ndt = nullptr;
pd.nwh = glfwGetCocoaWindow(_window);
pd.context = glfwGetNSGLContext(_window);
#elif BX_PLATFORM_WINDOWS
pd.ndt = NULL;
pd.ndt = nullptr;
pd.nwh = glfwGetWin32Window(_window);
pd.context = NULL;
pd.context = nullptr;
#endif // BX_PLATFORM_WINDOWS
pd.backBuffer = NULL;
pd.backBufferDS = NULL;
pd.backBuffer = nullptr;
pd.backBufferDS = nullptr;
setPlatformData(pd);
}

Expand Down Expand Up @@ -112,7 +112,7 @@ int32_t PlatformGLFW::run(int argc, char** argv)
GLFWwindow* window;

/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(width, height, "REGoth", fullscreen ? glfwGetPrimaryMonitor() : NULL, NULL);
window = glfwCreateWindow(width, height, "REGoth", fullscreen ? glfwGetPrimaryMonitor() : nullptr, nullptr);
if (!window)
{
std::cout << "GLFW: Failed to create window!";
Expand Down
2 changes: 1 addition & 1 deletion src/logic/CameraController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Logic
class CameraController : public Controller
{
public:
~CameraController();
~CameraController() override;

enum class ECameraMode
{
Expand Down
8 changes: 2 additions & 6 deletions src/logic/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ Console::Console(Engine::BaseEngine& e)
outputAdd(" ----------- REGoth Console -----------");
}

Console::~Console()
{
}

void Console::onKeyDown(int glfwKey, int mods)
{
auto& consoleBox = m_BaseEngine.getHud().getConsoleBox();
Expand Down Expand Up @@ -71,7 +67,7 @@ void Console::onKeyDown(int glfwKey, int mods)
}
else if (glfwKey == GLFW_KEY_BACKSPACE)
{
if (m_TypedLine.size() >= 1)
if (!m_TypedLine.empty())
{
m_TypedLine.pop_back();
generateSuggestions(m_TypedLine, false);
Expand Down Expand Up @@ -296,7 +292,7 @@ std::vector<std::string> Console::tokenized(const std::string& line)
if (tokens.empty() || std::isspace(line.back(), std::locale::classic()))
{
// append empty pseudo token to trigger lookahead for the next token
tokens.push_back("");
tokens.emplace_back("");
}
return tokens;
}
Expand Down
4 changes: 2 additions & 2 deletions src/logic/Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Logic
{
}

virtual ~SuggestionBase(){};
virtual ~SuggestionBase() = default;

bool operator<(const SuggestionBase& b) const;

Expand Down Expand Up @@ -104,7 +104,7 @@ namespace Logic

Console(Engine::BaseEngine& e);

~Console();
~Console() = default;

/**
* To be called when a key got pressed.
Expand Down
4 changes: 2 additions & 2 deletions src/logic/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ void Logic::Controller::exportPart(json& j)
for (int i = 0; i < 16; i++)
values[i] = getEntityTransform().mv[i];

for (int i = 0; i < 16; i++)
j["transform"].push_back(values[i]);
for (float value : values)
j["transform"].push_back(value);

Vob::VobInformation vob = Vob::asVob(m_World, m_Entity);

Expand Down
2 changes: 1 addition & 1 deletion src/logic/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Logic
* @param entity Entity owning this controller
*/
Controller(World::WorldInstance& world, Handle::EntityHandle entity);
virtual ~Controller(){};
virtual ~Controller() = default;

/**
* @return The type of this class. If you are adding a new base controller, be sure to add it to ControllerTypes.h
Expand Down
4 changes: 0 additions & 4 deletions src/logic/Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ Inventory::Inventory(World::WorldInstance& world, Daedalus::GameState::NpcHandle
{
}

Inventory::~Inventory()
{
}

Daedalus::GameState::ItemHandle Inventory::addItem(size_t sym, unsigned int count)
{
// Get script-engine
Expand Down
2 changes: 1 addition & 1 deletion src/logic/Inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Logic
{
public:
Inventory(World::WorldInstance& world, Daedalus::GameState::NpcHandle npc);
virtual ~Inventory();
virtual ~Inventory() = default;

/**
* Creates and adds an item of the underlaying script instance
Expand Down
5 changes: 3 additions & 2 deletions src/logic/MobController.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Logic
{
m_StateNum = 0;
}
virtual ~MobCore() {}
virtual ~MobCore() = default;
/**
* Sets the base animation-scheme to use
* @param name New scheme
Expand Down Expand Up @@ -116,7 +116,8 @@ namespace Logic
* @param entity Entity owning this controller
*/
MobController(World::WorldInstance& world, Handle::EntityHandle entity);
virtual ~MobController();

~MobController() override;

/**
* Starts an interaction from the given npc. This is the method you should use to let
Expand Down
Loading