Skip to content

Commit

Permalink
Merge pull request #519 from Wargus/clean_up
Browse files Browse the repository at this point in the history
Clean up
  • Loading branch information
Jarod42 authored Sep 30, 2023
2 parents d668340 + 1aed756 commit a5c2e61
Show file tree
Hide file tree
Showing 38 changed files with 290 additions and 341 deletions.
2 changes: 1 addition & 1 deletion src/ai/ai_force.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ unsigned int AiForceManager::FindFreeForce(AiForceRole role, int begin)
unsigned int f = begin;
while (f < forces.size() && (forces[f].State > AiForceAttackingState::Free)) {
++f;
};
}
if (f == forces.size()) {
forces.resize(f + 1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/editor/editloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "commands.h"
#include "font.h"
#include "game.h"
#include "guichan.h"
#include "interface.h"
#include "iolib.h"
#include "map.h"
Expand All @@ -65,6 +64,7 @@
#include "video.h"
#include "widgets.h"

#include <guichan.h>

extern void DoScrollArea(int state, bool fast, bool isKeyboard);
extern void DrawGuichanWidgets();
Expand Down
3 changes: 1 addition & 2 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
-- Includes
----------------------------------------------------------------------------*/

#include "SDL_image.h"

#include "stratagus.h"

#include "game.h"
Expand Down Expand Up @@ -76,6 +74,7 @@
#include "version.h"
#include "video.h"

#include <SDL_image.h>

extern void CleanGame();

Expand Down
2 changes: 1 addition & 1 deletion src/include/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class COrder

bool ParseGenericData(lua_State *l, int &j, std::string_view value);
bool HasGoal() const { return Goal != nullptr; }
CUnit *GetGoal() const { return Goal; };
CUnit *GetGoal() const { return Goal; }
void SetGoal(CUnit *const new_goal);
void ClearGoal();

Expand Down
4 changes: 2 additions & 2 deletions src/include/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
----------------------------------------------------------------------------*/

#include "color.h"
#include "guichan/font.h"

#include <array>
#include <guichan/font.h>
#include <string>
#include <SDL.h>

Expand All @@ -82,7 +82,7 @@ class CFont : public gcn::Font
{}

public:
virtual ~CFont();
~CFont() override;

static CFont *New(const std::string &ident, CGraphic *g);
static CFont *Get(std::string_view ident);
Expand Down
3 changes: 1 addition & 2 deletions src/include/fow_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@
#ifndef __FOW_UTILS_H__
#define __FOW_UTILS_H__

#include <SDL.h>
#include <cstdint>
#include <vector>
#include "SDL.h"


//@{

Expand Down
5 changes: 3 additions & 2 deletions src/include/iolib.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
-- Includes
----------------------------------------------------------------------------*/

#include "filesystem.h"

#include <SDL.h>
#include <memory>
#include <vector>
#include "filesystem.h"
#include "SDL.h"

/*----------------------------------------------------------------------------
-- Definitons
Expand Down
16 changes: 8 additions & 8 deletions src/include/mdns.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@

class MDNS {
public:
MDNS() : serviceSocket(-1), queryId(-1), numSockets(-1) { };
~MDNS();
MDNS() = default;
~MDNS();

void AnswerServerQueries();
void QueryServers(std::function<void(char*)> callback);
void AnswerServerQueries();
void QueryServers(std::function<void(char *)> callback);

private:
int serviceSocket;
int queryId;
int querySockets[20];
int numSockets;
int serviceSocket = -1;
int queryId = -1;
int querySockets[20]{};
int numSockets = -1;
};
67 changes: 34 additions & 33 deletions src/include/movie.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@

//@{

#include "SDL.h"
#include "guichan.h"
#include <SDL.h>
#include <guichan.h>

#ifdef USE_VORBIS

/*----------------------------------------------------------------------------
Expand Down Expand Up @@ -87,28 +88,27 @@ struct OggData {
class Movie : public gcn::Image
{
public:
Movie() : rect(nullptr), yuv_overlay(nullptr), surface(nullptr), need_data(true), start_time(0),
is_dirty(true), Width(0), Height(0), data(nullptr), f(nullptr) {};
~Movie();
bool Load(const std::string &filename, int w, int h);
bool IsPlaying() const { return is_dirty; }

//guichan
virtual void *_getData() const;
virtual int getWidth() const { return Width; }
virtual int getHeight() const { return Height; }
virtual bool isDirty() const { return is_dirty; }

int Width;
int Height;
SDL_Surface *surface;
CFile *f;
mutable bool is_dirty;
mutable bool need_data;
mutable Uint32 start_time;
mutable OggData *data;
mutable SDL_Rect *rect;
mutable SDL_Texture *yuv_overlay;
Movie() = default;
~Movie();
bool Load(const std::string &filename, int w, int h);
bool IsPlaying() const { return is_dirty; }

// guichan
void *_getData() const override;
int getWidth() const override { return Width; }
int getHeight() const override { return Height; }
bool isDirty() const override { return is_dirty; }

int Width = 0;
int Height = 0;
SDL_Surface *surface = nullptr;
CFile *f = nullptr;
mutable bool is_dirty = true;
mutable bool need_data = true;
mutable Uint32 start_time = 0;
mutable OggData *data = nullptr;
mutable SDL_Rect *rect = nullptr;
mutable SDL_Texture *yuv_overlay = nullptr;
};
#endif

Expand All @@ -133,15 +133,16 @@ extern int VorbisProcessData(OggData *data, char *buffer);
class Movie : public gcn::Image
{
public:
Movie() {};
~Movie() {};
bool Load(const std::string &filename, int w, int h) { return false; };
bool IsPlaying() const { return false; };
//guichan
virtual void *_getData() const { return nullptr; };
virtual int getWidth() const { return 0; };
virtual int getHeight() const { return 0; };
virtual bool isDirty() const { return false; };
Movie() {}
~Movie() {}
bool Load(const std::string &filename, int w, int h) { return false; }
bool IsPlaying() const { return false; }

// guichan
void *_getData() const override { return nullptr; }
int getWidth() const override { return 0; }
int getHeight() const override { return 0; }
bool isDirty() const override { return false; }
};
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/include/myendian.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
-- Includes
----------------------------------------------------------------------------*/

#include "SDL_byteorder.h"
#include "SDL_endian.h"
#include <SDL_byteorder.h>
#include <SDL_endian.h>

/*----------------------------------------------------------------------------
-- Macros
Expand Down
2 changes: 1 addition & 1 deletion src/include/online_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class OnlineContext {
public:
virtual ~OnlineContext() { };
virtual ~OnlineContext() = default;

// called in the sdl event loop
virtual bool handleUDP(const unsigned char *buffer, int len, CHost host) = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/include/sdl2_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

#pragma once

#include <SDL.h>
#include <memory>
#include "SDL.h"

//@{

Expand Down
5 changes: 3 additions & 2 deletions src/include/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
----------------------------------------------------------------------------*/

#include "unitsound.h"
#include "SDL.h"
#include "SDL_mixer.h"

#include <SDL.h>
#include <SDL_mixer.h>

/*----------------------------------------------------------------------------
-- Declarations
Expand Down
23 changes: 12 additions & 11 deletions src/include/tileset.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,20 @@
/*----------------------------------------------------------------------------
-- Declarations
----------------------------------------------------------------------------*/
#include "SDL_image.h"
#include "sdl2_helper.h"

#include "script.h"
#include "sdl2_helper.h"
#include "util.h"
#include "video.h"
#include "vec2i.h"
#include "script.h"
#include "video.h"

#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>

#include <SDL_image.h>
struct lua_State;

using tile_index = uint16_t;
Expand Down Expand Up @@ -344,15 +345,15 @@ class CTilesetGraphicGenerator
lua_rawgeti(luaStack, tablePos, argPos);
parseExtended(luaStack);
lua_pop(luaStack, 1);
}
bool hasIndexesOnly() const { return !Result.Indexes.empty(); };
}

