summaryrefslogtreecommitdiffstats
path: root/src/game/server/sessions.hh
blob: 656b76dc366286f055e14f7a5fe64e8f39f3c1d1 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once

namespace world
{
class Dimension;
} // namespace world

namespace config
{
class Unsigned;
} // namespace config

struct Session final {
    std::uint16_t client_index;
    std::uint64_t client_identity;
    std::string client_username;
    entt::entity player_entity;
    world::Dimension* dimension;
    ENetPeer* peer;
};

namespace sessions
{
extern config::Unsigned max_players;
extern unsigned int num_players;
} // namespace sessions

namespace sessions
{
void init(void);
void init_late(void);
void init_post_universe(void);
void shutdown(void);
} // namespace sessions

namespace sessions
{
Session* create(ENetPeer* peer, std::string_view client_username);
Session* find(std::string_view client_username);
Session* find(std::uint16_t client_index);
Session* find(std::uint64_t client_identity);
Session* find(ENetPeer* peer);
void destroy(Session* session);
} // namespace sessions

namespace sessions
{
void broadcast(const world::Dimension* dimension, ENetPacket* packet);
void broadcast(const world::Dimension* dimension, ENetPacket* packet, ENetPeer* except);
} // namespace sessions

namespace sessions
{
void refresh_scoreboard(void);
} // namespace sessions