Skip to content

Commit

Permalink
Core: Random cleanup + compile fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Shauren committed Feb 23, 2012
1 parent dbd8cbc commit dc28b92
Show file tree
Hide file tree
Showing 20 changed files with 114 additions and 113 deletions.
14 changes: 3 additions & 11 deletions src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
Expand Up @@ -62,27 +62,19 @@ void SmartWaypointMgr::LoadFromDB()
y = fields[3].GetFloat();
z = fields[4].GetFloat();

WayPoint* wp = new WayPoint(id, x, y, z);

if (last_entry != entry)
{
path = new WPPath;
waypoint_map[entry] = new WPPath();
last_id = 1;
count++;
}

if (last_id != id)
{
sLog->outErrorDb("SmartWaypointMgr::LoadFromDB: Path entry %u, unexpected point id %u, expected %u.", entry, id, last_id);
}

last_id++;
(*path)[id] = wp;
(*waypoint_map[entry])[id] = new WayPoint(id, x, y, z);

if (last_entry != entry)
{
count++;
waypoint_map[entry] = path;
}
last_entry = entry;
total++;
}
Expand Down
4 changes: 3 additions & 1 deletion src/server/game/Battlegrounds/ArenaTeam.cpp
Expand Up @@ -295,8 +295,10 @@ void ArenaTeam::SetCaptain(uint64 guid)
if (newCaptain)
{
newCaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 0);
char const* oldCaptainName = oldCaptain ? oldCaptain->GetName() : "";
uint32 oldCaptainLowGuid = oldCaptain ? oldCaptain->GetGUIDLow() : 0;
sLog->outArena("Player: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team [Id: %u] [Type: %u].",
oldCaptain->GetName(), oldCaptain->GetGUIDLow(), newCaptain->GetName(), newCaptain->GetGUIDLow(), GetId(), GetType());
oldCaptainName, oldCaptainLowGuid, newCaptain->GetName(), newCaptain->GetGUIDLow(), GetId(), GetType());
}
}

Expand Down
15 changes: 8 additions & 7 deletions src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
Expand Up @@ -1032,17 +1032,18 @@ void BattlegroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object)
std::vector<uint64> ghost_list = m_ReviveQueue[BgCreatures[node]];
if (!ghost_list.empty())
{
Player* player;
WorldSafeLocsEntry const* ClosestGrave = NULL;
Player* waitingPlayer; // player waiting at graveyard for resurrection
WorldSafeLocsEntry const* closestGrave = NULL;
for (std::vector<uint64>::iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr)
{
player = ObjectAccessor::FindPlayer(*ghost_list.begin());
if (!player)
waitingPlayer = ObjectAccessor::FindPlayer(*ghost_list.begin());
if (!waitingPlayer)
continue;
if (!ClosestGrave)
ClosestGrave = GetClosestGraveYard(player);

if (!closestGrave)
closestGrave = GetClosestGraveYard(waitingPlayer);
else
player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation());
waitingPlayer->TeleportTo(GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation());
}
m_ReviveQueue[BgCreatures[node]].clear();
}
Expand Down
20 changes: 10 additions & 10 deletions src/server/game/Entities/Creature/Creature.cpp
Expand Up @@ -2408,24 +2408,24 @@ bool Creature::IsDungeonBoss() const
return cinfo && (cinfo->flags_extra & CREATURE_FLAG_EXTRA_DUNGEON_BOSS);
}

void Creature::SetWalk(bool enable)
bool Creature::SetWalk(bool enable)
{
if (enable)
AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
else
RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
if (!Unit::SetWalk(enable))
return false;

WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_WALK_MODE : SMSG_SPLINE_MOVE_SET_RUN_MODE, 9);
data.append(GetPackGUID());
SendMessageToSet(&data, true);
return true;
}

