Merge branch 'master' into 303

Conflicts:
	src/game/Level2.cpp
	src/game/Pet.cpp
	src/game/Player.cpp
This commit is contained in:
tomrus88 2008-11-03 14:44:58 +03:00
commit 9cc6f1f3ec
32 changed files with 353 additions and 238 deletions

View file

@ -26,7 +26,7 @@ EventProcessor::EventProcessor()
EventProcessor::~EventProcessor()
{
KillAllEvents();
KillAllEvents(true);
}
void EventProcessor::Update(uint32 p_time)
@ -58,20 +58,30 @@ void EventProcessor::Update(uint32 p_time)
}
}
void EventProcessor::KillAllEvents()
void EventProcessor::KillAllEvents(bool force)
{
// prevent event insertions
m_aborting = true;
// first, abort all existing events
for (EventList::iterator i = m_events.begin(); i != m_events.end(); ++i)
for (EventList::iterator i = m_events.begin(); i != m_events.end();)
{
i->second->to_Abort = true;
i->second->Abort(m_time);
delete i->second;
EventList::iterator i_old = i;
++i;
i_old->second->to_Abort = true;
i_old->second->Abort(m_time);
if(force || i_old->second->IsDeletable())
{
delete i_old->second;
if(!force) // need per-element cleanup
m_events.erase (i_old);
}
}
// clear event list
// fast clear event list (in force case)
if(force)
m_events.clear();
}

View file

@ -38,6 +38,8 @@ class BasicEvent
// e_time is execution time, p_time is update interval
virtual bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) { return true; }
virtual bool IsDeletable() const { return true; } // this event can be safely deleted
virtual void Abort(uint64 /*e_time*/) {} // this method executes when the event is aborted
bool to_Abort; // set by externals when the event is aborted, aborted events don't execute
@ -57,7 +59,7 @@ class EventProcessor
~EventProcessor();
void Update(uint32 p_time);
void KillAllEvents();
void KillAllEvents(bool force);
void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true);
uint64 CalculateTime(uint64 t_offset);
protected:

View file

@ -88,39 +88,44 @@ bool ArenaTeam::AddMember(uint64 PlayerGuid)
std::string plName;
uint8 plClass;
if(GetMembersSize() >= GetType() * 2)
{
// arena team is full (can't have more than type * 2 players!)
// return false
if(GetMembersSize() >= GetType() * 2)
return false;
}
if(!objmgr.GetPlayerNameByGUID(PlayerGuid, plName)) // player doesnt exist
return false;
// player already in arenateam of that size
if(Player::GetArenaTeamIdFromDB(PlayerGuid, GetType()) != 0)
Player *pl = objmgr.GetPlayer(PlayerGuid);
if(pl)
{
if(pl->GetArenaTeamId(GetType()))
{
sLog.outError("Arena::AddMember() : player already in this sized team");
return false;
}
// remove all player signs from another petitions
// this will be prevent attempt joining player to many arenateams and corrupt arena team data integrity
Player::RemovePetitionsAndSigns(PlayerGuid, GetType());
Player *pl = objmgr.GetPlayer(PlayerGuid);
if(pl)
{
plClass = (uint8)pl->getClass();
plName = pl->GetName();
}
else
{
QueryResult *result = CharacterDatabase.PQuery("SELECT class FROM characters WHERE guid='%u'", GUID_LOPART(PlayerGuid));
// 0 1
QueryResult *result = CharacterDatabase.PQuery("SELECT name, class FROM characters WHERE guid='%u'", GUID_LOPART(PlayerGuid));
if(!result)
return false;
plClass = (*result)[0].GetUInt8();
plName = (*result)[0].GetCppString();
plClass = (*result)[1].GetUInt8();
delete result;
// check if player already in arenateam of that size
if(Player::GetArenaTeamIdFromDB(PlayerGuid, GetType()) != 0)
{
sLog.outError("Arena::AddMember() : player already in this sized team");
return false;
}
}
// remove all player signs from another petitions
// this will be prevent attempt joining player to many arenateams and corrupt arena team data integrity
Player::RemovePetitionsAndSigns(PlayerGuid, GetType());
ArenaTeamMember newmember;
newmember.name = plName;

View file

@ -643,7 +643,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
}
// friend status
sSocialMgr.SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUIDLow(), "", true);
sSocialMgr.SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUIDLow(), true);
// Place character in world (and load zone) before some object loading
pCurrChar->LoadCorpse();

View file

