mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-31 00:49:35 -06:00
Compare commits
6 Commits
poc-gm-imp
...
player-stu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0dd3cce8ed | ||
|
|
87d5bd0229 | ||
|
|
f4a6086e4c | ||
|
|
eccd6f691f | ||
|
|
a54085945f | ||
|
|
66cc582a9a |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -17,6 +17,3 @@
|
||||
[submodule "thirdparty/magic_enum"]
|
||||
path = thirdparty/magic_enum
|
||||
url = https://github.com/Neargye/magic_enum.git
|
||||
[submodule "thirdparty/json"]
|
||||
path = thirdparty/json
|
||||
url = https://github.com/nlohmann/json
|
||||
|
||||
@@ -96,7 +96,7 @@ make_directory(${CMAKE_BINARY_DIR}/resServer)
|
||||
make_directory(${CMAKE_BINARY_DIR}/logs)
|
||||
|
||||
# Copy resource files on first build
|
||||
set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blacklist.dcf" "gms.json")
|
||||
set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blacklist.dcf")
|
||||
message(STATUS "Checking resource file integrity")
|
||||
|
||||
include(Utils)
|
||||
@@ -244,7 +244,6 @@ set(INCLUDED_DIRECTORIES
|
||||
"thirdparty/SQLite"
|
||||
"thirdparty/cpplinq"
|
||||
"thirdparty/cpp-httplib"
|
||||
"thirdparty/json/include"
|
||||
|
||||
"tests"
|
||||
"tests/dCommonTests"
|
||||
@@ -318,7 +317,7 @@ add_subdirectory(dPhysics)
|
||||
add_subdirectory(dServer)
|
||||
|
||||
# Create a list of common libraries shared between all binaries
|
||||
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "mariadbConnCpp" "magic_enum" "nlohmann_json")
|
||||
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "mariadbConnCpp" "magic_enum")
|
||||
|
||||
# Add platform specific common libraries
|
||||
if(UNIX)
|
||||
|
||||
@@ -629,7 +629,7 @@ enum class eGameMessageType : uint16_t {
|
||||
GET_INSTRUCTION_COUNT = 676,
|
||||
GET_IS_NPC = 677,
|
||||
ACTIVATE_BUBBLE_BUFF = 678,
|
||||
DECTIVATE_BUBBLE_BUFF = 679, // thanks netdevil
|
||||
DECTIVATE_BUBBLE_BUFF = 679, // This is spelled wrong in the client, so we misspell it here.
|
||||
EXHIBIT_VOTE = 680,
|
||||
ADD_PET_TO_PLAYER = 681,
|
||||
REMOVE_PET_FROM_PLAYER = 682,
|
||||
|
||||
@@ -1879,7 +1879,7 @@ const NiQuaternion& Entity::GetRotation() const {
|
||||
return NiQuaternion::IDENTITY;
|
||||
}
|
||||
|
||||
void Entity::SetPosition(NiPoint3 position) {
|
||||
void Entity::SetPosition(const NiPoint3& position) {
|
||||
auto* controllable = GetComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (controllable != nullptr) {
|
||||
@@ -1907,7 +1907,7 @@ void Entity::SetPosition(NiPoint3 position) {
|
||||
Game::entityManager->SerializeEntity(this);
|
||||
}
|
||||
|
||||
void Entity::SetRotation(NiQuaternion rotation) {
|
||||
void Entity::SetRotation(const NiQuaternion& rotation) {
|
||||
auto* controllable = GetComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (controllable != nullptr) {
|
||||
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
|
||||
virtual User* GetParentUser() const;
|
||||
|
||||
virtual SystemAddress GetSystemAddress() const { return UNASSIGNED_SYSTEM_ADDRESS; };
|
||||
virtual const SystemAddress& GetSystemAddress() const { return UNASSIGNED_SYSTEM_ADDRESS; };
|
||||
|
||||
/**
|
||||
* Setters
|
||||
@@ -124,13 +124,13 @@ public:
|
||||
|
||||
void SetNetworkId(uint16_t id);
|
||||
|
||||
void SetPosition(NiPoint3 position);
|
||||
void SetPosition(const NiPoint3& position);
|
||||
|
||||
void SetRotation(NiQuaternion rotation);
|
||||
void SetRotation(const NiQuaternion& rotation);
|
||||
|
||||
virtual void SetRespawnPos(NiPoint3 position) {}
|
||||
virtual void SetRespawnPos(const NiPoint3& position) {}
|
||||
|
||||
virtual void SetRespawnRot(NiQuaternion rotation) {}
|
||||
virtual void SetRespawnRot(const NiQuaternion& rotation) {}
|
||||
|
||||
virtual void SetSystemAddress(const SystemAddress& value) {};
|
||||
|
||||
@@ -229,8 +229,8 @@ public:
|
||||
void TriggerEvent(eTriggerEventType event, Entity* optionalTarget = nullptr);
|
||||
void ScheduleDestructionAfterUpdate() { m_ShouldDestroyAfterUpdate = true; }
|
||||
|
||||
virtual NiPoint3 GetRespawnPosition() const { return NiPoint3::ZERO; }
|
||||
virtual NiQuaternion GetRespawnRotation() const { return NiQuaternion::IDENTITY; }
|
||||
virtual const NiPoint3& GetRespawnPosition() const { return NiPoint3::ZERO; }
|
||||
virtual const NiQuaternion& GetRespawnRotation() const { return NiQuaternion::IDENTITY; }
|
||||
|
||||
void Sleep();
|
||||
void Wake();
|
||||
|
||||
289
dGame/Player.cpp
289
dGame/Player.cpp
@@ -3,162 +3,22 @@
|
||||
#include <ctime>
|
||||
|
||||
#include "Character.h"
|
||||
#include "Database.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "UserManager.h"
|
||||
#include "EntityManager.h"
|
||||
#include "Game.h"
|
||||
#include "Logger.h"
|
||||
#include "ZoneInstanceManager.h"
|
||||
#include "WorldPackets.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "Mail.h"
|
||||
#include "User.h"
|
||||
#include "CppScripts.h"
|
||||
#include "Loot.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
std::vector<Player*> Player::m_Players = {};
|
||||
namespace {
|
||||
std::vector<Player*> m_Players;
|
||||
};
|
||||
|
||||
Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Entity* parentEntity) : Entity(objectID, info, parentEntity) {
|
||||
m_ParentUser = user;
|
||||
m_Character = m_ParentUser->GetLastUsedChar();
|
||||
m_ParentUser->SetLoggedInChar(objectID);
|
||||
m_GMLevel = m_Character->GetGMLevel();
|
||||
m_SystemAddress = m_ParentUser->GetSystemAddress();
|
||||
m_DroppedLoot = {};
|
||||
m_DroppedCoins = 0;
|
||||
|
||||
m_GhostReferencePoint = NiPoint3::ZERO;
|
||||
m_GhostOverridePoint = NiPoint3::ZERO;
|
||||
m_GhostOverride = false;
|
||||
m_ObservedEntitiesLength = 256;
|
||||
m_ObservedEntitiesUsed = 0;
|
||||
m_ObservedEntities.resize(m_ObservedEntitiesLength);
|
||||
|
||||
m_Character->SetEntity(this);
|
||||
|
||||
const auto& iter = std::find(m_Players.begin(), m_Players.end(), this);
|
||||
|
||||
if (iter != m_Players.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_Players.push_back(this);
|
||||
}
|
||||
|
||||
User* Player::GetParentUser() const {
|
||||
return m_ParentUser;
|
||||
}
|
||||
|
||||
SystemAddress Player::GetSystemAddress() const {
|
||||
return m_SystemAddress;
|
||||
}
|
||||
|
||||
void Player::SetSystemAddress(const SystemAddress& value) {
|
||||
m_SystemAddress = value;
|
||||
}
|
||||
|
||||
void Player::SetRespawnPos(const NiPoint3 position) {
|
||||
if (!m_Character) return;
|
||||
|
||||
m_respawnPos = position;
|
||||
|
||||
m_Character->SetRespawnPoint(Game::zoneManager->GetZone()->GetWorldID(), position);
|
||||
}
|
||||
|
||||
void Player::SetRespawnRot(const NiQuaternion rotation) {
|
||||
m_respawnRot = rotation;
|
||||
}
|
||||
|
||||
NiPoint3 Player::GetRespawnPosition() const {
|
||||
return m_respawnPos;
|
||||
}
|
||||
|
||||
NiQuaternion Player::GetRespawnRotation() const {
|
||||
return m_respawnRot;
|
||||
}
|
||||
|
||||
void Player::SendMail(const LWOOBJID sender, const std::string& senderName, const std::string& subject, const std::string& body, LOT attachment, uint16_t attachmentCount) const {
|
||||
Mail::SendMail(sender, senderName, this, subject, body, attachment, attachmentCount);
|
||||
}
|
||||
|
||||
void Player::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId) {
|
||||
const auto objid = GetObjectID();
|
||||
|
||||
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, zoneId, cloneId, false, [objid](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
|
||||
auto* entity = Game::entityManager->GetEntity(objid);
|
||||
|
||||
if (entity == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto sysAddr = entity->GetSystemAddress();
|
||||
|
||||
auto* character = entity->GetCharacter();
|
||||
auto* characterComponent = entity->GetComponent<CharacterComponent>();
|
||||
|
||||
if (character != nullptr && characterComponent != nullptr) {
|
||||
character->SetZoneID(zoneID);
|
||||
character->SetZoneInstance(zoneInstance);
|
||||
character->SetZoneClone(zoneClone);
|
||||
|
||||
characterComponent->SetLastRocketConfig(u"");
|
||||
|
||||
character->SaveXMLToDatabase();
|
||||
}
|
||||
|
||||
WorldPackets::SendTransferToWorld(sysAddr, serverIP, serverPort, mythranShift);
|
||||
|
||||
Game::entityManager->DestructEntity(entity);
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
void Player::AddLimboConstruction(LWOOBJID objectId) {
|
||||
const auto& iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
|
||||
|
||||
if (iter != m_LimboConstructions.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_LimboConstructions.push_back(objectId);
|
||||
}
|
||||
|
||||
void Player::RemoveLimboConstruction(LWOOBJID objectId) {
|
||||
const auto& iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
|
||||
|
||||
if (iter == m_LimboConstructions.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_LimboConstructions.erase(iter);
|
||||
}
|
||||
|
||||
void Player::ConstructLimboEntities() {
|
||||
for (const auto objectId : m_LimboConstructions) {
|
||||
auto* entity = Game::entityManager->GetEntity(objectId);
|
||||
|
||||
if (entity == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Game::entityManager->ConstructEntity(entity, m_SystemAddress);
|
||||
}
|
||||
|
||||
m_LimboConstructions.clear();
|
||||
}
|
||||
|
||||
std::map<LWOOBJID, Loot::Info>& Player::GetDroppedLoot() {
|
||||
return m_DroppedLoot;
|
||||
}
|
||||
|
||||
const NiPoint3& Player::GetGhostReferencePoint() const {
|
||||
return m_GhostOverride ? m_GhostOverridePoint : m_GhostReferencePoint;
|
||||
}
|
||||
|
||||
const NiPoint3& Player::GetOriginGhostReferencePoint() const {
|
||||
return m_GhostReferencePoint;
|
||||
const std::vector<Player*>& Player::GetAllPlayers() {
|
||||
return m_Players;
|
||||
}
|
||||
|
||||
void Player::SetGhostReferencePoint(const NiPoint3& value) {
|
||||
@@ -169,52 +29,94 @@ void Player::SetGhostOverridePoint(const NiPoint3& value) {
|
||||
m_GhostOverridePoint = value;
|
||||
}
|
||||
|
||||
const NiPoint3& Player::GetGhostOverridePoint() const {
|
||||
return m_GhostOverridePoint;
|
||||
void Player::SetRespawnPos(const NiPoint3& position) {
|
||||
if (!m_Character) return;
|
||||
|
||||
m_respawnPos = position;
|
||||
|
||||
m_Character->SetRespawnPoint(Game::zoneManager->GetZone()->GetWorldID(), position);
|
||||
|
||||
}
|
||||
|
||||
void Player::SetGhostOverride(bool value) {
|
||||
m_GhostOverride = value;
|
||||
void Player::SetRespawnRot(const NiQuaternion& rotation) {
|
||||
m_respawnRot = rotation;
|
||||
}
|
||||
|
||||
bool Player::GetGhostOverride() const {
|
||||
return m_GhostOverride;
|
||||
void Player::SetSystemAddress(const SystemAddress& value) {
|
||||
m_SystemAddress = value;
|
||||
}
|
||||
|
||||
Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Entity* parentEntity) : Entity(objectID, info, parentEntity) {
|
||||
m_ParentUser = user;
|
||||
m_Character = m_ParentUser->GetLastUsedChar();
|
||||
m_ParentUser->SetLoggedInChar(objectID);
|
||||
m_GMLevel = m_Character->GetGMLevel();
|
||||
m_SystemAddress = m_ParentUser->GetSystemAddress();
|
||||
m_DroppedCoins = 0;
|
||||
|
||||
m_GhostReferencePoint = NiPoint3::ZERO;
|
||||
m_GhostOverridePoint = NiPoint3::ZERO;
|
||||
m_GhostOverride = false;
|
||||
|
||||
int32_t initialObservedEntitiesCapacity = 256;
|
||||
m_ObservedEntities.resize(initialObservedEntitiesCapacity);
|
||||
|
||||
m_Character->SetEntity(this);
|
||||
|
||||
const auto& iter = std::find(m_Players.begin(), m_Players.end(), this);
|
||||
|
||||
if (iter == m_Players.end()) {
|
||||
m_Players.push_back(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::AddLimboConstruction(LWOOBJID objectId) {
|
||||
const auto iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
|
||||
if (iter == m_LimboConstructions.end()) {
|
||||
m_LimboConstructions.push_back(objectId);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::RemoveLimboConstruction(LWOOBJID objectId) {
|
||||
const auto iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
|
||||
if (iter != m_LimboConstructions.end()) {
|
||||
m_LimboConstructions.erase(iter);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::ConstructLimboEntities() {
|
||||
for (const auto& objectId : m_LimboConstructions) {
|
||||
auto* entity = Game::entityManager->GetEntity(objectId);
|
||||
if (!entity) continue;
|
||||
|
||||
Game::entityManager->ConstructEntity(entity, m_SystemAddress);
|
||||
}
|
||||
|
||||
m_LimboConstructions.clear();
|
||||
}
|
||||
|
||||
void Player::ObserveEntity(int32_t id) {
|
||||
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
|
||||
if (m_ObservedEntities[i] == 0 || m_ObservedEntities[i] == id) {
|
||||
m_ObservedEntities[i] = id;
|
||||
for (auto& observedEntity : m_ObservedEntities) {
|
||||
if (observedEntity == 0 || observedEntity == id) {
|
||||
observedEntity = id;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const auto index = m_ObservedEntitiesUsed++;
|
||||
m_ObservedEntities.reserve(m_ObservedEntities.size() + 1);
|
||||
|
||||
if (m_ObservedEntitiesUsed > m_ObservedEntitiesLength) {
|
||||
m_ObservedEntities.resize(m_ObservedEntitiesLength + m_ObservedEntitiesLength);
|
||||
|
||||
m_ObservedEntitiesLength = m_ObservedEntitiesLength + m_ObservedEntitiesLength;
|
||||
}
|
||||
|
||||
m_ObservedEntities[index] = id;
|
||||
m_ObservedEntities.push_back(id);
|
||||
}
|
||||
|
||||
bool Player::IsObserved(int32_t id) {
|
||||
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
|
||||
if (m_ObservedEntities[i] == id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return std::find(m_ObservedEntities.begin(), m_ObservedEntities.end(), id) != m_ObservedEntities.end();
|
||||
}
|
||||
|
||||
void Player::GhostEntity(int32_t id) {
|
||||
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
|
||||
if (m_ObservedEntities[i] == id) {
|
||||
m_ObservedEntities[i] = 0;
|
||||
for (auto& observedEntity : m_ObservedEntities) {
|
||||
if (observedEntity == id) {
|
||||
observedEntity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,59 +130,44 @@ Player* Player::GetPlayer(const SystemAddress& sysAddr) {
|
||||
Player* Player::GetPlayer(const std::string& name) {
|
||||
const auto characters = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::CHARACTER);
|
||||
|
||||
Player* player = nullptr;
|
||||
for (auto* character : characters) {
|
||||
if (!character->IsPlayer()) continue;
|
||||
|
||||
if (GeneralUtils::CaseInsensitiveStringCompare(name, character->GetCharacter()->GetName())) {
|
||||
return dynamic_cast<Player*>(character);
|
||||
player = dynamic_cast<Player*>(character);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return player;
|
||||
}
|
||||
|
||||
Player* Player::GetPlayer(LWOOBJID playerID) {
|
||||
Player* playerToReturn = nullptr;
|
||||
for (auto* player : m_Players) {
|
||||
if (player->GetObjectID() == playerID) {
|
||||
return player;
|
||||
playerToReturn = player;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::vector<Player*>& Player::GetAllPlayers() {
|
||||
return m_Players;
|
||||
}
|
||||
|
||||
uint64_t Player::GetDroppedCoins() {
|
||||
return m_DroppedCoins;
|
||||
}
|
||||
|
||||
void Player::SetDroppedCoins(uint64_t value) {
|
||||
m_DroppedCoins = value;
|
||||
return playerToReturn;
|
||||
}
|
||||
|
||||
Player::~Player() {
|
||||
LOG("Deleted player");
|
||||
|
||||
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
|
||||
const auto id = m_ObservedEntities[i];
|
||||
for (auto& observedEntity : m_ObservedEntities) {
|
||||
if (observedEntity == 0) continue;
|
||||
|
||||
if (id == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* entity = Game::entityManager->GetGhostCandidate(id);
|
||||
|
||||
if (entity != nullptr) {
|
||||
entity->SetObservers(entity->GetObservers() - 1);
|
||||
}
|
||||
auto* entity = Game::entityManager->GetGhostCandidate(observedEntity);
|
||||
if (!entity) continue;
|
||||
|
||||
entity->SetObservers(entity->GetObservers() - 1);
|
||||
}
|
||||
|
||||
m_LimboConstructions.clear();
|
||||
|
||||
const auto& iter = std::find(m_Players.begin(), m_Players.end(), this);
|
||||
const auto iter = std::find(m_Players.begin(), m_Players.end(), this);
|
||||
|
||||
if (iter == m_Players.end()) {
|
||||
return;
|
||||
|
||||
@@ -18,64 +18,44 @@ public:
|
||||
* Getters
|
||||
*/
|
||||
|
||||
User* GetParentUser() const override;
|
||||
User* GetParentUser() const override { return m_ParentUser; };
|
||||
|
||||
SystemAddress GetSystemAddress() const override;
|
||||
const SystemAddress& GetSystemAddress() const override { return m_SystemAddress; };
|
||||
|
||||
NiPoint3 GetRespawnPosition() const override;
|
||||
const NiPoint3& GetRespawnPosition() const override { return m_respawnPos; };
|
||||
|
||||
NiQuaternion GetRespawnRotation() const override;
|
||||
const NiQuaternion& GetRespawnRotation() const override { return m_respawnRot; };
|
||||
|
||||
const NiPoint3& GetGhostReferencePoint() const;
|
||||
const NiPoint3& GetGhostReferencePoint() const { return m_GhostOverride ? m_GhostOverridePoint : m_GhostReferencePoint; };
|
||||
|
||||
const NiPoint3& GetOriginGhostReferencePoint() const;
|
||||
const NiPoint3& GetOriginGhostReferencePoint() const { return m_GhostReferencePoint; };
|
||||
|
||||
const NiPoint3& GetGhostOverridePoint() const;
|
||||
const NiPoint3& GetGhostOverridePoint() const { return m_GhostOverridePoint; };
|
||||
|
||||
bool GetGhostOverride() const;
|
||||
bool GetGhostOverride() const { return m_GhostOverride; };
|
||||
|
||||
std::map<LWOOBJID, Loot::Info>& GetDroppedLoot();
|
||||
std::map<LWOOBJID, Loot::Info>& GetDroppedLoot() { return m_DroppedLoot; };
|
||||
|
||||
uint64_t GetDroppedCoins();
|
||||
uint64_t GetDroppedCoins() const { return m_DroppedCoins; };
|
||||
|
||||
/**
|
||||
* Setters
|
||||
*/
|
||||
|
||||
void SetGhostOverride(bool value) { m_GhostOverride = value; };
|
||||
|
||||
void SetDroppedCoins(const uint64_t value) { m_DroppedCoins = value; };
|
||||
|
||||
void SetSystemAddress(const SystemAddress& value) override;
|
||||
|
||||
void SetRespawnPos(NiPoint3 position) override;
|
||||
void SetRespawnPos(const NiPoint3& position) override;
|
||||
|
||||
void SetRespawnRot(NiQuaternion rotation) override;
|
||||
void SetRespawnRot(const NiQuaternion& rotation) override;
|
||||
|
||||
void SetGhostReferencePoint(const NiPoint3& value);
|
||||
|
||||
void SetGhostOverridePoint(const NiPoint3& value);
|
||||
|
||||
void SetGhostOverride(bool value);
|
||||
|
||||
void SetDroppedCoins(uint64_t value);
|
||||
|
||||
/**
|
||||
* Wrapper for sending an in-game mail.
|
||||
*
|
||||
* @param sender id of the sender. LWOOBJID_EMPTY for system mail
|
||||
* @param senderName name of the sender. Max 32 characters.
|
||||
* @param subject mail subject. Max 50 characters.
|
||||
* @param body mail body. Max 400 characters.
|
||||
* @param attachment LOT of the attached item. LOT_NULL if no attachment.
|
||||
* @param attachmentCount stack size for attachment.
|
||||
*/
|
||||
void SendMail(LWOOBJID sender, const std::string& senderName, const std::string& subject, const std::string& body, LOT attachment, uint16_t attachmentCount) const;
|
||||
|
||||
/**
|
||||
* Wrapper for transfering the player to another instance.
|
||||
*
|
||||
* @param zoneId zoneID for the new instance.
|
||||
* @param cloneId cloneID for the new instance.
|
||||
*/
|
||||
void SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId = 0);
|
||||
|
||||
/**
|
||||
* Ghosting
|
||||
*/
|
||||
@@ -86,11 +66,11 @@ public:
|
||||
|
||||
void ConstructLimboEntities();
|
||||
|
||||
void ObserveEntity(int32_t id);
|
||||
void ObserveEntity(const int32_t id);
|
||||
|
||||
bool IsObserved(int32_t id);
|
||||
bool IsObserved(const int32_t id);
|
||||
|
||||
void GhostEntity(int32_t id);
|
||||
void GhostEntity(const int32_t id);
|
||||
|
||||
/**
|
||||
* Static methods
|
||||
@@ -122,15 +102,9 @@ private:
|
||||
|
||||
std::vector<int32_t> m_ObservedEntities;
|
||||
|
||||
int32_t m_ObservedEntitiesLength;
|
||||
|
||||
int32_t m_ObservedEntitiesUsed;
|
||||
|
||||
std::vector<LWOOBJID> m_LimboConstructions;
|
||||
|
||||
std::map<LWOOBJID, Loot::Info> m_DroppedLoot;
|
||||
|
||||
uint64_t m_DroppedCoins;
|
||||
|
||||
static std::vector<Player*> m_Players;
|
||||
};
|
||||
|
||||
@@ -46,18 +46,20 @@ ActivityComponent::ActivityComponent(Entity* parent, int32_t activityID) : Compo
|
||||
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent) {
|
||||
// check for LMIs and set the loot LMIs
|
||||
// First lookup the loot matrix id for this component id.
|
||||
CDActivityRewardsTable* activityRewardsTable = CDClientManager::Instance().GetTable<CDActivityRewardsTable>();
|
||||
std::vector<CDActivityRewards> activityRewards = activityRewardsTable->Query([=](CDActivityRewards entry) {return (entry.LootMatrixIndex == destroyableComponent->GetLootMatrixID()); });
|
||||
|
||||
uint32_t startingLMI = 0;
|
||||
|
||||
// If we have one, set the starting loot matrix id to that.
|
||||
if (activityRewards.size() > 0) {
|
||||
startingLMI = activityRewards[0].LootMatrixIndex;
|
||||
}
|
||||
|
||||
if (startingLMI > 0) {
|
||||
// now time for bodge :)
|
||||
// We may have more than 1 loot matrix index to use depending ont the size of the team that is looting the activity.
|
||||
// So this logic will get the rest of the loot matrix indices for this activity.
|
||||
|
||||
std::vector<CDActivityRewards> objectTemplateActivities = activityRewardsTable->Query([=](CDActivityRewards entry) {return (activityRewards[0].objectTemplate == entry.objectTemplate); });
|
||||
for (const auto& item : objectTemplateActivities) {
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "Database.h"
|
||||
#include "CDRewardCodesTable.h"
|
||||
#include "Mail.h"
|
||||
#include "ZoneInstanceManager.h"
|
||||
#include "WorldPackets.h"
|
||||
#include <ctime>
|
||||
|
||||
CharacterComponent::CharacterComponent(Entity* parent, Character* character) : Component(parent) {
|
||||
@@ -763,12 +765,12 @@ void CharacterComponent::AwardClaimCodes() {
|
||||
if (!m_Parent) return;
|
||||
auto* user = m_Parent->GetParentUser();
|
||||
if (!user) return;
|
||||
|
||||
|
||||
auto rewardCodes = Database::Get()->GetRewardCodesByAccountID(user->GetAccountID());
|
||||
if (rewardCodes.empty()) return;
|
||||
|
||||
auto* cdrewardCodes = CDClientManager::Instance().GetTable<CDRewardCodesTable>();
|
||||
for (auto const rewardCode: rewardCodes){
|
||||
for (auto const rewardCode : rewardCodes) {
|
||||
LOG_DEBUG("Processing RewardCode %i", rewardCode);
|
||||
const uint32_t rewardCodeIndex = rewardCode >> 6;
|
||||
const uint32_t bitIndex = rewardCode % 64;
|
||||
@@ -786,3 +788,32 @@ void CharacterComponent::AwardClaimCodes() {
|
||||
Mail::SendMail(LWOOBJID_EMPTY, "%[MAIL_SYSTEM_NOTIFICATION]", m_Parent, subject.str(), body.str(), attachmentLOT, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void CharacterComponent::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId) const {
|
||||
const auto objid = m_Parent->GetObjectID();
|
||||
|
||||
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, zoneId, cloneId, false, [objid](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
|
||||
auto* entity = Game::entityManager->GetEntity(objid);
|
||||
|
||||
if (!entity) return;
|
||||
|
||||
const auto sysAddr = entity->GetSystemAddress();
|
||||
|
||||
auto* character = entity->GetCharacter();
|
||||
auto* characterComponent = entity->GetComponent<CharacterComponent>();
|
||||
|
||||
if (character && characterComponent) {
|
||||
character->SetZoneID(zoneID);
|
||||
character->SetZoneInstance(zoneInstance);
|
||||
character->SetZoneClone(zoneClone);
|
||||
|
||||
characterComponent->SetLastRocketConfig(u"");
|
||||
|
||||
character->SaveXMLToDatabase();
|
||||
}
|
||||
|
||||
WorldPackets::SendTransferToWorld(sysAddr, serverIP, serverPort, mythranShift);
|
||||
|
||||
Game::entityManager->DestructEntity(entity);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -281,6 +281,14 @@ public:
|
||||
|
||||
LWOOBJID GetCurrentInteracting() {return m_CurrentInteracting;};
|
||||
|
||||
/**
|
||||
* Sends a player to another zone with an optional clone ID
|
||||
*
|
||||
* @param zoneId zoneID for the new instance.
|
||||
* @param cloneId cloneID for the new instance.
|
||||
*/
|
||||
void SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId = 0) const;
|
||||
|
||||
/**
|
||||
* Character info regarding this character, including clothing styles, etc.
|
||||
*/
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "eMissionTaskType.h"
|
||||
#include "eStateChangeType.h"
|
||||
#include "eUseItemResponse.h"
|
||||
#include "Mail.h"
|
||||
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
#include "CDInventoryComponentTable.h"
|
||||
@@ -264,17 +265,11 @@ void InventoryComponent::AddItem(
|
||||
}
|
||||
|
||||
if (slot == -1) {
|
||||
auto* player = dynamic_cast<Player*>(GetParent());
|
||||
|
||||
if (player == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
outOfSpace += size;
|
||||
|
||||
switch (sourceType) {
|
||||
case 0:
|
||||
player->SendMail(LWOOBJID_EMPTY, "Darkflame Universe", "Lost Reward", "You received an item and didn't have room for it.", lot, size);
|
||||
Mail::SendMail(LWOOBJID_EMPTY, "Darkflame Universe", m_Parent, "Lost Reward", "You received an item and didn't have room for it.", lot, size);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "InventoryComponent.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "eObjectBits.h"
|
||||
#include "CharacterComponent.h"
|
||||
|
||||
#include <vector>
|
||||
#include "CppScripts.h"
|
||||
@@ -247,7 +248,8 @@ void PropertyManagementComponent::OnStartBuilding() {
|
||||
for (auto* player : players) {
|
||||
if (player == ownerEntity) continue;
|
||||
|
||||
player->SendToZone(zoneId);
|
||||
auto* characterComponent = player->GetComponent<CharacterComponent>();
|
||||
if (characterComponent) characterComponent->SendToZone(zoneId);
|
||||
}
|
||||
auto inventoryComponent = ownerEntity->GetComponent<InventoryComponent>();
|
||||
|
||||
@@ -519,7 +521,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
{
|
||||
item->SetCount(item->GetCount() - 1);
|
||||
|
||||
LOG("BODGE TIME, YES IT GOES HERE");
|
||||
LOG("DLU currently does not support breaking apart brick by brick models.");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -71,10 +71,8 @@ void RacingControlComponent::OnPlayerLoaded(Entity* player) {
|
||||
|
||||
// If the race has already started, send the player back to the main world.
|
||||
if (m_Loaded || !vehicle) {
|
||||
auto* playerInstance = dynamic_cast<Player*>(player);
|
||||
if (playerInstance) {
|
||||
playerInstance->SendToZone(m_MainWorld);
|
||||
}
|
||||
auto* characterComponent = player->GetComponent<CharacterComponent>();
|
||||
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -105,10 +103,11 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
|
||||
if (item == nullptr) {
|
||||
LOG("Failed to find item");
|
||||
auto* playerInstance = dynamic_cast<Player*>(player);
|
||||
if (playerInstance) {
|
||||
auto* characterComponent = player->GetComponent<CharacterComponent>();
|
||||
|
||||
if (characterComponent) {
|
||||
m_LoadedPlayers--;
|
||||
playerInstance->SendToZone(m_MainWorld);
|
||||
characterComponent->SendToZone(m_MainWorld);
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -427,9 +426,9 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu
|
||||
m_Parent->GetObjectID(), 3, 0, LWOOBJID_EMPTY, u"",
|
||||
player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
auto* playerInstance = dynamic_cast<Player*>(player);
|
||||
auto* characterComponent = player->GetComponent<CharacterComponent>();
|
||||
|
||||
playerInstance->SendToZone(m_MainWorld);
|
||||
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
|
||||
|
||||
vehicle->Kill();
|
||||
}
|
||||
@@ -561,9 +560,9 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* playerInstance = dynamic_cast<Player*>(playerEntity);
|
||||
auto* characterComponent = playerEntity->GetComponent<CharacterComponent>();
|
||||
|
||||
playerInstance->SendToZone(m_MainWorld);
|
||||
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
|
||||
}
|
||||
|
||||
m_LobbyPlayers.clear();
|
||||
@@ -623,9 +622,9 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* playerInstance = dynamic_cast<Player*>(playerEntity);
|
||||
auto* characterComponent = playerEntity->GetComponent<CharacterComponent>();
|
||||
|
||||
playerInstance->SendToZone(m_MainWorld);
|
||||
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -2,8 +2,7 @@ set(DGAME_DGAMEMESSAGES_SOURCES
|
||||
"GameMessageHandler.cpp"
|
||||
"GameMessages.cpp"
|
||||
"PropertyDataMessage.cpp"
|
||||
"PropertySelectQueryProperty.cpp"
|
||||
"GameMessage.cpp")
|
||||
"PropertySelectQueryProperty.cpp")
|
||||
|
||||
add_library(dGameMessages STATIC ${DGAME_DGAMEMESSAGES_SOURCES})
|
||||
target_link_libraries(dGameMessages PUBLIC dDatabase)
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
#include "GameMessage.h"
|
||||
|
||||
#include "AssetManager.h"
|
||||
#include <BinaryPathFinder.h>
|
||||
|
||||
#include "dServer.h"
|
||||
|
||||
GameMessageStorage::GameMessageStorage() {
|
||||
auto path = BinaryPathFinder::GetBinaryDir() / "gms.json";
|
||||
|
||||
std::ifstream i(path);
|
||||
i >> m_Storage;
|
||||
i.close();
|
||||
}
|
||||
|
||||
uint32_t GameMessageStorage::GetGMFromName(std::string name) {
|
||||
auto messages = m_Storage["messages"];
|
||||
|
||||
for (auto& [key, value] : messages.items()) {
|
||||
if (value["name"] == name) {
|
||||
return std::stoi(key);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
nlohmann::json GameMessageStorage::GetGM(uint32_t id) {
|
||||
auto messages = m_Storage["messages"];
|
||||
|
||||
if (messages.contains(std::to_string(id))) {
|
||||
return messages[std::to_string(id)];
|
||||
}
|
||||
|
||||
return nlohmann::json();
|
||||
}
|
||||
|
||||
|
||||
GameMessageStorage::~GameMessageStorage() {
|
||||
|
||||
}
|
||||
|
||||
GameMessage::GameMessage(std::string name) {
|
||||
auto id = GameMessageStorage::Instance().GetGMFromName(name);
|
||||
if (id == 0) {
|
||||
throw std::exception("GameMessage not found");
|
||||
}
|
||||
|
||||
new(this) GameMessage((eGameMessageType)id);
|
||||
}
|
||||
|
||||
GameMessage::GameMessage(eGameMessageType type) {
|
||||
m_Type = type;
|
||||
m_Message = GameMessageStorage::Instance().GetGM((uint32_t)type);
|
||||
|
||||
m_State = std::map<std::string, std::any>();
|
||||
}
|
||||
|
||||
void GameMessage::Serialize(RakNet::BitStream* bs) {
|
||||
bs->Write<uint16_t>((uint16_t)m_Type);
|
||||
|
||||
for (auto& value : m_Message["params"]) {
|
||||
bool presentInState = m_State.contains(value["name"]);
|
||||
|
||||
if (value["type"] != "bool") {
|
||||
if (!presentInState) {
|
||||
if (value.contains("default")) {
|
||||
|
||||
LOG("Written type %s as default", value["name"].get<std::string>().c_str());
|
||||
bs->Write0();
|
||||
continue;
|
||||
} else {
|
||||
throw std::exception("Fuck.");
|
||||
}
|
||||
} else {
|
||||
if (value.contains("default") && value["type"] != "bool") {
|
||||
bs->Write1();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// special case for bool
|
||||
|
||||
if (!presentInState) {
|
||||
if (!value.contains("default")) throw std::exception("uh oh");
|
||||
|
||||
m_State.insert(std::make_pair(value["name"].get<std::string>(), std::any(value["default"] == "true" ? true : false)));
|
||||
}
|
||||
}
|
||||
|
||||
std::string type = value["type"];
|
||||
|
||||
if (type == "Vector3") {
|
||||
auto res = std::any_cast<Vector3>(m_State[value["name"]]);
|
||||
bs->Write(res.GetX());
|
||||
bs->Write(res.GetY());
|
||||
bs->Write(res.GetZ());
|
||||
LOG("Written type %s with values %f %f %f", value["name"].get<std::string>().c_str(), res.GetX(), res.GetY(), res.GetZ());
|
||||
} else if (type == "float") {
|
||||
bs->Write<float>(std::any_cast<float>(m_State[value["name"]]));
|
||||
LOG("Written type %s with value %s", value["name"].get<std::string>().c_str(), std::to_string(std::any_cast<float>(m_State[value["name"]])).c_str());
|
||||
} else if (type == "bool") {
|
||||
bs->Write(std::any_cast<bool>(m_State[value["name"]]));
|
||||
LOG("Written type %s with value %s", value["name"].get<std::string>().c_str(), std::to_string(std::any_cast<bool>(m_State[value["name"]])).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <any>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "Singleton.h"
|
||||
#include "eGameMessageType.h"
|
||||
|
||||
typedef std::map<std::string, std::any> StateStorage;
|
||||
|
||||
class GameMessageStorage : public Singleton<GameMessageStorage> {
|
||||
public:
|
||||
GameMessageStorage();
|
||||
~GameMessageStorage();
|
||||
|
||||
uint32_t GetGMFromName(std::string name);
|
||||
nlohmann::json GetGM(uint32_t id);
|
||||
private:
|
||||
nlohmann::json m_Storage;
|
||||
};
|
||||
|
||||
class GameMessage {
|
||||
public:
|
||||
GameMessage(std::string name);
|
||||
GameMessage(eGameMessageType type);
|
||||
|
||||
void Serialize(RakNet::BitStream* bs);
|
||||
|
||||
template <typename T>
|
||||
inline void Set(std::string key, T value) {
|
||||
m_State[key] = std::any(value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T Get(std::string key) {
|
||||
return m_State[key];
|
||||
}
|
||||
|
||||
inline eGameMessageType GetType() {
|
||||
return m_Type;
|
||||
}
|
||||
|
||||
inline StateStorage GetState() {
|
||||
return m_State;
|
||||
}
|
||||
|
||||
inline nlohmann::json GetMessage() {
|
||||
return m_Message;
|
||||
}
|
||||
|
||||
private:
|
||||
eGameMessageType m_Type;
|
||||
nlohmann::json m_Message;
|
||||
|
||||
StateStorage m_State;
|
||||
};
|
||||
@@ -196,8 +196,8 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
}
|
||||
|
||||
case eGameMessageType::MISSION_DIALOGUE_CANCELLED: {
|
||||
//This message is pointless for our implementation, as the client just carries on after
|
||||
//rejecting a mission offer. We dont need to do anything. This is just here to remove a warning in our logs :)
|
||||
// This message is pointless for our implementation, as the client just carries on after
|
||||
// rejecting a mission offer. We dont need to do anything. This is just here to remove a warning in our logs :)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,8 +100,6 @@
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
#include "CDObjectsTable.h"
|
||||
|
||||
#include "GameMessage.h"
|
||||
|
||||
void GameMessages::SendFireEventClientSide(const LWOOBJID& objectID, const SystemAddress& sysAddr, std::u16string args, const LWOOBJID& object, int64_t param1, int param2, const LWOOBJID& sender) {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
@@ -129,15 +127,30 @@ void GameMessages::SendTeleport(const LWOOBJID& objectID, const NiPoint3& pos, c
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
bitStream.Write(objectID);
|
||||
bitStream.Write(eGameMessageType::TELEPORT);
|
||||
|
||||
GameMessage msg = GameMessage(eGameMessageType::TELEPORT);
|
||||
bool bIgnoreY = (pos.y == 0.0f);
|
||||
bool bUseNavmesh = false;
|
||||
bool bSkipAllChecks = false;
|
||||
//float w = 1.0f;
|
||||
//float x = 0.0f;
|
||||
//float y = 0.0f;
|
||||
//float z = 0.0f;
|
||||
|
||||
msg.Set("pos", pos);
|
||||
msg.Set("x", rot.x);
|
||||
msg.Set("y", rot.y);
|
||||
msg.Set("z", rot.z);
|
||||
bitStream.Write(bIgnoreY);
|
||||
bitStream.Write(bSetRotation);
|
||||
bitStream.Write(bSkipAllChecks);
|
||||
bitStream.Write(pos.x);
|
||||
bitStream.Write(pos.y);
|
||||
bitStream.Write(pos.z);
|
||||
bitStream.Write(bUseNavmesh);
|
||||
|
||||
msg.Serialize(&bitStream);
|
||||
bitStream.Write(rot.w != 1.0f);
|
||||
if (rot.w != 1.0f) bitStream.Write(rot.w);
|
||||
|
||||
bitStream.Write(rot.x);
|
||||
bitStream.Write(rot.y);
|
||||
bitStream.Write(rot.z);
|
||||
|
||||
SEND_PACKET;
|
||||
}
|
||||
@@ -4614,7 +4627,7 @@ void GameMessages::HandleSetGhostReferencePosition(RakNet::BitStream* inStream,
|
||||
|
||||
|
||||
void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||
bool bConfirmed{}; // this doesnt even do anything, thanks ND!
|
||||
bool bConfirmed{}; // This doesn't appear to do anything. Further research is needed.
|
||||
bool countIsDefault{};
|
||||
int count = 1;
|
||||
LOT item;
|
||||
|
||||
@@ -20,7 +20,7 @@ RawFile::RawFile(std::string fileName) {
|
||||
|
||||
|
||||
if (m_Version < 0x20) {
|
||||
return; // Version too crusty to handle
|
||||
return; // Version is too old to be supported
|
||||
}
|
||||
|
||||
// Read in chunks
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
5708
resources/gms.json
5708
resources/gms.json
File diff suppressed because it is too large
Load Diff
3
thirdparty/CMakeLists.txt
vendored
3
thirdparty/CMakeLists.txt
vendored
@@ -34,9 +34,6 @@ include(CMakeMariaDBLists.txt)
|
||||
# Create our third party library objects
|
||||
add_subdirectory(raknet)
|
||||
|
||||
# Add nlohmann JSON library
|
||||
add_subdirectory(json)
|
||||
|
||||
# Download Backtrace if configured
|
||||
if(UNIX AND NOT APPLE)
|
||||
include(FetchContent)
|
||||
|
||||
1
thirdparty/json
vendored
1
thirdparty/json
vendored
Submodule thirdparty/json deleted from a259ecc51e
Reference in New Issue
Block a user