void Creature::SetLevitate(bool enable)
bool Creature::SetLevitate(bool enable)
{
if (enable)
AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
else
RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
if (!Unit::SetLevitate(enable))
return false;

WorldPacket data(enable ? SMSG_SPLINE_MOVE_GRAVITY_DISABLE : SMSG_SPLINE_MOVE_GRAVITY_ENABLE, 9);
data.append(GetPackGUID());
SendMessageToSet(&data, true);
return true;
}
4 changes: 2 additions & 2 deletions src/server/game/Entities/Creature/Creature.h
Expand Up @@ -520,8 +520,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type);
CreatureAI* AI() const { return (CreatureAI*)i_AI; }

void SetWalk(bool enable);
void SetLevitate(bool enable);
bool SetWalk(bool enable);
bool SetLevitate(bool enable);

uint32 GetShieldBlockValue() const //dunno mob block value
{
Expand Down
44 changes: 19 additions & 25 deletions src/server/game/Entities/Player/Player.cpp
Expand Up @@ -7944,14 +7944,12 @@ void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply
_ApplyWeaponDamage(slot, proto, ssv, apply);

// Apply feral bonus from ScalingStatValue if set
if (ssv)
if (int32 feral_bonus = ssv->getFeralBonus(proto->ScalingStatValue))
ApplyFeralAPBonus(feral_bonus, apply);

// Druids get feral AP bonus from weapon dps (lso use DPS from ScalingStatValue)
if (getClass() == CLASS_DRUID)
if (int32 feral_bonus = proto->getFeralBonus(ssv->getDPSMod(proto->ScalingStatValue)))
if (ssv && getClass() == CLASS_DRUID)
{
int32 feral_bonus = ssv->getFeralBonus(proto->ScalingStatValue) + proto->getFeralBonus(ssv->getDPSMod(proto->ScalingStatValue));
if (feral_bonus)
ApplyFeralAPBonus(feral_bonus, apply);
}
}

void Player::_ApplyWeaponDamage(uint8 slot, ItemTemplate const* proto, ScalingStatValuesEntry const* ssv, bool apply)
Expand Down Expand Up @@ -14071,12 +14069,10 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
menuItemBounds = sObjectMgr->GetGossipMenuItemsMapBounds(0);

uint32 npcflags = 0;
Creature* creature = NULL;

if (source->GetTypeId() == TYPEID_UNIT)
{
creature = source->ToCreature();
npcflags = creature->GetUInt32Value(UNIT_NPC_FLAGS);
npcflags = source->GetUInt32Value(UNIT_NPC_FLAGS);
if (npcflags & UNIT_NPC_FLAG_QUESTGIVER && showQuests)
PrepareQuestMenu(source->GetGUID());
}
Expand All @@ -14091,7 +14087,7 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
if (!sConditionMgr->IsObjectMeetToConditions(this, source, itr->second.Conditions))
continue;

if (source->GetTypeId() == TYPEID_UNIT)
if (Creature* creature = source->ToCreature())
{
if (!(itr->second.OptionNpcflag & npcflags))
continue;
Expand Down Expand Up @@ -14164,10 +14160,8 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
break;
}
}
else if (source->GetTypeId() == TYPEID_GAMEOBJECT)
else if (GameObject* go = source->ToGameObject())
{
GameObject* go = source->ToGameObject();

switch (itr->second.OptionType)
{
case GOSSIP_OPTION_GOSSIP:
Expand Down Expand Up @@ -16002,9 +15996,9 @@ void Player::CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id)
if (reqTarget != entry) // if entry doesn't match, check for killcredits referenced in template
{
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
for (uint8 j = 0; j < MAX_KILL_CREDIT; ++j)
if (cinfo->KillCredit[j] == reqTarget)
entry = cinfo->KillCredit[j];
for (uint8 k = 0; k < MAX_KILL_CREDIT; ++k)
if (cinfo->KillCredit[k] == reqTarget)
entry = cinfo->KillCredit[k];
}
}
}
Expand Down Expand Up @@ -17649,7 +17643,7 @@ void Player::_LoadMailedItems(Mail* mail)
{
sLog->outError("Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), itemGuid, itemTemplate, mail->messageID);

PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_INVALID_MAIL_ITEM);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_INVALID_MAIL_ITEM);
stmt->setUInt32(0, itemGuid);
CharacterDatabase.Execute(stmt);

