diff --git a/contrib/extractor/.gitignore b/contrib/extractor/.gitignore
index bbf017c83..908bb677d 100644
--- a/contrib/extractor/.gitignore
+++ b/contrib/extractor/.gitignore
@@ -17,3 +17,4 @@
debug
release
*.user
+*.ilk
diff --git a/contrib/extractor/System.cpp b/contrib/extractor/System.cpp
index 39bf1d5b1..978a7d2d9 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,9 +261,9 @@ 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)
@@ -272,7 +272,7 @@ void LoadCommonMPQFiles()
if(i > 1)
sprintf(ext, "-%i", i);
- sprintf(filename,"%s/Data/patch%s.MPQ",input_path,ext);
+ sprintf(filename,"%s/Data/patch%s.MPQ", input_path, ext);
if(FileExists(filename))
new MPQArchive(filename);
}
@@ -306,12 +306,12 @@ int main(int argc, char * arg[])
if((extract & EXTRACT_DBC) == 0)
{
- FirstLocale=i;
+ FirstLocale = i;
break;
}
//Extract DBC files
- if(FirstLocale<0)
+ if(FirstLocale < 0)
{
ExtractDBCFiles(i, true);
FirstLocale = i;
@@ -324,7 +324,7 @@ int main(int argc, char * arg[])
}
}
- 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 2bd27e526..fd2d16120 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 30657907f..fedab5b89 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 14aa824a0..59fdf6d21 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 1f2c45dfc..2dc24c087 100755
Binary files a/contrib/extractor/ad.exe and b/contrib/extractor/ad.exe differ
diff --git a/contrib/vmap_assembler/.gitignore b/contrib/vmap_assembler/.gitignore
new file mode 100644
index 000000000..267442f37
--- /dev/null
+++ b/contrib/vmap_assembler/.gitignore
@@ -0,0 +1,16 @@
+#
+# NOTE! Don't add files that are generated in specific
+# subdirectories here. Add them in the ".gitignore" file
+# in that subdirectory instead.
+#
+# NOTE! Please use 'git-ls-files -i --exclude-standard'
+# command after changing this file, to see if there are
+# any tracked files which get ignored after the change.
+#
+# MaNGOS generated files at Windows build
+#
+
+*.ncb
+*.suo
+Release
+Debug
diff --git a/contrib/vmap_assembler/VC71/.gitignore b/contrib/vmap_assembler/VC71/.gitignore
new file mode 100644
index 000000000..7835e14b5
--- /dev/null
+++ b/contrib/vmap_assembler/VC71/.gitignore
@@ -0,0 +1,13 @@
+#
+# NOTE! Don't add files that are generated in specific
+# subdirectories here. Add them in the ".gitignore" file
+# in that subdirectory instead.
+#
+# NOTE! Please use 'git-ls-files -i --exclude-standard'
+# command after changing this file, to see if there are
+# any tracked files which get ignored after the change.
+#
+# MaNGOS generated files at Windows build
+#
+
+*.user
diff --git a/contrib/vmap_assembler/VC80/.gitignore b/contrib/vmap_assembler/VC80/.gitignore
new file mode 100644
index 000000000..7835e14b5
--- /dev/null
+++ b/contrib/vmap_assembler/VC80/.gitignore
@@ -0,0 +1,13 @@
+#
+# NOTE! Don't add files that are generated in specific
+# subdirectories here. Add them in the ".gitignore" file
+# in that subdirectory instead.
+#
+# NOTE! Please use 'git-ls-files -i --exclude-standard'
+# command after changing this file, to see if there are
+# any tracked files which get ignored after the change.
+#
+# MaNGOS generated files at Windows build
+#
+
+*.user
diff --git a/contrib/vmap_assembler/VC90/.gitignore b/contrib/vmap_assembler/VC90/.gitignore
new file mode 100644
index 000000000..7835e14b5
--- /dev/null
+++ b/contrib/vmap_assembler/VC90/.gitignore
@@ -0,0 +1,13 @@
+#
+# NOTE! Don't add files that are generated in specific
+# subdirectories here. Add them in the ".gitignore" file
+# in that subdirectory instead.
+#
+# NOTE! Please use 'git-ls-files -i --exclude-standard'
+# command after changing this file, to see if there are
+# any tracked files which get ignored after the change.
+#
+# MaNGOS generated files at Windows build
+#
+
+*.user
diff --git a/contrib/vmap_assembler/VC90/vmap_assembler.vcproj b/contrib/vmap_assembler/VC90/vmap_assembler.vcproj
new file mode 100644
index 000000000..4710f92f1
--- /dev/null
+++ b/contrib/vmap_assembler/VC90/vmap_assembler.vcproj
@@ -0,0 +1,455 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/contrib/vmap_assembler/vmap_assemblerVC90.sln b/contrib/vmap_assembler/vmap_assemblerVC90.sln
new file mode 100644
index 000000000..0aeab053c
--- /dev/null
+++ b/contrib/vmap_assembler/vmap_assemblerVC90.sln
@@ -0,0 +1,19 @@
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vmap_assembler", "VC90\vmap_assembler.vcproj", "{572FFF74-480C-4472-8ABF-81733BB4049D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {572FFF74-480C-4472-8ABF-81733BB4049D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {572FFF74-480C-4472-8ABF-81733BB4049D}.Debug|Win32.Build.0 = Debug|Win32
+ {572FFF74-480C-4472-8ABF-81733BB4049D}.Release|Win32.ActiveCfg = Release|Win32
+ {572FFF74-480C-4472-8ABF-81733BB4049D}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/contrib/vmap_extractor_v2/vmapExtractor_VC90.sln b/contrib/vmap_extractor_v2/vmapExtractor_VC90.sln
new file mode 100644
index 000000000..82d3e1509
--- /dev/null
+++ b/contrib/vmap_extractor_v2/vmapExtractor_VC90.sln
@@ -0,0 +1,19 @@
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vmapExtractor", "vmapExtractor_VC90.vcproj", "{87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug Ansi Static|Win32 = Debug Ansi Static|Win32
+ Release Ansi Static|Win32 = Release Ansi Static|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}.Debug Ansi Static|Win32.ActiveCfg = Debug Ansi Static|Win32
+ {87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}.Debug Ansi Static|Win32.Build.0 = Debug Ansi Static|Win32
+ {87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}.Release Ansi Static|Win32.ActiveCfg = Release Ansi Static|Win32
+ {87335BBF-5DA8-4FEC-A51E-1FB948F2FFE9}.Release Ansi Static|Win32.Build.0 = Release Ansi Static|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/contrib/vmap_extractor_v2/vmapExtractor_VC90.vcproj b/contrib/vmap_extractor_v2/vmapExtractor_VC90.vcproj
new file mode 100644
index 000000000..ed75735c4
--- /dev/null
+++ b/contrib/vmap_extractor_v2/vmapExtractor_VC90.vcproj
@@ -0,0 +1,999 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dep/include/mersennetwister/MersenneTwister.h b/dep/include/mersennetwister/MersenneTwister.h
index 9c6994bdf..af919319a 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/sql/characters.sql b/sql/characters.sql
index e26bff136..f73ca3c78 100644
--- a/sql/characters.sql
+++ b/sql/characters.sql
@@ -21,7 +21,7 @@
DROP TABLE IF EXISTS `character_db_version`;
CREATE TABLE `character_db_version` (
- `required_2008_11_12_01_character_character_aura` bit(1) default NULL
+ `required_2008_12_03_01_character_guild_member` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
--
@@ -249,6 +249,7 @@ CREATE TABLE `character_aura` (
`caster_guid` bigint(20) unsigned NOT NULL default '0' COMMENT 'Full Global Unique Identifier',
`spell` int(11) unsigned NOT NULL default '0',
`effect_index` int(11) unsigned NOT NULL default '0',
+ `stackcount` int(11) NOT NULL default '1',
`amount` int(11) NOT NULL default '0',
`maxduration` int(11) NOT NULL default '0',
`remaintime` int(11) NOT NULL default '0',
@@ -938,7 +939,7 @@ CREATE TABLE `guild_member` (
`BankRemSlotsTab5` int(11) unsigned NOT NULL default '0',
KEY `guildid_key` (`guildid`),
KEY `guildid_rank_key` (`guildid`,`rank`),
- KEY `guid_key` (`guid`)
+ UNIQUE KEY `guid_key` (`guid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Guild System';
--
@@ -1125,6 +1126,7 @@ CREATE TABLE `pet_aura` (
`caster_guid` bigint(20) unsigned NOT NULL default '0' COMMENT 'Full Global Unique Identifier',
`spell` int(11) unsigned NOT NULL default '0',
`effect_index` int(11) unsigned NOT NULL default '0',
+ `stackcount` int(11) NOT NULL default '1',
`amount` int(11) NOT NULL default '0',
`maxduration` int(11) NOT NULL default '0',
`remaintime` int(11) NOT NULL default '0',
diff --git a/sql/mangos.sql b/sql/mangos.sql
index 5b9a11518..7c5817f30 100644
--- a/sql/mangos.sql
+++ b/sql/mangos.sql
@@ -22,7 +22,7 @@
DROP TABLE IF EXISTS `db_version`;
CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
- `required_2008_11_18_02_mangos_mangos_string` bit(1) default NULL
+ `required_2008_11_29_02_mangos_spell_elixir` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
--
@@ -8073,435 +8073,6 @@ CREATE TABLE `playercreateinfo_item` (
LOCK TABLES `playercreateinfo_item` WRITE;
/*!40000 ALTER TABLE `playercreateinfo_item` DISABLE KEYS */;
-INSERT INTO `playercreateinfo_item` VALUES
-(1,1,38,1),
-(1,1,39,1),
-(1,1,40,1),
-(1,1,25,1),
-(1,1,2362,1),
-(1,1,117,4),
-(1,1,6948,1),
-(1,1,14646,1),
-(1,2,45,1),
-(1,2,44,1),
-(1,2,43,1),
-(1,2,2361,1),
-(1,2,6948,1),
-(1,2,159,2),
-(1,2,2070,4),
-(1,2,14646,1),
-(1,4,49,1),
-(1,4,48,1),
-(1,4,47,1),
-(1,4,2092,1),
-(1,4,2947,100),
-(1,4,2070,4),
-(1,4,6948,1),
-(1,4,14646,1),
-(1,5,53,1),
-(1,5,6098,1),
-(1,5,52,1),
-(1,5,51,1),
-(1,5,36,1),
-(1,5,159,2),
-(1,5,2070,4),
-(1,5,6948,1),
-(1,5,14646,1),
-(1,8,6096,1),
-(1,8,56,1),
-(1,8,1395,1),
-(1,8,55,1),
-(1,8,35,1),
-(1,8,2070,4),
-(1,8,159,2),
-(1,8,6948,1),
-(1,8,14646,1),
-(1,9,6097,1),
-(1,9,57,1),
-(1,9,1396,1),
-(1,9,59,1),
-(1,9,2092,1),
-(1,9,4604,4),
-(1,9,159,2),
-(1,9,6948,1),
-(1,9,14646,1),
-(2,1,6125,1),
-(2,1,139,1),
-(2,1,140,1),
-(2,1,12282,1),
-(2,1,6948,1),
-(2,1,117,4),
-(2,1,14649,1),
-(2,3,127,1),
-(2,3,6126,1),
-(2,3,6127,1),
-(2,3,37,1),
-(2,3,2504,1),
-(2,3,159,2),
-(2,3,117,4),
-(2,3,6948,1),
-(2,3,14649,1),
-(2,3,2512,200),
-(2,3,2101,1),
-(2,4,2105,1),
-(2,4,120,1),
-(2,4,121,1),
-(2,4,2092,1),
-(2,4,25861,100),
-(2,4,117,4),
-(2,4,6948,1),
-(2,4,14649,1),
-(2,7,154,1),
-(2,7,153,1),
-(2,7,36,1),
-(2,7,6948,1),
-(2,7,117,4),
-(2,7,159,2),
-(2,7,14649,1),
-(2,9,6129,1),
-(2,9,1396,1),
-(2,9,59,1),
-(2,9,2092,1),
-(2,9,6948,1),
-(2,9,117,4),
-(2,9,159,2),
-(2,9,14649,1),
-(3,1,38,1),
-(3,1,39,1),
-(3,1,40,1),
-(3,1,12282,1),
-(3,1,6948,1),
-(3,1,117,4),
-(3,1,14647,1),
-(3,2,45,1),
-(3,2,44,1),
-(3,2,43,1),
-(3,2,2361,1),
-(3,2,4540,4),
-(3,2,159,2),
-(3,2,6948,1),
-(3,2,14647,1),
-(3,3,148,1),
-(3,3,147,1),
-(3,3,129,1),
-(3,3,37,1),
-(3,3,2508,1),
-(3,3,159,2),
-(3,3,117,4),
-(3,3,6948,1),
-(3,3,14647,1),
-(3,3,2516,200),
-(3,3,2102,1),
-(3,4,49,1),
-(3,4,48,1),
-(3,4,47,1),
-(3,4,2092,1),
-(3,4,25861,100),
-(3,4,4540,4),
-(3,4,6948,1),
-(3,4,14647,1),
-(3,5,53,1),
-(3,5,6098,1),
-(3,5,52,1),
-(3,5,51,1),
-(3,5,36,1),
-(3,5,159,2),
-(3,5,4540,4),
-(3,5,6948,1),
-(3,5,14647,1),
-(4,1,38,1),
-(4,1,39,1),
-(4,1,40,1),
-(4,1,25,1),
-(4,1,2362,1),
-(4,1,117,4),
-(4,1,6948,1),
-(4,1,14648,1),
-(4,3,148,1),
-(4,3,147,1),
-(4,3,129,1),
-(4,3,2092,1),
-(4,3,2504,1),
-(4,3,159,2),
-(4,3,117,4),
-(4,3,6948,1),
-(4,3,14648,1),
-(4,3,2512,200),
-(4,3,2101,1),
-(4,4,49,1),
-(4,4,48,1),
-(4,4,47,1),
-(4,4,2092,1),
-(4,4,2947,100),
-(4,4,4540,4),
-(4,4,6948,1),
-(4,4,14648,1),
-(4,5,53,1),
-(4,5,6119,1),
-(4,5,52,1),
-(4,5,51,1),
-(4,5,36,1),
-(4,5,2070,4),
-(4,5,159,2),
-(4,5,6948,1),
-(4,5,14648,1),
-(4,11,6123,1),
-(4,11,44,1),
-(4,11,3661,1),
-(4,11,159,2),
-(4,11,4536,4),
-(4,11,6948,1),
-(4,11,14648,1),
-(5,1,6125,1),
-(5,1,139,1),
-(5,1,140,1),
-(5,1,25,1),
-(5,1,2362,1),
-(5,1,4604,4),
-(5,1,6948,1),
-(5,1,14651,1),
-(5,4,2105,1),
-(5,4,120,1),
-(5,4,121,1),
-(5,4,2092,1),
-(5,4,2947,100),
-(5,4,4604,4),
-(5,4,6948,1),
-(5,4,14651,1),
-(5,5,53,1),
-(5,5,6144,1),
-(5,5,52,1),
-(5,5,51,1),
-(5,5,36,1),
-(5,5,4604,4),
-(5,5,159,2),
-(5,5,6948,1),
-(5,5,14651,1),
-(5,8,6096,1),
-(5,8,6140,1),
-(5,8,1395,1),
-(5,8,55,1),
-(5,8,35,1),
-(5,8,4604,4),
-(5,8,159,2),
-(5,8,6948,1),
-(5,8,14651,1),
-(5,9,6129,1),
-(5,9,1396,1),
-(5,9,59,1),
-(5,9,2092,1),
-(5,9,4604,4),
-(5,9,159,2),
-(5,9,6948,1),
-(5,9,14651,1),
-(6,1,6125,1),
-(6,1,139,1),
-(6,1,2361,1),
-(6,1,6948,1),
-(6,1,4540,4),
-(6,1,14650,1),
-(6,3,127,1),
-(6,3,6126,1),
-(6,3,37,1),
-(6,3,2508,1),
-(6,3,159,2),
-(6,3,117,4),
-(6,3,6948,1),
-(6,3,14650,1),
-(6,3,2516,200),
-(6,3,2102,1),
-(6,7,154,1),
-(6,7,153,1),
-(6,7,36,1),
-(6,7,6948,1),
-(6,7,4604,4),
-(6,7,159,2),
-(6,7,14650,1),
-(6,11,6139,1),
-(6,11,6124,1),
-(6,11,35,1),
-(6,11,159,2),
-(6,11,4536,4),
-(6,11,6948,1),
-(6,11,14650,1),
-(7,1,38,1),
-(7,1,39,1),
-(7,1,40,1),
-(7,1,25,1),
-(7,1,2362,1),
-(7,1,117,4),
-(7,1,6948,1),
-(7,1,14647,1),
-(7,4,49,1),
-(7,4,48,1),
-(7,4,47,1),
-(7,4,2092,1),
-(7,4,2947,100),
-(7,4,117,4),
-(7,4,6948,1),
-(7,4,14647,1),
-(7,8,6096,1),
-(7,8,56,1),
-(7,8,1395,1),
-(7,8,55,1),
-(7,8,35,1),
-(7,8,4536,4),
-(7,8,159,2),
-(7,8,6948,1),
-(7,8,14647,1),
-(7,9,6097,1),
-(7,9,57,1),
-(7,9,1396,1),
-(7,9,59,1),
-(7,9,2092,1),
-(7,9,159,2),
-(7,9,4604,4),
-(7,9,6948,1),
-(7,9,14647,1),
-(8,1,6125,1),
-(8,1,139,1),
-(8,1,140,1),
-(8,1,37,1),
-(8,1,2362,1),
-(8,1,25861,100),
-(8,1,117,4),
-(8,1,6948,1),
-(8,1,14649,1),
-(8,3,127,1),
-(8,3,6126,1),
-(8,3,6127,1),
-(8,3,37,1),
-(8,3,2504,1),
-(8,3,4604,4),
-(8,3,159,2),
-(8,3,2512,200),
-(8,3,2101,1),
-(8,3,14649,1),
-(8,3,6948,1),
-(8,4,2105,1),
-(8,4,120,1),
-(8,4,121,1),
-(8,4,2092,1),
-(8,4,25861,100),
-(8,4,117,4),
-(8,4,6948,1),
-(8,4,14649,1),
-(8,5,53,1),
-(8,5,6144,1),
-(8,5,52,1),
-(8,5,36,1),
-(8,5,4540,4),
-(8,5,159,2),
-(8,5,6948,1),
-(8,5,14649,1),
-(8,7,6134,1),
-(8,7,6135,1),
-(8,7,36,1),
-(8,7,117,4),
-(8,7,159,2),
-(8,7,6948,1),
-(8,7,14649,1),
-(8,8,6096,1),
-(8,8,6140,1),
-(8,8,1395,1),
-(8,8,55,1),
-(8,8,35,1),
-(8,8,117,4),
-(8,8,159,2),
-(8,8,6948,1),
-(8,8,14649,1),
-(10,2,159,5),
-(10,2,2070,5),
-(10,2,6948,1),
-(10,2,23346,1),
-(10,2,24143,1),
-(10,2,24145,1),
-(10,2,24146,1),
-(10,3,159,5),
-(10,3,2101,1),
-(10,3,2512,200),
-(10,3,6948,1),
-(10,3,20857,5),
-(10,3,20899,1),
-(10,3,20900,1),
-(10,3,20901,1),
-(10,3,20980,1),
-(10,3,20982,1),
-(10,4,3111,100),
-(10,4,6948,1),
-(10,4,20857,10),
-(10,4,20896,1),
-(10,4,20897,1),
-(10,4,20898,1),
-(10,4,20982,1),
-(10,5,51,1),
-(10,5,52,1),
-(10,5,53,1),
-(10,5,159,5),
-(10,5,6948,1),
-(10,5,20891,1),
-(10,5,20981,5),
-(10,8,35,1),
-(10,8,159,5),
-(10,8,6096,1),
-(10,8,6948,1),
-(10,8,20857,5),
-(10,8,20893,1),
-(10,8,20894,1),
-(10,8,20895,1),
-(10,9,59,1),
-(10,9,159,5),
-(10,9,1396,1),
-(10,9,6948,1),
-(10,9,20857,5),
-(10,9,20892,1),
-(10,9,20983,1),
-(11,1,4540,5),
-(11,1,6948,1),
-(11,1,23346,1),
-(11,1,23473,1),
-(11,1,23474,1),
-(11,1,23475,1),
-(11,2,159,5),
-(11,2,2361,1),
-(11,2,4540,5),
-(11,2,6948,1),
-(11,2,23476,1),
-(11,2,23476,1),
-(11,2,23477,1),
-(11,3,25,1),
-(11,3,159,5),
-(11,3,2101,1),
-(11,3,2504,1),
-(11,3,2512,200),
-(11,3,4540,5),
-(11,3,6948,1),
-(11,3,23344,1),
-(11,3,23345,1),
-(11,3,23348,1),
-(11,5,36,1),
-(11,5,59,1),
-(11,5,159,5),
-(11,5,1396,1),
-(11,5,4540,5),
-(11,5,6097,1),
-(11,5,6948,1),
-(11,5,23322,1),
-(11,7,36,1),
-(11,7,159,5),
-(11,7,4540,5),
-(11,7,6948,1),
-(11,7,23344,1),
-(11,7,23345,1),
-(11,7,23348,1),
-(11,8,35,1),
-(11,8,159,5),
-(11,8,4540,5),
-(11,8,6948,1),
-(11,8,23473,1),
-(11,8,23475,1),
-(11,8,23478,1),
-(11,8,23479,1);
/*!40000 ALTER TABLE `playercreateinfo_item` ENABLE KEYS */;
UNLOCK TABLES;
@@ -14170,6 +13741,7 @@ INSERT INTO `spell_elixir` VALUES
(41610,0xB),
(41611,0xB),
(42735,0x3),
+(45373,0x1),
(46837,0xB),
(46839,0xB);
/*!40000 ALTER TABLE `spell_elixir` ENABLE KEYS */;
@@ -15160,7 +14732,7 @@ INSERT INTO `spell_proc_event` VALUES
(34950,0,0,0,0,0x0000000000000000,0x00400000,0,0),
(34954,0,0,0,0,0x0000000000000000,0x00400000,0,0),
(35077,0,0,0,0,0x0000000000000000,0x00008000,0,60),
-(35080,0,0,0,0,0x0000000000000000,0x00000001,0,60),
+(35080,0,0,0,0,0x0000000000000000,0x00080001,0,60),
(35083,0,0,0,0,0x0000000000000000,0x00020000,0,60),
(35086,0,0,0,0,0x0000000000000000,0x08020000,0,60),
(35100,0,0,0,0,0x0000000000000000,0x00080000,0,0),
diff --git a/sql/updates/2008_11_27_01_mangos_playercreateinfo_item.sql b/sql/updates/2008_11_27_01_mangos_playercreateinfo_item.sql
new file mode 100644
index 000000000..48d50dd91
--- /dev/null
+++ b/sql/updates/2008_11_27_01_mangos_playercreateinfo_item.sql
@@ -0,0 +1,3 @@
+ALTER TABLE db_version CHANGE COLUMN required_2008_11_18_02_mangos_mangos_string required_2008_11_27_01_mangos_playercreateinfo_item bit;
+
+TRUNCATE TABLE playercreateinfo_item;
diff --git a/sql/updates/2008_11_29_01_mangos_spell_proc_event.sql b/sql/updates/2008_11_29_01_mangos_spell_proc_event.sql
new file mode 100644
index 000000000..339ae216d
--- /dev/null
+++ b/sql/updates/2008_11_29_01_mangos_spell_proc_event.sql
@@ -0,0 +1,5 @@
+ALTER TABLE db_version CHANGE COLUMN required_2008_11_27_01_mangos_playercreateinfo_item required_2008_11_29_01_mangos_spell_proc_event bit;
+
+DELETE FROM spell_proc_event where entry = 35080;
+INSERT INTO spell_proc_event (entry, SchoolMask, Category, SkillID, SpellFamilyName, SpellFamilyMask, procFlags, ppmRate, cooldown) VALUES
+(35080,0,0,0,0,0x0000000000000000,0x00080001,0,60);
diff --git a/sql/updates/2008_11_29_02_mangos_spell_elixir.sql b/sql/updates/2008_11_29_02_mangos_spell_elixir.sql
new file mode 100644
index 000000000..7d6d353a2
--- /dev/null
+++ b/sql/updates/2008_11_29_02_mangos_spell_elixir.sql
@@ -0,0 +1,5 @@
+ALTER TABLE db_version CHANGE COLUMN required_2008_11_29_01_mangos_spell_proc_event required_2008_11_29_02_mangos_spell_elixir bit;
+
+DELETE FROM `spell_elixir` WHERE `entry` = 45373;
+INSERT INTO `spell_elixir` VALUES
+(45373,0x1);
diff --git a/sql/updates/2008_12_03_01_character_guild_member.sql b/sql/updates/2008_12_03_01_character_guild_member.sql
new file mode 100644
index 000000000..f339d6b45
--- /dev/null
+++ b/sql/updates/2008_12_03_01_character_guild_member.sql
@@ -0,0 +1,3 @@
+ALTER TABLE character_db_version CHANGE COLUMN required_2008_11_12_01_character_character_aura required_2008_12_03_01_character_guild_member bit;
+ALTER TABLE `guild_member` DROP INDEX `guid_key` ,
+ADD UNIQUE `guid_key` ( `guid` );
diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am
index 13245d807..c4ca950f1 100644
--- a/sql/updates/Makefile.am
+++ b/sql/updates/Makefile.am
@@ -137,6 +137,10 @@ pkgdata_DATA = \
2008_11_16_01_mangos_command.sql \
2008_11_18_01_mangos_creature_movement.sql \
2008_11_18_02_mangos_mangos_string.sql \
+ 2008_11_27_01_mangos_playercreateinfo_item.sql \
+ 2008_11_29_01_mangos_spell_proc_event.sql \
+ 2008_11_29_02_mangos_spell_elixir.sql \
+ 2008_12_03_01_character_guild_member.sql \
README
## Additional files to include when running 'make dist'
@@ -255,4 +259,8 @@ EXTRA_DIST = \
2008_11_16_01_mangos_command.sql \
2008_11_18_01_mangos_creature_movement.sql \
2008_11_18_02_mangos_mangos_string.sql \
+ 2008_11_27_01_mangos_playercreateinfo_item.sql \
+ 2008_11_29_01_mangos_spell_proc_event.sql \
+ 2008_11_29_02_mangos_spell_elixir.sql \
+ 2008_12_03_01_character_guild_member.sql \
README
diff --git a/src/framework/Utilities/LinkedList.h b/src/framework/Utilities/LinkedList.h
index 7ca217fe7..9e6f9249c 100644
--- a/src/framework/Utilities/LinkedList.h
+++ b/src/framework/Utilities/LinkedList.h
@@ -44,6 +44,11 @@ class LinkedListElement
LinkedListElement * prev() { return hasPrev() ? iPrev : NULL; }
LinkedListElement const* prev() const { return hasPrev() ? iPrev : NULL; }
+ LinkedListElement * nocheck_next() { return iNext; }
+ LinkedListElement const* nocheck_next() const { return iNext; }
+ LinkedListElement * nocheck_prev() { return iPrev; }
+ LinkedListElement const* nocheck_prev() const { return iPrev; }
+
void delink()
{
if(isInList())
@@ -134,7 +139,10 @@ class LinkedListHead
typedef ptrdiff_t difference_type;
typedef ptrdiff_t distance_type;
typedef _Ty* pointer;
+ typedef _Ty const* const_pointer;
typedef _Ty& reference;
+ typedef _Ty const & const_reference;
+
Iterator() : _Ptr(0)
{ // construct with null node pointer
@@ -144,6 +152,17 @@ class LinkedListHead
{ // construct with node pointer _Pnode
}
+ Iterator& operator=(Iterator const &_Right)
+ {
+ return (*this) = _Right._Ptr;
+ }
+
+ Iterator& operator=(const_pointer const &_Right)
+ {
+ _Ptr = (pointer)_Right;
+ return (*this);
+ }
+
reference operator*()
{ // return designated value
return *_Ptr;
@@ -200,6 +219,17 @@ class LinkedListHead
return (!(*this == _Right));
}
+ bool operator==(const_reference _Right) const
+ { // test for reference equality
+ return (_Ptr == &_Right);
+ }
+
+ bool operator!=(const_reference _Right) const
+ { // test for reference equality
+ return (_Ptr != &_Right);
+ }
+
+
pointer _Mynode()
{ // return node pointer
return (_Ptr);
diff --git a/src/framework/Utilities/LinkedReference/Reference.h b/src/framework/Utilities/LinkedReference/Reference.h
index a3c879709..3c84704dc 100644
--- a/src/framework/Utilities/LinkedReference/Reference.h
+++ b/src/framework/Utilities/LinkedReference/Reference.h
@@ -71,9 +71,15 @@ template class Reference : public LinkedListElement
return iRefTo != NULL;
}
- Reference* next() { return((Reference*)LinkedListElement::next()); }
- Referenceconst* next() const { return((Reference const*)LinkedListElement::next()); }
- Reference* prev() { return((Reference*)LinkedListElement::prev()); }
+ Reference * next() { return((Reference *) LinkedListElement::next()); }
+ Reference const * next() const { return((Reference const *) LinkedListElement::next()); }
+ Reference * prev() { return((Reference *) LinkedListElement::prev()); }
+ Reference const * prev() const { return((Reference const *) LinkedListElement::prev()); }
+
+ Reference * nocheck_next() { return((Reference *) LinkedListElement::nocheck_next()); }
+ Reference const * nocheck_next() const { return((Reference const *) LinkedListElement::nocheck_next()); }
+ Reference * nocheck_prev() { return((Reference *) LinkedListElement::nocheck_prev()); }
+ Reference const * nocheck_prev() const { return((Reference const *) LinkedListElement::nocheck_prev()); }
inline TO* operator ->() const { return iRefTo; }
inline TO* getTarget() const { return iRefTo; }
diff --git a/src/game/AccountMgr.cpp b/src/game/AccountMgr.cpp
index 459cdbeac..3060554a9 100644
--- a/src/game/AccountMgr.cpp
+++ b/src/game/AccountMgr.cpp
@@ -55,7 +55,7 @@ AccountOpResult AccountMgr::CreateAccount(std::string username, std::string pass
return AOR_NAME_ALREDY_EXIST; // username does already exist
}
- if(!loginDatabase.PExecute("INSERT INTO account(username,sha_pass_hash,joindate) VALUES('%s',SHA1(CONCAT('%s',':','%s')),NOW())", username.c_str(), username.c_str(), password.c_str()))
+ if(!loginDatabase.PExecute("INSERT INTO account(username,sha_pass_hash,joindate) VALUES('%s',SHA1("_CONCAT3_("'%s'","':'","'%s'")"),NOW())", username.c_str(), username.c_str(), password.c_str()))
return AOR_DB_INTERNAL_ERROR; // unexpected error
loginDatabase.Execute("INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist,account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL");
@@ -127,7 +127,7 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname,
loginDatabase.escape_string(new_uname);
loginDatabase.escape_string(new_passwd);
- if(!loginDatabase.PExecute("UPDATE account SET username='%s',sha_pass_hash=SHA1(CONCAT('%s',':','%s')) WHERE id='%d'", new_uname.c_str(), new_uname.c_str(), new_passwd.c_str(), accid))
+ if(!loginDatabase.PExecute("UPDATE account SET username='%s',sha_pass_hash=SHA1("_CONCAT3_("'%s'","':'","'%s'")") WHERE id='%d'", new_uname.c_str(), new_uname.c_str(), new_passwd.c_str(), accid))
return AOR_DB_INTERNAL_ERROR; // unexpected error
return AOR_OK;
@@ -146,7 +146,7 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd)
normilizeString(new_passwd);
loginDatabase.escape_string(new_passwd);
- if(!loginDatabase.PExecute("UPDATE account SET sha_pass_hash=SHA1(CONCAT(username,':','%s')) WHERE id='%d'", new_passwd.c_str(), accid))
+ if(!loginDatabase.PExecute("UPDATE account SET sha_pass_hash=SHA1("_CONCAT3_("username","':'","'%s'")") WHERE id='%d'", new_passwd.c_str(), accid))
return AOR_DB_INTERNAL_ERROR; // unexpected error
return AOR_OK;
@@ -197,7 +197,7 @@ bool AccountMgr::CheckPassword(uint32 accid, std::string passwd)
normilizeString(passwd);
loginDatabase.escape_string(passwd);
- QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d' AND sha_pass_hash=SHA1(CONCAT(username,':','%s'))", accid, passwd.c_str());
+ QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d' AND sha_pass_hash=SHA1("_CONCAT3_("username","':'","'%s'")")", accid, passwd.c_str());
if (result)
{
delete result;
diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp
index 637410c1f..25244e7a2 100644
--- a/src/game/AggressorAI.cpp
+++ b/src/game/AggressorAI.cpp
@@ -47,15 +47,23 @@ AggressorAI::MoveInLineOfSight(Unit *u)
if( !i_creature.canFly() && i_creature.GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE )
return;
- if( !i_creature.getVictim() && !i_creature.hasUnitState(UNIT_STAT_STUNNED) && u->isTargetableForAttack() &&
+ if( !i_creature.hasUnitState(UNIT_STAT_STUNNED) && u->isTargetableForAttack() &&
( i_creature.IsHostileTo( u ) /*|| u->getVictim() && i_creature.IsFriendlyTo( u->getVictim() )*/ ) &&
u->isInAccessablePlaceFor(&i_creature) )
{
float attackRadius = i_creature.GetAttackDistance(u);
if(i_creature.IsWithinDistInMap(u, attackRadius) && i_creature.IsWithinLOSInMap(u) )
{
- AttackStart(u);
- u->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
+ if(!i_creature.getVictim())
+ {
+ AttackStart(u);
+ u->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
+ }
+ else if(sMapStore.LookupEntry(i_creature.GetMapId())->IsDungeon())
+ {
+ u->SetInCombatWith(&i_creature);
+ i_creature.AddThreat(u, 0.0f);
+ }
}
}
}
diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp
index 88ed21ebf..72ed8d679 100644
--- a/src/game/ArenaTeam.cpp
+++ b/src/game/ArenaTeam.cpp
@@ -22,21 +22,21 @@
ArenaTeam::ArenaTeam()
{
- Id = 0;
- Type = 0;
- Name = "";
- CaptainGuid = 0;
- BackgroundColor = 0; // background
- EmblemStyle = 0; // icon
- EmblemColor = 0; // icon color
- BorderStyle = 0; // border
- BorderColor = 0; // border color
- stats.games = 0;
- stats.played = 0;
- stats.rank = 0;
- stats.rating = 1500;
- stats.wins = 0;
- stats.wins2 = 0;
+ Id = 0;
+ Type = 0;
+ Name = "";
+ CaptainGuid = 0;
+ BackgroundColor = 0; // background
+ EmblemStyle = 0; // icon
+ EmblemColor = 0; // icon color
+ BorderStyle = 0; // border
+ BorderColor = 0; // border color
+ stats.games_week = 0;
+ stats.games_season = 0;
+ stats.rank = 0;
+ stats.rating = 1500;
+ stats.wins_week = 0;
+ stats.wins_season = 0;
}
ArenaTeam::~ArenaTeam()
@@ -51,7 +51,7 @@ bool ArenaTeam::create(uint64 captainGuid, uint32 type, std::string ArenaTeamNam
if(objmgr.GetArenaTeamByName(ArenaTeamName)) // arena team with this name already exist
return false;
- sLog.outDebug("GUILD: creating arena team %s to leader: %u", ArenaTeamName.c_str(), GUID_LOPART(CaptainGuid));
+ sLog.outDebug("GUILD: creating arena team %s to leader: %u", ArenaTeamName.c_str(), GUID_LOPART(captainGuid));
CaptainGuid = captainGuid;
Name = ArenaTeamName;
@@ -69,7 +69,7 @@ bool ArenaTeam::create(uint64 captainGuid, uint32 type, std::string ArenaTeamNam
"VALUES('%u','%s','%u','%u','%u','%u','%u','%u','%u')",
Id, ArenaTeamName.c_str(), GUID_LOPART(CaptainGuid), Type, BackgroundColor,EmblemStyle,EmblemColor,BorderStyle,BorderColor);
CharacterDatabase.PExecute("INSERT INTO arena_team_stats (arenateamid, rating, games, wins, played, wins2, rank) VALUES "
- "('%u', '%u', '%u', '%u', '%u', '%u', '%u')", Id,stats.rating,stats.games,stats.wins,stats.played,stats.wins2,stats.rank);
+ "('%u', '%u', '%u', '%u', '%u', '%u', '%u')", Id,stats.rating,stats.games_week,stats.wins_week,stats.games_season,stats.wins_season,stats.rank);
CharacterDatabase.CommitTransaction();
@@ -122,13 +122,14 @@ bool ArenaTeam::AddMember(uint64 PlayerGuid)
Player::RemovePetitionsAndSigns(PlayerGuid, GetType());
ArenaTeamMember newmember;
- newmember.name = plName;
- newmember.guid = PlayerGuid;
- newmember.Class = plClass;
- newmember.played_season = 0;
- newmember.played_week = 0;
- newmember.wons_season = 0;
- newmember.wons_week = 0;
+ newmember.name = plName;
+ newmember.guid = PlayerGuid;
+ newmember.Class = plClass;
+ newmember.games_season = 0;
+ newmember.games_week = 0;
+ newmember.wins_season = 0;
+ newmember.wins_week = 0;
+ newmember.personal_rating = 1500;
members.push_back(newmember);
CharacterDatabase.PExecute("INSERT INTO arena_team_member (arenateamid,guid) VALUES ('%u', '%u')", Id, GUID_LOPART(newmember.guid));
@@ -137,19 +138,23 @@ bool ArenaTeam::AddMember(uint64 PlayerGuid)
{
pl->SetInArenaTeam(Id, GetSlot());
pl->SetArenaTeamIdInvited(0);
+
+ // hide promote/remove buttons
+ if(CaptainGuid != PlayerGuid)
+ pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6), 1);
}
else
{
- Player::SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6), Id, PlayerGuid);
- }
+ Tokens tokens;
+ if(Player::LoadValuesArrayFromDB(tokens,PlayerGuid))
+ {
+ Player::SetUInt32ValueInArray(tokens,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6), Id);
+ // hide promote/remove buttons
+ if(CaptainGuid != PlayerGuid)
+ Player::SetUInt32ValueInArray(tokens,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6), 1);
- // hide promote/remove buttons
- if(CaptainGuid != PlayerGuid)
- {
- if(pl)
- pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6), 1);
- else
- Player::SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6), 1, PlayerGuid);
+ Player::SaveValuesArrayInDB(tokens,PlayerGuid);
+ }
}
return true;
}
@@ -192,12 +197,12 @@ void ArenaTeam::LoadStatsFromDB(uint32 ArenaTeamId)
Field *fields = result->Fetch();
- stats.rating = fields[0].GetUInt32();
- stats.games = fields[1].GetUInt32();
- stats.wins = fields[2].GetUInt32();
- stats.played = fields[3].GetUInt32();
- stats.wins2 = fields[4].GetUInt32();
- stats.rank = fields[5].GetUInt32();
+ stats.rating = fields[0].GetUInt32();
+ stats.games_week = fields[1].GetUInt32();
+ stats.wins_week = fields[2].GetUInt32();
+ stats.games_season = fields[3].GetUInt32();
+ stats.wins_season = fields[4].GetUInt32();
+ stats.rank = fields[5].GetUInt32();
delete result;
}
@@ -216,10 +221,10 @@ void ArenaTeam::LoadMembersFromDB(uint32 ArenaTeamId)
ArenaTeamMember newmember;
newmember.guid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
LoadPlayerStats(&newmember);
- newmember.played_week = fields[1].GetUInt32();
- newmember.wons_week = fields[2].GetUInt32();
- newmember.played_season = fields[3].GetUInt32();
- newmember.wons_season = fields[4].GetUInt32();
+ newmember.games_week = fields[1].GetUInt32();
+ newmember.wins_week = fields[2].GetUInt32();
+ newmember.games_season = fields[3].GetUInt32();
+ newmember.wins_season = fields[4].GetUInt32();
members.push_back(newmember);
}while( result->NextRow() );
delete result;
@@ -337,11 +342,11 @@ void ArenaTeam::Roster(WorldSession *session)
data << uint32(itr->guid == GetCaptain() ? 0 : 1);// unknown
data << uint8(pl->getLevel()); // unknown, probably level
data << uint8(pl->getClass()); // class
- data << uint32(itr->played_week); // played this week
- data << uint32(itr->wons_week); // wins this week
- data << uint32(itr->played_season); // played this season
- data << uint32(itr->wons_season); // wins this season
- data << uint32(0); // personal rating?
+ data << uint32(itr->games_week); // played this week
+ data << uint32(itr->wins_week); // wins this week
+ data << uint32(itr->games_season); // played this season
+ data << uint32(itr->wins_season); // wins this season
+ data << uint32(itr->personal_rating); // personal rating
}
else
{
@@ -351,11 +356,11 @@ void ArenaTeam::Roster(WorldSession *session)
data << uint32(itr->guid == GetCaptain() ? 0 : 1);// unknown
data << uint8(0); // unknown, level?
data << uint8(itr->Class); // class
- data << uint32(itr->played_week); // played this week
- data << uint32(itr->wons_week); // wins this week
- data << uint32(itr->played_season); // played this season
- data << uint32(itr->wons_season); // wins this season
- data << uint32(0); // personal rating?
+ data << uint32(itr->games_week); // played this week
+ data << uint32(itr->wins_week); // wins this week
+ data << uint32(itr->games_season); // played this season
+ data << uint32(itr->wins_season); // wins this season
+ data << uint32(itr->personal_rating); // personal rating
}
}
session->SendPacket(&data);
@@ -382,25 +387,29 @@ void ArenaTeam::Stats(WorldSession *session)
WorldPacket data(SMSG_ARENA_TEAM_STATS, 4*7);
data << uint32(GetId()); // arena team id
data << uint32(stats.rating); // rating
- data << uint32(stats.games); // games
- data << uint32(stats.wins); // wins
- data << uint32(stats.played); // played
- data << uint32(stats.wins2); // wins(again o_O)
+ data << uint32(stats.games_week); // games this week
+ data << uint32(stats.wins_week); // wins this week
+ data << uint32(stats.games_season); // played this season
+ data << uint32(stats.wins_season); // wins this season
data << uint32(stats.rank); // rank
session->SendPacket(&data);
}
void ArenaTeam::InspectStats(WorldSession *session, uint64 guid)
{
+ ArenaTeamMember* member = GetMember(guid);
+ if(!member)
+ return;
+
WorldPacket data(MSG_INSPECT_ARENA_TEAMS, 8+1+4*6);
data << uint64(guid); // player guid
data << uint8(GetSlot()); // slot (0...2)
data << uint32(GetId()); // arena team id
data << uint32(stats.rating); // rating
- data << uint32(stats.games); // games
- data << uint32(stats.wins); // wins
- data << uint32(stats.played); // played (count of all games, that played...)
- data << uint32(0); // 2.3.3 personal rating?
+ data << uint32(stats.games_season); // season played
+ data << uint32(stats.wins_season); // season wins
+ data << member->games_season; // played (count of all games, that the inspected member participated...)
+ data << member->personal_rating; // personal rating
session->SendPacket(&data);
}
@@ -423,20 +432,20 @@ void ArenaTeam::SetStats(uint32 stat_type, uint32 value)
stats.rating = value;
CharacterDatabase.PExecute("UPDATE arena_team_stats SET rating = '%u' WHERE arenateamid = '%u'", value, GetId());
break;
- case STAT_TYPE_GAMES:
- stats.games = value;
+ case STAT_TYPE_GAMES_WEEK:
+ stats.games_week = value;
CharacterDatabase.PExecute("UPDATE arena_team_stats SET games = '%u' WHERE arenateamid = '%u'", value, GetId());
break;
- case STAT_TYPE_WINS:
- stats.wins = value;
+ case STAT_TYPE_WINS_WEEK:
+ stats.wins_week = value;
CharacterDatabase.PExecute("UPDATE arena_team_stats SET wins = '%u' WHERE arenateamid = '%u'", value, GetId());
break;
- case STAT_TYPE_PLAYED:
- stats.played = value;
+ case STAT_TYPE_GAMES_SEASON:
+ stats.games_season = value;
CharacterDatabase.PExecute("UPDATE arena_team_stats SET played = '%u' WHERE arenateamid = '%u'", value, GetId());
break;
- case STAT_TYPE_WINS2:
- stats.wins2 = value;
+ case STAT_TYPE_WINS_SEASON:
+ stats.wins_season = value;
CharacterDatabase.PExecute("UPDATE arena_team_stats SET wins2 = '%u' WHERE arenateamid = '%u'", value, GetId());
break;
case STAT_TYPE_RANK:
@@ -463,7 +472,7 @@ uint8 ArenaTeam::GetSlot() const
void ArenaTeam::BroadcastPacket(WorldPacket *packet)
{
- for (MemberList::iterator itr = members.begin(); itr != members.end(); itr++)
+ for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
{
Player *player = objmgr.GetPlayer(itr->guid);
if(player)
@@ -493,24 +502,35 @@ bool ArenaTeam::HaveMember( uint64 guid ) const
return false;
}
+void ArenaTeam::FinishWeek()
+{
+ stats.games_week = 0; // played this week
+ stats.wins_week = 0; // wins this week
+ for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
+ {
+ itr->games_week = 0;
+ itr->wins_week = 0;
+ }
+}
+
/*
arenateam fields (id from 2.3.3 client):
1414 - arena team id 2v2
1415 - 0=captain, 1=member
-1416 - played this season
-1417 - played this week
+1416 - played this week
+1417 - played this season
1418 - unk
-1419 - unk
+1419 - personal arena rating
1420 - arena team id 3v3
1421 - 0=captain, 1=member
-1422 - played this season
-1423 - played this week
+1422 - played this week
+1423 - played this season
1424 - unk
-1425 - unk
+1425 - personal arena rating
1426 - arena team id 5v5
1427 - 0=captain, 1=member
-1428 - played this season
-1429 - played this week
+1428 - played this week
+1429 - played this season
1430 - unk
-1431 - unk
+1431 - personal arena rating
*/
diff --git a/src/game/ArenaTeam.h b/src/game/ArenaTeam.h
index 0d26b00cf..43adca888 100644
--- a/src/game/ArenaTeam.h
+++ b/src/game/ArenaTeam.h
@@ -66,12 +66,12 @@ ERR_ARENA_TEAM_LEVEL_TOO_LOW_I
enum ArenaTeamStatTypes
{
- STAT_TYPE_RATING = 0,
- STAT_TYPE_GAMES = 1,
- STAT_TYPE_WINS = 2,
- STAT_TYPE_PLAYED = 3,
- STAT_TYPE_WINS2 = 4,
- STAT_TYPE_RANK = 5
+ STAT_TYPE_RATING = 0,
+ STAT_TYPE_GAMES_WEEK = 1,
+ STAT_TYPE_WINS_WEEK = 2,
+ STAT_TYPE_GAMES_SEASON = 3,
+ STAT_TYPE_WINS_SEASON = 4,
+ STAT_TYPE_RANK = 5
};
enum ArenaTeamTypes
@@ -88,19 +88,20 @@ struct ArenaTeamMember
//uint32 unk2;
//uint8 unk1;
uint8 Class;
- uint32 played_week;
- uint32 wons_week;
- uint32 played_season;
- uint32 wons_season;
+ uint32 games_week;
+ uint32 wins_week;
+ uint32 games_season;
+ uint32 wins_season;
+ uint32 personal_rating;
};
struct ArenaTeamStats
{
uint32 rating;
- uint32 games;
- uint32 wins;
- uint32 played;
- uint32 wins2;
+ uint32 games_week;
+ uint32 wins_week;
+ uint32 games_season;
+ uint32 wins_season;
uint32 rank;
};
@@ -123,7 +124,7 @@ class ArenaTeam
static uint8 GetSlotByType(uint32 type);
const uint64& GetCaptain() const { return CaptainGuid; }
std::string GetName() const { return Name; }
- ArenaTeamStats GetStats() const { return stats; }
+ const ArenaTeamStats& GetStats() const { return stats; }
void SetStats(uint32 stat_type, uint32 value);
uint32 GetRating() const { return stats.rating; }
@@ -143,6 +144,22 @@ class ArenaTeam
MemberList::iterator membersbegin(){ return members.begin(); }
MemberList::iterator membersEnd(){ return members.end(); }
bool HaveMember(uint64 guid) const;
+ ArenaTeamMember* GetMember(uint64 guid)
+ {
+ for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
+ if(itr->guid==guid)
+ return &(*itr);
+
+ return NULL;
+ }
+ ArenaTeamMember* GetMember(std::string& name)
+ {
+ for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
+ if(itr->name==name)
+ return &(*itr);
+
+ return NULL;
+ }
bool LoadArenaTeamFromDB(uint32 ArenaTeamId);
void LoadMembersFromDB(uint32 ArenaTeamId);
@@ -156,6 +173,8 @@ class ArenaTeam
void Stats(WorldSession *session);
void InspectStats(WorldSession *session, uint64 guid);
+ void FinishWeek();
+
protected:
uint32 Id;
diff --git a/src/game/ArenaTeamHandler.cpp b/src/game/ArenaTeamHandler.cpp
index c6b9059e7..7cab8d085 100644
--- a/src/game/ArenaTeamHandler.cpp
+++ b/src/game/ArenaTeamHandler.cpp
@@ -289,25 +289,8 @@ void WorldSession::HandleArenaTeamRemoveFromTeamOpcode(WorldPacket & recv_data)
recv_data >> name;
ArenaTeam *at = objmgr.GetArenaTeamById(ArenaTeamId);
- if(!at)
- {
- // arena team not found
+ if(!at) // arena team not found
return;
- }
-
- uint64 guid = objmgr.GetPlayerGUIDByName(name);
- if(!guid)
- {
- // player guid not found
- return;
- }
-
- if(at->GetCaptain() == guid)
- {
- // unsure
- SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PERMISSIONS);
- return;
- }
if(at->GetCaptain() != _player->GetGUID())
{
@@ -315,13 +298,20 @@ void WorldSession::HandleArenaTeamRemoveFromTeamOpcode(WorldPacket & recv_data)
return;
}
- if(at->GetCaptain() == guid)
+ if(!normalizePlayerName(name))
+ return;
+
+ ArenaTeamMember* member = at->GetMember(name);
+ if(!member) // member not found
+ return;
+
+ if(at->GetCaptain() == member->guid)
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_LEADER_LEAVE_S);
return;
}
- at->DelMember(guid);
+ at->DelMember(member->guid);
// event
WorldPacket data;
@@ -343,24 +333,8 @@ void WorldSession::HandleArenaTeamPromoteToCaptainOpcode(WorldPacket & recv_data
recv_data >> name;
ArenaTeam *at = objmgr.GetArenaTeamById(ArenaTeamId);
- if(!at)
- {
- // arena team not found
+ if(!at) // arena team not found
return;
- }
-
- uint64 guid = objmgr.GetPlayerGUIDByName(name);
- if(!guid)
- {
- // player guid not found
- return;
- }
-
- if(at->GetCaptain() == guid)
- {
- // target player already captain
- return;
- }
if(at->GetCaptain() != _player->GetGUID())
{
@@ -368,7 +342,17 @@ void WorldSession::HandleArenaTeamPromoteToCaptainOpcode(WorldPacket & recv_data
return;
}
- at->SetCaptain(guid);
+ if(!normalizePlayerName(name))
+ return;
+
+ ArenaTeamMember* member = at->GetMember(name);
+ if(!member) // member not found
+ return;
+
+ if(at->GetCaptain() == member->guid) // target player already captain
+ return;
+
+ at->SetCaptain(member->guid);
// event
WorldPacket data;
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index 2781ef6e2..1a3d70fb6 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -709,14 +709,21 @@ void BattleGround::AddPlayer(Player *plr)
plr->RemoveArenaSpellCooldowns();
//plr->RemoveArenaAuras();
plr->RemoveAllEnchantments(TEMP_ENCHANTMENT_SLOT);
- if(team == ALLIANCE && plr->GetTeam() == ALLIANCE)
- plr->CastSpell(plr,SPELL_ALLIANCE_GOLD_FLAG,true);
- else if(team == HORDE && plr->GetTeam() == ALLIANCE)
- plr->CastSpell(plr,SPELL_ALLIANCE_GREEN_FLAG,true);
- else if(team == ALLIANCE && plr->GetTeam() == HORDE)
- plr->CastSpell(plr,SPELL_HORDE_GOLD_FLAG,true);
- else
- plr->CastSpell(plr,SPELL_HORDE_GREEN_FLAG,true);
+ if(team == ALLIANCE) // gold
+ {
+ if(plr->GetTeam() == HORDE)
+ plr->CastSpell(plr, SPELL_HORDE_GOLD_FLAG,true);
+ else
+ plr->CastSpell(plr, SPELL_ALLIANCE_GOLD_FLAG,true);
+ }
+ else // green
+ {
+ if(plr->GetTeam() == HORDE)
+ plr->CastSpell(plr, SPELL_HORDE_GREEN_FLAG,true);
+ else
+ plr->CastSpell(plr, SPELL_ALLIANCE_GREEN_FLAG,true);
+ }
+
plr->DestroyConjuredItems(true);
if(GetStatus() == STATUS_WAIT_JOIN) // not started yet
diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp
index 5cee001fa..9c3350bd1 100644
--- a/src/game/BattleGroundMgr.cpp
+++ b/src/game/BattleGroundMgr.cpp
@@ -103,13 +103,13 @@ void BattleGroundQueue::AddPlayer(Player *plr, uint32 bgTypeId)
if(sWorld.getConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
{
ChatHandler(plr).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF,
- bgName, q_min_level, q_max_level, qAlliance, MinPlayers - qAlliance, qHorde, MinPlayers - qHorde);
+ bgName, q_min_level, q_max_level, qAlliance, (MinPlayers > qAlliance) ? (MinPlayers - qAlliance) : 0, qHorde, (MinPlayers > qHorde) ? (MinPlayers - qHorde) : 0);
}
// System message
else
{
sWorld.SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD,
- bgName, q_min_level, q_max_level, qAlliance, MinPlayers - qAlliance, qHorde, MinPlayers - qHorde);
+ bgName, q_min_level, q_max_level, qAlliance, (MinPlayers > qAlliance) ? (MinPlayers - qAlliance) : 0, qHorde, (MinPlayers > qHorde) ? (MinPlayers - qHorde) : 0);
}
}
}
diff --git a/src/game/Channel.cpp b/src/game/Channel.cpp
index ca7c8ff3e..2fb8b5d09 100644
--- a/src/game/Channel.cpp
+++ b/src/game/Channel.cpp
@@ -209,7 +209,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
@@ -258,7 +258,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);
diff --git a/src/game/Channel.h b/src/game/Channel.h
index 31e196948..fc87efdd0 100644
--- a/src/game/Channel.h
+++ b/src/game/Channel.h
@@ -147,7 +147,7 @@ class Channel
typedef std::map PlayerList;
PlayerList players;
- typedef std::list BannedList;
+ typedef std::set BannedList;
BannedList banned;
bool m_announce;
bool m_moderate;
@@ -202,15 +202,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); }
diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index 33f653dae..8880a7b2e 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -156,18 +156,20 @@ void WorldSession::HandleCharEnumOpcode( WorldPacket & /*recv_data*/ )
// ------- Query Without Declined Names --------
// 0 1 2 3 4 5 6 7 8
"SELECT characters.guid, characters.data, characters.name, characters.position_x, characters.position_y, characters.position_z, characters.map, characters.totaltime, characters.leveltime, "
- // 9 10 11 12
- "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level "
+ // 9 10 11 12 13
+ "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, guild_member.guildid "
"FROM characters LEFT JOIN character_pet ON characters.guid=character_pet.owner AND character_pet.slot='0' "
+ "LEFT JOIN guild_member ON characters.guid = guild_member.guid "
"WHERE characters.account = '%u' ORDER BY characters.guid"
:
// --------- Query With Declined Names ---------
// 0 1 2 3 4 5 6 7 8
"SELECT characters.guid, characters.data, characters.name, characters.position_x, characters.position_y, characters.position_z, characters.map, characters.totaltime, characters.leveltime, "
- // 9 10 11 12 13
- "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, genitive "
+ // 9 10 11 12 13 14
+ "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, guild_member.guildid, genitive "
"FROM characters LEFT JOIN character_pet ON characters.guid = character_pet.owner AND character_pet.slot='0' "
"LEFT JOIN character_declinedname ON characters.guid = character_declinedname.guid "
+ "LEFT JOIN guild_member ON characters.guid = guild_member.guid "
"WHERE characters.account = '%u' ORDER BY characters.guid",
GetAccountId());
}
@@ -540,6 +542,22 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
DEBUG_LOG( "WORLD: Sent motd (SMSG_MOTD)" );
}
+ //QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
+ QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
+
+ if(resultGuild)
+ {
+ Field *fields = resultGuild->Fetch();
+ pCurrChar->SetInGuild(fields[0].GetUInt32());
+ pCurrChar->SetRank(fields[1].GetUInt32());
+ delete resultGuild;
+ }
+ else if(pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership
+ {
+ pCurrChar->SetInGuild(0);
+ pCurrChar->SetRank(0);
+ }
+
if(pCurrChar->GetGuildId() != 0)
{
Guild* guild = objmgr.GetGuildById(pCurrChar->GetGuildId());
@@ -567,8 +585,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
{
// remove wrong guild data
sLog.outError("Player %s (GUID: %u) marked as member not existed guild (id: %u), removing guild membership for player.",pCurrChar->GetName(),pCurrChar->GetGUIDLow(),pCurrChar->GetGuildId());
- pCurrChar->SetUInt32Value(PLAYER_GUILDID,0);
- pCurrChar->SetUInt32ValueInDB(PLAYER_GUILDID,0,pCurrChar->GetGUID());
+ pCurrChar->SetInGuild(0);
}
}
@@ -591,22 +608,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
}
}
- //QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
- QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
-
- if(resultGuild)
- {
- Field *fields = resultGuild->Fetch();
- pCurrChar->SetInGuild(fields[0].GetUInt32());
- pCurrChar->SetRank(fields[1].GetUInt32());
- delete resultGuild;
- }
- else if(pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership
- {
- pCurrChar->SetInGuild(0);
- pCurrChar->SetRank(0);
- }
-
if (!pCurrChar->GetMap()->Add(pCurrChar))
{
AreaTrigger const* at = objmgr.GetGoBackTrigger(pCurrChar->GetMapId());
@@ -640,7 +641,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...
@@ -745,6 +745,9 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
if(sWorld.IsShutdowning())
sWorld.ShutdownMsg(true,pCurrChar);
+ if(sWorld.getConfig(CONFIG_ALL_TAXI_PATHS))
+ pCurrChar->SetTaxiCheater(true);
+
if(pCurrChar->isGameMaster())
SendNotification(LANG_GM_ON);
@@ -901,23 +904,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;
@@ -925,10 +913,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/Corpse.cpp b/src/game/Corpse.cpp
index b1c096281..cacd7deac 100644
--- a/src/game/Corpse.cpp
+++ b/src/game/Corpse.cpp
@@ -209,5 +209,5 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
bool Corpse::isVisibleForInState(Player const* u, bool inVisibleList) const
{
- return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f));
+ return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
}
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 8def022a8..8ab1b3258 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -446,6 +446,11 @@ void Creature::Update(uint32 diff)
m_regenTimer = 2000;
break;
}
+ case DEAD_FALLING:
+ {
+ if (!FallGround())
+ setDeathState(JUST_DIED);
+ }
default:
break;
}
@@ -689,7 +694,7 @@ void Creature::prepareGossipMenu( Player *pPlayer,uint32 gossipid )
// lazy loading single time at use
LoadGossipOptions();
- for( GossipOptionList::iterator i = m_goptions.begin( ); i != m_goptions.end( ); i++ )
+ for( GossipOptionList::iterator i = m_goptions.begin( ); i != m_goptions.end( ); ++i )
{
GossipOption* gso=&*i;
if(gso->GossipId == gossipid)
@@ -921,44 +926,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)
{
@@ -975,8 +943,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() );
}
}
@@ -1009,7 +978,7 @@ uint32 Creature::GetNpcTextId()
GossipOption const* Creature::GetGossipOption( uint32 id ) const
{
- for( GossipOptionList::const_iterator i = m_goptions.begin( ); i != m_goptions.end( ); i++ )
+ for( GossipOptionList::const_iterator i = m_goptions.begin( ); i != m_goptions.end( ); ++i )
{
if(i->Action==id )
return &*i;
@@ -1340,7 +1309,15 @@ bool Creature::LoadFromDB(uint32 guid, Map *map)
m_respawnTime = objmgr.GetCreatureRespawnTime(m_DBTableGuid,GetInstanceId());
if(m_respawnTime > time(NULL)) // not ready to respawn
+ {
m_deathState = DEAD;
+ if(canFly())
+ {
+ float tz = GetMap()->GetHeight(data->posX,data->posY,data->posZ,false);
+ if(data->posZ - tz > 0.1)
+ Relocate(data->posX,data->posY,tz);
+ }
+ }
else if(m_respawnTime) // respawn time set but expired
{
m_respawnTime = 0;
@@ -1487,6 +1464,9 @@ void Creature::setDeathState(DeathState s)
if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY) || isWorldBoss())
SaveRespawnTime();
+ if (canFly() && FallGround())
+ return;
+
if(!IsStopped())
StopMoving();
}
@@ -1501,6 +1481,9 @@ void Creature::setDeathState(DeathState s)
if ( LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId) )
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
+ if (canFly() && FallGround())
+ return;
+
Unit::setDeathState(CORPSE);
}
if(s == JUST_ALIVED)
@@ -1520,6 +1503,25 @@ void Creature::setDeathState(DeathState s)
}
}
+bool Creature::FallGround()
+{
+ // Let's abort after we called this function one time
+ if (getDeathState() == DEAD_FALLING)
+ return false;
+
+ // Let's do with no vmap because no way to get far distance with vmap high call
+ float tz = GetMap()->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), false);
+
+ // Abort too if the ground is very near
+ if (fabs(GetPositionZ() - tz) < 0.1f)
+ return false;
+
+ Unit::setDeathState(DEAD_FALLING);
+ GetMotionMaster()->MovePoint(0, GetPositionX(), GetPositionY(), tz);
+ Relocate(GetPositionX(), GetPositionY(), tz);
+ return true;
+}
+
void Creature::Respawn()
{
RemoveCorpse();
@@ -1775,7 +1777,7 @@ bool Creature::IsOutOfThreatArea(Unit* pVictim) const
if(!pVictim->isInAccessablePlaceFor(this))
return true;
- if(sMapStore.LookupEntry(GetMapId())->Instanceable())
+ if(sMapStore.LookupEntry(GetMapId())->IsDungeon())
return false;
float length = pVictim->GetDistance(CombatStartX,CombatStartY,CombatStartZ);
diff --git a/src/game/Creature.h b/src/game/Creature.h
index 98f54017e..01111568a 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -218,7 +218,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);
}
};
@@ -521,6 +521,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
const char* GetNameForLocaleIdx(int32 locale_idx) const;
void setDeathState(DeathState s); // overwrite virtual Unit::setDeathState
+ bool FallGround();
bool LoadFromDB(uint32 guid, Map *map);
void SaveToDB();
diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp
index 7e6d2a88f..a73ffecc8 100644
--- a/src/game/DynamicObject.cpp
+++ b/src/game/DynamicObject.cpp
@@ -148,5 +148,5 @@ void DynamicObject::Delay(int32 delaytime)
bool DynamicObject::isVisibleForInState(Player const* u, bool inVisibleList) const
{
- return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f));
+ return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
}
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index a1677f972..ab412dcf2 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -190,7 +190,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;
@@ -723,7 +723,7 @@ bool GameObject::isVisibleForInState(Player const* u, bool inVisibleList) const
// check distance
return IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject() +
- (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f) );
+ (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
}
void GameObject::Respawn()
diff --git a/src/game/GlobalEvents.cpp b/src/game/GlobalEvents.cpp
index 14ad25607..219086c61 100644
--- a/src/game/GlobalEvents.cpp
+++ b/src/game/GlobalEvents.cpp
@@ -22,6 +22,7 @@
#include "Log.h"
#include "Database/DatabaseEnv.h"
+#include "Database/DatabaseImpl.h"
#include "Platform/Define.h"
#include "MapManager.h"
#include "ObjectAccessor.h"
@@ -29,49 +30,52 @@
#include "ObjectDefines.h"
#include "Corpse.h"
+static void CorpsesEraseCallBack(QueryResult *result, bool bones)
+{
+ if(!result)
+ return;
+
+ do
+ {
+ Field *fields = result->Fetch();
+ uint32 guidlow = fields[0].GetUInt32();
+ float positionX = fields[1].GetFloat();
+ float positionY = fields[2].GetFloat();
+ uint32 mapid = fields[3].GetUInt32();
+ uint64 player_guid = MAKE_NEW_GUID(fields[4].GetUInt32(), 0, HIGHGUID_PLAYER);
+
+ uint64 guid = MAKE_NEW_GUID(guidlow, 0, HIGHGUID_CORPSE);
+
+ sLog.outDebug("[Global event] Removing %s %u (X:%f Y:%f Map:%u).",(bones?"bones":"corpse"),guidlow,positionX,positionY,mapid);
+
+ /// Resurrectable - convert corpses to bones
+ if(!bones)
+ {
+ if(!ObjectAccessor::Instance().ConvertCorpseForPlayer(player_guid))
+ {
+ sLog.outDebug("Corpse %u not found in world. Delete from DB.",guidlow);
+ CharacterDatabase.PExecute("DELETE FROM corpse WHERE guid = '%u'",guidlow);
+ }
+ }
+ else
+ ///- or delete bones
+ {
+ MapManager::Instance().RemoveBonesFromMap(mapid, guid, positionX, positionY);
+
+ ///- remove bones from the database
+ CharacterDatabase.PExecute("DELETE FROM corpse WHERE guid = '%u'",guidlow);
+ }
+ } while (result->NextRow());
+
+ delete result;
+}
+
/// Handle periodic erase of corpses and bones
static void CorpsesErase(bool bones,uint32 delay)
{
///- Get the list of eligible corpses/bones to be removed
//No SQL injection (uint32 and enum)
- QueryResult *result = CharacterDatabase.PQuery("SELECT guid,position_x,position_y,map,player FROM corpse WHERE UNIX_TIMESTAMP()-time > '%u' AND corpse_type %s '0'", delay, (bones ? "=" : "<>") );
-
- if(result)
- {
- do
- {
- Field *fields = result->Fetch();
- uint32 guidlow = fields[0].GetUInt32();
- float positionX = fields[1].GetFloat();
- float positionY = fields[2].GetFloat();
- uint32 mapid = fields[3].GetUInt32();
- uint64 player_guid = MAKE_NEW_GUID(fields[4].GetUInt32(), 0, HIGHGUID_PLAYER);
-
- uint64 guid = MAKE_NEW_GUID(guidlow, 0, HIGHGUID_CORPSE);
-
- sLog.outDebug("[Global event] Removing %s %u (X:%f Y:%f Map:%u).",(bones?"bones":"corpse"),guidlow,positionX,positionY,mapid);
-
- /// Resurrectable - convert corpses to bones
- if(!bones)
- {
- if(!ObjectAccessor::Instance().ConvertCorpseForPlayer(player_guid))
- {
- sLog.outDebug("Corpse %u not found in world. Delete from DB.",guidlow);
- CharacterDatabase.PExecute("DELETE FROM corpse WHERE guid = '%u'",guidlow);
- }
- }
- else
- ///- or delete bones
- {
- MapManager::Instance().RemoveBonesFromMap(mapid, guid, positionX, positionY);
-
- ///- remove bones from the database
- CharacterDatabase.PExecute("DELETE FROM corpse WHERE guid = '%u'",guidlow);
- }
- } while (result->NextRow());
-
- delete result;
- }
+ CharacterDatabase.AsyncPQuery(&CorpsesEraseCallBack, bones, "SELECT guid,position_x,position_y,map,player FROM corpse WHERE UNIX_TIMESTAMP()-time > '%u' AND corpse_type %s '0'", delay, (bones ? "=" : "<>"));
}
/// not thread guarded variant for call from other thread
diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp
index 173e69f66..a690254e2 100644
--- a/src/game/GossipDef.cpp
+++ b/src/game/GossipDef.cpp
@@ -128,26 +128,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++ )
{
@@ -155,7 +149,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();
@@ -332,7 +326,7 @@ void QuestMenu::AddMenuItem( uint32 QuestId, uint8 Icon)
bool QuestMenu::HasItem( uint32 questid )
{
- for (QuestMenuItemList::iterator i = m_qItems.begin(); i != m_qItems.end(); i++)
+ for (QuestMenuItemList::iterator i = m_qItems.begin(); i != m_qItems.end(); ++i)
{
if(i->m_qId==questid)
{
@@ -381,8 +375,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 )
@@ -392,7 +385,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 )
@@ -462,6 +455,7 @@ void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID
else
data << uint32(0);
}
+
data << uint32(pQuest->GetRewOrReqMoney());
}
@@ -479,7 +473,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 )
@@ -760,8 +754,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/GridDefines.h b/src/game/GridDefines.h
index 0942c5c31..ced42871b 100644
--- a/src/game/GridDefines.h
+++ b/src/game/GridDefines.h
@@ -41,10 +41,10 @@ class Player;
#define MIN_GRID_DELAY MINUTE*1000
#define MIN_MAP_UPDATE_DELAY 50
-#define MAX_NUMBER_OF_CELLS 8
+#define MAX_NUMBER_OF_CELLS 4
#define SIZE_OF_GRID_CELL (SIZE_OF_GRIDS/MAX_NUMBER_OF_CELLS)
-#define CENTER_GRID_CELL_ID 256
+#define CENTER_GRID_CELL_ID 128
#define CENTER_GRID_CELL_OFFSET (SIZE_OF_GRID_CELL/2)
#define TOTAL_NUMBER_OF_CELLS_PER_MAP (MAX_NUMBER_OF_GRIDS*MAX_NUMBER_OF_CELLS)
diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h
index 05eb46197..602d3d247 100644
--- a/src/game/GridNotifiersImpl.h
+++ b/src/game/GridNotifiersImpl.h
@@ -70,7 +70,7 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c)
pl->UpdateVisibilityOf(c);
// Creature AI reaction
- if(!c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
+ if(!c->hasUnitState(UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
{
if( c->AI() && c->AI()->IsVisible(pl) && !c->IsInEvadeMode() )
c->AI()->MoveInLineOfSight(pl);
@@ -79,13 +79,13 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c)
inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2)
{
- if(!c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
+ if(!c1->hasUnitState(UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
{
if( c1->AI() && c1->AI()->IsVisible(c2) && !c1->IsInEvadeMode() )
c1->AI()->MoveInLineOfSight(c2);
}
- if(!c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
+ if(!c2->hasUnitState(UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
{
if( c2->AI() && c2->AI()->IsVisible(c1) && !c2->IsInEvadeMode() )
c2->AI()->MoveInLineOfSight(c1);
diff --git a/src/game/Group.cpp b/src/game/Group.cpp
index cb03edabd..de97b70b3 100644
--- a/src/game/Group.cpp
+++ b/src/game/Group.cpp
@@ -212,7 +212,7 @@ bool Group::AddInvite(Player *player)
RemoveInvite(player);
- m_invitees.insert(player->GetGUID());
+ m_invitees.insert(player);
player->SetGroupInvite(this);
@@ -231,14 +231,7 @@ bool Group::AddLeaderInvite(Player *player)
uint32 Group::RemoveInvite(Player *player)
{
- for(InvitesList::iterator itr=m_invitees.begin(); itr!=m_invitees.end(); ++itr)
- {
- if((*itr) == player->GetGUID())
- {
- m_invitees.erase(itr);
- break;
- }
- }
+ m_invitees.erase(player);
player->SetGroupInvite(NULL);
return GetMembersCount();
@@ -247,14 +240,31 @@ uint32 Group::RemoveInvite(Player *player)
void Group::RemoveAllInvites()
{
for(InvitesList::iterator itr=m_invitees.begin(); itr!=m_invitees.end(); ++itr)
- {
- Player *invitee = objmgr.GetPlayer(*itr);
- if(invitee)
- invitee->SetGroupInvite(NULL);
- }
+ (*itr)->SetGroupInvite(NULL);
+
m_invitees.clear();
}
+Player* Group::GetInvited(const uint64& guid) const
+{
+ for(InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr)
+ {
+ if((*itr)->GetGUID() == guid)
+ return (*itr);
+ }
+ return NULL;
+}
+
+Player* Group::GetInvited(const std::string& name) const
+{
+ for(InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr)
+ {
+ if((*itr)->GetName() == name)
+ return (*itr);
+ }
+ return NULL;
+}
+
bool Group::AddMember(const uint64 &guid, const char* name)
{
if(!_addMember(guid, name))
@@ -1109,7 +1119,7 @@ void Group::_setLeader(const uint64 &guid)
void Group::_removeRolls(const uint64 &guid)
{
- for (Rolls::iterator it = RollId.begin(); it < RollId.end(); it++)
+ for (Rolls::iterator it = RollId.begin(); it < RollId.end(); ++it)
{
Roll* roll = *it;
Roll::PlayerVote::iterator itr2 = roll->playerVote.find(guid);
diff --git a/src/game/Group.h b/src/game/Group.h
index 6160fd0f2..a9e6a733f 100644
--- a/src/game/Group.h
+++ b/src/game/Group.h
@@ -143,7 +143,7 @@ class MANGOS_DLL_SPEC Group
typedef UNORDERED_MAP< uint32 /*mapId*/, InstanceGroupBind> BoundInstancesMap;
protected:
typedef MemberSlotList::iterator member_witerator;
- typedef std::set InvitesList;
+ typedef std::set InvitesList;
typedef std::vector Rolls;
@@ -183,6 +183,17 @@ class MANGOS_DLL_SPEC Group
// member manipulation methods
bool IsMember(const uint64& guid) const { return _getMemberCSlot(guid) != m_memberSlots.end(); }
bool IsLeader(const uint64& guid) const { return (GetLeaderGUID() == guid); }
+ uint64 GetMemberGUID(const std::string& name)
+ {
+ for(member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
+ {
+ if(itr->name == name)
+ {
+ return itr->guid;
+ }
+ }
+ return 0;
+ }
bool IsAssistant(uint64 guid) const
{
member_citerator mslot = _getMemberCSlot(guid);
@@ -191,6 +202,8 @@ class MANGOS_DLL_SPEC Group
return mslot->assistant;
}
+ Player* GetInvited(const uint64& guid) const;
+ Player* GetInvited(const std::string& name) const;
bool SameSubGroup(uint64 guid1,const uint64& guid2) const
{
diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp
index ad56314e7..2d05e6655 100644
--- a/src/game/GroupHandler.cpp
+++ b/src/game/GroupHandler.cpp
@@ -42,7 +42,7 @@
-FIX sending PartyMemberStats
*/
-void WorldSession::SendPartyResult(PartyOperation operation, std::string member, PartyResult res)
+void WorldSession::SendPartyResult(PartyOperation operation, const std::string& member, PartyResult res)
{
WorldPacket data(SMSG_PARTY_COMMAND_RESULT, (8+member.size()+1));
data << (uint32)operation;
@@ -246,17 +246,37 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data)
uint64 guid;
recv_data >> guid;
- if(_player->InBattleGround())
+ //can't uninvite yourself
+ if(guid == GetPlayer()->GetGUID())
{
- SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_INVITE_RESTRICTED);
+ sLog.outError("WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
return;
}
- std::string membername;
- if(!objmgr.GetPlayerNameByGUID(guid, membername))
- return; // not found
+ PartyResult res = GetPlayer()->CanUninviteFromGroup();
+ if(res != PARTY_RESULT_OK)
+ {
+ SendPartyResult(PARTY_OP_LEAVE, "", res);
+ return;
+ }
- HandleGroupUninvite(guid, membername);
+ Group* grp = GetPlayer()->GetGroup();
+ if(!grp)
+ return;
+
+ if(grp->IsMember(guid))
+ {
+ Player::RemoveFromGroup(grp,guid);
+ return;
+ }
+
+ if(Player* plr = grp->GetInvited(guid))
+ {
+ plr->UninviteFromGroup();
+ return;
+ }
+
+ SendPartyResult(PARTY_OP_LEAVE, "", PARTY_RESULT_NOT_IN_YOUR_PARTY);
}
void WorldSession::HandleGroupUninviteNameOpcode(WorldPacket & recv_data)
@@ -266,65 +286,41 @@ void WorldSession::HandleGroupUninviteNameOpcode(WorldPacket & recv_data)
std::string membername;
recv_data >> membername;
- if(_player->InBattleGround())
- {
- SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_INVITE_RESTRICTED);
- return;
- }
-
// player not found
if(!normalizePlayerName(membername))
return;
- uint64 guid = objmgr.GetPlayerGUIDByName(membername);
-
- // player not found
- if(!guid)
- return;
-
- HandleGroupUninvite(guid, membername);
-}
-
-void WorldSession::HandleGroupUninvite(uint64 guid, std::string name)
-{
- Group *group = GetPlayer()->GetGroup();
- if(!group)
- return;
-
- if(_player->InBattleGround())
+ // can't uninvite yourself
+ if(GetPlayer()->GetName() == membername)
{
- SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_INVITE_RESTRICTED);
+ sLog.outError("WorldSession::HandleGroupUninviteNameOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
return;
}
- Player *player = objmgr.GetPlayer(guid);
-
- /** error handling **/
- if(!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
+ PartyResult res = GetPlayer()->CanUninviteFromGroup();
+ if(res != PARTY_RESULT_OK)
{
- SendPartyResult(PARTY_OP_LEAVE, "", PARTY_RESULT_YOU_NOT_LEADER);
+ SendPartyResult(PARTY_OP_LEAVE, "", res);
return;
}
- if(!group->IsMember(guid) && (player && player->GetGroupInvite() != group))
+ Group* grp = GetPlayer()->GetGroup();
+ if(!grp)
+ return;
+
+ if(uint64 guid = grp->GetMemberGUID(membername))
{
- SendPartyResult(PARTY_OP_LEAVE, name, PARTY_RESULT_NOT_IN_YOUR_PARTY);
+ Player::RemoveFromGroup(grp,guid);
return;
}
- if(guid == GetPlayer()->GetGUID())
+ if(Player* plr = grp->GetInvited(membername))
{
- sLog.outError("WorldSession::HandleGroupUninvite: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
+ plr->UninviteFromGroup();
return;
}
- /********************/
- // everything's fine, do it
-
- if(player && player->GetGroupInvite()) // uninvite invitee
- player->UninviteFromGroup();
- else // uninvite member
- Player::RemoveFromGroup(group,guid);
+ SendPartyResult(PARTY_OP_LEAVE, membername, PARTY_RESULT_NOT_IN_YOUR_PARTY);
}
void WorldSession::HandleGroupSetLeaderOpcode( WorldPacket & recv_data )
diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp
index 77bce20b0..19f6214b8 100644
--- a/src/game/Guild.cpp
+++ b/src/game/Guild.cpp
@@ -143,17 +143,13 @@ bool Guild::AddMember(uint64 plGuid, uint32 plRank)
CharacterDatabase.PExecute("INSERT INTO guild_member (guildid,guid,rank,pnote,offnote) VALUES ('%u', '%u', '%u','%s','%s')",
Id, GUID_LOPART(plGuid), newmember.RankId, dbPnote.c_str(), dbOFFnote.c_str());
+ // If player not in game data in data field will be loaded from guild tables, no need to update it!!
if(pl)
{
pl->SetInGuild(Id);
pl->SetRank(newmember.RankId);
pl->SetGuildIdInvited(0);
}
- else
- {
- Player::SetUInt32ValueInDB(PLAYER_GUILDID, Id, plGuid);
- Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, newmember.RankId, plGuid);
- }
return true;
}
@@ -421,69 +417,64 @@ void Guild::DelMember(uint64 guid, bool isDisbanding)
{
if(leaderGuid == guid && !isDisbanding)
{
- QueryResult *result = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid='%u' AND guid != '%u' ORDER BY rank ASC LIMIT 1", Id, GUID_LOPART(leaderGuid));
- if( result )
+ MemberSlot* oldLeader = NULL;
+ MemberSlot* best = NULL;
+ uint64 newLeaderGUID = 0;
+ for(Guild::MemberList::iterator i = members.begin(); i != members.end(); ++i)
{
- uint64 newLeaderGUID;
- Player *newLeader;
- std::string newLeaderName, oldLeaderName;
-
- newLeaderGUID = (*result)[0].GetUInt64();
- delete result;
-
- SetLeader(newLeaderGUID);
-
- newLeader = objmgr.GetPlayer(newLeaderGUID);
- if(newLeader)
+ if(i->first == GUID_LOPART(guid))
{
- newLeader->SetRank(GR_GUILDMASTER);
- newLeaderName = newLeader->GetName();
- }
- else
- {
- Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, GR_GUILDMASTER, newLeaderGUID);
- objmgr.GetPlayerNameByGUID(newLeaderGUID, newLeaderName);
+ oldLeader = &(i->second);
+ continue;
}
- // when leader non-exist (at guild load with deleted leader only) not send broadcasts
- if(objmgr.GetPlayerNameByGUID(guid, oldLeaderName))
+ if(!best || best->RankId > i->second.RankId)
{
- WorldPacket data(SMSG_GUILD_EVENT, (1+1+oldLeaderName.size()+1+newLeaderName.size()+1));
- data << (uint8)GE_LEADER_CHANGED;
- data << (uint8)2;
- data << oldLeaderName;
- data << newLeaderName;
- BroadcastPacket(&data);
-
- data.Initialize(SMSG_GUILD_EVENT, (1+1+oldLeaderName.size()+1));
- data << (uint8)GE_LEFT;
- data << (uint8)1;
- data << oldLeaderName;
- BroadcastPacket(&data);
+ best = &(i->second);
+ newLeaderGUID = i->first;
}
-
- sLog.outDebug( "WORLD: Sent (SMSG_GUILD_EVENT)" );
}
- else
+ if(!best)
{
Disband();
return;
}
+
+ SetLeader(newLeaderGUID);
+
+ // If player not online data in data field will be loaded from guild tabs no need to update it !!
+ if(Player *newLeader = objmgr.GetPlayer(newLeaderGUID))
+ newLeader->SetRank(GR_GUILDMASTER);
+
+ // when leader non-exist (at guild load with deleted leader only) not send broadcasts
+ if(oldLeader)
+ {
+ WorldPacket data(SMSG_GUILD_EVENT, (1+1+(oldLeader->name).size()+1+(best->name).size()+1));
+ data << (uint8)GE_LEADER_CHANGED;
+ data << (uint8)2;
+ data << oldLeader->name;
+ data << best->name;
+ BroadcastPacket(&data);
+
+ data.Initialize(SMSG_GUILD_EVENT, (1+1+(oldLeader->name).size()+1));
+ data << (uint8)GE_LEFT;
+ data << (uint8)1;
+ data << oldLeader->name;
+ BroadcastPacket(&data);
+ }
+
+ sLog.outDebug( "WORLD: Sent (SMSG_GUILD_EVENT)" );
}
members.erase(GUID_LOPART(guid));
Player *player = objmgr.GetPlayer(guid);
+ // If player not online data in data field will be loaded from guild tabs no need to update it !!
if(player)
{
player->SetInGuild(0);
player->SetRank(0);
}
- else
- {
- Player::SetUInt32ValueInDB(PLAYER_GUILDID, 0, guid);
- Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, GR_GUILDMASTER, guid);
- }
CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", GUID_LOPART(guid));
}
@@ -495,10 +486,9 @@ void Guild::ChangeRank(uint64 guid, uint32 newRank)
itr->second.RankId = newRank;
Player *player = objmgr.GetPlayer(guid);
+ // If player not online data in data field will be loaded from guild tabs no need to update it !!
if(player)
player->SetRank(newRank);
- else
- Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, newRank, guid);
CharacterDatabase.PExecute( "UPDATE guild_member SET rank='%u' WHERE guid='%u'", newRank, GUID_LOPART(guid) );
}
diff --git a/src/game/Guild.h b/src/game/Guild.h
index 31da4438a..a97a8cfb0 100644
--- a/src/game/Guild.h
+++ b/src/game/Guild.h
@@ -329,7 +329,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)
{
diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp
index 80417c0f3..d40bb9b4d 100644
--- a/src/game/GuildHandler.cpp
+++ b/src/game/GuildHandler.cpp
@@ -977,7 +977,7 @@ void WorldSession::HandleGuildBankDeposit( WorldPacket & recv_data )
pGuild->SetBankMoney(pGuild->GetGuildBankMoney()+money);
GetPlayer()->ModifyMoney(-int(money));
- GetPlayer()->SaveGoldToDB();
+ GetPlayer()->SaveDataFieldToDB(); //contains money
CharacterDatabase.CommitTransaction();
@@ -1033,7 +1033,7 @@ void WorldSession::HandleGuildBankWithdraw( WorldPacket & recv_data )
}
GetPlayer()->ModifyMoney(money);
- GetPlayer()->SaveGoldToDB();
+ GetPlayer()->SaveDataFieldToDB(); // contains money
CharacterDatabase.CommitTransaction();
diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp
index 2f1833480..8fa06c3cb 100644
--- a/src/game/InstanceSaveMgr.cpp
+++ b/src/game/InstanceSaveMgr.cpp
@@ -339,7 +339,7 @@ void InstanceSaveManager::PackInstances()
uint32 InstanceNumber = 1;
// we do assume std::set is sorted properly on integer value
- for (std::set< uint32 >::iterator i = InstanceSet.begin(); i != InstanceSet.end(); i++)
+ for (std::set< uint32 >::iterator i = InstanceSet.begin(); i != InstanceSet.end(); ++i)
{
if (*i != InstanceNumber)
{
diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp
index 421f6ae53..7d24fd5a2 100644
--- a/src/game/ItemHandler.cpp
+++ b/src/game/ItemHandler.cpp
@@ -369,7 +369,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 ba6f50f48..e3dab0d57 100644
--- a/src/game/ItemPrototype.h
+++ b/src/game/ItemPrototype.h
@@ -443,17 +443,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
{
@@ -464,7 +462,6 @@ struct _Spell
int32 SpellCooldown;
uint32 SpellCategory; // id from SpellCategory.dbc
int32 SpellCategoryCooldown;
-
};
struct _Socket
@@ -479,7 +476,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;
@@ -511,12 +508,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 5730ad1d6..c73231635 100644
--- a/src/game/Level1.cpp
+++ b/src/game/Level1.cpp
@@ -1028,7 +1028,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;
}
@@ -1144,7 +1144,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;
}
@@ -1176,7 +1176,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/LootMgr.cpp b/src/game/LootMgr.cpp
index c61e22b7e..44e9d5982 100644
--- a/src/game/LootMgr.cpp
+++ b/src/game/LootMgr.cpp
@@ -910,7 +910,7 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, uint8 groupId) co
}
// Rolling non-grouped items
- for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; i++ )
+ for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i )
{
if ( !i->Roll() )
continue; // Bad luck for the entry
@@ -930,7 +930,7 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, uint8 groupId) co
}
// Now processing groups
- for (LootGroups::const_iterator i = Groups.begin( ) ; i != Groups.end( ) ; i++ )
+ for (LootGroups::const_iterator i = Groups.begin( ) ; i != Groups.end( ) ; ++i )
i->Process(loot);
}
@@ -959,7 +959,7 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con
}
// Now processing groups
- for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; i++ )
+ for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i )
if (i->HasQuestDrop())
return true;
@@ -977,7 +977,7 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co
}
// Checking non-grouped entries
- for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; i++ )
+ for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i )
{
if (i->mincountOrRef < 0) // References processing
{
diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp
index aafcdfa93..06499d15b 100644
--- a/src/game/Mail.cpp
+++ b/src/game/Mail.cpp
@@ -517,7 +517,7 @@ void WorldSession::HandleTakeMoney(WorldPacket & recv_data )
// save money and mail to prevent cheating
CharacterDatabase.BeginTransaction();
- pl->SetUInt32ValueInDB(PLAYER_FIELD_COINAGE,pl->GetMoney(),pl->GetGUID());
+ pl->SaveDataFieldToDB(); // contains money
pl->_SaveMail();
CharacterDatabase.CommitTransaction();
}
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index 606d53df6..b1cb12720 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -573,9 +573,12 @@ void Map::Update(const uint32 &t_diff)
// for pets
TypeContainerVisitor world_object_update(updater);
- for(MapRefManager::iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter)
+ // the player iterator is stored in the map object
+ // to make sure calls to Map::Remove don't invalidate it
+ for(m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter)
{
- Player* plr = iter->getSource();
+ Player* plr = m_mapRefIter->getSource();
+
if(!plr->IsInWorld())
continue;
@@ -613,7 +616,6 @@ void Map::Update(const uint32 &t_diff)
}
}
-
// Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load !
// This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended
if (IsBattleGroundOrArena())
@@ -631,6 +633,13 @@ void Map::Update(const uint32 &t_diff)
void Map::Remove(Player *player, bool remove)
{
+ // this may be called during Map::Update
+ // after decrement+unlink, ++m_mapRefIter will continue correctly
+ // when the first element of the list is being removed
+ // nocheck_prev will return the padding element of the RefManager
+ // instead of NULL in the case of prev
+ if(m_mapRefIter == player->GetMapRef())
+ m_mapRefIter = m_mapRefIter->nocheck_prev();
player->GetMapRef().unlink();
CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
@@ -687,7 +696,7 @@ Map::Remove(T *obj, bool remove)
CellPair p = MaNGOS::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;
}
@@ -695,7 +704,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 );
@@ -949,7 +958,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
@@ -1112,7 +1121,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
@@ -1616,6 +1624,8 @@ bool InstanceMap::Add(Player *player)
}
if(i_data) i_data->OnPlayerEnter(player);
+ // for normal instances cancel the reset schedule when the
+ // first player enters (no players yet)
SetResetSchedule(false);
player->SendInitWorldStates();
@@ -1642,11 +1652,12 @@ void InstanceMap::Update(const uint32& t_diff)
void InstanceMap::Remove(Player *player, bool remove)
{
sLog.outDetail("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName());
- SetResetSchedule(true);
//if last player set unload timer
if(!m_unloadTimer && m_mapRefManager.getSize() == 1)
m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld.getConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY);
Map::Remove(player, remove);
+ // for normal instances schedule the reset after all players have left
+ SetResetSchedule(true);
}
void InstanceMap::CreateInstanceData(bool load)
diff --git a/src/game/Map.h b/src/game/Map.h
index d24523e84..1fe978754 100644
--- a/src/game/Map.h
+++ b/src/game/Map.h
@@ -292,6 +292,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj
uint32 m_unloadTimer;
MapRefManager m_mapRefManager;
+ MapRefManager::iterator m_mapRefIter;
private:
typedef GridReadGuard ReadGuard;
typedef GridWriteGuard WriteGuard;
diff --git a/src/game/MapInstanced.cpp b/src/game/MapInstanced.cpp
index 79a8b88d4..8037e907d 100644
--- a/src/game/MapInstanced.cpp
+++ b/src/game/MapInstanced.cpp
@@ -57,7 +57,7 @@ void MapInstanced::Update(const uint32& t)
void MapInstanced::MoveAllCreaturesInMoveList()
{
- for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); i++)
+ for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
{
i->second->MoveAllCreaturesInMoveList();
}
@@ -67,7 +67,7 @@ void MapInstanced::MoveAllCreaturesInMoveList()
void MapInstanced::RemoveAllObjectsInRemoveList()
{
- for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); i++)
+ for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
{
i->second->RemoveAllObjectsInRemoveList();
}
@@ -79,7 +79,7 @@ bool MapInstanced::RemoveBones(uint64 guid, float x, float y)
{
bool remove_result = false;
- for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); i++)
+ for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
{
remove_result = remove_result || i->second->RemoveBones(guid, x, y);
}
@@ -90,11 +90,11 @@ bool MapInstanced::RemoveBones(uint64 guid, float x, float y)
void MapInstanced::UnloadAll(bool pForce)
{
// Unload instanced maps
- for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); i++)
+ for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
i->second->UnloadAll(pForce);
// Delete the maps only after everything is unloaded to prevent crashes
- for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); i++)
+ for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
delete i->second;
m_InstancedMaps.clear();
diff --git a/src/game/MapRefManager.h b/src/game/MapRefManager.h
index 05d93903c..bfd0ca12e 100644
--- a/src/game/MapRefManager.h
+++ b/src/game/MapRefManager.h
@@ -39,6 +39,6 @@ class MapRefManager : public RefManager