mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-05-08 05:19:59 -05:00
Merge remote-tracking branch 'upstream/main' into more-cdclient-cleanup
This commit is contained in:
+18
-16
@@ -18,7 +18,9 @@
|
||||
#include "InventoryComponent.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "eMissionState.h"
|
||||
#include "eObjectBits.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
#include "ePlayerFlag.h"
|
||||
|
||||
Character::Character(uint32_t id, User* parentUser) {
|
||||
//First load the name, etc:
|
||||
@@ -69,8 +71,8 @@ Character::Character(uint32_t id, User* parentUser) {
|
||||
|
||||
//Set our objectID:
|
||||
m_ObjectID = m_ID;
|
||||
m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_CHARACTER);
|
||||
m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_PERSISTENT);
|
||||
GeneralUtils::SetBit(m_ObjectID, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(m_ObjectID, eObjectBits::PERSISTENT);
|
||||
|
||||
m_ParentUser = parentUser;
|
||||
m_OurEntity = nullptr;
|
||||
@@ -128,8 +130,8 @@ void Character::UpdateFromDatabase() {
|
||||
|
||||
//Set our objectID:
|
||||
m_ObjectID = m_ID;
|
||||
m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_CHARACTER);
|
||||
m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_PERSISTENT);
|
||||
GeneralUtils::SetBit(m_ObjectID, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(m_ObjectID, eObjectBits::PERSISTENT);
|
||||
|
||||
m_OurEntity = nullptr;
|
||||
m_BuildMode = false;
|
||||
@@ -361,9 +363,9 @@ void Character::SaveXMLToDatabase() {
|
||||
}
|
||||
|
||||
// Prevents the news feed from showing up on world transfers
|
||||
if (GetPlayerFlag(ePlayerFlags::IS_NEWS_SCREEN_VISIBLE)) {
|
||||
if (GetPlayerFlag(ePlayerFlag::IS_NEWS_SCREEN_VISIBLE)) {
|
||||
auto* s = m_Doc->NewElement("s");
|
||||
s->SetAttribute("si", ePlayerFlags::IS_NEWS_SCREEN_VISIBLE);
|
||||
s->SetAttribute("si", ePlayerFlag::IS_NEWS_SCREEN_VISIBLE);
|
||||
flags->LinkEndChild(s);
|
||||
}
|
||||
|
||||
@@ -371,7 +373,7 @@ void Character::SaveXMLToDatabase() {
|
||||
|
||||
//Call upon the entity to update our xmlDoc:
|
||||
if (!m_OurEntity) {
|
||||
Game::logger->Log("Character", "We didn't have an entity set while saving! CHARACTER WILL NOT BE SAVED!");
|
||||
Game::logger->Log("Character", "%i:%s didn't have an entity set while saving! CHARACTER WILL NOT BE SAVED!", this->GetID(), this->GetName().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -382,7 +384,7 @@ void Character::SaveXMLToDatabase() {
|
||||
//For metrics, log the time it took to save:
|
||||
auto end = std::chrono::system_clock::now();
|
||||
std::chrono::duration<double> elapsed = end - start;
|
||||
Game::logger->Log("Character", "Saved character to Database in: %fs", elapsed.count());
|
||||
Game::logger->Log("Character", "%i:%s Saved character to Database in: %fs", this->GetID(), this->GetName().c_str(), elapsed.count());
|
||||
}
|
||||
|
||||
void Character::SetIsNewLogin() {
|
||||
@@ -394,7 +396,7 @@ void Character::SetIsNewLogin() {
|
||||
while (currentChild) {
|
||||
if (currentChild->Attribute("si")) {
|
||||
flags->DeleteChild(currentChild);
|
||||
Game::logger->Log("Character", "Removed isLoggedIn flag from character %i, saving character to database", GetID());
|
||||
Game::logger->Log("Character", "Removed isLoggedIn flag from character %i:%s, saving character to database", GetID(), GetName().c_str());
|
||||
WriteToDatabase();
|
||||
}
|
||||
currentChild = currentChild->NextSiblingElement();
|
||||
@@ -416,7 +418,7 @@ void Character::WriteToDatabase() {
|
||||
delete printer;
|
||||
}
|
||||
|
||||
void Character::SetPlayerFlag(const uint32_t flagId, const bool value) {
|
||||
void Character::SetPlayerFlag(const int32_t flagId, const bool value) {
|
||||
// If the flag is already set, we don't have to recalculate it
|
||||
if (GetPlayerFlag(flagId) == value) return;
|
||||
|
||||
@@ -463,7 +465,7 @@ void Character::SetPlayerFlag(const uint32_t flagId, const bool value) {
|
||||
GameMessages::SendNotifyClientFlagChange(m_ObjectID, flagId, value, m_ParentUser->GetSystemAddress());
|
||||
}
|
||||
|
||||
bool Character::GetPlayerFlag(const uint32_t flagId) const {
|
||||
bool Character::GetPlayerFlag(const int32_t flagId) const {
|
||||
// Calculate the index first
|
||||
const auto flagIndex = uint32_t(std::floor(flagId / 64));
|
||||
|
||||
@@ -480,8 +482,8 @@ bool Character::GetPlayerFlag(const uint32_t flagId) const {
|
||||
|
||||
void Character::SetRetroactiveFlags() {
|
||||
// Retroactive check for if player has joined a faction to set their 'joined a faction' flag to true.
|
||||
if (GetPlayerFlag(ePlayerFlags::VENTURE_FACTION) || GetPlayerFlag(ePlayerFlags::ASSEMBLY_FACTION) || GetPlayerFlag(ePlayerFlags::PARADOX_FACTION) || GetPlayerFlag(ePlayerFlags::SENTINEL_FACTION)) {
|
||||
SetPlayerFlag(ePlayerFlags::JOINED_A_FACTION, true);
|
||||
if (GetPlayerFlag(ePlayerFlag::VENTURE_FACTION) || GetPlayerFlag(ePlayerFlag::ASSEMBLY_FACTION) || GetPlayerFlag(ePlayerFlag::PARADOX_FACTION) || GetPlayerFlag(ePlayerFlag::SENTINEL_FACTION)) {
|
||||
SetPlayerFlag(ePlayerFlag::JOINED_A_FACTION, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,7 +543,7 @@ void Character::OnZoneLoad() {
|
||||
if (missionComponent != nullptr) {
|
||||
// Fix the monument race flag
|
||||
if (missionComponent->GetMissionState(319) >= eMissionState::READY_TO_COMPLETE) {
|
||||
SetPlayerFlag(33, true);
|
||||
SetPlayerFlag(ePlayerFlag::AG_FINISH_LINE_BUILT, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,7 +559,7 @@ void Character::OnZoneLoad() {
|
||||
*/
|
||||
if (HasPermission(ePermissionMap::Old)) {
|
||||
if (GetCoins() > 1000000) {
|
||||
SetCoins(1000000, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
SetCoins(1000000, eLootSourceType::NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -635,7 +637,7 @@ void Character::SetBillboardVisible(bool visible) {
|
||||
|
||||
// The GameMessage we send for turning the nameplate off just deletes the BillboardSubcomponent from the parent component.
|
||||
// Because that same message does not allow for custom parameters, we need to create the BillboardSubcomponent a different way
|
||||
// This workaround involves sending an unrelated GameMessage that does not apply to player entites,
|
||||
// This workaround involves sending an unrelated GameMessage that does not apply to player entites,
|
||||
// but forces the client to create the necessary SubComponent that controls the billboard.
|
||||
GameMessages::SendShowBillboardInteractIcon(UNASSIGNED_SYSTEM_ADDRESS, m_OurEntity->GetObjectID());
|
||||
|
||||
|
||||
+3
-2
@@ -16,6 +16,7 @@ struct Packet;
|
||||
class Entity;
|
||||
enum class ePermissionMap : uint64_t;
|
||||
enum class eGameMasterLevel : uint8_t;
|
||||
enum class eLootSourceType : uint32_t;
|
||||
|
||||
/**
|
||||
* Meta information about a character, like their name and style
|
||||
@@ -414,14 +415,14 @@ public:
|
||||
* @param flagId the ID of the flag to set
|
||||
* @param value the value to set for the flag
|
||||
*/
|
||||
void SetPlayerFlag(uint32_t flagId, bool value);
|
||||
void SetPlayerFlag(int32_t flagId, bool value);
|
||||
|
||||
/**
|
||||
* Gets the value for a certain character flag
|
||||
* @param flagId the ID of the flag to get a value for
|
||||
* @return the value of the flag given the ID (the default is false, obviously)
|
||||
*/
|
||||
bool GetPlayerFlag(uint32_t flagId) const;
|
||||
bool GetPlayerFlag(int32_t flagId) const;
|
||||
|
||||
/**
|
||||
* Notifies the character that they're now muted
|
||||
|
||||
+28
-8
@@ -24,6 +24,7 @@
|
||||
#include "Loot.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "eTriggerEventType.h"
|
||||
#include "eObjectBits.h"
|
||||
|
||||
//Component includes:
|
||||
#include "Component.h"
|
||||
@@ -72,6 +73,7 @@
|
||||
#include "TriggerComponent.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "eReplicaPacketType.h"
|
||||
|
||||
// Table includes
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
@@ -706,6 +708,13 @@ void Entity::Initialize() {
|
||||
// TODO: create movementAIcomp and set path
|
||||
}
|
||||
}*/
|
||||
} else {
|
||||
// else we still need to setup moving platform if it has a moving platform comp but no path
|
||||
int32_t movingPlatformComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MOVING_PLATFORM, -1);
|
||||
if (movingPlatformComponentId >= 0) {
|
||||
MovingPlatformComponent* plat = new MovingPlatformComponent(this, pathName);
|
||||
m_Components.insert(std::make_pair(eReplicaComponentType::MOVING_PLATFORM, plat));
|
||||
}
|
||||
}
|
||||
|
||||
int proximityMonitorID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROXIMITY_MONITOR);
|
||||
@@ -728,7 +737,7 @@ void Entity::Initialize() {
|
||||
|
||||
if (!m_Character && EntityManager::Instance()->GetGhostingEnabled()) {
|
||||
// Don't ghost what is likely large scene elements
|
||||
if (m_Components.size() == 2 && HasComponent(eReplicaComponentType::SIMPLE_PHYSICS) && HasComponent(eReplicaComponentType::RENDER)) {
|
||||
if (HasComponent(eReplicaComponentType::SIMPLE_PHYSICS) && HasComponent(eReplicaComponentType::RENDER) && (m_Components.size() == 2 || (HasComponent(eReplicaComponentType::TRIGGER) && m_Components.size() == 3))) {
|
||||
goto no_ghosting;
|
||||
}
|
||||
|
||||
@@ -876,7 +885,7 @@ void Entity::SetGMLevel(eGameMasterLevel value) {
|
||||
}
|
||||
|
||||
void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType) {
|
||||
if (packetType == PACKET_TYPE_CONSTRUCTION) {
|
||||
if (packetType == eReplicaPacketType::CONSTRUCTION) {
|
||||
outBitStream->Write(m_ObjectID);
|
||||
outBitStream->Write(m_TemplateID);
|
||||
|
||||
@@ -953,9 +962,9 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke
|
||||
|
||||
if (m_ParentEntity != nullptr || m_SpawnerID != 0) {
|
||||
outBitStream->Write1();
|
||||
if (m_ParentEntity != nullptr) outBitStream->Write(GeneralUtils::SetBit(m_ParentEntity->GetObjectID(), OBJECT_BIT_CLIENT));
|
||||
if (m_ParentEntity != nullptr) outBitStream->Write(GeneralUtils::SetBit(m_ParentEntity->GetObjectID(), static_cast<uint32_t>(eObjectBits::CLIENT)));
|
||||
else if (m_Spawner != nullptr && m_Spawner->m_Info.isNetwork) outBitStream->Write(m_SpawnerID);
|
||||
else outBitStream->Write(GeneralUtils::SetBit(m_SpawnerID, OBJECT_BIT_CLIENT));
|
||||
else outBitStream->Write(GeneralUtils::SetBit(m_SpawnerID, static_cast<uint32_t>(eObjectBits::CLIENT)));
|
||||
} else outBitStream->Write0();
|
||||
|
||||
outBitStream->Write(m_HasSpawnerNodeID);
|
||||
@@ -978,8 +987,8 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke
|
||||
}
|
||||
|
||||
// Only serialize parent / child info should the info be dirty (changed) or if this is the construction of the entity.
|
||||
outBitStream->Write(m_IsParentChildDirty || packetType == PACKET_TYPE_CONSTRUCTION);
|
||||
if (m_IsParentChildDirty || packetType == PACKET_TYPE_CONSTRUCTION) {
|
||||
outBitStream->Write(m_IsParentChildDirty || packetType == eReplicaPacketType::CONSTRUCTION);
|
||||
if (m_IsParentChildDirty || packetType == eReplicaPacketType::CONSTRUCTION) {
|
||||
m_IsParentChildDirty = false;
|
||||
outBitStream->Write(m_ParentEntity != nullptr);
|
||||
if (m_ParentEntity) {
|
||||
@@ -1004,7 +1013,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
|
||||
|
||||
bool destroyableSerialized = false;
|
||||
bool bIsInitialUpdate = false;
|
||||
if (packetType == PACKET_TYPE_CONSTRUCTION) bIsInitialUpdate = true;
|
||||
if (packetType == eReplicaPacketType::CONSTRUCTION) bIsInitialUpdate = true;
|
||||
unsigned int flags = 0;
|
||||
|
||||
PossessableComponent* possessableComponent;
|
||||
@@ -1233,6 +1242,7 @@ void Entity::Update(const float deltaTime) {
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
||||
script->OnTimerDone(this, timerName);
|
||||
}
|
||||
TriggerEvent(eTriggerEventType::TIMER_DONE, this);
|
||||
} else {
|
||||
timerPosition++;
|
||||
}
|
||||
@@ -1343,6 +1353,10 @@ void Entity::OnCollisionLeavePhantom(const LWOOBJID otherEntity) {
|
||||
auto* other = EntityManager::Instance()->GetEntity(otherEntity);
|
||||
if (!other) return;
|
||||
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
||||
script->OnOffCollisionPhantom(this, other);
|
||||
}
|
||||
|
||||
TriggerEvent(eTriggerEventType::EXIT, other);
|
||||
|
||||
SwitchComponent* switchComp = GetComponent<SwitchComponent>();
|
||||
@@ -1479,6 +1493,12 @@ void Entity::OnChoiceBoxResponse(Entity* sender, int32_t button, const std::u16s
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::RequestActivityExit(Entity* sender, LWOOBJID player, bool canceled) {
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
||||
script->OnRequestActivityExit(sender, player, canceled);
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::Smash(const LWOOBJID source, const eKillType killType, const std::u16string& deathType) {
|
||||
if (!m_PlayerIsReadyForUpdates) return;
|
||||
|
||||
@@ -1619,7 +1639,7 @@ void Entity::PickupItem(const LWOOBJID& objectID) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inv->AddItem(p.second.lot, p.second.count, eLootSourceType::LOOT_SOURCE_PICKUP, eInventoryType::INVALID, {}, LWOOBJID_EMPTY, true, false, LWOOBJID_EMPTY, eInventoryType::INVALID, 1);
|
||||
inv->AddItem(p.second.lot, p.second.count, eLootSourceType::PICKUP, eInventoryType::INVALID, {}, LWOOBJID_EMPTY, true, false, LWOOBJID_EMPTY, eInventoryType::INVALID, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "NiPoint3.h"
|
||||
#include "NiQuaternion.h"
|
||||
#include "LDFFormat.h"
|
||||
#include "eKillType.h"
|
||||
|
||||
namespace Loot {
|
||||
class Info;
|
||||
@@ -33,6 +34,8 @@ class EntityCallbackTimer;
|
||||
enum class eTriggerEventType;
|
||||
enum class eGameMasterLevel : uint8_t;
|
||||
enum class eReplicaComponentType : uint32_t;
|
||||
enum class eReplicaPacketType : uint8_t;
|
||||
enum class eCinematicEvent : uint32_t;
|
||||
|
||||
namespace CppScripts {
|
||||
class Script;
|
||||
@@ -204,6 +207,7 @@ public:
|
||||
|
||||
void OnMessageBoxResponse(Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData);
|
||||
void OnChoiceBoxResponse(Entity* sender, int32_t button, const std::u16string& buttonIdentifier, const std::u16string& identifier);
|
||||
void RequestActivityExit(Entity* sender, LWOOBJID player, bool canceled);
|
||||
|
||||
void Smash(const LWOOBJID source = LWOOBJID_EMPTY, const eKillType killType = eKillType::VIOLENT, const std::u16string& deathType = u"");
|
||||
void Kill(Entity* murderer = nullptr);
|
||||
|
||||
+49
-38
@@ -20,8 +20,10 @@
|
||||
#include "MessageIdentifiers.h"
|
||||
#include "dConfig.h"
|
||||
#include "eTriggerEventType.h"
|
||||
#include "eObjectBits.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "eReplicaPacketType.h"
|
||||
|
||||
EntityManager* EntityManager::m_Address = nullptr;
|
||||
|
||||
@@ -108,11 +110,11 @@ Entity* EntityManager::CreateEntity(EntityInfo info, User* user, Entity* parentE
|
||||
if (!controller && info.lot != 14) {
|
||||
|
||||
// The client flags means the client should render the entity
|
||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_CLIENT);
|
||||
GeneralUtils::SetBit(id, eObjectBits::CLIENT);
|
||||
|
||||
// Spawned entities require the spawned flag to render
|
||||
if (info.spawnerID != 0) {
|
||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_SPAWNED);
|
||||
GeneralUtils::SetBit(id, eObjectBits::SPAWNED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,9 +161,7 @@ void EntityManager::DestroyEntity(const LWOOBJID& objectID) {
|
||||
}
|
||||
|
||||
void EntityManager::DestroyEntity(Entity* entity) {
|
||||
if (entity == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (!entity) return;
|
||||
|
||||
entity->TriggerEvent(eTriggerEventType::DESTROY, entity);
|
||||
|
||||
@@ -180,15 +180,11 @@ void EntityManager::DestroyEntity(Entity* entity) {
|
||||
ScheduleForDeletion(id);
|
||||
}
|
||||
|
||||
void EntityManager::UpdateEntities(const float deltaTime) {
|
||||
for (const auto& e : m_Entities) {
|
||||
e.second->Update(deltaTime);
|
||||
}
|
||||
|
||||
void EntityManager::SerializeEntities() {
|
||||
for (auto entry = m_EntitiesToSerialize.begin(); entry != m_EntitiesToSerialize.end(); entry++) {
|
||||
auto* entity = GetEntity(*entry);
|
||||
|
||||
if (entity == nullptr) continue;
|
||||
if (!entity) continue;
|
||||
|
||||
m_SerializationCounter++;
|
||||
|
||||
@@ -196,8 +192,8 @@ void EntityManager::UpdateEntities(const float deltaTime) {
|
||||
stream.Write(static_cast<char>(ID_REPLICA_MANAGER_SERIALIZE));
|
||||
stream.Write(static_cast<unsigned short>(entity->GetNetworkId()));
|
||||
|
||||
entity->WriteBaseReplicaData(&stream, PACKET_TYPE_SERIALIZATION);
|
||||
entity->WriteComponents(&stream, PACKET_TYPE_SERIALIZATION);
|
||||
entity->WriteBaseReplicaData(&stream, eReplicaPacketType::SERIALIZATION);
|
||||
entity->WriteComponents(&stream, eReplicaPacketType::SERIALIZATION);
|
||||
|
||||
if (entity->GetIsGhostingCandidate()) {
|
||||
for (auto* player : Player::GetAllPlayers()) {
|
||||
@@ -210,45 +206,59 @@ void EntityManager::UpdateEntities(const float deltaTime) {
|
||||
}
|
||||
}
|
||||
m_EntitiesToSerialize.clear();
|
||||
}
|
||||
|
||||
void EntityManager::KillEntities() {
|
||||
for (auto entry = m_EntitiesToKill.begin(); entry != m_EntitiesToKill.end(); entry++) {
|
||||
auto* entity = GetEntity(*entry);
|
||||
|
||||
if (!entity) continue;
|
||||
if (!entity) {
|
||||
Game::logger->Log("EntityManager", "Attempting to kill null entity %llu", *entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entity->GetScheduledKiller()) {
|
||||
entity->Smash(entity->GetScheduledKiller()->GetObjectID(), SILENT);
|
||||
entity->Smash(entity->GetScheduledKiller()->GetObjectID(), eKillType::SILENT);
|
||||
} else {
|
||||
entity->Smash(LWOOBJID_EMPTY, SILENT);
|
||||
entity->Smash(LWOOBJID_EMPTY, eKillType::SILENT);
|
||||
}
|
||||
}
|
||||
m_EntitiesToKill.clear();
|
||||
}
|
||||
|
||||
void EntityManager::DeleteEntities() {
|
||||
for (auto entry = m_EntitiesToDelete.begin(); entry != m_EntitiesToDelete.end(); entry++) {
|
||||
|
||||
// Get all this info first before we delete the player.
|
||||
auto entityToDelete = GetEntity(*entry);
|
||||
auto networkIdToErase = entityToDelete->GetNetworkId();
|
||||
const auto& ghostingToDelete = std::find(m_EntitiesToGhost.begin(), m_EntitiesToGhost.end(), entityToDelete);
|
||||
|
||||
if (entityToDelete) {
|
||||
// If we are a player run through the player destructor.
|
||||
if (entityToDelete->IsPlayer()) {
|
||||
delete dynamic_cast<Player*>(entityToDelete);
|
||||
} else {
|
||||
delete entityToDelete;
|
||||
}
|
||||
// Get all this info first before we delete the player.
|
||||
auto networkIdToErase = entityToDelete->GetNetworkId();
|
||||
const auto& ghostingToDelete = std::find(m_EntitiesToGhost.begin(), m_EntitiesToGhost.end(), entityToDelete);
|
||||
|
||||
delete entityToDelete;
|
||||
|
||||
entityToDelete = nullptr;
|
||||
|
||||
if (networkIdToErase != 0) m_LostNetworkIds.push(networkIdToErase);
|
||||
|
||||
if (ghostingToDelete != m_EntitiesToGhost.end()) m_EntitiesToGhost.erase(ghostingToDelete);
|
||||
} else {
|
||||
Game::logger->Log("EntityManager", "Attempted to delete non-existent entity %llu", *entry);
|
||||
}
|
||||
|
||||
if (ghostingToDelete != m_EntitiesToGhost.end()) m_EntitiesToGhost.erase(ghostingToDelete);
|
||||
|
||||
m_Entities.erase(*entry);
|
||||
}
|
||||
m_EntitiesToDelete.clear();
|
||||
}
|
||||
|
||||
void EntityManager::UpdateEntities(const float deltaTime) {
|
||||
for (const auto& e : m_Entities) {
|
||||
e.second->Update(deltaTime);
|
||||
}
|
||||
|
||||
SerializeEntities();
|
||||
KillEntities();
|
||||
DeleteEntities();
|
||||
}
|
||||
|
||||
Entity* EntityManager::GetEntity(const LWOOBJID& objectId) const {
|
||||
const auto& index = m_Entities.find(objectId);
|
||||
|
||||
@@ -314,6 +324,11 @@ const std::unordered_map<std::string, LWOOBJID>& EntityManager::GetSpawnPointEnt
|
||||
}
|
||||
|
||||
void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr, const bool skipChecks) {
|
||||
if (!entity) {
|
||||
Game::logger->Log("EntityManager", "Attempted to construct null entity");
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity->GetNetworkId() == 0) {
|
||||
uint16_t networkId;
|
||||
|
||||
@@ -351,8 +366,8 @@ void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr
|
||||
stream.Write(true);
|
||||
stream.Write(static_cast<unsigned short>(entity->GetNetworkId()));
|
||||
|
||||
entity->WriteBaseReplicaData(&stream, PACKET_TYPE_CONSTRUCTION);
|
||||
entity->WriteComponents(&stream, PACKET_TYPE_CONSTRUCTION);
|
||||
entity->WriteBaseReplicaData(&stream, eReplicaPacketType::CONSTRUCTION);
|
||||
entity->WriteComponents(&stream, eReplicaPacketType::CONSTRUCTION);
|
||||
|
||||
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) {
|
||||
if (skipChecks) {
|
||||
@@ -393,9 +408,7 @@ void EntityManager::ConstructAllEntities(const SystemAddress& sysAddr) {
|
||||
}
|
||||
|
||||
void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr) {
|
||||
if (entity->GetNetworkId() == 0) {
|
||||
return;
|
||||
}
|
||||
if (!entity || entity->GetNetworkId() == 0) return;
|
||||
|
||||
RakNet::BitStream stream;
|
||||
|
||||
@@ -412,9 +425,7 @@ void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr)
|
||||
}
|
||||
|
||||
void EntityManager::SerializeEntity(Entity* entity) {
|
||||
if (entity->GetNetworkId() == 0) {
|
||||
return;
|
||||
}
|
||||
if (!entity || entity->GetNetworkId() == 0) return;
|
||||
|
||||
if (std::find(m_EntitiesToSerialize.begin(), m_EntitiesToSerialize.end(), entity->GetObjectID()) == m_EntitiesToSerialize.end()) {
|
||||
m_EntitiesToSerialize.push_back(entity->GetObjectID());
|
||||
|
||||
@@ -85,6 +85,10 @@ public:
|
||||
const uint32_t GetHardcoreUscoreEnemiesMultiplier() { return m_HardcoreUscoreEnemiesMultiplier; };
|
||||
|
||||
private:
|
||||
void SerializeEntities();
|
||||
void KillEntities();
|
||||
void DeleteEntities();
|
||||
|
||||
static EntityManager* m_Address; //For singleton method
|
||||
static std::vector<LWOMAPID> m_GhostingExcludedZones;
|
||||
static std::vector<LOT> m_GhostingExcludedLOTs;
|
||||
|
||||
@@ -156,21 +156,21 @@ void Trade::Complete() {
|
||||
}
|
||||
|
||||
// Now actually do the trade.
|
||||
characterA->SetCoins(characterA->GetCoins() - m_CoinsA + m_CoinsB, eLootSourceType::LOOT_SOURCE_TRADE);
|
||||
characterB->SetCoins(characterB->GetCoins() - m_CoinsB + m_CoinsA, eLootSourceType::LOOT_SOURCE_TRADE);
|
||||
characterA->SetCoins(characterA->GetCoins() - m_CoinsA + m_CoinsB, eLootSourceType::TRADE);
|
||||
characterB->SetCoins(characterB->GetCoins() - m_CoinsB + m_CoinsA, eLootSourceType::TRADE);
|
||||
|
||||
for (const auto& tradeItem : m_ItemsA) {
|
||||
auto* itemToRemove = inventoryA->FindItemById(tradeItem.itemId);
|
||||
if (itemToRemove) itemToRemove->SetCount(itemToRemove->GetCount() - tradeItem.itemCount);
|
||||
missionsA->Progress(eMissionTaskType::GATHER, tradeItem.itemLot, LWOOBJID_EMPTY, "", -tradeItem.itemCount);
|
||||
inventoryB->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::LOOT_SOURCE_TRADE);
|
||||
inventoryB->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::TRADE);
|
||||
}
|
||||
|
||||
for (const auto& tradeItem : m_ItemsB) {
|
||||
auto* itemToRemove = inventoryB->FindItemById(tradeItem.itemId);
|
||||
if (itemToRemove) itemToRemove->SetCount(itemToRemove->GetCount() - tradeItem.itemCount);
|
||||
missionsB->Progress(eMissionTaskType::GATHER, tradeItem.itemLot, LWOOBJID_EMPTY, "", -tradeItem.itemCount);
|
||||
inventoryA->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::LOOT_SOURCE_TRADE);
|
||||
inventoryA->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::TRADE);
|
||||
}
|
||||
|
||||
characterA->SaveXMLToDatabase();
|
||||
|
||||
+22
-18
@@ -22,8 +22,12 @@
|
||||
#include "SkillComponent.h"
|
||||
#include "AssetManager.h"
|
||||
#include "CDClientDatabase.h"
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "eObjectBits.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
#include "eCharacterCreationResponse.h"
|
||||
#include "eRenameResponse.h"
|
||||
#include "eConnectionType.h"
|
||||
#include "eChatInternalMessageType.h"
|
||||
|
||||
UserManager* UserManager::m_Address = nullptr;
|
||||
|
||||
@@ -268,13 +272,13 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
|
||||
if (name != "" && !UserManager::IsNameAvailable(name)) {
|
||||
Game::logger->Log("UserManager", "AccountID: %i chose unavailable name: %s", u->GetAccountID(), name.c_str());
|
||||
WorldPackets::SendCharacterCreationResponse(sysAddr, CREATION_RESPONSE_CUSTOM_NAME_IN_USE);
|
||||
WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::CUSTOM_NAME_IN_USE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsNameAvailable(predefinedName)) {
|
||||
Game::logger->Log("UserManager", "AccountID: %i chose unavailable predefined name: %s", u->GetAccountID(), predefinedName.c_str());
|
||||
WorldPackets::SendCharacterCreationResponse(sysAddr, CREATION_RESPONSE_PREDEFINED_NAME_IN_USE);
|
||||
WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::PREDEFINED_NAME_IN_USE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -293,7 +297,7 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
|
||||
if (overlapResult->next()) {
|
||||
Game::logger->Log("UserManager", "Character object id unavailable, check objectidtracker!");
|
||||
WorldPackets::SendCharacterCreationResponse(sysAddr, CREATION_RESPONSE_OBJECT_ID_UNAVAILABLE);
|
||||
WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::OBJECT_ID_UNAVAILABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -313,16 +317,16 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
std::stringstream xml2;
|
||||
|
||||
LWOOBJID lwoidforshirt = idforshirt;
|
||||
lwoidforshirt = GeneralUtils::SetBit(lwoidforshirt, OBJECT_BIT_CHARACTER);
|
||||
lwoidforshirt = GeneralUtils::SetBit(lwoidforshirt, OBJECT_BIT_PERSISTENT);
|
||||
GeneralUtils::SetBit(lwoidforshirt, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(lwoidforshirt, eObjectBits::PERSISTENT);
|
||||
xml2 << xmlSave1 << "<i l=\"" << shirtLOT << "\" id=\"" << lwoidforshirt << "\" s=\"0\" c=\"1\" eq=\"1\" b=\"1\"/>";
|
||||
|
||||
std::string xmlSave2 = xml2.str();
|
||||
|
||||
ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t idforpants) {
|
||||
LWOOBJID lwoidforpants = idforpants;
|
||||
lwoidforpants = GeneralUtils::SetBit(lwoidforpants, OBJECT_BIT_CHARACTER);
|
||||
lwoidforpants = GeneralUtils::SetBit(lwoidforpants, OBJECT_BIT_PERSISTENT);
|
||||
GeneralUtils::SetBit(lwoidforpants, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(lwoidforpants, eObjectBits::PERSISTENT);
|
||||
|
||||
std::stringstream xml3;
|
||||
xml3 << xmlSave2 << "<i l=\"" << pantsLOT << "\" id=\"" << lwoidforpants << "\" s=\"1\" c=\"1\" eq=\"1\" b=\"1\"/>";
|
||||
@@ -369,7 +373,7 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
stmt->execute();
|
||||
delete stmt;
|
||||
|
||||
WorldPackets::SendCharacterCreationResponse(sysAddr, CREATION_RESPONSE_SUCCESS);
|
||||
WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::SUCCESS);
|
||||
UserManager::RequestCharacterList(sysAddr);
|
||||
});
|
||||
});
|
||||
@@ -419,7 +423,7 @@ void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
stmt->execute();
|
||||
delete stmt;
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_PLAYER_REMOVED_NOTIFICATION);
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::PLAYER_REMOVED_NOTIFICATION);
|
||||
bitStream.Write(objectID);
|
||||
Game::chatServer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE, 0, Game::chatSysAddr, false);
|
||||
}
|
||||
@@ -480,8 +484,8 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
}
|
||||
|
||||
LWOOBJID objectID = PacketUtils::ReadPacketS64(8, packet);
|
||||
objectID = GeneralUtils::ClearBit(objectID, OBJECT_BIT_CHARACTER);
|
||||
objectID = GeneralUtils::ClearBit(objectID, OBJECT_BIT_PERSISTENT);
|
||||
GeneralUtils::ClearBit(objectID, eObjectBits::CHARACTER);
|
||||
GeneralUtils::ClearBit(objectID, eObjectBits::PERSISTENT);
|
||||
|
||||
uint32_t charID = static_cast<uint32_t>(objectID);
|
||||
Game::logger->Log("UserManager", "Received char rename request for ID: %llu (%u)", objectID, charID);
|
||||
@@ -499,10 +503,10 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
|
||||
if (!hasCharacter || !character) {
|
||||
Game::logger->Log("UserManager", "User %i tried to rename a character that it does not own!", u->GetAccountID());
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_UNKNOWN_ERROR);
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::UNKNOWN_ERROR);
|
||||
} else if (hasCharacter && character) {
|
||||
if (newName == character->GetName()) {
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_NAME_UNAVAILABLE);
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::NAME_UNAVAILABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -516,7 +520,7 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
delete stmt;
|
||||
|
||||
Game::logger->Log("UserManager", "Character %s now known as %s", character->GetName().c_str(), newName.c_str());
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_SUCCESS);
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::SUCCESS);
|
||||
UserManager::RequestCharacterList(sysAddr);
|
||||
} else {
|
||||
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("UPDATE charinfo SET pending_name=?, needs_rename=0, last_login=? WHERE id=? LIMIT 1");
|
||||
@@ -527,15 +531,15 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
delete stmt;
|
||||
|
||||
Game::logger->Log("UserManager", "Character %s has been renamed to %s and is pending approval by a moderator.", character->GetName().c_str(), newName.c_str());
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_SUCCESS);
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::SUCCESS);
|
||||
UserManager::RequestCharacterList(sysAddr);
|
||||
}
|
||||
} else {
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_NAME_IN_USE);
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::NAME_IN_USE);
|
||||
}
|
||||
} else {
|
||||
Game::logger->Log("UserManager", "Unknown error occurred when renaming character, either hasCharacter or character variable != true.");
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_UNKNOWN_ERROR);
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::UNKNOWN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ void AirMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
|
||||
return;
|
||||
}
|
||||
|
||||
context->RegisterSyncBehavior(handle, this, branch);
|
||||
context->RegisterSyncBehavior(handle, this, branch, this->m_Timeout);
|
||||
}
|
||||
|
||||
void AirMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
@@ -47,4 +47,5 @@ void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitS
|
||||
}
|
||||
|
||||
void AirMovementBehavior::Load() {
|
||||
this->m_Timeout = (GetFloat("timeout_ms") / 1000.0f);
|
||||
}
|
||||
|
||||
@@ -4,13 +4,7 @@
|
||||
class AirMovementBehavior final : public Behavior
|
||||
{
|
||||
public:
|
||||
|
||||
/*
|
||||
* Inherited
|
||||
*/
|
||||
|
||||
explicit AirMovementBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {
|
||||
}
|
||||
explicit AirMovementBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {}
|
||||
|
||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
@@ -19,4 +13,6 @@ public:
|
||||
void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void Load() override;
|
||||
private:
|
||||
float m_Timeout;
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ void AttackDelayBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
|
||||
};
|
||||
|
||||
for (auto i = 0u; i < this->m_numIntervals; ++i) {
|
||||
context->RegisterSyncBehavior(handle, this, branch, m_ignoreInterrupts);
|
||||
context->RegisterSyncBehavior(handle, this, branch, this->m_delay * i, m_ignoreInterrupts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ void BasicAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream*
|
||||
DoBehaviorCalculation(context, bitStream, branch);
|
||||
|
||||
const auto endAddress = bitStream->GetWriteOffset();
|
||||
const uint16_t allocate = endAddress - startAddress + 1;
|
||||
const uint16_t allocate = endAddress - startAddress;
|
||||
|
||||
bitStream->SetWriteOffset(allocatedAddress);
|
||||
bitStream->Write(allocate);
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
#include "SpeedBehavior.h"
|
||||
#include "DamageReductionBehavior.h"
|
||||
#include "JetPackBehavior.h"
|
||||
#include "FallSpeedBehavior.h"
|
||||
#include "ChangeIdleFlagsBehavior.h"
|
||||
#include "DarkInspirationBehavior.h"
|
||||
|
||||
@@ -164,7 +165,9 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId) {
|
||||
case BehaviorTemplates::BEHAVIOR_CAR_BOOST:
|
||||
behavior = new CarBoostBehavior(behaviorId);
|
||||
break;
|
||||
case BehaviorTemplates::BEHAVIOR_FALL_SPEED: break;
|
||||
case BehaviorTemplates::BEHAVIOR_FALL_SPEED:
|
||||
behavior = new FallSpeedBehavior(behaviorId);
|
||||
break;
|
||||
case BehaviorTemplates::BEHAVIOR_SHIELD: break;
|
||||
case BehaviorTemplates::BEHAVIOR_REPAIR_ARMOR:
|
||||
behavior = new RepairBehavior(behaviorId);
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "EchoSyncSkill.h"
|
||||
#include "PhantomPhysicsComponent.h"
|
||||
#include "RebuildComponent.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "eConnectionType.h"
|
||||
|
||||
BehaviorSyncEntry::BehaviorSyncEntry() {
|
||||
}
|
||||
@@ -47,7 +47,7 @@ uint32_t BehaviorContext::GetUniqueSkillId() const {
|
||||
}
|
||||
|
||||
|
||||
void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* behavior, const BehaviorBranchContext& branchContext, bool ignoreInterrupts) {
|
||||
void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* behavior, const BehaviorBranchContext& branchContext, const float duration, bool ignoreInterrupts) {
|
||||
auto entry = BehaviorSyncEntry();
|
||||
|
||||
entry.handle = syncId;
|
||||
@@ -55,6 +55,9 @@ void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* beha
|
||||
entry.branchContext = branchContext;
|
||||
entry.branchContext.isSync = true;
|
||||
entry.ignoreInterrupts = ignoreInterrupts;
|
||||
// Add 10 seconds + duration time to account for lag and give clients time to send their syncs to the server.
|
||||
constexpr float lagTime = 10.0f;
|
||||
entry.time = lagTime + duration;
|
||||
|
||||
this->syncEntries.push_back(entry);
|
||||
}
|
||||
@@ -183,6 +186,21 @@ void BehaviorContext::SyncCalculation(const uint32_t syncId, const float time, B
|
||||
this->syncEntries.push_back(entry);
|
||||
}
|
||||
|
||||
void BehaviorContext::UpdatePlayerSyncs(float deltaTime) {
|
||||
uint32_t i = 0;
|
||||
while (i < this->syncEntries.size()) {
|
||||
auto& entry = this->syncEntries.at(i);
|
||||
|
||||
entry.time -= deltaTime;
|
||||
|
||||
if (entry.time >= 0.0f) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
this->syncEntries.erase(this->syncEntries.begin() + i);
|
||||
}
|
||||
}
|
||||
|
||||
void BehaviorContext::InvokeEnd(const uint32_t id) {
|
||||
std::vector<BehaviorEndEntry> entries;
|
||||
|
||||
@@ -235,7 +253,7 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime) {
|
||||
// Write message
|
||||
RakNet::BitStream message;
|
||||
|
||||
PacketUtils::WriteHeader(message, CLIENT, MSG_CLIENT_GAME_MSG);
|
||||
PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
message.Write(this->originator);
|
||||
echo.Serialize(&message);
|
||||
|
||||
|
||||
@@ -80,7 +80,9 @@ struct BehaviorContext
|
||||
|
||||
uint32_t GetUniqueSkillId() const;
|
||||
|
||||
void RegisterSyncBehavior(uint32_t syncId, Behavior* behavior, const BehaviorBranchContext& branchContext, bool ignoreInterrupts = false);
|
||||
void UpdatePlayerSyncs(float deltaTime);
|
||||
|
||||
void RegisterSyncBehavior(uint32_t syncId, Behavior* behavior, const BehaviorBranchContext& branchContext, const float duration, bool ignoreInterrupts = false);
|
||||
|
||||
void RegisterTimerBehavior(Behavior* behavior, const BehaviorBranchContext& branchContext, LWOOBJID second = LWOOBJID_EMPTY);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ set(DGAME_DBEHAVIORS_SOURCES "AirMovementBehavior.cpp"
|
||||
"DurationBehavior.cpp"
|
||||
"EmptyBehavior.cpp"
|
||||
"EndBehavior.cpp"
|
||||
"FallSpeedBehavior.cpp"
|
||||
"ForceMovementBehavior.cpp"
|
||||
"HealBehavior.cpp"
|
||||
"ImaginationBehavior.cpp"
|
||||
|
||||
@@ -2,43 +2,35 @@
|
||||
#include "BehaviorBranchContext.h"
|
||||
#include "BehaviorContext.h"
|
||||
#include "EntityManager.h"
|
||||
#include "BaseCombatAIComponent.h"
|
||||
|
||||
void ChangeOrientationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
}
|
||||
|
||||
void ChangeOrientationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
if (!m_ToTarget) return; // TODO: Add the other arguments to this behavior
|
||||
Entity* sourceEntity;
|
||||
if (this->m_orientCaster) sourceEntity = EntityManager::Instance()->GetEntity(context->originator);
|
||||
else sourceEntity = EntityManager::Instance()->GetEntity(branch.target);
|
||||
if (!sourceEntity) return;
|
||||
|
||||
auto* self = EntityManager::Instance()->GetEntity(context->originator);
|
||||
auto* other = EntityManager::Instance()->GetEntity(branch.target);
|
||||
if (this->m_toTarget) {
|
||||
Entity* destinationEntity;
|
||||
if (this->m_orientCaster) destinationEntity = EntityManager::Instance()->GetEntity(branch.target);
|
||||
else destinationEntity = EntityManager::Instance()->GetEntity(context->originator);
|
||||
if (!destinationEntity) return;
|
||||
|
||||
if (self == nullptr || other == nullptr) return;
|
||||
|
||||
const auto source = self->GetPosition();
|
||||
const auto destination = self->GetPosition();
|
||||
|
||||
if (m_OrientCaster) {
|
||||
auto* baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>();
|
||||
|
||||
/*if (baseCombatAIComponent != nullptr)
|
||||
{
|
||||
baseCombatAIComponent->LookAt(destination);
|
||||
}
|
||||
else*/
|
||||
{
|
||||
self->SetRotation(NiQuaternion::LookAt(source, destination));
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(self);
|
||||
} else {
|
||||
other->SetRotation(NiQuaternion::LookAt(destination, source));
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(other);
|
||||
}
|
||||
sourceEntity->SetRotation(
|
||||
NiQuaternion::LookAt(sourceEntity->GetPosition(), destinationEntity->GetPosition())
|
||||
);
|
||||
} else if (this->m_toAngle){
|
||||
auto baseAngle = NiPoint3(0, 0, this->m_angle);
|
||||
if (this->m_relative) baseAngle += sourceEntity->GetRotation().GetForwardVector();
|
||||
sourceEntity->SetRotation(NiQuaternion::FromEulerAngles(baseAngle));
|
||||
} else return;
|
||||
EntityManager::Instance()->SerializeEntity(sourceEntity);
|
||||
return;
|
||||
}
|
||||
|
||||
void ChangeOrientationBehavior::Load() {
|
||||
m_OrientCaster = GetBoolean("orient_caster");
|
||||
m_ToTarget = GetBoolean("to_target");
|
||||
this->m_orientCaster = GetBoolean("orient_caster", true);
|
||||
this->m_toTarget = GetBoolean("to_target", false);
|
||||
this->m_toAngle = GetBoolean("to_angle", false);
|
||||
this->m_angle = GetFloat("angle", 0.0f);
|
||||
this->m_relative = GetBoolean("relative", false);
|
||||
}
|
||||
|
||||
@@ -2,24 +2,15 @@
|
||||
|
||||
#include "Behavior.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class ChangeOrientationBehavior final : public Behavior
|
||||
{
|
||||
class ChangeOrientationBehavior final : public Behavior {
|
||||
public:
|
||||
bool m_OrientCaster;
|
||||
bool m_ToTarget;
|
||||
|
||||
/*
|
||||
* Inherited
|
||||
*/
|
||||
|
||||
explicit ChangeOrientationBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||
}
|
||||
|
||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
explicit ChangeOrientationBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {}
|
||||
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void Load() override;
|
||||
private:
|
||||
bool m_orientCaster;
|
||||
bool m_toTarget;
|
||||
bool m_toAngle;
|
||||
float m_angle;
|
||||
bool m_relative;
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ void ChargeUpBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
|
||||
return;
|
||||
};
|
||||
|
||||
context->RegisterSyncBehavior(handle, this, branch);
|
||||
context->RegisterSyncBehavior(handle, this, branch, this->m_MaxDuration);
|
||||
}
|
||||
|
||||
void ChargeUpBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
@@ -24,4 +24,5 @@ void ChargeUpBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStre
|
||||
|
||||
void ChargeUpBehavior::Load() {
|
||||
this->m_action = GetAction("action");
|
||||
this->m_MaxDuration = GetFloat("max_duration");
|
||||
}
|
||||
|
||||
@@ -4,14 +4,7 @@
|
||||
class ChargeUpBehavior final : public Behavior
|
||||
{
|
||||
public:
|
||||
Behavior* m_action;
|
||||
|
||||
/*
|
||||
* Inherited
|
||||
*/
|
||||
|
||||
explicit ChargeUpBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||
}
|
||||
explicit ChargeUpBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {}
|
||||
|
||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
@@ -20,4 +13,7 @@ public:
|
||||
void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void Load() override;
|
||||
private:
|
||||
Behavior* m_action;
|
||||
float m_MaxDuration;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "FallSpeedBehavior.h"
|
||||
|
||||
#include "ControllablePhysicsComponent.h"
|
||||
#include "BehaviorContext.h"
|
||||
#include "BehaviorBranchContext.h"
|
||||
|
||||
|
||||
void FallSpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
// make sure required parameter has non-default value
|
||||
if (m_PercentSlowed == 0.0f) return;
|
||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||
if (!target) return;
|
||||
|
||||
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
||||
if (!controllablePhysicsComponent) return;
|
||||
controllablePhysicsComponent->SetGravityScale(m_PercentSlowed);
|
||||
EntityManager::Instance()->SerializeEntity(target);
|
||||
|
||||
if (branch.duration > 0.0f) {
|
||||
context->RegisterTimerBehavior(this, branch);
|
||||
} else if (branch.start > 0) {
|
||||
context->RegisterEndBehavior(this, branch);
|
||||
}
|
||||
}
|
||||
|
||||
void FallSpeedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
Handle(context, bitStream, branch);
|
||||
}
|
||||
|
||||
void FallSpeedBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||
End(context, branch, second);
|
||||
}
|
||||
|
||||
void FallSpeedBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
||||
End(context, branch, LWOOBJID_EMPTY);
|
||||
}
|
||||
|
||||
void FallSpeedBehavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||
if (!target) return;
|
||||
|
||||
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
||||
if (!controllablePhysicsComponent) return;
|
||||
controllablePhysicsComponent->SetGravityScale(1);
|
||||
EntityManager::Instance()->SerializeEntity(target);
|
||||
}
|
||||
|
||||
void FallSpeedBehavior::Load(){
|
||||
m_PercentSlowed = GetFloat("percent_slowed");
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include "Behavior.h"
|
||||
|
||||
class FallSpeedBehavior final : public Behavior
|
||||
{
|
||||
public:
|
||||
explicit FallSpeedBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {}
|
||||
|
||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override;
|
||||
void End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override;
|
||||
void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override;
|
||||
void Load() override;
|
||||
|
||||
private:
|
||||
float m_PercentSlowed;
|
||||
};
|
||||
@@ -16,7 +16,7 @@ void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream*
|
||||
Game::logger->Log("ForceMovementBehavior", "Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
||||
return;
|
||||
}
|
||||
context->RegisterSyncBehavior(handle, this, branch);
|
||||
context->RegisterSyncBehavior(handle, this, branch, this->m_Duration);
|
||||
}
|
||||
|
||||
void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "dLogger.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "ControllablePhysicsComponent.h"
|
||||
#include "eStateChangeType.h"
|
||||
|
||||
void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "dLogger.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "../dWorldServer/ObjectIDManager.h"
|
||||
#include "eObjectBits.h"
|
||||
|
||||
void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
LWOOBJID target{};
|
||||
@@ -107,7 +108,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
|
||||
for (auto i = 0u; i < this->m_projectileCount; ++i) {
|
||||
auto id = static_cast<LWOOBJID>(ObjectIDManager::Instance()->GenerateObjectID());
|
||||
|
||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_SPAWNED);
|
||||
GeneralUtils::SetBit(id, eObjectBits::SPAWNED);
|
||||
|
||||
bitStream->Write(id);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
|
||||
|
||||
Game::logger->LogDebug("SwitchBehavior", "[%i] State: (%d), imagination: (%i) / (%f)", entity->GetLOT(), state, destroyableComponent->GetImagination(), destroyableComponent->GetMaxImagination());
|
||||
|
||||
if (state || (entity->GetLOT() == 8092 && destroyableComponent->GetImagination() >= m_imagination)) {
|
||||
if (state) {
|
||||
this->m_actionTrue->Handle(context, bitStream, branch);
|
||||
} else {
|
||||
this->m_actionFalse->Handle(context, bitStream, branch);
|
||||
|
||||
@@ -22,13 +22,9 @@ void SwitchMultipleBehavior::Handle(BehaviorContext* context, RakNet::BitStream*
|
||||
for (unsigned int i = 0; i < this->m_behaviors.size(); i++) {
|
||||
|
||||
const double data = this->m_behaviors.at(i).first;
|
||||
trigger = i;
|
||||
|
||||
if (value <= data) {
|
||||
|
||||
trigger = i;
|
||||
|
||||
break;
|
||||
}
|
||||
if (value <= data) break;
|
||||
}
|
||||
|
||||
auto* behavior = this->m_behaviors.at(trigger).second;
|
||||
|
||||
@@ -248,7 +248,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
|
||||
if (rebuild != nullptr) {
|
||||
const auto state = rebuild->GetState();
|
||||
|
||||
if (state != REBUILD_COMPLETED) {
|
||||
if (state != eRebuildState::COMPLETED) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -566,7 +566,7 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
|
||||
if (quickbuild != nullptr) {
|
||||
const auto state = quickbuild->GetState();
|
||||
|
||||
if (state != REBUILD_COMPLETED) {
|
||||
if (state != eRebuildState::COMPLETED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
#include "VehiclePhysicsComponent.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Item.h"
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
#include "eGameActivity.h"
|
||||
|
||||
CharacterComponent::CharacterComponent(Entity* parent, Character* character) : Component(parent) {
|
||||
m_Character = character;
|
||||
@@ -35,7 +36,7 @@ CharacterComponent::CharacterComponent(Entity* parent, Character* character) : C
|
||||
m_EditorLevel = m_GMLevel;
|
||||
m_Reputation = 0;
|
||||
|
||||
m_CurrentActivity = 0;
|
||||
m_CurrentActivity = eGameActivity::NONE;
|
||||
m_CountryCode = 0;
|
||||
m_LastUpdateTimestamp = std::time(nullptr);
|
||||
}
|
||||
@@ -733,6 +734,6 @@ void CharacterComponent::RemoveVentureVisionEffect(std::string ventureVisionType
|
||||
void CharacterComponent::UpdateClientMinimap(bool showFaction, std::string ventureVisionType) const {
|
||||
if (!m_Parent) return;
|
||||
AMFArrayValue arrayToSend;
|
||||
arrayToSend.InsertValue(ventureVisionType, showFaction ? static_cast<AMFValue*>(new AMFTrueValue()) : static_cast<AMFValue*>(new AMFFalseValue()));
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent ? m_Parent->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS, "SetFactionVisibility", &arrayToSend);
|
||||
arrayToSend.Insert(ventureVisionType, showFaction);
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent ? m_Parent->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS, "SetFactionVisibility", arrayToSend);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "tinyxml2.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
enum class eGameActivity : uint32_t;
|
||||
|
||||
/**
|
||||
* The statistics that can be achieved per zone
|
||||
*/
|
||||
@@ -112,13 +114,13 @@ public:
|
||||
* Gets the current activity that the character is partaking in, see ScriptedActivityComponent for more details
|
||||
* @return the current activity that the character is partaking in
|
||||
*/
|
||||
const uint32_t GetCurrentActivity() const { return m_CurrentActivity; }
|
||||
const eGameActivity GetCurrentActivity() const { return m_CurrentActivity; }
|
||||
|
||||
/**
|
||||
* Set the current activity of the character, see ScriptedActivityComponent for more details
|
||||
* @param currentActivity the activity to set
|
||||
*/
|
||||
void SetCurrentActivity(uint32_t currentActivity) { m_CurrentActivity = currentActivity; m_DirtyCurrentActivity = true; }
|
||||
void SetCurrentActivity(eGameActivity currentActivity) { m_CurrentActivity = currentActivity; m_DirtyCurrentActivity = true; }
|
||||
|
||||
/**
|
||||
* Gets if the entity is currently racing
|
||||
@@ -353,7 +355,7 @@ private:
|
||||
/**
|
||||
* The ID of the curently active activity
|
||||
*/
|
||||
int m_CurrentActivity;
|
||||
eGameActivity m_CurrentActivity;
|
||||
|
||||
/**
|
||||
* Whether the social info has been changed
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "Character.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "LevelProgressionComponent.h"
|
||||
#include "eStateChangeType.h"
|
||||
|
||||
ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Component(entity) {
|
||||
m_Position = {};
|
||||
@@ -319,7 +320,7 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) {
|
||||
|
||||
// Recalculate speedboost since we removed one
|
||||
m_SpeedBoost = 0.0f;
|
||||
if (m_ActiveSpeedBoosts.size() == 0) { // no active speed boosts left, so return to base speed
|
||||
if (m_ActiveSpeedBoosts.empty()) { // no active speed boosts left, so return to base speed
|
||||
auto* levelProgressionComponent = m_Parent->GetComponent<LevelProgressionComponent>();
|
||||
if (levelProgressionComponent) m_SpeedBoost = levelProgressionComponent->GetSpeedBase();
|
||||
} else { // Used the last applied speedboost
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
class Entity;
|
||||
class dpEntity;
|
||||
enum class eStateChangeType : uint32_t;
|
||||
|
||||
/**
|
||||
* Handles the movement of controllable Entities, e.g. enemies and players
|
||||
@@ -275,7 +276,7 @@ public:
|
||||
* The speed boosts of this component.
|
||||
* @return All active Speed boosts for this component.
|
||||
*/
|
||||
std::vector<float> GetActiveSpeedboosts() { return m_ActivePickupRadiusScales; };
|
||||
std::vector<float> GetActiveSpeedboosts() { return m_ActiveSpeedBoosts; };
|
||||
|
||||
/**
|
||||
* Activates the Bubble Buff
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "Game.h"
|
||||
#include "dConfig.h"
|
||||
|
||||
#include "AMFFormat.h"
|
||||
#include "AMFFormat_BitStream.h"
|
||||
#include "Amf3.h"
|
||||
#include "AmfSerialize.h"
|
||||
#include "GameMessages.h"
|
||||
#include "User.h"
|
||||
#include "CDClientManager.h"
|
||||
@@ -33,6 +33,8 @@
|
||||
#include "dZoneManager.h"
|
||||
#include "WorldConfig.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "eStateChangeType.h"
|
||||
#include "eGameActivity.h"
|
||||
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
|
||||
@@ -243,16 +245,12 @@ void DestroyableComponent::SetMaxHealth(float value, bool playAnim) {
|
||||
if (playAnim) {
|
||||
// Now update the player bar
|
||||
if (!m_Parent->GetParentUser()) return;
|
||||
AMFStringValue* amount = new AMFStringValue();
|
||||
amount->SetStringValue(std::to_string(difference));
|
||||
AMFStringValue* type = new AMFStringValue();
|
||||
type->SetStringValue("health");
|
||||
|
||||
AMFArrayValue args;
|
||||
args.InsertValue("amount", amount);
|
||||
args.InsertValue("type", type);
|
||||
args.Insert("amount", std::to_string(difference));
|
||||
args.Insert("type", "health");
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
@@ -288,16 +286,12 @@ void DestroyableComponent::SetMaxArmor(float value, bool playAnim) {
|
||||
if (playAnim) {
|
||||
// Now update the player bar
|
||||
if (!m_Parent->GetParentUser()) return;
|
||||
AMFStringValue* amount = new AMFStringValue();
|
||||
amount->SetStringValue(std::to_string(value));
|
||||
AMFStringValue* type = new AMFStringValue();
|
||||
type->SetStringValue("armor");
|
||||
|
||||
AMFArrayValue args;
|
||||
args.InsertValue("amount", amount);
|
||||
args.InsertValue("type", type);
|
||||
args.Insert("amount", std::to_string(value));
|
||||
args.Insert("type", "armor");
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
@@ -332,16 +326,12 @@ void DestroyableComponent::SetMaxImagination(float value, bool playAnim) {
|
||||
if (playAnim) {
|
||||
// Now update the player bar
|
||||
if (!m_Parent->GetParentUser()) return;
|
||||
AMFStringValue* amount = new AMFStringValue();
|
||||
amount->SetStringValue(std::to_string(difference));
|
||||
AMFStringValue* type = new AMFStringValue();
|
||||
type->SetStringValue("imagination");
|
||||
|
||||
AMFArrayValue args;
|
||||
args.InsertValue("amount", amount);
|
||||
args.InsertValue("type", type);
|
||||
args.Insert("amount", std::to_string(difference));
|
||||
args.Insert("type", "imagination");
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||
}
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
}
|
||||
@@ -468,7 +458,7 @@ bool DestroyableComponent::IsKnockbackImmune() const {
|
||||
auto* characterComponent = m_Parent->GetComponent<CharacterComponent>();
|
||||
auto* inventoryComponent = m_Parent->GetComponent<InventoryComponent>();
|
||||
|
||||
if (characterComponent != nullptr && inventoryComponent != nullptr && characterComponent->GetCurrentActivity() == eGameActivities::ACTIVITY_QUICKBUILDING) {
|
||||
if (characterComponent != nullptr && inventoryComponent != nullptr && characterComponent->GetCurrentActivity() == eGameActivity::QUICKBUILDING) {
|
||||
const auto hasPassive = inventoryComponent->HasAnyPassive({
|
||||
eItemSetPassiveAbilityID::EngineerRank2, eItemSetPassiveAbilityID::EngineerRank3,
|
||||
eItemSetPassiveAbilityID::SummonerRank2, eItemSetPassiveAbilityID::SummonerRank3,
|
||||
@@ -514,7 +504,7 @@ bool DestroyableComponent::CheckValidity(const LWOOBJID target, const bool ignor
|
||||
if (targetQuickbuild != nullptr) {
|
||||
const auto state = targetQuickbuild->GetState();
|
||||
|
||||
if (state != REBUILD_COMPLETED) {
|
||||
if (state != eRebuildState::COMPLETED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -803,7 +793,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
coinsTotal -= coinsToLose;
|
||||
|
||||
LootGenerator::Instance().DropLoot(m_Parent, m_Parent, -1, coinsToLose, coinsToLose);
|
||||
character->SetCoins(coinsTotal, eLootSourceType::LOOT_SOURCE_PICKUP);
|
||||
character->SetCoins(coinsTotal, eLootSourceType::PICKUP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -992,7 +982,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
||||
auto uscoreToLose = uscore * (EntityManager::Instance()->GetHardcoreLoseUscoreOnDeathPercent() / 100);
|
||||
character->SetUScore(uscore - uscoreToLose);
|
||||
|
||||
GameMessages::SendModifyLEGOScore(m_Parent, m_Parent->GetSystemAddress(), -uscoreToLose, eLootSourceType::LOOT_SOURCE_MISSION);
|
||||
GameMessages::SendModifyLEGOScore(m_Parent, m_Parent->GetSystemAddress(), -uscoreToLose, eLootSourceType::MISSION);
|
||||
|
||||
if (EntityManager::Instance()->GetHardcoreDropinventoryOnDeath()) {
|
||||
//drop all items from inventory:
|
||||
@@ -1023,7 +1013,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
||||
auto coins = chars->GetCoins();
|
||||
|
||||
//lose all coins:
|
||||
chars->SetCoins(0, eLootSourceType::LOOT_SOURCE_NONE);
|
||||
chars->SetCoins(0, eLootSourceType::NONE);
|
||||
|
||||
//drop all coins:
|
||||
GameMessages::SendDropClientLoot(m_Parent, source, LOT_NULL, coins, m_Parent->GetPosition());
|
||||
@@ -1047,7 +1037,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
||||
int uscore = maxHealth * EntityManager::Instance()->GetHardcoreUscoreEnemiesMultiplier();
|
||||
|
||||
playerStats->SetUScore(playerStats->GetUScore() + uscore);
|
||||
GameMessages::SendModifyLEGOScore(player, player->GetSystemAddress(), uscore, eLootSourceType::LOOT_SOURCE_MISSION);
|
||||
GameMessages::SendModifyLEGOScore(player, player->GetSystemAddress(), uscore, eLootSourceType::MISSION);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace CppScripts {
|
||||
class Script;
|
||||
}; //! namespace CppScripts
|
||||
enum class eStateChangeType : uint32_t;
|
||||
|
||||
/**
|
||||
* Represents the stats of an entity, for example its health, imagination and armor. Also handles factions, which
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "eUnequippableActiveType.h"
|
||||
#include "CppScripts.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "eStateChangeType.h"
|
||||
#include "eUseItemResponse.h"
|
||||
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
#include "CDInventoryComponentTable.h"
|
||||
@@ -356,7 +358,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in
|
||||
|
||||
left -= delta;
|
||||
|
||||
AddItem(lot, delta, eLootSourceType::LOOT_SOURCE_NONE, inventory, {}, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, false, preferredSlot);
|
||||
AddItem(lot, delta, eLootSourceType::NONE, inventory, {}, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, false, preferredSlot);
|
||||
|
||||
item->SetCount(item->GetCount() - delta, false, false);
|
||||
|
||||
@@ -371,7 +373,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in
|
||||
|
||||
const auto delta = std::min<uint32_t>(item->GetCount(), count);
|
||||
|
||||
AddItem(lot, delta, eLootSourceType::LOOT_SOURCE_NONE, inventory, config, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, subkey, origin->GetType(), 0, item->GetBound(), preferredSlot);
|
||||
AddItem(lot, delta, eLootSourceType::NONE, inventory, config, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, subkey, origin->GetType(), 0, item->GetBound(), preferredSlot);
|
||||
|
||||
item->SetCount(item->GetCount() - delta, false, false);
|
||||
}
|
||||
@@ -1247,7 +1249,7 @@ void InventoryComponent::SpawnPet(Item* item) {
|
||||
auto destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (Game::config->GetValue("pets_take_imagination") == "1" && destroyableComponent && destroyableComponent->GetImagination() <= 0) {
|
||||
GameMessages::SendUseItemRequirementsResponse(m_Parent->GetObjectID(), m_Parent->GetSystemAddress(), UseItemResponse::NoImaginationForPet);
|
||||
GameMessages::SendUseItemRequirementsResponse(m_Parent->GetObjectID(), m_Parent->GetSystemAddress(), eUseItemResponse::NoImaginationForPet);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "PossessorComponent.h"
|
||||
#include "eInventoryType.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "eLootSourceType.h"
|
||||
|
||||
class Entity;
|
||||
class ItemSet;
|
||||
@@ -99,7 +100,7 @@ public:
|
||||
void AddItem(
|
||||
LOT lot,
|
||||
uint32_t count,
|
||||
eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE,
|
||||
eLootSourceType lootSourceType = eLootSourceType::NONE,
|
||||
eInventoryType inventoryType = INVALID,
|
||||
const std::vector<LDFBaseData*>& config = {},
|
||||
LWOOBJID parent = LWOOBJID_EMPTY,
|
||||
|
||||
@@ -59,7 +59,7 @@ void LevelProgressionComponent::HandleLevelUp() {
|
||||
for (auto* reward : rewards) {
|
||||
switch (reward->rewardType) {
|
||||
case 0:
|
||||
inventoryComponent->AddItem(reward->value, reward->count, eLootSourceType::LOOT_SOURCE_LEVEL_REWARD);
|
||||
inventoryComponent->AddItem(reward->value, reward->count, eLootSourceType::LEVEL_REWARD);
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "InventoryComponent.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Game.h"
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "Mail.h"
|
||||
#include "MissionPrerequisites.h"
|
||||
|
||||
@@ -14,7 +14,7 @@ class ModuleAssemblyComponent : public Component {
|
||||
public:
|
||||
static const eReplicaComponentType ComponentType = eReplicaComponentType::MODULE_ASSEMBLY;
|
||||
|
||||
ModuleAssemblyComponent(Entity* MSG_CHAT_INTERNAL_PLAYER_REMOVED_NOTIFICATION);
|
||||
ModuleAssemblyComponent(Entity* parent);
|
||||
~ModuleAssemblyComponent() override;
|
||||
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||
|
||||
@@ -307,13 +307,14 @@ float MovementAIComponent::GetBaseSpeed(LOT lot) {
|
||||
|
||||
foundComponent:
|
||||
|
||||
float speed;
|
||||
// Client defaults speed to 10 and if the speed is also null in the table, it defaults to 10.
|
||||
float speed = 10.0f;
|
||||
|
||||
if (physicsComponent == nullptr) {
|
||||
speed = 8;
|
||||
} else {
|
||||
speed = physicsComponent->speed;
|
||||
}
|
||||
if (physicsComponent) speed = physicsComponent->speed;
|
||||
|
||||
float delta = fabs(speed) - 1.0f;
|
||||
|
||||
if (delta <= std::numeric_limits<float>::epsilon()) speed = 10.0f;
|
||||
|
||||
m_PhysicsSpeedCache[lot] = speed;
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
#include "PetDigServer.h"
|
||||
#include "../dWorldServer/ObjectIDManager.h"
|
||||
#include "eUnequippableActiveType.h"
|
||||
#include "eTerminateType.h"
|
||||
#include "ePetTamingNotifyType.h"
|
||||
#include "eUseItemResponse.h"
|
||||
#include "ePlayerFlag.h"
|
||||
|
||||
#include "Game.h"
|
||||
#include "dConfig.h"
|
||||
@@ -23,6 +27,7 @@
|
||||
#include "EntityInfo.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "eObjectBits.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
|
||||
std::unordered_map<LOT, PetComponent::PetPuzzleData> PetComponent::buildCache{};
|
||||
@@ -33,7 +38,7 @@ std::unordered_map<LWOOBJID, LWOOBJID> PetComponent::activePets{};
|
||||
* Maps all the pet lots to a flag indicating that the player has caught it. All basic pets have been guessed by ObjID
|
||||
* while the faction ones could be checked using their respective missions.
|
||||
*/
|
||||
std::map<LOT, uint32_t> PetComponent::petFlags = {
|
||||
std::map<LOT, int32_t> PetComponent::petFlags = {
|
||||
{ 3050, 801 }, // Elephant
|
||||
{ 3054, 803 }, // Cat
|
||||
{ 3195, 806 }, // Triceratops
|
||||
@@ -285,7 +290,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
m_Parent->GetObjectID(),
|
||||
LWOOBJID_EMPTY,
|
||||
true,
|
||||
NOTIFY_TYPE_BEGIN,
|
||||
ePetTamingNotifyType::BEGIN,
|
||||
petPosition,
|
||||
position,
|
||||
rotation,
|
||||
@@ -297,7 +302,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
LWOOBJID_EMPTY,
|
||||
originator->GetObjectID(),
|
||||
true,
|
||||
NOTIFY_TYPE_BEGIN,
|
||||
ePetTamingNotifyType::BEGIN,
|
||||
petPosition,
|
||||
position,
|
||||
rotation,
|
||||
@@ -313,7 +318,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
|
||||
// Notify the start of a pet taming minigame
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) {
|
||||
script->OnNotifyPetTamingMinigame(m_Parent, originator, NOTIFY_TYPE_BEGIN);
|
||||
script->OnNotifyPetTamingMinigame(m_Parent, originator, ePetTamingNotifyType::BEGIN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,8 +557,8 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
||||
|
||||
LWOOBJID petSubKey = ObjectIDManager::Instance()->GenerateRandomObjectID();
|
||||
|
||||
petSubKey = GeneralUtils::SetBit(petSubKey, OBJECT_BIT_CHARACTER);
|
||||
petSubKey = GeneralUtils::SetBit(petSubKey, OBJECT_BIT_PERSISTENT);
|
||||
GeneralUtils::SetBit(petSubKey, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(petSubKey, eObjectBits::PERSISTENT);
|
||||
|
||||
m_DatabaseId = petSubKey;
|
||||
|
||||
@@ -566,7 +571,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
||||
|
||||
GameMessages::SendRegisterPetDBID(m_Tamer, petSubKey, tamer->GetSystemAddress());
|
||||
|
||||
inventoryComponent->AddItem(m_Parent->GetLOT(), 1, eLootSourceType::LOOT_SOURCE_ACTIVITY, eInventoryType::MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey);
|
||||
inventoryComponent->AddItem(m_Parent->GetLOT(), 1, eLootSourceType::ACTIVITY, eInventoryType::MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey);
|
||||
auto* item = inventoryComponent->FindItemBySubKey(petSubKey, MODELS);
|
||||
|
||||
if (item == nullptr) {
|
||||
@@ -590,7 +595,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
||||
LWOOBJID_EMPTY,
|
||||
LWOOBJID_EMPTY,
|
||||
false,
|
||||
NOTIFY_TYPE_NAMINGPET,
|
||||
ePetTamingNotifyType::NAMINGPET,
|
||||
NiPoint3::ZERO,
|
||||
NiPoint3::ZERO,
|
||||
NiQuaternion::IDENTITY,
|
||||
@@ -670,7 +675,7 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
||||
m_Parent->GetObjectID(),
|
||||
m_Tamer,
|
||||
false,
|
||||
NOTIFY_TYPE_SUCCESS,
|
||||
ePetTamingNotifyType::SUCCESS,
|
||||
NiPoint3::ZERO,
|
||||
NiPoint3::ZERO,
|
||||
NiQuaternion::IDENTITY,
|
||||
@@ -691,7 +696,7 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
||||
|
||||
// Notify the end of a pet taming minigame
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) {
|
||||
script->OnNotifyPetTamingMinigame(m_Parent, tamer, NOTIFY_TYPE_SUCCESS);
|
||||
script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,7 +716,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
||||
m_Parent->GetObjectID(),
|
||||
m_Tamer,
|
||||
false,
|
||||
NOTIFY_TYPE_QUIT,
|
||||
ePetTamingNotifyType::QUIT,
|
||||
NiPoint3::ZERO,
|
||||
NiPoint3::ZERO,
|
||||
NiQuaternion::IDENTITY,
|
||||
@@ -732,7 +737,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
||||
|
||||
// Notify the end of a pet taming minigame
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) {
|
||||
script->OnNotifyPetTamingMinigame(m_Parent, tamer, NOTIFY_TYPE_QUIT);
|
||||
script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::QUIT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -762,7 +767,7 @@ void PetComponent::ClientFailTamingMinigame() {
|
||||
m_Parent->GetObjectID(),
|
||||
m_Tamer,
|
||||
false,
|
||||
NOTIFY_TYPE_FAILED,
|
||||
ePetTamingNotifyType::FAILED,
|
||||
NiPoint3::ZERO,
|
||||
NiPoint3::ZERO,
|
||||
NiQuaternion::IDENTITY,
|
||||
@@ -783,7 +788,7 @@ void PetComponent::ClientFailTamingMinigame() {
|
||||
|
||||
// Notify the end of a pet taming minigame
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) {
|
||||
script->OnNotifyPetTamingMinigame(m_Parent, tamer, NOTIFY_TYPE_FAILED);
|
||||
script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -884,7 +889,7 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) {
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
|
||||
owner->GetCharacter()->SetPlayerFlag(69, true);
|
||||
owner->GetCharacter()->SetPlayerFlag(ePlayerFlag::FIRST_MANUAL_PET_HIBERNATE, true);
|
||||
|
||||
if (registerPet) {
|
||||
GameMessages::SendAddPetToPlayer(m_Owner, 0, GeneralUtils::UTF8ToUTF16(m_Name), m_DatabaseId, m_Parent->GetLOT(), owner->GetSystemAddress());
|
||||
@@ -928,7 +933,7 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) {
|
||||
auto playerEntity = playerDestroyableComponent->GetParent();
|
||||
if (!playerEntity) return;
|
||||
|
||||
GameMessages::SendUseItemRequirementsResponse(playerEntity->GetObjectID(), playerEntity->GetSystemAddress(), UseItemResponse::NoImaginationForPet);
|
||||
GameMessages::SendUseItemRequirementsResponse(playerEntity->GetObjectID(), playerEntity->GetSystemAddress(), eUseItemResponse::NoImaginationForPet);
|
||||
}
|
||||
|
||||
this->AddDrainImaginationTimer(item);
|
||||
|
||||
@@ -263,7 +263,7 @@ private:
|
||||
/**
|
||||
* Flags that indicate that a player has tamed a pet, indexed by the LOT of the pet
|
||||
*/
|
||||
static std::map<LOT, uint32_t> petFlags;
|
||||
static std::map<LOT, int32_t> petFlags;
|
||||
|
||||
/**
|
||||
* The ID of the component in the pet component table
|
||||
|
||||
@@ -216,6 +216,13 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
||||
m_dpEntity->SetRotation(m_Rotation);
|
||||
m_dpEntity->SetPosition(m_Position);
|
||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||
} else if (info->physicsAsset == "env\\env_won_fv_gas-blocking-volume.hkx"){
|
||||
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 390.496826f, 111.467964f, 600.821534f, true);
|
||||
m_dpEntity->SetScale(m_Scale);
|
||||
m_dpEntity->SetRotation(m_Rotation);
|
||||
m_Position.y -= (111.467964f * m_Scale) / 2;
|
||||
m_dpEntity->SetPosition(m_Position);
|
||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||
} else {
|
||||
//Game::logger->Log("PhantomPhysicsComponent", "This one is supposed to have %s", info->physicsAsset.c_str());
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "EntityManager.h"
|
||||
#include "GameMessages.h"
|
||||
#include "eUnequippableActiveType.h"
|
||||
#include "eControlScheme.h"
|
||||
#include "eStateChangeType.h"
|
||||
|
||||
PossessorComponent::PossessorComponent(Entity* parent) : Component(parent) {
|
||||
m_Possessable = LWOOBJID_EMPTY;
|
||||
@@ -78,5 +80,5 @@ void PossessorComponent::Dismount(Entity* mount, bool forceDismount) {
|
||||
if (characterComponent) characterComponent->SetIsRacing(false);
|
||||
}
|
||||
// Make sure we don't have wacky controls
|
||||
GameMessages::SendSetPlayerControlScheme(m_Parent, eControlSceme::SCHEME_A);
|
||||
GameMessages::SendSetPlayerControlScheme(m_Parent, eControlScheme::SCHEME_A);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
#include "CharacterComponent.h"
|
||||
#include "UserManager.h"
|
||||
#include "dLogger.h"
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
#include "eObjectBits.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
|
||||
PropertyEntranceComponent::PropertyEntranceComponent(uint32_t componentID, Entity* parent) : Component(parent) {
|
||||
@@ -35,12 +36,9 @@ void PropertyEntranceComponent::OnUse(Entity* entity) {
|
||||
|
||||
AMFArrayValue args;
|
||||
|
||||
auto* state = new AMFStringValue();
|
||||
state->SetStringValue("property_menu");
|
||||
args.Insert("state", "property_menu");
|
||||
|
||||
args.InsertValue("state", state);
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", args);
|
||||
}
|
||||
|
||||
void PropertyEntranceComponent::OnEnterProperty(Entity* entity, uint32_t index, bool returnToZone, const SystemAddress& sysAddr) {
|
||||
@@ -243,8 +241,8 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
|
||||
|
||||
// Convert owner char id to LWOOBJID
|
||||
LWOOBJID ownerObjId = owner;
|
||||
ownerObjId = GeneralUtils::SetBit(ownerObjId, OBJECT_BIT_CHARACTER);
|
||||
ownerObjId = GeneralUtils::SetBit(ownerObjId, OBJECT_BIT_PERSISTENT);
|
||||
GeneralUtils::SetBit(ownerObjId, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(ownerObjId, eObjectBits::PERSISTENT);
|
||||
|
||||
// Query to get friend and best friend fields
|
||||
auto friendCheck = Database::CreatePreppedStmt("SELECT best_friend FROM friends WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?)");
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "PropertyEntranceComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "eObjectBits.h"
|
||||
|
||||
#include <vector>
|
||||
#include "CppScripts.h"
|
||||
@@ -66,8 +67,8 @@ PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Compo
|
||||
if (propertyEntry->next()) {
|
||||
this->propertyId = propertyEntry->getUInt64(1);
|
||||
this->owner = propertyEntry->getUInt64(2);
|
||||
this->owner = GeneralUtils::SetBit(this->owner, OBJECT_BIT_CHARACTER);
|
||||
this->owner = GeneralUtils::SetBit(this->owner, OBJECT_BIT_PERSISTENT);
|
||||
GeneralUtils::SetBit(this->owner, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(this->owner, eObjectBits::PERSISTENT);
|
||||
this->clone_Id = propertyEntry->getInt(2);
|
||||
this->propertyName = propertyEntry->getString(5).c_str();
|
||||
this->propertyDescription = propertyEntry->getString(6).c_str();
|
||||
@@ -372,16 +373,15 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
|
||||
info.emulated = true;
|
||||
info.emulator = EntityManager::Instance()->GetZoneControlEntity()->GetObjectID();
|
||||
|
||||
LWOOBJID id = static_cast<LWOOBJID>(persistentId) | 1ull << OBJECT_BIT_CLIENT;
|
||||
|
||||
info.spawnerID = id;
|
||||
info.spawnerID = persistentId;
|
||||
GeneralUtils::SetBit(info.spawnerID, eObjectBits::CLIENT);
|
||||
|
||||
const auto spawnerId = dZoneManager::Instance()->MakeSpawner(info);
|
||||
|
||||
auto* spawner = dZoneManager::Instance()->GetSpawner(spawnerId);
|
||||
|
||||
auto ldfModelBehavior = new LDFData<LWOOBJID>(u"modelBehaviors", 0);
|
||||
auto userModelID = new LDFData<LWOOBJID>(u"userModelID", id);
|
||||
auto userModelID = new LDFData<LWOOBJID>(u"userModelID", info.spawnerID);
|
||||
auto modelType = new LDFData<int>(u"modelType", 2);
|
||||
auto propertyObjectID = new LDFData<bool>(u"propertyObjectID", true);
|
||||
auto componentWhitelist = new LDFData<int>(u"componentWhitelist", 1);
|
||||
@@ -476,7 +476,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
settings.push_back(propertyObjectID);
|
||||
settings.push_back(modelType);
|
||||
|
||||
inventoryComponent->AddItem(6662, 1, eLootSourceType::LOOT_SOURCE_DELETION, eInventoryType::MODELS_IN_BBB, settings, LWOOBJID_EMPTY, false, false, spawnerId);
|
||||
inventoryComponent->AddItem(6662, 1, eLootSourceType::DELETION, eInventoryType::MODELS_IN_BBB, settings, LWOOBJID_EMPTY, false, false, spawnerId);
|
||||
auto* item = inventoryComponent->FindItemBySubKey(spawnerId);
|
||||
|
||||
if (item == nullptr) {
|
||||
@@ -498,7 +498,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
if (spawner != nullptr) {
|
||||
dZoneManager::Instance()->RemoveSpawner(spawner->m_Info.spawnerID);
|
||||
} else {
|
||||
model->Smash(SILENT);
|
||||
model->Smash(LWOOBJID_EMPTY, eKillType::SILENT);
|
||||
}
|
||||
|
||||
item->SetCount(0, true, false, false);
|
||||
@@ -506,7 +506,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
return;
|
||||
}
|
||||
|
||||
inventoryComponent->AddItem(model->GetLOT(), 1, eLootSourceType::LOOT_SOURCE_DELETION, INVALID, {}, LWOOBJID_EMPTY, false);
|
||||
inventoryComponent->AddItem(model->GetLOT(), 1, eLootSourceType::DELETION, INVALID, {}, LWOOBJID_EMPTY, false);
|
||||
|
||||
auto* item = inventoryComponent->FindItemByLot(model->GetLOT());
|
||||
|
||||
@@ -551,7 +551,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
if (spawner != nullptr) {
|
||||
dZoneManager::Instance()->RemoveSpawner(spawner->m_Info.spawnerID);
|
||||
} else {
|
||||
model->Smash(SILENT);
|
||||
model->Smash(LWOOBJID_EMPTY, eKillType::SILENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,8 +622,8 @@ void PropertyManagementComponent::Load() {
|
||||
//BBB property models need to have extra stuff set for them:
|
||||
if (lot == 14) {
|
||||
LWOOBJID blueprintID = lookupResult->getUInt(10);
|
||||
blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_CHARACTER);
|
||||
blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_PERSISTENT);
|
||||
GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT);
|
||||
|
||||
LDFBaseData* ldfBlueprintID = new LDFData<LWOOBJID>(u"blueprintid", blueprintID);
|
||||
LDFBaseData* componentWhitelist = new LDFData<int>(u"componentWhitelist", 1);
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "dConfig.h"
|
||||
#include "Loot.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "CDActivitiesTable.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846264338327950288
|
||||
@@ -45,36 +47,14 @@ RacingControlComponent::RacingControlComponent(Entity* parent)
|
||||
m_EmptyTimer = 0;
|
||||
m_SoloRacing = Game::config->GetValue("solo_racing") == "1";
|
||||
|
||||
// Select the main world ID as fallback when a player fails to load.
|
||||
|
||||
m_MainWorld = 1200;
|
||||
const auto worldID = Game::server->GetZoneID();
|
||||
if (dZoneManager::Instance()->CheckIfAccessibleZone((worldID/10)*10)) m_MainWorld = (worldID/10)*10;
|
||||
|
||||
switch (worldID) {
|
||||
case 1203:
|
||||
m_ActivityID = 42;
|
||||
m_MainWorld = 1200;
|
||||
break;
|
||||
|
||||
case 1261:
|
||||
m_ActivityID = 60;
|
||||
m_MainWorld = 1260;
|
||||
break;
|
||||
|
||||
case 1303:
|
||||
m_ActivityID = 39;
|
||||
m_MainWorld = 1300;
|
||||
break;
|
||||
|
||||
case 1403:
|
||||
m_ActivityID = 54;
|
||||
m_MainWorld = 1400;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_ActivityID = 42;
|
||||
m_MainWorld = 1200;
|
||||
break;
|
||||
}
|
||||
m_ActivityID = 42;
|
||||
CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable<CDActivitiesTable>();
|
||||
std::vector<CDActivities> activities = activitiesTable->Query([=](CDActivities entry) {return (entry.instanceMapID == worldID); });
|
||||
for (CDActivities activity : activities) m_ActivityID = activity.ActivityID;
|
||||
}
|
||||
|
||||
RacingControlComponent::~RacingControlComponent() {}
|
||||
@@ -311,7 +291,7 @@ void RacingControlComponent::OnRequestDie(Entity* player) {
|
||||
if (!racingPlayer.noSmashOnReload) {
|
||||
racingPlayer.smashedTimes++;
|
||||
GameMessages::SendDie(vehicle, vehicle->GetObjectID(), LWOOBJID_EMPTY, true,
|
||||
VIOLENT, u"", 0, 0, 90.0f, false, true, 0);
|
||||
eKillType::VIOLENT, u"", 0, 0, 90.0f, false, true, 0);
|
||||
|
||||
auto* destroyableComponent = vehicle->GetComponent<DestroyableComponent>();
|
||||
uint32_t respawnImagination = 0;
|
||||
@@ -382,8 +362,7 @@ void RacingControlComponent::OnRacingPlayerInfoResetFinished(Entity* player) {
|
||||
}
|
||||
}
|
||||
|
||||
void RacingControlComponent::HandleMessageBoxResponse(Entity* player,
|
||||
const std::string& id) {
|
||||
void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t button, const std::string& id) {
|
||||
auto* data = GetPlayerData(player->GetObjectID());
|
||||
|
||||
if (data == nullptr) {
|
||||
@@ -425,7 +404,7 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player,
|
||||
missionComponent->Progress(eMissionTaskType::RACING, dZoneManager::Instance()->GetZone()->GetWorldID(), (LWOOBJID)eRacingTaskParam::LAST_PLACE_FINISH); // Finished first place in specific world.
|
||||
}
|
||||
}
|
||||
} else if (id == "ACT_RACE_EXIT_THE_RACE?" || id == "Exit") {
|
||||
} else if ((id == "ACT_RACE_EXIT_THE_RACE?" || id == "Exit") && button == m_ActivityExitConfirm) {
|
||||
auto* vehicle = EntityManager::Instance()->GetEntity(data->vehicleID);
|
||||
|
||||
if (vehicle == nullptr) {
|
||||
@@ -765,7 +744,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
// be smashed by death plane
|
||||
if (vehiclePosition.y < -500) {
|
||||
GameMessages::SendDie(vehicle, m_Parent->GetObjectID(),
|
||||
LWOOBJID_EMPTY, true, VIOLENT, u"", 0, 0, 0,
|
||||
LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0,
|
||||
true, false, 0);
|
||||
|
||||
OnRequestDie(playerEntity);
|
||||
|
||||
@@ -144,7 +144,7 @@ public:
|
||||
/**
|
||||
* Invoked when the player responds to the GUI.
|
||||
*/
|
||||
void HandleMessageBoxResponse(Entity* player, const std::string& id);
|
||||
void HandleMessageBoxResponse(Entity* player, int32_t button, const std::string& id);
|
||||
|
||||
/**
|
||||
* Get the racing data from a player's LWOOBJID.
|
||||
@@ -246,4 +246,9 @@ private:
|
||||
float m_EmptyTimer;
|
||||
|
||||
bool m_SoloRacing;
|
||||
|
||||
/**
|
||||
* Value for message box response to know if we are exiting the race via the activity dialogue
|
||||
*/
|
||||
const int32_t m_ActivityExitConfirm = 1;
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "dLogger.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "EntityManager.h"
|
||||
#include "eStateChangeType.h"
|
||||
|
||||
RailActivatorComponent::RailActivatorComponent(Entity* parent, int32_t componentID) : Component(parent) {
|
||||
m_ComponentID = componentID;
|
||||
@@ -43,7 +44,7 @@ RailActivatorComponent::~RailActivatorComponent() = default;
|
||||
|
||||
void RailActivatorComponent::OnUse(Entity* originator) {
|
||||
auto* rebuildComponent = m_Parent->GetComponent<RebuildComponent>();
|
||||
if (rebuildComponent != nullptr && rebuildComponent->GetState() != REBUILD_COMPLETED)
|
||||
if (rebuildComponent != nullptr && rebuildComponent->GetState() != eRebuildState::COMPLETED)
|
||||
return;
|
||||
|
||||
if (rebuildComponent != nullptr) {
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
#include "MissionComponent.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "eTriggerEventType.h"
|
||||
#include "eQuickBuildFailReason.h"
|
||||
#include "eTerminateType.h"
|
||||
#include "eGameActivity.h"
|
||||
|
||||
#include "dServer.h"
|
||||
#include "PacketUtils.h"
|
||||
@@ -48,7 +51,7 @@ RebuildComponent::~RebuildComponent() {
|
||||
|
||||
Entity* builder = GetBuilder();
|
||||
if (builder) {
|
||||
CancelRebuild(builder, eFailReason::REASON_BUILD_ENDED, true);
|
||||
CancelRebuild(builder, eQuickBuildFailReason::BUILD_ENDED, true);
|
||||
}
|
||||
|
||||
DespawnActivator();
|
||||
@@ -67,7 +70,7 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia
|
||||
// If build state is completed and we've already serialized once in the completed state,
|
||||
// don't serializing this component anymore as this will cause the build to jump again.
|
||||
// If state changes, serialization will begin again.
|
||||
if (!m_StateDirty && m_State == REBUILD_COMPLETED) {
|
||||
if (!m_StateDirty && m_State == eRebuildState::COMPLETED) {
|
||||
outBitStream->Write0();
|
||||
outBitStream->Write0();
|
||||
return;
|
||||
@@ -91,7 +94,7 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia
|
||||
|
||||
outBitStream->Write1();
|
||||
|
||||
outBitStream->Write<uint32_t>(m_State);
|
||||
outBitStream->Write(m_State);
|
||||
|
||||
outBitStream->Write(m_ShowResetEffect);
|
||||
outBitStream->Write(m_Activator != nullptr);
|
||||
@@ -121,7 +124,7 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
}*/
|
||||
|
||||
switch (m_State) {
|
||||
case REBUILD_OPEN: {
|
||||
case eRebuildState::OPEN: {
|
||||
SpawnActivator();
|
||||
m_TimeBeforeDrain = 0;
|
||||
|
||||
@@ -151,7 +154,7 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
|
||||
break;
|
||||
}
|
||||
case REBUILD_COMPLETED: {
|
||||
case eRebuildState::COMPLETED: {
|
||||
m_Timer += deltaTime;
|
||||
|
||||
// For reset times < 0 this has to be handled manually
|
||||
@@ -173,7 +176,7 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case REBUILD_BUILDING:
|
||||
case eRebuildState::BUILDING:
|
||||
{
|
||||
Entity* builder = GetBuilder();
|
||||
|
||||
@@ -194,18 +197,18 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
DestroyableComponent* destComp = builder->GetComponent<DestroyableComponent>();
|
||||
if (!destComp) break;
|
||||
|
||||
int newImagination = destComp->GetImagination() - 1;
|
||||
int newImagination = destComp->GetImagination();
|
||||
if (newImagination <= 0) {
|
||||
CancelRebuild(builder, eQuickBuildFailReason::OUT_OF_IMAGINATION, true);
|
||||
break;
|
||||
}
|
||||
|
||||
++m_DrainedImagination;
|
||||
--newImagination;
|
||||
destComp->SetImagination(newImagination);
|
||||
EntityManager::Instance()->SerializeEntity(builder);
|
||||
|
||||
++m_DrainedImagination;
|
||||
|
||||
if (newImagination == 0 && m_DrainedImagination < m_TakeImagination) {
|
||||
CancelRebuild(builder, eFailReason::REASON_OUT_OF_IMAGINATION, true);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Timer >= m_CompleteTime && m_DrainedImagination >= m_TakeImagination) {
|
||||
@@ -214,7 +217,7 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
|
||||
break;
|
||||
}
|
||||
case REBUILD_INCOMPLETE: {
|
||||
case eRebuildState::INCOMPLETE: {
|
||||
m_TimerIncomplete += deltaTime;
|
||||
|
||||
// For reset times < 0 this has to be handled manually
|
||||
@@ -235,11 +238,12 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case eRebuildState::RESETTING: break;
|
||||
}
|
||||
}
|
||||
|
||||
void RebuildComponent::OnUse(Entity* originator) {
|
||||
if (GetBuilder() != nullptr || m_State == REBUILD_COMPLETED) {
|
||||
if (GetBuilder() != nullptr || m_State == eRebuildState::COMPLETED) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -393,18 +397,18 @@ void RebuildComponent::SetRepositionPlayer(bool value) {
|
||||
}
|
||||
|
||||
void RebuildComponent::StartRebuild(Entity* user) {
|
||||
if (m_State == eRebuildState::REBUILD_OPEN || m_State == eRebuildState::REBUILD_COMPLETED || m_State == eRebuildState::REBUILD_INCOMPLETE) {
|
||||
if (m_State == eRebuildState::OPEN || m_State == eRebuildState::COMPLETED || m_State == eRebuildState::INCOMPLETE) {
|
||||
m_Builder = user->GetObjectID();
|
||||
|
||||
auto* character = user->GetComponent<CharacterComponent>();
|
||||
character->SetCurrentActivity(eGameActivities::ACTIVITY_QUICKBUILDING);
|
||||
character->SetCurrentActivity(eGameActivity::QUICKBUILDING);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(user);
|
||||
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_BUILDING, user->GetObjectID());
|
||||
GameMessages::SendEnableRebuild(m_Parent, true, false, false, eFailReason::REASON_NOT_GIVEN, 0.0f, user->GetObjectID());
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::BUILDING, user->GetObjectID());
|
||||
GameMessages::SendEnableRebuild(m_Parent, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID());
|
||||
|
||||
m_State = eRebuildState::REBUILD_BUILDING;
|
||||
m_State = eRebuildState::BUILDING;
|
||||
m_StateDirty = true;
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
|
||||
@@ -432,7 +436,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
|
||||
auto* characterComponent = user->GetComponent<CharacterComponent>();
|
||||
if (characterComponent != nullptr) {
|
||||
characterComponent->SetCurrentActivity(eGameActivities::ACTIVITY_NONE);
|
||||
characterComponent->SetCurrentActivity(eGameActivity::NONE);
|
||||
characterComponent->TrackRebuildComplete();
|
||||
} else {
|
||||
Game::logger->Log("RebuildComponent", "Some user tried to finish the rebuild but they didn't have a character somehow.");
|
||||
@@ -441,13 +445,13 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(user);
|
||||
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_COMPLETED, user->GetObjectID());
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::COMPLETED, user->GetObjectID());
|
||||
GameMessages::SendPlayFXEffect(m_Parent, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true);
|
||||
GameMessages::SendEnableRebuild(m_Parent, false, false, true, eFailReason::REASON_NOT_GIVEN, m_ResetTime, user->GetObjectID());
|
||||
GameMessages::SendEnableRebuild(m_Parent, false, false, true, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, user->GetObjectID());
|
||||
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID());
|
||||
|
||||
|
||||
m_State = eRebuildState::REBUILD_COMPLETED;
|
||||
m_State = eRebuildState::COMPLETED;
|
||||
m_StateDirty = true;
|
||||
m_Timer = 0.0f;
|
||||
m_DrainedImagination = 0;
|
||||
@@ -520,17 +524,17 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
void RebuildComponent::ResetRebuild(bool failed) {
|
||||
Entity* builder = GetBuilder();
|
||||
|
||||
if (m_State == eRebuildState::REBUILD_BUILDING && builder) {
|
||||
GameMessages::SendEnableRebuild(m_Parent, false, false, failed, eFailReason::REASON_NOT_GIVEN, m_ResetTime, builder->GetObjectID());
|
||||
if (m_State == eRebuildState::BUILDING && builder) {
|
||||
GameMessages::SendEnableRebuild(m_Parent, false, false, failed, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, builder->GetObjectID());
|
||||
|
||||
if (failed) {
|
||||
RenderComponent::PlayAnimation(builder, u"rebuild-fail");
|
||||
}
|
||||
}
|
||||
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_RESETTING, LWOOBJID_EMPTY);
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::RESETTING, LWOOBJID_EMPTY);
|
||||
|
||||
m_State = eRebuildState::REBUILD_RESETTING;
|
||||
m_State = eRebuildState::RESETTING;
|
||||
m_StateDirty = true;
|
||||
m_Timer = 0.0f;
|
||||
m_TimerIncomplete = 0.0f;
|
||||
@@ -552,15 +556,15 @@ void RebuildComponent::ResetRebuild(bool failed) {
|
||||
}
|
||||
}
|
||||
|
||||
void RebuildComponent::CancelRebuild(Entity* entity, eFailReason failReason, bool skipChecks) {
|
||||
if (m_State != eRebuildState::REBUILD_COMPLETED || skipChecks) {
|
||||
void RebuildComponent::CancelRebuild(Entity* entity, eQuickBuildFailReason failReason, bool skipChecks) {
|
||||
if (m_State != eRebuildState::COMPLETED || skipChecks) {
|
||||
|
||||
m_Builder = LWOOBJID_EMPTY;
|
||||
|
||||
const auto entityID = entity != nullptr ? entity->GetObjectID() : LWOOBJID_EMPTY;
|
||||
|
||||
// Notify the client that a state has changed
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_INCOMPLETE, entityID);
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::INCOMPLETE, entityID);
|
||||
GameMessages::SendEnableRebuild(m_Parent, false, true, false, failReason, m_Timer, entityID);
|
||||
|
||||
// Now terminate any interaction with the rebuild
|
||||
@@ -568,7 +572,7 @@ void RebuildComponent::CancelRebuild(Entity* entity, eFailReason failReason, boo
|
||||
GameMessages::SendTerminateInteraction(m_Parent->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID());
|
||||
|
||||
// Now update the component itself
|
||||
m_State = eRebuildState::REBUILD_INCOMPLETE;
|
||||
m_State = eRebuildState::INCOMPLETE;
|
||||
m_StateDirty = true;
|
||||
|
||||
// Notify scripts and possible subscribers
|
||||
@@ -586,7 +590,7 @@ void RebuildComponent::CancelRebuild(Entity* entity, eFailReason failReason, boo
|
||||
|
||||
CharacterComponent* characterComponent = entity->GetComponent<CharacterComponent>();
|
||||
if (characterComponent) {
|
||||
characterComponent->SetCurrentActivity(eGameActivities::ACTIVITY_NONE);
|
||||
characterComponent->SetCurrentActivity(eGameActivity::NONE);
|
||||
EntityManager::Instance()->SerializeEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
#include "Preconditions.h"
|
||||
#include "Component.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "eRebuildState.h"
|
||||
|
||||
class Entity;
|
||||
enum class eQuickBuildFailReason : uint32_t;
|
||||
|
||||
/**
|
||||
* Component that handles entities that can be built into other entities using the quick build mechanic. Generally
|
||||
@@ -215,7 +217,7 @@ public:
|
||||
* @param failReason the reason the rebuild was cancelled
|
||||
* @param skipChecks whether or not to skip the check for the rebuild not being completed
|
||||
*/
|
||||
void CancelRebuild(Entity* builder, eFailReason failReason, bool skipChecks = false);
|
||||
void CancelRebuild(Entity* builder, eQuickBuildFailReason failReason, bool skipChecks = false);
|
||||
private:
|
||||
/**
|
||||
* Whether or not the quickbuild state has been changed since we last serialized it.
|
||||
@@ -225,7 +227,7 @@ private:
|
||||
/**
|
||||
* The state the rebuild is currently in
|
||||
*/
|
||||
eRebuildState m_State = eRebuildState::REBUILD_OPEN;
|
||||
eRebuildState m_State = eRebuildState::OPEN;
|
||||
|
||||
/**
|
||||
* The time that has passed since initiating the rebuild
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
#include "Component.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
|
||||
@@ -15,8 +15,10 @@
|
||||
#include "PropertyEntranceComponent.h"
|
||||
#include "RocketLaunchLupComponent.h"
|
||||
#include "dServer.h"
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "PacketUtils.h"
|
||||
#include "eObjectWorldState.h"
|
||||
#include "eConnectionType.h"
|
||||
#include "eMasterMessageType.h"
|
||||
|
||||
RocketLaunchpadControlComponent::RocketLaunchpadControlComponent(Entity* parent, int rocketId) : Component(parent) {
|
||||
auto query = CDClientDatabase::CreatePreppedStmt(
|
||||
@@ -77,7 +79,7 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId,
|
||||
|
||||
GameMessages::SendFireEventClientSide(m_Parent->GetObjectID(), originator->GetSystemAddress(), u"RocketEquipped", rocket->GetId(), cloneId, -1, originator->GetObjectID());
|
||||
|
||||
GameMessages::SendChangeObjectWorldState(rocket->GetId(), WORLDSTATE_ATTACHED, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
GameMessages::SendChangeObjectWorldState(rocket->GetId(), eObjectWorldState::ATTACHED, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(originator);
|
||||
}
|
||||
@@ -135,7 +137,7 @@ LWOCLONEID RocketLaunchpadControlComponent::GetSelectedCloneId(LWOOBJID player)
|
||||
|
||||
void RocketLaunchpadControlComponent::TellMasterToPrepZone(int zoneID) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_PREP_ZONE);
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::PREP_ZONE);
|
||||
bitStream.Write(zoneID);
|
||||
Game::server->SendToMaster(&bitStream);
|
||||
}
|
||||
|
||||
@@ -18,13 +18,16 @@
|
||||
#include "dConfig.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "Loot.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "eMatchUpdate.h"
|
||||
#include "eConnectionType.h"
|
||||
#include "eChatInternalMessageType.h"
|
||||
|
||||
#include "CDCurrencyTableTable.h"
|
||||
#include "CDActivityRewardsTable.h"
|
||||
#include "CDActivitiesTable.h"
|
||||
#include "LeaderboardManager.h"
|
||||
|
||||
ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activityID) : Component(parent) {
|
||||
m_ActivityID = activityID;
|
||||
@@ -33,10 +36,7 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit
|
||||
|
||||
for (CDActivities activity : activities) {
|
||||
m_ActivityInfo = activity;
|
||||
|
||||
const auto mapID = m_ActivityInfo.instanceMapID;
|
||||
|
||||
if ((mapID == 1203 || mapID == 1261 || mapID == 1303 || mapID == 1403) && Game::config->GetValue("solo_racing") == "1") {
|
||||
if (static_cast<LeaderboardType>(activity.leaderboardType) == LeaderboardType::Racing && Game::config->GetValue("solo_racing") == "1") {
|
||||
m_ActivityInfo.minTeamSize = 1;
|
||||
m_ActivityInfo.minTeams = 1;
|
||||
}
|
||||
@@ -167,9 +167,9 @@ void ScriptedActivityComponent::PlayerJoinLobby(Entity* player) {
|
||||
}
|
||||
|
||||
std::string matchUpdate = "player=9:" + std::to_string(entity->GetObjectID()) + "\nplayerName=0:" + entity->GetCharacter()->GetName();
|
||||
GameMessages::SendMatchUpdate(player, player->GetSystemAddress(), matchUpdate, eMatchUpdate::MATCH_UPDATE_PLAYER_JOINED);
|
||||
GameMessages::SendMatchUpdate(player, player->GetSystemAddress(), matchUpdate, eMatchUpdate::PLAYER_ADDED);
|
||||
PlayerReady(entity, joinedPlayer->ready);
|
||||
GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchUpdateJoined, eMatchUpdate::MATCH_UPDATE_PLAYER_JOINED);
|
||||
GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchUpdateJoined, eMatchUpdate::PLAYER_ADDED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,7 @@ void ScriptedActivityComponent::PlayerJoinLobby(Entity* player) {
|
||||
if (m_ActivityInfo.maxTeamSize != 1 && playerLobby->players.size() >= m_ActivityInfo.minTeamSize || m_ActivityInfo.maxTeamSize == 1 && playerLobby->players.size() >= m_ActivityInfo.minTeams) {
|
||||
// Update the joining player on the match timer
|
||||
std::string matchTimerUpdate = "time=3:" + std::to_string(playerLobby->timer);
|
||||
GameMessages::SendMatchUpdate(player, player->GetSystemAddress(), matchTimerUpdate, eMatchUpdate::MATCH_UPDATE_TIME);
|
||||
GameMessages::SendMatchUpdate(player, player->GetSystemAddress(), matchTimerUpdate, eMatchUpdate::PHASE_WAIT_READY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ void ScriptedActivityComponent::PlayerLeave(LWOOBJID playerID) {
|
||||
if (entity == nullptr)
|
||||
continue;
|
||||
|
||||
GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchUpdateLeft, eMatchUpdate::MATCH_UPDATE_PLAYER_LEFT);
|
||||
GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchUpdateLeft, eMatchUpdate::PLAYER_REMOVED);
|
||||
}
|
||||
|
||||
delete lobby->players[i];
|
||||
@@ -242,7 +242,7 @@ void ScriptedActivityComponent::Update(float deltaTime) {
|
||||
continue;
|
||||
|
||||
std::string matchTimerUpdate = "time=3:" + std::to_string(lobby->timer);
|
||||
GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchTimerUpdate, eMatchUpdate::MATCH_UPDATE_TIME);
|
||||
GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchTimerUpdate, eMatchUpdate::PHASE_WAIT_READY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ void ScriptedActivityComponent::Update(float deltaTime) {
|
||||
if (entity == nullptr)
|
||||
continue;
|
||||
|
||||
GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchTimerUpdate, eMatchUpdate::MATCH_UPDATE_TIME_START_DELAY);
|
||||
GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchTimerUpdate, eMatchUpdate::PHASE_WAIT_START);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,8 +375,8 @@ void ScriptedActivityComponent::PlayerReady(Entity* player, bool bReady) {
|
||||
|
||||
// Update players in lobby on player being ready
|
||||
std::string matchReadyUpdate = "player=9:" + std::to_string(player->GetObjectID());
|
||||
eMatchUpdate readyStatus = eMatchUpdate::MATCH_UPDATE_PLAYER_READY;
|
||||
if (!bReady) readyStatus = eMatchUpdate::MATCH_UPDATE_PLAYER_UNREADY;
|
||||
eMatchUpdate readyStatus = eMatchUpdate::PLAYER_READY;
|
||||
if (!bReady) readyStatus = eMatchUpdate::PLAYER_NOT_READY;
|
||||
for (LobbyPlayer* otherPlayer : lobby->players) {
|
||||
auto* entity = otherPlayer->GetEntity();
|
||||
if (entity == nullptr)
|
||||
@@ -516,7 +516,7 @@ void ActivityInstance::StartZone() {
|
||||
// only make a team if we have more than one participant
|
||||
if (participants.size() > 1) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_CREATE_TEAM);
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::CREATE_TEAM);
|
||||
|
||||
bitStream.Write(leader->GetObjectID());
|
||||
bitStream.Write(m_Participants.size());
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
#include "ScriptComponent.h"
|
||||
#include "BuffComponent.h"
|
||||
#include "EchoStartSkill.h"
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "DoClientProjectileImpact.h"
|
||||
#include "CDClientManager.h"
|
||||
|
||||
#include "CDSkillBehaviorTable.h"
|
||||
#include "eConnectionType.h"
|
||||
#include "eClientMessageType.h"
|
||||
|
||||
ProjectileSyncEntry::ProjectileSyncEntry() {
|
||||
}
|
||||
@@ -134,6 +134,10 @@ void SkillComponent::Update(const float deltaTime) {
|
||||
CalculateUpdate(deltaTime);
|
||||
}
|
||||
|
||||
if (m_Parent->IsPlayer()) {
|
||||
for (const auto& pair : this->m_managedBehaviors) pair.second->UpdatePlayerSyncs(deltaTime);
|
||||
}
|
||||
|
||||
std::map<uint32_t, BehaviorContext*> keep{};
|
||||
|
||||
for (const auto& pair : this->m_managedBehaviors) {
|
||||
@@ -192,7 +196,15 @@ void SkillComponent::Interrupt() {
|
||||
auto* combat = m_Parent->GetComponent<BaseCombatAIComponent>();
|
||||
if (combat != nullptr && combat->GetStunImmune()) return;
|
||||
|
||||
for (const auto& behavior : this->m_managedBehaviors) behavior.second->Interrupt();
|
||||
for (const auto& behavior : this->m_managedBehaviors) {
|
||||
for (const auto& behaviorEndEntry : behavior.second->endEntries) {
|
||||
behaviorEndEntry.behavior->End(behavior.second, behaviorEndEntry.branchContext, behaviorEndEntry.second);
|
||||
}
|
||||
behavior.second->endEntries.clear();
|
||||
if (m_Parent->IsPlayer()) continue;
|
||||
behavior.second->Interrupt();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SkillComponent::RegisterCalculatedProjectile(const LWOOBJID projectileId, BehaviorContext* context, const BehaviorBranchContext& branch, const LOT lot, const float maxTime,
|
||||
@@ -215,7 +227,7 @@ void SkillComponent::RegisterCalculatedProjectile(const LWOOBJID projectileId, B
|
||||
this->m_managedProjectiles.push_back(entry);
|
||||
}
|
||||
|
||||
bool SkillComponent::CastSkill(const uint32_t skillId, LWOOBJID target, const LWOOBJID optionalOriginatorID){
|
||||
bool SkillComponent::CastSkill(const uint32_t skillId, LWOOBJID target, const LWOOBJID optionalOriginatorID) {
|
||||
uint32_t behaviorId = -1;
|
||||
// try to find it via the cache
|
||||
const auto& pair = m_skillBehaviorCache.find(skillId);
|
||||
@@ -248,6 +260,8 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c
|
||||
|
||||
context->caster = m_Parent->GetObjectID();
|
||||
|
||||
context->skillID = skillId;
|
||||
|
||||
context->clientInitalized = clientInitalized;
|
||||
|
||||
context->foundTarget = target != LWOOBJID_EMPTY || ignoreTarget || clientInitalized;
|
||||
@@ -290,7 +304,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c
|
||||
// Write message
|
||||
RakNet::BitStream message;
|
||||
|
||||
PacketUtils::WriteHeader(message, CLIENT, MSG_CLIENT_GAME_MSG);
|
||||
PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
message.Write(this->m_Parent->GetObjectID());
|
||||
start.Serialize(&message);
|
||||
|
||||
@@ -423,7 +437,7 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry)
|
||||
|
||||
RakNet::BitStream message;
|
||||
|
||||
PacketUtils::WriteHeader(message, CLIENT, MSG_CLIENT_GAME_MSG);
|
||||
PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
message.Write(this->m_Parent->GetObjectID());
|
||||
projectileImpact.Serialize(&message);
|
||||
|
||||
@@ -463,7 +477,7 @@ void SkillComponent::HandleUnCast(const uint32_t behaviorId, const LWOOBJID targ
|
||||
delete context;
|
||||
}
|
||||
|
||||
SkillComponent::SkillComponent(Entity* parent) : Component(parent) {
|
||||
SkillComponent::SkillComponent(Entity* parent): Component(parent) {
|
||||
this->m_skillUid = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ bool SwitchComponent::GetActive() const {
|
||||
void SwitchComponent::EntityEnter(Entity* entity) {
|
||||
if (!m_Active) {
|
||||
if (m_Rebuild) {
|
||||
if (m_Rebuild->GetState() != eRebuildState::REBUILD_COMPLETED) return;
|
||||
if (m_Rebuild->GetState() != eRebuildState::COMPLETED) return;
|
||||
}
|
||||
m_Active = true;
|
||||
if (!m_Parent) return;
|
||||
|
||||
@@ -83,8 +83,12 @@ void TriggerComponent::HandleTriggerCommand(LUTriggers::Command* command, Entity
|
||||
case eTriggerCommandType::REPEL_OBJECT:
|
||||
HandleRepelObject(targetEntity, command->args);
|
||||
break;
|
||||
case eTriggerCommandType::SET_TIMER: break;
|
||||
case eTriggerCommandType::CANCEL_TIMER: break;
|
||||
case eTriggerCommandType::SET_TIMER:
|
||||
HandleSetTimer(targetEntity, argArray);
|
||||
break;
|
||||
case eTriggerCommandType::CANCEL_TIMER:
|
||||
HandleCancelTimer(targetEntity, command->args);
|
||||
break;
|
||||
case eTriggerCommandType::PLAY_CINEMATIC:
|
||||
HandlePlayCinematic(targetEntity, argArray);
|
||||
break;
|
||||
@@ -194,7 +198,7 @@ void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string arg
|
||||
void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args){
|
||||
auto* triggerComponent = targetEntity->GetComponent<TriggerComponent>();
|
||||
if (!triggerComponent) {
|
||||
Game::logger->Log("TriggerComponent::HandleToggleTrigger", "Trigger component not found!");
|
||||
Game::logger->LogDebug("TriggerComponent::HandleToggleTrigger", "Trigger component not found!");
|
||||
return;
|
||||
}
|
||||
triggerComponent->SetTriggerEnabled(args == "1");
|
||||
@@ -203,7 +207,7 @@ void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string arg
|
||||
void TriggerComponent::HandleResetRebuild(Entity* targetEntity, std::string args){
|
||||
auto* rebuildComponent = targetEntity->GetComponent<RebuildComponent>();
|
||||
if (!rebuildComponent) {
|
||||
Game::logger->Log("TriggerComponent::HandleResetRebuild", "Rebuild component not found!");
|
||||
Game::logger->LogDebug("TriggerComponent::HandleResetRebuild", "Rebuild component not found!");
|
||||
return;
|
||||
}
|
||||
rebuildComponent->ResetRebuild(args == "1");
|
||||
@@ -231,9 +235,11 @@ void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector<std:
|
||||
}
|
||||
|
||||
void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::string> argArray){
|
||||
if (argArray.size() < 3) return;
|
||||
|
||||
auto* phantomPhysicsComponent = m_Parent->GetComponent<PhantomPhysicsComponent>();
|
||||
if (!phantomPhysicsComponent) {
|
||||
Game::logger->Log("TriggerComponent::HandlePushObject", "Phantom Physics component not found!");
|
||||
Game::logger->LogDebug("TriggerComponent::HandlePushObject", "Phantom Physics component not found!");
|
||||
return;
|
||||
}
|
||||
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
||||
@@ -250,7 +256,7 @@ void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::s
|
||||
void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args){
|
||||
auto* phantomPhysicsComponent = m_Parent->GetComponent<PhantomPhysicsComponent>();
|
||||
if (!phantomPhysicsComponent) {
|
||||
Game::logger->Log("TriggerComponent::HandleRepelObject", "Phantom Physics component not found!");
|
||||
Game::logger->LogDebug("TriggerComponent::HandleRepelObject", "Phantom Physics component not found!");
|
||||
return;
|
||||
}
|
||||
float forceMultiplier;
|
||||
@@ -271,6 +277,20 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args)
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector<std::string> argArray){
|
||||
if (argArray.size() != 2) {
|
||||
Game::logger->LogDebug("TriggerComponent::HandleSetTimer", "Not ehought variables!");
|
||||
return;
|
||||
}
|
||||
float time = 0.0;
|
||||
GeneralUtils::TryParse<float>(argArray.at(1), time);
|
||||
m_Parent->AddTimer(argArray.at(0), time);
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleCancelTimer(Entity* targetEntity, std::string args){
|
||||
m_Parent->CancelTimer(args);
|
||||
}
|
||||
|
||||
void TriggerComponent::HandlePlayCinematic(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||
float leadIn = -1.0;
|
||||
auto wait = eEndBehavior::RETURN;
|
||||
@@ -300,7 +320,7 @@ void TriggerComponent::HandlePlayCinematic(Entity* targetEntity, std::vector<std
|
||||
void TriggerComponent::HandleToggleBBB(Entity* targetEntity, std::string args) {
|
||||
auto* character = targetEntity->GetCharacter();
|
||||
if (!character) {
|
||||
Game::logger->Log("TriggerComponent::HandleToggleBBB", "Character was not found!");
|
||||
Game::logger->LogDebug("TriggerComponent::HandleToggleBBB", "Character was not found!");
|
||||
return;
|
||||
}
|
||||
bool buildMode = !(character->GetBuildMode());
|
||||
@@ -316,7 +336,7 @@ void TriggerComponent::HandleUpdateMission(Entity* targetEntity, std::vector<std
|
||||
if (argArray.at(0) != "exploretask") return;
|
||||
MissionComponent* missionComponent = targetEntity->GetComponent<MissionComponent>();
|
||||
if (!missionComponent){
|
||||
Game::logger->Log("TriggerComponent::HandleUpdateMission", "Mission component not found!");
|
||||
Game::logger->LogDebug("TriggerComponent::HandleUpdateMission", "Mission component not found!");
|
||||
return;
|
||||
}
|
||||
missionComponent->Progress(eMissionTaskType::EXPLORE, 0, 0, argArray.at(4));
|
||||
@@ -335,7 +355,7 @@ void TriggerComponent::HandlePlayEffect(Entity* targetEntity, std::vector<std::s
|
||||
void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args){
|
||||
auto* skillComponent = targetEntity->GetComponent<SkillComponent>();
|
||||
if (!skillComponent) {
|
||||
Game::logger->Log("TriggerComponent::HandleCastSkill", "Skill component not found!");
|
||||
Game::logger->LogDebug("TriggerComponent::HandleCastSkill", "Skill component not found!");
|
||||
return;
|
||||
}
|
||||
uint32_t skillId;
|
||||
@@ -346,7 +366,7 @@ void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args){
|
||||
void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||
auto* phantomPhysicsComponent = targetEntity->GetComponent<PhantomPhysicsComponent>();
|
||||
if (!phantomPhysicsComponent) {
|
||||
Game::logger->Log("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!");
|
||||
Game::logger->LogDebug("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!");
|
||||
return;
|
||||
}
|
||||
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
||||
@@ -381,7 +401,7 @@ void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::v
|
||||
void TriggerComponent::HandleSetPhysicsVolumeStatus(Entity* targetEntity, std::string args) {
|
||||
auto* phantomPhysicsComponent = targetEntity->GetComponent<PhantomPhysicsComponent>();
|
||||
if (!phantomPhysicsComponent) {
|
||||
Game::logger->Log("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!");
|
||||
Game::logger->LogDebug("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!");
|
||||
return;
|
||||
}
|
||||
phantomPhysicsComponent->SetPhysicsEffectActive(args == "On");
|
||||
|
||||
@@ -30,6 +30,8 @@ private:
|
||||
void HandleRotateObject(Entity* targetEntity, std::vector<std::string> argArray);
|
||||
void HandlePushObject(Entity* targetEntity, std::vector<std::string> argArray);
|
||||
void HandleRepelObject(Entity* targetEntity, std::string args);
|
||||
void HandleSetTimer(Entity* targetEntity, std::vector<std::string> argArray);
|
||||
void HandleCancelTimer(Entity* targetEntity, std::string args);
|
||||
void HandlePlayCinematic(Entity* targetEntity, std::vector<std::string> argArray);
|
||||
void HandleToggleBBB(Entity* targetEntity, std::string args);
|
||||
void HandleUpdateMission(Entity* targetEntity, std::vector<std::string> argArray);
|
||||
|
||||
@@ -11,6 +11,7 @@ VehiclePhysicsComponent::VehiclePhysicsComponent(Entity* parent) : Component(par
|
||||
m_DirtyPosition = true;
|
||||
m_DirtyVelocity = true;
|
||||
m_DirtyAngularVelocity = true;
|
||||
m_EndBehavior = GeneralUtils::GenerateRandomNumber<uint32_t>(0, 7);
|
||||
}
|
||||
|
||||
VehiclePhysicsComponent::~VehiclePhysicsComponent() {
|
||||
@@ -93,7 +94,7 @@ void VehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
|
||||
}
|
||||
|
||||
if (bIsInitialUpdate) {
|
||||
outBitStream->Write<uint8_t>(5);
|
||||
outBitStream->Write<uint8_t>(m_EndBehavior);
|
||||
outBitStream->Write1();
|
||||
}
|
||||
|
||||
|
||||
@@ -109,4 +109,5 @@ private:
|
||||
bool m_IsOnRail;
|
||||
|
||||
float m_SoftUpdate = 0;
|
||||
uint32_t m_EndBehavior;
|
||||
};
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
#ifndef __DOCLIENTPROJECTILEIMPACT__H__
|
||||
#define __DOCLIENTPROJECTILEIMPACT__H__
|
||||
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "dCommonVars.h"
|
||||
|
||||
/* Tell a client local projectile to impact */
|
||||
class DoClientProjectileImpact {
|
||||
static const GAME_MSG MsgID = GAME_MSG_DO_CLIENT_PROJECTILE_IMPACT;
|
||||
|
||||
public:
|
||||
DoClientProjectileImpact() {
|
||||
i64OrgID = LWOOBJID_EMPTY;
|
||||
@@ -30,7 +27,7 @@ public:
|
||||
}
|
||||
|
||||
void Serialize(RakNet::BitStream* stream) {
|
||||
stream->Write(MsgID);
|
||||
stream->Write(eGameMessageType::DO_CLIENT_PROJECTILE_IMPACT);
|
||||
|
||||
stream->Write(i64OrgID != LWOOBJID_EMPTY);
|
||||
if (i64OrgID != LWOOBJID_EMPTY) stream->Write(i64OrgID);
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
#define __ECHOSTARTSKILL__H__
|
||||
|
||||
#include "dCommonVars.h"
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "NiPoint3.h"
|
||||
#include "NiQuaternion.h"
|
||||
#include "eGameMessageType.h"
|
||||
|
||||
/* Same as start skill but with different network options. An echo down to other clients that need to play the skill. */
|
||||
class EchoStartSkill {
|
||||
static const GAME_MSG MsgID = GAME_MSG_ECHO_START_SKILL;
|
||||
|
||||
public:
|
||||
EchoStartSkill() {
|
||||
bUsedMouse = false;
|
||||
@@ -42,7 +40,7 @@ public:
|
||||
}
|
||||
|
||||
void Serialize(RakNet::BitStream* stream) {
|
||||
stream->Write(MsgID);
|
||||
stream->Write(eGameMessageType::ECHO_START_SKILL);
|
||||
|
||||
stream->Write(bUsedMouse);
|
||||
|
||||
|
||||
@@ -4,13 +4,11 @@
|
||||
#include <string>
|
||||
|
||||
#include "BitStream.h"
|
||||
#include "eGameMessageType.h"
|
||||
|
||||
#include "dMessageIdentifiers.h"
|
||||
|
||||
/* Message to synchronize a skill cast */
|
||||
class EchoSyncSkill {
|
||||
static const GAME_MSG MsgID = GAME_MSG_ECHO_SYNC_SKILL;
|
||||
|
||||
public:
|
||||
EchoSyncSkill() {
|
||||
bDone = false;
|
||||
@@ -31,7 +29,7 @@ public:
|
||||
}
|
||||
|
||||
void Serialize(RakNet::BitStream* stream) {
|
||||
stream->Write(MsgID);
|
||||
stream->Write(eGameMessageType::ECHO_SYNC_SKILL);
|
||||
|
||||
stream->Write(bDone);
|
||||
uint32_t sBitStreamLength = sBitStream.length();
|
||||
|
||||
@@ -33,10 +33,11 @@
|
||||
#include "EchoSyncSkill.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "eConnectionType.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, GAME_MSG messageID) {
|
||||
void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, eGameMessageType messageID) {
|
||||
|
||||
CBITSTREAM;
|
||||
|
||||
@@ -53,54 +54,54 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
|
||||
switch (messageID) {
|
||||
|
||||
case GAME_MSG_UN_USE_BBB_MODEL: {
|
||||
case eGameMessageType::UN_USE_BBB_MODEL: {
|
||||
GameMessages::HandleUnUseModel(inStream, entity, sysAddr);
|
||||
break;
|
||||
}
|
||||
case GAME_MSG_PLAY_EMOTE: {
|
||||
case eGameMessageType::PLAY_EMOTE: {
|
||||
GameMessages::HandlePlayEmote(inStream, entity);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_MOVE_ITEM_IN_INVENTORY: {
|
||||
case eGameMessageType::MOVE_ITEM_IN_INVENTORY: {
|
||||
GameMessages::HandleMoveItemInInventory(inStream, entity);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_REMOVE_ITEM_FROM_INVENTORY: {
|
||||
case eGameMessageType::REMOVE_ITEM_FROM_INVENTORY: {
|
||||
GameMessages::HandleRemoveItemFromInventory(inStream, entity, sysAddr);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_EQUIP_ITEM:
|
||||
case eGameMessageType::EQUIP_ITEM:
|
||||
GameMessages::HandleEquipItem(inStream, entity);
|
||||
break;
|
||||
|
||||
case GAME_MSG_UN_EQUIP_ITEM:
|
||||
case eGameMessageType::UN_EQUIP_ITEM:
|
||||
GameMessages::HandleUnequipItem(inStream, entity);
|
||||
break;
|
||||
|
||||
case GAME_MSG_RESPOND_TO_MISSION: {
|
||||
case eGameMessageType::RESPOND_TO_MISSION: {
|
||||
GameMessages::HandleRespondToMission(inStream, entity);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_REQUEST_USE: {
|
||||
case eGameMessageType::REQUEST_USE: {
|
||||
GameMessages::HandleRequestUse(inStream, entity, sysAddr);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_SET_FLAG: {
|
||||
case eGameMessageType::SET_FLAG: {
|
||||
GameMessages::HandleSetFlag(inStream, entity);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_HAS_BEEN_COLLECTED: {
|
||||
case eGameMessageType::HAS_BEEN_COLLECTED: {
|
||||
GameMessages::HandleHasBeenCollected(inStream, entity);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_PLAYER_LOADED: {
|
||||
case eGameMessageType::PLAYER_LOADED: {
|
||||
GameMessages::SendRestoreToPostLoadStats(entity, sysAddr);
|
||||
entity->SetPlayerReadyForUpdates();
|
||||
|
||||
@@ -174,73 +175,73 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_REQUEST_LINKED_MISSION: {
|
||||
case eGameMessageType::REQUEST_LINKED_MISSION: {
|
||||
GameMessages::HandleRequestLinkedMission(inStream, entity);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_MISSION_DIALOGUE_OK: {
|
||||
case eGameMessageType::MISSION_DIALOGUE_OK: {
|
||||
GameMessages::HandleMissionDialogOK(inStream, entity);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_MISSION_DIALOGUE_CANCELLED: {
|
||||
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 :)
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_REQUEST_PLATFORM_RESYNC: {
|
||||
case eGameMessageType::REQUEST_PLATFORM_RESYNC: {
|
||||
GameMessages::HandleRequestPlatformResync(inStream, entity, sysAddr);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_FIRE_EVENT_SERVER_SIDE: {
|
||||
case eGameMessageType::FIRE_EVENT_SERVER_SIDE: {
|
||||
GameMessages::HandleFireEventServerSide(inStream, entity, sysAddr);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_SEND_ACTIVITY_SUMMARY_LEADERBOARD_DATA: {
|
||||
case eGameMessageType::SEND_ACTIVITY_SUMMARY_LEADERBOARD_DATA: {
|
||||
GameMessages::HandleActivitySummaryLeaderboardData(inStream, entity, sysAddr);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_REQUEST_ACTIVITY_SUMMARY_LEADERBOARD_DATA: {
|
||||
case eGameMessageType::REQUEST_ACTIVITY_SUMMARY_LEADERBOARD_DATA: {
|
||||
GameMessages::HandleRequestActivitySummaryLeaderboardData(inStream, entity, sysAddr);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_ACTIVITY_STATE_CHANGE_REQUEST: {
|
||||
case eGameMessageType::ACTIVITY_STATE_CHANGE_REQUEST: {
|
||||
GameMessages::HandleActivityStateChangeRequest(inStream, entity);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_PARSE_CHAT_MESSAGE: {
|
||||
case eGameMessageType::PARSE_CHAT_MESSAGE: {
|
||||
GameMessages::HandleParseChatMessage(inStream, entity, sysAddr);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_NOTIFY_SERVER_LEVEL_PROCESSING_COMPLETE: {
|
||||
case eGameMessageType::NOTIFY_SERVER_LEVEL_PROCESSING_COMPLETE: {
|
||||
GameMessages::HandleNotifyServerLevelProcessingComplete(inStream, entity);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_PICKUP_CURRENCY: {
|
||||
case eGameMessageType::PICKUP_CURRENCY: {
|
||||
GameMessages::HandlePickupCurrency(inStream, entity);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_PICKUP_ITEM: {
|
||||
case eGameMessageType::PICKUP_ITEM: {
|
||||
GameMessages::HandlePickupItem(inStream, entity);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_RESURRECT: {
|
||||
case eGameMessageType::RESURRECT: {
|
||||
GameMessages::HandleResurrect(inStream, entity);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_REQUEST_RESURRECT: {
|
||||
case eGameMessageType::REQUEST_RESURRECT: {
|
||||
GameMessages::SendResurrect(entity);
|
||||
/*auto* dest = static_cast<DestroyableComponent*>(entity->GetComponent(eReplicaComponentType::DESTROYABLE));
|
||||
if (dest) {
|
||||
@@ -251,12 +252,12 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
}*/
|
||||
break;
|
||||
}
|
||||
case GAME_MSG_HANDLE_HOT_PROPERTY_DATA: {
|
||||
case eGameMessageType::HANDLE_HOT_PROPERTY_DATA: {
|
||||
GameMessages::HandleGetHotPropertyData(inStream, entity, sysAddr);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_REQUEST_SERVER_PROJECTILE_IMPACT:
|
||||
case eGameMessageType::REQUEST_SERVER_PROJECTILE_IMPACT:
|
||||
{
|
||||
auto message = RequestServerProjectileImpact();
|
||||
|
||||
@@ -275,7 +276,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_MSG_START_SKILL: {
|
||||
case eGameMessageType::START_SKILL: {
|
||||
StartSkill startSkill = StartSkill();
|
||||
startSkill.Deserialize(inStream); // inStream replaces &bitStream
|
||||
|
||||
@@ -313,7 +314,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
if (success) {
|
||||
//Broadcast our startSkill:
|
||||
RakNet::BitStream bitStreamLocal;
|
||||
PacketUtils::WriteHeader(bitStreamLocal, CLIENT, MSG_CLIENT_GAME_MSG);
|
||||
PacketUtils::WriteHeader(bitStreamLocal, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
bitStreamLocal.Write(entity->GetObjectID());
|
||||
|
||||
EchoStartSkill echoStartSkill;
|
||||
@@ -333,11 +334,11 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
}
|
||||
} break;
|
||||
|
||||
case GAME_MSG_SYNC_SKILL: {
|
||||
case eGameMessageType::SYNC_SKILL: {
|
||||
RakNet::BitStream bitStreamLocal;
|
||||
PacketUtils::WriteHeader(bitStreamLocal, CLIENT, MSG_CLIENT_GAME_MSG);
|
||||
PacketUtils::WriteHeader(bitStreamLocal, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
bitStreamLocal.Write(entity->GetObjectID());
|
||||
//bitStreamLocal.Write((unsigned short)GAME_MSG_ECHO_SYNC_SKILL);
|
||||
//bitStreamLocal.Write((unsigned short)eGameMessageType::ECHO_SYNC_SKILL);
|
||||
//bitStreamLocal.Write(inStream);
|
||||
|
||||
SyncSkill sync = SyncSkill(inStream); // inStream replaced &bitStream
|
||||
@@ -374,308 +375,311 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
Game::server->Send(&bitStreamLocal, sysAddr, true);
|
||||
} break;
|
||||
|
||||
case GAME_MSG_REQUEST_SMASH_PLAYER:
|
||||
case eGameMessageType::REQUEST_SMASH_PLAYER:
|
||||
entity->Smash(entity->GetObjectID());
|
||||
break;
|
||||
|
||||
case GAME_MSG_MOVE_ITEM_BETWEEN_INVENTORY_TYPES:
|
||||
case eGameMessageType::MOVE_ITEM_BETWEEN_INVENTORY_TYPES:
|
||||
GameMessages::HandleMoveItemBetweenInventoryTypes(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_MODULAR_BUILD_FINISH:
|
||||
case eGameMessageType::MODULAR_BUILD_FINISH:
|
||||
GameMessages::HandleModularBuildFinish(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_PUSH_EQUIPPED_ITEMS_STATE:
|
||||
case eGameMessageType::PUSH_EQUIPPED_ITEMS_STATE:
|
||||
GameMessages::HandlePushEquippedItemsState(inStream, entity);
|
||||
break;
|
||||
|
||||
case GAME_MSG_POP_EQUIPPED_ITEMS_STATE:
|
||||
case eGameMessageType::POP_EQUIPPED_ITEMS_STATE:
|
||||
GameMessages::HandlePopEquippedItemsState(inStream, entity);
|
||||
break;
|
||||
|
||||
case GAME_MSG_BUY_FROM_VENDOR:
|
||||
case eGameMessageType::BUY_FROM_VENDOR:
|
||||
GameMessages::HandleBuyFromVendor(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_SELL_TO_VENDOR:
|
||||
case eGameMessageType::SELL_TO_VENDOR:
|
||||
GameMessages::HandleSellToVendor(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_BUYBACK_FROM_VENDOR:
|
||||
case eGameMessageType::BUYBACK_FROM_VENDOR:
|
||||
GameMessages::HandleBuybackFromVendor(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_MODULAR_BUILD_MOVE_AND_EQUIP:
|
||||
case eGameMessageType::MODULAR_BUILD_MOVE_AND_EQUIP:
|
||||
GameMessages::HandleModularBuildMoveAndEquip(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_DONE_ARRANGING_WITH_ITEM:
|
||||
case eGameMessageType::DONE_ARRANGING_WITH_ITEM:
|
||||
GameMessages::HandleDoneArrangingWithItem(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_MODULAR_BUILD_CONVERT_MODEL:
|
||||
case eGameMessageType::MODULAR_BUILD_CONVERT_MODEL:
|
||||
GameMessages::HandleModularBuildConvertModel(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_BUILD_MODE_SET:
|
||||
case eGameMessageType::BUILD_MODE_SET:
|
||||
GameMessages::HandleBuildModeSet(inStream, entity);
|
||||
break;
|
||||
|
||||
case GAME_MSG_REBUILD_CANCEL:
|
||||
case eGameMessageType::REBUILD_CANCEL:
|
||||
GameMessages::HandleRebuildCancel(inStream, entity);
|
||||
break;
|
||||
|
||||
case GAME_MSG_MATCH_REQUEST:
|
||||
case eGameMessageType::MATCH_REQUEST:
|
||||
GameMessages::HandleMatchRequest(inStream, entity);
|
||||
break;
|
||||
|
||||
case GAME_MSG_USE_NON_EQUIPMENT_ITEM:
|
||||
case eGameMessageType::USE_NON_EQUIPMENT_ITEM:
|
||||
GameMessages::HandleUseNonEquipmentItem(inStream, entity);
|
||||
break;
|
||||
|
||||
case GAME_MSG_CLIENT_ITEM_CONSUMED:
|
||||
case eGameMessageType::CLIENT_ITEM_CONSUMED:
|
||||
GameMessages::HandleClientItemConsumed(inStream, entity);
|
||||
break;
|
||||
|
||||
case GAME_MSG_SET_CONSUMABLE_ITEM:
|
||||
case eGameMessageType::SET_CONSUMABLE_ITEM:
|
||||
GameMessages::HandleSetConsumableItem(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_VERIFY_ACK:
|
||||
case eGameMessageType::VERIFY_ACK:
|
||||
GameMessages::HandleVerifyAck(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
// Trading
|
||||
case GAME_MSG_CLIENT_TRADE_REQUEST:
|
||||
case eGameMessageType::CLIENT_TRADE_REQUEST:
|
||||
GameMessages::HandleClientTradeRequest(inStream, entity, sysAddr);
|
||||
break;
|
||||
case GAME_MSG_CLIENT_TRADE_CANCEL:
|
||||
case eGameMessageType::CLIENT_TRADE_CANCEL:
|
||||
GameMessages::HandleClientTradeCancel(inStream, entity, sysAddr);
|
||||
break;
|
||||
case GAME_MSG_CLIENT_TRADE_ACCEPT:
|
||||
case eGameMessageType::CLIENT_TRADE_ACCEPT:
|
||||
GameMessages::HandleClientTradeAccept(inStream, entity, sysAddr);
|
||||
break;
|
||||
case GAME_MSG_CLIENT_TRADE_UPDATE:
|
||||
case eGameMessageType::CLIENT_TRADE_UPDATE:
|
||||
GameMessages::HandleClientTradeUpdate(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
// Pets
|
||||
case GAME_MSG_PET_TAMING_TRY_BUILD:
|
||||
case eGameMessageType::PET_TAMING_TRY_BUILD:
|
||||
GameMessages::HandlePetTamingTryBuild(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_NOTIFY_TAMING_BUILD_SUCCESS:
|
||||
case eGameMessageType::NOTIFY_TAMING_BUILD_SUCCESS:
|
||||
GameMessages::HandleNotifyTamingBuildSuccess(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_REQUEST_SET_PET_NAME:
|
||||
case eGameMessageType::REQUEST_SET_PET_NAME:
|
||||
GameMessages::HandleRequestSetPetName(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_START_SERVER_PET_MINIGAME_TIMER:
|
||||
case eGameMessageType::START_SERVER_PET_MINIGAME_TIMER:
|
||||
GameMessages::HandleStartServerPetMinigameTimer(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_CLIENT_EXIT_TAMING_MINIGAME:
|
||||
case eGameMessageType::CLIENT_EXIT_TAMING_MINIGAME:
|
||||
GameMessages::HandleClientExitTamingMinigame(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_COMMAND_PET:
|
||||
case eGameMessageType::COMMAND_PET:
|
||||
GameMessages::HandleCommandPet(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_DESPAWN_PET:
|
||||
case eGameMessageType::DESPAWN_PET:
|
||||
GameMessages::HandleDespawnPet(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_MESSAGE_BOX_RESPOND:
|
||||
case eGameMessageType::MESSAGE_BOX_RESPOND:
|
||||
GameMessages::HandleMessageBoxResponse(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_CHOICE_BOX_RESPOND:
|
||||
case eGameMessageType::CHOICE_BOX_RESPOND:
|
||||
GameMessages::HandleChoiceBoxRespond(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
// Property
|
||||
case GAME_MSG_QUERY_PROPERTY_DATA:
|
||||
case eGameMessageType::QUERY_PROPERTY_DATA:
|
||||
GameMessages::HandleQueryPropertyData(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_START_BUILDING_WITH_ITEM:
|
||||
case eGameMessageType::START_BUILDING_WITH_ITEM:
|
||||
GameMessages::HandleStartBuildingWithItem(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_SET_BUILD_MODE:
|
||||
case eGameMessageType::SET_BUILD_MODE:
|
||||
GameMessages::HandleSetBuildMode(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_PROPERTY_EDITOR_BEGIN:
|
||||
case eGameMessageType::PROPERTY_EDITOR_BEGIN:
|
||||
GameMessages::HandlePropertyEditorBegin(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_PROPERTY_EDITOR_END:
|
||||
case eGameMessageType::PROPERTY_EDITOR_END:
|
||||
GameMessages::HandlePropertyEditorEnd(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_PROPERTY_CONTENTS_FROM_CLIENT:
|
||||
case eGameMessageType::PROPERTY_CONTENTS_FROM_CLIENT:
|
||||
GameMessages::HandlePropertyContentsFromClient(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_ZONE_PROPERTY_MODEL_EQUIPPED:
|
||||
case eGameMessageType::ZONE_PROPERTY_MODEL_EQUIPPED:
|
||||
GameMessages::HandlePropertyModelEquipped(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_PLACE_PROPERTY_MODEL:
|
||||
case eGameMessageType::PLACE_PROPERTY_MODEL:
|
||||
GameMessages::HandlePlacePropertyModel(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_UPDATE_MODEL_FROM_CLIENT:
|
||||
case eGameMessageType::UPDATE_MODEL_FROM_CLIENT:
|
||||
GameMessages::HandleUpdatePropertyModel(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_DELETE_MODEL_FROM_CLIENT:
|
||||
case eGameMessageType::DELETE_MODEL_FROM_CLIENT:
|
||||
GameMessages::HandleDeletePropertyModel(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_BBB_LOAD_ITEM_REQUEST:
|
||||
case eGameMessageType::BBB_LOAD_ITEM_REQUEST:
|
||||
GameMessages::HandleBBBLoadItemRequest(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_BBB_SAVE_REQUEST:
|
||||
case eGameMessageType::BBB_SAVE_REQUEST:
|
||||
GameMessages::HandleBBBSaveRequest(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_CONTROL_BEHAVIOR:
|
||||
case eGameMessageType::CONTROL_BEHAVIOR:
|
||||
GameMessages::HandleControlBehaviors(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_PROPERTY_ENTRANCE_SYNC:
|
||||
case eGameMessageType::PROPERTY_ENTRANCE_SYNC:
|
||||
GameMessages::HandlePropertyEntranceSync(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_ENTER_PROPERTY1:
|
||||
case eGameMessageType::ENTER_PROPERTY1:
|
||||
GameMessages::HandleEnterProperty(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_ZONE_PROPERTY_MODEL_ROTATED:
|
||||
case eGameMessageType::ZONE_PROPERTY_MODEL_ROTATED:
|
||||
EntityManager::Instance()->GetZoneControlEntity()->OnZonePropertyModelRotated(usr->GetLastUsedChar()->GetEntity());
|
||||
break;
|
||||
|
||||
case GAME_MSG_UPDATE_PROPERTY_OR_MODEL_FOR_FILTER_CHECK:
|
||||
case eGameMessageType::UPDATE_PROPERTY_OR_MODEL_FOR_FILTER_CHECK:
|
||||
GameMessages::HandleUpdatePropertyOrModelForFilterCheck(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_SET_PROPERTY_ACCESS:
|
||||
case eGameMessageType::SET_PROPERTY_ACCESS:
|
||||
GameMessages::HandleSetPropertyAccess(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
// Racing
|
||||
case GAME_MSG_MODULE_ASSEMBLY_QUERY_DATA:
|
||||
case eGameMessageType::MODULE_ASSEMBLY_QUERY_DATA:
|
||||
GameMessages::HandleModuleAssemblyQueryData(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_ACKNOWLEDGE_POSSESSION:
|
||||
case eGameMessageType::ACKNOWLEDGE_POSSESSION:
|
||||
GameMessages::HandleAcknowledgePossession(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_VEHICLE_SET_WHEEL_LOCK_STATE:
|
||||
case eGameMessageType::VEHICLE_SET_WHEEL_LOCK_STATE:
|
||||
GameMessages::HandleVehicleSetWheelLockState(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_MODULAR_ASSEMBLY_NIF_COMPLETED:
|
||||
case eGameMessageType::MODULAR_ASSEMBLY_NIF_COMPLETED:
|
||||
GameMessages::HandleModularAssemblyNIFCompleted(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_RACING_CLIENT_READY:
|
||||
case eGameMessageType::RACING_CLIENT_READY:
|
||||
GameMessages::HandleRacingClientReady(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_REQUEST_DIE:
|
||||
case eGameMessageType::REQUEST_DIE:
|
||||
GameMessages::HandleRequestDie(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_VEHICLE_NOTIFY_SERVER_ADD_PASSIVE_BOOST_ACTION:
|
||||
case eGameMessageType::VEHICLE_NOTIFY_SERVER_ADD_PASSIVE_BOOST_ACTION:
|
||||
GameMessages::HandleVehicleNotifyServerAddPassiveBoostAction(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_VEHICLE_NOTIFY_SERVER_REMOVE_PASSIVE_BOOST_ACTION:
|
||||
case eGameMessageType::VEHICLE_NOTIFY_SERVER_REMOVE_PASSIVE_BOOST_ACTION:
|
||||
GameMessages::HandleVehicleNotifyServerRemovePassiveBoostAction(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_RACING_PLAYER_INFO_RESET_FINISHED:
|
||||
case eGameMessageType::RACING_PLAYER_INFO_RESET_FINISHED:
|
||||
GameMessages::HandleRacingPlayerInfoResetFinished(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_VEHICLE_NOTIFY_HIT_IMAGINATION_SERVER:
|
||||
case eGameMessageType::VEHICLE_NOTIFY_HIT_IMAGINATION_SERVER:
|
||||
GameMessages::HandleVehicleNotifyHitImaginationServer(inStream, entity, sysAddr);
|
||||
break;
|
||||
case GAME_MSG_UPDATE_PROPERTY_PERFORMANCE_COST:
|
||||
case eGameMessageType::UPDATE_PROPERTY_PERFORMANCE_COST:
|
||||
GameMessages::HandleUpdatePropertyPerformanceCost(inStream, entity, sysAddr);
|
||||
break;
|
||||
// SG
|
||||
case GAME_MSG_UPDATE_SHOOTING_GALLERY_ROTATION:
|
||||
case eGameMessageType::UPDATE_SHOOTING_GALLERY_ROTATION:
|
||||
GameMessages::HandleUpdateShootingGalleryRotation(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
// NT
|
||||
case GAME_MSG_REQUEST_MOVE_ITEM_BETWEEN_INVENTORY_TYPES:
|
||||
case eGameMessageType::REQUEST_MOVE_ITEM_BETWEEN_INVENTORY_TYPES:
|
||||
GameMessages::HandleRequestMoveItemBetweenInventoryTypes(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_TOGGLE_GHOST_REFERENCE_OVERRIDE:
|
||||
case eGameMessageType::TOGGLE_GHOST_REFERENCE_OVERRIDE:
|
||||
GameMessages::HandleToggleGhostReferenceOverride(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_SET_GHOST_REFERENCE_POSITION:
|
||||
case eGameMessageType::SET_GHOST_REFERENCE_POSITION:
|
||||
GameMessages::HandleSetGhostReferencePosition(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_READY_FOR_UPDATES:
|
||||
case eGameMessageType::READY_FOR_UPDATES:
|
||||
//We don't really care about this message, as it's simply here to inform us that the client is done loading an object.
|
||||
//In the event we _do_ send an update to an object that hasn't finished loading, the client will handle it anyway.
|
||||
break;
|
||||
|
||||
case GAME_MSG_REPORT_BUG:
|
||||
case eGameMessageType::REPORT_BUG:
|
||||
GameMessages::HandleReportBug(inStream, entity);
|
||||
break;
|
||||
|
||||
case GAME_MSG_CLIENT_RAIL_MOVEMENT_READY:
|
||||
case eGameMessageType::CLIENT_RAIL_MOVEMENT_READY:
|
||||
GameMessages::HandleClientRailMovementReady(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_CANCEL_RAIL_MOVEMENT:
|
||||
case eGameMessageType::CANCEL_RAIL_MOVEMENT:
|
||||
GameMessages::HandleCancelRailMovement(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_PLAYER_RAIL_ARRIVED_NOTIFICATION:
|
||||
case eGameMessageType::PLAYER_RAIL_ARRIVED_NOTIFICATION:
|
||||
GameMessages::HandlePlayerRailArrivedNotification(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_CINEMATIC_UPDATE:
|
||||
case eGameMessageType::CINEMATIC_UPDATE:
|
||||
GameMessages::HandleCinematicUpdate(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_MODIFY_PLAYER_ZONE_STATISTIC:
|
||||
case eGameMessageType::MODIFY_PLAYER_ZONE_STATISTIC:
|
||||
GameMessages::HandleModifyPlayerZoneStatistic(inStream, entity);
|
||||
break;
|
||||
|
||||
case GAME_MSG_UPDATE_PLAYER_STATISTIC:
|
||||
case eGameMessageType::UPDATE_PLAYER_STATISTIC:
|
||||
GameMessages::HandleUpdatePlayerStatistic(inStream, entity);
|
||||
break;
|
||||
|
||||
case GAME_MSG_DISMOUNT_COMPLETE:
|
||||
case eGameMessageType::DISMOUNT_COMPLETE:
|
||||
GameMessages::HandleDismountComplete(inStream, entity, sysAddr);
|
||||
break;
|
||||
case GAME_MSG_DEACTIVATE_BUBBLE_BUFF:
|
||||
case eGameMessageType::DEACTIVATE_BUBBLE_BUFF:
|
||||
GameMessages::HandleDeactivateBubbleBuff(inStream, entity);
|
||||
break;
|
||||
case GAME_MSG_ACTIVATE_BUBBLE_BUFF:
|
||||
case eGameMessageType::ACTIVATE_BUBBLE_BUFF:
|
||||
GameMessages::HandleActivateBubbleBuff(inStream, entity);
|
||||
break;
|
||||
case GAME_MSG_ZONE_SUMMARY_DISMISSED:
|
||||
case eGameMessageType::ZONE_SUMMARY_DISMISSED:
|
||||
GameMessages::HandleZoneSummaryDismissed(inStream, entity);
|
||||
break;
|
||||
case eGameMessageType::REQUEST_ACTIVITY_EXIT:
|
||||
GameMessages::HandleRequestActivityExit(inStream, entity);
|
||||
break;
|
||||
default:
|
||||
// Game::logger->Log("GameMessageHandler", "Unknown game message ID: %i", messageID);
|
||||
break;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#define GAMEMESSAGEHANDLER_H
|
||||
|
||||
#include "RakNetTypes.h"
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "dCommonVars.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@@ -21,8 +20,10 @@
|
||||
#include "GameMessages.h"
|
||||
#include "../dDatabase/CDClientDatabase.h"
|
||||
|
||||
enum class eGameMessageType : uint16_t;
|
||||
|
||||
namespace GameMessageHandler {
|
||||
void HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, GAME_MSG messageID);
|
||||
void HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, eGameMessageType messageID);
|
||||
};
|
||||
|
||||
#endif // GAMEMESSAGEHANDLER_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,8 +8,11 @@
|
||||
#include "eMovementPlatformState.h"
|
||||
#include "NiPoint3.h"
|
||||
#include "eEndBehavior.h"
|
||||
#include "eCyclingMode.h"
|
||||
#include "eLootSourceType.h"
|
||||
#include "Brick.h"
|
||||
|
||||
class AMFValue;
|
||||
class AMFBaseValue;
|
||||
class Entity;
|
||||
class Item;
|
||||
class NiQuaternion;
|
||||
@@ -23,6 +26,16 @@ enum class eAnimationFlags : uint32_t;
|
||||
enum class eUnequippableActiveType;
|
||||
enum eInventoryType : uint32_t;
|
||||
enum class eGameMasterLevel : uint8_t;
|
||||
enum class eMatchUpdate : int32_t;
|
||||
enum class eKillType : uint32_t;
|
||||
enum class eObjectWorldState : uint32_t;
|
||||
enum class eTerminateType : uint32_t;
|
||||
enum class eControlScheme : uint32_t;
|
||||
enum class eStateChangeType : uint32_t;
|
||||
enum class ePetTamingNotifyType : uint32_t;
|
||||
enum class eUseItemResponse : uint32_t;
|
||||
enum class eQuickBuildFailReason : uint32_t;
|
||||
enum class eRebuildState : uint32_t;
|
||||
|
||||
namespace GameMessages {
|
||||
class PropertyDataMessage;
|
||||
@@ -51,8 +64,7 @@ namespace GameMessages {
|
||||
int targetTYPE = 0
|
||||
);
|
||||
|
||||
void SendPlayerSetCameraCyclingMode(const LWOOBJID& objectID, const SystemAddress& sysAddr,
|
||||
bool bAllowCyclingWhileDeadOnly = true, eCyclingMode cyclingMode = ALLOW_CYCLE_TEAMMATES);
|
||||
void SendPlayerSetCameraCyclingMode(const LWOOBJID& objectID, const SystemAddress& sysAddr, bool bAllowCyclingWhileDeadOnly = true, eCyclingMode cyclingMode = eCyclingMode::ALLOW_CYCLE_TEAMMATES);
|
||||
|
||||
void SendPlayNDAudioEmitter(Entity* entity, const SystemAddress& sysAddr, std::string audioGUID);
|
||||
|
||||
@@ -66,9 +78,9 @@ namespace GameMessages {
|
||||
void SendGMLevelBroadcast(const LWOOBJID& objectID, eGameMasterLevel level);
|
||||
void SendChatModeUpdate(const LWOOBJID& objectID, eGameMasterLevel level);
|
||||
|
||||
void SendAddItemToInventoryClientSync(Entity* entity, const SystemAddress& sysAddr, Item* item, const LWOOBJID& objectID, bool showFlyingLoot, int itemCount, LWOOBJID subKey = LWOOBJID_EMPTY, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE);
|
||||
void SendNotifyClientFlagChange(const LWOOBJID& objectID, int iFlagID, bool bFlag, const SystemAddress& sysAddr);
|
||||
void SendChangeObjectWorldState(const LWOOBJID& objectID, int state, const SystemAddress& sysAddr);
|
||||
void SendAddItemToInventoryClientSync(Entity* entity, const SystemAddress& sysAddr, Item* item, const LWOOBJID& objectID, bool showFlyingLoot, int itemCount, LWOOBJID subKey = LWOOBJID_EMPTY, eLootSourceType lootSourceType = eLootSourceType::NONE);
|
||||
void SendNotifyClientFlagChange(const LWOOBJID& objectID, uint32_t iFlagID, bool bFlag, const SystemAddress& sysAddr);
|
||||
void SendChangeObjectWorldState(const LWOOBJID& objectID, eObjectWorldState state, const SystemAddress& sysAddr);
|
||||
|
||||
void SendOfferMission(const LWOOBJID& entity, const SystemAddress& sysAddr, int32_t missionID, const LWOOBJID& offererID);
|
||||
void SendNotifyMission(Entity* entity, const SystemAddress& sysAddr, int missionID, int missionState, bool sendingRewards);
|
||||
@@ -76,8 +88,8 @@ namespace GameMessages {
|
||||
void NotifyLevelRewards(LWOOBJID objectID, const SystemAddress& sysAddr, int level, bool sending_rewards);
|
||||
|
||||
void SendModifyLEGOScore(Entity* entity, const SystemAddress& sysAddr, int64_t score, eLootSourceType sourceType);
|
||||
void SendUIMessageServerToSingleClient(Entity* entity, const SystemAddress& sysAddr, const std::string& message, AMFValue* args);
|
||||
void SendUIMessageServerToAllClients(const std::string& message, AMFValue* args);
|
||||
void SendUIMessageServerToSingleClient(Entity* entity, const SystemAddress& sysAddr, const std::string& message, AMFBaseValue& args);
|
||||
void SendUIMessageServerToAllClients(const std::string& message, AMFBaseValue& args);
|
||||
|
||||
void SendPlayEmbeddedEffectOnAllClientsNearObject(Entity* entity, std::u16string effectName, const LWOOBJID& fromObjectID, float radius);
|
||||
void SendPlayFXEffect(Entity* entity, int32_t effectID, const std::u16string& effectType, const std::string& name, LWOOBJID secondary, float priority = 1, float scale = 1, bool serialize = true);
|
||||
@@ -86,8 +98,8 @@ namespace GameMessages {
|
||||
void SendBroadcastTextToChatbox(Entity* entity, const SystemAddress& sysAddr, const std::u16string& attrs, const std::u16string& wsText);
|
||||
void SendSetCurrency(Entity* entity, int64_t currency, int lootType, const LWOOBJID& sourceID, const LOT& sourceLOT, int sourceTradeID, bool overrideCurrent, eLootSourceType sourceType);
|
||||
|
||||
void SendRebuildNotifyState(Entity* entity, int prevState, int state, const LWOOBJID& playerID);
|
||||
void SendEnableRebuild(Entity* entity, bool enable, bool fail, bool success, int failReason, float duration, const LWOOBJID& playerID);
|
||||
void SendRebuildNotifyState(Entity* entity, eRebuildState prevState, eRebuildState state, const LWOOBJID& playerID);
|
||||
void SendEnableRebuild(Entity* entity, bool enable, bool fail, bool success, eQuickBuildFailReason failReason, float duration, const LWOOBJID& playerID);
|
||||
void AddActivityOwner(Entity* entity, LWOOBJID& ownerID);
|
||||
void SendTerminateInteraction(const LWOOBJID& objectID, eTerminateType type, const LWOOBJID& terminator);
|
||||
|
||||
@@ -104,7 +116,7 @@ namespace GameMessages {
|
||||
void SendSetNetworkScriptVar(Entity* entity, const SystemAddress& sysAddr, std::string data);
|
||||
void SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID, LOT item, int currency, NiPoint3 spawnPos = NiPoint3::ZERO, int count = 1);
|
||||
|
||||
void SendSetPlayerControlScheme(Entity* entity, eControlSceme controlScheme);
|
||||
void SendSetPlayerControlScheme(Entity* entity, eControlScheme controlScheme);
|
||||
void SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPoint3& position, const NiQuaternion& rotation);
|
||||
|
||||
void SendAddSkill(Entity* entity, TSkillID skillID, int slotID);
|
||||
@@ -123,7 +135,7 @@ namespace GameMessages {
|
||||
void SendMoveInventoryBatch(Entity* entity, uint32_t stackCount, int srcInv, int dstInv, const LWOOBJID& iObjID);
|
||||
|
||||
void SendMatchResponse(Entity* entity, const SystemAddress& sysAddr, int response);
|
||||
void SendMatchUpdate(Entity* entity, const SystemAddress& sysAddr, std::string data, int type);
|
||||
void SendMatchUpdate(Entity* entity, const SystemAddress& sysAddr, std::string data, eMatchUpdate type);
|
||||
|
||||
void HandleUnUseModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
void SendStartCelebrationEffect(Entity* entity, const SystemAddress& sysAddr, int celebrationID);
|
||||
@@ -350,7 +362,7 @@ namespace GameMessages {
|
||||
void HandleClientTradeUpdate(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
|
||||
//Pets:
|
||||
void SendNotifyPetTamingMinigame(LWOOBJID objectId, LWOOBJID petId, LWOOBJID playerTamingId, bool bForceTeleport, uint32_t notifyType, NiPoint3 petsDestPos, NiPoint3 telePos, NiQuaternion teleRot, const SystemAddress& sysAddr);
|
||||
void SendNotifyPetTamingMinigame(LWOOBJID objectId, LWOOBJID petId, LWOOBJID playerTamingId, bool bForceTeleport, ePetTamingNotifyType notifyType, NiPoint3 petsDestPos, NiPoint3 telePos, NiQuaternion teleRot, const SystemAddress& sysAddr);
|
||||
|
||||
void SendNotifyPetTamingPuzzleSelected(LWOOBJID objectId, std::vector<Brick>& bricks, const SystemAddress& sysAddr);
|
||||
|
||||
@@ -520,7 +532,7 @@ namespace GameMessages {
|
||||
void SendActivityPause(LWOOBJID objectId, bool pause = false, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
||||
void SendStartActivityTime(LWOOBJID objectId, float_t startTime, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
||||
void SendRequestActivityEnter(LWOOBJID objectId, const SystemAddress& sysAddr, bool bStart, LWOOBJID userID);
|
||||
void SendUseItemRequirementsResponse(LWOOBJID objectID, const SystemAddress& sysAddr, UseItemResponse itemResponse);
|
||||
void SendUseItemRequirementsResponse(LWOOBJID objectID, const SystemAddress& sysAddr, eUseItemResponse itemResponse);
|
||||
|
||||
// SG:
|
||||
|
||||
@@ -636,6 +648,7 @@ namespace GameMessages {
|
||||
void SendDeactivateBubbleBuffFromServer(LWOOBJID objectId, const SystemAddress& sysAddr);
|
||||
|
||||
void HandleZoneSummaryDismissed(RakNet::BitStream* inStream, Entity* entity);
|
||||
void HandleRequestActivityExit(RakNet::BitStream* inStream, Entity* entity);
|
||||
};
|
||||
|
||||
#endif // GAMEMESSAGES_H
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
#define __REQUESTSERVERPROJECTILEIMPACT__H__
|
||||
|
||||
#include "dCommonVars.h"
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "eGameMessageType.h"
|
||||
|
||||
/* Notifying the server that a locally owned projectile impacted. Sent to the caster of the projectile
|
||||
should always be the local char. */
|
||||
class RequestServerProjectileImpact {
|
||||
static const GAME_MSG MsgID = GAME_MSG_REQUEST_SERVER_PROJECTILE_IMPACT;
|
||||
|
||||
public:
|
||||
RequestServerProjectileImpact() {
|
||||
i64LocalID = LWOOBJID_EMPTY;
|
||||
@@ -29,7 +27,7 @@ public:
|
||||
}
|
||||
|
||||
void Serialize(RakNet::BitStream* stream) {
|
||||
stream->Write(MsgID);
|
||||
stream->Write(eGameMessageType::REQUEST_SERVER_PROJECTILE_IMPACT);
|
||||
|
||||
stream->Write(i64LocalID != LWOOBJID_EMPTY);
|
||||
if (i64LocalID != LWOOBJID_EMPTY) stream->Write(i64LocalID);
|
||||
|
||||
@@ -2,16 +2,14 @@
|
||||
#define __STARTSKILL__H__
|
||||
|
||||
#include "dCommonVars.h"
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "NiPoint3.h"
|
||||
#include "NiQuaternion.h"
|
||||
#include "eGameMessageType.h"
|
||||
|
||||
/**
|
||||
* Same as sync skill but with different network options. An echo down to other clients that need to play the skill.
|
||||
*/
|
||||
class StartSkill {
|
||||
static const GAME_MSG MsgID = GAME_MSG_START_SKILL;
|
||||
|
||||
public:
|
||||
StartSkill() {
|
||||
bUsedMouse = false;
|
||||
@@ -46,7 +44,7 @@ public:
|
||||
}
|
||||
|
||||
void Serialize(RakNet::BitStream* stream) {
|
||||
stream->Write(MsgID);
|
||||
stream->Write(eGameMessageType::START_SKILL);
|
||||
|
||||
stream->Write(bUsedMouse);
|
||||
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
#include <string>
|
||||
|
||||
#include "BitStream.h"
|
||||
#include "eGameMessageType.h"
|
||||
|
||||
/* Message to synchronize a skill cast */
|
||||
class SyncSkill {
|
||||
static const GAME_MSG MsgID = GAME_MSG_SYNC_SKILL;
|
||||
|
||||
public:
|
||||
SyncSkill() {
|
||||
bDone = false;
|
||||
@@ -30,7 +29,7 @@ public:
|
||||
}
|
||||
|
||||
void Serialize(RakNet::BitStream* stream) {
|
||||
stream->Write(MsgID);
|
||||
stream->Write(eGameMessageType::SYNC_SKILL);
|
||||
|
||||
stream->Write(bDone);
|
||||
uint32_t sBitStreamLength = sBitStream.length();
|
||||
|
||||
@@ -244,9 +244,9 @@ eInventoryType Inventory::FindInventoryTypeForLot(const LOT lot) {
|
||||
return PROPERTY_DEEDS;
|
||||
|
||||
case eItemType::MODEL:
|
||||
case eItemType::VEHICLE:
|
||||
case eItemType::PET_INVENTORY_ITEM:
|
||||
case eItemType::LOOT_MODEL:
|
||||
case eItemType::LUP_MODEL:
|
||||
case eItemType::VEHICLE:
|
||||
case eItemType::MOUNT:
|
||||
return MODELS;
|
||||
|
||||
@@ -263,9 +263,8 @@ eInventoryType Inventory::FindInventoryTypeForLot(const LOT lot) {
|
||||
case eItemType::CHEST:
|
||||
case eItemType::EGG:
|
||||
case eItemType::PET_FOOD:
|
||||
case eItemType::PET_INVENTORY_ITEM:
|
||||
case eItemType::PACKAGE:
|
||||
|
||||
case eItemType::LUP_MODEL:
|
||||
return ITEMS;
|
||||
|
||||
case eItemType::QUEST_OBJECT:
|
||||
|
||||
+17
-12
@@ -16,7 +16,9 @@
|
||||
#include "AssetManager.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "Loot.h"
|
||||
#include "eObjectBits.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "eUseItemResponse.h"
|
||||
|
||||
#include "CDBrickIDTableTable.h"
|
||||
#include "CDObjectSkillsTable.h"
|
||||
@@ -77,13 +79,13 @@ Item::Item(
|
||||
|
||||
LWOOBJID id = ObjectIDManager::GenerateRandomObjectID();
|
||||
|
||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_CHARACTER);
|
||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_PERSISTENT);
|
||||
GeneralUtils::SetBit(id, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(id, eObjectBits::PERSISTENT);
|
||||
|
||||
const auto type = static_cast<eItemType>(info->itemType);
|
||||
|
||||
if (type == eItemType::MOUNT) {
|
||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_CLIENT);
|
||||
GeneralUtils::SetBit(id, eObjectBits::CLIENT);
|
||||
}
|
||||
|
||||
this->id = id;
|
||||
@@ -329,7 +331,7 @@ void Item::UseNonEquip(Item* item) {
|
||||
}
|
||||
}
|
||||
if (playerInventoryComponent->HasSpaceForLoot(rolledLoot)) {
|
||||
LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetParent(), rolledLoot, eLootSourceType::LOOT_SOURCE_CONSUMPTION);
|
||||
LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetParent(), rolledLoot, eLootSourceType::CONSUMPTION);
|
||||
item->SetCount(item->GetCount() - 1);
|
||||
} else {
|
||||
success = false;
|
||||
@@ -338,7 +340,7 @@ void Item::UseNonEquip(Item* item) {
|
||||
GameMessages::SendUseItemRequirementsResponse(
|
||||
playerInventoryComponent->GetParent()->GetObjectID(),
|
||||
playerInventoryComponent->GetParent()->GetSystemAddress(),
|
||||
UseItemResponse::FailedPrecondition
|
||||
eUseItemResponse::FailedPrecondition
|
||||
);
|
||||
success = false;
|
||||
}
|
||||
@@ -378,7 +380,7 @@ void Item::Disassemble(const eInventoryType inventoryType) {
|
||||
}
|
||||
|
||||
for (const auto mod : modArray) {
|
||||
inventory->GetComponent()->AddItem(mod, 1, eLootSourceType::LOOT_SOURCE_DELETION, inventoryType);
|
||||
inventory->GetComponent()->AddItem(mod, 1, eLootSourceType::DELETION, inventoryType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -390,19 +392,22 @@ void Item::DisassembleModel() {
|
||||
const auto componentId = table->GetByIDAndType(GetLot(), eReplicaComponentType::RENDER);
|
||||
|
||||
auto query = CDClientDatabase::CreatePreppedStmt(
|
||||
"SELECT render_asset FROM RenderComponent WHERE id = ?;");
|
||||
"SELECT render_asset, LXFMLFolder FROM RenderComponent WHERE id = ?;");
|
||||
query.bind(1, (int)componentId);
|
||||
|
||||
auto result = query.execQuery();
|
||||
|
||||
if (result.eof()) {
|
||||
if (result.eof() || result.fieldIsNull(0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string renderAsset = result.fieldIsNull(0) ? "" : std::string(result.getStringField(0));
|
||||
std::vector<std::string> renderAssetSplit = GeneralUtils::SplitString(renderAsset, '\\');
|
||||
std::string renderAsset = std::string(result.getStringField(0));
|
||||
std::string lxfmlFolderName = std::string(result.getStringField(1));
|
||||
|
||||
std::string lxfmlPath = "BrickModels/" + GeneralUtils::SplitString(renderAssetSplit.back(), '.').at(0) + ".lxfml";
|
||||
std::vector<std::string> renderAssetSplit = GeneralUtils::SplitString(renderAsset, '\\');
|
||||
if (renderAssetSplit.size() == 0) return;
|
||||
|
||||
std::string lxfmlPath = "BrickModels/" + lxfmlFolderName + "/" + GeneralUtils::SplitString(renderAssetSplit.back(), '.').at(0) + ".lxfml";
|
||||
auto buffer = Game::assetManager->GetFileAsBuffer(lxfmlPath.c_str());
|
||||
|
||||
if (!buffer.m_Success) {
|
||||
@@ -473,7 +478,7 @@ void Item::DisassembleModel() {
|
||||
continue;
|
||||
}
|
||||
|
||||
GetInventory()->GetComponent()->AddItem(brickID[0].NDObjectID, 1, eLootSourceType::LOOT_SOURCE_DELETION);
|
||||
GetInventory()->GetComponent()->AddItem(brickID[0].NDObjectID, 1, eLootSourceType::DELETION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "dLogger.h"
|
||||
#include "Preconditions.h"
|
||||
#include "eInventoryType.h"
|
||||
#include "eLootSourceType.h"
|
||||
|
||||
/**
|
||||
* An item that can be stored in an inventory and optionally consumed or equipped
|
||||
@@ -38,7 +39,7 @@ public:
|
||||
const std::vector<LDFBaseData*>& config,
|
||||
LWOOBJID parent,
|
||||
LWOOBJID subKey,
|
||||
eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE
|
||||
eLootSourceType lootSourceType = eLootSourceType::NONE
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -65,7 +66,7 @@ public:
|
||||
bool isModMoveAndEquip = false,
|
||||
LWOOBJID subKey = LWOOBJID_EMPTY,
|
||||
bool bound = false,
|
||||
eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE
|
||||
eLootSourceType lootSourceType = eLootSourceType::NONE
|
||||
);
|
||||
|
||||
~Item();
|
||||
@@ -89,7 +90,7 @@ public:
|
||||
* @param disassemble if items were removed, this returns all the sub parts of the item individually if it had assembly part lots
|
||||
* @param showFlyingLoot shows flying loot to the client, if not silent
|
||||
*/
|
||||
void SetCount(uint32_t value, bool silent = false, bool disassemble = true, bool showFlyingLoot = true, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE);
|
||||
void SetCount(uint32_t value, bool silent = false, bool disassemble = true, bool showFlyingLoot = true, eLootSourceType lootSourceType = eLootSourceType::NONE);
|
||||
|
||||
/**
|
||||
* Returns the number of items this item represents (e.g. for stacks)
|
||||
|
||||
@@ -388,7 +388,7 @@ void Mission::Catchup() {
|
||||
}
|
||||
|
||||
if (type == eMissionTaskType::PLAYER_FLAG) {
|
||||
for (auto target : task->GetAllTargets()) {
|
||||
for (int32_t target : task->GetAllTargets()) {
|
||||
const auto flag = GetUser()->GetLastUsedChar()->GetPlayerFlag(target);
|
||||
|
||||
if (!flag) {
|
||||
@@ -442,7 +442,7 @@ void Mission::YieldRewards() {
|
||||
|
||||
int32_t coinsToSend = 0;
|
||||
if (info->LegoScore > 0) {
|
||||
eLootSourceType lootSource = info->isMission ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT;
|
||||
eLootSourceType lootSource = info->isMission ? eLootSourceType::MISSION : eLootSourceType::ACHIEVEMENT;
|
||||
if (levelComponent->GetLevel() >= dZoneManager::Instance()->GetWorldConfig()->levelCap) {
|
||||
// Since the character is at the level cap we reward them with coins instead of UScore.
|
||||
coinsToSend += info->LegoScore * dZoneManager::Instance()->GetWorldConfig()->levelCapCurrencyConversion;
|
||||
@@ -475,11 +475,11 @@ void Mission::YieldRewards() {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
inventoryComponent->AddItem(pair.first, count, IsMission() ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT);
|
||||
inventoryComponent->AddItem(pair.first, count, IsMission() ? eLootSourceType::MISSION : eLootSourceType::ACHIEVEMENT);
|
||||
}
|
||||
|
||||
if (info->reward_currency_repeatable > 0 || coinsToSend > 0) {
|
||||
eLootSourceType lootSource = info->isMission ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT;
|
||||
eLootSourceType lootSource = info->isMission ? eLootSourceType::MISSION : eLootSourceType::ACHIEVEMENT;
|
||||
character->SetCoins(character->GetCoins() + info->reward_currency_repeatable + coinsToSend, lootSource);
|
||||
}
|
||||
|
||||
@@ -508,11 +508,11 @@ void Mission::YieldRewards() {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
inventoryComponent->AddItem(pair.first, count, IsMission() ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT);
|
||||
inventoryComponent->AddItem(pair.first, count, IsMission() ? eLootSourceType::MISSION : eLootSourceType::ACHIEVEMENT);
|
||||
}
|
||||
|
||||
if (info->reward_currency > 0 || coinsToSend > 0) {
|
||||
eLootSourceType lootSource = info->isMission ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT;
|
||||
eLootSourceType lootSource = info->isMission ? eLootSourceType::MISSION : eLootSourceType::ACHIEVEMENT;
|
||||
character->SetCoins(character->GetCoins() + info->reward_currency + coinsToSend, lootSource);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,19 +12,19 @@ Action::Action(AMFArrayValue* arguments) {
|
||||
valueParameterName = "";
|
||||
valueParameterString = "";
|
||||
valueParameterDouble = 0.0;
|
||||
for (auto& typeValueMap : arguments->GetAssociativeMap()) {
|
||||
for (auto& typeValueMap : arguments->GetAssociative()) {
|
||||
if (typeValueMap.first == "Type") {
|
||||
if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue;
|
||||
type = static_cast<AMFStringValue*>(typeValueMap.second)->GetStringValue();
|
||||
if (typeValueMap.second->GetValueType() != eAmf::String) continue;
|
||||
type = static_cast<AMFStringValue*>(typeValueMap.second)->GetValue();
|
||||
} else {
|
||||
valueParameterName = typeValueMap.first;
|
||||
// Message is the only known string parameter
|
||||
if (valueParameterName == "Message") {
|
||||
if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue;
|
||||
valueParameterString = static_cast<AMFStringValue*>(typeValueMap.second)->GetStringValue();
|
||||
if (typeValueMap.second->GetValueType() != eAmf::String) continue;
|
||||
valueParameterString = static_cast<AMFStringValue*>(typeValueMap.second)->GetValue();
|
||||
} else {
|
||||
if (typeValueMap.second->GetValueType() != AMFValueType::AMFDouble) continue;
|
||||
valueParameterDouble = static_cast<AMFDoubleValue*>(typeValueMap.second)->GetDoubleValue();
|
||||
if (typeValueMap.second->GetValueType() != eAmf::Double) continue;
|
||||
valueParameterDouble = static_cast<AMFDoubleValue*>(typeValueMap.second)->GetValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
|
||||
ActionContext::ActionContext() {
|
||||
stripId = 0;
|
||||
@@ -17,15 +17,15 @@ ActionContext::ActionContext(AMFArrayValue* arguments, std::string customStateKe
|
||||
}
|
||||
|
||||
BehaviorState ActionContext::GetBehaviorStateFromArgument(AMFArrayValue* arguments, const std::string& key) {
|
||||
auto* stateIDValue = arguments->FindValue<AMFDoubleValue>(key);
|
||||
auto* stateIDValue = arguments->Get<double>(key);
|
||||
if (!stateIDValue) throw std::invalid_argument("Unable to find behavior state from argument \"" + key + "\"");
|
||||
|
||||
return static_cast<BehaviorState>(stateIDValue->GetDoubleValue());
|
||||
return static_cast<BehaviorState>(stateIDValue->GetValue());
|
||||
}
|
||||
|
||||
StripId ActionContext::GetStripIdFromArgument(AMFArrayValue* arguments, const std::string& key) {
|
||||
auto* stripIdValue = arguments->FindValue<AMFDoubleValue>(key);
|
||||
auto* stripIdValue = arguments->Get<double>(key);
|
||||
if (!stripIdValue) throw std::invalid_argument("Unable to find strip ID from argument \"" + key + "\"");
|
||||
|
||||
return static_cast<StripId>(stripIdValue->GetDoubleValue());
|
||||
return static_cast<StripId>(stripIdValue->GetValue());
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ AddActionMessage::AddActionMessage(AMFArrayValue* arguments) : BehaviorMessageBa
|
||||
actionContext = ActionContext(arguments);
|
||||
actionIndex = GetActionIndexFromArgument(arguments);
|
||||
|
||||
auto* actionValue = arguments->FindValue<AMFArrayValue>("action");
|
||||
auto* actionValue = arguments->GetArray("action");
|
||||
if (!actionValue) return;
|
||||
|
||||
action = Action(actionValue);
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
AddMessage::AddMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
behaviorIndex = 0;
|
||||
auto* behaviorIndexValue = arguments->FindValue<AMFDoubleValue>("BehaviorIndex");
|
||||
auto* behaviorIndexValue = arguments->Get<double>("BehaviorIndex");
|
||||
|
||||
if (!behaviorIndexValue) return;
|
||||
|
||||
behaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetDoubleValue());
|
||||
behaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetValue());
|
||||
Game::logger->LogDebug("AddMessage", "behaviorId %i index %i", behaviorId, behaviorIndex);
|
||||
}
|
||||
|
||||
@@ -4,17 +4,16 @@
|
||||
|
||||
AddStripMessage::AddStripMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
actionContext = ActionContext(arguments);
|
||||
|
||||
position = StripUiPosition(arguments);
|
||||
|
||||
auto* strip = arguments->FindValue<AMFArrayValue>("strip");
|
||||
auto* strip = arguments->GetArray("strip");
|
||||
if (!strip) return;
|
||||
|
||||
auto* actions = strip->FindValue<AMFArrayValue>("actions");
|
||||
auto* actions = strip->GetArray("actions");
|
||||
if (!actions) return;
|
||||
|
||||
for (uint32_t actionNumber = 0; actionNumber < actions->GetDenseValueSize(); actionNumber++) {
|
||||
auto* actionValue = actions->GetValueAt<AMFArrayValue>(actionNumber);
|
||||
for (uint32_t actionNumber = 0; actionNumber < actions->GetDense().size(); actionNumber++) {
|
||||
auto* actionValue = actions->GetArray(actionNumber);
|
||||
if (!actionValue) continue;
|
||||
|
||||
actionsToAdd.push_back(Action(actionValue));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
#include "BehaviorStates.h"
|
||||
#include "dCommonVars.h"
|
||||
|
||||
@@ -11,12 +11,12 @@ BehaviorMessageBase::BehaviorMessageBase(AMFArrayValue* arguments) {
|
||||
|
||||
int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(AMFArrayValue* arguments) {
|
||||
const auto* key = "BehaviorID";
|
||||
auto* behaviorIDValue = arguments->FindValue<AMFStringValue>(key);
|
||||
auto* behaviorIDValue = arguments->Get<std::string>(key);
|
||||
int32_t behaviorID = -1;
|
||||
|
||||
if (behaviorIDValue) {
|
||||
behaviorID = std::stoul(behaviorIDValue->GetStringValue());
|
||||
} else if (!arguments->FindValue<AMFUndefinedValue>(key)) {
|
||||
if (behaviorIDValue && behaviorIDValue->GetValueType() == eAmf::String) {
|
||||
behaviorID = std::stoul(behaviorIDValue->GetValue());
|
||||
} else if (arguments->Get(key)->GetValueType() != eAmf::Undefined) {
|
||||
throw std::invalid_argument("Unable to find behavior ID");
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(AMFArrayValue* arguments)
|
||||
}
|
||||
|
||||
uint32_t BehaviorMessageBase::GetActionIndexFromArgument(AMFArrayValue* arguments, const std::string& keyName) {
|
||||
auto* actionIndexAmf = arguments->FindValue<AMFDoubleValue>(keyName);
|
||||
auto* actionIndexAmf = arguments->Get<double>(keyName);
|
||||
if (!actionIndexAmf) {
|
||||
throw std::invalid_argument("Unable to find actionIndex");
|
||||
}
|
||||
|
||||
return static_cast<uint32_t>(actionIndexAmf->GetDoubleValue());
|
||||
return static_cast<uint32_t>(actionIndexAmf->GetValue());
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
#include "dCommonVars.h"
|
||||
|
||||
#include "Game.h"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "MoveToInventoryMessage.h"
|
||||
|
||||
MoveToInventoryMessage::MoveToInventoryMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
auto* behaviorIndexValue = arguments->FindValue<AMFDoubleValue>("BehaviorIndex");
|
||||
auto* behaviorIndexValue = arguments->Get<double>("BehaviorIndex");
|
||||
if (!behaviorIndexValue) return;
|
||||
|
||||
behaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetDoubleValue());
|
||||
behaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetValue());
|
||||
Game::logger->LogDebug("MoveToInventoryMessage", "behaviorId %i behaviorIndex %i", behaviorId, behaviorIndex);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "RenameMessage.h"
|
||||
|
||||
RenameMessage::RenameMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
auto* nameAmf = arguments->FindValue<AMFStringValue>("Name");
|
||||
auto* nameAmf = arguments->Get<std::string>("Name");
|
||||
if (!nameAmf) return;
|
||||
|
||||
name = nameAmf->GetStringValue();
|
||||
name = nameAmf->GetValue();
|
||||
Game::logger->LogDebug("RenameMessage", "behaviorId %i n %s", behaviorId, name.c_str());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "StripUiPosition.h"
|
||||
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
|
||||
StripUiPosition::StripUiPosition() {
|
||||
xPosition = 0.0;
|
||||
@@ -10,13 +10,13 @@ StripUiPosition::StripUiPosition() {
|
||||
StripUiPosition::StripUiPosition(AMFArrayValue* arguments, std::string uiKeyName) {
|
||||
xPosition = 0.0;
|
||||
yPosition = 0.0;
|
||||
auto* uiArray = arguments->FindValue<AMFArrayValue>(uiKeyName);
|
||||
auto* uiArray = arguments->GetArray(uiKeyName);
|
||||
if (!uiArray) return;
|
||||
|
||||
auto* xPositionValue = uiArray->FindValue<AMFDoubleValue>("x");
|
||||
auto* yPositionValue = uiArray->FindValue<AMFDoubleValue>("y");
|
||||
auto* xPositionValue = uiArray->Get<double>("x");
|
||||
auto* yPositionValue = uiArray->Get<double>("y");
|
||||
if (!xPositionValue || !yPositionValue) return;
|
||||
|
||||
yPosition = yPositionValue->GetDoubleValue();
|
||||
xPosition = xPositionValue->GetDoubleValue();
|
||||
yPosition = yPositionValue->GetValue();
|
||||
xPosition = xPositionValue->GetValue();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
UpdateActionMessage::UpdateActionMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
actionContext = ActionContext(arguments);
|
||||
|
||||
auto* actionValue = arguments->FindValue<AMFArrayValue>("action");
|
||||
auto* actionValue = arguments->GetArray("action");
|
||||
if (!actionValue) return;
|
||||
|
||||
action = Action(actionValue);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "ControlBehaviors.h"
|
||||
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
#include "Entity.h"
|
||||
#include "Game.h"
|
||||
#include "GameMessages.h"
|
||||
@@ -43,11 +43,11 @@ void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, ModelComponent* mode
|
||||
// AMFArrayValue args;
|
||||
|
||||
// AMFStringValue* behaviorIDString = new AMFStringValue();
|
||||
// behaviorIDString->SetStringValue(std::to_string(persistentId));
|
||||
// behaviorIDString->SetValue(std::to_string(persistentId));
|
||||
// args.InsertValue("behaviorID", behaviorIDString);
|
||||
|
||||
// AMFStringValue* objectIDAsString = new AMFStringValue();
|
||||
// objectIDAsString->SetStringValue(std::to_string(modelComponent->GetParent()->GetObjectID()));
|
||||
// objectIDAsString->SetValue(std::to_string(modelComponent->GetParent()->GetObjectID()));
|
||||
// args.InsertValue("objectID", objectIDAsString);
|
||||
|
||||
// GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorID", &args);
|
||||
@@ -63,8 +63,6 @@ void ControlBehaviors::SendBehaviorListToClient(Entity* modelEntity, const Syste
|
||||
|
||||
AMFArrayValue behaviorsToSerialize;
|
||||
|
||||
AMFArrayValue* behaviors = new AMFArrayValue(); // Empty for now
|
||||
|
||||
/**
|
||||
* The behaviors AMFArray will have up to 5 elements in the dense portion.
|
||||
* Each element in the dense portion will be made up of another AMFArray
|
||||
@@ -75,20 +73,17 @@ void ControlBehaviors::SendBehaviorListToClient(Entity* modelEntity, const Syste
|
||||
* "name": The name of the behavior formatted as an AMFString
|
||||
*/
|
||||
|
||||
behaviorsToSerialize.InsertValue("behaviors", behaviors);
|
||||
behaviorsToSerialize.Insert("behaviors");
|
||||
behaviorsToSerialize.Insert("objectID", std::to_string(modelComponent->GetParent()->GetObjectID()));
|
||||
|
||||
AMFStringValue* amfStringValueForObjectID = new AMFStringValue();
|
||||
amfStringValueForObjectID->SetStringValue(std::to_string(modelComponent->GetParent()->GetObjectID()));
|
||||
|
||||
behaviorsToSerialize.InsertValue("objectID", amfStringValueForObjectID);
|
||||
GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorList", &behaviorsToSerialize);
|
||||
GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorList", behaviorsToSerialize);
|
||||
}
|
||||
|
||||
void ControlBehaviors::ModelTypeChanged(AMFArrayValue* arguments, ModelComponent* ModelComponent) {
|
||||
auto* modelTypeAmf = arguments->FindValue<AMFDoubleValue>("ModelType");
|
||||
auto* modelTypeAmf = arguments->Get<double>("ModelType");
|
||||
if (!modelTypeAmf) return;
|
||||
|
||||
uint32_t modelType = static_cast<uint32_t>(modelTypeAmf->GetDoubleValue());
|
||||
uint32_t modelType = static_cast<uint32_t>(modelTypeAmf->GetValue());
|
||||
|
||||
//TODO Update the model type here
|
||||
}
|
||||
@@ -179,7 +174,7 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent
|
||||
// AMFArrayValue* state = new AMFArrayValue();
|
||||
|
||||
// AMFDoubleValue* stateAsDouble = new AMFDoubleValue();
|
||||
// stateAsDouble->SetDoubleValue(it->first);
|
||||
// stateAsDouble->SetValue(it->first);
|
||||
// state->InsertValue("id", stateAsDouble);
|
||||
|
||||
// AMFArrayValue* strips = new AMFArrayValue();
|
||||
@@ -189,16 +184,16 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent
|
||||
// AMFArrayValue* thisStrip = new AMFArrayValue();
|
||||
|
||||
// AMFDoubleValue* stripID = new AMFDoubleValue();
|
||||
// stripID->SetDoubleValue(strip->first);
|
||||
// stripID->SetValue(strip->first);
|
||||
// thisStrip->InsertValue("id", stripID);
|
||||
|
||||
// AMFArrayValue* uiArray = new AMFArrayValue();
|
||||
// AMFDoubleValue* yPosition = new AMFDoubleValue();
|
||||
// yPosition->SetDoubleValue(strip->second->GetYPosition());
|
||||
// yPosition->SetValue(strip->second->GetYPosition());
|
||||
// uiArray->InsertValue("y", yPosition);
|
||||
|
||||
// AMFDoubleValue* xPosition = new AMFDoubleValue();
|
||||
// xPosition->SetDoubleValue(strip->second->GetXPosition());
|
||||
// xPosition->SetValue(strip->second->GetXPosition());
|
||||
// uiArray->InsertValue("x", xPosition);
|
||||
|
||||
// thisStrip->InsertValue("ui", uiArray);
|
||||
@@ -211,19 +206,19 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent
|
||||
// AMFArrayValue* thisAction = new AMFArrayValue();
|
||||
|
||||
// AMFStringValue* actionName = new AMFStringValue();
|
||||
// actionName->SetStringValue(behaviorAction->actionName);
|
||||
// actionName->SetValue(behaviorAction->actionName);
|
||||
// thisAction->InsertValue("Type", actionName);
|
||||
|
||||
// if (behaviorAction->parameterValueString != "")
|
||||
// {
|
||||
// AMFStringValue* valueAsString = new AMFStringValue();
|
||||
// valueAsString->SetStringValue(behaviorAction->parameterValueString);
|
||||
// valueAsString->SetValue(behaviorAction->parameterValueString);
|
||||
// thisAction->InsertValue(behaviorAction->parameterName, valueAsString);
|
||||
// }
|
||||
// else if (behaviorAction->parameterValueDouble != 0.0)
|
||||
// {
|
||||
// AMFDoubleValue* valueAsDouble = new AMFDoubleValue();
|
||||
// valueAsDouble->SetDoubleValue(behaviorAction->parameterValueDouble);
|
||||
// valueAsDouble->SetValue(behaviorAction->parameterValueDouble);
|
||||
// thisAction->InsertValue(behaviorAction->parameterName, valueAsDouble);
|
||||
// }
|
||||
// stripSerialize->PushBackValue(thisAction);
|
||||
@@ -237,11 +232,11 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent
|
||||
// behaviorInfo.InsertValue("states", stateSerialize);
|
||||
|
||||
// AMFStringValue* objectidAsString = new AMFStringValue();
|
||||
// objectidAsString->SetStringValue(std::to_string(targetObjectID));
|
||||
// objectidAsString->SetValue(std::to_string(targetObjectID));
|
||||
// behaviorInfo.InsertValue("objectID", objectidAsString);
|
||||
|
||||
// AMFStringValue* behaviorIDAsString = new AMFStringValue();
|
||||
// behaviorIDAsString->SetStringValue(std::to_string(behaviorID));
|
||||
// behaviorIDAsString->SetValue(std::to_string(behaviorID));
|
||||
// behaviorInfo.InsertValue("BehaviorID", behaviorIDAsString);
|
||||
|
||||
// GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorBlocks", &behaviorInfo);
|
||||
@@ -275,10 +270,9 @@ void ControlBehaviors::MoveToInventory(ModelComponent* modelComponent, const Sys
|
||||
// This closes the UI menu should it be open while the player is removing behaviors
|
||||
AMFArrayValue args;
|
||||
|
||||
AMFFalseValue* stateToPop = new AMFFalseValue();
|
||||
args.InsertValue("visible", stateToPop);
|
||||
args.Insert("visible", false);
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(modelOwner, modelOwner->GetParentUser()->GetSystemAddress(), "ToggleBehaviorEditor", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(modelOwner, modelOwner->GetParentUser()->GetSystemAddress(), "ToggleBehaviorEditor", args);
|
||||
|
||||
MoveToInventoryMessage moveToInventoryMessage(arguments);
|
||||
|
||||
|
||||
@@ -318,13 +318,13 @@ void LootGenerator::GiveActivityLoot(Entity* player, Entity* source, uint32_t ac
|
||||
maxCoins = currencyTable[0].maxvalue;
|
||||
}
|
||||
|
||||
GiveLoot(player, selectedReward->LootMatrixIndex, eLootSourceType::LOOT_SOURCE_ACTIVITY);
|
||||
GiveLoot(player, selectedReward->LootMatrixIndex, eLootSourceType::ACTIVITY);
|
||||
|
||||
uint32_t coins = (int)(minCoins + GeneralUtils::GenerateRandomNumber<float>(0, 1) * (maxCoins - minCoins));
|
||||
|
||||
auto* character = player->GetCharacter();
|
||||
|
||||
character->SetCoins(character->GetCoins() + coins, eLootSourceType::LOOT_SOURCE_ACTIVITY);
|
||||
character->SetCoins(character->GetCoins() + coins, eLootSourceType::ACTIVITY);
|
||||
}
|
||||
|
||||
void LootGenerator::DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins) {
|
||||
|
||||
@@ -47,8 +47,8 @@ public:
|
||||
|
||||
std::unordered_map<LOT, int32_t> RollLootMatrix(Entity* player, uint32_t matrixIndex);
|
||||
std::unordered_map<LOT, int32_t> RollLootMatrix(uint32_t matrixIndex);
|
||||
void GiveLoot(Entity* player, uint32_t matrixIndex, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE);
|
||||
void GiveLoot(Entity* player, std::unordered_map<LOT, int32_t>& result, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE);
|
||||
void GiveLoot(Entity* player, uint32_t matrixIndex, eLootSourceType lootSourceType = eLootSourceType::NONE);
|
||||
void GiveLoot(Entity* player, std::unordered_map<LOT, int32_t>& result, eLootSourceType lootSourceType = eLootSourceType::NONE);
|
||||
void GiveActivityLoot(Entity* player, Entity* source, uint32_t activityID, int32_t rating = 0);
|
||||
void DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins);
|
||||
void DropLoot(Entity* player, Entity* killedObject, std::unordered_map<LOT, int32_t>& result, uint32_t minCoins, uint32_t maxCoins);
|
||||
|
||||
+11
-11
@@ -13,7 +13,6 @@
|
||||
#include "Entity.h"
|
||||
#include "Character.h"
|
||||
#include "PacketUtils.h"
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "dLogger.h"
|
||||
#include "EntityManager.h"
|
||||
#include "InventoryComponent.h"
|
||||
@@ -26,6 +25,7 @@
|
||||
#include "WorldConfig.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "eConnectionType.h"
|
||||
|
||||
void Mail::SendMail(const Entity* recipient, const std::string& subject, const std::string& body, const LOT attachment,
|
||||
const uint16_t attachmentCount) {
|
||||
@@ -130,7 +130,7 @@ void Mail::HandleMailStuff(RakNet::BitStream* packet, const SystemAddress& sysAd
|
||||
int mailStuffID = 0;
|
||||
packet->Read(mailStuffID);
|
||||
|
||||
std::async(std::launch::async, [packet, &sysAddr, entity, mailStuffID]() {
|
||||
auto returnVal = std::async(std::launch::async, [packet, &sysAddr, entity, mailStuffID]() {
|
||||
Mail::MailMessageID stuffID = MailMessageID(mailStuffID);
|
||||
switch (stuffID) {
|
||||
case MailMessageID::AttachmentCollect:
|
||||
@@ -259,7 +259,7 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd
|
||||
}
|
||||
|
||||
Mail::SendSendResponse(sysAddr, Mail::MailSendResponse::Success);
|
||||
entity->GetCharacter()->SetCoins(entity->GetCharacter()->GetCoins() - mailCost, eLootSourceType::LOOT_SOURCE_MAIL);
|
||||
entity->GetCharacter()->SetCoins(entity->GetCharacter()->GetCoins() - mailCost, eLootSourceType::MAIL);
|
||||
|
||||
Game::logger->Log("Mail", "Seeing if we need to remove item with ID/count/LOT: %i %i %i", itemID, attachmentCount, itemLOT);
|
||||
|
||||
@@ -283,7 +283,7 @@ void Mail::HandleDataRequest(RakNet::BitStream* packet, const SystemAddress& sys
|
||||
sql::ResultSet* res = stmt->executeQuery();
|
||||
|
||||
RakNet::BitStream bitStream;
|
||||
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAIL);
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAIL);
|
||||
bitStream.Write(int(MailMessageID::MailData));
|
||||
bitStream.Write(int(0));
|
||||
|
||||
@@ -359,7 +359,7 @@ void Mail::HandleAttachmentCollect(RakNet::BitStream* packet, const SystemAddres
|
||||
auto inv = static_cast<InventoryComponent*>(player->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
if (!inv) return;
|
||||
|
||||
inv->AddItem(attachmentLOT, attachmentCount, eLootSourceType::LOOT_SOURCE_MAIL);
|
||||
inv->AddItem(attachmentLOT, attachmentCount, eLootSourceType::MAIL);
|
||||
|
||||
Mail::SendAttachmentRemoveConfirm(sysAddr, mailID);
|
||||
|
||||
@@ -393,7 +393,7 @@ void Mail::HandleMailRead(RakNet::BitStream* packet, const SystemAddress& sysAdd
|
||||
}
|
||||
|
||||
void Mail::HandleNotificationRequest(const SystemAddress& sysAddr, uint32_t objectID) {
|
||||
std::async(std::launch::async, [&]() {
|
||||
auto returnVal = std::async(std::launch::async, [&]() {
|
||||
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("SELECT id FROM mail WHERE receiver_id=? AND was_read=0");
|
||||
stmt->setUInt(1, objectID);
|
||||
sql::ResultSet* res = stmt->executeQuery();
|
||||
@@ -406,7 +406,7 @@ void Mail::HandleNotificationRequest(const SystemAddress& sysAddr, uint32_t obje
|
||||
|
||||
void Mail::SendSendResponse(const SystemAddress& sysAddr, MailSendResponse response) {
|
||||
RakNet::BitStream bitStream;
|
||||
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAIL);
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAIL);
|
||||
bitStream.Write(int(MailMessageID::SendResponse));
|
||||
bitStream.Write(int(response));
|
||||
Game::server->Send(&bitStream, sysAddr, false);
|
||||
@@ -414,7 +414,7 @@ void Mail::SendSendResponse(const SystemAddress& sysAddr, MailSendResponse respo
|
||||
|
||||
void Mail::SendNotification(const SystemAddress& sysAddr, int mailCount) {
|
||||
RakNet::BitStream bitStream;
|
||||
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAIL);
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAIL);
|
||||
uint64_t messageType = 2;
|
||||
uint64_t s1 = 0;
|
||||
uint64_t s2 = 0;
|
||||
@@ -433,7 +433,7 @@ void Mail::SendNotification(const SystemAddress& sysAddr, int mailCount) {
|
||||
|
||||
void Mail::SendAttachmentRemoveConfirm(const SystemAddress& sysAddr, uint64_t mailID) {
|
||||
RakNet::BitStream bitStream;
|
||||
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAIL);
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAIL);
|
||||
bitStream.Write(int(MailMessageID::AttachmentCollectConfirm));
|
||||
bitStream.Write(int(0)); //unknown
|
||||
bitStream.Write(mailID);
|
||||
@@ -442,7 +442,7 @@ void Mail::SendAttachmentRemoveConfirm(const SystemAddress& sysAddr, uint64_t ma
|
||||
|
||||
void Mail::SendDeleteConfirm(const SystemAddress& sysAddr, uint64_t mailID, LWOOBJID playerID) {
|
||||
RakNet::BitStream bitStream;
|
||||
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAIL);
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAIL);
|
||||
bitStream.Write(int(MailMessageID::MailDeleteConfirm));
|
||||
bitStream.Write(int(0)); //unknown
|
||||
bitStream.Write(mailID);
|
||||
@@ -456,7 +456,7 @@ void Mail::SendDeleteConfirm(const SystemAddress& sysAddr, uint64_t mailID, LWOO
|
||||
|
||||
void Mail::SendReadConfirm(const SystemAddress& sysAddr, uint64_t mailID) {
|
||||
RakNet::BitStream bitStream;
|
||||
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAIL);
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAIL);
|
||||
bitStream.Write(int(MailMessageID::MailReadConfirm));
|
||||
bitStream.Write(int(0)); //unknown
|
||||
bitStream.Write(mailID);
|
||||
|
||||
@@ -69,58 +69,42 @@
|
||||
#include "BinaryPathFinder.h"
|
||||
#include "dConfig.h"
|
||||
#include "eBubbleType.h"
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
#include "MovingPlatformComponent.h"
|
||||
#include "dMessageIdentifiers.h"
|
||||
#include "eMissionState.h"
|
||||
#include "TriggerComponent.h"
|
||||
#include "eServerDisconnectIdentifiers.h"
|
||||
#include "eObjectBits.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "eControlScheme.h"
|
||||
#include "eConnectionType.h"
|
||||
#include "eChatInternalMessageType.h"
|
||||
#include "eMasterMessageType.h"
|
||||
|
||||
#include "CDObjectsTable.h"
|
||||
#include "CDZoneTableTable.h"
|
||||
|
||||
void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entity* entity, const SystemAddress& sysAddr) {
|
||||
auto commandCopy = command;
|
||||
// Sanity check that a command was given
|
||||
if (command.empty() || command.front() != u'/') return;
|
||||
commandCopy.erase(commandCopy.begin());
|
||||
|
||||
// Split the command by spaces
|
||||
std::string chatCommand;
|
||||
std::vector<std::string> args;
|
||||
auto wideCommand = GeneralUtils::SplitString(commandCopy, u' ');
|
||||
if (wideCommand.empty()) return;
|
||||
|
||||
uint32_t breakIndex = 0;
|
||||
for (uint32_t i = 1; i < command.size(); ++i) {
|
||||
if (command[i] == L' ') {
|
||||
breakIndex = i;
|
||||
break;
|
||||
}
|
||||
// Convert the command to lowercase
|
||||
chatCommand = GeneralUtils::UTF16ToWTF8(wideCommand.front());
|
||||
std::transform(chatCommand.begin(), chatCommand.end(), chatCommand.begin(), ::tolower);
|
||||
wideCommand.erase(wideCommand.begin());
|
||||
|
||||
chatCommand.push_back(static_cast<unsigned char>(command[i]));
|
||||
breakIndex++;
|
||||
}
|
||||
|
||||
uint32_t index = ++breakIndex;
|
||||
while (true) {
|
||||
std::string arg;
|
||||
|
||||
while (index < command.size()) {
|
||||
if (command[index] == L' ') {
|
||||
args.push_back(arg);
|
||||
arg = "";
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
arg.push_back(static_cast<char>(command[index]));
|
||||
index++;
|
||||
}
|
||||
|
||||
if (arg != "") {
|
||||
args.push_back(arg);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//Game::logger->Log("SlashCommandHandler", "Received chat command \"%s\"", GeneralUtils::UTF16ToWTF8(command).c_str());
|
||||
// Convert the arguements to not u16strings
|
||||
for (auto wideArg : wideCommand) args.push_back(GeneralUtils::UTF16ToWTF8(wideArg));
|
||||
|
||||
User* user = UserManager::Instance()->GetUser(sysAddr);
|
||||
if ((chatCommand == "setgmlevel" || chatCommand == "makegm" || chatCommand == "gmlevel") && user->GetMaxGMLevel() > eGameMasterLevel::CIVILIAN) {
|
||||
@@ -174,7 +158,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
#endif
|
||||
|
||||
if (chatCommand == "togglenameplate" && (Game::config->GetValue("allownameplateoff") == "1" || entity->GetGMLevel() > eGameMasterLevel::DEVELOPER)) {
|
||||
if (chatCommand == "togglenameplate" && (Game::config->GetValue("allow_nameplate_off") == "1" || entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER)) {
|
||||
auto* character = entity->GetCharacter();
|
||||
|
||||
if (character && character->GetBillboardVisible()) {
|
||||
@@ -268,26 +252,20 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
{
|
||||
AMFArrayValue args;
|
||||
|
||||
auto* state = new AMFStringValue();
|
||||
state->SetStringValue("Story");
|
||||
args.Insert("state", "Story");
|
||||
|
||||
args.InsertValue("state", state);
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", args);
|
||||
}
|
||||
|
||||
entity->AddCallbackTimer(0.5f, [customText, entity]() {
|
||||
AMFArrayValue args;
|
||||
|
||||
auto* text = new AMFStringValue();
|
||||
text->SetStringValue(customText);
|
||||
|
||||
args.InsertValue("visible", new AMFTrueValue());
|
||||
args.InsertValue("text", text);
|
||||
args.Insert("visible", true);
|
||||
args.Insert("text", customText);
|
||||
|
||||
Game::logger->Log("SlashCommandHandler", "Sending %s", customText.c_str());
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "ToggleStoryBox", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "ToggleStoryBox", args);
|
||||
});
|
||||
|
||||
return;
|
||||
@@ -296,7 +274,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
if (chatCommand == "leave-zone") {
|
||||
const auto currentZone = dZoneManager::Instance()->GetZone()->GetZoneID().GetMapID();
|
||||
|
||||
auto newZone = 0;
|
||||
LWOMAPID newZone = 0;
|
||||
if (currentZone % 100 == 0) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"You are not in an instanced zone.");
|
||||
return;
|
||||
@@ -304,7 +282,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
newZone = (currentZone / 100) * 100;
|
||||
}
|
||||
// If new zone would be inaccessible, then default to Avant Gardens.
|
||||
if (!CheckIfAccessibleZone(newZone)) newZone = 1100;
|
||||
if (!dZoneManager::Instance()->CheckIfAccessibleZone(newZone)) newZone = 1100;
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Leaving zone...");
|
||||
|
||||
@@ -517,7 +495,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
const auto state = !entity->GetVar<bool>(u"freecam");
|
||||
entity->SetVar<bool>(u"freecam", state);
|
||||
|
||||
GameMessages::SendSetPlayerControlScheme(entity, static_cast<eControlSceme>(state ? 9 : 1));
|
||||
GameMessages::SendSetPlayerControlScheme(entity, static_cast<eControlScheme>(state ? 9 : 1));
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Toggled freecam.");
|
||||
return;
|
||||
@@ -531,7 +509,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
return;
|
||||
}
|
||||
|
||||
GameMessages::SendSetPlayerControlScheme(entity, static_cast<eControlSceme>(scheme));
|
||||
GameMessages::SendSetPlayerControlScheme(entity, static_cast<eControlScheme>(scheme));
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Switched control scheme.");
|
||||
return;
|
||||
@@ -547,12 +525,11 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
|
||||
if (chatCommand == "setuistate" && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
AMFStringValue* value = new AMFStringValue();
|
||||
value->SetStringValue(args[0]);
|
||||
AMFArrayValue uiState;
|
||||
|
||||
AMFArrayValue args;
|
||||
args.InsertValue("state", value);
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, "pushGameState", &args);
|
||||
uiState.Insert("state", args.at(0));
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, "pushGameState", uiState);
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Switched UI state.");
|
||||
|
||||
@@ -560,11 +537,11 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
|
||||
if (chatCommand == "toggle" && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
AMFTrueValue* value = new AMFTrueValue();
|
||||
|
||||
AMFArrayValue amfArgs;
|
||||
amfArgs.InsertValue("visible", value);
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, args[0], &amfArgs);
|
||||
|
||||
amfArgs.Insert("visible", true);
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, args[0], amfArgs);
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Toggled UI state.");
|
||||
|
||||
@@ -673,7 +650,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
|
||||
if (chatCommand == "setflag" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 1) {
|
||||
uint32_t flagId;
|
||||
int32_t flagId;
|
||||
|
||||
if (!GeneralUtils::TryParse(args[0], flagId)) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag id.");
|
||||
@@ -684,7 +661,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
|
||||
if (chatCommand == "setflag" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 2) {
|
||||
uint32_t flagId;
|
||||
int32_t flagId;
|
||||
std::string onOffFlag = args[0];
|
||||
if (!GeneralUtils::TryParse(args[1], flagId)) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag id.");
|
||||
@@ -697,7 +674,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
entity->GetCharacter()->SetPlayerFlag(flagId, onOffFlag == "on");
|
||||
}
|
||||
if (chatCommand == "clearflag" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 1) {
|
||||
uint32_t flagId;
|
||||
int32_t flagId;
|
||||
|
||||
if (!GeneralUtils::TryParse(args[0], flagId)) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag id.");
|
||||
@@ -784,7 +761,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
if (chatCommand == "shutdownuniverse" && entity->GetGMLevel() == eGameMasterLevel::OPERATOR) {
|
||||
//Tell the master server that we're going to be shutting down whole "universe":
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_SHUTDOWN_UNIVERSE);
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SHUTDOWN_UNIVERSE);
|
||||
Game::server->SendToMaster(&bitStream);
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Sent universe shutdown notification to master.");
|
||||
|
||||
@@ -813,7 +790,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
InventoryComponent* inventory = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
|
||||
inventory->AddItem(itemLOT, 1, eLootSourceType::LOOT_SOURCE_MODERATION);
|
||||
inventory->AddItem(itemLOT, 1, eLootSourceType::MODERATION);
|
||||
} else if (args.size() == 2) {
|
||||
uint32_t itemLOT;
|
||||
|
||||
@@ -831,7 +808,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
InventoryComponent* inventory = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
|
||||
inventory->AddItem(itemLOT, count, eLootSourceType::LOOT_SOURCE_MODERATION);
|
||||
inventory->AddItem(itemLOT, count, eLootSourceType::MODERATION);
|
||||
} else {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /gmadditem <lot>");
|
||||
}
|
||||
@@ -1050,8 +1027,8 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
accountId = result->getUInt(1);
|
||||
characterId = result->getUInt64(2);
|
||||
|
||||
characterId = GeneralUtils::SetBit(characterId, OBJECT_BIT_CHARACTER);
|
||||
characterId = GeneralUtils::SetBit(characterId, OBJECT_BIT_PERSISTENT);
|
||||
GeneralUtils::SetBit(characterId, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(characterId, eObjectBits::PERSISTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1115,7 +1092,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
//Notify chat about it
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_MUTE_UPDATE);
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::MUTE_UPDATE);
|
||||
|
||||
bitStream.Write(characterId);
|
||||
bitStream.Write(expire);
|
||||
@@ -1366,9 +1343,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
CharacterComponent* character = entity->GetComponent<CharacterComponent>();
|
||||
if (character) character->SetUScore(character->GetUScore() + uscore);
|
||||
// LOOT_SOURCE_MODERATION should work but it doesn't. Relog to see uscore changes
|
||||
// MODERATION should work but it doesn't. Relog to see uscore changes
|
||||
|
||||
eLootSourceType lootType = eLootSourceType::LOOT_SOURCE_MODERATION;
|
||||
eLootSourceType lootType = eLootSourceType::MODERATION;
|
||||
|
||||
int32_t type;
|
||||
if (args.size() >= 2 && GeneralUtils::TryParse(args[1], type)) {
|
||||
@@ -1486,7 +1463,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
|
||||
auto* ch = entity->GetCharacter();
|
||||
ch->SetCoins(ch->GetCoins() + money, eLootSourceType::LOOT_SOURCE_MODERATION);
|
||||
ch->SetCoins(ch->GetCoins() + money, eLootSourceType::MODERATION);
|
||||
}
|
||||
|
||||
if ((chatCommand == "setcurrency") && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
@@ -1498,7 +1475,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
|
||||
auto* ch = entity->GetCharacter();
|
||||
ch->SetCoins(money, eLootSourceType::LOOT_SOURCE_MODERATION);
|
||||
ch->SetCoins(money, eLootSourceType::MODERATION);
|
||||
}
|
||||
|
||||
// Allow for this on even while not a GM, as it sometimes toggles incorrrectly.
|
||||
@@ -1576,7 +1553,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
const auto objid = entity->GetObjectID();
|
||||
|
||||
if (force || CheckIfAccessibleZone(reqZone)) { // to prevent tomfoolery
|
||||
if (force || dZoneManager::Instance()->CheckIfAccessibleZone(reqZone)) { // to prevent tomfoolery
|
||||
|
||||
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, reqZone, cloneId, false, [objid](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
|
||||
|
||||
@@ -1634,7 +1611,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
if ((chatCommand == "debugui") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Opening UIDebugger...");
|
||||
AMFArrayValue args;
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, "ToggleUIDebugger;", nullptr);
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, "ToggleUIDebugger;", args);
|
||||
}
|
||||
|
||||
if ((chatCommand == "boost") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
@@ -1747,7 +1724,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
std::vector<LDFBaseData*> data{};
|
||||
data.push_back(new LDFData<int32_t>(u"reforgedLOT", reforgedItem));
|
||||
|
||||
inventoryComponent->AddItem(baseItem, 1, eLootSourceType::LOOT_SOURCE_MODERATION, eInventoryType::INVALID, data);
|
||||
inventoryComponent->AddItem(baseItem, 1, eLootSourceType::MODERATION, eInventoryType::INVALID, data);
|
||||
}
|
||||
|
||||
if (chatCommand == "crash" && entity->GetGMLevel() >= eGameMasterLevel::OPERATOR) {
|
||||
@@ -2038,32 +2015,17 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
}
|
||||
|
||||
bool SlashCommandHandler::CheckIfAccessibleZone(const unsigned int zoneID) {
|
||||
//We're gonna go ahead and presume we've got the db loaded already:
|
||||
CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable<CDZoneTableTable>();
|
||||
const CDZoneTable* zone = zoneTable->Query(zoneID);
|
||||
if (zone != nullptr) {
|
||||
return Game::assetManager->HasFile(("maps/" + zone->zoneName).c_str());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void SlashCommandHandler::SendAnnouncement(const std::string& title, const std::string& message) {
|
||||
AMFArrayValue args;
|
||||
auto* titleValue = new AMFStringValue();
|
||||
titleValue->SetStringValue(title);
|
||||
auto* messageValue = new AMFStringValue();
|
||||
messageValue->SetStringValue(message);
|
||||
|
||||
args.InsertValue("title", titleValue);
|
||||
args.InsertValue("message", messageValue);
|
||||
args.Insert("title", title);
|
||||
args.Insert("message", message);
|
||||
|
||||
GameMessages::SendUIMessageServerToAllClients("ToggleAnnounce", &args);
|
||||
GameMessages::SendUIMessageServerToAllClients("ToggleAnnounce", args);
|
||||
|
||||
//Notify chat about it
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ANNOUNCEMENT);
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ANNOUNCEMENT);
|
||||
|
||||
bitStream.Write<uint32_t>(title.size());
|
||||
for (auto character : title) {
|
||||
|
||||
@@ -13,8 +13,6 @@ class Entity;
|
||||
|
||||
namespace SlashCommandHandler {
|
||||
void HandleChatCommand(const std::u16string& command, Entity* entity, const SystemAddress& sysAddr);
|
||||
bool CheckIfAccessibleZone(const unsigned int zoneID);
|
||||
|
||||
void SendAnnouncement(const std::string& title, const std::string& message);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user