Merge branch 'DarkflameUniverse:main' into PetFixes

This commit is contained in:
jadebenn 2023-12-16 19:55:17 -06:00 committed by GitHub
commit 60e4813d40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 44 additions and 35 deletions

View File

@ -110,3 +110,7 @@ void User::UserOutOfSync() {
Game::server->Disconnect(this->m_SystemAddress, eServerDisconnectIdentifiers::PLAY_SCHEDULE_TIME_DONE); Game::server->Disconnect(this->m_SystemAddress, eServerDisconnectIdentifiers::PLAY_SCHEDULE_TIME_DONE);
} }
} }
void User::UpdateBestFriendValue(const std::string_view playerName, const bool newValue) {
m_IsBestFriendMap[playerName.data()] = newValue;
}

View File

@ -43,8 +43,8 @@ public:
bool GetLastChatMessageApproved() { return m_LastChatMessageApproved; } bool GetLastChatMessageApproved() { return m_LastChatMessageApproved; }
void SetLastChatMessageApproved(bool approved) { m_LastChatMessageApproved = approved; } void SetLastChatMessageApproved(bool approved) { m_LastChatMessageApproved = approved; }
std::unordered_map<std::string, bool> GetIsBestFriendMap() { return m_IsBestFriendMap; } const std::unordered_map<std::string, bool>& GetIsBestFriendMap() { return m_IsBestFriendMap; }
void SetIsBestFriendMap(std::unordered_map<std::string, bool> mapToSet) { m_IsBestFriendMap = mapToSet; } void UpdateBestFriendValue(const std::string_view playerName, const bool newValue);
bool GetIsMuted() const; bool GetIsMuted() const;

View File

