SEGS  0.6.1-develop [3e741b81]
Super Entity Game Server
MapServer.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2019 SEGS Team (see AUTHORS.md)
5  * This software is licensed under the terms of the 3-clause BSD License. See LICENSE.md for details.
6  */
7 
8 #pragma once
9 
12 #include "GameServer/GameServer.h"
13 //#include "Entity.h"
14 #include "MapLink.h"
15 
16 #include <memory>
17 
18 class Net;
19 class MapServerEndpoint;
20 struct MapClientSession;
21 class MapInstance;
22 class GameDataStore;
23 class MapManager;
24 namespace SEGSEvents
25 {
26 struct ExpectMapClientRequest;
27 struct ClientMapXferMessage;
28 }
29 
30 static constexpr uint8_t INVALID_GAME_SERVER_ID = 255;
31 static constexpr char RUNTIME_DATA_PATH[] = "./data/";
32 
33 class MapServer final : public EventProcessor
34 {
35  class PrivateData;
36 public:
38  MapServer(uint8_t id);
39  ~MapServer() override;
40 
41  bool ReadConfigAndRestart();
42 
43  void per_thread_shutdown() override;
44  MapManager & map_manager();
45  void set_game_server_owner(uint8_t owner_id);
46  bool session_has_xfer_in_progress(uint64_t session_token);
47  MapXferData & session_map_xfer_idx(uint64_t session_token);
48  void session_xfer_complete(uint64_t session_token);
49 private:
50  bool Run();
51  // EventProcessor interface
52  void dispatch(SEGSEvents::Event *ev) override;
53  void on_expect_client(SEGSEvents::ExpectMapClientRequest *ev);
54  void on_client_map_xfer(SEGSEvents::ClientMapXferMessage *ev);
55  void serialize_from(std::istream &is) override;
56  void serialize_to(std::ostream &is) override;
57 
58  std::unique_ptr<PrivateData> d;
59 
60  uint8_t m_id = 1;
61  uint8_t m_owner_game_server_id = INVALID_GAME_SERVER_ID;
62  ACE_INET_Addr m_base_location;
63  ACE_INET_Addr m_base_listen_point;
64  std::map<uint64_t, MapXferData> m_current_map_transfers; // Current map transfers in progress on this map server.
65 };
66 
Definition: MapClientSession.h:32
Definition: GameDataStore.h:27
Definition: SEGSEvent.h:35
The MapServer::PrivateData class - PIMPL idiom for internal MapServer data.
Definition: MapServer.cpp:50
Definition: LinkLevelEvent.h:13
Definition: MapInstance.h:132
Definition: MapServer.h:33
Definition: MapManager.h:20
Definition: EventProcessor.h:22
Definition: map_definitions.h:41
MapServer * g_GlobalMapServer
Definition: MapServer.cpp:38
#define IMPL_ID(EventProcessorChildType)
Definition: EventProcessor.h:44