Expand All @@ -17665,10 +17659,8 @@ void Player::_LoadMailedItems(Mail* mail)
{
sLog->outError("Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, itemGuid);

PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM);

stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM);
stmt->setUInt32(0, itemGuid);

CharacterDatabase.Execute(stmt);

item->FSetState(ITEM_REMOVED);
Expand Down Expand Up @@ -19044,20 +19036,22 @@ void Player::_SaveDailyQuestStatus(SQLTransaction& trans)
stmt->setUInt32(0, GetGUIDLow());
trans->Append(stmt);
for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
{
if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx))
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_DAILYQUESTSTATUS);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_DAILYQUESTSTATUS);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(1, GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx));
stmt->setUInt64(2, uint64(m_lastDailyQuestTime));
trans->Append(stmt);
}
}

if (!m_DFQuests.empty())
{
for (DFQuestsDoneList::iterator itr = m_DFQuests.begin(); itr != m_DFQuests.end(); ++itr)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_DAILYQUESTSTATUS);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_DAILYQUESTSTATUS);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(1, (*itr));
stmt->setUInt64(2, uint64(m_lastDailyQuestTime));
Expand All @@ -19080,7 +19074,7 @@ void Player::_SaveWeeklyQuestStatus(SQLTransaction& trans)
{
uint32 quest_id = *iter;

PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_WEEKLYQUESTSTATUS);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_WEEKLYQUESTSTATUS);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(1, quest_id);
trans->Append(stmt);
Expand All @@ -19106,7 +19100,7 @@ void Player::_SaveSeasonalQuestStatus(SQLTransaction& trans)
{
uint32 quest_id = (*itr);

PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_SEASONALQUESTSTATUS);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_SEASONALQUESTSTATUS);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(1, quest_id);
stmt->setUInt32(2, event_id);
Expand Down
30 changes: 24 additions & 6 deletions src/server/game/Entities/Unit/Unit.cpp
Expand Up @@ -1469,8 +1469,8 @@ uint32 Unit::CalcArmorReducedDamage(Unit* victim, const uint32 damage, SpellInfo
if (GetTypeId() == TYPEID_PLAYER)
{
float bonusPct = 0;
AuraEffectList const& ResIgnoreAuras = GetAuraEffectsByType(SPELL_AURA_MOD_ARMOR_PENETRATION_PCT);
for (AuraEffectList::const_iterator itr = ResIgnoreAuras.begin(); itr != ResIgnoreAuras.end(); ++itr)
AuraEffectList const& armorPenAuras = GetAuraEffectsByType(SPELL_AURA_MOD_ARMOR_PENETRATION_PCT);
for (AuraEffectList::const_iterator itr = armorPenAuras.begin(); itr != armorPenAuras.end(); ++itr)
{
if ((*itr)->GetSpellInfo()->EquippedItemClass == -1)
{
Expand Down Expand Up @@ -15459,7 +15459,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
// Inform pets (if any) when player kills target)
// MUST come after victim->setDeathState(JUST_DIED); or pet next target
// selection will get stuck on same target and break pet react state
if (Player* player = ToPlayer())
if (player)
{
Pet* pet = player->GetPet();
if (pet && pet->isAlive() && pet->isControlled())
Expand Down Expand Up @@ -17003,7 +17003,7 @@ void Unit::ExitVehicle(Position const* exitPosition)
return;

GetVehicleBase()->RemoveAurasByType(SPELL_AURA_CONTROL_VEHICLE, GetGUID());
//! The following call would not even be executed successfully as the
//! The following call would not even be executed successfully as the
//! SPELL_AURA_CONTROL_VEHICLE unapply handler already calls _ExitVehicle without
//! specifying an exitposition. The subsequent call below would return on if (!m_vehicle).
/*_ExitVehicle(exitPosition);*/
Expand Down Expand Up @@ -17456,10 +17456,28 @@ void Unit::SetFacingToObject(WorldObject* pObject)
SetFacingTo(GetAngle(pObject));
}

void Unit::SetWalk(bool enable)
bool Unit::SetWalk(bool enable)
{
if (enable == IsWalking())
return false;

if (enable)
AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
else
RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);

return true;
}

bool Unit::SetLevitate(bool enable)
{
if (enable == IsLevitating())
return false;

if (enable)
AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
else
RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
}

return true;
}
3 changes: 2 additions & 1 deletion src/server/game/Entities/Unit/Unit.h
Expand Up @@ -1627,7 +1627,8 @@ class Unit : public WorldObject
void SendMovementFlagUpdate();
bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_LEVITATING);}
bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING);}
virtual void SetWalk(bool enable);
virtual bool SetWalk(bool enable);
virtual bool SetLevitate(bool enable);

