[svn] * Fixed startup error flood if creature model id is 0

* Fixed totems using proper model ids broken after recent change
* Set pet grid activity state to that of caster upon summoning
* Fix a possible crash in ObjectAccessor
note to self: don't commit anything without 3 days testing. ever. after this one ofc.

--HG--
branch : trunk
This commit is contained in:
w12x
2008-10-27 15:28:04 -05:00
parent 1b820f93eb
commit dd97776501
6 changed files with 32 additions and 14 deletions

View File

@@ -533,10 +533,15 @@ ObjectAccessor::Update(uint32 diff)
// clone the active object list, because update might remove from it
std::set<WorldObject *> activeobjects(i_activeobjects);
std::set<WorldObject *>::const_iterator itr;
for(itr = activeobjects.begin(); itr != activeobjects.end(); ++itr)
std::set<WorldObject *>::iterator itr, next;
for(itr = activeobjects.begin(); itr != activeobjects.end(); itr = next)
{
(*itr)->GetMap()->resetMarkedCells();
next = itr;
++next;
if((*itr)->IsInWorld())
(*itr)->GetMap()->resetMarkedCells();
else
activeobjects.erase(itr);
}
Map *map;

View File

@@ -711,22 +711,22 @@ void ObjectMgr::LoadCreatureTemplates()
sLog.outErrorDb("Creature (Entry: %u) has non-existing faction_H template (%u)", cInfo->Entry, cInfo->faction_H);
// check model ids, supplying and sending non-existent ids to the client might crash them
if(!sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid1))
if(cInfo->Modelid1 && !sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid1))
{
sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_A (%u), setting it to 0", cInfo->Entry, cInfo->Modelid1);
const_cast<CreatureInfo*>(cInfo)->Modelid1 = 0;
}
if(!sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid2))
if(cInfo->Modelid2 && !sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid2))
{
sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_A2 (%u), setting it to 0", cInfo->Entry, cInfo->Modelid2);
const_cast<CreatureInfo*>(cInfo)->Modelid2 = 0;
}
if(!sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid3))
if(cInfo->Modelid3 && !sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid3))
{
sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_H (%u), setting it to 0", cInfo->Entry, cInfo->Modelid3);
const_cast<CreatureInfo*>(cInfo)->Modelid3 = 0;
}
if(!sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid4))
if(cInfo->Modelid4 && !sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid4))
{
sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_H2 (%u), setting it to 0", cInfo->Entry, cInfo->Modelid4);
const_cast<CreatureInfo*>(cInfo)->Modelid4 = 0;

View File

@@ -122,8 +122,6 @@ class Pet : public Creature
void AddToWorld();
void RemoveFromWorld();
// always active
void setActive() {}
PetType getPetType() const { return m_petType; }
void setPetType(PetType type) { m_petType = type; }

View File

@@ -903,7 +903,7 @@ class TRINITY_DLL_SPEC Player : public Unit
void AddToWorld();
void RemoveFromWorld();
// always active
void setActive() {}
void setActive(bool) {}
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0);

View File

@@ -3108,6 +3108,7 @@ void Spell::EffectSummon(uint32 i)
return;
uint32 level = m_caster->getLevel();
Pet* spawnCreature = new Pet(SUMMON_PET);
spawnCreature->setActive(m_caster->isActive());
if(spawnCreature->LoadPetFromDB(m_caster,pet_entry))
{
@@ -3543,6 +3544,7 @@ void Spell::EffectSummonGuardian(uint32 i)
for(int32 count = 0; count < amount; ++count)
{
Pet* spawnCreature = new Pet(GUARDIAN_PET);
spawnCreature->setActive(m_caster->isActive());
Map *map = m_caster->GetMap();
uint32 pet_number = objmgr.GeneratePetNumber();
@@ -3937,6 +3939,7 @@ void Spell::EffectSummonPet(uint32 i)
}
Pet* NewSummon = new Pet;
NewSummon->setActive(m_caster->isActive());
// petentry==0 for hunter "call pet" (current pet summoned if any)
if(NewSummon->LoadPetFromDB(m_caster,petentry))

View File

@@ -59,13 +59,25 @@ void Totem::Summon(Unit* owner)
CreatureInfo const *cinfo = GetCreatureInfo();
if (owner->GetTypeId()==TYPEID_PLAYER && cinfo)
{
if (uint32 modelid = cinfo->GetRandomValidModelId())
SetDisplayId(modelid);
uint32 modelid = 0;
if(((Player*)owner)->GetTeam() == HORDE)
{
if(cinfo->Modelid3)
modelid = cinfo->Modelid3;
else if(cinfo->Modelid4)
modelid = cinfo->Modelid4;
}
else
{
sLog.outErrorDb("No displayid found for the totem with the entry %u! Can't summon it!", GetEntry());
return;
if(cinfo->Modelid1)
modelid = cinfo->Modelid1;
else if(cinfo->Modelid2)
modelid = cinfo->Modelid2;
}
if (modelid)
SetDisplayId(modelid);
else
sLog.outErrorDb("Totem::Summon: Missing modelid information for entry %u, team %u, totem will use default values.",GetEntry(),((Player*)owner)->GetTeam());
}
// Only add if a display exists.