Merge branch 'master' into 303

Conflicts:
	src/game/Player.h
This commit is contained in:
tomrus88 2008-12-12 18:14:49 +03:00
commit 5d4d7292b9
47 changed files with 244 additions and 209 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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; }

View file

@ -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;

View file

@ -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 = "";

View file

@ -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);

View file

@ -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)
{
}

View file

@ -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);

View file

@ -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);

View file

@ -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))

View file

@ -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<uint64> InvitesList;
typedef std::set<Player*> InvitesList;
typedef std::vector<Roll*> 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
{

View file

@ -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)
// can't uninvite yourself
if(GetPlayer()->GetName() == membername)
{
Group *group = GetPlayer()->GetGroup();
if(!group)
return;
if(_player->InBattleGround())
{
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 )

View file

@ -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));
}

View file

@ -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;

View file

@ -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;

View file

@ -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
{

View file

@ -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);

View file

@ -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" );

View file

@ -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(); }

View file

@ -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();
}

View file

@ -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; }

View file

@ -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);

View file

@ -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
@ -2032,10 +2034,11 @@ bool Player::IsInSameGroupWith(Player const* p) const
///- If the player is invited, remove him. If the group if then only 1 person, disband the group.
/// \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
@ -2051,7 +2054,6 @@ void Player::UninviteFromGroup()
delete group;
}
}
}
void Player::RemoveFromGroup(Group* group, uint64 guid)
{
@ -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);

View file

@ -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<Player> &GetGridRef() { return m_gridRef; }
MapReference &GetMapRef() { return m_mapRef; }

View file

@ -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
{

View file

@ -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<uint32> 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

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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))

View file

@ -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 );

View file

@ -155,7 +155,6 @@ void WorldSocket::CloseSocket (void)
return;
closing_ = true;
peer ().close_writer ();
}

View file

@ -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());

View file

@ -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;

View file

@ -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];

View file

@ -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;

View file

@ -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])

View file

@ -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

View file

@ -23,6 +23,5 @@
#include "Common.h"
#include "dotconfpp/dotconfpp.h"
#include "Config.h"
#include "Log.h"
#endif

View file

@ -141,7 +141,7 @@ DBCStorage <WorldMapOverlayEntry> sWorldMapOverlayStore(WorldMapOverlayEntryfmt)
typedef std::list<std::string> 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<class T>
inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList& errlist, DBCStorage<T>& storage, std::string dbc_path, std::string filename)
inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList& errlist, DBCStorage<T>& 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/";

View file

@ -208,7 +208,7 @@ extern DBCStorage <VehicleSeatEntry> sVehicleSeatStore;
extern DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore;
extern DBCStorage <WorldMapOverlayEntry> sWorldMapOverlayStore;
void LoadDBCStores(std::string dataPath);
void LoadDBCStores(const std::string& dataPath);
// script support functions
MANGOS_DLL_SPEC DBCStorage <SoundEntriesEntry> const* GetSoundEntriesStore();

View file

