SEGS  0.4.2
Super Entity Game Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MapClientSession.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2018 SEGS Team (see Authors.txt)
5  * This software is licensed! (See License.txt for details)
6  */
7 
8 #pragma once
9 #include "FixedPointValue.h"
10 #include "Events/GameCommandList.h"
13 
14 #include <map>
15 #include <memory>
16 
17 class MapHandler;
18 class MapInstance;
19 class NetCommand;
20 struct MapLink;
21 class GamePacket;
22 class SEGSTimer;
23 class Entity;
24 
26 {
27  const Entity *m_entity = nullptr; // this is the entity this belief is linked to.
28  Vector3_FPV position; // we think client considers m_entity to be located here.
29  bool m_is_logging_out = false;
30 };
31 
33 {
34  using mNetCommands = std::map<int, NetCommand *>;
35  using vBelief = std::map<int, ClientEntityStateBelief>;
36  using vStoredCommands = std::vector<std::unique_ptr<GameCommand>>;
37  friend class CharacterDatabase;
38 
39  uint32_t m_client_id = 0;
40  uint8_t m_access_level = 0;
42  uint16_t m_max_slots;
46  Entity * m_ent = nullptr;
47  QString m_name; // current character name, stored here for quick lookups
48  SEGSTimer * m_tick_source = nullptr;
50  bool m_in_map = false;
51 
52  // The values below might be needed for map<->map handover ?
55  void addCommandToSendNextUpdate(std::unique_ptr<GameCommand> &&v) {
56  m_contents.emplace_back(std::move(v));
57  }
58  void AddShortcut(int index, NetCommand *command)
59  {
60  if (m_shortcuts.find(index) != m_shortcuts.end())
61  {
62  qDebug() << "Replacing command" << index << m_shortcuts[index]->m_name <<
63  "->" << command->m_name;
64  }
65  m_shortcuts[index] = command;
66  }
67 
68  uint32_t auth_id() const { return m_client_id; }
69  // TODO: for now session reuse does not retain any data, should it ?
70  void reset() { *this = {}; }
71  // Map sessions do not support temporary ones right now.
72  void set_temporary(bool v) { assert(v==false); }
73  bool is_temporary() const { return false; }
74  MapLink * link() { return m_link; }
76  void link(MapLink *l) { m_link = l; }
77 
78 protected:
79  MapLink * m_link = nullptr;
80 };
uint32_t is_connected_to_map_instance_id
Definition: MapClientSession.h:54
Instances of SEGSTimer class are used to schedule events in the future.
Definition: SEGSTimer.h:18
Definition: MapClientSession.h:32
bool is_temporary() const
Definition: MapClientSession.h:73
Entity * m_ent
Definition: MapClientSession.h:46
uint8_t m_access_level
Definition: MapClientSession.h:40
uint32_t m_client_id
Definition: MapClientSession.h:39
Vector3_FPV position
Definition: MapClientSession.h:28
Definition: MapClientSession.h:25
void addCommandToSendNextUpdate(std::unique_ptr< GameCommand > &&v)
Definition: MapClientSession.h:55
void link(MapLink *l)
Definition: MapClientSession.h:76
MapInstance * m_current_map
Definition: MapClientSession.h:45
void reset()
Definition: MapClientSession.h:70
std::map< int, NetCommand * > mNetCommands
Definition: MapClientSession.h:34
Definition: MapInstance.h:35
std::vector< std::unique_ptr< GameCommand >> vStoredCommands
Definition: MapClientSession.h:36
void set_temporary(bool v)
Definition: MapClientSession.h:72
bool m_in_map
Definition: MapClientSession.h:50
const Entity * m_entity
Definition: MapClientSession.h:27
uint32_t is_connected_to_map_server_id
Definition: MapClientSession.h:53
Definition: Entity.h:221
QString m_name
Definition: MapClientSession.h:47
Definition: NetCommandManager.h:20
void AddShortcut(int index, NetCommand *command)
Definition: MapClientSession.h:58
Definition: FixedPointValue.h:28
vStoredCommands m_contents
Definition: MapClientSession.h:44
MapLink * link()
Definition: MapClientSession.h:74
friend class CharacterDatabase
Definition: MapClientSession.h:37
QString m_name
Definition: NetCommandManager.h:43
uint16_t m_requested_slot_idx
Definition: MapClientSession.h:41
bool m_is_logging_out
Definition: MapClientSession.h:29
SEGSTimer * m_tick_source
Definition: MapClientSession.h:48
vBelief m_worldstate_belief
Definition: MapClientSession.h:49
uint16_t m_max_slots
Definition: MapClientSession.h:42
uint32_t auth_id() const
Definition: MapClientSession.h:68
std::map< int, ClientEntityStateBelief > vBelief
Definition: MapClientSession.h:35
MapLink * m_link
Definition: MapClientSession.h:79
mNetCommands m_shortcuts
Definition: MapClientSession.h:43