OpenFusion/src/settings.cpp

58 lines
2.2 KiB
C++
Raw Normal View History

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;
bool settings::APPROVEALLNAMES = true;
int settings::DBSAVEINTERVAL = 240;
2020-08-18 20:42:30 +00:00
int settings::SHARDPORT = 8002;
std::string settings::SHARDSERVERIP = "127.0.0.1";
int settings::PLAYERDISTANCE = 20000;
int settings::NPCDISTANCE = 16000;
2020-08-18 20:42:30 +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;
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!";
bool settings::GM = false;
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;
else
std::cerr << "[WARN] Settings: invalid config.ini syntax at line " << reader.ParseError() << std::endl;
return;
}
APPROVEALLNAMES = reader.GetBoolean("", "acceptallcustomnames", APPROVEALLNAMES);
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");
DBSAVEINTERVAL = reader.GetInteger("login", "dbsaveinterval", DBSAVEINTERVAL);
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);
SPAWN_ANGLE = reader.GetInteger("shard", "spawnangle", SPAWN_ANGLE);
2020-08-21 22:14:11 +00:00
NPCJSON = reader.Get("shard", "npcdata", NPCJSON);
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);
GM = reader.GetBoolean("shard", "gm", GM);
}