Browse Source

clang tidy fixes

djeada 1 tháng trước cách đây
mục cha
commit
d566aaa747
62 tập tin đã thay đổi với 623 bổ sung583 xóa
  1. 4 4
      app/controllers/command_controller.cpp
  2. 2 2
      app/controllers/command_controller.h
  3. 8 14
      app/core/game_engine.cpp
  4. 26 34
      app/core/game_engine.h
  5. 1 1
      app/core/language_manager.cpp
  6. 2 2
      app/core/language_manager.h
  7. 4 4
      app/models/audio_system_proxy.cpp
  8. 1 0
      app/models/audio_system_proxy.h
  9. 2 2
      app/models/cursor_manager.cpp
  10. 4 2
      app/utils/engine_view_helpers.h
  11. 1 1
      game/audio/AudioSystem.cpp
  12. 1 1
      game/core/world.cpp
  13. 3 8
      game/map/map_transformer.cpp
  14. 3 3
      game/map/terrain.cpp
  15. 10 9
      game/map/world_bootstrap.cpp
  16. 4 3
      game/systems/ai_system.cpp
  17. 2 2
      game/systems/ai_system/ai_snapshot_builder.cpp
  18. 3 3
      game/systems/building_collision_registry.cpp
  19. 1 1
      game/systems/camera_service.cpp
  20. 3 2
      game/systems/camera_service.h
  21. 2 1
      game/systems/capture_system.h
  22. 1 1
      game/systems/combat_system.cpp
  23. 1 1
      game/systems/combat_system.h
  24. 4 3
      game/systems/pathfinding.cpp
  25. 22 22
      game/systems/picking_service.cpp
  26. 10 8
      game/systems/picking_service.h
  27. 3 3
      game/systems/save_load_service.cpp
  28. 2 2
      game/systems/save_load_service.h
  29. 7 10
      game/systems/selection_system.cpp
  30. 1 1
      game/systems/victory_service.h
  31. 72 53
      main.cpp
  32. 7 5
      render/entity/archer_renderer.cpp
  33. 4 4
      render/entity/horse_renderer.cpp
  34. 19 19
      render/gl/backend.cpp
  35. 15 15
      render/gl/backend/cylinder_pipeline.cpp
  36. 3 3
      render/gl/backend/terrain_pipeline.cpp
  37. 13 13
      render/gl/backend/vegetation_pipeline.cpp
  38. 7 7
      render/gl/bootstrap.cpp
  39. 4 4
      render/gl/buffer.cpp
  40. 1 1
      render/gl/camera.cpp
  41. 36 25
      render/gl/gl_capabilities.h
  42. 1 1
      render/gl/mesh.cpp
  43. 4 5
      render/gl/opengl_headers.h
  44. 18 18
      render/gl/persistent_buffer.h
  45. 34 40
      render/gl/platform_gl.h
  46. 5 5
      render/gl/primitives.cpp
  47. 1 1
      render/gl/resources.cpp
  48. 1 1
      render/gl/shader.cpp
  49. 5 5
      render/gl/texture.cpp
  50. 6 6
      render/ground/biome_renderer.cpp
  51. 6 5
      render/ground/firecamp_renderer.cpp
  52. 5 3
      render/ground/ground_utils.h
  53. 7 6
      render/ground/pine_renderer.cpp
  54. 7 6
      render/ground/plant_renderer.cpp
  55. 6 6
      render/ground/riverbank_asset_renderer.cpp
  56. 7 6
      render/ground/stone_renderer.cpp
  57. 9 9
      render/ground/terrain_renderer.cpp
  58. 2 2
      tools/map_editor/editor_window.h
  59. 25 23
      ui/gl_view.cpp
  60. 82 68
      ui/qml/GameView.qml
  61. 12 7
      ui/theme.cpp
  62. 61 61
      ui/theme.h

+ 4 - 4
app/controllers/command_controller.cpp

