Read /config/char-server.yaml.
Process Configuration that is common between servers.
70{
71 sol::state lua;
73
74
75 try {
76 lua.script_file(file_path);
77 } catch(const std::exception &e) {
78 HLog(error) <<
"Char::ReadConfig: " << e.what();
79 return false;
80 }
81
82 sol::table tbl = lua["horizon_config"];
83
84 try {
85 sol::table chtbl = tbl.get<sol::table>("new_character");
90
91 sol::optional<sol::table> maybe_chitbl = chtbl.get<sol::optional<sol::table>>("start_items");
92
93 if (maybe_chitbl) {
94 sol::table chitbl = maybe_chitbl.value();
95 chitbl.for_each([this](sol::object const &key, sol::object const &value) {
97 });
98 if (chitbl.size() < 1) {
101 }
102 }
103 } catch (sol::error &err) {
104 HLog(error) <<
"Error for setting in new_character:" << err.what();
105 }
106
107 try {
108 int char_deletion_time = tbl.get_or("character_deletion_time", 86400);
110 HLog(info) <<
"Character deletion wait period : '" << char_deletion_time <<
"'.";
111 } catch (sol::error &err) {
112 HLog(error) <<
"Error for setting character_deletion_time:" << err.what();
113 }
114
115 try {
116 bool char_hard_delete = tbl.get_or("character_hard_delete", false);
118 HLog(info) <<
"Character hard delete (permanently deleted) : '" << (char_hard_delete ?
"True" :
"False") <<
"'.";
119 } catch (sol::error &err) {
120 HLog(error) <<
"Error for setting character_hard_delete:" << err.what();
121 }
122
123 try {
124 sol::table zone_tbl = tbl.get<sol::table>("zone_server");
125
126 std::string ip_addr = zone_tbl.get_or("ip_address", std::string("127.0.0.1"));
127 int32_t port = zone_tbl.get_or("port", 5121);
128
132 } catch (sol::error &err) {
133 HLog(error) <<
"Error for setting zone_server:" << err.what();
134 }
135
136 try {
137 int32_t pincode_expiry = tbl.get<int32_t>("pincode_expiry");
140 } catch (sol::error &err) {
141 HLog(error) <<
"Error for setting pincode_expiry:" << err.what();
142 }
143
144 try {
145 int32_t pincode_max_retry = tbl.get<uint32_t>("pincode_max_retry");
148 } catch (sol::error &err) {
149 HLog(error) <<
"Error for setting pincode_max_retry:" << err.what();
150 }
151
152 try {
153 int32_t session_max_timeout = tbl.get_or("session_max_timeout", 60);
156 << " sessions surpassing this time limit will be disconnected.";
157 } catch (sol::error &err) {
158 HLog(error) <<
"Error for setting session_max_timeout:" << err.what();
159 }
160
161
162 try {
163 int32_t max_network_threads = tbl.get_or("max_network_threads", 1);
166 } catch (sol::error &err) {
167 HLog(error) <<
"Error for setting max_network_threads:" << err.what();
168 }
169
174 return false;
175
176 HLog(info) <<
"Done reading server configurations from '" << file_path <<
"'.";
177
178 return true;
179}
bool parse_common_configs(sol::table &cfg)
Definition: Server.cpp:372
void set_zone_server_port(int16_t port)
Definition: Char.hpp:80
int32_t pincode_max_retry()
Definition: Char.hpp:88
void set_pincode_expiry(int32_t pincode_expiry)
Definition: Char.hpp:86
int max_network_threads()
Definition: Char.hpp:94
void set_pincode_max_retry(int32_t retry)
Definition: Char.hpp:89
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 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
int32_t pincode_expiry()
Definition: Char.hpp:85
void set_start_x(int16_t x)
Definition: Char.hpp:61
const boost::filesystem::path & get_config_file_path() const
Definition: ServerConfiguration.hpp:55