2020-08-18 20:42:30 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include "settings.hpp"
|
2020-08-22 02:03:12 +00:00
|
|
|
#include "contrib/INIReader.hpp"
|
2020-08-18 20:42:30 +00:00
|
|
|
|
|
|
|
// defaults :)
|
2020-08-23 21:09:31 +00:00
|
|
|
int settings::VERBOSITY = 1;
|
2020-08-22 17:39:13 +00:00
|
|
|
|
2020-08-18 20:42:30 +00:00
|
|
|
int settings::LOGINPORT = 8001;
|
2020-09-01 22:37:09 +00:00
|
|
|
bool settings::APPROVEALLNAMES = true;
|
2020-09-08 22:23:45 +00:00
|
|
|
int settings::DBSAVEINTERVAL = 240;
|
2020-08-18 20:42:30 +00:00
|
|
|
|
|
|
|
int settings::SHARDPORT = 8002;
|
|
|
|
std::string settings::SHARDSERVERIP = "127.0.0.1";
|
2020-09-16 15:45:53 +00:00
|
|
|
time_t settings::TIMEOUT = 60000;
|
2020-08-26 02:53:27 +00:00
|
|
|
int settings::PLAYERDISTANCE = 20000;
|
|
|
|
int settings::NPCDISTANCE = 16000;
|
2020-08-18 20:42:30 +00:00
|
|
|
|
2020-09-08 20:41:02 +00:00
|
|
|
// default spawn point is Sector V (future)
|
|
|
|
int settings::SPAWN_X = 632032;
|
|
|
|
int settings::SPAWN_Y = 187177;
|
|
|
|
int settings::SPAWN_Z = -5500;
|
|
|
|
int settings::SPAWN_ANGLE = 130;
|
2020-09-14 13:20:55 +00:00
|
|
|
std::string settings::NPCJSON = "tdata/NPCs.json";
|
|
|
|
std::string settings::XDTJSON = "tdata/xdt.json";
|
|
|
|
std::string settings::MOBJSON = "tdata/mobs.json";
|
2020-08-20 15:43:37 +00:00
|
|
|
std::string settings::MOTDSTRING = "Welcome to OpenFusion!";
|
2020-09-20 18:50:58 +00:00
|
|
|
bool settings::GM = true;
|
2020-08-18 20:42:30 +00:00
|
|
|
|
|
|
|
void settings::init() {
|
|
|
|
INIReader reader("config.ini");
|
|
|
|
|
|
|
|
if (reader.ParseError() != 0) {
|
|
|
|
if (reader.ParseError() == -1)
|
|
|
|
std::cerr << "[WARN] Settings: missing config.ini file!" << std::endl;
|
2020-09-14 13:53:48 +00:00
|
|
|
else
|
2020-08-18 20:42:30 +00:00
|
|
|
std::cerr << "[WARN] Settings: invalid config.ini syntax at line " << reader.ParseError() << std::endl;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-02 15:47:10 +00:00
|
|
|
APPROVEALLNAMES = reader.GetBoolean("", "acceptallcustomnames", APPROVEALLNAMES);
|
2020-09-14 13:53:48 +00:00
|
|
|
VERBOSITY = reader.GetInteger("", "verbosity", VERBOSITY);
|
2020-08-18 20:42:30 +00:00
|
|
|
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
|
|
|
|
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
|
|
|
|
SHARDSERVERIP = reader.Get("shard", "ip", "127.0.0.1");
|
2020-09-21 19:43:53 +00:00
|
|
|
DBSAVEINTERVAL = reader.GetInteger("shard", "dbsaveinterval", DBSAVEINTERVAL);
|
2020-09-16 15:45:53 +00:00
|
|
|
TIMEOUT = reader.GetInteger("shard", "timeout", TIMEOUT);
|
2020-08-26 02:53:27 +00:00
|
|
|
PLAYERDISTANCE = reader.GetInteger("shard", "playerdistance", PLAYERDISTANCE);
|
|
|
|
NPCDISTANCE = reader.GetInteger("shard", "npcdistance", NPCDISTANCE);
|
2020-08-18 20:42:30 +00:00
|
|
|
SPAWN_X = reader.GetInteger("shard", "spawnx", SPAWN_X);
|
|
|
|
SPAWN_Y = reader.GetInteger("shard", "spawny", SPAWN_Y);
|
|
|
|
SPAWN_Z = reader.GetInteger("shard", "spawnz", SPAWN_Z);
|
2020-09-08 20:41:02 +00:00
|
|
|
SPAWN_ANGLE = reader.GetInteger("shard", "spawnangle", SPAWN_ANGLE);
|
2020-08-21 22:14:11 +00:00
|
|
|
NPCJSON = reader.Get("shard", "npcdata", NPCJSON);
|
2020-09-09 17:06:22 +00:00
|
|
|
XDTJSON = reader.Get("shard", "xdtdata", XDTJSON);
|
2020-09-07 17:54:40 +00:00
|
|
|
MOBJSON = reader.Get("shard", "mobdata", MOBJSON);
|
2020-08-21 22:14:11 +00:00
|
|
|
MOTDSTRING = reader.Get("shard", "motd", MOTDSTRING);
|
2020-08-25 02:28:42 +00:00
|
|
|
GM = reader.GetBoolean("shard", "gm", GM);
|
2020-08-19 17:22:54 +00:00
|
|
|
}
|