mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
Remove GameConfig (#874)
* Remove GameConfig * Fully remove GmeConfig * Update worldconfig.ini Co-authored-by: Aaron Kimbrell <aronwk.aaron@gmail.com>
This commit is contained in:
parent
fc75d6048f
commit
1ac898ba00
@ -24,7 +24,6 @@ public:
|
||||
* Reloads the config file to reset values
|
||||
*/
|
||||
void ReloadConfig();
|
||||
|
||||
private:
|
||||
void ProcessLine(const std::string& line);
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "dConfig.h"
|
||||
#include "TeamManager.h"
|
||||
#include "ChatPackets.h"
|
||||
#include "GameConfig.h"
|
||||
#include "RocketLaunchLupComponent.h"
|
||||
#include "eUnequippableActiveType.h"
|
||||
#include "eMovementPlatformState.h"
|
||||
@ -1005,7 +1004,7 @@ void GameMessages::SendSetNetworkScriptVar(Entity* entity, const SystemAddress&
|
||||
}
|
||||
|
||||
void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID, LOT item, int currency, NiPoint3 spawnPos, int count) {
|
||||
if (GameConfig::GetValue<int32_t>("no_drops") == 1) {
|
||||
if (Game::config->GetValue("disable_drops") == "1") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
set(DGAME_DUTILITIES_SOURCES "BrickDatabase.cpp"
|
||||
"GameConfig.cpp"
|
||||
"GUID.cpp"
|
||||
"Loot.cpp"
|
||||
"Mail.cpp"
|
||||
|
@ -1,50 +0,0 @@
|
||||
#include "GameConfig.h"
|
||||
#include <sstream>
|
||||
|
||||
std::map<std::string, std::string> GameConfig::m_Config{};
|
||||
std::string GameConfig::m_EmptyString{};
|
||||
|
||||
void GameConfig::Load(const std::string& filepath) {
|
||||
m_EmptyString = "";
|
||||
std::ifstream in(filepath);
|
||||
if (!in.good()) return;
|
||||
|
||||
std::string line;
|
||||
while (std::getline(in, line)) {
|
||||
if (line.length() > 0) {
|
||||
if (line[0] != '#') ProcessLine(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& GameConfig::GetValue(const std::string& key) {
|
||||
const auto& it = m_Config.find(key);
|
||||
|
||||
if (it != m_Config.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return m_EmptyString;
|
||||
}
|
||||
|
||||
void GameConfig::SetValue(const std::string& key, const std::string& value) {
|
||||
m_Config.insert_or_assign(key, value);
|
||||
}
|
||||
|
||||
void GameConfig::ProcessLine(const std::string& line) {
|
||||
std::stringstream ss(line);
|
||||
std::string segment;
|
||||
std::vector<std::string> seglist;
|
||||
|
||||
while (std::getline(ss, segment, '=')) {
|
||||
seglist.push_back(segment);
|
||||
}
|
||||
|
||||
if (seglist.size() != 2) return;
|
||||
|
||||
//Make sure that on Linux, we remove special characters:
|
||||
if (!seglist[1].empty() && seglist[1][seglist[1].size() - 1] == '\r')
|
||||
seglist[1].erase(seglist[1].size() - 1);
|
||||
|
||||
m_Config.insert_or_assign(seglist[0], seglist[1]);
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "GeneralUtils.h"
|
||||
|
||||
class GameConfig {
|
||||
public:
|
||||
static void Load(const std::string& filepath);
|
||||
|
||||
static const std::string& GetValue(const std::string& key);
|
||||
|
||||
static void SetValue(const std::string& key, const std::string& value);
|
||||
|
||||
template <typename T>
|
||||
static T GetValue(const std::string& key) {
|
||||
T value;
|
||||
|
||||
if (GeneralUtils::TryParse(GetValue(key), value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return T();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void SetValue(const std::string& key, const T& value) {
|
||||
SetValue(key, std::to_string(value));
|
||||
}
|
||||
|
||||
private:
|
||||
static void ProcessLine(const std::string& line);
|
||||
|
||||
static std::map<std::string, std::string> m_Config;
|
||||
static std::string m_EmptyString;
|
||||
};
|
@ -63,7 +63,6 @@
|
||||
#include "BuffComponent.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "VanityUtilities.h"
|
||||
#include "GameConfig.h"
|
||||
#include "ScriptedActivityComponent.h"
|
||||
#include "LevelProgressionComponent.h"
|
||||
#include "AssetManager.h"
|
||||
@ -1701,25 +1700,6 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
return;
|
||||
}
|
||||
|
||||
if (chatCommand == "config-set" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER && args.size() >= 2) {
|
||||
GameConfig::SetValue(args[0], args[1]);
|
||||
|
||||
ChatPackets::SendSystemMessage(
|
||||
sysAddr, u"Set config value: " + GeneralUtils::UTF8ToUTF16(args[0]) + u" to " + GeneralUtils::UTF8ToUTF16(args[1])
|
||||
);
|
||||
}
|
||||
|
||||
if (chatCommand == "config-get" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER && args.size() >= 1) {
|
||||
const auto& value = GameConfig::GetValue(args[0]);
|
||||
|
||||
std::u16string u16key = GeneralUtils::UTF8ToUTF16(args[0]);
|
||||
if (value.empty()) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"No value found for " + u16key);
|
||||
} else {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Value for " + u16key + u": " + GeneralUtils::UTF8ToUTF16(value));
|
||||
}
|
||||
}
|
||||
|
||||
if (chatCommand == "metrics" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||
for (const auto variable : Metrics::GetAllMetrics()) {
|
||||
auto* metric = Metrics::GetMetric(variable);
|
||||
|
@ -36,8 +36,6 @@
|
||||
|Command|Usage|Description|Admin Level Requirement|
|
||||
|--- |--- |--- |--- |
|
||||
|announce|`/announce`|Sends a announcement. `/setanntitle` and `/setannmsg` must be called first to configure the announcement.|8|
|
||||
|config-set|`/config-set <key> <value>`|Set configuration item.|8|
|
||||
|config-get|`/config-get <key>`|Get current value of a configuration item.|8|
|
||||
|kill|`/kill <username>`|Smashes the character whom the given user is playing.|8|
|
||||
|metrics|`/metrics`|Prints some information about the server's performance.|8|
|
||||
|setannmsg|`/setannmsg <title>`|Sets the message of an announcement.|8|
|
||||
|
@ -43,3 +43,6 @@ pets_take_imagination=1
|
||||
# If you would like to increase the maximum number of best friends a player can have on the server
|
||||
# Change the value below to what you would like this to be (5 is live accurate)
|
||||
max_number_of_best_friends=5
|
||||
|
||||
# Disables loot drops
|
||||
disable_drops=0
|
||||
|
Loading…
Reference in New Issue
Block a user