Changeset 173
- Timestamp:
- 11/19/08 13:43:02 (17 years ago)
- Location:
- trunk/src
- Files:
-
- 27 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/framework/Utilities/EventProcessor.cpp
r102 r173 29 29 EventProcessor::~EventProcessor() 30 30 { 31 KillAllEvents( );31 KillAllEvents(true); 32 32 } 33 33 … … 61 61 } 62 62 63 void EventProcessor::KillAllEvents( )63 void EventProcessor::KillAllEvents(bool force) 64 64 { 65 65 // prevent event insertions … … 67 67 68 68 // first, abort all existing events 69 for (EventList::iterator i = m_events.begin(); i != m_events.end(); ++i)69 for (EventList::iterator i = m_events.begin(); i != m_events.end();) 70 70 { 71 i->second->to_Abort = true; 72 i->second->Abort(m_time); 73 delete i->second; 71 EventList::iterator i_old = i; 72 ++i; 73 74 i_old->second->to_Abort = true; 75 i_old->second->Abort(m_time); 76 if(force || i_old->second->IsDeletable()) 77 { 78 delete i_old->second; 79 80 if(!force) // need per-element cleanup 81 m_events.erase (i_old); 82 } 74 83 } 75 84 76 // clear event list 77 m_events.clear(); 85 // fast clear event list (in force case) 86 if(force) 87 m_events.clear(); 78 88 } 79 89 -
trunk/src/framework/Utilities/EventProcessor.h
r102 r173 40 40 // e_time is execution time, p_time is update interval 41 41 virtual bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) { return true; } 42 43 virtual bool IsDeletable() const { return true; } // this event can be safely deleted 42 44 43 45 virtual void Abort(uint64 /*e_time*/) {} // this method executes when the event is aborted … … 60 62 61 63 void Update(uint32 p_time); 62 void KillAllEvents( );64 void KillAllEvents(bool force); 63 65 void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true); 64 66 uint64 CalculateTime(uint64 t_offset); -
trunk/src/game/CharacterHandler.cpp
r168 r173 635 635 636 636 // friend status 637 sSocialMgr.SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUIDLow(), "",true);637 sSocialMgr.SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUIDLow(), true); 638 638 639 639 // Place character in world (and load zone) before some object loading -
trunk/src/game/Creature.cpp
r168 r173 854 854 return; 855 855 } 856 uint32 textid=GetGossipTextId( action, zoneid);857 if(textid==0)858 textid=GetNpcTextId();859 856 860 857 switch (gossip->Action) 861 858 { 862 859 case GOSSIP_OPTION_GOSSIP: 860 { 861 uint32 textid = GetGossipTextId(action, zoneid); 862 if (textid == 0) 863 textid=GetNpcTextId(); 864 863 865 player->PlayerTalkClass->CloseGossip(); 864 866 player->PlayerTalkClass->SendTalking(textid); 865 867 break; 868 } 866 869 case GOSSIP_OPTION_OUTDOORPVP: 867 870 sOutdoorPvPMgr.HandleGossipOption(player, GetGUID(), option); -
trunk/src/game/Guild.cpp
r102 r173 113 113 bool Guild::AddMember(uint64 plGuid, uint32 plRank) 114 114 { 115 if(Player::GetGuildIdFromDB(plGuid) != 0) // player already in guild 115 Player* pl = objmgr.GetPlayer(plGuid); 116 if(pl) 117 { 118 if(pl->GetGuildId() != 0) 116 119 return false; 120 } 121 else 122 { 123 if(Player::GetGuildIdFromDB(plGuid) != 0) // player already in guild 124 return false; 125 } 117 126 118 127 // remove all player signs from another petitions … … 143 152 Id, GUID_LOPART(plGuid), newmember.RankId, dbPnote.c_str(), dbOFFnote.c_str()); 144 153 145 Player* pl = objmgr.GetPlayer(plGuid);146 154 if(pl) 147 155 { … … 675 683 676 684 CharacterDatabase.PExecute("UPDATE guild_rank SET rights='%u' WHERE rid='%u' AND guildid='%u'", rights, (rankId+1), Id); 685 } 686 687 int32 Guild::GetRank(uint32 LowGuid) 688 { 689 MemberList::iterator itr = members.find(LowGuid); 690 if (itr==members.end()) 691 return -1; 692 693 return itr->second.RankId; 677 694 } 678 695 -
trunk/src/game/Guild.h
r102 r173 327 327 return ((GetRankRights(rankId) & right) != GR_RIGHT_EMPTY) ? true : false; 328 328 } 329 int32 GetRank(uint32 LowGuid); 329 330 330 331 void Roster(WorldSession *session); -
trunk/src/game/GuildHandler.cpp
r102 r173 165 165 return; 166 166 167 guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); 168 if(!guild) 169 { 170 SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); 171 return; 172 } 173 174 if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_REMOVE)) 175 { 176 SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS); 177 return; 178 } 179 167 180 player = ObjectAccessor::Instance().FindPlayerByName(plName.c_str()); 168 guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());169 170 181 if(player) 171 182 { … … 179 190 } 180 191 181 if(!guild)182 {183 SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD);184 return;185 }186 187 192 if(!plGuid) 188 193 { 189 194 SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_FOUND); 190 return;191 }192 193 if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_REMOVE))194 {195 SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS);196 195 return; 197 196 } … … 297 296 298 297 std::string plName; 299 uint64 plGuid;300 uint32 plGuildId;301 uint32 plRankId;302 Player *player;303 Guild *guild;304 298 305 299 //sLog.outDebug("WORLD: Received CMSG_GUILD_PROMOTE"); … … 309 303 if(!normalizePlayerName(plName)) 310 304 return; 311 312 player = ObjectAccessor::Instance().FindPlayerByName(plName.c_str()); 313 guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); 314 if(player) 315 { 316 plGuid = player->GetGUID(); 317 plGuildId = player->GetGuildId(); 318 plRankId = player->GetRank(); 319 } 320 else 321 { 322 plGuid = objmgr.GetPlayerGUIDByName(plName); 323 plGuildId = Player::GetGuildIdFromDB(plGuid); 324 plRankId = Player::GetRankFromDB(plGuid); 325 } 326 305 306 Guild* guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); 327 307 if(!guild) 328 308 { … … 330 310 return; 331 311 } 332 else if(!plGuid) 312 if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_PROMOTE)) 313 { 314 SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS); 315 return; 316 } 317 318 uint64 plGuid = objmgr.GetPlayerGUIDByName(plName); 319 320 if(!plGuid) 333 321 { 334 322 SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_FOUND); … … 340 328 return; 341 329 } 342 else if(GetPlayer()->GetGuildId() != plGuildId) 330 331 int32 plRankId = guild->GetRank(GUID_LOPART(plGuid)); 332 if(plRankId == -1) 343 333 { 344 334 SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_IN_GUILD_S); 345 335 return; 346 336 } 347 else if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_PROMOTE)) 348 { 349 SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS); 350 return; 351 } 352 else if((plRankId-1) == 0 || (plRankId-1) < this->GetPlayer()->GetRank()) 353 return; 354 355 if(plRankId < 1) 356 { 357 SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_INTERNAL); 358 return; 359 } 337 if(plRankId < 2 || (plRankId-1) < GetPlayer()->GetRank()) 338 return; 360 339 361 340 uint32 newRankId = plRankId < guild->GetNrRanks() ? plRankId-1 : guild->GetNrRanks()-1; … … 379 358 380 359 std::string plName; 381 uint64 plGuid;382 uint32 plGuildId;383 uint32 plRankId;384 Player *player;385 Guild *guild;386 360 387 361 //sLog.outDebug("WORLD: Received CMSG_GUILD_DEMOTE"); … … 392 366 return; 393 367 394 player = ObjectAccessor::Instance().FindPlayerByName(plName.c_str()); 395 guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); 396 if(player) 397 { 398 plGuid = player->GetGUID(); 399 plGuildId = player->GetGuildId(); 400 plRankId = player->GetRank(); 401 } 402 else 403 { 404 plGuid = objmgr.GetPlayerGUIDByName(plName); 405 plGuildId = Player::GetGuildIdFromDB(plGuid); 406 plRankId = Player::GetRankFromDB(plGuid); 407 } 368 Guild* guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); 408 369 409 370 if(!guild) … … 412 373 return; 413 374 } 375 376 if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_DEMOTE)) 377 { 378 SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS); 379 return; 380 } 381 382 uint64 plGuid = objmgr.GetPlayerGUIDByName(plName); 414 383 415 384 if( !plGuid ) … … 425 394 } 426 395 427 if(GetPlayer()->GetGuildId() != plGuildId) 396 int32 plRankId = guild->GetRank(GUID_LOPART(plGuid)); 397 if(plRankId == -1) 428 398 { 429 399 SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_IN_GUILD_S); 430 return;431 }432 433 if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_DEMOTE))434 {435 SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS);436 400 return; 437 401 } … … 536 500 if(!normalizePlayerName(name)) 537 501 return; 502 503 guild = objmgr.GetGuildById(oldLeader->GetGuildId()); 504 505 if(!guild) 506 { 507 SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); 508 return; 509 } 510 511 if(oldLeader->GetGUID() != guild->GetLeader()) 512 { 513 SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS); 514 return; 515 } 538 516 539 517 newLeader = ObjectAccessor::Instance().FindPlayerByName(name.c_str()); … … 548 526 newLeaderGuild = Player::GetGuildIdFromDB(newLeaderGUID); 549 527 } 550 guild = objmgr.GetGuildById(oldLeader->GetGuildId()); 551 552 if(!guild) 553 { 554 SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); 555 return; 556 } 557 else if(!newLeaderGUID) 528 if(!newLeaderGUID) 558 529 { 559 530 SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_FOUND); … … 563 534 { 564 535 SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_IN_GUILD_S); 565 return;566 }567 if(oldLeader->GetGUID() != guild->GetLeader())568 {569 SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS);570 536 return; 571 537 } … … 636 602 return; 637 603 604 guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); 605 if(!guild) 606 { 607 SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); 608 return; 609 } 610 611 if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_EPNOTE)) 612 { 613 SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS); 614 return; 615 } 616 638 617 player = ObjectAccessor::Instance().FindPlayerByName(name.c_str()); 639 guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());640 618 if(player) 641 619 { … … 649 627 } 650 628 651 if(!guild) 652 { 653 SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); 654 return; 655 } 656 else if(!plGuid) 629 if(!plGuid) 657 630 { 658 631 SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_FOUND); … … 662 635 { 663 636 SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_IN_GUILD_S); 664 return;665 }666 if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_EPNOTE))667 {668 SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS);669 637 return; 670 638 } … … 693 661 return; 694 662 663 guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); 664 if(!guild) 665 { 666 SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); 667 return; 668 } 669 if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_EOFFNOTE)) 670 { 671 SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS); 672 return; 673 } 674 695 675 player = ObjectAccessor::Instance().FindPlayerByName(plName.c_str()); 696 guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());697 676 if(player) 698 677 { … … 706 685 } 707 686 708 if(!guild) 709 { 710 SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); 711 return; 712 } 713 else if( !plGuid ) 687 if( !plGuid ) 714 688 { 715 689 SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_FOUND); … … 719 693 { 720 694 SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_IN_GUILD_S); 721 return;722 }723 if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_EOFFNOTE))724 {725 SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS);726 695 return; 727 696 } -
trunk/src/game/InstanceSaveMgr.cpp
r102 r173 272 272 // first, obtain total instance set 273 273 std::set< uint32 > InstanceSet; 274 QueryResult *result = CharacterDatabase. PQuery("SELECT id FROM instance");274 QueryResult *result = CharacterDatabase.Query("SELECT id FROM instance"); 275 275 if( result ) 276 276 { … … 285 285 286 286 // creature_respawn 287 result = WorldDatabase. PQuery("SELECT DISTINCT(instance) FROM creature_respawn WHERE instance <> 0");287 result = WorldDatabase.Query("SELECT DISTINCT(instance) FROM creature_respawn WHERE instance <> 0"); 288 288 if( result ) 289 289 { … … 299 299 300 300 // gameobject_respawn 301 result = WorldDatabase. PQuery("SELECT DISTINCT(instance) FROM gameobject_respawn WHERE instance <> 0");301 result = WorldDatabase.Query("SELECT DISTINCT(instance) FROM gameobject_respawn WHERE instance <> 0"); 302 302 if( result ) 303 303 { … … 328 328 // any associations to ids not in this table are assumed to be 329 329 // cleaned already in CleanupInstances 330 QueryResult *result = CharacterDatabase. PQuery("SELECT id FROM instance");330 QueryResult *result = CharacterDatabase.Query("SELECT id FROM instance"); 331 331 if( result ) 332 332 { … … 378 378 typedef std::map<uint32, std::pair<uint32, uint64> > ResetTimeMapType; 379 379 ResetTimeMapType InstResetTime; 380 QueryResult *result = CharacterDatabase. PQuery("SELECT id, map, resettime FROM instance WHERE resettime > 0");380 QueryResult *result = CharacterDatabase.Query("SELECT id, map, resettime FROM instance WHERE resettime > 0"); 381 381 if( result ) 382 382 { … … 394 394 395 395 // update reset time for normal instances with the max creature respawn time + X hours 396 result = WorldDatabase. PQuery("SELECT MAX(respawntime), instance FROM creature_respawn WHERE instance > 0 GROUP BY instance");396 result = WorldDatabase.Query("SELECT MAX(respawntime), instance FROM creature_respawn WHERE instance > 0 GROUP BY instance"); 397 397 if( result ) 398 398 { -
trunk/src/game/Level2.cpp
r168 r173 1796 1796 else 1797 1797 { 1798 QueryResult *result = CharacterDatabase.PQuery("SELECT totaltime FROM characters WHERE guid = '%u'", targetGUID); 1799 if (!result) 1800 { 1801 SendSysMessage(LANG_PLAYER_NOT_FOUND); 1802 SetSentErrorMessage(true); 1803 return false; 1804 } 1805 Field *fields = result->Fetch(); 1806 total_player_time = fields[0].GetUInt32(); 1807 delete result; 1808 1809 Tokens data; 1810 if (!Player::LoadValuesArrayFromDB(data,targetGUID)) 1811 { 1812 SendSysMessage(LANG_PLAYER_NOT_FOUND); 1813 SetSentErrorMessage(true); 1814 return false; 1815 } 1816 1817 money = Player::GetUInt32ValueFromArray(data, PLAYER_FIELD_COINAGE); 1818 level = Player::GetUInt32ValueFromArray(data, UNIT_FIELD_LEVEL); 1798 1819 accId = objmgr.GetPlayerAccountIdByGUID(targetGUID); 1799 WorldSession session(0,NULL,SEC_PLAYER,0,0,LOCALE_enUS);1800 Player plr(&session); // use fake session for temporary load1801 plr.MinimalLoadFromDB(NULL, targetGUID);1802 money = plr.GetMoney();1803 total_player_time = plr.GetTotalPlayedTime();1804 level = plr.getLevel();1805 1820 } 1806 1821 … … 3384 3399 getline (infile,line); 3385 3400 //cout << line << endl; 3386 QueryResult *result = WorldDatabase. PQuery(line.c_str());3401 QueryResult *result = WorldDatabase.Query(line.c_str()); 3387 3402 delete result; 3388 3403 } -
trunk/src/game/Level3.cpp
r169 r173 2005 2005 sLog.outDetail(GetTrinityString(LANG_ADDITEMSET), itemsetId); 2006 2006 2007 QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE itemset = %u",itemsetId); 2008 2009 if(!result) 2007 bool found = false; 2008 for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) 2009 { 2010 ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype>(id); 2011 if (!pProto) 2012 continue; 2013 2014 if (pProto->ItemSet == itemsetId) 2015 { 2016 found = true; 2017 ItemPosCountVec dest; 2018 uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pProto->ItemId, 1 ); 2019 if (msg == EQUIP_ERR_OK) 2020 { 2021 Item* item = plTarget->StoreNewItem( dest, pProto->ItemId, true); 2022 // remove binding (let GM give it to another player later) 2023 if (pl==plTarget) 2024 item->SetBinding( false ); 2025 2026 pl->SendNewItem(item,1,false,true); 2027 if (pl!=plTarget) 2028 plTarget->SendNewItem(item,1,true,false); 2029 } 2030 else 2031 { 2032 pl->SendEquipError( msg, NULL, NULL ); 2033 PSendSysMessage(LANG_ITEM_CANNOT_CREATE, pProto->ItemId, 1); 2034 } 2035 } 2036 } 2037 2038 if (!found) 2010 2039 { 2011 2040 PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND,itemsetId); … … 2014 2043 return false; 2015 2044 } 2016 2017 do2018 {2019 Field *fields = result->Fetch();2020 uint32 itemId = fields[0].GetUInt32();2021 2022 ItemPosCountVec dest;2023 uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, 1 );2024 if( msg == EQUIP_ERR_OK )2025 {2026 Item* item = plTarget->StoreNewItem( dest, itemId, true);2027 2028 // remove binding (let GM give it to another player later)2029 if(pl==plTarget)2030 item->SetBinding( false );2031 2032 pl->SendNewItem(item,1,false,true);2033 if(pl!=plTarget)2034 plTarget->SendNewItem(item,1,true,false);2035 }2036 else2037 {2038 pl->SendEquipError( msg, NULL, NULL );2039 PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, 1);2040 }2041 2042 }while( result->NextRow() );2043 2044 delete result;2045 2046 2045 return true; 2047 2046 } … … 4766 4765 4767 4766 // check item starting quest (it can work incorrectly if added without item in inventory) 4768 QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE startquest = '%u' LIMIT 1",entry); 4769 if(result) 4770 { 4771 Field* fields = result->Fetch(); 4772 uint32 item_id = fields[0].GetUInt32(); 4773 delete result; 4774 4775 PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry,item_id); 4776 SetSentErrorMessage(true); 4777 return false; 4767 for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) 4768 { 4769 ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype>(id); 4770 if (!pProto) 4771 continue; 4772 4773 if (pProto->StartQuest == entry) 4774 { 4775 PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, pProto->ItemId); 4776 SetSentErrorMessage(true); 4777 return false; 4778 } 4778 4779 } 4779 4780 -
trunk/src/game/Map.cpp
r149 r173 1358 1358 break; 1359 1359 case TYPEID_UNIT: 1360 // in case triggred sequence some spell can continue casting after prev CleanupsBeforeDelete call 1361 // make sure that like sources auras/etc removed before destructor start 1362 ((Creature*)obj)->CleanupsBeforeDelete (); 1360 1363 Remove((Creature*)obj,true); 1361 1364 break; -
trunk/src/game/MiscHandler.cpp
r139 r173 22 22 #include "Language.h" 23 23 #include "Database/DatabaseEnv.h" 24 #include "Database/DatabaseImpl.h" 24 25 #include "WorldPacket.h" 25 26 #include "Opcodes.h" … … 650 651 sLog.outDebug( "WORLD: Received CMSG_ADD_FRIEND" ); 651 652 652 std::string friendName 653 std::string friendName = GetTrinityString(LANG_FRIEND_IGNORE_UNKNOWN); 653 654 std::string friendNote; 654 FriendsResult friendResult = FRIEND_NOT_FOUND; 655 Player *pFriend = NULL; 656 uint64 friendGuid = 0; 657 655 658 656 recv_data >> friendName; 659 657 … … 671 669 GetPlayer()->GetName(), friendName.c_str() ); 672 670 673 friendGuid = objmgr.GetPlayerGUIDByName(friendName); 674 671 CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddFriendOpcodeCallBack, GetAccountId(), friendNote, "SELECT guid, race FROM characters WHERE name = '%s'", friendName.c_str()); 672 } 673 674 void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 accountId, std::string friendNote) 675 { 676 if(!result) 677 return; 678 679 uint64 friendGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); 680 uint32 team = Player::TeamForRace((*result)[1].GetUInt8()); 681 682 delete result; 683 684 WorldSession * session = sWorld.FindSession(accountId); 685 if(!session) 686 return; 687 688 FriendsResult friendResult = FRIEND_NOT_FOUND; 675 689 if(friendGuid) 676 690 { 677 pFriend = ObjectAccessor::FindPlayer(friendGuid); 678 if(pFriend==GetPlayer()) 691 if(friendGuid==session->GetPlayer()->GetGUID()) 679 692 friendResult = FRIEND_SELF; 680 else if( GetPlayer()->GetTeam()!=objmgr.GetPlayerTeamByGUID(friendGuid) && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) &&GetSecurity() < SEC_MODERATOR)693 else if(session->GetPlayer()->GetTeam() != team && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && session->GetSecurity() < SEC_MODERATOR) 681 694 friendResult = FRIEND_ENEMY; 682 else if( GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid)))695 else if(session->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid))) 683 696 friendResult = FRIEND_ALREADY; 684 }685 686 if (friendGuid && friendResult==FRIEND_NOT_FOUND)687 {688 if( pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(GetPlayer()))689 friendResult = FRIEND_ADDED_ONLINE;690 697 else 691 friendResult = FRIEND_ADDED_OFFLINE; 692 693 if(!_player->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false)) 698 { 699 Player* pFriend = ObjectAccessor::FindPlayer(friendGuid); 700 if( pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(session->GetPlayer())) 701 friendResult = FRIEND_ADDED_ONLINE; 702 else 703 friendResult = FRIEND_ADDED_OFFLINE; 704 705 if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false)) 694 706 { 695 707 friendResult = FRIEND_LIST_FULL; 696 sLog.outDebug( "WORLD: %s's friend list is full.", GetPlayer()->GetName()); 697 } 698 699 _player->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote); 700 701 sLog.outDebug( "WORLD: %s Guid found '%u'.", friendName.c_str(), GUID_LOPART(friendGuid)); 702 } 703 else if(friendResult==FRIEND_ALREADY) 704 { 705 sLog.outDebug( "WORLD: %s Guid Already a Friend.", friendName.c_str() ); 706 } 707 else if(friendResult==FRIEND_SELF) 708 { 709 sLog.outDebug( "WORLD: %s Guid can't add himself.", friendName.c_str() ); 710 } 711 else 712 { 713 sLog.outDebug( "WORLD: %s Guid not found.", friendName.c_str() ); 714 } 715 716 sSocialMgr.SendFriendStatus(GetPlayer(), friendResult, GUID_LOPART(friendGuid), friendName, false); 708 sLog.outDebug( "WORLD: %s's friend list is full.", session->GetPlayer()->GetName()); 709 } 710 711 session->GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote); 712 } 713 } 714 715 sSocialMgr.SendFriendStatus(session->GetPlayer(), friendResult, GUID_LOPART(friendGuid), false); 717 716 718 717 sLog.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" ); … … 731 730 _player->GetSocial()->RemoveFromSocialList(GUID_LOPART(FriendGUID), false); 732 731 733 sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_REMOVED, GUID_LOPART(FriendGUID), "",false);732 sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_REMOVED, GUID_LOPART(FriendGUID), false); 734 733 735 734 sLog.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" ); … … 743 742 744 743 std::string IgnoreName = GetTrinityString(LANG_FRIEND_IGNORE_UNKNOWN); 745 FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND;746 uint64 IgnoreGuid = 0;747 744 748 745 recv_data >> IgnoreName; … … 756 753 GetPlayer()->GetName(), IgnoreName.c_str() ); 757 754 758 IgnoreGuid = objmgr.GetPlayerGUIDByName(IgnoreName); 759 755 CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddIgnoreOpcodeCallBack, GetAccountId(), "SELECT guid FROM characters WHERE name = '%s'", IgnoreName.c_str()); 756 } 757 758 void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 accountId) 759 { 760 if(!result) 761 return; 762 763 uint64 IgnoreGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); 764 765 delete result; 766 767 WorldSession * session = sWorld.FindSession(accountId); 768 if(!session) 769 return; 770 771 FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND; 760 772 if(IgnoreGuid) 761 773 { 762 if(IgnoreGuid== GetPlayer()->GetGUID())774 if(IgnoreGuid==session->GetPlayer()->GetGUID()) //not add yourself 763 775 ignoreResult = FRIEND_IGNORE_SELF; 776 else if( session->GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid)) ) 777 ignoreResult = FRIEND_IGNORE_ALREADY; 764 778 else 765 779 { 766 if( GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid)) ) 767 ignoreResult = FRIEND_IGNORE_ALREADY; 768 } 769 } 770 771 if (IgnoreGuid && ignoreResult == FRIEND_IGNORE_NOT_FOUND) 772 { 773 ignoreResult = FRIEND_IGNORE_ADDED; 774 775 if(!_player->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid), true)) 780 ignoreResult = FRIEND_IGNORE_ADDED; 781 782 // ignore list full 783 if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid), true)) 776 784 ignoreResult = FRIEND_IGNORE_FULL; 777 } 778 else if(ignoreResult==FRIEND_IGNORE_ALREADY) 779 { 780 sLog.outDebug( "WORLD: %s Guid Already Ignored.", IgnoreName.c_str() ); 781 } 782 else if(ignoreResult==FRIEND_IGNORE_SELF) 783 { 784 sLog.outDebug( "WORLD: %s Guid can't add himself.", IgnoreName.c_str() ); 785 } 786 else 787 { 788 sLog.outDebug( "WORLD: %s Guid not found.", IgnoreName.c_str() ); 789 } 790 791 sSocialMgr.SendFriendStatus(GetPlayer(), ignoreResult, GUID_LOPART(IgnoreGuid), "", false); 785 } 786 } 787 788 sSocialMgr.SendFriendStatus(session->GetPlayer(), ignoreResult, GUID_LOPART(IgnoreGuid), false); 792 789 793 790 sLog.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" ); … … 806 803 _player->GetSocial()->RemoveFromSocialList(GUID_LOPART(IgnoreGUID), true); 807 804 808 sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED, GUID_LOPART(IgnoreGUID), "",false);805 sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED, GUID_LOPART(IgnoreGUID), false); 809 806 810 807 sLog.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" ); -
trunk/src/game/ObjectMgr.cpp
r168 r173 2729 2729 uint32 count = 0; 2730 2730 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2731 QueryResult *result = CharacterDatabase. PQuery("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, leaderGuid FROM groups");2731 QueryResult *result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, leaderGuid FROM groups"); 2732 2732 2733 2733 if( !result ) … … 2771 2771 leaderGuid = 0; 2772 2772 // 0 1 2 3 2773 result = CharacterDatabase. PQuery("SELECT memberGuid, assistant, subgroup, leaderGuid FROM group_member ORDER BY leaderGuid");2773 result = CharacterDatabase.Query("SELECT memberGuid, assistant, subgroup, leaderGuid FROM group_member ORDER BY leaderGuid"); 2774 2774 if(!result) 2775 2775 { … … 2824 2824 group = NULL; 2825 2825 leaderGuid = 0; 2826 result = CharacterDatabase. PQuery(2826 result = CharacterDatabase.Query( 2827 2827 // 0 1 2 3 4 5 2828 2828 "SELECT leaderGuid, map, instance, permanent, difficulty, resettime, " … … 3692 3692 void ObjectMgr::LoadPetCreateSpells() 3693 3693 { 3694 QueryResult *result = WorldDatabase. PQuery("SELECT entry, Spell1, Spell2, Spell3, Spell4 FROM petcreateinfo_spell");3694 QueryResult *result = WorldDatabase.Query("SELECT entry, Spell1, Spell2, Spell3, Spell4 FROM petcreateinfo_spell"); 3695 3695 if(!result) 3696 3696 { … … 4072 4072 void ObjectMgr::LoadItemTexts() 4073 4073 { 4074 QueryResult *result = CharacterDatabase. PQuery("SELECT id, text FROM item_text");4074 QueryResult *result = CharacterDatabase.Query("SELECT id, text FROM item_text"); 4075 4075 4076 4076 uint32 count = 0; … … 4155 4155 mPageTextLocaleMap.clear(); 4156 4156 4157 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");4157 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"); 4158 4158 4159 4159 if(!result) … … 5711 5711 uint32 count = 0; 5712 5712 // 0 1 2 3 4 5 6 7 8 10 5713 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");5713 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"); 5714 5714 5715 5715 if( !result ) … … 6075 6075 m_ReservedNames.clear(); // need for reload case 6076 6076 6077 QueryResult *result = WorldDatabase. PQuery("SELECT name FROM reserved_name");6077 QueryResult *result = WorldDatabase.Query("SELECT name FROM reserved_name"); 6078 6078 6079 6079 uint32 count = 0; … … 6962 6962 std::set<uint32> skip_trainers; 6963 6963 6964 QueryResult *result = WorldDatabase. PQuery("SELECT entry, spell,spellcost,reqskill,reqskillvalue,reqlevel FROM npc_trainer");6964 QueryResult *result = WorldDatabase.Query("SELECT entry, spell,spellcost,reqskill,reqskillvalue,reqlevel FROM npc_trainer"); 6965 6965 6966 6966 if( !result ) … … 7053 7053 std::set<uint32> skip_vendors; 7054 7054 7055 QueryResult *result = WorldDatabase. PQuery("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor");7055 QueryResult *result = WorldDatabase.Query("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor"); 7056 7056 if( !result ) 7057 7057 { … … 7099 7099 m_mCacheNpcTextIdMap.clear(); 7100 7100 7101 QueryResult* result = WorldDatabase. PQuery("SELECT npc_guid, textid FROM npc_gossip");7101 QueryResult* result = WorldDatabase.Query("SELECT npc_guid, textid FROM npc_gossip"); 7102 7102 if( !result ) 7103 7103 { -
trunk/src/game/SkillDiscovery.cpp
r102 r173 55 55 56 56 // 0 1 2 57 QueryResult *result = WorldDatabase. PQuery("SELECT spellId, reqSpell, chance FROM skill_discovery_template");57 QueryResult *result = WorldDatabase.Query("SELECT spellId, reqSpell, chance FROM skill_discovery_template"); 58 58 59 59 if (result) -
trunk/src/game/SkillExtraItems.cpp
r102 r173 60 60 61 61 // 0 1 2 3 62 QueryResult *result = WorldDatabase. PQuery("SELECT spellId, requiredSpecialization, additionalCreateChance, additionalMaxNum FROM skill_extra_item_template");62 QueryResult *result = WorldDatabase.Query("SELECT spellId, requiredSpecialization, additionalCreateChance, additionalMaxNum FROM skill_extra_item_template"); 63 63 64 64 if (result) -
trunk/src/game/SocialMgr.cpp
r139 r173 238 238 } 239 239 240 void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, std::string name,bool broadcast)240 void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, bool broadcast) 241 241 { 242 242 FriendInfo fi; -
trunk/src/game/SocialMgr.h
r139 r173 148 148 // Packet management 149 149 void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket *data); 150 void SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, std::string name,bool broadcast);150 void SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, bool broadcast); 151 151 void BroadcastToFriendListers(Player *player, WorldPacket *packet); 152 152 // Loading -
trunk/src/game/Spell.cpp
r168 r173 288 288 m_magnetPair.first = false; 289 289 m_magnetPair.second = NULL; 290 m_deletable = true; 290 m_referencedFromCurrentSpell = false; 291 m_executedCurrently = false; 291 292 m_delayAtDamageCount = 0; 292 293 … … 2202 2203 void Spell::cast(bool skipCheck) 2203 2204 { 2205 SetExecutedCurrently(true); 2206 2204 2207 uint8 castResult = 0; 2205 2208 … … 2211 2214 { 2212 2215 cancel(); 2216 SetExecutedCurrently(false); 2213 2217 return; 2214 2218 } … … 2222 2226 SendCastResult(castResult); 2223 2227 finish(false); 2228 SetExecutedCurrently(false); 2224 2229 return; 2225 2230 } … … 2233 2238 SendCastResult(castResult); 2234 2239 finish(false); 2240 SetExecutedCurrently(false); 2235 2241 return; 2236 2242 } … … 2278 2284 2279 2285 if(m_spellState == SPELL_STATE_FINISHED) // stop cast if spell marked as finish somewhere in Take*/FillTargetMap 2280 return; 2286 { 2287 SetExecutedCurrently(false); 2288 return; 2289 } 2281 2290 2282 2291 SendCastResult(castResult); … … 2310 2319 handle_immediate(); 2311 2320 } 2321 2322 SetExecutedCurrently(false); 2312 2323 } 2313 2324 … … 5127 5138 m_Spell->cancel(); 5128 5139 } 5140 5141 bool SpellEvent::IsDeletable() const 5142 { 5143 return m_Spell->IsDeletable(); 5144 } -
trunk/src/game/Spell.h
r145 r173 397 397 bool IsRangedAttackResetSpell() const { return !m_IsTriggeredSpell && IsRangedSpell() && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK); } 398 398 399 bool IsDeletable() const { return m_deletable; } 400 void SetDeletable(bool deletable) { m_deletable = deletable; } 399 bool IsDeletable() const { return !m_referencedFromCurrentSpell && !m_executedCurrently; } 400 void SetReferencedFromCurrent(bool yes) { m_referencedFromCurrentSpell = yes; } 401 void SetExecutedCurrently(bool yes) { m_executedCurrently = yes; } 401 402 uint64 GetDelayStart() const { return m_delayStart; } 402 403 void SetDelayStart(uint64 m_time) { m_delayStart = m_time; } … … 450 451 451 452 // These vars are used in both delayed spell system and modified immediate spell system 452 bool m_deletable; // is the spell pending deletion or must be updated till permitted to delete? 453 bool m_referencedFromCurrentSpell; // mark as references to prevent deleted and access by dead pointers 454 bool m_executedCurrently; // mark as executed to prevent deleted and access by dead pointers 453 455 bool m_needSpellLog; // need to send spell log? 454 456 uint8 m_applyMultiplierMask; // by effect: damage multiplier needed? … … 657 659 virtual bool Execute(uint64 e_time, uint32 p_time); 658 660 virtual void Abort(uint64 e_time); 661 virtual bool IsDeletable() const; 659 662 protected: 660 663 Spell* m_Spell; -
trunk/src/game/SpellAuras.cpp
r162 r173 3483 3483 { 3484 3484 currentSpell->cancel(); 3485 currentSpell->Set Deletable(true);3485 currentSpell->SetReferencedFromCurrent(false); 3486 3486 m_target->m_currentSpells[i] = NULL; 3487 3487 } -
trunk/src/game/SpellMgr.cpp
r160 r173 1459 1459 mSpellChainsNext.clear(); // need for reload case 1460 1460 1461 QueryResult *result = WorldDatabase. PQuery("SELECT spell_id, prev_spell, first_spell, rank, req_spell FROM spell_chain");1461 QueryResult *result = WorldDatabase.Query("SELECT spell_id, prev_spell, first_spell, rank, req_spell FROM spell_chain"); 1462 1462 if(result == NULL) 1463 1463 { … … 1666 1666 mSpellLearnSpells.clear(); // need for reload case 1667 1667 1668 QueryResult *result = WorldDatabase. PQuery("SELECT entry, SpellID FROM spell_learn_spell");1668 QueryResult *result = WorldDatabase.Query("SELECT entry, SpellID FROM spell_learn_spell"); 1669 1669 if(!result) 1670 1670 { -
trunk/src/game/Transports.cpp
r102 r173 117 117 118 118 // check transport data DB integrity 119 result = WorldDatabase. PQuery("SELECT gameobject.guid,gameobject.id,transports.name FROM gameobject,transports WHERE gameobject.id = transports.entry");119 result = WorldDatabase.Query("SELECT gameobject.guid,gameobject.id,transports.name FROM gameobject,transports WHERE gameobject.id = transports.entry"); 120 120 if(result) // wrong data found 121 121 { -
trunk/src/game/Unit.cpp
r172 r173 238 238 for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) 239 239 { 240 // spell may be safely deleted now 241 if (m_currentSpells[i]) m_currentSpells[i]->SetDeletable(true); 242 m_currentSpells[i] = NULL; 240 if (m_currentSpells[i]) 241 { 242 m_currentSpells[i]->SetReferencedFromCurrent(false); 243 m_currentSpells[i] = NULL; 244 } 243 245 } 244 246 … … 3164 3166 if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED) 3165 3167 { 3166 m_currentSpells[i]->Set Deletable(true); // spell may be safely deleted now3168 m_currentSpells[i]->SetReferencedFromCurrent(false); 3167 3169 m_currentSpells[i] = NULL; // remove pointer 3168 3170 } … … 3277 3279 uint32 CSpellType = pSpell->GetCurrentContainer(); 3278 3280 3279 pSpell->SetDeletable(false); // spell will not be deleted until gone from current pointers3280 3281 if (pSpell == m_currentSpells[CSpellType]) return; // avoid breaking self 3281 3282 … … 3334 3335 // current spell (if it is still here) may be safely deleted now 3335 3336 if (m_currentSpells[CSpellType]) 3336 m_currentSpells[CSpellType]->Set Deletable(true);3337 m_currentSpells[CSpellType]->SetReferencedFromCurrent(false); 3337 3338 3338 3339 // set new current spell 3339 3340 m_currentSpells[CSpellType] = pSpell; 3341 pSpell->SetReferencedFromCurrent(true); 3340 3342 } 3341 3343 … … 3355 3357 if (m_currentSpells[spellType]->getState() != SPELL_STATE_FINISHED) 3356 3358 m_currentSpells[spellType]->cancel(); 3357 m_currentSpells[spellType]->Set Deletable(true);3359 m_currentSpells[spellType]->SetReferencedFromCurrent(false); 3358 3360 m_currentSpells[spellType] = NULL; 3359 3361 } … … 3391 3393 (withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED) ) 3392 3394 m_currentSpells[CURRENT_GENERIC_SPELL]->cancel(); 3393 m_currentSpells[CURRENT_GENERIC_SPELL]->Set Deletable(true);3395 m_currentSpells[CURRENT_GENERIC_SPELL]->SetReferencedFromCurrent(false); 3394 3396 m_currentSpells[CURRENT_GENERIC_SPELL] = NULL; 3395 3397 } … … 3405 3407 (withDelayed || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_DELAYED) ) 3406 3408 m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->cancel(); 3407 m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->Set Deletable(true);3409 m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->SetReferencedFromCurrent(false); 3408 3410 m_currentSpells[CURRENT_AUTOREPEAT_SPELL] = NULL; 3409 3411 } … … 3414 3416 if (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED) 3415 3417 m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel(); 3416 m_currentSpells[CURRENT_CHANNELED_SPELL]->Set Deletable(true);3418 m_currentSpells[CURRENT_CHANNELED_SPELL]->SetReferencedFromCurrent(false); 3417 3419 m_currentSpells[CURRENT_CHANNELED_SPELL] = NULL; 3418 3420 } … … 9861 9863 { 9862 9864 InterruptNonMeleeSpells(true); 9863 m_Events.KillAllEvents( );9865 m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted ans will deleated at call in Map::RemoveAllObjectsInRemoveList 9864 9866 CombatStop(); 9865 9867 ClearComboPointHolders(); -
trunk/src/game/WorldSession.cpp
r168 r173 380 380 381 381 ///- Broadcast a logout message to the player's friends 382 sSocialMgr.SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUIDLow(), "",true);382 sSocialMgr.SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUIDLow(), true); 383 383 384 384 ///- Delete the player object -
trunk/src/game/WorldSession.h
r152 r173 282 282 void HandleFriendListOpcode(WorldPacket& recvPacket); 283 283 void HandleAddFriendOpcode(WorldPacket& recvPacket); 284 static void HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 accountId, std::string friendNote); 284 285 void HandleDelFriendOpcode(WorldPacket& recvPacket); 285 286 void HandleAddIgnoreOpcode(WorldPacket& recvPacket); 287 static void HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 accountId); 286 288 void HandleDelIgnoreOpcode(WorldPacket& recvPacket); 287 289 void HandleSetFriendNoteOpcode(WorldPacket& recvPacket); -
trunk/src/shared/Database/Database.h
r102 r173 62 62 template<class Class, typename ParamType1> 63 63 bool AsyncQuery(Class *object, void (Class::*method)(QueryResult*, ParamType1), ParamType1 param1, const char *sql); 64 template<class Class, typename ParamType1, typename ParamType2> 65 bool AsyncQuery(Class *object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *sql); 64 66 template<typename ParamType1> 65 67 bool AsyncQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char *sql); 68 template<typename ParamType1, typename ParamType2> 69 bool AsyncQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *sql); 66 70 template<class Class> 67 71 bool AsyncPQuery(Class *object, void (Class::*method)(QueryResult*), const char *format,...) ATTR_PRINTF(4,5); 68 72 template<class Class, typename ParamType1> 69 73 bool AsyncPQuery(Class *object, void (Class::*method)(QueryResult*, ParamType1), ParamType1 param1, const char *format,...) ATTR_PRINTF(5,6); 74 template<class Class, typename ParamType1, typename ParamType2> 75 bool AsyncPQuery(Class *object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *format,...) ATTR_PRINTF(5,6); 70 76 template<typename ParamType1> 71 77 bool AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char *format,...) ATTR_PRINTF(5,6); 78 template<typename ParamType1, typename ParamType2> 79 bool AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *format,...) ATTR_PRINTF(5,6); 72 80 template<class Class> 73 81 bool DelayQueryHolder(Class *object, void (Class::*method)(QueryResult*, SqlQueryHolder*), SqlQueryHolder *holder); -
trunk/src/shared/Database/DatabaseImpl.h
r102 r173 48 48 } 49 49 50 template<class Class, typename ParamType1, typename ParamType2> 51 bool 52 Database::AsyncQuery(Class *object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *sql) 53 { 54 if (!sql) return false; 55 ZThread::ThreadImpl * queryThread = ZThread::ThreadImpl::current(); 56 QueryQueues::iterator itr = m_queryQueues.find(queryThread); 57 if (itr == m_queryQueues.end()) return false; 58 m_threadBody->Delay(new SqlQuery(sql, new Trinity::QueryCallback<Class, ParamType1, ParamType2>(object, method, (QueryResult*)NULL, param1, param2), itr->second)); 59 return true; 60 } 61 50 62 template<typename ParamType1> 51 63 bool … … 60 72 } 61 73 74 template<typename ParamType1, typename ParamType2> 75 bool 76 Database::AsyncQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *sql) 77 { 78 if (!sql) return false; 79 ZThread::ThreadImpl * queryThread = ZThread::ThreadImpl::current(); 80 QueryQueues::iterator itr = m_queryQueues.find(queryThread); 81 if (itr == m_queryQueues.end()) return false; 82 m_threadBody->Delay(new SqlQuery(sql, new Trinity::SQueryCallback<ParamType1, ParamType2>(method, (QueryResult*)NULL, param1, param2), itr->second)); 83 return true; 84 } 85 62 86 template<class Class> 63 87 bool … … 102 126 } 103 127 128 template<class Class, typename ParamType1, typename ParamType2> 129 bool 130 Database::AsyncPQuery(Class *object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *format,...) 131 { 132 if(!format) return false; 133 134 va_list ap; 135 char szQuery [MAX_QUERY_LEN]; 136 va_start(ap, format); 137 int res = vsnprintf( szQuery, MAX_QUERY_LEN, format, ap ); 138 va_end(ap); 139 140 if(res==-1) 141 { 142 sLog.outError("SQL Query truncated (and not execute) for format: %s",format); 143 return false; 144 } 145 146 return AsyncQuery(object, method, param1, param2, szQuery); 147 } 148 104 149 template<typename ParamType1> 105 150 bool … … 123 168 } 124 169 170 template<typename ParamType1, typename ParamType2> 171 bool 172 Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char *format,...) 173 { 174 if(!format) return false; 175 176 va_list ap; 177 char szQuery [MAX_QUERY_LEN]; 178 va_start(ap, format); 179 int res = vsnprintf( szQuery, MAX_QUERY_LEN, format, ap ); 180 va_end(ap); 181 182 if(res==-1) 183 { 184 sLog.outError("SQL Query truncated (and not execute) for format: %s",format); 185 return false; 186 } 187 188 return AsyncQuery(method, param1, param2, szQuery); 189 } 125 190 126 191 template<class Class>