@@ -196,8 +196,8 @@ auto CommandController::onPatrolClick(qreal sx, qreal sy, int viewportWidth,
 
   auto *cam = static_cast<Render::GL::Camera *>(camera);
   QVector3D hit;
-  if (!m_pickingService->screenToGround(QPointF(sx, sy), *cam, viewportWidth,
-                                        viewportHeight, hit)) {
+  if (!Game::Systems::PickingService::screenToGround(
+          QPointF(sx, sy), *cam, viewportWidth, viewportHeight, hit)) {
     if (m_hasPatrolFirstWaypoint) {
       clearPatrolFirstWaypoint();
       result.resetCursorToNormal = true;
@@ -260,8 +260,8 @@ auto CommandController::setRallyAtScreen(qreal sx, qreal sy, int viewportWidth,
 
   auto *cam = static_cast<Render::GL::Camera *>(camera);
   QVector3D hit;
-  if (!m_pickingService->screenToGround(QPointF(sx, sy), *cam, viewportWidth,
-                                        viewportHeight, hit)) {
+  if (!Game::Systems::PickingService::screenToGround(
+          QPointF(sx, sy), *cam, viewportWidth, viewportHeight, hit)) {
     return result;
   }
 

+ 2 - 2
app/controllers/command_controller.h

@@ -42,10 +42,10 @@ public:
                         int localOwnerId) -> CommandResult;
   void recruitNearSelected(const QString &unit_type, int localOwnerId);
 
-  [[nodiscard]] auto hasPatrolFirstWaypoint() const -> bool {
+  [[nodiscard]] bool hasPatrolFirstWaypoint() const {
     return m_hasPatrolFirstWaypoint;
   }
-  [[nodiscard]] auto getPatrolFirstWaypoint() const -> QVector3D {
+  [[nodiscard]] QVector3D getPatrolFirstWaypoint() const {
     return m_patrolFirstWaypoint;
   }
   void clearPatrolFirstWaypoint() { m_hasPatrolFirstWaypoint = false; }

+ 8 - 14
app/core/game_engine.cpp

@@ -317,7 +317,6 @@ void GameEngine::onRightClick(qreal sx, qreal sy) {
     return;
   }
 
-  // Cancel special cursor modes
   if (m_cursorManager->mode() == CursorMode::Patrol ||
       m_cursorManager->mode() == CursorMode::Attack) {
     setCursorMode(CursorMode::Normal);
@@ -326,41 +325,36 @@ void GameEngine::onRightClick(qreal sx, qreal sy) {
 
   const auto &sel = selection_system->getSelectedUnits();
   if (sel.empty()) {
-    // No units selected, right-click does nothing
+
     return;
   }
 
-  // Check if clicking on a unit (enemy or ally)
   if (m_pickingService && m_camera) {
     Engine::Core::EntityID const target_id = m_pickingService->pickUnitFirst(
         float(sx), float(sy), *m_world, *m_camera, m_viewport.width,
         m_viewport.height, 0);
 
-    if (target_id != 0u) {
+    if (target_id != 0U) {
       auto *target_entity = m_world->getEntity(target_id);
       if (target_entity != nullptr) {
         auto *target_unit =
             target_entity->getComponent<Engine::Core::UnitComponent>();
         if (target_unit != nullptr) {
-          // Check if enemy or ally
-          bool is_enemy = (target_unit->owner_id != m_runtime.localOwnerId);
-          
+
+          bool const is_enemy =
+              (target_unit->owner_id != m_runtime.localOwnerId);
+
           if (is_enemy) {
-            // Right-click on enemy: Issue attack command
+
             Game::Systems::CommandService::attack_target(*m_world, sel,
                                                          target_id, true);
             return;
-          } else {
-            // Right-click on ally: Could be interact/garrison/repair
-            // For now, just treat as empty terrain click (move nearby)
-            // Future: implement interact logic here
           }
         }
       }
     }
   }
 
-  // Right-click on empty terrain or ally: Move units to location
   if (m_pickingService && m_camera) {
     QVector3D hit;
     if (m_pickingService->screenToGround(QPointF(sx, sy), *m_camera,
@@ -578,7 +572,7 @@ auto GameEngine::enemyTroopsDefeated() const -> int {
   return m_enemyTroopsDefeated;
 }
 
-QVariantMap GameEngine::getPlayerStats(int owner_id) {
+auto GameEngine::getPlayerStats(int owner_id) -> QVariantMap {
   QVariantMap result;
 
   auto &stats_registry = Game::Systems::GlobalStatsRegistry::instance();

+ 26 - 34
app/core/game_engine.h

@@ -135,37 +135,31 @@ public:
   Q_INVOKABLE void setGameSpeed(float speed) {
     m_runtime.timeScale = std::max(0.0F, speed);
   }
-  [[nodiscard]] auto paused() const -> bool { return m_runtime.paused; }
-  [[nodiscard]] auto timeScale() const -> float { return m_runtime.timeScale; }
-  [[nodiscard]] auto victoryState() const -> QString {
-    return m_runtime.victoryState;
-  }
-  [[nodiscard]] auto cursorMode() const -> QString;
+  [[nodiscard]] bool paused() const { return m_runtime.paused; }
+  [[nodiscard]] float timeScale() const { return m_runtime.timeScale; }
+  [[nodiscard]] QString victoryState() const { return m_runtime.victoryState; }
+  [[nodiscard]] QString cursorMode() const;
   void setCursorMode(CursorMode mode);
   void setCursorMode(const QString &mode);
-  [[nodiscard]] auto globalCursorX() const -> qreal;
-  [[nodiscard]] auto globalCursorY() const -> qreal;
-  [[nodiscard]] auto hasUnitsSelected() const -> bool;
-  [[nodiscard]] auto playerTroopCount() const -> int;
-  [[nodiscard]] auto max_troops_per_player() const -> int {
+  [[nodiscard]] qreal globalCursorX() const;
+  [[nodiscard]] qreal globalCursorY() const;
+  [[nodiscard]] bool hasUnitsSelected() const;
+  [[nodiscard]] int playerTroopCount() const;
+  [[nodiscard]] int max_troops_per_player() const {
     return m_level.max_troops_per_player;
   }
-  [[nodiscard]] auto enemyTroopsDefeated() const -> int;
+  [[nodiscard]] int enemyTroopsDefeated() const;
 
   Q_INVOKABLE [[nodiscard]] static QVariantMap getPlayerStats(int owner_id);
 
-  [[nodiscard]] auto selectedPlayerId() const -> int {
-    return m_selectedPlayerId;
-  }
+  [[nodiscard]] int selectedPlayerId() const { return m_selectedPlayerId; }
   void setSelectedPlayerId(int id) {
     if (m_selectedPlayerId != id) {
       m_selectedPlayerId = id;
       emit selectedPlayerIdChanged();
     }
   }
-  [[nodiscard]] auto lastError() const -> QString {
-    return m_runtime.lastError;
-  }
+  [[nodiscard]] QString lastError() const { return m_runtime.lastError; }
   Q_INVOKABLE void clearError() {
     if (!m_runtime.lastError.isEmpty()) {
       m_runtime.lastError = "";
@@ -179,7 +173,7 @@ public:
   Q_INVOKABLE [[nodiscard]] QString getSelectedUnitsCommandMode() const;
   Q_INVOKABLE void setRallyAtScreen(qreal sx, qreal sy);
   Q_INVOKABLE [[nodiscard]] QVariantList availableMaps() const;
-  [[nodiscard]] auto mapsLoading() const -> bool { return m_mapsLoading; }
+  [[nodiscard]] bool mapsLoading() const { return m_mapsLoading; }
   Q_INVOKABLE void
   startSkirmish(const QString &map_path,
                 const QVariantList &playerConfigs = QVariantList());
@@ -194,7 +188,7 @@ public:
   Q_INVOKABLE void exitGame();
   Q_INVOKABLE [[nodiscard]] QVariantList getOwnerInfo() const;
 
-  auto audio_system() -> QObject *;
+  QObject *audio_system();
 
   void setWindow(QQuickWindow *w) { m_window = w; }
 
@@ -203,12 +197,11 @@ public:
   void render(int pixelWidth, int pixelHeight);
 
   void getSelectedUnitIds(std::vector<Engine::Core::EntityID> &out) const;
-  auto getUnitInfo(Engine::Core::EntityID id, QString &name, int &health,
-                   int &max_health, bool &isBuilding,
-                   bool &alive) const -> bool;
+  bool getUnitInfo(Engine::Core::EntityID id, QString &name, int &health,
+                   int &max_health, bool &isBuilding, bool &alive) const;
 
-  [[nodiscard]] auto hasPatrolPreviewWaypoint() const -> bool;
-  [[nodiscard]] auto getPatrolPreviewWaypoint() const -> QVector3D;
+  [[nodiscard]] bool hasPatrolPreviewWaypoint() const;
+  [[nodiscard]] QVector3D getPatrolPreviewWaypoint() const;
 
 private:
   struct RuntimeState {
@@ -246,11 +239,11 @@ private:
     int height = 0;
   };
 
-  auto screenToGround(const QPointF &screenPt, QVector3D &outWorld) -> bool;
-  auto worldToScreen(const QVector3D &world, QPointF &outScreen) const -> bool;
+  bool screenToGround(const QPointF &screenPt, QVector3D &outWorld);
+  bool worldToScreen(const QVector3D &world, QPointF &outScreen) const;
   void syncSelectionFlags();
   static void resetMovement(Engine::Core::Entity *entity);
-  auto selectedUnitsModel() -> QObject *;
+  QObject *selectedUnitsModel();
   void onUnitSpawned(const Engine::Core::UnitSpawnedEvent &event);
   void onUnitDied(const Engine::Core::UnitDiedEvent &event);
   void rebuildEntityCache();
@@ -259,12 +252,11 @@ private:
   void restoreEnvironmentFromMetadata(const QJsonObject &metadata);
   void updateCursor(Qt::CursorShape newCursor);
   void setError(const QString &errorMessage);
-  auto loadFromSlot(const QString &slot) -> bool;
-  auto saveToSlot(const QString &slot, const QString &title) -> bool;
-  [[nodiscard]] auto
-  toRuntimeSnapshot() const -> Game::Systems::RuntimeSnapshot;
+  bool loadFromSlot(const QString &slot);
+  bool saveToSlot(const QString &slot, const QString &title);
+  [[nodiscard]] Game::Systems::RuntimeSnapshot toRuntimeSnapshot() const;
   void applyRuntimeSnapshot(const Game::Systems::RuntimeSnapshot &snapshot);
-  [[nodiscard]] auto captureScreenshot() const -> QByteArray;
+  [[nodiscard]] QByteArray captureScreenshot() const;
 
   std::unique_ptr<Engine::Core::World> m_world;
   std::unique_ptr<Render::GL::Renderer> m_renderer;
@@ -313,7 +305,7 @@ private:
   float m_ambientCheckTimer = 0.0F;
 
   void updateAmbientState(float dt);
-  [[nodiscard]] auto isPlayerInCombat() const -> bool;
+  [[nodiscard]] bool isPlayerInCombat() const;
   static void loadAudioResources();
 signals:
   void selectedUnitsChanged();

+ 1 - 1
app/core/language_manager.cpp

@@ -59,7 +59,7 @@ void LanguageManager::loadLanguage(const QString &language) {
   }
 }
 
-QString LanguageManager::languageDisplayName(const QString &language) {
+auto LanguageManager::languageDisplayName(const QString &language) -> QString {
   if (language == "en") {
     return "English";
   }

+ 2 - 2
app/core/language_manager.h

@@ -14,8 +14,8 @@ public:
   explicit LanguageManager(QObject *parent = nullptr);
   ~LanguageManager() override;
 
-  [[nodiscard]] auto currentLanguage() const -> QString;
-  [[nodiscard]] auto availableLanguages() const -> QStringList;
+  [[nodiscard]] QString currentLanguage() const;
+  [[nodiscard]] QStringList availableLanguages() const;
 
   Q_INVOKABLE void setLanguage(const QString &language);
   Q_INVOKABLE [[nodiscard]] static QString

+ 4 - 4
app/models/audio_system_proxy.cpp

@@ -22,19 +22,19 @@ void AudioSystemProxy::setVoiceVolume(float volume) {
   AudioSystem::getInstance().setVoiceVolume(volume);
 }
 
-float AudioSystemProxy::getMasterVolume() {
+auto AudioSystemProxy::getMasterVolume() -> float {
   return AudioSystem::getInstance().getMasterVolume();
 }
 
-float AudioSystemProxy::getMusicVolume() {
+auto AudioSystemProxy::getMusicVolume() -> float {
   return AudioSystem::getInstance().getMusicVolume();
 }
 
-float AudioSystemProxy::getSoundVolume() {
+auto AudioSystemProxy::getSoundVolume() -> float {
   return AudioSystem::getInstance().getSoundVolume();
 }
 
-float AudioSystemProxy::getVoiceVolume() {
+auto AudioSystemProxy::getVoiceVolume() -> float {
   return AudioSystem::getInstance().getVoiceVolume();
 }
 

+ 1 - 0
app/models/audio_system_proxy.h

@@ -6,6 +6,7 @@ namespace App::Models {
 
 class AudioSystemProxy : public QObject {
   Q_OBJECT
+
 public:
   explicit AudioSystemProxy(QObject *parent = nullptr);
   ~AudioSystemProxy() override = default;

+ 2 - 2
app/models/cursor_manager.cpp

@@ -45,7 +45,7 @@ void CursorManager::updateCursorShape(QQuickWindow *window) {
   }
 }
 
-qreal CursorManager::globalCursorX(QQuickWindow *window) {
+auto CursorManager::globalCursorX(QQuickWindow *window) -> qreal {
   if (window == nullptr) {
     return 0;
   }
@@ -54,7 +54,7 @@ qreal CursorManager::globalCursorX(QQuickWindow *window) {
   return local_pos.x();
 }
 
-qreal CursorManager::globalCursorY(QQuickWindow *window) {
+auto CursorManager::globalCursorY(QQuickWindow *window) -> qreal {
   if (window == nullptr) {
     return 0;
   }

+ 4 - 2
app/utils/engine_view_helpers.h

@@ -19,7 +19,8 @@ inline auto screenToGround(const Game::Systems::PickingService *pickingService,
   }
   int const w = (viewportWidth > 0 ? viewportWidth : window->width());
   int const h = (viewportHeight > 0 ? viewportHeight : window->height());
-  return pickingService->screenToGround(*camera, w, h, screenPt, outWorld);
+  return Game::Systems::PickingService::screenToGround(*camera, w, h, screenPt,
+                                                       outWorld);
 }
 
 inline auto worldToScreen(const Game::Systems::PickingService *pickingService,
@@ -33,7 +34,8 @@ inline auto worldToScreen(const Game::Systems::PickingService *pickingService,
   }
   int const w = (viewportWidth > 0 ? viewportWidth : window->width());
   int const h = (viewportHeight > 0 ? viewportHeight : window->height());
-  return pickingService->worldToScreen(*camera, w, h, world, outScreen);
+  return Game::Systems::PickingService::worldToScreen(*camera, w, h, world,
+                                                      outScreen);
 }
 
 } // namespace App::Utils

+ 1 - 1
game/audio/AudioSystem.cpp

@@ -6,8 +6,8 @@
 #include <QDebug>
 #include <algorithm>
 #include <chrono>
+#include <cmath>
 #include <cstddef>
-#include <math.h>
 #include <memory>
 #include <mutex>
 #include <qglobal.h>

+ 1 - 1
game/core/world.cpp

@@ -139,7 +139,7 @@ auto World::getEnemyUnits(int owner_id) const -> std::vector<Entity *> {
   return result;
 }
 
-int World::countTroopsForPlayer(int owner_id) {
+auto World::countTroopsForPlayer(int owner_id) -> int {
   return Game::Systems::TroopCountRegistry::instance().getTroopCount(owner_id);
 }
 

+ 3 - 8
game/map/map_transformer.cpp

@@ -79,13 +79,9 @@ auto MapTransformer::applyToWorld(
   }
 
   for (int const player_id : unique_player_ids) {
-    bool const has_team_override =
-        (s_player_team_overrides.find(player_id) !=
-         s_player_team_overrides.end());
+    bool const has_team_override = (s_player_team_overrides.find(player_id) !=
+                                    s_player_team_overrides.end());
 
-    // Skip players not in the configuration (only when overrides are provided)
-    // This ensures only selected players spawn, while maintaining backward
-    // compatibility when no overrides are set.
     if (!s_player_team_overrides.empty() && !has_team_override) {
       continue;
     }
@@ -123,8 +119,7 @@ auto MapTransformer::applyToWorld(
   }
 
   for (const auto &s : def.spawns) {
-    // Determine the effective player_id for this spawn
-    // If player is not in configuration, spawn as neutral
+
     int effective_player_id = s.player_id;
     if (!s_player_team_overrides.empty() &&
         s.player_id != Game::Core::NEUTRAL_OWNER_ID) {

+ 3 - 3
game/map/terrain.cpp

@@ -3,7 +3,6 @@
 #include <cmath>
 #include <cstddef>
 #include <cstdint>
-#include <math.h>
 #include <numbers>
 #include <vector>
 
@@ -448,8 +447,9 @@ auto TerrainHeightMap::inBounds(int x, int z) const -> bool {
   return x >= 0 && x < m_width && z >= 0 && z < m_height;
 }
 
-float TerrainHeightMap::calculateFeatureHeight(const TerrainFeature &feature,
-                                               float world_x, float world_z) {
+auto TerrainHeightMap::calculateFeatureHeight(const TerrainFeature &feature,
+                                              float world_x,
+                                              float world_z) -> float {
   float const dx = world_x - feature.center_x;
   float const dz = world_z - feature.center_z;
   float const dist = std::sqrt(dx * dx + dz * dz);

+ 10 - 9
game/map/world_bootstrap.cpp

@@ -10,15 +10,16 @@ auto WorldBootstrap::initialize(Render::GL::Renderer &renderer,
                                 QString *out_error) -> bool {
   if (!Render::GL::RenderBootstrap::initialize(renderer, camera)) {
     if (out_error != nullptr) {
-      *out_error = "Failed to initialize OpenGL renderer.\n\n"
-                   "This usually means:\n"
-                   "1. Running in software rendering mode (QT_QUICK_BACKEND=software)\n"
-                   "2. Graphics drivers don't support required OpenGL version\n"
-                   "3. Running in a VM with incomplete OpenGL support\n\n"
-                   "To fix:\n"
-                   "- For full 3D functionality, run without QT_QUICK_BACKEND set\n"
-                   "- Update graphics drivers\n"
-                   "- On VMs: Enable 3D acceleration in VM settings";
+      *out_error =
+          "Failed to initialize OpenGL renderer.\n\n"
+          "This usually means:\n"
+          "1. Running in software rendering mode (QT_QUICK_BACKEND=software)\n"
+          "2. Graphics drivers don't support required OpenGL version\n"
+          "3. Running in a VM with incomplete OpenGL support\n\n"
+          "To fix:\n"
+          "- For full 3D functionality, run without QT_QUICK_BACKEND set\n"
+          "- Update graphics drivers\n"
+          "- On VMs: Enable 3D acceleration in VM settings";
     }
     return false;
   }

+ 4 - 3
game/systems/ai_system.cpp

@@ -89,8 +89,8 @@ void AISystem::update(Engine::Core::World *world, float deltaTime) {
       continue;
     }
 
-    AI::AISnapshot snapshot =
-        m_snapshotBuilder.build(*world, ai.context.player_id);
+    AI::AISnapshot snapshot = Game::Systems::AI::AISnapshotBuilder::build(
+        *world, ai.context.player_id);
     snapshot.gameTime = m_totalGameTime;
 
     AI::AIJob job;
@@ -119,7 +119,8 @@ void AISystem::processResults(Engine::Core::World &world) {
       auto filtered_commands =
           m_commandFilter.filter(result.commands, m_totalGameTime);
 
-      m_applier.apply(world, ai.context.player_id, filtered_commands);
+      Game::Systems::AI::AICommandApplier::apply(world, ai.context.player_id,
+                                                 filtered_commands);
 
       results.pop();
     }

+ 2 - 2
game/systems/ai_system/ai_snapshot_builder.cpp

@@ -6,8 +6,8 @@
 
 namespace Game::Systems::AI {
 
-AISnapshot AISnapshotBuilder::build(const Engine::Core::World &world,
-                                    int aiOwnerId) {
+auto AISnapshotBuilder::build(const Engine::Core::World &world,
+                              int aiOwnerId) -> AISnapshot {
   AISnapshot snapshot;
   snapshot.player_id = aiOwnerId;
 

+ 3 - 3
game/systems/building_collision_registry.cpp

@@ -129,9 +129,9 @@ auto BuildingCollisionRegistry::isPointInBuilding(
   return false;
 }
 
-std::vector<std::pair<int, int>>
-BuildingCollisionRegistry::getOccupiedGridCells(
-    const BuildingFootprint &footprint, float gridCellSize) {
+auto BuildingCollisionRegistry::getOccupiedGridCells(
+    const BuildingFootprint &footprint,
+    float gridCellSize) -> std::vector<std::pair<int, int>> {
   std::vector<std::pair<int, int>> cells;
 
   float const half_width = footprint.width / 2.0F;

+ 1 - 1
game/systems/camera_service.cpp

@@ -37,7 +37,7 @@ void CameraService::zoom(Render::GL::Camera &camera, float delta) {
   m_controller->zoomDistance(camera, delta);
 }
 
-float CameraService::getDistance(const Render::GL::Camera &camera) {
+auto CameraService::getDistance(const Render::GL::Camera &camera) -> float {
   return camera.getDistance();
 }
 

+ 3 - 2
game/systems/camera_service.h

@@ -33,8 +33,9 @@ public:
   void setFollowLerp(Render::GL::Camera &camera, float alpha);
   [[nodiscard]] static auto
   getDistance(const Render::GL::Camera &camera) -> float;
-  void resetCamera(Render::GL::Camera &camera, Engine::Core::World &world,
-                   int localOwnerId, unsigned int playerUnitId);
+  static void resetCamera(Render::GL::Camera &camera,
+                          Engine::Core::World &world, int localOwnerId,
+                          unsigned int playerUnitId);
   static void snapToEntity(Render::GL::Camera &camera,
                            Engine::Core::Entity &entity);
   void updateFollow(Render::GL::Camera &camera, Engine::Core::World &world,

+ 2 - 1
game/systems/capture_system.h

@@ -14,7 +14,8 @@ public:
   void update(Engine::Core::World *world, float deltaTime) override;
 
 private:
-  void processBarrackCapture(Engine::Core::World *world, float deltaTime);
+  static void processBarrackCapture(Engine::Core::World *world,
+                                    float deltaTime);
   static auto countNearbyTroops(Engine::Core::World *world, float barrack_x,
                                 float barrack_z, int owner_id,
                                 float radius) -> int;

+ 1 - 1
game/systems/combat_system.cpp

@@ -888,7 +888,7 @@ auto CombatSystem::isUnitIdle(Engine::Core::Entity *unit) -> bool {
   }
 
   auto *patrol = unit->getComponent<Engine::Core::PatrolComponent>();
-  return !(patrol && patrol->patrolling);
+  return !((patrol != nullptr) && patrol->patrolling);
 }
 
 auto CombatSystem::findNearestEnemy(Engine::Core::Entity *unit,

+ 1 - 1
game/systems/combat_system.h

@@ -15,7 +15,7 @@ public:
   void update(Engine::Core::World *world, float deltaTime) override;
 
 private:
-  void processAttacks(Engine::Core::World *world, float deltaTime);
+  static void processAttacks(Engine::Core::World *world, float deltaTime);
   static void updateCombatMode(Engine::Core::Entity *attacker,
                                Engine::Core::World *world,
                                Engine::Core::AttackComponent *attack_comp);

+ 4 - 3
game/systems/pathfinding.cpp

@@ -99,7 +99,8 @@ void Pathfinding::updateBuildingObstacles() {
   const auto &buildings = registry.getAllBuildings();
 
   for (const auto &building : buildings) {
-    auto cells = registry.getOccupiedGridCells(building, m_gridCellSize);
+    auto cells = Game::Systems::BuildingCollisionRegistry::getOccupiedGridCells(
+        building, m_gridCellSize);
     for (const auto &cell : cells) {
       int const grid_x =
           static_cast<int>(std::round(cell.first - m_gridOffsetX));
@@ -240,7 +241,7 @@ auto Pathfinding::findPathInternal(const Point &start,
   return path;
 }
 
-int Pathfinding::calculateHeuristic(const Point &a, const Point &b) {
+auto Pathfinding::calculateHeuristic(const Point &a, const Point &b) -> int {
   return std::abs(a.x - b.x) + std::abs(a.y - b.y);
 }
 
@@ -399,7 +400,7 @@ void Pathfinding::buildPath(int startIndex, int endIndex,
   outPath.clear();
 }
 
-bool Pathfinding::heapLess(const QueueNode &lhs, const QueueNode &rhs) {
+auto Pathfinding::heapLess(const QueueNode &lhs, const QueueNode &rhs) -> bool {
   if (lhs.fCost != rhs.fCost) {
     return lhs.fCost < rhs.fCost;
   }

+ 22 - 22
game/systems/picking_service.cpp

@@ -11,15 +11,15 @@
 
 namespace Game::Systems {
 
-bool PickingService::worldToScreen(const Render::GL::Camera &cam, int viewW,
+auto PickingService::worldToScreen(const Render::GL::Camera &cam, int viewW,
                                    int viewH, const QVector3D &world,
-                                   QPointF &out) {
+                                   QPointF &out) -> bool {
   return cam.worldToScreen(world, qreal(viewW), qreal(viewH), out);
 }
 
-bool PickingService::screenToGround(const Render::GL::Camera &cam, int viewW,
+auto PickingService::screenToGround(const Render::GL::Camera &cam, int viewW,
                                     int viewH, const QPointF &screenPt,
-                                    QVector3D &outWorld) {
+                                    QVector3D &outWorld) -> bool {
   if (viewW <= 0 || viewH <= 0) {
     return false;
   }
@@ -29,8 +29,7 @@ bool PickingService::screenToGround(const Render::GL::Camera &cam, int viewW,
 
 auto PickingService::projectBounds(const Render::GL::Camera &cam,
                                    const QVector3D &center, float hx, float hz,
-                                   int viewW, int viewH,
-                                   QRectF &out) const -> bool {
+                                   int viewW, int viewH, QRectF &out) -> bool {
   QVector3D const corners[4] = {
       QVector3D(center.x() - hx, center.y(), center.z() - hz),
       QVector3D(center.x() + hx, center.y(), center.z() - hz),
@@ -85,11 +84,10 @@ auto PickingService::updateHover(float sx, float sy, Engine::Core::World &world,
   return current_hover;
 }
 
-Engine::Core::EntityID
-PickingService::pickSingle(float sx, float sy, Engine::Core::World &world,
-                           const Render::GL::Camera &camera, int viewW,
-                           int viewH, int ownerFilter,
-                           bool preferBuildingsFirst) {
+auto PickingService::pickSingle(
+    float sx, float sy, Engine::Core::World &world,
+    const Render::GL::Camera &camera, int viewW, int viewH, int ownerFilter,
+    bool preferBuildingsFirst) -> Engine::Core::EntityID {
 
   const float base_unit_pick_radius = 30.0F;
   const float base_building_pick_radius = 30.0F;
@@ -196,28 +194,29 @@ PickingService::pickSingle(float sx, float sy, Engine::Core::World &world,
     }
   }
   if (preferBuildingsFirst) {
-    if ((best_building_id != 0u) &&
-        ((best_unit_id == 0u) || best_building_dist2 <= best_unit_dist2)) {
+    if ((best_building_id != 0U) &&
+        ((best_unit_id == 0U) || best_building_dist2 <= best_unit_dist2)) {
       return best_building_id;
     }
-    if (best_unit_id != 0u) {
+    if (best_unit_id != 0U) {
       return best_unit_id;
     }
   } else {
-    if (best_unit_id != 0u) {
+    if (best_unit_id != 0U) {
       return best_unit_id;
     }
-    if (best_building_id != 0u) {
+    if (best_building_id != 0U) {
       return best_building_id;
     }
   }
   return 0;
 }
 
-auto PickingService::pickUnitFirst(
-    float sx, float sy, Engine::Core::World &world,
-    const Render::GL::Camera &camera, int viewW, int viewH,
-    int ownerFilter) const -> Engine::Core::EntityID {
+auto PickingService::pickUnitFirst(float sx, float sy,
+                                   Engine::Core::World &world,
+                                   const Render::GL::Camera &camera, int viewW,
+                                   int viewH,
+                                   int ownerFilter) -> Engine::Core::EntityID {
 
   auto id = pickSingle(sx, sy, world, camera, viewW, viewH, ownerFilter, false);
   if (id != 0) {
@@ -227,9 +226,10 @@ auto PickingService::pickUnitFirst(
   return pickSingle(sx, sy, world, camera, viewW, viewH, ownerFilter, true);
 }
 
-std::vector<Engine::Core::EntityID> PickingService::pickInRect(
+auto PickingService::pickInRect(
     float x1, float y1, float x2, float y2, Engine::Core::World &world,
-    const Render::GL::Camera &camera, int viewW, int viewH, int ownerFilter) {
+    const Render::GL::Camera &camera, int viewW, int viewH,
+    int ownerFilter) -> std::vector<Engine::Core::EntityID> {
   float const minX = std::min(x1, x2);
   float const maxX = std::max(x1, x2);
   float const minY = std::min(y1, y2);

+ 10 - 8
game/systems/picking_service.h

@@ -28,8 +28,9 @@ public:
   static auto screenToGround(const Render::GL::Camera &camera, int viewW,
                              int viewH, const QPointF &screenPt,
                              QVector3D &outWorld) -> bool;
-  auto screenToGround(const QPointF &screenPt, const Render::GL::Camera &camera,
-                      int viewW, int viewH, QVector3D &outWorld) const -> bool {
+  static auto screenToGround(const QPointF &screenPt,
+                             const Render::GL::Camera &camera, int viewW,
+                             int viewH, QVector3D &outWorld) -> bool {
     return screenToGround(camera, viewW, viewH, screenPt, outWorld);
   }
   static auto worldToScreen(const Render::GL::Camera &camera, int viewW,
@@ -41,9 +42,10 @@ public:
                          int ownerFilter,
                          bool preferBuildingsFirst) -> Engine::Core::EntityID;
 
-  auto pickUnitFirst(float sx, float sy, Engine::Core::World &world,
-                     const Render::GL::Camera &camera, int viewW, int viewH,
-                     int ownerFilter) const -> Engine::Core::EntityID;
+  static auto pickUnitFirst(float sx, float sy, Engine::Core::World &world,
+                            const Render::GL::Camera &camera, int viewW,
+                            int viewH,
+                            int ownerFilter) -> Engine::Core::EntityID;
 
   static auto
   pickInRect(float x1, float y1, float x2, float y2, Engine::Core::World &world,
@@ -53,9 +55,9 @@ public:
 private:
   Engine::Core::EntityID m_prev_hoverId = 0;
   int m_hoverGraceTicks = 0;
-  auto projectBounds(const Render::GL::Camera &cam, const QVector3D &center,
-                     float hx, float hz, int viewW, int viewH,
-                     QRectF &out) const -> bool;
+  static auto projectBounds(const Render::GL::Camera &cam,
+                            const QVector3D &center, float hx, float hz,
+                            int viewW, int viewH, QRectF &out) -> bool;
 };
 
 } // namespace Game::Systems

+ 3 - 3
game/systems/save_load_service.cpp

@@ -39,17 +39,17 @@ SaveLoadService::SaveLoadService() {
 
 SaveLoadService::~SaveLoadService() = default;
 
-QString SaveLoadService::getSavesDirectory() {
+auto SaveLoadService::getSavesDirectory() -> QString {
   QString const savesPath =
       QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
   return savesPath + "/saves";
 }
 
-auto SaveLoadService::get_database_path() const -> QString {
+auto SaveLoadService::get_database_path() -> QString {
   return getSavesDirectory() + QStringLiteral("/saves.sqlite");
 }
 
-void SaveLoadService::ensureSavesDirectoryExists() const {
+void SaveLoadService::ensureSavesDirectoryExists() {
   QString const savesDir = getSavesDirectory();
   QDir const dir;
   if (!dir.exists(savesDir)) {

+ 2 - 2
game/systems/save_load_service.h

@@ -46,8 +46,8 @@ public:
 
 private:
   static auto getSavesDirectory() -> QString;
-  auto get_database_path() const -> QString;
-  void ensureSavesDirectoryExists() const;
+  static auto get_database_path() -> QString;
+  static void ensureSavesDirectoryExists();
 
   mutable QString m_last_error;
   QJsonObject m_lastMetadata;

+ 7 - 10
game/systems/selection_system.cpp

@@ -4,9 +4,7 @@
 #include "../core/component.h"
 #include "../core/event_manager.h"
 #include "../core/world.h"
-#include "../game_config.h"
 #include "command_service.h"
-#include "formation_planner.h"
 #include "picking_service.h"
 #include "units/spawn_type.h"
 #include <QPointF>
@@ -15,7 +13,6 @@
 #include <qglobal.h>
 #include <qobject.h>
 #include <qtmetamacros.h>
-#include <qvectornd.h>
 #include <vector>
 
 namespace Game::Systems {
@@ -73,12 +70,13 @@ void SelectionController::onClickSelect(qreal sx, qreal sy, bool additive,
   }
 
   auto *cam = static_cast<Render::GL::Camera *>(camera);
-  Engine::Core::EntityID const picked = m_pickingService->pickSingle(
-      float(sx), float(sy), *m_world, *cam, viewportWidth, viewportHeight,
-      localOwnerId, true);
+  Engine::Core::EntityID const picked =
+      Game::Systems::PickingService::pickSingle(
+          float(sx), float(sy), *m_world, *cam, viewportWidth, viewportHeight,
+          localOwnerId, true);
+
+  if (picked != 0U) {
 
-  if (picked != 0u) {
-    // Clicked on a unit or building - select it
     if (!additive) {
       m_selection_system->clearSelection();
     }
@@ -88,7 +86,6 @@ void SelectionController::onClickSelect(qreal sx, qreal sy, bool additive,
     return;
   }
 
-  // Clicked on empty terrain - deselect all units
   if (!additive && !m_selection_system->getSelectedUnits().empty()) {
     m_selection_system->clearSelection();
     syncSelectionFlags();
@@ -110,7 +107,7 @@ void SelectionController::onAreaSelected(qreal x1, qreal y1, qreal x2, qreal y2,
   }
 
   auto *cam = static_cast<Render::GL::Camera *>(camera);
-  auto picked = m_pickingService->pickInRect(
+  auto picked = Game::Systems::PickingService::pickInRect(
       float(x1), float(y1), float(x2), float(y2), *m_world, *cam, viewportWidth,
       viewportHeight, localOwnerId);
   for (auto id : picked) {

+ 1 - 1
game/systems/victory_service.h

@@ -55,7 +55,7 @@ private:
   void checkDefeatConditions(Engine::Core::World &world);
 
   auto checkElimination(Engine::Core::World &world) -> bool;
-  auto checkSurviveTime() const -> bool;
+  [[nodiscard]] auto checkSurviveTime() const -> bool;
   auto checkNoUnits(Engine::Core::World &world) const -> bool;
   auto checkNoKeyStructures(Engine::Core::World &world) -> bool;
 

+ 72 - 53
main.cpp

@@ -4,9 +4,9 @@
 #include <QDir>
 #include <QFile>
 #include <QGuiApplication>
+#include <QOffscreenSurface>
 #include <QOpenGLContext>
 #include <QOpenGLFunctions>
-#include <QOffscreenSurface>
 #include <QQmlApplicationEngine>
 #include <QQmlContext>
 #include <QQuickWindow>
@@ -14,20 +14,23 @@
 #include <QSurfaceFormat>
 #include <QTextStream>
 #include <QUrl>
+#include <cstdio>
 #include <qglobal.h>
 #include <qguiapplication.h>
+#include <qnamespace.h>
 #include <qobject.h>
 #include <qqml.h>
 #include <qqmlapplicationengine.h>
 #include <qsgrendererinterface.h>
 #include <qstringliteral.h>
+#include <qstringview.h>
 #include <qsurfaceformat.h>
 #include <qurl.h>
 
 #ifdef Q_OS_WIN
-#include <windows.h>
 #include <QProcess>
 #include <gl/gl.h>
+#include <windows.h>
 #pragma comment(lib, "opengl32.lib")
 #endif
 
@@ -48,25 +51,25 @@ static bool testNativeOpenGL() {
   wc.lpfnWndProc = DefWindowProcA;
   wc.hInstance = GetModuleHandle(nullptr);
   wc.lpszClassName = "OpenGLTest";
-  
+
   if (!RegisterClassA(&wc)) {
     return false;
   }
-  
-  HWND hwnd = CreateWindowExA(0, "OpenGLTest", "", WS_OVERLAPPEDWINDOW,
-                               0, 0, 1, 1, nullptr, nullptr, wc.hInstance, nullptr);
+
+  HWND hwnd = CreateWindowExA(0, "OpenGLTest", "", WS_OVERLAPPEDWINDOW, 0, 0, 1,
+                              1, nullptr, nullptr, wc.hInstance, nullptr);
   if (!hwnd) {
     UnregisterClassA("OpenGLTest", wc.hInstance);
     return false;
   }
-  
+
   HDC hdc = GetDC(hwnd);
   if (!hdc) {
     DestroyWindow(hwnd);
     UnregisterClassA("OpenGLTest", wc.hInstance);
     return false;
   }
-  
+
   PIXELFORMATDESCRIPTOR pfd = {};
   pfd.nSize = sizeof(pfd);
   pfd.nVersion = 1;
@@ -76,53 +79,57 @@ static bool testNativeOpenGL() {
   pfd.cDepthBits = 24;
   pfd.cStencilBits = 8;
   pfd.iLayerType = PFD_MAIN_PLANE;
-  
+
   int pixelFormat = ChoosePixelFormat(hdc, &pfd);
   bool success = false;
-  
+
   if (pixelFormat != 0 && SetPixelFormat(hdc, pixelFormat, &pfd)) {
     HGLRC hglrc = wglCreateContext(hdc);
     if (hglrc) {
       if (wglMakeCurrent(hdc, hglrc)) {
         // Successfully created OpenGL context
-        const char* vendor = (const char*)glGetString(GL_VENDOR);
-        const char* renderer = (const char*)glGetString(GL_RENDERER);
-        const char* version = (const char*)glGetString(GL_VERSION);
-        
+        const char *vendor = (const char *)glGetString(GL_VENDOR);
+        const char *renderer = (const char *)glGetString(GL_RENDERER);
+        const char *version = (const char *)glGetString(GL_VERSION);
+
         if (vendor && renderer && version) {
-          fprintf(stderr, "[OpenGL Test] Native context created successfully\n");
+          fprintf(stderr,
+                  "[OpenGL Test] Native context created successfully\n");
           fprintf(stderr, "[OpenGL Test] Vendor: %s\n", vendor);
           fprintf(stderr, "[OpenGL Test] Renderer: %s\n", renderer);
           fprintf(stderr, "[OpenGL Test] Version: %s\n", version);
           success = true;
         }
-        
+
         wglMakeCurrent(nullptr, nullptr);
       }
       wglDeleteContext(hglrc);
     }
   }
-  
+
   ReleaseDC(hwnd, hdc);
   DestroyWindow(hwnd);
   UnregisterClassA("OpenGLTest", wc.hInstance);
-  
+
   return success;
 }
 
 // Windows crash handler to detect OpenGL failures and suggest fallback
 static bool g_opengl_crashed = false;
-static LONG WINAPI crashHandler(EXCEPTION_POINTERS* exceptionInfo) {
-  if (exceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
+static LONG WINAPI crashHandler(EXCEPTION_POINTERS *exceptionInfo) {
+  if (exceptionInfo->ExceptionRecord->ExceptionCode ==
+      EXCEPTION_ACCESS_VIOLATION) {
     // Log crash
-    FILE* crash_log = fopen("opengl_crash.txt", "w");
+    FILE *crash_log = fopen("opengl_crash.txt", "w");
     if (crash_log) {
-      fprintf(crash_log, "OpenGL/Qt rendering crash detected (Access Violation)\n");
+      fprintf(crash_log,
+              "OpenGL/Qt rendering crash detected (Access Violation)\n");
       fprintf(crash_log, "Try running with: run_debug_softwaregl.cmd\n");
-      fprintf(crash_log, "Or set environment variable: QT_QUICK_BACKEND=software\n");
+      fprintf(crash_log,
+              "Or set environment variable: QT_QUICK_BACKEND=software\n");
       fclose(crash_log);
     }
-    
+
     qCritical() << "=== CRASH DETECTED ===";
     qCritical() << "OpenGL rendering failed. This usually means:";
     qCritical() << "1. Graphics drivers are outdated";
@@ -131,7 +138,7 @@ static LONG WINAPI crashHandler(EXCEPTION_POINTERS* exceptionInfo) {
     qCritical() << "";
     qCritical() << "To fix: Run run_debug_softwaregl.cmd instead";
     qCritical() << "Or set: set QT_QUICK_BACKEND=software";
-    
+
     g_opengl_crashed = true;
   }
   return EXCEPTION_CONTINUE_SEARCH;
@@ -142,11 +149,11 @@ auto main(int argc, char *argv[]) -> int {
 #ifdef Q_OS_WIN
   // Install crash handler to detect OpenGL failures
   SetUnhandledExceptionFilter(crashHandler);
-  
+
   // Test OpenGL BEFORE any Qt initialization (using native Win32 API)
   fprintf(stderr, "[Pre-Init] Testing native OpenGL availability...\n");
   bool opengl_available = testNativeOpenGL();
-  
+
   if (!opengl_available) {
     fprintf(stderr, "[Pre-Init] WARNING: OpenGL test failed!\n");
     fprintf(stderr, "[Pre-Init] Forcing software rendering mode\n");
@@ -155,11 +162,11 @@ auto main(int argc, char *argv[]) -> int {
   } else {
     fprintf(stderr, "[Pre-Init] OpenGL test passed\n");
   }
-  
+
   // Check if we should use software rendering
   bool use_software = qEnvironmentVariableIsSet("QT_QUICK_BACKEND") &&
                       qEnvironmentVariable("QT_QUICK_BACKEND") == "software";
-  
+
   if (use_software) {
     qInfo() << "=== SOFTWARE RENDERING MODE ===";
     qInfo() << "Using Qt Quick Software renderer (CPU-based)";
@@ -168,34 +175,43 @@ auto main(int argc, char *argv[]) -> int {
 #endif
 
   // Setup message handler for debugging
-  qInstallMessageHandler([](QtMsgType type, const QMessageLogContext &context, const QString &msg) {
-    QByteArray localMsg = msg.toLocal8Bit();
-    const char *file = context.file ? context.file : "";
-    const char *function = context.function ? context.function : "";
-    
+  qInstallMessageHandler([](QtMsgType type, const QMessageLogContext &context,
+                            const QString &msg) {
+    QByteArray const localMsg = msg.toLocal8Bit();
+    const char *file = (context.file != nullptr) ? context.file : "";
+    const char *function =
+        (context.function != nullptr) ? context.function : "";
+
     FILE *out = stderr;
     switch (type) {
     case QtDebugMsg:
-      fprintf(out, "[DEBUG] %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
+      fprintf(out, "[DEBUG] %s (%s:%u, %s)\n", localMsg.constData(), file,
+              context.line, function);
       break;
     case QtInfoMsg:
       fprintf(out, "[INFO] %s\n", localMsg.constData());
       break;
     case QtWarningMsg:
-      fprintf(out, "[WARNING] %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
+      fprintf(out, "[WARNING] %s (%s:%u, %s)\n", localMsg.constData(), file,
+              context.line, function);
       // Check for critical OpenGL warnings
-      if (msg.contains("OpenGL", Qt::CaseInsensitive) || 
+      if (msg.contains("OpenGL", Qt::CaseInsensitive) ||
           msg.contains("scene graph", Qt::CaseInsensitive) ||
           msg.contains("RHI", Qt::CaseInsensitive)) {
-        fprintf(out, "[HINT] If you see crashes, try software rendering: set QT_QUICK_BACKEND=software\n");
+        fprintf(out, "[HINT] If you see crashes, try software rendering: set "
+                     "QT_QUICK_BACKEND=software\n");
       }
       break;
     case QtCriticalMsg:
-      fprintf(out, "[CRITICAL] %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
-      fprintf(out, "[CRITICAL] Try running with software rendering if this persists\n");
+      fprintf(out, "[CRITICAL] %s (%s:%u, %s)\n", localMsg.constData(), file,
+              context.line, function);
+      fprintf(
+          out,
+          "[CRITICAL] Try running with software rendering if this persists\n");
       break;
     case QtFatalMsg:
-      fprintf(out, "[FATAL] %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
+      fprintf(out, "[FATAL] %s (%s:%u, %s)\n", localMsg.constData(), file,
+              context.line, function);
       fprintf(out, "[FATAL] === RECOVERY SUGGESTION ===\n");
       fprintf(out, "[FATAL] Run: run_debug_softwaregl.cmd\n");
       fprintf(out, "[FATAL] Or set: QT_QUICK_BACKEND=software\n");
@@ -206,7 +222,7 @@ auto main(int argc, char *argv[]) -> int {
 
   qInfo() << "=== Standard of Iron - Starting ===";
   qInfo() << "Qt version:" << QT_VERSION_STR;
-  
+
   // Linux-specific: prefer X11 over Wayland for better OpenGL compatibility
 #ifndef Q_OS_WIN
   if (qEnvironmentVariableIsSet("WAYLAND_DISPLAY") &&
@@ -232,21 +248,22 @@ auto main(int argc, char *argv[]) -> int {
   fmt.setDepthBufferSize(k_depth_buffer_bits);
   fmt.setStencilBufferSize(k_stencil_buffer_bits);
   fmt.setSamples(0);
-  
+
 #ifdef Q_OS_WIN
   // Windows: Request compatibility profile for better driver support
   // Some Windows drivers have issues with Core profile on older hardware
   fmt.setProfile(QSurfaceFormat::CompatibilityProfile);
   qInfo() << "Windows detected: Using OpenGL Compatibility Profile";
 #endif
-  
+
   QSurfaceFormat::setDefaultFormat(fmt);
-  qInfo() << "Surface format configured: OpenGL" << fmt.majorVersion() << "." << fmt.minorVersion();
+  qInfo() << "Surface format configured: OpenGL" << fmt.majorVersion() << "."
+          << fmt.minorVersion();
 
   qInfo() << "Creating QGuiApplication...";
   QGuiApplication app(argc, argv);
   qInfo() << "QGuiApplication created successfully";
-  
+
   qInfo() << "Creating LanguageManager...";
   auto *language_manager = new LanguageManager();
   qInfo() << "LanguageManager created";
@@ -273,13 +290,14 @@ auto main(int argc, char *argv[]) -> int {
   qInfo() << "Loading Main.qml...";
   qInfo() << "Loading Main.qml...";
   engine.load(QUrl(QStringLiteral("qrc:/StandardOfIron/ui/qml/Main.qml")));
-  
+
   qInfo() << "Checking if QML loaded...";
   if (engine.rootObjects().isEmpty()) {
     qWarning() << "Failed to load QML file";
     return -1;
   }
-  qInfo() << "QML loaded successfully, root objects count:" << engine.rootObjects().size();
+  qInfo() << "QML loaded successfully, root objects count:"
+          << engine.rootObjects().size();
 
   qInfo() << "Finding QQuickWindow...";
   auto *root_obj = engine.rootObjects().first();
@@ -340,9 +358,9 @@ auto main(int argc, char *argv[]) -> int {
                    });
 
   qInfo() << "Starting event loop...";
-  
-  int result = QGuiApplication::exec();
-  
+
+  int const result = QGuiApplication::exec();
+
 #ifdef Q_OS_WIN
   // Check if we crashed during OpenGL initialization
   if (g_opengl_crashed) {
@@ -352,7 +370,8 @@ auto main(int argc, char *argv[]) -> int {
     qCritical() << "========================================";
     qCritical() << "";
     qCritical() << "The application crashed during OpenGL initialization.";
-    qCritical() << "This is a known issue with Qt + some Windows graphics drivers.";
+    qCritical()
+        << "This is a known issue with Qt + some Windows graphics drivers.";
     qCritical() << "";
     qCritical() << "SOLUTION: Set environment variable before running:";
     qCritical() << "  set QT_QUICK_BACKEND=software";
@@ -363,6 +382,6 @@ auto main(int argc, char *argv[]) -> int {
     return -1;
   }
 #endif
-  
+
   return result;
 }

+ 7 - 5
render/entity/archer_renderer.cpp

@@ -12,6 +12,7 @@
 #include "../palette.h"
 #include "../scene_renderer.h"
 #include "../submitter.h"
+#include "gl/render_constants.h"
 #include "registry.h"
 #include "renderer_constants.h"
 
@@ -528,7 +529,8 @@ private:
              v.palette.leather, nullptr, 1.0F);
 
     float const j = (hash_01(seed) - 0.5F) * 0.04F;
-    float const k = (hash_01(seed ^ HashXorShift::k_golden_ratio) - 0.5F) * 0.04F;
+    float const k =
+        (hash_01(seed ^ HashXorShift::k_golden_ratio) - 0.5F) * 0.04F;
 
     QVector3D const a1 = qTop + QVector3D(0.00F + j, 0.08F, 0.00F + k);
     out.mesh(getUnitCylinder(), cylinderBetween(ctx.model, qTop, a1, 0.010F),
@@ -613,10 +615,10 @@ private:
       QVector3D const head_base = tip - forward * 0.10F;
       out.mesh(getUnitCone(), coneFromTo(ctx.model, head_base, tip, 0.05F),
                extras.metalHead, nullptr, 1.0F);
-      QVector3D f1b = tail - forward * 0.02F;
-      QVector3D f1a = f1b - forward * 0.06F;
-      QVector3D f2b = tail + forward * 0.02F;
-      QVector3D f2a = f2b + forward * 0.06F;
+      QVector3D const f1b = tail - forward * 0.02F;
+      QVector3D const f1a = f1b - forward * 0.06F;
+      QVector3D const f2b = tail + forward * 0.02F;
+      QVector3D const f2a = f2b + forward * 0.06F;
       out.mesh(getUnitCone(), coneFromTo(ctx.model, f1b, f1a, 0.04F),
                extras.fletch, nullptr, 1.0F);
       out.mesh(getUnitCone(), coneFromTo(ctx.model, f2a, f2b, 0.04F),

+ 4 - 4
render/entity/horse_renderer.cpp

@@ -48,13 +48,13 @@ inline auto saturate(float x) -> float {
 }
 
 inline auto rotateAroundY(const QVector3D &v, float angle) -> QVector3D {
-  float s = std::sin(angle);
-  float c = std::cos(angle);
+  float const s = std::sin(angle);
+  float const c = std::cos(angle);
   return {v.x() * c + v.z() * s, v.y(), -v.x() * s + v.z() * c};
 }
 inline auto rotateAroundZ(const QVector3D &v, float angle) -> QVector3D {
-  float s = std::sin(angle);
-  float c = std::cos(angle);
+  float const s = std::sin(angle);
+  float const c = std::cos(angle);
   return {v.x() * c - v.y() * s, v.x() * s + v.y() * c, v.z()};
 }
 

+ 19 - 19
render/gl/backend.cpp

@@ -17,11 +17,11 @@
 #include "ground/plant_gpu.h"
 #include "ground/stone_gpu.h"
 #include "mesh.h"
-#include "opengl_headers.h"
 #include "render_constants.h"
 #include "shader.h"
 #include "state_scopes.h"
 #include "texture.h"
+#include <GL/gl.h>
 #include <QDebug>
 #include <cmath>
 #include <cstddef>
@@ -56,7 +56,7 @@ Backend::~Backend() {
 
 void Backend::initialize() {
   qInfo() << "Backend::initialize() - Starting...";
-  
+
   qInfo() << "Backend: Initializing OpenGL functions...";
   initializeOpenGLFunctions();
   qInfo() << "Backend: OpenGL functions initialized";
@@ -77,7 +77,7 @@ void Backend::initialize() {
     qWarning() << "Backend: failed to initialize ResourceManager";
   }
   qInfo() << "Backend: ResourceManager created";
-  
+
   qInfo() << "Backend: Creating ShaderCache...";
   m_shaderCache = std::make_unique<ShaderCache>();
   m_shaderCache->initializeDefaults();
@@ -200,7 +200,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
       if (instance_count > 0 &&
           (m_cylinderPipeline->cylinderShader() != nullptr)) {
         glDepthMask(GL_TRUE);
-        if (glIsEnabled(GL_POLYGON_OFFSET_FILL) != 0u) {
+        if (glIsEnabled(GL_POLYGON_OFFSET_FILL) != 0U) {
           glDisable(GL_POLYGON_OFFSET_FILL);
         }
         Shader *cylinderShader = m_cylinderPipeline->cylinderShader();
@@ -239,7 +239,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
           m_cylinderPipeline->m_fogScratch[idx] = gpu;
         }
         glDepthMask(GL_TRUE);
-        if (glIsEnabled(GL_POLYGON_OFFSET_FILL) != 0u) {
+        if (glIsEnabled(GL_POLYGON_OFFSET_FILL) != 0U) {
           glDisable(GL_POLYGON_OFFSET_FILL);
         }
         Shader *fogShader = m_cylinderPipeline->fogShader();
@@ -263,7 +263,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
       const auto &grass = std::get<GrassBatchCmdIndex>(cmd);
       if ((grass.instanceBuffer == nullptr) || grass.instance_count == 0 ||
           (m_terrainPipeline->m_grassShader == nullptr) ||
-          (m_terrainPipeline->m_grassVao == 0u) ||
+          (m_terrainPipeline->m_grassVao == 0U) ||
           m_terrainPipeline->m_grassVertexCount == 0) {
         break;
       }
@@ -272,7 +272,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
       BlendScope const blend(true);
       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
       GLboolean const prev_cull = glIsEnabled(GL_CULL_FACE);
-      if (prev_cull != 0u) {
+      if (prev_cull != 0U) {
         glDisable(GL_CULL_FACE);
       }
 
@@ -338,7 +338,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
                             static_cast<GLsizei>(grass.instance_count));
       glBindVertexArray(0);
 
-      if (prev_cull != 0u) {
+      if (prev_cull != 0U) {
         glEnable(GL_CULL_FACE);
       }
 
@@ -352,7 +352,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
       const auto &stone = std::get<StoneBatchCmdIndex>(cmd);
       if ((stone.instanceBuffer == nullptr) || stone.instance_count == 0 ||
           (m_vegetationPipeline->stoneShader() == nullptr) ||
-          (m_vegetationPipeline->m_stoneVao == 0u) ||
+          (m_vegetationPipeline->m_stoneVao == 0U) ||
           m_vegetationPipeline->m_stoneIndexCount == 0) {
         break;
       }
@@ -410,7 +410,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
 
       if ((plant.instanceBuffer == nullptr) || plant.instance_count == 0 ||
           (m_vegetationPipeline->plantShader() == nullptr) ||
-          (m_vegetationPipeline->m_plantVao == 0u) ||
+          (m_vegetationPipeline->m_plantVao == 0U) ||
           m_vegetationPipeline->m_plantIndexCount == 0) {
         break;
       }
@@ -421,7 +421,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
       BlendScope const blend(true);
       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
       GLboolean const prev_cull = glIsEnabled(GL_CULL_FACE);
-      if (prev_cull != 0u) {
+      if (prev_cull != 0U) {
         glDisable(GL_CULL_FACE);
       }
 
@@ -483,7 +483,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
                               static_cast<GLsizei>(plant.instance_count));
       glBindVertexArray(0);
 
-      if (prev_cull != 0u) {
+      if (prev_cull != 0U) {
         glEnable(GL_CULL_FACE);
       }
 
@@ -498,7 +498,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
 
       if ((pine.instanceBuffer == nullptr) || pine.instance_count == 0 ||
           (m_vegetationPipeline->pineShader() == nullptr) ||
-          (m_vegetationPipeline->m_pineVao == 0u) ||
+          (m_vegetationPipeline->m_pineVao == 0U) ||
           m_vegetationPipeline->m_pineIndexCount == 0) {
         break;
       }
@@ -508,7 +508,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
       BlendScope const blend(true);
       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
       GLboolean const prev_cull = glIsEnabled(GL_CULL_FACE);
-      if (prev_cull != 0u) {
+      if (prev_cull != 0U) {
         glDisable(GL_CULL_FACE);
       }
 
@@ -569,7 +569,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
                               static_cast<GLsizei>(pine.instance_count));
       glBindVertexArray(0);
 
-      if (prev_cull != 0u) {
+      if (prev_cull != 0U) {
         glEnable(GL_CULL_FACE);
       }
 
@@ -585,7 +585,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
       if ((firecamp.instanceBuffer == nullptr) ||
           firecamp.instance_count == 0 ||
           (m_vegetationPipeline->firecampShader() == nullptr) ||
-          (m_vegetationPipeline->m_firecampVao == 0u) ||
+          (m_vegetationPipeline->m_firecampVao == 0U) ||
           m_vegetationPipeline->m_firecampIndexCount == 0) {
         break;
       }
@@ -595,7 +595,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
       BlendScope const blend(true);
       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
       GLboolean const prev_cull = glIsEnabled(GL_CULL_FACE);
-      if (prev_cull != 0u) {
+      if (prev_cull != 0U) {
         glDisable(GL_CULL_FACE);
       }
 
@@ -686,7 +686,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
                               static_cast<GLsizei>(firecamp.instance_count));
       glBindVertexArray(0);
 
-      if (prev_cull != 0u) {
+      if (prev_cull != 0U) {
         glEnable(GL_CULL_FACE);
       }
 
@@ -955,7 +955,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
       }
 
       glDepthMask(GL_TRUE);
-      if (glIsEnabled(GL_POLYGON_OFFSET_FILL) != 0u) {
+      if (glIsEnabled(GL_POLYGON_OFFSET_FILL) != 0U) {
         glDisable(GL_POLYGON_OFFSET_FILL);
       }
 

+ 15 - 15
render/gl/backend/cylinder_pipeline.cpp

@@ -4,7 +4,7 @@
 #include "../primitives.h"
 #include "../render_constants.h"
 #include "gl/shader_cache.h"
-#include "../opengl_headers.h"
+#include <GL/gl.h>
 #include <algorithm>
 #include <cstddef>
 #include <qopenglext.h>
@@ -174,19 +174,19 @@ void CylinderPipeline::shutdownCylinderPipeline() {
 
   m_cylinderPersistentBuffer.destroy();
 
-  if (m_cylinderInstanceBuffer != 0u) {
+  if (m_cylinderInstanceBuffer != 0U) {
     glDeleteBuffers(1, &m_cylinderInstanceBuffer);
     m_cylinderInstanceBuffer = 0;
   }
-  if (m_cylinderVertexBuffer != 0u) {
+  if (m_cylinderVertexBuffer != 0U) {
     glDeleteBuffers(1, &m_cylinderVertexBuffer);
     m_cylinderVertexBuffer = 0;
   }
-  if (m_cylinderIndexBuffer != 0u) {
+  if (m_cylinderIndexBuffer != 0U) {
     glDeleteBuffers(1, &m_cylinderIndexBuffer);
     m_cylinderIndexBuffer = 0;
   }
-  if (m_cylinderVao != 0u) {
+  if (m_cylinderVao != 0U) {
     glDeleteVertexArrays(1, &m_cylinderVao);
     m_cylinderVao = 0;
   }
@@ -213,14 +213,14 @@ void CylinderPipeline::uploadCylinderInstances(std::size_t count) {
     return;
   }
 
-  if (m_cylinderInstanceBuffer == 0u) {
+  if (m_cylinderInstanceBuffer == 0U) {
     return;
   }
 
   glBindBuffer(GL_ARRAY_BUFFER, m_cylinderInstanceBuffer);
   if (count > m_cylinderInstanceCapacity) {
     m_cylinderInstanceCapacity = std::max<std::size_t>(
-        count, (m_cylinderInstanceCapacity != 0u)
+        count, (m_cylinderInstanceCapacity != 0U)
                    ? m_cylinderInstanceCapacity * Growth::CapacityMultiplier
                    : count);
     glBufferData(GL_ARRAY_BUFFER,
@@ -234,7 +234,7 @@ void CylinderPipeline::uploadCylinderInstances(std::size_t count) {
 }
 
 void CylinderPipeline::drawCylinders(std::size_t count) {
-  if ((m_cylinderVao == 0u) || m_cylinderIndexCount == 0 || count == 0) {
+  if ((m_cylinderVao == 0U) || m_cylinderIndexCount == 0 || count == 0) {
     return;
   }
 
@@ -325,19 +325,19 @@ void CylinderPipeline::initializeFogPipeline() {
 void CylinderPipeline::shutdownFogPipeline() {
   initializeOpenGLFunctions();
 
-  if (m_fogInstanceBuffer != 0u) {
+  if (m_fogInstanceBuffer != 0U) {
     glDeleteBuffers(1, &m_fogInstanceBuffer);
     m_fogInstanceBuffer = 0;
   }
-  if (m_fogVertexBuffer != 0u) {
+  if (m_fogVertexBuffer != 0U) {
     glDeleteBuffers(1, &m_fogVertexBuffer);
     m_fogVertexBuffer = 0;
   }
-  if (m_fogIndexBuffer != 0u) {
+  if (m_fogIndexBuffer != 0U) {
     glDeleteBuffers(1, &m_fogIndexBuffer);
     m_fogIndexBuffer = 0;
   }
-  if (m_fogVao != 0u) {
+  if (m_fogVao != 0U) {
     glDeleteVertexArrays(1, &m_fogVao);
     m_fogVao = 0;
   }
@@ -347,7 +347,7 @@ void CylinderPipeline::shutdownFogPipeline() {
 }
 
 void CylinderPipeline::uploadFogInstances(std::size_t count) {
-  if ((m_fogInstanceBuffer == 0u) || count == 0) {
+  if ((m_fogInstanceBuffer == 0U) || count == 0) {
     return;
   }
 
@@ -355,7 +355,7 @@ void CylinderPipeline::uploadFogInstances(std::size_t count) {
   glBindBuffer(GL_ARRAY_BUFFER, m_fogInstanceBuffer);
   if (count > m_fogInstanceCapacity) {
     m_fogInstanceCapacity = std::max<std::size_t>(
-        count, (m_fogInstanceCapacity != 0u)
+        count, (m_fogInstanceCapacity != 0U)
                    ? m_fogInstanceCapacity * Growth::CapacityMultiplier
                    : count);
     glBufferData(GL_ARRAY_BUFFER,
@@ -369,7 +369,7 @@ void CylinderPipeline::uploadFogInstances(std::size_t count) {
 }
 
 void CylinderPipeline::drawFog(std::size_t count) {
-  if ((m_fogVao == 0u) || m_fogIndexCount == 0 || count == 0) {
+  if ((m_fogVao == 0U) || m_fogIndexCount == 0 || count == 0) {
     return;
   }
 

+ 3 - 3
render/gl/backend/terrain_pipeline.cpp

@@ -2,7 +2,7 @@
 #include "../backend.h"
 #include "../render_constants.h"
 #include "../shader_cache.h"
-#include "../opengl_headers.h"
+#include <GL/gl.h>
 #include <QDebug>
 #include <QOpenGLExtraFunctions>
 #include <cstddef>
@@ -206,11 +206,11 @@ void TerrainPipeline::shutdownGrassGeometry() {
     return;
   }
 
-  if (m_grassVertexBuffer != 0u) {
+  if (m_grassVertexBuffer != 0U) {
     gl->glDeleteBuffers(1, &m_grassVertexBuffer);
     m_grassVertexBuffer = 0;
   }
-  if (m_grassVao != 0u) {
+  if (m_grassVao != 0U) {
     gl->glDeleteVertexArrays(1, &m_grassVao);
     m_grassVao = 0;
   }

+ 13 - 13
render/gl/backend/vegetation_pipeline.cpp

@@ -1,7 +1,7 @@
 #include "vegetation_pipeline.h"
 #include "../render_constants.h"
 #include "gl/shader_cache.h"
-#include "../opengl_headers.h"
+#include <GL/gl.h>
 #include <QDebug>
 #include <cmath>
 #include <cstddef>
@@ -187,15 +187,15 @@ void VegetationPipeline::initializeStonePipeline() {
 
 void VegetationPipeline::shutdownStonePipeline() {
   initializeOpenGLFunctions();
-  if (m_stoneIndexBuffer != 0u) {
+  if (m_stoneIndexBuffer != 0U) {
     glDeleteBuffers(1, &m_stoneIndexBuffer);
     m_stoneIndexBuffer = 0;
   }
-  if (m_stoneVertexBuffer != 0u) {
+  if (m_stoneVertexBuffer != 0U) {
     glDeleteBuffers(1, &m_stoneVertexBuffer);
     m_stoneVertexBuffer = 0;
   }
-  if (m_stoneVao != 0u) {
+  if (m_stoneVao != 0U) {
     glDeleteVertexArrays(1, &m_stoneVao);
     m_stoneVao = 0;
   }
@@ -281,15 +281,15 @@ void VegetationPipeline::initializePlantPipeline() {
 
 void VegetationPipeline::shutdownPlantPipeline() {
   initializeOpenGLFunctions();
-  if (m_plantIndexBuffer != 0u) {
+  if (m_plantIndexBuffer != 0U) {
     glDeleteBuffers(1, &m_plantIndexBuffer);
     m_plantIndexBuffer = 0;
   }
-  if (m_plantVertexBuffer != 0u) {
+  if (m_plantVertexBuffer != 0U) {
     glDeleteBuffers(1, &m_plantVertexBuffer);
     m_plantVertexBuffer = 0;
   }
-  if (m_plantVao != 0u) {
+  if (m_plantVao != 0U) {
     glDeleteVertexArrays(1, &m_plantVao);
     m_plantVao = 0;
   }
@@ -430,15 +430,15 @@ void VegetationPipeline::initializePinePipeline() {
 
 void VegetationPipeline::shutdownPinePipeline() {
   initializeOpenGLFunctions();
-  if (m_pineIndexBuffer != 0u) {
+  if (m_pineIndexBuffer != 0U) {
     glDeleteBuffers(1, &m_pineIndexBuffer);
     m_pineIndexBuffer = 0;
   }
-  if (m_pineVertexBuffer != 0u) {
+  if (m_pineVertexBuffer != 0U) {
     glDeleteBuffers(1, &m_pineVertexBuffer);
     m_pineVertexBuffer = 0;
   }
-  if (m_pineVao != 0u) {
+  if (m_pineVao != 0U) {
     glDeleteVertexArrays(1, &m_pineVao);
     m_pineVao = 0;
   }
@@ -523,15 +523,15 @@ void VegetationPipeline::initializeFireCampPipeline() {
 
 void VegetationPipeline::shutdownFireCampPipeline() {
   initializeOpenGLFunctions();
-  if (m_firecampIndexBuffer != 0u) {
+  if (m_firecampIndexBuffer != 0U) {
     glDeleteBuffers(1, &m_firecampIndexBuffer);
     m_firecampIndexBuffer = 0;
   }
-  if (m_firecampVertexBuffer != 0u) {
+  if (m_firecampVertexBuffer != 0U) {
     glDeleteBuffers(1, &m_firecampVertexBuffer);
     m_firecampVertexBuffer = 0;
   }
-  if (m_firecampVao != 0u) {
+  if (m_firecampVao != 0U) {
     glDeleteVertexArrays(1, &m_firecampVao);
     m_firecampVao = 0;
   }

+ 7 - 7
render/gl/bootstrap.cpp

@@ -9,31 +9,31 @@
 namespace Render::GL {
 
 auto RenderBootstrap::initialize(Renderer &renderer, Camera &camera) -> bool {
-  qInfo() << "RenderBootstrap::initialize() - Starting OpenGL initialization...";
-  
+  qInfo()
+      << "RenderBootstrap::initialize() - Starting OpenGL initialization...";
+
   QOpenGLContext *ctx = QOpenGLContext::currentContext();
   if ((ctx == nullptr) || !ctx->isValid()) {
     qCritical() << "RenderBootstrap: no current valid OpenGL context";
     return false;
   }
   qInfo() << "RenderBootstrap: OpenGL context is valid";
-  
-  // Log OpenGL capabilities for debugging (especially useful on Windows)
+
   qInfo() << "RenderBootstrap: Logging OpenGL capabilities...";
   GLCapabilities::logCapabilities();
   qInfo() << "RenderBootstrap: Capabilities logged";
-  
+
   qInfo() << "RenderBootstrap: Calling renderer.initialize()...";
   if (!renderer.initialize()) {
     qCritical() << "RenderBootstrap: renderer initialize failed";
     return false;
   }
   qInfo() << "RenderBootstrap: Renderer initialized successfully";
-  
+
   qInfo() << "RenderBootstrap: Setting camera...";
   renderer.setCamera(&camera);
   qInfo() << "RenderBootstrap: Camera set, initialization complete";
-  
+
   return true;
 }
 

+ 4 - 4
render/gl/buffer.cpp

@@ -1,5 +1,5 @@
 #include "buffer.h"
-#include "opengl_headers.h"
+#include <GL/gl.h>
 #include <cstddef>
 #include <qopenglext.h>
 #include <vector>
@@ -15,7 +15,7 @@ Buffer::~Buffer() {
 }
 
 void Buffer::bind() {
-  if (m_buffer == 0u) {
+  if (m_buffer == 0U) {
     initializeOpenGLFunctions();
     glGenBuffers(1, &m_buffer);
   }
@@ -41,7 +41,7 @@ auto Buffer::getGLType() const -> GLenum {
   return GL_ARRAY_BUFFER;
 }
 
-GLenum Buffer::getGLUsage(Usage usage) {
+auto Buffer::getGLUsage(Usage usage) -> GLenum {
   switch (usage) {
   case Usage::Static:
     return GL_STATIC_DRAW;
@@ -62,7 +62,7 @@ VertexArray::~VertexArray() {
 }
 
 void VertexArray::bind() {
-  if (m_vao == 0u) {
+  if (m_vao == 0U) {
     initializeOpenGLFunctions();
     glGenVertexArrays(1, &m_vao);
   }

+ 1 - 1
render/gl/camera.cpp

@@ -316,7 +316,7 @@ void Camera::orbit(float yaw_deg, float pitch_deg) {
   }
 
   QVector3D const offset = m_position - m_target;
-  float cur_yaw = 0.f;
+  float cur_yaw = 0.F;
   float cur_pitch = 0.F;
   computeYawPitchFromOffset(offset, cur_yaw, cur_pitch);
 

+ 36 - 25
render/gl/gl_capabilities.h

@@ -7,7 +7,6 @@
 
 namespace Render::GL {
 
-// Helper class to detect and report OpenGL capabilities at runtime
 class GLCapabilities {
 public:
   static void logCapabilities() {
@@ -21,14 +20,22 @@ public:
     const auto format = ctx->format();
 
     qInfo() << "=== OpenGL Context Information ===";
-    qInfo() << "Vendor:" << reinterpret_cast<const char*>(gl->glGetString(GL_VENDOR));
-    qInfo() << "Renderer:" << reinterpret_cast<const char*>(gl->glGetString(GL_RENDERER));
-    qInfo() << "Version:" << reinterpret_cast<const char*>(gl->glGetString(GL_VERSION));
-    qInfo() << "GLSL Version:" << reinterpret_cast<const char*>(gl->glGetString(GL_SHADING_LANGUAGE_VERSION));
-    qInfo() << "Context Version:" << format.majorVersion() << "." << format.minorVersion();
-    qInfo() << "Profile:" << (format.profile() == QSurfaceFormat::CoreProfile ? "Core" : 
-                              format.profile() == QSurfaceFormat::CompatibilityProfile ? "Compatibility" : 
-                              "NoProfile");
+    qInfo() << "Vendor:"
+            << reinterpret_cast<const char *>(gl->glGetString(GL_VENDOR));
+    qInfo() << "Renderer:"
+            << reinterpret_cast<const char *>(gl->glGetString(GL_RENDERER));
+    qInfo() << "Version:"
+            << reinterpret_cast<const char *>(gl->glGetString(GL_VERSION));
+    qInfo() << "GLSL Version:"
+            << reinterpret_cast<const char *>(
+                   gl->glGetString(GL_SHADING_LANGUAGE_VERSION));
+    qInfo() << "Context Version:" << format.majorVersion() << "."
+            << format.minorVersion();
+    qInfo() << "Profile:"
+            << (format.profile() == QSurfaceFormat::CoreProfile ? "Core"
+                : format.profile() == QSurfaceFormat::CompatibilityProfile
+                    ? "Compatibility"
+                    : "NoProfile");
 
 #ifdef Q_OS_WIN
     qInfo() << "Platform: Windows";
@@ -40,23 +47,27 @@ public:
     qInfo() << "Platform: Unknown";
 #endif
 
-    // Check for important extensions
     const QString extensions = QString::fromLatin1(
-        reinterpret_cast<const char*>(gl->glGetString(GL_EXTENSIONS)));
-    
+        reinterpret_cast<const char *>(gl->glGetString(GL_EXTENSIONS)));
+
     qInfo() << "=== Extension Support ===";
-    qInfo() << "GL_ARB_buffer_storage:" << extensions.contains("GL_ARB_buffer_storage");
-    qInfo() << "GL_ARB_direct_state_access:" << extensions.contains("GL_ARB_direct_state_access");
-    qInfo() << "GL_ARB_vertex_array_object:" << extensions.contains("GL_ARB_vertex_array_object");
-    qInfo() << "GL_ARB_uniform_buffer_object:" << extensions.contains("GL_ARB_uniform_buffer_object");
-    
-    // Check for persistent mapping support
-    const bool hasPersistentMapping = 
-        (format.majorVersion() > 4 || (format.majorVersion() == 4 && format.minorVersion() >= 4)) ||
+    qInfo() << "GL_ARB_buffer_storage:"
+            << extensions.contains("GL_ARB_buffer_storage");
+    qInfo() << "GL_ARB_direct_state_access:"
+            << extensions.contains("GL_ARB_direct_state_access");
+    qInfo() << "GL_ARB_vertex_array_object:"
+            << extensions.contains("GL_ARB_vertex_array_object");
+    qInfo() << "GL_ARB_uniform_buffer_object:"
+            << extensions.contains("GL_ARB_uniform_buffer_object");
+
+    const bool hasPersistentMapping =
+        (format.majorVersion() > 4 ||
+         (format.majorVersion() == 4 && format.minorVersion() >= 4)) ||
         extensions.contains("GL_ARB_buffer_storage");
-    
-    qInfo() << "Persistent Buffer Mapping:" << (hasPersistentMapping ? "Supported" : "Not Supported");
-    
+
+    qInfo() << "Persistent Buffer Mapping:"
+            << (hasPersistentMapping ? "Supported" : "Not Supported");
+
     qInfo() << "==================================";
   }
 
@@ -68,8 +79,8 @@ public:
 
     auto *gl = ctx->extraFunctions();
     const QString extensions = QString::fromLatin1(
-        reinterpret_cast<const char*>(gl->glGetString(GL_EXTENSIONS)));
-    
+        reinterpret_cast<const char *>(gl->glGetString(GL_EXTENSIONS)));
+
     return extensions.contains(extension);
   }
 };

+ 1 - 1
render/gl/mesh.cpp

@@ -1,7 +1,7 @@
 #include "mesh.h"
 #include "gl/buffer.h"
 #include "render_constants.h"
-#include "opengl_headers.h"
+#include <GL/gl.h>
 #include <QOpenGLFunctions_3_3_Core>
 #include <memory>
 #include <vector>

+ 4 - 5
render/gl/opengl_headers.h

@@ -1,10 +1,9 @@
 #pragma once
 
-// Platform-specific OpenGL header inclusion
 #ifdef __APPLE__
-    #include <OpenGL/gl.h>
-    #include <OpenGL/glu.h>
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
 #else
-    #include <GL/gl.h>
-    #include <GL/glu.h>
+#include <GL/gl.h>
+#include <GL/glu.h>
 #endif

+ 18 - 18
render/gl/persistent_buffer.h

@@ -51,9 +51,9 @@ public:
       return false;
     }
 
-    // Try to create buffer using platform-aware helper with fallback
     Platform::BufferStorageHelper::Mode mode;
-    if (!Platform::BufferStorageHelper::createBuffer(m_buffer, m_totalSize, &mode)) {
+    if (!Platform::BufferStorageHelper::createBuffer(m_buffer, m_totalSize,
+                                                     &mode)) {
       qWarning() << "PersistentRingBuffer: Failed to create buffer storage";
       glBindBuffer(GL_ARRAY_BUFFER, 0);
       glDeleteBuffers(1, &m_buffer);
@@ -63,7 +63,6 @@ public:
 
     m_bufferMode = mode;
 
-    // Map the buffer with appropriate mode
     m_mappedPtr = Platform::BufferStorageHelper::mapBuffer(m_totalSize, mode);
 
     if (m_mappedPtr == nullptr) {
@@ -73,11 +72,11 @@ public:
       return false;
     }
 
-    // For fallback mode, we need to unmap after each write
     if (mode == Platform::BufferStorageHelper::Mode::Fallback) {
-      qInfo() << "PersistentRingBuffer: Running in fallback mode (non-persistent mapping)";
+      qInfo() << "PersistentRingBuffer: Running in fallback mode "
+                 "(non-persistent mapping)";
       glUnmapBuffer(GL_ARRAY_BUFFER);
-      m_mappedPtr = nullptr;  // Will be remapped on each write
+      m_mappedPtr = nullptr;
     }
 
     glBindBuffer(GL_ARRAY_BUFFER, 0);
@@ -115,30 +114,30 @@ public:
       return 0;
     }
 
-    // For fallback mode, we need to map/unmap on each write
     if (m_bufferMode == Platform::BufferStorageHelper::Mode::Fallback) {
       glBindBuffer(GL_ARRAY_BUFFER, m_buffer);
-      
-      std::size_t const writeOffset = m_frameOffset + m_currentCount * sizeof(T);
-      void *ptr = glMapBufferRange(GL_ARRAY_BUFFER, writeOffset, count * sizeof(T), 
-                                    GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
-      
+
+      std::size_t const writeOffset =
+          m_frameOffset + m_currentCount * sizeof(T);
+      void *ptr =
+          glMapBufferRange(GL_ARRAY_BUFFER, writeOffset, count * sizeof(T),
+                           GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
+
       if (ptr == nullptr) {
         qWarning() << "PersistentRingBuffer: Failed to map buffer for write";
         glBindBuffer(GL_ARRAY_BUFFER, 0);
         return 0;
       }
-      
+
       std::memcpy(ptr, data, count * sizeof(T));
       glUnmapBuffer(GL_ARRAY_BUFFER);
       glBindBuffer(GL_ARRAY_BUFFER, 0);
-      
+
       std::size_t const elementOffset = m_currentCount;
       m_currentCount += count;
       return elementOffset;
     }
 
-    // Persistent mode: direct write to mapped memory
     if (m_mappedPtr == nullptr) {
       return 0;
     }
@@ -164,8 +163,8 @@ public:
   [[nodiscard]] auto count() const -> std::size_t { return m_currentCount; }
 
   [[nodiscard]] auto isValid() const -> bool {
-    return m_buffer != 0 && 
-           (m_bufferMode == Platform::BufferStorageHelper::Mode::Fallback || 
+    return m_buffer != 0 &&
+           (m_bufferMode == Platform::BufferStorageHelper::Mode::Fallback ||
             m_mappedPtr != nullptr);
   }
 
@@ -178,7 +177,8 @@ private:
   std::size_t m_currentCount = 0;
   int m_buffersInFlight = BufferCapacity::BuffersInFlight;
   int m_currentFrame = 0;
-  Platform::BufferStorageHelper::Mode m_bufferMode = Platform::BufferStorageHelper::Mode::Persistent;
+  Platform::BufferStorageHelper::Mode m_bufferMode =
+      Platform::BufferStorageHelper::Mode::Persistent;
 };
 
 } // namespace Render::GL

+ 34 - 40
render/gl/platform_gl.h

@@ -1,60 +1,53 @@
 #pragma once
 
+#include <QDebug>
 #include <QOpenGLContext>
 #include <QOpenGLExtraFunctions>
-#include <QDebug>
 
-// Platform-specific OpenGL helpers for Windows/Linux compatibility
 namespace Render::GL::Platform {
 
-// Check if persistent mapped buffers are supported (ARB_buffer_storage)
 inline auto supportsPersistentMapping() -> bool {
   auto *ctx = QOpenGLContext::currentContext();
   if (ctx == nullptr) {
     return false;
   }
 
-  // Check for GL 4.4+ or ARB_buffer_storage extension
   const auto glVersion = ctx->format().version();
   const int majorVersion = glVersion.first;
   const int minorVersion = glVersion.second;
-  
+
   if (majorVersion > 4 || (majorVersion == 4 && minorVersion >= 4)) {
     return true;
   }
 
-  // Check for extension on older OpenGL versions
-  const auto extensions = QString::fromLatin1(
-      reinterpret_cast<const char*>(ctx->extraFunctions()->glGetString(GL_EXTENSIONS)));
+  const auto extensions = QString::fromLatin1(reinterpret_cast<const char *>(
+      ctx->extraFunctions()->glGetString(GL_EXTENSIONS)));
   return extensions.contains("GL_ARB_buffer_storage");
 }
 
-// Platform-agnostic way to get glBufferStorage function pointer
-inline auto getBufferStorageFunction() -> void* {
+inline auto getBufferStorageFunction() -> void * {
   auto *ctx = QOpenGLContext::currentContext();
   if (ctx == nullptr) {
     return nullptr;
   }
 
-  // Try core function first (GL 4.4+)
-  void *func = reinterpret_cast<void*>(ctx->getProcAddress("glBufferStorage"));
-  
-  // Fallback to ARB extension on older drivers
+  void *func = reinterpret_cast<void *>(ctx->getProcAddress("glBufferStorage"));
+
   if (func == nullptr) {
-    func = reinterpret_cast<void*>(ctx->getProcAddress("glBufferStorageARB"));
+    func = reinterpret_cast<void *>(ctx->getProcAddress("glBufferStorageARB"));
   }
 
 #ifdef Q_OS_WIN
-  // Windows may need explicit wglGetProcAddress fallback
+
   if (func == nullptr) {
-    qWarning() << "Platform::getBufferStorageFunction: glBufferStorage not available on Windows";
+    qWarning() << "Platform::getBufferStorageFunction: glBufferStorage not "
+                  "available on Windows";
   }
 #endif
 
   return func;
 }
 
-// GL constants for persistent mapping (may not be defined on all platforms)
 #ifndef GL_MAP_PERSISTENT_BIT
 #define GL_MAP_PERSISTENT_BIT 0x0040
 #endif
@@ -71,63 +64,64 @@ inline auto getBufferStorageFunction() -> void* {
 #define GL_DYNAMIC_STORAGE_BIT 0x0100
 #endif
 
-// Wrapper for buffer storage creation with fallback
 class BufferStorageHelper {
 public:
-  enum class Mode {
-    Persistent,  // Use persistent mapping (GL 4.4+)
-    Fallback     // Use traditional glBufferData + map/unmap
-  };
+  enum class Mode { Persistent, Fallback };
 
-  static auto createBuffer(GLuint buffer, GLsizeiptr size, Mode *outMode) -> bool {
+  static auto createBuffer(GLuint buffer, GLsizeiptr size,
+                           Mode *outMode) -> bool {
     if (supportsPersistentMapping()) {
       typedef void(QOPENGLF_APIENTRYP type_glBufferStorage)(
           GLenum target, GLsizeiptr size, const void *data, GLbitfield flags);
-      
-      auto glBufferStorage = reinterpret_cast<type_glBufferStorage>(
-          getBufferStorageFunction());
+
+      auto glBufferStorage =
+          reinterpret_cast<type_glBufferStorage>(getBufferStorageFunction());
 
       if (glBufferStorage != nullptr) {
         const GLbitfield storageFlags = GL_DYNAMIC_STORAGE_BIT;
-        const GLbitfield mapFlags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
-        
-        glBufferStorage(GL_ARRAY_BUFFER, size, nullptr, storageFlags | mapFlags);
-        
-        GLenum err = QOpenGLContext::currentContext()->extraFunctions()->glGetError();
+        const GLbitfield mapFlags =
+            GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
+
+        glBufferStorage(GL_ARRAY_BUFFER, size, nullptr,
+                        storageFlags | mapFlags);
+
+        GLenum const err =
+            QOpenGLContext::currentContext()->extraFunctions()->glGetError();
         if (err == GL_NO_ERROR) {
           if (outMode != nullptr) {
             *outMode = Mode::Persistent;
           }
           return true;
         }
-        qWarning() << "BufferStorageHelper: glBufferStorage failed with error:" << err;
+        qWarning() << "BufferStorageHelper: glBufferStorage failed with error:"
+                   << err;
       }
     }
 
-    // Fallback to traditional buffer allocation
     qInfo() << "BufferStorageHelper: Using fallback buffer mode (glBufferData)";
     QOpenGLContext::currentContext()->extraFunctions()->glBufferData(
         GL_ARRAY_BUFFER, size, nullptr, GL_DYNAMIC_DRAW);
-    
+
     if (outMode != nullptr) {
       *outMode = Mode::Fallback;
     }
     return true;
   }
 
-  static auto mapBuffer(GLsizeiptr size, Mode mode) -> void* {
+  static auto mapBuffer(GLsizeiptr size, Mode mode) -> void * {
     auto *gl = QOpenGLContext::currentContext()->extraFunctions();
-    
+
     if (mode == Mode::Persistent) {
-      const GLbitfield mapFlags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
+      const GLbitfield mapFlags =
+          GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
       void *ptr = gl->glMapBufferRange(GL_ARRAY_BUFFER, 0, size, mapFlags);
       if (ptr != nullptr) {
         return ptr;
       }
-      qWarning() << "BufferStorageHelper: Persistent mapping failed, falling back";
+      qWarning()
+          << "BufferStorageHelper: Persistent mapping failed, falling back";
     }
 
-    // Fallback mapping (non-persistent)
     return gl->glMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_WRITE_BIT);
   }
 };

+ 5 - 5
render/gl/primitives.cpp

@@ -383,8 +383,8 @@ auto createUnitTorsoMesh(int radialSegments, int heightSegments) -> Mesh * {
   };
 
   auto ellipse_radius = [&](float a, float b, float ang) {
-    float c = std::cos(ang);
-    float s = std::sin(ang);
+    float const c = std::cos(ang);
+    float const s = std::sin(ang);
     float const denom = std::sqrt((b * b * c * c) + (a * a * s * s));
     return (a * b) / (denom + k_radius_epsilon);
   };
@@ -412,9 +412,9 @@ auto createUnitTorsoMesh(int radialSegments, int heightSegments) -> Mesh * {
 
   auto theta_scale = [&](float t, float ang) {
     float s = 0.0F;
-    float sinA = std::sin(ang);
-    float cosA = std::cos(ang);
-    float cos2 = cosA * cosA;
+    float const sinA = std::sin(ang);
+    float const cosA = std::cos(ang);
+    float const cos2 = cosA * cosA;
     s += k_theta_sin_pos_amp *
          smooth_band(t, k_theta_sin_pos_start, k_theta_sin_pos_end) *
          std::max(0.0F, sinA);

+ 1 - 1
render/gl/resources.cpp

@@ -2,7 +2,7 @@
 #include "gl/mesh.h"
 #include "gl/texture.h"
 #include "render_constants.h"
-#include "opengl_headers.h"
+#include <GL/gl.h>
 #include <QVector3D>
 #include <cmath>
 #include <memory>

+ 1 - 1
render/gl/shader.cpp

@@ -1,7 +1,7 @@
 #include "shader.h"
 #include "render_constants.h"
 #include "utils/resource_utils.h"
-#include "opengl_headers.h"
+#include <GL/gl.h>
 #include <QByteArray>
 #include <QDebug>
 #include <QFile>

+ 5 - 5
render/gl/texture.cpp

@@ -1,5 +1,5 @@
 #include "texture.h"
-#include "opengl_headers.h"
+#include <GL/gl.h>
 #include <QDebug>
 #include <QImage>
 #include <qglobal.h>
@@ -75,7 +75,7 @@ auto Texture::createEmpty(int width, int height, Format format) -> bool {
 
 void Texture::bind(int unit) {
   initializeOpenGLFunctions();
-  if (m_texture == 0u) {
+  if (m_texture == 0U) {
     glGenTextures(1, &m_texture);
   }
   glActiveTexture(GL_TEXTURE0 + unit);
@@ -99,7 +99,7 @@ void Texture::setWrap(Wrap sWrap, Wrap tWrap) {
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, getGLWrap(tWrap));
 }
 
-GLenum Texture::getGLFormat(Format format) {
+auto Texture::getGLFormat(Format format) -> GLenum {
   switch (format) {
   case Format::RGB:
     return GL_RGB;
@@ -111,7 +111,7 @@ GLenum Texture::getGLFormat(Format format) {
   return GL_RGBA;
 }
 
-GLenum Texture::getGLFilter(Filter filter) {
+auto Texture::getGLFilter(Filter filter) -> GLenum {
   switch (filter) {
   case Filter::Nearest:
     return GL_NEAREST;
@@ -121,7 +121,7 @@ GLenum Texture::getGLFilter(Filter filter) {
   return GL_LINEAR;
 }
 
-GLenum Texture::getGLWrap(Wrap wrap) {
+auto Texture::getGLWrap(Wrap wrap) -> GLenum {
   switch (wrap) {
   case Wrap::Repeat:
     return GL_REPEAT;

+ 6 - 6
render/ground/biome_renderer.cpp

@@ -27,12 +27,12 @@ using namespace Render::Ground;
 using namespace Render::GL::Geometry;
 
 inline auto valueNoise(float x, float z, uint32_t salt = 0U) -> float {
-  int x0 = int(std::floor(x));
-  int z0 = int(std::floor(z));
-  int x1 = x0 + 1;
-  int z1 = z0 + 1;
-  float tx = x - float(x0);
-  float tz = z - float(z0);
+  int const x0 = int(std::floor(x));
+  int const z0 = int(std::floor(z));
+  int const x1 = x0 + 1;
+  int const z1 = z0 + 1;
+  float const tx = x - float(x0);
+  float const tz = z - float(z0);
   float const n00 = hash_to_01(hash_coords(x0, z0, salt));
   float const n10 = hash_to_01(hash_coords(x1, z0, salt));
   float const n01 = hash_to_01(hash_coords(x0, z1, salt));

+ 6 - 5
render/ground/firecamp_renderer.cpp

@@ -3,6 +3,7 @@
 #include "../../game/systems/building_collision_registry.h"
 #include "../gl/buffer.h"
 #include "../scene_renderer.h"
+#include "gl/render_constants.h"
 #include "gl/resources.h"
 #include "ground/firecamp_gpu.h"
 #include "ground_utils.h"
@@ -136,11 +137,11 @@ void FireCampRenderer::submit(Renderer &renderer, ResourceManager *resources) {
     const float intensity = std::clamp(pos_intensity.w(), 0.6F, 1.6F);
     const float base_radius = std::max(radius_phase.x(), 1.0F);
 
-    uint32_t state =
-        hash_coords(static_cast<int>(std::floor(camp_pos.x())),
-                   static_cast<int>(std::floor(camp_pos.z())),
-                   static_cast<uint32_t>(radius_phase.y() *
-                                         HashConstants::k_temporal_variation_frequency));
+    uint32_t state = hash_coords(
+        static_cast<int>(std::floor(camp_pos.x())),
+        static_cast<int>(std::floor(camp_pos.z())),
+        static_cast<uint32_t>(radius_phase.y() *
+                              HashConstants::k_temporal_variation_frequency));
 
     const float time = params.time;
     const float char_amount =

+ 5 - 3
render/ground/ground_utils.h

@@ -10,7 +10,7 @@ using std::uint32_t;
 
 namespace MathConstants {
 inline constexpr float k_two_pi = ::Render::GL::MathConstants::k_two_pi;
-} // namespace MathConstants
+}
 
 namespace HashConstants {
 inline constexpr uint32_t k_spatial_hash_prime_1 = 73856093U;
@@ -32,8 +32,10 @@ inline constexpr float k_temporal_variation_frequency = 37.0F;
 } // namespace HashConstants
 
 inline auto hash_coords(int x, int z, uint32_t salt = 0U) -> uint32_t {
-  auto const ux = static_cast<uint32_t>(x * HashConstants::k_spatial_hash_prime_1);
-  auto const uz = static_cast<uint32_t>(z * HashConstants::k_spatial_hash_prime_2);
+  auto const ux =
+      static_cast<uint32_t>(x * HashConstants::k_spatial_hash_prime_1);
+  auto const uz =
+      static_cast<uint32_t>(z * HashConstants::k_spatial_hash_prime_2);
   return ux ^ uz ^ (salt * HashConstants::k_spatial_hash_prime_3);
 }
 

+ 7 - 6
render/ground/pine_renderer.cpp

@@ -3,6 +3,7 @@
 #include "../../game/systems/building_collision_registry.h"
 #include "../gl/buffer.h"
 #include "../scene_renderer.h"
+#include "gl/render_constants.h"
 #include "gl/resources.h"
 #include "ground/pine_gpu.h"
 #include "ground_utils.h"
@@ -20,12 +21,12 @@ using std::uint32_t;
 using namespace Render::Ground;
 
 inline auto valueNoise(float x, float z, uint32_t salt = 0U) -> float {
-  int x0 = int(std::floor(x));
-  int z0 = int(std::floor(z));
-  int x1 = x0 + 1;
-  int z1 = z0 + 1;
-  float tx = x - float(x0);
-  float tz = z - float(z0);
+  int const x0 = int(std::floor(x));
+  int const z0 = int(std::floor(z));
+  int const x1 = x0 + 1;
+  int const z1 = z0 + 1;
+  float const tx = x - float(x0);
+  float const tz = z - float(z0);
   float const n00 = hash_to_01(hash_coords(x0, z0, salt));
   float const n10 = hash_to_01(hash_coords(x1, z0, salt));
   float const n01 = hash_to_01(hash_coords(x0, z1, salt));

+ 7 - 6
render/ground/plant_renderer.cpp

@@ -3,6 +3,7 @@
 #include "../../game/systems/building_collision_registry.h"
 #include "../gl/buffer.h"
 #include "../scene_renderer.h"
+#include "gl/render_constants.h"
 #include "gl/resources.h"
 #include "ground/plant_gpu.h"
 #include "ground_utils.h"
@@ -20,12 +21,12 @@ using std::uint32_t;
 using namespace Render::Ground;
 
 inline auto valueNoise(float x, float z, uint32_t salt = 0U) -> float {
-  int x0 = int(std::floor(x));
-  int z0 = int(std::floor(z));
-  int x1 = x0 + 1;
-  int z1 = z0 + 1;
-  float tx = x - float(x0);
-  float tz = z - float(z0);
+  int const x0 = int(std::floor(x));
+  int const z0 = int(std::floor(z));
+  int const x1 = x0 + 1;
+  int const z1 = z0 + 1;
+  float const tx = x - float(x0);
+  float const tz = z - float(z0);
   float const n00 = hash_to_01(hash_coords(x0, z0, salt));
   float const n10 = hash_to_01(hash_coords(x1, z0, salt));
   float const n01 = hash_to_01(hash_coords(x0, z1, salt));

+ 6 - 6
render/ground/riverbank_asset_renderer.cpp

@@ -22,12 +22,12 @@ using std::uint32_t;
 using namespace Render::Ground;
 
 inline auto valueNoise(float x, float z, uint32_t salt = 0U) -> float {
-  int x0 = int(std::floor(x));
-  int z0 = int(std::floor(z));
-  int x1 = x0 + 1;
-  int z1 = z0 + 1;
-  float tx = x - float(x0);
-  float tz = z - float(z0);
+  int const x0 = int(std::floor(x));
+  int const z0 = int(std::floor(z));
+  int const x1 = x0 + 1;
+  int const z1 = z0 + 1;
+  float const tx = x - float(x0);
+  float const tz = z - float(z0);
   float const n00 = hash_to_01(hash_coords(x0, z0, salt));
   float const n10 = hash_to_01(hash_coords(x1, z0, salt));
   float const n01 = hash_to_01(hash_coords(x0, z1, salt));

+ 7 - 6
render/ground/stone_renderer.cpp

@@ -2,6 +2,7 @@
 #include "../../game/systems/building_collision_registry.h"
 #include "../gl/buffer.h"
 #include "../scene_renderer.h"
+#include "gl/render_constants.h"
 #include "gl/resources.h"
 #include "ground/stone_gpu.h"
 #include "ground_utils.h"
@@ -23,12 +24,12 @@ using std::uint32_t;
 using namespace Render::Ground;
 
 inline auto valueNoise(float x, float z, uint32_t salt = 0U) -> float {
-  int x0 = int(std::floor(x));
-  int z0 = int(std::floor(z));
-  int x1 = x0 + 1;
-  int z1 = z0 + 1;
-  float tx = x - float(x0);
-  float tz = z - float(z0);
+  int const x0 = int(std::floor(x));
+  int const z0 = int(std::floor(z));
+  int const x1 = x0 + 1;
+  int const z1 = z0 + 1;
+  float const tx = x - float(x0);
+  float const tz = z - float(z0);
   float const n00 = hash_to_01(hash_coords(x0, z0, salt));
   float const n10 = hash_to_01(hash_coords(x1, z0, salt));
   float const n01 = hash_to_01(hash_coords(x0, z1, salt));

+ 9 - 9
render/ground/terrain_renderer.cpp

@@ -56,12 +56,12 @@ inline auto smooth(float a, float b, float x) -> float {
 }
 
 inline auto valueNoise(float x, float z, uint32_t salt = 0U) -> float {
-  int x0 = int(std::floor(x));
-  int z0 = int(std::floor(z));
-  int x1 = x0 + 1;
-  int z1 = z0 + 1;
-  float tx = x - float(x0);
-  float tz = z - float(z0);
+  int const x0 = int(std::floor(x));
+  int const z0 = int(std::floor(z));
+  int const x1 = x0 + 1;
+  int const z1 = z0 + 1;
+  float const tx = x - float(x0);
+  float const tz = z - float(z0);
   float const n00 = hash_to_01(hash_coords(x0, z0, salt));
   float const n10 = hash_to_01(hash_coords(x1, z0, salt));
   float const n01 = hash_to_01(hash_coords(x0, z1, salt));
@@ -127,7 +127,7 @@ void TerrainRenderer::submit(Renderer &renderer, ResourceManager *resources) {
   }
 }
 
-int TerrainRenderer::sectionFor(Game::Map::TerrainType type) {
+auto TerrainRenderer::sectionFor(Game::Map::TerrainType type) -> int {
   switch (type) {
   case Game::Map::TerrainType::Mountain:
     return 2;
@@ -466,8 +466,8 @@ void TerrainRenderer::buildMeshes() {
               gz = std::clamp(gz, 0, m_height - 1);
               return m_heightData[gz * m_width + gx];
             };
-            int cx = x;
-            int cz = z;
+            int const cx = x;
+            int const cz = z;
             float const hC = quad_height;
             float ao = 0.0F;
             ao += std::max(0.0F, H(cx - 1, cz) - hC);

+ 2 - 2
tools/map_editor/editor_window.h

@@ -17,11 +17,11 @@ private slots:
   void openMap();
   void saveMap();
 
-private:
   void setupUI();
   void setupMenus();
 
+private:
   QWidget *m_renderWidget{};
 };
 
-} // namespace MapEditor
+} // namespace MapEditor

+ 25 - 23
ui/gl_view.cpp

@@ -1,38 +1,41 @@
 #include "gl_view.h"
 #include "../app/core/game_engine.h"
 
+#include <QOpenGLContext>
 #include <QOpenGLFramebufferObject>
 #include <QOpenGLFramebufferObjectFormat>
-#include <QOpenGLContext>
 #include <QQuickWindow>
+#include <exception>
+#include <qglobal.h>
 #include <qobject.h>
+#include <qopenglcontext.h>
 #include <qopenglframebufferobject.h>
 #include <qpointer.h>
 #include <qquickframebufferobject.h>
 #include <qtmetamacros.h>
 #include <utility>
 
-GLView::GLView() { 
+GLView::GLView() {
   setMirrorVertically(true);
-  
-  // Check if OpenGL is available
-  QOpenGLContext* ctx = QOpenGLContext::currentContext();
-  if (!ctx) {
+
+  QOpenGLContext *ctx = QOpenGLContext::currentContext();
+  if (ctx == nullptr) {
     qWarning() << "GLView: No OpenGL context available";
     qWarning() << "GLView: 3D rendering will not work in software mode";
-    qWarning() << "GLView: Try running without QT_QUICK_BACKEND=software for full functionality";
+    qWarning() << "GLView: Try running without QT_QUICK_BACKEND=software for "
+                  "full functionality";
   }
 }
 
 auto GLView::createRenderer() const -> QQuickFramebufferObject::Renderer * {
-  // Check if we have a valid OpenGL context
-  QOpenGLContext* ctx = QOpenGLContext::currentContext();
-  if (!ctx || !ctx->isValid()) {
+
+  QOpenGLContext *ctx = QOpenGLContext::currentContext();
+  if ((ctx == nullptr) || !ctx->isValid()) {
     qCritical() << "GLView::createRenderer() - No valid OpenGL context";
     qCritical() << "Running in software rendering mode - 3D view not available";
     return nullptr;
   }
-  
+
   return new GLRenderer(m_engine);
 }
 
@@ -55,14 +58,13 @@ void GLView::GLRenderer::render() {
     qWarning() << "GLRenderer::render() - engine is null";
     return;
   }
-  
-  // Double-check OpenGL context is still valid
-  QOpenGLContext* ctx = QOpenGLContext::currentContext();
-  if (!ctx || !ctx->isValid()) {
+
+  QOpenGLContext *ctx = QOpenGLContext::currentContext();
+  if ((ctx == nullptr) || !ctx->isValid()) {
     qCritical() << "GLRenderer::render() - OpenGL context lost";
     return;
   }
-  
+
   try {
     m_engine->ensureInitialized();
     m_engine->update(1.0F / 60.0F);
@@ -74,21 +76,21 @@ void GLView::GLRenderer::render() {
     qCritical() << "GLRenderer::render() unknown exception";
     return;
   }
-  
+
   update();
 }
 
 auto GLView::GLRenderer::createFramebufferObject(const QSize &size)
     -> QOpenGLFramebufferObject * {
   m_size = size;
-  
-  // Verify OpenGL context before creating FBO
-  QOpenGLContext* ctx = QOpenGLContext::currentContext();
-  if (!ctx || !ctx->isValid()) {
-    qCritical() << "GLRenderer::createFramebufferObject() - No valid OpenGL context";
+
+  QOpenGLContext *ctx = QOpenGLContext::currentContext();
+  if ((ctx == nullptr) || !ctx->isValid()) {
+    qCritical()
+        << "GLRenderer::createFramebufferObject() - No valid OpenGL context";
     return nullptr;
   }
-  
+
   QOpenGLFramebufferObjectFormat fmt;
   fmt.setAttachment(QOpenGLFramebufferObject::Depth);
   fmt.setSamples(0);

+ 82 - 68
ui/qml/GameView.qml

@@ -9,7 +9,8 @@ Item {
     property real gameSpeed: 1
     property bool setRallyMode: false
     property string cursorMode: "normal"
-    property var pressedKeys: ({})
+    property var pressedKeys: ({
+    })
 
     signal mapClicked(real x, real y)
     signal unitSelected(int unitId)
@@ -19,12 +20,14 @@ Item {
         isPaused = paused;
         if (typeof game !== 'undefined' && game.setPaused)
             game.setPaused(paused);
+
     }
 
     function setGameSpeed(speed) {
         gameSpeed = speed;
         if (typeof game !== 'undefined' && game.setGameSpeed)
             game.setGameSpeed(speed);
+
     }
 
     function issueCommand(command) {
@@ -32,27 +35,13 @@ Item {
     }
 
     objectName: "GameView"
-
     Keys.onPressed: function(event) {
         if (typeof game === 'undefined')
-            return;
+            return ;
 
         var yawStep = (event.modifiers & Qt.ShiftModifier) ? 8 : 4;
         var inputStep = (event.modifiers & Qt.ShiftModifier) ? 2 : 1;
         var shiftHeld = (event.modifiers & Qt.ShiftModifier) !== 0;
-
-        function beginPanKey(e) {
-            if (!e.isAutoRepeat && !pressedKeys[e.key]) {
-                pressedKeys[e.key] = true;
-                renderArea.keyPanCount += 1;
-                mainWindow.edgeScrollDisabled = true;
-            }
-        }
-        function ensurePanTimerRunning() {
-            if (!keyPanTimer.running)
-                keyPanTimer.start();
-        }
-
         switch (event.key) {
         case Qt.Key_Escape:
             if (typeof mainWindow !== 'undefined' && !mainWindow.menuVisible) {
@@ -60,7 +49,6 @@ Item {
                 event.accepted = true;
             }
             break;
-
         case Qt.Key_Space:
             if (typeof mainWindow !== 'undefined') {
                 mainWindow.gamePaused = !mainWindow.gamePaused;
@@ -68,19 +56,17 @@ Item {
                 event.accepted = true;
             }
             break;
-
         case Qt.Key_W:
             beginPanKey(event);
             game.cameraMove(0, inputStep);
             ensurePanTimerRunning();
             event.accepted = true;
             break;
-
         case Qt.Key_S:
-            // Stop command when units selected and Shift not held; otherwise pan backward
             if (game.hasUnitsSelected && !shiftHeld) {
                 if (game.onStopCommand)
                     game.onStopCommand();
+
                 event.accepted = true;
             } else {
                 beginPanKey(event);
@@ -89,9 +75,7 @@ Item {
                 event.accepted = true;
             }
             break;
-
         case Qt.Key_A:
-            // Attack mode when units selected and Shift not held; otherwise pan left
             if (game.hasUnitsSelected && !shiftHeld) {
                 game.cursorMode = "attack";
                 event.accepted = true;
@@ -102,86 +86,71 @@ Item {
                 event.accepted = true;
             }
             break;
-
         case Qt.Key_D:
             beginPanKey(event);
             game.cameraMove(inputStep, 0);
             ensurePanTimerRunning();
             event.accepted = true;
             break;
-
         case Qt.Key_M:
-            // M - Move mode (normal cursor when units selected)
             if (game.hasUnitsSelected) {
                 game.cursorMode = "normal";
                 event.accepted = true;
             }
             break;
-
         case Qt.Key_Up:
             beginPanKey(event);
             game.cameraMove(0, inputStep);
             ensurePanTimerRunning();
             event.accepted = true;
             break;
-
         case Qt.Key_Down:
             beginPanKey(event);
             game.cameraMove(0, -inputStep);
             ensurePanTimerRunning();
             event.accepted = true;
             break;
-
         case Qt.Key_Left:
             beginPanKey(event);
             game.cameraMove(-inputStep, 0);
             ensurePanTimerRunning();
             event.accepted = true;
             break;
-
         case Qt.Key_Right:
             beginPanKey(event);
             game.cameraMove(inputStep, 0);
             ensurePanTimerRunning();
             event.accepted = true;
             break;
-
         case Qt.Key_Q:
             game.cameraYaw(-yawStep);
             event.accepted = true;
             break;
-
         case Qt.Key_E:
             game.cameraYaw(yawStep);
             event.accepted = true;
             break;
-
         case Qt.Key_R:
             game.cameraOrbitDirection(1, shiftHeld);
             event.accepted = true;
             break;
-
         case Qt.Key_F:
             game.cameraOrbitDirection(-1, shiftHeld);
             event.accepted = true;
             break;
-
         case Qt.Key_X:
             if (game.selectAllTroops)
                 game.selectAllTroops();
+
             event.accepted = true;
             break;
-
         case Qt.Key_P:
-            // P - Patrol mode when units selected
             if (game.hasUnitsSelected) {
                 game.cursorMode = "patrol";
                 event.accepted = true;
             }
             break;
-
         case Qt.Key_H:
-            // H - Hold command when units selected
             if (game.hasUnitsSelected && game.onHoldCommand) {
                 game.onHoldCommand();
                 event.accepted = true;
@@ -189,70 +158,85 @@ Item {
             break;
         }
     }
+    function beginPanKey(e) {
+        if (!e.isAutoRepeat && !pressedKeys[e.key]) {
+            pressedKeys[e.key] = true;
+            renderArea.keyPanCount += 1;
+            mainWindow.edgeScrollDisabled = true;
+        }
+    }
+
+    function ensurePanTimerRunning() {
+        if (!keyPanTimer.running)
+            keyPanTimer.start();
+
+    }
 
     Keys.onReleased: function(event) {
         if (typeof game === 'undefined')
-            return;
-
-        // Any keys that participate in camera panning
-        var movementKeys = [Qt.Key_W, Qt.Key_A, Qt.Key_S, Qt.Key_D,
-                            Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right];
+            return ;
 
+        var movementKeys = [Qt.Key_W, Qt.Key_A, Qt.Key_S, Qt.Key_D, Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right];
         if (movementKeys.indexOf(event.key) !== -1) {
-            // Only decrement pan count if this key was registered as a pan key
             if (pressedKeys[event.key]) {
                 pressedKeys[event.key] = false;
                 renderArea.keyPanCount = Math.max(0, renderArea.keyPanCount - 1);
             }
-
-            // If no movement keys are held, stop timer and maybe re-enable edge scroll
             var anyHeld = false;
             for (var k in pressedKeys) {
-                if (pressedKeys[k]) { anyHeld = true; break; }
+                if (pressedKeys[k]) {
+                    anyHeld = true;
+                    break;
+                }
             }
             if (!anyHeld) {
                 if (keyPanTimer.running)
                     keyPanTimer.stop();
+
                 if (renderArea.keyPanCount === 0 && !renderArea.mousePanActive)
                     mainWindow.edgeScrollDisabled = false;
+
             }
         }
-
-        // If Shift is released while not panning/mouse-dragging, re-enable edge scroll
         if (event.key === Qt.Key_Shift) {
             if (renderArea.keyPanCount === 0 && !renderArea.mousePanActive)
                 mainWindow.edgeScrollDisabled = false;
+
         }
     }
+    focus: true
 
     Timer {
         id: keyPanTimer
+
         interval: 16
         repeat: true
         running: false
         onTriggered: {
             if (typeof game === 'undefined')
-                return;
+                return ;
 
             var step = (Qt.inputModifiers & Qt.ShiftModifier) ? 2 : 1;
             var dx = 0;
             var dz = 0;
             if (pressedKeys[Qt.Key_W] || pressedKeys[Qt.Key_Up])
                 dz += step;
+
             if (pressedKeys[Qt.Key_S] || pressedKeys[Qt.Key_Down])
                 dz -= step;
+
             if (pressedKeys[Qt.Key_A] || pressedKeys[Qt.Key_Left])
                 dx -= step;
+
             if (pressedKeys[Qt.Key_D] || pressedKeys[Qt.Key_Right])
                 dx += step;
 
             if (dx !== 0 || dz !== 0)
                 game.cameraMove(dx, dz);
+
         }
     }
 
-    focus: true
-
     GLView {
         id: renderArea
 
@@ -262,18 +246,20 @@ Item {
         anchors.fill: parent
         engine: game
         focus: false
-
         Component.onCompleted: {
             if (typeof game !== 'undefined' && game.cursorMode)
                 gameView.cursorMode = game.cursorMode;
+
         }
 
         Connections {
-            target: game
             function onCursorModeChanged() {
                 if (typeof game !== 'undefined' && game.cursorMode)
                     gameView.cursorMode = game.cursorMode;
+
             }
+
+            target: game
         }
 
         MouseArea {
@@ -290,14 +276,15 @@ Item {
             preventStealing: true
             cursorShape: (gameView.cursorMode === "normal") ? Qt.ArrowCursor : Qt.BlankCursor
             enabled: gameView.visible
-
             onEntered: {
                 if (typeof game !== 'undefined' && game.setHoverAtScreen)
                     game.setHoverAtScreen(0, 0);
+
             }
             onExited: {
                 if (typeof game !== 'undefined' && game.setHoverAtScreen)
                     game.setHoverAtScreen(-1, -1);
+
             }
             onPositionChanged: function(mouse) {
                 if (isSelecting) {
@@ -310,12 +297,14 @@ Item {
                 } else {
                     if (typeof game !== 'undefined' && game.setHoverAtScreen)
                         game.setHoverAtScreen(mouse.x, mouse.y);
+
                 }
             }
             onWheel: function(w) {
                 var dy = (w.angleDelta ? w.angleDelta.y / 120 : w.delta / 120);
                 if (dy !== 0 && typeof game !== 'undefined' && game.cameraZoom)
                     game.cameraZoom(dy * 0.8);
+
                 w.accepted = true;
             }
             onPressed: function(mouse) {
@@ -323,23 +312,25 @@ Item {
                     if (gameView.setRallyMode) {
                         if (typeof game !== 'undefined' && game.setRallyAtScreen)
                             game.setRallyAtScreen(mouse.x, mouse.y);
+
                         gameView.setRallyMode = false;
-                        return;
+                        return ;
                     }
                     if (gameView.cursorMode === "attack") {
                         if (typeof game !== 'undefined' && game.onAttackClick)
                             game.onAttackClick(mouse.x, mouse.y);
-                        return;
+
+                        return ;
                     }
                     if (gameView.cursorMode === "guard")
-                        return;
+                        return ;
 
                     if (gameView.cursorMode === "patrol") {
                         if (typeof game !== 'undefined' && game.onPatrolClick)
                             game.onPatrolClick(mouse.x, mouse.y);
-                        return;
-                    }
 
+                        return ;
+                    }
                     isSelecting = true;
                     startX = mouse.x;
                     startY = mouse.y;
@@ -353,8 +344,10 @@ Item {
                     mainWindow.edgeScrollDisabled = true;
                     if (gameView.setRallyMode)
                         gameView.setRallyMode = false;
+
                     if (typeof game !== 'undefined' && game.onRightClick)
                         game.onRightClick(mouse.x, mouse.y);
+
                 }
             }
             onReleased: function(mouse) {
@@ -362,17 +355,15 @@ Item {
                     isSelecting = false;
                     selectionBox.visible = false;
                     if (selectionBox.width > 5 && selectionBox.height > 5) {
-                        areaSelected(selectionBox.x, selectionBox.y,
-                                     selectionBox.x + selectionBox.width,
-                                     selectionBox.y + selectionBox.height);
+                        areaSelected(selectionBox.x, selectionBox.y, selectionBox.x + selectionBox.width, selectionBox.y + selectionBox.height);
                         if (typeof game !== 'undefined' && game.onAreaSelected)
-                            game.onAreaSelected(selectionBox.x, selectionBox.y,
-                                                selectionBox.x + selectionBox.width,
-                                                selectionBox.y + selectionBox.height, false);
+                            game.onAreaSelected(selectionBox.x, selectionBox.y, selectionBox.x + selectionBox.width, selectionBox.y + selectionBox.height, false);
+
                     } else {
                         mapClicked(mouse.x, mouse.y);
                         if (typeof game !== 'undefined' && game.onClickSelect)
                             game.onClickSelect(mouse.x, mouse.y, false);
+
                     }
                 }
                 if (mouse.button === Qt.RightButton) {
@@ -384,11 +375,13 @@ Item {
 
         Rectangle {
             id: selectionBox
+
             visible: false
             border.color: "white"
             border.width: 1
             color: "transparent"
         }
+
     }
 
     Item {
@@ -403,12 +396,15 @@ Item {
 
         Item {
             id: attackCursorContainer
+
             property real pulseScale: 1
+
             visible: gameView.cursorMode === "attack"
             anchors.fill: parent
 
             Canvas {
                 id: attackCursor
+
                 anchors.fill: parent
                 scale: attackCursorContainer.pulseScale
                 transformOrigin: Item.Center
@@ -463,13 +459,28 @@ Item {
             SequentialAnimation on pulseScale {
                 running: attackCursorContainer.visible
                 loops: Animation.Infinite
-                NumberAnimation { from: 1; to: 1.2; duration: 400; easing.type: Easing.InOutQuad }
-                NumberAnimation { from: 1.2; to: 1; duration: 400; easing.type: Easing.InOutQuad }
+
+                NumberAnimation {
+                    from: 1
+                    to: 1.2
+                    duration: 400
+                    easing.type: Easing.InOutQuad
+                }
+
+                NumberAnimation {
+                    from: 1.2
+                    to: 1
+                    duration: 400
+                    easing.type: Easing.InOutQuad
+                }
+
             }
+
         }
 
         Canvas {
             id: guardCursor
+
             visible: gameView.cursorMode === "guard"
             anchors.fill: parent
             onPaint: {
@@ -501,6 +512,7 @@ Item {
 
         Canvas {
             id: patrolCursor
+
             visible: gameView.cursorMode === "patrol"
             anchors.fill: parent
             onPaint: {
@@ -530,5 +542,7 @@ Item {
             }
             Component.onCompleted: requestPaint()
         }
+
     }
+
 }

+ 12 - 7
ui/theme.cpp

@@ -1,23 +1,28 @@
 #include "theme.h"
+#include <qglobal.h>
+#include <qjsengine.h>
+#include <qjsonarray.h>
+#include <qobject.h>
+#include <qqmlengine.h>
 
 Theme *Theme::m_instance = nullptr;
 
 Theme::Theme(QObject *parent) : QObject(parent) {}
 
-Theme *Theme::instance() {
-  if (!m_instance) {
+auto Theme::instance() -> Theme * {
+  if (m_instance == nullptr) {
     m_instance = new Theme();
   }
   return m_instance;
 }
 
-Theme *Theme::create(QQmlEngine *engine, QJSEngine *scriptEngine) {
+auto Theme::create(QQmlEngine *engine, QJSEngine *scriptEngine) -> Theme * {
   Q_UNUSED(engine)
   Q_UNUSED(scriptEngine)
   return instance();
 }
 
-QVariantList Theme::playerColors() const {
+QVariantList Theme::playerColors() {
   QVariantList colors;
   colors.append(QVariantMap{{"name", "Red"}, {"hex", "#E74C3C"}});
   colors.append(QVariantMap{{"name", "Blue"}, {"hex", "#3498DB"}});
@@ -30,13 +35,13 @@ QVariantList Theme::playerColors() const {
   return colors;
 }
 
-QVariantList Theme::teamIcons() const {
+QVariantList Theme::teamIcons() {
   QVariantList icons;
   icons << "⚪" << "①" << "②" << "③" << "④" << "⑤" << "⑥" << "⑦" << "⑧";
   return icons;
 }
 
-QVariantList Theme::factions() const {
+QVariantList Theme::factions() {
   QVariantList factionsData;
   factionsData.append(QVariantMap{{"id", 0}, {"name", "Standard"}});
   factionsData.append(QVariantMap{{"id", 1}, {"name", "Romans"}});
@@ -45,7 +50,7 @@ QVariantList Theme::factions() const {
   return factionsData;
 }
 
-QVariantMap Theme::unitIcons() const {
+QVariantMap Theme::unitIcons() {
   QVariantMap icons;
   icons["archer"] = "🏹";
   icons["knight"] = "⚔️";

+ 61 - 61
ui/theme.h

@@ -76,67 +76,67 @@ public:
   static auto instance() -> Theme *;
   static auto create(QQmlEngine *engine, QJSEngine *scriptEngine) -> Theme *;
 
-  [[nodiscard]] static QColor bg() { return {"#071018"}; }
-  [[nodiscard]] static QColor bgShade() { return {"#061214"}; }
-  [[nodiscard]] static QColor dim() { return {0, 0, 0, 115}; }
-
-  [[nodiscard]] static QColor panelBase() { return {"#071018"}; }
-  [[nodiscard]] static QColor panelBr() { return {"#0f2430"}; }
-  [[nodiscard]] static QColor panelBorder() { return {"#0f2430"}; }
-
-  [[nodiscard]] static QColor cardBase() { return {"#061214"}; }
-  [[nodiscard]] static QColor cardBaseA() { return {"#061214AA"}; }
-  [[nodiscard]] static QColor cardBaseB() { return {"#061214"}; }
-  [[nodiscard]] static QColor cardBorder() { return {"#12323a"}; }
-
-  [[nodiscard]] static QColor hover() { return {"#184c7a"}; }
-  [[nodiscard]] static QColor hoverBg() { return {"#184c7a"}; }
-  [[nodiscard]] static QColor selected() { return {"#1f8bf5"}; }
-  [[nodiscard]] static QColor selectedBg() { return {"#1f8bf5"}; }
-  [[nodiscard]] static QColor selectedBr() { return {"#1b74d1"}; }
-
-  [[nodiscard]] static QColor thumbBr() { return {"#2A4E56"}; }
-  [[nodiscard]] static QColor border() { return {"#0f2b34"}; }
-
-  [[nodiscard]] static QColor textMain() { return {"#eaf6ff"}; }
-  [[nodiscard]] static QColor textBright() { return {"#dff0ff"}; }
-  [[nodiscard]] static QColor textSub() { return {"#86a7b6"}; }
-  [[nodiscard]] static QColor textSubLite() { return {"#79a6b7"}; }
-  [[nodiscard]] static QColor textDim() { return {"#4f6a75"}; }
-  [[nodiscard]] static QColor textHint() { return {"#2a5e6e"}; }
-
-  [[nodiscard]] static QColor accent() { return {"#9fd9ff"}; }
-  [[nodiscard]] static QColor accentBright() { return {"#d0e8ff"}; }
-
-  [[nodiscard]] static QColor addColor() { return {"#3A9CA8"}; }
-  [[nodiscard]] static QColor removeColor() { return {"#D04040"}; }
-
-  [[nodiscard]] static int spacingTiny() { return 4; }
-  [[nodiscard]] static int spacingSmall() { return 8; }
-  [[nodiscard]] static int spacingMedium() { return 12; }
-  [[nodiscard]] static int spacingLarge() { return 16; }
-  [[nodiscard]] static int spacingXLarge() { return 20; }
-
-  [[nodiscard]] static int radiusSmall() { return 4; }
-  [[nodiscard]] static int radiusMedium() { return 6; }
-  [[nodiscard]] static int radiusLarge() { return 8; }
-  [[nodiscard]] static int radiusPanel() { return 14; }
-
-  [[nodiscard]] static int animFast() { return 120; }
-  [[nodiscard]] static int animNormal() { return 160; }
-  [[nodiscard]] static int animSlow() { return 200; }
-
-  [[nodiscard]] static int fontSizeTiny() { return 11; }
-  [[nodiscard]] static int fontSizeSmall() { return 12; }
-  [[nodiscard]] static int fontSizeMedium() { return 14; }
-  [[nodiscard]] static int fontSizeLarge() { return 16; }
-  [[nodiscard]] static int fontSizeTitle() { return 18; }
-  [[nodiscard]] static int fontSizeHero() { return 28; }
-
-  [[nodiscard]] auto playerColors() const -> QVariantList;
-  [[nodiscard]] auto teamIcons() const -> QVariantList;
-  [[nodiscard]] auto factions() const -> QVariantList;
-  [[nodiscard]] auto unitIcons() const -> QVariantMap;
+  [[nodiscard]] static auto bg() -> QColor { return {"#071018"}; }
+  [[nodiscard]] static auto bgShade() -> QColor { return {"#061214"}; }
+  [[nodiscard]] static auto dim() -> QColor { return {0, 0, 0, 115}; }
+
+  [[nodiscard]] static auto panelBase() -> QColor { return {"#071018"}; }
+  [[nodiscard]] static auto panelBr() -> QColor { return {"#0f2430"}; }
+  [[nodiscard]] static auto panelBorder() -> QColor { return {"#0f2430"}; }
+
+  [[nodiscard]] static auto cardBase() -> QColor { return {"#061214"}; }
+  [[nodiscard]] static auto cardBaseA() -> QColor { return {"#061214AA"}; }
+  [[nodiscard]] static auto cardBaseB() -> QColor { return {"#061214"}; }
+  [[nodiscard]] static auto cardBorder() -> QColor { return {"#12323a"}; }
+
+  [[nodiscard]] static auto hover() -> QColor { return {"#184c7a"}; }
+  [[nodiscard]] static auto hoverBg() -> QColor { return {"#184c7a"}; }
+  [[nodiscard]] static auto selected() -> QColor { return {"#1f8bf5"}; }
+  [[nodiscard]] static auto selectedBg() -> QColor { return {"#1f8bf5"}; }
+  [[nodiscard]] static auto selectedBr() -> QColor { return {"#1b74d1"}; }
+
+  [[nodiscard]] static auto thumbBr() -> QColor { return {"#2A4E56"}; }
+  [[nodiscard]] static auto border() -> QColor { return {"#0f2b34"}; }
+
+  [[nodiscard]] static auto textMain() -> QColor { return {"#eaf6ff"}; }
+  [[nodiscard]] static auto textBright() -> QColor { return {"#dff0ff"}; }
+  [[nodiscard]] static auto textSub() -> QColor { return {"#86a7b6"}; }
+  [[nodiscard]] static auto textSubLite() -> QColor { return {"#79a6b7"}; }
+  [[nodiscard]] static auto textDim() -> QColor { return {"#4f6a75"}; }
+  [[nodiscard]] static auto textHint() -> QColor { return {"#2a5e6e"}; }
+
+  [[nodiscard]] static auto accent() -> QColor { return {"#9fd9ff"}; }
+  [[nodiscard]] static auto accentBright() -> QColor { return {"#d0e8ff"}; }
+
+  [[nodiscard]] static auto addColor() -> QColor { return {"#3A9CA8"}; }
+  [[nodiscard]] static auto removeColor() -> QColor { return {"#D04040"}; }
+
+  [[nodiscard]] static auto spacingTiny() -> int { return 4; }
+  [[nodiscard]] static auto spacingSmall() -> int { return 8; }
+  [[nodiscard]] static auto spacingMedium() -> int { return 12; }
+  [[nodiscard]] static auto spacingLarge() -> int { return 16; }
+  [[nodiscard]] static auto spacingXLarge() -> int { return 20; }
+
+  [[nodiscard]] static auto radiusSmall() -> int { return 4; }
+  [[nodiscard]] static auto radiusMedium() -> int { return 6; }
+  [[nodiscard]] static auto radiusLarge() -> int { return 8; }
+  [[nodiscard]] static auto radiusPanel() -> int { return 14; }
+
+  [[nodiscard]] static auto animFast() -> int { return 120; }
+  [[nodiscard]] static auto animNormal() -> int { return 160; }
+  [[nodiscard]] static auto animSlow() -> int { return 200; }
+
+  [[nodiscard]] static auto fontSizeTiny() -> int { return 11; }
+  [[nodiscard]] static auto fontSizeSmall() -> int { return 12; }
+  [[nodiscard]] static auto fontSizeMedium() -> int { return 14; }
+  [[nodiscard]] static auto fontSizeLarge() -> int { return 16; }
+  [[nodiscard]] static auto fontSizeTitle() -> int { return 18; }
+  [[nodiscard]] static auto fontSizeHero() -> int { return 28; }
+
+  [[nodiscard]] static auto playerColors() -> QVariantList;
+  [[nodiscard]] static auto teamIcons() -> QVariantList;
+  [[nodiscard]] static auto factions() -> QVariantList;
+  [[nodiscard]] static auto unitIcons() -> QVariantMap;
 
 private:
   explicit Theme(QObject *parent = nullptr);