OpenFusion/src/settings.cpp

106 lines
4.1 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"
#include "CNStructs.hpp" // for ACADEMY
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
int settings::LOGINPORT = 23000;
bool settings::APPROVEALLNAMES = true;
int settings::DBSAVEINTERVAL = 240;
2020-08-18 20:42:30 +00:00
int settings::SHARDPORT = 23001;
2020-08-18 20:42:30 +00:00
std::string settings::SHARDSERVERIP = "127.0.0.1";
time_t settings::TIMEOUT = 60000;
int settings::VIEWDISTANCE = 25600;
bool settings::SIMULATEMOBS = true;
2020-08-18 20:42:30 +00:00
// default spawn point
#ifndef ACADEMY
// Sector V (The Future)
int settings::SPAWN_X = 632032;
int settings::SPAWN_Y = 187177;
int settings::SPAWN_Z = -5500;
#else
// Null Void (Training Area)
int settings::SPAWN_X = 19835;
int settings::SPAWN_Y = 108682;
int settings::SPAWN_Z = 8450;
#endif
int settings::SPAWN_ANGLE = 130;
std::string settings::NPCJSON = "tdata/NPCs.json";
std::string settings::MOBJSON = "tdata/mobs.json";
2020-10-24 19:48:55 +00:00
std::string settings::EGGSJSON = "tdata/eggs.json";
std::string settings::GRUNTWORKJSON = "tdata/gruntwork.json";
2020-08-20 15:43:37 +00:00
std::string settings::MOTDSTRING = "Welcome to OpenFusion!";
2020-11-28 23:31:00 +00:00
std::string settings::DBPATH = "database.db";
std::string settings::ACADEMYJSON = "tdata/1013/academy.json";
#if PROTOCOL_VERSION == 1013
std::string settings::XDTJSON = "tdata/1013/xdt.json";
std::string settings::DROPSJSON = "tdata/1013/drops.json";
2021-01-05 13:07:41 +00:00
std::string settings::PATHJSON = "tdata/1013/paths.json";
#else
std::string settings::DROPSJSON = "tdata/drops.json";
std::string settings::XDTJSON = "tdata/xdt.json";
2021-01-05 13:07:41 +00:00
std::string settings::PATHJSON = "tdata/paths.json";
#endif
int settings::ACCLEVEL = 1;
bool settings::DISABLEFIRSTUSEFLAG = true;
2020-08-18 20:42:30 +00:00
2020-12-02 22:42:33 +00:00
// monitor settings
bool settings::MONITORENABLED = false;
2020-12-02 22:42:33 +00:00
int settings::MONITORPORT = 8003;
int settings::MONITORINTERVAL = 5000;
// event mode settings
int settings::EVENTMODE = 0;
int settings::EVENTCRATECHANCE = 10;
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
2020-08-18 20:42:30 +00:00
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);
DBSAVEINTERVAL = reader.GetInteger("login", "dbsaveinterval", DBSAVEINTERVAL);
2020-08-18 20:42:30 +00:00
SHARDSERVERIP = reader.Get("shard", "ip", "127.0.0.1");
TIMEOUT = reader.GetInteger("shard", "timeout", TIMEOUT);
VIEWDISTANCE = reader.GetInteger("shard", "viewdistance", VIEWDISTANCE);
SIMULATEMOBS = reader.GetBoolean("shard", "simulatemobs", SIMULATEMOBS);
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);
ACADEMYJSON = reader.Get("shard", "academydata", ACADEMYJSON);
DROPSJSON = reader.Get("shard", "dropdata", DROPSJSON);
2020-10-24 19:48:55 +00:00
EGGSJSON = reader.Get("shard", "eggdata", EGGSJSON);
2020-09-17 02:27:21 +00:00
PATHJSON = reader.Get("shard", "pathdata", PATHJSON);
GRUNTWORKJSON = reader.Get("shard", "gruntwork", GRUNTWORKJSON);
2020-08-21 22:14:11 +00:00
MOTDSTRING = reader.Get("shard", "motd", MOTDSTRING);
2020-11-28 23:31:00 +00:00
DBPATH = reader.Get("shard", "dbpath", DBPATH);
ACCLEVEL = reader.GetInteger("shard", "accountlevel", ACCLEVEL);
EVENTMODE = reader.GetInteger("shard", "eventmode", EVENTMODE);
EVENTCRATECHANCE = reader.GetInteger("shard", "eventcratechance", EVENTCRATECHANCE);
DISABLEFIRSTUSEFLAG = reader.GetBoolean("shard", "disablefirstuseflag", DISABLEFIRSTUSEFLAG);
MONITORENABLED = reader.GetBoolean("monitor", "enabled", MONITORENABLED);
2020-12-02 22:42:33 +00:00
MONITORPORT = reader.GetInteger("monitor", "port", MONITORPORT);
2020-12-07 20:10:19 +00:00
MONITORINTERVAL = reader.GetInteger("monitor", "interval", MONITORINTERVAL);
}