@ -268,7 +268,7 @@ void InstanceSaveManager::CleanupInstances()
// creature_respawn and gameobject_respawn are in another database
// first, obtain total instance set
std::set< uint32 > InstanceSet;
QueryResult *result = CharacterDatabase.PQuery("SELECT id FROM instance");
QueryResult *result = CharacterDatabase.Query("SELECT id FROM instance");
if( result )
{
do
@ -281,7 +281,7 @@ void InstanceSaveManager::CleanupInstances()
}
// creature_respawn
result = WorldDatabase.PQuery("SELECT DISTINCT(instance) FROM creature_respawn WHERE instance <> 0");
result = WorldDatabase.Query("SELECT DISTINCT(instance) FROM creature_respawn WHERE instance <> 0");
if( result )
{
do
@ -295,7 +295,7 @@ void InstanceSaveManager::CleanupInstances()
}
// gameobject_respawn
result = WorldDatabase.PQuery("SELECT DISTINCT(instance) FROM gameobject_respawn WHERE instance <> 0");
result = WorldDatabase.Query("SELECT DISTINCT(instance) FROM gameobject_respawn WHERE instance <> 0");
if( result )
{
do
@ -324,7 +324,7 @@ void InstanceSaveManager::PackInstances()
// all valid ids are in the instance table
// any associations to ids not in this table are assumed to be
// cleaned already in CleanupInstances
QueryResult *result = CharacterDatabase.PQuery("SELECT id FROM instance");
QueryResult *result = CharacterDatabase.Query("SELECT id FROM instance");
if( result )
{
do
@ -374,7 +374,7 @@ void InstanceSaveManager::LoadResetTimes()
// resettime = 0 in the DB for raid/heroic instances so those are skipped
typedef std::map<uint32, std::pair<uint32, uint64> > ResetTimeMapType;
ResetTimeMapType InstResetTime;
QueryResult *result = CharacterDatabase.PQuery("SELECT id, map, resettime FROM instance WHERE resettime > 0");
QueryResult *result = CharacterDatabase.Query("SELECT id, map, resettime FROM instance WHERE resettime > 0");
if( result )
{
do
@ -390,7 +390,7 @@ void InstanceSaveManager::LoadResetTimes()
delete result;
// update reset time for normal instances with the max creature respawn time + X hours
result = WorldDatabase.PQuery("SELECT MAX(respawntime), instance FROM creature_respawn WHERE instance > 0 GROUP BY instance");
result = WorldDatabase.Query("SELECT MAX(respawntime), instance FROM creature_respawn WHERE instance > 0 GROUP BY instance");
if( result )
{
do

View file

@ -4220,6 +4220,7 @@ bool ChatHandler::HandleNpcTameCommand(const char* args)
// set pet to defensive mode by default (some classes can't control controlled pets in fact).
pet->GetCharmInfo()->SetReactState(REACT_DEFENSIVE);
// calculate proper level
uint32 level = (creatureTarget->getLevel() < (player->getLevel() - 5)) ? (player->getLevel() - 5) : creatureTarget->getLevel();
// prepare visual effect for levelup

View file

@ -1355,6 +1355,9 @@ void Map::RemoveAllObjectsInRemoveList()
Remove((GameObject*)obj,true);
break;
case TYPEID_UNIT:
// in case triggred sequence some spell can continue casting after prev CleanupsBeforeDelete call
// make sure that like sources auras/etc removed before destructor start
((Creature*)obj)->CleanupsBeforeDelete ();
Remove((Creature*)obj,true);
break;
default:

View file

@ -19,6 +19,7 @@
#include "Common.h"
#include "Language.h"
#include "Database/DatabaseEnv.h"
#include "Database/DatabaseImpl.h"
#include "WorldPacket.h"
#include "Opcodes.h"
#include "Log.h"
@ -645,9 +646,6 @@ void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data )
std::string friendName = GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN);
std::string friendNote;
FriendsResult friendResult = FRIEND_NOT_FOUND;
Player *pFriend = NULL;
uint64 friendGuid = 0;
recv_data >> friendName;
@ -664,50 +662,51 @@ void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data )
sLog.outDebug( "WORLD: %s asked to add friend : '%s'",
GetPlayer()->GetName(), friendName.c_str() );
friendGuid = objmgr.GetPlayerGUIDByName(friendName);
if(friendGuid)
{
pFriend = ObjectAccessor::FindPlayer(friendGuid);
if(pFriend==GetPlayer())
friendResult = FRIEND_SELF;
else if(GetPlayer()->GetTeam()!=objmgr.GetPlayerTeamByGUID(friendGuid) && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && GetSecurity() < SEC_MODERATOR)
friendResult = FRIEND_ENEMY;
else if(GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid)))
friendResult = FRIEND_ALREADY;
CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddFriendOpcodeCallBack, GetAccountId(), friendNote, "SELECT guid, race FROM characters WHERE name = '%s'", friendName.c_str());
}
if (friendGuid && friendResult==FRIEND_NOT_FOUND)
void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 accountId, std::string friendNote)
{
if( pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(GetPlayer()))
if(!result)
return;
uint64 friendGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER);
uint32 team = Player::TeamForRace((*result)[1].GetUInt8());
delete result;
WorldSession * session = sWorld.FindSession(accountId);
if(!session)
return;
FriendsResult friendResult = FRIEND_NOT_FOUND;
if(friendGuid)
{
if(friendGuid==session->GetPlayer()->GetGUID())
friendResult = FRIEND_SELF;
else if(session->GetPlayer()->GetTeam() != team && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && session->GetSecurity() < SEC_MODERATOR)
friendResult = FRIEND_ENEMY;
else if(session->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid)))
friendResult = FRIEND_ALREADY;
else
{
Player* pFriend = ObjectAccessor::FindPlayer(friendGuid);
if( pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(session->GetPlayer()))
friendResult = FRIEND_ADDED_ONLINE;
else
friendResult = FRIEND_ADDED_OFFLINE;
if(!_player->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false))
if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false))
{
friendResult = FRIEND_LIST_FULL;
sLog.outDebug( "WORLD: %s's friend list is full.", GetPlayer()->GetName());
sLog.outDebug( "WORLD: %s's friend list is full.", session->GetPlayer()->GetName());
}
_player->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote);
sLog.outDebug( "WORLD: %s Guid found '%u'.", friendName.c_str(), GUID_LOPART(friendGuid));
session->GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote);
}
else if(friendResult==FRIEND_ALREADY)
{
sLog.outDebug( "WORLD: %s Guid Already a Friend.", friendName.c_str() );
}
else if(friendResult==FRIEND_SELF)
{
sLog.outDebug( "WORLD: %s Guid can't add himself.", friendName.c_str() );
}
else
{
sLog.outDebug( "WORLD: %s Guid not found.", friendName.c_str() );
}
sSocialMgr.SendFriendStatus(GetPlayer(), friendResult, GUID_LOPART(friendGuid), friendName, false);
sSocialMgr.SendFriendStatus(session->GetPlayer(), friendResult, GUID_LOPART(friendGuid), false);
sLog.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
}
@ -724,7 +723,7 @@ void WorldSession::HandleDelFriendOpcode( WorldPacket & recv_data )
_player->GetSocial()->RemoveFromSocialList(GUID_LOPART(FriendGUID), false);
sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_REMOVED, GUID_LOPART(FriendGUID), "", false);
sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_REMOVED, GUID_LOPART(FriendGUID), false);
sLog.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
}
@ -736,8 +735,6 @@ void WorldSession::HandleAddIgnoreOpcode( WorldPacket & recv_data )
sLog.outDebug( "WORLD: Received CMSG_ADD_IGNORE" );
std::string IgnoreName = GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN);
FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND;
uint64 IgnoreGuid = 0;
recv_data >> IgnoreName;
@ -749,40 +746,40 @@ void WorldSession::HandleAddIgnoreOpcode( WorldPacket & recv_data )
sLog.outDebug( "WORLD: %s asked to Ignore: '%s'",
GetPlayer()->GetName(), IgnoreName.c_str() );
IgnoreGuid = objmgr.GetPlayerGUIDByName(IgnoreName);
CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddIgnoreOpcodeCallBack, GetAccountId(), "SELECT guid FROM characters WHERE name = '%s'", IgnoreName.c_str());
}
void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 accountId)
{
if(!result)
return;
uint64 IgnoreGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER);
delete result;
WorldSession * session = sWorld.FindSession(accountId);
if(!session)
return;
FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND;
if(IgnoreGuid)
{
if(IgnoreGuid==GetPlayer()->GetGUID())
if(IgnoreGuid==session->GetPlayer()->GetGUID()) //not add yourself
ignoreResult = FRIEND_IGNORE_SELF;
else
{
if( GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid)) )
else if( session->GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid)) )
ignoreResult = FRIEND_IGNORE_ALREADY;
}
}
if (IgnoreGuid && ignoreResult == FRIEND_IGNORE_NOT_FOUND)
else
{
ignoreResult = FRIEND_IGNORE_ADDED;
if(!_player->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid), true))
// ignore list full
if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid), true))
ignoreResult = FRIEND_IGNORE_FULL;
}
else if(ignoreResult==FRIEND_IGNORE_ALREADY)
{
sLog.outDebug( "WORLD: %s Guid Already Ignored.", IgnoreName.c_str() );
}
else if(ignoreResult==FRIEND_IGNORE_SELF)
{
sLog.outDebug( "WORLD: %s Guid can't add himself.", IgnoreName.c_str() );
}
else
{
sLog.outDebug( "WORLD: %s Guid not found.", IgnoreName.c_str() );
}
sSocialMgr.SendFriendStatus(GetPlayer(), ignoreResult, GUID_LOPART(IgnoreGuid), "", false);
sSocialMgr.SendFriendStatus(session->GetPlayer(), ignoreResult, GUID_LOPART(IgnoreGuid), false);
sLog.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
}
@ -799,7 +796,7 @@ void WorldSession::HandleDelIgnoreOpcode( WorldPacket & recv_data )
_player->GetSocial()->RemoveFromSocialList(GUID_LOPART(IgnoreGUID), true);
sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED, GUID_LOPART(IgnoreGUID), "", false);
sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED, GUID_LOPART(IgnoreGUID), false);
sLog.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
}

