aboutsummaryrefslogtreecommitdiff
path: root/src/server/database.hh
diff options
context:
space:
mode:
authorNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 18:05:18 +1100
committerNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 18:05:18 +1100
commit1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df (patch)
tree222dfcd07a1e40716127a347bbfd7119ce3d0984 /src/server/database.hh
initial commit
Diffstat (limited to 'src/server/database.hh')
-rw-r--r--src/server/database.hh39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/server/database.hh b/src/server/database.hh
new file mode 100644
index 0000000..154cdf2
--- /dev/null
+++ b/src/server/database.hh
@@ -0,0 +1,39 @@
+#ifndef SERVER_DATABASE_HH_
+#define SERVER_DATABASE_HH_
+
+#include <bit>
+#include <filesystem>
+#include <optional>
+#include <string>
+#include <unordered_map>
+#include <utility>
+
+#include <sqlite3.h>
+
+#include "server/shared.hh"
+#include "shared/net/net.hh"
+#include "shared/shared.hh"
+#include "shared/world.hh"
+
+namespace server {
+namespace database {
+
+void init() noexcept;
+void quit() noexcept;
+
+// chunks
+std::optional<proto::chunk>
+maybe_read_chunk(const shared::math::coords& c) noexcept;
+void write_chunk(const shared::math::coords& pos,
+ const proto::chunk& chunk) noexcept;
+
+// players
+std::optional<std::pair<proto::player, std::string>> // player, password
+maybe_read_player(const std::string& username) noexcept;
+void write_player(const std::string& username, const std::string& password,
+ const proto::player& player) noexcept;
+
+} // namespace database
+} // namespace server
+
+#endif