Jump to content

[10226][bug+fix] Loot chests spawned by scripts.


Auntie Mangos

Recommended Posts

  • 39 years later...

What bug does the patch fix? What features does the patch add?

There is an exploit related to loot chests spawned by scripts, like Four Horsemen etc. If the player stands still while looting the chest, chest doesn't disappear after player takes all the loot, and it can be looted again and again, giving new loot, until the player moves.

For which repository revision was the patch created?

8869

Who has been writing this patch? Please include either forum user names or email addresses.

Me, Lutik.

diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index 0aa6f7f..4209298 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -431,13 +431,7 @@ void GameObject::Update(uint32 /*p_time*/)
            if(!m_respawnDelayTime)
                return;

-            if(!m_spawnedByDefault)
-            {
-                m_respawnTime = 0;
-                return;
-            }
-
-            m_respawnTime = time(NULL) + m_respawnDelayTime;
+            m_respawnTime = m_spawnedByDefault ? time(NULL) + m_respawnDelayTime : 0;

            // if option not set then object will be saved at grid unload
            if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY))

m_spawnedByDefault is false for such chests, and in that case (as you can see in red lines of code) return is called without updating gameobject's visibility (which is located just a few lines below). So, without this patch, the chest remains visible for the player even when it is despawned, until the player moves and visibility update is called for him in some other place.

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 months later...

This is probably more correct version of the patch:

diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index 0bfb0b9..1826608 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -438,7 +438,11 @@ void GameObject::Update(uint32 /*p_time*/)
            if(!m_spawnedByDefault)
            {
                m_respawnTime = 0;
-                return;
+
+                if (IsInWorld())
+                    UpdateObjectVisibility();
+
+                break;
            }

            // since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 3 weeks later...
  • 3 months later...
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use