mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-16 20:24:39 -06:00
Compare commits
7 Commits
mail-fixes
...
revert-lxf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2184a7fdfb | ||
|
|
1f580491c7 | ||
|
|
2618e9a864 | ||
|
|
0f0d0a6dee | ||
|
|
f63a9a6bea | ||
|
|
f0f98a6108 | ||
|
|
4ed7bd6767 |
@@ -66,9 +66,11 @@ Lxfml::Result Lxfml::NormalizePosition(const std::string_view data) {
|
||||
|
||||
auto delta = (highest - lowest) / 2.0f;
|
||||
auto newRootPos = lowest + delta;
|
||||
|
||||
|
||||
// Clamp the Y to the lowest point on the model
|
||||
newRootPos.y = lowest.y;
|
||||
// newRootPos = newRootPos - NiPoint3{-0.4f, 0, 0.4};
|
||||
const auto posToReturn = newRootPos;
|
||||
|
||||
// Adjust all positions to account for the new origin
|
||||
for (auto& transformation : transformations | std::views::values) {
|
||||
@@ -112,6 +114,6 @@ Lxfml::Result Lxfml::NormalizePosition(const std::string_view data) {
|
||||
doc.Print(&printer);
|
||||
|
||||
toReturn.lxfml = printer.CStr();
|
||||
toReturn.center = newRootPos;
|
||||
toReturn.center = posToReturn;
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
// this file should not be touched
|
||||
|
||||
Lxfml::Result Lxfml::NormalizePositionOnlyFirstPart(const std::string_view data) {
|
||||
// this is bugged
|
||||
return;
|
||||
Result toReturn;
|
||||
tinyxml2::XMLDocument doc;
|
||||
const auto err = doc.Parse(data.data());
|
||||
@@ -117,6 +119,9 @@ Lxfml::Result Lxfml::NormalizePositionOnlyFirstPart(const std::string_view data)
|
||||
}
|
||||
|
||||
Lxfml::Result Lxfml::NormalizePositionAfterFirstPart(const std::string_view data, const NiPoint3& position) {
|
||||
// this is bugged
|
||||
return;
|
||||
|
||||
Result toReturn;
|
||||
tinyxml2::XMLDocument doc;
|
||||
const auto err = doc.Parse(data.data());
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "Sd0.h"
|
||||
|
||||
void ModelNormalizeMigration::Run() {
|
||||
// Take this out when model position normalization works (never)
|
||||
return;
|
||||
const auto oldCommit = Database::Get()->GetAutoCommit();
|
||||
Database::Get()->SetAutoCommit(false);
|
||||
for (auto& [lxfmlData, id, modelID] : Database::Get()->GetAllUgcModels()) {
|
||||
@@ -30,6 +32,8 @@ void ModelNormalizeMigration::Run() {
|
||||
}
|
||||
|
||||
void ModelNormalizeMigration::RunAfterFirstPart() {
|
||||
// Take this out when model position normalization works (never)
|
||||
return;
|
||||
const auto oldCommit = Database::Get()->GetAutoCommit();
|
||||
Database::Get()->SetAutoCommit(false);
|
||||
for (auto& [lxfmlData, id, modelID] : Database::Get()->GetAllUgcModels()) {
|
||||
|
||||
528
dGame/Entity.cpp
528
dGame/Entity.cpp
File diff suppressed because it is too large
Load Diff
@@ -34,7 +34,6 @@ namespace tinyxml2 {
|
||||
};
|
||||
|
||||
class Player;
|
||||
class EntityInfo;
|
||||
class User;
|
||||
class Spawner;
|
||||
class ScriptComponent;
|
||||
@@ -45,6 +44,7 @@ class Item;
|
||||
class Character;
|
||||
class EntityCallbackTimer;
|
||||
class PositionUpdate;
|
||||
struct EntityInfo;
|
||||
enum class eTriggerEventType;
|
||||
enum class eGameMasterLevel : uint8_t;
|
||||
enum class eReplicaComponentType : uint32_t;
|
||||
@@ -60,7 +60,7 @@ namespace CppScripts {
|
||||
*/
|
||||
class Entity {
|
||||
public:
|
||||
explicit Entity(const LWOOBJID& objectID, EntityInfo info, User* parentUser = nullptr, Entity* parentEntity = nullptr);
|
||||
Entity(const LWOOBJID& objectID, const EntityInfo& info, User* parentUser = nullptr, Entity* parentEntity = nullptr);
|
||||
~Entity();
|
||||
|
||||
void Initialize();
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
|
||||
float GetDefaultScale() const;
|
||||
|
||||
const NiPoint3& GetPosition() const;
|
||||
NiPoint3 GetPosition() const;
|
||||
|
||||
const NiQuaternion& GetRotation() const;
|
||||
|
||||
@@ -146,9 +146,9 @@ public:
|
||||
|
||||
void SetRotation(const NiQuaternion& rotation);
|
||||
|
||||
void SetRespawnPos(const NiPoint3& position);
|
||||
void SetRespawnPos(const NiPoint3& position) const;
|
||||
|
||||
void SetRespawnRot(const NiQuaternion& rotation);
|
||||
void SetRespawnRot(const NiQuaternion& rotation) const;
|
||||
|
||||
void SetVelocity(const NiPoint3& velocity);
|
||||
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
void AddComponent(eReplicaComponentType componentId, Component* component);
|
||||
|
||||
// This is expceted to never return nullptr, an assert checks this.
|
||||
CppScripts::Script* const GetScript();
|
||||
CppScripts::Script* const GetScript() const;
|
||||
|
||||
void Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName);
|
||||
void Unsubscribe(LWOOBJID scriptObjId, const std::string& notificationName);
|
||||
@@ -182,8 +182,8 @@ public:
|
||||
void RemoveParent();
|
||||
|
||||
// Adds a timer to start next frame with the given name and time.
|
||||
void AddTimer(std::string name, float time);
|
||||
void AddCallbackTimer(float time, std::function<void()> callback);
|
||||
void AddTimer(const std::string& name, float time);
|
||||
void AddCallbackTimer(float time, const std::function<void()> callback);
|
||||
bool HasTimer(const std::string& name);
|
||||
void CancelCallbackTimers();
|
||||
void CancelAllTimers();
|
||||
@@ -195,7 +195,7 @@ public:
|
||||
std::unordered_map<eReplicaComponentType, Component*>& GetComponents() { return m_Components; } // TODO: Remove
|
||||
|
||||
void WriteBaseReplicaData(RakNet::BitStream& outBitStream, eReplicaPacketType packetType);
|
||||
void WriteComponents(RakNet::BitStream& outBitStream, eReplicaPacketType packetType);
|
||||
void WriteComponents(RakNet::BitStream& outBitStream, eReplicaPacketType packetType) const;
|
||||
void UpdateXMLDoc(tinyxml2::XMLDocument& doc);
|
||||
void Update(float deltaTime);
|
||||
|
||||
@@ -242,21 +242,21 @@ public:
|
||||
void AddDieCallback(const std::function<void()>& callback);
|
||||
void Resurrect();
|
||||
|
||||
void AddLootItem(const Loot::Info& info);
|
||||
void PickupItem(const LWOOBJID& objectID);
|
||||
void AddLootItem(const Loot::Info& info) const;
|
||||
void PickupItem(const LWOOBJID& objectID) const;
|
||||
|
||||
bool CanPickupCoins(uint64_t count);
|
||||
void RegisterCoinDrop(uint64_t count);
|
||||
bool PickupCoins(uint64_t count) const;
|
||||
void RegisterCoinDrop(uint64_t count) const;
|
||||
|
||||
void ScheduleKillAfterUpdate(Entity* murderer = nullptr);
|
||||
void TriggerEvent(eTriggerEventType event, Entity* optionalTarget = nullptr);
|
||||
void TriggerEvent(eTriggerEventType event, Entity* optionalTarget = nullptr) const;
|
||||
void ScheduleDestructionAfterUpdate() { m_ShouldDestroyAfterUpdate = true; }
|
||||
|
||||
const NiPoint3& GetRespawnPosition() const;
|
||||
const NiQuaternion& GetRespawnRotation() const;
|
||||
|
||||
void Sleep();
|
||||
void Wake();
|
||||
void Sleep() const;
|
||||
void Wake() const;
|
||||
bool IsSleeping() const;
|
||||
|
||||
/*
|
||||
@@ -266,7 +266,7 @@ public:
|
||||
* Retroactively corrects the model vault size due to incorrect initialization in a previous patch.
|
||||
*
|
||||
*/
|
||||
void RetroactiveVaultSize();
|
||||
void RetroactiveVaultSize() const;
|
||||
bool GetBoolean(const std::u16string& name) const;
|
||||
int32_t GetI32(const std::u16string& name) const;
|
||||
int64_t GetI64(const std::u16string& name) const;
|
||||
@@ -334,7 +334,8 @@ public:
|
||||
*/
|
||||
static Observable<Entity*, const PositionUpdate&> OnPlayerPositionUpdate;
|
||||
|
||||
protected:
|
||||
private:
|
||||
void WriteLDFData(const std::vector<LDFBaseData*>& ldf, RakNet::BitStream& outBitStream) const;
|
||||
LWOOBJID m_ObjectID;
|
||||
|
||||
LOT m_TemplateID;
|
||||
@@ -357,7 +358,6 @@ protected:
|
||||
Entity* m_ParentEntity; //For spawners and the like
|
||||
std::vector<Entity*> m_ChildEntities;
|
||||
eGameMasterLevel m_GMLevel;
|
||||
uint16_t m_CollectibleID;
|
||||
std::vector<std::string> m_Groups;
|
||||
uint16_t m_NetworkID;
|
||||
std::vector<std::function<void()>> m_DieCallbacks;
|
||||
@@ -383,6 +383,8 @@ protected:
|
||||
|
||||
bool m_IsParentChildDirty = true;
|
||||
|
||||
bool m_IsSleeping = false;
|
||||
|
||||
/*
|
||||
* Collision
|
||||
*/
|
||||
@@ -391,7 +393,7 @@ protected:
|
||||
// objectID of receiver and map of notification name to script
|
||||
std::map<LWOOBJID, std::map<std::string, CppScripts::Script*>> m_Subscriptions;
|
||||
|
||||
std::multimap<MessageType::Game, std::function<bool(GameMessages::GameMsg&)>> m_MsgHandlers;
|
||||
std::unordered_multimap<MessageType::Game, std::function<bool(GameMessages::GameMsg&)>> m_MsgHandlers;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -394,7 +394,7 @@ void EntityManager::ConstructAllEntities(const SystemAddress& sysAddr) {
|
||||
}
|
||||
}
|
||||
|
||||
UpdateGhosting(PlayerManager::GetPlayer(sysAddr));
|
||||
UpdateGhosting(PlayerManager::GetPlayer(sysAddr), true);
|
||||
}
|
||||
|
||||
void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr) {
|
||||
@@ -417,7 +417,7 @@ void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr)
|
||||
|
||||
void EntityManager::SerializeEntity(Entity* entity) {
|
||||
if (!entity) return;
|
||||
|
||||
|
||||
EntityManager::SerializeEntity(*entity);
|
||||
}
|
||||
|
||||
@@ -463,7 +463,7 @@ void EntityManager::UpdateGhosting() {
|
||||
m_PlayersToUpdateGhosting.clear();
|
||||
}
|
||||
|
||||
void EntityManager::UpdateGhosting(Entity* player) {
|
||||
void EntityManager::UpdateGhosting(Entity* player, const bool constructAll) {
|
||||
if (!player) return;
|
||||
|
||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||
@@ -511,9 +511,12 @@ void EntityManager::UpdateGhosting(Entity* player) {
|
||||
|
||||
ghostComponent->ObserveEntity(id);
|
||||
|
||||
ConstructEntity(entity, player->GetSystemAddress());
|
||||
|
||||
entity->SetObservers(entity->GetObservers() + 1);
|
||||
|
||||
// TODO: figure out if zone control should be ghosted at all
|
||||
if (constructAll && entity->GetObjectID() == GetZoneControlEntity()->GetObjectID()) continue;
|
||||
|
||||
ConstructEntity(entity, player->GetSystemAddress());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "dCommonVars.h"
|
||||
|
||||
class Entity;
|
||||
class EntityInfo;
|
||||
struct EntityInfo;
|
||||
class Player;
|
||||
class User;
|
||||
enum class eReplicaComponentType : uint32_t;
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
void SetGhostDistanceMin(float value);
|
||||
void QueueGhostUpdate(LWOOBJID playerID);
|
||||
void UpdateGhosting();
|
||||
void UpdateGhosting(Entity* player);
|
||||
void UpdateGhosting(Entity* player, const bool constructAll = false);
|
||||
void CheckGhosting(Entity* entity);
|
||||
Entity* GetGhostCandidate(LWOOBJID id) const;
|
||||
bool GetGhostingEnabled() const;
|
||||
|
||||
@@ -37,6 +37,7 @@ bool ModelComponent::OnResetModelToDefaults(GameMessages::GameMsg& msg) {
|
||||
m_Parent->SetRotation(m_OriginalRotation);
|
||||
m_Parent->SetVelocity(NiPoint3Constant::ZERO);
|
||||
|
||||
m_Speed = 3.0f;
|
||||
m_NumListeningInteract = 0;
|
||||
m_NumActiveUnSmash = 0;
|
||||
m_Dirty = true;
|
||||
@@ -279,6 +280,7 @@ bool ModelComponent::TrySetVelocity(const NiPoint3& velocity) const {
|
||||
currentVelocity = velocity;
|
||||
}
|
||||
|
||||
currentVelocity *= m_Speed;
|
||||
m_Parent->SetVelocity(currentVelocity);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
*
|
||||
* @tparam Msg The message type to pass
|
||||
* @param args the arguments of the message to be deserialized
|
||||
*
|
||||
*
|
||||
* @return returns true if a new behaviorID is needed.
|
||||
*/
|
||||
template<typename Msg>
|
||||
@@ -145,6 +145,8 @@ public:
|
||||
void SetVelocity(const NiPoint3& velocity) const;
|
||||
|
||||
void OnChatMessageReceived(const std::string& sMessage);
|
||||
|
||||
void SetSpeed(const float newSpeed) { m_Speed = newSpeed; }
|
||||
private:
|
||||
|
||||
// Loads a behavior from the database.
|
||||
@@ -185,4 +187,7 @@ private:
|
||||
* The ID of the user that made the model
|
||||
*/
|
||||
LWOOBJID m_userModelID;
|
||||
|
||||
// The speed at which this model moves
|
||||
float m_Speed{ 3.0f };
|
||||
};
|
||||
|
||||
@@ -29,6 +29,13 @@ PhysicsComponent::PhysicsComponent(Entity* parent, int32_t componentId) : Compon
|
||||
}
|
||||
|
||||
if (m_Parent->HasVar(u"CollisionGroupID")) m_CollisionGroup = m_Parent->GetVar<int32_t>(u"CollisionGroupID");
|
||||
|
||||
RegisterMsg(MessageType::Game::GET_POSITION, this, &PhysicsComponent::OnGetPosition);
|
||||
}
|
||||
|
||||
bool PhysicsComponent::OnGetPosition(GameMessages::GameMsg& msg) {
|
||||
static_cast<GameMessages::GetPosition&>(msg).pos = GetPosition();
|
||||
return true;
|
||||
}
|
||||
|
||||
void PhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
|
||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||
|
||||
const NiPoint3& GetPosition() const { return m_Position; }
|
||||
const NiPoint3& GetPosition() const noexcept { return m_Position; }
|
||||
virtual void SetPosition(const NiPoint3& pos) { if (m_Position == pos) return; m_Position = pos; m_DirtyPosition = true; }
|
||||
|
||||
const NiQuaternion& GetRotation() const { return m_Rotation; }
|
||||
@@ -35,6 +35,8 @@ protected:
|
||||
|
||||
void SpawnVertices(dpEntity* entity) const;
|
||||
|
||||
bool OnGetPosition(GameMessages::GameMsg& msg);
|
||||
|
||||
NiPoint3 m_Position;
|
||||
|
||||
NiQuaternion m_Rotation;
|
||||
|
||||
@@ -2611,10 +2611,15 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream& inStream, Entity* ent
|
||||
|
||||
// Uncompress the data and normalize the position
|
||||
const auto asStr = sd0.GetAsStringUncompressed();
|
||||
const auto [newLxfml, newCenter] = Lxfml::NormalizePosition(asStr);
|
||||
|
||||
// This logic doesnt work
|
||||
/*
|
||||
// const auto [newLxfml, newCenter] = Lxfml::NormalizePosition(asStr);
|
||||
|
||||
// Recompress the data and save to the database
|
||||
sd0.FromData(reinterpret_cast<const uint8_t*>(newLxfml.data()), newLxfml.size());
|
||||
// sd0.FromData(reinterpret_cast<const uint8_t*>(newLxfml.data()), newLxfml.size());
|
||||
*/
|
||||
|
||||
auto sd0AsStream = sd0.GetAsStream();
|
||||
Database::Get()->InsertNewUgcModel(sd0AsStream, blueprintIDSmall, entity->GetCharacter()->GetParentUser()->GetAccountID(), entity->GetCharacter()->GetID());
|
||||
|
||||
@@ -2622,8 +2627,8 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream& inStream, Entity* ent
|
||||
IPropertyContents::Model model;
|
||||
model.id = newIDL;
|
||||
model.ugcId = blueprintIDSmall;
|
||||
model.position = newCenter;
|
||||
model.rotation = NiQuaternion(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
model.position = NiPoint3Constant::ZERO;
|
||||
model.rotation = NiQuaternionConstant::IDENTITY;
|
||||
model.lot = 14;
|
||||
Database::Get()->InsertNewPropertyModel(propertyId, model, "Objects_14_name");
|
||||
|
||||
@@ -2668,8 +2673,8 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream& inStream, Entity* ent
|
||||
|
||||
EntityInfo info;
|
||||
info.lot = 14;
|
||||
info.pos = newCenter;
|
||||
info.rot = {};
|
||||
info.pos = NiPoint3Constant::ZERO;
|
||||
info.rot = NiQuaternionConstant::IDENTITY;
|
||||
info.spawner = nullptr;
|
||||
info.spawnerID = entity->GetObjectID();
|
||||
info.spawnerNodeID = 0;
|
||||
@@ -5207,7 +5212,7 @@ void GameMessages::HandlePickupCurrency(RakNet::BitStream& inStream, Entity* ent
|
||||
if (currency == 0) return;
|
||||
|
||||
auto* ch = entity->GetCharacter();
|
||||
if (ch && entity->CanPickupCoins(currency)) {
|
||||
if (ch && entity->PickupCoins(currency)) {
|
||||
ch->SetCoins(ch->GetCoins() + currency, eLootSourceType::PICKUP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -843,5 +843,10 @@ namespace GameMessages {
|
||||
LWOOBJID targetID;
|
||||
};
|
||||
|
||||
struct GetPosition : public GameMsg {
|
||||
GetPosition() : GameMsg(MessageType::Game::GET_POSITION) {}
|
||||
|
||||
NiPoint3 pos{};
|
||||
};
|
||||
};
|
||||
#endif // GAMEMESSAGES_H
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "eUseItemResponse.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "ChatPackets.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "eMissionTaskType.h"
|
||||
|
||||
#include "CDBrickIDTableTable.h"
|
||||
#include "CDObjectSkillsTable.h"
|
||||
@@ -268,9 +270,9 @@ bool Item::IsEquipped() const {
|
||||
}
|
||||
|
||||
bool Item::Consume() {
|
||||
auto* skillsTable = CDClientManager::GetTable<CDObjectSkillsTable>();
|
||||
auto* const skillsTable = CDClientManager::GetTable<CDObjectSkillsTable>();
|
||||
|
||||
auto skills = skillsTable->Query([this](const CDObjectSkills entry) {
|
||||
const auto skills = skillsTable->Query([this](const CDObjectSkills& entry) {
|
||||
return entry.objectTemplate == static_cast<uint32_t>(lot);
|
||||
});
|
||||
|
||||
@@ -288,7 +290,12 @@ bool Item::Consume() {
|
||||
GameMessages::SendUseItemResult(inventory->GetComponent()->GetParent(), lot, success);
|
||||
|
||||
if (success) {
|
||||
// Save this because if this is the last item in the inventory
|
||||
// we may delete ourself (lol)
|
||||
const auto myLot = this->lot;
|
||||
inventory->GetComponent()->RemoveItem(lot, 1);
|
||||
auto* missionComponent = inventory->GetComponent()->GetParent()->GetComponent<MissionComponent>();
|
||||
if (missionComponent) missionComponent->Progress(eMissionTaskType::GATHER, myLot, LWOOBJID_EMPTY, "", -1);
|
||||
}
|
||||
|
||||
return success;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "ChatPackets.h"
|
||||
#include "PropertyManagementComponent.h"
|
||||
#include "PlayerManager.h"
|
||||
#include "SimplePhysicsComponent.h"
|
||||
|
||||
#include "dChatFilter.h"
|
||||
|
||||
@@ -154,16 +155,18 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent) {
|
||||
if (nextActionType == "MoveRight" || nextActionType == "MoveLeft") {
|
||||
// X axis
|
||||
bool isMoveLeft = nextActionType == "MoveLeft";
|
||||
int negative = isMoveLeft ? -1 : 1;
|
||||
// Default velocity is 3 units per second.
|
||||
if (modelComponent.TrySetVelocity(NiPoint3{ isMoveLeft ? -3.0f : 3.0f, 0.0f, 0.0f })) {
|
||||
if (modelComponent.TrySetVelocity(NiPoint3Constant::UNIT_X * negative)) {
|
||||
m_PreviousFramePosition = entity.GetPosition();
|
||||
m_InActionMove.x = isMoveLeft ? -number : number;
|
||||
}
|
||||
} else if (nextActionType == "FlyUp" || nextActionType == "FlyDown") {
|
||||
// Y axis
|
||||
bool isFlyDown = nextActionType == "FlyDown";
|
||||
int negative = isFlyDown ? -1 : 1;
|
||||
// Default velocity is 3 units per second.
|
||||
if (modelComponent.TrySetVelocity(NiPoint3{ 0.0f, isFlyDown ? -3.0f : 3.0f, 0.0f })) {
|
||||
if (modelComponent.TrySetVelocity(NiPoint3Constant::UNIT_Y * negative)) {
|
||||
m_PreviousFramePosition = entity.GetPosition();
|
||||
m_InActionMove.y = isFlyDown ? -number : number;
|
||||
}
|
||||
@@ -171,14 +174,21 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent) {
|
||||
} else if (nextActionType == "MoveForward" || nextActionType == "MoveBackward") {
|
||||
// Z axis
|
||||
bool isMoveBackward = nextActionType == "MoveBackward";
|
||||
int negative = isMoveBackward ? -1 : 1;
|
||||
// Default velocity is 3 units per second.
|
||||
if (modelComponent.TrySetVelocity(NiPoint3{ 0.0f, 0.0f, isMoveBackward ? -3.0f : 3.0f })) {
|
||||
if (modelComponent.TrySetVelocity(NiPoint3Constant::UNIT_Z * negative)) {
|
||||
m_PreviousFramePosition = entity.GetPosition();
|
||||
m_InActionMove.z = isMoveBackward ? -number : number;
|
||||
}
|
||||
}
|
||||
/* END Move */
|
||||
|
||||
/* BEGIN Navigation */
|
||||
else if (nextActionType == "SetSpeed") {
|
||||
modelComponent.SetSpeed(number);
|
||||
}
|
||||
/* END Navigation */
|
||||
|
||||
/* BEGIN Action */
|
||||
else if (nextActionType == "Smash") {
|
||||
if (!modelComponent.IsUnSmashing()) {
|
||||
|
||||
@@ -24,9 +24,8 @@ namespace {
|
||||
}
|
||||
|
||||
void Loot::CacheMatrix(uint32_t matrixIndex) {
|
||||
if (CachedMatrices.find(matrixIndex) != CachedMatrices.end()) {
|
||||
return;
|
||||
}
|
||||
if (CachedMatrices.contains(matrixIndex)) return;
|
||||
|
||||
CachedMatrices.insert(matrixIndex);
|
||||
CDComponentsRegistryTable* componentsRegistryTable = CDClientManager::GetTable<CDComponentsRegistryTable>();
|
||||
CDItemComponentTable* itemComponentTable = CDClientManager::GetTable<CDItemComponentTable>();
|
||||
|
||||
@@ -132,6 +132,7 @@ namespace Mail {
|
||||
} else {
|
||||
response.status = eSendResponse::SenderAccountIsMuted;
|
||||
}
|
||||
LOG("Finished send with status %s", StringifiedEnum::ToString(response.status).data());
|
||||
response.Send(sysAddr);
|
||||
}
|
||||
|
||||
@@ -158,6 +159,7 @@ namespace Mail {
|
||||
DataResponse response;
|
||||
response.playerMail = playerMail;
|
||||
response.Send(sysAddr);
|
||||
LOG("DataRequest");
|
||||
}
|
||||
|
||||
void DataResponse::Serialize(RakNet::BitStream& bitStream) const {
|
||||
@@ -196,6 +198,7 @@ namespace Mail {
|
||||
response.status = eAttachmentCollectResponse::Success;
|
||||
}
|
||||
}
|
||||
LOG("AttachmentCollectResponse %s", StringifiedEnum::ToString(response.status).data());
|
||||
response.Send(sysAddr);
|
||||
}
|
||||
|
||||
@@ -218,14 +221,15 @@ namespace Mail {
|
||||
response.mailID = mailID;
|
||||
|
||||
auto mailData = Database::Get()->GetMail(mailID);
|
||||
if (mailData && !(mailData->itemLOT != 0 && mailData->itemCount > 0)) {
|
||||
if (mailData && !(mailData->itemLOT > 0 && mailData->itemCount > 0)) {
|
||||
Database::Get()->DeleteMail(mailID);
|
||||
response.status = eDeleteResponse::Success;
|
||||
} else if (mailData && mailData->itemLOT != 0 && mailData->itemCount > 0) {
|
||||
} else if (mailData && mailData->itemLOT > 0 && mailData->itemCount > 0) {
|
||||
response.status = eDeleteResponse::HasAttachments;
|
||||
} else {
|
||||
response.status = eDeleteResponse::NotFound;
|
||||
}
|
||||
LOG("DeleteRequest status %s", StringifiedEnum::ToString(response.status).data());
|
||||
response.Send(sysAddr);
|
||||
}
|
||||
|
||||
@@ -249,7 +253,9 @@ namespace Mail {
|
||||
if (Database::Get()->GetMail(mailID)) {
|
||||
response.status = eReadResponse::Success;
|
||||
Database::Get()->MarkMailRead(mailID);
|
||||
}
|
||||
}
|
||||
|
||||
LOG("ReadRequest %s", StringifiedEnum::ToString(response.status).data());
|
||||
response.Send(sysAddr);
|
||||
}
|
||||
|
||||
@@ -267,6 +273,8 @@ namespace Mail {
|
||||
response.status = eNotificationResponse::NewMail;
|
||||
response.mailCount = unreadMailCount;
|
||||
}
|
||||
|
||||
LOG("NotificationRequest %s", StringifiedEnum::ToString(response.status).data());
|
||||
response.Send(sysAddr);
|
||||
}
|
||||
}
|
||||
@@ -288,6 +296,7 @@ void Mail::HandleMail(RakNet::BitStream& inStream, const SystemAddress& sysAddr,
|
||||
LOG_DEBUG("Error Reading Mail Request: %s", StringifiedEnum::ToString(data.messageID).data());
|
||||
return;
|
||||
}
|
||||
LOG("Received mail message %s", StringifiedEnum::ToString(data.messageID).data());
|
||||
request->Handle();
|
||||
} else {
|
||||
LOG_DEBUG("Unhandled Mail Request with ID: %i", data.messageID);
|
||||
|
||||
@@ -119,12 +119,15 @@ namespace Mail {
|
||||
struct SendRequest : public MailLUBitStream {
|
||||
MailInfo mailInfo;
|
||||
|
||||
SendRequest() : MailLUBitStream(eMessageID::SendRequest) {}
|
||||
bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
void Handle() override;
|
||||
};
|
||||
|
||||
struct SendResponse :public MailLUBitStream {
|
||||
eSendResponse status = eSendResponse::UnknownError;
|
||||
|
||||
SendResponse() : MailLUBitStream(eMessageID::SendResponse) {}
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
@@ -137,6 +140,7 @@ namespace Mail {
|
||||
};
|
||||
|
||||
struct DataRequest : public MailLUBitStream {
|
||||
DataRequest() : MailLUBitStream(eMessageID::DataRequest) {}
|
||||
bool Deserialize(RakNet::BitStream& bitStream) override { return true; };
|
||||
void Handle() override;
|
||||
};
|
||||
|
||||
@@ -58,6 +58,7 @@ bool MailInfo::Deserialize(RakNet::BitStream& bitStream) {
|
||||
bitStream.IgnoreBytes(4); // padding
|
||||
|
||||
DluAssert(bitStream.GetNumberOfUnreadBits() == 0);
|
||||
LOG_DEBUG("MailInfo: %llu, %s, %s, %s, %llu, %i, %llu, %i, %llu, %i", id, subject.GetAsString().c_str(), body.GetAsString().c_str(), recipientName.GetAsString().c_str(), itemID, itemLOT, itemSubkey, itemCount, timeSent, wasRead);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user