fix: property behavior crashes (#1813)

This commit is contained in:
David Markowitz 2025-06-08 19:41:43 -07:00 committed by GitHub
parent 2858345269
commit c19ee04c8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 17 additions and 6 deletions

View File

@ -4,7 +4,7 @@
#include <assert.h> #include <assert.h>
#ifdef _DEBUG #ifdef _DEBUG
# define DluAssert(expression) do { assert(expression) } while(0) # define DluAssert(expression) do { assert(expression); } while(0)
#else #else
# define DluAssert(expression) # define DluAssert(expression)
#endif #endif

View File

@ -84,9 +84,11 @@ void Strip::HandleMsg(MigrateActionsMessage& msg) {
template<> template<>
void Strip::HandleMsg(GameMessages::RequestUse& msg) { void Strip::HandleMsg(GameMessages::RequestUse& msg) {
if (m_PausedTime > 0.0f) return; if (m_PausedTime > 0.0f || !HasMinimumActions()) return;
if (m_Actions[m_NextActionIndex].GetType() == "OnInteract") { auto& nextAction = GetNextAction();
if (nextAction.GetType() == "OnInteract") {
IncrementAction(); IncrementAction();
m_WaitingForAction = false; m_WaitingForAction = false;
} }
@ -170,7 +172,6 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent) {
LOG("Tried to play action (%s) which is not supported.", nextActionType.data()); LOG("Tried to play action (%s) which is not supported.", nextActionType.data());
g_WarnedActions.insert(nextActionType.data()); g_WarnedActions.insert(nextActionType.data());
} }
return;
} }
IncrementAction(); IncrementAction();
@ -190,11 +191,17 @@ void Strip::RemoveStates(ModelComponent& modelComponent) const {
} }
void Strip::Update(float deltaTime, ModelComponent& modelComponent) { void Strip::Update(float deltaTime, ModelComponent& modelComponent) {
// No point in running a strip with only one action.
// Strips are also designed to have 2 actions or more to run.
if (!HasMinimumActions()) return;
// Don't run this strip if we're paused.
m_PausedTime -= deltaTime; m_PausedTime -= deltaTime;
if (m_PausedTime > 0.0f) return; if (m_PausedTime > 0.0f) return;
m_PausedTime = 0.0f; m_PausedTime = 0.0f;
// Return here if we're waiting for external interactions to continue.
if (m_WaitingForAction) return; if (m_WaitingForAction) return;
auto& entity = *modelComponent.GetParent(); auto& entity = *modelComponent.GetParent();

View File

@ -33,6 +33,9 @@ public:
void SpawnDrop(LOT dropLOT, Entity& entity); void SpawnDrop(LOT dropLOT, Entity& entity);
void ProcNormalAction(float deltaTime, ModelComponent& modelComponent); void ProcNormalAction(float deltaTime, ModelComponent& modelComponent);
void RemoveStates(ModelComponent& modelComponent) const; void RemoveStates(ModelComponent& modelComponent) const;
// 2 actions are required for strips to work
bool HasMinimumActions() const { return m_Actions.size() >= 2; }
private: private:
// Indicates this Strip is waiting for an action to be taken upon it to progress to its actions // Indicates this Strip is waiting for an action to be taken upon it to progress to its actions
bool m_WaitingForAction{ false }; bool m_WaitingForAction{ false };

View File

@ -713,12 +713,12 @@ void HandleMasterPacket(Packet* packet) {
//Create our user and send them in: //Create our user and send them in:
UserManager::Instance()->CreateUser(it->second.sysAddr, username.GetAsString(), userHash); UserManager::Instance()->CreateUser(it->second.sysAddr, username.GetAsString(), userHash);
auto zone = Game::zoneManager->GetZone(); if (Game::zoneManager->HasZone()) {
if (zone) {
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
float z = 0.0f; float z = 0.0f;
auto zone = Game::zoneManager->GetZone();
if (zone->GetZoneID().GetMapID() == 1100) { if (zone->GetZoneID().GetMapID() == 1100) {
auto pos = zone->GetSpawnPos(); auto pos = zone->GetSpawnPos();
x = pos.x; x = pos.x;

View File

@ -29,6 +29,7 @@ public:
/* Gets a pointer to the currently loaded zone. */ /* Gets a pointer to the currently loaded zone. */
Zone* GetZoneMut() const; Zone* GetZoneMut() const;
const Zone* GetZone() const { return GetZoneMut(); }; const Zone* GetZone() const { return GetZoneMut(); };
bool HasZone() const { return m_pZone != nullptr; };
void LoadZone(const LWOZONEID& zoneID); //Discard the current zone (if any) and loads a new zone. void LoadZone(const LWOZONEID& zoneID); //Discard the current zone (if any) and loads a new zone.
/* Adds a spawner to the zone with the specified ID. */ /* Adds a spawner to the zone with the specified ID. */