void SetInFront(Unit const* target);
void SetFacingTo(float ori);
Expand Down
22 changes: 11 additions & 11 deletions src/server/game/Handlers/AuctionHouseHandler.cpp
Expand Up @@ -309,28 +309,28 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
sAuctionMgr->AddAItem(newItem);
auctionHouse->AddAuction(AH);

for (uint32 i = 0; i < itemsCount; ++i)
for (uint32 j = 0; j < itemsCount; ++j)
{
Item* item = items[i];
Item* item2 = items[j];

if (item->GetCount() == count[i])
if (item2->GetCount() == count[j])
{
_player->MoveItemFromInventory(item->GetBagSlot(), item->GetSlot(), true);
_player->MoveItemFromInventory(item2->GetBagSlot(), item2->GetSlot(), true);

SQLTransaction trans = CharacterDatabase.BeginTransaction();
item->DeleteFromInventoryDB(trans);
item->SaveToDB(trans);
item2->DeleteFromInventoryDB(trans);
item2->SaveToDB(trans);
CharacterDatabase.CommitTransaction(trans);
}
else
{
item->SetCount(item->GetCount() - count[i]);
item->SetState(ITEM_CHANGED, _player);
_player->ItemRemovedQuestCheck(item->GetEntry(), count[i]);
item->SendUpdateToPlayer(_player);
item2->SetCount(item2->GetCount() - count[j]);
item2->SetState(ITEM_CHANGED, _player);
_player->ItemRemovedQuestCheck(item2->GetEntry(), count[j]);
item2->SendUpdateToPlayer(_player);

SQLTransaction trans = CharacterDatabase.BeginTransaction();
item->SaveToDB(trans);
item2->SaveToDB(trans);
CharacterDatabase.CommitTransaction(trans);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/Handlers/CharacterHandler.cpp
Expand Up @@ -1811,8 +1811,8 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD))
{
// Reset guild
if (QueryResult result = CharacterDatabase.PQuery("SELECT guildid FROM `guild_member` WHERE guid ='%u'", lowGuid))
if (Guild* guild = sGuildMgr->GetGuildById((result->Fetch()[0]).GetUInt32()))
if (QueryResult result2 = CharacterDatabase.PQuery("SELECT guildid FROM `guild_member` WHERE guid ='%u'", lowGuid))
if (Guild* guild = sGuildMgr->GetGuildById((result2->Fetch()[0]).GetUInt32()))
guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER));
}

Expand Down
Expand Up @@ -79,7 +79,7 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
if (i_path->at(i_currentNode)->event_id && urand(0, 99) < i_path->at(i_currentNode)->event_chance)
{
sLog->outDebug(LOG_FILTER_MAPSCRIPTS, "Creature movement start script %u at point %u for "UI64FMTD".", i_path->at(i_currentNode)->event_id, i_currentNode, creature.GetGUID());
creature.GetMap()->ScriptsStart(sWaypointScripts, i_path->at(i_currentNode)->event_id, &creature, NULL/*, false*/);
creature.GetMap()->ScriptsStart(sWaypointScripts, i_path->at(i_currentNode)->event_id, &creature, NULL);
}

// Inform script
Expand Down

0 comments on commit dc28b92

Please sign in to comment.