aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/extractor/System.cpp48
-rw-r--r--contrib/extractor/VC71_ad.vcproj4
-rw-r--r--contrib/extractor/VC80_ad.vcproj4
-rw-r--r--contrib/extractor/VC90_ad.vcproj4
-rw-r--r--contrib/extractor/ad.exebin167936 -> 167936 bytes
-rw-r--r--dep/include/mersennetwister/MersenneTwister.h4
-rw-r--r--src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp2
-rw-r--r--src/game/ArenaTeamHandler.cpp4
-rw-r--r--src/game/Channel.cpp8
-rw-r--r--src/game/Channel.h18
-rw-r--r--src/game/ChannelMgr.h8
-rw-r--r--src/game/CharacterHandler.cpp30
-rw-r--r--src/game/Chat.cpp2
-rw-r--r--src/game/Chat.h2
-rw-r--r--src/game/Creature.cpp42
-rw-r--r--src/game/Creature.h2
-rw-r--r--src/game/GMTicketMgr.h2
-rw-r--r--src/game/GameObject.cpp2
-rw-r--r--src/game/GossipDef.cpp32
-rw-r--r--src/game/GossipDef.h6
-rw-r--r--src/game/Group.cpp36
-rw-r--r--src/game/Group.h17
-rw-r--r--src/game/GroupHandler.cpp88
-rw-r--r--src/game/Guild.cpp6
-rw-r--r--src/game/Guild.h10
-rw-r--r--src/game/GuildHandler.cpp2
-rw-r--r--src/game/ItemHandler.cpp2
-rw-r--r--src/game/ItemPrototype.h20
-rw-r--r--src/game/Level1.cpp6
-rw-r--r--src/game/Mail.cpp4
-rw-r--r--src/game/Map.cpp7
-rw-r--r--src/game/MiscHandler.cpp6
-rw-r--r--src/game/MovementHandler.cpp24
-rw-r--r--src/game/NPCHandler.cpp14
-rw-r--r--src/game/Object.cpp62
-rw-r--r--src/game/Object.h22
-rw-r--r--src/game/ObjectAccessor.cpp3
-rw-r--r--src/game/ObjectAccessor.h2
-rw-r--r--src/game/ObjectGridLoader.cpp2
-rw-r--r--src/game/ObjectMgr.cpp16
-rw-r--r--src/game/ObjectMgr.h19
-rw-r--r--src/game/Opcodes.cpp2
-rw-r--r--src/game/Pet.cpp67
-rw-r--r--src/game/Pet.h3
-rw-r--r--src/game/PetHandler.cpp12
-rw-r--r--src/game/Player.cpp170
-rw-r--r--src/game/Player.h35
-rw-r--r--src/game/PlayerDump.cpp4
-rw-r--r--src/game/PlayerDump.h4
-rw-r--r--src/game/QuestDef.h30
-rw-r--r--src/game/SharedDefines.h23
-rw-r--r--src/game/SocialMgr.h2
-rw-r--r--src/game/Spell.cpp53
-rw-r--r--src/game/SpellAuras.cpp21
-rw-r--r--src/game/SpellEffects.cpp50
-rw-r--r--src/game/SpellHandler.cpp2
-rw-r--r--src/game/StatSystem.cpp1
-rw-r--r--src/game/TaxiHandler.cpp2
-rw-r--r--src/game/Totem.cpp7
-rw-r--r--src/game/Traveller.h2
-rw-r--r--src/game/Unit.cpp67
-rw-r--r--src/game/Unit.h25
-rw-r--r--src/game/World.cpp2
-rw-r--r--src/game/World.h2
-rw-r--r--src/game/WorldSession.cpp58
-rw-r--r--src/game/WorldSession.h17
-rw-r--r--src/game/WorldSocket.cpp18
-rw-r--r--src/game/debugcmds.cpp118
-rw-r--r--src/shared/Common.cpp2
-rw-r--r--src/shared/Common.h2
-rw-r--r--src/shared/Config/ConfigEnv.h1
-rw-r--r--src/shared/Database/DBCStores.cpp6
-rw-r--r--src/shared/Database/DBCStores.h2
-rw-r--r--src/shared/Log.cpp2
-rw-r--r--src/shared/Log.h2
-rw-r--r--src/shared/Util.cpp14
-rw-r--r--src/shared/Util.h16
-rw-r--r--src/shared/vmap/CoordModelMapping.h10
-rw-r--r--src/shared/vmap/VMapManager.cpp18
-rw-r--r--src/trinitycore/RASocket.h6
-rw-r--r--src/trinityrealm/AuthSocket.cpp6
-rw-r--r--src/trinityrealm/AuthSocket.h2
-rw-r--r--src/trinityrealm/RealmList.cpp2
-rw-r--r--src/trinityrealm/RealmList.h6
84 files changed, 783 insertions, 703 deletions
diff --git a/contrib/extractor/System.cpp b/contrib/extractor/System.cpp
index b7ece7e766e..197c4d35416 100644
--- a/contrib/extractor/System.cpp
+++ b/contrib/extractor/System.cpp
@@ -39,7 +39,7 @@ enum Extract
};
int extract = EXTRACT_MAP | EXTRACT_DBC;
-static char* const langs[]={"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" };
+static char* const langs[] = {"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" };
#define LANG_COUNT 12
#define ADT_RES 64
@@ -55,9 +55,9 @@ void CreateDir( const std::string& Path )
bool FileExists( const char* FileName )
{
- if( FILE* fp = fopen( FileName, "rb" ) )
+ if(FILE* fp = fopen( FileName, "rb" ))
{
- fclose( fp );
+ fclose(fp);
return true;
}
@@ -222,15 +222,15 @@ void ExtractDBCFiles(int locale, bool basicLocale)
string filename = path;
filename += (iter->c_str() + strlen("DBFilesClient\\"));
- FILE *output=fopen(filename.c_str(),"wb");
+ FILE *output=fopen(filename.c_str(), "wb");
if(!output)
{
- printf("Can't create the output file '%s'\n",filename.c_str());
+ printf("Can't create the output file '%s'\n", filename.c_str());
continue;
}
MPQFile m(iter->c_str());
if(!m.isEof())
- fwrite(m.getPointer(),1,m.getSize(),output);
+ fwrite(m.getPointer(), 1, m.getSize(), output);
fclose(output);
++count;
@@ -242,7 +242,7 @@ void LoadLocaleMPQFiles(int const locale)
{
char filename[512];
- sprintf(filename,"%s/Data/%s/locale-%s.MPQ",input_path,langs[locale],langs[locale]);
+ sprintf(filename,"%s/Data/%s/locale-%s.MPQ", input_path, langs[locale], langs[locale]);
new MPQArchive(filename);
for(int i = 1; i < 5; ++i)
@@ -251,7 +251,7 @@ void LoadLocaleMPQFiles(int const locale)
if(i > 1)
sprintf(ext, "-%i", i);
- sprintf(filename,"%s/Data/%s/patch-%s%s.MPQ",input_path,langs[locale],langs[locale],ext);
+ sprintf(filename,"%s/Data/%s/patch-%s%s.MPQ", input_path, langs[locale], langs[locale], ext);
if(FileExists(filename))
new MPQArchive(filename);
}
@@ -261,17 +261,19 @@ void LoadCommonMPQFiles()
{
char filename[512];
- sprintf(filename,"%s/Data/common.MPQ",input_path);
+ sprintf(filename,"%s/Data/common.MPQ", input_path);
new MPQArchive(filename);
- sprintf(filename,"%s/Data/expansion.MPQ",input_path);
+ sprintf(filename,"%s/Data/expansion.MPQ", input_path);
new MPQArchive(filename);
for(int i = 1; i < 5; ++i)
{
char ext[3] = "";
if(i > 1)
sprintf(ext, "-%i", i);
- if(FileExists(filename))
- new MPQArchive(filename);
+
+ sprintf(filename,"%s/Data/patch%s.MPQ", input_path, ext);
+ if(FileExists(filename))
+ new MPQArchive(filename);
}
}
@@ -303,25 +305,25 @@ int main(int argc, char * arg[])
if((extract & EXTRACT_DBC) == 0)
{
- FirstLocale=i;
+ FirstLocale = i;
break;
}
- //Extract DBC files
- if(FirstLocale<0)
- {
- ExtractDBCFiles(i, true);
- FirstLocale = i;
- }
- else
- ExtractDBCFiles(i, false);
-
+ //Extract DBC files
+ if(FirstLocale < 0)
+ {
+ ExtractDBCFiles(i, true);
+ FirstLocale = i;
+ }
+ else
+ ExtractDBCFiles(i, false);
+
//Close MPQs
CloseMPQFiles();
}
}
- if(FirstLocale<0)
+ if(FirstLocale < 0)
{
printf("No locales detected\n");
return 0;
diff --git a/contrib/extractor/VC71_ad.vcproj b/contrib/extractor/VC71_ad.vcproj
index 2bd27e526ea..fd2d16120e8 100644
--- a/contrib/extractor/VC71_ad.vcproj
+++ b/contrib/extractor/VC71_ad.vcproj
@@ -76,7 +76,7 @@
Name="VCLinkerTool"
AdditionalDependencies="zlib.lib"
OutputFile="ad debug.exe"
- LinkIncremental="1"
+ LinkIncremental="0"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="./debug/"
IgnoreDefaultLibraryNames="LIBCD.lib"
@@ -171,7 +171,7 @@
Name="VCLinkerTool"
AdditionalDependencies="zlib.lib"
OutputFile="./ad.exe"
- LinkIncremental="1"
+ LinkIncremental="0"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="./release/"
IgnoreDefaultLibraryNames="LIBC.lib"
diff --git a/contrib/extractor/VC80_ad.vcproj b/contrib/extractor/VC80_ad.vcproj
index 30657907fd8..fedab5b89eb 100644
--- a/contrib/extractor/VC80_ad.vcproj
+++ b/contrib/extractor/VC80_ad.vcproj
@@ -79,7 +79,7 @@
Name="VCLinkerTool"
AdditionalDependencies="zlib.lib"
OutputFile="ad debug.exe"
- LinkIncremental="1"
+ LinkIncremental="0"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="./debug"
IgnoreDefaultLibraryNames="LIBCD.lib"
@@ -176,7 +176,7 @@
Name="VCLinkerTool"
AdditionalDependencies="zlib.lib"
OutputFile="./ad.exe"
- LinkIncremental="1"
+ LinkIncremental="0"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="./release"
IgnoreDefaultLibraryNames="LIBC.lib"
diff --git a/contrib/extractor/VC90_ad.vcproj b/contrib/extractor/VC90_ad.vcproj
index 14aa824a0e9..59fdf6d21f1 100644
--- a/contrib/extractor/VC90_ad.vcproj
+++ b/contrib/extractor/VC90_ad.vcproj
@@ -80,7 +80,7 @@
Name="VCLinkerTool"
AdditionalDependencies="zlib.lib"
OutputFile="ad debug.exe"
- LinkIncremental="1"
+ LinkIncremental="0"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="./debug/"
IgnoreDefaultLibraryNames="LIBCD.lib"
@@ -175,7 +175,7 @@
Name="VCLinkerTool"
AdditionalDependencies="zlib.lib"
OutputFile="./ad.exe"
- LinkIncremental="1"
+ LinkIncremental="0"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="./release/"
IgnoreDefaultLibraryNames="LIBC.lib"
diff --git a/contrib/extractor/ad.exe b/contrib/extractor/ad.exe
index 1f2c45dfc56..2dc24c0872e 100644
--- a/contrib/extractor/ad.exe
+++ b/contrib/extractor/ad.exe
Binary files differ
diff --git a/dep/include/mersennetwister/MersenneTwister.h b/dep/include/mersennetwister/MersenneTwister.h
index 6b5c4ef3798..553d3899328 100644
--- a/dep/include/mersennetwister/MersenneTwister.h
+++ b/dep/include/mersennetwister/MersenneTwister.h
@@ -86,8 +86,8 @@ public:
MTRand( const uint32& oneSeed ); // initialize with a simple uint32
MTRand( uint32 *const bigSeed, uint32 const seedLength = N ); // or an array
MTRand(); // auto-initialize with /dev/urandom or time() and clock()
- MTRand(const MTRand&); // prevent copy constructor
- MTRand& operator=(const MTRand&); // no-op operator=
+ MTRand(const MTRand&); // prevent copy constructor
+ MTRand& operator=(const MTRand&); // no-op operator=
// Do NOT use for CRYPTOGRAPHY without securely hashing several returned
// values together, otherwise the generator state can be learned after
diff --git a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp
index f08ff848237..0bb7be32d99 100644
--- a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp
+++ b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp
@@ -279,7 +279,7 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
data.append(i_pl->GetPackGUID());
data << uint32(0);
i_pl->SendMessageToSet(&data, true);
- i_pl->SetSpeed(MOVE_FLY, 2.0f);
+ i_pl->SetSpeed(MOVE_FLIGHT, 2.0f);
}
}
}
diff --git a/src/game/ArenaTeamHandler.cpp b/src/game/ArenaTeamHandler.cpp
index 1ce844c4a26..6a4ff6259d3 100644
--- a/src/game/ArenaTeamHandler.cpp
+++ b/src/game/ArenaTeamHandler.cpp
@@ -362,7 +362,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;
@@ -372,7 +372,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 87d669c089a..17b761d3933 100644
--- a/src/game/Channel.cpp
+++ b/src/game/Channel.cpp
@@ -23,7 +23,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
@@ -211,7 +211,7 @@ void Channel::KickOrBan(uint64 good, const char *badname, bool ban)
if(ban && !IsBanned(bad->GetGUID()))
{
- banned.push_back(bad->GetGUID());
+ banned.insert(bad->GetGUID());
MakePlayerBanned(&data, bad->GetGUID(), good);
}
else
@@ -260,7 +260,7 @@ void Channel::UnBan(uint64 good, const char *badname)
}
else
{
- banned.remove(bad->GetGUID());
+ banned.erase(bad->GetGUID());
WorldPacket data;
MakePlayerUnbanned(&data, bad->GetGUID(), good);
@@ -775,7 +775,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 4c1ffb70c60..ed7bb316154 100644
--- a/src/game/Channel.h
+++ b/src/game/Channel.h
@@ -149,7 +149,7 @@ class Channel
typedef std::map<uint64, PlayerInfo> PlayerList;
PlayerList players;
- typedef std::list<uint64> BannedList;
+ typedef std::set<uint64> BannedList;
BannedList banned;
bool m_announce;
bool m_moderate;
@@ -172,7 +172,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
@@ -204,15 +204,9 @@ class Channel
void SendToAllButOne(WorldPacket *data, uint64 who);
void SendToOne(WorldPacket *data, uint64 who);
- bool IsOn(uint64 who) const { return players.count(who) > 0; }
+ bool IsOn(uint64 who) const { return players.count(who) != 0; }
- bool IsBanned(const uint64 guid) const
- {
- for(BannedList::const_iterator i = banned.begin(); i != banned.end(); ++i)
- if(*i == guid)
- return true;
- return false;
- }
+ bool IsBanned(const uint64 guid) const {return banned.count(guid) != 0; }
bool IsFirst() const { return !(players.size() > 1); }
@@ -252,14 +246,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 db936295347..c31998c0569 100644
--- a/src/game/ChannelMgr.h
+++ b/src/game/ChannelMgr.h
@@ -38,7 +38,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)
{
@@ -47,7 +47,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);
@@ -61,7 +61,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);
@@ -78,7 +78,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/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index fc2ad63b277..a68d46fe6d4 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -643,7 +643,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
pCurrChar->LoadCorpse();
// setting Ghost+speed if dead
- //if ( pCurrChar->m_deathState == DEAD )
if (pCurrChar->m_deathState != ALIVE)
{
// not blizz like, we must correctly save and load player instead...
@@ -907,23 +906,8 @@ void WorldSession::HandleChangePlayerNameOpcode(WorldPacket& recv_data)
recv_data >> guid;
recv_data >> newname;
- QueryResult *result = CharacterDatabase.PQuery("SELECT at_login FROM characters WHERE guid ='%u'", GUID_LOPART(guid));
- if (result)
- {
- uint32 at_loginFlags;
- Field *fields = result->Fetch();
- at_loginFlags = fields[0].GetUInt32();
- delete result;
-
- if (!(at_loginFlags & AT_LOGIN_RENAME))
- {
- WorldPacket data(SMSG_CHAR_RENAME, 1);
- data << (uint8)CHAR_CREATE_ERROR;
- SendPacket( &data );
- return;
- }
- }
- else
+ QueryResult *result = CharacterDatabase.PQuery("SELECT at_login, name FROM characters WHERE guid ='%u'", GUID_LOPART(guid));
+ if (!result)
{
WorldPacket data(SMSG_CHAR_RENAME, 1);
data << (uint8)CHAR_CREATE_ERROR;
@@ -931,10 +915,16 @@ void WorldSession::HandleChangePlayerNameOpcode(WorldPacket& recv_data)
return;
}
- if(!objmgr.GetPlayerNameByGUID(guid, oldname)) // character not exist, because we have no name for this guid
+ uint32 at_loginFlags;
+ Field *fields = result->Fetch();
+ at_loginFlags = fields[0].GetUInt32();
+ oldname = fields[1].GetCppString();
+ delete result;
+
+ if (!(at_loginFlags & AT_LOGIN_RENAME))
{
WorldPacket data(SMSG_CHAR_RENAME, 1);
- data << (uint8)CHAR_LOGIN_NO_CHARACTER;
+ data << (uint8)CHAR_CREATE_ERROR;
SendPacket( &data );
return;
}
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index 09af5f18c78..30bab9ec0d3 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -746,7 +746,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 57e1b486189..6c5c07ed70e 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -82,7 +82,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/Creature.cpp b/src/game/Creature.cpp
index 3afc23c3ba4..5ab31242bc8 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -1009,44 +1009,7 @@ void Creature::OnPoiSelect(Player* player, GossipOption const *gossip)
{
if(gossip->GossipId==GOSSIP_GUARD_SPELLTRAINER || gossip->GossipId==GOSSIP_GUARD_SKILLTRAINER)
{
- //float x,y;
- //bool findnpc=false;
Poi_Icon icon = ICON_POI_0;
- //QueryResult *result;
- //Field *fields;
- uint32 mapid=GetMapId();
- Map const* map=MapManager::Instance().GetBaseMap( mapid );
- uint16 areaflag=map->GetAreaFlag(GetPositionX(),GetPositionY());
- uint32 zoneid=Map::GetZoneId(areaflag,mapid);
- std::string areaname= gossip->OptionText;
- /*
- uint16 pflag;
-
- // use the action relate to creaturetemplate.trainer_type ?
- result= WorldDatabase.PQuery("SELECT creature.position_x,creature.position_y FROM creature,creature_template WHERE creature.map = '%u' AND creature.id = creature_template.entry AND creature_template.trainer_type = '%u'", mapid, gossip->Action );
- if(!result)
- return;
- do
- {
- fields = result->Fetch();
- x=fields[0].GetFloat();
- y=fields[1].GetFloat();
- pflag=map->GetAreaFlag(GetPositionX(),GetPositionY());
- if(pflag==areaflag)
- {
- findnpc=true;
- break;
- }
- }while(result->NextRow());
-
- delete result;
-
- if(!findnpc)
- {
- player->PlayerTalkClass->SendTalking( "$NSorry", "Here no this person.");
- return;
- }*/
-
//need add more case.
switch(gossip->Action)
{
@@ -1063,8 +1026,9 @@ void Creature::OnPoiSelect(Player* player, GossipOption const *gossip)
icon=ICON_POI_TOWER;
break;
}
- uint32 textid=GetGossipTextId( gossip->Action, zoneid );
- player->PlayerTalkClass->SendTalking( textid );
+ uint32 textid = GetGossipTextId( gossip->Action, GetZoneId() );
+ player->PlayerTalkClass->SendTalking(textid);
+ // std::string areaname= gossip->OptionText;
// how this could worked player->PlayerTalkClass->SendPointOfInterest( x, y, icon, 2, 15, areaname.c_str() );
}
}
diff --git a/src/game/Creature.h b/src/game/Creature.h
index 9a76b293266..59dd8ea3132 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -224,7 +224,7 @@ struct CreatureInfo
bool isTameable() const
{
- return type == CREATURE_TYPE_BEAST && family != 0 && (type_flags & CREATURE_TYPEFLAGS_TAMEBLE);
+ return type == CREATURE_TYPE_BEAST && family != 0 && (type_flags & CREATURE_TYPEFLAGS_TAMEABLE);
}
};
diff --git a/src/game/GMTicketMgr.h b/src/game/GMTicketMgr.h
index 1fd4e4c3a8f..c55804914a3 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/GameObject.cpp b/src/game/GameObject.cpp
index e43b703d3cb..28c39ee5bbe 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -196,7 +196,7 @@ void GameObject::Update(uint32 /*p_time*/)
if(caster && caster->GetTypeId()==TYPEID_PLAYER)
{
SetGoState(0);
- SetUInt32Value(GAMEOBJECT_FLAGS, 32);
+ SetUInt32Value(GAMEOBJECT_FLAGS, GO_FLAG_NODESPAWN);
UpdateData udata;
WorldPacket packet;
diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp
index bd9589e0579..85414fa3372 100644
--- a/src/game/GossipDef.cpp
+++ b/src/game/GossipDef.cpp
@@ -36,7 +36,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 );
@@ -53,7 +53,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);
}
@@ -130,26 +130,20 @@ void PlayerMenu::SendGossipMenu( uint32 TitleTextId, uint64 npcGUID )
data << npcGUID;
data << uint32(0); // new 2.4.0
data << uint32( TitleTextId );
- data << uint32( mGossipMenu.MenuItemCount() ); // max count 0x0F
+ data << uint32( mGossipMenu.MenuItemCount() ); // max count 0x0F
for ( unsigned int iI = 0; iI < mGossipMenu.MenuItemCount(); iI++ )
{
GossipMenuItem const& gItem = mGossipMenu.GetItem(iI);
data << uint32( iI );
data << uint8( gItem.m_gIcon );
- // icons:
- // 0 unlearn talents/misc
- // 1 trader
- // 2 taxi
- // 3 trainer
- // 9 BG/arena
data << uint8( gItem.m_gCoded ); // makes pop up box password
data << uint32(gItem.m_gBoxMoney); // money required to open menu, 2.0.3
data << gItem.m_gMessage; // text for gossip item
data << gItem.m_gBoxMessage; // accept text (related to money) pop up box, 2.0.3
}
- data << uint32( mQuestMenu.MenuItemCount() ); // max count 0x20
+ data << uint32( mQuestMenu.MenuItemCount() ); // max count 0x20
for ( uint16 iI = 0; iI < mQuestMenu.MenuItemCount(); iI++ )
{
@@ -157,7 +151,7 @@ void PlayerMenu::SendGossipMenu( uint32 TitleTextId, uint64 npcGUID )
uint32 questID = qItem.m_qId;
Quest const* pQuest = objmgr.GetQuestTemplate(questID);
- data << questID;
+ data << uint32(questID);
data << uint32( qItem.m_qIcon );
data << uint32( pQuest ? pQuest->GetQuestLevel() : 0 );
std::string Title = pQuest->GetTitle();
@@ -349,7 +343,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);
@@ -383,8 +377,7 @@ void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote, std::string Title, uint
data << title;
}
pSession->SendPacket( &data );
- //uint32 fqid=pQuestMenu->GetItem(0).m_qId;
- //sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u, questid-0=%u",npcGUID,fqid);
+ sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID));
}
void PlayerMenu::SendQuestGiverStatus( uint8 questStatus, uint64 npcGUID )
@@ -394,7 +387,7 @@ void PlayerMenu::SendQuestGiverStatus( uint8 questStatus, uint64 npcGUID )
data << uint8(questStatus);
pSession->SendPacket( &data );
- sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u",GUID_LOPART(npcGUID),questStatus);
+ sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u", GUID_LOPART(npcGUID), questStatus);
}
void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID, bool ActivateAccept )
@@ -464,6 +457,7 @@ void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID
else
data << uint32(0);
}
+
data << uint32(pQuest->GetRewOrReqMoney());
}
@@ -481,7 +475,7 @@ void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID
}
pSession->SendPacket( &data );
- sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId());
+ sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), pQuest->GetQuestId());
}
void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest )
@@ -762,8 +756,10 @@ void PlayerMenu::SendQuestGiverRequestItems( Quest const *pQuest, uint64 npcGUID
else
data << uint32(0x03);
- data << uint32(0x04) << uint32(0x08) << uint32(0x10);
+ data << uint32(0x04);
+ data << uint32(0x08);
+ data << uint32(0x10);
pSession->SendPacket( &data );
- sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId() );
+ sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), pQuest->GetQuestId() );
}
diff --git a/src/game/GossipDef.h b/src/game/GossipDef.h
index a9c56b54551..ac4ac213b3d 100644
--- a/src/game/GossipDef.h
+++ b/src/game/GossipDef.h
@@ -103,8 +103,8 @@ class TRINITY_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);
@@ -197,7 +197,7 @@ class TRINITY_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 8f79f94697c..3e9dcff7d1b 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,12 +240,29 @@ uint32 Group::RemoveInvite(Player *player)
void Group::RemoveAllInvites()
{
for(InvitesList::iterator itr=m_invitees.begin(); itr!=m_invitees.end(); ++itr)
+ (*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)
{
- Player *invitee = objmgr.GetPlayer(*itr);
- if(invitee)
- invitee->SetGroupInvite(NULL);
+ if((*itr)->GetGUID() == guid)
+ return (*itr);
}
- m_invitees.clear();
+ 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)
diff --git a/src/game/Group.h b/src/game/Group.h
index d6c69a857db..8417a145268 100644
--- a/src/game/Group.h
+++ b/src/game/Group.h
@@ -145,7 +145,7 @@ class TRINITY_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,7 +184,18 @@ class TRINITY_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); }
+ 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);
@@ -193,6 +204,8 @@ class TRINITY_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 5f384aa1d8d..3890a9f77a6 100644
--- a/src/game/GroupHandler.cpp
+++ b/src/game/GroupHandler.cpp
@@ -44,7 +44,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;
@@ -254,85 +254,81 @@ 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
-
- HandleGroupUninvite(guid, membername);
-}
-
-void WorldSession::HandleGroupUninviteNameOpcode(WorldPacket & recv_data)
-{
- CHECK_PACKET_SIZE(recv_data,1);
-
- std::string membername;
- recv_data >> membername;
-
- if(_player->InBattleGround())
+ PartyResult res = GetPlayer()->CanUninviteFromGroup();
+ if(res != PARTY_RESULT_OK)
{
- SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_INVITE_RESTRICTED);
+ SendPartyResult(PARTY_OP_LEAVE, "", res);
return;
}
- // player not found
- if(!normalizePlayerName(membername))
+ Group* grp = GetPlayer()->GetGroup();
+ if(!grp)
return;
- uint64 guid = objmgr.GetPlayerGUIDByName(membername);
+ if(grp->IsMember(guid))
+ {
+ Player::RemoveFromGroup(grp,guid);
+ return;
+ }
- // player not found
- if(!guid)
+ if(Player* plr = grp->GetInvited(guid))
+ {
+ plr->UninviteFromGroup();
return;
+ }
- HandleGroupUninvite(guid, membername);
+ SendPartyResult(PARTY_OP_LEAVE, "", PARTY_RESULT_NOT_IN_YOUR_PARTY);
}
-void WorldSession::HandleGroupUninvite(uint64 guid, std::string name)
+void WorldSession::HandleGroupUninviteNameOpcode(WorldPacket & recv_data)
{
- Group *group = GetPlayer()->GetGroup();
- if(!group)
+ CHECK_PACKET_SIZE(recv_data,1);
+
+ std::string membername;
+ recv_data >> membername;
+
+ // player not found
+ if(!normalizePlayerName(membername))
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 e4bfa23d4a7..06eef145af5 100644
--- a/src/game/Guild.cpp
+++ b/src/game/Guild.cpp
@@ -535,7 +535,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))
{
@@ -552,7 +552,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))
{
@@ -611,7 +611,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 839b8dd17f0..683ff980e3a 100644
--- a/src/game/Guild.h
+++ b/src/game/Guild.h
@@ -244,7 +244,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)
{
@@ -309,8 +309,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);
@@ -331,7 +331,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)
{
@@ -407,7 +407,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 f29a07b89f7..0737314168e 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/ItemHandler.cpp b/src/game/ItemHandler.cpp
index c074ac98d77..085c9553a30 100644
--- a/src/game/ItemHandler.cpp
+++ b/src/game/ItemHandler.cpp
@@ -371,7 +371,7 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data )
data << pProto->ArcaneRes;
data << pProto->Delay;
- data << pProto->Ammo_type;
+ data << pProto->AmmoType;
data << pProto->RangedModRange;
for(int s = 0; s < 5; s++)
diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h
index 8a90ad49adb..1ca412d246a 100644
--- a/src/game/ItemPrototype.h
+++ b/src/game/ItemPrototype.h
@@ -445,17 +445,15 @@ inline uint8 ItemSubClassToDurabilityMultiplierId(uint32 ItemClass, uint32 ItemS
struct _Damage
{
- float DamageMin;
- float DamageMax;
- uint32 DamageType; // id from Resistances.dbc
-
+ float DamageMin;
+ float DamageMax;
+ uint32 DamageType; // id from Resistances.dbc
};
struct _ItemStat
{
- uint32 ItemStatType;
- int32 ItemStatValue;
-
+ uint32 ItemStatType;
+ int32 ItemStatValue;
};
struct _Spell
{
@@ -466,7 +464,6 @@ struct _Spell
int32 SpellCooldown;
uint32 SpellCategory; // id from SpellCategory.dbc
int32 SpellCategoryCooldown;
-
};
struct _Socket
@@ -481,7 +478,7 @@ struct ItemPrototype
uint32 Class; // id from ItemClass.dbc
uint32 SubClass; // id from ItemSubClass.dbc
uint32 Unk0;
- char* Name1;
+ char* Name1;
uint32 DisplayInfoID; // id from ItemDisplayInfo.dbc
uint32 Quality;
uint32 Flags;
@@ -513,12 +510,11 @@ struct ItemPrototype
uint32 ShadowRes;
uint32 ArcaneRes;
uint32 Delay;
- uint32 Ammo_type;
+ uint32 AmmoType;
float RangedModRange;
-
_Spell Spells[5];
uint32 Bonding;
- char* Description;
+ char* Description;
uint32 PageText;
uint32 LanguageID;
uint32 PageMaterial;
diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp
index ac10dab7f98..d842cd34361 100644
--- a/src/game/Level1.cpp
+++ b/src/game/Level1.cpp
@@ -1071,7 +1071,7 @@ bool ChatHandler::HandleModifyASpeedCommand(const char* args)
chr->SetSpeed(MOVE_RUN, ASpeed,true);
chr->SetSpeed(MOVE_SWIM, ASpeed,true);
//chr->SetSpeed(MOVE_TURN, ASpeed,true);
- chr->SetSpeed(MOVE_FLY, ASpeed,true);
+ chr->SetSpeed(MOVE_FLIGHT, ASpeed,true);
return true;
}
@@ -1187,7 +1187,7 @@ bool ChatHandler::HandleModifyBWalkCommand(const char* args)
if (needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, GetName(), BSpeed);
- chr->SetSpeed(MOVE_WALKBACK,BSpeed,true);
+ chr->SetSpeed(MOVE_RUN_BACK,BSpeed,true);
return true;
}
@@ -1219,7 +1219,7 @@ bool ChatHandler::HandleModifyFlyCommand(const char* args)
if (needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_FLY_SPEED_CHANGED, GetName(), FSpeed);
- chr->SetSpeed(MOVE_FLY,FSpeed,true);
+ chr->SetSpeed(MOVE_FLIGHT,FSpeed,true);
return true;
}
diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp
index 57d90178869..00211094d4e 100644
--- a/src/game/Mail.cpp
+++ b/src/game/Mail.cpp
@@ -348,13 +348,13 @@ void WorldSession::HandleReturnToSender(WorldPacket & recv_data )
}
}
- SendReturnToSender(MAIL_NORMAL, GetAccountId(), m->receiver, m->sender, m->subject, m->itemTextId, &mi, m->money, 0, m->mailTemplateId);
+ SendReturnToSender(MAIL_NORMAL, GetAccountId(), m->receiver, m->sender, m->subject, m->itemTextId, &mi, m->money, m->mailTemplateId);
delete m; //we can deallocate old mail
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, uint32 COD, 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/Map.cpp b/src/game/Map.cpp
index 6e12597f4dd..f3c4adbd805 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -810,7 +810,7 @@ Map::Remove(T *obj, bool remove)
CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP )
{
- sLog.outError("Map::Remove: Object " I64FMTD " have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
+ sLog.outError("Map::Remove: Object " I64FMT " have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
return;
}
@@ -818,7 +818,7 @@ Map::Remove(T *obj, bool remove)
if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) )
return;
- DEBUG_LOG("Remove object " I64FMTD " from grid[%u,%u]", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y);
+ DEBUG_LOG("Remove object " I64FMT " from grid[%u,%u]", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y);
NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
assert( grid != NULL );
@@ -1092,7 +1092,7 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool pForce)
if (i_InstanceId == 0)
{
if(GridMaps[gx][gy]) delete (GridMaps[gx][gy]);
- // x and y are swaped
+ // x and y are swapped
VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gy, gx);
}
else
@@ -1259,7 +1259,6 @@ uint8 Map::GetTerrainType(float x, float y ) const
return GridMaps[gx][gy]->terrain_type[(int)(lx)][(int)(ly)];
else
return 0;
-
}
float Map::GetWaterLevel(float x, float y ) const
diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
index e63a92c27b1..0b1bb606b14 100644
--- a/src/game/MiscHandler.cpp
+++ b/src/game/MiscHandler.cpp
@@ -1402,7 +1402,7 @@ void WorldSession::HandleFarSightOpcode( WorldPacket & recv_data )
pair = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
else
return;
- sLog.outDebug("Player %u set vision to farsight target " I64FMTD ".", _player->GetGUIDLow(), _player->GetUInt64Value(PLAYER_FARSIGHT));
+ sLog.outDebug("Added FarSight " I64FMT " to player %u", _player->GetFarSight(), _player->GetGUIDLow());
break;
default:
sLog.outDebug("Unhandled mode in CMSG_FAR_SIGHT: %u", apply);
@@ -1423,9 +1423,9 @@ void WorldSession::HandleChooseTitleOpcode( WorldPacket & recv_data )
recv_data >> title;
// -1 at none
- if(title > 0 && title < 64)
+ if(title > 0 && title < 128)
{
- if(!GetPlayer()->HasFlag64(PLAYER__FIELD_KNOWN_TITLES,uint64(1) << title))
+ if(!GetPlayer()->HasTitle(title))
return;
}
else
diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp
index cdc922aa84c..95a5ce588b1 100644
--- a/src/game/MovementHandler.cpp
+++ b/src/game/MovementHandler.cpp
@@ -303,8 +303,8 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
movementInfo.t_time = 0;
}
- // handle fall damage
- if (recv_data.GetOpcode() == MSG_MOVE_FALL_LAND)
+ // fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map).
+ if (recv_data.GetOpcode() == MSG_MOVE_FALL_LAND && !GetPlayer()->isInFlight())
GetPlayer()->HandleFallDamage(movementInfo);
if(((MovementFlags & MOVEMENTFLAG_SWIMMING) != 0) != GetPlayer()->IsInWater())
@@ -324,6 +324,8 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
GetPlayer()->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
GetPlayer()->m_movementInfo = movementInfo;
+ if (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);
@@ -471,19 +473,19 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recv_data)
UnitMoveType move_type;
UnitMoveType force_move_type;
- static char const* move_type_name[MAX_MOVE_TYPE] = { "Walk", "Run", "Walkback", "Swim", "Swimback", "Turn", "Fly", "Flyback" };
+ static char const* move_type_name[MAX_MOVE_TYPE] = { "Walk", "Run", "RunBack", "Swim", "SwimBack", "TurnRate", "Flight", "FlightBack" };
uint16 opcode = recv_data.GetOpcode();
switch(opcode)
{
- case CMSG_FORCE_WALK_SPEED_CHANGE_ACK: move_type = MOVE_WALK; force_move_type = MOVE_WALK; break;
- case CMSG_FORCE_RUN_SPEED_CHANGE_ACK: move_type = MOVE_RUN; force_move_type = MOVE_RUN; break;
- case CMSG_FORCE_RUN_BACK_SPEED_CHANGE_ACK: move_type = MOVE_WALKBACK; force_move_type = MOVE_WALKBACK; break;
- case CMSG_FORCE_SWIM_SPEED_CHANGE_ACK: move_type = MOVE_SWIM; force_move_type = MOVE_SWIM; break;
- case CMSG_FORCE_SWIM_BACK_SPEED_CHANGE_ACK: move_type = MOVE_SWIMBACK; force_move_type = MOVE_SWIMBACK; break;
- case CMSG_FORCE_TURN_RATE_CHANGE_ACK: move_type = MOVE_TURN; force_move_type = MOVE_TURN; break;
- case CMSG_FORCE_FLIGHT_SPEED_CHANGE_ACK: move_type = MOVE_FLY; force_move_type = MOVE_FLY; break;
- case CMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE_ACK: move_type = MOVE_FLYBACK; force_move_type = MOVE_FLYBACK; break;
+ case CMSG_FORCE_WALK_SPEED_CHANGE_ACK: move_type = MOVE_WALK; force_move_type = MOVE_WALK; break;
+ case CMSG_FORCE_RUN_SPEED_CHANGE_ACK: move_type = MOVE_RUN; force_move_type = MOVE_RUN; break;
+ case CMSG_FORCE_RUN_BACK_SPEED_CHANGE_ACK: move_type = MOVE_RUN_BACK; force_move_type = MOVE_RUN_BACK; break;
+ case CMSG_FORCE_SWIM_SPEED_CHANGE_ACK: move_type = MOVE_SWIM; force_move_type = MOVE_SWIM; break;
+ case CMSG_FORCE_SWIM_BACK_SPEED_CHANGE_ACK: move_type = MOVE_SWIM_BACK; force_move_type = MOVE_SWIM_BACK; break;
+ case CMSG_FORCE_TURN_RATE_CHANGE_ACK: move_type = MOVE_TURN_RATE; force_move_type = MOVE_TURN_RATE; break;
+ case CMSG_FORCE_FLIGHT_SPEED_CHANGE_ACK: move_type = MOVE_FLIGHT; force_move_type = MOVE_FLIGHT; break;
+ case CMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE_ACK: move_type = MOVE_FLIGHT_BACK; force_move_type = MOVE_FLIGHT_BACK; break;
default:
sLog.outError("WorldSession::HandleForceSpeedChangeAck: Unknown move type opcode: %u", opcode);
return;
diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp
index 4936e9f0991..59e88d669bc 100644
--- a/src/game/NPCHandler.cpp
+++ b/src/game/NPCHandler.cpp
@@ -116,7 +116,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" );
@@ -554,9 +554,9 @@ void WorldSession::SendStablePet(uint64 guid )
void WorldSession::HandleStablePet( WorldPacket & recv_data )
{
- CHECK_PACKET_SIZE(recv_data,8);
+ CHECK_PACKET_SIZE(recv_data, 8);
- sLog.outDebug("WORLD: Recv CMSG_STABLE_PET not dispose.");
+ sLog.outDebug("WORLD: Recv CMSG_STABLE_PET");
uint64 npcGUID;
recv_data >> npcGUID;
@@ -617,7 +617,7 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data )
void WorldSession::HandleUnstablePet( WorldPacket & recv_data )
{
- CHECK_PACKET_SIZE(recv_data,8+4);
+ CHECK_PACKET_SIZE(recv_data, 8+4);
sLog.outDebug("WORLD: Recv CMSG_UNSTABLE_PET.");
uint64 npcGUID;
@@ -677,7 +677,7 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data )
void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data )
{
- CHECK_PACKET_SIZE(recv_data,8);
+ CHECK_PACKET_SIZE(recv_data, 8);
sLog.outDebug("WORLD: Recv CMSG_BUY_STABLE_SLOT.");
uint64 npcGUID;
@@ -722,7 +722,7 @@ void WorldSession::HandleStableRevivePet( WorldPacket &/* recv_data */)
void WorldSession::HandleStableSwapPet( WorldPacket & recv_data )
{
- CHECK_PACKET_SIZE(recv_data,8+4);
+ CHECK_PACKET_SIZE(recv_data, 8+4);
sLog.outDebug("WORLD: Recv CMSG_STABLE_SWAP_PET.");
uint64 npcGUID;
@@ -777,7 +777,7 @@ void WorldSession::HandleStableSwapPet( WorldPacket & recv_data )
void WorldSession::HandleRepairItemOpcode( WorldPacket & recv_data )
{
- CHECK_PACKET_SIZE(recv_data,8+8+1);
+ CHECK_PACKET_SIZE(recv_data, 8+8+1);
sLog.outDebug("WORLD: CMSG_REPAIR_ITEM");
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 2872f29cdaf..6ecf241dfa2 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -378,12 +378,12 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint8 flags, uint32 flags2
*data << ((Unit*)this)->GetSpeed( MOVE_WALK );
*data << ((Unit*)this)->GetSpeed( MOVE_RUN );
- *data << ((Unit*)this)->GetSpeed( MOVE_SWIMBACK );
+ *data << ((Unit*)this)->GetSpeed( MOVE_SWIM_BACK );
*data << ((Unit*)this)->GetSpeed( MOVE_SWIM );
- *data << ((Unit*)this)->GetSpeed( MOVE_WALKBACK );
- *data << ((Unit*)this)->GetSpeed( MOVE_FLY );
- *data << ((Unit*)this)->GetSpeed( MOVE_FLYBACK );
- *data << ((Unit*)this)->GetSpeed( MOVE_TURN );
+ *data << ((Unit*)this)->GetSpeed( MOVE_RUN_BACK );
+ *data << ((Unit*)this)->GetSpeed( MOVE_FLIGHT );
+ *data << ((Unit*)this)->GetSpeed( MOVE_FLIGHT_BACK );
+ *data << ((Unit*)this)->GetSpeed( MOVE_TURN_RATE );
// 0x08000000
if(flags2 & MOVEMENTFLAG_SPLINE2)
@@ -654,7 +654,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
*data << uint32(1);
break;
default:
- *data << uint32(0); //unknown. not happen.
+ *data << uint32(0); // unknown. not happen.
break;
}
}
@@ -963,6 +963,56 @@ void Object::RemoveFlag( uint16 index, uint32 oldFlag )
}
}
+void Object::SetByteFlag( uint16 index, uint8 offset, uint8 newFlag )
+{
+ ASSERT( index < m_valuesCount || PrintIndexError( index , true ) );
+
+ if(offset > 4)
+ {
+ sLog.outError("Object::SetByteFlag: wrong offset %u", offset);
+ return;
+ }
+
+ if(!(uint8(m_uint32Values[ index ] >> (offset * 8)) & newFlag))
+ {
+ m_uint32Values[ index ] |= uint32(uint32(newFlag) << (offset * 8));
+
+ if(m_inWorld)
+ {
+ if(!m_objectUpdated)
+ {
+ ObjectAccessor::Instance().AddUpdateObject(this);
+ m_objectUpdated = true;
+ }
+ }
+ }
+}
+
+void Object::RemoveByteFlag( uint16 index, uint8 offset, uint8 oldFlag )
+{
+ ASSERT( index < m_valuesCount || PrintIndexError( index , true ) );
+
+ if(offset > 4)
+ {
+ sLog.outError("Object::RemoveByteFlag: wrong offset %u", offset);
+ return;
+ }
+
+ if(uint8(m_uint32Values[ index ] >> (offset * 8)) & oldFlag)
+ {
+ m_uint32Values[ index ] &= ~uint32(uint32(oldFlag) << (offset * 8));
+
+ if(m_inWorld)
+ {
+ if(!m_objectUpdated)
+ {
+ ObjectAccessor::Instance().AddUpdateObject(this);
+ m_objectUpdated = true;
+ }
+ }
+ }
+}
+
bool Object::PrintIndexError(uint32 index, bool set) const
{
sLog.outError("ERROR: Attempt %s non-existed value field: %u (count: %u) for object typeid: %u type mask: %u",(set ? "set value to" : "get value from"),index,m_valuesCount,GetTypeId(),m_objectType);
diff --git a/src/game/Object.h b/src/game/Object.h
index a63458e6133..4eab67185df 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -234,6 +234,24 @@ class TRINITY_DLL_SPEC Object
return (m_uint32Values[ index ] & flag) != 0;
}
+ void SetByteFlag( uint16 index, uint8 offset, uint8 newFlag );
+ void RemoveByteFlag( uint16 index, uint8 offset, uint8 newFlag );
+
+ void ToggleFlag( uint16 index, uint8 offset, uint8 flag )
+ {
+ if(HasByteFlag(index, offset, flag))
+ RemoveByteFlag(index, offset, flag);
+ else
+ SetByteFlag(index, offset, flag);
+ }
+
+ bool HasByteFlag( uint16 index, uint8 offset, uint8 flag ) const
+ {
+ ASSERT( index < m_valuesCount || PrintIndexError( index , false ) );
+ ASSERT( offset < 4 );
+ return (((uint8*)&m_uint32Values[index])[offset] & flag) != 0;
+ }
+
void ApplyModFlag( uint16 index, uint32 flag, bool apply)
{
if(apply) SetFlag(index,flag); else RemoveFlag(index,flag);
@@ -305,7 +323,7 @@ class TRINITY_DLL_SPEC Object
{
int32 *m_int32Values;
uint32 *m_uint32Values;
- float *m_floatValues;
+ float *m_floatValues;
};
uint32 *m_uint32Values_mirror;
@@ -401,7 +419,7 @@ class TRINITY_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/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp
index 82e01e6529a..605d9827a01 100644
--- a/src/game/ObjectAccessor.cpp
+++ b/src/game/ObjectAccessor.cpp
@@ -47,7 +47,6 @@ INSTANTIATE_CLASS_MUTEX(ObjectAccessor, ZThread::FastMutex);
namespace Trinity
{
-
struct TRINITY_DLL_DECL BuildUpdateForPlayer
{
Player &i_player;
@@ -672,7 +671,7 @@ void ObjectAccessor::UpdateVisibilityForPlayer( Player* player )
template <class T> UNORDERED_MAP< uint64, T* > HashMapHolder<T>::m_objectMap;
template <class T> ZThread::FastMutex HashMapHolder<T>::i_lock;
-/// Global defintions for the hashmap storage
+/// Global definitions for the hashmap storage
template class HashMapHolder<Player>;
template class HashMapHolder<Pet>;
diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h
index 21ede723da5..844a6b49e4d 100644
--- a/src/game/ObjectAccessor.h
+++ b/src/game/ObjectAccessor.h
@@ -74,7 +74,7 @@ class HashMapHolder
static LockType* GetLock() { return &i_lock; }
private:
- //Non instanciable only static
+ //Non instanceable only static
HashMapHolder() {}
static LockType i_lock;
diff --git a/src/game/ObjectGridLoader.cpp b/src/game/ObjectGridLoader.cpp
index 39727db2985..0e2b6ae329d 100644
--- a/src/game/ObjectGridLoader.cpp
+++ b/src/game/ObjectGridLoader.cpp
@@ -52,7 +52,7 @@ ObjectGridRespawnMover::Visit(CreatureMapType &m)
{
// creature in unloading grid can have respawn point in another grid
// if it will be unloaded then it will not respawn in original grid until unload/load original grid
- // move to respwn point to prevent this case. For player view in respawn grid this wll be normal respawn.
+ // move to respawn point to prevent this case. For player view in respawn grid this will be normal respawn.
for(CreatureMapType::iterator iter=m.begin(), next; iter != m.end(); iter = next)
{
next = iter; ++next;
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 1d359a2df7c..a2a7d34fdf5 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -261,7 +261,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)
@@ -297,7 +297,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)
@@ -1475,7 +1475,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)
@@ -6293,7 +6293,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))
@@ -6307,7 +6307,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))
@@ -6321,7 +6321,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))
@@ -7004,7 +7004,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;
@@ -7049,7 +7049,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;
diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h
index 7dc6c1f8a9f..7750cf7095a 100644
--- a/src/game/ObjectMgr.h
+++ b/src/game/ObjectMgr.h
@@ -335,13 +335,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 ); }
@@ -429,7 +429,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);
@@ -728,15 +728,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);
@@ -764,10 +764,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; }
@@ -878,6 +878,7 @@ class ObjectMgr
int GetOrNewIndexForLocale(LocaleConstant loc);
int DBCLocaleIndex;
+
private:
void LoadScripts(ScriptMapMap& scripts, char const* tablename);
void CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids);
diff --git a/src/game/Opcodes.cpp b/src/game/Opcodes.cpp
index ad68167b746..57c3c0ca879 100644
--- a/src/game/Opcodes.cpp
+++ b/src/game/Opcodes.cpp
@@ -140,7 +140,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x06D*/ { "CMSG_DEL_IGNORE", STATUS_LOGGEDIN, &WorldSession::HandleDelIgnoreOpcode },
/*0x06E*/ { "CMSG_GROUP_INVITE", STATUS_LOGGEDIN, &WorldSession::HandleGroupInviteOpcode },
/*0x06F*/ { "SMSG_GROUP_INVITE", STATUS_NEVER, &WorldSession::Handle_ServerSide },
- /*0x070*/ { "CMSG_GROUP_CANCEL", STATUS_LOGGEDIN, &WorldSession::Handle_Depricated },
+ /*0x070*/ { "CMSG_GROUP_CANCEL", STATUS_LOGGEDIN, &WorldSession::Handle_Deprecated },
/*0x071*/ { "SMSG_GROUP_CANCEL", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x072*/ { "CMSG_GROUP_ACCEPT", STATUS_LOGGEDIN, &WorldSession::HandleGroupAcceptOpcode },
/*0x073*/ { "CMSG_GROUP_DECLINE", STATUS_LOGGEDIN, &WorldSession::HandleGroupDeclineOpcode },
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp
index 23cfb027671..59a6f596c72 100644
--- a/src/game/Pet.cpp
+++ b/src/game/Pet.cpp
@@ -173,7 +173,7 @@ bool Pet::LoadPetFromDB( Unit* owner, uint32 petentry, uint32 petnumber, bool cu
}
Map *map = owner->GetMap();
- uint32 guid=objmgr.GenerateLowGuid(HIGHGUID_PET);
+ uint32 guid = objmgr.GenerateLowGuid(HIGHGUID_PET);
uint32 pet_number = fields[0].GetUInt32();
if(!Create(guid, map, petentry, pet_number))
{
@@ -182,7 +182,7 @@ bool Pet::LoadPetFromDB( Unit* owner, uint32 petentry, uint32 petnumber, bool cu
}
float px, py, pz;
- owner->GetClosePoint(px, py, pz,GetObjectSize(),PET_FOLLOW_DIST,PET_FOLLOW_ANGLE);
+ owner->GetClosePoint(px, py, pz, GetObjectSize(), PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
Relocate(px, py, pz, owner->GetOrientation());
@@ -359,7 +359,7 @@ bool Pet::LoadPetFromDB( Unit* owner, uint32 petentry, uint32 petnumber, bool cu
if(owner->GetTypeId() == TYPEID_PLAYER && getPetType() == HUNTER_PET)
{
- result = CharacterDatabase.PQuery("SELECT genitive, dative, accusative, instrumental, prepositional FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'",owner->GetGUIDLow(),GetCharmInfo()->GetPetNumber());
+ result = CharacterDatabase.PQuery("SELECT genitive, dative, accusative, instrumental, prepositional FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", owner->GetGUIDLow(), GetCharmInfo()->GetPetNumber());
if(result)
{
@@ -959,14 +959,14 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
}
SetDisplayId(creature->GetDisplayId());
SetNativeDisplayId(creature->GetNativeDisplayId());
- SetMaxPower(POWER_HAPPINESS,GetCreatePowers(POWER_HAPPINESS));
- SetPower( POWER_HAPPINESS,166500);
+ SetMaxPower(POWER_HAPPINESS, GetCreatePowers(POWER_HAPPINESS));
+ SetPower(POWER_HAPPINESS, 166500);
setPowerType(POWER_FOCUS);
- SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,0);
- SetUInt32Value(UNIT_FIELD_PETEXPERIENCE,0);
+ SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0);
+ SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32((Trinity::XP::xp_to_level(creature->getLevel()))/4));
SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
- SetUInt32Value(UNIT_NPC_FLAGS , 0);
+ SetUInt32Value(UNIT_NPC_FLAGS, 0);
CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(creature->GetCreatureInfo()->family);
if( char* familyname = cFamily->Name[sWorld.GetDefaultDbcLocale()] )
@@ -1002,7 +1002,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel)
uint32 creature_ID = (getPetType() == HUNTER_PET) ? 1 : cinfo->Entry;
- SetLevel( petlevel);
+ SetLevel(petlevel);
SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool));
@@ -1091,7 +1091,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel)
for(int stat = 0; stat < MAX_STATS; ++stat)
{
- SetCreateStat(Stats(stat),float(pInfo->stats[stat]));
+ SetCreateStat(Stats(stat), float(pInfo->stats[stat]));
}
}
else // not exist in DB, use some default fake data
@@ -1102,11 +1102,11 @@ bool Pet::InitStatsForLevel(uint32 petlevel)
SetCreateHealth(uint32(((float(cinfo->maxhealth) / cinfo->maxlevel) / (1 + 2 * cinfo->rank)) * petlevel) );
SetCreateMana( uint32(((float(cinfo->maxmana) / cinfo->maxlevel) / (1 + 2 * cinfo->rank)) * petlevel) );
- SetCreateStat(STAT_STRENGTH,22);
- SetCreateStat(STAT_AGILITY,22);
- SetCreateStat(STAT_STAMINA,25);
- SetCreateStat(STAT_INTELLECT,28);
- SetCreateStat(STAT_SPIRIT,27);
+ SetCreateStat(STAT_STRENGTH, 22);
+ SetCreateStat(STAT_AGILITY, 22);
+ SetCreateStat(STAT_STAMINA, 25);
+ SetCreateStat(STAT_INTELLECT, 28);
+ SetCreateStat(STAT_SPIRIT, 27);
}
break;
}
@@ -1141,34 +1141,35 @@ bool Pet::InitStatsForLevel(uint32 petlevel)
// remove elite bonuses included in DB values
SetCreateHealth( uint32(((float(cinfo->maxhealth) / cinfo->maxlevel) / (1 + 2 * cinfo->rank)) * petlevel) );
- SetCreateStat(STAT_STRENGTH,22);
- SetCreateStat(STAT_AGILITY,22);
- SetCreateStat(STAT_STAMINA,25);
- SetCreateStat(STAT_INTELLECT,28);
- SetCreateStat(STAT_SPIRIT,27);
+ SetCreateStat(STAT_STRENGTH, 22);
+ SetCreateStat(STAT_AGILITY, 22);
+ SetCreateStat(STAT_STAMINA, 25);
+ SetCreateStat(STAT_INTELLECT, 28);
+ SetCreateStat(STAT_SPIRIT, 27);
}
break;
}
case GUARDIAN_PET:
- SetUInt32Value(UNIT_FIELD_PETEXPERIENCE,0);
- SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP,1000);
+ SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
+ SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
- SetCreateMana( 28 + 10*petlevel );
- SetCreateHealth( 28 + 30*petlevel );
+ SetCreateMana(28 + 10*petlevel);
+ SetCreateHealth(28 + 30*petlevel);
// FIXME: this is wrong formula, possible each guardian pet have own damage formula
//these formula may not be correct; however, it is designed to be close to what it should be
//this makes dps 0.5 of pets level
- SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)) );
+ SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)));
//damage range is then petlevel / 2
- SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4)) );
+ SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4)));
break;
default:
- sLog.outError("Pet have incorrect type (%u) for levelup.",getPetType()); break;
+ sLog.outError("Pet have incorrect type (%u) for levelup.", getPetType());
+ break;
}
for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
- SetModifierValue(UnitMods(UNIT_MOD_RESISTANCE_START + i), BASE_VALUE, float(createResistance[i]) );
+ SetModifierValue(UnitMods(UNIT_MOD_RESISTANCE_START + i), BASE_VALUE, float(createResistance[i]));
UpdateAllStats();
@@ -1199,7 +1200,7 @@ bool Pet::HaveInDiet(ItemPrototype const* item) const
uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel)
{
// -5 or greater food level
- if(getLevel() <= itemlevel +5) //possible to feed level 60 pet with level 55 level food for full effect
+ if(getLevel() <= itemlevel + 5) //possible to feed level 60 pet with level 55 level food for full effect
return 35000;
// -10..-6
else if(getLevel() <= itemlevel + 10) //pure guess, but sounds good
@@ -1249,7 +1250,7 @@ void Pet::_LoadSpellCooldowns()
_AddCreatureSpellCooldown(spell_id,db_time);
- sLog.outDebug("Pet (Number: %u) spell %u cooldown loaded (%u secs).",m_charmInfo->GetPetNumber(),spell_id,uint32(db_time-curTime));
+ sLog.outDebug("Pet (Number: %u) spell %u cooldown loaded (%u secs).", m_charmInfo->GetPetNumber(), spell_id, uint32(db_time-curTime));
}
while( result->NextRow() );
@@ -1396,7 +1397,7 @@ void Pet::_LoadAuras(uint32 timediff)
void Pet::_SaveAuras()
{
- CharacterDatabase.PExecute("DELETE FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber());
+ CharacterDatabase.PExecute("DELETE FROM pet_aura WHERE guid = '%u'", m_charmInfo->GetPetNumber());
AuraMap const& auras = GetAuras();
if (auras.empty())
@@ -1780,7 +1781,7 @@ void Pet::CastPetAuras(bool current)
if(getPetType() != HUNTER_PET && (getPetType() != SUMMON_PET || owner->getClass() != CLASS_WARLOCK))
return;
- for(PetAuraSet::iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end(); )
+ for(PetAuraSet::iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end();)
{
PetAura const* pa = *itr;
++itr;
@@ -1801,7 +1802,7 @@ void Pet::CastPetAura(PetAura const* aura)
if(auraId == 35696) // Demonic Knowledge
{
int32 basePoints = int32(aura->GetDamage() * (GetStat(STAT_STAMINA) + GetStat(STAT_INTELLECT)) / 100);
- CastCustomSpell(this,auraId,&basePoints, NULL, NULL, true );
+ CastCustomSpell(this, auraId, &basePoints, NULL, NULL, true);
}
else
CastSpell(this, auraId, true);
diff --git a/src/game/Pet.h b/src/game/Pet.h
index ea13bd5d0dc..1057abc0edf 100644
--- a/src/game/Pet.h
+++ b/src/game/Pet.h
@@ -80,6 +80,7 @@ struct PetSpell
{
uint16 slotId;
uint16 active;
+
PetSpellState state : 16;
PetSpellType type : 16;
};
@@ -146,7 +147,7 @@ class Pet : public Creature
bool isTemporarySummoned() const { return m_duration > 0; }
bool Create (uint32 guidlow, Map *map, uint32 Entry, uint32 pet_number);
- bool CreateBaseAtCreature( Creature* creature );
+ bool CreateBaseAtCreature(Creature* creature);
bool LoadPetFromDB( Unit* owner,uint32 petentry = 0,uint32 petnumber = 0, bool current = false );
void SavePetToDB(PetSaveMode mode);
void Remove(PetSaveMode mode, bool returnreagent = false);
diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp
index 3f8468e3ebc..e4269ddafd6 100644
--- a/src/game/PetHandler.cpp
+++ b/src/game/PetHandler.cpp
@@ -36,7 +36,7 @@
void WorldSession::HandlePetAction( WorldPacket & recv_data )
{
- CHECK_PACKET_SIZE(recv_data,8+2+2+8);
+ CHECK_PACKET_SIZE(recv_data, 8+2+2+8);
uint64 guid1;
uint16 spellid;
@@ -48,8 +48,8 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
recv_data >> guid2; //tag guid
// used also for charmed creature
- Unit* pet= ObjectAccessor::GetUnit(*_player,guid1);
- sLog.outDetail( "HandlePetAction.Pet %u flag is %u, spellid is %u, target %u.\n", uint32(GUID_LOPART(guid1)), flag, spellid, uint32(GUID_LOPART(guid2)) );
+ Unit* pet= ObjectAccessor::GetUnit(*_player, guid1);
+ sLog.outDetail("HandlePetAction.Pet %u flag is %u, spellid is %u, target %u.\n", uint32(GUID_LOPART(guid1)), flag, spellid, uint32(GUID_LOPART(guid2)) );
if(!pet)
{
sLog.outError( "Pet %u not exist.\n", uint32(GUID_LOPART(guid1)) );
@@ -58,7 +58,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
if(pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharm())
{
- sLog.outError( "HandlePetAction.Pet %u isn't pet of player %s .\n", uint32(GUID_LOPART(guid1)),GetPlayer()->GetName() );
+ sLog.outError("HandlePetAction.Pet %u isn't pet of player %s.\n", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName() );
return;
}
@@ -327,7 +327,7 @@ void WorldSession::SendPetNameQuery( uint64 petguid, uint32 petnumber)
void WorldSession::HandlePetSetAction( WorldPacket & recv_data )
{
- CHECK_PACKET_SIZE(recv_data,8+4+2+2);
+ CHECK_PACKET_SIZE(recv_data, 8+4+2+2);
sLog.outDetail( "HandlePetSetAction. CMSG_PET_SET_ACTION\n" );
@@ -698,7 +698,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 5b5c859097f..ea2a0224f4d 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -179,7 +179,7 @@ void PlayerTaxi::AppendTaximaskTo( ByteBuffer& data, bool all )
if(all)
{
for (uint8 i=0; i<TaxiMaskSize; i++)
- data << sTaxiNodesMask[i]; // all existed nodes
+ data << uint32(sTaxiNodesMask[i]); // all existed nodes
}
else
{
@@ -188,7 +188,7 @@ void PlayerTaxi::AppendTaximaskTo( ByteBuffer& data, bool all )
}
}
-bool PlayerTaxi::LoadTaxiDestinationsFromString( std::string values )
+bool PlayerTaxi::LoadTaxiDestinationsFromString( const std::string& values )
{
ClearTaxiDestinations();
@@ -489,7 +489,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
@@ -507,13 +507,6 @@ bool Player::Create( uint32 guidlow, std::string name, uint8 race, uint8 class_,
for (int i = 0; i < PLAYER_SLOTS_COUNT; i++)
m_items[i] = NULL;
- //for(int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; j++)
- //{
- // SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1+j*2,0);
- // SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1+j,0);
- // SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1+j,0);
- //}
-
m_race = race;
m_class = class_;
@@ -859,9 +852,8 @@ void Player::EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 da
data << (uint32)damage;
data << (uint32)0;
data << (uint32)0;
- //m_session->SendPacket(&data);
- //Let other players see that you get damage
SendMessageToSet(&data, true);
+
DealDamage(this, damage, NULL, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
if(type==DAMAGE_FALL && !isAlive()) // DealDamage not apply item durability loss at self damage
@@ -907,7 +899,7 @@ void Player::HandleDrowning()
m_isunderwater|= 0x04;
StartMirrorTimer(BREATH_TIMER, UnderWaterTime);
}
- //continius trigger drowning "Damage"
+ //continuous trigger drowning "Damage"
if ((m_breathTimer == 0) && (m_isunderwater & 0x01))
{
//TODO: Check this formula
@@ -1029,7 +1021,7 @@ void Player::SetDrunkValue(uint16 newDrunkenValue, uint32 itemId)
return;
WorldPacket data(SMSG_CROSSED_INEBRIATION_THRESHOLD, (8+4+4));
- data << GetGUID();
+ data << uint64(GetGUID());
data << uint32(newDrunkenState);
data << uint32(itemId);
@@ -1407,7 +1399,7 @@ void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
*p_data << uint8(getLevel()); // player level
// do not use GetMap! it will spawn a new instance since the bound instances are not loaded
uint32 zoneId = MapManager::Instance().GetZoneId(GetMapId(), GetPositionX(),GetPositionY());
-
+ sLog.outDebug("Player::BuildEnumData: m:%u, x:%f, y:%f, z:%f zone:%u", GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), zoneId);
*p_data << zoneId;
*p_data << GetMapId();
@@ -1651,6 +1643,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);
@@ -1798,6 +1791,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
@@ -2119,23 +2113,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();
- group->RemoveInvite(this);
+ Group* group = GetGroupInvite();
+ if(!group)
+ return;
- if(group->GetMembersCount() <= 1) // group has just 1 member => disband
- {
- if(group->IsCreated())
- {
- group->Disband(true);
- objmgr.RemoveGroup(group);
- }
- else
- group->RemoveAllInvites();
+ group->RemoveInvite(this);
- delete group;
+ if(group->GetMembersCount() <= 1) // group has just 1 member => disband
+ {
+ if(group->IsCreated())
+ {
+ group->Disband(true);
+ objmgr.RemoveGroup(group);
}
+ else
+ group->RemoveAllInvites();
+
+ delete group;
}
}
@@ -2472,7 +2466,6 @@ void Player::SendInitialSpells()
continue;
data << uint16(itr->first);
- //data << uint16(itr->second->slotId);
data << uint16(0); // it's not slot id
spellCount +=1;
@@ -2499,13 +2492,13 @@ void Player::SendInitialSpells()
data << uint16(sEntry->Category); // spell category
if(sEntry->Category) // may be wrong, but anyway better than nothing...
{
- data << uint32(0);
- data << uint32(cooldown);
+ data << uint32(0); // cooldown
+ data << uint32(cooldown); // category cooldown
}
else
{
- data << uint32(cooldown);
- data << uint32(0);
+ data << uint32(cooldown); // cooldown
+ data << uint32(0); // category cooldown
}
}
@@ -3491,7 +3484,6 @@ void Player::DestroyForPlayer( Player *target ) const
if(target == this)
{
-
for(int i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++)
{
if(m_items[i] == NULL)
@@ -3682,7 +3674,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
uint32 pl_account = objmgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER));
- WorldSession::SendReturnToSender(MAIL_NORMAL, pl_account, guid, sender, subject, itemTextId, &mi, money, 0, mailTemplateId);
+ WorldSession::SendReturnToSender(MAIL_NORMAL, pl_account, guid, sender, subject, itemTextId, &mi, money, mailTemplateId);
}
while (resultMail->NextRow());
@@ -6629,23 +6621,23 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply)
break;
case ITEM_MOD_AGILITY: // modify agility
HandleStatModifier(UNIT_MOD_STAT_AGILITY, BASE_VALUE, float(val), apply);
- ApplyStatBuffMod(STAT_AGILITY, val, apply);
+ ApplyStatBuffMod(STAT_AGILITY, float(val), apply);
break;
case ITEM_MOD_STRENGTH: //modify strength
HandleStatModifier(UNIT_MOD_STAT_STRENGTH, BASE_VALUE, float(val), apply);
- ApplyStatBuffMod(STAT_STRENGTH, val, apply);
+ ApplyStatBuffMod(STAT_STRENGTH, float(val), apply);
break;
case ITEM_MOD_INTELLECT: //modify intellect
HandleStatModifier(UNIT_MOD_STAT_INTELLECT, BASE_VALUE, float(val), apply);
- ApplyStatBuffMod(STAT_INTELLECT, val, apply);
+ ApplyStatBuffMod(STAT_INTELLECT, float(val), apply);
break;
case ITEM_MOD_SPIRIT: //modify spirit
HandleStatModifier(UNIT_MOD_STAT_SPIRIT, BASE_VALUE, float(val), apply);
- ApplyStatBuffMod(STAT_SPIRIT, val, apply);
+ ApplyStatBuffMod(STAT_SPIRIT, float(val), apply);
break;
case ITEM_MOD_STAMINA: //modify stamina
HandleStatModifier(UNIT_MOD_STAT_STAMINA, BASE_VALUE, float(val), apply);
- ApplyStatBuffMod(STAT_STAMINA, val, apply);
+ ApplyStatBuffMod(STAT_STAMINA, float(val), apply);
break;
case ITEM_MOD_DEFENSE_SKILL_RATING:
ApplyRatingMod(CR_DEFENSE_SKILL, int32(val), apply);
@@ -9199,7 +9191,7 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
}
else // equipped bag
{
- // we need check 2 time (specilized/non_specialized), use NULL_BAG to prevent skipping bag
+ // we need check 2 time (specialized/non_specialized), use NULL_BAG to prevent skipping bag
res = _CanStoreItem_InBag(bag,dest,pProto,count,true,false,pItem,NULL_BAG,slot);
if(res!=EQUIP_ERR_OK)
res = _CanStoreItem_InBag(bag,dest,pProto,count,true,true,pItem,NULL_BAG,slot);
@@ -10657,7 +10649,6 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update )
if( bag == INVENTORY_SLOT_BAG_0 )
{
-
SetUInt64Value((uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot*2)), 0);
// equipment and equipped bags can have applied bonuses
@@ -12488,7 +12479,7 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
if(pQuest->GetCharTitleId())
{
if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId()))
- SetFlag64(PLAYER__FIELD_KNOWN_TITLES, (uint64(1) << titleEntry->bit_index));
+ SetTitle(titleEntry);
}
// Send reward mail
@@ -13506,7 +13497,7 @@ void Player::SendQuestComplete( uint32 quest_id )
if( quest_id )
{
WorldPacket data( SMSG_QUESTUPDATE_COMPLETE, 4 );
- data << quest_id;
+ data << uint32(quest_id);
GetSession()->SendPacket( &data );
sLog.outDebug( "WORLD: Sent SMSG_QUESTUPDATE_COMPLETE quest = %u", quest_id );
}
@@ -13878,6 +13869,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
@@ -14094,14 +14086,14 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
SetUInt32Value(UNIT_CHANNEL_SPELL,0);
// clear charm/summon related fields
- SetUInt64Value(UNIT_FIELD_CHARM,0);
- SetUInt64Value(UNIT_FIELD_SUMMON,0);
- SetUInt64Value(UNIT_FIELD_CHARMEDBY,0);
- SetUInt64Value(UNIT_FIELD_SUMMONEDBY,0);
- SetUInt64Value(UNIT_FIELD_CREATEDBY,0);
+ SetCharm(NULL);
+ SetPet(NULL);
+ SetCharmerGUID(NULL);
+ SetOwnerGUID(NULL);
+ SetCreatorGUID(NULL);
// reset some aura modifiers before aura apply
- SetUInt64Value(PLAYER_FARSIGHT, 0);
+ SetFarSight(NULL);
SetUInt32Value(PLAYER_TRACK_CREATURES, 0 );
SetUInt32Value(PLAYER_TRACK_RESOURCES, 0 );
@@ -14186,7 +14178,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
// note: PLAYER__FIELD_KNOWN_TITLES updated at quest status loaded
if(uint32 curTitle = GetUInt32Value(PLAYER_CHOSEN_TITLE))
{
- if(!HasFlag64(PLAYER__FIELD_KNOWN_TITLES,uint64(1) << curTitle))
+ if(!HasTitle(curTitle))
SetUInt32Value(PLAYER_CHOSEN_TITLE,0);
}
@@ -14801,7 +14793,7 @@ void Player::_LoadQuestStatus(QueryResult *result)
if(pQuest->GetCharTitleId())
{
if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId()))
- SetFlag64(PLAYER__FIELD_KNOWN_TITLES, (uint64(1) << titleEntry->bit_index));
+ SetTitle(titleEntry);
}
}
@@ -16116,8 +16108,8 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
m_guardianPets.erase(pet->GetGUID());
break;
default:
- if(GetPetGUID()==pet->GetGUID())
- SetPet(0);
+ if(GetPetGUID() == pet->GetGUID())
+ SetPet(NULL);
break;
}
@@ -16202,7 +16194,7 @@ void Player::Uncharm()
charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM);
}
-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;
@@ -16214,28 +16206,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), true );
}
-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
@@ -18853,10 +18845,25 @@ 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);
- float height_z = m->GetHeight(x,y,z, false); // use .map base surface height
+ float height_z = m->GetHeight(x,y,z, false); // use .map base surface height
uint8 flag1 = m->GetTerrainType(x,y);
//!Underwater check, not in water if underground or above water level
@@ -18902,20 +18909,24 @@ bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const
void Player::HandleFallDamage(MovementInfo& movementInfo)
{
- //Players with Feather Fall or low fall time, or physical immunity (charges used) are ignored
- if (!isInFlight() && movementInfo.fallTime > 1100 && !isDead() && !isGameMaster() &&
+ // calculate total z distance of the fall
+ float z_diff = m_lastFallZ - movementInfo.z;
+ sLog.outDebug("zDiff = %f", z_diff);
+
+ //Players with low fall distance, Feather Fall or physical immunity (charges used) are ignored
+ // 14.57 can be calculated by resolving damageperc formular below to 0
+ if (z_diff >= 14.57f && !isDead() && !isGameMaster() &&
!HasAuraType(SPELL_AURA_HOVER) && !HasAuraType(SPELL_AURA_FEATHER_FALL) &&
!HasAuraType(SPELL_AURA_FLY) && !IsImmunedToDamage(SPELL_SCHOOL_MASK_NORMAL,true) )
{
- //Safe fall, fall time reduction
+ //Safe fall, fall height reduction
int32 safe_fall = GetTotalAuraModifier(SPELL_AURA_SAFE_FALL);
- uint32 fall_time = (movementInfo.fallTime > (safe_fall*10)) ? movementInfo.fallTime - (safe_fall*10) : 0;
- if(fall_time > 1100) //Prevent damage if fall time < 1100
+ float damageperc = 0.018f*(z_diff-safe_fall)-0.2426f;
+
+ if(damageperc >0 )
{
- //Fall Damage calculation
- float fallperc = float(fall_time)/1100;
- uint32 damage = (uint32)(((fallperc*fallperc -1) / 9 * GetMaxHealth())*sWorld.getRate(RATE_DAMAGE_FALL));
+ uint32 damage = (uint32)(damageperc * GetMaxHealth()*sWorld.getRate(RATE_DAMAGE_FALL));
float height = movementInfo.z;
UpdateGroundPositionZ(movementInfo.x,movementInfo.y,height);
@@ -19201,6 +19212,25 @@ bool Player::isAllowUseBattleGroundObject()
);
}
+bool Player::HasTitle(uint32 bitIndex)
+{
+ if (bitIndex > 128)
+ return false;
+
+ uint32 fieldIndexOffset = bitIndex/32;
+ uint32 flag = 1 << (bitIndex%32);
+ return HasFlag(PLAYER__FIELD_KNOWN_TITLES+fieldIndexOffset, flag);
+}
+
+void Player::SetTitle(CharTitlesEntry const* title)
+{
+ uint32 fieldIndexOffset = title->bit_index/32;
+ uint32 flag = 1 << (title->bit_index%32);
+ SetFlag(PLAYER__FIELD_KNOWN_TITLES+fieldIndexOffset, flag);
+}
+
+
+/*-----------------------TRINITY--------------------------*/
bool Player::isTotalImmunity()
{
AuraList const& immune = GetAurasByType(SPELL_AURA_SCHOOL_IMMUNITY);
@@ -19255,4 +19285,4 @@ void Player::UpdateCharmedAI()
GetMotionMaster()->MoveChase(target);
Attack(target, true);
}
-} \ No newline at end of file
+}
diff --git a/src/game/Player.h b/src/game/Player.h
index 67aab9f74fc..2f3a799805a 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -519,10 +519,10 @@ typedef std::map<uint32, QuestStatusData> QuestStatusMap;
enum QuestSlotOffsets
{
- QUEST_ID_OFFSET = 0,
- QUEST_STATE_OFFSET = 1,
+ QUEST_ID_OFFSET = 0,
+ QUEST_STATE_OFFSET = 1,
QUEST_COUNTS_OFFSET = 2,
- QUEST_TIME_OFFSET = 3
+ QUEST_TIME_OFFSET = 3
};
#define MAX_QUEST_OFFSET 4
@@ -862,7 +862,7 @@ class TRINITY_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(); }
@@ -926,7 +926,7 @@ class TRINITY_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 );
@@ -1018,11 +1018,11 @@ class TRINITY_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 ***/
@@ -1696,6 +1696,7 @@ class TRINITY_DLL_SPEC Player : public Unit
FactionStateList m_factions;
ForcedReactions m_forcedReactions;
+ FactionStateList const& GetFactionStateList() { return m_factions; }
uint32 GetDefaultReputationFlags(const FactionEntry *factionEntry) const;
int32 GetBaseReputation(const FactionEntry *factionEntry) const;
int32 GetReputation(uint32 faction_id) const;
@@ -1950,6 +1951,13 @@ class TRINITY_DLL_SPEC Player : public Unit
/*** VARIOUS SYSTEMS ***/
/*********************************************************/
MovementInfo m_movementInfo;
+ uint32 m_lastFallTime;
+ float m_lastFallZ;
+ void SetFallInformation(uint32 time, float z)
+ {
+ m_lastFallTime = time;
+ m_lastFallZ = z;
+ }
bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask); }
bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask); }
@@ -1962,6 +1970,9 @@ class TRINITY_DLL_SPEC Player : public Unit
void SetClientControl(Unit* target, uint8 allowMove);
+ uint64 GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT); }
+ void SetFarSight(uint64 guid) { SetUInt64Value(PLAYER_FARSIGHT, guid); }
+
// Transports
Transport * GetTransport() const { return m_transport; }
void SetTransport(Transport * t) { m_transport = t; }
@@ -2059,6 +2070,7 @@ class TRINITY_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; }
@@ -2068,6 +2080,9 @@ class TRINITY_DLL_SPEC Player : public Unit
WorldLocation& GetTeleportDest() { return m_teleport_dest; }
DeclinedName const* GetDeclinedNames() const { return m_declinedname; }
+ bool HasTitle(uint32 bitIndex);
+ bool HasTitle(CharTitlesEntry const* title) { return HasTitle(title->bit_index); }
+ void SetTitle(CharTitlesEntry const* title);
protected:
diff --git a/src/game/PlayerDump.cpp b/src/game/PlayerDump.cpp
index 7b32f547bff..597c84de8f9 100644
--- a/src/game/PlayerDump.cpp
+++ b/src/game/PlayerDump.cpp
@@ -339,7 +339,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)
@@ -355,7 +355,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 af5462e1fd6..86224d1fbca 100644
--- a/src/game/PlayerDump.h
+++ b/src/game/PlayerDump.h
@@ -94,7 +94,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;
@@ -113,7 +113,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/QuestDef.h b/src/game/QuestDef.h
index 4b4ec82607b..52f58c2c87e 100644
--- a/src/game/QuestDef.h
+++ b/src/game/QuestDef.h
@@ -114,20 +114,20 @@ enum __QuestGiverStatus
enum __QuestFlags
{
- // Flags used at server and sended to client
- QUEST_FLAGS_STAY_ALIVE = 1, // Not used currently
- QUEST_FLAGS_PARTY_ACCEPT = 2, // Not used currently. If player in party, all players that can accept this quest will receive confirmation box to accept quest CMSG_QUEST_CONFIRM_ACCEPT/SMSG_QUEST_CONFIRM_ACCEPT
- QUEST_FLAGS_EXPLORATION = 4, // Not used currently
- QUEST_FLAGS_SHARABLE = 8, // Can be shared: Player::CanShareQuest()
- //QUEST_FLAGS_NONE2 = 16, // Not used currently
- QUEST_FLAGS_EPIC = 32, // Not used currently: Unsure of content
- QUEST_FLAGS_RAID = 64, // Not used currently
- QUEST_FLAGS_TBC = 128, // Not used currently: Available if TBC expension enabled only
- QUEST_FLAGS_UNK2 = 256, // Not used currently: _DELIVER_MORE Quest needs more than normal _q-item_ drops from mobs
- QUEST_FLAGS_HIDDEN_REWARDS = 512, // Items and money rewarded only sent in SMSG_QUESTGIVER_OFFER_REWARD (not in SMSG_QUESTGIVER_QUEST_DETAILS or in client quest log(SMSG_QUEST_QUERY_RESPONSE))
- QUEST_FLAGS_AUTO_REWARDED = 1024, // These quests are automatically rewarded on quest complete and they will never appear in quest log client side.
- QUEST_FLAGS_TBC_RACES = 2048, // Not used currently: Bloodelf/draenei starting zone quests
- QUEST_FLAGS_DAILY = 4096, // Used to know quest is Daily one
+ // Flags used at server and sent to client
+ QUEST_FLAGS_STAY_ALIVE = 0x00000001, // Not used currently
+ QUEST_FLAGS_PARTY_ACCEPT = 0x00000002, // Not used currently. If player in party, all players that can accept this quest will receive confirmation box to accept quest CMSG_QUEST_CONFIRM_ACCEPT/SMSG_QUEST_CONFIRM_ACCEPT
+ QUEST_FLAGS_EXPLORATION = 0x00000004, // Not used currently
+ QUEST_FLAGS_SHARABLE = 0x00000008, // Can be shared: Player::CanShareQuest()
+ //QUEST_FLAGS_NONE2 = 0x00000010, // Not used currently
+ QUEST_FLAGS_EPIC = 0x00000020, // Not used currently: Unsure of content
+ QUEST_FLAGS_RAID = 0x00000040, // Not used currently
+ QUEST_FLAGS_TBC = 0x00000080, // Not used currently: Available if TBC expension enabled only
+ QUEST_FLAGS_UNK2 = 0x00000100, // Not used currently: _DELIVER_MORE Quest needs more than normal _q-item_ drops from mobs
+ QUEST_FLAGS_HIDDEN_REWARDS = 0x00000200, // Items and money rewarded only sent in SMSG_QUESTGIVER_OFFER_REWARD (not in SMSG_QUESTGIVER_QUEST_DETAILS or in client quest log(SMSG_QUEST_QUERY_RESPONSE))
+ QUEST_FLAGS_AUTO_REWARDED = 0x00000400, // These quests are automatically rewarded on quest complete and they will never appear in quest log client side.
+ QUEST_FLAGS_TBC_RACES = 0x00000800, // Not used currently: Blood elf/Draenei starting zone quests
+ QUEST_FLAGS_DAILY = 0x00001000, // Used to know quest is Daily one
// Trinity flags for set SpecialFlags in DB if required but used only at server
QUEST_TRINITY_FLAGS_REPEATABLE = 0x010000, // Set by 1 in SpecialFlags from DB
@@ -320,7 +320,7 @@ struct QuestStatusData
: m_status(QUEST_STATUS_NONE),m_rewarded(false),
m_explored(false), m_timer(0), uState(QUEST_NEW)
{
- memset(m_itemcount, 0, QUEST_OBJECTIVES_COUNT * sizeof(uint32));
+ memset(m_itemcount, 0, QUEST_OBJECTIVES_COUNT * sizeof(uint32));
memset(m_creatureOrGOcount, 0, QUEST_OBJECTIVES_COUNT * sizeof(uint32));
}
diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h
index 3edc724b7a8..52719b02ea8 100644
--- a/src/game/SharedDefines.h
+++ b/src/game/SharedDefines.h
@@ -561,7 +561,6 @@ enum SpellEffects
SPELL_EFFECT_TRADE_SKILL = 47,
SPELL_EFFECT_STEALTH = 48,
SPELL_EFFECT_DETECT = 49,
- // SPELL_EFFECT_SUMMON_OBJECT = 50,
SPELL_EFFECT_TRANS_DOOR = 50,
SPELL_EFFECT_FORCE_CRITICAL_HIT = 51,
SPELL_EFFECT_GUARANTEE_HIT = 52,
@@ -775,7 +774,7 @@ enum SpellImmunity
IMMUNITY_ID = 6
};
-#define MAX_SPELL_IMMUNITY 7
+#define MAX_SPELL_IMMUNITY 7
enum Targets
{
@@ -980,13 +979,13 @@ enum GameobjectTypes
enum GameObjectFlags
{
- GO_FLAG_IN_USE = 0x01, //disables interaction while animated
- GO_FLAG_LOCKED = 0x02, //require key, spell, event, etc to be opened. Makes "Locked" appear in tooltip
- GO_FLAG_INTERACT_COND = 0x04, //cannot interact (condition to interact)
- GO_FLAG_TRANSPORT = 0x08, //any kind of transport? Object can transport (elevator, boat, car)
- GO_FLAG_UNK1 = 0x10, //
- GO_FLAG_NODESPAWN = 0x20, //never despawn, typically for doors, they just change state
- GO_FLAG_TRIGGERED = 0x40, //typically, summoned objects. Triggered by spell or other events
+ GO_FLAG_IN_USE = 0x00000001, //disables interaction while animated
+ GO_FLAG_LOCKED = 0x00000002, //require key, spell, event, etc to be opened. Makes "Locked" appear in tooltip
+ GO_FLAG_INTERACT_COND = 0x00000004, //cannot interact (condition to interact)
+ GO_FLAG_TRANSPORT = 0x00000008, //any kind of transport? Object can transport (elevator, boat, car)
+ GO_FLAG_UNK1 = 0x00000010, //
+ GO_FLAG_NODESPAWN = 0x00000020, //never despawn, typically for doors, they just change state
+ GO_FLAG_TRIGGERED = 0x00000040 //typically, summoned objects. Triggered by spell or other events
};
enum TextEmotes
@@ -1580,7 +1579,7 @@ enum CreatureFamily
CREATURE_FAMILY_SPIDER = 3,
CREATURE_FAMILY_BEAR = 4,
CREATURE_FAMILY_BOAR = 5,
- CREATURE_FAMILY_CROCILISK = 6,
+ CREATURE_FAMILY_CROCOLISK = 6,
CREATURE_FAMILY_CARRION_BIRD = 7,
CREATURE_FAMILY_CRAB = 8,
CREATURE_FAMILY_GORILLA = 9,
@@ -1610,9 +1609,9 @@ enum CreatureFamily
enum CreatureTypeFlags
{
- CREATURE_TYPEFLAGS_TAMEBLE = 0x0001,
+ CREATURE_TYPEFLAGS_TAMEABLE = 0x0001,
CREATURE_TYPEFLAGS_HERBLOOT = 0x0100,
- CREATURE_TYPEFLAGS_MININGLOOT = 0x0200,
+ CREATURE_TYPEFLAGS_MININGLOOT = 0x0200
};
enum CreatureEliteType
diff --git a/src/game/SocialMgr.h b/src/game/SocialMgr.h
index 9ce1fbcfbed..1cc14589e51 100644
--- a/src/game/SocialMgr.h
+++ b/src/game/SocialMgr.h
@@ -65,7 +65,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/Spell.cpp b/src/game/Spell.cpp
index 78809841e3a..96cf260adc5 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -288,6 +288,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi
m_triggeringContainer = triggeringContainer;
m_referencedFromCurrentSpell = false;
m_executedCurrently = false;
+ m_delayStart = 0;
m_delayAtDamageCount = 0;
m_applyMultiplierMask = 0;
@@ -3049,17 +3050,13 @@ void Spell::SendSpellStart()
if(!IsNeedSendToClient())
return;
- sLog.outDebug("Sending SMSG_SPELL_START id=%u",m_spellInfo->Id);
+ sLog.outDebug("Sending SMSG_SPELL_START id=%u", m_spellInfo->Id);
- uint16 castFlags = CAST_FLAG_UNKNOWN1;
+ uint32 castFlags = CAST_FLAG_UNKNOWN1;
if(IsRangedSpell())
castFlags |= CAST_FLAG_AMMO;
- Unit * target;
- if(!m_targets.getUnitTarget())
- target = m_caster;
- else
- target = m_targets.getUnitTarget();
+ Unit *target = m_targets.getUnitTarget() ? m_targets.getUnitTarget() : m_caster;
WorldPacket data(SMSG_SPELL_START, (8+8+4+4+2));
if(m_CastItem)
@@ -3087,17 +3084,13 @@ void Spell::SendSpellGo()
if(!IsNeedSendToClient())
return;
- sLog.outDebug("Sending SMSG_SPELL_GO id=%u",m_spellInfo->Id);
+ sLog.outDebug("Sending SMSG_SPELL_GO id=%u", m_spellInfo->Id);
- Unit * target;
- if(!m_targets.getUnitTarget())
- target = m_caster;
- else
- target = m_targets.getUnitTarget();
+ Unit *target = m_targets.getUnitTarget() ? m_targets.getUnitTarget() : m_caster;
- uint16 castFlags = CAST_FLAG_UNKNOWN3;
+ uint32 castFlags = CAST_FLAG_UNKNOWN3;
if(IsRangedSpell())
- castFlags |= CAST_FLAG_AMMO;
+ castFlags |= CAST_FLAG_AMMO; // arrows/bullets visual
WorldPacket data(SMSG_SPELL_GO, 50); // guess size
if(m_CastItem)
@@ -3198,7 +3191,7 @@ void Spell::SendLogExecute()
data << uint32(count1); // count1 (effect count?)
for(uint32 i = 0; i < count1; ++i)
{
- data << uint32(m_spellInfo->Effect[0]); // spell effect?
+ data << uint32(m_spellInfo->Effect[0]); // spell effect
uint32 count2 = 1;
data << uint32(count2); // count2 (target count?)
for(uint32 j = 0; j < count2; ++j)
@@ -3322,7 +3315,7 @@ void Spell::SendChannelUpdate(uint32 time)
WorldPacket data( MSG_CHANNEL_UPDATE, 8+4 );
data.append(m_caster->GetPackGUID());
- data << time;
+ data << uint32(time);
((Player*)m_caster)->GetSession()->SendPacket( &data );
}
@@ -3359,8 +3352,8 @@ void Spell::SendChannelStart(uint32 duration)
{
WorldPacket data( MSG_CHANNEL_START, (8+4+4) );
data.append(m_caster->GetPackGUID());
- data << m_spellInfo->Id;
- data << duration;
+ data << uint32(m_spellInfo->Id);
+ data << uint32(duration);
((Player*)m_caster)->GetSession()->SendPacket( &data );
}
@@ -3386,8 +3379,8 @@ void Spell::SendPlaySpellVisual(uint32 SpellID)
return;
WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12);
- data << m_caster->GetGUID();
- data << SpellID;
+ data << uint64(m_caster->GetGUID());
+ data << uint32(SpellID); // spell visual id?
((Player*)m_caster)->GetSession()->SendPacket(&data);
}
@@ -4392,7 +4385,9 @@ uint8 Spell::CanCast(bool strict)
if(int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(i,m_targets.getUnitTarget()))
return SPELL_FAILED_HIGHLEVEL;
- };break;
+
+ break;
+ }
case SPELL_AURA_MOUNTED:
{
if (m_caster->IsInWater())
@@ -4425,7 +4420,9 @@ uint8 Spell::CanCast(bool strict)
// can be casted at non-friendly unit or own pet/charm
if(m_caster->IsFriendlyTo(m_targets.getUnitTarget()))
return SPELL_FAILED_TARGET_FRIENDLY;
- };break;
+
+ break;
+ }
case SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED:
case SPELL_AURA_FLY:
{
@@ -4436,7 +4433,9 @@ uint8 Spell::CanCast(bool strict)
GetVirtualMapForMapAndZone(m_caster->GetMapId(),m_caster->GetZoneId()) != 530)
return SPELL_FAILED_NOT_HERE;
}
- };break;
+
+ break;
+ }
case SPELL_AURA_PERIODIC_MANA_LEECH:
{
if (!m_targets.getUnitTarget())
@@ -4447,9 +4446,11 @@ uint8 Spell::CanCast(bool strict)
if(m_targets.getUnitTarget()->getPowerType()!=POWER_MANA)
return SPELL_FAILED_BAD_TARGETS;
+
break;
}
- default:break;
+ default:
+ break;
}
}
@@ -4556,7 +4557,7 @@ uint8 Spell::CheckCasterAuras() const
else if(m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) && m_spellInfo->PreventionType==SPELL_PREVENTION_TYPE_PACIFY)
prevented_reason = SPELL_FAILED_PACIFIED;
- // Attr must make flag drop spell totally immuned from all effects
+ // Attr must make flag drop spell totally immune from all effects
if(prevented_reason)
{
if(school_immune || mechanic_immune || dispel_immune)
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 742014ddb78..325b686c6b9 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -2850,7 +2850,7 @@ void Aura::HandleFarSight(bool apply, bool Real)
if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
return;
- caster->SetUInt64Value(PLAYER_FARSIGHT,apply ? m_modifier.m_miscvalue : 0);
+ ((Player*)caster)->SetFarSight(apply ? m_target->GetGUID() : NULL);
}
void Aura::HandleAuraTrackCreatures(bool apply, bool Real)
@@ -3522,7 +3522,7 @@ void Aura::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real)
m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314);
}
- m_target->UpdateSpeed(MOVE_FLY, true);
+ m_target->UpdateSpeed(MOVE_FLIGHT, true);
}
void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real)
@@ -3542,7 +3542,7 @@ void Aura::HandleAuraModDecreaseSpeed(bool /*apply*/, bool Real)
m_target->UpdateSpeed(MOVE_RUN, true);
m_target->UpdateSpeed(MOVE_SWIM, true);
- m_target->UpdateSpeed(MOVE_FLY, true);
+ m_target->UpdateSpeed(MOVE_FLIGHT, true);
}
void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real)
@@ -3553,7 +3553,7 @@ void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real)
m_target->UpdateSpeed(MOVE_RUN, true);
m_target->UpdateSpeed(MOVE_SWIM, true);
- m_target->UpdateSpeed(MOVE_FLY, true);
+ m_target->UpdateSpeed(MOVE_FLIGHT, true);
}
/*********************************************************/
@@ -4533,21 +4533,24 @@ void Aura::HandleAuraModIncreaseEnergy(bool apply, bool Real)
if(int32(powerType) != m_modifier.m_miscvalue)
return;
- m_target->HandleStatModifier(UnitMods(UNIT_MOD_POWER_START + powerType), TOTAL_VALUE, float(GetModifierValue()), apply);
+ UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType);
+
+ m_target->HandleStatModifier(unitMod, TOTAL_VALUE, float(GetModifierValue()), apply);
}
-void Aura::HandleAuraModIncreaseEnergyPercent(bool apply, bool Real)
+void Aura::HandleAuraModIncreaseEnergyPercent(bool apply, bool /*Real*/)
{
Powers powerType = m_target->getPowerType();
if(int32(powerType) != m_modifier.m_miscvalue)
return;
- m_target->HandleStatModifier(UnitMods(UNIT_MOD_POWER_START + powerType), TOTAL_PCT, float(GetModifierValue()), apply);
+ UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType);
+
+ m_target->HandleStatModifier(unitMod, TOTAL_PCT, float(GetModifierValue()), apply);
}
-void Aura::HandleAuraModIncreaseHealthPercent(bool apply, bool Real)
+void Aura::HandleAuraModIncreaseHealthPercent(bool apply, bool /*Real*/)
{
- //m_target->ApplyMaxHealthPercentMod(m_modifier.m_amount,apply);
m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_PCT, float(GetModifierValue()), apply);
}
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 0cf8a059d74..9dd386ef918 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -880,7 +880,7 @@ void Spell::EffectDummy(uint32 i)
if (!m_caster->HasAuraType(SPELL_AURA_MOUNTED))
return;
- float flyspeed = m_caster->GetSpeedRate(MOVE_FLY);
+ float flyspeed = m_caster->GetSpeedRate(MOVE_FLIGHT);
float speed = m_caster->GetSpeedRate(MOVE_RUN);
m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
@@ -3178,17 +3178,17 @@ void Spell::EffectSummon(uint32 i)
if(duration > 0)
spawnCreature->SetDuration(duration);
- spawnCreature->SetUInt64Value(UNIT_FIELD_SUMMONEDBY,m_caster->GetGUID());
- spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS , 0);
+ spawnCreature->SetOwnerGUID(m_caster->GetGUID());
+ spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS, 0);
spawnCreature->setPowerType(POWER_MANA);
- spawnCreature->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction());
- spawnCreature->SetUInt32Value(UNIT_FIELD_FLAGS,0);
- spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_0,2048);
- spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_1,0);
- spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,0);
- spawnCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE,0);
- spawnCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP,1000);
- spawnCreature->SetUInt64Value(UNIT_FIELD_CREATEDBY, m_caster->GetGUID());
+ spawnCreature->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, m_caster->getFaction());
+ spawnCreature->SetUInt32Value(UNIT_FIELD_FLAGS, 0);
+ spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048);
+ spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
+ spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0);
+ spawnCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
+ spawnCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
+ spawnCreature->SetCreatorGUID(m_caster->GetGUID());
spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
spawnCreature->InitStatsForLevel(level);
@@ -3464,7 +3464,7 @@ void Spell::EffectAddFarsight(uint32 i)
CellPair pair = Trinity::ComputeCellPair(dynObj->GetPositionX(), dynObj->GetPositionY());
Cell cell(pair);
- Map* map = MapManager::Instance().GetMap(dynObj->GetMapId(), dynObj);
+ Map* map = dynObj->GetMap();
map->LoadGrid(cell); // In case the spell is casted into a different grid by player
map->Add(dynObj);
map->SwitchGridContainers(dynObj, true); // Needed for forwarding player packets
@@ -3640,14 +3640,14 @@ void Spell::EffectSummonGuardian(uint32 i)
if(duration > 0)
spawnCreature->SetDuration(duration);
- spawnCreature->SetUInt64Value(UNIT_FIELD_SUMMONEDBY,m_caster->GetGUID());
+ spawnCreature->SetOwnerGUID(m_caster->GetGUID());
spawnCreature->setPowerType(POWER_MANA);
spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS , 0);
spawnCreature->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction());
spawnCreature->SetUInt32Value(UNIT_FIELD_FLAGS,0);
spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_1,0);
spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,0);
- spawnCreature->SetUInt64Value(UNIT_FIELD_CREATEDBY, m_caster->GetGUID());
+ spawnCreature->SetCreatorGUID(m_caster->GetGUID());
spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
spawnCreature->InitStatsForLevel(level);
@@ -4073,15 +4073,15 @@ void Spell::EffectSummonPet(uint32 i)
NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE);
}
- NewSummon->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID());
- NewSummon->SetUInt64Value(UNIT_FIELD_CREATEDBY, m_caster->GetGUID());
- NewSummon->SetUInt32Value(UNIT_NPC_FLAGS , 0);
+ NewSummon->SetOwnerGUID(m_caster->GetGUID());
+ NewSummon->SetCreatorGUID(m_caster->GetGUID());
+ NewSummon->SetUInt32Value(UNIT_NPC_FLAGS, 0);
NewSummon->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction);
- NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_0,2048);
- NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_1,0);
- NewSummon->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,time(NULL));
- NewSummon->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE,0);
- NewSummon->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP,1000);
+ NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048);
+ NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
+ NewSummon->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
+ NewSummon->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
+ NewSummon->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
NewSummon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
NewSummon->GetCharmInfo()->SetPetNumber(pet_number, true);
@@ -4090,7 +4090,7 @@ void Spell::EffectSummonPet(uint32 i)
// this enables popup window (pet dismiss, cancel), hunter pet additional flags set later
NewSummon->SetUInt32Value(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE);
- NewSummon->InitStatsForLevel( petlevel);
+ NewSummon->InitStatsForLevel(petlevel);
NewSummon->InitPetCreateSpells();
if(NewSummon->getPetType()==SUMMON_PET)
@@ -5738,8 +5738,8 @@ void Spell::EffectSummonCritter(uint32 i)
return;
}
- critter->SetUInt64Value(UNIT_FIELD_SUMMONEDBY,m_caster->GetGUID());
- critter->SetUInt64Value(UNIT_FIELD_CREATEDBY,m_caster->GetGUID());
+ critter->SetOwnerGUID(m_caster->GetGUID());
+ critter->SetCreatorGUID(m_caster->GetGUID());
critter->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction());
critter->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp
index 77f2ab8f1d6..9b77e19b30b 100644
--- a/src/game/SpellHandler.cpp
+++ b/src/game/SpellHandler.cpp
@@ -263,7 +263,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data )
{
- CHECK_PACKET_SIZE(recv_data,8);
+ CHECK_PACKET_SIZE(recv_data, 8);
uint64 guid;
diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp
index ca561dd4b36..36818adb36d 100644
--- a/src/game/StatSystem.cpp
+++ b/src/game/StatSystem.cpp
@@ -890,6 +890,7 @@ void Pet::UpdateMaxHealth()
void Pet::UpdateMaxPower(Powers power)
{
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power);
+
float addValue = (power == POWER_MANA) ? GetStat(STAT_INTELLECT) - GetCreateStat(STAT_INTELLECT) : 0.0f;
float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power);
diff --git a/src/game/TaxiHandler.cpp b/src/game/TaxiHandler.cpp
index 4a525cc0591..640618eaebb 100644
--- a/src/game/TaxiHandler.cpp
+++ b/src/game/TaxiHandler.cpp
@@ -84,7 +84,7 @@ void WorldSession::HandleTaxiQueryAvailableNodesOpcode( WorldPacket & recv_data
Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_FLIGHTMASTER);
if (!unit)
{
- sLog.outDebug( "WORLD: HandleTaxiQueryAvailableNodesOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
+ sLog.outDebug( "WORLD: HandleTaxiQueryAvailableNodes - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
return;
}
diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp
index aa7094cd986..2ac26f823d6 100644
--- a/src/game/Totem.cpp
+++ b/src/game/Totem.cpp
@@ -147,10 +147,9 @@ void Totem::UnSummon()
void Totem::SetOwner(uint64 guid)
{
- SetUInt64Value(UNIT_FIELD_SUMMONEDBY, guid);
- SetUInt64Value(UNIT_FIELD_CREATEDBY, guid);
- Unit *owner = this->GetOwner();
- if (owner)
+ SetCreatorGUID(guid);
+ SetOwnerGUID(guid);
+ if (Unit *owner = GetOwner())
{
this->setFaction(owner->getFaction());
this->SetLevel(owner->getLevel());
diff --git a/src/game/Traveller.h b/src/game/Traveller.h
index 55a164d35dc..4a70353e7c0 100644
--- a/src/game/Traveller.h
+++ b/src/game/Traveller.h
@@ -64,7 +64,7 @@ inline float Traveller<Creature>::Speed()
if(i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
return i_traveller.GetSpeed(MOVE_WALK);
else if(i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_FLYING2))
- return i_traveller.GetSpeed(MOVE_FLY);
+ return i_traveller.GetSpeed(MOVE_FLIGHT);
else
return i_traveller.GetSpeed(MOVE_RUN);
}
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index be225b0118b..4cd1eb5426a 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -53,12 +53,12 @@ float baseMoveSpeed[MAX_MOVE_TYPE] =
{
2.5f, // MOVE_WALK
7.0f, // MOVE_RUN
- 1.25f, // MOVE_WALKBACK
+ 1.25f, // MOVE_RUN_BACK
4.722222f, // MOVE_SWIM
- 4.5f, // MOVE_SWIMBACK
- 3.141594f, // MOVE_TURN
- 7.0f, // MOVE_FLY
- 4.5f, // MOVE_FLYBACK
+ 4.5f, // MOVE_SWIM_BACK
+ 3.141594f, // MOVE_TURN_RATE
+ 7.0f, // MOVE_FLIGHT
+ 4.5f, // MOVE_FLIGHT_BACK
};
void InitTriggerAuraData();
@@ -3032,8 +3032,8 @@ float Unit::CalculateLevelPenalty(SpellEntry const* spellProto) const
void Unit::SendAttackStart(Unit* pVictim)
{
WorldPacket data( SMSG_ATTACKSTART, 16 );
- data << GetGUID();
- data << pVictim->GetGUID();
+ data << uint64(GetGUID());
+ data << uint64(pVictim->GetGUID());
SendMessageToSet(&data, true);
DEBUG_LOG( "WORLD: Sent SMSG_ATTACKSTART" );
@@ -8126,7 +8126,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
if(GetTypeId()==TYPEID_UNIT)
{
WorldPacket data(SMSG_AI_REACTION, 12);
- data << GetGUID();
+ data << uint64(GetGUID());
data << uint32(AI_REACTION_AGGRO); // Aggro sound
((WorldObject*)this)->SendMessageToSet(&data, true);
@@ -8342,17 +8342,17 @@ Unit* Unit::GetCharm() const
void Unit::SetPet(Pet* pet)
{
- SetUInt64Value(UNIT_FIELD_SUMMON,pet ? pet->GetGUID() : 0);
+ SetUInt64Value(UNIT_FIELD_SUMMON, pet ? pet->GetGUID() : 0);
// FIXME: hack, speed must be set only at follow
if(pet)
for(int i = 0; i < MAX_MOVE_TYPE; ++i)
- pet->SetSpeed(UnitMoveType(i),m_speed_rate[i],true);
+ pet->SetSpeed(UnitMoveType(i), m_speed_rate[i], true);
}
-void Unit::SetCharm(Unit* charmed)
+void Unit::SetCharm(Unit* pet)
{
- SetUInt64Value(UNIT_FIELD_CHARM,charmed ? charmed->GetGUID() : 0);
+ SetUInt64Value(UNIT_FIELD_CHARM, pet ? pet->GetGUID() : 0);
}
void Unit::AddPlayerToVision(Player* plr)
@@ -8444,7 +8444,6 @@ void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Po
data << uint32(SpellID);
data << uint32(powertype);
data << uint32(Damage);
- //data << uint8(critical ? 1 : 0); // removed in 2.4.0
SendMessageToSet(&data, true);
}
@@ -8903,7 +8902,7 @@ int32 Unit::SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask, Unit *pVic
bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType)
{
- // not criting spell
+ // not critting spell
if((spellProto->AttributesEx2 & SPELL_ATTR_EX2_CANT_CRIT))
return false;
@@ -9692,7 +9691,7 @@ void Unit::SetInCombatState(bool PvP)
{
pet->UpdateSpeed(MOVE_RUN, true);
pet->UpdateSpeed(MOVE_SWIM, true);
- pet->UpdateSpeed(MOVE_FLY, true);
+ pet->UpdateSpeed(MOVE_FLIGHT, true);
}
}
}
@@ -9947,16 +9946,16 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
}
break;
}
- case MOVE_WALKBACK:
+ case MOVE_RUN_BACK:
return;
case MOVE_SWIM:
{
main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_SWIM_SPEED);
break;
}
- case MOVE_SWIMBACK:
+ case MOVE_SWIM_BACK:
return;
- case MOVE_FLY:
+ case MOVE_FLIGHT:
{
if (IsMounted()) // Use on mount auras
main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED);
@@ -9966,7 +9965,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
non_stack_bonus = (100.0 + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK))/100.0f;
break;
}
- case MOVE_FLYBACK:
+ case MOVE_FLIGHT_BACK:
return;
default:
sLog.outError("Unit::UpdateSpeed: Unsupported move type (%d)", mtype);
@@ -9981,7 +9980,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
{
case MOVE_RUN:
case MOVE_SWIM:
- case MOVE_FLY:
+ case MOVE_FLIGHT:
{
// Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need
// TODO: possible affect only on MOVE_RUN
@@ -10038,22 +10037,22 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
case MOVE_RUN:
data.Initialize(MSG_MOVE_SET_RUN_SPEED, 8+4+1+4+4+4+4+4+4+4);
break;
- case MOVE_WALKBACK:
+ case MOVE_RUN_BACK:
data.Initialize(MSG_MOVE_SET_RUN_BACK_SPEED, 8+4+1+4+4+4+4+4+4+4);
break;
case MOVE_SWIM:
data.Initialize(MSG_MOVE_SET_SWIM_SPEED, 8+4+1+4+4+4+4+4+4+4);
break;
- case MOVE_SWIMBACK:
+ case MOVE_SWIM_BACK:
data.Initialize(MSG_MOVE_SET_SWIM_BACK_SPEED, 8+4+1+4+4+4+4+4+4+4);
break;
- case MOVE_TURN:
+ case MOVE_TURN_RATE:
data.Initialize(MSG_MOVE_SET_TURN_RATE, 8+4+1+4+4+4+4+4+4+4);
break;
- case MOVE_FLY:
+ case MOVE_FLIGHT:
data.Initialize(MSG_MOVE_SET_FLIGHT_SPEED, 8+4+1+4+4+4+4+4+4+4);
break;
- case MOVE_FLYBACK:
+ case MOVE_FLIGHT_BACK:
data.Initialize(MSG_MOVE_SET_FLIGHT_BACK_SPEED, 8+4+1+4+4+4+4+4+4+4);
break;
default:
@@ -10086,22 +10085,22 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
case MOVE_RUN:
data.Initialize(SMSG_FORCE_RUN_SPEED_CHANGE, 17);
break;
- case MOVE_WALKBACK:
+ case MOVE_RUN_BACK:
data.Initialize(SMSG_FORCE_RUN_BACK_SPEED_CHANGE, 16);
break;
case MOVE_SWIM:
data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, 16);
break;
- case MOVE_SWIMBACK:
+ case MOVE_SWIM_BACK:
data.Initialize(SMSG_FORCE_SWIM_BACK_SPEED_CHANGE, 16);
break;
- case MOVE_TURN:
+ case MOVE_TURN_RATE:
data.Initialize(SMSG_FORCE_TURN_RATE_CHANGE, 16);
break;
- case MOVE_FLY:
+ case MOVE_FLIGHT:
data.Initialize(SMSG_FORCE_FLIGHT_SPEED_CHANGE, 16);
break;
- case MOVE_FLYBACK:
+ case MOVE_FLIGHT_BACK:
data.Initialize(SMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE, 16);
break;
default:
@@ -10109,7 +10108,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
return;
}
data.append(GetPackGUID());
- data << (uint32)0;
+ data << (uint32)0; // moveEvent, NUM_PMOVE_EVTS = 0x39
if (mtype == MOVE_RUN)
data << uint8(0); // new 2.1.0
data << float(GetSpeed(mtype));
@@ -12314,9 +12313,9 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
return NULL;
}
- pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID());
- pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, GetGUID());
- pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,getFaction());
+ pet->SetOwnerGUID(GetGUID());
+ pet->SetCreatorGUID(GetGUID());
+ pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction());
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id);
if(!pet->InitStatsForLevel(creatureTarget->getLevel()))
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 8f06d09029f..68da9a93730 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -375,14 +375,14 @@ enum UnitState
enum UnitMoveType
{
- MOVE_WALK = 0,
- MOVE_RUN = 1,
- MOVE_WALKBACK = 2,
- MOVE_SWIM = 3,
- MOVE_SWIMBACK = 4,
- MOVE_TURN = 5,
- MOVE_FLY = 6,
- MOVE_FLYBACK = 7
+ MOVE_WALK = 0,
+ MOVE_RUN = 1,
+ MOVE_RUN_BACK = 2,
+ MOVE_SWIM = 3,
+ MOVE_SWIM_BACK = 4,
+ MOVE_TURN_RATE = 5,
+ MOVE_FLIGHT = 6,
+ MOVE_FLIGHT_BACK = 7,
};
#define MAX_MOVE_TYPE 8
@@ -1030,11 +1030,14 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
DeathState getDeathState() { return m_deathState; };
virtual void setDeathState(DeathState s); // overwrited in Creature/Player/Pet
- uint64 const& GetOwnerGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMONEDBY); }
+ uint64 GetOwnerGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMONEDBY); }
+ void SetOwnerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_SUMMONEDBY, owner); }
+ uint64 GetCreatorGUID() const { return GetUInt64Value(UNIT_FIELD_CREATEDBY); }
+ void SetCreatorGUID(uint64 creator) { SetUInt64Value(UNIT_FIELD_CREATEDBY, creator); }
uint64 GetPetGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMON); }
uint64 GetCharmerGUID() const { return GetUInt64Value(UNIT_FIELD_CHARMEDBY); }
- uint64 GetCharmGUID() const { return GetUInt64Value(UNIT_FIELD_CHARM); }
void SetCharmerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_CHARMEDBY, owner); }
+ uint64 GetCharmGUID() const { return GetUInt64Value(UNIT_FIELD_CHARM); }
uint64 GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); }
uint64 GetCharmerOrOwnerOrOwnGUID() const
@@ -1229,7 +1232,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
AuraList const& GetSingleCastAuras() const { return m_scAuras; }
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY];
- // Threat related methodes
+ // Threat related methods
bool CanHaveThreatList() const;
void AddThreat(Unit* pVictim, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell = NULL);
float ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL);
diff --git a/src/game/World.cpp b/src/game/World.cpp
index 66054d95afb..6ab82fffed2 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -2357,7 +2357,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 885047e6685..e93444d8957 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -463,7 +463,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 eeb7d41efb6..47e1334198e 100644
--- a/src/game/WorldSession.cpp
+++ b/src/game/WorldSession.cpp
@@ -156,20 +156,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)",
@@ -229,6 +220,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))
@@ -499,31 +497,31 @@ void WorldSession::Handle_EarlyProccess( WorldPacket& recvPacket )
void WorldSession::Handle_ServerSide( WorldPacket& recvPacket )
{
- sLog.outError( "SESSION: received sever-side opcode %s (0x%.4X)",
+ sLog.outError( "SESSION: received server-side opcode %s (0x%.4X)",
LookupOpcodeName(recvPacket.GetOpcode()),
recvPacket.GetOpcode());
}
-void WorldSession::Handle_Depricated( WorldPacket& recvPacket )
+void WorldSession::Handle_Deprecated( WorldPacket& recvPacket )
{
- sLog.outError( "SESSION: received depricated opcode %s (0x%.4X)",
+ sLog.outError( "SESSION: received deprecated opcode %s (0x%.4X)",
LookupOpcodeName(recvPacket.GetOpcode()),
recvPacket.GetOpcode());
}
void WorldSession::SendAuthWaitQue(uint32 position)
- {
- if(position == 0)
- {
- WorldPacket packet( SMSG_AUTH_RESPONSE, 1 );
- packet << uint8( AUTH_OK );
- SendPacket(&packet);
- }
- else
- {
- WorldPacket packet( SMSG_AUTH_RESPONSE, 5 );
- packet << uint8( AUTH_WAIT_QUEUE );
- packet << uint32 (position);
- SendPacket(&packet);
- }
- }
+{
+ if(position == 0)
+ {
+ WorldPacket packet( SMSG_AUTH_RESPONSE, 1 );
+ packet << uint8( AUTH_OK );
+ SendPacket(&packet);
+ }
+ else
+ {
+ WorldPacket packet( SMSG_AUTH_RESPONSE, 5 );
+ packet << uint8( AUTH_WAIT_QUEUE );
+ packet << uint32 (position);
+ SendPacket(&packet);
+ }
+}
diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h
index c9f98765092..231fc2a2abf 100644
--- a/src/game/WorldSession.h
+++ b/src/game/WorldSession.h
@@ -84,9 +84,9 @@ class TRINITY_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; }
@@ -131,7 +131,7 @@ class TRINITY_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 );
@@ -156,7 +156,7 @@ class TRINITY_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, uint32 COD, 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
@@ -179,9 +179,9 @@ class TRINITY_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 );
@@ -212,7 +212,7 @@ class TRINITY_DLL_SPEC WorldSession
void Handle_NULL(WorldPacket& recvPacket); // not used
void Handle_EarlyProccess( WorldPacket& recvPacket);// just mark packets processed in WorldSocket::OnRead
void Handle_ServerSide(WorldPacket& recvPacket); // sever side only, can't be accepted from client
- void Handle_Depricated(WorldPacket& recvPacket); // never used anymore by client
+ void Handle_Deprecated(WorldPacket& recvPacket); // never used anymore by client
void HandleCharEnumOpcode(WorldPacket& recvPacket);
void HandleCharDeleteOpcode(WorldPacket& recvPacket);
@@ -337,7 +337,6 @@ class TRINITY_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 0dab9c3d8d4..01d5a0e5490 100644
--- a/src/game/WorldSocket.cpp
+++ b/src/game/WorldSocket.cpp
@@ -114,10 +114,9 @@ void WorldSocket::CloseSocket (void)
ACE_GUARD (LockType, Guard, m_OutBufferLock);
if (closing_)
- return;
+ return;
closing_ = true;
-
peer ().close_writer ();
}
@@ -263,7 +262,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));
@@ -281,7 +280,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);
@@ -475,7 +474,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));
@@ -718,6 +717,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
uint32 world_expansion = sWorld.getConfig(CONFIG_EXPANSION);
if(expansion > world_expansion)
expansion = world_expansion;
+ //expansion = ((sWorld.getConfig(CONFIG_EXPANSION) > fields[8].GetUInt8()) ? fields[8].GetUInt8() : sWorld.getConfig(CONFIG_EXPANSION));
N.SetHexStr ("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7");
g.SetDword (7);
@@ -739,8 +739,8 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
x.SetBinary (sha1.GetDigest (), sha1.GetLength ());
v = g.ModExp (x, N);
- const char* sStr = s.AsHexStr (); //Must be freed by OPENSSL_free()
- const char* vStr = v.AsHexStr (); //Must be freed by OPENSSL_free()
+ const char* sStr = s.AsHexStr (); //Must be freed by OPENSSL_free()
+ const char* vStr = v.AsHexStr (); //Must be freed by OPENSSL_free()
const char* vold = fields[6].GetString ();
DEBUG_LOG ("WorldSocket::HandleAuthSession: (s,v) check s: %s v_old: %s v_new: %s",
@@ -830,7 +830,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
SendPacket (packet);
- sLog.outBasic ("WorldSocket::HandleAuthSession: User tryes to login but his security level is not enough");
+ sLog.outBasic ("WorldSocket::HandleAuthSession: User tries to login but his security level is not enough");
return -1;
}
@@ -945,7 +945,7 @@ int WorldSocket::HandlePing (WorldPacket& recvPacket)
ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1);
if (m_Session)
- m_Session->SetLatency (latency);
+ m_Session->SetLatency (latency);
else
{
sLog.outError ("WorldSocket::HandlePing: peer sent CMSG_PING, "
diff --git a/src/game/debugcmds.cpp b/src/game/debugcmds.cpp
index e98550315f9..c5ba79d671b 100644
--- a/src/game/debugcmds.cpp
+++ b/src/game/debugcmds.cpp
@@ -10,12 +10,12 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "Common.h"
@@ -32,6 +32,8 @@
#include "GossipDef.h"
#include "Language.h"
#include "MapManager.h"
+#include <fstream>
+#include "ObjectMgr.h"
#include "BattleGroundMgr.h"
bool ChatHandler::HandleDebugInArcCommand(const char* /*args*/)
@@ -61,8 +63,8 @@ bool ChatHandler::HandleDebugSpellFailCommand(const char* args)
uint8 failnum = (uint8)atoi(px);
WorldPacket data(SMSG_CAST_FAILED, 5);
- data << (uint32)133;
- data << failnum;
+ data << uint32(133);
+ data << uint8(failnum);
m_session->SendPacket(&data);
return true;
@@ -127,70 +129,76 @@ bool ChatHandler::HandleBuyErrorCommand(const char* args)
return true;
}
-bool ChatHandler::HandleSendOpcodeCommand(const char* args)
+bool ChatHandler::HandleSendOpcodeCommand(const char* /*args*/)
{
Unit *unit = getSelectedUnit();
if (!unit || (unit->GetTypeId() != TYPEID_PLAYER))
unit = m_session->GetPlayer();
- FILE *file = fopen("opcode.txt", "r");
- if(!file)
+ std::ifstream ifs("opcode.txt");
+ if(ifs.bad())
return false;
- uint32 type;
+ uint32 opcode;
+ ifs >> opcode;
- uint32 val1;
- uint64 val2;
- float val3;
- char val4[101];
+ WorldPacket data(opcode, 0);
- uint32 opcode = 0;
- fscanf(file, "%u", &opcode);
- if(!opcode)
+ while(!ifs.eof())
{
- fclose(file);
- return false;
- }
+ std::string type;
+ ifs >> type;
- WorldPacket data(opcode, 0);
+ if(type == "")
+ break;
- while(fscanf(file, "%u", &type) != EOF)
- {
- switch(type)
+ if(type == "uint8")
+ {
+ uint16 val1;
+ ifs >> val1;
+ data << uint8(val1);
+ }
+ else if(type == "uint16")
+ {
+ uint16 val2;
+ ifs >> val2;
+ data << val2;
+ }
+ else if(type == "uint32")
+ {
+ uint32 val3;
+ ifs >> val3;
+ data << val3;
+ }
+ else if(type == "uint64")
+ {
+ uint64 val4;
+ ifs >> val4;
+ data << val4;
+ }
+ else if(type == "float")
+ {
+ float val5;
+ ifs >> val5;
+ data << val5;
+ }
+ else if(type == "string")
+ {
+ std::string val6;
+ ifs >> val6;
+ data << val6;
+ }
+ else if(type == "pguid")
+ {
+ data.append(unit->GetPackGUID());
+ }
+ else
{
- case 0: // uint8
- fscanf(file, "%u", &val1);
- data << uint8(val1);
- break;
- case 1: // uint16
- fscanf(file, "%u", &val1);
- data << uint16(val1);
- break;
- case 2: // uint32
- fscanf(file, "%u", &val1);
- data << uint32(val1);
- break;
- case 3: // uint64
- fscanf(file, I64FMTD, &val2);
- data << uint64(val2);
- break;
- case 4: // float
- fscanf(file, "%f", &val3);
- data << float(val3);
- break;
- case 5: // string
- fscanf(file, "%s", val4, 101);
- data << val4;
- break;
- case 6: // packed guid
- data.append(unit->GetPackGUID());
- break;
- default:
- fclose(file);
- return false;
+ sLog.outDebug("Sending opcode: unknown type '%s'", type.c_str());
+ break;
}
}
- fclose(file);
+ ifs.close();
sLog.outDebug("Sending opcode %u", data.GetOpcode());
data.hexlike();
((Player*)unit)->GetSession()->SendPacket(&data);
@@ -218,7 +226,7 @@ bool ChatHandler::HandlePlaySound2Command(const char* args)
return false;
uint32 soundid = atoi(args);
- m_session->GetPlayer()->SendPlaySound(soundid, false);
+ m_session->GetPlayer()->PlaySound(soundid, false);
return true;
}
@@ -262,7 +270,7 @@ bool ChatHandler::HandleSendQuestPartyMsgCommand(const char* args)
return true;
}
-bool ChatHandler::HandleGetLootRecipient(const char* args)
+bool ChatHandler::HandleGetLootRecipient(const char* /*args*/)
{
Creature* target = getSelectedCreature();
if(!target)
diff --git a/src/shared/Common.cpp b/src/shared/Common.cpp
index 93e876bc007..5e24b0e6594 100644
--- a/src/shared/Common.cpp
+++ b/src/shared/Common.cpp
@@ -32,7 +32,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 9bf44b78f16..684776a694f 100644
--- a/src/shared/Common.h
+++ b/src/shared/Common.h
@@ -190,7 +190,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 ad66d56b67e..1b823ccf8c8 100644
--- a/src/shared/Config/ConfigEnv.h
+++ b/src/shared/Config/ConfigEnv.h
@@ -25,6 +25,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 03536daf738..fb132c75768 100644
--- a/src/shared/Database/DBCStores.cpp
+++ b/src/shared/Database/DBCStores.cpp
@@ -130,7 +130,7 @@ DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore(WorldSafeLocsEntryfmt);
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);
@@ -139,7 +139,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));
@@ -174,7 +174,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 399b94213fe..98a54fbeccf 100644
--- a/src/shared/Database/DBCStores.h
+++ b/src/shared/Database/DBCStores.h
@@ -197,7 +197,7 @@ extern DBCStorage <TotemCategoryEntry> sTotemCategoryStore;
//extern DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore; -- use Zone2MapCoordinates and Map2ZoneCoordinates
extern DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore;
-void LoadDBCStores(std::string dataPath);
+void LoadDBCStores(const std::string& dataPath);
// script support functions
TRINITY_DLL_SPEC DBCStorage <SoundEntriesEntry> const* GetSoundEntriesStore();
diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp
index 705b34d3cc7..518c91940dc 100644
--- a/src/shared/Log.cpp
+++ b/src/shared/Log.cpp
@@ -45,7 +45,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 02f996d26c5..d68529a77a8 100644
--- a/src/shared/Log.h
+++ b/src/shared/Log.h
@@ -84,7 +84,7 @@ class Log : public Trinity::Singleton<Log, Trinity::ClassLevelLockable<Log, ZThr
}
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
diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp
index 4f135dcc4ce..a35af77e7f6 100644
--- a/src/shared/Util.cpp
+++ b/src/shared/Util.cpp
@@ -133,13 +133,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))
{
@@ -195,7 +195,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)
@@ -273,7 +273,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
{
@@ -378,7 +378,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;
@@ -395,7 +395,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;
@@ -410,7 +410,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;
diff --git a/src/shared/Util.h b/src/shared/Util.h
index 44c0dda8370..b99cdb13bde 100644
--- a/src/shared/Util.h
+++ b/src/shared/Util.h
@@ -33,7 +33,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)
@@ -97,11 +97,11 @@ 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);
}
@@ -282,9 +282,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) \
@@ -313,6 +313,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
diff --git a/src/shared/vmap/CoordModelMapping.h b/src/shared/vmap/CoordModelMapping.h
index 9482bd23f80..59766e5e7d5 100644
--- a/src/shared/vmap/CoordModelMapping.h
+++ b/src/shared/vmap/CoordModelMapping.h
@@ -45,8 +45,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()); }
};
@@ -115,7 +115,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;
@@ -128,8 +128,8 @@ namespace VMAP
}
const G3D::Array<unsigned int>& getMaps() const { return iMapIds; }
- inline bool isAlreadyProcessedSingleFile(std::string pName) { return(iProcesseSingleFiles.containsKey(pName)); }
- inline 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)
{
diff --git a/src/shared/vmap/VMapManager.cpp b/src/shared/vmap/VMapManager.cpp
index fe105df1f5c..337e553f38d 100644
--- a/src/shared/vmap/VMapManager.cpp
+++ b/src/shared/vmap/VMapManager.cpp
@@ -277,10 +277,8 @@ namespace VMAP
{
dirFileName = getDirFileName(pMapId);
}
- size_t len = pBasePath.length() + dirFileName.length();
- char *filenameBuffer = new char[len+1];
- sprintf(filenameBuffer, "%s%s", pBasePath.c_str(), dirFileName.c_str());
- FILE* df = fopen(filenameBuffer, "rb");
+ std::string fb = pBasePath + dirFileName;
+ FILE* df = fopen(fb.c_str(), "rb");
if(df)
{
char lineBuffer[FILENAMEBUFFER_SIZE];
@@ -290,8 +288,8 @@ namespace VMAP
chomp(name);
if(name.length() >1)
{
- sprintf(filenameBuffer, "%s%s", pBasePath.c_str(), name.c_str());
- FILE* df2 = fopen(filenameBuffer, "rb");
+ std::string fb2 = pBasePath + name;
+ FILE* df2 = fopen(fb2.c_str(), "rb");
if(df2)
{
char magic[8];
@@ -304,7 +302,6 @@ namespace VMAP
}
fclose(df);
}
- delete[] filenameBuffer;
return result;
}
@@ -661,14 +658,12 @@ namespace VMAP
bool MapTree::loadMap(const std::string& pDirFileName, unsigned int pMapTileIdent)
{
bool result = true;
- size_t len = iBasePath.length() + pDirFileName.length();
- char *filenameBuffer = new char[len+1];
if(!hasDirFile(pDirFileName))
{
FilesInDir filesInDir;
result = false;
- sprintf(filenameBuffer, "%s%s", iBasePath.c_str(), pDirFileName.c_str());
- FILE* df = fopen(filenameBuffer, "rb");
+ std::string fb = iBasePath + pDirFileName;
+ FILE* df = fopen(fb.c_str(), "rb");
if(df)
{
char lineBuffer[FILENAMEBUFFER_SIZE];
@@ -728,7 +723,6 @@ namespace VMAP
filesInDir.incRefCount();
}
}
- delete [] filenameBuffer;
return (result);
}
diff --git a/src/trinitycore/RASocket.h b/src/trinitycore/RASocket.h
index dd6ebbc572d..a164c9d3aa2 100644
--- a/src/trinitycore/RASocket.h
+++ b/src/trinitycore/RASocket.h
@@ -10,12 +10,12 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/// \addtogroup Trinityd
@@ -52,7 +52,7 @@ class RASocket: public TcpSocket
bool bLog;
bool bSecure; //kick on wrong pass, non exist. user, user with no priv
//will protect from DOS, bruteforce attacks
- //some 'smart' protection must be added for more scurity
+ //some 'smart' protection must be added for more security
uint8 iMinLevel;
enum
{
diff --git a/src/trinityrealm/AuthSocket.cpp b/src/trinityrealm/AuthSocket.cpp
index dce10fe4562..7168bcf700b 100644
--- a/src/trinityrealm/AuthSocket.cpp
+++ b/src/trinityrealm/AuthSocket.cpp
@@ -10,12 +10,12 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** \file
@@ -300,7 +300,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/trinityrealm/AuthSocket.h b/src/trinityrealm/AuthSocket.h
index 17f41ad945b..f704283c215 100644
--- a/src/trinityrealm/AuthSocket.h
+++ b/src/trinityrealm/AuthSocket.h
@@ -58,7 +58,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/trinityrealm/RealmList.cpp b/src/trinityrealm/RealmList.cpp
index e393ead1ac4..97fdfbdd91f 100644
--- a/src/trinityrealm/RealmList.cpp
+++ b/src/trinityrealm/RealmList.cpp
@@ -44,7 +44,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/trinityrealm/RealmList.h b/src/trinityrealm/RealmList.h
index 2b1a74e83c2..9cb5380bd25 100644
--- a/src/trinityrealm/RealmList.h
+++ b/src/trinityrealm/RealmList.h
@@ -10,12 +10,12 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/// \addtogroup realmd
@@ -58,7 +58,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;