@ -43,7 +43,7 @@ Log::Log() :
Initialize();
}
void Log::InitColors(std::string str)
void Log::InitColors(const std::string& str)
{
if(str.empty())
{

View file

@ -82,7 +82,7 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
}
public:
void Initialize();
void InitColors(std::string init_str);
void InitColors(const std::string& init_str);
void outTitle( const char * str);
void outCommand( uint32 account, const char * str, ...) ATTR_PRINTF(3,4);
void outString(); // any log level

View file

@ -131,13 +131,13 @@ std::string secsToTimeString(uint32 timeInSecs, bool shortText, bool hoursOnly)
return ss.str();
}
uint32 TimeStringToSecs(std::string timestring)
uint32 TimeStringToSecs(const std::string& timestring)
{
uint32 secs = 0;
uint32 buffer = 0;
uint32 multiplier = 0;
for(std::string::iterator itr = timestring.begin(); itr != timestring.end(); itr++ )
for(std::string::const_iterator itr = timestring.begin(); itr != timestring.end(); itr++ )
{
if(isdigit(*itr))
{
@ -193,7 +193,7 @@ bool IsIPAddress(char const* ipaddress)
}
/// create PID file
uint32 CreatePIDFile(std::string filename)
uint32 CreatePIDFile(const std::string& filename)
{
FILE * pid_file = fopen (filename.c_str(), "w" );
if (pid_file == NULL)
@ -271,7 +271,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)
return true;
}
bool Utf8toWStr(std::string utf8str, std::wstring& wstr)
bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr)
{
try
{
@ -376,7 +376,7 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension)
return wname;
}
bool utf8ToConsole(std::string utf8str, std::string& conStr)
bool utf8ToConsole(const std::string& utf8str, std::string& conStr)
{
#if PLATFORM == PLATFORM_WINDOWS
std::wstring wstr;
@ -393,7 +393,7 @@ bool utf8ToConsole(std::string utf8str, std::string& conStr)
return true;
}
bool consoleToUtf8(std::string conStr,std::string& utf8str)
bool consoleToUtf8(const std::string& conStr,std::string& utf8str)
{
#if PLATFORM == PLATFORM_WINDOWS
std::wstring wstr;
@ -408,7 +408,7 @@ bool consoleToUtf8(std::string conStr,std::string& utf8str)
#endif
}
bool Utf8FitTo(std::string str, std::wstring search)
bool Utf8FitTo(const std::string& str, std::wstring search)
{
std::wstring temp;

View file

@ -31,7 +31,7 @@ Tokens StrSplit(const std::string &src, const std::string &sep);
void stripLineInvisibleChars(std::string &src);
std::string secsToTimeString(uint32 timeInSecs, bool shortText = false, bool hoursOnly = false);
uint32 TimeStringToSecs(std::string timestring);
uint32 TimeStringToSecs(const std::string& timestring);
std::string TimeToTimestampStr(time_t t);
inline uint32 secsToTimeBitFields(time_t secs)
@ -95,10 +95,10 @@ inline void ApplyPercentModFloatVar(float& var, float val, bool apply)
var *= (apply?(100.0f+val)/100.0f : 100.0f / (100.0f+val));
}
bool Utf8toWStr(std::string utf8str, std::wstring& wstr);
bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr);
// in wsize==max size of buffer, out wsize==real string size
bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize);
inline bool Utf8toWStr(std::string utf8str, wchar_t* wstr, size_t& wsize)
inline bool Utf8toWStr(const std::string& utf8str, wchar_t* wstr, size_t& wsize)
{
return Utf8toWStr(utf8str.c_str(), utf8str.size(), wstr, wsize);
}
@ -280,9 +280,9 @@ inline void wstrToLower(std::wstring& str)
std::wstring GetMainPartOfName(std::wstring wname, uint32 declension);
bool utf8ToConsole(std::string utf8str, std::string& conStr);
bool consoleToUtf8(std::string conStr,std::string& utf8str);
bool Utf8FitTo(std::string str, std::wstring search);
bool utf8ToConsole(const std::string& utf8str, std::string& conStr);
bool consoleToUtf8(const std::string& conStr,std::string& utf8str);
bool Utf8FitTo(const std::string& str, std::wstring search);
#if PLATFORM == PLATFORM_WINDOWS
#define UTF8PRINTF(OUT,FRM,RESERR) \
@ -311,6 +311,6 @@ bool Utf8FitTo(std::string str, std::wstring search);
#endif
bool IsIPAddress(char const* ipaddress);
uint32 CreatePIDFile(std::string filename);
uint32 CreatePIDFile(const std::string& filename);
#endif

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "6895"
#define REVISION_NR "6902"
#endif // __REVISION_NR_H__

View file

@ -43,8 +43,8 @@ namespace VMAP
G3D::Array<std::string> iMainFiles;
G3D::Array<std::string> 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<unsigned int>& 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)
{