View file

@ -30,9 +30,8 @@
#include <string>
#define CONTACT_DISTANCE 0.5f
#define INTERACTION_DISTANCE 5
#define ATTACK_DISTANCE 5
#define DETECT_DISTANCE 20 // max distance to successful detect stealthed unit
#define INTERACTION_DISTANCE 5.0f
#define ATTACK_DISTANCE 5.0f
#define MAX_VISIBILITY_DISTANCE (5*SIZE_OF_GRID_CELL/2.0f) // max distance for visible object show, limited by active zone for player based at cell size (active zone = 5x5 cells)
#define DEFAULT_VISIBILITY_DISTANCE (SIZE_OF_GRID_CELL) // default visible distance

View file

@ -2682,7 +2682,7 @@ void ObjectMgr::LoadGroups()
uint64 leaderGuid = 0;
uint32 count = 0;
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
QueryResult *result = CharacterDatabase.PQuery("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, leaderGuid FROM groups");
QueryResult *result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, leaderGuid FROM groups");
if( !result )
{
@ -2724,7 +2724,7 @@ void ObjectMgr::LoadGroups()
group = NULL;
leaderGuid = 0;
// 0 1 2 3
result = CharacterDatabase.PQuery("SELECT memberGuid, assistant, subgroup, leaderGuid FROM group_member ORDER BY leaderGuid");
result = CharacterDatabase.Query("SELECT memberGuid, assistant, subgroup, leaderGuid FROM group_member ORDER BY leaderGuid");
if(!result)
{
barGoLink bar( 1 );
@ -2777,7 +2777,7 @@ void ObjectMgr::LoadGroups()
count = 0;
group = NULL;
leaderGuid = 0;
result = CharacterDatabase.PQuery(
result = CharacterDatabase.Query(
// 0 1 2 3 4 5
"SELECT leaderGuid, map, instance, permanent, difficulty, resettime, "
// 6
@ -3645,7 +3645,7 @@ void ObjectMgr::LoadQuestLocales()
void ObjectMgr::LoadPetCreateSpells()
{
QueryResult *result = WorldDatabase.PQuery("SELECT entry, Spell1, Spell2, Spell3, Spell4 FROM petcreateinfo_spell");
QueryResult *result = WorldDatabase.Query("SELECT entry, Spell1, Spell2, Spell3, Spell4 FROM petcreateinfo_spell");
if(!result)
{
barGoLink bar( 1 );
@ -3854,19 +3854,22 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
if(float(tmp.datalong2) > DEFAULT_VISIBILITY_DISTANCE)
{
sLog.outErrorDb("Table `%s` has too large distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u",tablename,tmp.datalong2,tmp.id);
sLog.outErrorDb("Table `%s` has too large distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u",
tablename,tmp.datalong2,tmp.id);
continue;
}
if(tmp.datalong2 && float(tmp.datalong2) > DEFAULT_VISIBILITY_DISTANCE)
{
sLog.outErrorDb("Table `%s` has too large distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u, max distance is %u or 0 for disable distance check",tablename,tmp.datalong2,tmp.id,uint32(DEFAULT_VISIBILITY_DISTANCE));
sLog.outErrorDb("Table `%s` has too large distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u, max distance is %f or 0 for disable distance check",
tablename,tmp.datalong2,tmp.id,DEFAULT_VISIBILITY_DISTANCE);
continue;
}
if(tmp.datalong2 && float(tmp.datalong2) < INTERACTION_DISTANCE)
{
sLog.outErrorDb("Table `%s` has too small distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u, min distance is %u or 0 for disable distance check",tablename,tmp.datalong2,tmp.id,uint32(INTERACTION_DISTANCE));
sLog.outErrorDb("Table `%s` has too small distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u, min distance is %f or 0 for disable distance check",
tablename,tmp.datalong2,tmp.id,INTERACTION_DISTANCE);
continue;
}
@ -3878,7 +3881,8 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
{
if(!sSpellStore.LookupEntry(tmp.datalong))
{
sLog.outErrorDb("Table `%s` using non-existent spell (id: %u) in SCRIPT_COMMAND_REMOVE_AURA or SCRIPT_COMMAND_CAST_SPELL for script id %u",tablename,tmp.datalong,tmp.id);
sLog.outErrorDb("Table `%s` using non-existent spell (id: %u) in SCRIPT_COMMAND_REMOVE_AURA or SCRIPT_COMMAND_CAST_SPELL for script id %u",
tablename,tmp.datalong,tmp.id);
continue;
}
break;
@ -4025,7 +4029,7 @@ void ObjectMgr::LoadEventScripts()
void ObjectMgr::LoadItemTexts()
{
QueryResult *result = CharacterDatabase.PQuery("SELECT id, text FROM item_text");
QueryResult *result = CharacterDatabase.Query("SELECT id, text FROM item_text");
uint32 count = 0;
@ -4108,7 +4112,7 @@ void ObjectMgr::LoadPageTextLocales()
{
mPageTextLocaleMap.clear(); // need for reload case
QueryResult *result = WorldDatabase.PQuery("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text");
QueryResult *result = WorldDatabase.Query("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text");
if(!result)
{
@ -5619,7 +5623,7 @@ void ObjectMgr::LoadCorpses()
{
uint32 count = 0;
// 0 1 2 3 4 5 6 7 8 10
QueryResult *result = CharacterDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map, data, time, corpse_type, instance, guid FROM corpse WHERE corpse_type <> 0");
QueryResult *result = CharacterDatabase.Query("SELECT position_x, position_y, position_z, orientation, map, data, time, corpse_type, instance, guid FROM corpse WHERE corpse_type <> 0");
if( !result )
{
@ -5983,7 +5987,7 @@ void ObjectMgr::LoadReservedPlayersNames()
{
m_ReservedNames.clear(); // need for reload case
QueryResult *result = WorldDatabase.PQuery("SELECT name FROM reserved_name");
QueryResult *result = WorldDatabase.Query("SELECT name FROM reserved_name");
uint32 count = 0;
@ -6840,7 +6844,7 @@ void ObjectMgr::LoadTrainerSpell()
std::set<uint32> skip_trainers;
QueryResult *result = WorldDatabase.PQuery("SELECT entry, spell,spellcost,reqskill,reqskillvalue,reqlevel FROM npc_trainer");
QueryResult *result = WorldDatabase.Query("SELECT entry, spell,spellcost,reqskill,reqskillvalue,reqlevel FROM npc_trainer");
if( !result )
{
@ -6931,7 +6935,7 @@ void ObjectMgr::LoadVendors()
std::set<uint32> skip_vendors;
QueryResult *result = WorldDatabase.PQuery("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor");
QueryResult *result = WorldDatabase.Query("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor");
if( !result )
{
barGoLink bar( 1 );
@ -6977,7 +6981,7 @@ void ObjectMgr::LoadNpcTextId()
m_mCacheNpcTextIdMap.clear();
QueryResult* result = WorldDatabase.PQuery("SELECT npc_guid, textid FROM npc_gossip");
QueryResult* result = WorldDatabase.Query("SELECT npc_guid, textid FROM npc_gossip");
if( !result )
{
barGoLink bar( 1 );

View file

@ -833,8 +833,9 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
for(uint8 i = 0; i < signs; ++i)
{
Field* fields = result->Fetch();
sLog.outDebug("PetitionsHandler: adding arena member %u", fields[0].GetUInt64());
at->AddMember(fields[0].GetUInt64());
uint64 memberGUID = fields[0].GetUInt64();
sLog.outDebug("PetitionsHandler: adding arena member %u", GUID_LOPART(memberGUID));
at->AddMember(memberGUID);
result->NextRow();
}
}

View file

@ -3977,24 +3977,20 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g
uint32 LostDurability = maxDurability - curDurability;
if(LostDurability>0)
{
ItemPrototype const *ditemProto = sItemStorage.LookupEntry<ItemPrototype>(item->GetEntry());
if(!ditemProto)
{
sLog.outError("ERROR: RepairDurability: Unknown item id %u", ditemProto);
return TotalCost;
}
ItemPrototype const *ditemProto = item->GetProto();
DurabilityCostsEntry const *dcost = sDurabilityCostsStore.LookupEntry(ditemProto->ItemLevel);
if(!dcost)
{
sLog.outError("ERROR: RepairDurability: Wrong item lvl %u", dcost);
sLog.outError("ERROR: RepairDurability: Wrong item lvl %u", ditemProto->ItemLevel);
return TotalCost;
}
DurabilityQualityEntry const *dQualitymodEntry = sDurabilityQualityStore.LookupEntry((ditemProto->Quality+1)*2);
uint32 dQualitymodEntryId = (ditemProto->Quality+1)*2;
DurabilityQualityEntry const *dQualitymodEntry = sDurabilityQualityStore.LookupEntry(dQualitymodEntryId);
if(!dQualitymodEntry)
{
sLog.outError("ERROR: RepairDurability: Wrong dQualityModEntry %u", dQualitymodEntry);
sLog.outError("ERROR: RepairDurability: Wrong dQualityModEntry %u", dQualitymodEntryId);
return TotalCost;
}
@ -6054,33 +6050,14 @@ uint32 Player::GetRankFromDB(uint64 guid)
uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type)
{
// need fix it!
QueryResult *result = CharacterDatabase.PQuery("SELECT arenateamid FROM arena_team_member WHERE guid='%u'", GUID_LOPART(guid));
if(result)
{
// init id to 0, check the arena type before assigning a value to id
uint32 id = 0;
do
{
QueryResult *result2 = CharacterDatabase.PQuery("SELECT type FROM arena_team WHERE arenateamid='%u'", id);
if(result2)
{
uint8 dbtype = (*result2)[0].GetUInt32();
delete result2;
if(dbtype == type)
{
// if the type matches, we've found the id
id = (*result)[0].GetUInt32();
break;
}
}
} while(result->NextRow());
QueryResult *result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u' AND type='%u' LIMIT 1", GUID_LOPART(guid), type);
if(!result)
return 0;
uint32 id = (*result)[0].GetUInt32();
delete result;
return id;
}
// no arenateam for the specified guid, return 0
return 0;
}
uint32 Player::GetZoneIdFromDB(uint64 guid)
{

View file

@ -200,7 +200,8 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data )
uint64 guid;
recv_data >> guid;
sLog.outDebug( "WORLD: CMSG_CREATURE_QUERY - (%u) NO CREATURE INFO! (GUID: %u, ENTRY: %u)", uint32(GUID_LOPART(guid)), guid, entry );
sLog.outDebug("WORLD: CMSG_CREATURE_QUERY - NO CREATURE INFO! (GUID: %u, ENTRY: %u)",
GUID_LOPART(guid), entry);
WorldPacket data( SMSG_CREATURE_QUERY_RESPONSE, 4 );
data << uint32(entry | 0x80000000);
SendPacket( &data );
@ -259,7 +260,8 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data )
uint64 guid;
recv_data >> guid;
sLog.outDebug( "WORLD: CMSG_GAMEOBJECT_QUERY - (%u) Missing gameobject info for (GUID: %u, ENTRY: %u)", uint32(GUID_LOPART(guid)), guid, entryID );
sLog.outDebug( "WORLD: CMSG_GAMEOBJECT_QUERY - Missing gameobject info for (GUID: %u, ENTRY: %u)",
GUID_LOPART(guid), entryID );
WorldPacket data ( SMSG_GAMEOBJECT_QUERY_RESPONSE, 4 );
data << uint32(entryID | 0x80000000);
SendPacket( &data );

View file

@ -85,12 +85,13 @@ void WorldSession::HandleQuestgiverHelloOpcode( WorldPacket & recv_data )
uint64 guid;
recv_data >> guid;
sLog.outDebug( "WORLD: Received CMSG_QUESTGIVER_HELLO npc = %u",guid );
sLog.outDebug ("WORLD: Received CMSG_QUESTGIVER_HELLO npc = %u", GUID_LOPART(guid));
Creature *pCreature = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid,UNIT_NPC_FLAG_NONE);
if (!pCreature)
{
sLog.outDebug( "WORLD: HandleQuestgiverHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
sLog.outDebug ("WORLD: HandleQuestgiverHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.",
GUID_LOPART(guid));
return;
}

View file

@ -52,7 +52,7 @@ void LoadSkillDiscoveryTable()
uint32 count = 0;
// 0 1 2
QueryResult *result = WorldDatabase.PQuery("SELECT spellId, reqSpell, chance FROM skill_discovery_template");
QueryResult *result = WorldDatabase.Query("SELECT spellId, reqSpell, chance FROM skill_discovery_template");
if (result)
{

View file

@ -57,7 +57,7 @@ void LoadSkillExtraItemTable()
SkillExtraItemStore.clear(); // need for reload
// 0 1 2 3
QueryResult *result = WorldDatabase.PQuery("SELECT spellId, requiredSpecialization, additionalCreateChance, additionalMaxNum FROM skill_extra_item_template");
QueryResult *result = WorldDatabase.Query("SELECT spellId, requiredSpecialization, additionalCreateChance, additionalMaxNum FROM skill_extra_item_template");
if (result)
{

View file

@ -235,7 +235,7 @@ void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint32 guid, WorldP
*data << uint64(guid);
}
void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, std::string name, bool broadcast)
void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, bool broadcast)
{
FriendInfo fi;

View file

@ -145,7 +145,7 @@ class SocialMgr
void GetFriendInfo(Player *player, uint32 friendGUID, FriendInfo &friendInfo);
// Packet management
void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket *data);
void SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, std::string name, bool broadcast);
void SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, bool broadcast);
void BroadcastToFriendListers(Player *player, WorldPacket *packet);
// Loading
PlayerSocial *LoadFromDB(QueryResult *result, uint32 guid);

View file

@ -268,7 +268,8 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi
m_caster = Caster;
m_selfContainer = NULL;
m_triggeringContainer = triggeringContainer;
m_deletable = true;
m_referencedFromCurrentSpell = false;
m_executedCurrently = false;
m_delayAtDamageCount = 0;
m_applyMultiplierMask = 0;
@ -2020,6 +2021,8 @@ void Spell::cancel()
void Spell::cast(bool skipCheck)
{
SetExecutedCurrently(true);
uint8 castResult = 0;
// update pointers base at GUIDs to prevent access to non-existed already object
@ -2029,6 +2032,7 @@ void Spell::cast(bool skipCheck)
if(!m_targets.getUnitTarget() && m_targets.getUnitTargetGUID() && m_targets.getUnitTargetGUID() != m_caster->GetGUID())
{
cancel();
SetExecutedCurrently(false);
return;
}
@ -2040,6 +2044,7 @@ void Spell::cast(bool skipCheck)
{
SendCastResult(castResult);
finish(false);
SetExecutedCurrently(false);
return;
}
@ -2051,6 +2056,7 @@ void Spell::cast(bool skipCheck)
{
SendCastResult(castResult);
finish(false);
SetExecutedCurrently(false);
return;
}
}
@ -2083,7 +2089,10 @@ void Spell::cast(bool skipCheck)
FillTargetMap();
if(m_spellState == SPELL_STATE_FINISHED) // stop cast if spell marked as finish somewhere in Take*/FillTargetMap
{
SetExecutedCurrently(false);
return;
}
SendCastResult(castResult);
SendSpellGo(); // we must send smsg_spell_go packet before m_castItem delete in TakeCastItem()...
@ -2115,6 +2124,8 @@ void Spell::cast(bool skipCheck)
// Immediate spell, no big deal
handle_immediate();
}
SetExecutedCurrently(false);
}
void Spell::handle_immediate()
@ -5106,3 +5117,8 @@ void SpellEvent::Abort(uint64 /*e_time*/)
if (m_Spell->getState() != SPELL_STATE_FINISHED)
m_Spell->cancel();
}
bool SpellEvent::IsDeletable() const
{
return m_Spell->IsDeletable();
}

View file

@ -388,8 +388,9 @@ class Spell
bool IsMeleeAttackResetSpell() const { return !m_IsTriggeredSpell && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK); }
bool IsRangedAttackResetSpell() const { return !m_IsTriggeredSpell && IsRangedSpell() && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK); }
bool IsDeletable() const { return m_deletable; }
void SetDeletable(bool deletable) { m_deletable = deletable; }
bool IsDeletable() const { return !m_referencedFromCurrentSpell && !m_executedCurrently; }
void SetReferencedFromCurrent(bool yes) { m_referencedFromCurrentSpell = yes; }
void SetExecutedCurrently(bool yes) { m_executedCurrently = yes; }
uint64 GetDelayStart() const { return m_delayStart; }
void SetDelayStart(uint64 m_time) { m_delayStart = m_time; }
uint64 GetDelayMoment() const { return m_delayMoment; }
@ -441,7 +442,8 @@ class Spell
bool m_immediateHandled; // were immediate actions handled? (used by delayed spells only)
// These vars are used in both delayed spell system and modified immediate spell system
bool m_deletable; // is the spell pending deletion or must be updated till permitted to delete?
bool m_referencedFromCurrentSpell; // mark as references to prevent deleted and access by dead pointers
bool m_executedCurrently; // mark as executed to prevent deleted and access by dead pointers
bool m_needSpellLog; // need to send spell log?
uint8 m_applyMultiplierMask; // by effect: damage multiplier needed?
float m_damageMultipliers[3]; // by effect: damage multiplier
@ -703,6 +705,7 @@ class SpellEvent : public BasicEvent
virtual bool Execute(uint64 e_time, uint32 p_time);
virtual void Abort(uint64 e_time);
virtual bool IsDeletable() const;
protected:
Spell* m_Spell;
};

View file

@ -3448,7 +3448,7 @@ void Aura::HandleAuraModSilence(bool apply, bool Real)
if ( state == SPELL_STATE_PREPARING || state == SPELL_STATE_CASTING )
{
currentSpell->cancel();
currentSpell->SetDeletable(true);
currentSpell->SetReferencedFromCurrent(false);
m_target->m_currentSpells[i] = NULL;
}
}
@ -5600,7 +5600,7 @@ void Aura::PeriodicTick()
pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist);
sLog.outDetail("PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
GetCasterGUID(), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size
data.append(m_target->GetPackGUID());
@ -5722,7 +5722,7 @@ void Aura::PeriodicTick()
pdamage = uint32(m_target->GetHealth());
sLog.outDetail("PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
GetCasterGUID(), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
pCaster->SendSpellNonMeleeDamageLog(m_target, GetId(), pdamage, GetSpellSchoolMask(GetSpellProto()), absorb, resist, false, 0);

View file

@ -1876,7 +1876,8 @@ void Spell::EffectTriggerMissileSpell(uint32 effect_idx)
if(!spellInfo)
{
sLog.outError("EffectTriggerMissileSpell of spell %u: triggering unknown spell id %effect_idx", m_spellInfo->Id,triggered_spell_id);
sLog.outError("EffectTriggerMissileSpell of spell %u (eff: %u): triggering unknown spell id %u",
m_spellInfo->Id,effect_idx,triggered_spell_id);
return;
}
@ -3190,7 +3191,8 @@ void Spell::EffectSummon(uint32 i)
if(!spawnCreature->IsPositionValid())
{
sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %d Y: ^%d)", spawnCreature->GetGUIDLow(), spawnCreature->GetEntry(), spawnCreature->GetPositionX(), spawnCreature->GetPositionY());
sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",
spawnCreature->GetGUIDLow(), spawnCreature->GetEntry(), spawnCreature->GetPositionX(), spawnCreature->GetPositionY());
delete spawnCreature;
return;
}
@ -3620,7 +3622,8 @@ void Spell::EffectSummonGuardian(uint32 i)
if(!spawnCreature->IsPositionValid())
{
sLog.outError("ERROR: Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %d Y: ^%d)", spawnCreature->GetGUIDLow(), spawnCreature->GetEntry(), spawnCreature->GetPositionX(), spawnCreature->GetPositionY());
sLog.outError("ERROR: Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)",
spawnCreature->GetGUIDLow(), spawnCreature->GetEntry(), spawnCreature->GetPositionX(), spawnCreature->GetPositionY());
delete spawnCreature;
return;
}
@ -4017,7 +4020,8 @@ void Spell::EffectSummonPet(uint32 i)
if(!NewSummon->IsPositionValid())
{
sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %d Y: ^%d)", NewSummon->GetGUIDLow(), NewSummon->GetEntry(), NewSummon->GetPositionX(), NewSummon->GetPositionY());
sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",
NewSummon->GetGUIDLow(), NewSummon->GetEntry(), NewSummon->GetPositionX(), NewSummon->GetPositionY());
delete NewSummon;
return;
}
@ -5649,7 +5653,8 @@ void Spell::EffectSummonCritter(uint32 i)
if(!critter->IsPositionValid())
{
sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %d Y: ^%d)", critter->GetGUIDLow(), critter->GetEntry(), critter->GetPositionX(), critter->GetPositionY());
sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",
critter->GetGUIDLow(), critter->GetEntry(), critter->GetPositionX(), critter->GetPositionY());
delete critter;
return;
}

