| 1 | /* |
| 2 | * Copyright (C) 2000,2001 Onlyer ([email protected]) |
| 3 | * Copyright (C) 2005 Dizzy |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | #include "common/setup_before.h" |
| 20 | #include "setup.h" |
| 21 | #include "prefs.h" |
| 22 | |
| 23 | #include <cstdio> |
| 24 | #include <ctime> |
| 25 | |
| 26 | #include "common/conf.h" |
| 27 | #include "common/eventlog.h" |
| 28 | #include "common/setup_after.h" |
| 29 | |
| 30 | namespace pvpgn |
| 31 | { |
| 32 | |
| 33 | namespace d2cs |
| 34 | { |
| 35 | |
| 36 | static struct |
| 37 | { |
| 38 | char const * logfile; |
| 39 | char const * loglevels; |
| 40 | char const * servaddrs; |
| 41 | char const * gameservlist; |
| 42 | char const * bnetdaddr; |
| 43 | char const * charsavedir; |
| 44 | char const * charinfodir; |
| 45 | char const * bak_charsavedir; |
| 46 | char const * bak_charinfodir; |
| 47 | char const * ladderdir; |
| 48 | char const * newbiefile_amazon; |
| 49 | char const * newbiefile_sorceress; |
| 50 | char const * newbiefile_necromancer; |
| 51 | char const * newbiefile_paladin; |
| 52 | char const * newbiefile_barbarian; |
| 53 | char const * newbiefile_druid; |
| 54 | char const * newbiefile_assasin; |
| 55 | char const * motd; |
| 56 | char const * realmname; |
| 57 | char const * d2gs_password; |
| 58 | char const * transfile; |
| 59 | char const * account_allowed_symbols; |
| 60 | char const * d2gsconffile; |
| 61 | char const * pidfile; |
| 62 | unsigned int ladder_refresh_interval; |
| 63 | unsigned int maxchar; |
| 64 | unsigned int listpurgeinterval; |
| 65 | unsigned int gqcheckinterval; |
| 66 | unsigned int s2s_retryinterval; |
| 67 | unsigned int s2s_timeout; |
| 68 | unsigned int s2s_idletime; |
| 69 | unsigned int sq_checkinterval; |
| 70 | unsigned int sq_timeout; |
| 71 | unsigned int maxgamelist; |
| 72 | unsigned int max_game_idletime; |
| 73 | unsigned int gamelist_showall; |
| 74 | unsigned int hide_pass_games; |
| 75 | unsigned int game_maxlifetime; |
| 76 | unsigned int game_maxlevel; |
| 77 | unsigned int allow_gamelimit; |
| 78 | unsigned int allow_newchar; |
| 79 | unsigned int idletime; |
| 80 | unsigned int shutdown_delay; |
| 81 | unsigned int shutdown_decr; |
| 82 | unsigned int d2gs_checksum; |
| 83 | unsigned int d2gs_version; |
| 84 | unsigned int check_multilogin; |
| 85 | unsigned int timeout_checkinterval; |
| 86 | unsigned int s2s_keepalive_interval; |
| 87 | unsigned int lod_realm; |
| 88 | unsigned int allow_convert; |
| 89 | unsigned int d2gs_restart_delay; |
| 90 | std::time_t ladder_start_time; |
| 91 | unsigned int char_expire_day; |
| 92 | char const * charlist_sort; |
| 93 | char const * charlist_sort_order; |
| 94 | unsigned int max_connections; |
| 95 | } prefs_conf; |
| 96 | |
| 97 | static int conf_set_logfile(const char* valstr); |
| 98 | static int conf_setdef_logfile(void); |
| 99 | |
| 100 | static int conf_set_loglevels(const char* valstr); |
| 101 | static int conf_setdef_loglevels(void); |
| 102 | |
| 103 | static int conf_set_servaddrs(const char* valstr); |
| 104 | static int conf_setdef_servaddrs(void); |
| 105 | |
| 106 | static int conf_set_gameservlist(const char* valstr); |
| 107 | static int conf_setdef_gameservlist(void); |
| 108 | |
| 109 | static int conf_set_bnetdaddr(const char* valstr); |
| 110 | static int conf_setdef_bnetaddr(void); |
| 111 | |
| 112 | static int conf_set_charsavedir(const char* valstr); |
| 113 | static int conf_setdef_charsavedir(void); |
| 114 | |
| 115 | static int conf_set_charinfodir(const char* valstr); |
| 116 | static int conf_setdef_charinfodir(void); |
| 117 | |
| 118 | static int conf_set_bakcharsavedir(const char* valstr); |
| 119 | static int conf_setdef_backcharsavedir(void); |
| 120 | |
| 121 | static int conf_set_bakcharinfodir(const char* valstr); |
| 122 | static int conf_setdef_backcharinfodir(void); |
| 123 | |
| 124 | static int conf_set_ladderdir(const char* valstr); |
| 125 | static int conf_setdef_ladderdir(void); |
| 126 | |
| 127 | static int conf_set_ladder_start_time(const char* valstr); |
| 128 | static int conf_setdef_ladder_start_time(void); |
| 129 | |
| 130 | static int conf_set_ladder_refresh_interval(const char* valstr); |
| 131 | static int conf_setdef_ladder_refresh_interval(void); |
| 132 | |
| 133 | static int conf_set_newbiefile_amazon(const char* valstr); |
| 134 | static int conf_setdef_newbiefile_amazon(void); |
| 135 | static int conf_set_newbiefile_sorceress(const char* valstr); |
| 136 | static int conf_setdef_newbiefile_sorceress(void); |
| 137 | static int conf_set_newbiefile_necromancer(const char* valstr); |
| 138 | static int conf_setdef_newbiefile_necromancer(void); |
| 139 | static int conf_set_newbiefile_paladin(const char* valstr); |
| 140 | static int conf_setdef_newbiefile_paladin(void); |
| 141 | static int conf_set_newbiefile_barbarian(const char* valstr); |
| 142 | static int conf_setdef_newbiefile_barbarian(void); |
| 143 | static int conf_set_newbiefile_druid(const char* valstr); |
| 144 | static int conf_setdef_newbiefile_druid(void); |
| 145 | static int conf_set_newbiefile_assasin(const char* valstr); |
| 146 | static int conf_setdef_newbiefile_assasin(void); |
| 147 | |
| 148 | static int conf_set_transfile(const char* valstr); |
| 149 | static int conf_setdef_transfile(void); |
| 150 | |
| 151 | static int conf_set_motd(const char* valstr); |
| 152 | static int conf_setdef_motd(void); |
| 153 | |
| 154 | static int conf_set_realmname(const char* valstr); |
| 155 | static int conf_setdef_realmname(void); |
| 156 | |
| 157 | static int conf_set_maxchar(const char* valstr); |
| 158 | static int conf_setdef_maxchar(void); |
| 159 | |
| 160 | static int conf_set_listpurgeinterval(const char* valstr); |
| 161 | static int conf_setdef_listpurgeinterval(void); |
| 162 | |
| 163 | static int conf_set_gqcheckinterval(const char* valstr); |
| 164 | static int conf_setdef_gqcheckinterval(void); |
| 165 | |
| 166 | static int conf_set_maxgamelist(const char* valstr); |
| 167 | static int conf_setdef_maxgamelist(void); |
| 168 | |
| 169 | static int conf_set_max_game_idletime(const char* valstr); |
| 170 | static int conf_setdef_max_game_idletime(void); |
| 171 | |
| 172 | static int conf_set_gamelist_showall(const char* valstr); |
| 173 | static int conf_setdef_gamelist_showall(void); |
| 174 | |
| 175 | static int conf_set_hide_pass_games(const char* valstr); |
| 176 | static int conf_setdef_hide_pass_games(void); |
| 177 | |
| 178 | static int conf_set_game_maxlifetime(const char* valstr); |
| 179 | static int conf_setdef_game_maxlifetime(void); |
| 180 | |
| 181 | static int conf_set_game_maxlevel(const char* valstr); |
| 182 | static int conf_setdef_game_maxlevel(void); |
| 183 | |
| 184 | static int conf_set_allow_gamelimit(const char* valstr); |
| 185 | static int conf_setdef_allow_gamelimit(void); |
| 186 | |
| 187 | static int conf_set_allow_newchar(const char* valstr); |
| 188 | static int conf_setdef_allow_newchar(void); |
| 189 | |
| 190 | static int conf_set_idletime(const char* valstr); |
| 191 | static int conf_setdef_idletime(void); |
| 192 | |
| 193 | static int conf_set_shutdown_delay(const char* valstr); |
| 194 | static int conf_setdef_shutdown_delay(void); |
| 195 | |
| 196 | static int conf_set_shutdown_decr(const char* valstr); |
| 197 | static int conf_setdef_shutdown_decr(void); |
| 198 | |
| 199 | static int conf_set_s2s_retryinterval(const char* valstr); |
| 200 | static int conf_setdef_s2s_retryinterval(void); |
| 201 | |
| 202 | static int conf_set_s2s_timeout(const char* valstr); |
| 203 | static int conf_setdef_s2s_timeout(void); |
| 204 | |
| 205 | static int conf_set_sq_checkinterval(const char* valstr); |
| 206 | static int conf_setdef_sq_checkinterval(void); |
| 207 | |
| 208 | static int conf_set_sq_timeout(const char* valstr); |
| 209 | static int conf_setdef_sq_timeout(void); |
| 210 | |
| 211 | static int conf_set_d2gs_checksum(const char* valstr); |
| 212 | static int conf_setdef_d2gs_checksum(void); |
| 213 | |
| 214 | static int conf_set_d2gs_version(const char* valstr); |
| 215 | static int conf_setdef_d2gs_version(void); |
| 216 | |
| 217 | static int conf_set_d2gs_password(const char* valstr); |
| 218 | static int conf_setdef_d2gs_password(void); |
| 219 | |
| 220 | static int conf_set_check_multilogin(const char* valstr); |
| 221 | static int conf_setdef_check_multilogin(void); |
| 222 | |
| 223 | static int conf_set_s2s_idletime(const char* valstr); |
| 224 | static int conf_setdef_s2s_idletime(void); |
| 225 | |
| 226 | static int conf_set_s2s_keepalive_interval(const char* valstr); |
| 227 | static int conf_setdef_s2s_keepalive_interval(void); |
| 228 | |
| 229 | static int conf_set_timeout_checkinterval(const char* valstr); |
| 230 | static int conf_setdef_timeout_checkinterval(void); |
| 231 | |
| 232 | static int conf_set_lod_realm(const char* valstr); |
| 233 | static int conf_setdef_lod_realm(void); |
| 234 | |
| 235 | static int conf_set_allow_convert(const char* valstr); |
| 236 | static int conf_setdef_allow_convert(void); |
| 237 | |
| 238 | static int conf_set_account_allowed_symbols(const char* valstr); |
| 239 | static int conf_setdef_account_allowed_symbols(void); |
| 240 | |
| 241 | static int conf_set_d2gs_restart_delay(const char* valstr); |
| 242 | static int conf_setdef_d2gs_restart_delay(void); |
| 243 | |
| 244 | static int conf_set_char_expire_day(const char* valstr); |
| 245 | static int conf_setdef_char_expire_day(void); |
| 246 | |
| 247 | static int conf_set_d2gsconffile(const char* valstr); |
| 248 | static int conf_setdef_d2gsconffile(void); |
| 249 | |
| 250 | static int conf_set_charlist_sort(const char* valstr); |
| 251 | static int conf_setdef_charlist_sort(void); |
| 252 | |
| 253 | static int conf_set_charlist_sort_order(const char* valstr); |
| 254 | static int conf_setdef_charlist_sort_order(void); |
| 255 | |
| 256 | static int conf_set_max_connections(const char* valstr); |
| 257 | static int conf_setdef_max_connections(void); |
| 258 | |
| 259 | static int conf_set_pidfile(const char* valstr); |
| 260 | static int conf_setdef_pidfile(void); |
| 261 | |
| 262 | static t_conf_entry prefs_conf_table[]={ |
| 263 | { "logfile", conf_set_logfile, NULL, conf_setdef_logfile }, |
| 264 | { "loglevels", conf_set_loglevels, NULL, conf_setdef_loglevels}, |
| 265 | { "servaddrs", conf_set_servaddrs, NULL, conf_setdef_servaddrs}, |
| 266 | { "gameservlist", conf_set_gameservlist, NULL, conf_setdef_gameservlist}, |
| 267 | { "bnetdaddr", conf_set_bnetdaddr, NULL, conf_setdef_bnetaddr}, |
| 268 | { "charsavedir", conf_set_charsavedir, NULL, conf_setdef_charsavedir}, |
| 269 | { "charinfodir", conf_set_charinfodir, NULL, conf_setdef_charinfodir}, |
| 270 | { "bak_charsavedir", conf_set_bakcharsavedir, NULL, conf_setdef_backcharsavedir}, |
| 271 | { "bak_charinfodir", conf_set_bakcharinfodir, NULL, conf_setdef_backcharinfodir}, |
| 272 | { "ladderdir", conf_set_ladderdir, NULL, conf_setdef_ladderdir}, |
| 273 | { "ladder_start_time", conf_set_ladder_start_time, NULL, conf_setdef_ladder_start_time}, |
| 274 | { "ladder_refresh_interval",conf_set_ladder_refresh_interval,NULL, conf_setdef_ladder_refresh_interval}, |
| 275 | { "newbiefile_amazon", conf_set_newbiefile_amazon, NULL, conf_setdef_newbiefile_amazon }, |
| 276 | { "newbiefile_sorceress", conf_set_newbiefile_sorceress, NULL, conf_setdef_newbiefile_sorceress }, |
| 277 | { "newbiefile_necromancer", conf_set_newbiefile_necromancer, NULL, conf_setdef_newbiefile_necromancer }, |
| 278 | { "newbiefile_paladin", conf_set_newbiefile_paladin, NULL, conf_setdef_newbiefile_paladin }, |
| 279 | { "newbiefile_barbarian", conf_set_newbiefile_barbarian, NULL, conf_setdef_newbiefile_barbarian }, |
| 280 | { "newbiefile_druid", conf_set_newbiefile_druid, NULL, conf_setdef_newbiefile_druid }, |
| 281 | { "newbiefile_assasin", conf_set_newbiefile_assasin, NULL, conf_setdef_newbiefile_assasin }, |
| 282 | { "transfile", conf_set_transfile, NULL, conf_setdef_transfile}, |
| 283 | { "pidfile", conf_set_pidfile, NULL, conf_setdef_pidfile}, |
| 284 | { "motd", conf_set_motd, NULL, conf_setdef_motd}, |
| 285 | { "realmname", conf_set_realmname, NULL, conf_setdef_realmname}, |
| 286 | { "maxchar", conf_set_maxchar, NULL, conf_setdef_maxchar}, |
| 287 | { "listpurgeinterval", conf_set_listpurgeinterval, NULL, conf_setdef_listpurgeinterval}, |
| 288 | { "gqcheckinterval", conf_set_gqcheckinterval, NULL, conf_setdef_gqcheckinterval}, |
| 289 | { "maxgamelist", conf_set_maxgamelist, NULL, conf_setdef_maxgamelist}, |
| 290 | { "max_game_idletime", conf_set_max_game_idletime, NULL, conf_setdef_max_game_idletime}, |
| 291 | { "gamelist_showall", conf_set_gamelist_showall, NULL, conf_setdef_gamelist_showall}, |
| 292 | { "hide_pass_games", conf_set_hide_pass_games, NULL, conf_setdef_hide_pass_games}, |
| 293 | { "game_maxlifetime", conf_set_game_maxlifetime, NULL, conf_setdef_game_maxlifetime}, |
| 294 | { "game_maxlevel", conf_set_game_maxlevel, NULL, conf_setdef_game_maxlevel}, |
| 295 | { "allow_gamelimit", conf_set_allow_gamelimit, NULL, conf_setdef_allow_gamelimit}, |
| 296 | { "allow_newchar", conf_set_allow_newchar, NULL, conf_setdef_allow_newchar}, |
| 297 | { "idletime", conf_set_idletime, NULL, conf_setdef_idletime}, |
| 298 | { "shutdown_delay", conf_set_shutdown_delay, NULL, conf_setdef_shutdown_delay}, |
| 299 | { "shutdown_decr", conf_set_shutdown_decr, NULL, conf_setdef_shutdown_decr}, |
| 300 | { "s2s_retryinterval", conf_set_s2s_retryinterval, NULL, conf_setdef_s2s_retryinterval}, |
| 301 | { "s2s_timeout", conf_set_s2s_timeout, NULL, conf_setdef_s2s_timeout}, |
| 302 | { "sq_checkinterval", conf_set_sq_checkinterval, NULL, conf_setdef_sq_checkinterval}, |
| 303 | { "sq_timeout", conf_set_sq_timeout, NULL, conf_setdef_sq_timeout}, |
| 304 | { "d2gs_checksum", conf_set_d2gs_checksum, NULL, conf_setdef_d2gs_checksum}, |
| 305 | { "d2gs_version", conf_set_d2gs_version, NULL, conf_setdef_d2gs_version}, |
| 306 | { "d2gs_password", conf_set_d2gs_password, NULL, conf_setdef_d2gs_password}, |
| 307 | { "check_multilogin", conf_set_check_multilogin, NULL, conf_setdef_check_multilogin}, |
| 308 | { "s2s_idletime", conf_set_s2s_idletime, NULL, conf_setdef_s2s_idletime}, |
| 309 | { "s2s_keepalive_interval", conf_set_s2s_keepalive_interval, NULL, conf_setdef_s2s_keepalive_interval}, |
| 310 | { "timeout_checkinterval", conf_set_timeout_checkinterval, NULL, conf_setdef_timeout_checkinterval}, |
| 311 | { "lod_realm", conf_set_lod_realm, NULL, conf_setdef_lod_realm}, |
| 312 | { "allow_convert", conf_set_allow_convert, NULL, conf_setdef_allow_convert}, |
| 313 | { "account_allowed_symbols",conf_set_account_allowed_symbols,NULL, conf_setdef_account_allowed_symbols}, |
| 314 | { "d2gs_restart_delay", conf_set_d2gs_restart_delay, NULL, conf_setdef_d2gs_restart_delay}, |
| 315 | { "char_expire_day", conf_set_char_expire_day, NULL, conf_setdef_char_expire_day}, |
| 316 | { "d2gsconffile", conf_set_d2gsconffile, NULL, conf_setdef_d2gsconffile}, |
| 317 | { "charlist_sort", conf_set_charlist_sort, NULL, conf_setdef_charlist_sort}, |
| 318 | { "charlist_sort_order", conf_set_charlist_sort_order, NULL, conf_setdef_charlist_sort_order}, |
| 319 | { "max_connections", conf_set_max_connections, NULL, conf_setdef_max_connections}, |
| 320 | { NULL, NULL, NULL, NULL } |
| 321 | }; |
| 322 | |
| 323 | extern int d2cs_prefs_load(char const * filename) |
| 324 | { |
| 325 | std::FILE *fd; |
| 326 | |
| 327 | if (!filename) { |
| 328 | eventlog(eventlog_level_error,__FUNCTION__,"got NULL filename"); |
| 329 | return -1; |
| 330 | } |
| 331 | |
| 332 | fd = std::fopen(filename,"rt"); |
| 333 | if (!fd) { |
| 334 | eventlog(eventlog_level_error,__FUNCTION__,"could not open file '{}'",filename); |
| 335 | return -1; |
| 336 | } |
| 337 | |
| 338 | if (conf_load_file(fd,prefs_conf_table)) { |
| 339 | eventlog(eventlog_level_error,__FUNCTION__,"error loading config file '{}'",filename); |
| 340 | std::fclose(fd); |
| 341 | return -1; |
| 342 | } |
| 343 | |
| 344 | std::fclose(fd); |
| 345 | |
| 346 | return 0; |
| 347 | } |
| 348 | |
| 349 | extern int prefs_reload(char const * filename) |
| 350 | { |
| 351 | d2cs_prefs_unload(); |
| 352 | if (d2cs_prefs_load(filename)<0) return -1; |
| 353 | return 0; |
| 354 | } |
| 355 | |
| 356 | extern int d2cs_prefs_unload(void) |
| 357 | { |
| 358 | conf_unload(prefs_conf_table); |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | extern char const * prefs_get_servaddrs(void) |
| 363 | { |
| 364 | return prefs_conf.servaddrs; |
| 365 | } |
| 366 | |
| 367 | static int conf_set_servaddrs(const char* valstr) |
| 368 | { |
| 369 | return conf_set_str(&prefs_conf.servaddrs,valstr,NULL); |
| 370 | } |
| 371 | |
| 372 | static int conf_setdef_servaddrs(void) |
| 373 | { |
| 374 | return conf_set_str(&prefs_conf.servaddrs,NULL,D2CS_SERVER_ADDRS); |
| 375 | } |
| 376 | |
| 377 | |
| 378 | extern char const * prefs_get_charsave_dir(void) |
| 379 | { |
| 380 | return prefs_conf.charsavedir; |
| 381 | } |
| 382 | |
| 383 | static int conf_set_charsavedir(const char* valstr) |
| 384 | { |
| 385 | return conf_set_str(&prefs_conf.charsavedir,valstr,NULL); |
| 386 | } |
| 387 | |
| 388 | static int conf_setdef_charsavedir(void) |
| 389 | { |
| 390 | return conf_set_str(&prefs_conf.charsavedir,NULL,D2CS_CHARSAVE_DIR); |
| 391 | } |
| 392 | |
| 393 | |
| 394 | extern char const * prefs_get_charinfo_dir(void) |
| 395 | { |
| 396 | return prefs_conf.charinfodir; |
| 397 | } |
| 398 | |
| 399 | static int conf_set_charinfodir(const char* valstr) |
| 400 | { |
| 401 | return conf_set_str(&prefs_conf.charinfodir,valstr,NULL); |
| 402 | } |
| 403 | |
| 404 | static int conf_setdef_charinfodir(void) |
| 405 | { |
| 406 | return conf_set_str(&prefs_conf.charinfodir,NULL,D2CS_CHARINFO_DIR); |
| 407 | } |
| 408 | |
| 409 | |
| 410 | extern char const * prefs_get_bak_charsave_dir(void) |
| 411 | { |
| 412 | return prefs_conf.bak_charsavedir; |
| 413 | } |
| 414 | |
| 415 | static int conf_set_bakcharsavedir(const char* valstr) |
| 416 | { |
| 417 | return conf_set_str(&prefs_conf.bak_charsavedir,valstr,NULL); |
| 418 | } |
| 419 | |
| 420 | static int conf_setdef_backcharsavedir(void) |
| 421 | { |
| 422 | return conf_set_str(&prefs_conf.bak_charsavedir,NULL,D2CS_BAK_CHARSAVE_DIR); |
| 423 | } |
| 424 | |
| 425 | |
| 426 | extern char const * prefs_get_bak_charinfo_dir(void) |
| 427 | { |
| 428 | return prefs_conf.bak_charinfodir; |
| 429 | } |
| 430 | |
| 431 | static int conf_set_bakcharinfodir(const char* valstr) |
| 432 | { |
| 433 | return conf_set_str(&prefs_conf.bak_charinfodir,valstr,NULL); |
| 434 | } |
| 435 | |
| 436 | static int conf_setdef_backcharinfodir(void) |
| 437 | { |
| 438 | return conf_set_str(&prefs_conf.bak_charinfodir,NULL,D2CS_BAK_CHARINFO_DIR); |
| 439 | } |
| 440 | |
| 441 | |
| 442 | /* newbiefile */ |
| 443 | |
| 444 | extern char const * prefs_get_charsave_newbie_amazon(void) |
| 445 | { |
| 446 | return prefs_conf.newbiefile_amazon; |
| 447 | } |
| 448 | static int conf_set_newbiefile_amazon(const char* valstr) |
| 449 | { |
| 450 | return conf_set_str(&prefs_conf.newbiefile_amazon, valstr, NULL); |
| 451 | } |
| 452 | static int conf_setdef_newbiefile_amazon(void) |
| 453 | { |
| 454 | return conf_set_str(&prefs_conf.newbiefile_amazon, NULL, D2CS_CHARSAVE_NEWBIE); |
| 455 | } |
| 456 | |
| 457 | extern char const * prefs_get_charsave_newbie_sorceress(void) |
| 458 | { |
| 459 | return prefs_conf.newbiefile_sorceress; |
| 460 | } |
| 461 | static int conf_set_newbiefile_sorceress(const char* valstr) |
| 462 | { |
| 463 | return conf_set_str(&prefs_conf.newbiefile_sorceress, valstr, NULL); |
| 464 | } |
| 465 | static int conf_setdef_newbiefile_sorceress(void) |
| 466 | { |
| 467 | return conf_set_str(&prefs_conf.newbiefile_sorceress, NULL, D2CS_CHARSAVE_NEWBIE); |
| 468 | } |
| 469 | |
| 470 | extern char const * prefs_get_charsave_newbie_necromancer(void) |
| 471 | { |
| 472 | return prefs_conf.newbiefile_necromancer; |
| 473 | } |
| 474 | static int conf_set_newbiefile_necromancer(const char* valstr) |
| 475 | { |
| 476 | return conf_set_str(&prefs_conf.newbiefile_necromancer, valstr, NULL); |
| 477 | } |
| 478 | static int conf_setdef_newbiefile_necromancer(void) |
| 479 | { |
| 480 | return conf_set_str(&prefs_conf.newbiefile_necromancer, NULL, D2CS_CHARSAVE_NEWBIE); |
| 481 | } |
| 482 | |
| 483 | extern char const * prefs_get_charsave_newbie_paladin(void) |
| 484 | { |
| 485 | return prefs_conf.newbiefile_paladin; |
| 486 | } |
| 487 | static int conf_set_newbiefile_paladin(const char* valstr) |
| 488 | { |
| 489 | return conf_set_str(&prefs_conf.newbiefile_paladin, valstr, NULL); |
| 490 | } |
| 491 | static int conf_setdef_newbiefile_paladin(void) |
| 492 | { |
| 493 | return conf_set_str(&prefs_conf.newbiefile_paladin, NULL, D2CS_CHARSAVE_NEWBIE); |
| 494 | } |
| 495 | |
| 496 | extern char const * prefs_get_charsave_newbie_barbarian(void) |
| 497 | { |
| 498 | return prefs_conf.newbiefile_barbarian; |
| 499 | } |
| 500 | static int conf_set_newbiefile_barbarian(const char* valstr) |
| 501 | { |
| 502 | return conf_set_str(&prefs_conf.newbiefile_barbarian, valstr, NULL); |
| 503 | } |
| 504 | static int conf_setdef_newbiefile_barbarian(void) |
| 505 | { |
| 506 | return conf_set_str(&prefs_conf.newbiefile_barbarian, NULL, D2CS_CHARSAVE_NEWBIE); |
| 507 | } |
| 508 | |
| 509 | extern char const * prefs_get_charsave_newbie_druid(void) |
| 510 | { |
| 511 | return prefs_conf.newbiefile_druid; |
| 512 | } |
| 513 | static int conf_set_newbiefile_druid(const char* valstr) |
| 514 | { |
| 515 | return conf_set_str(&prefs_conf.newbiefile_druid, valstr, NULL); |
| 516 | } |
| 517 | static int conf_setdef_newbiefile_druid(void) |
| 518 | { |
| 519 | return conf_set_str(&prefs_conf.newbiefile_druid, NULL, D2CS_CHARSAVE_NEWBIE); |
| 520 | } |
| 521 | |
| 522 | extern char const * prefs_get_charsave_newbie_assasin(void) |
| 523 | { |
| 524 | return prefs_conf.newbiefile_assasin; |
| 525 | } |
| 526 | static int conf_set_newbiefile_assasin(const char* valstr) |
| 527 | { |
| 528 | return conf_set_str(&prefs_conf.newbiefile_assasin, valstr, NULL); |
| 529 | } |
| 530 | static int conf_setdef_newbiefile_assasin(void) |
| 531 | { |
| 532 | return conf_set_str(&prefs_conf.newbiefile_assasin, NULL, D2CS_CHARSAVE_NEWBIE); |
| 533 | } |
| 534 | |
| 535 | |
| 536 | |
| 537 | extern char const * prefs_get_motd(void) |
| 538 | { |
| 539 | return prefs_conf.motd; |
| 540 | } |
| 541 | |
| 542 | static int conf_set_motd(const char* valstr) |
| 543 | { |
| 544 | return conf_set_str(&prefs_conf.motd,valstr,NULL); |
| 545 | } |
| 546 | |
| 547 | static int conf_setdef_motd(void) |
| 548 | { |
| 549 | return conf_set_str(&prefs_conf.motd,NULL,D2CS_MOTD); |
| 550 | } |
| 551 | |
| 552 | |
| 553 | extern char const * prefs_get_d2gs_list(void) |
| 554 | { |
| 555 | return prefs_conf.gameservlist; |
| 556 | } |
| 557 | |
| 558 | static int conf_set_gameservlist(const char* valstr) |
| 559 | { |
| 560 | return conf_set_str(&prefs_conf.gameservlist,valstr,NULL); |
| 561 | } |
| 562 | |
| 563 | static int conf_setdef_gameservlist(void) |
| 564 | { |
| 565 | return conf_set_str(&prefs_conf.gameservlist,NULL,D2GS_SERVER_LIST); |
| 566 | } |
| 567 | |
| 568 | |
| 569 | extern unsigned int prefs_get_maxchar(void) |
| 570 | { |
| 571 | return (prefs_conf.maxchar>MAX_MAX_CHAR_PER_ACCT)?MAX_MAX_CHAR_PER_ACCT:prefs_conf.maxchar; |
| 572 | } |
| 573 | |
| 574 | static int conf_set_maxchar(const char* valstr) |
| 575 | { |
| 576 | return conf_set_int(&prefs_conf.maxchar,valstr,0); |
| 577 | } |
| 578 | |
| 579 | |
| 580 | static int conf_setdef_maxchar(void) |
| 581 | { |
| 582 | return conf_set_int(&prefs_conf.maxchar,NULL,MAX_CHAR_PER_ACCT); |
| 583 | } |
| 584 | |
| 585 | |
| 586 | extern unsigned int prefs_get_list_purgeinterval(void) |
| 587 | { |
| 588 | return prefs_conf.listpurgeinterval; |
| 589 | } |
| 590 | |
| 591 | static int conf_set_listpurgeinterval(const char* valstr) |
| 592 | { |
| 593 | return conf_set_int(&prefs_conf.listpurgeinterval,valstr,0); |
| 594 | } |
| 595 | |
| 596 | static int conf_setdef_listpurgeinterval(void) |
| 597 | { |
| 598 | return conf_set_int(&prefs_conf.listpurgeinterval,NULL,LIST_PURGE_INTERVAL); |
| 599 | } |
| 600 | |
| 601 | |
| 602 | extern unsigned int prefs_get_gamequeue_checkinterval(void) |
| 603 | { |
| 604 | return prefs_conf.gqcheckinterval; |
| 605 | } |
| 606 | |
| 607 | static int conf_set_gqcheckinterval(const char* valstr) |
| 608 | { |
| 609 | return conf_set_int(&prefs_conf.gqcheckinterval,valstr,0); |
| 610 | } |
| 611 | |
| 612 | static int conf_setdef_gqcheckinterval(void) |
| 613 | { |
| 614 | return conf_set_int(&prefs_conf.gqcheckinterval,NULL,GAMEQUEUE_CHECK_INTERVAL); |
| 615 | } |
| 616 | |
| 617 | |
| 618 | extern unsigned int prefs_get_maxgamelist(void) |
| 619 | { |
| 620 | return prefs_conf.maxgamelist; |
| 621 | } |
| 622 | |
| 623 | static int conf_set_maxgamelist(const char* valstr) |
| 624 | { |
| 625 | return conf_set_int(&prefs_conf.maxgamelist,valstr,0); |
| 626 | } |
| 627 | |
| 628 | static int conf_setdef_maxgamelist(void) |
| 629 | { |
| 630 | return conf_set_int(&prefs_conf.maxgamelist,NULL,MAX_GAME_LIST); |
| 631 | } |
| 632 | |
| 633 | |
| 634 | extern unsigned int prefs_allow_newchar(void) |
| 635 | { |
| 636 | return prefs_conf.allow_newchar; |
| 637 | } |
| 638 | |
| 639 | static int conf_set_allow_newchar(const char* valstr) |
| 640 | { |
| 641 | return conf_set_bool(&prefs_conf.allow_newchar,valstr,0); |
| 642 | } |
| 643 | |
| 644 | |
| 645 | static int conf_setdef_allow_newchar(void) |
| 646 | { |
| 647 | return conf_set_bool(&prefs_conf.allow_newchar,NULL,1); |
| 648 | } |
| 649 | |
| 650 | |
| 651 | extern unsigned int prefs_get_idletime(void) |
| 652 | { |
| 653 | return prefs_conf.idletime; |
| 654 | } |
| 655 | |
| 656 | static int conf_set_idletime(const char* valstr) |
| 657 | { |
| 658 | return conf_set_int(&prefs_conf.idletime,valstr,0); |
| 659 | } |
| 660 | |
| 661 | static int conf_setdef_idletime(void) |
| 662 | { |
| 663 | return conf_set_int(&prefs_conf.idletime,NULL,MAX_CLIENT_IDLETIME); |
| 664 | } |
| 665 | |
| 666 | |
| 667 | extern char const * d2cs_prefs_get_logfile(void) |
| 668 | { |
| 669 | return prefs_conf.logfile; |
| 670 | } |
| 671 | |
| 672 | static int conf_set_logfile(const char* valstr) |
| 673 | { |
| 674 | return conf_set_str(&prefs_conf.logfile,valstr,NULL); |
| 675 | } |
| 676 | |
| 677 | static int conf_setdef_logfile(void) |
| 678 | { |
| 679 | return conf_set_str(&prefs_conf.logfile,NULL,DEFAULT_LOG_FILE); |
| 680 | } |
| 681 | |
| 682 | |
| 683 | extern unsigned int d2cs_prefs_get_shutdown_delay(void) |
| 684 | { |
| 685 | return prefs_conf.shutdown_delay; |
| 686 | } |
| 687 | |
| 688 | static int conf_set_shutdown_delay(const char* valstr) |
| 689 | { |
| 690 | return conf_set_int(&prefs_conf.shutdown_delay,valstr,0); |
| 691 | } |
| 692 | |
| 693 | static int conf_setdef_shutdown_delay(void) |
| 694 | { |
| 695 | return conf_set_int(&prefs_conf.shutdown_delay,NULL,DEFAULT_SHUTDOWN_DELAY); |
| 696 | } |
| 697 | |
| 698 | |
| 699 | extern unsigned int d2cs_prefs_get_shutdown_decr(void) |
| 700 | { |
| 701 | return prefs_conf.shutdown_decr; |
| 702 | } |
| 703 | |
| 704 | static int conf_set_shutdown_decr(const char* valstr) |
| 705 | { |
| 706 | return conf_set_int(&prefs_conf.shutdown_decr,valstr,0); |
| 707 | } |
| 708 | |
| 709 | static int conf_setdef_shutdown_decr(void) |
| 710 | { |
| 711 | return conf_set_int(&prefs_conf.shutdown_decr,NULL,DEFAULT_SHUTDOWN_DECR); |
| 712 | } |
| 713 | |
| 714 | |
| 715 | extern char const * prefs_get_bnetdaddr(void) |
| 716 | { |
| 717 | return prefs_conf.bnetdaddr; |
| 718 | } |
| 719 | |
| 720 | static int conf_set_bnetdaddr(const char* valstr) |
| 721 | { |
| 722 | return conf_set_str(&prefs_conf.bnetdaddr,valstr,NULL); |
| 723 | } |
| 724 | |
| 725 | static int conf_setdef_bnetaddr(void) |
| 726 | { |
| 727 | return conf_set_str(&prefs_conf.bnetdaddr,NULL,BNETD_SERVER_LIST); |
| 728 | } |
| 729 | |
| 730 | |
| 731 | extern char const * prefs_get_realmname(void) |
| 732 | { |
| 733 | return prefs_conf.realmname; |
| 734 | } |
| 735 | |
| 736 | static int conf_set_realmname(const char* valstr) |
| 737 | { |
| 738 | return conf_set_str(&prefs_conf.realmname,valstr,NULL); |
| 739 | } |
| 740 | |
| 741 | static int conf_setdef_realmname(void) |
| 742 | { |
| 743 | return conf_set_str(&prefs_conf.realmname,NULL,DEFAULT_REALM_NAME); |
| 744 | } |
| 745 | |
| 746 | |
| 747 | extern unsigned int prefs_get_s2s_retryinterval(void) |
| 748 | { |
| 749 | return prefs_conf.s2s_retryinterval; |
| 750 | } |
| 751 | |
| 752 | static int conf_set_s2s_retryinterval(const char* valstr) |
| 753 | { |
| 754 | return conf_set_int(&prefs_conf.s2s_retryinterval,valstr,0); |
| 755 | } |
| 756 | |
| 757 | static int conf_setdef_s2s_retryinterval(void) |
| 758 | { |
| 759 | return conf_set_int(&prefs_conf.s2s_retryinterval,NULL,DEFAULT_S2S_RETRYINTERVAL); |
| 760 | } |
| 761 | |
| 762 | |
| 763 | extern unsigned int prefs_get_s2s_timeout(void) |
| 764 | { |
| 765 | return prefs_conf.s2s_timeout; |
| 766 | } |
| 767 | |
| 768 | static int conf_set_s2s_timeout(const char* valstr) |
| 769 | { |
| 770 | return conf_set_int(&prefs_conf.s2s_timeout,valstr,0); |
| 771 | } |
| 772 | |
| 773 | static int conf_setdef_s2s_timeout(void) |
| 774 | { |
| 775 | return conf_set_int(&prefs_conf.s2s_timeout,NULL,DEFAULT_S2S_TIMEOUT); |
| 776 | } |
| 777 | |
| 778 | |
| 779 | extern unsigned int prefs_get_sq_timeout(void) |
| 780 | { |
| 781 | return prefs_conf.sq_timeout; |
| 782 | } |
| 783 | |
| 784 | static int conf_set_sq_timeout(const char* valstr) |
| 785 | { |
| 786 | return conf_set_int(&prefs_conf.sq_timeout,valstr,0); |
| 787 | } |
| 788 | |
| 789 | static int conf_setdef_sq_timeout(void) |
| 790 | { |
| 791 | return conf_set_int(&prefs_conf.sq_timeout,NULL,DEFAULT_SQ_TIMEOUT); |
| 792 | } |
| 793 | |
| 794 | |
| 795 | extern unsigned int prefs_get_sq_checkinterval(void) |
| 796 | { |
| 797 | return prefs_conf.sq_checkinterval; |
| 798 | } |
| 799 | |
| 800 | static int conf_set_sq_checkinterval(const char* valstr) |
| 801 | { |
| 802 | return conf_set_int(&prefs_conf.sq_checkinterval,valstr,0); |
| 803 | } |
| 804 | |
| 805 | static int conf_setdef_sq_checkinterval(void) |
| 806 | { |
| 807 | return conf_set_int(&prefs_conf.sq_checkinterval,NULL,DEFAULT_SQ_CHECKINTERVAL); |
| 808 | } |
| 809 | |
| 810 | |
| 811 | extern unsigned int prefs_get_d2gs_checksum(void) |
| 812 | { |
| 813 | return prefs_conf.d2gs_checksum; |
| 814 | } |
| 815 | |
| 816 | static int conf_set_d2gs_checksum(const char* valstr) |
| 817 | { |
| 818 | return conf_set_int(&prefs_conf.d2gs_checksum,valstr,0); |
| 819 | } |
| 820 | |
| 821 | static int conf_setdef_d2gs_checksum(void) |
| 822 | { |
| 823 | return conf_set_int(&prefs_conf.d2gs_checksum,NULL,0); |
| 824 | } |
| 825 | |
| 826 | |
| 827 | extern unsigned int prefs_get_d2gs_version(void) |
| 828 | { |
| 829 | return prefs_conf.d2gs_version; |
| 830 | } |
| 831 | |
| 832 | static int conf_set_d2gs_version(const char* valstr) |
| 833 | { |
| 834 | return conf_set_int(&prefs_conf.d2gs_version,valstr,0); |
| 835 | } |
| 836 | |
| 837 | static int conf_setdef_d2gs_version(void) |
| 838 | { |
| 839 | return conf_set_int(&prefs_conf.d2gs_version,NULL,0); |
| 840 | } |
| 841 | |
| 842 | |
| 843 | extern unsigned int prefs_get_ladderlist_count(void) |
| 844 | { |
| 845 | return 0x10; |
| 846 | } |
| 847 | |
| 848 | extern unsigned int prefs_get_d2ladder_refresh_interval(void) |
| 849 | { |
| 850 | return prefs_conf.ladder_refresh_interval; |
| 851 | } |
| 852 | |
| 853 | static int conf_set_ladder_refresh_interval(const char* valstr) |
| 854 | { |
| 855 | return conf_set_int(&prefs_conf.ladder_refresh_interval,valstr,0); |
| 856 | } |
| 857 | |
| 858 | static int conf_setdef_ladder_refresh_interval(void) |
| 859 | { |
| 860 | return conf_set_int(&prefs_conf.ladder_refresh_interval,NULL,3600); |
| 861 | } |
| 862 | |
| 863 | |
| 864 | extern unsigned int prefs_get_game_maxlifetime(void) |
| 865 | { |
| 866 | return prefs_conf.game_maxlifetime; |
| 867 | } |
| 868 | |
| 869 | static int conf_set_game_maxlifetime(const char* valstr) |
| 870 | { |
| 871 | return conf_set_int(&prefs_conf.game_maxlifetime,valstr,0); |
| 872 | } |
| 873 | |
| 874 | static int conf_setdef_game_maxlifetime(void) |
| 875 | { |
| 876 | return conf_set_int(&prefs_conf.game_maxlifetime,NULL,0); |
| 877 | } |
| 878 | |
| 879 | |
| 880 | extern unsigned int prefs_get_game_maxlevel(void) |
| 881 | { |
| 882 | return prefs_conf.game_maxlevel; |
| 883 | } |
| 884 | |
| 885 | static int conf_set_game_maxlevel(const char* valstr) |
| 886 | { |
| 887 | return conf_set_int(&prefs_conf.game_maxlevel,valstr,0); |
| 888 | } |
| 889 | |
| 890 | static int conf_setdef_game_maxlevel(void) |
| 891 | { |
| 892 | return conf_set_int(&prefs_conf.game_maxlevel,NULL,0xff); |
| 893 | } |
| 894 | |
| 895 | |
| 896 | extern char const * prefs_get_ladder_dir(void) |
| 897 | { |
| 898 | return prefs_conf.ladderdir; |
| 899 | } |
| 900 | |
| 901 | static int conf_set_ladderdir(const char* valstr) |
| 902 | { |
| 903 | return conf_set_str(&prefs_conf.ladderdir,valstr,NULL); |
| 904 | } |
| 905 | |
| 906 | static int conf_setdef_ladderdir(void) |
| 907 | { |
| 908 | return conf_set_str(&prefs_conf.ladderdir,NULL,D2CS_LADDER_DIR); |
| 909 | } |
| 910 | |
| 911 | |
| 912 | extern char const * d2cs_prefs_get_loglevels(void) |
| 913 | { |
| 914 | return prefs_conf.loglevels; |
| 915 | } |
| 916 | |
| 917 | static int conf_set_loglevels(const char* valstr) |
| 918 | { |
| 919 | return conf_set_str(&prefs_conf.loglevels,valstr,NULL); |
| 920 | } |
| 921 | |
| 922 | static int conf_setdef_loglevels(void) |
| 923 | { |
| 924 | return conf_set_str(&prefs_conf.loglevels,NULL,DEFAULT_LOG_LEVELS); |
| 925 | } |
| 926 | |
| 927 | |
| 928 | extern unsigned int prefs_allow_gamelist_showall(void) |
| 929 | { |
| 930 | return prefs_conf.gamelist_showall; |
| 931 | } |
| 932 | |
| 933 | static int conf_set_gamelist_showall(const char* valstr) |
| 934 | { |
| 935 | return conf_set_bool(&prefs_conf.gamelist_showall,valstr,0); |
| 936 | } |
| 937 | |
| 938 | static int conf_setdef_gamelist_showall(void) |
| 939 | { |
| 940 | return conf_set_bool(&prefs_conf.gamelist_showall,NULL,0); |
| 941 | } |
| 942 | |
| 943 | |
| 944 | extern unsigned int prefs_hide_pass_games(void) |
| 945 | { |
| 946 | return prefs_conf.hide_pass_games; |
| 947 | } |
| 948 | |
| 949 | static int conf_set_hide_pass_games(const char* valstr) |
| 950 | { |
| 951 | return conf_set_bool(&prefs_conf.hide_pass_games,valstr,0); |
| 952 | } |
| 953 | |
| 954 | static int conf_setdef_hide_pass_games(void) |
| 955 | { |
| 956 | return conf_set_bool(&prefs_conf.hide_pass_games,NULL,0); |
| 957 | } |
| 958 | |
| 959 | |
| 960 | extern unsigned int prefs_allow_gamelimit(void) |
| 961 | { |
| 962 | return prefs_conf.allow_gamelimit; |
| 963 | } |
| 964 | |
| 965 | static int conf_set_allow_gamelimit(const char* valstr) |
| 966 | { |
| 967 | return conf_set_bool(&prefs_conf.allow_gamelimit,valstr,0); |
| 968 | } |
| 969 | |
| 970 | static int conf_setdef_allow_gamelimit(void) |
| 971 | { |
| 972 | return conf_set_bool(&prefs_conf.allow_gamelimit,NULL,1); |
| 973 | } |
| 974 | |
| 975 | |
| 976 | extern unsigned int prefs_check_multilogin(void) |
| 977 | { |
| 978 | return prefs_conf.check_multilogin; |
| 979 | } |
| 980 | |
| 981 | static int conf_set_check_multilogin(const char* valstr) |
| 982 | { |
| 983 | return conf_set_bool(&prefs_conf.check_multilogin,valstr,0); |
| 984 | } |
| 985 | |
| 986 | static int conf_setdef_check_multilogin(void) |
| 987 | { |
| 988 | return conf_set_bool(&prefs_conf.check_multilogin,NULL,1); |
| 989 | } |
| 990 | |
| 991 | |
| 992 | extern char const * prefs_get_d2gs_password(void) |
| 993 | { |
| 994 | return prefs_conf.d2gs_password; |
| 995 | } |
| 996 | |
| 997 | static int conf_set_d2gs_password(const char* valstr) |
| 998 | { |
| 999 | return conf_set_str(&prefs_conf.d2gs_password,valstr,NULL); |
| 1000 | } |
| 1001 | |
| 1002 | static int conf_setdef_d2gs_password(void) |
| 1003 | { |
| 1004 | return conf_set_str(&prefs_conf.d2gs_password,NULL,""); |
| 1005 | } |
| 1006 | |
| 1007 | |
| 1008 | extern unsigned int prefs_get_s2s_idletime(void) |
| 1009 | { |
| 1010 | return prefs_conf.s2s_idletime; |
| 1011 | } |
| 1012 | |
| 1013 | static int conf_set_s2s_idletime(const char* valstr) |
| 1014 | { |
| 1015 | return conf_set_int(&prefs_conf.s2s_idletime,valstr,0); |
| 1016 | } |
| 1017 | |
| 1018 | static int conf_setdef_s2s_idletime(void) |
| 1019 | { |
| 1020 | return conf_set_int(&prefs_conf.s2s_idletime,NULL,DEFAULT_S2S_IDLETIME); |
| 1021 | } |
| 1022 | |
| 1023 | |
| 1024 | extern unsigned int prefs_get_s2s_keepalive_interval(void) |
| 1025 | { |
| 1026 | return prefs_conf.s2s_keepalive_interval; |
| 1027 | } |
| 1028 | |
| 1029 | static int conf_set_s2s_keepalive_interval(const char* valstr) |
| 1030 | { |
| 1031 | return conf_set_int(&prefs_conf.s2s_keepalive_interval,valstr,0); |
| 1032 | } |
| 1033 | |
| 1034 | static int conf_setdef_s2s_keepalive_interval(void) |
| 1035 | { |
| 1036 | return conf_set_int(&prefs_conf.s2s_keepalive_interval,NULL,DEFAULT_S2S_KEEPALIVE_INTERVAL); |
| 1037 | } |
| 1038 | |
| 1039 | |
| 1040 | extern unsigned int prefs_get_timeout_checkinterval(void) |
| 1041 | { |
| 1042 | return prefs_conf.timeout_checkinterval; |
| 1043 | } |
| 1044 | |
| 1045 | static int conf_set_timeout_checkinterval(const char* valstr) |
| 1046 | { |
| 1047 | return conf_set_int(&prefs_conf.timeout_checkinterval,valstr,0); |
| 1048 | } |
| 1049 | |
| 1050 | static int conf_setdef_timeout_checkinterval(void) |
| 1051 | { |
| 1052 | return conf_set_int(&prefs_conf.timeout_checkinterval,NULL,DEFAULT_TIMEOUT_CHECKINTERVAL); |
| 1053 | } |
| 1054 | |
| 1055 | |
| 1056 | extern unsigned int prefs_get_max_game_idletime(void) |
| 1057 | { |
| 1058 | return prefs_conf.max_game_idletime; |
| 1059 | } |
| 1060 | |
| 1061 | static int conf_set_max_game_idletime(const char* valstr) |
| 1062 | { |
| 1063 | return conf_set_int(&prefs_conf.max_game_idletime,valstr,0); |
| 1064 | } |
| 1065 | |
| 1066 | static int conf_setdef_max_game_idletime(void) |
| 1067 | { |
| 1068 | return conf_set_int(&prefs_conf.max_game_idletime,NULL,MAX_GAME_IDLE_TIME); |
| 1069 | } |
| 1070 | |
| 1071 | |
| 1072 | extern unsigned int prefs_get_lod_realm(void) |
| 1073 | { |
| 1074 | return prefs_conf.lod_realm; |
| 1075 | } |
| 1076 | |
| 1077 | static int conf_set_lod_realm(const char* valstr) |
| 1078 | { |
| 1079 | return conf_set_int(&prefs_conf.lod_realm,valstr,0); |
| 1080 | } |
| 1081 | |
| 1082 | static int conf_setdef_lod_realm(void) |
| 1083 | { |
| 1084 | return conf_set_int(&prefs_conf.lod_realm,NULL,2); |
| 1085 | } |
| 1086 | |
| 1087 | |
| 1088 | extern unsigned int prefs_get_allow_convert(void) |
| 1089 | { |
| 1090 | return prefs_conf.allow_convert; |
| 1091 | } |
| 1092 | |
| 1093 | static int conf_set_allow_convert(const char* valstr) |
| 1094 | { |
| 1095 | return conf_set_bool(&prefs_conf.allow_convert,valstr,0); |
| 1096 | } |
| 1097 | |
| 1098 | static int conf_setdef_allow_convert(void) |
| 1099 | { |
| 1100 | return conf_set_bool(&prefs_conf.allow_convert,NULL,0); |
| 1101 | } |
| 1102 | |
| 1103 | |
| 1104 | extern char const * d2cs_prefs_get_transfile(void) |
| 1105 | { |
| 1106 | return prefs_conf.transfile; |
| 1107 | } |
| 1108 | |
| 1109 | static int conf_set_transfile(const char* valstr) |
| 1110 | { |
| 1111 | return conf_set_str(&prefs_conf.transfile,valstr,NULL); |
| 1112 | } |
| 1113 | |
| 1114 | static int conf_setdef_transfile(void) |
| 1115 | { |
| 1116 | return conf_set_str(&prefs_conf.transfile,NULL,D2CS_TRANS_FILE); |
| 1117 | } |
| 1118 | |
| 1119 | |
| 1120 | extern char const * prefs_get_d2cs_account_allowed_symbols(void) |
| 1121 | { |
| 1122 | return prefs_conf.account_allowed_symbols; |
| 1123 | } |
| 1124 | |
| 1125 | static int conf_set_account_allowed_symbols(const char* valstr) |
| 1126 | { |
| 1127 | return conf_set_str(&prefs_conf.account_allowed_symbols,valstr,NULL); |
| 1128 | } |
| 1129 | |
| 1130 | static int conf_setdef_account_allowed_symbols(void) |
| 1131 | { |
| 1132 | return conf_set_str(&prefs_conf.account_allowed_symbols,NULL,DEFAULT_ACC_ALLOWED_SYMBOLS); |
| 1133 | } |
| 1134 | |
| 1135 | |
| 1136 | extern std::time_t prefs_get_ladder_start_time() |
| 1137 | { |
| 1138 | return prefs_conf.ladder_start_time; |
| 1139 | } |
| 1140 | |
| 1141 | static int conf_set_ladder_start_time(const char* valstr) |
| 1142 | { |
| 1143 | return conf_set_timestr(&prefs_conf.ladder_start_time,valstr,0); |
| 1144 | } |
| 1145 | |
| 1146 | static int conf_setdef_ladder_start_time(void) |
| 1147 | { |
| 1148 | return conf_set_timestr(&prefs_conf.ladder_start_time,NULL,0); |
| 1149 | } |
| 1150 | |
| 1151 | |
| 1152 | extern unsigned int prefs_get_d2gs_restart_delay(void) |
| 1153 | { |
| 1154 | return prefs_conf.d2gs_restart_delay; |
| 1155 | } |
| 1156 | |
| 1157 | static int conf_set_d2gs_restart_delay(const char* valstr) |
| 1158 | { |
| 1159 | return conf_set_int(&prefs_conf.d2gs_restart_delay,valstr,0); |
| 1160 | } |
| 1161 | |
| 1162 | static int conf_setdef_d2gs_restart_delay(void) |
| 1163 | { |
| 1164 | return conf_set_int(&prefs_conf.d2gs_restart_delay,NULL,DEFAULT_D2GS_RESTART_DELAY); |
| 1165 | } |
| 1166 | |
| 1167 | |
| 1168 | extern unsigned int prefs_get_char_expire_time(void) |
| 1169 | { |
| 1170 | return prefs_conf.char_expire_day * 3600 * 24; |
| 1171 | } |
| 1172 | |
| 1173 | static int conf_set_char_expire_day(const char* valstr) |
| 1174 | { |
| 1175 | return conf_set_int(&prefs_conf.char_expire_day,valstr,0); |
| 1176 | } |
| 1177 | |
| 1178 | static int conf_setdef_char_expire_day(void) |
| 1179 | { |
| 1180 | return conf_set_int(&prefs_conf.char_expire_day,NULL,0); |
| 1181 | } |
| 1182 | |
| 1183 | |
| 1184 | extern char const * prefs_get_d2gsconffile(void) |
| 1185 | { |
| 1186 | return prefs_conf.d2gsconffile; |
| 1187 | } |
| 1188 | |
| 1189 | static int conf_set_d2gsconffile(const char* valstr) |
| 1190 | { |
| 1191 | return conf_set_str(&prefs_conf.d2gsconffile,valstr,NULL); |
| 1192 | } |
| 1193 | |
| 1194 | static int conf_setdef_d2gsconffile(void) |
| 1195 | { |
| 1196 | return conf_set_str(&prefs_conf.d2gsconffile,NULL,""); |
| 1197 | } |
| 1198 | |
| 1199 | |
| 1200 | extern char const * prefs_get_charlist_sort(void) |
| 1201 | { |
| 1202 | return prefs_conf.charlist_sort; |
| 1203 | } |
| 1204 | |
| 1205 | static int conf_set_charlist_sort(const char* valstr) |
| 1206 | { |
| 1207 | return conf_set_str(&prefs_conf.charlist_sort,valstr,NULL); |
| 1208 | } |
| 1209 | |
| 1210 | static int conf_setdef_charlist_sort(void) |
| 1211 | { |
| 1212 | return conf_set_str(&prefs_conf.charlist_sort,NULL,"none"); |
| 1213 | } |
| 1214 | |
| 1215 | |
| 1216 | extern char const * prefs_get_charlist_sort_order(void) |
| 1217 | { |
| 1218 | return prefs_conf.charlist_sort_order; |
| 1219 | } |
| 1220 | |
| 1221 | static int conf_set_charlist_sort_order(const char* valstr) |
| 1222 | { |
| 1223 | return conf_set_str(&prefs_conf.charlist_sort_order,valstr,NULL); |
| 1224 | } |
| 1225 | |
| 1226 | static int conf_setdef_charlist_sort_order(void) |
| 1227 | { |
| 1228 | return conf_set_str(&prefs_conf.charlist_sort_order,NULL,"ASC"); |
| 1229 | } |
| 1230 | |
| 1231 | |
| 1232 | extern unsigned int prefs_get_max_connections(void) |
| 1233 | { |
| 1234 | return prefs_conf.max_connections; |
| 1235 | } |
| 1236 | |
| 1237 | static int conf_set_max_connections(const char* valstr) |
| 1238 | { |
| 1239 | return conf_set_int(&prefs_conf.max_connections,valstr,0); |
| 1240 | } |
| 1241 | |
| 1242 | static int conf_setdef_max_connections(void) |
| 1243 | { |
| 1244 | return conf_set_int(&prefs_conf.max_connections,NULL,BNETD_MAX_SOCKETS); |
| 1245 | } |
| 1246 | |
| 1247 | |
| 1248 | extern char const * prefs_get_pidfile(void) |
| 1249 | { |
| 1250 | return prefs_conf.pidfile; |
| 1251 | } |
| 1252 | |
| 1253 | static int conf_set_pidfile(const char* valstr) |
| 1254 | { |
| 1255 | return conf_set_str(&prefs_conf.pidfile,valstr,NULL); |
| 1256 | } |
| 1257 | |
| 1258 | static int conf_setdef_pidfile(void) |
| 1259 | { |
| 1260 | return conf_set_str(&prefs_conf.pidfile,NULL,""); |
| 1261 | } |
| 1262 | |
| 1263 | } |
| 1264 | |
| 1265 | } |