GPR5100 - Rollback
Loading...
Searching...
No Matches
debug_db.h
1#pragma once
2
3#ifdef ENABLE_SQLITE
5#include "game/physics_manager.h"
6
7#include <string_view>
8#include <condition_variable>
9#include <thread>
10#include <vector>
11
12struct sqlite3;
13
14namespace game
15{
16
17struct DbPhysicsState
18{
19 std::array<PhysicsState, maxPlayerNmb> serverStates{};
20 std::array<PhysicsState, maxPlayerNmb> localStates{};
21 Frame lastLocalValidateFrame{};
22 Frame validateFrame{};
23};
24
25class DebugDatabase
26{
27public:
28 void Open(std::string_view path);
29 void StorePacket(const PlayerInputPacket* inputPacket);
30 void StorePhysicsState(const DbPhysicsState& physicsState);
31 void Close();
32private:
33 void Loop();
34 void CreateTables() const;
35 sqlite3* db = nullptr;
36 std::atomic<bool> isOver_ = false;
37 std::thread t_;
38 mutable std::mutex m_;
39 std::condition_variable cv_;
40 std::vector<std::string> commands_;
41};
42
43}
44#endif