View file

@ -270,7 +270,7 @@ void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data )
recv_data >> guid;
sLog.outDebug( "WORLD: Recvd CMSG_GAMEOBJ_USE Message [guid=%u]", guid);
sLog.outDebug( "WORLD: Recvd CMSG_GAMEOBJ_USE Message [guid=%u]", GUID_LOPART(guid));
GameObject *obj = ObjectAccessor::GetGameObject(*_player, guid);
if(!obj)

View file

@ -1458,7 +1458,7 @@ void SpellMgr::LoadSpellChains()
mSpellChains.clear(); // need for reload case
mSpellChainsNext.clear(); // need for reload case
QueryResult *result = WorldDatabase.PQuery("SELECT spell_id, prev_spell, first_spell, rank, req_spell FROM spell_chain");
QueryResult *result = WorldDatabase.Query("SELECT spell_id, prev_spell, first_spell, rank, req_spell FROM spell_chain");
if(result == NULL)
{
barGoLink bar( 1 );
@ -1665,7 +1665,7 @@ void SpellMgr::LoadSpellLearnSpells()
{
mSpellLearnSpells.clear(); // need for reload case
QueryResult *result = WorldDatabase.PQuery("SELECT entry, SpellID FROM spell_learn_spell");
QueryResult *result = WorldDatabase.Query("SELECT entry, SpellID FROM spell_learn_spell");
if(!result)
{
barGoLink bar( 1 );

View file

@ -114,7 +114,7 @@ void MapManager::LoadTransports()
sLog.outString( ">> Loaded %u transports", count );
// check transport data DB integrity
result = WorldDatabase.PQuery("SELECT gameobject.guid,gameobject.id,transports.name FROM gameobject,transports WHERE gameobject.id = transports.entry");
result = WorldDatabase.Query("SELECT gameobject.guid,gameobject.id,transports.name FROM gameobject,transports WHERE gameobject.id = transports.entry");
if(result) // wrong data found
{
do
@ -146,7 +146,8 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z,
if(!IsPositionValid())
{
sLog.outError("ERROR: Transport (GUID: %u) not created. Suggested coordinates isn't valid (X: %d Y: ^%d)",guidlow,x,y);
sLog.outError("ERROR: Transport (GUID: %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
guidlow,x,y);
return false;
}

View file

@ -235,10 +235,12 @@ Unit::~Unit()
// set current spells as deletable
for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++)
{
// spell may be safely deleted now
if (m_currentSpells[i]) m_currentSpells[i]->SetDeletable(true);
if (m_currentSpells[i])
{
m_currentSpells[i]->SetReferencedFromCurrent(false);
m_currentSpells[i] = NULL;
}
}
RemoveAllGameObjects();
RemoveAllDynObjects();
@ -1663,6 +1665,9 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
RemainingDamage -= currentAbsorb;
}
// only split damage if not damaing yourself
if(pVictim != this)
{
AuraList const& vSplitDamageFlat = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_FLAT);
for(AuraList::const_iterator i = vSplitDamageFlat.begin(), next; i != vSplitDamageFlat.end() && RemainingDamage >= 0; i = next)
{
@ -1714,6 +1719,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
CleanDamage cleanDamage = CleanDamage(splitted, BASE_ATTACK, MELEE_HIT_NORMAL);
DealDamage(caster, splitted, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false);
}
}
*absorb = damage - RemainingDamage - *resist;
}
@ -3150,7 +3156,7 @@ void Unit::_UpdateSpells( uint32 time )
{
if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED)
{
m_currentSpells[i]->SetDeletable(true); // spell may be safely deleted now
m_currentSpells[i]->SetReferencedFromCurrent(false);
m_currentSpells[i] = NULL; // remove pointer
}
}
@ -3263,7 +3269,6 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell )
uint32 CSpellType = pSpell->GetCurrentContainer();
pSpell->SetDeletable(false); // spell will not be deleted until gone from current pointers
if (pSpell == m_currentSpells[CSpellType]) return; // avoid breaking self
// break same type spell if it is not delayed
@ -3320,10 +3325,11 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell )
// current spell (if it is still here) may be safely deleted now
if (m_currentSpells[CSpellType])
m_currentSpells[CSpellType]->SetDeletable(true);
m_currentSpells[CSpellType]->SetReferencedFromCurrent(false);
// set new current spell
m_currentSpells[CSpellType] = pSpell;
pSpell->SetReferencedFromCurrent(true);
}
void Unit::InterruptSpell(uint32 spellType, bool withDelayed)
@ -3341,7 +3347,7 @@ void Unit::InterruptSpell(uint32 spellType, bool withDelayed)
if (m_currentSpells[spellType]->getState() != SPELL_STATE_FINISHED)
m_currentSpells[spellType]->cancel();
m_currentSpells[spellType]->SetDeletable(true);
m_currentSpells[spellType]->SetReferencedFromCurrent(false);
m_currentSpells[spellType] = NULL;
}
}
@ -3377,7 +3383,7 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id)
if ( (m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) &&
(withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED) )
m_currentSpells[CURRENT_GENERIC_SPELL]->cancel();
m_currentSpells[CURRENT_GENERIC_SPELL]->SetDeletable(true);
m_currentSpells[CURRENT_GENERIC_SPELL]->SetReferencedFromCurrent(false);
m_currentSpells[CURRENT_GENERIC_SPELL] = NULL;
}
@ -3391,7 +3397,7 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id)
if ( (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_FINISHED) &&
(withDelayed || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_DELAYED) )
m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->cancel();
m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->SetDeletable(true);
m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->SetReferencedFromCurrent(false);
m_currentSpells[CURRENT_AUTOREPEAT_SPELL] = NULL;
}
@ -3400,7 +3406,7 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id)
{
if (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED)
m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel();
m_currentSpells[CURRENT_CHANNELED_SPELL]->SetDeletable(true);
m_currentSpells[CURRENT_CHANNELED_SPELL]->SetReferencedFromCurrent(false);
m_currentSpells[CURRENT_CHANNELED_SPELL] = NULL;
}
}
@ -9839,7 +9845,7 @@ void Unit::CleanupsBeforeDelete()
if(m_uint32Values) // only for fully created object
{
InterruptNonMeleeSpells(true);
m_Events.KillAllEvents();
m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted ans will deleated at call in Map::RemoveAllObjectsInRemoveList
CombatStop();
ClearComboPointHolders();
DeleteThreatList();

View file

@ -89,8 +89,12 @@ void WaypointManager::Load()
if(!MaNGOS::IsValidMapCoord(node.x, node.y, node.z, node.orientation))
{
QueryResult *result1 = WorldDatabase.PQuery("SELECT id, map FROM creature WHERE guid = '%u'", id);
if(result1) sLog.outErrorDb("ERROR: Creature (guidlow %d, entry %d) have invalid coordinates in his waypoint %d (X: %d, Y: %d).", id, result1->Fetch()[0].GetUInt32(), point, node.x, node.y);
else sLog.outErrorDb("ERROR: Waypoint path %d, have invalid coordinates in his waypoint %d (X: %d, Y: %d).", id, point, node.x, node.y);
if(result1)
sLog.outErrorDb("ERROR: Creature (guidlow %d, entry %d) have invalid coordinates in his waypoint %d (X: %f, Y: %f).",
id, result1->Fetch()[0].GetUInt32(), point, node.x, node.y);
else
sLog.outErrorDb("ERROR: Waypoint path %d, have invalid coordinates in his waypoint %d (X: %f, Y: %f).",
id, point, node.x, node.y);
MaNGOS::NormalizeMapCoord(node.x);
MaNGOS::NormalizeMapCoord(node.y);

View file

@ -480,7 +480,8 @@ void World::LoadConfigSettings(bool reload)
}
else if(rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] > ATTACK_DISTANCE)
{
sLog.outError("TargetPosRecalculateRange (%f) must be <= %f. Using %f instead.",rate_values[RATE_TARGET_POS_RECALCULATION_RANGE],ATTACK_DISTANCE,ATTACK_DISTANCE);
sLog.outError("TargetPosRecalculateRange (%f) must be <= %f. Using %f instead.",
rate_values[RATE_TARGET_POS_RECALCULATION_RANGE],ATTACK_DISTANCE,ATTACK_DISTANCE);
rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = ATTACK_DISTANCE;
}
@ -1159,7 +1160,8 @@ void World::SetInitialWorldSettings()
sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d",
local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec);
WorldDatabase.PExecute("INSERT INTO uptime (startstring, starttime, uptime) VALUES('%s', %ld, 0)", isoDate, m_startTime );
WorldDatabase.PExecute("INSERT INTO uptime (startstring, starttime, uptime) VALUES('%s', " I64FMTD ", 0)",
isoDate, uint64(m_startTime));
m_timers[WUPDATE_OBJECTS].SetInterval(0);
m_timers[WUPDATE_SESSIONS].SetInterval(0);

