aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKingPin <none@none>2008-11-06 08:20:26 -0600
committerKingPin <none@none>2008-11-06 08:20:26 -0600
commit5746d0e98d8a5c4af96102835d501c47ed370def (patch)
treea17851f0bc08626df74b690df53f28754e9e89fe /src
parentc74f9b4a685a899091dc7cb1b5db5c494ed12b9a (diff)
[svn] * Avoid access to bag item prototype for getting bag size, use related item
update field instead as more fast source. source mangos. * Further reduce of DB access in guild handlers. * Multi-locale DBC extracting - source Foks *** Devs not responsible if all your player items drop to the ground and get eaten by ants or rabbits.. or some kind of wierd ant-rabbits.. --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/Bag.cpp60
-rw-r--r--src/game/Bag.h1
-rw-r--r--src/game/Chat.cpp40
-rw-r--r--src/game/Chat.h88
-rw-r--r--src/game/Guild.h4
-rw-r--r--src/game/GuildHandler.cpp97
-rw-r--r--src/game/Language.h4
-rw-r--r--src/game/Level1.cpp6
-rw-r--r--src/game/Level2.cpp30
-rw-r--r--src/game/Level3.cpp4
-rw-r--r--src/game/Player.cpp250
-rw-r--r--src/game/Player.h2
-rw-r--r--src/game/debugcmds.cpp6
13 files changed, 232 insertions, 360 deletions
diff --git a/src/game/Bag.cpp b/src/game/Bag.cpp
index 9a0395928cc..4b8284c7c37 100644
--- a/src/game/Bag.cpp
+++ b/src/game/Bag.cpp
@@ -39,30 +39,25 @@ Bag::Bag( ): Item()
Bag::~Bag()
{
- for(int i = 0; i<MAX_BAG_SIZE; i++)
- {
- if(m_bagslot[i]) delete m_bagslot[i];
- }
+ for(int i = 0; i < MAX_BAG_SIZE; ++i)
+ if (m_bagslot[i])
+ delete m_bagslot[i];
}
void Bag::AddToWorld()
{
Item::AddToWorld();
- for(int i = 0; i<MAX_BAG_SIZE; i++)
- {
+ for(uint32 i = 0; i < GetBagSize(); ++i)
if(m_bagslot[i])
m_bagslot[i]->AddToWorld();
- }
}
void Bag::RemoveFromWorld()
{
- for(int i = 0; i<MAX_BAG_SIZE; i++)
- {
+ for(uint32 i = 0; i < GetBagSize(); ++i)
if(m_bagslot[i])
m_bagslot[i]->RemoveFromWorld();
- }
Item::RemoveFromWorld();
}
@@ -111,7 +106,7 @@ bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result)
return false;
// cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
- for (uint32 i = 0; i < GetProto()->ContainerSlots; i++)
+ for (int i = 0; i < MAX_BAG_SIZE; ++i)
{
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0);
if (m_bagslot[i])
@@ -127,21 +122,16 @@ bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result)
void Bag::DeleteFromDB()
{
for (int i = 0; i < MAX_BAG_SIZE; i++)
- {
if (m_bagslot[i])
- {
m_bagslot[i]->DeleteFromDB();
- }
- }
Item::DeleteFromDB();
}
uint32 Bag::GetFreeSlots() const
{
- uint32 ContainerSlots=GetProto()->ContainerSlots;
uint32 slots = 0;
- for (uint8 i=0; i <ContainerSlots; i++)
+ for (uint32 i=0; i < GetBagSize(); i++)
if (!m_bagslot[i])
++slots;
@@ -178,30 +168,26 @@ void Bag::BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) co
{
Item::BuildCreateUpdateBlockForPlayer( data, target );
- for (int i = 0; i < MAX_BAG_SIZE; i++)
- {
+ for (uint32 i = 0; i < GetBagSize(); ++i)
if(m_bagslot[i])
m_bagslot[i]->BuildCreateUpdateBlockForPlayer( data, target );
- }
}
// If the bag is empty returns true
bool Bag::IsEmpty() const
{
- uint32 ContainerSlots=GetProto()->ContainerSlots;
- for(uint32 i=0; i < ContainerSlots; i++)
- if (m_bagslot[i]) return false;
+ for(uint32 i = 0; i < GetBagSize(); ++i)
+ if (m_bagslot[i])
+ return false;
return true;
}
uint32 Bag::GetItemCount( uint32 item, Item* eItem ) const
{
- uint32 ContainerSlots=GetProto()->ContainerSlots;
-
Item *pItem;
uint32 count = 0;
- for(uint32 i=0; i < ContainerSlots; i++)
+ for(uint32 i=0; i < GetBagSize(); ++i)
{
pItem = m_bagslot[i];
if( pItem && pItem != eItem && pItem->GetEntry() == item )
@@ -210,7 +196,7 @@ uint32 Bag::GetItemCount( uint32 item, Item* eItem ) const
if(eItem && eItem->GetProto()->GemProperties)
{
- for(uint32 i=0; i < ContainerSlots; i++)
+ for(uint32 i=0; i < GetBagSize(); ++i)
{
pItem = m_bagslot[i];
if( pItem && pItem != eItem && pItem->GetProto()->Socket[0].Color )
@@ -223,29 +209,17 @@ uint32 Bag::GetItemCount( uint32 item, Item* eItem ) const
uint8 Bag::GetSlotByItemGUID(uint64 guid) const
{
- uint32 ContainerSlots=GetProto()->ContainerSlots;
-
- for(uint32 i=0;i<ContainerSlots;i++)
- {
+ for(uint32 i = 0; i < GetBagSize(); ++i)
if(m_bagslot[i] != 0)
if(m_bagslot[i]->GetGUID() == guid)
return i;
- }
return NULL_SLOT;
}
-// Adds an item to a bag slot
-// - slot can be NULL_SLOT, in that case function searchs for a free slot
-// - Return values: 0 - item not added
-// 1 - item added to a free slot (and perhaps to a stack)
-// 2 - item added to a stack (item should be deleted)
Item* Bag::GetItemByPos( uint8 slot ) const
{
- ItemPrototype const *pBagProto = GetProto();
- if( pBagProto )
- {
- if( slot < pBagProto->ContainerSlots )
- return m_bagslot[slot];
- }
+ if( slot < GetBagSize() )
+ return m_bagslot[slot];
+
return NULL;
}
diff --git a/src/game/Bag.h b/src/game/Bag.h
index efb9a379be5..97f06917485 100644
--- a/src/game/Bag.h
+++ b/src/game/Bag.h
@@ -52,6 +52,7 @@ class Bag : public Item
uint8 GetSlotByItemGUID(uint64 guid) const;
bool IsEmpty() const;
uint32 GetFreeSlots() const;
+ uint32 GetBagSize() const { return GetUInt32Value(CONTAINER_FIELD_NUM_SLOTS); }
// DB operations
// overwrite virtual Item::SaveToDB
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index 13ee7c275a7..a051e7d893b 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -378,28 +378,28 @@ ChatCommand * ChatHandler::getCommandTable()
static ChatCommand npcCommandTable[] =
{
- { "say", SEC_MODERATOR, false, &ChatHandler::HandleSayCommand, "", NULL },
- { "whisper", SEC_MODERATOR, false, &ChatHandler::HandleNpcWhisperCommand, "", NULL },
- { "yell", SEC_MODERATOR, false, &ChatHandler::HandleYellCommand, "", NULL },
- { "textemote", SEC_MODERATOR, false, &ChatHandler::HandleTextEmoteCommand, "", NULL },
- { "add", SEC_GAMEMASTER, false, &ChatHandler::HandleAddSpwCommand, "", NULL },
- { "delete", SEC_GAMEMASTER, false, &ChatHandler::HandleDelCreatureCommand, "", NULL },
- { "spawndist", SEC_GAMEMASTER, false, &ChatHandler::HandleSpawnDistCommand, "", NULL },
- { "spawntime", SEC_GAMEMASTER, false, &ChatHandler::HandleSpawnTimeCommand, "", NULL },
- { "factionid", SEC_GAMEMASTER, false, &ChatHandler::HandleFactionIdCommand, "", NULL },
- { "addmove", SEC_GAMEMASTER, false, &ChatHandler::HandleAddMoveCommand, "", NULL },
- { "setmovetype", SEC_GAMEMASTER, false, &ChatHandler::HandleSetMoveTypeCommand, "", NULL },
- { "move", SEC_GAMEMASTER, false, &ChatHandler::HandleMoveCreatureCommand, "", NULL },
- { "changelevel", SEC_GAMEMASTER, false, &ChatHandler::HandleChangeLevelCommand, "", NULL },
- { "setmodel", SEC_GAMEMASTER, false, &ChatHandler::HandleSetModelCommand, "", NULL },
- { "additem", SEC_GAMEMASTER, false, &ChatHandler::HandleAddVendorItemCommand, "", NULL },
- { "delitem", SEC_GAMEMASTER, false, &ChatHandler::HandleDelVendorItemCommand, "", NULL },
- { "flag", SEC_GAMEMASTER, false, &ChatHandler::HandleNPCFlagCommand, "", NULL },
- { "changeentry", SEC_ADMINISTRATOR, false, &ChatHandler::HandleChangeEntryCommand, "", NULL },
- { "info", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNpcInfoCommand, "", NULL },
- { "playemote", SEC_ADMINISTRATOR, false, &ChatHandler::HandlePlayEmoteCommand, "", NULL },
+ { "say", SEC_MODERATOR, false, &ChatHandler::HandleNpcSayCommand, "", NULL },
+ { "textemote", SEC_MODERATOR, false, &ChatHandler::HandleNpcTextEmoteCommand, "", NULL },
+ { "add", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAddCommand, "", NULL },
+ { "delete", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcDeleteCommand, "", NULL },
+ { "spawndist", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcSpawnDistCommand, "", NULL },
+ { "spawntime", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcSpawnTimeCommand, "", NULL },
+ { "factionid", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcFactionIdCommand, "", NULL },
+ { "addmove", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAddMoveCommand, "", NULL },
+ { "setmovetype", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcSetMoveTypeCommand, "", NULL },
+ { "move", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcMoveCommand, "", NULL },
+ { "changelevel", SEC_GAMEMASTER, false, &ChatHandler::HandleChangeLevelCommand, "", NULL },
+ { "setmodel", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcSetModelCommand, "", NULL },
+ { "additem", SEC_GAMEMASTER, false, &ChatHandler::HandleAddVendorItemCommand, "", NULL },
+ { "delitem", SEC_GAMEMASTER, false, &ChatHandler::HandleDelVendorItemCommand, "", NULL },
+ { "flag", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcFlagCommand, "", NULL },
+ { "changeentry", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNpcChangeEntryCommand, "", NULL },
+ { "info", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNpcInfoCommand, "", NULL },
+ { "playemote", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNpcPlayEmoteCommand, "", NULL },
{ "follow", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcFollowCommand, "", NULL },
{ "unfollow", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcUnFollowCommand, "", NULL },
+ { "whisper", SEC_MODERATOR, false, &ChatHandler::HandleNpcWhisperCommand, "", NULL },
+ { "yell", SEC_MODERATOR, false, &ChatHandler::HandleNpcYellCommand, "", NULL },
//{ TODO: fix or remove this commands
{ "name", SEC_GAMEMASTER, false, &ChatHandler::HandleNameCommand, "", NULL },
diff --git a/src/game/Chat.h b/src/game/Chat.h
index 05cb23417f3..d1adecaec7d 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -117,10 +117,6 @@ class ChatHandler
bool HandleGPSCommand(const char* args);
bool HandleTaxiCheatCommand(const char* args);
bool HandleWhispersCommand(const char* args);
- bool HandleSayCommand(const char* args);
- bool HandleNpcWhisperCommand(const char* args);
- bool HandleYellCommand(const char* args);
- bool HandlePlayEmoteCommand(const char* args);
bool HandleSendMailCommand(const char* args);
bool HandleNameTeleCommand(const char* args);
bool HandleGroupTeleCommand(const char* args);
@@ -131,6 +127,32 @@ class ChatHandler
bool HandleEventStopCommand(const char* args);
bool HandleEventInfoCommand(const char* args);
+ bool HandleLearnCommand(const char* args);
+ bool HandleLearnAllCommand(const char* args);
+ bool HandleLearnAllGMCommand(const char* args);
+ bool HandleLearnAllCraftsCommand(const char* args);
+ bool HandleLearnAllRecipesCommand(const char* args);
+ bool HandleLearnAllDefaultCommand(const char* args);
+ bool HandleLearnAllLangCommand(const char* args);
+ bool HandleLearnAllMyClassCommand(const char* args);
+ bool HandleLearnAllMySpellsCommand(const char* args);
+ bool HandleLearnAllMyTalentsCommand(const char* args);
+
+ bool HandleLookupAreaCommand(const char* args);
+ bool HandleLookupCreatureCommand(const char* args);
+ bool HandleLookupEventCommand(const char* args);
+ bool HandleLookupFactionCommand(const char * args);
+ bool HandleLookupItemCommand(const char * args);
+ bool HandleLookupItemSetCommand(const char * args);
+ bool HandleLookupObjectCommand(const char* args);
+ bool HandleLookupPlayerIpCommand(const char* args);
+ bool HandleLookupPlayerAccountCommand(const char* args);
+ bool HandleLookupPlayerEmailCommand(const char* args);
+ bool HandleLookupQuestCommand(const char* args);
+ bool HandleLookupSkillCommand(const char* args);
+ bool HandleLookupSpellCommand(const char* args);
+ bool HandleLookupTeleCommand(const char * args);
+
bool HandleModifyKnownTitlesCommand(const char* args);
bool HandleModifyHPCommand(const char* args);
bool HandleModifyManaCommand(const char* args);
@@ -151,9 +173,26 @@ class ChatHandler
bool HandleModifyHonorCommand (const char* args);
bool HandleModifyRepCommand(const char* args);
bool HandleModifyArenaCommand(const char* args);
-
+
+ bool HandleNpcAddCommand(const char* args);
+ bool HandleNpcAddMoveCommand(const char* args);
+ bool HandleNpcChangeEntryCommand(const char *args);
+ bool HandleNpcDeleteCommand(const char* args);
+ bool HandleNpcFactionIdCommand(const char* args);
+ bool HandleNpcFlagCommand(const char* args);
bool HandleNpcFollowCommand(const char* args);
+ bool HandleNpcInfoCommand(const char* args);
+ bool HandleNpcMoveCommand(const char* args);
+ bool HandleNpcPlayEmoteCommand(const char* args);
+ bool HandleNpcSayCommand(const char* args);
+ bool HandleNpcSetModelCommand(const char* args);
+ bool HandleNpcSetMoveTypeCommand(const char* args);
+ bool HandleNpcSpawnDistCommand(const char* args);
+ bool HandleNpcSpawnTimeCommand(const char* args);
+ bool HandleNpcTextEmoteCommand(const char* args);
bool HandleNpcUnFollowCommand(const char* args);
+ bool HandleNpcWhisperCommand(const char* args);
+ bool HandleNpcYellCommand(const char* args);
bool HandleReloadCommand(const char* args);
bool HandleReloadAllCommand(const char* args);
@@ -249,28 +288,18 @@ class ChatHandler
bool HandleNameCommand(const char* args);
bool HandleSubNameCommand(const char* args);
bool HandleItemMoveCommand(const char* args);
- bool HandleDelCreatureCommand(const char* args);
bool HandleDeMorphCommand(const char* args);
bool HandleAddVendorItemCommand(const char* args);
bool HandleDelVendorItemCommand(const char* args);
- bool HandleAddMoveCommand(const char* args);
- bool HandleSetMoveTypeCommand(const char* args);
bool HandleChangeLevelCommand(const char* args);
bool HandleSetPoiCommand(const char* args);
bool HandleEquipErrorCommand(const char* args);
- bool HandleNPCFlagCommand(const char* args);
- bool HandleSetModelCommand(const char* args);
- bool HandleFactionIdCommand(const char* args);
- bool HandleAddSpwCommand(const char* args);
- bool HandleSpawnDistCommand(const char* args);
- bool HandleSpawnTimeCommand(const char* args);
bool HandleGoCreatureCommand(const char* args);
bool HandleGoObjectCommand(const char* args);
bool HandleGoTriggerCommand(const char* args);
bool HandleGoGraveyardCommand(const char* args);
bool HandleTargetObjectCommand(const char* args);
bool HandleDelObjectCommand(const char* args);
- bool HandleMoveCreatureCommand(const char* args);
bool HandleMoveObjectCommand(const char* args);
bool HandleTurnObjectCommand(const char* args);
bool HandleObjectStateCommand(const char* args);
@@ -309,32 +338,6 @@ class ChatHandler
bool HandleAllowMovementCommand(const char* args);
bool HandleGoCommand(const char* args);
- bool HandleLearnCommand(const char* args);
- bool HandleLearnAllCommand(const char* args);
- bool HandleLearnAllGMCommand(const char* args);
- bool HandleLearnAllCraftsCommand(const char* args);
- bool HandleLearnAllRecipesCommand(const char* args);
- bool HandleLearnAllDefaultCommand(const char* args);
- bool HandleLearnAllLangCommand(const char* args);
- bool HandleLearnAllMyClassCommand(const char* args);
- bool HandleLearnAllMySpellsCommand(const char* args);
- bool HandleLearnAllMyTalentsCommand(const char* args);
-
- bool HandleLookupAreaCommand(const char* args);
- bool HandleLookupCreatureCommand(const char* args);
- bool HandleLookupEventCommand(const char* args);
- bool HandleLookupFactionCommand(const char * args);
- bool HandleLookupItemCommand(const char * args);
- bool HandleLookupItemSetCommand(const char * args);
- bool HandleLookupObjectCommand(const char* args);
- bool HandleLookupPlayerIpCommand(const char* args);
- bool HandleLookupPlayerAccountCommand(const char* args);
- bool HandleLookupPlayerEmailCommand(const char* args);
- bool HandleLookupQuestCommand(const char* args);
- bool HandleLookupSkillCommand(const char* args);
- bool HandleLookupSpellCommand(const char* args);
- bool HandleLookupTeleCommand(const char * args);
-
bool HandleCooldownCommand(const char* args);
bool HandleUnLearnCommand(const char* args);
bool HandleGetDistanceCommand(const char* args);
@@ -353,8 +356,6 @@ class ChatHandler
bool HandleActivateObjectCommand(const char* args);
bool HandleSpawnTransportCommand(const char* args);
bool HandleExploreCheatCommand(const char* args);
- bool HandleTextEmoteCommand(const char* args);
- bool HandleNpcInfoCommand(const char* args);
bool HandleHoverCommand(const char* args);
bool HandleWaterwalkCommand(const char* args);
bool HandleLevelUpCommand(const char* args);
@@ -421,7 +422,6 @@ class ChatHandler
bool HandleRenameCommand(const char * args);
bool HandleLoadPDumpCommand(const char *args);
bool HandleWritePDumpCommand(const char *args);
- bool HandleChangeEntryCommand(const char *args);
bool HandleCastCommand(const char *args);
bool HandleCastBackCommand(const char *args);
bool HandleCastDistCommand(const char *args);
diff --git a/src/game/Guild.h b/src/game/Guild.h
index d1431c287bd..0e0e99b2cd4 100644
--- a/src/game/Guild.h
+++ b/src/game/Guild.h
@@ -327,6 +327,10 @@ class Guild
return ((GetRankRights(rankId) & right) != GR_RIGHT_EMPTY) ? true : false;
}
int32 GetRank(uint32 LowGuid);
+ bool IsMember(uint32 LowGuid)
+ {
+ return (members.find(LowGuid) != members.end());
+ }
void Roster(WorldSession *session);
void Query(WorldSession *session);
diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp
index fbe03b2776c..e503db9f299 100644
--- a/src/game/GuildHandler.cpp
+++ b/src/game/GuildHandler.cpp
@@ -152,10 +152,6 @@ void WorldSession::HandleGuildRemoveOpcode(WorldPacket& recvPacket)
CHECK_PACKET_SIZE(recvPacket, 1);
std::string plName;
- uint64 plGuid;
- uint32 plGuildId;
- Guild *guild;
- Player *player;
//sLog.outDebug("WORLD: Received CMSG_GUILD_REMOVE");
@@ -164,7 +160,7 @@ void WorldSession::HandleGuildRemoveOpcode(WorldPacket& recvPacket)
if(!normalizePlayerName(plName))
return;
- guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
+ Guild* guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
if(!guild)
{
SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD);
@@ -177,17 +173,7 @@ void WorldSession::HandleGuildRemoveOpcode(WorldPacket& recvPacket)
return;
}
- player = ObjectAccessor::Instance().FindPlayerByName(plName.c_str());
- if(player)
- {
- plGuid = player->GetGUID();
- plGuildId = player->GetGuildId();
- }
- else
- {
- plGuid = objmgr.GetPlayerGUIDByName(plName);
- plGuildId = Player::GetGuildIdFromDB(plGuid);
- }
+ uint64 plGuid = objmgr.GetPlayerGUIDByName(plName);
if(!plGuid)
{
@@ -201,7 +187,7 @@ void WorldSession::HandleGuildRemoveOpcode(WorldPacket& recvPacket)
return;
}
- if(GetPlayer()->GetGuildId() != plGuildId)
+ if(!guild->IsMember(GUID_LOPART(plGuid)))
{
SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_IN_GUILD_S);
return;
@@ -487,9 +473,6 @@ void WorldSession::HandleGuildLeaderOpcode(WorldPacket& recvPacket)
CHECK_PACKET_SIZE(recvPacket, 1);
std::string name;
- Player *newLeader;
- uint64 newLeaderGUID;
- uint32 newLeaderGuild;
Player *oldLeader = GetPlayer();
Guild *guild;
@@ -502,35 +485,25 @@ void WorldSession::HandleGuildLeaderOpcode(WorldPacket& recvPacket)
guild = objmgr.GetGuildById(oldLeader->GetGuildId());
- if(!guild)
+ if (!guild)
{
SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD);
return;
}
- if(oldLeader->GetGUID() != guild->GetLeader())
+ if( oldLeader->GetGUID() != guild->GetLeader())
{
SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS);
return;
}
- newLeader = ObjectAccessor::Instance().FindPlayerByName(name.c_str());
- if(newLeader)
- {
- newLeaderGUID = newLeader->GetGUID();
- newLeaderGuild = newLeader->GetGuildId();
- }
- else
- {
- newLeaderGUID = objmgr.GetPlayerGUIDByName(name);
- newLeaderGuild = Player::GetGuildIdFromDB(newLeaderGUID);
- }
- if(!newLeaderGUID)
+ uint64 newLeaderGUID = objmgr.GetPlayerGUIDByName(name);
+ if (!newLeaderGUID)
{
SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_FOUND);
return;
}
- if(oldLeader->GetGuildId() != newLeaderGuild)
+ if(!guild->IsMember(GUID_LOPART(newLeaderGUID)))
{
SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_IN_GUILD_S);
return;
@@ -588,10 +561,6 @@ void WorldSession::HandleGuildSetPublicNoteOpcode(WorldPacket& recvPacket)
{
CHECK_PACKET_SIZE(recvPacket, 1);
- Guild *guild;
- Player *player;
- uint64 plGuid;
- uint32 plGuildId;
std::string name,PNOTE;
//sLog.outDebug("WORLD: Received CMSG_GUILD_SET_PUBLIC_NOTE");
@@ -601,37 +570,28 @@ void WorldSession::HandleGuildSetPublicNoteOpcode(WorldPacket& recvPacket)
if(!normalizePlayerName(name))
return;
- guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
- if(!guild)
+ Guild* guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
+ if (!guild)
{
SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD);
return;
}
- if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_EPNOTE))
+ if (!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_EPNOTE))
{
SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS);
return;
}
- player = ObjectAccessor::Instance().FindPlayerByName(name.c_str());
- if(player)
- {
- plGuid = player->GetGUID();
- plGuildId = player->GetGuildId();
- }
- else
- {
- plGuid = objmgr.GetPlayerGUIDByName(name);
- plGuildId = Player::GetGuildIdFromDB(plGuid);
- }
+ uint64 plGuid = objmgr.GetPlayerGUIDByName(name);
- if(!plGuid)
+ if (!plGuid)
{
SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_FOUND);
return;
}
- else if(GetPlayer()->GetGuildId() != plGuildId)
+
+ if (!guild->IsMember(GUID_LOPART(plGuid)))
{
SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_IN_GUILD_S);
return;
@@ -647,10 +607,6 @@ void WorldSession::HandleGuildSetOfficerNoteOpcode(WorldPacket& recvPacket)
{
CHECK_PACKET_SIZE(recvPacket, 1);
- Guild *guild;
- Player *player;
- uint64 plGuid;
- uint32 plGuildId;
std::string plName, OFFNOTE;
//sLog.outDebug("WORLD: Received CMSG_GUILD_SET_OFFICER_NOTE");
@@ -660,36 +616,27 @@ void WorldSession::HandleGuildSetOfficerNoteOpcode(WorldPacket& recvPacket)
if(!normalizePlayerName(plName))
return;
- guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
- if(!guild)
+ Guild* guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
+ if (!guild)
{
SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD);
return;
}
- if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_EOFFNOTE))
+ if (!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_EOFFNOTE))
{
SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS);
return;
}
- player = ObjectAccessor::Instance().FindPlayerByName(plName.c_str());
- if(player)
- {
- plGuid = player->GetGUID();
- plGuildId = player->GetGuildId();
- }
- else
- {
- plGuid = objmgr.GetPlayerGUIDByName(plName);
- plGuildId = Player::GetGuildIdFromDB(plGuid);
- }
+ uint64 plGuid = objmgr.GetPlayerGUIDByName(plName);
- if( !plGuid )
+ if (!plGuid)
{
SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_FOUND);
return;
}
- else if(GetPlayer()->GetGuildId() != plGuildId)
+
+ if (!guild->IsMember(GUID_LOPART(plGuid)))
{
SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_IN_GUILD_S);
return;
diff --git a/src/game/Language.h b/src/game/Language.h
index 4e8cc8fc75f..86c66c546d6 100644
--- a/src/game/Language.h
+++ b/src/game/Language.h
@@ -697,8 +697,8 @@ enum TrinityStrings
// Room for more level 4 1012-1099 not used
// Level 3 (continue)
- LANG_MOTD_NEW = 1100,
- LANG_ACCOUNT_SETADDON = 1101,
+ LANG_ACCOUNT_SETADDON = 1100,
+ LANG_MOTD_NEW = 1101,
LANG_SENDMESSAGE = 1102,
LANG_EVENT_ENTRY_LIST_CONSOLE = 1103,
LANG_CREATURE_ENTRY_LIST_CONSOLE = 1104,
diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp
index 3543b3b91fa..766db5d972f 100644
--- a/src/game/Level1.cpp
+++ b/src/game/Level1.cpp
@@ -38,7 +38,7 @@
#include "VMapFactory.h"
#endif
-bool ChatHandler::HandleSayCommand(const char* args)
+bool ChatHandler::HandleNpcSayCommand(const char* args)
{
if(!*args)
return false;
@@ -56,7 +56,7 @@ bool ChatHandler::HandleSayCommand(const char* args)
return true;
}
-bool ChatHandler::HandleYellCommand(const char* args)
+bool ChatHandler::HandleNpcYellCommand(const char* args)
{
if(!*args)
return false;
@@ -75,7 +75,7 @@ bool ChatHandler::HandleYellCommand(const char* args)
}
//show text emote by creature in chat
-bool ChatHandler::HandleTextEmoteCommand(const char* args)
+bool ChatHandler::HandleNpcTextEmoteCommand(const char* args)
{
if(!*args)
return false;
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index 9cc98d97169..9aff34d79f3 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -860,11 +860,11 @@ bool ChatHandler::HandleItemMoveCommand(const char* args)
srcslot = (uint8)atoi(pParam1);
dstslot = (uint8)atoi(pParam2);
- uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot);
- uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstslot);
-
if(srcslot==dstslot)
return true;
+
+ uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot);
+ uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstslot);
m_session->GetPlayer()->SwapItem( src, dst );
@@ -872,7 +872,7 @@ bool ChatHandler::HandleItemMoveCommand(const char* args)
}
//add spawn of creature
-bool ChatHandler::HandleAddSpwCommand(const char* args)
+bool ChatHandler::HandleNpcAddCommand(const char* args)
{
if(!*args)
return false;
@@ -922,7 +922,7 @@ bool ChatHandler::HandleAddSpwCommand(const char* args)
return true;
}
-bool ChatHandler::HandleDelCreatureCommand(const char* args)
+bool ChatHandler::HandleNpcDeleteCommand(const char* args)
{
Creature* unit = NULL;
@@ -1070,7 +1070,7 @@ bool ChatHandler::HandleTurnObjectCommand(const char* args)
}
//move selected creature
-bool ChatHandler::HandleMoveCreatureCommand(const char* args)
+bool ChatHandler::HandleNpcMoveCommand(const char* args)
{
uint32 lowguid = 0;
@@ -1323,7 +1323,7 @@ bool ChatHandler::HandleDelVendorItemCommand(const char* args)
}
//add move for creature
-bool ChatHandler::HandleAddMoveCommand(const char* args)
+bool ChatHandler::HandleNpcAddMoveCommand(const char* args)
{
if(!*args)
return false;
@@ -1397,7 +1397,7 @@ bool ChatHandler::HandleAddMoveCommand(const char* args)
* additional parameter: NODEL - so no waypoints are deleted, if you
* change the movement type
*/
-bool ChatHandler::HandleSetMoveTypeCommand(const char* args)
+bool ChatHandler::HandleNpcSetMoveTypeCommand(const char* args)
{
if(!*args)
return false;
@@ -1525,7 +1525,7 @@ bool ChatHandler::HandleSetMoveTypeCommand(const char* args)
}
return true;
-} // HandleSetMoveTypeCommand
+} // HandleNpcSetMoveTypeCommand
//change level of creature or pet
bool ChatHandler::HandleChangeLevelCommand(const char* args)
@@ -1565,7 +1565,7 @@ bool ChatHandler::HandleChangeLevelCommand(const char* args)
}
//set npcflag of creature
-bool ChatHandler::HandleNPCFlagCommand(const char* args)
+bool ChatHandler::HandleNpcFlagCommand(const char* args)
{
if (!*args)
return false;
@@ -1591,7 +1591,7 @@ bool ChatHandler::HandleNPCFlagCommand(const char* args)
}
//set model of creature
-bool ChatHandler::HandleSetModelCommand(const char* args)
+bool ChatHandler::HandleNpcSetModelCommand(const char* args)
{
if (!*args)
return false;
@@ -1632,8 +1632,8 @@ bool ChatHandler::HandleMorphCommand(const char* args)
return true;
}
-//set faction of creature or go
-bool ChatHandler::HandleFactionIdCommand(const char* args)
+//set faction of creature
+bool ChatHandler::HandleNpcFactionIdCommand(const char* args)
{
if (!*args)
return false;
@@ -2138,7 +2138,7 @@ bool ChatHandler::HandleDelTicketCommand(const char *args)
}
//set spawn dist of creature
-bool ChatHandler::HandleSpawnDistCommand(const char* args)
+bool ChatHandler::HandleNpcSpawnDistCommand(const char* args)
{
if(!*args)
return false;
@@ -2176,7 +2176,7 @@ bool ChatHandler::HandleSpawnDistCommand(const char* args)
return true;
}
-bool ChatHandler::HandleSpawnTimeCommand(const char* args)
+bool ChatHandler::HandleNpcSpawnTimeCommand(const char* args)
{
if(!*args)
return false;
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
index 4ab83c9fd3f..7914f10bc49 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -3656,7 +3656,7 @@ bool ChatHandler::HandleNearGraveCommand(const char* args)
}
//play npc emote
-bool ChatHandler::HandlePlayEmoteCommand(const char* args)
+bool ChatHandler::HandleNpcPlayEmoteCommand(const char* args)
{
uint32 emote = atoi((char*)args);
@@ -5564,7 +5564,7 @@ bool ChatHandler::HandleLoadPDumpCommand(const char *args)
return true;
}
-bool ChatHandler::HandleChangeEntryCommand(const char *args)
+bool ChatHandler::HandleNpcChangeEntryCommand(const char *args)
{
if(!args)
return false;
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 02d16277476..7723cb23a3b 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -3925,10 +3925,9 @@ void Player::DurabilityLossAll(double percent, bool inventory)
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
- if(ItemPrototype const *pBagProto = pBag->GetProto())
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
- if(Item* pItem = GetItemByPos( i, j ))
- DurabilityLoss(pItem,percent);
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
+ if(Item* pItem = GetItemByPos( i, j ))
+ DurabilityLoss(pItem,percent);
}
}
@@ -3970,10 +3969,9 @@ void Player::DurabilityPointsLossAll(int32 points, bool inventory)
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
- if(ItemPrototype const *pBagProto = pBag->GetProto())
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
- if(Item* pItem = GetItemByPos( i, j ))
- DurabilityPointsLoss(pItem,points);
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
+ if(Item* pItem = GetItemByPos( i, j ))
+ DurabilityPointsLoss(pItem,points);
}
}
@@ -8326,24 +8324,19 @@ uint8 Player::CanUnequipItems( uint32 item, uint32 count ) const
}
}
Bag *pBag;
- ItemPrototype const *pBagProto;
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
{
pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
if( pBag )
{
- pBagProto = pBag->GetProto();
- if( pBagProto )
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
+ pItem = GetItemByPos( i, j );
+ if( pItem && pItem->GetEntry() == item )
{
- pItem = GetItemByPos( i, j );
- if( pItem && pItem->GetEntry() == item )
- {
- tempcount += pItem->GetCount();
- if( tempcount >= count )
- return EQUIP_ERR_OK;
- }
+ tempcount += pItem->GetCount();
+ if( tempcount >= count )
+ return EQUIP_ERR_OK;
}
}
}
@@ -8434,15 +8427,11 @@ Item* Player::GetItemByGuid( uint64 guid ) const
Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
if( pBag )
{
- ItemPrototype const *pBagProto = pBag->GetProto();
- if( pBagProto )
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
- {
- Item* pItem = pBag->GetItemByPos( j );
- if( pItem && pItem->GetGUID() == guid )
- return pItem;
- }
+ Item* pItem = pBag->GetItemByPos( j );
+ if( pItem && pItem->GetGUID() == guid )
+ return pItem;
}
}
}
@@ -8451,15 +8440,11 @@ Item* Player::GetItemByGuid( uint64 guid ) const
Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
if( pBag )
{
- ItemPrototype const *pBagProto = pBag->GetProto();
- if( pBagProto )
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
- {
- Item* pItem = pBag->GetItemByPos( j );
- if( pItem && pItem->GetGUID() == guid )
- return pItem;
- }
+ Item* pItem = pBag->GetItemByPos( j );
+ if( pItem && pItem->GetGUID() == guid )
+ return pItem;
}
}
}
@@ -8617,17 +8602,14 @@ bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const
{
if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
{
- if(ItemPrototype const *pBagProto = pBag->GetProto())
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
+ Item* pItem = GetItemByPos( i, j );
+ if( pItem && pItem->GetEntry() == item )
{
- Item* pItem = GetItemByPos( i, j );
- if( pItem && pItem->GetEntry() == item )
- {
- tempcount += pItem->GetCount();
- if( tempcount >= count )
- return true;
- }
+ tempcount += pItem->GetCount();
+ if( tempcount >= count )
+ return true;
}
}
}
@@ -8649,17 +8631,14 @@ bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const
{
if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
{
- if(ItemPrototype const *pBagProto = pBag->GetProto())
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
+ Item* pItem = GetItemByPos( i, j );
+ if( pItem && pItem->GetEntry() == item )
{
- Item* pItem = GetItemByPos( i, j );
- if( pItem && pItem->GetEntry() == item )
- {
- tempcount += pItem->GetCount();
- if( tempcount >= count )
- return true;
- }
+ tempcount += pItem->GetCount();
+ if( tempcount >= count )
+ return true;
}
}
}
@@ -8737,22 +8716,15 @@ bool Player::HasItemTotemCategory( uint32 TotemCategory ) const
if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory ))
return true;
}
- Bag *pBag;
- ItemPrototype const *pBagProto;
for(uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
{
- pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pBag )
+ if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
{
- pBagProto = pBag->GetProto();
- if( pBagProto )
+ for(uint32 j = 0; j < pBag->GetBagSize(); ++j)
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; ++j)
- {
- pItem = GetItemByPos( i, j );
- if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory ))
- return true;
- }
+ pItem = GetItemByPos( i, j );
+ if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory ))
+ return true;
}
}
}
@@ -8846,7 +8818,7 @@ uint8 Player::_CanStoreItem_InBag( uint8 bag, ItemPosCountVec &dest, ItemPrototy
if( !ItemCanGoIntoBag(pProto,pBagProto) )
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
// skip specific slot already processed in first called _CanStoreItem_InSpecificSlot
if(j==skip_slot)
@@ -9353,23 +9325,14 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
{
- Bag *pBag;
- ItemPrototype const *pBagProto;
-
- pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pBag )
+ if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
{
- pBagProto = pBag->GetProto();
-
- if( pBagProto )
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
+ pItem2 = GetItemByPos( i, j );
+ if (pItem2 && !pItem2->IsInTrade())
{
- pItem2 = GetItemByPos( i, j );
- if (pItem2 && !pItem2->IsInTrade())
- {
- inv_bags[i-INVENTORY_SLOT_BAG_START][j] = pItem2->GetCount();
- }
+ inv_bags[i-INVENTORY_SLOT_BAG_START][j] = pItem2->GetCount();
}
}
}
@@ -9436,18 +9399,14 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t );
if( pBag )
{
- pBagProto = pBag->GetProto();
- if( pBagProto )
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
+ pItem2 = GetItemByPos( t, j );
+ if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_bags[t-INVENTORY_SLOT_BAG_START][j] + pItem->GetCount() <= pProto->Stackable )
{
- pItem2 = GetItemByPos( t, j );
- if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_bags[t-INVENTORY_SLOT_BAG_START][j] + pItem->GetCount() <= pProto->Stackable )
- {
- inv_bags[t-INVENTORY_SLOT_BAG_START][j] += pItem->GetCount();
- b_found = true;
- break;
- }
+ inv_bags[t-INVENTORY_SLOT_BAG_START][j] += pItem->GetCount();
+ b_found = true;
+ break;
}
}
}
@@ -9486,7 +9445,7 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
if( pBagProto && (pBagProto->Class != ITEM_CLASS_CONTAINER || pBagProto->SubClass != ITEM_SUBCLASS_CONTAINER) &&
ItemCanGoIntoBag(pProto,pBagProto) )
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 )
{
@@ -9520,17 +9479,13 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t );
if( pBag )
{
- pBagProto = pBag->GetProto();
- if( pBagProto && ItemCanGoIntoBag(pProto,pBagProto))
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
+ if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 )
{
- if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 )
- {
- inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1;
- b_found = true;
- break;
- }
+ inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1;
+ b_found = true;
+ break;
}
}
}
@@ -10624,40 +10579,33 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
}
// in inventory bags
- Bag *pBag;
- ItemPrototype const *pBagProto;
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
{
- pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pBag )
+ if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
{
- pBagProto = pBag->GetProto();
- if( pBagProto )
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
+ pItem = pBag->GetItemByPos(j);
+ if( pItem && pItem->GetEntry() == item )
{
- pItem = pBag->GetItemByPos(j);
- if( pItem && pItem->GetEntry() == item )
+ // all items in bags can be unequipped
+ if( pItem->GetCount() + remcount <= count )
{
- // all items in bags can be unequipped
- if( pItem->GetCount() + remcount <= count )
- {
- remcount += pItem->GetCount();
- DestroyItem( i, j, update );
+ remcount += pItem->GetCount();
+ DestroyItem( i, j, update );
- if(remcount >=count)
- return;
- }
- else
- {
- pProto = pItem->GetProto();
- ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount );
- pItem->SetCount( pItem->GetCount() - count + remcount );
- if( IsInWorld() && update )
- pItem->SendUpdateToPlayer( this );
- pItem->SetState(ITEM_CHANGED, this);
+ if(remcount >=count)
return;
- }
+ }
+ else
+ {
+ pProto = pItem->GetProto();
+ ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount );
+ pItem->SetCount( pItem->GetCount() - count + remcount );
+ if( IsInWorld() && update )
+ pItem->SendUpdateToPlayer( this );
+ pItem->SetState(ITEM_CHANGED, this);
+ return;
}
}
}
@@ -10719,15 +10667,11 @@ void Player::DestroyZoneLimitedItem( bool update, uint32 new_zone )
Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
if( pBag )
{
- ItemPrototype const *pBagProto = pBag->GetProto();
- if( pBagProto )
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
- {
- Item* pItem = pBag->GetItemByPos(j);
- if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) )
- DestroyItem( i, j, update);
- }
+ Item* pItem = pBag->GetItemByPos(j);
+ if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) )
+ DestroyItem( i, j, update);
}
}
}
@@ -10763,17 +10707,13 @@ void Player::DestroyConjuredItems( bool update )
Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
if( pBag )
{
- ItemPrototype const *pBagProto = pBag->GetProto();
- if( pBagProto )
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
- {
- Item* pItem = pBag->GetItemByPos(j);
- if( pItem && pItem->GetProto() &&
- (pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) &&
- (pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) )
- DestroyItem( i, j, update);
- }
+ Item* pItem = pBag->GetItemByPos(j);
+ if( pItem && pItem->GetProto() &&
+ (pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) &&
+ (pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) )
+ DestroyItem( i, j, update);
}
}
}
@@ -11422,15 +11362,11 @@ void Player::RemoveAllEnchantments(EnchantmentSlot slot)
Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
if( pBag )
{
- ItemPrototype const *pBagProto = pBag->GetProto();
- if( pBagProto )
+ for(uint32 j = 0; j < pBag->GetBagSize(); j++)
{
- for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)
- {
- Item* pItem = pBag->GetItemByPos(j);
- if( pItem && pItem->GetEnchantmentId(slot) )
- pItem->ClearEnchantment(slot);
- }
+ Item* pItem = pBag->GetItemByPos(j);
+ if( pItem && pItem->GetEnchantmentId(slot) )
+ pItem->ClearEnchantment(slot);
}
}
}
@@ -15716,6 +15652,16 @@ void Player::SendAutoRepeatCancel()
GetSession()->SendPacket( &data );
}
+void Player::PlaySound(uint32 Sound, bool OnlySelf)
+{
+ WorldPacket data(SMSG_PLAY_SOUND, 4);
+ data << Sound;
+ if (OnlySelf)
+ GetSession()->SendPacket( &data );
+ else
+ SendMessageToSet( &data, true );
+}
+
void Player::SendExplorationExperience(uint32 Area, uint32 Experience)
{
WorldPacket data( SMSG_EXPLORATION_EXPERIENCE, 8 );
diff --git a/src/game/Player.h b/src/game/Player.h
index 4727aba1716..f8865040a9e 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1605,6 +1605,8 @@ class TRINITY_DLL_SPEC Player : public Unit
void SendDelayResponse(const uint32);
void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP);
+ //Low Level Packets
+ void PlaySound(uint32 Sound, bool OnlySelf);
//notifiers
void SendAttackSwingCantAttack();
void SendAttackSwingCancelAttack();
diff --git a/src/game/debugcmds.cpp b/src/game/debugcmds.cpp
index e8deb551ebf..e98550315f9 100644
--- a/src/game/debugcmds.cpp
+++ b/src/game/debugcmds.cpp
@@ -319,8 +319,7 @@ bool ChatHandler::HandleGetItemState(const char* args)
else
{
Bag *bag = (Bag*)item;
- const ItemPrototype *proto = bag->GetProto();
- for (uint8 j = 0; j < proto->ContainerSlots; ++j)
+ for (uint8 j = 0; j < bag->GetBagSize(); ++j)
{
Item* item = bag->GetItemByPos(j);
if (item && item->GetState() == state)
@@ -416,8 +415,7 @@ bool ChatHandler::HandleGetItemState(const char* args)
if(item->IsBag())
{
Bag *bag = (Bag*)item;
- const ItemPrototype *proto = bag->GetProto();
- for (uint8 j = 0; j < proto->ContainerSlots; ++j)
+ for (uint8 j = 0; j < bag->GetBagSize(); ++j)
{
Item* item = bag->GetItemByPos(j);
if (!item) continue;