Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyx14 committed Dec 4, 2023
1 parent 67d066a commit 356c995
Show file tree
Hide file tree
Showing 90 changed files with 1,202 additions and 1,231 deletions.
34 changes: 17 additions & 17 deletions src/canary_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int CanaryServer::run() {
try {
loadConfigLua();

logger.info("Server protocol: {}.{}{}", CLIENT_VERSION_UPPER, CLIENT_VERSION_LOWER, g_configManager().getBoolean(OLD_PROTOCOL) ? " and 10x allowed!" : "");
logger.info("Server protocol: {}.{}{}", CLIENT_VERSION_UPPER, CLIENT_VERSION_LOWER, g_configManager().getBoolean(OLD_PROTOCOL, __FUNCTION__) ? " and 10x allowed!" : "");

rsa.start();
initializeDatabase();
Expand Down Expand Up @@ -89,7 +89,7 @@ int CanaryServer::run() {

g_game().start(&serviceManager);
g_game().setGameState(GAME_STATE_NORMAL);
if (g_configManager().getBoolean(TOGGLE_MAINTAIN_MODE)) {
if (g_configManager().getBoolean(TOGGLE_MAINTAIN_MODE, __FUNCTION__)) {
g_game().setGameState(GAME_STATE_CLOSED);
g_logger().warn("Initialized in maintain mode!");
g_webhook().sendMessage("Server is now online", "The server is now online. Access is currently restricted to administrators only.", WEBHOOK_COLOR_ONLINE);
Expand Down Expand Up @@ -123,7 +123,7 @@ int CanaryServer::run() {
return EXIT_FAILURE;
}

logger.info("{} {}", g_configManager().getString(SERVER_NAME), "server online!");
logger.info("{} {}", g_configManager().getString(SERVER_NAME, __FUNCTION__), "server online!");

serviceManager.run();

Expand All @@ -132,7 +132,7 @@ int CanaryServer::run() {
}

void CanaryServer::setWorldType() {
std::string worldType = asLowerCaseString(g_configManager().getString(WORLD_TYPE));
const std::string worldType = asLowerCaseString(g_configManager().getString(WORLD_TYPE, __FUNCTION__));
if (worldType == "pvp") {
g_game().setWorldType(WORLD_TYPE_PVP);
} else if (worldType == "no-pvp") {
Expand All @@ -143,7 +143,7 @@ void CanaryServer::setWorldType() {
throw FailedToInitializeCanary(
fmt::format(
"Unknown world type: {}, valid world types are: pvp, no-pvp and pvp-enforced",
g_configManager().getString(WORLD_TYPE)
g_configManager().getString(WORLD_TYPE, __FUNCTION__)
)
);
}
Expand All @@ -153,11 +153,11 @@ void CanaryServer::setWorldType() {

void CanaryServer::loadMaps() const {
try {
g_game().loadMainMap(g_configManager().getString(MAP_NAME));
g_game().loadMainMap(g_configManager().getString(MAP_NAME, __FUNCTION__));

// If "mapCustomEnabled" is true on config.lua, then load the custom map
if (g_configManager().getBoolean(TOGGLE_MAP_CUSTOM)) {
g_game().loadCustomMaps(g_configManager().getString(DATA_DIRECTORY) + "/world/custom/");
if (g_configManager().getBoolean(TOGGLE_MAP_CUSTOM, __FUNCTION__)) {
g_game().loadCustomMaps(g_configManager().getString(DATA_DIRECTORY, __FUNCTION__) + "/world/custom/");
}
Zone::refreshAll();
} catch (const std::exception &err) {
Expand All @@ -167,7 +167,7 @@ void CanaryServer::loadMaps() const {

void CanaryServer::setupHousesRent() {
RentPeriod_t rentPeriod;
std::string strRentPeriod = asLowerCaseString(g_configManager().getString(HOUSE_RENT_PERIOD));
std::string strRentPeriod = asLowerCaseString(g_configManager().getString(HOUSE_RENT_PERIOD, __FUNCTION__));

if (strRentPeriod == "yearly") {
rentPeriod = RENTPERIOD_YEARLY;
Expand Down Expand Up @@ -215,8 +215,8 @@ void CanaryServer::logInfos() {
*/
void CanaryServer::toggleForceCloseButton() {
#ifdef OS_WINDOWS
HWND hwnd = GetConsoleWindow();
HMENU hmenu = GetSystemMenu(hwnd, FALSE);
const HWND hwnd = GetConsoleWindow();
const HMENU hmenu = GetSystemMenu(hwnd, FALSE);
EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED);
#endif
}
Expand Down Expand Up @@ -281,7 +281,7 @@ void CanaryServer::loadConfigLua() {
modulesLoadHelper(g_configManager().load(), g_configManager().getConfigFileLua());

#ifdef _WIN32
const std::string &defaultPriority = g_configManager().getString(DEFAULT_PRIORITY);
const std::string &defaultPriority = g_configManager().getString(DEFAULT_PRIORITY, __FUNCTION__);
if (strcasecmp(defaultPriority.c_str(), "high") == 0) {
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
} else if (strcasecmp(defaultPriority.c_str(), "above-normal") == 0) {
Expand All @@ -307,16 +307,16 @@ void CanaryServer::initializeDatabase() {

DatabaseManager::updateDatabase();

if (g_configManager().getBoolean(OPTIMIZE_DATABASE)
if (g_configManager().getBoolean(OPTIMIZE_DATABASE, __FUNCTION__)
&& !DatabaseManager::optimizeTables()) {
logger.debug("No tables were optimized");
}
}

void CanaryServer::loadModules() {
// If "USE_ANY_DATAPACK_FOLDER" is set to true then you can choose any datapack folder for your server
auto useAnyDatapack = g_configManager().getBoolean(USE_ANY_DATAPACK_FOLDER);
auto datapackName = g_configManager().getString(DATA_DIRECTORY);
const auto useAnyDatapack = g_configManager().getBoolean(USE_ANY_DATAPACK_FOLDER, __FUNCTION__);
auto datapackName = g_configManager().getString(DATA_DIRECTORY, __FUNCTION__);
if (!useAnyDatapack && (datapackName != "data-canary" && datapackName != "data-otservbr-global" || datapackName != "data-otservbr-global" && datapackName != "data-canary")) {
throw FailedToInitializeCanary(fmt::format(
"The datapack folder name '{}' is wrong, please select valid "
Expand All @@ -331,12 +331,12 @@ void CanaryServer::loadModules() {
g_luaEnvironment().initState();
}

auto coreFolder = g_configManager().getString(CORE_DIRECTORY);
auto coreFolder = g_configManager().getString(CORE_DIRECTORY, __FUNCTION__);
// Load items dependencies
modulesLoadHelper((g_game().loadAppearanceProtobuf(coreFolder + "/items/appearances.dat") == ERROR_NONE), "appearances.dat");
modulesLoadHelper(Item::items.loadFromXml(), "items.xml");

auto datapackFolder = g_configManager().getString(DATA_DIRECTORY);
const auto datapackFolder = g_configManager().getString(DATA_DIRECTORY, __FUNCTION__);
logger.debug("Loading core scripts on folder: {}/", coreFolder);
// Load first core Lua libs
modulesLoadHelper((g_luaEnvironment().loadFile(coreFolder + "/core.lua", "core.lua") == 0), "core.lua");
Expand Down
29 changes: 2 additions & 27 deletions src/config/config_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#pragma once

// Enum
enum booleanConfig_t {
enum ConfigKey_t : uint16_t {
ALLOW_CHANGEOUTFIT,
ONE_PLAYER_ON_ACCOUNT,
AIMBOT_HOTKEY_ENABLED,
Expand Down Expand Up @@ -91,11 +91,6 @@ enum booleanConfig_t {
TOGGLE_HOUSE_TRANSFER_ON_SERVER_RESTART,
TOGGLE_RECEIVE_REWARD,
TOGGLE_MAINTAIN_MODE,

LAST_BOOLEAN_CONFIG
};

enum stringConfig_t {
MAP_NAME,
MAP_DOWNLOAD_URL,
MAP_AUTHOR,
Expand Down Expand Up @@ -128,11 +123,6 @@ enum stringConfig_t {
TIBIADROME_CONCOCTION_TICK_TYPE,
M_CONST,
MAINTAIN_MODE_MESSAGE,

LAST_STRING_CONFIG
};

enum integerConfig_t {
SQL_PORT,
MAX_PLAYERS,
PZ_LOCKED,
Expand Down Expand Up @@ -251,53 +241,38 @@ enum integerConfig_t {
PARALLELISM,
BOSS_DEFAULT_TIME_TO_FIGHT_AGAIN,
BOSS_DEFAULT_TIME_TO_DEFEAT,

VIP_BONUS_EXP,
VIP_BONUS_LOOT,
VIP_BONUS_SKILL,
VIP_FAMILIAR_TIME_COOLDOWN_REDUCTION,

REWARD_CHEST_MAX_COLLECT_ITEMS,
DISCORD_WEBHOOK_DELAY_MS,

PVP_MAX_LEVEL_DIFFERENCE,

LAST_INTEGER_CONFIG
};

enum floatingConfig_t {
BESTIARY_RATE_CHARM_SHOP_PRICE,

RATE_HEALTH_REGEN,
RATE_HEALTH_REGEN_SPEED,
RATE_MANA_REGEN,
RATE_MANA_REGEN_SPEED,
RATE_SOUL_REGEN,
RATE_SOUL_REGEN_SPEED,

RATE_SPELL_COOLDOWN,
RATE_ATTACK_SPEED,
RATE_OFFLINE_TRAINING_SPEED,
RATE_EXERCISE_TRAINING_SPEED,

RATE_MONSTER_HEALTH,
RATE_MONSTER_ATTACK,
RATE_MONSTER_DEFENSE,
RATE_BOSS_HEALTH,
RATE_BOSS_ATTACK,
RATE_BOSS_DEFENSE,

RATE_NPC_HEALTH,
RATE_NPC_ATTACK,
RATE_NPC_DEFENSE,
LOYALTY_BONUS_PERCENTAGE_MULTIPLIER,
PARTY_SHARE_LOOT_BOOSTS_DIMINISHING_FACTOR,

PVP_RATE_DAMAGE_TAKEN_PER_LEVEL,
PVP_RATE_DAMAGE_REDUCTION_PER_LEVEL,

HOUSE_PRICE_RENT_MULTIPLIER,
HOUSE_RENT_RATE,

LAST_FLOATING_CONFIG
LOGLEVEL,
};
Loading

0 comments on commit 356c995

Please sign in to comment.