From a19bead2680ee6d9d834aabe027e3f074e0d8ec9 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 29 Oct 2023 22:40:06 -0400 Subject: [PATCH 01/11] Fix edge case where leaderboard viewing would cause unhandled exception --- dGame/LeaderboardManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dGame/LeaderboardManager.cpp b/dGame/LeaderboardManager.cpp index b7083ea8..ce4643d0 100644 --- a/dGame/LeaderboardManager.cpp +++ b/dGame/LeaderboardManager.cpp @@ -193,7 +193,7 @@ void Leaderboard::SetupLeaderboard(bool weekly, uint32_t resultStart, uint32_t r SELECT leaderboardsRanked.*, character_id, UNIX_TIMESTAMP(last_played) as lastPlayed, leaderboardsRanked.name, leaderboardsRanked.ranking FROM leaderboardsRanked, myStanding, lowestRanking WHERE leaderboardsRanked.ranking BETWEEN - LEAST(GREATEST(CAST(myRank AS SIGNED) - 5, %i), lowestRanking.lowestRank - 9) + LEAST(GREATEST(CAST(myRank AS SIGNED) - 5, %i), CAST(lowestRanking.lowestRank AS SIGNED) - 9) AND LEAST(GREATEST(myRank + 5, %i), lowestRanking.lowestRank) ORDER BY ranking ASC; From fddf99946f0ddee73b661fb464edef2ab0b1bbc0 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Thu, 28 Dec 2023 19:11:19 -0600 Subject: [PATCH 02/11] chore: make scripted activity derived from activity (#1363) * chore: make scripted activity derived from activity this paves the way for other component being properly derived from the activity component * use a dirty flag instead * address feedback --- dGame/Entity.cpp | 4 +- ...ityComponent.cpp => ActivityComponent.cpp} | 125 +++--- dGame/dComponents/ActivityComponent.h | 371 +++++++++++++++++ dGame/dComponents/CMakeLists.txt | 4 +- dGame/dComponents/ScriptedActivityComponent.h | 380 +----------------- 5 files changed, 429 insertions(+), 455 deletions(-) rename dGame/dComponents/{ScriptedActivityComponent.cpp => ActivityComponent.cpp} (81%) create mode 100644 dGame/dComponents/ActivityComponent.h diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 0caeada8..6f8f65e9 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -605,8 +605,8 @@ void Entity::Initialize() { } // Scripted activity component - int scriptedActivityID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SCRIPTED_ACTIVITY); - if ((scriptedActivityID > 0)) { + int scriptedActivityID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SCRIPTED_ACTIVITY, -1); + if ((scriptedActivityID != -1)) { AddComponent(scriptedActivityID); } diff --git a/dGame/dComponents/ScriptedActivityComponent.cpp b/dGame/dComponents/ActivityComponent.cpp similarity index 81% rename from dGame/dComponents/ScriptedActivityComponent.cpp rename to dGame/dComponents/ActivityComponent.cpp index 8bcddd05..59637d59 100644 --- a/dGame/dComponents/ScriptedActivityComponent.cpp +++ b/dGame/dComponents/ActivityComponent.cpp @@ -1,4 +1,4 @@ -#include "ScriptedActivityComponent.h" +#include "ActivityComponent.h" #include "GameMessages.h" #include "CDClientManager.h" #include "MissionComponent.h" @@ -29,8 +29,9 @@ #include "CDActivitiesTable.h" #include "LeaderboardManager.h" -ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activityID) : Component(parent) { - m_ActivityID = activityID; +ActivityComponent::ActivityComponent(Entity* parent, int32_t activityID) : Component(parent) { + if (activityID > 0) m_ActivityID = activityID; + else m_ActivityID = parent->GetVar(u"activityID"); CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable(); std::vector activities = activitiesTable->Query([=](CDActivities entry) {return (entry.ActivityID == m_ActivityID); }); @@ -40,15 +41,10 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit m_ActivityInfo.minTeamSize = 1; m_ActivityInfo.minTeams = 1; } - - const auto& transferOverride = parent->GetVar(u"transferZoneID"); - if (!transferOverride.empty()) { - m_ActivityInfo.instanceMapID = std::stoi(GeneralUtils::UTF16ToWTF8(transferOverride)); - - // TODO: LU devs made me do it (for some reason cannon cove instancer is marked to go to GF survival) - // NOTE: 1301 is GF survival - if (m_ActivityInfo.instanceMapID == 1301) { - m_ActivityInfo.instanceMapID = 1302; + if (m_ActivityInfo.instanceMapID == -1) { + const auto& transferOverride = parent->GetVarAsString(u"transferZoneID"); + if (!transferOverride.empty()) { + GeneralUtils::TryParse(transferOverride, m_ActivityInfo.instanceMapID); } } } @@ -79,30 +75,28 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit } } -ScriptedActivityComponent::~ScriptedActivityComponent() -= default; - -void ScriptedActivityComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(true); - outBitStream->Write(m_ActivityPlayers.size()); - - if (!m_ActivityPlayers.empty()) { - for (const auto& activityPlayer : m_ActivityPlayers) { - - outBitStream->Write(activityPlayer->playerID); - for (const auto& activityValue : activityPlayer->values) { - outBitStream->Write(activityValue); +void ActivityComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { + outBitStream->Write(m_DirtyActivityInfo); + if (m_DirtyActivityInfo) { + outBitStream->Write(m_ActivityPlayers.size()); + if (!m_ActivityPlayers.empty()) { + for (const auto& activityPlayer : m_ActivityPlayers) { + outBitStream->Write(activityPlayer->playerID); + for (const auto& activityValue : activityPlayer->values) { + outBitStream->Write(activityValue); + } } } + if (!bIsInitialUpdate) m_DirtyActivityInfo = false; } } -void ScriptedActivityComponent::ReloadConfig() { +void ActivityComponent::ReloadConfig() { CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable(); std::vector activities = activitiesTable->Query([=](CDActivities entry) {return (entry.ActivityID == m_ActivityID); }); for (auto activity : activities) { auto mapID = m_ActivityInfo.instanceMapID; - if ((mapID == 1203 || mapID == 1261 || mapID == 1303 || mapID == 1403) && Game::config->GetValue("solo_racing") == "1") { + if (static_cast(activity.leaderboardType) == Leaderboard::Type::Racing && Game::config->GetValue("solo_racing") == "1") { m_ActivityInfo.minTeamSize = 1; m_ActivityInfo.minTeams = 1; } else { @@ -112,11 +106,7 @@ void ScriptedActivityComponent::ReloadConfig() { } } -void ScriptedActivityComponent::HandleMessageBoxResponse(Entity* player, const std::string& id) { - if (m_ActivityInfo.ActivityID == 103) { - return; - } - +void ActivityComponent::HandleMessageBoxResponse(Entity* player, const std::string& id) { if (id == "LobbyExit") { PlayerLeave(player->GetObjectID()); } else if (id == "PlayButton") { @@ -124,11 +114,7 @@ void ScriptedActivityComponent::HandleMessageBoxResponse(Entity* player, const s } } -void ScriptedActivityComponent::PlayerJoin(Entity* player) { - if (m_ActivityInfo.ActivityID == 103 || PlayerIsInQueue(player) || !IsValidActivity(player)) { - return; - } - +void ActivityComponent::PlayerJoin(Entity* player) { // If we have a lobby, queue the player and allow others to join, otherwise spin up an instance on the spot if (HasLobby()) { PlayerJoinLobby(player); @@ -136,11 +122,9 @@ void ScriptedActivityComponent::PlayerJoin(Entity* player) { auto* instance = NewInstance(); instance->AddParticipant(player); } - - Game::entityManager->SerializeEntity(m_Parent); } -void ScriptedActivityComponent::PlayerJoinLobby(Entity* player) { +void ActivityComponent::PlayerJoinLobby(Entity* player) { if (!m_Parent->HasComponent(eReplicaComponentType::QUICK_BUILD)) GameMessages::SendMatchResponse(player, player->GetSystemAddress(), 0); // tell the client they joined a lobby LobbyPlayer* newLobbyPlayer = new LobbyPlayer(); @@ -189,7 +173,7 @@ void ScriptedActivityComponent::PlayerJoinLobby(Entity* player) { } } -void ScriptedActivityComponent::PlayerLeave(LWOOBJID playerID) { +void ActivityComponent::PlayerLeave(LWOOBJID playerID) { // Removes the player from a lobby and notifies the others, not applicable for non-lobby instances for (Lobby* lobby : m_Queue) { @@ -214,7 +198,7 @@ void ScriptedActivityComponent::PlayerLeave(LWOOBJID playerID) { } } -void ScriptedActivityComponent::Update(float deltaTime) { +void ActivityComponent::Update(float deltaTime) { std::vector lobbiesToRemove{}; // Ticks all the lobbies, not applicable for non-instance activities for (Lobby* lobby : m_Queue) { @@ -287,7 +271,7 @@ void ScriptedActivityComponent::Update(float deltaTime) { } } -void ScriptedActivityComponent::RemoveLobby(Lobby* lobby) { +void ActivityComponent::RemoveLobby(Lobby* lobby) { for (int i = 0; i < m_Queue.size(); ++i) { if (m_Queue[i] == lobby) { m_Queue.erase(m_Queue.begin() + i); @@ -296,29 +280,12 @@ void ScriptedActivityComponent::RemoveLobby(Lobby* lobby) { } } -bool ScriptedActivityComponent::HasLobby() const { +bool ActivityComponent::HasLobby() const { // If the player is not in the world he has to be, create a lobby for the transfer return m_ActivityInfo.instanceMapID != UINT_MAX && m_ActivityInfo.instanceMapID != Game::server->GetZoneID(); } -bool ScriptedActivityComponent::IsValidActivity(Entity* player) { - // Makes it so that scripted activities with an unimplemented map cannot be joined - /*if (player->GetGMLevel() < eGameMasterLevel::DEVELOPER && (m_ActivityInfo.instanceMapID == 1302 || m_ActivityInfo.instanceMapID == 1301)) { - if (m_Parent->GetLOT() == 4860) { - auto* missionComponent = player->GetComponent(); - missionComponent->CompleteMission(229); - } - - ChatPackets::SendSystemMessage(player->GetSystemAddress(), u"Sorry, this activity is not ready."); - static_cast(player)->SendToZone(Game::zoneManager->GetZone()->GetWorldID()); // Gets them out of this stuck state - - return false; - }*/ - - return true; -} - -bool ScriptedActivityComponent::PlayerIsInQueue(Entity* player) { +bool ActivityComponent::PlayerIsInQueue(Entity* player) { for (Lobby* lobby : m_Queue) { for (LobbyPlayer* lobbyPlayer : lobby->players) { if (player->GetObjectID() == lobbyPlayer->entityID) return true; @@ -328,7 +295,7 @@ bool ScriptedActivityComponent::PlayerIsInQueue(Entity* player) { return false; } -bool ScriptedActivityComponent::IsPlayedBy(Entity* player) const { +bool ActivityComponent::IsPlayedBy(Entity* player) const { for (const auto* instance : this->m_Instances) { for (const auto* instancePlayer : instance->GetParticipants()) { if (instancePlayer != nullptr && instancePlayer->GetObjectID() == player->GetObjectID()) @@ -339,7 +306,7 @@ bool ScriptedActivityComponent::IsPlayedBy(Entity* player) const { return false; } -bool ScriptedActivityComponent::IsPlayedBy(LWOOBJID playerID) const { +bool ActivityComponent::IsPlayedBy(LWOOBJID playerID) const { for (const auto* instance : this->m_Instances) { for (const auto* instancePlayer : instance->GetParticipants()) { if (instancePlayer != nullptr && instancePlayer->GetObjectID() == playerID) @@ -350,7 +317,7 @@ bool ScriptedActivityComponent::IsPlayedBy(LWOOBJID playerID) const { return false; } -bool ScriptedActivityComponent::TakeCost(Entity* player) const { +bool ActivityComponent::TakeCost(Entity* player) const { if (m_ActivityInfo.optionalCostLOT <= 0 || m_ActivityInfo.optionalCostCount <= 0) return true; @@ -366,7 +333,7 @@ bool ScriptedActivityComponent::TakeCost(Entity* player) const { return true; } -void ScriptedActivityComponent::PlayerReady(Entity* player, bool bReady) { +void ActivityComponent::PlayerReady(Entity* player, bool bReady) { for (Lobby* lobby : m_Queue) { for (LobbyPlayer* lobbyPlayer : lobby->players) { if (lobbyPlayer->entityID == player->GetObjectID()) { @@ -389,13 +356,13 @@ void ScriptedActivityComponent::PlayerReady(Entity* player, bool bReady) { } } -ActivityInstance* ScriptedActivityComponent::NewInstance() { +ActivityInstance* ActivityComponent::NewInstance() { auto* instance = new ActivityInstance(m_Parent, m_ActivityInfo); m_Instances.push_back(instance); return instance; } -void ScriptedActivityComponent::LoadPlayersIntoInstance(ActivityInstance* instance, const std::vector& lobby) const { +void ActivityComponent::LoadPlayersIntoInstance(ActivityInstance* instance, const std::vector& lobby) const { for (LobbyPlayer* player : lobby) { auto* entity = player->GetEntity(); if (entity == nullptr || !TakeCost(entity)) { @@ -406,11 +373,11 @@ void ScriptedActivityComponent::LoadPlayersIntoInstance(ActivityInstance* instan } } -const std::vector& ScriptedActivityComponent::GetInstances() const { +const std::vector& ActivityComponent::GetInstances() const { return m_Instances; } -ActivityInstance* ScriptedActivityComponent::GetInstance(const LWOOBJID playerID) { +ActivityInstance* ActivityComponent::GetInstance(const LWOOBJID playerID) { for (const auto* instance : GetInstances()) { for (const auto* participant : instance->GetParticipants()) { if (participant->GetObjectID() == playerID) @@ -421,14 +388,14 @@ ActivityInstance* ScriptedActivityComponent::GetInstance(const LWOOBJID playerID return nullptr; } -void ScriptedActivityComponent::ClearInstances() { +void ActivityComponent::ClearInstances() { for (ActivityInstance* instance : m_Instances) { delete instance; } m_Instances.clear(); } -ActivityPlayer* ScriptedActivityComponent::GetActivityPlayerData(LWOOBJID playerID) { +ActivityPlayer* ActivityComponent::GetActivityPlayerData(LWOOBJID playerID) { for (auto* activityData : m_ActivityPlayers) { if (activityData->playerID == playerID) { return activityData; @@ -438,13 +405,14 @@ ActivityPlayer* ScriptedActivityComponent::GetActivityPlayerData(LWOOBJID player return nullptr; } -void ScriptedActivityComponent::RemoveActivityPlayerData(LWOOBJID playerID) { +void ActivityComponent::RemoveActivityPlayerData(LWOOBJID playerID) { for (size_t i = 0; i < m_ActivityPlayers.size(); i++) { if (m_ActivityPlayers[i]->playerID == playerID) { delete m_ActivityPlayers[i]; m_ActivityPlayers[i] = nullptr; m_ActivityPlayers.erase(m_ActivityPlayers.begin() + i); + m_DirtyActivityInfo = true; Game::entityManager->SerializeEntity(m_Parent); return; @@ -452,18 +420,19 @@ void ScriptedActivityComponent::RemoveActivityPlayerData(LWOOBJID playerID) { } } -ActivityPlayer* ScriptedActivityComponent::AddActivityPlayerData(LWOOBJID playerID) { +ActivityPlayer* ActivityComponent::AddActivityPlayerData(LWOOBJID playerID) { auto* data = GetActivityPlayerData(playerID); if (data != nullptr) return data; m_ActivityPlayers.push_back(new ActivityPlayer{ playerID, {} }); + m_DirtyActivityInfo = true; Game::entityManager->SerializeEntity(m_Parent); return GetActivityPlayerData(playerID); } -float_t ScriptedActivityComponent::GetActivityValue(LWOOBJID playerID, uint32_t index) { +float_t ActivityComponent::GetActivityValue(LWOOBJID playerID, uint32_t index) { auto value = -1.0f; auto* data = GetActivityPlayerData(playerID); @@ -474,16 +443,16 @@ float_t ScriptedActivityComponent::GetActivityValue(LWOOBJID playerID, uint32_t return value; } -void ScriptedActivityComponent::SetActivityValue(LWOOBJID playerID, uint32_t index, float_t value) { +void ActivityComponent::SetActivityValue(LWOOBJID playerID, uint32_t index, float_t value) { auto* data = AddActivityPlayerData(playerID); if (data != nullptr) { data->values[std::min(index, static_cast(9))] = value; } - + m_DirtyActivityInfo = true; Game::entityManager->SerializeEntity(m_Parent); } -void ScriptedActivityComponent::PlayerRemove(LWOOBJID playerID) { +void ActivityComponent::PlayerRemove(LWOOBJID playerID) { for (auto* instance : GetInstances()) { auto participants = instance->GetParticipants(); for (const auto* participant : participants) { diff --git a/dGame/dComponents/ActivityComponent.h b/dGame/dComponents/ActivityComponent.h new file mode 100644 index 00000000..96dbd5fb --- /dev/null +++ b/dGame/dComponents/ActivityComponent.h @@ -0,0 +1,371 @@ +#ifndef ACTIVITYCOMPONENT_H +#define ACTIVITYCOMPONENT_H + +#include "CDClientManager.h" +#include "BitStream.h" +#include "Entity.h" +#include "Component.h" +#include "eReplicaComponentType.h" + +#include "CDActivitiesTable.h" + + /** + * Represents an instance of an activity, having participants and score + */ +class ActivityInstance { +public: + ActivityInstance(Entity* parent, CDActivities activityInfo) { m_Parent = parent; m_ActivityInfo = activityInfo; }; + //~ActivityInstance(); + + /** + * Adds an entity to this activity + * @param participant the entity to add + */ + void AddParticipant(Entity* participant); + + /** + * Removes all the participants from this activity + */ + void ClearParticipants() { m_Participants.clear(); }; + + /** + * Starts the instance world for this activity and sends all participants there + */ + void StartZone(); + + /** + * Gives the rewards for completing this activity to some participant + * @param participant the participant to give rewards to + */ + void RewardParticipant(Entity* participant); + + /** + * Removes a participant from this activity + * @param participant the participant to remove + */ + void RemoveParticipant(const Entity* participant); + + /** + * Returns all the participants of this activity + * @return all the participants of this activity + */ + std::vector GetParticipants() const; + + /** + * Currently unused + */ + uint32_t GetScore() const; + + /** + * Currently unused + */ + void SetScore(uint32_t score); +private: + + /** + * Currently unused + */ + uint32_t score = 0; + + /** + * The instance ID of this activity + */ + uint32_t m_NextZoneCloneID = 0; + + /** + * The database information for this activity + */ + CDActivities m_ActivityInfo; + + /** + * The entity that owns this activity (the entity that has the ScriptedActivityComponent) + */ + Entity* m_Parent; + + /** + * All the participants of this activity + */ + std::vector m_Participants; +}; + +/** + * Represents an entity in a lobby + */ +struct LobbyPlayer { + + /** + * The ID of the entity that is in the lobby + */ + LWOOBJID entityID; + + /** + * Whether or not the entity is ready + */ + bool ready = false; + + /** + * Returns the entity that is in the lobby + * @return the entity that is in the lobby + */ + Entity* GetEntity() const; +}; + +/** + * Represents a lobby of players with a timer until it should start the activity + */ +struct Lobby { + + /** + * The lobby of players + */ + std::vector players; + + /** + * The timer that determines when the activity should start + */ + float timer; +}; + +/** + * Represents the score for the player in an activity, one index might represent score, another one time, etc. + */ +struct ActivityPlayer { + + /** + * The entity that the score is tracked for + */ + LWOOBJID playerID; + + /** + * The list of score for this entity + */ + float values[10]; +}; + +/** + * Welcome to the absolute behemoth that is the scripted activity component. I have now clue how this was managed in + * live but I figure somewhat similarly and it's terrible. In a nutshell, this components handles any activity that + * can be done in the game from quick builds to boss fights to races. On top of that, this component handles instancing + * and lobbying. + */ +class ActivityComponent : public Component { +public: + ActivityComponent(Entity* parent, int32_t activityID); + + void Update(float deltaTime) override; + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + + /** + * Makes some entity join the minigame, if it's a lobbied one, the entity will be placed in the lobby + * @param player the entity to join the game + */ + void PlayerJoin(Entity* player); + + /** + * Makes an entity join the lobby for this minigame, if it exists + * @param player the entity to join + */ + void PlayerJoinLobby(Entity* player); + + /** + * Makes the player leave the lobby + * @param playerID the entity to leave the lobby + */ + void PlayerLeave(LWOOBJID playerID); + + /** + * Removes the entity from the minigame (and its score) + * @param playerID the entity to remove from the minigame + */ + void PlayerRemove(LWOOBJID playerID); + + /** + * Adds all the players to an instance of some activity + * @param instance the instance to load the players into + * @param lobby the players to load into the instance + */ + void LoadPlayersIntoInstance(ActivityInstance* instance, const std::vector& lobby) const; + + /** + * Removes a lobby from the activity manager + * @param lobby the lobby to remove + */ + void RemoveLobby(Lobby* lobby); + + /** + * Marks a player as (un)ready in a lobby + * @param player the entity to mark + * @param bReady true if the entity is ready, false otherwise + */ + void PlayerReady(Entity* player, bool bReady); + + /** + * Returns the ID of this activity + * @return the ID of this activity + */ + int GetActivityID() { return m_ActivityInfo.ActivityID; } + + /** + * Returns if this activity has a lobby, e.g. if it needs to instance players to some other map + * @return true if this activity has a lobby, false otherwise + */ + bool HasLobby() const; + + /** + * Checks if a player is currently waiting in a lobby + * @param player the entity to check for + * @return true if the entity is waiting in a lobby, false otherwise + */ + bool PlayerIsInQueue(Entity* player); + + /** + * Checks if an entity is currently playing this activity + * @param player the entity to check + * @return true if the entity is playing this lobby, false otherwise + */ + bool IsPlayedBy(Entity* player) const; + + /** + * Checks if an entity is currently playing this activity + * @param playerID the entity to check + * @return true if the entity is playing this lobby, false otherwise + */ + bool IsPlayedBy(LWOOBJID playerID) const; + + /** + * Removes the cost of the activity (e.g. green imaginate) for the entity that plays this activity + * @param player the entity to take cost for + * @return true if the cost was successfully deducted, false otherwise + */ + bool TakeCost(Entity* player) const; + + /** + * Handles any response from a player clicking on a lobby / instance menu + * @param player the entity that clicked + * @param id the message that was passed + */ + void HandleMessageBoxResponse(Entity* player, const std::string& id); + + /** + * Creates a new instance for this activity + * @return a new instance for this activity + */ + ActivityInstance* NewInstance(); + + /** + * Returns all the currently active instances of this activity + * @return all the currently active instances of this activity + */ + const std::vector& GetInstances() const; + + /** + * Returns the instance that some entity is currently playing in + * @param playerID the entity to check for + * @return if any, the instance that the entity is currently in + */ + ActivityInstance* GetInstance(const LWOOBJID playerID); + + /** + * @brief Reloads the config settings for this component + * + */ + void ReloadConfig(); + + /** + * Removes all the instances + */ + void ClearInstances(); + + /** + * Returns all the score for the players that are currently playing this activity + * @return + */ + std::vector GetActivityPlayers() { return m_ActivityPlayers; }; + + /** + * Returns activity data for a specific entity (e.g. score and such). + * @param playerID the entity to get data for + * @return the activity data (score) for the passed player in this activity, if it exists + */ + ActivityPlayer* GetActivityPlayerData(LWOOBJID playerID); + + /** + * Sets some score value for an entity + * @param playerID the entity to set score for + * @param index the score index to set + * @param value the value to set in for that index + */ + void SetActivityValue(LWOOBJID playerID, uint32_t index, float_t value); + + /** + * Returns activity score for the passed parameters + * @param playerID the entity to get score for + * @param index the index to get score for + * @return activity score for the passed parameters + */ + float_t GetActivityValue(LWOOBJID playerID, uint32_t index); + + /** + * Removes activity score tracking for some entity + * @param playerID the entity to remove score for + */ + void RemoveActivityPlayerData(LWOOBJID playerID); + + /** + * Adds activity score tracking for some entity + * @param playerID the entity to add the activity score for + * @return the created entry + */ + ActivityPlayer* AddActivityPlayerData(LWOOBJID playerID); + + /** + * Sets the mapID that this activity points to + * @param mapID the map ID to set + */ + void SetInstanceMapID(uint32_t mapID) { m_ActivityInfo.instanceMapID = mapID; }; + + /** + * Returns the LMI that this activity points to for a team size + * @param teamSize the team size to get the LMI for + * @return the LMI that this activity points to for a team size + */ + uint32_t GetLootMatrixForTeamSize(uint32_t teamSize) { return m_ActivityLootMatrices[teamSize]; } +private: + + /** + * The database information for this activity + */ + CDActivities m_ActivityInfo; + + /** + * All the active instances of this activity + */ + std::vector m_Instances; + + /** + * The current lobbies for this activity + */ + std::vector m_Queue; + + /** + * All the activity score for the players in this activity + */ + std::vector m_ActivityPlayers; + + /** + * LMIs for team sizes + */ + std::unordered_map m_ActivityLootMatrices; + + /** + * The activity id + */ + int32_t m_ActivityID; + + /** + * If the Activity info is dirty + */ + bool m_DirtyActivityInfo = true; +}; + +#endif // ACTIVITYCOMPONENT_H diff --git a/dGame/dComponents/CMakeLists.txt b/dGame/dComponents/CMakeLists.txt index fa0aea35..04358cbe 100644 --- a/dGame/dComponents/CMakeLists.txt +++ b/dGame/dComponents/CMakeLists.txt @@ -1,4 +1,5 @@ -set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp" +set(DGAME_DCOMPONENTS_SOURCES "ActivityComponent.cpp" + "BaseCombatAIComponent.cpp" "BouncerComponent.cpp" "BuffComponent.cpp" "BuildBorderComponent.cpp" @@ -36,7 +37,6 @@ set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp" "RigidbodyPhantomPhysicsComponent.cpp" "MultiZoneEntranceComponent.cpp" "RocketLaunchpadControlComponent.cpp" - "ScriptedActivityComponent.cpp" "ShootingGalleryComponent.cpp" "SimplePhysicsComponent.cpp" "SkillComponent.cpp" diff --git a/dGame/dComponents/ScriptedActivityComponent.h b/dGame/dComponents/ScriptedActivityComponent.h index 3bc8114f..79a9593d 100644 --- a/dGame/dComponents/ScriptedActivityComponent.h +++ b/dGame/dComponents/ScriptedActivityComponent.h @@ -1,381 +1,15 @@ -/* - * Darkflame Universe - * Copyright 2018 - */ +#ifndef __SCRIPTEDACTIVITYCOMPONENT__H__ +#define __SCRIPTEDACTIVITYCOMPONENT__H__ -#include "CDClientManager.h" - -#ifndef SCRIPTEDACTIVITYCOMPONENT_H -#define SCRIPTEDACTIVITYCOMPONENT_H - -#include "BitStream.h" -#include "Entity.h" -#include "Component.h" +#include "ActivityComponent.h" #include "eReplicaComponentType.h" -#include "CDActivitiesTable.h" +class Entity; - /** - * Represents an instance of an activity, having participants and score - */ -class ActivityInstance { -public: - ActivityInstance(Entity* parent, CDActivities activityInfo) { m_Parent = parent; m_ActivityInfo = activityInfo; }; - //~ActivityInstance(); - - /** - * Adds an entity to this activity - * @param participant the entity to add - */ - void AddParticipant(Entity* participant); - - /** - * Removes all the participants from this activity - */ - void ClearParticipants() { m_Participants.clear(); }; - - /** - * Starts the instance world for this activity and sends all participants there - */ - void StartZone(); - - /** - * Gives the rewards for completing this activity to some participant - * @param participant the participant to give rewards to - */ - void RewardParticipant(Entity* participant); - - /** - * Removes a participant from this activity - * @param participant the participant to remove - */ - void RemoveParticipant(const Entity* participant); - - /** - * Returns all the participants of this activity - * @return all the participants of this activity - */ - std::vector GetParticipants() const; - - /** - * Currently unused - */ - uint32_t GetScore() const; - - /** - * Currently unused - */ - void SetScore(uint32_t score); -private: - - /** - * Currently unused - */ - uint32_t score = 0; - - /** - * The instance ID of this activity - */ - uint32_t m_NextZoneCloneID = 0; - - /** - * The database information for this activity - */ - CDActivities m_ActivityInfo; - - /** - * The entity that owns this activity (the entity that has the ScriptedActivityComponent) - */ - Entity* m_Parent; - - /** - * All the participants of this activity - */ - std::vector m_Participants; -}; - -/** - * Represents an entity in a lobby - */ -struct LobbyPlayer { - - /** - * The ID of the entity that is in the lobby - */ - LWOOBJID entityID; - - /** - * Whether or not the entity is ready - */ - bool ready = false; - - /** - * Returns the entity that is in the lobby - * @return the entity that is in the lobby - */ - Entity* GetEntity() const; -}; - -/** - * Represents a lobby of players with a timer until it should start the activity - */ -struct Lobby { - - /** - * The lobby of players - */ - std::vector players; - - /** - * The timer that determines when the activity should start - */ - float timer; -}; - -/** - * Represents the score for the player in an activity, one index might represent score, another one time, etc. - */ -struct ActivityPlayer { - - /** - * The entity that the score is tracked for - */ - LWOOBJID playerID; - - /** - * The list of score for this entity - */ - float values[10]; -}; - -/** - * Welcome to the absolute behemoth that is the scripted activity component. I have now clue how this was managed in - * live but I figure somewhat similarly and it's terrible. In a nutshell, this components handles any activity that - * can be done in the game from quick builds to boss fights to races. On top of that, this component handles instancing - * and lobbying. - */ -class ScriptedActivityComponent : public Component { +class ScriptedActivityComponent : public ActivityComponent { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPTED_ACTIVITY; - - ScriptedActivityComponent(Entity* parent, int activityID); - ~ScriptedActivityComponent() override; - - void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; - - /** - * Makes some entity join the minigame, if it's a lobbied one, the entity will be placed in the lobby - * @param player the entity to join the game - */ - void PlayerJoin(Entity* player); - - /** - * Makes an entity join the lobby for this minigame, if it exists - * @param player the entity to join - */ - void PlayerJoinLobby(Entity* player); - - /** - * Makes the player leave the lobby - * @param playerID the entity to leave the lobby - */ - void PlayerLeave(LWOOBJID playerID); - - /** - * Removes the entity from the minigame (and its score) - * @param playerID the entity to remove from the minigame - */ - void PlayerRemove(LWOOBJID playerID); - - /** - * Adds all the players to an instance of some activity - * @param instance the instance to load the players into - * @param lobby the players to load into the instance - */ - void LoadPlayersIntoInstance(ActivityInstance* instance, const std::vector& lobby) const; - - /** - * Removes a lobby from the activity manager - * @param lobby the lobby to remove - */ - void RemoveLobby(Lobby* lobby); - - /** - * Marks a player as (un)ready in a lobby - * @param player the entity to mark - * @param bReady true if the entity is ready, false otherwise - */ - void PlayerReady(Entity* player, bool bReady); - - /** - * Returns the ID of this activity - * @return the ID of this activity - */ - int GetActivityID() { return m_ActivityInfo.ActivityID; } - - /** - * Returns if this activity has a lobby, e.g. if it needs to instance players to some other map - * @return true if this activity has a lobby, false otherwise - */ - bool HasLobby() const; - - /** - * Checks if a player is currently waiting in a lobby - * @param player the entity to check for - * @return true if the entity is waiting in a lobby, false otherwise - */ - bool PlayerIsInQueue(Entity* player); - - /** - * Checks if an entity is currently playing this activity - * @param player the entity to check - * @return true if the entity is playing this lobby, false otherwise - */ - bool IsPlayedBy(Entity* player) const; - - /** - * Checks if an entity is currently playing this activity - * @param playerID the entity to check - * @return true if the entity is playing this lobby, false otherwise - */ - bool IsPlayedBy(LWOOBJID playerID) const; - - /** - * Legacy: used to check for unimplemented maps, gladly, this now just returns true :) - */ - bool IsValidActivity(Entity* player); - - /** - * Removes the cost of the activity (e.g. green imaginate) for the entity that plays this activity - * @param player the entity to take cost for - * @return true if the cost was successfully deducted, false otherwise - */ - bool TakeCost(Entity* player) const; - - /** - * Handles any response from a player clicking on a lobby / instance menu - * @param player the entity that clicked - * @param id the message that was passed - */ - void HandleMessageBoxResponse(Entity* player, const std::string& id); - - /** - * Creates a new instance for this activity - * @return a new instance for this activity - */ - ActivityInstance* NewInstance(); - - /** - * Returns all the currently active instances of this activity - * @return all the currently active instances of this activity - */ - const std::vector& GetInstances() const; - - /** - * Returns the instance that some entity is currently playing in - * @param playerID the entity to check for - * @return if any, the instance that the entity is currently in - */ - ActivityInstance* GetInstance(const LWOOBJID playerID); - - /** - * @brief Reloads the config settings for this component - * - */ - void ReloadConfig(); - - /** - * Removes all the instances - */ - void ClearInstances(); - - /** - * Returns all the score for the players that are currently playing this activity - * @return - */ - std::vector GetActivityPlayers() { return m_ActivityPlayers; }; - - /** - * Returns activity data for a specific entity (e.g. score and such). - * @param playerID the entity to get data for - * @return the activity data (score) for the passed player in this activity, if it exists - */ - ActivityPlayer* GetActivityPlayerData(LWOOBJID playerID); - - /** - * Sets some score value for an entity - * @param playerID the entity to set score for - * @param index the score index to set - * @param value the value to set in for that index - */ - void SetActivityValue(LWOOBJID playerID, uint32_t index, float_t value); - - /** - * Returns activity score for the passed parameters - * @param playerID the entity to get score for - * @param index the index to get score for - * @return activity score for the passed parameters - */ - float_t GetActivityValue(LWOOBJID playerID, uint32_t index); - - /** - * Removes activity score tracking for some entity - * @param playerID the entity to remove score for - */ - void RemoveActivityPlayerData(LWOOBJID playerID); - - /** - * Adds activity score tracking for some entity - * @param playerID the entity to add the activity score for - * @return the created entry - */ - ActivityPlayer* AddActivityPlayerData(LWOOBJID playerID); - - /** - * Sets the mapID that this activity points to - * @param mapID the map ID to set - */ - void SetInstanceMapID(uint32_t mapID) { m_ActivityInfo.instanceMapID = mapID; }; - - /** - * Returns the LMI that this activity points to for a team size - * @param teamSize the team size to get the LMI for - * @return the LMI that this activity points to for a team size - */ - uint32_t GetLootMatrixForTeamSize(uint32_t teamSize) { return m_ActivityLootMatrices[teamSize]; } -private: - - /** - * The database information for this activity - */ - CDActivities m_ActivityInfo; - - /** - * All the active instances of this activity - */ - std::vector m_Instances; - - /** - * The current lobbies for this activity - */ - std::vector m_Queue; - - /** - * All the activity score for the players in this activity - */ - std::vector m_ActivityPlayers; - - /** - * LMIs for team sizes - */ - std::unordered_map m_ActivityLootMatrices; - - /** - * The activity id - * - */ - int32_t m_ActivityID; + ScriptedActivityComponent(Entity* parent, int activityID) : ActivityComponent(parent, activityID){}; }; -#endif // SCRIPTEDACTIVITYCOMPONENT_H +#endif //!__SCRIPTEDACTIVITYCOMPONENT__H__ From 15954413aea60b9cebf30b2ae710e76307cf15a6 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Thu, 28 Dec 2023 22:24:30 -0600 Subject: [PATCH 03/11] chore: rename rebuild to quickbuild (#1364) * rename rebuild to quickbuild * fix includes --- dCommon/dEnums/eQuickBuildState.h | 15 ++ dCommon/dEnums/eRebuildState.h | 15 -- dGame/Entity.cpp | 50 +++--- dGame/Entity.h | 2 +- dGame/dBehaviors/AreaOfEffectBehavior.cpp | 2 +- dGame/dBehaviors/BehaviorContext.cpp | 6 +- dGame/dBehaviors/SpawnBehavior.cpp | 8 +- dGame/dBehaviors/TacArcBehavior.cpp | 2 +- dGame/dComponents/BaseCombatAIComponent.cpp | 10 +- dGame/dComponents/CMakeLists.txt | 2 +- dGame/dComponents/CharacterComponent.cpp | 2 +- dGame/dComponents/CharacterComponent.h | 2 +- dGame/dComponents/DestroyableComponent.cpp | 6 +- dGame/dComponents/MovingPlatformComponent.cpp | 4 +- dGame/dComponents/MovingPlatformComponent.h | 4 +- ...dComponent.cpp => QuickBuildComponent.cpp} | 170 +++++++++--------- ...buildComponent.h => QuickBuildComponent.h} | 162 ++++++++--------- dGame/dComponents/RailActivatorComponent.cpp | 16 +- dGame/dComponents/SwitchComponent.cpp | 6 +- dGame/dComponents/SwitchComponent.h | 4 +- dGame/dComponents/TriggerComponent.cpp | 8 +- dGame/dGameMessages/GameMessageHandler.cpp | 2 +- dGame/dGameMessages/GameMessages.cpp | 14 +- dGame/dGameMessages/GameMessages.h | 8 +- .../Enemy/General/GfApeSmashingQB.cpp | 2 +- .../02_server/Enemy/General/GfApeSmashingQB.h | 2 +- dScripts/02_server/Map/AG/AgBugsprayer.cpp | 2 +- dScripts/02_server/Map/AG/AgBugsprayer.h | 2 +- dScripts/02_server/Map/AM/AmBridge.cpp | 2 +- dScripts/02_server/Map/AM/AmBridge.h | 2 +- .../02_server/Map/AM/AmDropshipComputer.cpp | 12 +- .../Map/AM/AmShieldGeneratorQuickbuild.cpp | 8 +- .../Map/AM/AmShieldGeneratorQuickbuild.h | 2 +- .../02_server/Map/FV/ImgBrickConsoleQB.cpp | 24 +-- dScripts/02_server/Map/FV/ImgBrickConsoleQB.h | 2 +- dScripts/02_server/Map/GF/MastTeleport.cpp | 2 +- dScripts/02_server/Map/GF/MastTeleport.h | 2 +- .../Ninjago/NjRailActivatorsServer.cpp | 6 +- .../Map/General/Ninjago/NjRailPostServer.cpp | 12 +- .../Map/General/Ninjago/NjRailPostServer.h | 2 +- .../02_server/Map/General/PropertyDevice.cpp | 2 +- .../02_server/Map/General/PropertyDevice.h | 2 +- .../Map/General/PropertyPlatform.cpp | 8 +- .../02_server/Map/General/PropertyPlatform.h | 2 +- .../02_server/Map/General/QbEnemyStunner.cpp | 2 +- .../02_server/Map/General/QbEnemyStunner.h | 2 +- .../02_server/Map/NS/NsTokenConsoleServer.cpp | 8 +- .../Map/NT/NTPipeVisibilityServer.cpp | 2 +- .../02_server/Map/NT/NTPipeVisibilityServer.h | 2 +- .../Map/NT/NtImagimeterVisibility.cpp | 2 +- .../02_server/Map/NT/NtImagimeterVisibility.h | 2 +- .../Map/njhub/CatapultBouncerServer.cpp | 2 +- .../Map/njhub/CatapultBouncerServer.h | 2 +- .../02_server/Map/njhub/CavePrisonCage.cpp | 16 +- dScripts/02_server/Map/njhub/CavePrisonCage.h | 2 +- .../Map/njhub/ImaginationShrineServer.cpp | 8 +- dScripts/02_server/Map/njhub/RainOfArrows.cpp | 2 +- dScripts/02_server/Map/njhub/RainOfArrows.h | 2 +- .../boss_instance/NjMonastryBossInstance.cpp | 16 +- .../Objects/AgSurvivalBuffStation.cpp | 2 +- .../02_server/Objects/AgSurvivalBuffStation.h | 2 +- dScripts/CppScripts.h | 14 +- dScripts/ai/ACT/ActMine.cpp | 14 +- dScripts/ai/ACT/ActMine.h | 2 +- dScripts/ai/AG/AgJetEffectServer.cpp | 2 +- dScripts/ai/AG/AgJetEffectServer.h | 2 +- dScripts/ai/AG/AgQbElevator.cpp | 2 +- dScripts/ai/AG/AgQbElevator.h | 2 +- dScripts/ai/AG/AgQbWall.cpp | 2 +- dScripts/ai/AG/AgQbWall.h | 2 +- dScripts/ai/AG/AgTurret.cpp | 2 +- dScripts/ai/AG/AgTurret.h | 2 +- dScripts/ai/FV/ActNinjaTurret.cpp | 8 +- dScripts/ai/FV/ActNinjaTurret.h | 2 +- dScripts/ai/FV/ActParadoxPipeFix.cpp | 12 +- dScripts/ai/FV/ActParadoxPipeFix.h | 4 +- dScripts/ai/FV/FvBrickPuzzleServer.cpp | 6 +- dScripts/ai/FV/FvConsoleLeftQuickbuild.cpp | 8 +- dScripts/ai/FV/FvConsoleLeftQuickbuild.h | 2 +- dScripts/ai/FV/FvConsoleRightQuickbuild.cpp | 8 +- dScripts/ai/FV/FvConsoleRightQuickbuild.h | 2 +- dScripts/ai/FV/FvDragonSmashingGolemQb.cpp | 6 +- dScripts/ai/FV/FvDragonSmashingGolemQb.h | 2 +- dScripts/ai/GF/GfArchway.cpp | 2 +- dScripts/ai/GF/GfArchway.h | 2 +- dScripts/ai/GF/GfJailWalls.cpp | 8 +- dScripts/ai/GF/GfJailWalls.h | 4 +- dScripts/ai/GF/PetDigBuild.cpp | 2 +- dScripts/ai/GF/PetDigBuild.h | 2 +- dScripts/ai/NS/NsConcertInstrument.cpp | 14 +- dScripts/ai/NS/NsConcertInstrument.h | 4 +- dScripts/ai/NS/NsConcertQuickBuild.cpp | 2 +- dScripts/ai/NS/NsConcertQuickBuild.h | 2 +- dScripts/ai/NS/NsQbImaginationStatue.cpp | 2 +- dScripts/ai/NS/NsQbImaginationStatue.h | 2 +- 95 files changed, 422 insertions(+), 422 deletions(-) create mode 100644 dCommon/dEnums/eQuickBuildState.h delete mode 100644 dCommon/dEnums/eRebuildState.h rename dGame/dComponents/{RebuildComponent.cpp => QuickBuildComponent.cpp} (70%) rename dGame/dComponents/{RebuildComponent.h => QuickBuildComponent.h} (50%) diff --git a/dCommon/dEnums/eQuickBuildState.h b/dCommon/dEnums/eQuickBuildState.h new file mode 100644 index 00000000..15acbfb5 --- /dev/null +++ b/dCommon/dEnums/eQuickBuildState.h @@ -0,0 +1,15 @@ +#ifndef __EQUICKBUILDSTATE__H__ +#define __EQUICKBUILDSTATE__H__ + +#include + +enum class eQuickBuildState : uint32_t { + OPEN, + COMPLETED = 2, + RESETTING = 4, + BUILDING, + INCOMPLETE +}; + + +#endif //!__EQUICKBUILDSTATE__H__ diff --git a/dCommon/dEnums/eRebuildState.h b/dCommon/dEnums/eRebuildState.h deleted file mode 100644 index 497bcb77..00000000 --- a/dCommon/dEnums/eRebuildState.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __EREBUILDSTATE__H__ -#define __EREBUILDSTATE__H__ - -#include - -enum class eRebuildState : uint32_t { - OPEN, - COMPLETED = 2, - RESETTING = 4, - BUILDING, - INCOMPLETE -}; - - -#endif //!__EREBUILDSTATE__H__ diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 6f8f65e9..fce2aefe 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -47,7 +47,7 @@ #include "MovingPlatformComponent.h" #include "MissionComponent.h" #include "MissionOfferComponent.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "BuildBorderComponent.h" #include "MovementAIComponent.h" #include "VendorComponent.h" @@ -327,11 +327,11 @@ void Entity::Initialize() { * Multiple components require the destructible component. */ int buffComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::BUFF); - int rebuildComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::QUICK_BUILD); + int quickBuildComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::QUICK_BUILD); int componentID = -1; if (collectibleComponentID > 0) componentID = collectibleComponentID; - if (rebuildComponentID > 0) componentID = rebuildComponentID; + if (quickBuildComponentID > 0) componentID = quickBuildComponentID; if (buffComponentID > 0) componentID = buffComponentID; CDDestructibleComponentTable* destCompTable = CDClientManager::Instance().GetTable(); @@ -521,50 +521,50 @@ void Entity::Initialize() { } if (int componentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::QUICK_BUILD) > 0) { - auto* rebuildComponent = AddComponent(); + auto* quickBuildComponent = AddComponent(); CDRebuildComponentTable* rebCompTable = CDClientManager::Instance().GetTable(); - std::vector rebCompData = rebCompTable->Query([=](CDRebuildComponent entry) { return (entry.id == rebuildComponentID); }); + std::vector rebCompData = rebCompTable->Query([=](CDRebuildComponent entry) { return (entry.id == quickBuildComponentID); }); if (rebCompData.size() > 0) { - rebuildComponent->SetResetTime(rebCompData[0].reset_time); - rebuildComponent->SetCompleteTime(rebCompData[0].complete_time); - rebuildComponent->SetTakeImagination(rebCompData[0].take_imagination); - rebuildComponent->SetInterruptible(rebCompData[0].interruptible); - rebuildComponent->SetSelfActivator(rebCompData[0].self_activator); - rebuildComponent->SetActivityId(rebCompData[0].activityID); - rebuildComponent->SetPostImaginationCost(rebCompData[0].post_imagination_cost); - rebuildComponent->SetTimeBeforeSmash(rebCompData[0].time_before_smash); + quickBuildComponent->SetResetTime(rebCompData[0].reset_time); + quickBuildComponent->SetCompleteTime(rebCompData[0].complete_time); + quickBuildComponent->SetTakeImagination(rebCompData[0].take_imagination); + quickBuildComponent->SetInterruptible(rebCompData[0].interruptible); + quickBuildComponent->SetSelfActivator(rebCompData[0].self_activator); + quickBuildComponent->SetActivityId(rebCompData[0].activityID); + quickBuildComponent->SetPostImaginationCost(rebCompData[0].post_imagination_cost); + quickBuildComponent->SetTimeBeforeSmash(rebCompData[0].time_before_smash); const auto rebuildResetTime = GetVar(u"rebuild_reset_time"); if (rebuildResetTime != 0.0f) { - rebuildComponent->SetResetTime(rebuildResetTime); + quickBuildComponent->SetResetTime(rebuildResetTime); // Known bug with moving platform in FV that casues it to build at the end instead of the start. // This extends the smash time so players can ride up the lift. if (m_TemplateID == 9483) { - rebuildComponent->SetResetTime(rebuildComponent->GetResetTime() + 25); + quickBuildComponent->SetResetTime(quickBuildComponent->GetResetTime() + 25); } } const auto activityID = GetVar(u"activityID"); if (activityID > 0) { - rebuildComponent->SetActivityId(activityID); + quickBuildComponent->SetActivityId(activityID); Loot::CacheMatrix(activityID); } const auto timeBeforeSmash = GetVar(u"tmeSmsh"); if (timeBeforeSmash > 0) { - rebuildComponent->SetTimeBeforeSmash(timeBeforeSmash); + quickBuildComponent->SetTimeBeforeSmash(timeBeforeSmash); } const auto compTime = GetVar(u"compTime"); if (compTime > 0) { - rebuildComponent->SetCompleteTime(compTime); + quickBuildComponent->SetCompleteTime(compTime); } } } @@ -1125,14 +1125,14 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType baseCombatAiComponent->Serialize(outBitStream, bIsInitialUpdate); } - RebuildComponent* rebuildComponent; - if (TryGetComponent(eReplicaComponentType::QUICK_BUILD, rebuildComponent)) { + QuickBuildComponent* quickBuildComponent; + if (TryGetComponent(eReplicaComponentType::QUICK_BUILD, quickBuildComponent)) { DestroyableComponent* destroyableComponent; if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) { destroyableComponent->Serialize(outBitStream, bIsInitialUpdate); } destroyableSerialized = true; - rebuildComponent->Serialize(outBitStream, bIsInitialUpdate); + quickBuildComponent->Serialize(outBitStream, bIsInitialUpdate); } MovingPlatformComponent* movingPlatformComponent; @@ -1588,10 +1588,10 @@ void Entity::AddCollisionPhantomCallback(const std::function& callback) const { - auto* rebuildComponent = GetComponent(); - if (rebuildComponent != nullptr) { - rebuildComponent->AddRebuildCompleteCallback(callback); +void Entity::AddQuickBuildCompleteCallback(const std::function& callback) const { + auto* quickBuildComponent = GetComponent(); + if (quickBuildComponent != nullptr) { + quickBuildComponent->AddQuickBuildCompleteCallback(callback); } } diff --git a/dGame/Entity.h b/dGame/Entity.h index cdc26838..77d77b16 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -211,7 +211,7 @@ public: void Smash(const LWOOBJID source = LWOOBJID_EMPTY, const eKillType killType = eKillType::VIOLENT, const std::u16string& deathType = u""); void Kill(Entity* murderer = nullptr, const eKillType killType = eKillType::SILENT); - void AddRebuildCompleteCallback(const std::function& callback) const; + void AddQuickBuildCompleteCallback(const std::function& callback) const; void AddCollisionPhantomCallback(const std::function& callback); void AddDieCallback(const std::function& callback); void Resurrect(); diff --git a/dGame/dBehaviors/AreaOfEffectBehavior.cpp b/dGame/dBehaviors/AreaOfEffectBehavior.cpp index 463cad8e..2a7e9754 100644 --- a/dGame/dBehaviors/AreaOfEffectBehavior.cpp +++ b/dGame/dBehaviors/AreaOfEffectBehavior.cpp @@ -7,7 +7,7 @@ #include "Logger.h" #include "BehaviorBranchContext.h" #include "BehaviorContext.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "DestroyableComponent.h" #include "Game.h" #include "Logger.h" diff --git a/dGame/dBehaviors/BehaviorContext.cpp b/dGame/dBehaviors/BehaviorContext.cpp index 77376558..e4f3011c 100644 --- a/dGame/dBehaviors/BehaviorContext.cpp +++ b/dGame/dBehaviors/BehaviorContext.cpp @@ -13,7 +13,7 @@ #include "DestroyableComponent.h" #include "EchoSyncSkill.h" #include "PhantomPhysicsComponent.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "eReplicaComponentType.h" #include "TeamManager.h" #include "eConnectionType.h" @@ -412,8 +412,8 @@ bool BehaviorContext::CheckTargetingRequirements(const Entity* target) const { if (!target) return false; // ignore quickbuilds that aren't completed - auto* targetQuickbuildComponent = target->GetComponent(); - if (targetQuickbuildComponent && targetQuickbuildComponent->GetState() != eRebuildState::COMPLETED) return false; + auto* targetQuickbuildComponent = target->GetComponent(); + if (targetQuickbuildComponent && targetQuickbuildComponent->GetState() != eQuickBuildState::COMPLETED) return false; return true; } diff --git a/dGame/dBehaviors/SpawnBehavior.cpp b/dGame/dBehaviors/SpawnBehavior.cpp index 96430766..dd45fb1b 100644 --- a/dGame/dBehaviors/SpawnBehavior.cpp +++ b/dGame/dBehaviors/SpawnBehavior.cpp @@ -6,7 +6,7 @@ #include "Game.h" #include "Logger.h" #include "DestroyableComponent.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "Entity.h" #include "EntityInfo.h" #include "eReplicaComponentType.h" @@ -53,10 +53,10 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea entity->SetOwnerOverride(context->originator); // Unset the flag to reposition the player, this makes it harder to glitch out of the map - auto* rebuildComponent = entity->GetComponent(); + auto* quickBuildComponent = entity->GetComponent(); - if (rebuildComponent != nullptr) { - rebuildComponent->SetRepositionPlayer(false); + if (quickBuildComponent != nullptr) { + quickBuildComponent->SetRepositionPlayer(false); } Game::entityManager->ConstructEntity(entity); diff --git a/dGame/dBehaviors/TacArcBehavior.cpp b/dGame/dBehaviors/TacArcBehavior.cpp index c240d5d9..0cea8213 100644 --- a/dGame/dBehaviors/TacArcBehavior.cpp +++ b/dGame/dBehaviors/TacArcBehavior.cpp @@ -6,7 +6,7 @@ #include "BehaviorContext.h" #include "BaseCombatAIComponent.h" #include "EntityManager.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "DestroyableComponent.h" #include diff --git a/dGame/dComponents/BaseCombatAIComponent.cpp b/dGame/dComponents/BaseCombatAIComponent.cpp index 50837629..17a2f1ea 100644 --- a/dGame/dComponents/BaseCombatAIComponent.cpp +++ b/dGame/dComponents/BaseCombatAIComponent.cpp @@ -20,7 +20,7 @@ #include #include "SkillComponent.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "DestroyableComponent.h" #include "Metrics.hpp" #include "CDComponentsRegistryTable.h" @@ -243,12 +243,12 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) { bool hadRemainingDowntime = m_SkillTime > 0.0f; if (m_SkillTime > 0.0f) m_SkillTime -= deltaTime; - auto* rebuild = m_Parent->GetComponent(); + auto* rebuild = m_Parent->GetComponent(); if (rebuild != nullptr) { const auto state = rebuild->GetState(); - if (state != eRebuildState::COMPLETED) { + if (state != eQuickBuildState::COMPLETED) { return; } } @@ -559,12 +559,12 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const { return false; } - auto* quickbuild = entity->GetComponent(); + auto* quickbuild = entity->GetComponent(); if (quickbuild != nullptr) { const auto state = quickbuild->GetState(); - if (state != eRebuildState::COMPLETED) { + if (state != eQuickBuildState::COMPLETED) { return false; } } diff --git a/dGame/dComponents/CMakeLists.txt b/dGame/dComponents/CMakeLists.txt index 04358cbe..d0bb89d3 100644 --- a/dGame/dComponents/CMakeLists.txt +++ b/dGame/dComponents/CMakeLists.txt @@ -32,7 +32,7 @@ set(DGAME_DCOMPONENTS_SOURCES "ActivityComponent.cpp" "ProximityMonitorComponent.cpp" "RacingControlComponent.cpp" "RailActivatorComponent.cpp" - "RebuildComponent.cpp" + "QuickBuildComponent.cpp" "RenderComponent.cpp" "RigidbodyPhantomPhysicsComponent.cpp" "MultiZoneEntranceComponent.cpp" diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index 6ba7db29..efc5d9d5 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -498,7 +498,7 @@ void CharacterComponent::TrackArmorDelta(int32_t armor) { } } -void CharacterComponent::TrackRebuildComplete() { +void CharacterComponent::TrackQuickBuildComplete() { UpdatePlayerStatistic(QuickBuildsCompleted); const auto mapID = Game::zoneManager->GetZoneID().GetMapID(); diff --git a/dGame/dComponents/CharacterComponent.h b/dGame/dComponents/CharacterComponent.h index 4222ef4a..158e011e 100644 --- a/dGame/dComponents/CharacterComponent.h +++ b/dGame/dComponents/CharacterComponent.h @@ -233,7 +233,7 @@ public: /** * Handles completing a rebuild by updating the statistics */ - void TrackRebuildComplete(); + void TrackQuickBuildComplete(); /** * Tracks a player completing the race, also updates stats diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index c90cadf5..1ced2f54 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -11,7 +11,7 @@ #include "CDClientManager.h" #include "CDDestructibleComponentTable.h" #include "EntityManager.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "CppScripts.h" #include "Loot.h" #include "Character.h" @@ -85,11 +85,11 @@ void DestroyableComponent::Reinitialize(LOT templateID) { int32_t buffComponentID = compRegistryTable->GetByIDAndType(templateID, eReplicaComponentType::BUFF); int32_t collectibleComponentID = compRegistryTable->GetByIDAndType(templateID, eReplicaComponentType::COLLECTIBLE); - int32_t rebuildComponentID = compRegistryTable->GetByIDAndType(templateID, eReplicaComponentType::QUICK_BUILD); + int32_t quickBuildComponentID = compRegistryTable->GetByIDAndType(templateID, eReplicaComponentType::QUICK_BUILD); int32_t componentID = 0; if (collectibleComponentID > 0) componentID = collectibleComponentID; - if (rebuildComponentID > 0) componentID = rebuildComponentID; + if (quickBuildComponentID > 0) componentID = quickBuildComponentID; if (buffComponentID > 0) componentID = buffComponentID; CDDestructibleComponentTable* destCompTable = CDClientManager::Instance().GetTable(); diff --git a/dGame/dComponents/MovingPlatformComponent.cpp b/dGame/dComponents/MovingPlatformComponent.cpp index c28d3cea..366bebd3 100644 --- a/dGame/dComponents/MovingPlatformComponent.cpp +++ b/dGame/dComponents/MovingPlatformComponent.cpp @@ -117,11 +117,11 @@ void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bI } } -void MovingPlatformComponent::OnRebuildInitilized() { +void MovingPlatformComponent::OnQuickBuildInitilized() { StopPathing(); } -void MovingPlatformComponent::OnCompleteRebuild() { +void MovingPlatformComponent::OnCompleteQuickBuild() { if (m_NoAutoStart) return; diff --git a/dGame/dComponents/MovingPlatformComponent.h b/dGame/dComponents/MovingPlatformComponent.h index e8e1dac7..bb5821d4 100644 --- a/dGame/dComponents/MovingPlatformComponent.h +++ b/dGame/dComponents/MovingPlatformComponent.h @@ -116,12 +116,12 @@ public: /** * Stops all pathing, called when an entity starts a quick build associated with this platform */ - void OnRebuildInitilized(); + void OnQuickBuildInitilized(); /** * Starts the pathing, called when an entity completed a quick build associated with this platform */ - void OnCompleteRebuild(); + void OnCompleteQuickBuild(); /** * Updates the movement state for the moving platform diff --git a/dGame/dComponents/RebuildComponent.cpp b/dGame/dComponents/QuickBuildComponent.cpp similarity index 70% rename from dGame/dComponents/RebuildComponent.cpp rename to dGame/dComponents/QuickBuildComponent.cpp index 25bab2e5..16263d81 100644 --- a/dGame/dComponents/RebuildComponent.cpp +++ b/dGame/dComponents/QuickBuildComponent.cpp @@ -1,4 +1,4 @@ -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "Entity.h" #include "DestroyableComponent.h" #include "GameMessages.h" @@ -24,7 +24,7 @@ #include "CppScripts.h" -RebuildComponent::RebuildComponent(Entity* entity) : Component(entity) { +QuickBuildComponent::QuickBuildComponent(Entity* entity) : Component(entity) { std::u16string checkPreconditions = entity->GetVar(u"CheckPrecondition"); if (!checkPreconditions.empty()) { @@ -46,18 +46,18 @@ RebuildComponent::RebuildComponent(Entity* entity) : Component(entity) { SpawnActivator(); } -RebuildComponent::~RebuildComponent() { +QuickBuildComponent::~QuickBuildComponent() { delete m_Precondition; Entity* builder = GetBuilder(); if (builder) { - CancelRebuild(builder, eQuickBuildFailReason::BUILD_ENDED, true); + CancelQuickBuild(builder, eQuickBuildFailReason::BUILD_ENDED, true); } DespawnActivator(); } -void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void QuickBuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { if (m_Parent->GetComponent(eReplicaComponentType::DESTROYABLE) == nullptr) { if (bIsInitialUpdate) { outBitStream->Write(false); @@ -70,7 +70,7 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia // If build state is completed and we've already serialized once in the completed state, // don't serializing this component anymore as this will cause the build to jump again. // If state changes, serialization will begin again. - if (!m_StateDirty && m_State == eRebuildState::COMPLETED) { + if (!m_StateDirty && m_State == eQuickBuildState::COMPLETED) { outBitStream->Write0(); outBitStream->Write0(); return; @@ -110,7 +110,7 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia m_StateDirty = false; } -void RebuildComponent::Update(float deltaTime) { +void QuickBuildComponent::Update(float deltaTime) { m_Activator = GetActivator(); // Serialize the quickbuild every so often, fixes the odd bug where the quickbuild is not buildable @@ -124,7 +124,7 @@ void RebuildComponent::Update(float deltaTime) { }*/ switch (m_State) { - case eRebuildState::OPEN: { + case eQuickBuildState::OPEN: { SpawnActivator(); m_TimeBeforeDrain = 0; @@ -147,14 +147,14 @@ void RebuildComponent::Update(float deltaTime) { GameMessages::SendDieNoImplCode(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true); - ResetRebuild(false); + ResetQuickBuild(false); } } } break; } - case eRebuildState::COMPLETED: { + case eQuickBuildState::COMPLETED: { m_Timer += deltaTime; // For reset times < 0 this has to be handled manually @@ -171,17 +171,17 @@ void RebuildComponent::Update(float deltaTime) { GameMessages::SendDieNoImplCode(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true); - ResetRebuild(false); + ResetQuickBuild(false); } } break; } - case eRebuildState::BUILDING: + case eQuickBuildState::BUILDING: { Entity* builder = GetBuilder(); if (!builder) { - ResetRebuild(false); + ResetQuickBuild(false); return; } @@ -205,18 +205,18 @@ void RebuildComponent::Update(float deltaTime) { Game::entityManager->SerializeEntity(builder); if (newImagination <= 0 && imaginationCostRemaining > 0) { - CancelRebuild(builder, eQuickBuildFailReason::OUT_OF_IMAGINATION, true); + CancelQuickBuild(builder, eQuickBuildFailReason::OUT_OF_IMAGINATION, true); break; } } if (m_Timer >= m_CompleteTime && m_DrainedImagination >= m_TakeImagination) { - CompleteRebuild(builder); + CompleteQuickBuild(builder); } break; } - case eRebuildState::INCOMPLETE: { + case eQuickBuildState::INCOMPLETE: { m_TimerIncomplete += deltaTime; // For reset times < 0 this has to be handled manually @@ -232,17 +232,17 @@ void RebuildComponent::Update(float deltaTime) { GameMessages::SendDieNoImplCode(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true); - ResetRebuild(false); + ResetQuickBuild(false); } } break; } - case eRebuildState::RESETTING: break; + case eQuickBuildState::RESETTING: break; } } -void RebuildComponent::OnUse(Entity* originator) { - if (GetBuilder() != nullptr || m_State == eRebuildState::COMPLETED) { +void QuickBuildComponent::OnUse(Entity* originator) { + if (GetBuilder() != nullptr || m_State == eQuickBuildState::COMPLETED) { return; } @@ -250,10 +250,10 @@ void RebuildComponent::OnUse(Entity* originator) { return; } - StartRebuild(originator); + StartQuickBuild(originator); } -void RebuildComponent::SpawnActivator() { +void QuickBuildComponent::SpawnActivator() { if (!m_SelfActivator || m_ActivatorPosition != NiPoint3::ZERO) { if (!m_Activator) { EntityInfo info; @@ -273,7 +273,7 @@ void RebuildComponent::SpawnActivator() { } } -void RebuildComponent::DespawnActivator() { +void QuickBuildComponent::DespawnActivator() { if (m_Activator) { Game::entityManager->DestructEntity(m_Activator); @@ -285,73 +285,73 @@ void RebuildComponent::DespawnActivator() { } } -Entity* RebuildComponent::GetActivator() { +Entity* QuickBuildComponent::GetActivator() { return Game::entityManager->GetEntity(m_ActivatorId); } -NiPoint3 RebuildComponent::GetActivatorPosition() { +NiPoint3 QuickBuildComponent::GetActivatorPosition() { return m_ActivatorPosition; } -float RebuildComponent::GetResetTime() { +float QuickBuildComponent::GetResetTime() { return m_ResetTime; } -float RebuildComponent::GetCompleteTime() { +float QuickBuildComponent::GetCompleteTime() { return m_CompleteTime; } -int RebuildComponent::GetTakeImagination() { +int QuickBuildComponent::GetTakeImagination() { return m_TakeImagination; } -bool RebuildComponent::GetInterruptible() { +bool QuickBuildComponent::GetInterruptible() { return m_Interruptible; } -bool RebuildComponent::GetSelfActivator() { +bool QuickBuildComponent::GetSelfActivator() { return m_SelfActivator; } -std::vector RebuildComponent::GetCustomModules() { +std::vector QuickBuildComponent::GetCustomModules() { return m_CustomModules; } -int RebuildComponent::GetActivityId() { +int QuickBuildComponent::GetActivityId() { return m_ActivityId; } -int RebuildComponent::GetPostImaginationCost() { +int QuickBuildComponent::GetPostImaginationCost() { return m_PostImaginationCost; } -float RebuildComponent::GetTimeBeforeSmash() { +float QuickBuildComponent::GetTimeBeforeSmash() { return m_TimeBeforeSmash; } -eRebuildState RebuildComponent::GetState() { +eQuickBuildState QuickBuildComponent::GetState() { return m_State; } -Entity* RebuildComponent::GetBuilder() const { +Entity* QuickBuildComponent::GetBuilder() const { auto* builder = Game::entityManager->GetEntity(m_Builder); return builder; } -bool RebuildComponent::GetRepositionPlayer() const { +bool QuickBuildComponent::GetRepositionPlayer() const { return m_RepositionPlayer; } -void RebuildComponent::SetActivatorPosition(NiPoint3 value) { +void QuickBuildComponent::SetActivatorPosition(NiPoint3 value) { m_ActivatorPosition = value; } -void RebuildComponent::SetResetTime(float value) { +void QuickBuildComponent::SetResetTime(float value) { m_ResetTime = value; } -void RebuildComponent::SetCompleteTime(float value) { +void QuickBuildComponent::SetCompleteTime(float value) { if (value < 0) { m_CompleteTime = 4.5f; } else { @@ -359,31 +359,31 @@ void RebuildComponent::SetCompleteTime(float value) { } } -void RebuildComponent::SetTakeImagination(int value) { +void QuickBuildComponent::SetTakeImagination(int value) { m_TakeImagination = value; } -void RebuildComponent::SetInterruptible(bool value) { +void QuickBuildComponent::SetInterruptible(bool value) { m_Interruptible = value; } -void RebuildComponent::SetSelfActivator(bool value) { +void QuickBuildComponent::SetSelfActivator(bool value) { m_SelfActivator = value; } -void RebuildComponent::SetCustomModules(std::vector value) { +void QuickBuildComponent::SetCustomModules(std::vector value) { m_CustomModules = value; } -void RebuildComponent::SetActivityId(int value) { +void QuickBuildComponent::SetActivityId(int value) { m_ActivityId = value; } -void RebuildComponent::SetPostImaginationCost(int value) { +void QuickBuildComponent::SetPostImaginationCost(int value) { m_PostImaginationCost = value; } -void RebuildComponent::SetTimeBeforeSmash(float value) { +void QuickBuildComponent::SetTimeBeforeSmash(float value) { if (value < 0) { m_TimeBeforeSmash = 10.0f; } else { @@ -391,12 +391,12 @@ void RebuildComponent::SetTimeBeforeSmash(float value) { } } -void RebuildComponent::SetRepositionPlayer(bool value) { +void QuickBuildComponent::SetRepositionPlayer(bool value) { m_RepositionPlayer = value; } -void RebuildComponent::StartRebuild(Entity* user) { - if (m_State == eRebuildState::OPEN || m_State == eRebuildState::COMPLETED || m_State == eRebuildState::INCOMPLETE) { +void QuickBuildComponent::StartQuickBuild(Entity* user) { + if (m_State == eQuickBuildState::OPEN || m_State == eQuickBuildState::COMPLETED || m_State == eQuickBuildState::INCOMPLETE) { m_Builder = user->GetObjectID(); auto* character = user->GetComponent(); @@ -404,31 +404,31 @@ void RebuildComponent::StartRebuild(Entity* user) { Game::entityManager->SerializeEntity(user); - GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::BUILDING, user->GetObjectID()); - GameMessages::SendEnableRebuild(m_Parent, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID()); + GameMessages::SendQuickBuildNotifyState(m_Parent, m_State, eQuickBuildState::BUILDING, user->GetObjectID()); + GameMessages::SendEnableQuickBuild(m_Parent, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID()); - m_State = eRebuildState::BUILDING; + m_State = eQuickBuildState::BUILDING; m_StateDirty = true; Game::entityManager->SerializeEntity(m_Parent); auto* movingPlatform = m_Parent->GetComponent(); if (movingPlatform != nullptr) { - movingPlatform->OnRebuildInitilized(); + movingPlatform->OnQuickBuildInitilized(); } for (auto* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnRebuildStart(m_Parent, user); + script->OnQuickBuildStart(m_Parent, user); } // Notify scripts and possible subscribers for (auto* script : CppScripts::GetEntityScripts(m_Parent)) - script->OnRebuildNotifyState(m_Parent, m_State); - for (const auto& cb : m_RebuildStateCallbacks) + script->OnQuickBuildNotifyState(m_Parent, m_State); + for (const auto& cb : m_QuickBuildStateCallbacks) cb(m_State); } } -void RebuildComponent::CompleteRebuild(Entity* user) { +void QuickBuildComponent::CompleteQuickBuild(Entity* user) { if (user == nullptr) { return; } @@ -436,7 +436,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) { auto* characterComponent = user->GetComponent(); if (characterComponent != nullptr) { characterComponent->SetCurrentActivity(eGameActivity::NONE); - characterComponent->TrackRebuildComplete(); + characterComponent->TrackQuickBuildComplete(); } else { LOG("Some user tried to finish the rebuild but they didn't have a character somehow."); return; @@ -444,13 +444,13 @@ void RebuildComponent::CompleteRebuild(Entity* user) { Game::entityManager->SerializeEntity(user); - GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::COMPLETED, user->GetObjectID()); + GameMessages::SendQuickBuildNotifyState(m_Parent, m_State, eQuickBuildState::COMPLETED, user->GetObjectID()); GameMessages::SendPlayFXEffect(m_Parent, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true); - GameMessages::SendEnableRebuild(m_Parent, false, false, true, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, user->GetObjectID()); + GameMessages::SendEnableQuickBuild(m_Parent, false, false, true, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, user->GetObjectID()); GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID()); - m_State = eRebuildState::COMPLETED; + m_State = eQuickBuildState::COMPLETED; m_StateDirty = true; m_Timer = 0.0f; m_DrainedImagination = 0; @@ -490,21 +490,21 @@ void RebuildComponent::CompleteRebuild(Entity* user) { // Notify scripts for (auto* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnRebuildComplete(m_Parent, user); - script->OnRebuildNotifyState(m_Parent, m_State); + script->OnQuickBuildComplete(m_Parent, user); + script->OnQuickBuildNotifyState(m_Parent, m_State); } // Notify subscribers - for (const auto& callback : m_RebuildStateCallbacks) + for (const auto& callback : m_QuickBuildStateCallbacks) callback(m_State); - for (const auto& callback : m_RebuildCompleteCallbacks) + for (const auto& callback : m_QuickBuildCompleteCallbacks) callback(user); m_Parent->TriggerEvent(eTriggerEventType::REBUILD_COMPLETE, user); auto* movingPlatform = m_Parent->GetComponent(); if (movingPlatform != nullptr) { - movingPlatform->OnCompleteRebuild(); + movingPlatform->OnCompleteQuickBuild(); } // Set flag @@ -520,20 +520,20 @@ void RebuildComponent::CompleteRebuild(Entity* user) { RenderComponent::PlayAnimation(user, u"rebuild-celebrate", 1.09f); } -void RebuildComponent::ResetRebuild(bool failed) { +void QuickBuildComponent::ResetQuickBuild(bool failed) { Entity* builder = GetBuilder(); - if (m_State == eRebuildState::BUILDING && builder) { - GameMessages::SendEnableRebuild(m_Parent, false, false, failed, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, builder->GetObjectID()); + if (m_State == eQuickBuildState::BUILDING && builder) { + GameMessages::SendEnableQuickBuild(m_Parent, false, false, failed, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, builder->GetObjectID()); if (failed) { RenderComponent::PlayAnimation(builder, u"rebuild-fail"); } } - GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::RESETTING, LWOOBJID_EMPTY); + GameMessages::SendQuickBuildNotifyState(m_Parent, m_State, eQuickBuildState::RESETTING, LWOOBJID_EMPTY); - m_State = eRebuildState::RESETTING; + m_State = eQuickBuildState::RESETTING; m_StateDirty = true; m_Timer = 0.0f; m_TimerIncomplete = 0.0f; @@ -544,8 +544,8 @@ void RebuildComponent::ResetRebuild(bool failed) { // Notify scripts and possible subscribers for (auto* script : CppScripts::GetEntityScripts(m_Parent)) - script->OnRebuildNotifyState(m_Parent, m_State); - for (const auto& cb : m_RebuildStateCallbacks) + script->OnQuickBuildNotifyState(m_Parent, m_State); + for (const auto& cb : m_QuickBuildStateCallbacks) cb(m_State); m_Parent->ScheduleKillAfterUpdate(); @@ -555,29 +555,29 @@ void RebuildComponent::ResetRebuild(bool failed) { } } -void RebuildComponent::CancelRebuild(Entity* entity, eQuickBuildFailReason failReason, bool skipChecks) { - if (m_State != eRebuildState::COMPLETED || skipChecks) { +void QuickBuildComponent::CancelQuickBuild(Entity* entity, eQuickBuildFailReason failReason, bool skipChecks) { + if (m_State != eQuickBuildState::COMPLETED || skipChecks) { m_Builder = LWOOBJID_EMPTY; const auto entityID = entity != nullptr ? entity->GetObjectID() : LWOOBJID_EMPTY; // Notify the client that a state has changed - GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::INCOMPLETE, entityID); - GameMessages::SendEnableRebuild(m_Parent, false, true, false, failReason, m_Timer, entityID); + GameMessages::SendQuickBuildNotifyState(m_Parent, m_State, eQuickBuildState::INCOMPLETE, entityID); + GameMessages::SendEnableQuickBuild(m_Parent, false, true, false, failReason, m_Timer, entityID); // Now terminate any interaction with the rebuild GameMessages::SendTerminateInteraction(entityID, eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID()); GameMessages::SendTerminateInteraction(m_Parent->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID()); // Now update the component itself - m_State = eRebuildState::INCOMPLETE; + m_State = eQuickBuildState::INCOMPLETE; m_StateDirty = true; // Notify scripts and possible subscribers for (auto* script : CppScripts::GetEntityScripts(m_Parent)) - script->OnRebuildNotifyState(m_Parent, m_State); - for (const auto& cb : m_RebuildStateCallbacks) + script->OnQuickBuildNotifyState(m_Parent, m_State); + for (const auto& cb : m_QuickBuildStateCallbacks) cb(m_State); Game::entityManager->SerializeEntity(m_Parent); @@ -594,10 +594,10 @@ void RebuildComponent::CancelRebuild(Entity* entity, eQuickBuildFailReason failR } } -void RebuildComponent::AddRebuildCompleteCallback(const std::function& callback) { - m_RebuildCompleteCallbacks.push_back(callback); +void QuickBuildComponent::AddQuickBuildCompleteCallback(const std::function& callback) { + m_QuickBuildCompleteCallbacks.push_back(callback); } -void RebuildComponent::AddRebuildStateCallback(const std::function& callback) { - m_RebuildStateCallbacks.push_back(callback); +void QuickBuildComponent::AddQuickBuildStateCallback(const std::function& callback) { + m_QuickBuildStateCallbacks.push_back(callback); } diff --git a/dGame/dComponents/RebuildComponent.h b/dGame/dComponents/QuickBuildComponent.h similarity index 50% rename from dGame/dComponents/RebuildComponent.h rename to dGame/dComponents/QuickBuildComponent.h index b67747aa..feef1f74 100644 --- a/dGame/dComponents/RebuildComponent.h +++ b/dGame/dComponents/QuickBuildComponent.h @@ -1,5 +1,5 @@ -#ifndef REBUILDCOMPONENT_H -#define REBUILDCOMPONENT_H +#ifndef QUICKBUILDCOMPONENT_H +#define QUICKBUILDCOMPONENT_H #include #include @@ -10,7 +10,7 @@ #include "Preconditions.h" #include "Component.h" #include "eReplicaComponentType.h" -#include "eRebuildState.h" +#include "eQuickBuildState.h" class Entity; enum class eQuickBuildFailReason : uint32_t; @@ -20,12 +20,12 @@ enum class eQuickBuildFailReason : uint32_t; * consists of an activator that shows a popup and then the actual entity that the bricks are built into. Note * that quick builds are also scripted activities so this shared some logic with the ScriptedActivityComponent. */ -class RebuildComponent : public Component { +class QuickBuildComponent : public Component { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::QUICK_BUILD; - RebuildComponent(Entity* entity); - ~RebuildComponent() override; + QuickBuildComponent(Entity* entity); + ~QuickBuildComponent() override; void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; @@ -37,78 +37,78 @@ public: void OnUse(Entity* originator) override; /** - * Spawns the activator that can be used to initiate the rebuild + * Spawns the activator that can be used to initiate the quickbuild */ void SpawnActivator(); /** - * Despawns the activiator that can be used to initiate the rebuild + * Despawns the activiator that can be used to initiate the quickbuild */ void DespawnActivator(); /** - * Returns the entity that acts as the activator for this rebuild - * @return the entity that acts as the activator for this rebuild + * Returns the entity that acts as the activator for this quickbuild + * @return the entity that acts as the activator for this quickbuild */ Entity* GetActivator(); /** - * Returns the spawn position of the activator for this rebuild, if any - * @return the spawn position of the activator for this rebuild, if any + * Returns the spawn position of the activator for this quickbuild, if any + * @return the spawn position of the activator for this quickbuild, if any */ NiPoint3 GetActivatorPosition(); /** - * Sets the spawn position for the activator of this rebuild + * Sets the spawn position for the activator of this quickbuild * @param value the spawn position to set for the activator */ void SetActivatorPosition(NiPoint3 value); /** - * Returns the time it takes for the rebuild to reset after being built - * @return the time it takes for the rebuild to reset after being built + * Returns the time it takes for the quickbuild to reset after being built + * @return the time it takes for the quickbuild to reset after being built */ float GetResetTime(); /** - * Sets the time it takes for the rebuild to reset after being built + * Sets the time it takes for the quickbuild to reset after being built * @param value the reset time to set */ void SetResetTime(float value); /** - * Returns the time it takes to complete the rebuild - * @return the time it takes to complete the rebuild + * Returns the time it takes to complete the quickbuild + * @return the time it takes to complete the quickbuild */ float GetCompleteTime(); /** - * Sets the time it takes to complete the rebuild + * Sets the time it takes to complete the quickbuild * @param value the completion time to set */ void SetCompleteTime(float value); /** - * Returns the imagination that's taken when completing the rebuild - * @return the imagination that's taken when completing the rebuild + * Returns the imagination that's taken when completing the quickbuild + * @return the imagination that's taken when completing the quickbuild */ int GetTakeImagination(); /** - * Sets the imagination that's taken when completing the rebuild + * Sets the imagination that's taken when completing the quickbuild * @param value the imagination deduction to set */ void SetTakeImagination(int value); /** - * Returns if the rebuild can be interrupted, currently unused - * @return if the rebuild can be interrupted + * Returns if the quickbuild can be interrupted, currently unused + * @return if the quickbuild can be interrupted */ bool GetInterruptible(); /** - * Sets whether or not the rebuild can be interrupted, currently unused - * @param value true if the rebuild may be interrupted, false otherwise + * Sets whether or not the quickbuild can be interrupted, currently unused + * @param value true if the quickbuild may be interrupted, false otherwise */ void SetInterruptible(bool value); @@ -120,7 +120,7 @@ public: /** * Sets whether or not this entity contains a built-in activator. If set to false this will spawn activators on - * each new rebuild. + * each new quickbuild. * @param value whether or not this entity contains a built-in activator */ void SetSelfActivator(bool value); @@ -136,13 +136,13 @@ public: void SetCustomModules(std::vector value); /** - * Returns the activity ID for participating in this rebuild - * @return the activity ID for participating in this rebuild + * Returns the activity ID for participating in this quickbuild + * @return the activity ID for participating in this quickbuild */ int GetActivityId(); /** - * Sets the activity ID for participating in this rebuild + * Sets the activity ID for participating in this quickbuild * @param value the activity ID to set */ void SetActivityId(int value); @@ -158,66 +158,66 @@ public: void SetPostImaginationCost(int value); /** - * Returns the time it takes for an incomplete rebuild to be smashed automatically - * @return the time it takes for an incomplete rebuild to be smashed automatically + * Returns the time it takes for an incomplete quickbuild to be smashed automatically + * @return the time it takes for an incomplete quickbuild to be smashed automatically */ float GetTimeBeforeSmash(); /** - * Sets the time it takes for an incomplete rebuild to be smashed automatically + * Sets the time it takes for an incomplete quickbuild to be smashed automatically * @param value the time to set */ void SetTimeBeforeSmash(float value); /** - * Returns the current rebuild state - * @return the current rebuild state + * Returns the current quickbuild state + * @return the current quickbuild state */ - eRebuildState GetState(); + eQuickBuildState GetState(); /** - * Returns the player that is currently building this rebuild - * @return the player that is currently building this rebuild + * Returns the player that is currently building this quickbuild + * @return the player that is currently building this quickbuild */ Entity* GetBuilder() const; /** - * Returns whether or not the player is repositioned when initiating the rebuild - * @return whether or not the player is repositioned when initiating the rebuild + * Returns whether or not the player is repositioned when initiating the quickbuild + * @return whether or not the player is repositioned when initiating the quickbuild */ bool GetRepositionPlayer() const; /** - * Sets whether or not the player is repositioned when initiating the rebuild - * @param value whether or not the player is repositioned when initiating the rebuild + * Sets whether or not the player is repositioned when initiating the quickbuild + * @param value whether or not the player is repositioned when initiating the quickbuild */ void SetRepositionPlayer(bool value); /** - * Adds a callback that is called when the rebuild is completed + * Adds a callback that is called when the quickbuild is completed * @param callback the callback to add */ - void AddRebuildCompleteCallback(const std::function& callback); + void AddQuickBuildCompleteCallback(const std::function& callback); /** - * Adds a callback when the rebuild state is updated + * Adds a callback when the quickbuild state is updated * @param callback the callback to add */ - void AddRebuildStateCallback(const std::function& callback); + void AddQuickBuildStateCallback(const std::function& callback); /** - * Resets the rebuild - * @param failed whether or not the player failed to complete the rebuild, triggers an extra animation + * Resets the quickbuild + * @param failed whether or not the player failed to complete the quickbuild, triggers an extra animation */ - void ResetRebuild(bool failed); + void ResetQuickBuild(bool failed); /** - * Cancels the rebuild if it wasn't completed + * Cancels the quickbuild if it wasn't completed * @param builder the player that's currently building - * @param failReason the reason the rebuild was cancelled - * @param skipChecks whether or not to skip the check for the rebuild not being completed + * @param failReason the reason the quickbuild was cancelled + * @param skipChecks whether or not to skip the check for the quickbuild not being completed */ - void CancelRebuild(Entity* builder, eQuickBuildFailReason failReason, bool skipChecks = false); + void CancelQuickBuild(Entity* builder, eQuickBuildFailReason failReason, bool skipChecks = false); private: /** * Whether or not the quickbuild state has been changed since we last serialized it. @@ -225,37 +225,37 @@ private: bool m_StateDirty = true; /** - * The state the rebuild is currently in + * The state the quickbuild is currently in */ - eRebuildState m_State = eRebuildState::OPEN; + eQuickBuildState m_State = eQuickBuildState::OPEN; /** - * The time that has passed since initiating the rebuild + * The time that has passed since initiating the quickbuild */ float m_Timer = 0; /** - * The time that has passed before completing the rebuild + * The time that has passed before completing the quickbuild */ float m_TimerIncomplete = 0; /** - * The position that the rebuild activator is spawned at + * The position that the quickbuild activator is spawned at */ NiPoint3 m_ActivatorPosition = NiPoint3::ZERO; /** - * The entity that represents the rebuild activator + * The entity that represents the quickbuild activator */ Entity* m_Activator = nullptr; /** - * The ID of the entity that represents the rebuild activator + * The ID of the entity that represents the quickbuild activator */ LWOOBJID m_ActivatorId = LWOOBJID_EMPTY; /** - * Triggers the blinking that indicates that the rebuild is resetting + * Triggers the blinking that indicates that the quickbuild is resetting */ bool m_ShowResetEffect = false; @@ -265,27 +265,27 @@ private: float m_Taken = 0; /** - * The callbacks that are called when the rebuild is completed + * The callbacks that are called when the quickbuild is completed */ - std::vector> m_RebuildCompleteCallbacks{}; + std::vector> m_QuickBuildCompleteCallbacks{}; /** - * The callbacks that are called when the rebuild state is updated + * The callbacks that are called when the quickbuild state is updated */ - std::vector> m_RebuildStateCallbacks{}; + std::vector> m_QuickBuildStateCallbacks{}; /** - * The time it takes for the rebuild to reset after being completed + * The time it takes for the quickbuild to reset after being completed */ float m_ResetTime = 0; /** - * The time it takes to complete the rebuild + * The time it takes to complete the quickbuild */ float m_CompleteTime = 0; /** - * The imagination that's deducted when completing the rebuild + * The imagination that's deducted when completing the quickbuild */ int m_TakeImagination = 0; @@ -295,7 +295,7 @@ private: bool m_Interruptible = false; /** - * Whether or not this rebuild entity also has an activator attached. If not a new one will be spawned + * Whether or not this quickbuild entity also has an activator attached. If not a new one will be spawned */ bool m_SelfActivator = false; @@ -305,7 +305,7 @@ private: std::vector m_CustomModules{}; /** - * The activity ID that players partake in when doing this rebuild + * The activity ID that players partake in when doing this quickbuild */ int m_ActivityId = 0; @@ -315,7 +315,7 @@ private: int m_PostImaginationCost = 0; /** - * The time it takes for the rebuild to reset when it's not completed yet + * The time it takes for the quickbuild to reset when it's not completed yet */ float m_TimeBeforeSmash = 0; @@ -325,7 +325,7 @@ private: float m_TimeBeforeDrain = 0; /** - * The amount of imagination that was drained when building this rebuild + * The amount of imagination that was drained when building this quickbuild */ int m_DrainedImagination = 0; @@ -340,26 +340,26 @@ private: float m_SoftTimer = 0; /** - * The ID of the entity that's currently building the rebuild + * The ID of the entity that's currently building the quickbuild */ LWOOBJID m_Builder = LWOOBJID_EMPTY; /** - * Preconditions to be met before being able to start the rebuild + * Preconditions to be met before being able to start the quickbuild */ PreconditionExpression* m_Precondition = nullptr; /** - * Starts the rebuild for a certain entity - * @param user the entity to start the rebuild + * Starts the quickbuild for a certain entity + * @param user the entity to start the quickbuild */ - void StartRebuild(Entity* user); + void StartQuickBuild(Entity* user); /** - * Completes the rebuild for an entity, dropping loot and despawning the activator - * @param user the entity that completed the rebuild + * Completes the quickbuild for an entity, dropping loot and despawning the activator + * @param user the entity that completed the quickbuild */ - void CompleteRebuild(Entity* user); + void CompleteQuickBuild(Entity* user); }; -#endif // REBUILDCOMPONENT_H +#endif // QUICKBUILDCOMPONENT_H diff --git a/dGame/dComponents/RailActivatorComponent.cpp b/dGame/dComponents/RailActivatorComponent.cpp index 5662303b..e0eb035a 100644 --- a/dGame/dComponents/RailActivatorComponent.cpp +++ b/dGame/dComponents/RailActivatorComponent.cpp @@ -4,7 +4,7 @@ #include "CDRailActivatorComponent.h" #include "Entity.h" #include "GameMessages.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "Game.h" #include "Logger.h" #include "RenderComponent.h" @@ -43,13 +43,13 @@ RailActivatorComponent::RailActivatorComponent(Entity* parent, int32_t component RailActivatorComponent::~RailActivatorComponent() = default; void RailActivatorComponent::OnUse(Entity* originator) { - auto* rebuildComponent = m_Parent->GetComponent(); - if (rebuildComponent != nullptr && rebuildComponent->GetState() != eRebuildState::COMPLETED) + auto* quickBuildComponent = m_Parent->GetComponent(); + if (quickBuildComponent != nullptr && quickBuildComponent->GetState() != eQuickBuildState::COMPLETED) return; - if (rebuildComponent != nullptr) { + if (quickBuildComponent != nullptr) { // Don't want it to be destroyed while a player is using it - rebuildComponent->SetResetTime(rebuildComponent->GetResetTime() + 10.0f); + quickBuildComponent->SetResetTime(quickBuildComponent->GetResetTime() + 10.0f); } m_EntitiesOnRail.push_back(originator->GetObjectID()); @@ -116,11 +116,11 @@ void RailActivatorComponent::OnCancelRailMovement(Entity* originator) { true, true, true, true, true, true, true ); - auto* rebuildComponent = m_Parent->GetComponent(); + auto* quickBuildComponent = m_Parent->GetComponent(); - if (rebuildComponent != nullptr) { + if (quickBuildComponent != nullptr) { // Set back reset time - rebuildComponent->SetResetTime(rebuildComponent->GetResetTime() - 10.0f); + quickBuildComponent->SetResetTime(quickBuildComponent->GetResetTime() - 10.0f); } if (std::find(m_EntitiesOnRail.begin(), m_EntitiesOnRail.end(), originator->GetObjectID()) != m_EntitiesOnRail.end()) { diff --git a/dGame/dComponents/SwitchComponent.cpp b/dGame/dComponents/SwitchComponent.cpp index 41dff9f5..25f18a4d 100644 --- a/dGame/dComponents/SwitchComponent.cpp +++ b/dGame/dComponents/SwitchComponent.cpp @@ -10,7 +10,7 @@ SwitchComponent::SwitchComponent(Entity* parent) : Component(parent) { m_ResetTime = m_Parent->GetVarAs(u"switch_reset_time"); - m_Rebuild = m_Parent->GetComponent(); + m_QuickBuild = m_Parent->GetComponent(); } SwitchComponent::~SwitchComponent() { @@ -39,8 +39,8 @@ bool SwitchComponent::GetActive() const { void SwitchComponent::EntityEnter(Entity* entity) { if (!m_Active) { - if (m_Rebuild) { - if (m_Rebuild->GetState() != eRebuildState::COMPLETED) return; + if (m_QuickBuild) { + if (m_QuickBuild->GetState() != eQuickBuildState::COMPLETED) return; } m_Active = true; if (!m_Parent) return; diff --git a/dGame/dComponents/SwitchComponent.h b/dGame/dComponents/SwitchComponent.h index 25f694ba..7f2c3498 100644 --- a/dGame/dComponents/SwitchComponent.h +++ b/dGame/dComponents/SwitchComponent.h @@ -5,7 +5,7 @@ #include "Entity.h" #include "GameMessages.h" #include "EntityManager.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "BouncerComponent.h" #include #include "Component.h" @@ -75,7 +75,7 @@ private: /** * Attached rebuild component. */ - RebuildComponent* m_Rebuild; + QuickBuildComponent* m_QuickBuild; /** * If the switch is on or off. diff --git a/dGame/dComponents/TriggerComponent.cpp b/dGame/dComponents/TriggerComponent.cpp index f7ef7c54..d30353ab 100644 --- a/dGame/dComponents/TriggerComponent.cpp +++ b/dGame/dComponents/TriggerComponent.cpp @@ -10,7 +10,7 @@ #include "MissionComponent.h" #include "PhantomPhysicsComponent.h" #include "Player.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "SkillComponent.h" #include "eEndBehavior.h" @@ -205,12 +205,12 @@ void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string arg } void TriggerComponent::HandleResetRebuild(Entity* targetEntity, std::string args){ - auto* rebuildComponent = targetEntity->GetComponent(); - if (!rebuildComponent) { + auto* quickBuildComponent = targetEntity->GetComponent(); + if (!quickBuildComponent) { LOG_DEBUG("Rebuild component not found!"); return; } - rebuildComponent->ResetRebuild(args == "1"); + quickBuildComponent->ResetQuickBuild(args == "1"); } void TriggerComponent::HandleMoveObject(Entity* targetEntity, std::vector argArray){ diff --git a/dGame/dGameMessages/GameMessageHandler.cpp b/dGame/dGameMessages/GameMessageHandler.cpp index b9e5284d..c4ac1910 100644 --- a/dGame/dGameMessages/GameMessageHandler.cpp +++ b/dGame/dGameMessages/GameMessageHandler.cpp @@ -422,7 +422,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System break; case eGameMessageType::REBUILD_CANCEL: - GameMessages::HandleRebuildCancel(inStream, entity); + GameMessages::HandleQuickBuildCancel(inStream, entity); break; case eGameMessageType::MATCH_REQUEST: diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index e6c1290b..5d3384cc 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -63,7 +63,7 @@ #include "MissionComponent.h" #include "DestroyableComponent.h" #include "ScriptComponent.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "VendorComponent.h" #include "InventoryComponent.h" #include "RocketLaunchpadControlComponent.h" @@ -767,7 +767,7 @@ void GameMessages::SendSetCurrency(Entity* entity, int64_t currency, int lootTyp SEND_PACKET; } -void GameMessages::SendRebuildNotifyState(Entity* entity, eRebuildState prevState, eRebuildState state, const LWOOBJID& playerID) { +void GameMessages::SendQuickBuildNotifyState(Entity* entity, eQuickBuildState prevState, eQuickBuildState state, const LWOOBJID& playerID) { CBITSTREAM; CMSGHEADER; @@ -781,7 +781,7 @@ void GameMessages::SendRebuildNotifyState(Entity* entity, eRebuildState prevStat SEND_PACKET_BROADCAST; } -void GameMessages::SendEnableRebuild(Entity* entity, bool enable, bool fail, bool success, eQuickBuildFailReason failReason, float duration, const LWOOBJID& playerID) { +void GameMessages::SendEnableQuickBuild(Entity* entity, bool enable, bool fail, bool success, eQuickBuildFailReason failReason, float duration, const LWOOBJID& playerID) { CBITSTREAM; CMSGHEADER; @@ -4946,17 +4946,17 @@ void GameMessages::HandleRequestPlatformResync(RakNet::BitStream* inStream, Enti GameMessages::SendPlatformResync(entity, sysAddr); } -void GameMessages::HandleRebuildCancel(RakNet::BitStream* inStream, Entity* entity) { +void GameMessages::HandleQuickBuildCancel(RakNet::BitStream* inStream, Entity* entity) { bool bEarlyRelease; LWOOBJID userID; inStream->Read(bEarlyRelease); inStream->Read(userID); - RebuildComponent* rebComp = static_cast(entity->GetComponent(eReplicaComponentType::QUICK_BUILD)); - if (!rebComp) return; + auto* quickBuildComponent = static_cast(entity->GetComponent(eReplicaComponentType::QUICK_BUILD));; + if (!quickBuildComponent) return; - rebComp->CancelRebuild(Game::entityManager->GetEntity(userID), eQuickBuildFailReason::CANCELED_EARLY); + quickBuildComponent->CancelQuickBuild(Game::entityManager->GetEntity(userID), eQuickBuildFailReason::CANCELED_EARLY); } void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { diff --git a/dGame/dGameMessages/GameMessages.h b/dGame/dGameMessages/GameMessages.h index 8d0a961c..6d29a394 100644 --- a/dGame/dGameMessages/GameMessages.h +++ b/dGame/dGameMessages/GameMessages.h @@ -35,7 +35,7 @@ enum class eStateChangeType : uint32_t; enum class ePetTamingNotifyType : uint32_t; enum class eUseItemResponse : uint32_t; enum class eQuickBuildFailReason : uint32_t; -enum class eRebuildState : uint32_t; +enum class eQuickBuildState : uint32_t; enum class BehaviorSlot : int32_t; namespace GameMessages { @@ -100,8 +100,8 @@ namespace GameMessages { void SendBroadcastTextToChatbox(Entity* entity, const SystemAddress& sysAddr, const std::u16string& attrs, const std::u16string& wsText); void SendSetCurrency(Entity* entity, int64_t currency, int lootType, const LWOOBJID& sourceID, const LOT& sourceLOT, int sourceTradeID, bool overrideCurrent, eLootSourceType sourceType); - void SendRebuildNotifyState(Entity* entity, eRebuildState prevState, eRebuildState state, const LWOOBJID& playerID); - void SendEnableRebuild(Entity* entity, bool enable, bool fail, bool success, eQuickBuildFailReason failReason, float duration, const LWOOBJID& playerID); + void SendQuickBuildNotifyState(Entity* entity, eQuickBuildState prevState, eQuickBuildState state, const LWOOBJID& playerID); + void SendEnableQuickBuild(Entity* entity, bool enable, bool fail, bool success, eQuickBuildFailReason failReason, float duration, const LWOOBJID& playerID); void AddActivityOwner(Entity* entity, LWOOBJID& ownerID); void SendTerminateInteraction(const LWOOBJID& objectID, eTerminateType type, const LWOOBJID& terminator); @@ -602,7 +602,7 @@ namespace GameMessages { void HandleSetGhostReffrenceOverride(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); void HandleFireEventServerSide(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); void HandleRequestPlatformResync(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); - void HandleRebuildCancel(RakNet::BitStream* inStream, Entity* entity); + void HandleQuickBuildCancel(RakNet::BitStream* inStream, Entity* entity); void HandleRequestUse(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); void HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity); void HandleModularBuildConvertModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); diff --git a/dScripts/02_server/Enemy/General/GfApeSmashingQB.cpp b/dScripts/02_server/Enemy/General/GfApeSmashingQB.cpp index aa4a56a7..edb68fc0 100644 --- a/dScripts/02_server/Enemy/General/GfApeSmashingQB.cpp +++ b/dScripts/02_server/Enemy/General/GfApeSmashingQB.cpp @@ -14,7 +14,7 @@ void GfApeSmashingQB::OnTimerDone(Entity* self, std::string timerName) { } } -void GfApeSmashingQB::OnRebuildComplete(Entity* self, Entity* target) { +void GfApeSmashingQB::OnQuickBuildComplete(Entity* self, Entity* target) { auto* ape = Game::entityManager->GetEntity(self->GetVar(u"ape")); if (ape != nullptr) { ape->OnFireEventServerSide(target, "rebuildDone"); diff --git a/dScripts/02_server/Enemy/General/GfApeSmashingQB.h b/dScripts/02_server/Enemy/General/GfApeSmashingQB.h index 0306c260..eac766ab 100644 --- a/dScripts/02_server/Enemy/General/GfApeSmashingQB.h +++ b/dScripts/02_server/Enemy/General/GfApeSmashingQB.h @@ -4,5 +4,5 @@ class GfApeSmashingQB : public CppScripts::Script { void OnStartup(Entity* self) override; void OnTimerDone(Entity* self, std::string timerName) override; - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; }; diff --git a/dScripts/02_server/Map/AG/AgBugsprayer.cpp b/dScripts/02_server/Map/AG/AgBugsprayer.cpp index d4ab7aa3..772c4d44 100644 --- a/dScripts/02_server/Map/AG/AgBugsprayer.cpp +++ b/dScripts/02_server/Map/AG/AgBugsprayer.cpp @@ -1,7 +1,7 @@ #include "AgBugsprayer.h" #include "SkillComponent.h" -void AgBugsprayer::OnRebuildComplete(Entity* self, Entity* target) { +void AgBugsprayer::OnQuickBuildComplete(Entity* self, Entity* target) { self->AddTimer("castSkill", 1); self->SetOwnerOverride(target->GetObjectID()); } diff --git a/dScripts/02_server/Map/AG/AgBugsprayer.h b/dScripts/02_server/Map/AG/AgBugsprayer.h index 055feb36..30d5848d 100644 --- a/dScripts/02_server/Map/AG/AgBugsprayer.h +++ b/dScripts/02_server/Map/AG/AgBugsprayer.h @@ -4,7 +4,7 @@ class AgBugsprayer : public CppScripts::Script { public: - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; void OnTimerDone(Entity* self, std::string timerName) override; }; diff --git a/dScripts/02_server/Map/AM/AmBridge.cpp b/dScripts/02_server/Map/AM/AmBridge.cpp index 2fce627d..e0f7c255 100644 --- a/dScripts/02_server/Map/AM/AmBridge.cpp +++ b/dScripts/02_server/Map/AM/AmBridge.cpp @@ -5,7 +5,7 @@ void AmBridge::OnStartup(Entity* self) { } -void AmBridge::OnRebuildComplete(Entity* self, Entity* target) { +void AmBridge::OnQuickBuildComplete(Entity* self, Entity* target) { const auto consoles = Game::entityManager->GetEntitiesInGroup("Console" + GeneralUtils::UTF16ToWTF8(self->GetVar(u"bridge"))); if (consoles.empty()) { diff --git a/dScripts/02_server/Map/AM/AmBridge.h b/dScripts/02_server/Map/AM/AmBridge.h index 0dc025f9..a0557235 100644 --- a/dScripts/02_server/Map/AM/AmBridge.h +++ b/dScripts/02_server/Map/AM/AmBridge.h @@ -5,6 +5,6 @@ class AmBridge : public CppScripts::Script { public: void OnStartup(Entity* self) override; - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; void OnTimerDone(Entity* self, std::string timerName) override; }; diff --git a/dScripts/02_server/Map/AM/AmDropshipComputer.cpp b/dScripts/02_server/Map/AM/AmDropshipComputer.cpp index 1ee2aba3..60b750cf 100644 --- a/dScripts/02_server/Map/AM/AmDropshipComputer.cpp +++ b/dScripts/02_server/Map/AM/AmDropshipComputer.cpp @@ -1,6 +1,6 @@ #include "AmDropshipComputer.h" #include "MissionComponent.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "InventoryComponent.h" #include "dZoneManager.h" #include "eMissionState.h" @@ -10,9 +10,9 @@ void AmDropshipComputer::OnStartup(Entity* self) { } void AmDropshipComputer::OnUse(Entity* self, Entity* user) { - auto* rebuildComponent = self->GetComponent(); + auto* quickBuildComponent = self->GetComponent(); - if (rebuildComponent == nullptr || rebuildComponent->GetState() != eRebuildState::COMPLETED) { + if (quickBuildComponent == nullptr || quickBuildComponent->GetState() != eQuickBuildState::COMPLETED) { return; } @@ -70,13 +70,13 @@ void AmDropshipComputer::OnDie(Entity* self, Entity* killer) { } void AmDropshipComputer::OnTimerDone(Entity* self, std::string timerName) { - auto* rebuildComponent = self->GetComponent(); + auto* quickBuildComponent = self->GetComponent(); - if (rebuildComponent == nullptr) { + if (quickBuildComponent == nullptr) { return; } - if (timerName == "reset" && rebuildComponent->GetState() == eRebuildState::OPEN) { + if (timerName == "reset" && quickBuildComponent->GetState() == eQuickBuildState::OPEN) { self->Smash(self->GetObjectID(), eKillType::SILENT); } } diff --git a/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.cpp b/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.cpp index 0c09a5da..32852c22 100644 --- a/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.cpp +++ b/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.cpp @@ -6,7 +6,7 @@ #include "BaseCombatAIComponent.h" #include "SkillComponent.h" #include "EntityInfo.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "MissionComponent.h" void AmShieldGeneratorQuickbuild::OnStartup(Entity* self) { @@ -100,7 +100,7 @@ void AmShieldGeneratorQuickbuild::OnTimerDone(Entity* self, std::string timerNam } } -void AmShieldGeneratorQuickbuild::OnRebuildComplete(Entity* self, Entity* target) { +void AmShieldGeneratorQuickbuild::OnQuickBuildComplete(Entity* self, Entity* target) { StartShield(self); auto enemiesInProximity = self->GetVar>(u"Enemies"); @@ -174,9 +174,9 @@ void AmShieldGeneratorQuickbuild::BuffPlayers(Entity* self) { } void AmShieldGeneratorQuickbuild::EnemyEnteredShield(Entity* self, Entity* intruder) { - auto* rebuildComponent = self->GetComponent(); + auto* quickBuildComponent = self->GetComponent(); - if (rebuildComponent == nullptr || rebuildComponent->GetState() != eRebuildState::COMPLETED) { + if (quickBuildComponent == nullptr || quickBuildComponent->GetState() != eQuickBuildState::COMPLETED) { return; } diff --git a/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.h b/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.h index 2aef6926..cf5afcae 100644 --- a/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.h +++ b/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.h @@ -8,7 +8,7 @@ public: void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override; void OnDie(Entity* self, Entity* killer) override; void OnTimerDone(Entity* self, std::string timerName) override; - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; void StartShield(Entity* self); void BuffPlayers(Entity* self); diff --git a/dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp b/dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp index cf065ad6..88415481 100644 --- a/dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp +++ b/dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp @@ -1,5 +1,5 @@ #include "ImgBrickConsoleQB.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "dZoneManager.h" #include "EntityManager.h" #include "GameMessages.h" @@ -19,18 +19,18 @@ void ImgBrickConsoleQB::OnStartup(Entity* self) { } void ImgBrickConsoleQB::OnUse(Entity* self, Entity* user) { - auto* rebuildComponent = self->GetComponent(); + auto* quickBuildComponent = self->GetComponent(); - if (rebuildComponent->GetState() == eRebuildState::COMPLETED) { + if (quickBuildComponent->GetState() == eQuickBuildState::COMPLETED) { if (!self->GetNetworkVar(u"used")) { const auto consoles = Game::entityManager->GetEntitiesInGroup("Console"); auto bothBuilt = false; for (auto* console : consoles) { - auto* consoleRebuildComponent = console->GetComponent(); + auto* consoleQuickBuildComponent = console->GetComponent(); - if (consoleRebuildComponent->GetState() != eRebuildState::COMPLETED) { + if (consoleQuickBuildComponent->GetState() != eQuickBuildState::COMPLETED) { continue; } @@ -124,7 +124,7 @@ void ImgBrickConsoleQB::SmashCanister(Entity* self) { } } -void ImgBrickConsoleQB::OnRebuildComplete(Entity* self, Entity* target) { +void ImgBrickConsoleQB::OnQuickBuildComplete(Entity* self, Entity* target) { auto energyFX = 0; const auto location = GeneralUtils::UTF16ToWTF8(self->GetVar(u"console")); @@ -145,9 +145,9 @@ void ImgBrickConsoleQB::OnRebuildComplete(Entity* self, Entity* target) { const auto consoles = Game::entityManager->GetEntitiesInGroup("Console"); for (auto* console : consoles) { - auto* consoleRebuildComponent = console->GetComponent(); + auto* consoleQuickBuildComponent = console->GetComponent(); - if (consoleRebuildComponent->GetState() != eRebuildState::COMPLETED) { + if (consoleQuickBuildComponent->GetState() != eQuickBuildState::COMPLETED) { continue; } @@ -166,9 +166,9 @@ void ImgBrickConsoleQB::OnDie(Entity* self, Entity* killer) { self->SetVar(u"Died", true); - auto* rebuildComponent = self->GetComponent(); + auto* quickBuildComponent = self->GetComponent(); - if (rebuildComponent->GetState() == eRebuildState::COMPLETED) { + if (quickBuildComponent->GetState() == eQuickBuildState::COMPLETED) { auto offFX = 0; const auto location = GeneralUtils::UTF16ToWTF8(self->GetVar(u"console")); @@ -227,9 +227,9 @@ void ImgBrickConsoleQB::OnDie(Entity* self, Entity* killer) { void ImgBrickConsoleQB::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "reset") { - auto* rebuildComponent = self->GetComponent(); + auto* quickBuildComponent = self->GetComponent(); - if (rebuildComponent->GetState() == eRebuildState::OPEN) { + if (quickBuildComponent->GetState() == eQuickBuildState::OPEN) { self->Smash(self->GetObjectID(), eKillType::SILENT); } } else if (timerName == "Die") { diff --git a/dScripts/02_server/Map/FV/ImgBrickConsoleQB.h b/dScripts/02_server/Map/FV/ImgBrickConsoleQB.h index 062a5888..62f1900a 100644 --- a/dScripts/02_server/Map/FV/ImgBrickConsoleQB.h +++ b/dScripts/02_server/Map/FV/ImgBrickConsoleQB.h @@ -8,7 +8,7 @@ public: void OnUse(Entity* self, Entity* user) override; void SpawnBrick(Entity* self); void SmashCanister(Entity* self); - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; void OnDie(Entity* self, Entity* killer) override; void OnTimerDone(Entity* self, std::string timerName) override; diff --git a/dScripts/02_server/Map/GF/MastTeleport.cpp b/dScripts/02_server/Map/GF/MastTeleport.cpp index 29df4bf5..5a40507d 100644 --- a/dScripts/02_server/Map/GF/MastTeleport.cpp +++ b/dScripts/02_server/Map/GF/MastTeleport.cpp @@ -16,7 +16,7 @@ void MastTeleport::OnStartup(Entity* self) { self->SetNetworkVar(u"hookPreconditions", "154;44", UNASSIGNED_SYSTEM_ADDRESS); } -void MastTeleport::OnRebuildComplete(Entity* self, Entity* target) { +void MastTeleport::OnQuickBuildComplete(Entity* self, Entity* target) { if (Preconditions::Check(target, 154) && Preconditions::Check(target, 44)) { self->SetVar(u"userID", target->GetObjectID()); diff --git a/dScripts/02_server/Map/GF/MastTeleport.h b/dScripts/02_server/Map/GF/MastTeleport.h index ea35d754..072f1d04 100644 --- a/dScripts/02_server/Map/GF/MastTeleport.h +++ b/dScripts/02_server/Map/GF/MastTeleport.h @@ -4,6 +4,6 @@ class MastTeleport : public CppScripts::Script { public: void OnStartup(Entity* self) override; - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; void OnTimerDone(Entity* self, std::string timerName) override; }; diff --git a/dScripts/02_server/Map/General/Ninjago/NjRailActivatorsServer.cpp b/dScripts/02_server/Map/General/Ninjago/NjRailActivatorsServer.cpp index 5ca726af..fee3cd42 100644 --- a/dScripts/02_server/Map/General/Ninjago/NjRailActivatorsServer.cpp +++ b/dScripts/02_server/Map/General/Ninjago/NjRailActivatorsServer.cpp @@ -1,13 +1,13 @@ #include "NjRailActivatorsServer.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "Character.h" void NjRailActivatorsServer::OnUse(Entity* self, Entity* user) { const auto flag = self->GetVar(u"RailFlagNum"); - auto* rebuildComponent = self->GetComponent(); + auto* quickBuildComponent = self->GetComponent(); // Only allow use if this is not a quick build or the quick build is built - if (rebuildComponent == nullptr || rebuildComponent->GetState() == eRebuildState::COMPLETED) { + if (quickBuildComponent == nullptr || quickBuildComponent->GetState() == eQuickBuildState::COMPLETED) { auto* character = user->GetCharacter(); if (character != nullptr) { character->SetPlayerFlag(flag, true); diff --git a/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.cpp b/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.cpp index f47f7e7b..46340592 100644 --- a/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.cpp +++ b/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.cpp @@ -1,10 +1,10 @@ #include "NjRailPostServer.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "EntityManager.h" void NjRailPostServer::OnStartup(Entity* self) { - auto* rebuildComponent = self->GetComponent(); - if (rebuildComponent != nullptr) { + auto* quickBuildComponent = self->GetComponent(); + if (quickBuildComponent != nullptr) { self->SetNetworkVar(NetworkNotActiveVariable, true); } } @@ -18,8 +18,8 @@ void NjRailPostServer::OnNotifyObject(Entity* self, Entity* sender, const std::s } } -void NjRailPostServer::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == eRebuildState::COMPLETED) { +void NjRailPostServer::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) { + if (state == eQuickBuildState::COMPLETED) { auto* relatedRail = GetRelatedRail(self); if (relatedRail == nullptr) return; @@ -30,7 +30,7 @@ void NjRailPostServer::OnRebuildNotifyState(Entity* self, eRebuildState state) { return; self->SetNetworkVar(NetworkNotActiveVariable, false); - } else if (state == eRebuildState::RESETTING) { + } else if (state == eQuickBuildState::RESETTING) { auto* relatedRail = GetRelatedRail(self); if (relatedRail == nullptr) return; diff --git a/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.h b/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.h index 3486db87..c486b79e 100644 --- a/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.h +++ b/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.h @@ -4,7 +4,7 @@ class NjRailPostServer : public CppScripts::Script { void OnStartup(Entity* self) override; void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) override; - void OnRebuildNotifyState(Entity* self, eRebuildState state) override; + void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override; private: Entity* GetRelatedRail(Entity* self); const std::u16string NetworkNotActiveVariable = u"NetworkNotActive"; diff --git a/dScripts/02_server/Map/General/PropertyDevice.cpp b/dScripts/02_server/Map/General/PropertyDevice.cpp index 61ebe96e..df13a325 100644 --- a/dScripts/02_server/Map/General/PropertyDevice.cpp +++ b/dScripts/02_server/Map/General/PropertyDevice.cpp @@ -11,7 +11,7 @@ void PropertyDevice::OnStartup(Entity* self) { } } -void PropertyDevice::OnRebuildComplete(Entity* self, Entity* target) { +void PropertyDevice::OnQuickBuildComplete(Entity* self, Entity* target) { auto propertyOwnerID = self->GetNetworkVar(m_PropertyOwnerVariable); if (propertyOwnerID == std::to_string(LWOOBJID_EMPTY)) return; diff --git a/dScripts/02_server/Map/General/PropertyDevice.h b/dScripts/02_server/Map/General/PropertyDevice.h index 87ca10ad..e23cbfa3 100644 --- a/dScripts/02_server/Map/General/PropertyDevice.h +++ b/dScripts/02_server/Map/General/PropertyDevice.h @@ -3,7 +3,7 @@ class PropertyDevice : public CppScripts::Script { void OnStartup(Entity* self) override; - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; const std::u16string m_PropertyOwnerVariable = u"PropertyOwnerID"; const uint32_t m_PropertyMissionID = 1291; }; diff --git a/dScripts/02_server/Map/General/PropertyPlatform.cpp b/dScripts/02_server/Map/General/PropertyPlatform.cpp index 7016db94..4ea78314 100644 --- a/dScripts/02_server/Map/General/PropertyPlatform.cpp +++ b/dScripts/02_server/Map/General/PropertyPlatform.cpp @@ -1,9 +1,9 @@ #include "PropertyPlatform.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "GameMessages.h" #include "MovingPlatformComponent.h" -void PropertyPlatform::OnRebuildComplete(Entity* self, Entity* target) { +void PropertyPlatform::OnQuickBuildComplete(Entity* self, Entity* target) { // auto* movingPlatform = self->GetComponent(); // if (movingPlatform != nullptr) { // movingPlatform->StopPathing(); @@ -14,8 +14,8 @@ void PropertyPlatform::OnRebuildComplete(Entity* self, Entity* target) { } void PropertyPlatform::OnUse(Entity* self, Entity* user) { - auto* rebuildComponent = self->GetComponent(); - if (rebuildComponent != nullptr && rebuildComponent->GetState() == eRebuildState::COMPLETED) { + auto* quickBuildComponent = self->GetComponent(); + if (quickBuildComponent != nullptr && quickBuildComponent->GetState() == eQuickBuildState::COMPLETED) { // auto* movingPlatform = self->GetComponent(); // if (movingPlatform != nullptr) { // movingPlatform->GotoWaypoint(1); diff --git a/dScripts/02_server/Map/General/PropertyPlatform.h b/dScripts/02_server/Map/General/PropertyPlatform.h index ec863ab0..21754e7f 100644 --- a/dScripts/02_server/Map/General/PropertyPlatform.h +++ b/dScripts/02_server/Map/General/PropertyPlatform.h @@ -4,7 +4,7 @@ class PropertyPlatform : public CppScripts::Script { public: void OnUse(Entity* self, Entity* user) override; - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; private: float_t movementDelay = 10.0f; float_t effectDelay = 5.0f; diff --git a/dScripts/02_server/Map/General/QbEnemyStunner.cpp b/dScripts/02_server/Map/General/QbEnemyStunner.cpp index 441d743c..8291f409 100644 --- a/dScripts/02_server/Map/General/QbEnemyStunner.cpp +++ b/dScripts/02_server/Map/General/QbEnemyStunner.cpp @@ -6,7 +6,7 @@ #include "CDObjectSkillsTable.h" #include "CDSkillBehaviorTable.h" -void QbEnemyStunner::OnRebuildComplete(Entity* self, Entity* target) { +void QbEnemyStunner::OnQuickBuildComplete(Entity* self, Entity* target) { auto* destroyable = self->GetComponent(); if (destroyable != nullptr) { diff --git a/dScripts/02_server/Map/General/QbEnemyStunner.h b/dScripts/02_server/Map/General/QbEnemyStunner.h index fd9033d6..3be0c89d 100644 --- a/dScripts/02_server/Map/General/QbEnemyStunner.h +++ b/dScripts/02_server/Map/General/QbEnemyStunner.h @@ -4,6 +4,6 @@ class QbEnemyStunner : public CppScripts::Script { public: - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; void OnTimerDone(Entity* self, std::string timerName) override; }; diff --git a/dScripts/02_server/Map/NS/NsTokenConsoleServer.cpp b/dScripts/02_server/Map/NS/NsTokenConsoleServer.cpp index 326842d2..74542f9f 100644 --- a/dScripts/02_server/Map/NS/NsTokenConsoleServer.cpp +++ b/dScripts/02_server/Map/NS/NsTokenConsoleServer.cpp @@ -3,7 +3,7 @@ #include "GameMessages.h" #include "Character.h" #include "MissionComponent.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "eTerminateType.h" #include "ePlayerFlag.h" @@ -12,13 +12,13 @@ void NsTokenConsoleServer::OnStartup(Entity* self) { } void NsTokenConsoleServer::OnUse(Entity* self, Entity* user) { - auto* rebuildComponent = self->GetComponent(); + auto* quickBuildComponent = self->GetComponent(); - if (rebuildComponent == nullptr) { + if (quickBuildComponent == nullptr) { return; } - if (rebuildComponent->GetState() != eRebuildState::COMPLETED) { + if (quickBuildComponent->GetState() != eQuickBuildState::COMPLETED) { return; } diff --git a/dScripts/02_server/Map/NT/NTPipeVisibilityServer.cpp b/dScripts/02_server/Map/NT/NTPipeVisibilityServer.cpp index d8d7d1d9..7d39e9d9 100644 --- a/dScripts/02_server/Map/NT/NTPipeVisibilityServer.cpp +++ b/dScripts/02_server/Map/NT/NTPipeVisibilityServer.cpp @@ -2,7 +2,7 @@ #include "Entity.h" #include "Character.h" -void NTPipeVisibilityServer::OnRebuildComplete(Entity* self, Entity* target) { +void NTPipeVisibilityServer::OnQuickBuildComplete(Entity* self, Entity* target) { const auto flag = self->GetVar(u"flag"); if (flag == 0) return; diff --git a/dScripts/02_server/Map/NT/NTPipeVisibilityServer.h b/dScripts/02_server/Map/NT/NTPipeVisibilityServer.h index 2694af8b..2eff5bc3 100644 --- a/dScripts/02_server/Map/NT/NTPipeVisibilityServer.h +++ b/dScripts/02_server/Map/NT/NTPipeVisibilityServer.h @@ -5,7 +5,7 @@ class NTPipeVisibilityServer : public CppScripts::Script { public: - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; }; #endif //!__NTPIPEVISIBILITYSERVER__H__ diff --git a/dScripts/02_server/Map/NT/NtImagimeterVisibility.cpp b/dScripts/02_server/Map/NT/NtImagimeterVisibility.cpp index 64493d78..8003f4df 100644 --- a/dScripts/02_server/Map/NT/NtImagimeterVisibility.cpp +++ b/dScripts/02_server/Map/NT/NtImagimeterVisibility.cpp @@ -4,7 +4,7 @@ #include "Character.h" #include "ePlayerFlag.h" -void NTImagimeterVisibility::OnRebuildComplete(Entity* self, Entity* target) { +void NTImagimeterVisibility::OnQuickBuildComplete(Entity* self, Entity* target) { auto* character = target->GetCharacter(); if (character) character->SetPlayerFlag(ePlayerFlag::NT_PLINTH_REBUILD, true); diff --git a/dScripts/02_server/Map/NT/NtImagimeterVisibility.h b/dScripts/02_server/Map/NT/NtImagimeterVisibility.h index 04669d4b..adf67447 100644 --- a/dScripts/02_server/Map/NT/NtImagimeterVisibility.h +++ b/dScripts/02_server/Map/NT/NtImagimeterVisibility.h @@ -3,5 +3,5 @@ class NTImagimeterVisibility : public CppScripts::Script { public: - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; }; diff --git a/dScripts/02_server/Map/njhub/CatapultBouncerServer.cpp b/dScripts/02_server/Map/njhub/CatapultBouncerServer.cpp index 98b8a29d..28ed9f80 100644 --- a/dScripts/02_server/Map/njhub/CatapultBouncerServer.cpp +++ b/dScripts/02_server/Map/njhub/CatapultBouncerServer.cpp @@ -2,7 +2,7 @@ #include "GameMessages.h" #include "EntityManager.h" -void CatapultBouncerServer::OnRebuildComplete(Entity* self, Entity* target) { +void CatapultBouncerServer::OnQuickBuildComplete(Entity* self, Entity* target) { GameMessages::SendNotifyClientObject(self->GetObjectID(), u"Built", 0, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS); self->SetNetworkVar(u"Built", true); diff --git a/dScripts/02_server/Map/njhub/CatapultBouncerServer.h b/dScripts/02_server/Map/njhub/CatapultBouncerServer.h index 46ec20ab..c2e8ab87 100644 --- a/dScripts/02_server/Map/njhub/CatapultBouncerServer.h +++ b/dScripts/02_server/Map/njhub/CatapultBouncerServer.h @@ -3,5 +3,5 @@ class CatapultBouncerServer : public CppScripts::Script { public: - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; }; diff --git a/dScripts/02_server/Map/njhub/CavePrisonCage.cpp b/dScripts/02_server/Map/njhub/CavePrisonCage.cpp index 9bd89067..8496ecfb 100644 --- a/dScripts/02_server/Map/njhub/CavePrisonCage.cpp +++ b/dScripts/02_server/Map/njhub/CavePrisonCage.cpp @@ -1,6 +1,6 @@ #include "CavePrisonCage.h" #include "EntityManager.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "GameMessages.h" #include "Character.h" #include "dZoneManager.h" @@ -45,8 +45,8 @@ void CavePrisonCage::Setup(Entity* self, Spawner* spawner) { Game::entityManager->ConstructEntity(entity); } -void CavePrisonCage::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state != eRebuildState::RESETTING) { +void CavePrisonCage::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) { + if (state != eQuickBuildState::RESETTING) { return; } @@ -68,14 +68,14 @@ void CavePrisonCage::SpawnCounterweight(Entity* self, Spawner* spawner) { self->SetVar(u"Counterweight", counterweight->GetObjectID()); - auto* rebuildComponent = counterweight->GetComponent(); + auto* quickBuildComponent = counterweight->GetComponent(); - if (rebuildComponent != nullptr) { - rebuildComponent->AddRebuildStateCallback([this, self](eRebuildState state) { - OnRebuildNotifyState(self, state); + if (quickBuildComponent != nullptr) { + quickBuildComponent->AddQuickBuildStateCallback([this, self](eQuickBuildState state) { + OnQuickBuildNotifyState(self, state); }); - rebuildComponent->AddRebuildCompleteCallback([this, self](Entity* user) { + quickBuildComponent->AddQuickBuildCompleteCallback([this, self](Entity* user) { // The counterweight is a simple mover, which is not implemented, so we'll just set it's position auto* counterweight = Game::entityManager->GetEntity(self->GetVar(u"Counterweight")); diff --git a/dScripts/02_server/Map/njhub/CavePrisonCage.h b/dScripts/02_server/Map/njhub/CavePrisonCage.h index 43d826c7..3cd3ef30 100644 --- a/dScripts/02_server/Map/njhub/CavePrisonCage.h +++ b/dScripts/02_server/Map/njhub/CavePrisonCage.h @@ -5,7 +5,7 @@ class CavePrisonCage : public CppScripts::Script { public: void OnStartup(Entity* self) override; void Setup(Entity* self, Spawner* spawner); - void OnRebuildNotifyState(Entity* self, eRebuildState state) override; + void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override; void SpawnCounterweight(Entity* self, Spawner* spawner); void GetButton(Entity* self); void OnTimerDone(Entity* self, std::string timerName) override; diff --git a/dScripts/02_server/Map/njhub/ImaginationShrineServer.cpp b/dScripts/02_server/Map/njhub/ImaginationShrineServer.cpp index 1fbfad98..f03d980d 100644 --- a/dScripts/02_server/Map/njhub/ImaginationShrineServer.cpp +++ b/dScripts/02_server/Map/njhub/ImaginationShrineServer.cpp @@ -1,15 +1,15 @@ #include "ImaginationShrineServer.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" void ImaginationShrineServer::OnUse(Entity* self, Entity* user) { // If the rebuild component is complete, use the shrine - auto* rebuildComponent = self->GetComponent(); + auto* quickBuildComponent = self->GetComponent(); - if (rebuildComponent == nullptr) { + if (quickBuildComponent == nullptr) { return; } - if (rebuildComponent->GetState() == eRebuildState::COMPLETED) { + if (quickBuildComponent->GetState() == eQuickBuildState::COMPLETED) { // Use the shrine BaseUse(self, user); } diff --git a/dScripts/02_server/Map/njhub/RainOfArrows.cpp b/dScripts/02_server/Map/njhub/RainOfArrows.cpp index 8a8f9c50..2fc73eb6 100644 --- a/dScripts/02_server/Map/njhub/RainOfArrows.cpp +++ b/dScripts/02_server/Map/njhub/RainOfArrows.cpp @@ -8,7 +8,7 @@ void RainOfArrows::OnStartup(Entity* self) { } -void RainOfArrows::OnRebuildComplete(Entity* self, Entity* target) { +void RainOfArrows::OnQuickBuildComplete(Entity* self, Entity* target) { auto myPos = self->GetPosition(); auto myRot = self->GetRotation(); diff --git a/dScripts/02_server/Map/njhub/RainOfArrows.h b/dScripts/02_server/Map/njhub/RainOfArrows.h index 778ddfea..751aeedb 100644 --- a/dScripts/02_server/Map/njhub/RainOfArrows.h +++ b/dScripts/02_server/Map/njhub/RainOfArrows.h @@ -5,7 +5,7 @@ class RainOfArrows : public CppScripts::Script { public: void OnStartup(Entity* self) override; - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; void OnTimerDone(Entity* self, std::string timerName) override; private: diff --git a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp index ccb12e30..a74e1eac 100644 --- a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp +++ b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp @@ -1,5 +1,5 @@ #include "NjMonastryBossInstance.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "DestroyableComponent.h" #include "EntityManager.h" #include "dZoneManager.h" @@ -221,26 +221,26 @@ void NjMonastryBossInstance::HandleLedgedFrakjawSpawned(Entity* self, Entity* le } void NjMonastryBossInstance::HandleCounterWeightSpawned(Entity* self, Entity* counterWeight) { - auto* rebuildComponent = counterWeight->GetComponent(); - if (rebuildComponent != nullptr) { - rebuildComponent->AddRebuildStateCallback([this, self, counterWeight](eRebuildState state) { + auto* quickBuildComponent = counterWeight->GetComponent(); + if (quickBuildComponent != nullptr) { + quickBuildComponent->AddQuickBuildStateCallback([this, self, counterWeight](eQuickBuildState state) { switch (state) { - case eRebuildState::BUILDING: + case eQuickBuildState::BUILDING: GameMessages::SendNotifyClientObject(self->GetObjectID(), PlayCinematicNotification, 0, 0, counterWeight->GetObjectID(), BaseCounterweightQB + std::to_string(self->GetVar(WaveNumberVariable)), UNASSIGNED_SYSTEM_ADDRESS); return; - case eRebuildState::INCOMPLETE: + case eQuickBuildState::INCOMPLETE: GameMessages::SendNotifyClientObject(self->GetObjectID(), EndCinematicNotification, 0, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS); return; - case eRebuildState::RESETTING: + case eQuickBuildState::RESETTING: ActivityTimerStart(self, SpawnCounterWeightTimer, 0.0f, 0.0f); return; - case eRebuildState::COMPLETED: { + case eQuickBuildState::COMPLETED: { // TODO: Move the platform? // The counterweight is actually a moving platform and we should listen to the last waypoint event here diff --git a/dScripts/02_server/Objects/AgSurvivalBuffStation.cpp b/dScripts/02_server/Objects/AgSurvivalBuffStation.cpp index 2ce44bd1..04d9711c 100644 --- a/dScripts/02_server/Objects/AgSurvivalBuffStation.cpp +++ b/dScripts/02_server/Objects/AgSurvivalBuffStation.cpp @@ -5,7 +5,7 @@ #include "SkillComponent.h" #include "TeamManager.h" -void AgSurvivalBuffStation::OnRebuildComplete(Entity* self, Entity* target) { +void AgSurvivalBuffStation::OnQuickBuildComplete(Entity* self, Entity* target) { auto destroyableComponent = self->GetComponent(); // We set the faction to 1 so that the buff station sees players as friendly targets to buff if (destroyableComponent != nullptr) destroyableComponent->SetFaction(1); diff --git a/dScripts/02_server/Objects/AgSurvivalBuffStation.h b/dScripts/02_server/Objects/AgSurvivalBuffStation.h index 5434b0cd..63b05698 100644 --- a/dScripts/02_server/Objects/AgSurvivalBuffStation.h +++ b/dScripts/02_server/Objects/AgSurvivalBuffStation.h @@ -10,7 +10,7 @@ public: * @param self The Entity that called this script. * @param target The target of the self that called this script. */ - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; void OnTimerDone(Entity* self, std::string timerName) override; private: /** diff --git a/dScripts/CppScripts.h b/dScripts/CppScripts.h index 67ecb6ff..d005a14a 100644 --- a/dScripts/CppScripts.h +++ b/dScripts/CppScripts.h @@ -9,7 +9,7 @@ class Entity; class NiPoint3; enum class eMissionState : int32_t; enum class ePetTamingNotifyType : uint32_t; -enum class eRebuildState : uint32_t; +enum class eQuickBuildState : uint32_t; namespace CppScripts { /** @@ -154,23 +154,23 @@ namespace CppScripts { /** * Invoked when a player has started building this quickbuild. * - * Equivalent to 'function onRebuildStart(self, msg)' + * Equivalent to 'function onQuickBuildStart(self, msg)' */ - virtual void OnRebuildStart(Entity* self, Entity* target) {}; + virtual void OnQuickBuildStart(Entity* self, Entity* target) {}; /** * Invoked when this quickbuild has changed state. * - * Equivalent to 'function onRebuildNotifyState(self, msg)' + * Equivalent to 'function onQuickBuildNotifyState(self, msg)' */ - virtual void OnRebuildNotifyState(Entity* self, eRebuildState state) {}; + virtual void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) {}; /** * Invoked when this quickbuild has been completed. * - * Equivalent to 'function onRebuildComplete(self, msg)' + * Equivalent to 'function OnQuickBuildComplete(self, msg)' */ - virtual void OnRebuildComplete(Entity* self, Entity* target) {}; + virtual void OnQuickBuildComplete(Entity* self, Entity* target) {}; /** * Invoked when self has received either a hit or heal. diff --git a/dScripts/ai/ACT/ActMine.cpp b/dScripts/ai/ACT/ActMine.cpp index 9651e13d..24863e50 100644 --- a/dScripts/ai/ACT/ActMine.cpp +++ b/dScripts/ai/ACT/ActMine.cpp @@ -1,22 +1,22 @@ #include "ActMine.h" #include "SkillComponent.h" #include "DestroyableComponent.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" void ActMine::OnStartup(Entity* self) { - self->SetVar(u"RebuildComplete", false); + self->SetVar(u"QuickBuildComplete", false); self->SetProximityRadius(MINE_RADIUS, "mineRadius"); } -void ActMine::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == eRebuildState::COMPLETED) { - auto* rebuild = self->GetComponent(); +void ActMine::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) { + if (state == eQuickBuildState::COMPLETED) { + auto* rebuild = self->GetComponent(); if (rebuild) { auto* builder = rebuild->GetBuilder(); self->SetVar(u"Builder", builder->GetObjectID()); } - self->SetVar(u"RebuildComplete", true); + self->SetVar(u"QuickBuildComplete", true); self->SetVar(u"NumWarnings", 0); self->AddToGroup("reset"); } @@ -26,7 +26,7 @@ void ActMine::OnRebuildNotifyState(Entity* self, eRebuildState state) { void ActMine::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { auto* detroyable = self->GetComponent(); if (!detroyable) return; - if (status == "ENTER" && self->GetVar(u"RebuildComplete") == true && detroyable->IsEnemy(entering)) { + if (status == "ENTER" && self->GetVar(u"QuickBuildComplete") == true && detroyable->IsEnemy(entering)) { GameMessages::SendPlayFXEffect(self->GetObjectID(), 242, u"orange", "sirenlight_B"); self->AddTimer("Tick", TICK_TIME); } diff --git a/dScripts/ai/ACT/ActMine.h b/dScripts/ai/ACT/ActMine.h index fb222f2e..c5077f51 100644 --- a/dScripts/ai/ACT/ActMine.h +++ b/dScripts/ai/ACT/ActMine.h @@ -4,7 +4,7 @@ class ActMine : public CppScripts::Script { public: void OnStartup(Entity* self) override; - void OnRebuildNotifyState(Entity* self, eRebuildState state) override; + void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override; void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override; void OnTimerDone(Entity* self, std::string timerName) override; private: diff --git a/dScripts/ai/AG/AgJetEffectServer.cpp b/dScripts/ai/AG/AgJetEffectServer.cpp index 5d25c9e0..69e94c8f 100644 --- a/dScripts/ai/AG/AgJetEffectServer.cpp +++ b/dScripts/ai/AG/AgJetEffectServer.cpp @@ -20,7 +20,7 @@ void AgJetEffectServer::OnUse(Entity* self, Entity* user) { self->AddTimer("CineDone", 7.5f + 5.0f); // 7.5f is time the cinematic takes to play } -void AgJetEffectServer::OnRebuildComplete(Entity* self, Entity* target) { +void AgJetEffectServer::OnQuickBuildComplete(Entity* self, Entity* target) { if (self->GetLOT() != 6209) return; auto entities = Game::entityManager->GetEntitiesInGroup("Jet_FX"); if (entities.empty()) return; diff --git a/dScripts/ai/AG/AgJetEffectServer.h b/dScripts/ai/AG/AgJetEffectServer.h index 3cb3bd83..ecac4590 100644 --- a/dScripts/ai/AG/AgJetEffectServer.h +++ b/dScripts/ai/AG/AgJetEffectServer.h @@ -6,7 +6,7 @@ class AgJetEffectServer final : public CppScripts::Script public: void OnUse(Entity* self, Entity* user) override; - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; void OnTimerDone(Entity* self, std::string timerName) override; private: diff --git a/dScripts/ai/AG/AgQbElevator.cpp b/dScripts/ai/AG/AgQbElevator.cpp index 5a535347..07cd7e61 100644 --- a/dScripts/ai/AG/AgQbElevator.cpp +++ b/dScripts/ai/AG/AgQbElevator.cpp @@ -7,7 +7,7 @@ void AgQbElevator::OnStartup(Entity* self) { } //when the QB is finished being built by a player -void AgQbElevator::OnRebuildComplete(Entity* self, Entity* target) { +void AgQbElevator::OnQuickBuildComplete(Entity* self, Entity* target) { self->SetProximityRadius(proxRadius, "elevatorProx"); self->SetI64(u"qbPlayer", target->GetObjectID()); diff --git a/dScripts/ai/AG/AgQbElevator.h b/dScripts/ai/AG/AgQbElevator.h index 4d07b8a2..de95a2ad 100644 --- a/dScripts/ai/AG/AgQbElevator.h +++ b/dScripts/ai/AG/AgQbElevator.h @@ -4,7 +4,7 @@ class AgQbElevator : public CppScripts::Script { public: void OnStartup(Entity* self) override; - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override; void OnTimerDone(Entity* self, std::string timerName) override; diff --git a/dScripts/ai/AG/AgQbWall.cpp b/dScripts/ai/AG/AgQbWall.cpp index 3e7d9c2b..987644b3 100644 --- a/dScripts/ai/AG/AgQbWall.cpp +++ b/dScripts/ai/AG/AgQbWall.cpp @@ -1,6 +1,6 @@ #include "AgQbWall.h" -void AgQbWall::OnRebuildComplete(Entity* self, Entity* player) { +void AgQbWall::OnQuickBuildComplete(Entity* self, Entity* player) { self->SetVar(u"player", player->GetObjectID()); auto targetWallSpawners = GeneralUtils::UTF16ToWTF8(self->GetVar(u"spawner")); if (targetWallSpawners != "") { diff --git a/dScripts/ai/AG/AgQbWall.h b/dScripts/ai/AG/AgQbWall.h index 93187e0e..d6704958 100644 --- a/dScripts/ai/AG/AgQbWall.h +++ b/dScripts/ai/AG/AgQbWall.h @@ -3,5 +3,5 @@ class AgQbWall : public CppScripts::Script { public: - void OnRebuildComplete(Entity* self, Entity* player) override; + void OnQuickBuildComplete(Entity* self, Entity* player) override; }; diff --git a/dScripts/ai/AG/AgTurret.cpp b/dScripts/ai/AG/AgTurret.cpp index 6db493d5..823ab96b 100644 --- a/dScripts/ai/AG/AgTurret.cpp +++ b/dScripts/ai/AG/AgTurret.cpp @@ -12,6 +12,6 @@ void AgTurret::OnTimerDone(Entity* self, std::string timerName) { } } -void AgTurret::OnRebuildStart(Entity* self, Entity* user) { +void AgTurret::OnQuickBuildStart(Entity* self, Entity* user) { GameMessages::SendLockNodeRotation(self, "base"); } diff --git a/dScripts/ai/AG/AgTurret.h b/dScripts/ai/AG/AgTurret.h index 1cbba31a..1c3aeb83 100644 --- a/dScripts/ai/AG/AgTurret.h +++ b/dScripts/ai/AG/AgTurret.h @@ -4,5 +4,5 @@ class AgTurret : public CppScripts::Script { void OnStartup(Entity* self); void OnTimerDone(Entity* self, std::string timerName); - void OnRebuildStart(Entity* self, Entity* user); + void OnQuickBuildStart(Entity* self, Entity* user); }; diff --git a/dScripts/ai/FV/ActNinjaTurret.cpp b/dScripts/ai/FV/ActNinjaTurret.cpp index ea6e2278..7bef188c 100644 --- a/dScripts/ai/FV/ActNinjaTurret.cpp +++ b/dScripts/ai/FV/ActNinjaTurret.cpp @@ -1,10 +1,10 @@ #include "ActNinjaTurret.h" -#include "eRebuildState.h" +#include "eQuickBuildState.h" -void ActNinjaTurret::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == eRebuildState::COMPLETED) { +void ActNinjaTurret::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) { + if (state == eQuickBuildState::COMPLETED) { self->SetVar(u"AmBuilt", true); - } else if (state == eRebuildState::RESETTING) { + } else if (state == eQuickBuildState::RESETTING) { self->SetVar(u"AmBuilt", false); } } diff --git a/dScripts/ai/FV/ActNinjaTurret.h b/dScripts/ai/FV/ActNinjaTurret.h index d06e6afd..5d4404b6 100644 --- a/dScripts/ai/FV/ActNinjaTurret.h +++ b/dScripts/ai/FV/ActNinjaTurret.h @@ -4,7 +4,7 @@ class ActNinjaTurret : public CppScripts::Script { public: - void OnRebuildNotifyState(Entity* self, eRebuildState state) override; + void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override; void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override; }; diff --git a/dScripts/ai/FV/ActParadoxPipeFix.cpp b/dScripts/ai/FV/ActParadoxPipeFix.cpp index aad74dec..7e6451f9 100644 --- a/dScripts/ai/FV/ActParadoxPipeFix.cpp +++ b/dScripts/ai/FV/ActParadoxPipeFix.cpp @@ -1,11 +1,11 @@ #include "ActParadoxPipeFix.h" #include "EntityManager.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "GameMessages.h" #include "MissionComponent.h" #include "eEndBehavior.h" -void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) { +void ActParadoxPipeFix::OnQuickBuildComplete(Entity* self, Entity* target) { const auto myGroup = "AllPipes"; const auto groupObjs = Game::entityManager->GetEntitiesInGroup(myGroup); @@ -19,9 +19,9 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) { continue; } - auto* rebuildComponent = object->GetComponent(); + auto* quickBuildComponent = object->GetComponent(); - if (rebuildComponent->GetState() == eRebuildState::COMPLETED) { + if (quickBuildComponent->GetState() == eQuickBuildState::COMPLETED) { indexCount++; } } @@ -51,8 +51,8 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) { } } -void ActParadoxPipeFix::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == eRebuildState::RESETTING) { +void ActParadoxPipeFix::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) { + if (state == eQuickBuildState::RESETTING) { const auto refinery = Game::entityManager->GetEntitiesInGroup("Paradox"); if (!refinery.empty()) { diff --git a/dScripts/ai/FV/ActParadoxPipeFix.h b/dScripts/ai/FV/ActParadoxPipeFix.h index df323b00..57aa5239 100644 --- a/dScripts/ai/FV/ActParadoxPipeFix.h +++ b/dScripts/ai/FV/ActParadoxPipeFix.h @@ -4,7 +4,7 @@ class ActParadoxPipeFix : public CppScripts::Script { public: - void OnRebuildComplete(Entity* self, Entity* target) override; - void OnRebuildNotifyState(Entity* self, eRebuildState state) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override; }; diff --git a/dScripts/ai/FV/FvBrickPuzzleServer.cpp b/dScripts/ai/FV/FvBrickPuzzleServer.cpp index ce12d76e..e1f1ac88 100644 --- a/dScripts/ai/FV/FvBrickPuzzleServer.cpp +++ b/dScripts/ai/FV/FvBrickPuzzleServer.cpp @@ -2,7 +2,7 @@ #include "GeneralUtils.h" #include "dZoneManager.h" #include "Spawner.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" void FvBrickPuzzleServer::OnStartup(Entity* self) { const auto myGroup = GeneralUtils::UTF16ToWTF8(self->GetVar(u"spawner_name")); @@ -59,9 +59,9 @@ void FvBrickPuzzleServer::OnDie(Entity* self, Entity* killer) { void FvBrickPuzzleServer::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "reset") { - auto* rebuildComponent = self->GetComponent(); + auto* quickBuildComponent = self->GetComponent(); - if (rebuildComponent != nullptr && rebuildComponent->GetState() == eRebuildState::OPEN) { + if (quickBuildComponent != nullptr && quickBuildComponent->GetState() == eQuickBuildState::OPEN) { self->Smash(self->GetObjectID(), eKillType::SILENT); } } diff --git a/dScripts/ai/FV/FvConsoleLeftQuickbuild.cpp b/dScripts/ai/FV/FvConsoleLeftQuickbuild.cpp index 29de1fe5..64bf5c96 100644 --- a/dScripts/ai/FV/FvConsoleLeftQuickbuild.cpp +++ b/dScripts/ai/FV/FvConsoleLeftQuickbuild.cpp @@ -2,15 +2,15 @@ #include "EntityManager.h" #include "GameMessages.h" #include "eTerminateType.h" -#include "eRebuildState.h" +#include "eQuickBuildState.h" void FvConsoleLeftQuickbuild::OnStartup(Entity* self) { self->SetVar(u"IAmBuilt", false); self->SetVar(u"AmActive", false); } -void FvConsoleLeftQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == eRebuildState::COMPLETED) { +void FvConsoleLeftQuickbuild::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) { + if (state == eQuickBuildState::COMPLETED) { self->SetVar(u"IAmBuilt", true); const auto objects = Game::entityManager->GetEntitiesInGroup("Facility"); @@ -18,7 +18,7 @@ void FvConsoleLeftQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState s if (!objects.empty()) { objects[0]->NotifyObject(self, "ConsoleLeftUp"); } - } else if (state == eRebuildState::RESETTING) { + } else if (state == eQuickBuildState::RESETTING) { self->SetVar(u"IAmBuilt", false); self->SetVar(u"AmActive", false); diff --git a/dScripts/ai/FV/FvConsoleLeftQuickbuild.h b/dScripts/ai/FV/FvConsoleLeftQuickbuild.h index bbdea27e..2ce83e25 100644 --- a/dScripts/ai/FV/FvConsoleLeftQuickbuild.h +++ b/dScripts/ai/FV/FvConsoleLeftQuickbuild.h @@ -5,6 +5,6 @@ class FvConsoleLeftQuickbuild : public CppScripts::Script { public: void OnStartup(Entity* self) override; - void OnRebuildNotifyState(Entity* self, eRebuildState state) override; + void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override; void OnUse(Entity* self, Entity* user) override; }; diff --git a/dScripts/ai/FV/FvConsoleRightQuickbuild.cpp b/dScripts/ai/FV/FvConsoleRightQuickbuild.cpp index 20194f8d..9703c3c4 100644 --- a/dScripts/ai/FV/FvConsoleRightQuickbuild.cpp +++ b/dScripts/ai/FV/FvConsoleRightQuickbuild.cpp @@ -2,15 +2,15 @@ #include "EntityManager.h" #include "GameMessages.h" #include "eTerminateType.h" -#include "eRebuildState.h" +#include "eQuickBuildState.h" void FvConsoleRightQuickbuild::OnStartup(Entity* self) { self->SetVar(u"IAmBuilt", false); self->SetVar(u"AmActive", false); } -void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == eRebuildState::COMPLETED) { +void FvConsoleRightQuickbuild::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) { + if (state == eQuickBuildState::COMPLETED) { self->SetVar(u"IAmBuilt", true); const auto objects = Game::entityManager->GetEntitiesInGroup("Facility"); @@ -18,7 +18,7 @@ void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState if (!objects.empty()) { objects[0]->NotifyObject(self, "ConsoleRightUp"); } - } else if (state == eRebuildState::RESETTING) { + } else if (state == eQuickBuildState::RESETTING) { self->SetVar(u"IAmBuilt", false); self->SetVar(u"AmActive", false); diff --git a/dScripts/ai/FV/FvConsoleRightQuickbuild.h b/dScripts/ai/FV/FvConsoleRightQuickbuild.h index fab8c814..a066204c 100644 --- a/dScripts/ai/FV/FvConsoleRightQuickbuild.h +++ b/dScripts/ai/FV/FvConsoleRightQuickbuild.h @@ -5,6 +5,6 @@ class FvConsoleRightQuickbuild : public CppScripts::Script { public: void OnStartup(Entity* self) override; - void OnRebuildNotifyState(Entity* self, eRebuildState state) override; + void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override; void OnUse(Entity* self, Entity* user) override; }; diff --git a/dScripts/ai/FV/FvDragonSmashingGolemQb.cpp b/dScripts/ai/FV/FvDragonSmashingGolemQb.cpp index 3f3121ef..3706abba 100644 --- a/dScripts/ai/FV/FvDragonSmashingGolemQb.cpp +++ b/dScripts/ai/FV/FvDragonSmashingGolemQb.cpp @@ -3,7 +3,7 @@ #include "EntityManager.h" #include "RenderComponent.h" #include "Entity.h" -#include "eRebuildState.h" +#include "eQuickBuildState.h" void FvDragonSmashingGolemQb::OnStartup(Entity* self) { self->AddTimer("GolemBreakTimer", 10.5f); @@ -15,8 +15,8 @@ void FvDragonSmashingGolemQb::OnTimerDone(Entity* self, std::string timerName) { } } -void FvDragonSmashingGolemQb::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == eRebuildState::COMPLETED) { +void FvDragonSmashingGolemQb::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) { + if (state == eQuickBuildState::COMPLETED) { RenderComponent::PlayAnimation(self, u"dragonsmash"); const auto dragonId = self->GetVar(u"Dragon"); diff --git a/dScripts/ai/FV/FvDragonSmashingGolemQb.h b/dScripts/ai/FV/FvDragonSmashingGolemQb.h index 8aa772a3..7ee0e775 100644 --- a/dScripts/ai/FV/FvDragonSmashingGolemQb.h +++ b/dScripts/ai/FV/FvDragonSmashingGolemQb.h @@ -6,5 +6,5 @@ class FvDragonSmashingGolemQb : public CppScripts::Script public: void OnStartup(Entity* self) override; void OnTimerDone(Entity* self, std::string timerName) override; - void OnRebuildNotifyState(Entity* self, eRebuildState state) override; + void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override; }; diff --git a/dScripts/ai/GF/GfArchway.cpp b/dScripts/ai/GF/GfArchway.cpp index 429f62ae..571a9c2a 100644 --- a/dScripts/ai/GF/GfArchway.cpp +++ b/dScripts/ai/GF/GfArchway.cpp @@ -2,7 +2,7 @@ #include "Entity.h" #include "SkillComponent.h" -void GfArchway::OnRebuildComplete(Entity* self, Entity* target) { +void GfArchway::OnQuickBuildComplete(Entity* self, Entity* target) { auto* skillComponent = target->GetComponent(); if (skillComponent) skillComponent->CalculateBehavior(SHIELDING_SKILL, SHIELDING_BEHAVIOR, target->GetObjectID(), true); } diff --git a/dScripts/ai/GF/GfArchway.h b/dScripts/ai/GF/GfArchway.h index b60b2a9f..a12dc812 100644 --- a/dScripts/ai/GF/GfArchway.h +++ b/dScripts/ai/GF/GfArchway.h @@ -3,7 +3,7 @@ class GfArchway : public CppScripts::Script { public: - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; private: const uint32_t SHIELDING_SKILL = 863; const uint32_t SHIELDING_BEHAVIOR = 3788; diff --git a/dScripts/ai/GF/GfJailWalls.cpp b/dScripts/ai/GF/GfJailWalls.cpp index 1efca1cf..d93836d2 100644 --- a/dScripts/ai/GF/GfJailWalls.cpp +++ b/dScripts/ai/GF/GfJailWalls.cpp @@ -1,9 +1,9 @@ #include "GfJailWalls.h" #include "dZoneManager.h" #include "GeneralUtils.h" -#include "eRebuildState.h" +#include "eQuickBuildState.h" -void GfJailWalls::OnRebuildComplete(Entity* self, Entity* target) { +void GfJailWalls::OnQuickBuildComplete(Entity* self, Entity* target) { const auto wall = GeneralUtils::UTF16ToWTF8(self->GetVar(u"Wall")); for (auto* spawner : Game::zoneManager->GetSpawnersByName("Jail0" + wall)) { @@ -15,8 +15,8 @@ void GfJailWalls::OnRebuildComplete(Entity* self, Entity* target) { } } -void GfJailWalls::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state != eRebuildState::RESETTING) return; +void GfJailWalls::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) { + if (state != eQuickBuildState::RESETTING) return; const auto wall = GeneralUtils::UTF16ToWTF8(self->GetVar(u"Wall")); diff --git a/dScripts/ai/GF/GfJailWalls.h b/dScripts/ai/GF/GfJailWalls.h index f755f4d7..12d0a107 100644 --- a/dScripts/ai/GF/GfJailWalls.h +++ b/dScripts/ai/GF/GfJailWalls.h @@ -4,6 +4,6 @@ class GfJailWalls final : public CppScripts::Script { public: - void OnRebuildComplete(Entity* self, Entity* target) override; - void OnRebuildNotifyState(Entity* self, eRebuildState state) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override; }; diff --git a/dScripts/ai/GF/PetDigBuild.cpp b/dScripts/ai/GF/PetDigBuild.cpp index 9732e56b..9caf2f8c 100644 --- a/dScripts/ai/GF/PetDigBuild.cpp +++ b/dScripts/ai/GF/PetDigBuild.cpp @@ -4,7 +4,7 @@ #include "MissionComponent.h" #include "eMissionState.h" -void PetDigBuild::OnRebuildComplete(Entity* self, Entity* target) { +void PetDigBuild::OnQuickBuildComplete(Entity* self, Entity* target) { auto flagNumber = self->GetVar(u"flagNum"); EntityInfo info{}; diff --git a/dScripts/ai/GF/PetDigBuild.h b/dScripts/ai/GF/PetDigBuild.h index f342d7bb..561ba509 100644 --- a/dScripts/ai/GF/PetDigBuild.h +++ b/dScripts/ai/GF/PetDigBuild.h @@ -4,6 +4,6 @@ class PetDigBuild : public CppScripts::Script { public: - void OnRebuildComplete(Entity* self, Entity* target); + void OnQuickBuildComplete(Entity* self, Entity* target); void OnDie(Entity* self, Entity* killer); }; diff --git a/dScripts/ai/NS/NsConcertInstrument.cpp b/dScripts/ai/NS/NsConcertInstrument.cpp index bd397fbb..de234b2b 100644 --- a/dScripts/ai/NS/NsConcertInstrument.cpp +++ b/dScripts/ai/NS/NsConcertInstrument.cpp @@ -3,7 +3,7 @@ #include "Item.h" #include "DestroyableComponent.h" #include "EntityManager.h" -#include "RebuildComponent.h" +#include "QuickBuildComponent.h" #include "SoundTriggerComponent.h" #include "InventoryComponent.h" #include "MissionComponent.h" @@ -20,13 +20,13 @@ void NsConcertInstrument::OnStartup(Entity* self) { self->SetVar(u"oldItemRight", LWOOBJID_EMPTY); } -void NsConcertInstrument::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == eRebuildState::RESETTING || state == eRebuildState::OPEN) { +void NsConcertInstrument::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) { + if (state == eQuickBuildState::RESETTING || state == eQuickBuildState::OPEN) { self->SetVar(u"activePlayer", LWOOBJID_EMPTY); } } -void NsConcertInstrument::OnRebuildComplete(Entity* self, Entity* target) { +void NsConcertInstrument::OnQuickBuildComplete(Entity* self, Entity* target) { if (!target->GetIsDead()) { self->SetVar(u"activePlayer", target->GetObjectID()); @@ -93,9 +93,9 @@ void NsConcertInstrument::OnTimerDone(Entity* self, std::string name) { activePlayer->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS); } - auto* rebuildComponent = self->GetComponent(); - if (rebuildComponent != nullptr) - rebuildComponent->ResetRebuild(false); + auto* quickBuildComponent = self->GetComponent(); + if (quickBuildComponent != nullptr) + quickBuildComponent->ResetQuickBuild(false); self->Smash(self->GetObjectID(), eKillType::VIOLENT); self->SetVar(u"activePlayer", LWOOBJID_EMPTY); diff --git a/dScripts/ai/NS/NsConcertInstrument.h b/dScripts/ai/NS/NsConcertInstrument.h index 87ccc419..acdb6327 100644 --- a/dScripts/ai/NS/NsConcertInstrument.h +++ b/dScripts/ai/NS/NsConcertInstrument.h @@ -11,10 +11,10 @@ enum InstrumentLot { class NsConcertInstrument : public CppScripts::Script { public: void OnStartup(Entity* self) override; - void OnRebuildNotifyState(Entity* self, eRebuildState state) override; + void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override; void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override; - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; void OnTimerDone(Entity* self, std::string name) override; private: static void StartPlayingInstrument(Entity* self, Entity* player); diff --git a/dScripts/ai/NS/NsConcertQuickBuild.cpp b/dScripts/ai/NS/NsConcertQuickBuild.cpp index 960b90d5..7fd3f125 100644 --- a/dScripts/ai/NS/NsConcertQuickBuild.cpp +++ b/dScripts/ai/NS/NsConcertQuickBuild.cpp @@ -80,7 +80,7 @@ void NsConcertQuickBuild::OnDie(Entity* self, Entity* killer) { finishedQuickBuilds.erase(position); } -void NsConcertQuickBuild::OnRebuildComplete(Entity* self, Entity* target) { +void NsConcertQuickBuild::OnQuickBuildComplete(Entity* self, Entity* target) { const auto groupNumber = self->GetVar(u"groupNumber"); finishedQuickBuilds.push_back(self->GetObjectID()); self->SetNetworkVar(u"startEffect", -1.0f); diff --git a/dScripts/ai/NS/NsConcertQuickBuild.h b/dScripts/ai/NS/NsConcertQuickBuild.h index 667580f6..d940c3c9 100644 --- a/dScripts/ai/NS/NsConcertQuickBuild.h +++ b/dScripts/ai/NS/NsConcertQuickBuild.h @@ -9,7 +9,7 @@ struct QuickBuildSet { class NsConcertQuickBuild : public CppScripts::Script { public: void OnStartup(Entity* self) override; - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; void OnDie(Entity* self, Entity* killer) override; private: static std::vector finishedQuickBuilds; diff --git a/dScripts/ai/NS/NsQbImaginationStatue.cpp b/dScripts/ai/NS/NsQbImaginationStatue.cpp index 8f9a0b09..0d080d54 100644 --- a/dScripts/ai/NS/NsQbImaginationStatue.cpp +++ b/dScripts/ai/NS/NsQbImaginationStatue.cpp @@ -6,7 +6,7 @@ void NsQbImaginationStatue::OnStartup(Entity* self) { } -void NsQbImaginationStatue::OnRebuildComplete(Entity* self, Entity* target) { +void NsQbImaginationStatue::OnQuickBuildComplete(Entity* self, Entity* target) { if (target == nullptr) return; self->SetVar(u"Player", target->GetObjectID()); diff --git a/dScripts/ai/NS/NsQbImaginationStatue.h b/dScripts/ai/NS/NsQbImaginationStatue.h index b7a78c32..b9a61ba8 100644 --- a/dScripts/ai/NS/NsQbImaginationStatue.h +++ b/dScripts/ai/NS/NsQbImaginationStatue.h @@ -5,7 +5,7 @@ class NsQbImaginationStatue : public CppScripts::Script { public: void OnStartup(Entity* self) override; - void OnRebuildComplete(Entity* self, Entity* target) override; + void OnQuickBuildComplete(Entity* self, Entity* target) override; void OnTimerDone(Entity* self, std::string timerName) override; void SpawnLoot(Entity* self); }; From 1bdce8384fa3ced13e553c59224181c8556104ab Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Thu, 28 Dec 2023 22:24:45 -0600 Subject: [PATCH 04/11] fix: LUP Exhibit component type and use delta compression on serialization (#1365) * fix: component type and use delta compression on serialization * sorry jett, emo made me do it --- dGame/dComponents/LUPExhibitComponent.cpp | 38 ++++++----------------- dGame/dComponents/LUPExhibitComponent.h | 37 ++++++---------------- 2 files changed, 19 insertions(+), 56 deletions(-) diff --git a/dGame/dComponents/LUPExhibitComponent.cpp b/dGame/dComponents/LUPExhibitComponent.cpp index 151f2897..a312617d 100644 --- a/dGame/dComponents/LUPExhibitComponent.cpp +++ b/dGame/dComponents/LUPExhibitComponent.cpp @@ -1,44 +1,24 @@ #include "LUPExhibitComponent.h" - #include "EntityManager.h" -LUPExhibitComponent::LUPExhibitComponent(Entity* parent) : Component(parent) { - m_Exhibits = { 11121, 11295, 11423, 11979 }; - - m_ExhibitIndex = 0; - - m_Exhibit = m_Exhibits[m_ExhibitIndex]; - - -} - -LUPExhibitComponent::~LUPExhibitComponent() { - -} - void LUPExhibitComponent::Update(float deltaTime) { m_UpdateTimer += deltaTime; - if (m_UpdateTimer > 20.0f) { - NextExhibit(); - + NextLUPExhibit(); m_UpdateTimer = 0.0f; } } -void LUPExhibitComponent::NextExhibit() { - m_ExhibitIndex++; - - if (m_ExhibitIndex >= m_Exhibits.size()) { - m_ExhibitIndex = 0; - } - - m_Exhibit = m_Exhibits[m_ExhibitIndex]; - +void LUPExhibitComponent::NextLUPExhibit() { + m_LUPExhibitIndex++; + m_DirtyLUPExhibit = true; Game::entityManager->SerializeEntity(m_Parent); } void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write1(); // Dirty flag? - outBitStream->Write(m_Exhibit); + outBitStream->Write(m_DirtyLUPExhibit); + if (m_DirtyLUPExhibit) { + outBitStream->Write(m_LUPExhibits[m_LUPExhibitIndex % m_LUPExhibits.size()]); + if (!bIsInitialUpdate) m_DirtyLUPExhibit = false; + } } diff --git a/dGame/dComponents/LUPExhibitComponent.h b/dGame/dComponents/LUPExhibitComponent.h index 646d361c..47b13a17 100644 --- a/dGame/dComponents/LUPExhibitComponent.h +++ b/dGame/dComponents/LUPExhibitComponent.h @@ -3,6 +3,9 @@ #include "Component.h" #include "Entity.h" #include "eReplicaComponentType.h" +#include +#include +#include "dCommonVars.h" /** * Component that handles the LOT that is shown in the LUP exhibit in the LUP world. Works by setting a timer and @@ -11,35 +14,15 @@ class LUPExhibitComponent : public Component { public: - inline static const eReplicaComponentType ComponentType = eReplicaComponentType::EXHIBIT; + inline static const eReplicaComponentType ComponentType = eReplicaComponentType::LUP_EXHIBIT; - LUPExhibitComponent(Entity* parent); - ~LUPExhibitComponent(); + LUPExhibitComponent(Entity* parent) : Component(parent) {}; void Update(float deltaTime) override; void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; - - /** - * After the timer runs out, this changes the currently exhibited LOT to the next one - */ - void NextExhibit(); + void NextLUPExhibit(); private: - /** - * The LOT that's currently on exhibit - */ - LOT m_Exhibit; - - /** - * The time since we've last updated the exhibit - */ - float m_UpdateTimer; - - /** - * The list of possible exhibits to show - */ - std::vector m_Exhibits; - - /** - * The current index in the exhibit list - */ - size_t m_ExhibitIndex; + float m_UpdateTimer = 0.0f; + std::array m_LUPExhibits = { 11121, 11295, 11423, 11979 }; + uint8_t m_LUPExhibitIndex = 0; + bool m_DirtyLUPExhibit = true; }; From f08df25085c671b979d041b8ec2dd7778313f614 Mon Sep 17 00:00:00 2001 From: Daniel Seiler Date: Sat, 30 Dec 2023 08:00:43 +0100 Subject: [PATCH 05/11] feat: split out system() calls from the rest of MasterServer (#1368) --- dMasterServer/CMakeLists.txt | 1 + dMasterServer/InstanceManager.cpp | 54 ++--------------------- dMasterServer/MasterServer.cpp | 40 +---------------- dMasterServer/Start.cpp | 71 +++++++++++++++++++++++++++++++ dMasterServer/Start.h | 6 +++ 5 files changed, 83 insertions(+), 89 deletions(-) create mode 100644 dMasterServer/Start.cpp create mode 100644 dMasterServer/Start.h diff --git a/dMasterServer/CMakeLists.txt b/dMasterServer/CMakeLists.txt index 2161681f..656a026a 100644 --- a/dMasterServer/CMakeLists.txt +++ b/dMasterServer/CMakeLists.txt @@ -1,6 +1,7 @@ set(DMASTERSERVER_SOURCES "InstanceManager.cpp" "ObjectIDManager.cpp" + "Start.cpp" ) add_library(dMasterServer ${DMASTERSERVER_SOURCES}) diff --git a/dMasterServer/InstanceManager.cpp b/dMasterServer/InstanceManager.cpp index 28ee37b5..51aad2cc 100644 --- a/dMasterServer/InstanceManager.cpp +++ b/dMasterServer/InstanceManager.cpp @@ -9,10 +9,11 @@ #include "CDZoneTableTable.h" #include "MasterPackets.h" #include "BitStreamUtils.h" -#include "BinaryPathFinder.h" #include "eConnectionType.h" #include "eMasterMessageType.h" +#include "Start.h" + InstanceManager::InstanceManager(Logger* logger, const std::string& externalIP) { mLogger = logger; mExternalIP = externalIP; @@ -57,33 +58,7 @@ Instance* InstanceManager::GetInstance(LWOMAPID mapID, bool isFriendTransfer, LW instance = new Instance(mExternalIP, port, mapID, ++m_LastInstanceID, cloneID, softCap, maxPlayers); //Start the actual process: -#ifdef _WIN32 - std::string cmd = "start " + (BinaryPathFinder::GetBinaryDir() / "WorldServer.exe").string() + " -zone "; -#else - std::string cmd; - if (std::atoi(Game::config->GetValue("use_sudo_world").c_str())) { - cmd = "sudo " + (BinaryPathFinder::GetBinaryDir() / "WorldServer").string() + " -zone "; - } else { - cmd = (BinaryPathFinder::GetBinaryDir() / "WorldServer").string() + " -zone "; - } -#endif - - cmd.append(std::to_string(mapID)); - cmd.append(" -port "); - cmd.append(std::to_string(port)); - cmd.append(" -instance "); - cmd.append(std::to_string(m_LastInstanceID)); - cmd.append(" -maxclients "); - cmd.append(std::to_string(maxPlayers)); - - cmd.append(" -clone "); - cmd.append(std::to_string(cloneID)); - -#ifndef _WIN32 - cmd.append("&"); //Sends our next process to the background on Linux -#endif - - auto ret = system(cmd.c_str()); + StartWorldServer(mapID, port, m_LastInstanceID, maxPlayers, cloneID); m_Instances.push_back(instance); @@ -318,28 +293,7 @@ Instance* InstanceManager::CreatePrivateInstance(LWOMAPID mapID, LWOCLONEID clon instance = new Instance(mExternalIP, port, mapID, ++m_LastInstanceID, cloneID, maxPlayers, maxPlayers, true, password); //Start the actual process: - std::string cmd = "start " + (BinaryPathFinder::GetBinaryDir() / "WorldServer").string() + " -zone "; - -#ifndef _WIN32 - cmd = (BinaryPathFinder::GetBinaryDir() / "WorldServer").string() + " -zone "; -#endif - - cmd.append(std::to_string(mapID)); - cmd.append(" -port "); - cmd.append(std::to_string(port)); - cmd.append(" -instance "); - cmd.append(std::to_string(m_LastInstanceID)); - cmd.append(" -maxclients "); - cmd.append(std::to_string(maxPlayers)); - - cmd.append(" -clone "); - cmd.append(std::to_string(cloneID)); - -#ifndef WIN32 - cmd.append("&"); //Sends our next process to the background on Linux -#endif - - auto ret = system(cmd.c_str()); + StartWorldServer(mapID, port, m_LastInstanceID, maxPlayers, cloneID); m_Instances.push_back(instance); diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index 1f62a64e..d7d21243 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -43,6 +43,7 @@ #include "PacketUtils.h" #include "FdbToSqlite.h" #include "BitStreamUtils.h" +#include "Start.h" namespace Game { Logger* logger = nullptr; @@ -58,8 +59,6 @@ bool shutdownSequenceStarted = false; void ShutdownSequence(int32_t signal = -1); int32_t FinalizeShutdown(int32_t signal = -1); Logger* SetupLogger(); -void StartAuthServer(); -void StartChatServer(); void HandlePacket(Packet* packet); std::map activeSessions; SystemAddress authServerMasterPeerSysAddr; @@ -814,43 +813,6 @@ void HandlePacket(Packet* packet) { } } -void StartChatServer() { - if (Game::shouldShutdown) { - LOG("Currently shutting down. Chat will not be restarted."); - return; - } -#ifdef __APPLE__ - //macOS doesn't need sudo to run on ports < 1024 - auto result = system(((BinaryPathFinder::GetBinaryDir() / "ChatServer").string() + "&").c_str()); -#elif _WIN32 - auto result = system(("start " + (BinaryPathFinder::GetBinaryDir() / "ChatServer.exe").string()).c_str()); -#else - if (std::atoi(Game::config->GetValue("use_sudo_chat").c_str())) { - auto result = system(("sudo " + (BinaryPathFinder::GetBinaryDir() / "ChatServer").string() + "&").c_str()); - } else { - auto result = system(((BinaryPathFinder::GetBinaryDir() / "ChatServer").string() + "&").c_str()); -} -#endif -} - -void StartAuthServer() { - if (Game::shouldShutdown) { - LOG("Currently shutting down. Auth will not be restarted."); - return; - } -#ifdef __APPLE__ - auto result = system(((BinaryPathFinder::GetBinaryDir() / "AuthServer").string() + "&").c_str()); -#elif _WIN32 - auto result = system(("start " + (BinaryPathFinder::GetBinaryDir() / "AuthServer.exe").string()).c_str()); -#else - if (std::atoi(Game::config->GetValue("use_sudo_auth").c_str())) { - auto result = system(("sudo " + (BinaryPathFinder::GetBinaryDir() / "AuthServer").string() + "&").c_str()); - } else { - auto result = system(((BinaryPathFinder::GetBinaryDir() / "AuthServer").string() + "&").c_str()); -} -#endif -} - void ShutdownSequence(int32_t signal) { if (shutdownSequenceStarted) { return; diff --git a/dMasterServer/Start.cpp b/dMasterServer/Start.cpp new file mode 100644 index 00000000..8ef571f3 --- /dev/null +++ b/dMasterServer/Start.cpp @@ -0,0 +1,71 @@ +#include "Start.h" +#include "Logger.h" +#include "dConfig.h" +#include "Game.h" +#include "BinaryPathFinder.h" + +void StartChatServer() { + if (Game::shouldShutdown) { + LOG("Currently shutting down. Chat will not be restarted."); + return; + } +#ifdef __APPLE__ + //macOS doesn't need sudo to run on ports < 1024 + auto result = system(((BinaryPathFinder::GetBinaryDir() / "ChatServer").string() + "&").c_str()); +#elif _WIN32 + auto result = system(("start " + (BinaryPathFinder::GetBinaryDir() / "ChatServer.exe").string()).c_str()); +#else + if (std::atoi(Game::config->GetValue("use_sudo_chat").c_str())) { + auto result = system(("sudo " + (BinaryPathFinder::GetBinaryDir() / "ChatServer").string() + "&").c_str()); + } else { + auto result = system(((BinaryPathFinder::GetBinaryDir() / "ChatServer").string() + "&").c_str()); +} +#endif +} + +void StartAuthServer() { + if (Game::shouldShutdown) { + LOG("Currently shutting down. Auth will not be restarted."); + return; + } +#ifdef __APPLE__ + auto result = system(((BinaryPathFinder::GetBinaryDir() / "AuthServer").string() + "&").c_str()); +#elif _WIN32 + auto result = system(("start " + (BinaryPathFinder::GetBinaryDir() / "AuthServer.exe").string()).c_str()); +#else + if (std::atoi(Game::config->GetValue("use_sudo_auth").c_str())) { + auto result = system(("sudo " + (BinaryPathFinder::GetBinaryDir() / "AuthServer").string() + "&").c_str()); + } else { + auto result = system(((BinaryPathFinder::GetBinaryDir() / "AuthServer").string() + "&").c_str()); +} +#endif +} + +void StartWorldServer(LWOMAPID mapID, uint16_t port, LWOINSTANCEID lastInstanceID, int maxPlayers, LWOCLONEID cloneID) { +#ifdef _WIN32 + std::string cmd = "start " + (BinaryPathFinder::GetBinaryDir() / "WorldServer.exe").string() + " -zone "; +#else + std::string cmd; + if (std::atoi(Game::config->GetValue("use_sudo_world").c_str())) { + cmd = "sudo " + (BinaryPathFinder::GetBinaryDir() / "WorldServer").string() + " -zone "; + } else { + cmd = (BinaryPathFinder::GetBinaryDir() / "WorldServer").string() + " -zone "; + } +#endif + + cmd.append(std::to_string(mapID)); + cmd.append(" -port "); + cmd.append(std::to_string(port)); + cmd.append(" -instance "); + cmd.append(std::to_string(lastInstanceID)); + cmd.append(" -maxclients "); + cmd.append(std::to_string(maxPlayers)); + cmd.append(" -clone "); + cmd.append(std::to_string(cloneID)); + +#ifndef _WIN32 + cmd.append("&"); //Sends our next process to the background on Linux +#endif + + auto ret = system(cmd.c_str()); +} diff --git a/dMasterServer/Start.h b/dMasterServer/Start.h new file mode 100644 index 00000000..98c83233 --- /dev/null +++ b/dMasterServer/Start.h @@ -0,0 +1,6 @@ +#pragma once +#include "dCommonVars.h" + +void StartAuthServer(); +void StartChatServer(); +void StartWorldServer(LWOMAPID mapID, uint16_t port, LWOINSTANCEID lastInstanceID, int maxPlayers, LWOCLONEID cloneID); From dd9d94f75f43420f7e51e42f24339de375ff4fd4 Mon Sep 17 00:00:00 2001 From: Daniel Seiler Date: Sat, 30 Dec 2023 08:04:09 +0100 Subject: [PATCH 06/11] feat: allow env var override for game config (#1367) --- dCommon/dConfig.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dCommon/dConfig.cpp b/dCommon/dConfig.cpp index 35048d64..fc8097b8 100644 --- a/dCommon/dConfig.cpp +++ b/dCommon/dConfig.cpp @@ -34,6 +34,11 @@ void dConfig::ReloadConfig() { } const std::string& dConfig::GetValue(std::string key) { + std::string upper_key(key); + std::transform(upper_key.begin(), upper_key.end(), upper_key.begin(), ::toupper); + if (const char* env_p = std::getenv(upper_key.c_str())) { + this->m_ConfigValues[key] = env_p; + } return this->m_ConfigValues[key]; } From 98d2f25af2d224468fefba69b4b78dadf170ee55 Mon Sep 17 00:00:00 2001 From: Daniel Seiler Date: Sat, 30 Dec 2023 08:04:26 +0100 Subject: [PATCH 07/11] feat: get & print std::current_exception (#1366) --- dCommon/Diagnostics.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dCommon/Diagnostics.cpp b/dCommon/Diagnostics.cpp index 2dd4a850..a4055086 100644 --- a/dCommon/Diagnostics.cpp +++ b/dCommon/Diagnostics.cpp @@ -115,6 +115,13 @@ void GenerateDump() { } void CatchUnhandled(int sig) { + std::exception_ptr eptr = std::current_exception(); + try { + if (eptr) std::rethrow_exception(eptr); + } catch(const std::exception& e) { + LOG("Caught exception: '%s'", e.what()); + } + #ifndef __include_backtrace__ std::string fileName = Diagnostics::GetOutDirectory() + "crash_" + Diagnostics::GetProcessName() + "_" + std::to_string(getpid()) + ".log"; From 42a71bbeab44f94ec69d5b4ab8a07ed68417695d Mon Sep 17 00:00:00 2001 From: Daniel Seiler Date: Sat, 30 Dec 2023 14:07:49 +0100 Subject: [PATCH 08/11] feat: add DLU_CONFIG_DIR env var (#1370) * feat: add DLU_CONFIG_DIR env var * fix: PascalCase --- dAuthServer/AuthServer.cpp | 2 +- dChatServer/ChatServer.cpp | 2 +- dCommon/dConfig.cpp | 19 +++++++++++++++++-- dCommon/dConfig.h | 5 +++++ dMasterServer/MasterServer.cpp | 12 ++++++------ dWorldServer/WorldServer.cpp | 2 +- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/dAuthServer/AuthServer.cpp b/dAuthServer/AuthServer.cpp index 7cc28263..8f1b2e76 100644 --- a/dAuthServer/AuthServer.cpp +++ b/dAuthServer/AuthServer.cpp @@ -47,7 +47,7 @@ int main(int argc, char** argv) { if (!Game::logger) return EXIT_FAILURE; //Read our config: - Game::config = new dConfig((BinaryPathFinder::GetBinaryDir() / "authconfig.ini").string()); + Game::config = new dConfig("authconfig.ini"); Game::logger->SetLogToConsole(Game::config->GetValue("log_to_console") != "0"); Game::logger->SetLogDebugStatements(Game::config->GetValue("log_debug_statements") == "1"); diff --git a/dChatServer/ChatServer.cpp b/dChatServer/ChatServer.cpp index fccbdb23..49e427c8 100644 --- a/dChatServer/ChatServer.cpp +++ b/dChatServer/ChatServer.cpp @@ -53,7 +53,7 @@ int main(int argc, char** argv) { if (!Game::logger) return EXIT_FAILURE; //Read our config: - Game::config = new dConfig((BinaryPathFinder::GetBinaryDir() / "chatconfig.ini").string()); + Game::config = new dConfig("chatconfig.ini"); Game::logger->SetLogToConsole(Game::config->GetValue("log_to_console") != "0"); Game::logger->SetLogDebugStatements(Game::config->GetValue("log_debug_statements") == "1"); diff --git a/dCommon/dConfig.cpp b/dCommon/dConfig.cpp index fc8097b8..56a43848 100644 --- a/dCommon/dConfig.cpp +++ b/dCommon/dConfig.cpp @@ -10,8 +10,23 @@ dConfig::dConfig(const std::string& filepath) { LoadConfig(); } +std::filesystem::path GetConfigDir() { + std::filesystem::path config_dir = BinaryPathFinder::GetBinaryDir(); + if (const char* env_p = std::getenv("DLU_CONFIG_DIR")) { + config_dir /= env_p; + } + return config_dir; +} + +const bool dConfig::Exists(const std::string& filepath) { + std::filesystem::path config_dir = GetConfigDir(); + return std::filesystem::exists(config_dir / filepath); +} + void dConfig::LoadConfig() { - std::ifstream in(BinaryPathFinder::GetBinaryDir() / m_ConfigFilePath); + std::filesystem::path config_dir = GetConfigDir(); + + std::ifstream in(config_dir / m_ConfigFilePath); if (!in.good()) return; std::string line{}; @@ -19,7 +34,7 @@ void dConfig::LoadConfig() { if (!line.empty() && line.front() != '#') ProcessLine(line); } - std::ifstream sharedConfig(BinaryPathFinder::GetBinaryDir() / "sharedconfig.ini", std::ios::in); + std::ifstream sharedConfig(config_dir / "sharedconfig.ini", std::ios::in); if (!sharedConfig.good()) return; line.clear(); diff --git a/dCommon/dConfig.h b/dCommon/dConfig.h index 562c1ce9..65415eea 100644 --- a/dCommon/dConfig.h +++ b/dCommon/dConfig.h @@ -7,6 +7,11 @@ class dConfig { public: dConfig(const std::string& filepath); + /** + * Checks whether the specified filepath exists + */ + static const bool Exists(const std::string& filepath); + /** * Gets the specified key from the config. Returns an empty string if the value is not found. * diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index d7d21243..39cf2495 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -84,32 +84,32 @@ int main(int argc, char** argv) { Game::logger = SetupLogger(); if (!Game::logger) return EXIT_FAILURE; - if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / "authconfig.ini")) { + if (!dConfig::Exists("authconfig.ini")) { LOG("Couldnt find authconfig.ini"); return EXIT_FAILURE; } - if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / "chatconfig.ini")) { + if (!dConfig::Exists("chatconfig.ini")) { LOG("Couldnt find chatconfig.ini"); return EXIT_FAILURE; } - if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / "masterconfig.ini")) { + if (!dConfig::Exists("masterconfig.ini")) { LOG("Couldnt find masterconfig.ini"); return EXIT_FAILURE; } - if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / "sharedconfig.ini")) { + if (!dConfig::Exists("sharedconfig.ini")) { LOG("Couldnt find sharedconfig.ini"); return EXIT_FAILURE; } - if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / "worldconfig.ini")) { + if (!dConfig::Exists("worldconfig.ini")) { LOG("Couldnt find worldconfig.ini"); return EXIT_FAILURE; } - Game::config = new dConfig((BinaryPathFinder::GetBinaryDir() / "masterconfig.ini").string()); + Game::config = new dConfig("masterconfig.ini"); Game::logger->SetLogToConsole(Game::config->GetValue("log_to_console") != "0"); Game::logger->SetLogDebugStatements(Game::config->GetValue("log_debug_statements") == "1"); diff --git a/dWorldServer/WorldServer.cpp b/dWorldServer/WorldServer.cpp index 078ea50f..c42486e0 100644 --- a/dWorldServer/WorldServer.cpp +++ b/dWorldServer/WorldServer.cpp @@ -147,7 +147,7 @@ int main(int argc, char** argv) { if (!Game::logger) return EXIT_FAILURE; //Read our config: - Game::config = new dConfig((BinaryPathFinder::GetBinaryDir() / "worldconfig.ini").string()); + Game::config = new dConfig("worldconfig.ini"); Game::logger->SetLogToConsole(Game::config->GetValue("log_to_console") != "0"); Game::logger->SetLogDebugStatements(Game::config->GetValue("log_debug_statements") == "1"); From d8f74f008f959eb1c7859d81943437a0838287dc Mon Sep 17 00:00:00 2001 From: Xiphoseer Date: Sun, 31 Dec 2023 00:22:39 +0100 Subject: [PATCH 09/11] fix: bump connector version --- thirdparty/mariadb-connector-cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thirdparty/mariadb-connector-cpp b/thirdparty/mariadb-connector-cpp index 3fbdf8fa..8641b145 160000 --- a/thirdparty/mariadb-connector-cpp +++ b/thirdparty/mariadb-connector-cpp @@ -1 +1 @@ -Subproject commit 3fbdf8fa337d532861f6a61494a72dbce6402f8b +Subproject commit 8641b1453ae3ce5a70f78248a1f7fc20a048cb88 From 4ecb6ae30ec9bf8c2170595d47f58c9e7258ce8f Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 30 Dec 2023 22:14:58 -0800 Subject: [PATCH 10/11] fix: joining lobby twice (#1374) --- dGame/dComponents/ActivityComponent.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dGame/dComponents/ActivityComponent.cpp b/dGame/dComponents/ActivityComponent.cpp index 59637d59..f4865a03 100644 --- a/dGame/dComponents/ActivityComponent.cpp +++ b/dGame/dComponents/ActivityComponent.cpp @@ -115,6 +115,7 @@ void ActivityComponent::HandleMessageBoxResponse(Entity* player, const std::stri } void ActivityComponent::PlayerJoin(Entity* player) { + if (PlayerIsInQueue(player)) return; // If we have a lobby, queue the player and allow others to join, otherwise spin up an instance on the spot if (HasLobby()) { PlayerJoinLobby(player); From e54faa38202a9efa743abf6de2524312c4842617 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 30 Dec 2023 22:26:49 -0800 Subject: [PATCH 11/11] chore: organize build flags (#1371) * chore: organize build flags * Remove ambiguous include path Don't be default incluyde bcrypt so you need to specify the folder. Allows pre-processor to find the correct file. * Revert settings * working f --- CMakeLists.txt | 70 ++++++++----------- CMakeVariables.txt | 38 ++++++---- dAuthServer/AuthServer.cpp | 2 +- dAuthServer/CMakeLists.txt | 1 + dChatServer/CMakeLists.txt | 1 + dChatServer/ChatServer.cpp | 2 +- dCommon/Diagnostics.cpp | 8 +-- dCommon/Game.h | 2 + .../CDClientDatabase/CDClientManager.cpp | 4 +- dDatabase/CMakeLists.txt | 4 ++ dGame/dUtilities/VanityUtilities.cpp | 6 +- dMasterServer/CMakeLists.txt | 1 + dMasterServer/MasterServer.cpp | 6 +- dNet/AuthPackets.cpp | 4 -- dWorldServer/CMakeLists.txt | 1 + dWorldServer/WorldServer.cpp | 3 +- docker/Dockerfile | 2 +- tests/dGameTests/GameDependencies.cpp | 1 + thirdparty/CMakeLists.txt | 10 ++- thirdparty/CMakeMariaDBLists.txt | 2 +- 20 files changed, 90 insertions(+), 78 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e982346..aa7eb9b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,16 +28,13 @@ foreach(variable ${variables}) # Set the variable set(${variable_name} ${variable_value}) - # Add compiler definition - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${variable_name}=${variable_value}") - message(STATUS "Variable: ${variable_name} = ${variable_value}") endif() endif() endforeach() # Set the version -set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") +set(PROJECT_VERSION "\"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}\"") # Echo the version message(STATUS "Version: ${PROJECT_VERSION}") @@ -53,19 +50,21 @@ set(RECASTNAVIGATION_EXAMPLES OFF CACHE BOOL "" FORCE) # Disabled misleading indentation as DL_LinkedList from RakNet has a weird indent. # Disabled no-register # Disabled unknown pragmas because Linux doesn't understand Windows pragmas. -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROJECT_VERSION=${PROJECT_VERSION}") if(UNIX) - if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17 -O2 -Wuninitialized -D_GLIBCXX_USE_CXX11_ABI=0 -D_GLIBCXX_USE_CXX17_ABI=0 -fPIC") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17 -O2 -Wuninitialized -D_GLIBCXX_USE_CXX11_ABI=0 -D_GLIBCXX_USE_CXX17_ABI=0 -static-libgcc -fPIC -lstdc++fs") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17 -O2 -Wuninitialized -fPIC") + add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0 _GLIBCXX_USE_CXX17_ABI=0) + if(NOT APPLE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -lstdc++fs") endif() - if (__dynamic AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + + if (${DYNAMIC} AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic") endif() - if (__ggdb) + + if (${GGDB}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb") endif() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -O2 -fPIC") elseif(MSVC) # Skip warning for invalid conversion from size_t to uint32_t for all targets below for now @@ -154,10 +153,7 @@ if (NOT EXISTS ${PROJECT_BINARY_DIR}/navmeshes) endif() # Copy navmesh data on first build and extract it -configure_file( - ${CMAKE_SOURCE_DIR}/resources/navmeshes.zip ${PROJECT_BINARY_DIR}/navmeshes.zip - COPYONLY -) +configure_file(${CMAKE_SOURCE_DIR}/resources/navmeshes.zip ${PROJECT_BINARY_DIR}/navmeshes.zip COPYONLY) file(ARCHIVE_EXTRACT INPUT ${PROJECT_BINARY_DIR}/navmeshes.zip DESTINATION ${PROJECT_BINARY_DIR}/navmeshes) file(REMOVE ${PROJECT_BINARY_DIR}/navmeshes.zip) @@ -173,24 +169,14 @@ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/migrations/dlu/) file(GLOB SQL_FILES ${CMAKE_SOURCE_DIR}/migrations/dlu/*.sql) foreach(file ${SQL_FILES}) get_filename_component(file ${file} NAME) - if (NOT EXISTS ${PROJECT_BINARY_DIR}/migrations/dlu/${file}) - configure_file( - ${CMAKE_SOURCE_DIR}/migrations/dlu/${file} ${PROJECT_BINARY_DIR}/migrations/dlu/${file} - COPYONLY - ) - endif() + configure_file(${CMAKE_SOURCE_DIR}/migrations/dlu/${file} ${PROJECT_BINARY_DIR}/migrations/dlu/${file}) endforeach() file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/migrations/cdserver/) file(GLOB SQL_FILES ${CMAKE_SOURCE_DIR}/migrations/cdserver/*.sql) foreach(file ${SQL_FILES}) get_filename_component(file ${file} NAME) - if (NOT EXISTS ${PROJECT_BINARY_DIR}/migrations/cdserver/${file}) - configure_file( - ${CMAKE_SOURCE_DIR}/migrations/cdserver/${file} ${PROJECT_BINARY_DIR}/migrations/cdserver/${file} - COPYONLY - ) - endif() + configure_file(${CMAKE_SOURCE_DIR}/migrations/cdserver/${file} ${PROJECT_BINARY_DIR}/migrations/cdserver/${file}) endforeach() # Create our list of include directories @@ -198,7 +184,9 @@ set(INCLUDED_DIRECTORIES "dCommon" "dCommon/dClient" "dCommon/dEnums" + "dChatFilter" + "dGame" "dGame/dBehaviors" "dGame/dComponents" @@ -209,10 +197,14 @@ set(INCLUDED_DIRECTORIES "dGame/dPropertyBehaviors" "dGame/dPropertyBehaviors/ControlBehaviorMessages" "dGame/dUtilities" + "dPhysics" + "dNavigation" "dNavigation/dTerrain" + "dZoneManager" + "dDatabase" "dDatabase/CDClientDatabase" "dDatabase/CDClientDatabase/CDClientTables" @@ -220,7 +212,9 @@ set(INCLUDED_DIRECTORIES "dDatabase/GameDatabase/ITables" "dDatabase/GameDatabase/MySQL" "dDatabase/GameDatabase/MySQL/Tables" + "dNet" + "dScripts" "dScripts/02_server" "dScripts/ai" @@ -304,28 +298,24 @@ set(INCLUDED_DIRECTORIES "tests/dCommonTests" "tests/dGameTests" "tests/dGameTests/dComponentsTests" - ) +) # Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux) if (APPLE) include_directories("/usr/local/include/") endif() -if (WIN32) - set(INCLUDED_DIRECTORIES ${INCLUDED_DIRECTORIES} "thirdparty/libbcrypt/include") -elseif (UNIX) - set(INCLUDED_DIRECTORIES ${INCLUDED_DIRECTORIES} "thirdparty/libbcrypt") - set(INCLUDED_DIRECTORIES ${INCLUDED_DIRECTORIES} "thirdparty/libbcrypt/include/bcrypt") -endif() - -# Add binary directory as an include directory -include_directories(${PROJECT_BINARY_DIR}) - # Actually include the directories from our list foreach (dir ${INCLUDED_DIRECTORIES}) include_directories(${PROJECT_SOURCE_DIR}/${dir}) endforeach() +if (NOT WIN32) + include_directories("${PROJECT_SOURCE_DIR}/thirdparty/libbcrypt/include/bcrypt") +endif() +include_directories("${PROJECT_SOURCE_DIR}/thirdparty/libbcrypt/include") + + # Add linking directories: link_directories(${PROJECT_BINARY_DIR}) @@ -381,7 +371,7 @@ set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "mariadbConnCpp" "mag if (UNIX) set(COMMON_LIBRARIES ${COMMON_LIBRARIES} "dl" "pthread") - if (NOT APPLE AND __include_backtrace__) + if (NOT APPLE AND ${INCLUDE_BACKTRACE}) set(COMMON_LIBRARIES ${COMMON_LIBRARIES} "backtrace") endif() endif() @@ -419,6 +409,6 @@ target_precompile_headers( "$<$:${PROJECT_SOURCE_DIR}/thirdparty/tinyxml2/tinyxml2.h>" ) -if (${__enable_testing__} MATCHES "1") +if (${ENABLE_TESTING}) add_subdirectory(tests) endif() diff --git a/CMakeVariables.txt b/CMakeVariables.txt index abfe9e15..d9430d9d 100644 --- a/CMakeVariables.txt +++ b/CMakeVariables.txt @@ -1,22 +1,32 @@ PROJECT_VERSION_MAJOR=1 PROJECT_VERSION_MINOR=1 PROJECT_VERSION_PATCH=1 -# LICENSE -LICENSE=AGPL-3.0 + # Debugging -# Set __dynamic to 1 to enable the -rdynamic flag for the linker, yielding some symbols in crashlogs. -__dynamic=1 -# Set __ggdb to 1 to enable the -ggdb flag for the linker, including more debug info. -# __ggdb=1 -# Set __include_backtrace__ to 1 to includes the backtrace library for better crashlogs. -# __include_backtrace__=1 -# Set __compile_backtrace__ to 1 to compile the backtrace library instead of using system libraries. -# __compile_backtrace__=1 +# Set DYNAMIC to 1 to enable the -rdynamic flag for the linker, yielding some symbols in crashlogs. +DYNAMIC=1 + +# Set GGDB to 1 to enable the -ggdb flag for the linker, including more debug info. +# Do note, changing this will re-build the whole server +GGDB=0 + +# Set INCLUDE_BACKTRACE to 1 to includes the backtrace library for better crashlogs. +# Do note, changing this will re-build the whole server +INCLUDE_BACKTRACE=0 + +# Set COMPILE_BACKTRACE to 1 to compile the backtrace library instead of using system libraries. +# Do note, changing this will re-build the whole server +COMPILE_BACKTRACE=0 + # Set to the number of jobs (make -j equivalent) to compile the mariadbconn files with. -__maria_db_connector_compile_jobs__=1 +MARIADB_CONNECTOR_COMPILE_JOBS=1 + # When set to 1 and uncommented, compiling and linking testing folders and libraries will be done. -__enable_testing__=1 +ENABLE_TESTING=1 + # The path to OpenSSL. Change this if your OpenSSL install path is different than the default. OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3/ -# Uncomment the below line to cache the entire CDClient into memory -# CDCLIENT_CACHE_ALL=1 + +# Whether or not to cache the entire CDClient Database into memory instead of lazy loading. +# 0 means to lazy load, all other values mean load the entire database. +CDCLIENT_CACHE_ALL=0 diff --git a/dAuthServer/AuthServer.cpp b/dAuthServer/AuthServer.cpp index 8f1b2e76..52b35678 100644 --- a/dAuthServer/AuthServer.cpp +++ b/dAuthServer/AuthServer.cpp @@ -52,7 +52,7 @@ int main(int argc, char** argv) { Game::logger->SetLogDebugStatements(Game::config->GetValue("log_debug_statements") == "1"); LOG("Starting Auth server..."); - LOG("Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR); + LOG("Version: %s", PROJECT_VERSION); LOG("Compiled on: %s", __TIMESTAMP__); try { diff --git a/dAuthServer/CMakeLists.txt b/dAuthServer/CMakeLists.txt index 00fa6e7a..ebcbccad 100644 --- a/dAuthServer/CMakeLists.txt +++ b/dAuthServer/CMakeLists.txt @@ -1,2 +1,3 @@ add_executable(AuthServer "AuthServer.cpp") target_link_libraries(AuthServer ${COMMON_LIBRARIES}) +add_compile_definitions(AuthServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"") diff --git a/dChatServer/CMakeLists.txt b/dChatServer/CMakeLists.txt index 34d58a3a..b6a3efb8 100644 --- a/dChatServer/CMakeLists.txt +++ b/dChatServer/CMakeLists.txt @@ -6,6 +6,7 @@ set(DCHATSERVER_SOURCES add_executable(ChatServer "ChatServer.cpp") add_library(dChatServer ${DCHATSERVER_SOURCES}) +add_compile_definitions(ChatServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"") target_link_libraries(dChatServer ${COMMON_LIBRARIES} dChatFilter) target_link_libraries(ChatServer ${COMMON_LIBRARIES} dChatFilter dChatServer) diff --git a/dChatServer/ChatServer.cpp b/dChatServer/ChatServer.cpp index 49e427c8..c9bdcd9c 100644 --- a/dChatServer/ChatServer.cpp +++ b/dChatServer/ChatServer.cpp @@ -58,7 +58,7 @@ int main(int argc, char** argv) { Game::logger->SetLogDebugStatements(Game::config->GetValue("log_debug_statements") == "1"); LOG("Starting Chat server..."); - LOG("Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR); + LOG("Version: %s", PROJECT_VERSION); LOG("Compiled on: %s", __TIMESTAMP__); try { diff --git a/dCommon/Diagnostics.cpp b/dCommon/Diagnostics.cpp index a4055086..46c17e43 100644 --- a/dCommon/Diagnostics.cpp +++ b/dCommon/Diagnostics.cpp @@ -71,7 +71,7 @@ LONG CALLBACK unhandled_handler(EXCEPTION_POINTERS* e) { #include #include -#if defined(__include_backtrace__) +#if defined(INCLUDE_BACKTRACE) #include #include @@ -122,7 +122,7 @@ void CatchUnhandled(int sig) { LOG("Caught exception: '%s'", e.what()); } -#ifndef __include_backtrace__ +#ifndef INCLUDE_BACKTRACE std::string fileName = Diagnostics::GetOutDirectory() + "crash_" + Diagnostics::GetProcessName() + "_" + std::to_string(getpid()) + ".log"; LOG("Encountered signal %i, creating crash dump %s", sig, fileName.c_str()); @@ -174,7 +174,7 @@ void CatchUnhandled(int sig) { backtrace_symbols_fd(array, size, STDOUT_FILENO); # endif // defined(__GNUG__) -#else // __include_backtrace__ +#else // INCLUDE_BACKTRACE struct backtrace_state* state = backtrace_create_state( Diagnostics::GetProcessFileName().c_str(), @@ -185,7 +185,7 @@ void CatchUnhandled(int sig) { struct bt_ctx ctx = { state, 0 }; Bt(state); -#endif // __include_backtrace__ +#endif // INCLUDE_BACKTRACE exit(EXIT_FAILURE); } diff --git a/dCommon/Game.h b/dCommon/Game.h index 305b4f7a..972eea46 100644 --- a/dCommon/Game.h +++ b/dCommon/Game.h @@ -1,5 +1,6 @@ #pragma once +#include #include class dServer; @@ -28,4 +29,5 @@ namespace Game { extern EntityManager* entityManager; extern dZoneManager* zoneManager; extern PlayerContainer playerContainer; + extern std::string projectVersion; } diff --git a/dDatabase/CDClientDatabase/CDClientManager.cpp b/dDatabase/CDClientDatabase/CDClientManager.cpp index 7c2f3953..74c5c975 100644 --- a/dDatabase/CDClientDatabase/CDClientManager.cpp +++ b/dDatabase/CDClientDatabase/CDClientManager.cpp @@ -39,9 +39,11 @@ #include "CDRailActivatorComponent.h" #include "CDRewardCodesTable.h" +#ifndef CDCLIENT_CACHE_ALL // Uncomment this to cache the full cdclient database into memory. This will make the server load faster, but will use more memory. // A vanilla CDClient takes about 46MB of memory + the regular world data. -// #define CDCLIENT_CACHE_ALL +// # define CDCLIENT_CACHE_ALL +#endif // CDCLIENT_CACHE_ALL #ifdef CDCLIENT_CACHE_ALL #define CDCLIENT_DONT_CACHE_TABLE(x) x diff --git a/dDatabase/CMakeLists.txt b/dDatabase/CMakeLists.txt index 20f37bec..f0fe54b4 100644 --- a/dDatabase/CMakeLists.txt +++ b/dDatabase/CMakeLists.txt @@ -14,3 +14,7 @@ endforeach() add_library(dDatabase STATIC ${DDATABASE_SOURCES}) target_link_libraries(dDatabase sqlite3 mariadbConnCpp) + +if (${CDCLIENT_CACHE_ALL}) + add_compile_definitions(dDatabase CDCLIENT_CACHE_ALL=${CDCLIENT_CACHE_ALL}) +endif() diff --git a/dGame/dUtilities/VanityUtilities.cpp b/dGame/dUtilities/VanityUtilities.cpp index 6c008524..99087365 100644 --- a/dGame/dUtilities/VanityUtilities.cpp +++ b/dGame/dUtilities/VanityUtilities.cpp @@ -525,12 +525,12 @@ std::string VanityUtilities::ParseMarkdown(const std::string& file) { #endif // Replace "__TIMESTAMP__" with the __TIMESTAMP__ GeneralUtils::ReplaceInString(line, "__TIMESTAMP__", __TIMESTAMP__); - // Replace "__VERSION__" wit'h the PROJECT_VERSION - GeneralUtils::ReplaceInString(line, "__VERSION__", STRINGIFY(PROJECT_VERSION)); + // Replace "__VERSION__" with the PROJECT_VERSION + GeneralUtils::ReplaceInString(line, "__VERSION__", Game::projectVersion); // Replace "__SOURCE__" with SOURCE GeneralUtils::ReplaceInString(line, "__SOURCE__", Game::config->GetValue("source")); // Replace "__LICENSE__" with LICENSE - GeneralUtils::ReplaceInString(line, "__LICENSE__", STRINGIFY(LICENSE)); + GeneralUtils::ReplaceInString(line, "__LICENSE__", "AGPL-3.0"); if (line.find("##") != std::string::npos) { // Add "<font size='18' color='#000000'>" before the header diff --git a/dMasterServer/CMakeLists.txt b/dMasterServer/CMakeLists.txt index 656a026a..2ebdee37 100644 --- a/dMasterServer/CMakeLists.txt +++ b/dMasterServer/CMakeLists.txt @@ -6,6 +6,7 @@ set(DMASTERSERVER_SOURCES add_library(dMasterServer ${DMASTERSERVER_SOURCES}) add_executable(MasterServer "MasterServer.cpp") +add_compile_definitions(MasterServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"") target_link_libraries(dMasterServer ${COMMON_LIBRARIES}) target_link_libraries(MasterServer ${COMMON_LIBRARIES} dMasterServer) diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index 39cf2495..2de212a0 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -7,11 +7,7 @@ #include #include -#ifdef _WIN32 #include -#else -#include -#endif #include @@ -125,7 +121,7 @@ int main(int argc, char** argv) { LOG("Using net version %s", Game::config->GetValue("client_net_version").c_str()); LOG("Starting Master server..."); - LOG("Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR); + LOG("Version: %s", PROJECT_VERSION); LOG("Compiled on: %s", __TIMESTAMP__); //Connect to the MySQL Database diff --git a/dNet/AuthPackets.cpp b/dNet/AuthPackets.cpp index 83c1f58e..8f0542cc 100644 --- a/dNet/AuthPackets.cpp +++ b/dNet/AuthPackets.cpp @@ -11,11 +11,7 @@ #include "SHA512.h" #include "GeneralUtils.h" -#ifdef _WIN32 #include -#else -#include -#endif #include #include diff --git a/dWorldServer/CMakeLists.txt b/dWorldServer/CMakeLists.txt index c616da87..a790487e 100644 --- a/dWorldServer/CMakeLists.txt +++ b/dWorldServer/CMakeLists.txt @@ -5,6 +5,7 @@ set(DWORLDSERVER_SOURCES add_library(dWorldServer ${DWORLDSERVER_SOURCES}) add_executable(WorldServer "WorldServer.cpp") +add_compile_definitions(WorldServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"") target_link_libraries(dWorldServer ${COMMON_LIBRARIES}) target_link_libraries(WorldServer ${COMMON_LIBRARIES} dChatFilter dGame dZoneManager dPhysics Detour Recast tinyxml2 dWorldServer dNavigation) diff --git a/dWorldServer/WorldServer.cpp b/dWorldServer/WorldServer.cpp index c42486e0..cbab98d0 100644 --- a/dWorldServer/WorldServer.cpp +++ b/dWorldServer/WorldServer.cpp @@ -91,6 +91,7 @@ namespace Game { bool shouldShutdown = false; EntityManager* entityManager = nullptr; dZoneManager* zoneManager = nullptr; + std::string projectVersion = PROJECT_VERSION; } // namespace Game bool chatDisabled = false; @@ -152,7 +153,7 @@ int main(int argc, char** argv) { Game::logger->SetLogDebugStatements(Game::config->GetValue("log_debug_statements") == "1"); LOG("Starting World server..."); - LOG("Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR); + LOG("Version: %s", Game::projectVersion.c_str()); LOG("Compiled on: %s", __TIMESTAMP__); if (Game::config->GetValue("disable_chat") == "1") chatDisabled = true; diff --git a/docker/Dockerfile b/docker/Dockerfile index 39153110..fd211291 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -33,7 +33,7 @@ ARG BUILD_THREADS=1 ARG BUILD_VERSION=171022 RUN echo "Build server" -RUN sed -i -e "s/__maria_db_connector_compile_jobs__=.*/__maria_db_connector_compile_jobs__=${BUILD_THREADS}/g" CMakeVariables.txt +RUN sed -i -e "s/MARIADB_CONNECTOR_COMPILE_JOBS=.*/MARIADB_CONNECTOR_COMPILE_JOBS=${BUILD_THREADS}/g" CMakeVariables.txt RUN mkdir -p cmake_build RUN cd cmake_build && \ cmake .. -DCMAKE_BUILD_RPATH_USE_ORIGIN=TRUE && \ diff --git a/tests/dGameTests/GameDependencies.cpp b/tests/dGameTests/GameDependencies.cpp index 32563209..ef58e367 100644 --- a/tests/dGameTests/GameDependencies.cpp +++ b/tests/dGameTests/GameDependencies.cpp @@ -11,4 +11,5 @@ namespace Game { AssetManager* assetManager = nullptr; SystemAddress chatSysAddr; EntityManager* entityManager = nullptr; + std::string projectVersion; } diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 7b694b14..11d278c0 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -11,11 +11,17 @@ file( GLOB SOURCES_LIBBCRYPT LIST_DIRECTORIES false RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - ${CMAKE_CURRENT_SOURCE_DIR}/libbcrypt/*.c ${CMAKE_CURRENT_SOURCE_DIR}/libbcrypt/src/*.c ) + add_library(bcrypt ${SOURCES_LIBBCRYPT}) +# Because we are not using the libbcrypt CMakeLists.txt, we need to include these headers for the library to use. +# fortunately they are only needed for building the libbcrypt directory and nothing else, so these are marked private. + +target_include_directories(bcrypt PRIVATE "libbcrypt/include") +target_include_directories(bcrypt PRIVATE "libbcrypt/src") + # Source code for sqlite add_subdirectory(SQLite) @@ -31,7 +37,7 @@ add_subdirectory(raknet) # Download Backtrace if configured if(UNIX AND NOT APPLE) include(FetchContent) - if (__include_backtrace__ AND __compile_backtrace__) + if (${INCLUDE_BACKTRACE} AND ${COMPILE_BACKTRACE}) FetchContent_Declare( backtrace GIT_REPOSITORY https://github.com/ianlancetaylor/libbacktrace.git diff --git a/thirdparty/CMakeMariaDBLists.txt b/thirdparty/CMakeMariaDBLists.txt index 81b15a6f..d7a17f28 100644 --- a/thirdparty/CMakeMariaDBLists.txt +++ b/thirdparty/CMakeMariaDBLists.txt @@ -93,7 +93,7 @@ else() # Build from source -DINSTALL_PLUGINDIR=plugin ${MARIADB_EXTRA_CMAKE_ARGS} PREFIX "${PROJECT_BINARY_DIR}/mariadbcpp" - BUILD_COMMAND cmake --build . --config RelWithDebInfo -j${__maria_db_connector_compile_jobs__} + BUILD_COMMAND cmake --build . --config RelWithDebInfo -j${MARIADB_CONNECTOR_COMPILE_JOBS} INSTALL_COMMAND "") ExternalProject_Get_Property(mariadb_connector_cpp BINARY_DIR)