Skip to content

Commit

Permalink
Merge pull request #662 from Wargus/clean_up
Browse files Browse the repository at this point in the history
Clean up
  • Loading branch information
Jarod42 authored Apr 30, 2024
2 parents cd1f04a + d001986 commit ca579fd
Show file tree
Hide file tree
Showing 48 changed files with 135 additions and 145 deletions.
6 changes: 3 additions & 3 deletions gameheaders/stratagus-game-launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ static void ExtractData(char *extractor_tool,
}
} else {
// we cannot test if this is an innoextract installer, assume not but maybe warn
if (datafile.compare("INSTALL.EXE") == 0 || datafile.compare("install.exe") == 0
|| datafile.compare("INSTALL.exe") == 0 || datafile.compare("SETUP.EXE") == 0
|| datafile.compare("setup.exe") == 0 || datafile.compare("SETUP.exe") == 0) {
if (datafile == "INSTALL.EXE" || datafile == "install.exe"
|| datafile == "INSTALL.exe" || datafile == "SETUP.EXE"
|| datafile == "setup.exe" || datafile == "SETUP.exe") {
// probably not a packaged installer
} else {
// warn
Expand Down
18 changes: 8 additions & 10 deletions src/action/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
-- Includes
----------------------------------------------------------------------------*/

#include <time.h>

#include "stratagus.h"
#include "version.h"

#include "actions.h"

#include "action/action_attack.h"
Expand All @@ -58,7 +53,6 @@
#include "action/action_train.h"
#include "action/action_unload.h"
#include "action/action_upgradeto.h"

#include "animation/animation_die.h"
#include "commands.h"
#include "game.h"
Expand All @@ -71,19 +65,23 @@
#include "player.h"
#include "script.h"
#include "spells.h"
#include "stratagus.h"
#include "unit.h"
#include "unit_find.h"
#include "unit_manager.h"
#include "unittype.h"
#include "version.h"

#ifdef USE_STACKTRACE
#include <stdexcept>
#include <stacktrace/call_stack.hpp>
#include <stacktrace/stack_exception.hpp>
# include <stacktrace/call_stack.hpp>
# include <stacktrace/stack_exception.hpp>
# include <stdexcept>
#else
#include "st_backtrace.h"
# include "st_backtrace.h"
#endif

#include <ctime>

/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
Expand Down
6 changes: 3 additions & 3 deletions src/ai/ai_force.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,9 @@ bool AiForce::NewRallyPoint(const Vec2i &startPos, Vec2i *resultPos)

void AiForce::Attack(const Vec2i &pos)
{
bool isDefenceForce = false;
RemoveDeadUnit();

if (Units.size() == 0) {
if (Units.empty()) {
this->Attacking = false;
this->State = AiForceAttackingState::Waiting;
return;
Expand All @@ -424,7 +423,7 @@ void AiForce::Attack(const Vec2i &pos)
// Remember the original force position so we can return there after attack
if (this->Role == AiForceRole::Defend
|| (this->Role == AiForceRole::Attack && this->State == AiForceAttackingState::Waiting)) {
this->HomePos = this->Units[this->Units.size() - 1]->tilePos;
this->HomePos = this->Units.back()->tilePos;
}
this->Attacking = true;
}
Expand All @@ -436,6 +435,7 @@ void AiForce::Attack(const Vec2i &pos)
const bool isTransporter = ranges::any_of(this->Units, [](const CUnit *unit) {
return unit->Type->CanTransport() && unit->IsAgressive() == false;
});
bool isDefenceForce = false;
if (Map.Info.IsPointOnMap(goalPos) == false) {
/* Search in entire map */
const CUnit *enemy = nullptr;
Expand Down
5 changes: 2 additions & 3 deletions src/animation/animation_die.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@
-- Includes
----------------------------------------------------------------------------*/

#include "stratagus.h"

#include "animation/animation_die.h"

#include "stratagus.h"
#include "unit.h"

#include <stdio.h>
#include <cstdio>

void CAnimation_Die::Action(CUnit &unit, int & /*move*/, int /*scale*/) const /* override */
{
Expand Down
5 changes: 2 additions & 3 deletions src/animation/animation_setplayervar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@
-- Includes
----------------------------------------------------------------------------*/

#include "stratagus.h"

#include "animation/animation_setplayervar.h"

#include "animation.h"
#include "stratagus.h"
#include "unit.h"

#include <cstdio>
#include <sstream>
#include <stdio.h>

/**
** Gets the player data.
Expand Down
6 changes: 2 additions & 4 deletions src/animation/animation_setvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,14 @@
-- Includes
----------------------------------------------------------------------------*/

#include "stratagus.h"

#include "animation/animation_setvar.h"

#include "actions.h"
#include "map.h"
#include "unit.h"
#include "unit_manager.h"
#include "map.h"

#include <stdio.h>
#include <cstdio>
#include <sstream>

void CAnimation_SetVar::Action(CUnit &unit, int & /*move*/, int /*scale*/) const /* override */
Expand Down
4 changes: 1 addition & 3 deletions src/game/replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
// Includes
//----------------------------------------------------------------------------

#include "stratagus.h"

#include "replay.h"

#include "actions.h"
Expand All @@ -56,8 +54,8 @@
#include "unittype.h"
#include "version.h"

#include <ctime>
#include <sstream>
#include <time.h>

extern fs::path ExpandPath(const std::string &path);
extern void StartMap(const std::string &filename, bool clean);
Expand Down
2 changes: 1 addition & 1 deletion src/game/savegame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#include "upgrade.h"
#include "version.h"

#include <time.h>
#include <ctime>

extern void StartMap(const std::string &filename, bool clean);

Expand Down
2 changes: 2 additions & 0 deletions src/include/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
#include "icons.h"
#endif

#include "stratagus.h"
#include "unitsound.h"
#include "vec2i.h"

#include <optional>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions src/include/iolib.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
----------------------------------------------------------------------------*/

#include "filesystem.h"
#include "stratagus.h"

#include <SDL.h>
#include <memory>
Expand Down
1 change: 1 addition & 0 deletions src/include/luacallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define LUA_CALLBACK_HEADER_FILE

#include <map>
#include <memory>
#include <string>
#include <string_view>
#include <tuple>
Expand Down
1 change: 1 addition & 0 deletions src/include/sdl2_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

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

//@{

Expand Down
2 changes: 2 additions & 0 deletions src/include/unitptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

//@{

#include <cstddef>

class CUnit;


Expand Down
1 change: 1 addition & 0 deletions src/include/unittype.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "luacallback.h"
#include "missileconfig.h"
#include "spells.h"
#include "stratagus.h"
#include "util.h"
#include "vec2i.h"

Expand Down
3 changes: 3 additions & 0 deletions src/include/upgrade_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
-- Includes
----------------------------------------------------------------------------*/

#include "settings.h"

#include <cstring>
#include <memory>
#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion src/include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ extern uint32_t fletcher32(const std::string &content);
-- Strings
----------------------------------------------------------------------------*/

#include <string.h>
#include <cstring>

#ifndef _TRUNCATE
#define _TRUNCATE ((size_t)-1)
Expand Down
11 changes: 5 additions & 6 deletions src/map/fow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,17 @@
-- Includes
----------------------------------------------------------------------------*/

#include <string.h>
#include <algorithm>

#include "stratagus.h"

#include "fow.h"

#include "../video/intern_video.h"
#include "map.h"
#include "player.h"
#include "stratagus.h"
#include "tile.h"
#include "ui.h"
#include "viewport.h"
#include "../video/intern_video.h"

#include <algorithm>

/*----------------------------------------------------------------------------
-- Defines
Expand Down
6 changes: 3 additions & 3 deletions src/map/fow_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
-- Includes
----------------------------------------------------------------------------*/

#include <string.h>
#include <algorithm>
#include "fow_utils.h"

#include "stratagus.h"
#include "fow_utils.h"

#include <algorithm>
#include <cstring>

/*----------------------------------------------------------------------------
-- Defines
Expand Down
10 changes: 5 additions & 5 deletions src/map/map_wall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
-- Includes
----------------------------------------------------------------------------*/

#include <stdio.h>

#include "stratagus.h"
#include "map.h"
#include "fov.h"
#include "map.h"
#include "player.h"
#include "stratagus.h"
#include "tileset.h"
#include "ui.h"
#include "player.h"
#include "unittype.h"

#include <cstdio>

/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/
Expand Down
2 changes: 1 addition & 1 deletion src/map/script_tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
#include "video.h"

#include <SDL_image.h>
#include <cmath>
#include <cstring>
#include <math.h>
#include <set>

/*----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/map/tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@

#include "tileset.h"

#include <limits.h>
#include <climits>

/*----------------------------------------------------------------------------
-- Variables
Expand Down
6 changes: 2 additions & 4 deletions src/missile/missile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
-- Includes
----------------------------------------------------------------------------*/

#include <math.h>

#include "stratagus.h"

#include "missile.h"

#include "action/action_spellcast.h"
Expand All @@ -57,6 +53,8 @@
#include "unittype.h"
#include "video.h"

#include <cmath>

/*----------------------------------------------------------------------------
-- Declarations
----------------------------------------------------------------------------*/
Expand Down
10 changes: 4 additions & 6 deletions src/missile/missile_parabolic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,14 @@
-- Includes
----------------------------------------------------------------------------*/

#include <stdio.h>

#include "stratagus.h"

#include "missile.h"

#include "luacallback.h"
#include "map.h"
#include "missile.h"
#include "stratagus.h"
#include "unit_find.h"

#include <cstdio>

/**
** Calculate parabolic trajectories.
**
Expand Down
9 changes: 3 additions & 6 deletions src/missile/missile_tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,14 @@
-- Includes
----------------------------------------------------------------------------*/

#include <stdio.h>

#include "stratagus.h"

#include "missile.h"

#include "luacallback.h"
#include "map.h"
#include "missile.h"
#include "unit.h"
#include "unit_find.h"

#include <cstdio>

/**
** Handle tracer missile.
**
Expand Down
4 changes: 2 additions & 2 deletions src/network/net_lowlevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@

#include "net_lowlevel.h"

#include <stdio.h>
#include <cerrno>
#include <cstdio>
#include <fcntl.h>
#include <errno.h>

//----------------------------------------------------------------------------
// Declarations
Expand Down
Loading

0 comments on commit ca579fd

Please sign in to comment.