Skip to content

Commit

Permalink
[10603] Replace one hard coded value w/enum name. Additional code sty…
Browse files Browse the repository at this point in the history
…le cleanup

Signed-off-by: NoFantasy <nofantasy@nf.no>
  • Loading branch information
NoFantasy committed Oct 13, 2010
1 parent 778be4b commit 1b2b793
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
59 changes: 31 additions & 28 deletions src/game/GameObject.cpp
Expand Up @@ -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);
Expand All @@ -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)
Expand All @@ -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;
}
Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
Expand All @@ -389,17 +392,17 @@ 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);
Delete();
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());
Expand All @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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());
Expand All @@ -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);
}
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 "10602"
#define REVISION_NR "10603"
#endif // __REVISION_NR_H__

0 comments on commit 1b2b793

Please sign in to comment.