Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
henricj committed Jan 18, 2025
1 parent 7be311c commit d9365bb
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 24 deletions.
4 changes: 2 additions & 2 deletions include/FileClasses/music/MusicPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ enum MUSICTYPE {
class MusicPlayer {
protected:
MusicPlayer(bool bMusicOn, int newMusicVolume, std::string_view name)
: musicOn(bMusicOn), musicVolume(newMusicVolume), thisMusicID(INVALID),
currentMusicType(MUSIC_RANDOM), random_{RandomFactory{}.create(name)} {
: musicOn(bMusicOn), musicVolume(newMusicVolume), thisMusicID(INVALID), currentMusicType(MUSIC_RANDOM),
random_{RandomFactory{}.create(name)} {
Mix_VolumeMusic(musicVolume);
}

Expand Down
4 changes: 3 additions & 1 deletion include/Network/LANGameFinderAndAnnouncer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ class LANGameFinderAndAnnouncer final {
Sets the function that should be called when a new server is found
\param pOnNewServer Function to call on new server found
*/
void setOnNewServer(std::function<void(GameServerInfo)> pOnNewServer) { this->pOnNewServer_ = std::move(pOnNewServer); }
void setOnNewServer(std::function<void(GameServerInfo)> pOnNewServer) {
this->pOnNewServer_ = std::move(pOnNewServer);
}

/**
Sets the function that should be called when a server is updated
Expand Down
3 changes: 2 additions & 1 deletion include/ObjectManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ class ObjectManager final {

auto* const pObject = dune_cast<ObjectType>(object.get());
if (!pObject) {
sdl2::log_error("createObjectFromItemId() created the wrong type of object for build item type {}", static_cast<int>(itemID));
sdl2::log_error("createObjectFromItemId() created the wrong type of object for build item type {}",
static_cast<int>(itemID));
return nullptr;
}

Expand Down
4 changes: 3 additions & 1 deletion include/RadarViewBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ class RadarViewBase : public Widget {
Sets the function that should be called when the radar view is clicked.
\param pOnRadarClick A function to be called on click
*/
void setOnRadarClick(std::function<bool(Coord, bool, bool)> pOnRadarClick) { this->pOnRadarClick = std::move(pOnRadarClick); }
void setOnRadarClick(std::function<bool(Coord, bool, bool)> pOnRadarClick) {
this->pOnRadarClick = std::move(pOnRadarClick);
}

protected:
std::function<bool(Coord, bool, bool)>
Expand Down
2 changes: 1 addition & 1 deletion include/fixmath/fix16.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static inline fix16_t fix16_from_dbl(double a) {
you should only use this for constant values. For runtime-conversions,
use the functions above.
*/
#define F16(x) ((fix16_t)(((x) >= 0) ? ((x)*65536.0 + 0.5) : ((x)*65536.0 - 0.5)))
#define F16(x) ((fix16_t)(((x) >= 0) ? ((x) * 65536.0 + 0.5) : ((x) * 65536.0 - 0.5)))

static inline fix16_t fix16_abs(fix16_t x) {
return (x < 0 ? -x : x);
Expand Down
2 changes: 1 addition & 1 deletion include/fixmath/fix32.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static inline fix32_t fix32_from_dbl(double a) {
you should only use this for constant values. For runtime-conversions,
use the functions above.
*/
#define F32(x) ((fix32_t)(((x) >= 0) ? ((x)*4294967296.0 + 0.5) : ((x)*4294967296.0 - 0.5)))
#define F32(x) ((fix32_t)(((x) >= 0) ? ((x) * 4294967296.0 + 0.5) : ((x) * 4294967296.0 - 0.5)))

static inline fix32_t fix32_abs(fix32_t x) {
return (x < 0 ? -x : x);
Expand Down
13 changes: 8 additions & 5 deletions src/FileClasses/GFXManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include <SDL2/SDL.h>

GFXManager::GFXManager(SDL_Renderer* renderer, int width, int height)
: random_{RandomFactory{}.create("UI")}, surfaceLoader{width, height}, duneTextures{DuneTextures::create(
renderer, &surfaceLoader)} {
: random_{RandomFactory{}.create("UI")}, surfaceLoader{width, height},
duneTextures{DuneTextures::create(renderer, &surfaceLoader)} {
initialize_cursors();
}

Expand Down Expand Up @@ -89,7 +89,8 @@ const DuneTexture* GFXManager::getZoomedObjPic(ObjPic_enum id, HOUSETYPE house,

zoomable_texture GFXManager::getObjPic(ObjPic_enum id, HOUSETYPE house) const {
if (id >= NUM_OBJPICS) {
THROW(std::invalid_argument, "GFXManager::getObjPic(): Unit Picture with ID {} is not available!", static_cast<int>(id));
THROW(std::invalid_argument, "GFXManager::getObjPic(): Unit Picture with ID {} is not available!",
static_cast<int>(id));
}

return {&duneTextures.get_object_picture(id, house, 0), &duneTextures.get_object_picture(id, house, 1),
Expand Down Expand Up @@ -149,7 +150,8 @@ SDL_Cursor* GFXManager::getCursor(UIGraphics_Enum id) const {

const DuneTexture* GFXManager::getUIGraphic(UIGraphics_Enum id, HOUSETYPE house) const {
if (id >= NUM_UIGRAPHICS) {
THROW(std::invalid_argument, "GFXManager::getUIGraphic(): UI Graphic with ID {} is not available!", static_cast<int>(id));
THROW(std::invalid_argument, "GFXManager::getUIGraphic(): UI Graphic with ID {} is not available!",
static_cast<int>(id));
}

const auto& texture = duneTextures.get_ui_graphic(id, house);
Expand All @@ -169,7 +171,8 @@ const DuneTexture* GFXManager::getMapChoicePiece(UIGraphics_Enum num, HOUSETYPE
const auto& texture = duneTextures.get_map_choice(num, house);

if (!texture)
sdl2::log_info("Unable to get map choice piece {} for house {}", static_cast<int>(num), static_cast<int>(house));
sdl2::log_info("Unable to get map choice piece {} for house {}", static_cast<int>(num),
static_cast<int>(house));

return texture ? &texture : nullptr;
}
Expand Down
6 changes: 4 additions & 2 deletions src/House.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ void House::incrementUnits(ItemID_enum itemID) {

void House::decrementUnits(ItemID_enum itemID) {
if (numUnits_ < 1)
THROW(std::runtime_error, "Cannot decrement number of units {} (itemId {})", numUnits_, static_cast<int>(itemID));
THROW(std::runtime_error, "Cannot decrement number of units {} (itemId {})", numUnits_,
static_cast<int>(itemID));

numUnits_--;
numItemLosses_[itemID]++;
Expand Down Expand Up @@ -407,7 +408,8 @@ void House::incrementStructures(ItemID_enum itemID) {

void House::decrementStructures(ItemID_enum itemID, const Coord& location) {
if (numStructures_ < 1)
THROW(std::runtime_error, "Cannot decrement number of structures {} (itemId {})", numStructures_, static_cast<int>(itemID));
THROW(std::runtime_error, "Cannot decrement number of structures {} (itemId {})", numStructures_,
static_cast<int>(itemID));

numStructures_--;
numItem_[itemID]--;
Expand Down
4 changes: 2 additions & 2 deletions src/INIMap/INIMapLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,8 @@ void INIMapLoader::loadUnits(const GameContext& context) {

#if defined(DEBUG)
sdl2::log_info("Placed unit {} of type {} at {}x{} ({}/{}) after parsing {}",
newUnit->getObjectID(), static_cast<int>(itemID), newUnit->getLocation().x, newUnit->getLocation().y,
pos, PosStr, keyView);
newUnit->getObjectID(), static_cast<int>(itemID), newUnit->getLocation().x,
newUnit->getLocation().y, pos, PosStr, keyView);
#endif // defined(DEBUG)

newUnit->setHealth((newUnit->getMaxHealth() * percentHealth));
Expand Down
8 changes: 3 additions & 5 deletions src/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#include <stack>

Map::Map(Game& game, int xSize, int ySize)
: sizeX(xSize), sizeY(ySize), lastSinglySelectedObject(nullptr),
pathfinder_(this), random_{game.randomFactory.create("Map")} {
: sizeX(xSize), sizeY(ySize), lastSinglySelectedObject(nullptr), pathfinder_(this),
random_{game.randomFactory.create("Map")} {

tiles.resize(static_cast<size_t>(sizeX) * sizeY);

Expand Down Expand Up @@ -654,9 +654,7 @@ void Map::viewMap(HOUSETYPE houseID, const Coord& location, const int maxViewRan
void Map::createSpiceField(const GameContext& context, Coord location, int radius, bool centerIsThickSpice) {
for_each_filter(
location.x - radius, location.y - radius, location.x + radius, location.y + radius,
[&](int x, int y) {
return distanceFrom(location, {x, y}) <= radius;
},
[&](int x, int y) { return distanceFrom(location, {x, y}) <= radius; },
[&](Tile& t) {
if (t.isSand()) {
const auto terrain = centerIsThickSpice && (t.location_ == location) ? TERRAINTYPE::Terrain_ThickSpice
Expand Down
4 changes: 2 additions & 2 deletions src/fixmath/fix16_trig.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ fix16_t fix16_sin(fix16_t inAngle) {
const fix16_t tempAngleSq = fix16_mul(tempAngle, tempAngle);

# ifndef FIXMATH_FAST_SIN // Most accurate version, accurate to ~2.1%
fix16_t tempOut = tempAngle;
tempAngle = fix16_mul(tempAngle, tempAngleSq);
fix16_t tempOut = tempAngle;
tempAngle = fix16_mul(tempAngle, tempAngleSq);
tempOut -= (tempAngle / 6);
tempAngle = fix16_mul(tempAngle, tempAngleSq);
tempOut += (tempAngle / 120);
Expand Down
2 changes: 1 addition & 1 deletion src/misc/dune_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ DuneEventWatcher::~DuneEventWatcher() {
}

#else // defined(_WIN32)
DuneEventWatcher::DuneEventWatcher() = default;
DuneEventWatcher::DuneEventWatcher() = default;
DuneEventWatcher::~DuneEventWatcher() = default;
#endif // defined(_WIN32)

Expand Down

0 comments on commit d9365bb

Please sign in to comment.