mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-17 20:14:31 -06:00
Compare commits
22 Commits
fix-crash
...
MM12-Testi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05dc5d6fcd | ||
|
|
c24c756f73 | ||
|
|
bdb380aed2 | ||
|
|
2baef3f198 | ||
|
|
fbf7833b7b | ||
|
|
05c67fd712 | ||
|
|
9d4d618e63 | ||
|
|
6aa7c592a2 | ||
|
|
68187d9f96 | ||
|
|
716e8c646c | ||
|
|
d2cecd0073 | ||
|
|
d97f374a90 | ||
|
|
a6c6474e67 | ||
|
|
dbdf4ac46a | ||
|
|
6ed504c88e | ||
|
|
9be2ab03b6 | ||
|
|
e53e31021f | ||
|
|
41b8762c8f | ||
|
|
da07a70d4d | ||
|
|
d78b2958d3 | ||
|
|
9cfc126842 | ||
|
|
56e3d07669 |
2
build.sh
2
build.sh
@@ -9,5 +9,5 @@ cd build
|
||||
cmake ..
|
||||
|
||||
# To build utilizing multiple cores, append `-j` and the amount of cores to utilize, for example `cmake --build . --config Release -j8'
|
||||
cmake --build . --config Release -j4
|
||||
cmake --build . --config Release
|
||||
|
||||
|
||||
@@ -375,7 +375,7 @@ void Entity::Initialize() {
|
||||
comp->SetIsSmashable(destCompData[0].isSmashable);
|
||||
|
||||
comp->SetLootMatrixID(destCompData[0].LootMatrixIndex);
|
||||
Game::logger->Log("Entity", "%i %i %f", destCompData[0].life, destCompData[0].imagination, destCompData[0].armor);
|
||||
|
||||
// Now get currency information
|
||||
uint32_t npcMinLevel = destCompData[0].level;
|
||||
uint32_t currencyIndex = destCompData[0].CurrencyIndex;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
#include "MessageIdentifiers.h"
|
||||
#include "dConfig.h"
|
||||
|
||||
EntityManager* EntityManager::m_Address = nullptr;
|
||||
|
||||
@@ -59,16 +58,6 @@ void EntityManager::Initialize() {
|
||||
m_GhostingExcludedZones.end(),
|
||||
dZoneManager::Instance()->GetZoneID().GetMapID()
|
||||
) == m_GhostingExcludedZones.end();
|
||||
|
||||
// grab hardcore mode settings and load them with sane defaults
|
||||
auto hcmode = Game::config->GetValue("hardcore_mode");
|
||||
m_HardcoreMode = hcmode.empty() ? false : (hcmode == "1");
|
||||
auto hcUscorePercent = Game::config->GetValue("hardcore_lose_uscore_on_death_percent");
|
||||
m_HardcoreLoseUscoreOnDeathPercent = hcUscorePercent.empty() ? 10 : std::stoi(hcUscorePercent);
|
||||
auto hcUscoreMult = Game::config->GetValue("hardcore_uscore_enemies_multiplier");
|
||||
m_HardcoreUscoreEnemiesMultiplier = hcUscoreMult.empty() ? 2 : std::stoi(hcUscoreMult);
|
||||
auto hcDropInv = Game::config->GetValue("hardcore_dropinventory_on_death");
|
||||
m_HardcoreDropinventoryOnDeath = hcDropInv.empty() ? false : (hcDropInv == "1");
|
||||
}
|
||||
|
||||
EntityManager::~EntityManager() {
|
||||
|
||||
@@ -78,11 +78,6 @@ public:
|
||||
|
||||
static bool IsExcludedFromGhosting(LOT lot);
|
||||
|
||||
const bool GetHardcoreMode() { return m_HardcoreMode; };
|
||||
const uint32_t GetHardcoreLoseUscoreOnDeathPercent() { return m_HardcoreLoseUscoreOnDeathPercent; };
|
||||
const bool GetHardcoreDropinventoryOnDeath() { return m_HardcoreDropinventoryOnDeath; };
|
||||
const uint32_t GetHardcoreUscoreEnemiesMultiplier() { return m_HardcoreUscoreEnemiesMultiplier; };
|
||||
|
||||
private:
|
||||
static EntityManager* m_Address; //For singleton method
|
||||
static std::vector<LWOMAPID> m_GhostingExcludedZones;
|
||||
@@ -107,12 +102,6 @@ private:
|
||||
|
||||
// Map of spawnname to entity object ID
|
||||
std::unordered_map<std::string, LWOOBJID> m_SpawnPoints;
|
||||
|
||||
// hardcore mode vars
|
||||
bool m_HardcoreMode;
|
||||
uint32_t m_HardcoreLoseUscoreOnDeathPercent;
|
||||
bool m_HardcoreDropinventoryOnDeath;
|
||||
uint32_t m_HardcoreUscoreEnemiesMultiplier;
|
||||
};
|
||||
|
||||
#endif // ENTITYMANAGER_H
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <BitStream.h>
|
||||
#include "dLogger.h"
|
||||
#include "Game.h"
|
||||
#include "dConfig.h"
|
||||
|
||||
#include "AMFFormat.h"
|
||||
#include "AMFFormat_BitStream.h"
|
||||
@@ -666,12 +665,6 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//check if hardcore mode is enabled
|
||||
if (EntityManager::Instance()->GetHardcoreMode()) {
|
||||
DoHardcoreModeDrops(source);
|
||||
}
|
||||
|
||||
Smash(source, eKillType::VIOLENT, u"", skillID);
|
||||
}
|
||||
|
||||
@@ -978,75 +971,3 @@ void DestroyableComponent::FixStats() {
|
||||
void DestroyableComponent::AddOnHitCallback(const std::function<void(Entity*)>& callback) {
|
||||
m_OnHitCallbacks.push_back(callback);
|
||||
}
|
||||
|
||||
void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
||||
//check if this is a player:
|
||||
if (m_Parent->IsPlayer()) {
|
||||
//remove hardcore_lose_uscore_on_death_percent from the player's uscore:
|
||||
auto* character = m_Parent->GetComponent<CharacterComponent>();
|
||||
auto uscore = character->GetUScore();
|
||||
|
||||
auto uscoreToLose = uscore * (EntityManager::Instance()->GetHardcoreLoseUscoreOnDeathPercent() / 100);
|
||||
character->SetUScore(uscore - uscoreToLose);
|
||||
|
||||
GameMessages::SendModifyLEGOScore(m_Parent, m_Parent->GetSystemAddress(), -uscoreToLose, eLootSourceType::LOOT_SOURCE_MISSION);
|
||||
|
||||
if (EntityManager::Instance()->GetHardcoreDropinventoryOnDeath()) {
|
||||
//drop all items from inventory:
|
||||
auto* inventory = m_Parent->GetComponent<InventoryComponent>();
|
||||
if (inventory) {
|
||||
//get the items inventory:
|
||||
auto items = inventory->GetInventory(eInventoryType::ITEMS);
|
||||
if (items){
|
||||
auto itemMap = items->GetItems();
|
||||
if (!itemMap.empty()){
|
||||
for (const auto& item : itemMap) {
|
||||
//drop the item:
|
||||
if (!item.second) continue;
|
||||
// don't drop the thinkng cap
|
||||
if (item.second->GetLot() == 6086) continue;
|
||||
GameMessages::SendDropClientLoot(m_Parent, source, item.second->GetLot(), 0, m_Parent->GetPosition(), item.second->GetCount());
|
||||
item.second->SetCount(0, false, false);
|
||||
}
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get character:
|
||||
auto* chars = m_Parent->GetCharacter();
|
||||
if (chars) {
|
||||
auto coins = chars->GetCoins();
|
||||
|
||||
//lose all coins:
|
||||
chars->SetCoins(0, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
|
||||
//drop all coins:
|
||||
GameMessages::SendDropClientLoot(m_Parent, source, LOT_NULL, coins, m_Parent->GetPosition());
|
||||
}
|
||||
|
||||
// Reload the player since we can't normally reduce uscore from the server and we want the UI to update
|
||||
// do this last so we don't get killed.... again
|
||||
EntityManager::Instance()->DestructEntity(m_Parent);
|
||||
EntityManager::Instance()->ConstructEntity(m_Parent);
|
||||
return;
|
||||
}
|
||||
|
||||
//award the player some u-score:
|
||||
auto* player = EntityManager::Instance()->GetEntity(source);
|
||||
if (player && player->IsPlayer()) {
|
||||
auto* playerStats = player->GetComponent<CharacterComponent>();
|
||||
if (playerStats) {
|
||||
//get the maximum health from this enemy:
|
||||
auto maxHealth = GetMaxHealth();
|
||||
|
||||
int uscore = maxHealth * EntityManager::Instance()->GetHardcoreUscoreEnemiesMultiplier();
|
||||
|
||||
playerStats->SetUScore(playerStats->GetUScore() + uscore);
|
||||
GameMessages::SendModifyLEGOScore(player, player->GetSystemAddress(), uscore, eLootSourceType::LOOT_SOURCE_MISSION);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,9 +452,6 @@ public:
|
||||
void Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd);
|
||||
void Unsubscribe(LWOOBJID scriptObjId);
|
||||
|
||||
// handle hardcode mode drops
|
||||
void DoHardcoreModeDrops(const LWOOBJID source);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Whether or not the health should be serialized
|
||||
|
||||
@@ -42,7 +42,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
Entity* entity = EntityManager::Instance()->GetEntity(objectID);
|
||||
|
||||
User* usr = UserManager::Instance()->GetUser(sysAddr);
|
||||
|
||||
Game::logger->Log("GameMessageHandler", "handling message %i", messageID);
|
||||
if (!entity) {
|
||||
Game::logger->Log("GameMessageHandler", "Failed to find associated entity (%llu), aborting GM (%X)!", objectID, messageID);
|
||||
|
||||
|
||||
@@ -2555,6 +2555,7 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
|
||||
|
||||
//We runs this in async because the http library here is blocking, meaning it'll halt the thread.
|
||||
//But we don't want the server to go unresponsive, because then the client would disconnect.
|
||||
Game::logger->Log("GameMessages", "launching async");
|
||||
std::async(std::launch::async, [&]() {
|
||||
|
||||
//We need to get a new ID for our model first:
|
||||
@@ -2574,7 +2575,7 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
|
||||
|
||||
const auto zoneId = worldId.GetMapID();
|
||||
const auto cloneId = worldId.GetCloneID();
|
||||
|
||||
Game::logger->Log("GameMessages", "doing cdc lookup");
|
||||
auto query = CDClientDatabase::CreatePreppedStmt(
|
||||
"SELECT id FROM PropertyTemplate WHERE mapID = ?;");
|
||||
query.bind(1, (int)zoneId);
|
||||
@@ -2586,7 +2587,8 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
|
||||
int templateId = result.getIntField(0);
|
||||
|
||||
result.finalize();
|
||||
|
||||
try {
|
||||
Game::logger->Log("GameMessages", "preparing stmt for properties");
|
||||
auto* propertyLookup = Database::CreatePreppedStmt("SELECT * FROM properties WHERE template_id = ? AND clone_id = ?;");
|
||||
|
||||
propertyLookup->setInt(1, templateId);
|
||||
@@ -2601,7 +2603,7 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
|
||||
|
||||
delete propertyEntry;
|
||||
delete propertyLookup;
|
||||
|
||||
Game::logger->Log("GameMessages", "preparing ugc lookup");
|
||||
//Insert into ugc:
|
||||
auto ugcs = Database::CreatePreppedStmt("INSERT INTO `ugc`(`id`, `account_id`, `character_id`, `is_optimized`, `lxfml`, `bake_ao`, `filename`) VALUES (?,?,?,?,?,?,?)");
|
||||
ugcs->setUInt(1, blueprintIDSmall);
|
||||
@@ -2617,7 +2619,9 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
|
||||
ugcs->setBlob(5, &iss);
|
||||
ugcs->setBoolean(6, false);
|
||||
ugcs->setString(7, "weedeater.lxfml");
|
||||
Game::logger->Log("GameMessages", "prepared ugc lookup");
|
||||
ugcs->execute();
|
||||
Game::logger->Log("GameMessages", "preparing properties_contents lookup");
|
||||
delete ugcs;
|
||||
|
||||
//Insert into the db as a BBB model:
|
||||
@@ -2640,9 +2644,14 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
|
||||
stmt->setDouble(16, 0); // behavior 3. TODO implement this.
|
||||
stmt->setDouble(17, 0); // behavior 4. TODO implement this.
|
||||
stmt->setDouble(18, 0); // behavior 5. TODO implement this.
|
||||
Game::logger->Log("GameMessages", "Executing insertion");
|
||||
stmt->execute();
|
||||
delete stmt;
|
||||
|
||||
} catch (sql::SQLException& e) {
|
||||
Game::logger->Log("GameMessages", "error is %s", e.what());
|
||||
} catch (std::exception& e) {
|
||||
Game::logger->Log("GameMessages", "caught error %s", e.what());
|
||||
}
|
||||
/*
|
||||
Commented out until UGC server would be updated to use a sd0 file instead of lxfml stream.
|
||||
(or you uncomment the lxfml decomp stuff above)
|
||||
|
||||
@@ -1312,7 +1312,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
}
|
||||
|
||||
if ((chatCommand == "giveuscore") && args.size() >= 1 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||
if ((chatCommand == "giveuscore") && args.size() == 1 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||
int32_t uscore;
|
||||
|
||||
if (!GeneralUtils::TryParse(args[0], uscore)) {
|
||||
@@ -1323,16 +1323,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
CharacterComponent* character = entity->GetComponent<CharacterComponent>();
|
||||
if (character) character->SetUScore(character->GetUScore() + uscore);
|
||||
// LOOT_SOURCE_MODERATION should work but it doesn't. Relog to see uscore changes
|
||||
|
||||
eLootSourceType lootType = eLootSourceType::LOOT_SOURCE_MODERATION;
|
||||
|
||||
int32_t type;
|
||||
if (args.size() >= 2 && GeneralUtils::TryParse(args[1], type))
|
||||
{
|
||||
lootType = (eLootSourceType) type;
|
||||
}
|
||||
|
||||
GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), uscore, lootType);
|
||||
GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), uscore, eLootSourceType::LOOT_SOURCE_MODERATION);
|
||||
}
|
||||
|
||||
if ((chatCommand == "setlevel") && args.size() >= 1 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||
|
||||
@@ -65,21 +65,17 @@ void VanityUtilities::SpawnVanity() {
|
||||
npcIndex = GeneralUtils::GenerateRandomNumber<uint32_t>(0, npcList.size() - 1);
|
||||
}
|
||||
|
||||
auto& npc = npcList[npcIndex];
|
||||
const auto& npc = npcList[npcIndex];
|
||||
|
||||
taken.push_back(npcIndex);
|
||||
|
||||
// Spawn the NPC
|
||||
Game::logger->Log("VanityUtilities", "ldf size is %i", npc.ldf.size());
|
||||
if (npc.ldf.empty()) {
|
||||
npc.ldf = {
|
||||
new LDFData<std::vector<std::u16string>>(u"syncLDF", { u"custom_script_client" }),
|
||||
new LDFData<std::u16string>(u"custom_script_client", u"scripts\\ai\\SPEC\\MISSION_MINIGAME_CLIENT.lua")
|
||||
};
|
||||
}
|
||||
std::vector<LDFBaseData*> data = { new LDFData<std::vector<std::u16string>>(
|
||||
u"syncLDF", { u"custom_script_client" }),
|
||||
new LDFData<std::u16string>(u"custom_script_client", u"scripts\\ai\\SPEC\\MISSION_MINIGAME_CLIENT.lua") };
|
||||
|
||||
// Spawn the NPC
|
||||
auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, npc.ldf);
|
||||
auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, data);
|
||||
|
||||
npcEntity->SetVar<std::vector<std::string>>(u"chats", m_PartyPhrases);
|
||||
|
||||
@@ -90,11 +86,11 @@ void VanityUtilities::SpawnVanity() {
|
||||
}
|
||||
|
||||
// Loop through all NPCs
|
||||
for (auto& npc : m_NPCs) {
|
||||
if (npc.m_Locations.find(Game::server->GetZoneID()) == npc.m_Locations.end())
|
||||
for (const auto& pair : m_NPCs) {
|
||||
if (pair.m_Locations.find(Game::server->GetZoneID()) == pair.m_Locations.end())
|
||||
continue;
|
||||
|
||||
const std::vector<VanityNPCLocation>& locations = npc.m_Locations.at(Game::server->GetZoneID());
|
||||
const std::vector<VanityNPCLocation>& locations = pair.m_Locations.at(Game::server->GetZoneID());
|
||||
|
||||
// Pick a random location
|
||||
const auto& location = locations[GeneralUtils::GenerateRandomNumber<int>(
|
||||
@@ -105,30 +101,27 @@ void VanityUtilities::SpawnVanity() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (npc.ldf.empty()) {
|
||||
npc.ldf = {
|
||||
new LDFData<std::vector<std::u16string>>(u"syncLDF", { u"custom_script_client" }),
|
||||
new LDFData<std::u16string>(u"custom_script_client", u"scripts\\ai\\SPEC\\MISSION_MINIGAME_CLIENT.lua")
|
||||
};
|
||||
}
|
||||
std::vector<LDFBaseData*> data = { new LDFData<std::vector<std::u16string>>(
|
||||
u"syncLDF", { u"custom_script_client" }),
|
||||
new LDFData<std::u16string>(u"custom_script_client", u"scripts\\ai\\SPEC\\MISSION_MINIGAME_CLIENT.lua") };
|
||||
|
||||
// Spawn the NPC
|
||||
auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, npc.ldf);
|
||||
auto* npc = SpawnNPC(pair.m_LOT, pair.m_Name, location.m_Position, location.m_Rotation, pair.m_Equipment, data);
|
||||
|
||||
npcEntity->SetVar<std::vector<std::string>>(u"chats", npc.m_Phrases);
|
||||
npc->SetVar<std::vector<std::string>>(u"chats", pair.m_Phrases);
|
||||
|
||||
auto* scriptComponent = npcEntity->GetComponent<ScriptComponent>();
|
||||
auto* scriptComponent = npc->GetComponent<ScriptComponent>();
|
||||
|
||||
if (scriptComponent != nullptr) {
|
||||
scriptComponent->SetScript(npc.m_Script);
|
||||
scriptComponent->SetScript(pair.m_Script);
|
||||
scriptComponent->SetSerialized(false);
|
||||
|
||||
for (const auto& npc : npc.m_Flags) {
|
||||
npcEntity->SetVar<bool>(GeneralUtils::ASCIIToUTF16(npc.first), npc.second);
|
||||
for (const auto& pair : pair.m_Flags) {
|
||||
npc->SetVar<bool>(GeneralUtils::ASCIIToUTF16(pair.first), pair.second);
|
||||
}
|
||||
}
|
||||
|
||||
SetupNPCTalk(npcEntity);
|
||||
SetupNPCTalk(npc);
|
||||
}
|
||||
|
||||
if (zoneID == 1200) {
|
||||
@@ -273,7 +266,10 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
// Get the NPC name
|
||||
auto* name = npc->Attribute("name");
|
||||
|
||||
if (!name) name = "";
|
||||
if (name == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPC name");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the NPC lot
|
||||
auto* lot = npc->Attribute("lot");
|
||||
@@ -285,68 +281,64 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
|
||||
// Get the equipment
|
||||
auto* equipment = npc->FirstChildElement("equipment");
|
||||
std::vector<LOT> inventory;
|
||||
|
||||
if (equipment) {
|
||||
auto* text = equipment->GetText();
|
||||
|
||||
if (text != nullptr) {
|
||||
std::string equipmentString(text);
|
||||
|
||||
std::vector<std::string> splitEquipment = GeneralUtils::SplitString(equipmentString, ',');
|
||||
|
||||
for (auto& item : splitEquipment) {
|
||||
inventory.push_back(std::stoi(item));
|
||||
}
|
||||
}
|
||||
if (equipment == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPC equipment");
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* text = equipment->GetText();
|
||||
|
||||
std::vector<LOT> inventory;
|
||||
|
||||
if (text != nullptr) {
|
||||
std::string equipmentString(text);
|
||||
|
||||
std::vector<std::string> splitEquipment = GeneralUtils::SplitString(equipmentString, ',');
|
||||
|
||||
for (auto& item : splitEquipment) {
|
||||
inventory.push_back(std::stoi(item));
|
||||
}
|
||||
}
|
||||
|
||||
// Get the phrases
|
||||
auto* phrases = npc->FirstChildElement("phrases");
|
||||
|
||||
std::vector<std::string> phraseList = {};
|
||||
if (phrases == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPC phrases");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (phrases) {
|
||||
for (auto* phrase = phrases->FirstChildElement("phrase"); phrase != nullptr;
|
||||
phrase = phrase->NextSiblingElement("phrase")) {
|
||||
// Get the phrase
|
||||
auto* text = phrase->GetText();
|
||||
if (text == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPC phrase");
|
||||
continue;
|
||||
}
|
||||
phraseList.push_back(text);
|
||||
std::vector<std::string> phraseList;
|
||||
|
||||
for (auto* phrase = phrases->FirstChildElement("phrase"); phrase != nullptr;
|
||||
phrase = phrase->NextSiblingElement("phrase")) {
|
||||
// Get the phrase
|
||||
auto* text = phrase->GetText();
|
||||
|
||||
if (text == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPC phrase");
|
||||
continue;
|
||||
}
|
||||
|
||||
phraseList.push_back(text);
|
||||
}
|
||||
|
||||
// Get the script
|
||||
auto* scriptElement = npc->FirstChildElement("script");
|
||||
|
||||
std::string scriptName = "";
|
||||
std::string scriptName;
|
||||
|
||||
if (scriptElement != nullptr) {
|
||||
auto* scriptNameAttribute = scriptElement->Attribute("name");
|
||||
if (scriptNameAttribute) scriptName = scriptNameAttribute;
|
||||
}
|
||||
|
||||
auto* ldfElement = npc->FirstChildElement("ldf");
|
||||
std::vector<std::u16string> keys = {};
|
||||
|
||||
std::vector<LDFBaseData*> ldf = {};
|
||||
if(ldfElement) {
|
||||
for (auto* entry = ldfElement->FirstChildElement("entry"); entry != nullptr;
|
||||
entry = entry->NextSiblingElement("entry")) {
|
||||
// Get the ldf data
|
||||
auto* data = entry->Attribute("data");
|
||||
if (!data) continue;
|
||||
|
||||
LDFBaseData* ldfData = LDFBaseData::DataFromString(data);
|
||||
keys.push_back(ldfData->GetKey());
|
||||
ldf.push_back(ldfData);
|
||||
if (scriptNameAttribute == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPC script name");
|
||||
continue;
|
||||
}
|
||||
|
||||
scriptName = scriptNameAttribute;
|
||||
}
|
||||
if (!keys.empty()) ldf.push_back(new LDFData<std::vector<std::u16string>>(u"syncLDF", keys));
|
||||
|
||||
VanityNPC npcData;
|
||||
npcData.m_Name = name;
|
||||
@@ -354,7 +346,6 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
npcData.m_Equipment = inventory;
|
||||
npcData.m_Phrases = phraseList;
|
||||
npcData.m_Script = scriptName;
|
||||
npcData.ldf = ldf;
|
||||
|
||||
// Get flags
|
||||
auto* flags = npc->FirstChildElement("flags");
|
||||
|
||||
@@ -20,7 +20,6 @@ struct VanityNPC
|
||||
std::string m_Script;
|
||||
std::map<std::string, bool> m_Flags;
|
||||
std::map<uint32_t, std::vector<VanityNPCLocation>> m_Locations;
|
||||
std::vector<LDFBaseData*> ldf;
|
||||
};
|
||||
|
||||
struct VanityParty
|
||||
|
||||
@@ -248,6 +248,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
std::cout << "Account created successfully!\n";
|
||||
|
||||
Database::Destroy("MasterServer");
|
||||
delete Game::logger;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -295,7 +297,7 @@ int main(int argc, char** argv) {
|
||||
StartChatServer();
|
||||
|
||||
Game::im->GetInstance(0, false, 0);
|
||||
Game::im->GetInstance(1800, false, 0);
|
||||
Game::im->GetInstance(1000, false, 0);
|
||||
|
||||
StartAuthServer();
|
||||
}
|
||||
|
||||
@@ -413,21 +413,27 @@ int main(int argc, char** argv) {
|
||||
|
||||
UserManager::Instance()->DeletePendingRemovals();
|
||||
|
||||
auto t1 = std::chrono::high_resolution_clock::now();
|
||||
for (uint32_t curPacket = 0; curPacket < maxPacketsToProcess && timeSpent < maxPacketProcessingTime; curPacket++) {
|
||||
packet = Game::server->Receive();
|
||||
if (packet) {
|
||||
auto t1 = std::chrono::high_resolution_clock::now();
|
||||
HandlePacket(packet);
|
||||
auto t2 = std::chrono::high_resolution_clock::now();
|
||||
try {
|
||||
auto t1 = std::chrono::high_resolution_clock::now();
|
||||
for (uint32_t curPacket = 0; curPacket < maxPacketsToProcess && timeSpent < maxPacketProcessingTime; curPacket++) {
|
||||
packet = Game::server->Receive();
|
||||
if (packet) {
|
||||
auto t1 = std::chrono::high_resolution_clock::now();
|
||||
HandlePacket(packet);
|
||||
auto t2 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
timeSpent += std::chrono::duration_cast<std::chrono::duration<float>>(t2 - t1).count();
|
||||
Game::server->DeallocatePacket(packet);
|
||||
packet = nullptr;
|
||||
} else {
|
||||
break;
|
||||
timeSpent += std::chrono::duration_cast<std::chrono::duration<float>>(t2 - t1).count();
|
||||
Game::server->DeallocatePacket(packet);
|
||||
packet = nullptr;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (sql::SQLException& e) {
|
||||
Game::logger->Log("WorldServer", "Caught an error (%s)", e.what());
|
||||
std::raise(SIGTERM);
|
||||
}
|
||||
|
||||
|
||||
Metrics::EndMeasurement(MetricVariable::PacketHandling);
|
||||
|
||||
|
||||
@@ -46,15 +46,3 @@ max_number_of_best_friends=5
|
||||
|
||||
# Disables loot drops
|
||||
disable_drops=0
|
||||
|
||||
# Hardcore mode settings
|
||||
hardcore_mode=0
|
||||
|
||||
# Drop your entire inventory on death + coins (drops on the ground, so can be retrieved)
|
||||
hardcore_dropinventory_on_death=1
|
||||
|
||||
# Enemies drop their max hp * this value. 0 will effectively disable it.
|
||||
hardcore_uscore_enemies_multiplier=2
|
||||
|
||||
# Percentage of u-score to lose on player death
|
||||
hardcore_lose_uscore_on_death_percent=10
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "dServer.h"
|
||||
#include "EntityInfo.h"
|
||||
#include "EntityManager.h"
|
||||
#include "dConfig.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
class dZoneManager;
|
||||
@@ -31,7 +30,6 @@ protected:
|
||||
info.lot = 999;
|
||||
Game::logger = new dLogger("./testing.log", true, true);
|
||||
Game::server = new dServerMock();
|
||||
Game::config = new dConfig("worldconfig.ini");
|
||||
}
|
||||
|
||||
void TearDownDependencies() {
|
||||
@@ -41,7 +39,6 @@ protected:
|
||||
Game::logger->Flush();
|
||||
delete Game::logger;
|
||||
}
|
||||
if (Game::config) delete Game::config;
|
||||
}
|
||||
|
||||
EntityInfo info;
|
||||
|
||||
Reference in New Issue
Block a user