View file

@ -373,7 +373,7 @@ void WorldSession::LogoutPlayer(bool Save)
_player->GetGroup()->SendUpdate();
///- Broadcast a logout message to the player's friends
sSocialMgr.SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUIDLow(), "", true);
sSocialMgr.SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUIDLow(), true);
///- Delete the player object
_player->CleanupsBeforeDelete(); // do some cleanup before deleting to prevent crash at crossreferences to already deleted data

View file

@ -294,8 +294,10 @@ class MANGOS_DLL_SPEC WorldSession
void HandleEmoteOpcode(WorldPacket& recvPacket);
void HandleFriendListOpcode(WorldPacket& recvPacket);
void HandleAddFriendOpcode(WorldPacket& recvPacket);
static void HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 accountId, std::string friendNote);
void HandleDelFriendOpcode(WorldPacket& recvPacket);
void HandleAddIgnoreOpcode(WorldPacket& recvPacket);
static void HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 accountId);
void HandleDelIgnoreOpcode(WorldPacket& recvPacket);
void HandleSetFriendNoteOpcode(WorldPacket& recvPacket);
void HandleBugOpcode(WorldPacket& recvPacket);

View file

@ -59,14 +59,22 @@ class MANGOS_DLL_SPEC Database
bool AsyncQuery(Class *object, void (Class::*method)(QueryResult*), const char *sql);
template<class Class, typename ParamType1>
bool AsyncQuery(Class *object, void (Class::*method)(QueryResult*, ParamType1), ParamType1 param1, const char *sql);
template<class Class, typename ParamType1, typename ParamType2>
bool AsyncQuery(Class *object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *sql);
template<typename ParamType1>
bool AsyncQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char *sql);
template<typename ParamType1, typename ParamType2>
bool AsyncQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *sql);
template<class Class>
bool AsyncPQuery(Class *object, void (Class::*method)(QueryResult*), const char *format,...) ATTR_PRINTF(4,5);
template<class Class, typename ParamType1>
bool AsyncPQuery(Class *object, void (Class::*method)(QueryResult*, ParamType1), ParamType1 param1, const char *format,...) ATTR_PRINTF(5,6);
template<class Class, typename ParamType1, typename ParamType2>
bool AsyncPQuery(Class *object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *format,...) ATTR_PRINTF(5,6);
template<typename ParamType1>
bool AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char *format,...) ATTR_PRINTF(5,6);
template<typename ParamType1, typename ParamType2>
bool AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *format,...) ATTR_PRINTF(5,6);
template<class Class>
bool DelayQueryHolder(Class *object, void (Class::*method)(QueryResult*, SqlQueryHolder*), SqlQueryHolder *holder);
template<class Class, typename ParamType1>