bool hasIndexesOnly() const { return !Result.Indexes.empty(); }
bool isEmpty() const { return Result.Indexes.empty() && Result.Images.empty(); }

graphic_index pullOutIndex()
{
if (Result.Indexes.empty()) {
return 0;
return 0;
}
const graphic_index index {Result.Indexes.front()};
Result.Indexes.pop();
Expand Down Expand Up @@ -433,8 +434,8 @@ class CTilesetParser
CGraphic::Free(SrcImgGraphic);
}
}
const std::map<tile_index, CTile> &getTiles() const { return ExtTiles; };
const sequence_of_images& getGraphic() const { return ExtGraphic; };
const std::map<tile_index, CTile> &getTiles() const { return ExtTiles; }
const sequence_of_images& getGraphic() const { return ExtGraphic; }

static std::vector<tile_index> parseDstRange(lua_State *luaStack, const int tablePos, const int argPos);
static std::vector<tile_index> parseTilesRange(lua_State *luaStack, const int parseFromPos = 1);
Expand Down
2 changes: 1 addition & 1 deletion src/include/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class CFiller
return ((bstore[y + x_index] & (1 << x)) == 0);
}
return false;
};
}

int Width = 0;
int Height = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/include/unit_find.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
class CUnitFilter
{
public:
bool operator()(const CUnit *unit) const { return true; };
bool operator()(const CUnit *) const { return true; }
};

class NoFilter : public CUnitFilter
Expand Down
4 changes: 2 additions & 2 deletions src/include/unittype.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ class CBuildRestrictionHasUnit : public CBuildRestriction
public:
CBuildRestrictionHasUnit() = default;

void Init() override { this->RestrictType = &UnitTypeByIdent(this->RestrictTypeName); };
void Init() override { this->RestrictType = &UnitTypeByIdent(this->RestrictTypeName); }
bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const override;

int Count = 0;
Expand All @@ -481,7 +481,7 @@ class CBuildRestrictionSurroundedBy : public CBuildRestriction
public:
CBuildRestrictionSurroundedBy() = default;

void Init() override { this->RestrictType = &UnitTypeByIdent(this->RestrictTypeName); };
void Init() override { this->RestrictType = &UnitTypeByIdent(this->RestrictTypeName); }
bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const override;

int Distance = 0;
Expand Down
Loading

0 comments on commit a5c2e61

Please sign in to comment.