mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-19 18:25:27 +00:00
Merge exp/component-audit-2: component audit rounds 2-4
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -80,8 +80,11 @@ void ActivityComponent::LoadActivityData(const int32_t activityId) {
|
||||
}
|
||||
|
||||
void ActivityComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
||||
outBitStream.Write(m_DirtyActivityInfo);
|
||||
if (m_DirtyActivityInfo) {
|
||||
// A construction always carries the players: it is the only way a client coming into range learns who is in the
|
||||
// activity (LWOActivityComponent::Deserialize 0x00d002b0), and live wrote the block, empty or not, on every one
|
||||
const bool writeActivityInfo = m_DirtyActivityInfo || bIsInitialUpdate;
|
||||
outBitStream.Write(writeActivityInfo);
|
||||
if (writeActivityInfo) {
|
||||
outBitStream.Write<uint32_t>(m_ActivityPlayers.size());
|
||||
if (!m_ActivityPlayers.empty()) {
|
||||
for (const auto& [playerID, values] : m_ActivityPlayers) {
|
||||
|
||||
@@ -162,7 +162,7 @@ void QuickBuildComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsIni
|
||||
outBitStream.Write(m_ActivatorPosition);
|
||||
outBitStream.Write(m_RepositionPlayer);
|
||||
}
|
||||
m_StateDirty = false;
|
||||
if (!bIsInitialUpdate) m_StateDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#include "RacingControlComponent.h"
|
||||
#include "ControllablePhysicsComponent.h"
|
||||
|
||||
#include "CharacterComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
@@ -276,6 +277,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
jetPackMode.target = player->GetObjectID();
|
||||
jetPackMode.bUse = false;
|
||||
jetPackMode.Send(UNASSIGNED_SYSTEM_ADDRESS);
|
||||
if (auto* const physics = player->GetComponent<ControllablePhysicsComponent>()) physics->SetJetPackMode(jetPackMode.bUse, jetPackMode.effectID, jetPackMode.bBypassChecks);
|
||||
|
||||
// Set the vehicle's state.
|
||||
GameMessages::NotifyVehicleOfRacingObject notifyVehicle;
|
||||
|
||||
@@ -551,7 +551,7 @@ void BaseCombatAIComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsI
|
||||
if (m_DirtyStateOrTarget || bIsInitialUpdate) {
|
||||
outBitStream.Write(m_State);
|
||||
outBitStream.Write(m_Target);
|
||||
m_DirtyStateOrTarget = false;
|
||||
if (!bIsInitialUpdate) m_DirtyStateOrTarget = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ set(DGAME_DCOMPONENTS_SOURCES
|
||||
"Character/LevelProgressionComponent.cpp"
|
||||
"LUPExhibitComponent.cpp"
|
||||
"Character/MissionComponent.cpp"
|
||||
"Character/MountControlComponent.cpp"
|
||||
"MissionOfferComponent.cpp"
|
||||
"ModelComponent.cpp"
|
||||
"ModuleAssemblyComponent.cpp"
|
||||
@@ -33,6 +34,7 @@ set(DGAME_DCOMPONENTS_SOURCES
|
||||
"ProximityMonitorComponent.cpp"
|
||||
"Activity/RacingControlComponent.cpp"
|
||||
"RailActivatorComponent.cpp"
|
||||
"RollerComponent.cpp"
|
||||
"Activity/QuickBuildComponent.cpp"
|
||||
"RenderComponent.cpp"
|
||||
"Physics/RigidbodyPhantomPhysicsComponent.cpp"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <limits>
|
||||
#include "CharacterComponent.h"
|
||||
#include "WorldPackets.h"
|
||||
#include "BitStream.h"
|
||||
@@ -81,7 +82,7 @@ bool CharacterComponent::OnGetObjectReportInfo(GameMessages::GetObjectReportInfo
|
||||
cmptType.PushDebug<AMFIntValue>("Component ID") = GeneralUtils::ToUnderlying(ComponentType);
|
||||
cmptType.PushDebug<AMFIntValue>("Character's account ID") = m_Character->GetParentUser()->GetAccountID();
|
||||
cmptType.PushDebug<AMFBoolValue>("Last log out time") = m_Character->GetLastLogin();
|
||||
cmptType.PushDebug<AMFDoubleValue>("Seconds played this session") = 0;
|
||||
cmptType.PushDebug<AMFDoubleValue>("Seconds played this session") = m_SessionTimePlayed;
|
||||
cmptType.PushDebug<AMFBoolValue>("Editor enabled") = false;
|
||||
cmptType.PushDebug<AMFDoubleValue>("Total number of seconds played") = m_TotalTimePlayed;
|
||||
cmptType.PushDebug<AMFStringValue>("Total currency") = std::to_string(m_Character->GetCoins());
|
||||
@@ -246,11 +247,15 @@ void CharacterComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInit
|
||||
outBitStream.Write(m_GMLevel);
|
||||
outBitStream.Write(m_EditorEnabled);
|
||||
outBitStream.Write(m_EditorLevel);
|
||||
if (!bIsInitialUpdate) m_DirtyGMInfo = false;
|
||||
}
|
||||
|
||||
const bool writeCurrentActivity = bIsInitialUpdate || m_DirtyCurrentActivity;
|
||||
outBitStream.Write(writeCurrentActivity);
|
||||
if (writeCurrentActivity) outBitStream.Write(m_CurrentActivity);
|
||||
if (writeCurrentActivity) {
|
||||
outBitStream.Write(m_CurrentActivity);
|
||||
if (!bIsInitialUpdate) m_DirtyCurrentActivity = false;
|
||||
}
|
||||
|
||||
const bool writeSocialInfo = bIsInitialUpdate || m_DirtySocialInfo;
|
||||
outBitStream.Write(writeSocialInfo);
|
||||
@@ -325,6 +330,12 @@ void CharacterComponent::LoadFromSaveData(const tinyxml2::XMLDocument& doc) {
|
||||
m_TooltipFlags = 0;
|
||||
character->QueryUnsigned64Attribute("ttip", &m_TooltipFlags);
|
||||
|
||||
// Saves from before these were written have neither: a full day's votes, filled up at the next save
|
||||
m_VotesLeft = VOTES_PER_DAY;
|
||||
m_VoteDay = 0;
|
||||
character->QueryIntAttribute("v", &m_VotesLeft);
|
||||
character->QueryUnsigned64Attribute("vd", &m_VoteDay);
|
||||
|
||||
// Load the statistics
|
||||
const auto* statisticsAttribute = character->FindAttribute("stt");
|
||||
if (statisticsAttribute) {
|
||||
@@ -388,11 +399,22 @@ void CharacterComponent::LoadFromSaveData(const tinyxml2::XMLDocument& doc) {
|
||||
|
||||
LoadGuild();
|
||||
|
||||
if (character->FindAttribute("time")) {
|
||||
character->QueryUnsigned64Attribute("time", &m_TotalTimePlayed);
|
||||
} else {
|
||||
m_TotalTimePlayed = 0;
|
||||
}
|
||||
// Play time as live saved it and the client reads it (LWOCharacterComponent::LoadFromSaveData 0x00ca4910): time is
|
||||
// the total before the session, stime the seconds of the session so far; the client shows their sum (SendMessage
|
||||
// 0x00d34330, GetTimePlayed). Saves from before stime was written hold everything in time.
|
||||
uint64_t timeBeforeSession = 0;
|
||||
character->QueryUnsigned64Attribute("time", &timeBeforeSession);
|
||||
double savedSessionTime = 0.0; // the client reads a float
|
||||
character->QueryDoubleAttribute("stime", &savedSessionTime);
|
||||
m_SessionTimePlayed = savedSessionTime > 0.0 ? static_cast<uint64_t>(savedSessionTime) : 0;
|
||||
m_TotalTimePlayed = timeBeforeSession + m_SessionTimePlayed;
|
||||
|
||||
// A session starts when the character is picked on the character list; live's llog (and time) changed there and
|
||||
// stayed over the session's world transfers. A save of another login: its session is over, a new one starts at 0.
|
||||
uint64_t savedSessionLogin = 0;
|
||||
character->QueryUnsigned64Attribute("llog", &savedSessionLogin);
|
||||
const auto sessionLogin = m_Character ? m_Character->GetSessionLogin() : 0;
|
||||
if (sessionLogin != 0 && sessionLogin != savedSessionLogin) m_SessionTimePlayed = 0;
|
||||
|
||||
if (!m_Character) return;
|
||||
|
||||
@@ -445,6 +467,36 @@ void CharacterComponent::WriteSaveData(tinyxml2::XMLDocument& doc) {
|
||||
character->SetAttribute("ls", m_Uscore);
|
||||
// Live wrote ttip on every character, 0 when no tooltip was flagged
|
||||
character->SetAttribute("ttip", m_TooltipFlags);
|
||||
// Live wrote these on every character (450 of 450 saves that had been saved once); the client reads them in
|
||||
// LWOCharacterComponent::LoadFromSaveData (0x00ca4910).
|
||||
// cm, the most coins the character can hold: always 9223372036854775807 on live, the client's own value without
|
||||
// it. Nothing here caps coins by it, and one that is already in the save is left as it is.
|
||||
if (!character->FindAttribute("cm")) character->SetAttribute("cm", std::numeric_limits<int64_t>::max());
|
||||
// edit, the editor level: the client takes anything but 0 as the editor being on
|
||||
character->SetAttribute("edit", m_EditorEnabled ? static_cast<uint32_t>(m_EditorLevel) : 0u);
|
||||
// mldt, when the property moderation notice was last shown: not kept here, 0 as on most live saves
|
||||
if (!character->FindAttribute("mldt")) character->SetAttribute("mldt", 0);
|
||||
// gid and gn, the guild (0 and empty without one)
|
||||
character->SetAttribute("gid", static_cast<int64_t>(m_GuildID));
|
||||
character->SetAttribute("gn", GeneralUtils::UTF16ToWTF8(m_GuildName).c_str());
|
||||
// v and vd, the votes left and the day they are for: a new day fills them up
|
||||
const uint64_t today = static_cast<uint64_t>(std::time(nullptr)) / 86400;
|
||||
if (m_VoteDay != today) {
|
||||
m_VotesLeft = VOTES_PER_DAY;
|
||||
m_VoteDay = today;
|
||||
}
|
||||
character->SetAttribute("v", m_VotesLeft);
|
||||
character->SetAttribute("vd", m_VoteDay);
|
||||
// lrx.., the last respawn point reached, once one was reached in this world
|
||||
if (m_respawnPos != NiPoint3Constant::ZERO) {
|
||||
character->SetAttribute("lrx", m_respawnPos.x);
|
||||
character->SetAttribute("lry", m_respawnPos.y);
|
||||
character->SetAttribute("lrz", m_respawnPos.z);
|
||||
character->SetAttribute("lrrx", m_respawnRot.x);
|
||||
character->SetAttribute("lrry", m_respawnRot.y);
|
||||
character->SetAttribute("lrrz", m_respawnRot.z);
|
||||
character->SetAttribute("lrrw", m_respawnRot.w);
|
||||
}
|
||||
// Custom attribute to keep track of reputation.
|
||||
character->SetAttribute("rpt", GetReputation());
|
||||
character->SetAttribute("stt", StatisticsToString().c_str());
|
||||
@@ -490,8 +542,13 @@ void CharacterComponent::WriteSaveData(tinyxml2::XMLDocument& doc) {
|
||||
auto newUpdateTimestamp = std::time(nullptr);
|
||||
LOG("Time since last save: %d", newUpdateTimestamp - m_LastUpdateTimestamp);
|
||||
|
||||
m_TotalTimePlayed += newUpdateTimestamp - m_LastUpdateTimestamp;
|
||||
character->SetAttribute("time", m_TotalTimePlayed);
|
||||
const auto sinceLastSave = newUpdateTimestamp > m_LastUpdateTimestamp ? static_cast<uint64_t>(newUpdateTimestamp - m_LastUpdateTimestamp) : 0;
|
||||
m_TotalTimePlayed += sinceLastSave;
|
||||
m_SessionTimePlayed += sinceLastSave;
|
||||
// As live: the total before this session and the session's seconds (see LoadFromSaveData); their sum is the total
|
||||
character->SetAttribute("time", m_TotalTimePlayed - m_SessionTimePlayed);
|
||||
character->SetAttribute("stime", m_SessionTimePlayed);
|
||||
if (m_Character && m_Character->GetSessionLogin() != 0) character->SetAttribute("llog", m_Character->GetSessionLogin());
|
||||
|
||||
m_LastUpdateTimestamp = newUpdateTimestamp;
|
||||
}
|
||||
|
||||
@@ -368,8 +368,20 @@ public:
|
||||
void SetTooltipFlag(int32_t tooltip, bool flag);
|
||||
uint64_t GetTooltipFlags() const { return m_TooltipFlags; }
|
||||
|
||||
// WorldConfig's character_votes_per_day
|
||||
static constexpr int32_t VOTES_PER_DAY = 3;
|
||||
int32_t GetVotesLeft() const { return m_VotesLeft; }
|
||||
uint64_t GetVoteDay() const { return m_VoteDay; }
|
||||
|
||||
// Every second played, the running session included (saved as <char time> + <char stime>)
|
||||
uint64_t GetTotalTimePlayed() const { return m_TotalTimePlayed; };
|
||||
|
||||
// The seconds played since the character was picked on the character list (saved as <char stime>)
|
||||
uint64_t GetSessionTimePlayed() const { return m_SessionTimePlayed; };
|
||||
|
||||
// When the play time was last counted (construction, then every save); tests move it back to let time pass
|
||||
void SetLastUpdateTimestamp(const time_t value) { m_LastUpdateTimestamp = value; }
|
||||
|
||||
/**
|
||||
* Character info regarding this character, including clothing styles, etc.
|
||||
*/
|
||||
@@ -408,6 +420,11 @@ private:
|
||||
// The tooltips the player has seen, one bit each (char@ttip)
|
||||
uint64_t m_TooltipFlags{};
|
||||
|
||||
// The votes the character has left today (char@v) and the day, in days since 1970, they were last filled up on
|
||||
// (char@vd), as LWOCharacterComponent::LoadFromSaveData (0x00ca4910) reads them for GetVotesLeft
|
||||
int32_t m_VotesLeft = VOTES_PER_DAY;
|
||||
uint64_t m_VoteDay{};
|
||||
|
||||
/**
|
||||
* The lifetime reputation earned by the entity
|
||||
*/
|
||||
@@ -523,6 +540,11 @@ private:
|
||||
*/
|
||||
uint64_t m_TotalTimePlayed;
|
||||
|
||||
/**
|
||||
* The part of m_TotalTimePlayed that was played in the running session, in seconds
|
||||
*/
|
||||
uint64_t m_SessionTimePlayed = 0;
|
||||
|
||||
/**
|
||||
* The total amount of currency collected by this character
|
||||
*/
|
||||
|
||||
@@ -41,7 +41,8 @@ void LevelProgressionComponent::LoadFromSaveData(const tinyxml2::XMLDocument& do
|
||||
void LevelProgressionComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
||||
outBitStream.Write(bIsInitialUpdate || m_DirtyLevelInfo);
|
||||
if (bIsInitialUpdate || m_DirtyLevelInfo) outBitStream.Write(m_Level);
|
||||
m_DirtyLevelInfo = false;
|
||||
// A construction goes to one client; the players already watching still need a waiting change
|
||||
if (!bIsInitialUpdate) m_DirtyLevelInfo = false;
|
||||
}
|
||||
|
||||
void LevelProgressionComponent::HandleLevelUp() {
|
||||
|
||||
21
dGame/dComponents/Character/MountControlComponent.cpp
Normal file
21
dGame/dComponents/Character/MountControlComponent.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "MountControlComponent.h"
|
||||
|
||||
|
||||
#include "tinyxml2.h"
|
||||
|
||||
void MountControlComponent::LoadFromSaveData(const tinyxml2::XMLDocument& doc) {
|
||||
const auto* const obj = doc.FirstChildElement("obj");
|
||||
const auto* const mount = obj ? obj->FirstChildElement("mnt") : nullptr;
|
||||
if (mount) mount->QueryInt64Attribute("a", &m_SavedMountItemID);
|
||||
}
|
||||
|
||||
void MountControlComponent::WriteSaveData(tinyxml2::XMLDocument& doc) {
|
||||
auto* const obj = doc.FirstChildElement("obj");
|
||||
if (!obj) return;
|
||||
|
||||
auto* mount = obj->FirstChildElement("mnt");
|
||||
if (!mount) mount = obj->InsertNewChildElement("mnt");
|
||||
|
||||
// 0 in every live save looked at (450), so 0 is written, riding or not
|
||||
mount->SetAttribute("a", 0);
|
||||
}
|
||||
@@ -2,17 +2,31 @@
|
||||
#define MOUNTCONTROLCOMPONENT_H
|
||||
|
||||
#include "Component.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
/**
|
||||
* Mount control (111): the character's riding of mounts, as the client's LWOMountControlComponent: the client makes it (componentID -1) with every character
|
||||
* (LWOCharacterComponent::Factory). Nothing of it is sent or done on the server yet.
|
||||
* (LWOCharacterComponent::Factory). It writes the mount element of the character's save as live did: <mnt a="0"/> in
|
||||
* all 450 live saves looked at, so always 0.
|
||||
*/
|
||||
class MountControlComponent final : public Component {
|
||||
public:
|
||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MOUNT_CONTROL;
|
||||
|
||||
MountControlComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {}
|
||||
|
||||
// LWOMountControlComponent::LoadFromSaveData (0x00bf99c0): <mnt a>, the mount item of the save
|
||||
void LoadFromSaveData(const tinyxml2::XMLDocument& doc) override;
|
||||
|
||||
// Writes <mnt a="0"/>, as live did, also while a mount is ridden
|
||||
void WriteSaveData(tinyxml2::XMLDocument& doc) override;
|
||||
|
||||
// The mount item the save named (a save may hold one that is not 0). Nothing is mounted from it.
|
||||
LWOOBJID GetSavedMountItemID() const { return m_SavedMountItemID; }
|
||||
|
||||
private:
|
||||
LWOOBJID m_SavedMountItemID = LWOOBJID_EMPTY;
|
||||
};
|
||||
|
||||
#endif // MOUNTCONTROLCOMPONENT_H
|
||||
|
||||
@@ -14,7 +14,7 @@ void PlayerForcedMovementComponent::Serialize(RakNet::BitStream& outBitStream, b
|
||||
outBitStream.Write(m_PlayerOnRail);
|
||||
outBitStream.Write(m_ShowBillboard);
|
||||
}
|
||||
m_DirtyInfo = false;
|
||||
if (!bIsInitialUpdate) m_DirtyInfo = false;
|
||||
}
|
||||
|
||||
void PlayerForcedMovementComponent::Allocator(Entity& entity, ObjectLoadState& state) {
|
||||
|
||||
@@ -38,7 +38,7 @@ PossessorComponent::~PossessorComponent() {
|
||||
void PossessorComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
||||
outBitStream.Write(m_DirtyPossesor || bIsInitialUpdate);
|
||||
if (m_DirtyPossesor || bIsInitialUpdate) {
|
||||
m_DirtyPossesor = false;
|
||||
if (!bIsInitialUpdate) m_DirtyPossesor = false;
|
||||
outBitStream.Write(m_Possessable != LWOOBJID_EMPTY);
|
||||
if (m_Possessable != LWOOBJID_EMPTY) {
|
||||
outBitStream.Write(m_Possessable);
|
||||
@@ -70,6 +70,7 @@ void PossessorComponent::Mount(Entity* mount) {
|
||||
jetPackMode.target = m_Parent->GetObjectID();
|
||||
jetPackMode.bUse = false;
|
||||
jetPackMode.Send(UNASSIGNED_SYSTEM_ADDRESS);
|
||||
if (auto* const physics = m_Parent->GetComponent<ControllablePhysicsComponent>()) physics->SetJetPackMode(jetPackMode.bUse, jetPackMode.effectID, jetPackMode.bBypassChecks);
|
||||
if (mount->GetComponent<HavokVehiclePhysicsComponent>()) {
|
||||
auto characterComponent = m_Parent->GetComponent<CharacterComponent>();
|
||||
if (characterComponent) characterComponent->SetIsRacing(true);
|
||||
|
||||
@@ -1,17 +1,40 @@
|
||||
#ifndef CHESTCOMPONENT_H
|
||||
#define CHESTCOMPONENT_H
|
||||
|
||||
#include "BitStream.h"
|
||||
#include "Component.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
/**
|
||||
* Chest, as the client's LWOChestComponent makes it from the registry. Nothing of it is sent or done on the server yet.
|
||||
* Chest, as the client's LWOChestComponent makes it from the registry (LOT 2196). Its construction carries the player
|
||||
* the chest is for and the number of loot offers in it; nothing else of it is done on the server yet.
|
||||
*/
|
||||
class ChestComponent final : public Component {
|
||||
public:
|
||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::CHEST;
|
||||
|
||||
ChestComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {}
|
||||
|
||||
// LWOChestComponent::Deserialize (0x00c22010) reads on construction only: the player (u64) and the loot offer count
|
||||
// (u32), which it keeps when the chest is the local player's. Nothing in an update.
|
||||
void Serialize(RakNet::BitStream& outBitStream, const bool isConstruction) override {
|
||||
if (!isConstruction) return;
|
||||
outBitStream.Write(m_PlayerID);
|
||||
outBitStream.Write(m_LootOfferCount);
|
||||
}
|
||||
|
||||
LWOOBJID GetPlayerID() const { return m_PlayerID; }
|
||||
void SetPlayerID(const LWOOBJID value) { m_PlayerID = value; }
|
||||
uint32_t GetLootOfferCount() const { return m_LootOfferCount; }
|
||||
void SetLootOfferCount(const uint32_t value) { m_LootOfferCount = value; }
|
||||
|
||||
private:
|
||||
// The player the chest belongs to; none (the client's own start value) until something gives it one
|
||||
LWOOBJID m_PlayerID = LWOOBJID_EMPTY;
|
||||
|
||||
// The loot offers in the chest
|
||||
uint32_t m_LootOfferCount = 0;
|
||||
};
|
||||
|
||||
#endif // CHESTCOMPONENT_H
|
||||
|
||||
@@ -1,17 +1,61 @@
|
||||
#ifndef CHOICEBUILDCOMPONENT_H
|
||||
#define CHOICEBUILDCOMPONENT_H
|
||||
|
||||
#include "BitStream.h"
|
||||
#include "Component.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
/**
|
||||
* Choice build, as the client's LWOChoiceBuildComponent makes it from the registry. Nothing of it is sent or done on the server yet.
|
||||
* Choice build, as the client's LWOChoiceBuildComponent makes it from the registry (LOTs 5668, 6414, 6462, 7002, 16205).
|
||||
* Its state, the object built and the player using it are sent; nothing else of it is done on the server yet.
|
||||
*/
|
||||
class ChoiceBuildComponent final : public Component {
|
||||
public:
|
||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::CHOICE_BUILD;
|
||||
|
||||
// The client's states (its constructor starts at Waiting)
|
||||
enum class eState : uint32_t {
|
||||
Waiting = 0,
|
||||
Building = 1,
|
||||
};
|
||||
|
||||
ChoiceBuildComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {}
|
||||
|
||||
// LWOChoiceBuildComponent::Deserialize (0x00bf26d0) reads, in constructions and updates alike: a flag, then the
|
||||
// state (u32), the built object (u64) and the user (u64). A construction always carries them.
|
||||
void Serialize(RakNet::BitStream& outBitStream, const bool isConstruction) override {
|
||||
outBitStream.Write(isConstruction || m_Dirty);
|
||||
if (isConstruction || m_Dirty) {
|
||||
outBitStream.Write(m_State);
|
||||
outBitStream.Write(m_ChildObject);
|
||||
outBitStream.Write(m_UserID);
|
||||
}
|
||||
if (!isConstruction) m_Dirty = false;
|
||||
}
|
||||
|
||||
eState GetState() const { return m_State; }
|
||||
LWOOBJID GetChildObject() const { return m_ChildObject; }
|
||||
LWOOBJID GetUserID() const { return m_UserID; }
|
||||
|
||||
// Changes what the clients are told with the next update (the caller serializes the object)
|
||||
void SetState(const eState state, const LWOOBJID childObject, const LWOOBJID userID) {
|
||||
m_State = state;
|
||||
m_ChildObject = childObject;
|
||||
m_UserID = userID;
|
||||
m_Dirty = true;
|
||||
}
|
||||
|
||||
private:
|
||||
eState m_State = eState::Waiting;
|
||||
|
||||
// The object the choice build made, none while waiting
|
||||
LWOOBJID m_ChildObject = LWOOBJID_EMPTY;
|
||||
|
||||
// The player using the choice build, none while waiting
|
||||
LWOOBJID m_UserID = LWOOBJID_EMPTY;
|
||||
|
||||
bool m_Dirty = false;
|
||||
};
|
||||
|
||||
#endif // CHOICEBUILDCOMPONENT_H
|
||||
|
||||
@@ -42,8 +42,9 @@ bool CollectibleComponent::CountsFor(const Entity& player) const {
|
||||
}
|
||||
}
|
||||
|
||||
// LWOCollectibleComponent::Deserialize (0x00c45ec0) reads the id on construction only
|
||||
void CollectibleComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {
|
||||
outBitStream.Write(GetCollectibleId());
|
||||
if (isConstruction) outBitStream.Write(GetCollectibleId());
|
||||
}
|
||||
|
||||
bool CollectibleComponent::MsgGetObjectReportInfo(GameMessages::GetObjectReportInfo& reportMsg) {
|
||||
|
||||
@@ -259,13 +259,14 @@ void DestroyableComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsIn
|
||||
if (m_ExplodeFactor != 1.0f) outBitStream.Write(m_ExplodeFactor);
|
||||
}
|
||||
}
|
||||
m_DirtyHealth = false;
|
||||
// A construction goes to one client; the players already watching still need a waiting change
|
||||
if (!bIsInitialUpdate) m_DirtyHealth = false;
|
||||
}
|
||||
|
||||
outBitStream.Write(m_DirtyThreatList || bIsInitialUpdate);
|
||||
if (m_DirtyThreatList || bIsInitialUpdate) {
|
||||
outBitStream.Write(m_HasThreats);
|
||||
m_DirtyThreatList = false;
|
||||
if (!bIsInitialUpdate) m_DirtyThreatList = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,6 +533,8 @@ void DestroyableComponent::AddFaction(const int32_t factionID, const bool ignore
|
||||
bool DestroyableComponent::IsEnemy(const Entity* other) const {
|
||||
if (IsEnemyImplentation.ExecuteWithDefault(other, false)) return true;
|
||||
if (m_Parent->IsPlayer() && other->IsPlayer()) {
|
||||
// A player is never its own PVP target
|
||||
if (other == m_Parent) return false;
|
||||
auto* thisCharacterComponent = m_Parent->GetComponent<CharacterComponent>();
|
||||
if (!thisCharacterComponent) return false;
|
||||
auto* otherCharacterComponent = other->GetComponent<CharacterComponent>();
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "ZoneMessages.h"
|
||||
#include "MovementMessages.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "Behavior.h"
|
||||
#include "Character.h"
|
||||
#include "EntityManager.h"
|
||||
#include "ItemSet.h"
|
||||
@@ -1048,7 +1049,8 @@ void InventoryComponent::Serialize(RakNet::BitStream& outBitStream, const bool b
|
||||
outBitStream.Write(item.bound);
|
||||
}
|
||||
|
||||
m_Dirty = false;
|
||||
// A construction goes to one client; the players already watching still need a waiting equipment change
|
||||
if (!bIsInitialUpdate) m_Dirty = false;
|
||||
} else {
|
||||
outBitStream.Write(false);
|
||||
}
|
||||
@@ -1693,6 +1695,20 @@ std::vector<uint32_t> InventoryComponent::FindBuffs(Item* item, bool castOnEquip
|
||||
return buffs;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> InventoryComponent::FindEquippedJetPacks() const {
|
||||
std::vector<uint32_t> jetPacks;
|
||||
for (const auto& equipped : m_Equipped | std::views::values) {
|
||||
for (const auto behaviorID : FindBuffs(FindItemById(equipped.id), false)) {
|
||||
if (Behavior::GetBehaviorTemplate(behaviorID) == BehaviorTemplate::JETPACK) jetPacks.push_back(behaviorID);
|
||||
}
|
||||
}
|
||||
return jetPacks;
|
||||
}
|
||||
|
||||
void InventoryComponent::RecastEquippedJetPacks() const {
|
||||
for (const auto behaviorID : FindEquippedJetPacks()) SkillComponent::HandleUnmanaged(behaviorID, m_Parent->GetObjectID());
|
||||
}
|
||||
|
||||
void InventoryComponent::SetNPCItems(const std::vector<LOT>& items) {
|
||||
m_Equipped.clear();
|
||||
|
||||
|
||||
@@ -364,6 +364,17 @@ public:
|
||||
*/
|
||||
std::vector<uint32_t> FindBuffs(Item* item, bool castOnEquip) const;
|
||||
|
||||
/**
|
||||
* The jetpack behaviors among the equip skills of the equipped items
|
||||
*/
|
||||
std::vector<uint32_t> FindEquippedJetPacks() const;
|
||||
|
||||
/**
|
||||
* Puts a player that wears a jetpack back in jetpack mode after a world load: live sent SetJetPackMode again
|
||||
* shortly after the player's own construction in the next world, as the equip skill sends it
|
||||
*/
|
||||
void RecastEquippedJetPacks() const;
|
||||
|
||||
/**
|
||||
* One DeletionRestrictions row (CheckDeletionRestrictionIndex @ 00c94c20). visited stops rows that refer back to
|
||||
* themselves; the client lets such rows through.
|
||||
|
||||
@@ -16,8 +16,11 @@ void LUPExhibitComponent::NextLUPExhibit() {
|
||||
}
|
||||
|
||||
void LUPExhibitComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
||||
outBitStream.Write(m_DirtyLUPExhibit);
|
||||
if (m_DirtyLUPExhibit) {
|
||||
// LWOLUPExhibitComponent::Deserialize (0x00c63790) only learns the exhibit from this block, so a client the object
|
||||
// comes into range of gets it too
|
||||
const bool writeExhibit = bIsInitialUpdate || m_DirtyLUPExhibit;
|
||||
outBitStream.Write(writeExhibit);
|
||||
if (writeExhibit) {
|
||||
outBitStream.Write(m_LUPExhibits[m_LUPExhibitIndex % m_LUPExhibits.size()]);
|
||||
if (!bIsInitialUpdate) m_DirtyLUPExhibit = false;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,9 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bo
|
||||
outBitStream.Write(m_DirtyEquippedItemInfo || bIsInitialUpdate);
|
||||
if (m_DirtyEquippedItemInfo || bIsInitialUpdate) {
|
||||
outBitStream.Write(m_PickupRadius);
|
||||
outBitStream.Write(m_InJetpackMode);
|
||||
// LWOControllablePhysComponent::Deserialize (0x00c45770) reads this into the same flag as the jetpack block's
|
||||
// flying bit; live wrote 0, also for players in jetpack mode (10,069 player constructions)
|
||||
outBitStream.Write(m_JetpackFlying);
|
||||
|
||||
if (!bIsInitialUpdate) m_DirtyEquippedItemInfo = false;
|
||||
}
|
||||
@@ -181,6 +183,12 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bo
|
||||
}
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::SetJetPackMode(const bool use, const int32_t effectID, const bool bypassChecks) {
|
||||
m_InJetpackMode = use;
|
||||
m_JetpackEffectID = effectID;
|
||||
m_JetpackBypassChecks = bypassChecks;
|
||||
}
|
||||
|
||||
// A character's save, then where it comes into this world
|
||||
void ControllablePhysicsComponent::LoadFromSaveData(const tinyxml2::XMLDocument& doc) {
|
||||
ReadSaveData(doc);
|
||||
@@ -325,8 +333,7 @@ void ControllablePhysicsComponent::RemovePickupRadiusScale(float value) {
|
||||
|
||||
void ControllablePhysicsComponent::AddSpeedboost(float value) {
|
||||
m_ActiveSpeedBoosts.push_back(value);
|
||||
m_SpeedBoost = value;
|
||||
SetSpeedMultiplier(value / 500.0f); // 500 being the base speed
|
||||
UpdateSpeedBoost();
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::RemoveSpeedboost(float value) {
|
||||
@@ -338,16 +345,35 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Recalculate speedboost since we removed one
|
||||
m_SpeedBoost = 500.0f; // Entities without level progression (enemies, pets) go back to the normal multiplier of 1
|
||||
if (m_ActiveSpeedBoosts.empty()) { // no active speed boosts left, so return to base speed
|
||||
UpdateSpeedBoost();
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::UpdateSpeedBoost() {
|
||||
// The client's rule (LWOControllablePhysComponent::msgAddRunspeedModifier 0x00be0af0, msgRemoveRunSpeedModifier
|
||||
// 0x00be0720): a modifier over 1000 or of exactly the base 500 counts for nothing; with any slow (under 500) the
|
||||
// lowest one is the speed, otherwise the highest boost is
|
||||
constexpr float baseSpeed = 500.0f;
|
||||
constexpr float maxModifier = 1000.0f;
|
||||
float lowestSlow = baseSpeed;
|
||||
float highestBoost = baseSpeed;
|
||||
for (const auto boost : m_ActiveSpeedBoosts) {
|
||||
if (boost > maxModifier) continue;
|
||||
if (boost < lowestSlow) lowestSlow = boost;
|
||||
if (boost > highestBoost) highestBoost = boost;
|
||||
}
|
||||
|
||||
if (lowestSlow < baseSpeed) {
|
||||
m_SpeedBoost = lowestSlow;
|
||||
} else if (highestBoost > baseSpeed) {
|
||||
m_SpeedBoost = highestBoost;
|
||||
} else {
|
||||
// No modifier counts: entities without level progression (enemies, pets) go back to the normal multiplier of 1
|
||||
m_SpeedBoost = baseSpeed;
|
||||
auto* levelProgressionComponent = m_Parent->GetComponent<LevelProgressionComponent>();
|
||||
if (levelProgressionComponent) m_SpeedBoost = levelProgressionComponent->GetSpeedBase();
|
||||
} else { // Used the last applied speedboost
|
||||
m_SpeedBoost = m_ActiveSpeedBoosts.back();
|
||||
}
|
||||
SetSpeedMultiplier(m_SpeedBoost / 500.0f); // 500 being the base speed
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
SetSpeedMultiplier(m_SpeedBoost / baseSpeed);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bool specialAnims) {
|
||||
|
||||
@@ -150,6 +150,12 @@ public:
|
||||
*/
|
||||
const bool GetJetpackBypassChecks() const { return m_JetpackBypassChecks; }
|
||||
|
||||
/**
|
||||
* Keeps what a SetJetPackMode sent to the clients said, for the construction of this object: use, effect and
|
||||
* bypass checks, as LWOControllablePhysComponent::SendMessage (0x00d2f020) keeps them
|
||||
*/
|
||||
void SetJetPackMode(bool use, int32_t effectID, bool bypassChecks);
|
||||
|
||||
/**
|
||||
* Set the jetpack effect ID
|
||||
* @param effectID the effect to play while using the jetpack
|
||||
@@ -337,12 +343,12 @@ private:
|
||||
/**
|
||||
* Whether or not this entity is currently flying a jetpack
|
||||
*/
|
||||
bool m_JetpackFlying;
|
||||
bool m_JetpackFlying{ false };
|
||||
|
||||
/**
|
||||
* Bypass jetpack checks, currently unused
|
||||
* Bypass jetpack checks, from the last SetJetPackMode
|
||||
*/
|
||||
bool m_JetpackBypassChecks;
|
||||
bool m_JetpackBypassChecks{ false };
|
||||
|
||||
/**
|
||||
* The effect that plays while using the jetpack
|
||||
@@ -389,6 +395,11 @@ private:
|
||||
*/
|
||||
bool m_IsTeleporting;
|
||||
|
||||
/**
|
||||
* Works the speed out of the active speed boosts: the lowest slow if there is one, otherwise the highest boost
|
||||
*/
|
||||
void UpdateSpeedBoost();
|
||||
|
||||
/**
|
||||
* The list of speed boosts for this entity
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Copyright 2018
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
@@ -136,13 +137,13 @@ void PhantomPhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bI
|
||||
outBitStream.Write(m_EffectType);
|
||||
outBitStream.Write(m_DirectionalMultiplier);
|
||||
|
||||
// forgive me father for i have sinned
|
||||
outBitStream.Write0();
|
||||
//outBitStream.Write(m_MinMax);
|
||||
//if (m_MinMax) {
|
||||
//outBitStream.Write(m_Min);
|
||||
//outBitStream.Write(m_Max);
|
||||
//}
|
||||
// Live wrote the distances as the client keeps them: "true,150,175" went out as 1 and 175
|
||||
outBitStream.Write(m_MinMax);
|
||||
if (m_MinMax) {
|
||||
const float min = std::min(m_Min, 1.0f);
|
||||
outBitStream.Write(min);
|
||||
outBitStream.Write(std::max(m_Max, min));
|
||||
}
|
||||
|
||||
outBitStream.Write(m_IsDirectional);
|
||||
if (m_IsDirectional) {
|
||||
@@ -152,7 +153,8 @@ void PhantomPhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bI
|
||||
}
|
||||
}
|
||||
|
||||
m_EffectInfoDirty = false;
|
||||
// A construction goes to the one client the volume came into range of; the others still need the change
|
||||
if (!bIsInitialUpdate) m_EffectInfoDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,18 +246,50 @@ void PhantomPhysicsComponent::SetEffectType(ePhysicsEffectType type) {
|
||||
m_EffectInfoDirty = true;
|
||||
}
|
||||
|
||||
void PhantomPhysicsComponent::SetMin(uint32_t min) {
|
||||
void PhantomPhysicsComponent::SetMin(const float min) {
|
||||
m_Min = min;
|
||||
m_MinMax = true;
|
||||
m_EffectInfoDirty = true;
|
||||
}
|
||||
|
||||
void PhantomPhysicsComponent::SetMax(uint32_t max) {
|
||||
void PhantomPhysicsComponent::SetMax(const float max) {
|
||||
m_Max = max;
|
||||
m_MinMax = true;
|
||||
m_EffectInfoDirty = true;
|
||||
}
|
||||
|
||||
void PhantomPhysicsComponent::SetVolumeEffect(std::vector<std::string> args) {
|
||||
for (auto& arg : args) {
|
||||
arg.erase(0, arg.find_first_not_of(' '));
|
||||
arg.erase(arg.find_last_not_of(' ') + 1);
|
||||
}
|
||||
|
||||
SetPhysicsEffectActive(true);
|
||||
ePhysicsEffectType effectType = ePhysicsEffectType::PUSH;
|
||||
if (!args.empty()) {
|
||||
std::transform(args.at(0).begin(), args.at(0).end(), args.at(0).begin(), ::tolower);
|
||||
if (args.at(0) == "push") effectType = ePhysicsEffectType::PUSH;
|
||||
else if (args.at(0) == "attract") effectType = ePhysicsEffectType::ATTRACT;
|
||||
else if (args.at(0) == "repulse") effectType = ePhysicsEffectType::REPULSE;
|
||||
else if (args.at(0) == "gravity") effectType = ePhysicsEffectType::GRAVITY_SCALE;
|
||||
else if (args.at(0) == "friction") effectType = ePhysicsEffectType::FRICTION;
|
||||
}
|
||||
|
||||
SetEffectType(effectType);
|
||||
if (args.size() > 1) SetDirectionalMultiplier(GeneralUtils::TryParse(args.at(1), 0.0f));
|
||||
if (args.size() > 4) {
|
||||
// Live sent the direction with the amount as its length ("Push,50,0.91,-0.34,-0.22" as 45.68, -17.07, -11.04)
|
||||
// and none when it was zero ("Repulse,150,0,0,0,true,25,100")
|
||||
const NiPoint3 direction = GeneralUtils::TryParse(args.at(2), args.at(3), args.at(4), NiPoint3Constant::ZERO);
|
||||
if (direction != NiPoint3Constant::ZERO) SetDirection(direction.Unitize());
|
||||
}
|
||||
// Live sent the distances for "true" only: volumes with "1,20,50" went out without them
|
||||
if (args.size() > 7 && args.at(5) == "true") {
|
||||
SetMin(GeneralUtils::TryParse(args.at(6), 0.0f));
|
||||
SetMax(GeneralUtils::TryParse(args.at(7), 0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
void PhantomPhysicsComponent::SetPosition(const NiPoint3& pos) {
|
||||
PhysicsComponent::SetPosition(pos);
|
||||
if (m_dpEntity) m_dpEntity->SetPosition(pos);
|
||||
@@ -281,8 +315,8 @@ bool PhantomPhysicsComponent::OnGetObjectReportInfo(GameMessages::GetObjectRepor
|
||||
|
||||
if (m_MinMax) {
|
||||
auto& minMaxInfo = info.PushDebug("Min Max Info");
|
||||
minMaxInfo.PushDebug<AMFIntValue>("Min") = m_Min;
|
||||
minMaxInfo.PushDebug<AMFIntValue>("Max") = m_Max;
|
||||
minMaxInfo.PushDebug<AMFDoubleValue>("Min") = m_Min;
|
||||
minMaxInfo.PushDebug<AMFDoubleValue>("Max") = m_Max;
|
||||
}
|
||||
|
||||
if (m_IsRespawnVolume) {
|
||||
|
||||
@@ -120,14 +120,16 @@ public:
|
||||
void SpawnVertices() const;
|
||||
|
||||
/**
|
||||
* Legacy stuff no clue what this does
|
||||
* The distances the effect scales between; written only once one of them is set.
|
||||
* LWOPhantomPhysicsComponent::Deserialize (0x00c34db0) keeps the least of the min and 1, and a max of at least that.
|
||||
*/
|
||||
void SetMin(uint32_t min);
|
||||
void SetMin(float min);
|
||||
void SetMax(float max);
|
||||
|
||||
/**
|
||||
* Legacy stuff no clue what this does
|
||||
* A trigger's SetPhysicsVolumeEffect: type, amount, direction x, y, z, use distance, min, max
|
||||
*/
|
||||
void SetMax(uint32_t max);
|
||||
void SetVolumeEffect(std::vector<std::string> args);
|
||||
|
||||
private:
|
||||
bool OnGetObjectReportInfo(GameMessages::GetObjectReportInfo& reportInfo);
|
||||
@@ -158,8 +160,8 @@ private:
|
||||
float m_DirectionalMultiplier;
|
||||
|
||||
bool m_MinMax;
|
||||
uint32_t m_Min;
|
||||
uint32_t m_Max;
|
||||
float m_Min;
|
||||
float m_Max;
|
||||
|
||||
/**
|
||||
* Whether or not this physics object is pointed in some direction
|
||||
|
||||
@@ -73,13 +73,14 @@ void SimplePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIs
|
||||
outBitStream.Write(m_Velocity);
|
||||
outBitStream.Write(m_AngularVelocity);
|
||||
}
|
||||
if (writeVelocity || bIsInitialUpdate) m_DirtyVelocity = false;
|
||||
// A construction goes to the one client the object came into range of; the others still need the change
|
||||
if (writeVelocity && !bIsInitialUpdate) m_DirtyVelocity = false;
|
||||
|
||||
// Physics motion state
|
||||
outBitStream.Write(m_DirtyPhysicsMotionState || bIsInitialUpdate);
|
||||
if (m_DirtyPhysicsMotionState || bIsInitialUpdate) {
|
||||
outBitStream.Write<uint32_t>(m_PhysicsMotionState);
|
||||
m_DirtyPhysicsMotionState = false;
|
||||
if (!bIsInitialUpdate) m_DirtyPhysicsMotionState = false;
|
||||
}
|
||||
PhysicsComponent::Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ void PossessableComponent::LoadDataFromTemplate() {
|
||||
void PossessableComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
||||
outBitStream.Write(m_DirtyPossessable || bIsInitialUpdate);
|
||||
if (m_DirtyPossessable || bIsInitialUpdate) {
|
||||
m_DirtyPossessable = false; // reset flag
|
||||
if (!bIsInitialUpdate) m_DirtyPossessable = false; // reset flag
|
||||
outBitStream.Write(m_Possessor != LWOOBJID_EMPTY);
|
||||
if (m_Possessor != LWOOBJID_EMPTY) outBitStream.Write(m_Possessor);
|
||||
|
||||
@@ -45,7 +45,7 @@ void PossessableComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsIn
|
||||
if (m_AnimationFlag != eAnimationFlags::IDLE_NONE) outBitStream.Write(m_AnimationFlag);
|
||||
|
||||
outBitStream.Write(m_ImmediatelyDepossess);
|
||||
m_ImmediatelyDepossess = false; // reset flag
|
||||
if (!bIsInitialUpdate) m_ImmediatelyDepossess = false; // reset flag
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,32 @@
|
||||
#include "Logger.h"
|
||||
#include "PropertyManagementComponent.h"
|
||||
#include "UserManager.h"
|
||||
#include "Mission.h"
|
||||
#include "MissionComponent.h"
|
||||
|
||||
PropertyVendorComponent::PropertyVendorComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
|
||||
RegisterMsg(&PropertyVendorComponent::OnRequestUse);
|
||||
}
|
||||
|
||||
uint32_t PropertyVendorComponent::GetRequiredMission() const {
|
||||
return m_Parent->GetVarAs<uint32_t>(u"property_required_mission");
|
||||
}
|
||||
|
||||
bool PropertyVendorComponent::MayRent(Entity& player) const {
|
||||
const auto required = GetRequiredMission();
|
||||
if (required == 0) return true;
|
||||
|
||||
const auto* const missions = player.GetComponent<MissionComponent>();
|
||||
const auto* const mission = missions ? missions->GetMission(required) : nullptr;
|
||||
// The client asks its list of finished missions: one that was completed and is repeated counts as well
|
||||
return mission != nullptr && (mission->IsComplete() || mission->GetCompletions() > 0);
|
||||
}
|
||||
|
||||
bool PropertyVendorComponent::OnRequestUse(GameMessages::RequestUseEvent& event) {
|
||||
if (event.msg.IsMissionChoice()) return false;
|
||||
auto* const originator = event.user;
|
||||
// LWOPropertyVendorComponent::onCheckUseRequirements (0x00c2e210): no use without the level's mission
|
||||
if (!MayRent(*originator)) return true;
|
||||
if (PropertyManagementComponent::Instance() == nullptr) return true;
|
||||
|
||||
OnQueryPropertyData(originator, originator->GetSystemAddress());
|
||||
@@ -41,6 +59,15 @@ void PropertyVendorComponent::OnQueryPropertyData(Entity* originator, const Syst
|
||||
}
|
||||
|
||||
void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool confirmed, const LOT lot, const uint32_t count) {
|
||||
if (!MayRent(*originator)) {
|
||||
LOG("Player %llu rents a property without mission %u", originator->GetObjectID(), GetRequiredMission());
|
||||
GameMessages::PropertyRentalResponse refused;
|
||||
refused.target = m_Parent->GetObjectID();
|
||||
refused.code = RENTAL_MISSING_ACHIEVEMENT;
|
||||
refused.Send(originator->GetSystemAddress());
|
||||
return;
|
||||
}
|
||||
|
||||
if (PropertyManagementComponent::Instance() == nullptr) return;
|
||||
|
||||
if (PropertyManagementComponent::Instance()->Claim(originator->GetObjectID()) == false) {
|
||||
|
||||
@@ -34,4 +34,16 @@ public:
|
||||
* @param count unused
|
||||
*/
|
||||
void OnBuyFromVendor(Entity* originator, bool confirmed, LOT lot, uint32_t count);
|
||||
|
||||
// PropertyRentalResponse code the client shows as "you failed to rent" with UGG_PROPRENT_Dont_have_achievement
|
||||
// (LWOPropertyVendorComponent::onPropertyRentalResponse 0x00c56d70; 0 is a rented property)
|
||||
static constexpr uint32_t RENTAL_MISSING_ACHIEVEMENT = 9;
|
||||
|
||||
// The level's property_required_mission (LWOPropertyVendorComponent::LoadConfigData 0x00c2e550), 0 without one
|
||||
uint32_t GetRequiredMission() const;
|
||||
|
||||
// Whether the player has finished the level's property_required_mission, which the client asks for before the
|
||||
// vendor can be used (LWOPropertyVendorComponent::onCheckUseRequirements 0x00c2e210). A vendor without the key
|
||||
// asks for nothing here.
|
||||
bool MayRent(Entity& player) const;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "ProximityMonitorComponent.h"
|
||||
#include "CDClientManager.h"
|
||||
#include "CDClientDatabase.h"
|
||||
#include "CDProximityMonitorComponentTable.h"
|
||||
#include "GameMessages.h"
|
||||
#include "dZoneManager.h"
|
||||
@@ -19,20 +20,29 @@ ProximityMonitorComponent::ProximityMonitorComponent(Entity* parent, const int32
|
||||
RegisterMsg(&ProximityMonitorComponent::OnGetObjectReportInfo);
|
||||
}
|
||||
|
||||
// The ProximityMonitorComponent row's radii, "small,large" (one value, as LOT 9833's "4", is both): the rocket
|
||||
// launch radii
|
||||
// The ProximityMonitorComponent row lists ProximityTypes ids ("7,8": RocketSign and WorldLauncher), not radii. Each
|
||||
// type has a name, a radius and where it is loaded: LWOProximityMonitorComponent::LoadDataFromTemplate (0x00c2dfb0)
|
||||
// keeps the ids and SendMessage (0x00cbb930), on AddedToWorld, sets a proximity up under the type's name for each one
|
||||
// that has LoadOnClient. The server's are the ones with LoadOnServer, of a row that has it too.
|
||||
void ProximityMonitorComponent::LoadDataFromTemplate() {
|
||||
if (m_ComponentID <= 0) return;
|
||||
const auto componentID = m_ComponentID;
|
||||
const auto proxCompData = CDClientManager::GetTable<CDProximityMonitorComponentTable>()->Query([componentID](const CDProximityMonitorComponent& entry) { return (entry.id == componentID); });
|
||||
if (proxCompData.empty()) return;
|
||||
if (proxCompData.empty() || !proxCompData[0].LoadOnServer) return;
|
||||
|
||||
const auto radii = GeneralUtils::SplitString(proxCompData[0].Proximities, ',');
|
||||
const auto small = radii.empty() ? std::nullopt : GeneralUtils::TryParse<int32_t>(radii[0]);
|
||||
const auto large = radii.size() > 1 ? GeneralUtils::TryParse<int32_t>(radii[1]) : small;
|
||||
if (!small || !large) return;
|
||||
SetProximityRadius(*small, "rocketSmall");
|
||||
SetProximityRadius(*large, "rocketLarge");
|
||||
for (const auto& typeString : GeneralUtils::SplitString(proxCompData[0].Proximities, ',')) {
|
||||
const auto typeID = GeneralUtils::TryParse<int32_t>(typeString);
|
||||
if (!typeID) continue;
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT Name, Radius, LoadOnServer FROM ProximityTypes WHERE id = ?;");
|
||||
query.bind(1, *typeID);
|
||||
auto result = query.execQuery();
|
||||
if (result.eof() || result.getIntField("LoadOnServer", 0) == 0) continue;
|
||||
const std::string name = result.getStringField("Name", "");
|
||||
if (name.empty()) continue;
|
||||
// A missing or non-positive radius is 30, as the client takes it
|
||||
const auto radius = result.getIntField("Radius", 30);
|
||||
SetProximityRadius(static_cast<float>(radius > 0 ? radius : 30), name);
|
||||
}
|
||||
}
|
||||
|
||||
ProximityMonitorComponent::~ProximityMonitorComponent() {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "CombatMessages.h"
|
||||
#include "MovementMessages.h"
|
||||
#include "QuickBuildComponent.h"
|
||||
#include "Preconditions.h"
|
||||
#include "Game.h"
|
||||
#include "Logger.h"
|
||||
#include "RenderComponent.h"
|
||||
@@ -42,6 +43,7 @@ void RailActivatorComponent::LoadDataFromTemplate() {
|
||||
m_ShowNameBillboard = tableData.showNameBillboard;
|
||||
m_CameraLocked = tableData.cameraLocked;
|
||||
m_CollisionEnabled = tableData.playerCollision;
|
||||
m_Preconditions = tableData.preconditions;
|
||||
}
|
||||
|
||||
// The level config: a key, when there, replaces the row's value, as StartRailMovement's flags replace the row's in
|
||||
@@ -71,6 +73,11 @@ bool RailActivatorComponent::OnRequestUse(GameMessages::RequestUseEvent& event)
|
||||
if (quickBuildComponent != nullptr && quickBuildComponent->GetState() != eQuickBuildState::COMPLETED)
|
||||
return true;
|
||||
|
||||
// LWORailActivatorComponent::msgCheckUseRequirements (0x00c2c5b0): after the quick build, the row's preconditions
|
||||
// have to pass and the rail has to be on; the client does not send a use otherwise ("-1": the table has none)
|
||||
if (!m_Active) return true;
|
||||
if (!m_Preconditions.empty() && m_Preconditions != "-1" && !PreconditionExpression(m_Preconditions).Check(originator)) return true;
|
||||
|
||||
if (quickBuildComponent != nullptr) {
|
||||
// Don't want it to be destroyed while a player is using it
|
||||
quickBuildComponent->SetResetTime(quickBuildComponent->GetResetTime() + 10.0f);
|
||||
|
||||
@@ -46,6 +46,9 @@ public:
|
||||
* Whether the rail can be used (level key rail_activator_active; every rail in the live levels has it set)
|
||||
*/
|
||||
bool GetActive() const { return m_Active; }
|
||||
|
||||
// The players that used the rail and have not left it yet
|
||||
const std::vector<LWOOBJID>& GetEntitiesOnRail() const { return m_EntitiesOnRail; }
|
||||
bool GetNoAggro() const { return m_NoAggro; }
|
||||
bool GetShowNameBillboard() const { return m_ShowNameBillboard; }
|
||||
private:
|
||||
@@ -131,6 +134,11 @@ private:
|
||||
*/
|
||||
bool m_UseDB;
|
||||
|
||||
/**
|
||||
* The row's preconditions a player has to pass to use the rail
|
||||
*/
|
||||
std::string m_Preconditions;
|
||||
|
||||
/**
|
||||
* Client flag
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@ RocketLaunchpadControlComponent::RocketLaunchpadControlComponent(Entity* parent,
|
||||
// The RocketLaunchpadControlComponent row
|
||||
void RocketLaunchpadControlComponent::LoadDataFromTemplate() {
|
||||
auto query = CDClientDatabase::CreatePreppedStmt(
|
||||
"SELECT targetZone, defaultZoneID, targetScene, altLandingPrecondition, altLandingSpawnPointName FROM RocketLaunchpadControlComponent WHERE id = ?;");
|
||||
"SELECT targetZone, defaultZoneID, targetScene, altLandingPrecondition, altLandingSpawnPointName, gmLevel, useLaunchPrecondition, launchPrecondition FROM RocketLaunchpadControlComponent WHERE id = ?;");
|
||||
query.bind(1, m_ComponentID);
|
||||
|
||||
auto result = query.execQuery();
|
||||
@@ -41,11 +41,30 @@ void RocketLaunchpadControlComponent::LoadDataFromTemplate() {
|
||||
m_TargetScene = result.getStringField("targetScene");
|
||||
m_AltPrecondition = new PreconditionExpression(result.getStringField("altLandingPrecondition"));
|
||||
m_AltLandingScene = result.getStringField("altLandingSpawnPointName");
|
||||
m_GMLevel = result.getIntField("gmLevel", 0);
|
||||
if (result.getIntField("useLaunchPrecondition", 0) != 0) m_LaunchPrecondition = result.getStringField("launchPrecondition", "");
|
||||
}
|
||||
|
||||
result.finalize();
|
||||
}
|
||||
|
||||
// The level's keys. LWORocketLaunchComponentCommon::LoadConfigData (0x00c55150) reads them into the fields the row
|
||||
// would fill, and the row replaces them only while rocketLaunchUseDBDefaults is true, its default (0x00c12ea0). A pad
|
||||
// that turns it off is ruled by its level: 31 pads in the 1.10.64 maps, whose zones and scenes are their rows' but
|
||||
// whose launch preconditions only the level has (the Venture Explorer's and Avant Gardens' pads).
|
||||
void RocketLaunchpadControlComponent::LoadConfigData() {
|
||||
if (!m_Parent->HasVar(u"rocketLaunchUseDBDefaults") || m_Parent->GetVarAs<bool>(u"rocketLaunchUseDBDefaults")) return;
|
||||
|
||||
if (m_Parent->HasVar(u"targetZone")) m_TargetZone = m_Parent->GetVarAs<int32_t>(u"targetZone");
|
||||
m_DefaultZone = m_Parent->GetVarAs<int32_t>(u"propertyDefaultTargetZone");
|
||||
m_TargetScene = m_Parent->GetVarAsString(u"targetScene");
|
||||
m_GMLevel = m_Parent->GetVarAs<int32_t>(u"GMLevel");
|
||||
m_LaunchPrecondition = m_Parent->GetVarAs<bool>(u"rocketUseLaunchPrecondition") ? m_Parent->GetVarAsString(u"rocketLaunchPreCondition") : "";
|
||||
m_AltLandingScene = m_Parent->GetVarAsString(u"rocketAltLandingSpawnName");
|
||||
delete m_AltPrecondition;
|
||||
m_AltPrecondition = new PreconditionExpression(m_Parent->GetVarAsString(u"rocketAltLandingPrecondition"));
|
||||
}
|
||||
|
||||
RocketLaunchpadControlComponent::~RocketLaunchpadControlComponent() {
|
||||
delete m_AltPrecondition;
|
||||
}
|
||||
@@ -57,6 +76,11 @@ GameMessages::FireEventClientSide RocketLaunchpadControlComponent::MakeRocketEqu
|
||||
return rocketEquipped;
|
||||
}
|
||||
|
||||
bool RocketLaunchpadControlComponent::MayLaunch(Entity& player) const {
|
||||
if (static_cast<int32_t>(player.GetGMLevel()) < m_GMLevel) return false;
|
||||
return m_LaunchPrecondition.empty() || PreconditionExpression(m_LaunchPrecondition).Check(&player);
|
||||
}
|
||||
|
||||
void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId, LWOCLONEID cloneId, int32_t worldIndex) {
|
||||
auto zone = mapId == LWOMAPID_INVALID ? m_TargetZone : mapId;
|
||||
|
||||
@@ -64,6 +88,8 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MayLaunch(*originator)) return;
|
||||
|
||||
// This also gets triggered by a proximity monitor + item equip, I will set that up when havok is ready
|
||||
auto* characterComponent = originator->GetComponent<CharacterComponent>();
|
||||
auto* character = originator->GetCharacter();
|
||||
|
||||
@@ -28,6 +28,16 @@ public:
|
||||
~RocketLaunchpadControlComponent() override;
|
||||
|
||||
void LoadDataFromTemplate() override;
|
||||
void LoadConfigData() override;
|
||||
|
||||
const std::string& GetTargetScene() const { return m_TargetScene; }
|
||||
|
||||
/**
|
||||
* Whether the player may launch from this pad: LWORocketLaunchComponentCommon refuses a player under the pad's GM
|
||||
* level (msgFireEventClientSide 0x00cb78b0) or that fails its launch precondition (msgCheckUseRequirements
|
||||
* 0x00c7d0d0), so a client does not ask
|
||||
*/
|
||||
bool MayLaunch(Entity& player) const;
|
||||
|
||||
/**
|
||||
* Launches some entity to another world
|
||||
@@ -136,7 +146,18 @@ private:
|
||||
/**
|
||||
* Some precondition that needs to be met to trigger the alternative landing scene
|
||||
*/
|
||||
PreconditionExpression* m_AltPrecondition;
|
||||
PreconditionExpression* m_AltPrecondition{};
|
||||
|
||||
/**
|
||||
* The GM level a player needs to launch from this pad (the row's gmLevel, or the level's GMLevel)
|
||||
*/
|
||||
int32_t m_GMLevel{};
|
||||
|
||||
/**
|
||||
* The row's launchPrecondition, when its useLaunchPrecondition is set: what a player has to pass to launch. For a pad
|
||||
* whose level turns rocketLaunchUseDBDefaults off, the level's rocketLaunchPreCondition and rocketUseLaunchPrecondition.
|
||||
*/
|
||||
std::string m_LaunchPrecondition;
|
||||
|
||||
/**
|
||||
* Notifies the master server to prepare some world for a player to be able to travel to it
|
||||
|
||||
17
dGame/dComponents/RollerComponent.cpp
Normal file
17
dGame/dComponents/RollerComponent.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "RollerComponent.h"
|
||||
|
||||
#include "Entity.h"
|
||||
#include "GeneralUtils.h"
|
||||
|
||||
namespace {
|
||||
// A level point: the three numbers with character 31 between them
|
||||
NiPoint3 LevelPoint(const Entity& entity, const std::u16string& key) {
|
||||
const auto parts = GeneralUtils::SplitString(entity.GetVarAsString(key), '\x1f');
|
||||
return GeneralUtils::TryParse<NiPoint3>(parts).value_or(NiPoint3Constant::ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
void RollerComponent::LoadConfigData() {
|
||||
m_CameraPosition = LevelPoint(*m_Parent, u"activity_camera_pos");
|
||||
m_CameraLookAt = LevelPoint(*m_Parent, u"activity_camera_lookat_pos");
|
||||
}
|
||||
@@ -1,17 +1,54 @@
|
||||
#ifndef ROLLERCOMPONENT_H
|
||||
#define ROLLERCOMPONENT_H
|
||||
|
||||
#include "BitStream.h"
|
||||
#include "Component.h"
|
||||
#include "NiPoint3.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
/**
|
||||
* Roller, as the client's LWORollerComponent makes it from the registry. Nothing of it is sent or done on the server yet.
|
||||
* Roller (a launcher a player fires from: LOTs 2714, 13951), as the client's LWORollerComponent makes it from the
|
||||
* registry. Its construction carries the activity camera and the projectile skill; nobody uses one on the server
|
||||
* yet, so the block about its user is never sent.
|
||||
*/
|
||||
class RollerComponent final : public Component {
|
||||
public:
|
||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::ROLLER;
|
||||
|
||||
// The projectile skill the client's constructor starts with (LWORollerComponent::Initialize 0x00cc7e30)
|
||||
static constexpr uint32_t DEFAULT_PROJECTILE_SKILL = 1348;
|
||||
|
||||
RollerComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {}
|
||||
|
||||
// The level's activity_camera_pos and activity_camera_lookat_pos (LWORollerComponent::LoadConfigData 0x00c31820);
|
||||
// both stay at the origin without the key, as in the client
|
||||
void LoadConfigData() override;
|
||||
|
||||
// LWORollerComponent::Deserialize (0x00c15920) reads on construction: the camera position and what it looks at
|
||||
// (3 floats each) and the projectile skill (u32). Then, in constructions and updates alike, a flag in front of the
|
||||
// block about the player using it (3 x u64, 3 floats, a float, 3 floats, the player u64, a float): never set here.
|
||||
void Serialize(RakNet::BitStream& outBitStream, const bool isConstruction) override {
|
||||
if (isConstruction) {
|
||||
outBitStream.Write(m_CameraPosition.x);
|
||||
outBitStream.Write(m_CameraPosition.y);
|
||||
outBitStream.Write(m_CameraPosition.z);
|
||||
outBitStream.Write(m_CameraLookAt.x);
|
||||
outBitStream.Write(m_CameraLookAt.y);
|
||||
outBitStream.Write(m_CameraLookAt.z);
|
||||
outBitStream.Write(m_ProjectileSkill);
|
||||
}
|
||||
outBitStream.Write0();
|
||||
}
|
||||
|
||||
const NiPoint3& GetCameraPosition() const { return m_CameraPosition; }
|
||||
const NiPoint3& GetCameraLookAt() const { return m_CameraLookAt; }
|
||||
uint32_t GetProjectileSkill() const { return m_ProjectileSkill; }
|
||||
|
||||
private:
|
||||
NiPoint3 m_CameraPosition = NiPoint3Constant::ZERO;
|
||||
NiPoint3 m_CameraLookAt = NiPoint3Constant::ZERO;
|
||||
uint32_t m_ProjectileSkill = DEFAULT_PROJECTILE_SKILL;
|
||||
};
|
||||
|
||||
#endif // ROLLERCOMPONENT_H
|
||||
|
||||
@@ -407,34 +407,7 @@ void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::v
|
||||
LOG_DEBUG("Phantom Physics component not found!");
|
||||
return;
|
||||
}
|
||||
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
||||
ePhysicsEffectType effectType = ePhysicsEffectType::PUSH;
|
||||
if (!argArray.empty()) {
|
||||
std::transform(argArray.at(0).begin(), argArray.at(0).end(), argArray.at(0).begin(), ::tolower); //Transform to lowercase
|
||||
if (argArray.at(0) == "push") effectType = ePhysicsEffectType::PUSH;
|
||||
else if (argArray.at(0) == "attract") effectType = ePhysicsEffectType::ATTRACT;
|
||||
else if (argArray.at(0) == "repulse") effectType = ePhysicsEffectType::REPULSE;
|
||||
else if (argArray.at(0) == "gravity") effectType = ePhysicsEffectType::GRAVITY_SCALE;
|
||||
else if (argArray.at(0) == "friction") effectType = ePhysicsEffectType::FRICTION;
|
||||
}
|
||||
|
||||
phantomPhysicsComponent->SetEffectType(effectType);
|
||||
if (argArray.size() > 1) {
|
||||
phantomPhysicsComponent->SetDirectionalMultiplier(GeneralUtils::TryParse(argArray.at(1), 0.0f));
|
||||
}
|
||||
if (argArray.size() > 4) {
|
||||
const NiPoint3 direction =
|
||||
GeneralUtils::TryParse(argArray.at(2), argArray.at(3), argArray.at(4), NiPoint3Constant::ZERO);
|
||||
|
||||
phantomPhysicsComponent->SetDirection(direction);
|
||||
}
|
||||
if (argArray.size() > 6) {
|
||||
const uint32_t min = GeneralUtils::TryParse(argArray.at(6), 0);
|
||||
phantomPhysicsComponent->SetMin(min);
|
||||
|
||||
const uint32_t max = GeneralUtils::TryParse(argArray.at(7), 0);
|
||||
phantomPhysicsComponent->SetMax(max);
|
||||
}
|
||||
phantomPhysicsComponent->SetVolumeEffect(argArray);
|
||||
|
||||
Game::entityManager->SerializeEntity(targetEntity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user