View file

@ -45,6 +45,18 @@ Database::AsyncQuery(Class *object, void (Class::*method)(QueryResult*, ParamTyp
return true;
}
template<class Class, typename ParamType1, typename ParamType2>
bool
Database::AsyncQuery(Class *object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *sql)
{
if (!sql) return false;
ZThread::ThreadImpl * queryThread = ZThread::ThreadImpl::current();
QueryQueues::iterator itr = m_queryQueues.find(queryThread);
if (itr == m_queryQueues.end()) return false;
m_threadBody->Delay(new SqlQuery(sql, new MaNGOS::QueryCallback<Class, ParamType1, ParamType2>(object, method, (QueryResult*)NULL, param1, param2), itr->second));
return true;
}
template<typename ParamType1>
bool
Database::AsyncQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char *sql)
@ -57,6 +69,18 @@ Database::AsyncQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1
return true;
}
template<typename ParamType1, typename ParamType2>
bool
Database::AsyncQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *sql)
{
if (!sql) return false;
ZThread::ThreadImpl * queryThread = ZThread::ThreadImpl::current();
QueryQueues::iterator itr = m_queryQueues.find(queryThread);
if (itr == m_queryQueues.end()) return false;
m_threadBody->Delay(new SqlQuery(sql, new MaNGOS::SQueryCallback<ParamType1, ParamType2>(method, (QueryResult*)NULL, param1, param2), itr->second));
return true;
}
template<class Class>
bool
Database::AsyncPQuery(Class *object, void (Class::*method)(QueryResult*), const char *format,...)
@ -99,6 +123,27 @@ Database::AsyncPQuery(Class *object, void (Class::*method)(QueryResult*, ParamTy
return AsyncQuery(object, method, param1, szQuery);
}
template<class Class, typename ParamType1, typename ParamType2>
bool
Database::AsyncPQuery(Class *object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *format,...)
{
if(!format) return false;
va_list ap;
char szQuery [MAX_QUERY_LEN];
va_start(ap, format);
int res = vsnprintf( szQuery, MAX_QUERY_LEN, format, ap );
va_end(ap);
if(res==-1)
{
sLog.outError("SQL Query truncated (and not execute) for format: %s",format);
return false;
}
return AsyncQuery(object, method, param1, param2, szQuery);
}
template<typename ParamType1>
bool
Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char *format,...)
@ -120,6 +165,27 @@ Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param
return AsyncQuery(method, param1, szQuery);
}
template<typename ParamType1, typename ParamType2>
bool
Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *format,...)
{
if(!format) return false;
va_list ap;
char szQuery [MAX_QUERY_LEN];
va_start(ap, format);
int res = vsnprintf( szQuery, MAX_QUERY_LEN, format, ap );
va_end(ap);
if(res==-1)
{
sLog.outError("SQL Query truncated (and not execute) for format: %s",format);
return false;
}
return AsyncQuery(method, param1, param2, szQuery);
}
template<class Class>
bool
Database::DelayQueryHolder(Class *object, void (Class::*method)(QueryResult*, SqlQueryHolder*), SqlQueryHolder *holder)