Skip to content

Commit

Permalink
[12271] Fix creature spline relocation with ForceDespawn command
Browse files Browse the repository at this point in the history
Close #29
Thanks to tarwyn and Grz3s for reporting the issue
  • Loading branch information
Schmoozerd committed Nov 18, 2012
1 parent 5fd088b commit 747a0ef
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/game/Creature.cpp
Expand Up @@ -235,6 +235,13 @@ void Creature::RemoveCorpse()
float x, y, z, o;
GetRespawnCoord(x, y, z, &o);
GetMap()->CreatureRelocation(this, x, y, z, o);

// forced recreate creature object at clients
UnitVisibility currentVis = GetVisibility();
SetVisibility(VISIBILITY_REMOVE_CORPSE);
UpdateObjectVisibility();
SetVisibility(currentVis); // restore visibility state
UpdateObjectVisibility();
}

/**
Expand Down Expand Up @@ -1559,13 +1566,6 @@ void Creature::Respawn()
{
RemoveCorpse();

// forced recreate creature object at clients
UnitVisibility currentVis = GetVisibility();
SetVisibility(VISIBILITY_RESPAWN);
UpdateObjectVisibility();
SetVisibility(currentVis); // restore visibility state
UpdateObjectVisibility();

if (IsDespawned())
{
if (HasStaticDBSpawnData())
Expand All @@ -1587,7 +1587,7 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn)
if (isAlive())
SetDeathState(JUST_DIED);

RemoveCorpse();
m_corpseDecayTimer = 1; // Properly remove corpse on next tick (also pool system requires Creature::Update call with CORPSE state
SetHealth(0); // just for nice GM-mode view
}

Expand Down
2 changes: 1 addition & 1 deletion src/game/Object.cpp
Expand Up @@ -1325,7 +1325,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const
}
case TYPEID_PLAYER:
{
// for server controlled moves playr work same as creature (but it can always swim)
// for server controlled moves player work same as creature (but it can always swim)
if (!((Player const*)this)->CanFly())
{
float ground_z = z;
Expand Down
4 changes: 2 additions & 2 deletions src/game/Unit.cpp
Expand Up @@ -8106,8 +8106,8 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo
if (!at_same_transport && (!IsInWorld() || !u->IsInWorld()))
return false;

// forbidden to seen (at GM respawn command)
if (m_Visibility == VISIBILITY_RESPAWN)
// forbidden to seen (while Removing corpse)
if (m_Visibility == VISIBILITY_REMOVE_CORPSE)
return false;

Map& _map = *u->GetMap();
Expand Down
2 changes: 1 addition & 1 deletion src/game/Unit.h
Expand Up @@ -516,7 +516,7 @@ enum UnitVisibility
VISIBILITY_GROUP_STEALTH = 2, // detect chance, seen and can see group members
VISIBILITY_GROUP_INVISIBILITY = 3, // invisibility, can see and can be seen only another invisible unit or invisible detection unit, set only if not stealthed, and in checks not used (mask used instead)
VISIBILITY_GROUP_NO_DETECT = 4, // state just at stealth apply for update Grid state. Don't remove, otherwise stealth spells will break
VISIBILITY_RESPAWN = 5 // special totally not detectable visibility for force delete object at respawn command
VISIBILITY_REMOVE_CORPSE = 5 // special totally not detectable visibility for force delete object while removing a corpse
};

// Value masks for UNIT_FIELD_FLAGS
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12270"
#define REVISION_NR "12271"
#endif // __REVISION_NR_H__

1 comment on commit 747a0ef

@Grz3s
Copy link
Member

@Grz3s Grz3s commented on 747a0ef Nov 18, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested and works perfect
thank you very much ...

Please sign in to comment.