Skip to content

Commit

Permalink
Header cleanup
Browse files Browse the repository at this point in the history
- Add profiler/Profiler.h to various .cpp files which didn't include it prior
- Remove some unneeded includes
- Ensure GalaxyGenerator.h doesn't require a prior include of Galaxy.h
- Don't query for equality to Pi::player in Ship-AI.cpp (removes need for Pi.h and Player.h includes)
  • Loading branch information
sturnclaw committed Nov 14, 2024
1 parent c564366 commit e5ec9df
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 22 deletions.
2 changes: 2 additions & 0 deletions src/Beam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "lua/LuaEvent.h"
#include "lua/LuaUtils.h"

#include "profiler/Profiler.h"

namespace {
static float lifetime = 0.1f;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "core/Log.h"
#include "lua/LuaEvent.h"

#include "profiler/Profiler.h"

Body::Body() :
PropertiedObject(),
m_interpPos(0.0),
Expand Down
5 changes: 4 additions & 1 deletion src/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
#include "Player.h"
#include "Sfx.h"
#include "Space.h"
#include "SpaceStation.h"

#include "galaxy/StarSystem.h"
#include "graphics/TextureBuilder.h"
#include "graphics/Types.h"
#include "graphics/RenderState.h"
#include "SpaceStation.h"

#include "profiler/Profiler.h"

using namespace Graphics;

Expand Down
2 changes: 2 additions & 0 deletions src/DeathView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "graphics/Graphics.h"
#include "graphics/Renderer.h"

#include "profiler/Profiler.h"

DeathView::DeathView(Game *game) :
View(),
m_game(game)
Expand Down
2 changes: 2 additions & 0 deletions src/HudTrail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "graphics/Renderer.h"
#include "graphics/Types.h"

#include "profiler/Profiler.h"

const float UPDATE_INTERVAL = 0.1f;
const Uint16 MAX_POINTS = 100;

Expand Down
2 changes: 2 additions & 0 deletions src/Projectile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "lua/LuaEvent.h"
#include "lua/LuaUtils.h"

#include "profiler/Profiler.h"

std::unique_ptr<Graphics::MeshObject> Projectile::s_sideMesh;
std::unique_ptr<Graphics::MeshObject> Projectile::s_glowMesh;
std::unique_ptr<Graphics::Material> Projectile::s_sideMat;
Expand Down
7 changes: 4 additions & 3 deletions src/SectorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
#include "lua/LuaRef.h"
#include "lua/LuaTable.h"
#include "matrix4x4.h"
#include <assert.h>
#include <cmath>
#include <sstream>

#include "profiler/Profiler.h"

#include <cassert>
#include <cmath>
#include <unordered_set>

SectorView::~SectorView() {}
Expand Down
4 changes: 3 additions & 1 deletion src/Sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "Ship.h"
#include "Space.h"

#include "profiler/Profiler.h"

Sensors::RadarContact::RadarContact() :
body(0),
trail(0),
Expand Down Expand Up @@ -62,7 +64,7 @@ Body* Sensors::ChooseTarget(TargetingCriteria crit, const Body* oldTarget )

if(!m_owner->IsType(ObjectType::PLAYER))
return nullptr;

const Body* currTarget = oldTarget;

m_radarContacts.sort(ContactDistanceSort);
Expand Down
6 changes: 4 additions & 2 deletions src/Sfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#include "JsonUtils.h"
#include "ModelBody.h"
#include "Pi.h"
#include "StringF.h"
#include "matrix4x4.h"

#include "core/IniConfig.h"
#include "graphics/Drawables.h"
#include "graphics/Graphics.h"
Expand All @@ -21,7 +22,8 @@
#include "graphics/TextureBuilder.h"
#include "graphics/Types.h"
#include "graphics/VertexArray.h"
#include "matrix4x4.h"

#include "profiler/Profiler.h"

using namespace Graphics;

Expand Down
2 changes: 2 additions & 0 deletions src/Shields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "scenegraph/StaticGeometry.h"
#include "scenegraph/Node.h"

#include "profiler/Profiler.h"

#include <SDL_timer.h>

REGISTER_COMPONENT_TYPE(Shields) {
Expand Down
10 changes: 3 additions & 7 deletions src/Ship-AI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@

#include "EnumStrings.h"
#include "Frame.h"
#include "Pi.h"
#include "Planet.h"
#include "Player.h"
#include "Ship.h"
#include "ShipAICmd.h"
#include "Space.h"
#include "SpaceStation.h"
#include "lua/LuaConstants.h"
#include "lua/LuaEvent.h"
#include "perlin.h"
#include "ship/Propulsion.h"

#include "profiler/Profiler.h"

// returns true if command is complete
bool Ship::AITimeStep(float timeStep)
Expand All @@ -24,7 +20,7 @@ bool Ship::AITimeStep(float timeStep)

m_decelerating = false;
if (!m_curAICmd) {
if (this == Pi::player) return true;
if (this->IsType(ObjectType::PLAYER)) return true;

// just in case the AI left it on
ClearThrusterState();
Expand Down
5 changes: 3 additions & 2 deletions src/Space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
#include "collider/CollisionSpace.h"
#include "core/Log.h"
#include "galaxy/Galaxy.h"
#include "graphics/Graphics.h"
#include "lua/LuaEvent.h"
#include "lua/LuaTimer.h"

#include "profiler/Profiler.h"

#include <algorithm>
#include <functional>

//#define DEBUG_CACHE

Expand Down
1 change: 1 addition & 0 deletions src/SpeedLines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "core/IniConfig.h"
#include "graphics/RenderState.h"
#include "graphics/Renderer.h"
#include "profiler/Profiler.h"

// default values
float SpeedLines::BOUNDS = 2000.f;
Expand Down
1 change: 1 addition & 0 deletions src/SystemView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "graphics/Types.h"

#include "imgui/imgui.h"
#include "profiler/Profiler.h"
#include "SDL_keycode.h"

using namespace Graphics;
Expand Down
1 change: 1 addition & 0 deletions src/core/Property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "Json.h"
#include "JsonUtils.h"
#include "StringHash.h"

PropertyMapWrapper::PropertyMapWrapper(PropertyMap *m) :
m_map(m)
Expand Down
2 changes: 2 additions & 0 deletions src/core/Property.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "vector2.h"
#include "vector3.h"

#include "FNV1a.h"

#include <string>
#include <string_view>
#include <type_traits>
Expand Down
1 change: 1 addition & 0 deletions src/editor/UndoSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt

#include "UndoSystem.h"
#include "core/StringHash.h"
#include "utils.h"

#define XXH_INLINE_ALL
Expand Down
2 changes: 1 addition & 1 deletion src/editor/system/GalaxyEditAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#include "SystemEditorHelpers.h"

#include "core/Log.h"
#include "core/StringHash.h"
#include "core/macros.h"
#include "editor/UndoStepType.h"
#include "editor/EditorDraw.h"

#include "galaxy/Factions.h"
#include "galaxy/Galaxy.h"
#include "galaxy/NameGenerator.h"
#include "galaxy/Sector.h"
#include "galaxy/StarSystemGenerator.h"
Expand Down
1 change: 1 addition & 0 deletions src/galaxy/GalaxyGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifndef GALAXYGENERATOR_H
#define GALAXYGENERATOR_H

#include "Galaxy.h"
#include "RefCounted.h"
#include "Sector.h"
#include "StarSystem.h"
Expand Down
4 changes: 2 additions & 2 deletions src/lua/Lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "Pi.h"

#include "LuaColor.h"
#include "LuaConsole.h"
#include "LuaConstants.h"
#include "LuaDev.h"
#include "LuaEconomy.h"
Expand Down Expand Up @@ -35,9 +34,10 @@
#include "SystemView.h"

#include "galaxy/StarSystem.h"
#include "pigui/LuaPiGui.h"
#include "scenegraph/Lua.h"

#include "profiler/Profiler.h"

namespace Lua {

LuaManager *manager = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/lua/LuaStarSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
#include "FileSystem.h"
#include "Game.h"
#include "GameSaveError.h"
#include "LuaConstants.h"
#include "LuaObject.h"
#include "LuaTable.h"
#include "LuaUtils.h"
#include "Pi.h"
#include "Planet.h"
#include "Space.h"
#include "SpaceStation.h"
#include "Star.h"
Expand All @@ -21,6 +19,8 @@
#include "galaxy/Sector.h"
#include "galaxy/StarSystem.h"

#include "profiler/Profiler.h"

/*
* Class: StarSystem
*
Expand Down
3 changes: 2 additions & 1 deletion src/test/TestProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
#include "Quaternion.h"
#include "core/Log.h"
#include "core/Property.h"
#include "profiler/Profiler.h"

#include <algorithm>
#include <string>
#include <iostream>
#include <string>
#include "doctest.h"

static constexpr uint32_t ITERATIONS = 10000;
Expand Down
1 change: 1 addition & 0 deletions src/test/TestStringName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "core/FNV1a.h"
#include "core/Log.h"
#include "core/StringHash.h"
#include "core/StringName.h"
#include "profiler/Profiler.h"

Expand Down

0 comments on commit e5ec9df

Please sign in to comment.