aboutsummaryrefslogtreecommitdiff
path: root/src/server/database.hh
blob: 154cdf23aa837948fcc97c8c3100b38d7b911c54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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