Skip to content

Commit bc293e0

Browse files
fix cyclic includes
1 parent bbfc653 commit bc293e0

13 files changed

Lines changed: 274 additions & 313 deletions

File tree

include/database/DbManager.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ class DbManager {
4747
bool IsInitialized() const { return initialized_; }
4848

4949
// Backend Management
50+
bool SaveGameState(const std::string& key, const nlohmann::json& state);
5051
bool SetBackend(DatabaseType type, const nlohmann::json& config);
5152
DatabaseBackend* GetBackend() const { return backend_.get(); }
5253
DatabaseType GetCurrentType() const { return currentType_; }
54+
nlohmann::json Query(const std::string& sql) { return backend_->Query(sql); };
55+
nlohmann::json GetPlayer(uint64_t playerId){ return backend_->GetPlayer(playerId); };
5356

5457
// Configuration
5558
bool LoadConfiguration(const std::string& configPath = "");
@@ -85,6 +88,11 @@ class DbManager {
8588
static DbManager* instance_;
8689

8790
std::unique_ptr<DatabaseBackend> backend_;
91+
// #ifdef USE_CITUS
92+
// std::unique_ptr<CitusClient> backend_;
93+
// #else
94+
// std::unique_ptr<PostgreSqlClient> backend_;
95+
// #endif
8896
DatabaseType currentType_;
8997
nlohmann::json config_;
9098
std::atomic<bool> initialized_;

include/game/GameLogic.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@
66
#include <glm/glm.hpp>
77
#include <nlohmann/json.hpp>
88

9-
#include "config/ConfigManager.hpp"
10-
#include "logging/Logger.hpp"
11-
#include "network/ConnectionManager.hpp"
12-
#include "database/DbManager.hpp"
13-
14-
#include "game/LogicWorld.hpp"
15-
#include "game/LogicEntity.hpp"
16-
#include "game/ChunkLOD.hpp"
17-
#include "game/CollisionSystem.hpp"
18-
19-
20-
class GameLogic {
9+
// #include "config/ConfigManager.hpp"
10+
// #include "logging/Logger.hpp"
11+
// #include "network/ConnectionManager.hpp"
12+
// #include "database/DbManager.hpp"
13+
//
14+
// #include "game/ChunkLOD.hpp"
15+
// #include "game/CollisionSystem.hpp"
16+
#include "game/LogicCore.hpp"
17+
18+
class GameLogic : public LogicCore
19+
{
2120
public:
2221
static GameLogic& GetInstance();
2322

@@ -122,10 +121,11 @@ class GameLogic {
122121
// Component systems
123122
LogicWorld worldLogic_;
124123
LogicEntity entityLogic_;
125-
124+
//PlayerManager& playerManager_;
125+
126126
// Database backend
127127
std::unique_ptr<DatabaseBackend> databaseBackend_;
128-
128+
129129
// Connection manager for broadcasting
130130
std::shared_ptr<ConnectionManager> connectionManager_;
131131

include/game/LogicCore.hpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,20 @@
2121
//#include "config/ConfigManager.hpp"
2222
//#include "logging/Logger.hpp"
2323
//#include "database/DbManager.hpp"
24+
#include "game/RAIIThread.hpp"
2425
#include "game/PlayerManager.hpp"
26+
#include "game/LogicWorld.hpp"
27+
#include "game/LogicEntity.hpp"
2528

2629
class PythonScripting;
2730
class ScriptHotReloader;
2831
#include "scripting/PythonScripting.hpp"
2932

3033
class LogicCore {
3134
public:
35+
LogicCore();
36+
~LogicCore();
37+
3238
using MessageHandler = std::function<void(uint64_t sessionId, const nlohmann::json&)>;
3339
using BinaryMessageHandler = std::function<void(uint64_t sessionId, uint16_t messageType, const std::vector<uint8_t>&)>;
3440
using EventCallback = std::function<void()>;
@@ -81,15 +87,13 @@ class LogicCore {
8187
bool CheckRateLimit(uint64_t sessionId);
8288

8389
protected:
84-
LogicCore();
85-
virtual ~LogicCore();
8690

8791
// Threading
8892
RAIIThread gameLoopThread_;
8993
RAIIThread spawnerThread_;
9094
RAIIThread saveThread_;
9195

92-
std::atomic<bool> running_{false};
96+
std::atomic<bool> running_;
9397
std::chrono::milliseconds gameLoopInterval_{16};
9498

9599
std::condition_variable gameLoopCV_;
@@ -122,11 +126,11 @@ class LogicCore {
122126

123127
// References to other systems
124128
PlayerManager& playerManager_;
125-
CitusClient& dbClient_;
129+
DbManager& dbManager_;
126130

127131
PythonScripting& pythonScripting_;
128132
std::unique_ptr<ScriptHotReloader> scriptHotReloader_;
129-
bool pythonEnabled_{false};
133+
bool pythonEnabled_;
130134

131135
// Random generator
132136
std::mt19937 rng_;
@@ -136,15 +140,15 @@ class LogicCore {
136140
virtual void SpawnerLoop();
137141
virtual void SaveLoop();
138142

139-
// ADDED: Missing method declarations
143+
// method declarations
140144
void ProcessGameTick(float deltaTime);
141145
void SpawnEnemies();
142146
void RespawnNPCs();
143147
void SpawnResources();
144148
void SaveGameState();
145149
void CleanupOldData();
146150

147-
// ADDED: Missing handler declarations
151+
// handler declarations
148152
void HandleLogin(uint64_t sessionId, const nlohmann::json& data);
149153
void HandleChat(uint64_t sessionId, const nlohmann::json& data);
150154
void HandleCombat(uint64_t sessionId, const nlohmann::json& data);

0 commit comments

Comments
 (0)