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

@ -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"
@ -643,11 +644,8 @@ void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data )
sLog.outDebug( "WORLD: Received CMSG_ADD_FRIEND" );
std::string friendName = GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN);
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);
CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddFriendOpcodeCallBack, GetAccountId(), friendNote, "SELECT guid, race FROM characters WHERE name = '%s'", friendName.c_str());
}
void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 accountId, std::string friendNote)
{
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)
{
pFriend = ObjectAccessor::FindPlayer(friendGuid);
if(pFriend==GetPlayer())
if(friendGuid==session->GetPlayer()->GetGUID())
friendResult = FRIEND_SELF;
else if(GetPlayer()->GetTeam()!=objmgr.GetPlayerTeamByGUID(friendGuid) && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && GetSecurity() < SEC_MODERATOR)
else if(session->GetPlayer()->GetTeam() != team && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && session->GetSecurity() < SEC_MODERATOR)
friendResult = FRIEND_ENEMY;
else if(GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid)))
else if(session->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid)))
friendResult = FRIEND_ALREADY;
}
if (friendGuid && friendResult==FRIEND_NOT_FOUND)
{
if( pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(GetPlayer()))
friendResult = FRIEND_ADDED_ONLINE;
else
friendResult = FRIEND_ADDED_OFFLINE;
if(!_player->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false))
{
friendResult = FRIEND_LIST_FULL;
sLog.outDebug( "WORLD: %s's friend list is full.", GetPlayer()->GetName());
Player* pFriend = ObjectAccessor::FindPlayer(friendGuid);
if( pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(session->GetPlayer()))
friendResult = FRIEND_ADDED_ONLINE;
else
friendResult = FRIEND_ADDED_OFFLINE;
if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false))
{
friendResult = FRIEND_LIST_FULL;
sLog.outDebug( "WORLD: %s's friend list is full.", session->GetPlayer()->GetName());
}
session->GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote);
}
_player->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote);
sLog.outDebug( "WORLD: %s Guid found '%u'.", friendName.c_str(), GUID_LOPART(friendGuid));
}
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( session->GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid)) )
ignoreResult = FRIEND_IGNORE_ALREADY;
else
{
if( GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid)) )
ignoreResult = FRIEND_IGNORE_ALREADY;
ignoreResult = FRIEND_IGNORE_ADDED;
// ignore list full
if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid), true))
ignoreResult = FRIEND_IGNORE_FULL;
}
}
if (IgnoreGuid && ignoreResult == FRIEND_IGNORE_NOT_FOUND)
{
ignoreResult = FRIEND_IGNORE_ADDED;
if(!_player->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)" );
}