mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-30 16:10:56 -06:00
Compare commits
4 Commits
cdclient-2
...
v2.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 0bc12141c3 | |||
|
|
8b6fb8fb44 | ||
|
|
929d029f12 | ||
|
|
66cc582a9a |
@@ -81,7 +81,7 @@ void ChatIgnoreList::AddIgnore(Packet* packet) {
|
||||
|
||||
inStream.IgnoreBytes(4); // ignore some garbage zeros idk
|
||||
|
||||
LUWString toIgnoreName(33);
|
||||
LUWString toIgnoreName;
|
||||
inStream.Read(toIgnoreName);
|
||||
std::string toIgnoreStr = toIgnoreName.GetAsString();
|
||||
|
||||
@@ -147,7 +147,7 @@ void ChatIgnoreList::RemoveIgnore(Packet* packet) {
|
||||
|
||||
inStream.IgnoreBytes(4); // ignore some garbage zeros idk
|
||||
|
||||
LUWString removedIgnoreName(33);
|
||||
LUWString removedIgnoreName;
|
||||
inStream.Read(removedIgnoreName);
|
||||
std::string removedIgnoreStr = removedIgnoreName.GetAsString();
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
#include "RacingStatsComponent.h"
|
||||
#include "CollectibleComponent.h"
|
||||
#include "ItemComponent.h"
|
||||
#include "GhostComponent.h"
|
||||
|
||||
// Table includes
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
@@ -436,6 +437,8 @@ void Entity::Initialize() {
|
||||
AddComponent<PlayerForcedMovementComponent>();
|
||||
|
||||
AddComponent<CharacterComponent>(m_Character)->LoadFromXml(m_Character->GetXMLDoc());
|
||||
|
||||
AddComponent<GhostComponent>();
|
||||
}
|
||||
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::INVENTORY) > 0 || m_Character) {
|
||||
@@ -1879,7 +1882,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 +1910,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;
|
||||
};
|
||||
|
||||
@@ -267,7 +267,7 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
User* u = GetUser(sysAddr);
|
||||
if (!u) return;
|
||||
|
||||
LUWString LUWStringName(33);
|
||||
LUWString LUWStringName;
|
||||
uint32_t firstNameIndex;
|
||||
uint32_t middleNameIndex;
|
||||
uint32_t lastNameIndex;
|
||||
@@ -437,7 +437,7 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
uint32_t charID = static_cast<uint32_t>(objectID);
|
||||
LOG("Received char rename request for ID: %llu (%u)", objectID, charID);
|
||||
|
||||
LUWString LUWStringName(33);
|
||||
LUWString LUWStringName;
|
||||
inStream.Read(LUWStringName);
|
||||
const auto newName = LUWStringName.GetAsString();
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -10,6 +10,7 @@ set(DGAME_DCOMPONENTS_SOURCES
|
||||
"ControllablePhysicsComponent.cpp"
|
||||
"DestroyableComponent.cpp"
|
||||
"DonationVendorComponent.cpp"
|
||||
"GhostComponent.cpp"
|
||||
"InventoryComponent.cpp"
|
||||
"ItemComponent.cpp"
|
||||
"LevelProgressionComponent.cpp"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
4
dGame/dComponents/GhostComponent.cpp
Normal file
4
dGame/dComponents/GhostComponent.cpp
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "GhostComponent.h"
|
||||
|
||||
// TODO Move ghosting related code from Player to here
|
||||
GhostComponent::GhostComponent(Entity* parent) : Component(parent) {}
|
||||
13
dGame/dComponents/GhostComponent.h
Normal file
13
dGame/dComponents/GhostComponent.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef __GHOSTCOMPONENT__H__
|
||||
#define __GHOSTCOMPONENT__H__
|
||||
|
||||
#include "Component.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
class GhostComponent : public Component {
|
||||
public:
|
||||
static inline const eReplicaComponentType ComponentType = eReplicaComponentType::GHOST;
|
||||
GhostComponent(Entity* parent);
|
||||
};
|
||||
|
||||
#endif //!__GHOSTCOMPONENT__H__
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -4627,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;
|
||||
|
||||
@@ -503,7 +503,7 @@ void HandlePacket(Packet* packet) {
|
||||
uint32_t theirZoneID = 0;
|
||||
uint32_t theirInstanceID = 0;
|
||||
ServerType theirServerType;
|
||||
LUString theirIP(33);
|
||||
LUString theirIP;
|
||||
|
||||
inStream.Read(theirPort);
|
||||
inStream.Read(theirZoneID);
|
||||
@@ -555,7 +555,7 @@ void HandlePacket(Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
uint32_t sessionKey = 0;
|
||||
inStream.Read(sessionKey);
|
||||
LUString username(33);
|
||||
LUString username;
|
||||
inStream.Read(username);
|
||||
|
||||
for (auto it : activeSessions) {
|
||||
@@ -579,7 +579,7 @@ void HandlePacket(Packet* packet) {
|
||||
|
||||
case eMasterMessageType::REQUEST_SESSION_KEY: {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LUWString username(33);
|
||||
LUWString username;
|
||||
inStream.Read(username);
|
||||
LOG("Requesting session key for %s", username.GetAsString().c_str());
|
||||
for (auto key : activeSessions) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -95,7 +95,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
|
||||
std::vector<Stamp> stamps;
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_START, 0);
|
||||
|
||||
LUWString usernameLUString(33);
|
||||
LUWString usernameLUString;
|
||||
inStream.Read(usernameLUString);
|
||||
const auto username = usernameLUString.GetAsString();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ struct LUString {
|
||||
std::string string;
|
||||
uint32_t size;
|
||||
|
||||
LUString(uint32_t size) {
|
||||
LUString(uint32_t size = 33) {
|
||||
this->size = size;
|
||||
};
|
||||
LUString(std::string string, uint32_t size = 33) {
|
||||
@@ -28,7 +28,7 @@ struct LUWString {
|
||||
std::u16string string;
|
||||
uint32_t size;
|
||||
|
||||
LUWString(uint32_t size) {
|
||||
LUWString(uint32_t size = 33) {
|
||||
this->size = size;
|
||||
};
|
||||
LUWString(std::u16string string, uint32_t size = 33) {
|
||||
|
||||
@@ -99,7 +99,7 @@ void MasterPackets::HandleServerInfo(Packet* packet) {
|
||||
uint32_t theirPort = 0;
|
||||
uint32_t theirZoneID = 0;
|
||||
uint32_t theirInstanceID = 0;
|
||||
LUString theirIP(33);
|
||||
LUString theirIP;
|
||||
|
||||
inStream.Read(theirPort);
|
||||
inStream.Read(theirZoneID);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -677,7 +677,7 @@ void HandleMasterPacket(Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
uint32_t sessionKey = 0;
|
||||
inStream.Read(sessionKey);
|
||||
LUWString username(33);
|
||||
LUWString username;
|
||||
inStream.Read(username);
|
||||
|
||||
//Find them:
|
||||
@@ -761,7 +761,7 @@ void HandleMasterPacket(Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
uint32_t sessionKey = inStream.Read(sessionKey);
|
||||
|
||||
LUString username(33);
|
||||
LUString username;
|
||||
inStream.Read(username);
|
||||
LOG("Got new session alert for user %s", username.string.c_str());
|
||||
//Find them:
|
||||
@@ -847,10 +847,10 @@ void HandlePacket(Packet* packet) {
|
||||
switch (static_cast<eWorldMessageType>(packet->data[3])) {
|
||||
case eWorldMessageType::VALIDATION: {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LUWString username(33);
|
||||
LUWString username;
|
||||
inStream.Read(username);
|
||||
|
||||
LUWString sessionKey(33);
|
||||
LUWString sessionKey;
|
||||
// sometimes client puts a null terminator at the end of the checksum and sometimes doesn't, weird
|
||||
inStream.Read(sessionKey);
|
||||
LUString clientDatabaseChecksum(32);
|
||||
|
||||
@@ -101,7 +101,7 @@ TEST(LUString33Test, SerializeReadTestNew) {
|
||||
std::string testString;
|
||||
for (int i = 0; i < 33; i++) testString += "a";
|
||||
bitStream.Write(LUString(testString, 33));
|
||||
LUString result(33);
|
||||
LUString result;
|
||||
ASSERT_EQ(result.size, 33);
|
||||
ASSERT_TRUE(bitStream.Read(result));
|
||||
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0);
|
||||
@@ -113,7 +113,7 @@ TEST(LUString33Test, SerializeReadTestNewPartial) {
|
||||
std::string testString;
|
||||
for (int i = 0; i < 15; i++) testString += "a";
|
||||
bitStream.Write(LUString(testString, 33));
|
||||
LUString result(33);
|
||||
LUString result;
|
||||
ASSERT_EQ(result.size, 33);
|
||||
ASSERT_TRUE(bitStream.Read(result));
|
||||
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0);
|
||||
|
||||
@@ -101,7 +101,7 @@ TEST(LUWString33Test, SerializeReadTestNew) {
|
||||
std::u16string testString;
|
||||
for (int i = 0; i < 33; i++) testString += u'ü';
|
||||
bitStream.Write(LUWString(testString, 33));
|
||||
LUWString result(33);
|
||||
LUWString result;
|
||||
ASSERT_EQ(result.size, 33);
|
||||
ASSERT_TRUE(bitStream.Read(result));
|
||||
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0);
|
||||
@@ -113,7 +113,7 @@ TEST(LUWString33Test, SerializeReadTestNewPartial) {
|
||||
std::u16string testString;
|
||||
for (int i = 0; i < 15; i++) testString += u'ü';
|
||||
bitStream.Write(LUWString(testString, 33));
|
||||
LUWString result(33);
|
||||
LUWString result;
|
||||
ASSERT_EQ(result.size, 33);
|
||||
ASSERT_TRUE(bitStream.Read(result));
|
||||
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0);
|
||||
|
||||
Reference in New Issue
Block a user