This commit is contained in:
QAston
2011-07-01 12:48:21 +02:00
417 changed files with 4942 additions and 2694 deletions
+62 -33
View File
@@ -313,75 +313,85 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c
class EventMap : private std::map<uint32, uint32>
{
private:
uint32 m_time, m_phase;
public:
explicit EventMap(): m_time(0), m_phase(0) {}
EventMap() : _time(0), _phase(0) {}
uint32 GetTimer() const { return m_time; }
// Returns current timer value, does not represent real dates/times
uint32 GetTimer() const { return _time; }
void Reset() { clear(); m_time = 0; m_phase = 0; }
// Removes all events and clears phase
void Reset() { clear(); _time = 0; _phase = 0; }
void Update(uint32 time) { m_time += time; }
void Update(uint32 time) { _time += time; }
uint32 GetPhaseMask() const { return (m_phase >> 24) & 0xFF; }
uint32 GetPhaseMask() const { return (_phase >> 24) & 0xFF; }
// Sets event phase, must be in range 1 - 8
void SetPhase(uint32 phase)
{
if (phase && phase < 9)
m_phase = (1 << (phase + 24));
_phase = (1 << (phase + 24));
}
void ScheduleEvent(uint32 eventId, uint32 time, uint32 gcd = 0, uint32 phase = 0)
// Creates new event entry in map with given id, time, group if given (1 - 8) and phase if given (1 - 8)
// 0 for group/phase means it belongs to no group or runs in all phases
void ScheduleEvent(uint32 eventId, uint32 time, uint32 groupId = 0, uint32 phase = 0)
{
time += m_time;
if (gcd && gcd < 9)
eventId |= (1 << (gcd + 16));
time += _time;
if (groupId && groupId < 9)
eventId |= (1 << (groupId + 16));
if (phase && phase < 9)
eventId |= (1 << (phase + 24));
iterator itr = find(time);
const_iterator itr = find(time);
while (itr != end())
{
++time;
itr = find(time);
}
insert(std::make_pair(time, eventId));
}
void RescheduleEvent(uint32 eventId, uint32 time, uint32 gcd = 0, uint32 phase = 0)
// Removes event with specified id and creates new entry for it
void RescheduleEvent(uint32 eventId, uint32 time, uint32 groupId = 0, uint32 phase = 0)
{
CancelEvent(eventId);
ScheduleEvent(eventId, time, gcd, phase);
ScheduleEvent(eventId, time, groupId, phase);
}
// Reschedules closest event
void RepeatEvent(uint32 time)
{
if (empty())
return;
uint32 eventId = begin()->second;
erase(begin());
time += m_time;
iterator itr = find(time);
time += _time;
const_iterator itr = find(time);
while (itr != end())
{
++time;
itr = find(time);
}
insert(std::make_pair(time, eventId));
}
// Removes first event
void PopEvent()
{
erase(begin());
}
// Gets next event id to execute and removes it from map
uint32 ExecuteEvent()
{
while (!empty())
{
if (begin()->first > m_time)
if (begin()->first > _time)
return 0;
else if (m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase))
else if (_phase && (begin()->second & 0xFF000000) && !(begin()->second & _phase))
erase(begin());
else
{
@@ -393,39 +403,41 @@ class EventMap : private std::map<uint32, uint32>
return 0;
}
// Gets next event id to execute
uint32 GetEvent()
{
while (!empty())
{
if (begin()->first > m_time)
if (begin()->first > _time)
return 0;
else if (m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase))
else if (_phase && (begin()->second & 0xFF000000) && !(begin()->second & _phase))
erase(begin());
else
return (begin()->second & 0x0000FFFF);
}
return 0;
}
// Delay all events
void DelayEvents(uint32 delay)
{
if (delay < m_time)
m_time -= delay;
if (delay < _time)
_time -= delay;
else
m_time = 0;
_time = 0;
}
// Delay all events having the specified Global Cooldown.
void DelayEvents(uint32 delay, uint32 gcd)
// Delay all events having the specified Group
void DelayEvents(uint32 delay, uint32 groupId)
{
uint32 nextTime = m_time + delay;
gcd = (1 << (gcd + 16));
uint32 nextTime = _time + delay;
uint32 groupMask = (1 << (groupId + 16));
for (iterator itr = begin(); itr != end() && itr->first < nextTime;)
{
if (itr->second & gcd)
if (itr->second & groupMask)
{
ScheduleEvent(itr->second, itr->first-m_time+delay);
ScheduleEvent(itr->second, itr->first - _time + delay);
erase(itr);
itr = begin();
}
@@ -434,6 +446,7 @@ class EventMap : private std::map<uint32, uint32>
}
}
// Cancel events with specified id
void CancelEvent(uint32 eventId)
{
for (iterator itr = begin(); itr != end();)
@@ -448,13 +461,14 @@ class EventMap : private std::map<uint32, uint32>
}
}
void CancelEventsByGCD(uint32 gcd)
// Cancel events belonging to specified group
void CancelEventGroup(uint32 groupId)
{
gcd = (1 << (gcd + 16));
uint32 groupMask = (1 << (groupId + 16));
for (iterator itr = begin(); itr != end();)
{
if (itr->second & gcd)
if (itr->second & groupMask)
{
erase(itr);
itr = begin();
@@ -463,6 +477,21 @@ class EventMap : private std::map<uint32, uint32>
++itr;
}
}
// Returns time of next event to execute
// To get how much time remains substract _time
uint32 GetNextEventTime(uint32 eventId) const
{
for (const_iterator itr = begin(); itr != end(); ++itr)
if (eventId == (itr->second & 0x0000FFFF))
return itr->first;
return 0;
}
private:
uint32 _time;
uint32 _phase;
};
enum AITarget
+2 -2
View File
@@ -108,7 +108,7 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname,
normalizeString(new_passwd);
std::string safe_new_uname = new_uname;
LoginDatabase.escape_string(safe_new_uname);
LoginDatabase.EscapeString(safe_new_uname);
LoginDatabase.PExecute("UPDATE account SET v='0', s='0', username='%s', sha_pass_hash='%s' WHERE id='%d'", safe_new_uname.c_str(),
CalculateShaPassHash(new_uname, new_passwd).c_str(), accid);
@@ -138,7 +138,7 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd)
uint32 AccountMgr::GetId(std::string username)
{
LoginDatabase.escape_string(username);
LoginDatabase.EscapeString(username);
QueryResult result = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", username.c_str());
if (!result)
return 0;
+1 -1
View File
@@ -67,7 +67,7 @@ void AddonMgr::LoadFromDB()
void AddonMgr::SaveAddon(AddonInfo const& addon)
{
std::string name = addon.Name;
CharacterDatabase.escape_string(name);
CharacterDatabase.EscapeString(name);
CharacterDatabase.PExecute("INSERT INTO addons (name, crc) VALUES ('%s', %u)", name.c_str(), addon.CRC);
SavedAddon newAddon(addon.Name, addon.CRC);
+1 -1
View File
@@ -93,7 +93,7 @@ bool ChatHandler::HandleServerInfoCommand(const char* /*args*/)
std::string uptime = secsToTimeString(sWorld->GetUptime());
uint32 updateTime = sWorld->GetUpdateTime();
PSendSysMessage(_FULLVERSION);
SendSysMessage(_FULLVERSION);
PSendSysMessage(LANG_CONNECTED_PLAYERS, PlayersNum, MaxPlayersNum);
PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum);
PSendSysMessage(LANG_UPTIME, uptime.c_str());
+3 -3
View File
@@ -611,7 +611,7 @@ bool ChatHandler::HandleLookupPlayerIpCommand(const char* args)
char* limit_str = strtok (NULL, " ");
int32 limit = limit_str ? atoi (limit_str) : -1;
LoginDatabase.escape_string (ip);
LoginDatabase.EscapeString (ip);
QueryResult result = LoginDatabase.PQuery ("SELECT id, username FROM account WHERE last_ip = '%s'", ip.c_str ());
@@ -630,7 +630,7 @@ bool ChatHandler::HandleLookupPlayerAccountCommand(const char* args)
if (!AccountMgr::normalizeString (account))
return false;
LoginDatabase.escape_string (account);
LoginDatabase.EscapeString (account);
QueryResult result = LoginDatabase.PQuery ("SELECT id, username FROM account WHERE username = '%s'", account.c_str ());
@@ -647,7 +647,7 @@ bool ChatHandler::HandleLookupPlayerEmailCommand(const char* args)
char* limit_str = strtok (NULL, " ");
int32 limit = limit_str ? atoi (limit_str) : -1;
LoginDatabase.escape_string (email);
LoginDatabase.EscapeString (email);
QueryResult result = LoginDatabase.PQuery ("SELECT id, username FROM account WHERE email = '%s'", email.c_str ());
+4 -4
View File
@@ -225,7 +225,7 @@ bool ChatHandler::HandleAddItemCommand(const char *args)
if (citemName && citemName[0])
{
std::string itemName = citemName+1;
WorldDatabase.escape_string(itemName);
WorldDatabase.EscapeString(itemName);
QueryResult result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str());
if (!result)
{
@@ -3184,7 +3184,7 @@ bool ChatHandler::HandleBanInfoIPCommand(const char *args)
std::string IP = cIP;
LoginDatabase.escape_string(IP);
LoginDatabase.EscapeString(IP);
QueryResult result = LoginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason, bannedby, unbandate-bandate FROM ip_banned WHERE ip = '%s'", IP.c_str());
if (!result)
{
@@ -3293,7 +3293,7 @@ bool ChatHandler::HandleBanListAccountCommand(const char *args)
char* cFilter = strtok((char*)args, " ");
std::string filter = cFilter ? cFilter : "";
LoginDatabase.escape_string(filter);
LoginDatabase.EscapeString(filter);
QueryResult result;
@@ -3398,7 +3398,7 @@ bool ChatHandler::HandleBanListIPCommand(const char *args)
char* cFilter = strtok((char*)args, " ");
std::string filter = cFilter ? cFilter : "";
LoginDatabase.escape_string(filter);
LoginDatabase.EscapeString(filter);
QueryResult result;
+1 -1
View File
@@ -384,7 +384,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
{
uint32 owner = GUID_LOPART(GetOwnerGUID());
std::string name = m_name;
CharacterDatabase.escape_string(name);
CharacterDatabase.EscapeString(name);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
// remove current data
trans->PAppend("DELETE FROM character_pet WHERE owner = '%u' AND id = '%u'", owner, m_charmInfo->GetPetNumber());
+1 -1
View File
@@ -18186,7 +18186,7 @@ void Player::SaveToDB()
outDebugValues();
std::string sql_name = m_name;
CharacterDatabase.escape_string(sql_name);
CharacterDatabase.EscapeString(sql_name);
std::ostringstream ss;
ss << "REPLACE INTO characters (guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, "
@@ -108,7 +108,7 @@ void PlayerSocial::SetFriendNote(uint32 friend_guid, std::string note)
utf8truncate(note, 48); // DB and client size limitation
CharacterDatabase.escape_string(note);
CharacterDatabase.EscapeString(note);
CharacterDatabase.PExecute("UPDATE character_social SET note = '%s' WHERE guid = '%u' AND friend = '%u'", note.c_str(), GetPlayerGUID(), friend_guid);
m_playerSocialMap[friend_guid].Note = note;
}
+1 -1
View File
@@ -3797,7 +3797,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit
if (aura->IsSingleTarget())
aura->UnregisterSingleTarget();
if (newAura = Aura::TryRefreshStackOrCreate(aura->GetSpellProto(), effMask, stealer, NULL, &baseDamage[0], NULL, aura->GetCasterGUID()))
if (Aura* newAura = Aura::TryRefreshStackOrCreate(aura->GetSpellProto(), effMask, stealer, NULL, &baseDamage[0], NULL, aura->GetCasterGUID()))
{
// created aura must not be single target aura,, so stealer won't loose it on recast
if (newAura->IsSingleTarget())
+1 -1
View File
@@ -286,7 +286,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia
Corpse* bones = NULL;
// create the bones only if the map and the grid is loaded at the corpse's location
// ignore bones creating option in case insignia
if (map && (insignia ||
(map->IsBattlegroundOrArena() ? sWorld->getBoolConfig(CONFIG_DEATH_BONES_BG_OR_ARENA) : sWorld->getBoolConfig(CONFIG_DEATH_BONES_WORLD))) &&
!map->IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY()))
+1 -1
View File
@@ -2002,7 +2002,7 @@ uint64 ObjectMgr::GetPlayerGUIDByName(std::string name) const
{
uint64 guid = 0;
CharacterDatabase.escape_string(name);
CharacterDatabase.EscapeString(name);
// Player name safe to sending to DB (checked at login) and this function using
QueryResult result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE name = '%s'", name.c_str());
@@ -1158,7 +1158,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data)
}
std::string escaped_newname = newname;
CharacterDatabase.escape_string(escaped_newname);
CharacterDatabase.EscapeString(escaped_newname);
// make sure that the character belongs to the current account, that rename at login is enabled
// and that there is no character with the desired new name
@@ -1270,7 +1270,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data)
}
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
CharacterDatabase.escape_string(declinedname.name[i]);
CharacterDatabase.EscapeString(declinedname.name[i]);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("DELETE FROM character_declinedname WHERE guid = '%u'", GUID_LOPART(guid));
@@ -1431,7 +1431,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data)
}
}
CharacterDatabase.escape_string(newname);
CharacterDatabase.EscapeString(newname);
if (QueryResult result = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid ='%u'", GUID_LOPART(guid)))
{
std::string oldname = result->Fetch()[0].GetString();
@@ -1654,7 +1654,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
}
}
CharacterDatabase.escape_string(newname);
CharacterDatabase.EscapeString(newname);
Player::Customize(guid, gender, skin, face, hairStyle, hairColor, facialHair);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("UPDATE `characters` SET name='%s', race='%u', at_login=at_login & ~ %u WHERE guid='%u'", newname.c_str(), race, used_loginFlag, lowGuid);
@@ -599,7 +599,7 @@ void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket & recv_data)
}
else
{
CharacterDatabase.escape_string(name);
CharacterDatabase.EscapeString(name);
guid = sObjectMgr->GetPlayerGUIDByName(name.c_str());
}
@@ -553,7 +553,7 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket & recv_data)
if (!normalizePlayerName(friendName))
return;
CharacterDatabase.escape_string(friendName); // prevent SQL injection - normal name don't must changed by this call
CharacterDatabase.EscapeString(friendName); // prevent SQL injection - normal name don't must changed by this call
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s asked to add friend : '%s'",
GetPlayer()->GetName(), friendName.c_str());
@@ -642,7 +642,7 @@ void WorldSession::HandleAddIgnoreOpcode(WorldPacket & recv_data)
if (!normalizePlayerName(IgnoreName))
return;
CharacterDatabase.escape_string(IgnoreName); // prevent SQL injection - normal name don't must changed by this call
CharacterDatabase.EscapeString(IgnoreName); // prevent SQL injection - normal name don't must changed by this call
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s asked to Ignore: '%s'",
GetPlayer()->GetName(), IgnoreName.c_str());
@@ -728,8 +728,8 @@ void WorldSession::HandleBugOpcode(WorldPacket & recv_data)
sLog->outDebug(LOG_FILTER_NETWORKIO, "%s", type.c_str());
sLog->outDebug(LOG_FILTER_NETWORKIO, "%s", content.c_str());
CharacterDatabase.escape_string(type);
CharacterDatabase.escape_string(content);
CharacterDatabase.EscapeString(type);
CharacterDatabase.EscapeString(content);
CharacterDatabase.PExecute ("INSERT INTO bugreport (type, content) VALUES('%s', '%s')", type.c_str(), content.c_str());
}
@@ -643,13 +643,13 @@ void WorldSession::HandlePetRename(WorldPacket & recv_data)
if (isdeclined)
{
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
CharacterDatabase.escape_string(declinedname.name[i]);
CharacterDatabase.EscapeString(declinedname.name[i]);
trans->PAppend("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
trans->PAppend("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u', '%u', '%s', '%s', '%s', '%s', '%s')",
pet->GetCharmInfo()->GetPetNumber(), _player->GetGUIDLow(), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str());
}
CharacterDatabase.escape_string(name);
CharacterDatabase.EscapeString(name);
trans->PAppend("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
CharacterDatabase.CommitTransaction(trans);
@@ -233,7 +233,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
ssInvalidPetitionGUIDs << "'" << charter->GetGUIDLow() << "'";
sLog->outDebug(LOG_FILTER_NETWORKIO, "Invalid petition GUIDs: %s", ssInvalidPetitionGUIDs.str().c_str());
CharacterDatabase.escape_string(name);
CharacterDatabase.EscapeString(name);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("DELETE FROM petition WHERE petitionguid IN (%s)", ssInvalidPetitionGUIDs.str().c_str());
trans->PAppend("DELETE FROM petition_sign WHERE petitionguid IN (%s)", ssInvalidPetitionGUIDs.str().c_str());
@@ -432,7 +432,7 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data)
}
std::string db_newname = newname;
CharacterDatabase.escape_string(db_newname);
CharacterDatabase.EscapeString(db_newname);
CharacterDatabase.PExecute("UPDATE petition SET name = '%s' WHERE petitionguid = '%u'",
db_newname.c_str(), GUID_LOPART(petitionguid));
+1 -1
View File
@@ -755,7 +755,7 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi)
if (mi->HasMovementFlag(MOVEMENTFLAG_SPLINE_ELEVATION))
data >> mi->splineElevation;
// This must be a packet spoofing attempt. MOVEMENTFLAG_ROOT sent from the client is not valid,
// This must be a packet spoofing attempt. MOVEMENTFLAG_ROOT sent from the client is not valid,
// and when used in conjunction with any of the moving movement flags such as MOVEMENTFLAG_FORWARD
// it will freeze clients that receive this player's movement info.
if (mi->HasMovementFlag(MOVEMENTFLAG_ROOT))
+2 -2
View File
@@ -812,7 +812,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
// Get the account information from the realmd database
std::string safe_account = account; // Duplicate, else will screw the SHA hash verification below
LoginDatabase.escape_string (safe_account);
LoginDatabase.EscapeString (safe_account);
// No SQL injection, username escaped.
QueryResult result =
@@ -978,7 +978,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
// Update the last_ip in the database
// No SQL injection, username escaped.
LoginDatabase.escape_string (address);
LoginDatabase.EscapeString (address);
LoginDatabase.PExecute ("UPDATE account "
"SET last_ip = '%s' "
+37 -15
View File
@@ -3726,10 +3726,10 @@ void Spell::SendCastResult(Player* caster, SpellEntry const* spellInfo, uint8 ca
case SPELL_FAILED_TOO_MANY_OF_ITEM:
{
uint32 item = 0;
for (int8 x=0;x < 3;x++)
for (int8 x = 0;x < 3; x++)
if (spellInfo->EffectItemType[x])
item = spellInfo->EffectItemType[x];
ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(item);
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item);
if (pProto && pProto->ItemLimitCategory)
data << uint32(pProto->ItemLimitCategory);
break;
@@ -5579,7 +5579,7 @@ SpellCastResult Spell::CheckPetCast(Unit* target)
SpellCastResult Spell::CheckCasterAuras() const
{
// spells totally immuned to caster auras (wsg flag drop, give marks etc)
if (m_spellInfo->AttributesEx6& SPELL_ATTR6_IGNORE_CASTER_AURAS)
if (m_spellInfo->AttributesEx6 & SPELL_ATTR6_IGNORE_CASTER_AURAS)
return SPELL_CAST_OK;
uint8 school_immune = 0;
@@ -5604,17 +5604,38 @@ SpellCastResult Spell::CheckCasterAuras() const
mechanic_immune = IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
}
bool usableInStun = m_spellInfo->AttributesEx5 & SPELL_ATTR5_USABLE_WHILE_STUNNED;
// Glyph of Pain Suppression
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_PRIEST && m_spellInfo->SpellIconID == 2178)
if (m_caster->HasAuraEffect(63248, 0)) // no SpellFamilyFlags or SpellIconID to identify this
mechanic_immune = 1 << MECHANIC_STUN; // "immune" to stun only for this cast
// there is no other way to handle it
if (m_spellInfo->Id == 33206 && !m_caster->HasAura(63248))
usableInStun = false;
// Check whether the cast should be prevented by any state you might have.
SpellCastResult prevented_reason = SPELL_CAST_OK;
// Have to check if there is a stun aura. Otherwise will have problems with ghost aura apply while logging out
uint32 unitflag = m_caster->GetUInt32Value(UNIT_FIELD_FLAGS); // Get unit state
if (unitflag & UNIT_FLAG_STUNNED && !(m_spellInfo->AttributesEx5 & SPELL_ATTR5_USABLE_WHILE_STUNNED))
prevented_reason = SPELL_FAILED_STUNNED;
if (unitflag & UNIT_FLAG_STUNNED)
{
// spell is usable while stunned, check if caster has only mechanic stun auras, another stun types must prevent cast spell
if (usableInStun)
{
bool foundNotStun = false;
Unit::AuraEffectList const& stunAuras = m_caster->GetAuraEffectsByType(SPELL_AURA_MOD_STUN);
for (Unit::AuraEffectList::const_iterator i = stunAuras.begin(); i != stunAuras.end(); ++i)
{
if (!(GetAllSpellMechanicMask((*i)->GetSpellProto()) & (1<<MECHANIC_STUN)))
{
foundNotStun = true;
break;
}
}
if (foundNotStun)
prevented_reason = SPELL_FAILED_STUNNED;
}
else
prevented_reason = SPELL_FAILED_STUNNED;
}
else if (unitflag & UNIT_FLAG_CONFUSED && !(m_spellInfo->AttributesEx5 & SPELL_ATTR5_USABLE_WHILE_CONFUSED))
prevented_reason = SPELL_FAILED_CONFUSED;
else if (unitflag & UNIT_FLAG_FLEEING && !(m_spellInfo->AttributesEx5 & SPELL_ATTR5_USABLE_WHILE_FEARED))
@@ -5634,23 +5655,24 @@ SpellCastResult Spell::CheckCasterAuras() const
for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
Aura const* aura = itr->second->GetBase();
if (GetAllSpellMechanicMask(aura->GetSpellProto()) & mechanic_immune)
SpellEntry const* auraInfo = aura->GetSpellProto();
if (GetAllSpellMechanicMask(auraInfo) & mechanic_immune)
continue;
if (GetSpellSchoolMask(aura->GetSpellProto()) & school_immune)
if (GetSpellSchoolMask(auraInfo) & school_immune)
continue;
if ((1<<(aura->GetSpellProto()->Dispel)) & dispel_immune)
if ((1<<(auraInfo->Dispel)) & dispel_immune)
continue;
//Make a second check for spell failed so the right SPELL_FAILED message is returned.
//That is needed when your casting is prevented by multiple states and you are only immune to some of them.
for (uint8 i=0; i<MAX_SPELL_EFFECTS; ++i)
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (AuraEffect * part = aura->GetEffect(i))
if (AuraEffect* part = aura->GetEffect(i))
{
switch(part->GetAuraType())
switch (part->GetAuraType())
{
case SPELL_AURA_MOD_STUN:
if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR5_USABLE_WHILE_STUNNED))
if (!usableInStun || !(GetAllSpellMechanicMask(auraInfo) & (1<<MECHANIC_STUN)))
return SPELL_FAILED_STUNNED;
break;
case SPELL_AURA_MOD_CONFUSE:
-4
View File
@@ -4116,10 +4116,6 @@ void SpellMgr::LoadSpellCustomAttr()
spellInfo->AttributesEx3 |= SPELL_ATTR3_NO_DONE_BONUS;
++count;
break;
case 33206: // Pain Suppression
spellInfo->AttributesEx5 &= ~SPELL_ATTR5_USABLE_WHILE_STUNNED;
++count;
break;
case 8145: // Tremor Totem (instant pulse)
case 6474: // Earthbind Totem (instant pulse)
spellInfo->AttributesEx5 |= SPELL_ATTR5_START_PERIODIC_AT_APPLY;
+3 -3
View File
@@ -206,7 +206,7 @@ std::string CreateDumpString(char const* tableName, QueryResult result)
else ss << ", '";
std::string s = fields[i].GetString();
CharacterDatabase.escape_string(s);
CharacterDatabase.EscapeString(s);
ss << s;
ss << "'";
@@ -411,7 +411,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
if (ObjectMgr::CheckPlayerName(name, true) == CHAR_NAME_SUCCESS)
{
CharacterDatabase.escape_string(name); // for safe, we use name only for sql quearies anyway
CharacterDatabase.EscapeString(name); // for safe, we use name only for sql quearies anyway
result = CharacterDatabase.PQuery("SELECT 1 FROM characters WHERE name = '%s'", name.c_str());
if (result)
name = ""; // use the one from the dump
@@ -507,7 +507,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
{
// check if the original name already exists
name = getnth(line, 3);
CharacterDatabase.escape_string(name);
CharacterDatabase.EscapeString(name);
result = CharacterDatabase.PQuery("SELECT 1 FROM characters WHERE name = '%s'", name.c_str());
if (result)