Horizon Official Technical Documentation
Char.hpp
Go to the documentation of this file.
1/***************************************************
2 * _ _ _ *
3 * | | | | (_) *
4 * | |_| | ___ _ __ _ _______ _ __ *
5 * | _ |/ _ \| '__| |_ / _ \| '_ \ *
6 * | | | | (_) | | | |/ / (_) | | | | *
7 * \_| |_/\___/|_| |_/___\___/|_| |_| *
8 ***************************************************
9 * This file is part of Horizon (c).
10 *
11 * Copyright (c) 2019 Sagun K. (sagunxp@gmail.com).
12 * Copyright (c) 2019 Horizon Dev Team.
13 *
14 * Base Author - Sagun K. (sagunxp@gmail.com)
15 *
16 * This library is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this library. If not, see <http://www.gnu.org/licenses/>.
28 **************************************************/
29
30#ifndef HORIZON_CHAR_CHARMAIN_HPP
31#define HORIZON_CHAR_CHARMAIN_HPP
32
33#include "Server/pch.hpp"
34
36
37namespace Horizon
38{
39namespace Char
40{
41class CharServer : public Server
42{
43
44enum character_server_type : uint16_t
45{
52};
53
55{
56 /* Start Map */
57 const std::string &start_map() const { return _start_map; }
58 void set_start_map(std::string const &map) { _start_map = map; }
59 /* Start X */
60 int16_t start_x() const { return _start_x; }
61 void set_start_x(int16_t x) { _start_x = x; }
62 /* Start Y */
63 int16_t start_y() const { return _start_y; }
64 void set_start_y(int16_t y) { _start_y = y; }
65 /* Start Zeny */
66 int32_t start_zeny() const { return _start_zeny; }
67 void set_start_zeny(int32_t zeny) { _start_zeny = zeny; }
68 /* Start Items */
69 void add_start_item(std::pair<int32_t, int32_t> item) { _start_items.push_back(item); }
70 std::pair<int32_t, int32_t> &start_item(std::size_t index) { return _start_items.at(index); }
71 std::size_t start_item_count() { return _start_items.size(); }
72 /* Character Deletion Time */
75 /* Zone Server IP */
76 const std::string &zone_server_ip() const { return _zone_server_ip; }
77 void set_zone_server_ip(std::string const &ip) { _zone_server_ip = ip; }
78 /* Zone Server Port */
79 int16_t zone_server_port() const { return _zone_server_port; }
80 void set_zone_server_port(int16_t port) { _zone_server_port = port; }
81
84
85 int32_t pincode_expiry() { return _pincode_expiry; }
87
89 void set_pincode_max_retry(int32_t retry) { _pincode_max_retry = retry; }
90
91 std::time_t session_max_timeout() { return _session_max_timeout; }
92 void set_session_max_timeout(std::time_t timeout) { _session_max_timeout = timeout; }
93
95 void set_max_network_threads(int threads) { _max_network_threads = threads; }
96private:
97 std::string _start_map{"new_1-1"};
98 int16_t _start_x{53}, _start_y{111};
99 int32_t _start_zeny{0};
100 std::vector<std::pair<int32_t, int32_t>> _start_items;
102 std::string _zone_server_ip;
109};
110
111public:
112 CharServer();
113 ~CharServer();
114
116 {
117 static CharServer instance;
118 return &instance;
119 }
120
121 bool read_config();
123
124 void initialize() override;
125 void finalize() override;
126
128
130
131 void update(uint64_t time);
132
134
135private:
138 boost::asio::deadline_timer _update_timer;
139};
140}
141}
142
143#define sChar Horizon::Char::CharServer::getInstance()
144
145#endif //HORIZON_CHAR_CHARMAIN_HPP
Definition: Char.hpp:42
character_server_type
Definition: Char.hpp:45
@ CHAR_SERVER_TYPE_OVER18
Definition: Char.hpp:48
@ CHAR_SERVER_TYPE_PAYING
Definition: Char.hpp:49
@ CHAR_SERVER_TYPE_MAX
Definition: Char.hpp:51
@ CHAR_SERVER_TYPE_MAINTENANCE
Definition: Char.hpp:47
@ CHAR_SERVER_TYPE_NORMAL
Definition: Char.hpp:46
@ CHAR_SERVER_TYPE_FREE2PLAY
Definition: Char.hpp:50
TaskScheduler & getScheduler()
Definition: Char.hpp:129
TaskScheduler _task_scheduler
Definition: Char.hpp:137
void initialize() override
Definition: Char.cpp:264
void finalize() override
Definition: Char.cpp:305
character_server_configuration & config()
Definition: Char.hpp:127
bool read_config()
Read /config/char-server.yaml.
Definition: Char.cpp:69
~CharServer()
Char Destructor.
Definition: Char.cpp:57
void verify_connected_sessions()
Definition: Char.cpp:205
static CharServer * getInstance()
Definition: Char.hpp:115
character_server_configuration _char_server_config
Definition: Char.hpp:136
void update(uint64_t time)
Definition: Char.cpp:236
boost::asio::deadline_timer _update_timer
Definition: Char.hpp:138
void initialize_cli_commands()
Definition: Char.cpp:184
CharServer()
Char Constructor.
Definition: Char.cpp:48
Definition: Server.hpp:554
The TaskScheduler class provides the ability to schedule std::function's in the near future....
Definition: TaskScheduler.hpp:58
Definition: Element.hpp:7
void set_zone_server_port(int16_t port)
Definition: Char.hpp:80
std::string _zone_server_ip
Definition: Char.hpp:102
std::vector< std::pair< int32_t, int32_t > > _start_items
Definition: Char.hpp:100
const std::string & start_map() const
Definition: Char.hpp:57
void set_pincode_expiry(int32_t pincode_expiry)
Definition: Char.hpp:86
void set_pincode_max_retry(int32_t retry)
Definition: Char.hpp:89
int32_t start_zeny() const
Definition: Char.hpp:66
std::time_t _session_max_timeout
Definition: Char.hpp:107
int16_t start_y() const
Definition: Char.hpp:63
std::time_t session_max_timeout()
Definition: Char.hpp:91
void set_char_hard_delete(bool d)
Definition: Char.hpp:83
void set_start_y(int16_t y)
Definition: Char.hpp:64
void set_start_zeny(int32_t zeny)
Definition: Char.hpp:67
void add_start_item(std::pair< int32_t, int32_t > item)
Definition: Char.hpp:69
int16_t start_x() const
Definition: Char.hpp:60
std::pair< int32_t, int32_t > & start_item(std::size_t index)
Definition: Char.hpp:70
std::size_t start_item_count()
Definition: Char.hpp:71
time_t character_deletion_time() const
Definition: Char.hpp:73
int16_t zone_server_port() const
Definition: Char.hpp:79
void set_character_deletion_time(time_t time)
Definition: Char.hpp:74
void set_zone_server_ip(std::string const &ip)
Definition: Char.hpp:77
void set_session_max_timeout(std::time_t timeout)
Definition: Char.hpp:92
const std::string & zone_server_ip() const
Definition: Char.hpp:76
void set_start_map(std::string const &map)
Definition: Char.hpp:58
void set_max_network_threads(int threads)
Definition: Char.hpp:95
void set_start_x(int16_t x)
Definition: Char.hpp:61