Merge branch 'main' into fix/cmake-libs-2

This commit is contained in:
David Markowitz
2024-01-25 02:43:29 -08:00
225 changed files with 2937 additions and 2556 deletions

View File

@@ -7,6 +7,7 @@
#include "GeneralUtils.h"
#include "DestroyableComponent.h"
#include "eReplicaComponentType.h"
#include "dNavMesh.h"
void BaseEnemyMech::OnStartup(Entity* self) {
auto* destroyableComponent = self->GetComponent<DestroyableComponent>();
@@ -19,7 +20,7 @@ void BaseEnemyMech::OnDie(Entity* self, Entity* killer) {
ControllablePhysicsComponent* controlPhys = static_cast<ControllablePhysicsComponent*>(self->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS));
if (!controlPhys) return;
NiPoint3 newLoc = { controlPhys->GetPosition().x, dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(controlPhys->GetPosition()), controlPhys->GetPosition().z };
NiPoint3 newLoc = { controlPhys->GetPosition().x, dpWorld::GetNavMesh()->GetHeightAtPoint(controlPhys->GetPosition()), controlPhys->GetPosition().z };
EntityInfo info = EntityInfo();
std::vector<LDFBaseData*> cfg;

View File

@@ -1,6 +1,6 @@
#include "BaseConsoleTeleportServer.h"
#include "GameMessages.h"
#include "Player.h"
#include "CharacterComponent.h"
#include "RenderComponent.h"
#include "EntityManager.h"
#include "eTerminateType.h"
@@ -94,7 +94,9 @@ void BaseConsoleTeleportServer::TransferPlayer(Entity* self, Entity* player, int
const auto& teleportZone = self->GetVar<std::u16string>(u"transferZoneID");
static_cast<Player*>(player)->SendToZone(std::stoi(GeneralUtils::UTF16ToWTF8(teleportZone)));
auto* characterComponent = player->GetComponent<CharacterComponent>();
if (characterComponent) characterComponent->SendToZone(std::stoi(GeneralUtils::UTF16ToWTF8(teleportZone)));
UpdatePlayerTable(self, player, false);
}

View File

@@ -3,7 +3,7 @@
#include "DestroyableComponent.h"
#include "EntityManager.h"
#include "dZoneManager.h"
#include "Player.h"
#include "CharacterComponent.h"
#include "eMissionTaskType.h"
#include "eMissionState.h"
#include "MissionComponent.h"
@@ -23,7 +23,8 @@ void BaseSurvivalServer::BasePlayerLoaded(Entity* self, Entity* player) {
const auto& playersIter = std::find(state.players.begin(), state.players.end(), player->GetObjectID());
if (waitingIter != state.waitingPlayers.end() || playersIter != state.players.end()) {
static_cast<Player*>(player)->SendToZone(player->GetCharacter()->GetLastNonInstanceZoneID());
auto* characterComponent = player->GetComponent<CharacterComponent>();
if (characterComponent) characterComponent->SendToZone(player->GetCharacter()->GetLastNonInstanceZoneID());
return;
}
@@ -161,8 +162,8 @@ void BaseSurvivalServer::BaseMessageBoxResponse(Entity* self, Entity* sender, in
if (sender->IsPlayer()) {
auto* character = sender->GetCharacter();
if (character != nullptr) {
auto* player = dynamic_cast<Player*>(sender);
player->SendToZone(character->GetLastNonInstanceZoneID());
auto* characterComponent = sender->GetComponent<CharacterComponent>();
if (characterComponent) characterComponent->SendToZone(character->GetLastNonInstanceZoneID());
}
}
}

View File

@@ -3,7 +3,7 @@
#include "DestroyableComponent.h"
#include "EntityManager.h"
#include "dZoneManager.h"
#include "Player.h"
#include "CharacterComponent.h"
#include "eMissionTaskType.h"
#include "eMissionState.h"
#include "MissionComponent.h"
@@ -162,8 +162,8 @@ void BaseWavesServer::BaseMessageBoxResponse(Entity* self, Entity* sender, int32
if (sender->IsPlayer()) {
auto* character = sender->GetCharacter();
if (character != nullptr) {
auto* player = dynamic_cast<Player*>(sender);
player->SendToZone(character->GetLastNonInstanceZoneID());
auto* characterComponent = sender->GetComponent<CharacterComponent>();
if (characterComponent) characterComponent->SendToZone(character->GetLastNonInstanceZoneID());
}
}
}

View File

@@ -46,11 +46,7 @@ CppScripts::Script* ScriptComponent::GetScript() {
}
void ScriptComponent::SetScript(const std::string& scriptName) {
//we don't need to delete the script because others may be using it :)
/*if (m_Client) {
m_Script = new InvalidScript();
return;
}*/
// Scripts are managed by the CppScripts class and are effecitvely singletons
// and they may also be used by other script components so DON'T delete them.
m_Script = CppScripts::GetScript(m_Parent, scriptName);
}

View File

@@ -17,9 +17,9 @@ class Entity;
* Handles the loading and execution of server side scripts on entities, scripts were originally written in Lua,
* here they're written in C++
*/
class ScriptComponent : public Component {
class ScriptComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPT;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPT;
ScriptComponent(Entity* parent, std::string scriptName, bool serialized, bool client = false);
~ScriptComponent() override;

View File

@@ -1,6 +1,6 @@
#include "InstanceExitTransferPlayerToLastNonInstance.h"
#include "GameMessages.h"
#include "Player.h"
#include "CharacterComponent.h"
#include "Character.h"
#include "dServer.h"
#include "eTerminateType.h"
@@ -23,10 +23,8 @@ void InstanceExitTransferPlayerToLastNonInstance::OnUse(Entity* self, Entity* us
}
void InstanceExitTransferPlayerToLastNonInstance::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
auto* player = dynamic_cast<Player*>(sender);
if (player == nullptr)
return;
if (!sender->IsPlayer()) return;
auto* character = sender->GetCharacter();
if (character != nullptr) {
if (identifier == u"Instance_Exit" && button == 1) {
@@ -47,7 +45,8 @@ void InstanceExitTransferPlayerToLastNonInstance::OnMessageBoxResponse(Entity* s
}
}
player->SendToZone(lastInstance);
auto* characterComponent = sender->GetComponent<CharacterComponent>();
if (characterComponent) characterComponent->SendToZone(lastInstance);
}
}

View File

@@ -453,16 +453,12 @@ void SGCannon::SpawnNewModel(Entity* self) {
void SGCannon::RemovePlayer(LWOOBJID playerID) {
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr)
return;
if (!player) return;
auto* playerObject = dynamic_cast<Player*>(player);
if (playerObject == nullptr)
return;
auto* character = playerObject->GetCharacter();
if (character != nullptr) {
playerObject->SendToZone(character->GetLastNonInstanceZoneID());
auto* character = player->GetCharacter();
auto* characterComponent = player->GetComponent<CharacterComponent>();
if (characterComponent && character) {
characterComponent->SendToZone(character->GetLastNonInstanceZoneID());
}
}

View File

@@ -1,10 +1,11 @@
#include "WblGenericZone.h"
#include "Player.h"
#include "CharacterComponent.h"
void WblGenericZone::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
if (args == m_WblAbortMsg) {
if (!sender) return;
auto player = dynamic_cast<Player*>(sender);
if (player) player->SendToZone(m_WblMainZone);
auto* characterComponent = sender->GetComponent<CharacterComponent>();
if (characterComponent) characterComponent->SendToZone(m_WblMainZone);
}
}