mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-06 10:44:08 +00:00
Move to shared pointer
This commit is contained in:
@@ -110,7 +110,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
player->ConstructLimboEntities();
|
||||
}
|
||||
|
||||
InventoryComponent* inv = entity->GetComponent<InventoryComponent>();
|
||||
auto inv = entity->GetComponent<InventoryComponent>();
|
||||
if (inv) {
|
||||
auto items = inv->GetEquippedItems();
|
||||
for (auto pair : items) {
|
||||
@@ -120,13 +120,13 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
}
|
||||
}
|
||||
|
||||
auto* destroyable = entity->GetComponent<DestroyableComponent>();
|
||||
auto destroyable = entity->GetComponent<DestroyableComponent>();
|
||||
destroyable->SetImagination(destroyable->GetImagination());
|
||||
EntityManager::Instance()->SerializeEntity(entity);
|
||||
|
||||
std::vector<Entity*> racingControllers = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL);
|
||||
for (Entity* racingController : racingControllers) {
|
||||
auto* racingComponent = racingController->GetComponent<RacingControlComponent>();
|
||||
auto racingComponent = racingController->GetComponent<RacingControlComponent>();
|
||||
if (racingComponent != nullptr) {
|
||||
racingComponent->OnPlayerLoaded(entity);
|
||||
}
|
||||
@@ -243,13 +243,6 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
|
||||
case eGameMessageType::REQUEST_RESURRECT: {
|
||||
GameMessages::SendResurrect(entity);
|
||||
/*auto* dest = static_cast<DestroyableComponent*>(entity->GetComponent(eReplicaComponentType::DESTROYABLE));
|
||||
if (dest) {
|
||||
dest->SetHealth(4);
|
||||
dest->SetArmor(0);
|
||||
dest->SetImagination(6);
|
||||
EntityManager::Instance()->SerializeEntity(entity);
|
||||
}*/
|
||||
break;
|
||||
}
|
||||
case eGameMessageType::HANDLE_HOT_PROPERTY_DATA: {
|
||||
@@ -263,7 +256,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
|
||||
message.Deserialize(inStream);
|
||||
|
||||
auto* skill_component = entity->GetComponent<SkillComponent>();
|
||||
auto skill_component = entity->GetComponent<SkillComponent>();
|
||||
|
||||
if (skill_component != nullptr) {
|
||||
auto* bs = new RakNet::BitStream((unsigned char*)message.sBitStream.c_str(), message.sBitStream.size(), false);
|
||||
@@ -282,7 +275,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
|
||||
if (startSkill.skillID == 1561 || startSkill.skillID == 1562 || startSkill.skillID == 1541) return;
|
||||
|
||||
MissionComponent* comp = entity->GetComponent<MissionComponent>();
|
||||
auto comp = entity->GetComponent<MissionComponent>();
|
||||
if (comp) {
|
||||
comp->Progress(eMissionTaskType::USE_SKILL, startSkill.skillID);
|
||||
}
|
||||
@@ -295,12 +288,12 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
if (behaviorId > 0) {
|
||||
RakNet::BitStream* bs = new RakNet::BitStream((unsigned char*)startSkill.sBitStream.c_str(), startSkill.sBitStream.size(), false);
|
||||
|
||||
auto* skillComponent = entity->GetComponent<SkillComponent>();
|
||||
auto skillComponent = entity->GetComponent<SkillComponent>();
|
||||
|
||||
success = skillComponent->CastPlayerSkill(behaviorId, startSkill.uiSkillHandle, bs, startSkill.optionalTargetID, startSkill.skillID);
|
||||
|
||||
if (success && entity->GetCharacter()) {
|
||||
DestroyableComponent* destComp = entity->GetComponent<DestroyableComponent>();
|
||||
auto destComp = entity->GetComponent<DestroyableComponent>();
|
||||
destComp->SetImagination(destComp->GetImagination() - skillTable->GetSkillByID(startSkill.skillID).imaginationcost);
|
||||
}
|
||||
|
||||
@@ -357,7 +350,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
if (usr != nullptr) {
|
||||
RakNet::BitStream* bs = new RakNet::BitStream((unsigned char*)sync.sBitStream.c_str(), sync.sBitStream.size(), false);
|
||||
|
||||
auto* skillComponent = entity->GetComponent<SkillComponent>();
|
||||
auto skillComponent = entity->GetComponent<SkillComponent>();
|
||||
|
||||
skillComponent->SyncPlayerSkill(sync.uiSkillHandle, sync.uiBehaviorHandle, bs);
|
||||
|
||||
|
@@ -935,10 +935,10 @@ void GameMessages::SendResurrect(Entity* entity) {
|
||||
// and just make sure the client has time to be ready.
|
||||
constexpr float respawnTime = 3.66700005531311f + 0.5f;
|
||||
entity->AddCallbackTimer(respawnTime, [=]() {
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
auto destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent != nullptr && entity->GetLOT() == 1) {
|
||||
auto* levelComponent = entity->GetComponent<LevelProgressionComponent>();
|
||||
auto levelComponent = entity->GetComponent<LevelProgressionComponent>();
|
||||
if (levelComponent) {
|
||||
int32_t healthToRestore = levelComponent->GetLevel() >= 45 ? 8 : 4;
|
||||
if (healthToRestore > destroyableComponent->GetMaxHealth()) healthToRestore = destroyableComponent->GetMaxHealth();
|
||||
@@ -952,7 +952,7 @@ void GameMessages::SendResurrect(Entity* entity) {
|
||||
});
|
||||
|
||||
|
||||
auto cont = static_cast<ControllablePhysicsComponent*>(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS));
|
||||
auto cont = entity->GetComponent<ControllablePhysicsComponent>();
|
||||
if (cont && entity->GetLOT() == 1) {
|
||||
cont->SetPosition(entity->GetRespawnPosition());
|
||||
cont->SetRotation(entity->GetRespawnRotation());
|
||||
@@ -1149,7 +1149,7 @@ void GameMessages::SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPo
|
||||
bitStream.Write(position.y);
|
||||
bitStream.Write(position.z);
|
||||
|
||||
auto con = static_cast<ControllablePhysicsComponent*>(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS));
|
||||
auto con = entity->GetComponent<ControllablePhysicsComponent>();
|
||||
if (con) {
|
||||
auto rot = con->GetRotation();
|
||||
bitStream.Write(rot.x);
|
||||
@@ -1284,7 +1284,7 @@ void GameMessages::SendVendorStatusUpdate(Entity* entity, const SystemAddress& s
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
|
||||
VendorComponent* vendor = static_cast<VendorComponent*>(entity->GetComponent(eReplicaComponentType::VENDOR));
|
||||
auto vendor = entity->GetComponent<VendorComponent>();
|
||||
if (!vendor) return;
|
||||
|
||||
std::map<LOT, int> vendorItems = vendor->GetInventory();
|
||||
@@ -1406,7 +1406,7 @@ void GameMessages::SendMoveInventoryBatch(Entity* entity, uint32_t stackCount, i
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = entity->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
|
||||
Item* itemStack = inv->FindItemById(iObjID);
|
||||
@@ -2182,7 +2182,7 @@ void GameMessages::HandleUnUseModel(RakNet::BitStream* inStream, Entity* entity,
|
||||
LWOOBJID objIdToAddToInventory{};
|
||||
inStream->Read(unknown);
|
||||
inStream->Read(objIdToAddToInventory);
|
||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
auto inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
if (inventoryComponent) {
|
||||
auto* inventory = inventoryComponent->GetInventory(eInventoryType::MODELS_IN_BBB);
|
||||
auto* item = inventory->FindItemById(objIdToAddToInventory);
|
||||
@@ -2244,7 +2244,7 @@ void GameMessages::HandleQueryPropertyData(RakNet::BitStream* inStream, Entity*
|
||||
entity = entites[0];
|
||||
*/
|
||||
|
||||
auto* propertyVendorComponent = static_cast<PropertyVendorComponent*>(entity->GetComponent(eReplicaComponentType::PROPERTY_VENDOR));
|
||||
auto propertyVendorComponent = entity->GetComponent<PropertyVendorComponent>();
|
||||
|
||||
if (propertyVendorComponent != nullptr) {
|
||||
propertyVendorComponent->OnQueryPropertyData(entity, sysAddr);
|
||||
@@ -2256,7 +2256,7 @@ void GameMessages::HandleQueryPropertyData(RakNet::BitStream* inStream, Entity*
|
||||
entity = entites[0];
|
||||
*/
|
||||
|
||||
auto* propertyManagerComponent = static_cast<PropertyManagementComponent*>(entity->GetComponent(eReplicaComponentType::PROPERTY_MANAGEMENT));
|
||||
auto propertyManagerComponent = entity->GetComponent<PropertyManagementComponent>();
|
||||
|
||||
if (propertyManagerComponent != nullptr) {
|
||||
propertyManagerComponent->OnQueryPropertyData(entity, sysAddr);
|
||||
@@ -2422,7 +2422,7 @@ void GameMessages::HandleBBBLoadItemRequest(RakNet::BitStream* inStream, Entity*
|
||||
|
||||
Game::logger->Log("BBB", "Load item request for: %lld", previousItemID);
|
||||
LWOOBJID newId = previousItemID;
|
||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
auto inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
if (inventoryComponent) {
|
||||
auto* inventory = inventoryComponent->GetInventory(eInventoryType::MODELS);
|
||||
auto* itemToMove = inventory->FindItemById(previousItemID);
|
||||
@@ -2776,7 +2776,7 @@ void GameMessages::HandlePropertyEntranceSync(RakNet::BitStream* inStream, Entit
|
||||
|
||||
auto* player = Player::GetPlayer(sysAddr);
|
||||
|
||||
auto* entranceComponent = entity->GetComponent<PropertyEntranceComponent>();
|
||||
auto entranceComponent = entity->GetComponent<PropertyEntranceComponent>();
|
||||
|
||||
if (entranceComponent == nullptr) return;
|
||||
|
||||
@@ -2803,7 +2803,7 @@ void GameMessages::HandleEnterProperty(RakNet::BitStream* inStream, Entity* enti
|
||||
|
||||
auto* player = Player::GetPlayer(sysAddr);
|
||||
|
||||
auto* entranceComponent = entity->GetComponent<PropertyEntranceComponent>();
|
||||
auto entranceComponent = entity->GetComponent<PropertyEntranceComponent>();
|
||||
if (entranceComponent != nullptr) {
|
||||
entranceComponent->OnEnterProperty(player, index, returnToZone, sysAddr);
|
||||
return;
|
||||
@@ -2820,7 +2820,7 @@ void GameMessages::HandleSetConsumableItem(RakNet::BitStream* inStream, Entity*
|
||||
|
||||
inStream->Read(lot);
|
||||
|
||||
auto* inventory = entity->GetComponent<InventoryComponent>();
|
||||
auto inventory = entity->GetComponent<InventoryComponent>();
|
||||
|
||||
if (inventory == nullptr) return;
|
||||
|
||||
@@ -3719,7 +3719,7 @@ void GameMessages::SendPetNameChanged(LWOOBJID objectId, int32_t moderationStatu
|
||||
void GameMessages::HandleClientExitTamingMinigame(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||
bool bVoluntaryExit = inStream->ReadBit();
|
||||
|
||||
auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
|
||||
auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
|
||||
|
||||
if (petComponent == nullptr) {
|
||||
return;
|
||||
@@ -3729,7 +3729,7 @@ void GameMessages::HandleClientExitTamingMinigame(RakNet::BitStream* inStream, E
|
||||
}
|
||||
|
||||
void GameMessages::HandleStartServerPetMinigameTimer(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||
auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
|
||||
auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
|
||||
|
||||
if (petComponent == nullptr) {
|
||||
return;
|
||||
@@ -3757,7 +3757,7 @@ void GameMessages::HandlePetTamingTryBuild(RakNet::BitStream* inStream, Entity*
|
||||
|
||||
clientFailed = inStream->ReadBit();
|
||||
|
||||
auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
|
||||
auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
|
||||
|
||||
if (petComponent == nullptr) {
|
||||
return;
|
||||
@@ -3771,7 +3771,7 @@ void GameMessages::HandleNotifyTamingBuildSuccess(RakNet::BitStream* inStream, E
|
||||
|
||||
inStream->Read(position);
|
||||
|
||||
auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
|
||||
auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
|
||||
|
||||
if (petComponent == nullptr) {
|
||||
return;
|
||||
@@ -3792,7 +3792,7 @@ void GameMessages::HandleRequestSetPetName(RakNet::BitStream* inStream, Entity*
|
||||
name.push_back(character);
|
||||
}
|
||||
|
||||
auto* petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
|
||||
auto petComponent = PetComponent::GetTamingPet(entity->GetObjectID());
|
||||
|
||||
if (petComponent == nullptr) {
|
||||
petComponent = PetComponent::GetActivePet(entity->GetObjectID());
|
||||
@@ -3818,7 +3818,7 @@ void GameMessages::HandleCommandPet(RakNet::BitStream* inStream, Entity* entity,
|
||||
inStream->Read(iTypeID);
|
||||
overrideObey = inStream->ReadBit();
|
||||
|
||||
auto* petComponent = entity->GetComponent<PetComponent>();
|
||||
auto petComponent = entity->GetComponent<PetComponent>();
|
||||
|
||||
if (petComponent == nullptr) {
|
||||
return;
|
||||
@@ -3832,7 +3832,7 @@ void GameMessages::HandleDespawnPet(RakNet::BitStream* inStream, Entity* entity,
|
||||
|
||||
bDeletePet = inStream->ReadBit();
|
||||
|
||||
auto* petComponent = PetComponent::GetActivePet(entity->GetObjectID());
|
||||
auto petComponent = PetComponent::GetActivePet(entity->GetObjectID());
|
||||
|
||||
if (petComponent == nullptr) {
|
||||
return;
|
||||
@@ -3884,13 +3884,13 @@ void GameMessages::HandleMessageBoxResponse(RakNet::BitStream* inStream, Entity*
|
||||
|
||||
entity->OnMessageBoxResponse(userEntity, iButton, identifier, userData);
|
||||
|
||||
auto* scriptedActivityComponent = entity->GetComponent<ScriptedActivityComponent>();
|
||||
auto scriptedActivityComponent = entity->GetComponent<ScriptedActivityComponent>();
|
||||
|
||||
if (scriptedActivityComponent != nullptr) {
|
||||
scriptedActivityComponent->HandleMessageBoxResponse(userEntity, GeneralUtils::UTF16ToWTF8(identifier));
|
||||
}
|
||||
|
||||
auto* racingControlComponent = entity->GetComponent<RacingControlComponent>();
|
||||
auto racingControlComponent = entity->GetComponent<RacingControlComponent>();
|
||||
|
||||
if (racingControlComponent != nullptr) {
|
||||
racingControlComponent->HandleMessageBoxResponse(userEntity, iButton, GeneralUtils::UTF16ToWTF8(identifier));
|
||||
@@ -4056,7 +4056,7 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e
|
||||
|
||||
// If we aren't possessing somethings, the don't do anything
|
||||
if (objectId != LWOOBJID_EMPTY) {
|
||||
auto* possessorComponent = entity->GetComponent<PossessorComponent>();
|
||||
auto possessorComponent = entity->GetComponent<PossessorComponent>();
|
||||
auto* mount = EntityManager::Instance()->GetEntity(objectId);
|
||||
// make sure we have the things we need and they aren't null
|
||||
if (possessorComponent && mount) {
|
||||
@@ -4066,7 +4066,7 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e
|
||||
possessorComponent->SetPossessableType(ePossessionType::NO_POSSESSION);
|
||||
|
||||
// character related things
|
||||
auto* character = entity->GetComponent<CharacterComponent>();
|
||||
auto character = entity->GetComponent<CharacterComponent>();
|
||||
if (character) {
|
||||
// If we had an active item turn it off
|
||||
if (possessorComponent->GetMountItemID() != LWOOBJID_EMPTY) GameMessages::SendMarkInventoryItemAsActive(entity->GetObjectID(), false, eUnequippableActiveType::MOUNT, possessorComponent->GetMountItemID(), entity->GetSystemAddress());
|
||||
@@ -4074,11 +4074,11 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e
|
||||
}
|
||||
|
||||
// Set that the controllabel phsyics comp is teleporting
|
||||
auto* controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
|
||||
auto controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
|
||||
if (controllablePhysicsComponent) controllablePhysicsComponent->SetIsTeleporting(true);
|
||||
|
||||
// Call dismoint on the possessable comp to let it handle killing the possessable
|
||||
auto* possessableComponent = mount->GetComponent<PossessableComponent>();
|
||||
auto possessableComponent = mount->GetComponent<PossessableComponent>();
|
||||
if (possessableComponent) possessableComponent->Dismount();
|
||||
|
||||
// Update the entity that was possessing
|
||||
@@ -4102,7 +4102,7 @@ void GameMessages::HandleAcknowledgePossession(RakNet::BitStream* inStream, Enti
|
||||
//Racing
|
||||
|
||||
void GameMessages::HandleModuleAssemblyQueryData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||
auto* moduleAssemblyComponent = entity->GetComponent<ModuleAssemblyComponent>();
|
||||
auto moduleAssemblyComponent = entity->GetComponent<ModuleAssemblyComponent>();
|
||||
|
||||
Game::logger->Log("HandleModuleAssemblyQueryData", "Got Query from %i", entity->GetLOT());
|
||||
|
||||
@@ -4138,7 +4138,7 @@ void GameMessages::HandleRacingClientReady(RakNet::BitStream* inStream, Entity*
|
||||
return;
|
||||
}
|
||||
|
||||
auto* racingControlComponent = dZoneManager::Instance()->GetZoneControlObject()->GetComponent<RacingControlComponent>();
|
||||
auto racingControlComponent = dZoneManager::Instance()->GetZoneControlObject()->GetComponent<RacingControlComponent>();
|
||||
|
||||
if (racingControlComponent == nullptr) {
|
||||
return;
|
||||
@@ -4188,12 +4188,12 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity,
|
||||
|
||||
auto* zoneController = dZoneManager::Instance()->GetZoneControlObject();
|
||||
|
||||
auto* racingControlComponent = zoneController->GetComponent<RacingControlComponent>();
|
||||
auto racingControlComponent = zoneController->GetComponent<RacingControlComponent>();
|
||||
|
||||
Game::logger->Log("HandleRequestDie", "Got die request: %i", entity->GetLOT());
|
||||
|
||||
if (racingControlComponent != nullptr) {
|
||||
auto* possessableComponent = entity->GetComponent<PossessableComponent>();
|
||||
auto possessableComponent = entity->GetComponent<PossessableComponent>();
|
||||
|
||||
if (possessableComponent != nullptr) {
|
||||
entity = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
|
||||
@@ -4231,7 +4231,7 @@ void GameMessages::HandleRacingPlayerInfoResetFinished(RakNet::BitStream* inStre
|
||||
|
||||
auto* zoneController = dZoneManager::Instance()->GetZoneControlObject();
|
||||
|
||||
auto* racingControlComponent = zoneController->GetComponent<RacingControlComponent>();
|
||||
auto racingControlComponent = zoneController->GetComponent<RacingControlComponent>();
|
||||
|
||||
Game::logger->Log("HandleRacingPlayerInfoResetFinished", "Got finished: %i", entity->GetLOT());
|
||||
|
||||
@@ -4293,7 +4293,7 @@ void GameMessages::HandleVehicleNotifyHitImaginationServer(RakNet::BitStream* in
|
||||
return;
|
||||
}
|
||||
|
||||
auto* possessableComponent = entity->GetComponent<PossessableComponent>();
|
||||
auto possessableComponent = entity->GetComponent<PossessableComponent>();
|
||||
|
||||
if (possessableComponent != nullptr) {
|
||||
entity = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
|
||||
@@ -4303,7 +4303,7 @@ void GameMessages::HandleVehicleNotifyHitImaginationServer(RakNet::BitStream* in
|
||||
}
|
||||
}
|
||||
|
||||
auto* characterComponent = entity->GetComponent<CharacterComponent>();
|
||||
auto characterComponent = entity->GetComponent<CharacterComponent>();
|
||||
if (characterComponent != nullptr) {
|
||||
characterComponent->UpdatePlayerStatistic(RacingImaginationPowerUpsCollected);
|
||||
}
|
||||
@@ -4630,7 +4630,7 @@ void GameMessages::HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream*
|
||||
return;
|
||||
}
|
||||
|
||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
auto inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
|
||||
if (inventoryComponent != nullptr) {
|
||||
if (itemID != LWOOBJID_EMPTY) {
|
||||
@@ -4639,7 +4639,7 @@ void GameMessages::HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream*
|
||||
if (!item) return;
|
||||
|
||||
// Despawn the pet if we are moving that pet to the vault.
|
||||
auto* petComponent = PetComponent::GetActivePet(entity->GetObjectID());
|
||||
auto petComponent = PetComponent::GetActivePet(entity->GetObjectID());
|
||||
if (petComponent && petComponent->GetDatabaseId() == item->GetSubKey()) {
|
||||
inventoryComponent->DespawnPet();
|
||||
}
|
||||
@@ -4723,7 +4723,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti
|
||||
Entity* player = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
|
||||
if (!player) return;
|
||||
|
||||
auto* propertyVendorComponent = static_cast<PropertyVendorComponent*>(entity->GetComponent(eReplicaComponentType::PROPERTY_VENDOR));
|
||||
auto propertyVendorComponent = entity->GetComponent<PropertyVendorComponent>();
|
||||
|
||||
if (propertyVendorComponent != nullptr) {
|
||||
propertyVendorComponent->OnBuyFromVendor(player, bConfirmed, item, count);
|
||||
@@ -4733,10 +4733,10 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti
|
||||
|
||||
const auto isCommendationVendor = entity->GetLOT() == 13806;
|
||||
|
||||
auto* vend = entity->GetComponent<VendorComponent>();
|
||||
auto vend = entity->GetComponent<VendorComponent>();
|
||||
if (!vend && !isCommendationVendor) return;
|
||||
|
||||
auto* inv = player->GetComponent<InventoryComponent>();
|
||||
auto inv = player->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
|
||||
if (!isCommendationVendor && !vend->SellsItem(item)) {
|
||||
@@ -4764,7 +4764,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti
|
||||
return;
|
||||
}
|
||||
|
||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||
auto missionComponent = player->GetComponent<MissionComponent>();
|
||||
|
||||
if (missionComponent == nullptr) {
|
||||
return;
|
||||
@@ -4827,10 +4827,10 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit
|
||||
if (!player) return;
|
||||
Character* character = player->GetCharacter();
|
||||
if (!character) return;
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(player->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = player->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
|
||||
VendorComponent* vend = static_cast<VendorComponent*>(entity->GetComponent(eReplicaComponentType::VENDOR));
|
||||
auto vend = entity->GetComponent<VendorComponent>();
|
||||
if (!vend) return;
|
||||
|
||||
Item* item = inv->FindItemById(iObjID);
|
||||
@@ -4877,10 +4877,10 @@ void GameMessages::HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity*
|
||||
if (!player) return;
|
||||
Character* character = player->GetCharacter();
|
||||
if (!character) return;
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(player->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = player->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
|
||||
VendorComponent* vend = static_cast<VendorComponent*>(entity->GetComponent(eReplicaComponentType::VENDOR));
|
||||
auto vend = entity->GetComponent<VendorComponent>();
|
||||
if (!vend) return;
|
||||
|
||||
Item* item = inv->FindItemById(iObjID);
|
||||
@@ -4974,7 +4974,7 @@ void GameMessages::HandleFireEventServerSide(RakNet::BitStream* inStream, Entity
|
||||
LWOCLONEID cloneId = 0;
|
||||
LWOMAPID mapId = 0;
|
||||
|
||||
auto* rocketPad = entity->GetComponent<RocketLaunchpadControlComponent>();
|
||||
auto rocketPad = entity->GetComponent<RocketLaunchpadControlComponent>();
|
||||
|
||||
if (rocketPad == nullptr) return;
|
||||
|
||||
@@ -5031,7 +5031,7 @@ void GameMessages::HandleRebuildCancel(RakNet::BitStream* inStream, Entity* enti
|
||||
inStream->Read(bEarlyRelease);
|
||||
inStream->Read(userID);
|
||||
|
||||
RebuildComponent* rebComp = static_cast<RebuildComponent*>(entity->GetComponent(eReplicaComponentType::QUICK_BUILD));
|
||||
auto rebComp = entity->GetComponent<RebuildComponent>();
|
||||
if (!rebComp) return;
|
||||
|
||||
rebComp->CancelRebuild(EntityManager::Instance()->GetEntity(userID), eQuickBuildFailReason::CANCELED_EARLY);
|
||||
@@ -5064,7 +5064,7 @@ void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity,
|
||||
|
||||
if (bIsMultiInteractUse) {
|
||||
if (multiInteractType == 0) {
|
||||
auto* missionOfferComponent = static_cast<MissionOfferComponent*>(interactedObject->GetComponent(eReplicaComponentType::MISSION_OFFER));
|
||||
auto missionOfferComponent = interactedObject->GetComponent<MissionOfferComponent>();
|
||||
|
||||
if (missionOfferComponent != nullptr) {
|
||||
missionOfferComponent->OfferMissions(entity, multiInteractID);
|
||||
@@ -5077,7 +5077,7 @@ void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity,
|
||||
}
|
||||
|
||||
//Perform use task if possible:
|
||||
auto missionComponent = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION));
|
||||
auto missionComponent = entity->GetComponent<MissionComponent>();
|
||||
|
||||
if (missionComponent == nullptr) return;
|
||||
|
||||
@@ -5099,7 +5099,7 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity)
|
||||
if (emoteID == 0) return;
|
||||
std::string sAnimationName = "deaded"; //Default name in case we fail to get the emote
|
||||
|
||||
MissionComponent* missionComponent = entity->GetComponent<MissionComponent>();
|
||||
auto missionComponent = entity->GetComponent<MissionComponent>();
|
||||
if (!missionComponent) return;
|
||||
|
||||
if (targetID != LWOOBJID_EMPTY) {
|
||||
@@ -5143,7 +5143,7 @@ void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, E
|
||||
if (!user) return;
|
||||
Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
|
||||
if (!character) return;
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = character->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
|
||||
auto* item = inv->FindItemById(modelID);
|
||||
@@ -5186,7 +5186,7 @@ void GameMessages::HandleRespondToMission(RakNet::BitStream* inStream, Entity* e
|
||||
inStream->Read(isDefaultReward);
|
||||
if (isDefaultReward) inStream->Read(reward);
|
||||
|
||||
MissionComponent* missionComponent = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION));
|
||||
auto missionComponent = entity->GetComponent<MissionComponent>();
|
||||
if (!missionComponent) {
|
||||
Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle RespondToMission", playerID);
|
||||
return;
|
||||
@@ -5229,7 +5229,7 @@ void GameMessages::HandleMissionDialogOK(RakNet::BitStream* inStream, Entity* en
|
||||
}
|
||||
|
||||
// Get the player's mission component
|
||||
MissionComponent* missionComponent = static_cast<MissionComponent*>(player->GetComponent(eReplicaComponentType::MISSION));
|
||||
auto missionComponent = player->GetComponent<MissionComponent>();
|
||||
if (!missionComponent) {
|
||||
Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle MissionDialogueOK", player->GetObjectID());
|
||||
return;
|
||||
@@ -5253,7 +5253,7 @@ void GameMessages::HandleRequestLinkedMission(RakNet::BitStream* inStream, Entit
|
||||
|
||||
auto* player = EntityManager::Instance()->GetEntity(playerId);
|
||||
|
||||
auto* missionOfferComponent = static_cast<MissionOfferComponent*>(entity->GetComponent(eReplicaComponentType::MISSION_OFFER));
|
||||
auto missionOfferComponent = entity->GetComponent<MissionOfferComponent>();
|
||||
|
||||
if (missionOfferComponent != nullptr) {
|
||||
missionOfferComponent->OfferMissions(player, 0);
|
||||
@@ -5267,16 +5267,16 @@ void GameMessages::HandleHasBeenCollected(RakNet::BitStream* inStream, Entity* e
|
||||
Entity* player = EntityManager::Instance()->GetEntity(playerID);
|
||||
if (!player || !entity || entity->GetCollectibleID() == 0) return;
|
||||
|
||||
MissionComponent* missionComponent = static_cast<MissionComponent*>(player->GetComponent(eReplicaComponentType::MISSION));
|
||||
auto missionComponent = player->GetComponent<MissionComponent>();
|
||||
if (missionComponent) {
|
||||
missionComponent->Progress(eMissionTaskType::COLLECTION, entity->GetLOT(), entity->GetObjectID());
|
||||
}
|
||||
}
|
||||
|
||||
void GameMessages::HandleNotifyServerLevelProcessingComplete(RakNet::BitStream* inStream, Entity* entity) {
|
||||
auto* levelComp = entity->GetComponent<LevelProgressionComponent>();
|
||||
auto levelComp = entity->GetComponent<LevelProgressionComponent>();
|
||||
if (!levelComp) return;
|
||||
auto* character = entity->GetComponent<CharacterComponent>();
|
||||
auto character = entity->GetComponent<CharacterComponent>();
|
||||
if (!character) return;
|
||||
|
||||
//Update our character's level in memory:
|
||||
@@ -5284,7 +5284,7 @@ void GameMessages::HandleNotifyServerLevelProcessingComplete(RakNet::BitStream*
|
||||
|
||||
levelComp->HandleLevelUp();
|
||||
|
||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
auto inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
|
||||
if (inventoryComponent != nullptr) {
|
||||
auto* inventory = inventoryComponent->GetInventory(ITEMS);
|
||||
@@ -5370,7 +5370,7 @@ void GameMessages::HandleEquipItem(RakNet::BitStream* inStream, Entity* entity)
|
||||
inStream->Read(immediate); //twice?
|
||||
inStream->Read(objectID);
|
||||
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = entity->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
|
||||
Item* item = inv->FindItemById(objectID);
|
||||
@@ -5389,7 +5389,7 @@ void GameMessages::HandleUnequipItem(RakNet::BitStream* inStream, Entity* entity
|
||||
inStream->Read(immediate);
|
||||
inStream->Read(objectID);
|
||||
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = entity->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
|
||||
auto* item = inv->FindItemById(objectID);
|
||||
@@ -5464,7 +5464,7 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, En
|
||||
inStream->Read(iTradeIDIsDefault);
|
||||
if (iTradeIDIsDefault) inStream->Read(iTradeID);
|
||||
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = entity->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
|
||||
auto* item = inv->FindItemById(iObjID);
|
||||
@@ -5485,7 +5485,7 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, En
|
||||
item->SetCount(item->GetCount() - iStackCount, true);
|
||||
EntityManager::Instance()->SerializeEntity(entity);
|
||||
|
||||
auto* missionComponent = entity->GetComponent<MissionComponent>();
|
||||
auto missionComponent = entity->GetComponent<MissionComponent>();
|
||||
|
||||
if (missionComponent != nullptr) {
|
||||
missionComponent->Progress(eMissionTaskType::GATHER, item->GetLot(), LWOOBJID_EMPTY, "", -iStackCount);
|
||||
@@ -5507,7 +5507,7 @@ void GameMessages::HandleMoveItemInInventory(RakNet::BitStream* inStream, Entity
|
||||
inStream->Read(responseCode);
|
||||
inStream->Read(slot);
|
||||
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = entity->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
|
||||
auto* item = inv->FindItemById(iObjID);
|
||||
@@ -5584,7 +5584,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
|
||||
if (!user) return;
|
||||
Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
|
||||
if (!character) return;
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = character->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
|
||||
Game::logger->Log("GameMessages", "Build finished");
|
||||
@@ -5639,7 +5639,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
|
||||
inv->AddItem(8092, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config);
|
||||
}
|
||||
|
||||
auto* missionComponent = character->GetComponent<MissionComponent>();
|
||||
auto missionComponent = character->GetComponent<MissionComponent>();
|
||||
|
||||
if (entity->GetLOT() != 9980 || Game::server->GetZoneID() != 1200) {
|
||||
if (missionComponent != nullptr) {
|
||||
@@ -5649,7 +5649,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
|
||||
}
|
||||
}
|
||||
|
||||
ScriptComponent* script = static_cast<ScriptComponent*>(entity->GetComponent(eReplicaComponentType::SCRIPT));
|
||||
auto script = entity->GetComponent<ScriptComponent>();
|
||||
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(entity)) {
|
||||
script->OnModularBuildExit(entity, character, count >= 3, modList);
|
||||
@@ -5672,7 +5672,7 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti
|
||||
if (!user) return;
|
||||
Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
|
||||
if (!character) return;
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = character->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
|
||||
/**
|
||||
@@ -5790,7 +5790,7 @@ void GameMessages::HandleModularBuildMoveAndEquip(RakNet::BitStream* inStream, E
|
||||
|
||||
inStream->Read(templateID);
|
||||
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = character->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
|
||||
auto* item = inv->FindItemByLot(templateID, TEMP_MODELS);
|
||||
@@ -5842,13 +5842,13 @@ void GameMessages::HandleResurrect(RakNet::BitStream* inStream, Entity* entity)
|
||||
}
|
||||
|
||||
void GameMessages::HandlePushEquippedItemsState(RakNet::BitStream* inStream, Entity* entity) {
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = entity->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
inv->PushEquippedItems();
|
||||
}
|
||||
|
||||
void GameMessages::HandlePopEquippedItemsState(RakNet::BitStream* inStream, Entity* entity) {
|
||||
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = entity->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
inv->PopEquippedItems();
|
||||
EntityManager::Instance()->SerializeEntity(entity); // so it updates on client side
|
||||
@@ -5860,7 +5860,7 @@ void GameMessages::HandleClientItemConsumed(RakNet::BitStream* inStream, Entity*
|
||||
|
||||
inStream->Read(itemConsumed);
|
||||
|
||||
auto* inventory = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inventory = entity->GetComponent<InventoryComponent>();
|
||||
|
||||
if (inventory == nullptr) {
|
||||
return;
|
||||
@@ -5874,7 +5874,7 @@ void GameMessages::HandleClientItemConsumed(RakNet::BitStream* inStream, Entity*
|
||||
|
||||
item->Consume();
|
||||
|
||||
auto* missions = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION));
|
||||
auto missions = entity->GetComponent<MissionComponent>();
|
||||
if (missions != nullptr) {
|
||||
missions->Progress(eMissionTaskType::USE_ITEM, itemLot);
|
||||
}
|
||||
@@ -5886,7 +5886,7 @@ void GameMessages::HandleUseNonEquipmentItem(RakNet::BitStream* inStream, Entity
|
||||
|
||||
inStream->Read(itemConsumed);
|
||||
|
||||
auto* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto inv = entity->GetComponent<InventoryComponent>();
|
||||
|
||||
if (!inv) return;
|
||||
|
||||
@@ -5921,7 +5921,7 @@ void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entit
|
||||
if (type == 0) { // join
|
||||
if (value != 0) {
|
||||
for (Entity* scriptedAct : scriptedActs) {
|
||||
ScriptedActivityComponent* comp = static_cast<ScriptedActivityComponent*>(scriptedAct->GetComponent(eReplicaComponentType::SCRIPTED_ACTIVITY));
|
||||
auto comp = scriptedAct->GetComponent<ScriptedActivityComponent>();
|
||||
if (!comp) continue;
|
||||
if (comp->GetActivityID() == value) {
|
||||
comp->PlayerJoin(entity);
|
||||
@@ -5932,7 +5932,7 @@ void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entit
|
||||
}
|
||||
} else if (type == 1) { // ready/unready
|
||||
for (Entity* scriptedAct : scriptedActs) {
|
||||
ScriptedActivityComponent* comp = static_cast<ScriptedActivityComponent*>(scriptedAct->GetComponent(eReplicaComponentType::SCRIPTED_ACTIVITY));
|
||||
auto comp = scriptedAct->GetComponent<ScriptedActivityComponent>();
|
||||
if (!comp) continue;
|
||||
if (comp->PlayerIsInQueue(entity)) {
|
||||
comp->PlayerReady(entity, value);
|
||||
@@ -6052,7 +6052,7 @@ void
|
||||
GameMessages::HandleClientRailMovementReady(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||
const auto possibleRails = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR);
|
||||
for (const auto* possibleRail : possibleRails) {
|
||||
const auto* rail = possibleRail->GetComponent<RailActivatorComponent>();
|
||||
const auto rail = possibleRail->GetComponent<RailActivatorComponent>();
|
||||
if (rail != nullptr) {
|
||||
rail->OnRailMovementReady(entity);
|
||||
}
|
||||
@@ -6064,7 +6064,7 @@ void GameMessages::HandleCancelRailMovement(RakNet::BitStream* inStream, Entity*
|
||||
|
||||
const auto possibleRails = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR);
|
||||
for (const auto* possibleRail : possibleRails) {
|
||||
auto* rail = possibleRail->GetComponent<RailActivatorComponent>();
|
||||
auto rail = possibleRail->GetComponent<RailActivatorComponent>();
|
||||
if (rail != nullptr) {
|
||||
rail->OnCancelRailMovement(entity);
|
||||
}
|
||||
@@ -6113,7 +6113,7 @@ void GameMessages::HandleModifyPlayerZoneStatistic(RakNet::BitStream* inStream,
|
||||
}
|
||||
|
||||
// Notify the character component that something's changed
|
||||
auto* characterComponent = entity->GetComponent<CharacterComponent>();
|
||||
auto characterComponent = entity->GetComponent<CharacterComponent>();
|
||||
if (characterComponent != nullptr) {
|
||||
characterComponent->HandleZoneStatisticsUpdate(zone, statisticsName, value);
|
||||
}
|
||||
@@ -6130,7 +6130,7 @@ void GameMessages::HandleUpdatePlayerStatistic(RakNet::BitStream* inStream, Enti
|
||||
updateValue = 1;
|
||||
}
|
||||
|
||||
auto* characterComponent = entity->GetComponent<CharacterComponent>();
|
||||
auto characterComponent = entity->GetComponent<CharacterComponent>();
|
||||
if (characterComponent != nullptr) {
|
||||
characterComponent->UpdatePlayerStatistic((StatisticID)updateID, (uint64_t)std::max(updateValue, int64_t(0)));
|
||||
}
|
||||
|
Reference in New Issue
Block a user