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

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10602" #define REVISION_NR "10603"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__