diff --git a/src/game/ArenaTeamHandler.cpp b/src/game/ArenaTeamHandler.cpp index 7cab8d085..16784bbcb 100644 --- a/src/game/ArenaTeamHandler.cpp +++ b/src/game/ArenaTeamHandler.cpp @@ -360,7 +360,7 @@ void WorldSession::HandleArenaTeamPromoteToCaptainOpcode(WorldPacket & recv_data at->BroadcastPacket(&data); } -void WorldSession::SendArenaTeamCommandResult(uint32 unk1, std::string str1, std::string str2, uint32 unk3) +void WorldSession::SendArenaTeamCommandResult(uint32 unk1, const std::string& str1, const std::string& str2, uint32 unk3) { WorldPacket data(SMSG_ARENA_TEAM_COMMAND_RESULT, 4+str1.length()+1+str2.length()+1+4); data << unk1; @@ -370,7 +370,7 @@ void WorldSession::SendArenaTeamCommandResult(uint32 unk1, std::string str1, std SendPacket(&data); } -void WorldSession::BuildArenaTeamEventPacket(WorldPacket *data, uint8 eventid, uint8 str_count, std::string str1, std::string str2, std::string str3) +void WorldSession::BuildArenaTeamEventPacket(WorldPacket *data, uint8 eventid, uint8 str_count, const std::string& str1, const std::string& str2, const std::string& str3) { data->Initialize(SMSG_ARENA_TEAM_EVENT, 1+1+1); *data << eventid; diff --git a/src/game/Channel.cpp b/src/game/Channel.cpp index 2fb8b5d09..22c1a5b1a 100644 --- a/src/game/Channel.cpp +++ b/src/game/Channel.cpp @@ -21,7 +21,7 @@ #include "World.h" #include "SocialMgr.h" -Channel::Channel(std::string name, uint32 channel_id) +Channel::Channel(const std::string& name, uint32 channel_id) : m_name(name), m_announce(true), m_moderate(false), m_channelId(channel_id), m_ownerGUID(0), m_password(""), m_flags(0) { // set special flags if built-in channel @@ -773,7 +773,7 @@ void Channel::MakeOwnerChanged(WorldPacket *data, uint64 guid) } // done 0x09 -void Channel::MakePlayerNotFound(WorldPacket *data, std::string name) +void Channel::MakePlayerNotFound(WorldPacket *data, const std::string& name) { MakeNotifyPacket(data, CHAT_PLAYER_NOT_FOUND_NOTICE); *data << name; diff --git a/src/game/Channel.h b/src/game/Channel.h index fc87efdd0..c3214f824 100644 --- a/src/game/Channel.h +++ b/src/game/Channel.h @@ -170,7 +170,7 @@ class Channel void MakeNotModerator(WorldPacket *data); //? 0x06 void MakePasswordChanged(WorldPacket *data, uint64 guid); //+ 0x07 void MakeOwnerChanged(WorldPacket *data, uint64 guid); //? 0x08 - void MakePlayerNotFound(WorldPacket *data, std::string name); //+ 0x09 + void MakePlayerNotFound(WorldPacket *data, const std::string& name); //+ 0x09 void MakeNotOwner(WorldPacket *data); //? 0x0A void MakeChannelOwner(WorldPacket *data); //? 0x0B void MakeModeChange(WorldPacket *data, uint64 guid, uint8 oldflags); //+ 0x0C @@ -244,14 +244,14 @@ class Channel } public: - Channel(std::string name, uint32 channel_id); + Channel(const std::string& name, uint32 channel_id); std::string GetName() const { return m_name; } uint32 GetChannelId() const { return m_channelId; } bool IsConstant() const { return m_channelId != 0; } bool IsAnnounce() const { return m_announce; } bool IsLFG() const { return GetFlags() & CHANNEL_FLAG_LFG; } std::string GetPassword() const { return m_password; } - void SetPassword(std::string npassword) { m_password = npassword; } + void SetPassword(const std::string& npassword) { m_password = npassword; } void SetAnnounce(bool nannounce) { m_announce = nannounce; } uint32 GetNumPlayers() const { return players.size(); } uint8 GetFlags() const { return m_flags; } diff --git a/src/game/ChannelMgr.h b/src/game/ChannelMgr.h index b3e3ac2e4..124afec5c 100644 --- a/src/game/ChannelMgr.h +++ b/src/game/ChannelMgr.h @@ -36,7 +36,7 @@ class ChannelMgr delete itr->second; channels.clear(); } - Channel *GetJoinChannel(std::string name, uint32 channel_id) + Channel *GetJoinChannel(const std::string& name, uint32 channel_id) { if(channels.count(name) == 0) { @@ -45,7 +45,7 @@ class ChannelMgr } return channels[name]; } - Channel *GetChannel(std::string name, Player *p) + Channel *GetChannel(const std::string& name, Player *p) { ChannelMap::const_iterator i = channels.find(name); @@ -59,7 +59,7 @@ class ChannelMgr else return i->second; } - void LeftChannel(std::string name) + void LeftChannel(const std::string& name) { ChannelMap::const_iterator i = channels.find(name); @@ -76,7 +76,7 @@ class ChannelMgr } private: ChannelMap channels; - void MakeNotOnPacket(WorldPacket *data, std::string name) + void MakeNotOnPacket(WorldPacket *data, const std::string& name) { data->Initialize(SMSG_CHANNEL_NOTIFY, (1+10)); // we guess size (*data) << (uint8)0x05 << name; diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 531e28670..dba83eb46 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -709,7 +709,7 @@ void ChatHandler::PSendSysMessage(const char *format, ...) SendSysMessage(str); } -bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, std::string fullcmd) +bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, const std::string& fullcmd) { char const* oldtext = text; std::string cmd = ""; diff --git a/src/game/Chat.h b/src/game/Chat.h index f719d0aa8..35c417d97 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -80,7 +80,7 @@ class ChatHandler void SendGlobalSysMessage(const char *str); - bool ExecuteCommandInTable(ChatCommand *table, const char* text, std::string fullcommand); + bool ExecuteCommandInTable(ChatCommand *table, const char* text, const std::string& fullcommand); bool ShowHelpForCommand(ChatCommand *table, const char* cmd); bool ShowHelpForSubCommands(ChatCommand *table, char const* cmd, char const* subcmd); diff --git a/src/game/GMTicketMgr.h b/src/game/GMTicketMgr.h index 01e00874d..5f7bf69ea 100644 --- a/src/game/GMTicketMgr.h +++ b/src/game/GMTicketMgr.h @@ -31,7 +31,7 @@ class GMTicket { } - GMTicket(uint32 guid, std::string text, time_t update) : m_guid(guid), m_text(text), m_lastUpdate(update) + GMTicket(uint32 guid, const std::string& text, time_t update) : m_guid(guid), m_text(text), m_lastUpdate(update) { } diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index a977a17d9..c61ab5e10 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -34,7 +34,7 @@ GossipMenu::~GossipMenu() ClearMenu(); } -void GossipMenu::AddMenuItem(uint8 Icon, std::string Message, uint32 dtSender, uint32 dtAction, std::string BoxMessage, uint32 BoxMoney, bool Coded) +void GossipMenu::AddMenuItem(uint8 Icon, const std::string& Message, uint32 dtSender, uint32 dtAction, const std::string& BoxMessage, uint32 BoxMoney, bool Coded) { ASSERT( m_gItems.size() <= GOSSIP_MAX_MENU_ITEMS ); @@ -51,7 +51,7 @@ void GossipMenu::AddMenuItem(uint8 Icon, std::string Message, uint32 dtSender, u m_gItems.push_back(gItem); } -void GossipMenu::AddMenuItem(uint8 Icon, std::string Message, bool Coded) +void GossipMenu::AddMenuItem(uint8 Icon, const std::string& Message, bool Coded) { AddMenuItem( Icon, Message, 0, 0, "", 0, Coded); } @@ -341,7 +341,7 @@ void QuestMenu::ClearMenu() m_qItems.clear(); } -void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote, std::string Title, uint64 npcGUID ) +void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote, const std::string& Title, uint64 npcGUID ) { WorldPacket data( SMSG_QUESTGIVER_QUEST_LIST, 100 ); // guess size data << uint64(npcGUID); diff --git a/src/game/GossipDef.h b/src/game/GossipDef.h index ba5b36008..7cde0c3b1 100644 --- a/src/game/GossipDef.h +++ b/src/game/GossipDef.h @@ -101,8 +101,8 @@ class MANGOS_DLL_SPEC GossipMenu GossipMenu(); ~GossipMenu(); - void AddMenuItem(uint8 Icon, std::string Message, bool Coded = false); - void AddMenuItem(uint8 Icon, std::string Message, uint32 dtSender, uint32 dtAction, std::string BoxMessage, uint32 BoxMoney, bool Coded = false); + void AddMenuItem(uint8 Icon, const std::string& Message, bool Coded = false); + void AddMenuItem(uint8 Icon, const std::string& Message, uint32 dtSender, uint32 dtAction, const std::string& BoxMessage, uint32 BoxMoney, bool Coded = false); // for using from scripts, don't must be inlined void AddMenuItem(uint8 Icon, char const* Message, bool Coded = false); @@ -195,7 +195,7 @@ class MANGOS_DLL_SPEC PlayerMenu /*********************************************************/ void SendQuestGiverStatus( uint8 questStatus, uint64 npcGUID ); - void SendQuestGiverQuestList( QEmote eEmote, std::string Title, uint64 npcGUID ); + void SendQuestGiverQuestList( QEmote eEmote, const std::string& Title, uint64 npcGUID ); void SendQuestQueryResponse ( Quest const *pQuest ); void SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID, bool ActivateAccept); diff --git a/src/game/Group.cpp b/src/game/Group.cpp index 9cf107f06..de97b70b3 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -212,7 +212,7 @@ bool Group::AddInvite(Player *player) RemoveInvite(player); - m_invitees.insert(player->GetGUID()); + m_invitees.insert(player); player->SetGroupInvite(this); @@ -231,14 +231,7 @@ bool Group::AddLeaderInvite(Player *player) uint32 Group::RemoveInvite(Player *player) { - for(InvitesList::iterator itr=m_invitees.begin(); itr!=m_invitees.end(); ++itr) - { - if((*itr) == player->GetGUID()) - { - m_invitees.erase(itr); - break; - } - } + m_invitees.erase(player); player->SetGroupInvite(NULL); return GetMembersCount(); @@ -247,14 +240,31 @@ uint32 Group::RemoveInvite(Player *player) void Group::RemoveAllInvites() { for(InvitesList::iterator itr=m_invitees.begin(); itr!=m_invitees.end(); ++itr) - { - Player *invitee = objmgr.GetPlayer(*itr); - if(invitee) - invitee->SetGroupInvite(NULL); - } + (*itr)->SetGroupInvite(NULL); + m_invitees.clear(); } +Player* Group::GetInvited(const uint64& guid) const +{ + for(InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr) + { + if((*itr)->GetGUID() == guid) + return (*itr); + } + return NULL; +} + +Player* Group::GetInvited(const std::string& name) const +{ + for(InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr) + { + if((*itr)->GetName() == name) + return (*itr); + } + return NULL; +} + bool Group::AddMember(const uint64 &guid, const char* name) { if(!_addMember(guid, name)) diff --git a/src/game/Group.h b/src/game/Group.h index 5148a919f..3f893e31b 100644 --- a/src/game/Group.h +++ b/src/game/Group.h @@ -144,7 +144,7 @@ class MANGOS_DLL_SPEC Group typedef UNORDERED_MAP< uint32 /*mapId*/, InstanceGroupBind> BoundInstancesMap; protected: typedef MemberSlotList::iterator member_witerator; - typedef std::set InvitesList; + typedef std::set InvitesList; typedef std::vector Rolls; @@ -184,6 +184,17 @@ class MANGOS_DLL_SPEC Group // member manipulation methods bool IsMember(const uint64& guid) const { return _getMemberCSlot(guid) != m_memberSlots.end(); } bool IsLeader(const uint64& guid) const { return (GetLeaderGUID() == guid); } + uint64 GetMemberGUID(const std::string& name) + { + for(member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr) + { + if(itr->name == name) + { + return itr->guid; + } + } + return 0; + } bool IsAssistant(uint64 guid) const { member_citerator mslot = _getMemberCSlot(guid); @@ -192,6 +203,8 @@ class MANGOS_DLL_SPEC Group return mslot->assistant; } + Player* GetInvited(const uint64& guid) const; + Player* GetInvited(const std::string& name) const; bool SameSubGroup(uint64 guid1,const uint64& guid2) const { diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp index 218326448..851e21030 100644 --- a/src/game/GroupHandler.cpp +++ b/src/game/GroupHandler.cpp @@ -42,7 +42,7 @@ -FIX sending PartyMemberStats */ -void WorldSession::SendPartyResult(PartyOperation operation, std::string member, PartyResult res) +void WorldSession::SendPartyResult(PartyOperation operation, const std::string& member, PartyResult res) { WorldPacket data(SMSG_PARTY_COMMAND_RESULT, (8+member.size()+1)); data << (uint32)operation; @@ -246,17 +246,37 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data) uint64 guid; recv_data >> guid; - if(_player->InBattleGround()) + //can't uninvite yourself + if(guid == GetPlayer()->GetGUID()) { - SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_INVITE_RESTRICTED); + sLog.outError("WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); return; } - std::string membername; - if(!objmgr.GetPlayerNameByGUID(guid, membername)) - return; // not found + PartyResult res = GetPlayer()->CanUninviteFromGroup(); + if(res != PARTY_RESULT_OK) + { + SendPartyResult(PARTY_OP_LEAVE, "", res); + return; + } - HandleGroupUninvite(guid, membername); + Group* grp = GetPlayer()->GetGroup(); + if(!grp) + return; + + if(grp->IsMember(guid)) + { + Player::RemoveFromGroup(grp,guid); + return; + } + + if(Player* plr = grp->GetInvited(guid)) + { + plr->UninviteFromGroup(); + return; + } + + SendPartyResult(PARTY_OP_LEAVE, "", PARTY_RESULT_NOT_IN_YOUR_PARTY); } void WorldSession::HandleGroupUninviteNameOpcode(WorldPacket & recv_data) @@ -266,65 +286,41 @@ void WorldSession::HandleGroupUninviteNameOpcode(WorldPacket & recv_data) std::string membername; recv_data >> membername; - if(_player->InBattleGround()) - { - SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_INVITE_RESTRICTED); - return; - } - // player not found if(!normalizePlayerName(membername)) return; - uint64 guid = objmgr.GetPlayerGUIDByName(membername); - - // player not found - if(!guid) - return; - - HandleGroupUninvite(guid, membername); -} - -void WorldSession::HandleGroupUninvite(uint64 guid, std::string name) -{ - Group *group = GetPlayer()->GetGroup(); - if(!group) - return; - - if(_player->InBattleGround()) + // can't uninvite yourself + if(GetPlayer()->GetName() == membername) { - SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_INVITE_RESTRICTED); + sLog.outError("WorldSession::HandleGroupUninviteNameOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); return; } - Player *player = objmgr.GetPlayer(guid); - - /** error handling **/ - if(!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID())) + PartyResult res = GetPlayer()->CanUninviteFromGroup(); + if(res != PARTY_RESULT_OK) { - SendPartyResult(PARTY_OP_LEAVE, "", PARTY_RESULT_YOU_NOT_LEADER); + SendPartyResult(PARTY_OP_LEAVE, "", res); return; } - if(!group->IsMember(guid) && (player && player->GetGroupInvite() != group)) + Group* grp = GetPlayer()->GetGroup(); + if(!grp) + return; + + if(uint64 guid = grp->GetMemberGUID(membername)) { - SendPartyResult(PARTY_OP_LEAVE, name, PARTY_RESULT_NOT_IN_YOUR_PARTY); + Player::RemoveFromGroup(grp,guid); return; } - if(guid == GetPlayer()->GetGUID()) + if(Player* plr = grp->GetInvited(membername)) { - sLog.outError("WorldSession::HandleGroupUninvite: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); + plr->UninviteFromGroup(); return; } - /********************/ - // everything's fine, do it - - if(player && player->GetGroupInvite()) // uninvite invitee - player->UninviteFromGroup(); - else // uninvite member - Player::RemoveFromGroup(group,guid); + SendPartyResult(PARTY_OP_LEAVE, membername, PARTY_RESULT_NOT_IN_YOUR_PARTY); } void WorldSession::HandleGroupSetLeaderOpcode( WorldPacket & recv_data ) diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp index f4cc438e6..49efd8a5a 100644 --- a/src/game/Guild.cpp +++ b/src/game/Guild.cpp @@ -517,7 +517,7 @@ void Guild::SetOFFNOTE(uint64 guid,std::string offnote) CharacterDatabase.PExecute("UPDATE guild_member SET offnote = '%s' WHERE guid = '%u'", offnote.c_str(), itr->first); } -void Guild::BroadcastToGuild(WorldSession *session, std::string msg, uint32 language) +void Guild::BroadcastToGuild(WorldSession *session, const std::string& msg, uint32 language) { if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(),GR_RIGHT_GCHATSPEAK)) { @@ -534,7 +534,7 @@ void Guild::BroadcastToGuild(WorldSession *session, std::string msg, uint32 lang } } -void Guild::BroadcastToOfficers(WorldSession *session, std::string msg, uint32 language) +void Guild::BroadcastToOfficers(WorldSession *session, const std::string& msg, uint32 language) { if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(),GR_RIGHT_OFFCHATSPEAK)) { @@ -593,7 +593,7 @@ void Guild::CreateRank(std::string name_,uint32 rights) CharacterDatabase.PExecute( "INSERT INTO guild_rank (guildid,rid,rname,rights) VALUES ('%u', '%u', '%s', '%u')", Id, m_ranks.size(), name_.c_str(), rights ); } -void Guild::AddRank(std::string name_,uint32 rights, uint32 money) +void Guild::AddRank(const std::string& name_,uint32 rights, uint32 money) { m_ranks.push_back(RankInfo(name_,rights,money)); } diff --git a/src/game/Guild.h b/src/game/Guild.h index d1270a060..1a4cdf9a5 100644 --- a/src/game/Guild.h +++ b/src/game/Guild.h @@ -245,7 +245,7 @@ struct MemberSlot struct RankInfo { - RankInfo(std::string _name, uint32 _rights, uint32 _money) : name(_name), rights(_rights), BankMoneyPerDay(_money) + RankInfo(const std::string& _name, uint32 _rights, uint32 _money) : name(_name), rights(_rights), BankMoneyPerDay(_money) { for(uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i) { @@ -310,8 +310,8 @@ class Guild bool FillPlayerData(uint64 guid, MemberSlot* memslot); void LoadPlayerStatsByGuid(uint64 guid); - void BroadcastToGuild(WorldSession *session, std::string msg, uint32 language = LANG_UNIVERSAL); - void BroadcastToOfficers(WorldSession *session, std::string msg, uint32 language = LANG_UNIVERSAL); + void BroadcastToGuild(WorldSession *session, const std::string& msg, uint32 language = LANG_UNIVERSAL); + void BroadcastToOfficers(WorldSession *session, const std::string& msg, uint32 language = LANG_UNIVERSAL); void BroadcastPacketToRank(WorldPacket *packet, uint32 rankId); void BroadcastPacket(WorldPacket *packet); @@ -332,7 +332,7 @@ class Guild { return (members.find(LowGuid) != members.end()); } - MemberSlot* GetMemberSlot(std::string const& name, uint64& guid) + MemberSlot* GetMemberSlot(const std::string& name, uint64& guid) { for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) { @@ -408,7 +408,7 @@ class Guild bool AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry ); protected: - void AddRank(std::string name,uint32 rights,uint32 money); + void AddRank(const std::string& name,uint32 rights,uint32 money); uint32 Id; std::string name; diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp index d40bb9b4d..8b093b808 100644 --- a/src/game/GuildHandler.cpp +++ b/src/game/GuildHandler.cpp @@ -730,7 +730,7 @@ void WorldSession::HandleGuildDelRankOpcode(WorldPacket& /*recvPacket*/) guild->Roster(this); } -void WorldSession::SendGuildCommandResult(uint32 typecmd,std::string str,uint32 cmdresult) +void WorldSession::SendGuildCommandResult(uint32 typecmd, const std::string& str,uint32 cmdresult) { WorldPacket data(SMSG_GUILD_COMMAND_RESULT, (8+str.size()+1)); data << typecmd; diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 045674a0b..1bca38aac 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -352,7 +352,7 @@ void WorldSession::HandleReturnToSender(WorldPacket & recv_data ) pl->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, 0); } -void WorldSession::SendReturnToSender(uint8 messageType, uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid, std::string subject, uint32 itemTextId, MailItemsInfo *mi, uint32 money, uint16 mailTemplateId ) +void WorldSession::SendReturnToSender(uint8 messageType, uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid, const std::string& subject, uint32 itemTextId, MailItemsInfo *mi, uint32 money, uint16 mailTemplateId ) { if(messageType != MAIL_NORMAL) // return only to players { diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 63686583e..99e6a5aae 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -318,10 +318,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) } if (GetPlayer()->m_lastFallTime >= movementInfo.fallTime || GetPlayer()->m_lastFallZ <=movementInfo.z) - { - GetPlayer()->m_lastFallTime = movementInfo.fallTime; - GetPlayer()->m_lastFallZ= movementInfo.z; - } + GetPlayer()->SetFallInformation(movementInfo.fallTime, movementInfo.z); if(GetPlayer()->isMovingOrTurning()) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index 1c8b00cb8..e7ac60265 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -114,7 +114,7 @@ void WorldSession::SendTrainerList( uint64 guid ) SendTrainerList( guid, str ); } -void WorldSession::SendTrainerList( uint64 guid,std::string strTitle ) +void WorldSession::SendTrainerList( uint64 guid, const std::string& strTitle ) { sLog.outDebug( "WORLD: SendTrainerList" ); diff --git a/src/game/Object.h b/src/game/Object.h index 16e1fbfdf..6abd05203 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -407,7 +407,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object InstanceData* GetInstanceData(); const char* GetName() const { return m_name.c_str(); } - void SetName(std::string newname) { m_name=newname; } + void SetName(const std::string& newname) { m_name=newname; } virtual const char* GetNameForLocaleIdx(int32 /*locale_idx*/) const { return GetName(); } diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 2f13ccde6..5e934a44d 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -200,7 +200,7 @@ Guild * ObjectMgr::GetGuildById(const uint32 GuildId) const return NULL; } -Guild * ObjectMgr::GetGuildByName(std::string guildname) const +Guild * ObjectMgr::GetGuildByName(const std::string& guildname) const { for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); ++itr) if ((*itr)->GetName() == guildname) @@ -236,7 +236,7 @@ ArenaTeam* ObjectMgr::GetArenaTeamById(const uint32 ArenaTeamId) const return NULL; } -ArenaTeam* ObjectMgr::GetArenaTeamByName(std::string arenateamname) const +ArenaTeam* ObjectMgr::GetArenaTeamByName(const std::string& arenateamname) const { for(ArenaTeamSet::const_iterator itr = mArenaTeamSet.begin(); itr != mArenaTeamSet.end(); ++itr) if ((*itr)->GetName() == arenateamname) @@ -1433,7 +1433,7 @@ uint32 ObjectMgr::GetPlayerAccountIdByGUID(const uint64 &guid) const return 0; } -uint32 ObjectMgr::GetPlayerAccountIdByPlayerName(std::string name) const +uint32 ObjectMgr::GetPlayerAccountIdByPlayerName(const std::string& name) const { QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", name.c_str()); if(result) @@ -6198,7 +6198,7 @@ bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bo return false; } -bool ObjectMgr::IsValidName( std::string name, bool create ) +bool ObjectMgr::IsValidName( const std::string& name, bool create ) { std::wstring wname; if(!Utf8toWStr(name,wname)) @@ -6212,7 +6212,7 @@ bool ObjectMgr::IsValidName( std::string name, bool create ) return isValidString(wname,strictMask,false,create); } -bool ObjectMgr::IsValidCharterName( std::string name ) +bool ObjectMgr::IsValidCharterName( const std::string& name ) { std::wstring wname; if(!Utf8toWStr(name,wname)) @@ -6226,7 +6226,7 @@ bool ObjectMgr::IsValidCharterName( std::string name ) return isValidString(wname,strictMask,true); } -bool ObjectMgr::IsValidPetName( std::string name ) +bool ObjectMgr::IsValidPetName( const std::string& name ) { std::wstring wname; if(!Utf8toWStr(name,wname)) @@ -6872,7 +6872,7 @@ void ObjectMgr::LoadGameTele() sLog.outString( ">> Loaded %u game tele's", count ); } -GameTele const* ObjectMgr::GetGameTele(std::string name) const +GameTele const* ObjectMgr::GetGameTele(const std::string& name) const { // explicit name case std::wstring wname; @@ -6915,7 +6915,7 @@ bool ObjectMgr::AddGameTele(GameTele& tele) new_id,tele.position_x,tele.position_y,tele.position_z,tele.orientation,tele.mapId,tele.name.c_str()); } -bool ObjectMgr::DeleteGameTele(std::string name) +bool ObjectMgr::DeleteGameTele(const std::string& name) { // explicit name case std::wstring wname; @@ -7323,7 +7323,7 @@ uint32 ObjectMgr::GetScriptId(const char *name) if(!name) return 0; ScriptNameMap::const_iterator itr = std::lower_bound(m_scriptNames.begin(), m_scriptNames.end(), name); - if(itr == m_scriptNames.end()) return 0; + if(itr == m_scriptNames.end() || *itr != name) return 0; return itr - m_scriptNames.begin(); } diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 339d8d631..68d2346db 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -315,13 +315,13 @@ class ObjectMgr Guild* GetGuildByLeader(uint64 const&guid) const; Guild* GetGuildById(const uint32 GuildId) const; - Guild* GetGuildByName(std::string guildname) const; + Guild* GetGuildByName(const std::string& guildname) const; std::string GetGuildNameById(const uint32 GuildId) const; void AddGuild(Guild* guild) { mGuildSet.insert( guild ); } void RemoveGuild(Guild* guild) { mGuildSet.erase( guild ); } ArenaTeam* GetArenaTeamById(const uint32 ArenaTeamId) const; - ArenaTeam* GetArenaTeamByName(std::string ArenaTeamName) const; + ArenaTeam* GetArenaTeamByName(const std::string& ArenaTeamName) const; ArenaTeam* GetArenaTeamByCapitan(uint64 const& guid) const; void AddArenaTeam(ArenaTeam* arenateam) { mArenaTeamSet.insert( arenateam ); } void RemoveArenaTeam(ArenaTeam* arenateam) { mArenaTeamSet.erase( arenateam ); } @@ -407,7 +407,7 @@ class ObjectMgr bool GetPlayerNameByGUID(const uint64 &guid, std::string &name) const; uint32 GetPlayerTeamByGUID(const uint64 &guid) const; uint32 GetPlayerAccountIdByGUID(const uint64 &guid) const; - uint32 GetPlayerAccountIdByPlayerName(std::string name) const; + uint32 GetPlayerAccountIdByPlayerName(const std::string& name) const; uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid ); void GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost); @@ -701,15 +701,15 @@ class ObjectMgr // reserved names void LoadReservedPlayersNames(); - bool IsReservedName(std::string name) const + bool IsReservedName(const std::string& name) const { return m_ReservedNames.find(name) != m_ReservedNames.end(); } // name with valid structure and symbols - static bool IsValidName( std::string name, bool create = false ); - static bool IsValidCharterName( std::string name ); - static bool IsValidPetName( std::string name ); + static bool IsValidName( const std::string& name, bool create = false ); + static bool IsValidCharterName( const std::string& name ); + static bool IsValidPetName( const std::string& name ); static bool CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names); @@ -733,10 +733,10 @@ class ObjectMgr if(itr==m_GameTeleMap.end()) return NULL; return &itr->second; } - GameTele const* GetGameTele(std::string name) const; + GameTele const* GetGameTele(const std::string& name) const; GameTeleMap const& GetGameTeleMap() const { return m_GameTeleMap; } bool AddGameTele(GameTele& data); - bool DeleteGameTele(std::string name); + bool DeleteGameTele(const std::string& name); CacheNpcOptionList const& GetNpcOptions() const { return m_mCacheNpcOptionList; } diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index 47ac9d9d4..1a34358f0 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -672,7 +672,7 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) } } -void WorldSession::SendPetNameInvalid(uint32 error, std::string name, DeclinedName *declinedName) +void WorldSession::SendPetNameInvalid(uint32 error, const std::string& name, DeclinedName *declinedName) { WorldPacket data(SMSG_PET_NAME_INVALID, 4 + name.size() + 1 + 1); data << uint32(error); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index d07bfe94e..02f3d062d 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -190,7 +190,7 @@ void PlayerTaxi::AppendTaximaskTo( ByteBuffer& data, bool all ) } } -bool PlayerTaxi::LoadTaxiDestinationsFromString( std::string values ) +bool PlayerTaxi::LoadTaxiDestinationsFromString( const std::string& values ) { ClearTaxiDestinations(); @@ -488,7 +488,7 @@ void Player::CleanupsBeforeDelete() Unit::CleanupsBeforeDelete(); } -bool Player::Create( uint32 guidlow, std::string name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId ) +bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId ) { //FIXME: outfitId not used in player creating @@ -1549,6 +1549,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati else // this will be used instead of the current location in SaveToDB m_teleport_dest = WorldLocation(mapid, x, y, z, orientation); + SetFallInformation(0, z); //BuildHeartBeatMsg(&data); //SendMessageToSet(&data, true); @@ -1696,6 +1697,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati } m_teleport_dest = WorldLocation(mapid, final_x, final_y, final_z, final_o); + SetFallInformation(0, final_z); // if the player is saved before worldportack (at logout for example) // this will be used instead of the current location in SaveToDB @@ -2033,23 +2035,23 @@ bool Player::IsInSameGroupWith(Player const* p) const /// \todo Shouldn't we also check if there is no other invitees before disbanding the group? void Player::UninviteFromGroup() { - if(GetGroupInvite()) // uninvited invitee + Group* group = GetGroupInvite(); + if(!group) + return; + + group->RemoveInvite(this); + + if(group->GetMembersCount() <= 1) // group has just 1 member => disband { - Group* group = GetGroupInvite(); - group->RemoveInvite(this); - - if(group->GetMembersCount() <= 1) // group has just 1 member => disband + if(group->IsCreated()) { - if(group->IsCreated()) - { - group->Disband(true); - objmgr.RemoveGroup(group); - } - else - group->RemoveAllInvites(); - - delete group; + group->Disband(true); + objmgr.RemoveGroup(group); } + else + group->RemoveAllInvites(); + + delete group; } } @@ -13811,6 +13813,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) uint32 transGUID = fields[24].GetUInt32(); Relocate(fields[6].GetFloat(),fields[7].GetFloat(),fields[8].GetFloat(),fields[10].GetFloat()); + SetFallInformation(0, fields[8].GetFloat()); SetMapId(fields[9].GetUInt32()); SetDifficulty(fields[32].GetUInt32()); // may be changed in _LoadGroup @@ -16111,7 +16114,7 @@ void Player::Uncharm() charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS); } -void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, std::string text, uint32 language) const +void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const { *data << (uint8)msgtype; *data << (uint32)language; @@ -16123,28 +16126,28 @@ void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, std::string text, *data << (uint8)chatTag(); } -void Player::Say(const std::string text, const uint32 language) +void Player::Say(const std::string& text, const uint32 language) { WorldPacket data(SMSG_MESSAGECHAT, 200); BuildPlayerChat(&data, CHAT_MSG_SAY, text, language); SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY),true); } -void Player::Yell(const std::string text, const uint32 language) +void Player::Yell(const std::string& text, const uint32 language) { WorldPacket data(SMSG_MESSAGECHAT, 200); BuildPlayerChat(&data, CHAT_MSG_YELL, text, language); SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL),true); } -void Player::TextEmote(const std::string text) +void Player::TextEmote(const std::string& text) { WorldPacket data(SMSG_MESSAGECHAT, 200); BuildPlayerChat(&data, CHAT_MSG_EMOTE, text, LANG_UNIVERSAL); SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE),true, !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT) ); } -void Player::Whisper(std::string text, uint32 language,uint64 receiver) +void Player::Whisper(const std::string& text, uint32 language,uint64 receiver) { if (language != LANG_ADDON) // if not addon data language = LANG_UNIVERSAL; // whispers should always be readable @@ -18630,6 +18633,21 @@ Player* Player::GetNextRandomRaidMember(float radius) return nearMembers[randTarget]; } +PartyResult Player::CanUninviteFromGroup() const +{ + const Group* grp = GetGroup(); + if(!grp) + return PARTY_RESULT_YOU_NOT_IN_GROUP; + + if(!grp->IsLeader(GetGUID()) && !grp->IsAssistant(GetGUID())) + return PARTY_RESULT_YOU_NOT_LEADER; + + if(InBattleGround()) + return PARTY_RESULT_INVITE_RESTRICTED; + + return PARTY_RESULT_OK; +} + void Player::UpdateUnderwaterState( Map* m, float x, float y, float z ) { float water_z = m->GetWaterLevel(x,y); diff --git a/src/game/Player.h b/src/game/Player.h index 82c4899c8..820cef796 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -921,7 +921,7 @@ class MANGOS_DLL_SPEC PlayerTaxi void AppendTaximaskTo(ByteBuffer& data,bool all); // Destinations - bool LoadTaxiDestinationsFromString(std::string values); + bool LoadTaxiDestinationsFromString(const std::string& values); std::string SaveTaxiDestinationsToString(); void ClearTaxiDestinations() { m_TaxiDestinations.clear(); } @@ -974,7 +974,7 @@ class MANGOS_DLL_SPEC Player : public Unit } void SummonIfPossible(bool agree); - bool Create( uint32 guidlow, std::string name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId ); + bool Create( uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId ); void Update( uint32 time ); @@ -1068,11 +1068,11 @@ class MANGOS_DLL_SPEC Player : public Unit GuardianPetList const& GetGuardians() const { return m_guardianPets; } void Uncharm(); - void Say(std::string text, const uint32 language); - void Yell(std::string text, const uint32 language); - void TextEmote(std::string text); - void Whisper(std::string text, const uint32 language,uint64 receiver); - void BuildPlayerChat(WorldPacket *data, uint8 msgtype, std::string text, uint32 language) const; + void Say(const std::string& text, const uint32 language); + void Yell(const std::string& text, const uint32 language); + void TextEmote(const std::string& text); + void Whisper(const std::string& text, const uint32 language,uint64 receiver); + void BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const; /*********************************************************/ /*** STORAGE SYSTEM ***/ @@ -1982,6 +1982,11 @@ class MANGOS_DLL_SPEC Player : public Unit uint32 m_lastFallTime; float m_lastFallZ; Unit *m_mover; + void SetFallInformation(uint32 time, float z) + { + m_lastFallTime = time; + m_lastFallZ = z; + } bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask); } bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask); } @@ -2095,6 +2100,7 @@ class MANGOS_DLL_SPEC Player : public Unit uint64 GetAuraUpdateMask() { return m_auraUpdateMask; } void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); } Player* GetNextRandomRaidMember(float radius); + PartyResult CanUninviteFromGroup() const; GridReference &GetGridRef() { return m_gridRef; } MapReference &GetMapRef() { return m_mapRef; } diff --git a/src/game/PlayerDump.cpp b/src/game/PlayerDump.cpp index b7e66c968..b533cab6c 100644 --- a/src/game/PlayerDump.cpp +++ b/src/game/PlayerDump.cpp @@ -337,7 +337,7 @@ std::string PlayerDumpWriter::GetDump(uint32 guid) return dump; } -DumpReturn PlayerDumpWriter::WriteDump(std::string file, uint32 guid) +DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, uint32 guid) { FILE *fout = fopen(file.c_str(), "w"); if (!fout) @@ -353,7 +353,7 @@ DumpReturn PlayerDumpWriter::WriteDump(std::string file, uint32 guid) // Reading - High-level functions #define ROLLBACK(DR) {CharacterDatabase.RollbackTransaction(); fclose(fin); return (DR);} -DumpReturn PlayerDumpReader::LoadDump(std::string file, uint32 account, std::string name, uint32 guid) +DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, std::string name, uint32 guid) { // check character count { diff --git a/src/game/PlayerDump.h b/src/game/PlayerDump.h index 2e83102f9..5991b7445 100644 --- a/src/game/PlayerDump.h +++ b/src/game/PlayerDump.h @@ -92,7 +92,7 @@ class PlayerDumpWriter : public PlayerDump PlayerDumpWriter() {} std::string GetDump(uint32 guid); - DumpReturn WriteDump(std::string file, uint32 guid); + DumpReturn WriteDump(const std::string& file, uint32 guid); private: typedef std::set GUIDs; @@ -111,7 +111,7 @@ class PlayerDumpReader : public PlayerDump public: PlayerDumpReader() {} - DumpReturn LoadDump(std::string file, uint32 account, std::string name, uint32 guid); + DumpReturn LoadDump(const std::string& file, uint32 account, std::string name, uint32 guid); }; #endif diff --git a/src/game/SocialMgr.h b/src/game/SocialMgr.h index 8c873d8a0..0a7f822a7 100644 --- a/src/game/SocialMgr.h +++ b/src/game/SocialMgr.h @@ -63,7 +63,7 @@ struct FriendInfo Note = ""; } - FriendInfo(uint32 flags, std::string note) + FriendInfo(uint32 flags, const std::string& note) { Status = FRIEND_STATUS_OFFLINE; Flags = flags; diff --git a/src/game/World.cpp b/src/game/World.cpp index 6cbf87a76..9794ba523 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -2304,7 +2304,7 @@ void World::KickAllLess(AccountTypes sec) } /// Kick (and save) the designated player -bool World::KickPlayer(std::string playerName) +bool World::KickPlayer(const std::string& playerName) { SessionMap::iterator itr; diff --git a/src/game/World.h b/src/game/World.h index d8800e2c3..a89ef9abd 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -440,7 +440,7 @@ class World bool IsPvPRealm() { return (getConfig(CONFIG_GAME_TYPE) == REALM_TYPE_PVP || getConfig(CONFIG_GAME_TYPE) == REALM_TYPE_RPPVP || getConfig(CONFIG_GAME_TYPE) == REALM_TYPE_FFA_PVP); } bool IsFFAPvPRealm() { return getConfig(CONFIG_GAME_TYPE) == REALM_TYPE_FFA_PVP; } - bool KickPlayer(std::string playerName); + bool KickPlayer(const std::string& playerName); void KickAll(); void KickAllLess(AccountTypes sec); BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author); diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 08d4df368..858f33717 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -153,20 +153,11 @@ void WorldSession::logUnexpectedOpcode(WorldPacket* packet, const char *reason) /// Update the WorldSession (triggered by World update) bool WorldSession::Update(uint32 /*diff*/) { - if (m_Socket && m_Socket->IsClosed ()) - { - m_Socket->RemoveReference (); - m_Socket = NULL; - } - - WorldPacket *packet; - ///- Retrieve packets from the receive queue and call the appropriate handlers - /// \todo Is there a way to consolidate the OpcondeHandlerTable and the g_worldOpcodeNames to only maintain 1 list? - /// answer : there is a way, but this is better, because it would use redundant RAM - while (!_recvQueue.empty()) + /// not proccess packets if socket already closed + while (!_recvQueue.empty() && m_Socket && !m_Socket->IsClosed ()) { - packet = _recvQueue.next(); + WorldPacket *packet = _recvQueue.next(); /*#if 1 sLog.outError( "MOEP: %s (0x%.4X)", @@ -226,6 +217,13 @@ bool WorldSession::Update(uint32 /*diff*/) delete packet; } + ///- Cleanup socket pointer if need + if (m_Socket && m_Socket->IsClosed ()) + { + m_Socket->RemoveReference (); + m_Socket = NULL; + } + ///- If necessary, log the player out time_t currTime = time(NULL); if (!m_Socket || (ShouldLogOut(currTime) && !m_playerLoading)) diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index be0045224..aa5009a9a 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -94,9 +94,9 @@ class MANGOS_DLL_SPEC WorldSession void SendPacket(WorldPacket const* packet); void SendNotification(const char *format,...) ATTR_PRINTF(2,3); void SendNotification(int32 string_id,...); - void SendPetNameInvalid(uint32 error, std::string name, DeclinedName *declinedName); + void SendPetNameInvalid(uint32 error, const std::string& name, DeclinedName *declinedName); void SendLfgResult(uint32 type, uint32 entry, uint8 lfg_type); - void SendPartyResult(PartyOperation operation, std::string member, PartyResult res); + void SendPartyResult(PartyOperation operation, const std::string& member, PartyResult res); void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2,3); uint32 GetSecurity() const { return _security; } @@ -141,7 +141,7 @@ class MANGOS_DLL_SPEC WorldSession static void SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 accountId); void SendTrainerList( uint64 guid ); - void SendTrainerList( uint64 guid,std::string strTitle ); + void SendTrainerList( uint64 guid, const std::string& strTitle ); void SendListInventory( uint64 guid ); void SendShowBank( uint64 guid ); void SendTabardVendorActivate( uint64 guid ); @@ -171,7 +171,7 @@ class MANGOS_DLL_SPEC WorldSession //mail //used with item_page table bool SendItemInfo( uint32 itemid, WorldPacket data ); - static void SendReturnToSender(uint8 messageType, uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid, std::string subject, uint32 itemTextId, MailItemsInfo *mi, uint32 money, uint16 mailTemplateId = 0); + static void SendReturnToSender(uint8 messageType, uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid, const std::string& subject, uint32 itemTextId, MailItemsInfo *mi, uint32 money, uint16 mailTemplateId = 0); static void SendMailTo(Player* receiver, uint8 messageType, uint8 stationery, uint32 sender_guidlow_or_entry, uint32 received_guidlow, std::string subject, uint32 itemTextId, MailItemsInfo* mi, uint32 money, uint32 COD, uint32 checked, uint32 deliver_delay = 0, uint16 mailTemplateId = 0); //auction @@ -194,9 +194,9 @@ class MANGOS_DLL_SPEC WorldSession bool SendLearnNewTaxiNode( Creature* unit ); // Guild/Arena Team - void SendGuildCommandResult(uint32 typecmd,std::string str,uint32 cmdresult); - void SendArenaTeamCommandResult(uint32 unk1, std::string str1, std::string str2, uint32 unk3); - void BuildArenaTeamEventPacket(WorldPacket *data, uint8 eventid, uint8 str_count, std::string str1, std::string str2, std::string str3); + void SendGuildCommandResult(uint32 typecmd, const std::string& str, uint32 cmdresult); + void SendArenaTeamCommandResult(uint32 unk1, const std::string& str1, const std::string& str2, uint32 unk3); + void BuildArenaTeamEventPacket(WorldPacket *data, uint8 eventid, uint8 str_count, const std::string& str1, const std::string& str2, const std::string& str3); void SendNotInArenaTeamPacket(uint8 type); void SendPetitionShowList( uint64 guid ); void SendSaveGuildEmblem( uint32 msg ); @@ -352,7 +352,6 @@ class MANGOS_DLL_SPEC WorldSession void HandleGroupDeclineOpcode(WorldPacket& recvPacket); void HandleGroupUninviteNameOpcode(WorldPacket& recvPacket); void HandleGroupUninviteGuidOpcode(WorldPacket& recvPacket); - void HandleGroupUninvite(uint64 guid, std::string name); void HandleGroupSetLeaderOpcode(WorldPacket& recvPacket); void HandleGroupLeaveOpcode(WorldPacket& recvPacket); void HandleGroupPassOnLootOpcode( WorldPacket &recv_data ); diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index 8c246cf9c..9d40d398b 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -152,10 +152,9 @@ void WorldSocket::CloseSocket (void) ACE_GUARD (LockType, Guard, m_OutBufferLock); if (closing_) - return; + return; closing_ = true; - peer ().close_writer (); } @@ -301,7 +300,7 @@ int WorldSocket::handle_input (ACE_HANDLE) if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) { - return Update (); // interesting line ,isn't it ? + return Update (); // interesting line ,isn't it ? } DEBUG_LOG ("WorldSocket::handle_input: Peer error closing connection errno = %s", ACE_OS::strerror (errno)); @@ -319,7 +318,7 @@ int WorldSocket::handle_input (ACE_HANDLE) case 1: return 1; default: - return Update (); // another interesting line ;) + return Update (); // another interesting line ;) } ACE_NOTREACHED(return -1); @@ -513,7 +512,7 @@ int WorldSocket::handle_input_missing_data (void) return -1; } - // We just received nice new header + // We just received nice new header if (handle_input_header () == -1) { ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN)); diff --git a/src/realmd/AuthSocket.cpp b/src/realmd/AuthSocket.cpp index 987e1d210..e1759e7e0 100644 --- a/src/realmd/AuthSocket.cpp +++ b/src/realmd/AuthSocket.cpp @@ -298,7 +298,7 @@ void AuthSocket::OnRead() } /// Make the SRP6 calculation from hash in dB -void AuthSocket::_SetVSFields(std::string rI) +void AuthSocket::_SetVSFields(const std::string& rI) { BigNumber I; I.SetHexStr(rI.c_str()); diff --git a/src/realmd/AuthSocket.h b/src/realmd/AuthSocket.h index b46e1d425..0ed37587b 100644 --- a/src/realmd/AuthSocket.h +++ b/src/realmd/AuthSocket.h @@ -56,7 +56,7 @@ class AuthSocket: public TcpSocket bool _HandleXferCancel(); bool _HandleXferAccept(); - void _SetVSFields(std::string rI); + void _SetVSFields(const std::string& rI); FILE *pPatch; ZThread::Mutex patcherLock; diff --git a/src/realmd/RealmList.cpp b/src/realmd/RealmList.cpp index 7f4dd3e15..a25e495b0 100644 --- a/src/realmd/RealmList.cpp +++ b/src/realmd/RealmList.cpp @@ -42,7 +42,7 @@ void RealmList::Initialize(uint32 updateInterval) UpdateRealms(true); } -void RealmList::UpdateRealm( uint32 ID, std::string name, std::string address, uint32 port, uint8 icon, uint8 color, uint8 timezone, AccountTypes allowedSecurityLevel, float popu) +void RealmList::UpdateRealm( uint32 ID, const std::string& name, const std::string& address, uint32 port, uint8 icon, uint8 color, uint8 timezone, AccountTypes allowedSecurityLevel, float popu) { ///- Create new if not exist or update existed Realm& realm = m_realms[name]; diff --git a/src/realmd/RealmList.h b/src/realmd/RealmList.h index 15095e8fa..f3e04c07d 100644 --- a/src/realmd/RealmList.h +++ b/src/realmd/RealmList.h @@ -56,7 +56,7 @@ class RealmList uint32 size() const { return m_realms.size(); } private: void UpdateRealms(bool init); - void UpdateRealm( uint32 ID, std::string name, std::string address, uint32 port, uint8 icon, uint8 color, uint8 timezone, AccountTypes allowedSecurityLevel, float popu); + void UpdateRealm( uint32 ID, const std::string& name, const std::string& address, uint32 port, uint8 icon, uint8 color, uint8 timezone, AccountTypes allowedSecurityLevel, float popu); private: RealmMap m_realms; ///< Internal map of realms uint32 m_UpdateInterval; diff --git a/src/shared/Common.cpp b/src/shared/Common.cpp index 952997d3b..e7224bc5e 100644 --- a/src/shared/Common.cpp +++ b/src/shared/Common.cpp @@ -30,7 +30,7 @@ char const* localeNames[MAX_LOCALE] = { "ruRU" }; -LocaleConstant GetLocaleByName(std::string name) +LocaleConstant GetLocaleByName(const std::string& name) { for(uint32 i = 0; i < MAX_LOCALE; ++i) if(name==localeNames[i]) diff --git a/src/shared/Common.h b/src/shared/Common.h index 5c938ea67..0fc544fc6 100644 --- a/src/shared/Common.h +++ b/src/shared/Common.h @@ -186,7 +186,7 @@ enum LocaleConstant extern char const* localeNames[MAX_LOCALE]; -LocaleConstant GetLocaleByName(std::string name); +LocaleConstant GetLocaleByName(const std::string& name); // we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some pother platforms) #ifdef max diff --git a/src/shared/Config/ConfigEnv.h b/src/shared/Config/ConfigEnv.h index f2a0d5146..6c61aeb93 100644 --- a/src/shared/Config/ConfigEnv.h +++ b/src/shared/Config/ConfigEnv.h @@ -23,6 +23,5 @@ #include "Common.h" #include "dotconfpp/dotconfpp.h" #include "Config.h" -#include "Log.h" #endif diff --git a/src/shared/Database/DBCStores.cpp b/src/shared/Database/DBCStores.cpp index d70862eb4..0ae6f663b 100644 --- a/src/shared/Database/DBCStores.cpp +++ b/src/shared/Database/DBCStores.cpp @@ -141,7 +141,7 @@ DBCStorage sWorldMapOverlayStore(WorldMapOverlayEntryfmt) typedef std::list StoreProblemList; -static bool LoadDBC_assert_print(uint32 fsize,uint32 rsize, std::string filename) +static bool LoadDBC_assert_print(uint32 fsize,uint32 rsize, const std::string& filename) { sLog.outError("ERROR: Size of '%s' setted by format string (%u) not equal size of C++ structure (%u).",filename.c_str(),fsize,rsize); @@ -150,7 +150,7 @@ static bool LoadDBC_assert_print(uint32 fsize,uint32 rsize, std::string filename } template -inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList& errlist, DBCStorage& storage, std::string dbc_path, std::string filename) +inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList& errlist, DBCStorage& storage, const std::string& dbc_path, const std::string& filename) { // compatibility format and C++ structure sizes assert(DBCFile::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFile::GetFormatRecordSize(storage.GetFormat()),sizeof(T),filename)); @@ -185,7 +185,7 @@ inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList } } -void LoadDBCStores(std::string dataPath) +void LoadDBCStores(const std::string& dataPath) { std::string dbcPath = dataPath+"dbc/"; diff --git a/src/shared/Database/DBCStores.h b/src/shared/Database/DBCStores.h index 022ce7bbd..8143ec704 100644 --- a/src/shared/Database/DBCStores.h +++ b/src/shared/Database/DBCStores.h @@ -208,7 +208,7 @@ extern DBCStorage sVehicleSeatStore; extern DBCStorage sWorldSafeLocsStore; extern DBCStorage sWorldMapOverlayStore; -void LoadDBCStores(std::string dataPath); +void LoadDBCStores(const std::string& dataPath); // script support functions MANGOS_DLL_SPEC DBCStorage const* GetSoundEntriesStore(); diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp index ada02e62b..f5d05139b 100644 --- a/src/shared/Log.cpp +++ b/src/shared/Log.cpp @@ -43,7 +43,7 @@ Log::Log() : Initialize(); } -void Log::InitColors(std::string str) +void Log::InitColors(const std::string& str) { if(str.empty()) { diff --git a/src/shared/Log.h b/src/shared/Log.h index 2a4bb97e8..391a93d86 100644 --- a/src/shared/Log.h +++ b/src/shared/Log.h @@ -82,7 +82,7 @@ class Log : public MaNGOS::Singleton iMainFiles; G3D::Array iSingeFiles; - void appendToMain(std::string pStr) { iMainFiles.append(pStr); } - void appendToSingle(std::string pStr) { iSingeFiles.append(pStr); } + void appendToMain(const std::string& pStr) { iMainFiles.append(pStr); } + void appendToSingle(const std::string& pStr) { iSingeFiles.append(pStr); } size_t size() { return (iMainFiles.size() + iSingeFiles.size()); } }; @@ -113,7 +113,7 @@ namespace VMAP const NameCollection getFilenamesForCoordinate(unsigned int pMapId, int xPos, int yPos); - static unsigned int getMapIdFromFilename(std::string pName) + static unsigned int getMapIdFromFilename(const std::string& pName) { size_t spos; @@ -126,8 +126,8 @@ namespace VMAP } const G3D::Array& getMaps() const { return iMapIds; } - bool isAlreadyProcessedSingleFile(std::string pName) const { return iProcesseSingleFiles.containsKey(pName); } - void addAlreadyProcessedSingleFile(std::string pName) { iProcesseSingleFiles.set(pName,pName); } + bool isAlreadyProcessedSingleFile(const std::string& pName) const { return iProcesseSingleFiles.containsKey(pName); } + void addAlreadyProcessedSingleFile(const std::string& pName) { iProcesseSingleFiles.set(pName,pName); } inline void addWorldAreaMap(unsigned int pMapId) {