[10603] Replace one hard coded value w/enum name. Additional code style cleanup

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-10-13 09:41:14 +02:00
parent 589c9d8a5d
commit edbe9ed886
2 changed files with 32 additions and 29 deletions

View file

@ -185,11 +185,11 @@ void GameObject::Update(uint32 /*p_time*/)
case GAMEOBJECT_TYPE_FISHINGNODE:
{
// fishing code (bobber ready)
if( time(NULL) > m_respawnTime - FISHING_BOBBER_READY_TIME )
if (time(NULL) > m_respawnTime - FISHING_BOBBER_READY_TIME)
{
// splash bobber (bobber ready now)
Unit* caster = GetOwner();
if(caster && caster->GetTypeId()==TYPEID_PLAYER)
if (caster && caster->GetTypeId() == TYPEID_PLAYER)
{
SetGoState(GO_STATE_ACTIVE);
// SetUInt32Value(GAMEOBJECT_FLAGS, GO_FLAG_NODESPAWN);
@ -203,12 +203,12 @@ void GameObject::Update(uint32 /*p_time*/)
SendGameObjectCustomAnim(GetGUID());
}
m_lootState = GO_READY; // can be successfully open with some chance
m_lootState = GO_READY; // can be successfully open with some chance
}
return;
}
default:
m_lootState = GO_READY; // for other GOis same switched without delay to GO_READY
m_lootState = GO_READY; // for other GO is same switched without delay to GO_READY
break;
}
// NO BREAK for switch (m_lootState)
@ -224,17 +224,17 @@ void GameObject::Update(uint32 /*p_time*/)
switch (GetGoType())
{
case GAMEOBJECT_TYPE_FISHINGNODE: // can't fish now
case GAMEOBJECT_TYPE_FISHINGNODE: // can't fish now
{
Unit* caster = GetOwner();
if(caster && caster->GetTypeId()==TYPEID_PLAYER)
if (caster && caster->GetTypeId() == TYPEID_PLAYER)
{
caster->FinishSpell(CURRENT_CHANNELED_SPELL);
WorldPacket data(SMSG_FISH_NOT_HOOKED,0);
((Player*)caster)->GetSession()->SendPacket(&data);
}
// can be delete
// can be deleted
m_lootState = GO_JUST_DEACTIVATED;
return;
}
@ -247,18 +247,19 @@ void GameObject::Update(uint32 /*p_time*/)
default:
if (!m_spawnedByDefault) // despawn timer
{
// can be despawned or destroyed
// can be despawned or destroyed
SetLootState(GO_JUST_DEACTIVATED);
return;
}
// respawn timer
// respawn timer
GetMap()->Add(this);
break;
}
}
}
if(isSpawned())
if (isSpawned())
{
// traps can have time and can not have
GameObjectInfo const* goInfo = GetGOInfo();
@ -297,7 +298,7 @@ void GameObject::Update(uint32 /*p_time*/)
MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, owner, radius);
MaNGOS::UnitSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck> checker(ok, u_check);
Cell::VisitGridObjects(this,checker, radius);
if(!ok)
if (!ok)
Cell::VisitWorldObjects(this,checker, radius);
}
else // environmental trap
@ -370,16 +371,18 @@ void GameObject::Update(uint32 /*p_time*/)
}
case GO_JUST_DEACTIVATED:
{
//if Gameobject should cast spell, then this, but some GOs (type = 10) should be destroyed
// if Gameobject should cast spell, then this, but some GOs (type = 10) should be destroyed
if (GetGoType() == GAMEOBJECT_TYPE_GOOBER)
{
uint32 spellId = GetGOInfo()->goober.spellId;
if(spellId)
if (spellId)
{
for (GuidsSet::const_iterator itr = m_UniqueUsers.begin(); itr != m_UniqueUsers.end(); ++itr)
{
if (Player* owner = GetMap()->GetPlayer(*itr))
owner->CastSpell(owner, spellId, false, NULL, NULL, GetGUID());
}
ClearAllUsesData();
}
@ -389,9 +392,9 @@ void GameObject::Update(uint32 /*p_time*/)
//any return here in case battleground traps
}
if(GetOwnerGUID())
if (GetOwnerGUID())
{
if(Unit* owner = GetOwner())
if (Unit* owner = GetOwner())
owner->RemoveGameObject(this, false);
SetRespawnTime(0);
@ -399,7 +402,7 @@ void GameObject::Update(uint32 /*p_time*/)
return;
}
//burning flags in some battlegrounds, if you find better condition, just add it
// burning flags in some battlegrounds, if you find better condition, just add it
if (GetGOInfo()->IsDespawnAtAction() || GetGoAnimProgress() > 0)
{
SendObjectDeSpawnAnim(GetGUID());
@ -410,18 +413,18 @@ void GameObject::Update(uint32 /*p_time*/)
loot.clear();
SetLootState(GO_READY);
if(!m_respawnDelayTime)
if (!m_respawnDelayTime)
return;
// since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless
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_BOOL_SAVE_RESPAWN_TIME_IMMEDIATLY))
if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATLY))
SaveRespawnTime();
// if part of pool, let pool system schedule new spawn instead of just scheduling respawn
if(uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0)
if (uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0)
sPoolMgr.UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
// can be not in world at pool despawn
@ -1044,7 +1047,7 @@ void GameObject::Use(Unit* user)
{
GameObjectInfo const* info = GetGOInfo();
if(user->GetTypeId()==TYPEID_PLAYER)
if (user->GetTypeId() == TYPEID_PLAYER)
{
Player* player = (Player*)user;
@ -1117,7 +1120,7 @@ void GameObject::Use(Unit* user)
case GAMEOBJECT_TYPE_CAMERA: //13
{
GameObjectInfo const* info = GetGOInfo();
if(!info)
if (!info)
return;
if (user->GetTypeId() != TYPEID_PLAYER)
@ -1299,7 +1302,7 @@ void GameObject::Use(Unit* user)
}
case GAMEOBJECT_TYPE_SPELLCASTER: //22
{
SetUInt32Value(GAMEOBJECT_FLAGS,2);
SetUInt32Value(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
GameObjectInfo const* info = GetGOInfo();
if (!info)
@ -1372,7 +1375,7 @@ void GameObject::Use(Unit* user)
// 15004
// 15005
bg->EventPlayerClickedOnFlag(player, this);
return; //we don;t need to delete flag ... it is despawned!
return; //we don't need to delete flag ... it is despawned!
}
break;
}
@ -1413,15 +1416,15 @@ void GameObject::Use(Unit* user)
{
case 179785: // Silverwing Flag
// check if it's correct bg
if(bg->GetTypeID() == BATTLEGROUND_WS)
if (bg->GetTypeID() == BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag(player, this);
break;
case 179786: // Warsong Flag
if(bg->GetTypeID() == BATTLEGROUND_WS)
if (bg->GetTypeID() == BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag(player, this);
break;
case 184142: // Netherstorm Flag
if(bg->GetTypeID() == BATTLEGROUND_EY)
if (bg->GetTypeID() == BATTLEGROUND_EY)
bg->EventPlayerClickedOnFlag(player, this);
break;
}
@ -1460,7 +1463,7 @@ void GameObject::Use(Unit* user)
if (!spellId)
return;
SpellEntry const *spellInfo = sSpellStore.LookupEntry( spellId );
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo)
{
sLog.outError("WORLD: unknown spell id %u at use action for gameobject (Entry: %u GoType: %u )", spellId,GetEntry(),GetGoType());
@ -1471,7 +1474,7 @@ void GameObject::Use(Unit* user)
// spell target is user of GO
SpellCastTargets targets;
targets.setUnitTarget( user );
targets.setUnitTarget(user);
spell->prepare(&targets);
}