OpenFusion/src/settings.cpp

82 lines
3.4 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";
time_t settings::TIMEOUT = 60000;
int settings::VIEWDISTANCE = 25600;
bool settings::SIMULATEMOBS = true;
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-09-17 02:27:21 +00:00
std::string settings::PATHJSON = "tdata/paths.json";
std::string settings::DROPSJSON = "tdata/drops.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!";
int settings::ACCLEVEL = 1;
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);
SHARDSERVERIP = reader.Get("shard", "ip", "127.0.0.1");
Database saving update (#104) * implemented saving BatteryN and BatteryW * implemented saving mentor * moved int64->blob parsing to a separate function * moved parsing blob->int64 to a separate function * added functions for parsing int32->blob and vice versa * added functions for parsing int16->blob and vice versa * WIP saving quest items and active tasks * Quest items are stored in inventory table instead of blob * added sanity check for missionId * saving active missions works * removed unneccesary include * implemented saving warplocationflag, skywaylocationflag and currentmissionid in database * INFO DB message now shows how many accounts and player characters are in the database * fixed dbsaveinterval being in [login] instead of [shard] * fixed mission quit: - fixed wrong json name, causing qitems not deleting properly - quitting mission now resets npc kill count * adjusted saving active missions * removed blob parsing functions that ended up being unused * removed accidentaly added include * removed sending PCStyle2 on Player Enter * added a sanity check in itemMoveHandler * removed MapNum from PCLoad, as client doesn't even read it * set BuddyWarpCooldown to 60s on PCLoad * fixed a bug causing EXIT DUPLICATE not working * added creation and last login timestamps to accounts and players * added a sanity check for P_CL2LS_REQ_PC_EXIT_DUPLICATE * implemented web api support, toggled by new setting (off by default) * add usewebapi to config Co-authored-by: Gent <gentsemaj@live.com>
2020-09-21 19:43:53 +00:00
DBSAVEINTERVAL = reader.GetInteger("shard", "dbsaveinterval", DBSAVEINTERVAL);
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);
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);
ACCLEVEL = reader.GetInteger("shard", "accountlevel", ACCLEVEL);
EVENTMODE = reader.GetInteger("shard", "eventmode", EVENTMODE);
EVENTCRATECHANCE = reader.GetInteger("shard", "eventcratechance", EVENTCRATECHANCE);
MONITORENABLED = reader.GetBoolean("monitor", "enabled", MONITORENABLED);
2020-12-02 22:42:33 +00:00
MONITORPORT = reader.GetInteger("monitor", "port", MONITORPORT);
MONITORINTERVAL = reader.GetInteger("monitor", "interval", MONITORINTERVAL);
}