@ -145,8 +145,13 @@ void MissionComponent::RemoveMission(uint32_t missionId) {
} }
void MissionComponent::Progress(eMissionTaskType type, int32_t value, LWOOBJID associate, const std::string& targets, int32_t count, bool ignoreAchievements) { void MissionComponent::Progress(eMissionTaskType type, int32_t value, LWOOBJID associate, const std::string& targets, int32_t count, bool ignoreAchievements) {
for (const auto& pair : m_Missions) { std::vector<uint32_t> acceptedAchievements;
auto* mission = pair.second; if (count > 0 && !ignoreAchievements) {
acceptedAchievements = LookForAchievements(type, value, true, associate, targets, count);
}
for (const auto& [id, mission] : m_Missions) {
if (!mission || std::find(acceptedAchievements.begin(), acceptedAchievements.end(), mission->GetMissionId()) != acceptedAchievements.end()) continue;
if (mission->IsAchievement() && ignoreAchievements) continue; if (mission->IsAchievement() && ignoreAchievements) continue;
@ -154,10 +159,6 @@ void MissionComponent::Progress(eMissionTaskType type, int32_t value, LWOOBJID a
mission->Progress(type, value, associate, targets, count); mission->Progress(type, value, associate, targets, count);
} }
if (count > 0 && !ignoreAchievements) {
LookForAchievements(type, value, true, associate, targets, count);
}
} }
void MissionComponent::ForceProgress(const uint32_t missionId, const uint32_t taskId, const int32_t value, const bool acceptMission) { void MissionComponent::ForceProgress(const uint32_t missionId, const uint32_t taskId, const int32_t value, const bool acceptMission) {
@ -282,12 +283,12 @@ bool MissionComponent::GetMissionInfo(uint32_t missionId, CDMissions& result) {
#define MISSION_NEW_METHOD #define MISSION_NEW_METHOD
bool MissionComponent::LookForAchievements(eMissionTaskType type, int32_t value, bool progress, LWOOBJID associate, const std::string& targets, int32_t count) { const std::vector<uint32_t> MissionComponent::LookForAchievements(eMissionTaskType type, int32_t value, bool progress, LWOOBJID associate, const std::string& targets, int32_t count) {
#ifdef MISSION_NEW_METHOD #ifdef MISSION_NEW_METHOD
// Query for achievments, using the cache // Query for achievments, using the cache
const auto& result = QueryAchievements(type, value, targets); const auto& result = QueryAchievements(type, value, targets);
bool any = false; std::vector<uint32_t> acceptedAchievements;
for (const uint32_t missionID : result) { for (const uint32_t missionID : result) {
// Check if we already have this achievement // Check if we already have this achievement
@ -309,7 +310,7 @@ bool MissionComponent::LookForAchievements(eMissionTaskType type, int32_t value,
instance->Accept(); instance->Accept();
any = true; acceptedAchievements.push_back(missionID);
if (progress) { if (progress) {
// Progress mission to bring it up to speed // Progress mission to bring it up to speed
@ -317,7 +318,7 @@ bool MissionComponent::LookForAchievements(eMissionTaskType type, int32_t value,
} }
} }
return any; return acceptedAchievements;
#else #else
auto* missionTasksTable = CDClientManager::Instance().GetTable<CDMissionTasksTable>(); auto* missionTasksTable = CDClientManager::Instance().GetTable<CDMissionTasksTable>();
auto* missionsTable = CDClientManager::Instance().GetTable<CDMissionsTable>(); auto* missionsTable = CDClientManager::Instance().GetTable<CDMissionsTable>();
@ -326,7 +327,7 @@ bool MissionComponent::LookForAchievements(eMissionTaskType type, int32_t value,
return entry.taskType == static_cast<unsigned>(type); return entry.taskType == static_cast<unsigned>(type);
}); });
auto any = false; std::vector<uint32_t> acceptedAchievements;
for (const auto& task : tasks) { for (const auto& task : tasks) {
if (GetMission(task.id) != nullptr) { if (GetMission(task.id) != nullptr) {
@ -380,14 +381,14 @@ bool MissionComponent::LookForAchievements(eMissionTaskType type, int32_t value,
instance->Accept(); instance->Accept();
any = true; acceptedAchievements.push_back(mission.id);
if (progress) { if (progress) {
instance->Progress(type, value, associate, targets, count); instance->Progress(type, value, associate, targets, count);
} }
} }
return any; return acceptedAchievements;
#endif #endif
} }
@ -499,7 +500,7 @@ bool MissionComponent::RequiresItem(const LOT lot) {
const auto required = LookForAchievements(eMissionTaskType::GATHER, lot, false); const auto required = LookForAchievements(eMissionTaskType::GATHER, lot, false);
return required; return !required.empty();
} }

View File

@ -141,7 +141,7 @@ public:
* @param count the number of values to progress by (differs by task type) * @param count the number of values to progress by (differs by task type)
* @return true if a achievement was accepted, false otherwise * @return true if a achievement was accepted, false otherwise
*/ */
bool LookForAchievements(eMissionTaskType type, int32_t value, bool progress = true, LWOOBJID associate = LWOOBJID_EMPTY, const std::string& targets = "", int32_t count = 1); const std::vector<uint32_t> LookForAchievements(eMissionTaskType type, int32_t value, bool progress = true, LWOOBJID associate = LWOOBJID_EMPTY, const std::string& targets = "", int32_t count = 1);
/** /**
* Checks if there's a mission active that requires the collection of the specified LOT * Checks if there's a mission active that requires the collection of the specified LOT

View File

@ -197,18 +197,17 @@ void RebuildComponent::Update(float deltaTime) {
DestroyableComponent* destComp = builder->GetComponent<DestroyableComponent>(); DestroyableComponent* destComp = builder->GetComponent<DestroyableComponent>();
if (!destComp) break; if (!destComp) break;
int newImagination = destComp->GetImagination();
++m_DrainedImagination; ++m_DrainedImagination;
--newImagination; const int32_t imaginationCostRemaining = m_TakeImagination - m_DrainedImagination;
const int32_t newImagination = destComp->GetImagination() - 1;
destComp->SetImagination(newImagination); destComp->SetImagination(newImagination);
Game::entityManager->SerializeEntity(builder); Game::entityManager->SerializeEntity(builder);
if (newImagination <= 0) { if (newImagination <= 0 && imaginationCostRemaining > 0) {
CancelRebuild(builder, eQuickBuildFailReason::OUT_OF_IMAGINATION, true); CancelRebuild(builder, eQuickBuildFailReason::OUT_OF_IMAGINATION, true);
break; break;
} }
} }
if (m_Timer >= m_CompleteTime && m_DrainedImagination >= m_TakeImagination) { if (m_Timer >= m_CompleteTime && m_DrainedImagination >= m_TakeImagination) {

View File

@ -285,7 +285,7 @@ private:
float m_CompleteTime = 0; float m_CompleteTime = 0;
/** /**
* The imagination that's deducted when compeleting the rebuild * The imagination that's deducted when completing the rebuild
*/ */
int m_TakeImagination = 0; int m_TakeImagination = 0;

View File

@ -5591,7 +5591,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
std::unique_ptr<sql::PreparedStatement> stmt(Database::Get()->CreatePreppedStmt("INSERT INTO ugc_modular_build (ugc_id, ldf_config, character_id) VALUES (?,?,?)")); std::unique_ptr<sql::PreparedStatement> stmt(Database::Get()->CreatePreppedStmt("INSERT INTO ugc_modular_build (ugc_id, ldf_config, character_id) VALUES (?,?,?)"));
stmt->setUInt64(1, newIdBig); stmt->setUInt64(1, newIdBig);
stmt->setString(2, GeneralUtils::UTF16ToWTF8(modules)); stmt->setString(2, GeneralUtils::UTF16ToWTF8(modules).c_str());
auto* pCharacter = character->GetCharacter(); auto* pCharacter = character->GetCharacter();
pCharacter ? stmt->setUInt(3, pCharacter->GetID()) : stmt->setNull(3, sql::DataType::BIGINT); pCharacter ? stmt->setUInt(3, pCharacter->GetID()) : stmt->setNull(3, sql::DataType::BIGINT);
stmt->execute(); stmt->execute();

View File

@ -359,8 +359,8 @@ void ClientPackets::HandleChatModerationRequest(const SystemAddress& sysAddr, Pa
idOfReceiver = characterIdFetch->id; idOfReceiver = characterIdFetch->id;
} }
} }
const auto& bffMap = user->GetIsBestFriendMap();
if (user->GetIsBestFriendMap().find(receiver) == user->GetIsBestFriendMap().end() && idOfReceiver != LWOOBJID_EMPTY) { if (bffMap.find(receiver) == bffMap.end() && idOfReceiver != LWOOBJID_EMPTY) {
auto bffInfo = Database::Get()->GetBestFriendStatus(entity->GetObjectID(), idOfReceiver); auto bffInfo = Database::Get()->GetBestFriendStatus(entity->GetObjectID(), idOfReceiver);
if (bffInfo) { if (bffInfo) {
@ -368,11 +368,9 @@ void ClientPackets::HandleChatModerationRequest(const SystemAddress& sysAddr, Pa
} }
if (isBestFriend) { if (isBestFriend) {
auto tmpBestFriendMap = user->GetIsBestFriendMap(); user->UpdateBestFriendValue(receiver, true);
tmpBestFriendMap[receiver] = true;
user->SetIsBestFriendMap(tmpBestFriendMap);
} }
} else if (user->GetIsBestFriendMap().find(receiver) != user->GetIsBestFriendMap().end()) { } else if (bffMap.find(receiver) != bffMap.end()) {
isBestFriend = true; isBestFriend = true;
} }
} }

View File

@ -18,6 +18,7 @@
#include "PerformanceManager.h" #include "PerformanceManager.h"
#include "Diagnostics.h" #include "Diagnostics.h"
#include "BinaryPathFinder.h" #include "BinaryPathFinder.h"
#include "dPlatforms.h"
//RakNet includes: //RakNet includes:
#include "RakNetDefines.h" #include "RakNetDefines.h"
@ -1284,12 +1285,14 @@ void WorldShutdownProcess(uint32_t zoneId) {
} }
void WorldShutdownSequence() { void WorldShutdownSequence() {
if (Game::shouldShutdown || worldShutdownSequenceComplete) { Game::shouldShutdown = true;
#ifndef DARKFLAME_PLATFORM_WIN32
if (Game::shouldShutdown || worldShutdownSequenceComplete)
#endif
{
return; return;
} }
Game::shouldShutdown = true;
LOG("Zone (%i) instance (%i) shutting down outside of main loop!", Game::server->GetZoneID(), instanceID); LOG("Zone (%i) instance (%i) shutting down outside of main loop!", Game::server->GetZoneID(), instanceID);
WorldShutdownProcess(Game::server->GetZoneID()); WorldShutdownProcess(Game::server->GetZoneID());
FinalizeShutdown(); FinalizeShutdown();
@ -1302,11 +1305,17 @@ void FinalizeShutdown() {
Metrics::Clear(); Metrics::Clear();
Database::Destroy("WorldServer"); Database::Destroy("WorldServer");
if (Game::chatFilter) delete Game::chatFilter; if (Game::chatFilter) delete Game::chatFilter;
Game::chatFilter = nullptr;
if (Game::zoneManager) delete Game::zoneManager; if (Game::zoneManager) delete Game::zoneManager;
Game::zoneManager = nullptr;
if (Game::server) delete Game::server; if (Game::server) delete Game::server;
Game::server = nullptr;
if (Game::config) delete Game::config; if (Game::config) delete Game::config;
Game::config = nullptr;
if (Game::entityManager) delete Game::entityManager; if (Game::entityManager) delete Game::entityManager;
Game::entityManager = nullptr;
if (Game::logger) delete Game::logger; if (Game::logger) delete Game::logger;
Game::logger = nullptr;
worldShutdownSequenceComplete = true; worldShutdownSequenceComplete = true;

View File

@ -79,8 +79,6 @@ dZoneManager::~dZoneManager() {
delete p.second; delete p.second;
p.second = nullptr; p.second = nullptr;
} }
m_Spawners.erase(p.first);
} }
if (m_WorldConfig) delete m_WorldConfig; if (m_WorldConfig) delete m_WorldConfig;
} }