Prechádzať zdrojové kódy

Address code review feedback: improve modularity and add clarifying comments

Co-authored-by: djeada <[email protected]>
copilot-swe-agent[bot] 1 týždeň pred
rodič
commit
ea5dddd25a

+ 1 - 13
app/core/ambient_state_manager.h

@@ -6,19 +6,7 @@ namespace Engine::Core {
 class World;
 class World;
 }
 }
 
 
-struct EntityCache {
-  int player_troop_count = 0;
-  bool player_barracks_alive = false;
-  bool enemy_barracks_alive = false;
-  int enemy_barracks_count = 0;
-
-  void reset() {
-    player_troop_count = 0;
-    player_barracks_alive = false;
-    enemy_barracks_alive = false;
-    enemy_barracks_count = 0;
-  }
-};
+struct EntityCache;
 
 
 class AmbientStateManager {
 class AmbientStateManager {
 public:
 public:

+ 14 - 0
app/core/game_engine.h

@@ -83,6 +83,20 @@ class AudioSystemProxy;
 
 
 class QQuickWindow;
 class QQuickWindow;
 
 
+struct EntityCache {
+  int player_troop_count = 0;
+  bool player_barracks_alive = false;
+  bool enemy_barracks_alive = false;
+  int enemy_barracks_count = 0;
+
+  void reset() {
+    player_troop_count = 0;
+    player_barracks_alive = false;
+    enemy_barracks_alive = false;
+    enemy_barracks_count = 0;
+  }
+};
+
 class GameEngine : public QObject {
 class GameEngine : public QObject {
   Q_OBJECT
   Q_OBJECT
 public:
 public:

+ 5 - 1
app/core/minimap_manager.cpp

@@ -84,6 +84,8 @@ void MinimapManager::update_fog(float dt, int local_owner_id) {
   const int img_width = m_minimap_image.width();
   const int img_width = m_minimap_image.width();
   const int img_height = m_minimap_image.height();
   const int img_height = m_minimap_image.height();
 
 
+  // Rotation constants for -45 degree isometric projection
+  // k_inv_cos = -cos(45°), k_inv_sin = sin(45°)
   constexpr float k_inv_cos = -0.70710678118F;
   constexpr float k_inv_cos = -0.70710678118F;
   constexpr float k_inv_sin = 0.70710678118F;
   constexpr float k_inv_sin = 0.70710678118F;
 
 
@@ -180,7 +182,9 @@ void MinimapManager::update_units(
   }
   }
 
 
   std::vector<Game::Map::Minimap::UnitMarker> markers;
   std::vector<Game::Map::Minimap::UnitMarker> markers;
-  markers.reserve(128);
+  // Reserve space for typical unit count to avoid reallocations
+  constexpr size_t EXPECTED_MAX_UNITS = 128;
+  markers.reserve(EXPECTED_MAX_UNITS);
 
 
   std::unordered_set<Engine::Core::EntityID> selected_ids;
   std::unordered_set<Engine::Core::EntityID> selected_ids;
   if (selection_system) {
   if (selection_system) {