aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dep/jemalloc/VERSION2
-rw-r--r--dep/jemalloc/include/jemalloc/internal/arena.h252
-rw-r--r--dep/jemalloc/include/jemalloc/internal/atomic.h169
-rw-r--r--dep/jemalloc/include/jemalloc/internal/bitmap.h184
-rw-r--r--dep/jemalloc/include/jemalloc/internal/chunk.h2
-rw-r--r--dep/jemalloc/include/jemalloc/internal/ckh.h2
-rw-r--r--dep/jemalloc/include/jemalloc/internal/ctl.h1
-rw-r--r--dep/jemalloc/include/jemalloc/internal/hash.h6
-rw-r--r--dep/jemalloc/include/jemalloc/internal/jemalloc_internal.h185
-rw-r--r--dep/jemalloc/include/jemalloc/internal/mb.h2
-rw-r--r--dep/jemalloc/include/jemalloc/internal/mutex.h26
-rw-r--r--dep/jemalloc/include/jemalloc/internal/private_namespace.h195
-rw-r--r--dep/jemalloc/include/jemalloc/internal/prof.h144
-rw-r--r--dep/jemalloc/include/jemalloc/internal/rtree.h2
-rw-r--r--dep/jemalloc/include/jemalloc/internal/stats.h37
-rw-r--r--dep/jemalloc/include/jemalloc/internal/tcache.h89
-rw-r--r--dep/jemalloc/include/jemalloc/jemalloc.h10
-rw-r--r--dep/jemalloc/include/jemalloc/jemalloc_defs.h35
-rw-r--r--dep/jemalloc/src/arena.c671
-rw-r--r--dep/jemalloc/src/atomic.c2
-rw-r--r--dep/jemalloc/src/bitmap.c90
-rw-r--r--dep/jemalloc/src/chunk.c16
-rw-r--r--dep/jemalloc/src/chunk_mmap.c6
-rw-r--r--dep/jemalloc/src/ckh.c46
-rw-r--r--dep/jemalloc/src/ctl.c37
-rw-r--r--dep/jemalloc/src/hash.c2
-rw-r--r--dep/jemalloc/src/huge.c30
-rw-r--r--dep/jemalloc/src/jemalloc.c264
-rw-r--r--dep/jemalloc/src/mb.c2
-rw-r--r--dep/jemalloc/src/mutex.c6
-rw-r--r--dep/jemalloc/src/prof.c175
-rw-r--r--dep/jemalloc/src/rtree.c7
-rw-r--r--dep/jemalloc/src/stats.c21
-rw-r--r--dep/jemalloc/src/tcache.c153
-rw-r--r--sql/updates/world/2012_04_17_00_world_creature.sql28
-rw-r--r--sql/updates/world/2012_04_18_00_world_npc_spellclick_spells.sql2
-rw-r--r--sql/updates/world/2012_04_18_01_world_creature.sql1
-rw-r--r--sql/updates/world/2012_04_18_02_world_reference_loot_template.sql377
-rw-r--r--sql/updates/world/2012_04_18_03_world_creature_loot_template.sql2
-rw-r--r--sql/updates/world/2012_04_18_04_world_pickpocketing_loot_template.sql501
-rw-r--r--sql/updates/world/2012_04_18_05_world_conditions.sql4
-rw-r--r--sql/updates/world/2012_04_18_06_world_creature_template.sql2
-rw-r--r--sql/updates/world/2012_04_18_07_world_fishing_loot_template.sql2
-rw-r--r--sql/updates/world/2012_04_18_08_world_creature_loot_template.sql22
-rw-r--r--sql/updates/world/2012_04_19_00_world_creature_template.sql7
-rw-r--r--sql/updates/world/2012_04_19_01_world_pickpocketing_loot_template.sql202
-rw-r--r--sql/updates/world/2012_04_19_02_world_creature_loot_template.sql2
-rw-r--r--sql/updates/world/2012_04_19_03_world_instance_ulduar.sql174
-rw-r--r--sql/updates/world/2012_04_20_00_world_gameobject_loot_template.sql15
-rw-r--r--sql/updates/world/2012_04_20_01_world_item_loot_template.sql10
-rw-r--r--sql/updates/world/2012_04_20_02_world_creature_loot_template.sql4
-rw-r--r--sql/updates/world/2012_04_20_03_world_creature_loot_template.sql7
-rw-r--r--sql/updates/world/2012_04_20_04_world_creature_loot_template.sql3
-rw-r--r--sql/updates/world/2012_04_20_05_gameobject_template.sql8
-rw-r--r--sql/updates/world/2012_04_21_00_world_spell_script_names.sql14
-rw-r--r--sql/updates/world/2012_04_22_00_world_sai.sql63
-rw-r--r--sql/updates/world/2012_04_23_00_world_creatures.sql12
-rw-r--r--sql/updates/world/2012_04_23_01_world_conditions.sql5
-rw-r--r--sql/updates/world/2012_04_23_02_world_prospecting_loot_template.sql112
-rw-r--r--sql/updates/world/2012_04_23_03_world_skinning_loot_template.sql44
-rw-r--r--sql/updates/world/2012_04_23_04_world_creature_loot_template.sql2
-rw-r--r--sql/updates/world/2012_04_23_05_world_creature_loot_template.sql3
-rw-r--r--sql/updates/world/2012_04_24_00_world_command.sql10
-rw-r--r--sql/updates/world/2012_04_24_01_world_spell_proc_event.sql4
-rw-r--r--sql/updates/world/2012_04_24_02_world_warden_checks.sql8
-rw-r--r--sql/updates/world/2012_04_24_03_world_spell_script_names.sql4
-rw-r--r--sql/updates/world/2012_04_24_04_world_spell_proc_event.sql4
-rw-r--r--sql/updates/world/2012_04_24_05_world_creature_loot_template.sql9
-rw-r--r--sql/updates/world/2012_04_24_06_world_misc.sql31
-rw-r--r--sql/updates/world/2012_04_25_00_world_misc.sql3
-rw-r--r--sql/updates/world/2012_04_25_01_world_spell_script_names.sql3
-rw-r--r--sql/updates/world/2012_04_25_02_world_spell_script_names.sql11
-rw-r--r--sql/updates/world/2012_04_25_03_world_spell_group.sql11
-rw-r--r--sql/updates/world/2012_04_26_00_world_conditions.sql1
-rw-r--r--sql/updates/world/2012_04_26_01_world_smart_scripts.sql1
-rw-r--r--sql/updates/world/2012_04_27_00_world_instance_icc.sql5
-rw-r--r--sql/updates/world/2012_04_28_00_world_reference_loot_template.sql158
-rw-r--r--sql/updates/world/2012_04_28_01_world_reference_loot_template.sql22
-rwxr-xr-xsrc/server/game/AI/CreatureAIImpl.h4
-rwxr-xr-xsrc/server/game/AI/EventAI/CreatureEventAI.cpp2
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp13
-rw-r--r--src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp5
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundDS.h8
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundSA.cpp10
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundSA.h209
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundWS.cpp4
-rwxr-xr-xsrc/server/game/Chat/Chat.cpp1
-rwxr-xr-xsrc/server/game/Chat/Commands/Level2.cpp16
-rwxr-xr-xsrc/server/game/Combat/ThreatManager.cpp3
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.cpp13
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.h5
-rwxr-xr-xsrc/server/game/Entities/GameObject/GameObject.cpp3
-rwxr-xr-xsrc/server/game/Entities/Object/Object.h4
-rwxr-xr-xsrc/server/game/Entities/Player/Player.cpp13
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp4
-rwxr-xr-xsrc/server/game/Entities/Vehicle/Vehicle.cpp4
-rwxr-xr-xsrc/server/game/Grids/Notifiers/GridNotifiers.h2
-rwxr-xr-xsrc/server/game/Grids/Notifiers/GridNotifiersImpl.h25
-rwxr-xr-xsrc/server/game/Handlers/MovementHandler.cpp2
-rwxr-xr-xsrc/server/game/Maps/Map.h2
-rwxr-xr-xsrc/server/game/Miscellaneous/SharedDefines.h2
-rwxr-xr-xsrc/server/game/Scripting/ScriptLoader.cpp4
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuraEffects.cpp4
-rwxr-xr-xsrc/server/game/Spells/Spell.cpp14
-rwxr-xr-xsrc/server/game/Spells/SpellEffects.cpp37
-rwxr-xr-xsrc/server/game/Spells/SpellMgr.cpp26
-rwxr-xr-xsrc/server/game/Spells/SpellScript.cpp2
-rwxr-xr-xsrc/server/game/Spells/SpellScript.h2
-rw-r--r--src/server/scripts/CMakeLists.txt1
-rw-r--r--src/server/scripts/Commands/CMakeLists.txt1
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp11
-rw-r--r--src/server/scripts/Commands/cs_gps.cpp144
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp90
-rw-r--r--src/server/scripts/Commands/cs_modify.cpp40
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp4
-rw-r--r--src/server/scripts/Kalimdor/bloodmyst_isle.cpp2
-rw-r--r--src/server/scripts/Kalimdor/durotar.cpp4
-rw-r--r--src/server/scripts/Kalimdor/dustwallow_marsh.cpp2
-rw-r--r--src/server/scripts/Northrend/CMakeLists.txt2
-rwxr-xr-xsrc/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp2
-rwxr-xr-xsrc/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp31
-rw-r--r--src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp6
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp65
-rwxr-xr-xsrc/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp37
-rwxr-xr-xsrc/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp2
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp2
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp4
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp16
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon.cpp376
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp1374
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp4
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp10
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp8
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp270
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h226
-rw-r--r--src/server/scripts/Northrend/borean_tundra.cpp2
-rw-r--r--src/server/scripts/Northrend/storm_peaks.cpp6
-rw-r--r--src/server/scripts/Outland/blades_edge_mountains.cpp2
-rw-r--r--src/server/scripts/Outland/boss_doomlord_kazzak.cpp37
-rw-r--r--src/server/scripts/Outland/nagrand.cpp4
-rw-r--r--src/server/scripts/Outland/netherstorm.cpp2
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp83
-rw-r--r--src/server/scripts/Spells/spell_item.cpp35
-rw-r--r--src/server/scripts/Spells/spell_paladin.cpp11
-rw-r--r--src/server/scripts/Spells/spell_priest.cpp51
-rw-r--r--src/server/scripts/Spells/spell_quest.cpp2
-rw-r--r--src/server/scripts/Spells/spell_shaman.cpp56
-rw-r--r--src/server/scripts/Spells/spell_warrior.cpp3
-rw-r--r--src/server/scripts/World/go_scripts.cpp6
-rw-r--r--src/server/scripts/World/npcs_special.cpp167
-rw-r--r--src/server/shared/Debugging/WheatyExceptionReport.cpp18
151 files changed, 5214 insertions, 3232 deletions
diff --git a/dep/jemalloc/VERSION b/dep/jemalloc/VERSION
index aa85f5a2acf..585f53edd80 100644
--- a/dep/jemalloc/VERSION
+++ b/dep/jemalloc/VERSION
@@ -1 +1 @@
-2.2.5-0-gfc1bb70e5f0d9a58b39efa39cc549b5af5104760
+2.1.0-0-g1c4b088b08d3bc7617a34387e196ce03716160bf
diff --git a/dep/jemalloc/include/jemalloc/internal/arena.h b/dep/jemalloc/include/jemalloc/internal/arena.h
index b80c118d811..9556c2c68f7 100644
--- a/dep/jemalloc/include/jemalloc/internal/arena.h
+++ b/dep/jemalloc/include/jemalloc/internal/arena.h
@@ -19,7 +19,6 @@
#ifdef JEMALLOC_TINY
/* Smallest size class to support. */
# define LG_TINY_MIN LG_SIZEOF_PTR
-# define TINY_MIN (1U << LG_TINY_MIN)
#endif
/*
@@ -46,10 +45,9 @@
* point is implicitly RUN_BFP bits to the left.
*
* Note that it is possible to set RUN_MAX_OVRHD low enough that it cannot be
- * honored for some/all object sizes, since when heap profiling is enabled
- * there is one pointer of header overhead per object (plus a constant). This
- * constraint is relaxed (ignored) for runs that are so small that the
- * per-region overhead is greater than:
+ * honored for some/all object sizes, since there is one bit of header overhead
+ * per object (plus a constant). This constraint is relaxed (ignored) for runs
+ * that are so small that the per-region overhead is greater than:
*
* (RUN_MAX_OVRHD / (reg_size << (3+RUN_BFP))
*/
@@ -58,10 +56,6 @@
#define RUN_MAX_OVRHD 0x0000003dU
#define RUN_MAX_OVRHD_RELAX 0x00001800U
-/* Maximum number of regions in one run. */
-#define LG_RUN_MAXREGS 11
-#define RUN_MAXREGS (1U << LG_RUN_MAXREGS)
-
/*
* The minimum ratio of active:dirty pages per arena is computed as:
*
@@ -75,7 +69,6 @@
typedef struct arena_chunk_map_s arena_chunk_map_t;
typedef struct arena_chunk_s arena_chunk_t;
typedef struct arena_run_s arena_run_t;
-typedef struct arena_bin_info_s arena_bin_info_t;
typedef struct arena_bin_s arena_bin_t;
typedef struct arena_s arena_t;
@@ -112,7 +105,7 @@ struct arena_chunk_map_s {
* Run address (or size) and various flags are stored together. The bit
* layout looks like (assuming 32-bit system):
*
- * ???????? ???????? ????---- ----dula
+ * ???????? ???????? ????---- ----dzla
*
* ? : Unallocated: Run address for first/last pages, unset for internal
* pages.
@@ -120,7 +113,7 @@ struct arena_chunk_map_s {
* Large: Run size for first page, unset for trailing pages.
* - : Unused.
* d : dirty?
- * u : unzeroed?
+ * z : zeroed?
* l : large?
* a : allocated?
*
@@ -136,30 +129,30 @@ struct arena_chunk_map_s {
* [dula] : bit unset
*
* Unallocated (clean):
- * ssssssss ssssssss ssss---- ----du-a
+ * ssssssss ssssssss ssss---- ----du--
* xxxxxxxx xxxxxxxx xxxx---- -----Uxx
- * ssssssss ssssssss ssss---- ----dU-a
+ * ssssssss ssssssss ssss---- ----dU--
*
* Unallocated (dirty):
- * ssssssss ssssssss ssss---- ----D--a
+ * ssssssss ssssssss ssss---- ----D---
* xxxxxxxx xxxxxxxx xxxx---- ----xxxx
- * ssssssss ssssssss ssss---- ----D--a
+ * ssssssss ssssssss ssss---- ----D---
*
* Small:
- * pppppppp pppppppp pppp---- ----d--A
- * pppppppp pppppppp pppp---- -------A
- * pppppppp pppppppp pppp---- ----d--A
+ * pppppppp pppppppp pppp---- ----d--a
+ * pppppppp pppppppp pppp---- -------a
+ * pppppppp pppppppp pppp---- ----d--a
*
* Large:
- * ssssssss ssssssss ssss---- ----D-LA
+ * ssssssss ssssssss ssss---- ----D-la
* xxxxxxxx xxxxxxxx xxxx---- ----xxxx
- * -------- -------- -------- ----D-LA
+ * -------- -------- -------- ----D-la
*
* Large (sampled, size <= PAGE_SIZE):
- * ssssssss ssssssss sssscccc ccccD-LA
+ * ssssssss ssssssss sssscccc ccccD-la
*
* Large (not sampled, size == PAGE_SIZE):
- * ssssssss ssssssss ssss---- ----D-LA
+ * ssssssss ssssssss ssss---- ----D-la
*/
size_t bits;
#ifdef JEMALLOC_PROF
@@ -213,52 +206,16 @@ struct arena_run_s {
/* Bin this run is associated with. */
arena_bin_t *bin;
- /* Index of next region that has never been allocated, or nregs. */
- uint32_t nextind;
+ /* Stack of available freed regions, or NULL. */
+ void *avail;
+
+ /* Next region that has never been allocated, or run boundary. */
+ void *next;
/* Number of free regions in run. */
unsigned nfree;
};
-/*
- * Read-only information associated with each element of arena_t's bins array
- * is stored separately, partly to reduce memory usage (only one copy, rather
- * than one per arena), but mainly to avoid false cacheline sharing.
- */
-struct arena_bin_info_s {
- /* Size of regions in a run for this bin's size class. */
- size_t reg_size;
-
- /* Total size of a run for this bin's size class. */
- size_t run_size;
-
- /* Total number of regions in a run for this bin's size class. */
- uint32_t nregs;
-
- /*
- * Offset of first bitmap_t element in a run header for this bin's size
- * class.
- */
- uint32_t bitmap_offset;
-
- /*
- * Metadata used to manipulate bitmaps for runs associated with this
- * bin.
- */
- bitmap_info_t bitmap_info;
-
-#ifdef JEMALLOC_PROF
- /*
- * Offset of first (prof_ctx_t *) in a run header for this bin's size
- * class, or 0 if (opt_prof == false).
- */
- uint32_t ctx0_offset;
-#endif
-
- /* Offset of first region in a run for this bin's size class. */
- uint32_t reg0_offset;
-};
-
struct arena_bin_s {
/*
* All operations on runcur, runs, and stats require that lock be
@@ -283,6 +240,26 @@ struct arena_bin_s {
*/
arena_run_tree_t runs;
+ /* Size of regions in a run for this bin's size class. */
+ size_t reg_size;
+
+ /* Total size of a run for this bin's size class. */
+ size_t run_size;
+
+ /* Total number of regions in a run for this bin's size class. */
+ uint32_t nregs;
+
+#ifdef JEMALLOC_PROF
+ /*
+ * Offset of first (prof_ctx_t *) in a run header for this bin's size
+ * class, or 0 if (opt_prof == false).
+ */
+ uint32_t ctx0_offset;
+#endif
+
+ /* Offset of first region in a run for this bin's size class. */
+ uint32_t reg0_offset;
+
#ifdef JEMALLOC_STATS
/* Bin statistics. */
malloc_bin_stats_t stats;
@@ -299,18 +276,8 @@ struct arena_s {
unsigned ind;
/*
- * Number of threads currently assigned to this arena. This field is
- * protected by arenas_lock.
- */
- unsigned nthreads;
-
- /*
- * There are three classes of arena operations from a locking
- * perspective:
- * 1) Thread asssignment (modifies nthreads) is protected by
- * arenas_lock.
- * 2) Bin-related operations are protected by bin locks.
- * 3) Chunk- and run-related operations are protected by this mutex.
+ * All non-bin-related operations on this arena require that lock be
+ * locked.
*/
malloc_mutex_t lock;
@@ -380,35 +347,45 @@ struct arena_s {
/*
* bins is used to store trees of free regions of the following sizes,
- * assuming a 64-bit system with 16-byte quantum, 4 KiB page size, and
- * default MALLOC_CONF.
+ * assuming a 16-byte quantum, 4 KiB page size, and default
+ * JEMALLOC_OPTIONS.
*
* bins[i] | size |
* --------+--------+
- * 0 | 8 |
+ * 0 | 2 |
+ * 1 | 4 |
+ * 2 | 8 |
* --------+--------+
- * 1 | 16 |
- * 2 | 32 |
- * 3 | 48 |
+ * 3 | 16 |
+ * 4 | 32 |
+ * 5 | 48 |
* : :
- * 6 | 96 |
- * 7 | 112 |
- * 8 | 128 |
+ * 8 | 96 |
+ * 9 | 112 |
+ * 10 | 128 |
* --------+--------+
- * 9 | 192 |
- * 10 | 256 |
- * 11 | 320 |
- * 12 | 384 |
- * 13 | 448 |
- * 14 | 512 |
+ * 11 | 192 |
+ * 12 | 256 |
+ * 13 | 320 |
+ * 14 | 384 |
+ * 15 | 448 |
+ * 16 | 512 |
+ * --------+--------+
+ * 17 | 768 |
+ * 18 | 1024 |
+ * 19 | 1280 |
+ * : :
+ * 27 | 3328 |
+ * 28 | 3584 |
+ * 29 | 3840 |
* --------+--------+
- * 15 | 768 |
- * 16 | 1024 |
- * 17 | 1280 |
+ * 30 | 4 KiB |
+ * 31 | 6 KiB |
+ * 33 | 8 KiB |
* : :
- * 25 | 3328 |
- * 26 | 3584 |
- * 27 | 3840 |
+ * 43 | 28 KiB |
+ * 44 | 30 KiB |
+ * 45 | 32 KiB |
* --------+--------+
*/
arena_bin_t bins[1]; /* Dynamically sized. */
@@ -420,16 +397,8 @@ struct arena_s {
extern size_t opt_lg_qspace_max;
extern size_t opt_lg_cspace_max;
-extern ssize_t opt_lg_dirty_mult;
-/*
- * small_size2bin is a compact lookup table that rounds request sizes up to
- * size classes. In order to reduce cache footprint, the table is compressed,
- * and all accesses are via the SMALL_SIZE2BIN macro.
- */
+extern ssize_t opt_lg_dirty_mult;
extern uint8_t const *small_size2bin;
-#define SMALL_SIZE2BIN(s) (small_size2bin[(s-1) >> LG_TINY_MIN])
-
-extern arena_bin_info_t *arena_bin_info;
/* Various bin-related settings. */
#ifdef JEMALLOC_TINY /* Number of (2^n)-spaced tiny bins. */
@@ -496,9 +465,8 @@ bool arena_boot(void);
#ifdef JEMALLOC_H_INLINES
#ifndef JEMALLOC_ENABLE_INLINE
-size_t arena_bin_index(arena_t *arena, arena_bin_t *bin);
-unsigned arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info,
- const void *ptr);
+unsigned arena_run_regind(arena_run_t *run, arena_bin_t *bin,
+ const void *ptr, size_t size);
# ifdef JEMALLOC_PROF
prof_ctx_t *arena_prof_ctx_get(const void *ptr);
void arena_prof_ctx_set(const void *ptr, prof_ctx_t *ctx);
@@ -507,37 +475,21 @@ void arena_dalloc(arena_t *arena, arena_chunk_t *chunk, void *ptr);
#endif
#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_ARENA_C_))
-JEMALLOC_INLINE size_t
-arena_bin_index(arena_t *arena, arena_bin_t *bin)
-{
- size_t binind = bin - arena->bins;
- assert(binind < nbins);
- return (binind);
-}
-
JEMALLOC_INLINE unsigned
-arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info, const void *ptr)
+arena_run_regind(arena_run_t *run, arena_bin_t *bin, const void *ptr,
+ size_t size)
{
unsigned shift, diff, regind;
- size_t size;
- dassert(run->magic == ARENA_RUN_MAGIC);
- /*
- * Freeing a pointer lower than region zero can cause assertion
- * failure.
- */
- assert((uintptr_t)ptr >= (uintptr_t)run +
- (uintptr_t)bin_info->reg0_offset);
+ assert(run->magic == ARENA_RUN_MAGIC);
/*
* Avoid doing division with a variable divisor if possible. Using
* actual division here can reduce allocator throughput by over 20%!
*/
- diff = (unsigned)((uintptr_t)ptr - (uintptr_t)run -
- bin_info->reg0_offset);
+ diff = (unsigned)((uintptr_t)ptr - (uintptr_t)run - bin->reg0_offset);
/* Rescale (factor powers of 2 out of the numerator and denominator). */
- size = bin_info->reg_size;
shift = ffs(size) - 1;
diff >>= shift;
size >>= shift;
@@ -560,8 +512,8 @@ arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info, const void *ptr)
* divide by 0, and 1 and 2 are both powers of two, which are
* handled above.
*/
-#define SIZE_INV_SHIFT ((sizeof(unsigned) << 3) - LG_RUN_MAXREGS)
-#define SIZE_INV(s) (((1U << SIZE_INV_SHIFT) / (s)) + 1)
+#define SIZE_INV_SHIFT 21
+#define SIZE_INV(s) (((1U << SIZE_INV_SHIFT) / (s)) + 1)
static const unsigned size_invs[] = {
SIZE_INV(3),
SIZE_INV(4), SIZE_INV(5), SIZE_INV(6), SIZE_INV(7),
@@ -581,7 +533,7 @@ arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info, const void *ptr)
#undef SIZE_INV_SHIFT
}
assert(diff == regind * size);
- assert(regind < bin_info->nregs);
+ assert(regind < bin->nregs);
return (regind);
}
@@ -608,14 +560,13 @@ arena_prof_ctx_get(const void *ptr)
arena_run_t *run = (arena_run_t *)((uintptr_t)chunk +
(uintptr_t)((pageind - (mapbits >> PAGE_SHIFT)) <<
PAGE_SHIFT));
- size_t binind = arena_bin_index(chunk->arena, run->bin);
- arena_bin_info_t *bin_info = &arena_bin_info[binind];
+ arena_bin_t *bin = run->bin;
unsigned regind;
- dassert(run->magic == ARENA_RUN_MAGIC);
- regind = arena_run_regind(run, bin_info, ptr);
+ assert(run->magic == ARENA_RUN_MAGIC);
+ regind = arena_run_regind(run, bin, ptr, bin->reg_size);
ret = *(prof_ctx_t **)((uintptr_t)run +
- bin_info->ctx0_offset + (regind *
+ bin->ctx0_offset + (regind *
sizeof(prof_ctx_t *)));
}
} else
@@ -643,16 +594,12 @@ arena_prof_ctx_set(const void *ptr, prof_ctx_t *ctx)
(uintptr_t)((pageind - (mapbits >> PAGE_SHIFT)) <<
PAGE_SHIFT));
arena_bin_t *bin = run->bin;
- size_t binind;
- arena_bin_info_t *bin_info;
unsigned regind;
- dassert(run->magic == ARENA_RUN_MAGIC);
- binind = arena_bin_index(chunk->arena, bin);
- bin_info = &arena_bin_info[binind];
- regind = arena_run_regind(run, bin_info, ptr);
+ assert(run->magic == ARENA_RUN_MAGIC);
+ regind = arena_run_regind(run, bin, ptr, bin->reg_size);
- *((prof_ctx_t **)((uintptr_t)run + bin_info->ctx0_offset
+ *((prof_ctx_t **)((uintptr_t)run + bin->ctx0_offset
+ (regind * sizeof(prof_ctx_t *)))) = ctx;
} else
assert((uintptr_t)ctx == (uintptr_t)1U);
@@ -668,7 +615,7 @@ arena_dalloc(arena_t *arena, arena_chunk_t *chunk, void *ptr)
arena_chunk_map_t *mapelm;
assert(arena != NULL);
- dassert(arena->magic == ARENA_MAGIC);
+ assert(arena->magic == ARENA_MAGIC);
assert(chunk->arena == arena);
assert(ptr != NULL);
assert(CHUNK_ADDR2BASE(ptr) != ptr);
@@ -691,18 +638,11 @@ arena_dalloc(arena_t *arena, arena_chunk_t *chunk, void *ptr)
run = (arena_run_t *)((uintptr_t)chunk +
(uintptr_t)((pageind - (mapelm->bits >>
PAGE_SHIFT)) << PAGE_SHIFT));
- dassert(run->magic == ARENA_RUN_MAGIC);
+ assert(run->magic == ARENA_RUN_MAGIC);
+ assert(((uintptr_t)ptr - ((uintptr_t)run +
+ (uintptr_t)run->bin->reg0_offset)) %
+ run->bin->reg_size == 0);
bin = run->bin;
-#ifdef JEMALLOC_DEBUG
- {
- size_t binind = arena_bin_index(arena, bin);
- arena_bin_info_t *bin_info =
- &arena_bin_info[binind];
- assert(((uintptr_t)ptr - ((uintptr_t)run +
- (uintptr_t)bin_info->reg0_offset)) %
- bin_info->reg_size == 0);
- }
-#endif
malloc_mutex_lock(&bin->lock);
arena_dalloc_bin(arena, chunk, ptr, mapelm);
malloc_mutex_unlock(&bin->lock);
diff --git a/dep/jemalloc/include/jemalloc/internal/atomic.h b/dep/jemalloc/include/jemalloc/internal/atomic.h
deleted file mode 100644
index 9a298623f8a..00000000000
--- a/dep/jemalloc/include/jemalloc/internal/atomic.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/******************************************************************************/
-#ifdef JEMALLOC_H_TYPES
-
-#endif /* JEMALLOC_H_TYPES */
-/******************************************************************************/
-#ifdef JEMALLOC_H_STRUCTS
-
-#endif /* JEMALLOC_H_STRUCTS */
-/******************************************************************************/
-#ifdef JEMALLOC_H_EXTERNS
-
-#define atomic_read_uint64(p) atomic_add_uint64(p, 0)
-#define atomic_read_uint32(p) atomic_add_uint32(p, 0)
-
-#if (LG_SIZEOF_PTR == 3)
-# define atomic_read_z(p) \
- (size_t)atomic_add_uint64((uint64_t *)p, (uint64_t)0)
-# define atomic_add_z(p, x) \
- (size_t)atomic_add_uint64((uint64_t *)p, (uint64_t)x)
-# define atomic_sub_z(p, x) \
- (size_t)atomic_sub_uint64((uint64_t *)p, (uint64_t)x)
-#elif (LG_SIZEOF_PTR == 2)
-# define atomic_read_z(p) \
- (size_t)atomic_add_uint32((uint32_t *)p, (uint32_t)0)
-# define atomic_add_z(p, x) \
- (size_t)atomic_add_uint32((uint32_t *)p, (uint32_t)x)
-# define atomic_sub_z(p, x) \
- (size_t)atomic_sub_uint32((uint32_t *)p, (uint32_t)x)
-#endif
-
-#endif /* JEMALLOC_H_EXTERNS */
-/******************************************************************************/
-#ifdef JEMALLOC_H_INLINES
-
-#ifndef JEMALLOC_ENABLE_INLINE
-uint64_t atomic_add_uint64(uint64_t *p, uint64_t x);
-uint64_t atomic_sub_uint64(uint64_t *p, uint64_t x);
-uint32_t atomic_add_uint32(uint32_t *p, uint32_t x);
-uint32_t atomic_sub_uint32(uint32_t *p, uint32_t x);
-#endif
-
-#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_ATOMIC_C_))
-/******************************************************************************/
-/* 64-bit operations. */
-#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
-JEMALLOC_INLINE uint64_t
-atomic_add_uint64(uint64_t *p, uint64_t x)
-{
-
- return (__sync_add_and_fetch(p, x));
-}
-
-JEMALLOC_INLINE uint64_t
-atomic_sub_uint64(uint64_t *p, uint64_t x)
-{
-
- return (__sync_sub_and_fetch(p, x));
-}
-#elif (defined(JEMALLOC_OSATOMIC))
-JEMALLOC_INLINE uint64_t
-atomic_add_uint64(uint64_t *p, uint64_t x)
-{
-
- return (OSAtomicAdd64((int64_t)x, (int64_t *)p));
-}
-
-JEMALLOC_INLINE uint64_t
-atomic_sub_uint64(uint64_t *p, uint64_t x)
-{
-
- return (OSAtomicAdd64(-((int64_t)x), (int64_t *)p));
-}
-#elif (defined(__amd64_) || defined(__x86_64__))
-JEMALLOC_INLINE uint64_t
-atomic_add_uint64(uint64_t *p, uint64_t x)
-{
-
- asm volatile (
- "lock; xaddq %0, %1;"
- : "+r" (x), "=m" (*p) /* Outputs. */
- : "m" (*p) /* Inputs. */
- );
-
- return (x);
-}
-
-JEMALLOC_INLINE uint64_t
-atomic_sub_uint64(uint64_t *p, uint64_t x)
-{
-
- x = (uint64_t)(-(int64_t)x);
- asm volatile (
- "lock; xaddq %0, %1;"
- : "+r" (x), "=m" (*p) /* Outputs. */
- : "m" (*p) /* Inputs. */
- );
-
- return (x);
-}
-#else
-# if (LG_SIZEOF_PTR == 3)
-# error "Missing implementation for 64-bit atomic operations"
-# endif
-#endif
-
-/******************************************************************************/
-/* 32-bit operations. */
-#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
-JEMALLOC_INLINE uint32_t
-atomic_add_uint32(uint32_t *p, uint32_t x)
-{
-
- return (__sync_add_and_fetch(p, x));
-}
-
-JEMALLOC_INLINE uint32_t
-atomic_sub_uint32(uint32_t *p, uint32_t x)
-{
-
- return (__sync_sub_and_fetch(p, x));
-}
-#elif (defined(JEMALLOC_OSATOMIC))
-JEMALLOC_INLINE uint32_t
-atomic_add_uint32(uint32_t *p, uint32_t x)
-{
-
- return (OSAtomicAdd32((int32_t)x, (int32_t *)p));
-}
-
-JEMALLOC_INLINE uint32_t
-atomic_sub_uint32(uint32_t *p, uint32_t x)
-{
-
- return (OSAtomicAdd32(-((int32_t)x), (int32_t *)p));
-}
-#elif (defined(__i386__) || defined(__amd64_) || defined(__x86_64__))
-JEMALLOC_INLINE uint32_t
-atomic_add_uint32(uint32_t *p, uint32_t x)
-{
-
- asm volatile (
- "lock; xaddl %0, %1;"
- : "+r" (x), "=m" (*p) /* Outputs. */
- : "m" (*p) /* Inputs. */
- );
-
- return (x);
-}
-
-JEMALLOC_INLINE uint32_t
-atomic_sub_uint32(uint32_t *p, uint32_t x)
-{
-
- x = (uint32_t)(-(int32_t)x);
- asm volatile (
- "lock; xaddl %0, %1;"
- : "+r" (x), "=m" (*p) /* Outputs. */
- : "m" (*p) /* Inputs. */
- );
-
- return (x);
-}
-#else
-# error "Missing implementation for 32-bit atomic operations"
-#endif
-#endif
-
-#endif /* JEMALLOC_H_INLINES */
-/******************************************************************************/
diff --git a/dep/jemalloc/include/jemalloc/internal/bitmap.h b/dep/jemalloc/include/jemalloc/internal/bitmap.h
deleted file mode 100644
index 605ebac58c1..00000000000
--- a/dep/jemalloc/include/jemalloc/internal/bitmap.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/******************************************************************************/
-#ifdef JEMALLOC_H_TYPES
-
-/* Maximum bitmap bit count is 2^LG_BITMAP_MAXBITS. */
-#define LG_BITMAP_MAXBITS LG_RUN_MAXREGS
-
-typedef struct bitmap_level_s bitmap_level_t;
-typedef struct bitmap_info_s bitmap_info_t;
-typedef unsigned long bitmap_t;
-#define LG_SIZEOF_BITMAP LG_SIZEOF_LONG
-
-/* Number of bits per group. */
-#define LG_BITMAP_GROUP_NBITS (LG_SIZEOF_BITMAP + 3)
-#define BITMAP_GROUP_NBITS (ZU(1) << LG_BITMAP_GROUP_NBITS)
-#define BITMAP_GROUP_NBITS_MASK (BITMAP_GROUP_NBITS-1)
-
-/* Maximum number of levels possible. */
-#define BITMAP_MAX_LEVELS \
- (LG_BITMAP_MAXBITS / LG_SIZEOF_BITMAP) \
- + !!(LG_BITMAP_MAXBITS % LG_SIZEOF_BITMAP)
-
-#endif /* JEMALLOC_H_TYPES */
-/******************************************************************************/
-#ifdef JEMALLOC_H_STRUCTS
-
-struct bitmap_level_s {
- /* Offset of this level's groups within the array of groups. */
- size_t group_offset;
-};
-
-struct bitmap_info_s {
- /* Logical number of bits in bitmap (stored at bottom level). */
- size_t nbits;
-
- /* Number of levels necessary for nbits. */
- unsigned nlevels;
-
- /*
- * Only the first (nlevels+1) elements are used, and levels are ordered
- * bottom to top (e.g. the bottom level is stored in levels[0]).
- */
- bitmap_level_t levels[BITMAP_MAX_LEVELS+1];
-};
-
-#endif /* JEMALLOC_H_STRUCTS */
-/******************************************************************************/
-#ifdef JEMALLOC_H_EXTERNS
-
-void bitmap_info_init(bitmap_info_t *binfo, size_t nbits);
-size_t bitmap_info_ngroups(const bitmap_info_t *binfo);
-size_t bitmap_size(size_t nbits);
-void bitmap_init(bitmap_t *bitmap, const bitmap_info_t *binfo);
-
-#endif /* JEMALLOC_H_EXTERNS */
-/******************************************************************************/
-#ifdef JEMALLOC_H_INLINES
-
-#ifndef JEMALLOC_ENABLE_INLINE
-bool bitmap_full(bitmap_t *bitmap, const bitmap_info_t *binfo);
-bool bitmap_get(bitmap_t *bitmap, const bitmap_info_t *binfo, size_t bit);
-void bitmap_set(bitmap_t *bitmap, const bitmap_info_t *binfo, size_t bit);
-size_t bitmap_sfu(bitmap_t *bitmap, const bitmap_info_t *binfo);
-void bitmap_unset(bitmap_t *bitmap, const bitmap_info_t *binfo, size_t bit);
-#endif
-
-#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_BITMAP_C_))
-JEMALLOC_INLINE bool
-bitmap_full(bitmap_t *bitmap, const bitmap_info_t *binfo)
-{
- unsigned rgoff = binfo->levels[binfo->nlevels].group_offset - 1;
- bitmap_t rg = bitmap[rgoff];
- /* The bitmap is full iff the root group is 0. */
- return (rg == 0);
-}
-
-JEMALLOC_INLINE bool
-bitmap_get(bitmap_t *bitmap, const bitmap_info_t *binfo, size_t bit)
-{
- size_t goff;
- bitmap_t g;
-
- assert(bit < binfo->nbits);
- goff = bit >> LG_BITMAP_GROUP_NBITS;
- g = bitmap[goff];
- return (!(g & (1LU << (bit & BITMAP_GROUP_NBITS_MASK))));
-}
-
-JEMALLOC_INLINE void
-bitmap_set(bitmap_t *bitmap, const bitmap_info_t *binfo, size_t bit)
-{
- size_t goff;
- bitmap_t *gp;
- bitmap_t g;
-
- assert(bit < binfo->nbits);
- assert(bitmap_get(bitmap, binfo, bit) == false);
- goff = bit >> LG_BITMAP_GROUP_NBITS;
- gp = &bitmap[goff];
- g = *gp;
- assert(g & (1LU << (bit & BITMAP_GROUP_NBITS_MASK)));
- g ^= 1LU << (bit & BITMAP_GROUP_NBITS_MASK);
- *gp = g;
- assert(bitmap_get(bitmap, binfo, bit));
- /* Propagate group state transitions up the tree. */
- if (g == 0) {
- unsigned i;
- for (i = 1; i < binfo->nlevels; i++) {
- bit = goff;
- goff = bit >> LG_BITMAP_GROUP_NBITS;
- gp = &bitmap[binfo->levels[i].group_offset + goff];
- g = *gp;
- assert(g & (1LU << (bit & BITMAP_GROUP_NBITS_MASK)));
- g ^= 1LU << (bit & BITMAP_GROUP_NBITS_MASK);
- *gp = g;
- if (g != 0)
- break;
- }
- }
-}
-
-/* sfu: set first unset. */
-JEMALLOC_INLINE size_t
-bitmap_sfu(bitmap_t *bitmap, const bitmap_info_t *binfo)
-{
- size_t bit;
- bitmap_t g;
- unsigned i;
-
- assert(bitmap_full(bitmap, binfo) == false);
-
- i = binfo->nlevels - 1;
- g = bitmap[binfo->levels[i].group_offset];
- bit = ffsl(g) - 1;
- while (i > 0) {
- i--;
- g = bitmap[binfo->levels[i].group_offset + bit];
- bit = (bit << LG_BITMAP_GROUP_NBITS) + (ffsl(g) - 1);
- }
-
- bitmap_set(bitmap, binfo, bit);
- return (bit);
-}
-
-JEMALLOC_INLINE void
-bitmap_unset(bitmap_t *bitmap, const bitmap_info_t *binfo, size_t bit)
-{
- size_t goff;
- bitmap_t *gp;
- bitmap_t g;
- bool propagate;
-
- assert(bit < binfo->nbits);
- assert(bitmap_get(bitmap, binfo, bit));
- goff = bit >> LG_BITMAP_GROUP_NBITS;
- gp = &bitmap[goff];
- g = *gp;
- propagate = (g == 0);
- assert((g & (1LU << (bit & BITMAP_GROUP_NBITS_MASK))) == 0);
- g ^= 1LU << (bit & BITMAP_GROUP_NBITS_MASK);
- *gp = g;
- assert(bitmap_get(bitmap, binfo, bit) == false);
- /* Propagate group state transitions up the tree. */
- if (propagate) {
- unsigned i;
- for (i = 1; i < binfo->nlevels; i++) {
- bit = goff;
- goff = bit >> LG_BITMAP_GROUP_NBITS;
- gp = &bitmap[binfo->levels[i].group_offset + goff];
- g = *gp;
- propagate = (g == 0);
- assert((g & (1LU << (bit & BITMAP_GROUP_NBITS_MASK)))
- == 0);
- g ^= 1LU << (bit & BITMAP_GROUP_NBITS_MASK);
- *gp = g;
- if (propagate == false)
- break;
- }
- }
-}
-
-#endif
-
-#endif /* JEMALLOC_H_INLINES */
-/******************************************************************************/
diff --git a/dep/jemalloc/include/jemalloc/internal/chunk.h b/dep/jemalloc/include/jemalloc/internal/chunk.h
index 54b6a3ec886..a60f0ad7498 100644
--- a/dep/jemalloc/include/jemalloc/internal/chunk.h
+++ b/dep/jemalloc/include/jemalloc/internal/chunk.h
@@ -50,7 +50,7 @@ extern size_t map_bias; /* Number of arena chunk header pages. */
extern size_t arena_maxclass; /* Max size class for arenas. */
void *chunk_alloc(size_t size, bool base, bool *zero);
-void chunk_dealloc(void *chunk, size_t size, bool unmap);
+void chunk_dealloc(void *chunk, size_t size);
bool chunk_boot(void);
#endif /* JEMALLOC_H_EXTERNS */
diff --git a/dep/jemalloc/include/jemalloc/internal/ckh.h b/dep/jemalloc/include/jemalloc/internal/ckh.h
index 3e4ad4c85f9..d4e391b6360 100644
--- a/dep/jemalloc/include/jemalloc/internal/ckh.h
+++ b/dep/jemalloc/include/jemalloc/internal/ckh.h
@@ -31,7 +31,7 @@ struct ckhc_s {
struct ckh_s {
#ifdef JEMALLOC_DEBUG
-#define CKH_MAGIC 0x3af2489d
+#define CKH_MAGIG 0x3af2489d
uint32_t magic;
#endif
diff --git a/dep/jemalloc/include/jemalloc/internal/ctl.h b/dep/jemalloc/include/jemalloc/internal/ctl.h
index f1f5eb70a2a..8776ad135a7 100644
--- a/dep/jemalloc/include/jemalloc/internal/ctl.h
+++ b/dep/jemalloc/include/jemalloc/internal/ctl.h
@@ -29,7 +29,6 @@ struct ctl_node_s {
struct ctl_arena_stats_s {
bool initialized;
- unsigned nthreads;
size_t pactive;
size_t pdirty;
#ifdef JEMALLOC_STATS
diff --git a/dep/jemalloc/include/jemalloc/internal/hash.h b/dep/jemalloc/include/jemalloc/internal/hash.h
index 8a46ce30803..d12cdb8359f 100644
--- a/dep/jemalloc/include/jemalloc/internal/hash.h
+++ b/dep/jemalloc/include/jemalloc/internal/hash.h
@@ -17,7 +17,7 @@
uint64_t hash(const void *key, size_t len, uint64_t seed);
#endif
-#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_HASH_C_))
+#if (defined(JEMALLOC_ENABLE_INLINE) || defined(HASH_C_))
/*
* The following hash function is based on MurmurHash64A(), placed into the
* public domain by Austin Appleby. See http://murmurhash.googlepages.com/ for
@@ -26,7 +26,7 @@ uint64_t hash(const void *key, size_t len, uint64_t seed);
JEMALLOC_INLINE uint64_t
hash(const void *key, size_t len, uint64_t seed)
{
- const uint64_t m = 0xc6a4a7935bd1e995LLU;
+ const uint64_t m = 0xc6a4a7935bd1e995;
const int r = 47;
uint64_t h = seed ^ (len * m);
const uint64_t *data = (const uint64_t *)key;
@@ -62,7 +62,7 @@ hash(const void *key, size_t len, uint64_t seed)
h *= m;
h ^= h >> r;
- return (h);
+ return h;
}
#endif
diff --git a/dep/jemalloc/include/jemalloc/internal/jemalloc_internal.h b/dep/jemalloc/include/jemalloc/internal/jemalloc_internal.h
index cd554bea1b9..611f0c665a1 100644
--- a/dep/jemalloc/include/jemalloc/internal/jemalloc_internal.h
+++ b/dep/jemalloc/include/jemalloc/internal/jemalloc_internal.h
@@ -33,12 +33,6 @@
#define JEMALLOC_MANGLE
#include "../jemalloc.h"
-#include "jemalloc/internal/private_namespace.h"
-
-#if (defined(JEMALLOC_OSATOMIC) || defined(JEMALLOC_OSSPIN))
-#include <libkern/OSAtomic.h>
-#endif
-
#ifdef JEMALLOC_ZONE
#include <mach/mach_error.h>
#include <mach/mach_init.h>
@@ -61,9 +55,8 @@ extern void (*JEMALLOC_P(malloc_message))(void *wcbopaque, const char *s);
* Define a custom assert() in order to reduce the chances of deadlock during
* assertion failure.
*/
-#ifndef assert
-# ifdef JEMALLOC_DEBUG
-# define assert(e) do { \
+#ifdef JEMALLOC_DEBUG
+# define assert(e) do { \
if (!(e)) { \
char line_buf[UMAX2S_BUFSIZE]; \
malloc_write("<jemalloc>: "); \
@@ -77,15 +70,8 @@ extern void (*JEMALLOC_P(malloc_message))(void *wcbopaque, const char *s);
abort(); \
} \
} while (0)
-# else
-# define assert(e)
-# endif
-#endif
-
-#ifdef JEMALLOC_DEBUG
-# define dassert(e) assert(e)
#else
-# define dassert(e)
+#define assert(e)
#endif
/*
@@ -160,19 +146,12 @@ extern void (*JEMALLOC_P(malloc_message))(void *wcbopaque, const char *s);
#define QUANTUM_CEILING(a) \
(((a) + QUANTUM_MASK) & ~QUANTUM_MASK)
-#define LONG ((size_t)(1U << LG_SIZEOF_LONG))
-#define LONG_MASK (LONG - 1)
-
-/* Return the smallest long multiple that is >= a. */
-#define LONG_CEILING(a) \
- (((a) + LONG_MASK) & ~LONG_MASK)
-
#define SIZEOF_PTR (1U << LG_SIZEOF_PTR)
-#define PTR_MASK (SIZEOF_PTR - 1)
-/* Return the smallest (void *) multiple that is >= a. */
-#define PTR_CEILING(a) \
- (((a) + PTR_MASK) & ~PTR_MASK)
+/* We can't use TLS in non-PIC programs, since TLS relies on loader magic. */
+#if (!defined(PIC) && !defined(NO_TLS))
+# define NO_TLS
+#endif
/*
* Maximum size of L1 cache line. This is used to avoid cache line aliasing.
@@ -219,7 +198,6 @@ extern void (*JEMALLOC_P(malloc_message))(void *wcbopaque, const char *s);
#define PAGE_CEILING(s) \
(((s) + PAGE_MASK) & ~PAGE_MASK)
-#include "jemalloc/internal/atomic.h"
#include "jemalloc/internal/jemprn.h"
#include "jemalloc/internal/ckh.h"
#include "jemalloc/internal/stats.h"
@@ -228,7 +206,6 @@ extern void (*JEMALLOC_P(malloc_message))(void *wcbopaque, const char *s);
#include "jemalloc/internal/mb.h"
#include "jemalloc/internal/extent.h"
#include "jemalloc/internal/arena.h"
-#include "jemalloc/internal/bitmap.h"
#include "jemalloc/internal/base.h"
#include "jemalloc/internal/chunk.h"
#include "jemalloc/internal/huge.h"
@@ -244,14 +221,12 @@ extern void (*JEMALLOC_P(malloc_message))(void *wcbopaque, const char *s);
/******************************************************************************/
#define JEMALLOC_H_STRUCTS
-#include "jemalloc/internal/atomic.h"
#include "jemalloc/internal/jemprn.h"
#include "jemalloc/internal/ckh.h"
#include "jemalloc/internal/stats.h"
#include "jemalloc/internal/ctl.h"
#include "jemalloc/internal/mutex.h"
#include "jemalloc/internal/mb.h"
-#include "jemalloc/internal/bitmap.h"
#include "jemalloc/internal/extent.h"
#include "jemalloc/internal/arena.h"
#include "jemalloc/internal/base.h"
@@ -265,13 +240,6 @@ extern void (*JEMALLOC_P(malloc_message))(void *wcbopaque, const char *s);
#endif
#include "jemalloc/internal/prof.h"
-#ifdef JEMALLOC_STATS
-typedef struct {
- uint64_t allocated;
- uint64_t deallocated;
-} thread_allocated_t;
-#endif
-
#undef JEMALLOC_H_STRUCTS
/******************************************************************************/
#define JEMALLOC_H_EXTERNS
@@ -301,7 +269,6 @@ extern size_t lg_pagesize;
extern unsigned ncpus;
extern malloc_mutex_t arenas_lock; /* Protects arenas initialization. */
-extern pthread_key_t arenas_tsd;
#ifndef NO_TLS
/*
* Map of pthread_self() --> arenas[???], used for selecting an arena to use
@@ -311,9 +278,9 @@ extern __thread arena_t *arenas_tls JEMALLOC_ATTR(tls_model("initial-exec"));
# define ARENA_GET() arenas_tls
# define ARENA_SET(v) do { \
arenas_tls = (v); \
- pthread_setspecific(arenas_tsd, (void *)(v)); \
} while (0)
#else
+extern pthread_key_t arenas_tsd;
# define ARENA_GET() ((arena_t *)pthread_getspecific(arenas_tsd))
# define ARENA_SET(v) do { \
pthread_setspecific(arenas_tsd, (void *)(v)); \
@@ -328,28 +295,45 @@ extern arena_t **arenas;
extern unsigned narenas;
#ifdef JEMALLOC_STATS
+typedef struct {
+ uint64_t allocated;
+ uint64_t deallocated;
+} thread_allocated_t;
# ifndef NO_TLS
extern __thread thread_allocated_t thread_allocated_tls;
-# define ALLOCATED_GET() (thread_allocated_tls.allocated)
-# define ALLOCATEDP_GET() (&thread_allocated_tls.allocated)
-# define DEALLOCATED_GET() (thread_allocated_tls.deallocated)
-# define DEALLOCATEDP_GET() (&thread_allocated_tls.deallocated)
+# define ALLOCATED_GET() thread_allocated_tls.allocated
+# define DEALLOCATED_GET() thread_allocated_tls.deallocated
# define ALLOCATED_ADD(a, d) do { \
thread_allocated_tls.allocated += a; \
thread_allocated_tls.deallocated += d; \
} while (0)
# else
extern pthread_key_t thread_allocated_tsd;
-thread_allocated_t *thread_allocated_get_hard(void);
-
-# define ALLOCATED_GET() (thread_allocated_get()->allocated)
-# define ALLOCATEDP_GET() (&thread_allocated_get()->allocated)
-# define DEALLOCATED_GET() (thread_allocated_get()->deallocated)
-# define DEALLOCATEDP_GET() (&thread_allocated_get()->deallocated)
+# define ALLOCATED_GET() \
+ (uint64_t)((pthread_getspecific(thread_allocated_tsd) != NULL) \
+ ? ((thread_allocated_t *) \
+ pthread_getspecific(thread_allocated_tsd))->allocated : 0)
+# define DEALLOCATED_GET() \
+ (uint64_t)((pthread_getspecific(thread_allocated_tsd) != NULL) \
+ ? ((thread_allocated_t \
+ *)pthread_getspecific(thread_allocated_tsd))->deallocated : \
+ 0)
# define ALLOCATED_ADD(a, d) do { \
- thread_allocated_t *thread_allocated = thread_allocated_get(); \
- thread_allocated->allocated += (a); \
- thread_allocated->deallocated += (d); \
+ thread_allocated_t *thread_allocated = (thread_allocated_t *) \
+ pthread_getspecific(thread_allocated_tsd); \
+ if (thread_allocated != NULL) { \
+ thread_allocated->allocated += (a); \
+ thread_allocated->deallocated += (d); \
+ } else { \
+ thread_allocated = (thread_allocated_t *) \
+ imalloc(sizeof(thread_allocated_t)); \
+ if (thread_allocated != NULL) { \
+ pthread_setspecific(thread_allocated_tsd, \
+ thread_allocated); \
+ thread_allocated->allocated = (a); \
+ thread_allocated->deallocated = (d); \
+ } \
+ } \
} while (0)
# endif
#endif
@@ -360,14 +344,12 @@ int buferror(int errnum, char *buf, size_t buflen);
void jemalloc_prefork(void);
void jemalloc_postfork(void);
-#include "jemalloc/internal/atomic.h"
#include "jemalloc/internal/jemprn.h"
#include "jemalloc/internal/ckh.h"
#include "jemalloc/internal/stats.h"
#include "jemalloc/internal/ctl.h"
#include "jemalloc/internal/mutex.h"
#include "jemalloc/internal/mb.h"
-#include "jemalloc/internal/bitmap.h"
#include "jemalloc/internal/extent.h"
#include "jemalloc/internal/arena.h"
#include "jemalloc/internal/base.h"
@@ -385,7 +367,6 @@ void jemalloc_postfork(void);
/******************************************************************************/
#define JEMALLOC_H_INLINES
-#include "jemalloc/internal/atomic.h"
#include "jemalloc/internal/jemprn.h"
#include "jemalloc/internal/ckh.h"
#include "jemalloc/internal/stats.h"
@@ -403,9 +384,6 @@ size_t s2u(size_t size);
size_t sa2u(size_t size, size_t alignment, size_t *run_size_p);
void malloc_write(const char *s);
arena_t *choose_arena(void);
-# if (defined(JEMALLOC_STATS) && defined(NO_TLS))
-thread_allocated_t *thread_allocated_get(void);
-# endif
#endif
#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_C_))
@@ -436,10 +414,10 @@ s2u(size_t size)
{
if (size <= small_maxclass)
- return (arena_bin_info[SMALL_SIZE2BIN(size)].reg_size);
+ return arenas[0]->bins[small_size2bin[size]].reg_size;
if (size <= arena_maxclass)
- return (PAGE_CEILING(size));
- return (CHUNK_CEILING(size));
+ return PAGE_CEILING(size);
+ return CHUNK_CEILING(size);
}
/*
@@ -480,8 +458,10 @@ sa2u(size_t size, size_t alignment, size_t *run_size_p)
}
if (usize <= arena_maxclass && alignment <= PAGE_SIZE) {
- if (usize <= small_maxclass)
- return (arena_bin_info[SMALL_SIZE2BIN(usize)].reg_size);
+ if (usize <= small_maxclass) {
+ return
+ (arenas[0]->bins[small_size2bin[usize]].reg_size);
+ }
return (PAGE_CEILING(usize));
} else {
size_t run_size;
@@ -564,22 +544,8 @@ choose_arena(void)
return (ret);
}
-
-#if (defined(JEMALLOC_STATS) && defined(NO_TLS))
-JEMALLOC_INLINE thread_allocated_t *
-thread_allocated_get(void)
-{
- thread_allocated_t *thread_allocated = (thread_allocated_t *)
- pthread_getspecific(thread_allocated_tsd);
-
- if (thread_allocated == NULL)
- return (thread_allocated_get_hard());
- return (thread_allocated);
-}
-#endif
#endif
-#include "jemalloc/internal/bitmap.h"
#include "jemalloc/internal/rtree.h"
#include "jemalloc/internal/tcache.h"
#include "jemalloc/internal/arena.h"
@@ -591,7 +557,7 @@ thread_allocated_get(void)
#ifndef JEMALLOC_ENABLE_INLINE
void *imalloc(size_t size);
void *icalloc(size_t size);
-void *ipalloc(size_t usize, size_t alignment, bool zero);
+void *ipalloc(size_t size, size_t alignment, bool zero);
size_t isalloc(const void *ptr);
# ifdef JEMALLOC_IVSALLOC
size_t ivsalloc(const void *ptr);
@@ -625,39 +591,28 @@ icalloc(size_t size)
}
JEMALLOC_INLINE void *
-ipalloc(size_t usize, size_t alignment, bool zero)
+ipalloc(size_t size, size_t alignment, bool zero)
{
void *ret;
+ size_t usize;
+ size_t run_size
+# ifdef JEMALLOC_CC_SILENCE
+ = 0
+# endif
+ ;
- assert(usize != 0);
- assert(usize == sa2u(usize, alignment, NULL));
-
+ usize = sa2u(size, alignment, &run_size);
+ if (usize == 0)
+ return (NULL);
if (usize <= arena_maxclass && alignment <= PAGE_SIZE)
ret = arena_malloc(usize, zero);
- else {
- size_t run_size
-#ifdef JEMALLOC_CC_SILENCE
- = 0
-#endif
- ;
-
- /*
- * Ideally we would only ever call sa2u() once per aligned
- * allocation request, and the caller of this function has
- * already done so once. However, it's rather burdensome to
- * require every caller to pass in run_size, especially given
- * that it's only relevant to large allocations. Therefore,
- * just call it again here in order to get run_size.
- */
- sa2u(usize, alignment, &run_size);
- if (run_size <= arena_maxclass) {
- ret = arena_palloc(choose_arena(), usize, run_size,
- alignment, zero);
- } else if (alignment <= chunksize)
- ret = huge_malloc(usize, zero);
- else
- ret = huge_palloc(usize, alignment, zero);
- }
+ else if (run_size <= arena_maxclass) {
+ ret = arena_palloc(choose_arena(), usize, run_size, alignment,
+ zero);
+ } else if (alignment <= chunksize)
+ ret = huge_malloc(usize, zero);
+ else
+ ret = huge_palloc(usize, alignment, zero);
assert(((uintptr_t)ret & (alignment - 1)) == 0);
return (ret);
@@ -674,7 +629,7 @@ isalloc(const void *ptr)
chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr);
if (chunk != ptr) {
/* Region. */
- dassert(chunk->arena->magic == ARENA_MAGIC);
+ assert(chunk->arena->magic == ARENA_MAGIC);
#ifdef JEMALLOC_PROF
ret = arena_salloc_demote(ptr);
@@ -728,7 +683,7 @@ iralloc(void *ptr, size_t size, size_t extra, size_t alignment, bool zero,
if (alignment != 0 && ((uintptr_t)ptr & ((uintptr_t)alignment-1))
!= 0) {
- size_t usize, copysize;
+ size_t copysize;
/*
* Existing object alignment is inadquate; allocate new space
@@ -736,18 +691,12 @@ iralloc(void *ptr, size_t size, size_t extra, size_t alignment, bool zero,
*/
if (no_move)
return (NULL);
- usize = sa2u(size + extra, alignment, NULL);
- if (usize == 0)
- return (NULL);
- ret = ipalloc(usize, alignment, zero);
+ ret = ipalloc(size + extra, alignment, zero);
if (ret == NULL) {
if (extra == 0)
return (NULL);
/* Try again, without extra this time. */
- usize = sa2u(size, alignment, NULL);
- if (usize == 0)
- return (NULL);
- ret = ipalloc(usize, alignment, zero);
+ ret = ipalloc(size, alignment, zero);
if (ret == NULL)
return (NULL);
}
diff --git a/dep/jemalloc/include/jemalloc/internal/mb.h b/dep/jemalloc/include/jemalloc/internal/mb.h
index dc9f2a54262..1707aa91d68 100644
--- a/dep/jemalloc/include/jemalloc/internal/mb.h
+++ b/dep/jemalloc/include/jemalloc/internal/mb.h
@@ -17,7 +17,7 @@
void mb_write(void);
#endif
-#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_MB_C_))
+#if (defined(JEMALLOC_ENABLE_INLINE) || defined(MB_C_))
#ifdef __i386__
/*
* According to the Intel Architecture Software Developer's Manual, current
diff --git a/dep/jemalloc/include/jemalloc/internal/mutex.h b/dep/jemalloc/include/jemalloc/internal/mutex.h
index 62947ced55e..dcca01edd5d 100644
--- a/dep/jemalloc/include/jemalloc/internal/mutex.h
+++ b/dep/jemalloc/include/jemalloc/internal/mutex.h
@@ -1,11 +1,7 @@
/******************************************************************************/
#ifdef JEMALLOC_H_TYPES
-#ifdef JEMALLOC_OSSPIN
-typedef OSSpinLock malloc_mutex_t;
-#else
typedef pthread_mutex_t malloc_mutex_t;
-#endif
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
# define MALLOC_MUTEX_INITIALIZER PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
@@ -45,26 +41,17 @@ JEMALLOC_INLINE void
malloc_mutex_lock(malloc_mutex_t *mutex)
{
- if (isthreaded) {
-#ifdef JEMALLOC_OSSPIN
- OSSpinLockLock(mutex);
-#else
+ if (isthreaded)
pthread_mutex_lock(mutex);
-#endif
- }
}
JEMALLOC_INLINE bool
malloc_mutex_trylock(malloc_mutex_t *mutex)
{
- if (isthreaded) {
-#ifdef JEMALLOC_OSSPIN
- return (OSSpinLockTry(mutex) == false);
-#else
+ if (isthreaded)
return (pthread_mutex_trylock(mutex) != 0);
-#endif
- } else
+ else
return (false);
}
@@ -72,13 +59,8 @@ JEMALLOC_INLINE void
malloc_mutex_unlock(malloc_mutex_t *mutex)
{
- if (isthreaded) {
-#ifdef JEMALLOC_OSSPIN
- OSSpinLockUnlock(mutex);
-#else
+ if (isthreaded)
pthread_mutex_unlock(mutex);
-#endif
- }
}
#endif
diff --git a/dep/jemalloc/include/jemalloc/internal/private_namespace.h b/dep/jemalloc/include/jemalloc/internal/private_namespace.h
deleted file mode 100644
index d4f5f96d7b2..00000000000
--- a/dep/jemalloc/include/jemalloc/internal/private_namespace.h
+++ /dev/null
@@ -1,195 +0,0 @@
-#define arena_bin_index JEMALLOC_N(arena_bin_index)
-#define arena_boot JEMALLOC_N(arena_boot)
-#define arena_dalloc JEMALLOC_N(arena_dalloc)
-#define arena_dalloc_bin JEMALLOC_N(arena_dalloc_bin)
-#define arena_dalloc_large JEMALLOC_N(arena_dalloc_large)
-#define arena_malloc JEMALLOC_N(arena_malloc)
-#define arena_malloc_large JEMALLOC_N(arena_malloc_large)
-#define arena_malloc_small JEMALLOC_N(arena_malloc_small)
-#define arena_new JEMALLOC_N(arena_new)
-#define arena_palloc JEMALLOC_N(arena_palloc)
-#define arena_prof_accum JEMALLOC_N(arena_prof_accum)
-#define arena_prof_ctx_get JEMALLOC_N(arena_prof_ctx_get)
-#define arena_prof_ctx_set JEMALLOC_N(arena_prof_ctx_set)
-#define arena_prof_promoted JEMALLOC_N(arena_prof_promoted)
-#define arena_purge_all JEMALLOC_N(arena_purge_all)
-#define arena_ralloc JEMALLOC_N(arena_ralloc)
-#define arena_ralloc_no_move JEMALLOC_N(arena_ralloc_no_move)
-#define arena_run_regind JEMALLOC_N(arena_run_regind)
-#define arena_salloc JEMALLOC_N(arena_salloc)
-#define arena_salloc_demote JEMALLOC_N(arena_salloc_demote)
-#define arena_stats_merge JEMALLOC_N(arena_stats_merge)
-#define arena_tcache_fill_small JEMALLOC_N(arena_tcache_fill_small)
-#define arenas_bin_i_index JEMALLOC_N(arenas_bin_i_index)
-#define arenas_extend JEMALLOC_N(arenas_extend)
-#define arenas_lrun_i_index JEMALLOC_N(arenas_lrun_i_index)
-#define atomic_add_uint32 JEMALLOC_N(atomic_add_uint32)
-#define atomic_add_uint64 JEMALLOC_N(atomic_add_uint64)
-#define atomic_sub_uint32 JEMALLOC_N(atomic_sub_uint32)
-#define atomic_sub_uint64 JEMALLOC_N(atomic_sub_uint64)
-#define base_alloc JEMALLOC_N(base_alloc)
-#define base_boot JEMALLOC_N(base_boot)
-#define base_node_alloc JEMALLOC_N(base_node_alloc)
-#define base_node_dealloc JEMALLOC_N(base_node_dealloc)
-#define bitmap_full JEMALLOC_N(bitmap_full)
-#define bitmap_get JEMALLOC_N(bitmap_get)
-#define bitmap_info_init JEMALLOC_N(bitmap_info_init)
-#define bitmap_info_ngroups JEMALLOC_N(bitmap_info_ngroups)
-#define bitmap_init JEMALLOC_N(bitmap_init)
-#define bitmap_set JEMALLOC_N(bitmap_set)
-#define bitmap_sfu JEMALLOC_N(bitmap_sfu)
-#define bitmap_size JEMALLOC_N(bitmap_size)
-#define bitmap_unset JEMALLOC_N(bitmap_unset)
-#define bt_init JEMALLOC_N(bt_init)
-#define buferror JEMALLOC_N(buferror)
-#define choose_arena JEMALLOC_N(choose_arena)
-#define choose_arena_hard JEMALLOC_N(choose_arena_hard)
-#define chunk_alloc JEMALLOC_N(chunk_alloc)
-#define chunk_alloc_dss JEMALLOC_N(chunk_alloc_dss)
-#define chunk_alloc_mmap JEMALLOC_N(chunk_alloc_mmap)
-#define chunk_alloc_mmap_noreserve JEMALLOC_N(chunk_alloc_mmap_noreserve)
-#define chunk_alloc_swap JEMALLOC_N(chunk_alloc_swap)
-#define chunk_boot JEMALLOC_N(chunk_boot)
-#define chunk_dealloc JEMALLOC_N(chunk_dealloc)
-#define chunk_dealloc_dss JEMALLOC_N(chunk_dealloc_dss)
-#define chunk_dealloc_mmap JEMALLOC_N(chunk_dealloc_mmap)
-#define chunk_dealloc_swap JEMALLOC_N(chunk_dealloc_swap)
-#define chunk_dss_boot JEMALLOC_N(chunk_dss_boot)
-#define chunk_in_dss JEMALLOC_N(chunk_in_dss)
-#define chunk_in_swap JEMALLOC_N(chunk_in_swap)
-#define chunk_mmap_boot JEMALLOC_N(chunk_mmap_boot)
-#define chunk_swap_boot JEMALLOC_N(chunk_swap_boot)
-#define chunk_swap_enable JEMALLOC_N(chunk_swap_enable)
-#define ckh_bucket_search JEMALLOC_N(ckh_bucket_search)
-#define ckh_count JEMALLOC_N(ckh_count)
-#define ckh_delete JEMALLOC_N(ckh_delete)
-#define ckh_evict_reloc_insert JEMALLOC_N(ckh_evict_reloc_insert)
-#define ckh_insert JEMALLOC_N(ckh_insert)
-#define ckh_isearch JEMALLOC_N(ckh_isearch)
-#define ckh_iter JEMALLOC_N(ckh_iter)
-#define ckh_new JEMALLOC_N(ckh_new)
-#define ckh_pointer_hash JEMALLOC_N(ckh_pointer_hash)
-#define ckh_pointer_keycomp JEMALLOC_N(ckh_pointer_keycomp)
-#define ckh_rebuild JEMALLOC_N(ckh_rebuild)
-#define ckh_remove JEMALLOC_N(ckh_remove)
-#define ckh_search JEMALLOC_N(ckh_search)
-#define ckh_string_hash JEMALLOC_N(ckh_string_hash)
-#define ckh_string_keycomp JEMALLOC_N(ckh_string_keycomp)
-#define ckh_try_bucket_insert JEMALLOC_N(ckh_try_bucket_insert)
-#define ckh_try_insert JEMALLOC_N(ckh_try_insert)
-#define create_zone JEMALLOC_N(create_zone)
-#define ctl_boot JEMALLOC_N(ctl_boot)
-#define ctl_bymib JEMALLOC_N(ctl_bymib)
-#define ctl_byname JEMALLOC_N(ctl_byname)
-#define ctl_nametomib JEMALLOC_N(ctl_nametomib)
-#define extent_tree_ad_first JEMALLOC_N(extent_tree_ad_first)
-#define extent_tree_ad_insert JEMALLOC_N(extent_tree_ad_insert)
-#define extent_tree_ad_iter JEMALLOC_N(extent_tree_ad_iter)
-#define extent_tree_ad_iter_recurse JEMALLOC_N(extent_tree_ad_iter_recurse)
-#define extent_tree_ad_iter_start JEMALLOC_N(extent_tree_ad_iter_start)
-#define extent_tree_ad_last JEMALLOC_N(extent_tree_ad_last)
-#define extent_tree_ad_new JEMALLOC_N(extent_tree_ad_new)
-#define extent_tree_ad_next JEMALLOC_N(extent_tree_ad_next)
-#define extent_tree_ad_nsearch JEMALLOC_N(extent_tree_ad_nsearch)
-#define extent_tree_ad_prev JEMALLOC_N(extent_tree_ad_prev)
-#define extent_tree_ad_psearch JEMALLOC_N(extent_tree_ad_psearch)
-#define extent_tree_ad_remove JEMALLOC_N(extent_tree_ad_remove)
-#define extent_tree_ad_reverse_iter JEMALLOC_N(extent_tree_ad_reverse_iter)
-#define extent_tree_ad_reverse_iter_recurse JEMALLOC_N(extent_tree_ad_reverse_iter_recurse)
-#define extent_tree_ad_reverse_iter_start JEMALLOC_N(extent_tree_ad_reverse_iter_start)
-#define extent_tree_ad_search JEMALLOC_N(extent_tree_ad_search)
-#define extent_tree_szad_first JEMALLOC_N(extent_tree_szad_first)
-#define extent_tree_szad_insert JEMALLOC_N(extent_tree_szad_insert)
-#define extent_tree_szad_iter JEMALLOC_N(extent_tree_szad_iter)
-#define extent_tree_szad_iter_recurse JEMALLOC_N(extent_tree_szad_iter_recurse)
-#define extent_tree_szad_iter_start JEMALLOC_N(extent_tree_szad_iter_start)
-#define extent_tree_szad_last JEMALLOC_N(extent_tree_szad_last)
-#define extent_tree_szad_new JEMALLOC_N(extent_tree_szad_new)
-#define extent_tree_szad_next JEMALLOC_N(extent_tree_szad_next)
-#define extent_tree_szad_nsearch JEMALLOC_N(extent_tree_szad_nsearch)
-#define extent_tree_szad_prev JEMALLOC_N(extent_tree_szad_prev)
-#define extent_tree_szad_psearch JEMALLOC_N(extent_tree_szad_psearch)
-#define extent_tree_szad_remove JEMALLOC_N(extent_tree_szad_remove)
-#define extent_tree_szad_reverse_iter JEMALLOC_N(extent_tree_szad_reverse_iter)
-#define extent_tree_szad_reverse_iter_recurse JEMALLOC_N(extent_tree_szad_reverse_iter_recurse)
-#define extent_tree_szad_reverse_iter_start JEMALLOC_N(extent_tree_szad_reverse_iter_start)
-#define extent_tree_szad_search JEMALLOC_N(extent_tree_szad_search)
-#define hash JEMALLOC_N(hash)
-#define huge_boot JEMALLOC_N(huge_boot)
-#define huge_dalloc JEMALLOC_N(huge_dalloc)
-#define huge_malloc JEMALLOC_N(huge_malloc)
-#define huge_palloc JEMALLOC_N(huge_palloc)
-#define huge_prof_ctx_get JEMALLOC_N(huge_prof_ctx_get)
-#define huge_prof_ctx_set JEMALLOC_N(huge_prof_ctx_set)
-#define huge_ralloc JEMALLOC_N(huge_ralloc)
-#define huge_ralloc_no_move JEMALLOC_N(huge_ralloc_no_move)
-#define huge_salloc JEMALLOC_N(huge_salloc)
-#define iallocm JEMALLOC_N(iallocm)
-#define icalloc JEMALLOC_N(icalloc)
-#define idalloc JEMALLOC_N(idalloc)
-#define imalloc JEMALLOC_N(imalloc)
-#define ipalloc JEMALLOC_N(ipalloc)
-#define iralloc JEMALLOC_N(iralloc)
-#define isalloc JEMALLOC_N(isalloc)
-#define ivsalloc JEMALLOC_N(ivsalloc)
-#define jemalloc_darwin_init JEMALLOC_N(jemalloc_darwin_init)
-#define jemalloc_postfork JEMALLOC_N(jemalloc_postfork)
-#define jemalloc_prefork JEMALLOC_N(jemalloc_prefork)
-#define malloc_cprintf JEMALLOC_N(malloc_cprintf)
-#define malloc_mutex_destroy JEMALLOC_N(malloc_mutex_destroy)
-#define malloc_mutex_init JEMALLOC_N(malloc_mutex_init)
-#define malloc_mutex_lock JEMALLOC_N(malloc_mutex_lock)
-#define malloc_mutex_trylock JEMALLOC_N(malloc_mutex_trylock)
-#define malloc_mutex_unlock JEMALLOC_N(malloc_mutex_unlock)
-#define malloc_printf JEMALLOC_N(malloc_printf)
-#define malloc_write JEMALLOC_N(malloc_write)
-#define mb_write JEMALLOC_N(mb_write)
-#define pow2_ceil JEMALLOC_N(pow2_ceil)
-#define prof_backtrace JEMALLOC_N(prof_backtrace)
-#define prof_boot0 JEMALLOC_N(prof_boot0)
-#define prof_boot1 JEMALLOC_N(prof_boot1)
-#define prof_boot2 JEMALLOC_N(prof_boot2)
-#define prof_ctx_get JEMALLOC_N(prof_ctx_get)
-#define prof_ctx_set JEMALLOC_N(prof_ctx_set)
-#define prof_free JEMALLOC_N(prof_free)
-#define prof_gdump JEMALLOC_N(prof_gdump)
-#define prof_idump JEMALLOC_N(prof_idump)
-#define prof_lookup JEMALLOC_N(prof_lookup)
-#define prof_malloc JEMALLOC_N(prof_malloc)
-#define prof_mdump JEMALLOC_N(prof_mdump)
-#define prof_realloc JEMALLOC_N(prof_realloc)
-#define prof_sample_accum_update JEMALLOC_N(prof_sample_accum_update)
-#define prof_sample_threshold_update JEMALLOC_N(prof_sample_threshold_update)
-#define prof_tdata_init JEMALLOC_N(prof_tdata_init)
-#define pthread_create JEMALLOC_N(pthread_create)
-#define rtree_get JEMALLOC_N(rtree_get)
-#define rtree_get_locked JEMALLOC_N(rtree_get_locked)
-#define rtree_new JEMALLOC_N(rtree_new)
-#define rtree_set JEMALLOC_N(rtree_set)
-#define s2u JEMALLOC_N(s2u)
-#define sa2u JEMALLOC_N(sa2u)
-#define stats_arenas_i_bins_j_index JEMALLOC_N(stats_arenas_i_bins_j_index)
-#define stats_arenas_i_index JEMALLOC_N(stats_arenas_i_index)
-#define stats_arenas_i_lruns_j_index JEMALLOC_N(stats_arenas_i_lruns_j_index)
-#define stats_cactive_add JEMALLOC_N(stats_cactive_add)
-#define stats_cactive_get JEMALLOC_N(stats_cactive_get)
-#define stats_cactive_sub JEMALLOC_N(stats_cactive_sub)
-#define stats_print JEMALLOC_N(stats_print)
-#define szone2ozone JEMALLOC_N(szone2ozone)
-#define tcache_alloc_easy JEMALLOC_N(tcache_alloc_easy)
-#define tcache_alloc_large JEMALLOC_N(tcache_alloc_large)
-#define tcache_alloc_small JEMALLOC_N(tcache_alloc_small)
-#define tcache_alloc_small_hard JEMALLOC_N(tcache_alloc_small_hard)
-#define tcache_bin_flush_large JEMALLOC_N(tcache_bin_flush_large)
-#define tcache_bin_flush_small JEMALLOC_N(tcache_bin_flush_small)
-#define tcache_boot JEMALLOC_N(tcache_boot)
-#define tcache_create JEMALLOC_N(tcache_create)
-#define tcache_dalloc_large JEMALLOC_N(tcache_dalloc_large)
-#define tcache_dalloc_small JEMALLOC_N(tcache_dalloc_small)
-#define tcache_destroy JEMALLOC_N(tcache_destroy)
-#define tcache_event JEMALLOC_N(tcache_event)
-#define tcache_get JEMALLOC_N(tcache_get)
-#define tcache_stats_merge JEMALLOC_N(tcache_stats_merge)
-#define thread_allocated_get JEMALLOC_N(thread_allocated_get)
-#define thread_allocated_get_hard JEMALLOC_N(thread_allocated_get_hard)
-#define u2s JEMALLOC_N(u2s)
diff --git a/dep/jemalloc/include/jemalloc/internal/prof.h b/dep/jemalloc/include/jemalloc/internal/prof.h
index e9064ba6e73..7864000b88b 100644
--- a/dep/jemalloc/include/jemalloc/internal/prof.h
+++ b/dep/jemalloc/include/jemalloc/internal/prof.h
@@ -227,60 +227,9 @@ bool prof_boot2(void);
/******************************************************************************/
#ifdef JEMALLOC_H_INLINES
-#define PROF_ALLOC_PREP(nignore, size, ret) do { \
- prof_tdata_t *prof_tdata; \
- prof_bt_t bt; \
- \
- assert(size == s2u(size)); \
- \
- prof_tdata = PROF_TCACHE_GET(); \
- if (prof_tdata == NULL) { \
- prof_tdata = prof_tdata_init(); \
- if (prof_tdata == NULL) { \
- ret = NULL; \
- break; \
- } \
- } \
- \
- if (opt_prof_active == false) { \
- /* Sampling is currently inactive, so avoid sampling. */\
- ret = (prof_thr_cnt_t *)(uintptr_t)1U; \
- } else if (opt_lg_prof_sample == 0) { \
- /* Don't bother with sampling logic, since sampling */\
- /* interval is 1. */\
- bt_init(&bt, prof_tdata->vec); \
- prof_backtrace(&bt, nignore, prof_bt_max); \
- ret = prof_lookup(&bt); \
- } else { \
- if (prof_tdata->threshold == 0) { \
- /* Initialize. Seed the prng differently for */\
- /* each thread. */\
- prof_tdata->prn_state = \
- (uint64_t)(uintptr_t)&size; \
- prof_sample_threshold_update(prof_tdata); \
- } \
- \
- /* Determine whether to capture a backtrace based on */\
- /* whether size is enough for prof_accum to reach */\
- /* prof_tdata->threshold. However, delay updating */\
- /* these variables until prof_{m,re}alloc(), because */\
- /* we don't know for sure that the allocation will */\
- /* succeed. */\
- /* */\
- /* Use subtraction rather than addition to avoid */\
- /* potential integer overflow. */\
- if (size >= prof_tdata->threshold - \
- prof_tdata->accum) { \
- bt_init(&bt, prof_tdata->vec); \
- prof_backtrace(&bt, nignore, prof_bt_max); \
- ret = prof_lookup(&bt); \
- } else \
- ret = (prof_thr_cnt_t *)(uintptr_t)1U; \
- } \
-} while (0)
-
#ifndef JEMALLOC_ENABLE_INLINE
void prof_sample_threshold_update(prof_tdata_t *prof_tdata);
+prof_thr_cnt_t *prof_alloc_prep(size_t size);
prof_ctx_t *prof_ctx_get(const void *ptr);
void prof_ctx_set(const void *ptr, prof_ctx_t *ctx);
bool prof_sample_accum_update(size_t size);
@@ -298,22 +247,8 @@ prof_sample_threshold_update(prof_tdata_t *prof_tdata)
double u;
/*
- * Compute sample threshold as a geometrically distributed random
+ * Compute prof_sample_threshold as a geometrically distributed random
* variable with mean (2^opt_lg_prof_sample).
- *
- * __ __
- * | log(u) | 1
- * prof_tdata->threshold = | -------- |, where p = -------------------
- * | log(1-p) | opt_lg_prof_sample
- * 2
- *
- * For more information on the math, see:
- *
- * Non-Uniform Random Variate Generation
- * Luc Devroye
- * Springer-Verlag, New York, 1986
- * pp 500
- * (http://cg.scs.carleton.ca/~luc/rnbookindex.html)
*/
prn64(r, 53, prof_tdata->prn_state,
(uint64_t)6364136223846793005LLU, (uint64_t)1442695040888963407LLU);
@@ -323,6 +258,71 @@ prof_sample_threshold_update(prof_tdata_t *prof_tdata)
+ (uint64_t)1U;
}
+JEMALLOC_INLINE prof_thr_cnt_t *
+prof_alloc_prep(size_t size)
+{
+#ifdef JEMALLOC_ENABLE_INLINE
+ /* This function does not have its own stack frame, because it is inlined. */
+# define NIGNORE 1
+#else
+# define NIGNORE 2
+#endif
+ prof_thr_cnt_t *ret;
+ prof_tdata_t *prof_tdata;
+ prof_bt_t bt;
+
+ assert(size == s2u(size));
+
+ prof_tdata = PROF_TCACHE_GET();
+ if (prof_tdata == NULL) {
+ prof_tdata = prof_tdata_init();
+ if (prof_tdata == NULL)
+ return (NULL);
+ }
+
+ if (opt_prof_active == false) {
+ /* Sampling is currently inactive, so avoid sampling. */
+ ret = (prof_thr_cnt_t *)(uintptr_t)1U;
+ } else if (opt_lg_prof_sample == 0) {
+ /*
+ * Don't bother with sampling logic, since sampling interval is
+ * 1.
+ */
+ bt_init(&bt, prof_tdata->vec);
+ prof_backtrace(&bt, NIGNORE, prof_bt_max);
+ ret = prof_lookup(&bt);
+ } else {
+ if (prof_tdata->threshold == 0) {
+ /*
+ * Initialize. Seed the prng differently for each
+ * thread.
+ */
+ prof_tdata->prn_state = (uint64_t)(uintptr_t)&size;
+ prof_sample_threshold_update(prof_tdata);
+ }
+
+ /*
+ * Determine whether to capture a backtrace based on whether
+ * size is enough for prof_accum to reach
+ * prof_tdata->threshold. However, delay updating these
+ * variables until prof_{m,re}alloc(), because we don't know
+ * for sure that the allocation will succeed.
+ *
+ * Use subtraction rather than addition to avoid potential
+ * integer overflow.
+ */
+ if (size >= prof_tdata->threshold - prof_tdata->accum) {
+ bt_init(&bt, prof_tdata->vec);
+ prof_backtrace(&bt, NIGNORE, prof_bt_max);
+ ret = prof_lookup(&bt);
+ } else
+ ret = (prof_thr_cnt_t *)(uintptr_t)1U;
+ }
+
+ return (ret);
+#undef NIGNORE
+}
+
JEMALLOC_INLINE prof_ctx_t *
prof_ctx_get(const void *ptr)
{
@@ -334,7 +334,7 @@ prof_ctx_get(const void *ptr)
chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr);
if (chunk != ptr) {
/* Region. */
- dassert(chunk->arena->magic == ARENA_MAGIC);
+ assert(chunk->arena->magic == ARENA_MAGIC);
ret = arena_prof_ctx_get(ptr);
} else
@@ -353,7 +353,7 @@ prof_ctx_set(const void *ptr, prof_ctx_t *ctx)
chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr);
if (chunk != ptr) {
/* Region. */
- dassert(chunk->arena->magic == ARENA_MAGIC);
+ assert(chunk->arena->magic == ARENA_MAGIC);
arena_prof_ctx_set(ptr, ctx);
} else
@@ -374,7 +374,7 @@ prof_sample_accum_update(size_t size)
/* Take care to avoid integer overflow. */
if (size >= prof_tdata->threshold - prof_tdata->accum) {
prof_tdata->accum -= (prof_tdata->threshold - size);
- /* Compute new sample threshold. */
+ /* Compute new prof_sample_threshold. */
prof_sample_threshold_update(prof_tdata);
while (prof_tdata->accum >= prof_tdata->threshold) {
prof_tdata->accum -= prof_tdata->threshold;
@@ -401,7 +401,7 @@ prof_malloc(const void *ptr, size_t size, prof_thr_cnt_t *cnt)
* always possible to tell in advance how large an
* object's usable size will be, so there should never
* be a difference between the size passed to
- * PROF_ALLOC_PREP() and prof_malloc().
+ * prof_alloc_prep() and prof_malloc().
*/
assert((uintptr_t)cnt == (uintptr_t)1U);
}
@@ -445,7 +445,7 @@ prof_realloc(const void *ptr, size_t size, prof_thr_cnt_t *cnt,
if (prof_sample_accum_update(size)) {
/*
* Don't sample. The size passed to
- * PROF_ALLOC_PREP() was larger than what
+ * prof_alloc_prep() was larger than what
* actually got allocated, so a backtrace was
* captured for this allocation, even though
* its actual size was insufficient to cross
diff --git a/dep/jemalloc/include/jemalloc/internal/rtree.h b/dep/jemalloc/include/jemalloc/internal/rtree.h
index 95d6355a5f4..9d58ebac545 100644
--- a/dep/jemalloc/include/jemalloc/internal/rtree.h
+++ b/dep/jemalloc/include/jemalloc/internal/rtree.h
@@ -49,7 +49,7 @@ void *rtree_get(rtree_t *rtree, uintptr_t key);
bool rtree_set(rtree_t *rtree, uintptr_t key, void *val);
#endif
-#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_RTREE_C_))
+#if (defined(JEMALLOC_ENABLE_INLINE) || defined(RTREE_C_))
#define RTREE_GET_GENERATE(f) \
/* The least significant bits of the key are ignored. */ \
JEMALLOC_INLINE void * \
diff --git a/dep/jemalloc/include/jemalloc/internal/stats.h b/dep/jemalloc/include/jemalloc/internal/stats.h
index 2a9b31d9ffc..3fc2080a34b 100644
--- a/dep/jemalloc/include/jemalloc/internal/stats.h
+++ b/dep/jemalloc/include/jemalloc/internal/stats.h
@@ -154,10 +154,6 @@ struct chunk_stats_s {
extern bool opt_stats_print;
-#ifdef JEMALLOC_STATS
-extern size_t stats_cactive;
-#endif
-
char *u2s(uint64_t x, unsigned base, char *s);
#ifdef JEMALLOC_STATS
void malloc_cprintf(void (*write)(void *, const char *), void *cbopaque,
@@ -170,38 +166,9 @@ void stats_print(void (*write)(void *, const char *), void *cbopaque,
#endif /* JEMALLOC_H_EXTERNS */
/******************************************************************************/
-#ifdef JEMALLOC_H_INLINES
#ifdef JEMALLOC_STATS
+#ifdef JEMALLOC_H_INLINES
-#ifndef JEMALLOC_ENABLE_INLINE
-size_t stats_cactive_get(void);
-void stats_cactive_add(size_t size);
-void stats_cactive_sub(size_t size);
-#endif
-
-#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_STATS_C_))
-JEMALLOC_INLINE size_t
-stats_cactive_get(void)
-{
-
- return (atomic_read_z(&stats_cactive));
-}
-
-JEMALLOC_INLINE void
-stats_cactive_add(size_t size)
-{
-
- atomic_add_z(&stats_cactive, size);
-}
-
-JEMALLOC_INLINE void
-stats_cactive_sub(size_t size)
-{
-
- atomic_sub_z(&stats_cactive, size);
-}
-#endif
-
-#endif /* JEMALLOC_STATS */
#endif /* JEMALLOC_H_INLINES */
+#endif /* JEMALLOC_STATS */
/******************************************************************************/
diff --git a/dep/jemalloc/include/jemalloc/internal/tcache.h b/dep/jemalloc/include/jemalloc/internal/tcache.h
index da3c68c5770..1ad91a9b1e0 100644
--- a/dep/jemalloc/include/jemalloc/internal/tcache.h
+++ b/dep/jemalloc/include/jemalloc/internal/tcache.h
@@ -2,7 +2,6 @@
/******************************************************************************/
#ifdef JEMALLOC_H_TYPES
-typedef struct tcache_bin_info_s tcache_bin_info_t;
typedef struct tcache_bin_s tcache_bin_t;
typedef struct tcache_s tcache_t;
@@ -33,22 +32,15 @@ typedef struct tcache_s tcache_t;
/******************************************************************************/
#ifdef JEMALLOC_H_STRUCTS
-/*
- * Read-only information associated with each element of tcache_t's tbins array
- * is stored separately, mainly to reduce memory usage.
- */
-struct tcache_bin_info_s {
- unsigned ncached_max; /* Upper limit on ncached. */
-};
-
struct tcache_bin_s {
# ifdef JEMALLOC_STATS
tcache_bin_stats_t tstats;
# endif
- int low_water; /* Min # cached since last GC. */
- unsigned lg_fill_div; /* Fill (ncached_max >> lg_fill_div). */
+ unsigned low_water; /* Min # cached since last GC. */
+ unsigned high_water; /* Max # cached since last GC. */
unsigned ncached; /* # of cached objects. */
- void **avail; /* Stack of available objects. */
+ unsigned ncached_max; /* Upper limit on ncached. */
+ void *avail; /* Chain of available objects. */
};
struct tcache_s {
@@ -62,12 +54,6 @@ struct tcache_s {
unsigned ev_cnt; /* Event count since incremental GC. */
unsigned next_gc_bin; /* Next bin to GC. */
tcache_bin_t tbins[1]; /* Dynamically sized. */
- /*
- * The pointer stacks associated with tbins follow as a contiguous
- * array. During tcache initialization, the avail pointer in each
- * element of tbins is initialized to point to the proper offset within
- * this array.
- */
};
#endif /* JEMALLOC_H_STRUCTS */
@@ -78,8 +64,6 @@ extern bool opt_tcache;
extern ssize_t opt_lg_tcache_max;
extern ssize_t opt_lg_tcache_gc_sweep;
-extern tcache_bin_info_t *tcache_bin_info;
-
/* Map of thread-specific caches. */
#ifndef NO_TLS
extern __thread tcache_t *tcache_tls
@@ -126,7 +110,7 @@ void tcache_destroy(tcache_t *tcache);
#ifdef JEMALLOC_STATS
void tcache_stats_merge(tcache_t *tcache, arena_t *arena);
#endif
-bool tcache_boot(void);
+void tcache_boot(void);
#endif /* JEMALLOC_H_EXTERNS */
/******************************************************************************/
@@ -185,7 +169,6 @@ tcache_event(tcache_t *tcache)
if (tcache->ev_cnt == tcache_gc_incr) {
size_t binind = tcache->next_gc_bin;
tcache_bin_t *tbin = &tcache->tbins[binind];
- tcache_bin_info_t *tbin_info = &tcache_bin_info[binind];
if (tbin->low_water > 0) {
/*
@@ -209,22 +192,9 @@ tcache_event(tcache_t *tcache)
#endif
);
}
- /*
- * Reduce fill count by 2X. Limit lg_fill_div such that
- * the fill count is always at least 1.
- */
- if ((tbin_info->ncached_max >> (tbin->lg_fill_div+1))
- >= 1)
- tbin->lg_fill_div++;
- } else if (tbin->low_water < 0) {
- /*
- * Increase fill count by 2X. Make sure lg_fill_div
- * stays greater than 0.
- */
- if (tbin->lg_fill_div > 1)
- tbin->lg_fill_div--;
}
tbin->low_water = tbin->ncached;
+ tbin->high_water = tbin->ncached;
tcache->next_gc_bin++;
if (tcache->next_gc_bin == nhbins)
@@ -238,14 +208,13 @@ tcache_alloc_easy(tcache_bin_t *tbin)
{
void *ret;
- if (tbin->ncached == 0) {
- tbin->low_water = -1;
+ if (tbin->ncached == 0)
return (NULL);
- }
tbin->ncached--;
- if ((int)tbin->ncached < tbin->low_water)
+ if (tbin->ncached < tbin->low_water)
tbin->low_water = tbin->ncached;
- ret = tbin->avail[tbin->ncached];
+ ret = tbin->avail;
+ tbin->avail = *(void **)ret;
return (ret);
}
@@ -256,7 +225,7 @@ tcache_alloc_small(tcache_t *tcache, size_t size, bool zero)
size_t binind;
tcache_bin_t *tbin;
- binind = SMALL_SIZE2BIN(size);
+ binind = small_size2bin[size];
assert(binind < nbins);
tbin = &tcache->tbins[binind];
ret = tcache_alloc_easy(tbin);
@@ -265,7 +234,7 @@ tcache_alloc_small(tcache_t *tcache, size_t size, bool zero)
if (ret == NULL)
return (NULL);
}
- assert(arena_salloc(ret) == arena_bin_info[binind].reg_size);
+ assert(arena_salloc(ret) == tcache->arena->bins[binind].reg_size);
if (zero == false) {
#ifdef JEMALLOC_FILL
@@ -281,7 +250,7 @@ tcache_alloc_small(tcache_t *tcache, size_t size, bool zero)
tbin->tstats.nrequests++;
#endif
#ifdef JEMALLOC_PROF
- tcache->prof_accumbytes += arena_bin_info[binind].reg_size;
+ tcache->prof_accumbytes += tcache->arena->bins[binind].reg_size;
#endif
tcache_event(tcache);
return (ret);
@@ -345,7 +314,6 @@ tcache_dalloc_small(tcache_t *tcache, void *ptr)
arena_run_t *run;
arena_bin_t *bin;
tcache_bin_t *tbin;
- tcache_bin_info_t *tbin_info;
size_t pageind, binind;
arena_chunk_map_t *mapelm;
@@ -357,7 +325,7 @@ tcache_dalloc_small(tcache_t *tcache, void *ptr)
mapelm = &chunk->map[pageind-map_bias];
run = (arena_run_t *)((uintptr_t)chunk + (uintptr_t)((pageind -
(mapelm->bits >> PAGE_SHIFT)) << PAGE_SHIFT));
- dassert(run->magic == ARENA_RUN_MAGIC);
+ assert(run->magic == ARENA_RUN_MAGIC);
bin = run->bin;
binind = ((uintptr_t)bin - (uintptr_t)&arena->bins) /
sizeof(arena_bin_t);
@@ -365,22 +333,23 @@ tcache_dalloc_small(tcache_t *tcache, void *ptr)
#ifdef JEMALLOC_FILL
if (opt_junk)
- memset(ptr, 0x5a, arena_bin_info[binind].reg_size);
+ memset(ptr, 0x5a, bin->reg_size);
#endif
tbin = &tcache->tbins[binind];
- tbin_info = &tcache_bin_info[binind];
- if (tbin->ncached == tbin_info->ncached_max) {
- tcache_bin_flush_small(tbin, binind, (tbin_info->ncached_max >>
- 1)
+ if (tbin->ncached == tbin->ncached_max) {
+ tcache_bin_flush_small(tbin, binind, (tbin->ncached_max >> 1)
#if (defined(JEMALLOC_STATS) || defined(JEMALLOC_PROF))
, tcache
#endif
);
}
- assert(tbin->ncached < tbin_info->ncached_max);
- tbin->avail[tbin->ncached] = ptr;
+ assert(tbin->ncached < tbin->ncached_max);
+ *(void **)ptr = tbin->avail;
+ tbin->avail = ptr;
tbin->ncached++;
+ if (tbin->ncached > tbin->high_water)
+ tbin->high_water = tbin->ncached;
tcache_event(tcache);
}
@@ -392,7 +361,6 @@ tcache_dalloc_large(tcache_t *tcache, void *ptr, size_t size)
arena_chunk_t *chunk;
size_t pageind, binind;
tcache_bin_t *tbin;
- tcache_bin_info_t *tbin_info;
assert((size & PAGE_MASK) == 0);
assert(arena_salloc(ptr) > small_maxclass);
@@ -409,18 +377,19 @@ tcache_dalloc_large(tcache_t *tcache, void *ptr, size_t size)
#endif
tbin = &tcache->tbins[binind];
- tbin_info = &tcache_bin_info[binind];
- if (tbin->ncached == tbin_info->ncached_max) {
- tcache_bin_flush_large(tbin, binind, (tbin_info->ncached_max >>
- 1)
+ if (tbin->ncached == tbin->ncached_max) {
+ tcache_bin_flush_large(tbin, binind, (tbin->ncached_max >> 1)
#if (defined(JEMALLOC_STATS) || defined(JEMALLOC_PROF))
, tcache
#endif
);
}
- assert(tbin->ncached < tbin_info->ncached_max);
- tbin->avail[tbin->ncached] = ptr;
+ assert(tbin->ncached < tbin->ncached_max);
+ *(void **)ptr = tbin->avail;
+ tbin->avail = ptr;
tbin->ncached++;
+ if (tbin->ncached > tbin->high_water)
+ tbin->high_water = tbin->ncached;
tcache_event(tcache);
}
diff --git a/dep/jemalloc/include/jemalloc/jemalloc.h b/dep/jemalloc/include/jemalloc/jemalloc.h
index 3842e28115e..287dac46ed2 100644
--- a/dep/jemalloc/include/jemalloc/jemalloc.h
+++ b/dep/jemalloc/include/jemalloc/jemalloc.h
@@ -7,19 +7,19 @@ extern "C" {
#include <limits.h>
#include <strings.h>
-#define JEMALLOC_VERSION "2.2.5-0-gfc1bb70e5f0d9a58b39efa39cc549b5af5104760"
+#define JEMALLOC_VERSION "2.1.0-0-g1c4b088b08d3bc7617a34387e196ce03716160bf"
#define JEMALLOC_VERSION_MAJOR 2
-#define JEMALLOC_VERSION_MINOR 2
-#define JEMALLOC_VERSION_BUGFIX 5
+#define JEMALLOC_VERSION_MINOR 1
+#define JEMALLOC_VERSION_BUGFIX 0
#define JEMALLOC_VERSION_NREV 0
-#define JEMALLOC_VERSION_GID "fc1bb70e5f0d9a58b39efa39cc549b5af5104760"
+#define JEMALLOC_VERSION_GID "1c4b088b08d3bc7617a34387e196ce03716160bf"
#include "jemalloc_defs.h"
#ifndef JEMALLOC_P
# define JEMALLOC_P(s) s
#endif
-#define ALLOCM_LG_ALIGN(la) (la)
+#define ALLOCM_LG_ALIGN ((int)0x3f)
#if LG_SIZEOF_PTR == 2
#define ALLOCM_ALIGN(a) (ffs(a)-1)
#else
diff --git a/dep/jemalloc/include/jemalloc/jemalloc_defs.h b/dep/jemalloc/include/jemalloc/jemalloc_defs.h
index f0f8fa71a4d..a641b56da03 100644
--- a/dep/jemalloc/include/jemalloc/jemalloc_defs.h
+++ b/dep/jemalloc/include/jemalloc/jemalloc_defs.h
@@ -20,32 +20,11 @@
#endif
/*
- * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs.
- * For shared libraries, symbol visibility mechanisms prevent these symbols
- * from being exported, but for static libraries, naming collisions are a real
- * possibility.
- */
-#define JEMALLOC_PRIVATE_NAMESPACE ""
-#define JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix) string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix
-
-/*
* Hyper-threaded CPUs may need a special instruction inside spin loops in
* order to yield to another virtual CPU.
*/
#define CPU_SPINWAIT __asm__ volatile("pause")
-/*
- * Defined if OSAtomic*() functions are available, as provided by Darwin, and
- * documented in the atomic(3) manual page.
- */
-/* #undef JEMALLOC_OSATOMIC */
-
-/*
- * Defined if OSSpin*() functions are available, as provided by Darwin, and
- * documented in the spinlock(3) manual page.
- */
-/* #undef JEMALLOC_OSSPIN */
-
/* Defined if __attribute__((...)) syntax is supported. */
#define JEMALLOC_HAVE_ATTR
#ifdef JEMALLOC_HAVE_ATTR
@@ -75,21 +54,18 @@
/* Use libgcc for profile backtracing if defined. */
/* #undef JEMALLOC_PROF_LIBGCC */
-/* Use gcc intrinsics for profile backtracing if defined. */
-/* #undef JEMALLOC_PROF_GCC */
-
/*
* JEMALLOC_TINY enables support for tiny objects, which are smaller than one
* quantum.
*/
-#define JEMALLOC_TINY
+/* #undef JEMALLOC_TINY */
/*
* JEMALLOC_TCACHE enables a thread-specific caching layer for small objects.
* This makes it possible to allocate/deallocate objects without any locking
* when the cache is in the steady state.
*/
-#define JEMALLOC_TCACHE
+/* #undef JEMALLOC_TCACHE */
/*
* JEMALLOC_DSS enables use of sbrk(2) to allocate chunks from the data storage
@@ -110,7 +86,7 @@
/* #undef JEMALLOC_SYSV */
/* Support lazy locking (avoid locking unless a second thread is launched). */
-#define JEMALLOC_LAZY_LOCK
+/* #undef JEMALLOC_LAZY_LOCK */
/* Determine page size at run time if defined. */
/* #undef DYNAMIC_PAGE_SHIFT */
@@ -157,12 +133,9 @@
/* #undef JEMALLOC_PURGE_MADVISE_FREE */
/* sizeof(void *) == 2^LG_SIZEOF_PTR. */
-#define LG_SIZEOF_PTR 3
+#define LG_SIZEOF_PTR 2
/* sizeof(int) == 2^LG_SIZEOF_INT. */
#define LG_SIZEOF_INT 2
-/* sizeof(long) == 2^LG_SIZEOF_LONG. */
-#define LG_SIZEOF_LONG 3
-
#endif /* JEMALLOC_DEFS_H_ */
diff --git a/dep/jemalloc/src/arena.c b/dep/jemalloc/src/arena.c
index d166ca1ec4d..7f939b3cd77 100644
--- a/dep/jemalloc/src/arena.c
+++ b/dep/jemalloc/src/arena.c
@@ -8,7 +8,6 @@ size_t opt_lg_qspace_max = LG_QSPACE_MAX_DEFAULT;
size_t opt_lg_cspace_max = LG_CSPACE_MAX_DEFAULT;
ssize_t opt_lg_dirty_mult = LG_DIRTY_MULT_DEFAULT;
uint8_t const *small_size2bin;
-arena_bin_info_t *arena_bin_info;
/* Various bin-related settings. */
unsigned nqbins;
@@ -26,27 +25,26 @@ size_t mspace_mask;
/*
* const_small_size2bin is a static constant lookup table that in the common
- * case can be used as-is for small_size2bin.
+ * case can be used as-is for small_size2bin. For dynamically linked programs,
+ * this avoids a page of memory overhead per process.
*/
-#if (LG_TINY_MIN == 2)
-#define S2B_4(i) i,
+#define S2B_1(i) i,
+#define S2B_2(i) S2B_1(i) S2B_1(i)
+#define S2B_4(i) S2B_2(i) S2B_2(i)
#define S2B_8(i) S2B_4(i) S2B_4(i)
-#elif (LG_TINY_MIN == 3)
-#define S2B_8(i) i,
-#else
-# error "Unsupported LG_TINY_MIN"
-#endif
#define S2B_16(i) S2B_8(i) S2B_8(i)
#define S2B_32(i) S2B_16(i) S2B_16(i)
#define S2B_64(i) S2B_32(i) S2B_32(i)
#define S2B_128(i) S2B_64(i) S2B_64(i)
#define S2B_256(i) S2B_128(i) S2B_128(i)
/*
- * The number of elements in const_small_size2bin is dependent on the
- * definition for SUBPAGE.
+ * The number of elements in const_small_size2bin is dependent on page size
+ * and on the definition for SUBPAGE. If SUBPAGE changes, the '- 255' must also
+ * change, along with the addition/removal of static lookup table element
+ * definitions.
*/
-static JEMALLOC_ATTR(aligned(CACHELINE))
- const uint8_t const_small_size2bin[] = {
+static const uint8_t const_small_size2bin[STATIC_PAGE_SIZE - 255] = {
+ S2B_1(0xffU) /* 0 */
#if (LG_QUANTUM == 4)
/* 16-byte quantum **********************/
# ifdef JEMALLOC_TINY
@@ -175,6 +173,7 @@ static void arena_run_trim_tail(arena_t *arena, arena_chunk_t *chunk,
arena_run_t *run, size_t oldsize, size_t newsize, bool dirty);
static arena_run_t *arena_bin_nonfull_run_get(arena_t *arena, arena_bin_t *bin);
static void *arena_bin_malloc_hard(arena_t *arena, arena_bin_t *bin);
+static size_t arena_bin_run_size_calc(arena_bin_t *bin, size_t min_run_size);
static void arena_dissociate_bin_run(arena_chunk_t *chunk, arena_run_t *run,
arena_bin_t *bin);
static void arena_dalloc_bin_run(arena_t *arena, arena_chunk_t *chunk,
@@ -192,9 +191,6 @@ static bool small_size2bin_init(void);
static void small_size2bin_validate(void);
#endif
static bool small_size2bin_init_hard(void);
-static size_t bin_info_run_size_calc(arena_bin_info_t *bin_info,
- size_t min_run_size);
-static bool bin_info_init(void);
/******************************************************************************/
@@ -250,48 +246,57 @@ rb_gen(static JEMALLOC_ATTR(unused), arena_avail_tree_, arena_avail_tree_t,
arena_chunk_map_t, u.rb_link, arena_avail_comp)
static inline void *
-arena_run_reg_alloc(arena_run_t *run, arena_bin_info_t *bin_info)
+arena_run_reg_alloc(arena_run_t *run, arena_bin_t *bin)
{
void *ret;
- unsigned regind;
- bitmap_t *bitmap = (bitmap_t *)((uintptr_t)run +
- (uintptr_t)bin_info->bitmap_offset);
- dassert(run->magic == ARENA_RUN_MAGIC);
+ assert(run->magic == ARENA_RUN_MAGIC);
assert(run->nfree > 0);
- assert(bitmap_full(bitmap, &bin_info->bitmap_info) == false);
- regind = bitmap_sfu(bitmap, &bin_info->bitmap_info);
- ret = (void *)((uintptr_t)run + (uintptr_t)bin_info->reg0_offset +
- (uintptr_t)(bin_info->reg_size * regind));
run->nfree--;
- if (regind == run->nextind)
- run->nextind++;
- assert(regind < run->nextind);
+ ret = run->avail;
+ if (ret != NULL) {
+ /* Double free can cause assertion failure.*/
+ assert(ret != NULL);
+ /* Write-after free can cause assertion failure. */
+ assert((uintptr_t)ret >= (uintptr_t)run +
+ (uintptr_t)bin->reg0_offset);
+ assert((uintptr_t)ret < (uintptr_t)run->next);
+ assert(((uintptr_t)ret - ((uintptr_t)run +
+ (uintptr_t)bin->reg0_offset)) % (uintptr_t)bin->reg_size ==
+ 0);
+ run->avail = *(void **)ret;
+ return (ret);
+ }
+ ret = run->next;
+ run->next = (void *)((uintptr_t)ret + (uintptr_t)bin->reg_size);
+ assert(ret != NULL);
return (ret);
}
static inline void
arena_run_reg_dalloc(arena_run_t *run, void *ptr)
{
- arena_chunk_t *chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(run);
- size_t binind = arena_bin_index(chunk->arena, run->bin);
- arena_bin_info_t *bin_info = &arena_bin_info[binind];
- unsigned regind = arena_run_regind(run, bin_info, ptr);
- bitmap_t *bitmap = (bitmap_t *)((uintptr_t)run +
- (uintptr_t)bin_info->bitmap_offset);
-
- assert(run->nfree < bin_info->nregs);
+
+ assert(run->nfree < run->bin->nregs);
/* Freeing an interior pointer can cause assertion failure. */
assert(((uintptr_t)ptr - ((uintptr_t)run +
- (uintptr_t)bin_info->reg0_offset)) % (uintptr_t)bin_info->reg_size
+ (uintptr_t)run->bin->reg0_offset)) % (uintptr_t)run->bin->reg_size
== 0);
+ /*
+ * Freeing a pointer lower than region zero can cause assertion
+ * failure.
+ */
assert((uintptr_t)ptr >= (uintptr_t)run +
- (uintptr_t)bin_info->reg0_offset);
- /* Freeing an unallocated pointer can cause assertion failure. */
- assert(bitmap_get(bitmap, &bin_info->bitmap_info, regind));
+ (uintptr_t)run->bin->reg0_offset);
+ /*
+ * Freeing a pointer past in the run's frontier can cause assertion
+ * failure.
+ */
+ assert((uintptr_t)ptr < (uintptr_t)run->next);
- bitmap_unset(bitmap, &bin_info->bitmap_info, regind);
+ *(void **)ptr = run->avail;
+ run->avail = ptr;
run->nfree++;
}
@@ -315,9 +320,6 @@ arena_run_split(arena_t *arena, arena_run_t *run, size_t size, bool large,
size_t old_ndirty, run_ind, total_pages, need_pages, rem_pages, i;
size_t flag_dirty;
arena_avail_tree_t *runs_avail;
-#ifdef JEMALLOC_STATS
- size_t cactive_diff;
-#endif
chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(run);
old_ndirty = chunk->ndirty;
@@ -336,13 +338,6 @@ arena_run_split(arena_t *arena, arena_run_t *run, size_t size, bool large,
rem_pages = total_pages - need_pages;
arena_avail_tree_remove(runs_avail, &chunk->map[run_ind-map_bias]);
-#ifdef JEMALLOC_STATS
- /* Update stats_cactive if nactive is crossing a chunk multiple. */
- cactive_diff = CHUNK_CEILING((arena->nactive + need_pages) <<
- PAGE_SHIFT) - CHUNK_CEILING(arena->nactive << PAGE_SHIFT);
- if (cactive_diff != 0)
- stats_cactive_add(cactive_diff);
-#endif
arena->nactive += need_pages;
/* Keep track of trailing unused pages for later use. */
@@ -569,7 +564,7 @@ arena_chunk_dealloc(arena_t *arena, arena_chunk_t *chunk)
arena->ndirty -= spare->ndirty;
}
malloc_mutex_unlock(&arena->lock);
- chunk_dealloc((void *)spare, chunksize, true);
+ chunk_dealloc((void *)spare, chunksize);
malloc_mutex_lock(&arena->lock);
#ifdef JEMALLOC_STATS
arena->stats.mapped -= chunksize;
@@ -730,9 +725,6 @@ arena_chunk_purge(arena_t *arena, arena_chunk_t *chunk)
assert(pageind + npages <= chunk_npages);
if (mapelm->bits & CHUNK_MAP_DIRTY) {
size_t i;
-#ifdef JEMALLOC_STATS
- size_t cactive_diff;
-#endif
arena_avail_tree_remove(
&arena->runs_avail_dirty, mapelm);
@@ -755,17 +747,6 @@ arena_chunk_purge(arena_t *arena, arena_chunk_t *chunk)
CHUNK_MAP_ALLOCATED;
}
-#ifdef JEMALLOC_STATS
- /*
- * Update stats_cactive if nactive is crossing a
- * chunk multiple.
- */
- cactive_diff = CHUNK_CEILING((arena->nactive +
- npages) << PAGE_SHIFT) -
- CHUNK_CEILING(arena->nactive << PAGE_SHIFT);
- if (cactive_diff != 0)
- stats_cactive_add(cactive_diff);
-#endif
arena->nactive += npages;
/* Append to list for later processing. */
ql_elm_new(mapelm, u.ql_link);
@@ -782,12 +763,8 @@ arena_chunk_purge(arena_t *arena, arena_chunk_t *chunk)
chunk + (uintptr_t)(pageind << PAGE_SHIFT));
assert((mapelm->bits >> PAGE_SHIFT) == 0);
- dassert(run->magic == ARENA_RUN_MAGIC);
- size_t binind = arena_bin_index(arena,
- run->bin);
- arena_bin_info_t *bin_info =
- &arena_bin_info[binind];
- pageind += bin_info->run_size >> PAGE_SHIFT;
+ assert(run->magic == ARENA_RUN_MAGIC);
+ pageind += run->bin->run_size >> PAGE_SHIFT;
}
}
}
@@ -868,10 +845,9 @@ arena_purge(arena_t *arena, bool all)
}
assert(ndirty == arena->ndirty);
#endif
- assert(arena->ndirty > arena->npurgatory || all);
- assert(arena->ndirty - arena->npurgatory > chunk_npages || all);
- assert((arena->nactive >> opt_lg_dirty_mult) < (arena->ndirty -
- arena->npurgatory) || all);
+ assert(arena->ndirty > arena->npurgatory);
+ assert(arena->ndirty > chunk_npages || all);
+ assert((arena->nactive >> opt_lg_dirty_mult) < arena->ndirty || all);
#ifdef JEMALLOC_STATS
arena->stats.npurge++;
@@ -883,10 +859,8 @@ arena_purge(arena_t *arena, bool all)
* multiple threads from racing to reduce ndirty below the threshold.
*/
npurgatory = arena->ndirty - arena->npurgatory;
- if (all == false) {
- assert(npurgatory >= arena->nactive >> opt_lg_dirty_mult);
+ if (all == false)
npurgatory -= arena->nactive >> opt_lg_dirty_mult;
- }
arena->npurgatory += npurgatory;
while (npurgatory > 0) {
@@ -957,9 +931,6 @@ arena_run_dalloc(arena_t *arena, arena_run_t *run, bool dirty)
arena_chunk_t *chunk;
size_t size, run_ind, run_pages, flag_dirty;
arena_avail_tree_t *runs_avail;
-#ifdef JEMALLOC_STATS
- size_t cactive_diff;
-#endif
chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(run);
run_ind = (size_t)(((uintptr_t)run - (uintptr_t)chunk)
@@ -975,19 +946,9 @@ arena_run_dalloc(arena_t *arena, arena_run_t *run, bool dirty)
CHUNK_MAP_LARGE) != 0);
assert((chunk->map[run_ind+(size>>PAGE_SHIFT)-1-map_bias].bits &
CHUNK_MAP_ALLOCATED) != 0);
- } else {
- size_t binind = arena_bin_index(arena, run->bin);
- arena_bin_info_t *bin_info = &arena_bin_info[binind];
- size = bin_info->run_size;
- }
+ } else
+ size = run->bin->run_size;
run_pages = (size >> PAGE_SHIFT);
-#ifdef JEMALLOC_STATS
- /* Update stats_cactive if nactive is crossing a chunk multiple. */
- cactive_diff = CHUNK_CEILING(arena->nactive << PAGE_SHIFT) -
- CHUNK_CEILING((arena->nactive - run_pages) << PAGE_SHIFT);
- if (cactive_diff != 0)
- stats_cactive_sub(cactive_diff);
-#endif
arena->nactive -= run_pages;
/*
@@ -1213,8 +1174,6 @@ arena_bin_nonfull_run_get(arena_t *arena, arena_bin_t *bin)
{
arena_chunk_map_t *mapelm;
arena_run_t *run;
- size_t binind;
- arena_bin_info_t *bin_info;
/* Look for a usable run. */
mapelm = arena_run_tree_first(&bin->runs);
@@ -1238,23 +1197,18 @@ arena_bin_nonfull_run_get(arena_t *arena, arena_bin_t *bin)
}
/* No existing runs have any space available. */
- binind = arena_bin_index(arena, bin);
- bin_info = &arena_bin_info[binind];
-
/* Allocate a new run. */
malloc_mutex_unlock(&bin->lock);
/******************************/
malloc_mutex_lock(&arena->lock);
- run = arena_run_alloc(arena, bin_info->run_size, false, false);
+ run = arena_run_alloc(arena, bin->run_size, false, false);
if (run != NULL) {
- bitmap_t *bitmap = (bitmap_t *)((uintptr_t)run +
- (uintptr_t)bin_info->bitmap_offset);
-
/* Initialize run internals. */
run->bin = bin;
- run->nextind = 0;
- run->nfree = bin_info->nregs;
- bitmap_init(bitmap, &bin_info->bitmap_info);
+ run->avail = NULL;
+ run->next = (void *)((uintptr_t)run +
+ (uintptr_t)bin->reg0_offset);
+ run->nfree = bin->nregs;
#ifdef JEMALLOC_DEBUG
run->magic = ARENA_RUN_MAGIC;
#endif
@@ -1305,12 +1259,8 @@ static void *
arena_bin_malloc_hard(arena_t *arena, arena_bin_t *bin)
{
void *ret;
- size_t binind;
- arena_bin_info_t *bin_info;
arena_run_t *run;
- binind = arena_bin_index(arena, bin);
- bin_info = &arena_bin_info[binind];
bin->runcur = NULL;
run = arena_bin_nonfull_run_get(arena, bin);
if (bin->runcur != NULL && bin->runcur->nfree > 0) {
@@ -1318,22 +1268,22 @@ arena_bin_malloc_hard(arena_t *arena, arena_bin_t *bin)
* Another thread updated runcur while this one ran without the
* bin lock in arena_bin_nonfull_run_get().
*/
- dassert(bin->runcur->magic == ARENA_RUN_MAGIC);
+ assert(bin->runcur->magic == ARENA_RUN_MAGIC);
assert(bin->runcur->nfree > 0);
- ret = arena_run_reg_alloc(bin->runcur, bin_info);
+ ret = arena_run_reg_alloc(bin->runcur, bin);
if (run != NULL) {
arena_chunk_t *chunk;
/*
* arena_run_alloc() may have allocated run, or it may
- * have pulled run from the bin's run tree. Therefore
+ * have pulled it from the bin's run tree. Therefore
* it is unsafe to make any assumptions about how run
* has previously been used, and arena_bin_lower_run()
* must be called, as if a region were just deallocated
* from the run.
*/
chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(run);
- if (run->nfree == bin_info->nregs)
+ if (run->nfree == bin->nregs)
arena_dalloc_bin_run(arena, chunk, run, bin);
else
arena_bin_lower_run(arena, chunk, run, bin);
@@ -1346,10 +1296,10 @@ arena_bin_malloc_hard(arena_t *arena, arena_bin_t *bin)
bin->runcur = run;
- dassert(bin->runcur->magic == ARENA_RUN_MAGIC);
+ assert(bin->runcur->magic == ARENA_RUN_MAGIC);
assert(bin->runcur->nfree > 0);
- return (arena_run_reg_alloc(bin->runcur, bin_info));
+ return (arena_run_reg_alloc(bin->runcur, bin));
}
#ifdef JEMALLOC_PROF
@@ -1389,19 +1339,18 @@ arena_tcache_fill_small(arena_t *arena, tcache_bin_t *tbin, size_t binind
#endif
bin = &arena->bins[binind];
malloc_mutex_lock(&bin->lock);
- for (i = 0, nfill = (tcache_bin_info[binind].ncached_max >>
- tbin->lg_fill_div); i < nfill; i++) {
+ for (i = 0, nfill = (tbin->ncached_max >> 1); i < nfill; i++) {
if ((run = bin->runcur) != NULL && run->nfree > 0)
- ptr = arena_run_reg_alloc(run, &arena_bin_info[binind]);
+ ptr = arena_run_reg_alloc(run, bin);
else
ptr = arena_bin_malloc_hard(arena, bin);
if (ptr == NULL)
break;
- /* Insert such that low regions get used first. */
- tbin->avail[nfill - 1 - i] = ptr;
+ *(void **)ptr = tbin->avail;
+ tbin->avail = ptr;
}
#ifdef JEMALLOC_STATS
- bin->stats.allocated += i * arena_bin_info[binind].reg_size;
+ bin->stats.allocated += (i - tbin->ncached) * bin->reg_size;
bin->stats.nmalloc += i;
bin->stats.nrequests += tbin->tstats.nrequests;
bin->stats.nfills++;
@@ -1409,9 +1358,119 @@ arena_tcache_fill_small(arena_t *arena, tcache_bin_t *tbin, size_t binind
#endif
malloc_mutex_unlock(&bin->lock);
tbin->ncached = i;
+ if (tbin->ncached > tbin->high_water)
+ tbin->high_water = tbin->ncached;
}
#endif
+/*
+ * Calculate bin->run_size such that it meets the following constraints:
+ *
+ * *) bin->run_size >= min_run_size
+ * *) bin->run_size <= arena_maxclass
+ * *) run header overhead <= RUN_MAX_OVRHD (or header overhead relaxed).
+ * *) run header size < PAGE_SIZE
+ *
+ * bin->nregs and bin->reg0_offset are also calculated here, since these
+ * settings are all interdependent.
+ */
+static size_t
+arena_bin_run_size_calc(arena_bin_t *bin, size_t min_run_size)
+{
+ size_t try_run_size, good_run_size;
+ uint32_t try_nregs, good_nregs;
+ uint32_t try_hdr_size, good_hdr_size;
+#ifdef JEMALLOC_PROF
+ uint32_t try_ctx0_offset, good_ctx0_offset;
+#endif
+ uint32_t try_reg0_offset, good_reg0_offset;
+
+ assert(min_run_size >= PAGE_SIZE);
+ assert(min_run_size <= arena_maxclass);
+
+ /*
+ * Calculate known-valid settings before entering the run_size
+ * expansion loop, so that the first part of the loop always copies
+ * valid settings.
+ *
+ * The do..while loop iteratively reduces the number of regions until
+ * the run header and the regions no longer overlap. A closed formula
+ * would be quite messy, since there is an interdependency between the
+ * header's mask length and the number of regions.
+ */
+ try_run_size = min_run_size;
+ try_nregs = ((try_run_size - sizeof(arena_run_t)) / bin->reg_size)
+ + 1; /* Counter-act try_nregs-- in loop. */
+ do {
+ try_nregs--;
+ try_hdr_size = sizeof(arena_run_t);
+#ifdef JEMALLOC_PROF
+ if (opt_prof && prof_promote == false) {
+ /* Pad to a quantum boundary. */
+ try_hdr_size = QUANTUM_CEILING(try_hdr_size);
+ try_ctx0_offset = try_hdr_size;
+ /* Add space for one (prof_ctx_t *) per region. */
+ try_hdr_size += try_nregs * sizeof(prof_ctx_t *);
+ } else
+ try_ctx0_offset = 0;
+#endif
+ try_reg0_offset = try_run_size - (try_nregs * bin->reg_size);
+ } while (try_hdr_size > try_reg0_offset);
+
+ /* run_size expansion loop. */
+ do {
+ /*
+ * Copy valid settings before trying more aggressive settings.
+ */
+ good_run_size = try_run_size;
+ good_nregs = try_nregs;
+ good_hdr_size = try_hdr_size;
+#ifdef JEMALLOC_PROF
+ good_ctx0_offset = try_ctx0_offset;
+#endif
+ good_reg0_offset = try_reg0_offset;
+
+ /* Try more aggressive settings. */
+ try_run_size += PAGE_SIZE;
+ try_nregs = ((try_run_size - sizeof(arena_run_t)) /
+ bin->reg_size) + 1; /* Counter-act try_nregs-- in loop. */
+ do {
+ try_nregs--;
+ try_hdr_size = sizeof(arena_run_t);
+#ifdef JEMALLOC_PROF
+ if (opt_prof && prof_promote == false) {
+ /* Pad to a quantum boundary. */
+ try_hdr_size = QUANTUM_CEILING(try_hdr_size);
+ try_ctx0_offset = try_hdr_size;
+ /*
+ * Add space for one (prof_ctx_t *) per region.
+ */
+ try_hdr_size += try_nregs *
+ sizeof(prof_ctx_t *);
+ }
+#endif
+ try_reg0_offset = try_run_size - (try_nregs *
+ bin->reg_size);
+ } while (try_hdr_size > try_reg0_offset);
+ } while (try_run_size <= arena_maxclass
+ && try_run_size <= arena_maxclass
+ && RUN_MAX_OVRHD * (bin->reg_size << 3) > RUN_MAX_OVRHD_RELAX
+ && (try_reg0_offset << RUN_BFP) > RUN_MAX_OVRHD * try_run_size
+ && try_hdr_size < PAGE_SIZE);
+
+ assert(good_hdr_size <= good_reg0_offset);
+
+ /* Copy final settings. */
+ bin->run_size = good_run_size;
+ bin->nregs = good_nregs;
+#ifdef JEMALLOC_PROF
+ bin->ctx0_offset = good_ctx0_offset;
+#endif
+ bin->reg0_offset = good_reg0_offset;
+
+ return (good_run_size);
+}
+
void *
arena_malloc_small(arena_t *arena, size_t size, bool zero)
{
@@ -1420,14 +1479,14 @@ arena_malloc_small(arena_t *arena, size_t size, bool zero)
arena_run_t *run;
size_t binind;
- binind = SMALL_SIZE2BIN(size);
+ binind = small_size2bin[size];
assert(binind < nbins);
bin = &arena->bins[binind];
- size = arena_bin_info[binind].reg_size;
+ size = bin->reg_size;
malloc_mutex_lock(&bin->lock);
if ((run = bin->runcur) != NULL && run->nfree > 0)
- ret = arena_run_reg_alloc(run, &arena_bin_info[binind]);
+ ret = arena_run_reg_alloc(run, bin);
else
ret = arena_bin_malloc_hard(arena, bin);
@@ -1631,13 +1690,11 @@ arena_salloc(const void *ptr)
arena_run_t *run = (arena_run_t *)((uintptr_t)chunk +
(uintptr_t)((pageind - (mapbits >> PAGE_SHIFT)) <<
PAGE_SHIFT));
- dassert(run->magic == ARENA_RUN_MAGIC);
- size_t binind = arena_bin_index(chunk->arena, run->bin);
- arena_bin_info_t *bin_info = &arena_bin_info[binind];
+ assert(run->magic == ARENA_RUN_MAGIC);
assert(((uintptr_t)ptr - ((uintptr_t)run +
- (uintptr_t)bin_info->reg0_offset)) % bin_info->reg_size ==
+ (uintptr_t)run->bin->reg0_offset)) % run->bin->reg_size ==
0);
- ret = bin_info->reg_size;
+ ret = run->bin->reg_size;
} else {
assert(((uintptr_t)ptr & PAGE_MASK) == 0);
ret = mapbits & ~PAGE_MASK;
@@ -1657,11 +1714,10 @@ arena_prof_promoted(const void *ptr, size_t size)
assert(ptr != NULL);
assert(CHUNK_ADDR2BASE(ptr) != ptr);
assert(isalloc(ptr) == PAGE_SIZE);
- assert(size <= small_maxclass);
chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr);
pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> PAGE_SHIFT;
- binind = SMALL_SIZE2BIN(size);
+ binind = small_size2bin[size];
assert(binind < nbins);
chunk->map[pageind-map_bias].bits = (chunk->map[pageind-map_bias].bits &
~CHUNK_MAP_CLASS_MASK) | ((binind+1) << CHUNK_MAP_CLASS_SHIFT);
@@ -1685,13 +1741,11 @@ arena_salloc_demote(const void *ptr)
arena_run_t *run = (arena_run_t *)((uintptr_t)chunk +
(uintptr_t)((pageind - (mapbits >> PAGE_SHIFT)) <<
PAGE_SHIFT));
- dassert(run->magic == ARENA_RUN_MAGIC);
- size_t binind = arena_bin_index(chunk->arena, run->bin);
- arena_bin_info_t *bin_info = &arena_bin_info[binind];
+ assert(run->magic == ARENA_RUN_MAGIC);
assert(((uintptr_t)ptr - ((uintptr_t)run +
- (uintptr_t)bin_info->reg0_offset)) % bin_info->reg_size ==
+ (uintptr_t)run->bin->reg0_offset)) % run->bin->reg_size ==
0);
- ret = bin_info->reg_size;
+ ret = run->bin->reg_size;
} else {
assert(((uintptr_t)ptr & PAGE_MASK) == 0);
ret = mapbits & ~PAGE_MASK;
@@ -1700,7 +1754,7 @@ arena_salloc_demote(const void *ptr)
size_t binind = ((mapbits & CHUNK_MAP_CLASS_MASK) >>
CHUNK_MAP_CLASS_SHIFT) - 1;
assert(binind < nbins);
- ret = arena_bin_info[binind].reg_size;
+ ret = chunk->arena->bins[binind].reg_size;
}
assert(ret != 0);
}
@@ -1717,22 +1771,17 @@ arena_dissociate_bin_run(arena_chunk_t *chunk, arena_run_t *run,
/* Dissociate run from bin. */
if (run == bin->runcur)
bin->runcur = NULL;
- else {
- size_t binind = arena_bin_index(chunk->arena, bin);
- arena_bin_info_t *bin_info = &arena_bin_info[binind];
-
- if (bin_info->nregs != 1) {
- size_t run_pageind = (((uintptr_t)run -
- (uintptr_t)chunk)) >> PAGE_SHIFT;
- arena_chunk_map_t *run_mapelm =
- &chunk->map[run_pageind-map_bias];
- /*
- * This block's conditional is necessary because if the
- * run only contains one region, then it never gets
- * inserted into the non-full runs tree.
- */
- arena_run_tree_remove(&bin->runs, run_mapelm);
- }
+ else if (bin->nregs != 1) {
+ size_t run_pageind = (((uintptr_t)run - (uintptr_t)chunk)) >>
+ PAGE_SHIFT;
+ arena_chunk_map_t *run_mapelm =
+ &chunk->map[run_pageind-map_bias];
+ /*
+ * This block's conditional is necessary because if the run
+ * only contains one region, then it never gets inserted into
+ * the non-full runs tree.
+ */
+ arena_run_tree_remove(&bin->runs, run_mapelm);
}
}
@@ -1740,24 +1789,18 @@ static void
arena_dalloc_bin_run(arena_t *arena, arena_chunk_t *chunk, arena_run_t *run,
arena_bin_t *bin)
{
- size_t binind;
- arena_bin_info_t *bin_info;
size_t npages, run_ind, past;
assert(run != bin->runcur);
assert(arena_run_tree_search(&bin->runs, &chunk->map[
(((uintptr_t)run-(uintptr_t)chunk)>>PAGE_SHIFT)-map_bias]) == NULL);
- binind = arena_bin_index(chunk->arena, run->bin);
- bin_info = &arena_bin_info[binind];
-
malloc_mutex_unlock(&bin->lock);
/******************************/
- npages = bin_info->run_size >> PAGE_SHIFT;
+ npages = bin->run_size >> PAGE_SHIFT;
run_ind = (size_t)(((uintptr_t)run - (uintptr_t)chunk) >> PAGE_SHIFT);
- past = (size_t)(PAGE_CEILING((uintptr_t)run +
- (uintptr_t)bin_info->reg0_offset + (uintptr_t)(run->nextind *
- bin_info->reg_size) - (uintptr_t)chunk) >> PAGE_SHIFT);
+ past = (size_t)((PAGE_CEILING((uintptr_t)run->next) - (uintptr_t)chunk)
+ >> PAGE_SHIFT);
malloc_mutex_lock(&arena->lock);
/*
@@ -1774,7 +1817,7 @@ arena_dalloc_bin_run(arena_t *arena, arena_chunk_t *chunk, arena_run_t *run,
chunk->map[run_ind+npages-1-map_bias].bits = CHUNK_MAP_LARGE |
(chunk->map[run_ind+npages-1-map_bias].bits &
CHUNK_MAP_FLAGS_MASK);
- chunk->map[run_ind-map_bias].bits = bin_info->run_size |
+ chunk->map[run_ind-map_bias].bits = bin->run_size |
CHUNK_MAP_LARGE | (chunk->map[run_ind-map_bias].bits &
CHUNK_MAP_FLAGS_MASK);
arena_run_trim_tail(arena, chunk, run, (npages << PAGE_SHIFT),
@@ -1843,12 +1886,10 @@ arena_dalloc_bin(arena_t *arena, arena_chunk_t *chunk, void *ptr,
pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> PAGE_SHIFT;
run = (arena_run_t *)((uintptr_t)chunk + (uintptr_t)((pageind -
(mapelm->bits >> PAGE_SHIFT)) << PAGE_SHIFT));
- dassert(run->magic == ARENA_RUN_MAGIC);
+ assert(run->magic == ARENA_RUN_MAGIC);
bin = run->bin;
- size_t binind = arena_bin_index(arena, bin);
- arena_bin_info_t *bin_info = &arena_bin_info[binind];
#if (defined(JEMALLOC_FILL) || defined(JEMALLOC_STATS))
- size = bin_info->reg_size;
+ size = bin->reg_size;
#endif
#ifdef JEMALLOC_FILL
@@ -1857,7 +1898,7 @@ arena_dalloc_bin(arena_t *arena, arena_chunk_t *chunk, void *ptr,
#endif
arena_run_reg_dalloc(run, ptr);
- if (run->nfree == bin_info->nregs) {
+ if (run->nfree == bin->nregs) {
arena_dissociate_bin_run(chunk, run, bin);
arena_dalloc_bin_run(arena, chunk, run, bin);
} else if (run->nfree == 1 && run != bin->runcur)
@@ -2091,7 +2132,7 @@ arena_ralloc_large(void *ptr, size_t oldsize, size_t size, size_t extra,
chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr);
arena = chunk->arena;
- dassert(arena->magic == ARENA_MAGIC);
+ assert(arena->magic == ARENA_MAGIC);
if (psize < oldsize) {
#ifdef JEMALLOC_FILL
@@ -2129,11 +2170,11 @@ arena_ralloc_no_move(void *ptr, size_t oldsize, size_t size, size_t extra,
*/
if (oldsize <= arena_maxclass) {
if (oldsize <= small_maxclass) {
- assert(arena_bin_info[SMALL_SIZE2BIN(oldsize)].reg_size
- == oldsize);
+ assert(choose_arena()->bins[small_size2bin[
+ oldsize]].reg_size == oldsize);
if ((size + extra <= small_maxclass &&
- SMALL_SIZE2BIN(size + extra) ==
- SMALL_SIZE2BIN(oldsize)) || (size <= oldsize &&
+ small_size2bin[size + extra] ==
+ small_size2bin[oldsize]) || (size <= oldsize &&
size + extra >= oldsize)) {
#ifdef JEMALLOC_FILL
if (opt_junk && size < oldsize) {
@@ -2169,29 +2210,24 @@ arena_ralloc(void *ptr, size_t oldsize, size_t size, size_t extra,
if (ret != NULL)
return (ret);
+
/*
* size and oldsize are different enough that we need to move the
* object. In that case, fall back to allocating new space and
* copying.
*/
- if (alignment != 0) {
- size_t usize = sa2u(size + extra, alignment, NULL);
- if (usize == 0)
- return (NULL);
- ret = ipalloc(usize, alignment, zero);
- } else
+ if (alignment != 0)
+ ret = ipalloc(size + extra, alignment, zero);
+ else
ret = arena_malloc(size + extra, zero);
if (ret == NULL) {
if (extra == 0)
return (NULL);
/* Try again, this time without extra. */
- if (alignment != 0) {
- size_t usize = sa2u(size, alignment, NULL);
- if (usize == 0)
- return (NULL);
- ret = ipalloc(usize, alignment, zero);
- } else
+ if (alignment != 0)
+ ret = ipalloc(size, alignment, zero);
+ else
ret = arena_malloc(size, zero);
if (ret == NULL)
@@ -2215,9 +2251,9 @@ arena_new(arena_t *arena, unsigned ind)
{
unsigned i;
arena_bin_t *bin;
+ size_t prev_run_size;
arena->ind = ind;
- arena->nthreads = 0;
if (malloc_mutex_init(&arena->lock))
return (true);
@@ -2251,6 +2287,8 @@ arena_new(arena_t *arena, unsigned ind)
arena_avail_tree_new(&arena->runs_avail_dirty);
/* Initialize bins. */
+ prev_run_size = PAGE_SIZE;
+
i = 0;
#ifdef JEMALLOC_TINY
/* (2^n)-spaced tiny bins. */
@@ -2260,6 +2298,11 @@ arena_new(arena_t *arena, unsigned ind)
return (true);
bin->runcur = NULL;
arena_run_tree_new(&bin->runs);
+
+ bin->reg_size = (1U << (LG_TINY_MIN + i));
+
+ prev_run_size = arena_bin_run_size_calc(bin, prev_run_size);
+
#ifdef JEMALLOC_STATS
memset(&bin->stats, 0, sizeof(malloc_bin_stats_t));
#endif
@@ -2273,6 +2316,11 @@ arena_new(arena_t *arena, unsigned ind)
return (true);
bin->runcur = NULL;
arena_run_tree_new(&bin->runs);
+
+ bin->reg_size = (i - ntbins + 1) << LG_QUANTUM;
+
+ prev_run_size = arena_bin_run_size_calc(bin, prev_run_size);
+
#ifdef JEMALLOC_STATS
memset(&bin->stats, 0, sizeof(malloc_bin_stats_t));
#endif
@@ -2285,6 +2333,12 @@ arena_new(arena_t *arena, unsigned ind)
return (true);
bin->runcur = NULL;
arena_run_tree_new(&bin->runs);
+
+ bin->reg_size = cspace_min + ((i - (ntbins + nqbins)) <<
+ LG_CACHELINE);
+
+ prev_run_size = arena_bin_run_size_calc(bin, prev_run_size);
+
#ifdef JEMALLOC_STATS
memset(&bin->stats, 0, sizeof(malloc_bin_stats_t));
#endif
@@ -2297,6 +2351,12 @@ arena_new(arena_t *arena, unsigned ind)
return (true);
bin->runcur = NULL;
arena_run_tree_new(&bin->runs);
+
+ bin->reg_size = sspace_min + ((i - (ntbins + nqbins + ncbins))
+ << LG_SUBPAGE);
+
+ prev_run_size = arena_bin_run_size_calc(bin, prev_run_size);
+
#ifdef JEMALLOC_STATS
memset(&bin->stats, 0, sizeof(malloc_bin_stats_t));
#endif
@@ -2315,39 +2375,40 @@ small_size2bin_validate(void)
{
size_t i, size, binind;
+ assert(small_size2bin[0] == 0xffU);
i = 1;
# ifdef JEMALLOC_TINY
/* Tiny. */
for (; i < (1U << LG_TINY_MIN); i++) {
size = pow2_ceil(1U << LG_TINY_MIN);
binind = ffs((int)(size >> (LG_TINY_MIN + 1)));
- assert(SMALL_SIZE2BIN(i) == binind);
+ assert(small_size2bin[i] == binind);
}
for (; i < qspace_min; i++) {
size = pow2_ceil(i);
binind = ffs((int)(size >> (LG_TINY_MIN + 1)));
- assert(SMALL_SIZE2BIN(i) == binind);
+ assert(small_size2bin[i] == binind);
}
# endif
/* Quantum-spaced. */
for (; i <= qspace_max; i++) {
size = QUANTUM_CEILING(i);
binind = ntbins + (size >> LG_QUANTUM) - 1;
- assert(SMALL_SIZE2BIN(i) == binind);
+ assert(small_size2bin[i] == binind);
}
/* Cacheline-spaced. */
for (; i <= cspace_max; i++) {
size = CACHELINE_CEILING(i);
binind = ntbins + nqbins + ((size - cspace_min) >>
LG_CACHELINE);
- assert(SMALL_SIZE2BIN(i) == binind);
+ assert(small_size2bin[i] == binind);
}
/* Sub-page. */
for (; i <= sspace_max; i++) {
size = SUBPAGE_CEILING(i);
binind = ntbins + nqbins + ncbins + ((size - sspace_min)
>> LG_SUBPAGE);
- assert(SMALL_SIZE2BIN(i) == binind);
+ assert(small_size2bin[i] == binind);
}
}
#endif
@@ -2358,12 +2419,12 @@ small_size2bin_init(void)
if (opt_lg_qspace_max != LG_QSPACE_MAX_DEFAULT
|| opt_lg_cspace_max != LG_CSPACE_MAX_DEFAULT
- || (sizeof(const_small_size2bin) != ((small_maxclass-1) >>
- LG_TINY_MIN) + 1))
+ || sizeof(const_small_size2bin) != small_maxclass + 1)
return (small_size2bin_init_hard());
small_size2bin = const_small_size2bin;
#ifdef JEMALLOC_DEBUG
+ assert(sizeof(const_small_size2bin) == small_maxclass + 1);
small_size2bin_validate();
#endif
return (false);
@@ -2374,52 +2435,49 @@ small_size2bin_init_hard(void)
{
size_t i, size, binind;
uint8_t *custom_small_size2bin;
-#define CUSTOM_SMALL_SIZE2BIN(s) \
- custom_small_size2bin[(s-1) >> LG_TINY_MIN]
assert(opt_lg_qspace_max != LG_QSPACE_MAX_DEFAULT
|| opt_lg_cspace_max != LG_CSPACE_MAX_DEFAULT
- || (sizeof(const_small_size2bin) != ((small_maxclass-1) >>
- LG_TINY_MIN) + 1));
+ || sizeof(const_small_size2bin) != small_maxclass + 1);
- custom_small_size2bin = (uint8_t *)
- base_alloc(small_maxclass >> LG_TINY_MIN);
+ custom_small_size2bin = (uint8_t *)base_alloc(small_maxclass + 1);
if (custom_small_size2bin == NULL)
return (true);
+ custom_small_size2bin[0] = 0xffU;
i = 1;
#ifdef JEMALLOC_TINY
/* Tiny. */
- for (; i < (1U << LG_TINY_MIN); i += TINY_MIN) {
+ for (; i < (1U << LG_TINY_MIN); i++) {
size = pow2_ceil(1U << LG_TINY_MIN);
binind = ffs((int)(size >> (LG_TINY_MIN + 1)));
- CUSTOM_SMALL_SIZE2BIN(i) = binind;
+ custom_small_size2bin[i] = binind;
}
- for (; i < qspace_min; i += TINY_MIN) {
+ for (; i < qspace_min; i++) {
size = pow2_ceil(i);
binind = ffs((int)(size >> (LG_TINY_MIN + 1)));
- CUSTOM_SMALL_SIZE2BIN(i) = binind;
+ custom_small_size2bin[i] = binind;
}
#endif
/* Quantum-spaced. */
- for (; i <= qspace_max; i += TINY_MIN) {
+ for (; i <= qspace_max; i++) {
size = QUANTUM_CEILING(i);
binind = ntbins + (size >> LG_QUANTUM) - 1;
- CUSTOM_SMALL_SIZE2BIN(i) = binind;
+ custom_small_size2bin[i] = binind;
}
/* Cacheline-spaced. */
- for (; i <= cspace_max; i += TINY_MIN) {
+ for (; i <= cspace_max; i++) {
size = CACHELINE_CEILING(i);
binind = ntbins + nqbins + ((size - cspace_min) >>
LG_CACHELINE);
- CUSTOM_SMALL_SIZE2BIN(i) = binind;
+ custom_small_size2bin[i] = binind;
}
/* Sub-page. */
- for (; i <= sspace_max; i += TINY_MIN) {
+ for (; i <= sspace_max; i++) {
size = SUBPAGE_CEILING(i);
binind = ntbins + nqbins + ncbins + ((size - sspace_min) >>
LG_SUBPAGE);
- CUSTOM_SMALL_SIZE2BIN(i) = binind;
+ custom_small_size2bin[i] = binind;
}
small_size2bin = custom_small_size2bin;
@@ -2427,190 +2485,6 @@ small_size2bin_init_hard(void)
small_size2bin_validate();
#endif
return (false);
-#undef CUSTOM_SMALL_SIZE2BIN
-}
-
-/*
- * Calculate bin_info->run_size such that it meets the following constraints:
- *
- * *) bin_info->run_size >= min_run_size
- * *) bin_info->run_size <= arena_maxclass
- * *) run header overhead <= RUN_MAX_OVRHD (or header overhead relaxed).
- * *) bin_info->nregs <= RUN_MAXREGS
- *
- * bin_info->nregs, bin_info->bitmap_offset, and bin_info->reg0_offset are also
- * calculated here, since these settings are all interdependent.
- */
-static size_t
-bin_info_run_size_calc(arena_bin_info_t *bin_info, size_t min_run_size)
-{
- size_t try_run_size, good_run_size;
- uint32_t try_nregs, good_nregs;
- uint32_t try_hdr_size, good_hdr_size;
- uint32_t try_bitmap_offset, good_bitmap_offset;
-#ifdef JEMALLOC_PROF
- uint32_t try_ctx0_offset, good_ctx0_offset;
-#endif
- uint32_t try_reg0_offset, good_reg0_offset;
-
- assert(min_run_size >= PAGE_SIZE);
- assert(min_run_size <= arena_maxclass);
-
- /*
- * Calculate known-valid settings before entering the run_size
- * expansion loop, so that the first part of the loop always copies
- * valid settings.
- *
- * The do..while loop iteratively reduces the number of regions until
- * the run header and the regions no longer overlap. A closed formula
- * would be quite messy, since there is an interdependency between the
- * header's mask length and the number of regions.
- */
- try_run_size = min_run_size;
- try_nregs = ((try_run_size - sizeof(arena_run_t)) / bin_info->reg_size)
- + 1; /* Counter-act try_nregs-- in loop. */
- if (try_nregs > RUN_MAXREGS) {
- try_nregs = RUN_MAXREGS
- + 1; /* Counter-act try_nregs-- in loop. */
- }
- do {
- try_nregs--;
- try_hdr_size = sizeof(arena_run_t);
- /* Pad to a long boundary. */
- try_hdr_size = LONG_CEILING(try_hdr_size);
- try_bitmap_offset = try_hdr_size;
- /* Add space for bitmap. */
- try_hdr_size += bitmap_size(try_nregs);
-#ifdef JEMALLOC_PROF
- if (opt_prof && prof_promote == false) {
- /* Pad to a quantum boundary. */
- try_hdr_size = QUANTUM_CEILING(try_hdr_size);
- try_ctx0_offset = try_hdr_size;
- /* Add space for one (prof_ctx_t *) per region. */
- try_hdr_size += try_nregs * sizeof(prof_ctx_t *);
- } else
- try_ctx0_offset = 0;
-#endif
- try_reg0_offset = try_run_size - (try_nregs *
- bin_info->reg_size);
- } while (try_hdr_size > try_reg0_offset);
-
- /* run_size expansion loop. */
- do {
- /*
- * Copy valid settings before trying more aggressive settings.
- */
- good_run_size = try_run_size;
- good_nregs = try_nregs;
- good_hdr_size = try_hdr_size;
- good_bitmap_offset = try_bitmap_offset;
-#ifdef JEMALLOC_PROF
- good_ctx0_offset = try_ctx0_offset;
-#endif
- good_reg0_offset = try_reg0_offset;
-
- /* Try more aggressive settings. */
- try_run_size += PAGE_SIZE;
- try_nregs = ((try_run_size - sizeof(arena_run_t)) /
- bin_info->reg_size)
- + 1; /* Counter-act try_nregs-- in loop. */
- if (try_nregs > RUN_MAXREGS) {
- try_nregs = RUN_MAXREGS
- + 1; /* Counter-act try_nregs-- in loop. */
- }
- do {
- try_nregs--;
- try_hdr_size = sizeof(arena_run_t);
- /* Pad to a long boundary. */
- try_hdr_size = LONG_CEILING(try_hdr_size);
- try_bitmap_offset = try_hdr_size;
- /* Add space for bitmap. */
- try_hdr_size += bitmap_size(try_nregs);
-#ifdef JEMALLOC_PROF
- if (opt_prof && prof_promote == false) {
- /* Pad to a quantum boundary. */
- try_hdr_size = QUANTUM_CEILING(try_hdr_size);
- try_ctx0_offset = try_hdr_size;
- /*
- * Add space for one (prof_ctx_t *) per region.
- */
- try_hdr_size += try_nregs *
- sizeof(prof_ctx_t *);
- }
-#endif
- try_reg0_offset = try_run_size - (try_nregs *
- bin_info->reg_size);
- } while (try_hdr_size > try_reg0_offset);
- } while (try_run_size <= arena_maxclass
- && try_run_size <= arena_maxclass
- && RUN_MAX_OVRHD * (bin_info->reg_size << 3) > RUN_MAX_OVRHD_RELAX
- && (try_reg0_offset << RUN_BFP) > RUN_MAX_OVRHD * try_run_size
- && try_nregs < RUN_MAXREGS);
-
- assert(good_hdr_size <= good_reg0_offset);
-
- /* Copy final settings. */
- bin_info->run_size = good_run_size;
- bin_info->nregs = good_nregs;
- bin_info->bitmap_offset = good_bitmap_offset;
-#ifdef JEMALLOC_PROF
- bin_info->ctx0_offset = good_ctx0_offset;
-#endif
- bin_info->reg0_offset = good_reg0_offset;
-
- return (good_run_size);
-}
-
-static bool
-bin_info_init(void)
-{
- arena_bin_info_t *bin_info;
- unsigned i;
- size_t prev_run_size;
-
- arena_bin_info = base_alloc(sizeof(arena_bin_info_t) * nbins);
- if (arena_bin_info == NULL)
- return (true);
-
- prev_run_size = PAGE_SIZE;
- i = 0;
-#ifdef JEMALLOC_TINY
- /* (2^n)-spaced tiny bins. */
- for (; i < ntbins; i++) {
- bin_info = &arena_bin_info[i];
- bin_info->reg_size = (1U << (LG_TINY_MIN + i));
- prev_run_size = bin_info_run_size_calc(bin_info, prev_run_size);
- bitmap_info_init(&bin_info->bitmap_info, bin_info->nregs);
- }
-#endif
-
- /* Quantum-spaced bins. */
- for (; i < ntbins + nqbins; i++) {
- bin_info = &arena_bin_info[i];
- bin_info->reg_size = (i - ntbins + 1) << LG_QUANTUM;
- prev_run_size = bin_info_run_size_calc(bin_info, prev_run_size);
- bitmap_info_init(&bin_info->bitmap_info, bin_info->nregs);
- }
-
- /* Cacheline-spaced bins. */
- for (; i < ntbins + nqbins + ncbins; i++) {
- bin_info = &arena_bin_info[i];
- bin_info->reg_size = cspace_min + ((i - (ntbins + nqbins)) <<
- LG_CACHELINE);
- prev_run_size = bin_info_run_size_calc(bin_info, prev_run_size);
- bitmap_info_init(&bin_info->bitmap_info, bin_info->nregs);
- }
-
- /* Subpage-spaced bins. */
- for (; i < nbins; i++) {
- bin_info = &arena_bin_info[i];
- bin_info->reg_size = sspace_min + ((i - (ntbins + nqbins +
- ncbins)) << LG_SUBPAGE);
- prev_run_size = bin_info_run_size_calc(bin_info, prev_run_size);
- bitmap_info_init(&bin_info->bitmap_info, bin_info->nregs);
- }
-
- return (false);
}
bool
@@ -2671,6 +2545,9 @@ arena_boot(void)
abort();
}
+ if (small_size2bin_init())
+ return (true);
+
/*
* Compute the header size such that it is large enough to contain the
* page map. The page map is biased to omit entries for the header
@@ -2694,11 +2571,5 @@ arena_boot(void)
arena_maxclass = chunksize - (map_bias << PAGE_SHIFT);
- if (small_size2bin_init())
- return (true);
-
- if (bin_info_init())
- return (true);
-
return (false);
}
diff --git a/dep/jemalloc/src/atomic.c b/dep/jemalloc/src/atomic.c
deleted file mode 100644
index 77ee313113b..00000000000
--- a/dep/jemalloc/src/atomic.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define JEMALLOC_ATOMIC_C_
-#include "jemalloc/internal/jemalloc_internal.h"
diff --git a/dep/jemalloc/src/bitmap.c b/dep/jemalloc/src/bitmap.c
deleted file mode 100644
index b47e2629093..00000000000
--- a/dep/jemalloc/src/bitmap.c
+++ /dev/null
@@ -1,90 +0,0 @@
-#define JEMALLOC_BITMAP_C_
-#include "jemalloc/internal/jemalloc_internal.h"
-
-/******************************************************************************/
-/* Function prototypes for non-inline static functions. */
-
-static size_t bits2groups(size_t nbits);
-
-/******************************************************************************/
-
-static size_t
-bits2groups(size_t nbits)
-{
-
- return ((nbits >> LG_BITMAP_GROUP_NBITS) +
- !!(nbits & BITMAP_GROUP_NBITS_MASK));
-}
-
-void
-bitmap_info_init(bitmap_info_t *binfo, size_t nbits)
-{
- unsigned i;
- size_t group_count;
-
- assert(nbits > 0);
- assert(nbits <= (ZU(1) << LG_BITMAP_MAXBITS));
-
- /*
- * Compute the number of groups necessary to store nbits bits, and
- * progressively work upward through the levels until reaching a level
- * that requires only one group.
- */
- binfo->levels[0].group_offset = 0;
- group_count = bits2groups(nbits);
- for (i = 1; group_count > 1; i++) {
- assert(i < BITMAP_MAX_LEVELS);
- binfo->levels[i].group_offset = binfo->levels[i-1].group_offset
- + group_count;
- group_count = bits2groups(group_count);
- }
- binfo->levels[i].group_offset = binfo->levels[i-1].group_offset
- + group_count;
- binfo->nlevels = i;
- binfo->nbits = nbits;
-}
-
-size_t
-bitmap_info_ngroups(const bitmap_info_t *binfo)
-{
-
- return (binfo->levels[binfo->nlevels].group_offset << LG_SIZEOF_BITMAP);
-}
-
-size_t
-bitmap_size(size_t nbits)
-{
- bitmap_info_t binfo;
-
- bitmap_info_init(&binfo, nbits);
- return (bitmap_info_ngroups(&binfo));
-}
-
-void
-bitmap_init(bitmap_t *bitmap, const bitmap_info_t *binfo)
-{
- size_t extra;
- unsigned i;
-
- /*
- * Bits are actually inverted with regard to the external bitmap
- * interface, so the bitmap starts out with all 1 bits, except for
- * trailing unused bits (if any). Note that each group uses bit 0 to
- * correspond to the first logical bit in the group, so extra bits
- * are the most significant bits of the last group.
- */
- memset(bitmap, 0xffU, binfo->levels[binfo->nlevels].group_offset <<
- LG_SIZEOF_BITMAP);
- extra = (BITMAP_GROUP_NBITS - (binfo->nbits & BITMAP_GROUP_NBITS_MASK))
- & BITMAP_GROUP_NBITS_MASK;
- if (extra != 0)
- bitmap[binfo->levels[1].group_offset - 1] >>= extra;
- for (i = 1; i < binfo->nlevels; i++) {
- size_t group_count = binfo->levels[i].group_offset -
- binfo->levels[i-1].group_offset;
- extra = (BITMAP_GROUP_NBITS - (group_count &
- BITMAP_GROUP_NBITS_MASK)) & BITMAP_GROUP_NBITS_MASK;
- if (extra != 0)
- bitmap[binfo->levels[i+1].group_offset - 1] >>= extra;
- }
-}
diff --git a/dep/jemalloc/src/chunk.c b/dep/jemalloc/src/chunk.c
index d190c6f49b3..301519e8042 100644
--- a/dep/jemalloc/src/chunk.c
+++ b/dep/jemalloc/src/chunk.c
@@ -70,7 +70,7 @@ RETURN:
#ifdef JEMALLOC_IVSALLOC
if (base == false && ret != NULL) {
if (rtree_set(chunks_rtree, (uintptr_t)ret, ret)) {
- chunk_dealloc(ret, size, true);
+ chunk_dealloc(ret, size);
return (NULL);
}
}
@@ -108,7 +108,7 @@ RETURN:
}
void
-chunk_dealloc(void *chunk, size_t size, bool unmap)
+chunk_dealloc(void *chunk, size_t size)
{
assert(chunk != NULL);
@@ -125,17 +125,15 @@ chunk_dealloc(void *chunk, size_t size, bool unmap)
malloc_mutex_unlock(&chunks_mtx);
#endif
- if (unmap) {
#ifdef JEMALLOC_SWAP
- if (swap_enabled && chunk_dealloc_swap(chunk, size) == false)
- return;
+ if (swap_enabled && chunk_dealloc_swap(chunk, size) == false)
+ return;
#endif
#ifdef JEMALLOC_DSS
- if (chunk_dealloc_dss(chunk, size) == false)
- return;
+ if (chunk_dealloc_dss(chunk, size) == false)
+ return;
#endif
- chunk_dealloc_mmap(chunk, size);
- }
+ chunk_dealloc_mmap(chunk, size);
}
bool
diff --git a/dep/jemalloc/src/chunk_mmap.c b/dep/jemalloc/src/chunk_mmap.c
index 164e86e7b38..bc367559774 100644
--- a/dep/jemalloc/src/chunk_mmap.c
+++ b/dep/jemalloc/src/chunk_mmap.c
@@ -206,15 +206,13 @@ chunk_alloc_mmap_internal(size_t size, bool noreserve)
void *
chunk_alloc_mmap(size_t size)
{
-
- return (chunk_alloc_mmap_internal(size, false));
+ return chunk_alloc_mmap_internal(size, false);
}
void *
chunk_alloc_mmap_noreserve(size_t size)
{
-
- return (chunk_alloc_mmap_internal(size, true));
+ return chunk_alloc_mmap_internal(size, true);
}
void
diff --git a/dep/jemalloc/src/ckh.c b/dep/jemalloc/src/ckh.c
index 43fcc25239d..682a8db65bf 100644
--- a/dep/jemalloc/src/ckh.c
+++ b/dep/jemalloc/src/ckh.c
@@ -34,7 +34,7 @@
* respectively.
*
******************************************************************************/
-#define JEMALLOC_CKH_C_
+#define CKH_C_
#include "jemalloc/internal/jemalloc_internal.h"
/******************************************************************************/
@@ -73,7 +73,7 @@ ckh_isearch(ckh_t *ckh, const void *key)
size_t hash1, hash2, bucket, cell;
assert(ckh != NULL);
- dassert(ckh->magic == CKH_MAGIC);
+ assert(ckh->magic = CKH_MAGIG);
ckh->hash(key, ckh->lg_curbuckets, &hash1, &hash2);
@@ -262,15 +262,9 @@ ckh_grow(ckh_t *ckh)
lg_prevbuckets = ckh->lg_curbuckets;
lg_curcells = ckh->lg_curbuckets + LG_CKH_BUCKET_CELLS;
while (true) {
- size_t usize;
-
lg_curcells++;
- usize = sa2u(sizeof(ckhc_t) << lg_curcells, CACHELINE, NULL);
- if (usize == 0) {
- ret = true;
- goto RETURN;
- }
- tab = (ckhc_t *)ipalloc(usize, CACHELINE, true);
+ tab = (ckhc_t *)ipalloc(sizeof(ckhc_t) << lg_curcells,
+ ZU(1) << LG_CACHELINE, true);
if (tab == NULL) {
ret = true;
goto RETURN;
@@ -301,7 +295,7 @@ static void
ckh_shrink(ckh_t *ckh)
{
ckhc_t *tab, *ttab;
- size_t lg_curcells, usize;
+ size_t lg_curcells;
unsigned lg_prevbuckets;
/*
@@ -310,10 +304,8 @@ ckh_shrink(ckh_t *ckh)
*/
lg_prevbuckets = ckh->lg_curbuckets;
lg_curcells = ckh->lg_curbuckets + LG_CKH_BUCKET_CELLS - 1;
- usize = sa2u(sizeof(ckhc_t) << lg_curcells, CACHELINE, NULL);
- if (usize == 0)
- return;
- tab = (ckhc_t *)ipalloc(usize, CACHELINE, true);
+ tab = (ckhc_t *)ipalloc(sizeof(ckhc_t) << lg_curcells,
+ ZU(1) << LG_CACHELINE, true);
if (tab == NULL) {
/*
* An OOM error isn't worth propagating, since it doesn't
@@ -348,7 +340,7 @@ bool
ckh_new(ckh_t *ckh, size_t minitems, ckh_hash_t *hash, ckh_keycomp_t *keycomp)
{
bool ret;
- size_t mincells, usize;
+ size_t mincells;
unsigned lg_mincells;
assert(minitems > 0);
@@ -383,19 +375,15 @@ ckh_new(ckh_t *ckh, size_t minitems, ckh_hash_t *hash, ckh_keycomp_t *keycomp)
ckh->hash = hash;
ckh->keycomp = keycomp;
- usize = sa2u(sizeof(ckhc_t) << lg_mincells, CACHELINE, NULL);
- if (usize == 0) {
- ret = true;
- goto RETURN;
- }
- ckh->tab = (ckhc_t *)ipalloc(usize, CACHELINE, true);
+ ckh->tab = (ckhc_t *)ipalloc(sizeof(ckhc_t) << lg_mincells,
+ (ZU(1) << LG_CACHELINE), true);
if (ckh->tab == NULL) {
ret = true;
goto RETURN;
}
#ifdef JEMALLOC_DEBUG
- ckh->magic = CKH_MAGIC;
+ ckh->magic = CKH_MAGIG;
#endif
ret = false;
@@ -408,7 +396,7 @@ ckh_delete(ckh_t *ckh)
{
assert(ckh != NULL);
- dassert(ckh->magic == CKH_MAGIC);
+ assert(ckh->magic = CKH_MAGIG);
#ifdef CKH_VERBOSE
malloc_printf(
@@ -433,7 +421,7 @@ ckh_count(ckh_t *ckh)
{
assert(ckh != NULL);
- dassert(ckh->magic == CKH_MAGIC);
+ assert(ckh->magic = CKH_MAGIG);
return (ckh->count);
}
@@ -464,7 +452,7 @@ ckh_insert(ckh_t *ckh, const void *key, const void *data)
bool ret;
assert(ckh != NULL);
- dassert(ckh->magic == CKH_MAGIC);
+ assert(ckh->magic = CKH_MAGIG);
assert(ckh_search(ckh, key, NULL, NULL));
#ifdef CKH_COUNT
@@ -489,7 +477,7 @@ ckh_remove(ckh_t *ckh, const void *searchkey, void **key, void **data)
size_t cell;
assert(ckh != NULL);
- dassert(ckh->magic == CKH_MAGIC);
+ assert(ckh->magic = CKH_MAGIG);
cell = ckh_isearch(ckh, searchkey);
if (cell != SIZE_T_MAX) {
@@ -521,7 +509,7 @@ ckh_search(ckh_t *ckh, const void *searchkey, void **key, void **data)
size_t cell;
assert(ckh != NULL);
- dassert(ckh->magic == CKH_MAGIC);
+ assert(ckh->magic = CKH_MAGIG);
cell = ckh_isearch(ckh, searchkey);
if (cell != SIZE_T_MAX) {
@@ -556,7 +544,7 @@ ckh_string_hash(const void *key, unsigned minbits, size_t *hash1, size_t *hash2)
} else {
ret1 = h;
ret2 = hash(key, strlen((const char *)key),
- 0x8432a476666bbc13LLU);
+ 0x8432a476666bbc13U);
}
*hash1 = ret1;
diff --git a/dep/jemalloc/src/ctl.c b/dep/jemalloc/src/ctl.c
index e5336d36949..3c8adab90a3 100644
--- a/dep/jemalloc/src/ctl.c
+++ b/dep/jemalloc/src/ctl.c
@@ -182,7 +182,6 @@ CTL_PROTO(stats_arenas_i_lruns_j_highruns)
CTL_PROTO(stats_arenas_i_lruns_j_curruns)
INDEX_PROTO(stats_arenas_i_lruns_j)
#endif
-CTL_PROTO(stats_arenas_i_nthreads)
CTL_PROTO(stats_arenas_i_pactive)
CTL_PROTO(stats_arenas_i_pdirty)
#ifdef JEMALLOC_STATS
@@ -193,7 +192,6 @@ CTL_PROTO(stats_arenas_i_purged)
#endif
INDEX_PROTO(stats_arenas_i)
#ifdef JEMALLOC_STATS
-CTL_PROTO(stats_cactive)
CTL_PROTO(stats_allocated)
CTL_PROTO(stats_active)
CTL_PROTO(stats_mapped)
@@ -436,7 +434,6 @@ static const ctl_node_t stats_arenas_i_lruns_node[] = {
#endif
static const ctl_node_t stats_arenas_i_node[] = {
- {NAME("nthreads"), CTL(stats_arenas_i_nthreads)},
{NAME("pactive"), CTL(stats_arenas_i_pactive)},
{NAME("pdirty"), CTL(stats_arenas_i_pdirty)}
#ifdef JEMALLOC_STATS
@@ -461,7 +458,6 @@ static const ctl_node_t stats_arenas_node[] = {
static const ctl_node_t stats_node[] = {
#ifdef JEMALLOC_STATS
- {NAME("cactive"), CTL(stats_cactive)},
{NAME("allocated"), CTL(stats_allocated)},
{NAME("active"), CTL(stats_active)},
{NAME("mapped"), CTL(stats_mapped)},
@@ -624,7 +620,6 @@ ctl_arena_refresh(arena_t *arena, unsigned i)
ctl_arena_clear(astats);
- sstats->nthreads += astats->nthreads;
#ifdef JEMALLOC_STATS
ctl_arena_stats_amerge(astats, arena);
/* Merge into sum stats as well. */
@@ -662,17 +657,10 @@ ctl_refresh(void)
* Clear sum stats, since they will be merged into by
* ctl_arena_refresh().
*/
- ctl_stats.arenas[narenas].nthreads = 0;
ctl_arena_clear(&ctl_stats.arenas[narenas]);
malloc_mutex_lock(&arenas_lock);
memcpy(tarenas, arenas, sizeof(arena_t *) * narenas);
- for (i = 0; i < narenas; i++) {
- if (arenas[i] != NULL)
- ctl_stats.arenas[i].nthreads = arenas[i]->nthreads;
- else
- ctl_stats.arenas[i].nthreads = 0;
- }
malloc_mutex_unlock(&arenas_lock);
for (i = 0; i < narenas; i++) {
bool initialized = (tarenas[i] != NULL);
@@ -1126,8 +1114,8 @@ thread_arena_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
unsigned newind, oldind;
newind = oldind = choose_arena()->ind;
- WRITE(newind, unsigned);
- READ(oldind, unsigned);
+ WRITE(oldind, unsigned);
+ READ(newind, unsigned);
if (newind != oldind) {
arena_t *arena;
@@ -1141,8 +1129,6 @@ thread_arena_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
malloc_mutex_lock(&arenas_lock);
if ((arena = arenas[newind]) == NULL)
arena = arenas_extend(newind);
- arenas[oldind]->nthreads--;
- arenas[newind]->nthreads++;
malloc_mutex_unlock(&arenas_lock);
if (arena == NULL) {
ret = EAGAIN;
@@ -1151,13 +1137,6 @@ thread_arena_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
/* Set new arena association. */
ARENA_SET(arena);
-#ifdef JEMALLOC_TCACHE
- {
- tcache_t *tcache = TCACHE_GET();
- if (tcache != NULL)
- tcache->arena = arena;
- }
-#endif
}
ret = 0;
@@ -1167,9 +1146,9 @@ RETURN:
#ifdef JEMALLOC_STATS
CTL_RO_NL_GEN(thread_allocated, ALLOCATED_GET(), uint64_t);
-CTL_RO_NL_GEN(thread_allocatedp, ALLOCATEDP_GET(), uint64_t *);
+CTL_RO_NL_GEN(thread_allocatedp, &ALLOCATED_GET(), uint64_t *);
CTL_RO_NL_GEN(thread_deallocated, DEALLOCATED_GET(), uint64_t);
-CTL_RO_NL_GEN(thread_deallocatedp, DEALLOCATEDP_GET(), uint64_t *);
+CTL_RO_NL_GEN(thread_deallocatedp, &DEALLOCATED_GET(), uint64_t *);
#endif
/******************************************************************************/
@@ -1305,9 +1284,9 @@ CTL_RO_NL_GEN(opt_overcommit, opt_overcommit, bool)
/******************************************************************************/
-CTL_RO_NL_GEN(arenas_bin_i_size, arena_bin_info[mib[2]].reg_size, size_t)
-CTL_RO_NL_GEN(arenas_bin_i_nregs, arena_bin_info[mib[2]].nregs, uint32_t)
-CTL_RO_NL_GEN(arenas_bin_i_run_size, arena_bin_info[mib[2]].run_size, size_t)
+CTL_RO_NL_GEN(arenas_bin_i_size, arenas[0]->bins[mib[2]].reg_size, size_t)
+CTL_RO_NL_GEN(arenas_bin_i_nregs, arenas[0]->bins[mib[2]].nregs, uint32_t)
+CTL_RO_NL_GEN(arenas_bin_i_run_size, arenas[0]->bins[mib[2]].run_size, size_t)
const ctl_node_t *
arenas_bin_i_index(const size_t *mib, size_t miblen, size_t i)
{
@@ -1552,7 +1531,6 @@ stats_arenas_i_lruns_j_index(const size_t *mib, size_t miblen, size_t j)
}
#endif
-CTL_RO_GEN(stats_arenas_i_nthreads, ctl_stats.arenas[mib[2]].nthreads, unsigned)
CTL_RO_GEN(stats_arenas_i_pactive, ctl_stats.arenas[mib[2]].pactive, size_t)
CTL_RO_GEN(stats_arenas_i_pdirty, ctl_stats.arenas[mib[2]].pdirty, size_t)
#ifdef JEMALLOC_STATS
@@ -1584,7 +1562,6 @@ RETURN:
}
#ifdef JEMALLOC_STATS
-CTL_RO_GEN(stats_cactive, &stats_cactive, size_t *)
CTL_RO_GEN(stats_allocated, ctl_stats.allocated, size_t)
CTL_RO_GEN(stats_active, ctl_stats.active, size_t)
CTL_RO_GEN(stats_mapped, ctl_stats.mapped, size_t)
diff --git a/dep/jemalloc/src/hash.c b/dep/jemalloc/src/hash.c
index cfa4da0275c..6a13d7a03c0 100644
--- a/dep/jemalloc/src/hash.c
+++ b/dep/jemalloc/src/hash.c
@@ -1,2 +1,2 @@
-#define JEMALLOC_HASH_C_
+#define HASH_C_
#include "jemalloc/internal/jemalloc_internal.h"
diff --git a/dep/jemalloc/src/huge.c b/dep/jemalloc/src/huge.c
index a4f9b054ed5..0aadc4339a9 100644
--- a/dep/jemalloc/src/huge.c
+++ b/dep/jemalloc/src/huge.c
@@ -50,7 +50,6 @@ huge_malloc(size_t size, bool zero)
malloc_mutex_lock(&huge_mtx);
extent_tree_ad_insert(&huge, node);
#ifdef JEMALLOC_STATS
- stats_cactive_add(csize);
huge_nmalloc++;
huge_allocated += csize;
#endif
@@ -84,7 +83,7 @@ huge_palloc(size_t size, size_t alignment, bool zero)
* alignment, in order to assure the alignment can be achieved, then
* unmap leading and trailing chunks.
*/
- assert(alignment > chunksize);
+ assert(alignment >= chunksize);
chunk_size = CHUNK_CEILING(size);
@@ -110,12 +109,12 @@ huge_palloc(size_t size, size_t alignment, bool zero)
if (offset == 0) {
/* Trim trailing space. */
chunk_dealloc((void *)((uintptr_t)ret + chunk_size), alloc_size
- - chunk_size, true);
+ - chunk_size);
} else {
size_t trailsize;
/* Trim leading space. */
- chunk_dealloc(ret, alignment - offset, true);
+ chunk_dealloc(ret, alignment - offset);
ret = (void *)((uintptr_t)ret + (alignment - offset));
@@ -124,7 +123,7 @@ huge_palloc(size_t size, size_t alignment, bool zero)
/* Trim trailing space. */
assert(trailsize < alloc_size);
chunk_dealloc((void *)((uintptr_t)ret + chunk_size),
- trailsize, true);
+ trailsize);
}
}
@@ -135,7 +134,6 @@ huge_palloc(size_t size, size_t alignment, bool zero)
malloc_mutex_lock(&huge_mtx);
extent_tree_ad_insert(&huge, node);
#ifdef JEMALLOC_STATS
- stats_cactive_add(chunk_size);
huge_nmalloc++;
huge_allocated += chunk_size;
#endif
@@ -194,7 +192,7 @@ huge_ralloc(void *ptr, size_t oldsize, size_t size, size_t extra,
* different size class. In that case, fall back to allocating new
* space and copying.
*/
- if (alignment > chunksize)
+ if (alignment != 0)
ret = huge_palloc(size + extra, alignment, zero);
else
ret = huge_malloc(size + extra, zero);
@@ -203,7 +201,7 @@ huge_ralloc(void *ptr, size_t oldsize, size_t size, size_t extra,
if (extra == 0)
return (NULL);
/* Try again, this time without extra. */
- if (alignment > chunksize)
+ if (alignment != 0)
ret = huge_palloc(size, alignment, zero);
else
ret = huge_malloc(size, zero);
@@ -234,13 +232,6 @@ huge_ralloc(void *ptr, size_t oldsize, size_t size, size_t extra,
) {
size_t newsize = huge_salloc(ret);
- /*
- * Remove ptr from the tree of huge allocations before
- * performing the remap operation, in order to avoid the
- * possibility of another thread acquiring that mapping before
- * this one removes it from the tree.
- */
- huge_dalloc(ptr, false);
if (mremap(ptr, oldsize, newsize, MREMAP_MAYMOVE|MREMAP_FIXED,
ret) == MAP_FAILED) {
/*
@@ -260,8 +251,9 @@ huge_ralloc(void *ptr, size_t oldsize, size_t size, size_t extra,
if (opt_abort)
abort();
memcpy(ret, ptr, copysize);
- chunk_dealloc_mmap(ptr, oldsize);
- }
+ idalloc(ptr);
+ } else
+ huge_dalloc(ptr, false);
} else
#endif
{
@@ -286,7 +278,6 @@ huge_dalloc(void *ptr, bool unmap)
extent_tree_ad_remove(&huge, node);
#ifdef JEMALLOC_STATS
- stats_cactive_sub(node->size);
huge_ndalloc++;
huge_allocated -= node->size;
#endif
@@ -301,10 +292,9 @@ huge_dalloc(void *ptr, bool unmap)
memset(node->addr, 0x5a, node->size);
#endif
#endif
+ chunk_dealloc(node->addr, node->size);
}
- chunk_dealloc(node->addr, node->size, unmap);
-
base_node_dealloc(node);
}
diff --git a/dep/jemalloc/src/jemalloc.c b/dep/jemalloc/src/jemalloc.c
index a161c2e26e1..2aebc51dd19 100644
--- a/dep/jemalloc/src/jemalloc.c
+++ b/dep/jemalloc/src/jemalloc.c
@@ -7,10 +7,12 @@
malloc_mutex_t arenas_lock;
arena_t **arenas;
unsigned narenas;
+static unsigned next_arena;
-pthread_key_t arenas_tsd;
#ifndef NO_TLS
__thread arena_t *arenas_tls JEMALLOC_ATTR(tls_model("initial-exec"));
+#else
+pthread_key_t arenas_tsd;
#endif
#ifdef JEMALLOC_STATS
@@ -28,13 +30,7 @@ static bool malloc_initialized = false;
static pthread_t malloc_initializer = (unsigned long)0;
/* Used to avoid initialization races. */
-static malloc_mutex_t init_lock =
-#ifdef JEMALLOC_OSSPIN
- 0
-#else
- MALLOC_MUTEX_INITIALIZER
-#endif
- ;
+static malloc_mutex_t init_lock = MALLOC_MUTEX_INITIALIZER;
#ifdef DYNAMIC_PAGE_SHIFT
size_t pagesize;
@@ -74,7 +70,6 @@ size_t opt_narenas = 0;
static void wrtmessage(void *cbopaque, const char *s);
static void stats_print_atexit(void);
static unsigned malloc_ncpus(void);
-static void arenas_cleanup(void *arg);
#if (defined(JEMALLOC_STATS) && defined(NO_TLS))
static void thread_allocated_cleanup(void *arg);
#endif
@@ -84,7 +79,6 @@ static void malloc_conf_error(const char *msg, const char *k, size_t klen,
const char *v, size_t vlen);
static void malloc_conf_init(void);
static bool malloc_init_hard(void);
-static int imemalign(void **memptr, size_t alignment, size_t size);
/******************************************************************************/
/* malloc_message() setup. */
@@ -153,53 +147,13 @@ choose_arena_hard(void)
arena_t *ret;
if (narenas > 1) {
- unsigned i, choose, first_null;
-
- choose = 0;
- first_null = narenas;
malloc_mutex_lock(&arenas_lock);
- assert(arenas[0] != NULL);
- for (i = 1; i < narenas; i++) {
- if (arenas[i] != NULL) {
- /*
- * Choose the first arena that has the lowest
- * number of threads assigned to it.
- */
- if (arenas[i]->nthreads <
- arenas[choose]->nthreads)
- choose = i;
- } else if (first_null == narenas) {
- /*
- * Record the index of the first uninitialized
- * arena, in case all extant arenas are in use.
- *
- * NB: It is possible for there to be
- * discontinuities in terms of initialized
- * versus uninitialized arenas, due to the
- * "thread.arena" mallctl.
- */
- first_null = i;
- }
- }
-
- if (arenas[choose] == 0 || first_null == narenas) {
- /*
- * Use an unloaded arena, or the least loaded arena if
- * all arenas are already initialized.
- */
- ret = arenas[choose];
- } else {
- /* Initialize a new arena. */
- ret = arenas_extend(first_null);
- }
- ret->nthreads++;
+ if ((ret = arenas[next_arena]) == NULL)
+ ret = arenas_extend(next_arena);
+ next_arena = (next_arena + 1) % narenas;
malloc_mutex_unlock(&arenas_lock);
- } else {
+ } else
ret = arenas[0];
- malloc_mutex_lock(&arenas_lock);
- ret->nthreads++;
- malloc_mutex_unlock(&arenas_lock);
- }
ARENA_SET(ret);
@@ -259,28 +213,6 @@ stats_print_atexit(void)
JEMALLOC_P(malloc_stats_print)(NULL, NULL, NULL);
}
-#if (defined(JEMALLOC_STATS) && defined(NO_TLS))
-thread_allocated_t *
-thread_allocated_get_hard(void)
-{
- thread_allocated_t *thread_allocated = (thread_allocated_t *)
- imalloc(sizeof(thread_allocated_t));
- if (thread_allocated == NULL) {
- static thread_allocated_t static_thread_allocated = {0, 0};
- malloc_write("<jemalloc>: Error allocating TSD;"
- " mallctl(\"thread.{de,}allocated[p]\", ...)"
- " will be inaccurate\n");
- if (opt_abort)
- abort();
- return (&static_thread_allocated);
- }
- pthread_setspecific(thread_allocated_tsd, thread_allocated);
- thread_allocated->allocated = 0;
- thread_allocated->deallocated = 0;
- return (thread_allocated);
-}
-#endif
-
/*
* End miscellaneous support functions.
*/
@@ -305,16 +237,6 @@ malloc_ncpus(void)
return (ret);
}
-static void
-arenas_cleanup(void *arg)
-{
- arena_t *arena = (arena_t *)arg;
-
- malloc_mutex_lock(&arenas_lock);
- arena->nthreads--;
- malloc_mutex_unlock(&arenas_lock);
-}
-
#if (defined(JEMALLOC_STATS) && defined(NO_TLS))
static void
thread_allocated_cleanup(void *arg)
@@ -499,8 +421,8 @@ malloc_conf_init(void)
if ((opts = getenv(envname)) != NULL) {
/*
* Do nothing; opts is already initialized to
- * the value of the MALLOC_CONF environment
- * variable.
+ * the value of the JEMALLOC_OPTIONS
+ * environment variable.
*/
} else {
/* No configuration specified. */
@@ -689,7 +611,7 @@ malloc_init_hard(void)
result = sysconf(_SC_PAGESIZE);
assert(result != -1);
- pagesize = (size_t)result;
+ pagesize = (unsigned)result;
/*
* We assume that pagesize is a power of 2 when calculating
@@ -749,10 +671,7 @@ malloc_init_hard(void)
}
#ifdef JEMALLOC_TCACHE
- if (tcache_boot()) {
- malloc_mutex_unlock(&init_lock);
- return (true);
- }
+ tcache_boot();
#endif
if (huge_boot()) {
@@ -769,14 +688,6 @@ malloc_init_hard(void)
}
#endif
- if (malloc_mutex_init(&arenas_lock))
- return (true);
-
- if (pthread_key_create(&arenas_tsd, arenas_cleanup) != 0) {
- malloc_mutex_unlock(&init_lock);
- return (true);
- }
-
/*
* Create enough scaffolding to allow recursive allocation in
* malloc_ncpus().
@@ -801,7 +712,8 @@ malloc_init_hard(void)
* threaded mode.
*/
ARENA_SET(arenas[0]);
- arenas[0]->nthreads++;
+
+ malloc_mutex_init(&arenas_lock);
#ifdef JEMALLOC_PROF
if (prof_boot2()) {
@@ -841,6 +753,15 @@ malloc_init_hard(void)
malloc_write(")\n");
}
+ next_arena = (narenas > 0) ? 1 : 0;
+
+#ifdef NO_TLS
+ if (pthread_key_create(&arenas_tsd, NULL) != 0) {
+ malloc_mutex_unlock(&init_lock);
+ return (true);
+ }
+#endif
+
/* Allocate and initialize arenas. */
arenas = (arena_t **)base_alloc(sizeof(arena_t *) * narenas);
if (arenas == NULL) {
@@ -872,6 +793,7 @@ malloc_init_hard(void)
return (false);
}
+
#ifdef JEMALLOC_ZONE
JEMALLOC_ATTR(constructor)
void
@@ -940,8 +862,7 @@ JEMALLOC_P(malloc)(size_t size)
#ifdef JEMALLOC_PROF
if (opt_prof) {
usize = s2u(size);
- PROF_ALLOC_PREP(1, usize, cnt);
- if (cnt == NULL) {
+ if ((cnt = prof_alloc_prep(usize)) == NULL) {
ret = NULL;
goto OOM;
}
@@ -990,23 +911,19 @@ RETURN:
}
JEMALLOC_ATTR(nonnull(1))
-#ifdef JEMALLOC_PROF
-/*
- * Avoid any uncertainty as to how many backtrace frames to ignore in
- * PROF_ALLOC_PREP().
- */
-JEMALLOC_ATTR(noinline)
-#endif
-static int
-imemalign(void **memptr, size_t alignment, size_t size)
+JEMALLOC_ATTR(visibility("default"))
+int
+JEMALLOC_P(posix_memalign)(void **memptr, size_t alignment, size_t size)
{
int ret;
+ void *result;
+#if (defined(JEMALLOC_PROF) || defined(JEMALLOC_STATS))
size_t usize
-#ifdef JEMALLOC_CC_SILENCE
+# ifdef JEMALLOC_CC_SILENCE
= 0
-#endif
+# endif
;
- void *result;
+#endif
#ifdef JEMALLOC_PROF
prof_thr_cnt_t *cnt
# ifdef JEMALLOC_CC_SILENCE
@@ -1056,38 +973,34 @@ imemalign(void **memptr, size_t alignment, size_t size)
goto RETURN;
}
- usize = sa2u(size, alignment, NULL);
- if (usize == 0) {
- result = NULL;
- ret = ENOMEM;
- goto RETURN;
- }
-
#ifdef JEMALLOC_PROF
if (opt_prof) {
- PROF_ALLOC_PREP(2, usize, cnt);
- if (cnt == NULL) {
+ usize = sa2u(size, alignment, NULL);
+ if ((cnt = prof_alloc_prep(usize)) == NULL) {
result = NULL;
ret = EINVAL;
} else {
if (prof_promote && (uintptr_t)cnt !=
(uintptr_t)1U && usize <= small_maxclass) {
- assert(sa2u(small_maxclass+1,
- alignment, NULL) != 0);
- result = ipalloc(sa2u(small_maxclass+1,
- alignment, NULL), alignment, false);
+ result = ipalloc(small_maxclass+1,
+ alignment, false);
if (result != NULL) {
arena_prof_promoted(result,
usize);
}
} else {
- result = ipalloc(usize, alignment,
+ result = ipalloc(size, alignment,
false);
}
}
} else
#endif
- result = ipalloc(usize, alignment, false);
+ {
+#ifdef JEMALLOC_STATS
+ usize = sa2u(size, alignment, NULL);
+#endif
+ result = ipalloc(size, alignment, false);
+ }
}
if (result == NULL) {
@@ -1119,15 +1032,6 @@ RETURN:
return (ret);
}
-JEMALLOC_ATTR(nonnull(1))
-JEMALLOC_ATTR(visibility("default"))
-int
-JEMALLOC_P(posix_memalign)(void **memptr, size_t alignment, size_t size)
-{
-
- return imemalign(memptr, alignment, size);
-}
-
JEMALLOC_ATTR(malloc)
JEMALLOC_ATTR(visibility("default"))
void *
@@ -1183,8 +1087,7 @@ JEMALLOC_P(calloc)(size_t num, size_t size)
#ifdef JEMALLOC_PROF
if (opt_prof) {
usize = s2u(num_size);
- PROF_ALLOC_PREP(1, usize, cnt);
- if (cnt == NULL) {
+ if ((cnt = prof_alloc_prep(usize)) == NULL) {
ret = NULL;
goto RETURN;
}
@@ -1297,9 +1200,7 @@ JEMALLOC_P(realloc)(void *ptr, size_t size)
if (opt_prof) {
usize = s2u(size);
old_ctx = prof_ctx_get(ptr);
- PROF_ALLOC_PREP(1, usize, cnt);
- if (cnt == NULL) {
- old_ctx = NULL;
+ if ((cnt = prof_alloc_prep(usize)) == NULL) {
ret = NULL;
goto OOM;
}
@@ -1309,13 +1210,8 @@ JEMALLOC_P(realloc)(void *ptr, size_t size)
false, false);
if (ret != NULL)
arena_prof_promoted(ret, usize);
- else
- old_ctx = NULL;
- } else {
+ } else
ret = iralloc(ptr, size, 0, 0, false, false);
- if (ret == NULL)
- old_ctx = NULL;
- }
} else
#endif
{
@@ -1353,8 +1249,7 @@ OOM:
#ifdef JEMALLOC_PROF
if (opt_prof) {
usize = s2u(size);
- PROF_ALLOC_PREP(1, usize, cnt);
- if (cnt == NULL)
+ if ((cnt = prof_alloc_prep(usize)) == NULL)
ret = NULL;
else {
if (prof_promote && (uintptr_t)cnt !=
@@ -1459,7 +1354,7 @@ JEMALLOC_P(memalign)(size_t alignment, size_t size)
#ifdef JEMALLOC_CC_SILENCE
int result =
#endif
- imemalign(&ret, alignment, size);
+ JEMALLOC_P(posix_memalign)(&ret, alignment, size);
#ifdef JEMALLOC_CC_SILENCE
if (result != 0)
return (NULL);
@@ -1478,7 +1373,7 @@ JEMALLOC_P(valloc)(size_t size)
#ifdef JEMALLOC_CC_SILENCE
int result =
#endif
- imemalign(&ret, PAGE_SIZE, size);
+ JEMALLOC_P(posix_memalign)(&ret, PAGE_SIZE, size);
#ifdef JEMALLOC_CC_SILENCE
if (result != 0)
return (NULL);
@@ -1559,18 +1454,15 @@ JEMALLOC_P(mallctlbymib)(const size_t *mib, size_t miblen, void *oldp,
}
JEMALLOC_INLINE void *
-iallocm(size_t usize, size_t alignment, bool zero)
+iallocm(size_t size, size_t alignment, bool zero)
{
- assert(usize == ((alignment == 0) ? s2u(usize) : sa2u(usize, alignment,
- NULL)));
-
if (alignment != 0)
- return (ipalloc(usize, alignment, zero));
+ return (ipalloc(size, alignment, zero));
else if (zero)
- return (icalloc(usize));
+ return (icalloc(size));
else
- return (imalloc(usize));
+ return (imalloc(size));
}
JEMALLOC_ATTR(nonnull(1))
@@ -1593,43 +1485,38 @@ JEMALLOC_P(allocm)(void **ptr, size_t *rsize, size_t size, int flags)
if (malloc_init())
goto OOM;
- usize = (alignment == 0) ? s2u(size) : sa2u(size, alignment, NULL);
- if (usize == 0)
- goto OOM;
-
#ifdef JEMALLOC_PROF
if (opt_prof) {
- PROF_ALLOC_PREP(1, usize, cnt);
- if (cnt == NULL)
+ usize = (alignment == 0) ? s2u(size) : sa2u(size, alignment,
+ NULL);
+ if ((cnt = prof_alloc_prep(usize)) == NULL)
goto OOM;
if (prof_promote && (uintptr_t)cnt != (uintptr_t)1U && usize <=
small_maxclass) {
- size_t usize_promoted = (alignment == 0) ?
- s2u(small_maxclass+1) : sa2u(small_maxclass+1,
- alignment, NULL);
- assert(usize_promoted != 0);
- p = iallocm(usize_promoted, alignment, zero);
+ p = iallocm(small_maxclass+1, alignment, zero);
if (p == NULL)
goto OOM;
arena_prof_promoted(p, usize);
} else {
- p = iallocm(usize, alignment, zero);
+ p = iallocm(size, alignment, zero);
if (p == NULL)
goto OOM;
}
- prof_malloc(p, usize, cnt);
+
if (rsize != NULL)
*rsize = usize;
} else
#endif
{
- p = iallocm(usize, alignment, zero);
+ p = iallocm(size, alignment, zero);
if (p == NULL)
goto OOM;
#ifndef JEMALLOC_STATS
if (rsize != NULL)
#endif
{
+ usize = (alignment == 0) ? s2u(size) : sa2u(size,
+ alignment, NULL);
#ifdef JEMALLOC_STATS
if (rsize != NULL)
#endif
@@ -1672,6 +1559,7 @@ JEMALLOC_P(rallocm)(void **ptr, size_t *rsize, size_t size, size_t extra,
bool no_move = flags & ALLOCM_NO_MOVE;
#ifdef JEMALLOC_PROF
prof_thr_cnt_t *cnt;
+ prof_ctx_t *old_ctx;
#endif
assert(ptr != NULL);
@@ -1686,33 +1574,25 @@ JEMALLOC_P(rallocm)(void **ptr, size_t *rsize, size_t size, size_t extra,
/*
* usize isn't knowable before iralloc() returns when extra is
* non-zero. Therefore, compute its maximum possible value and
- * use that in PROF_ALLOC_PREP() to decide whether to capture a
+ * use that in prof_alloc_prep() to decide whether to capture a
* backtrace. prof_realloc() will use the actual usize to
* decide whether to sample.
*/
size_t max_usize = (alignment == 0) ? s2u(size+extra) :
sa2u(size+extra, alignment, NULL);
- prof_ctx_t *old_ctx = prof_ctx_get(p);
old_size = isalloc(p);
- PROF_ALLOC_PREP(1, max_usize, cnt);
- if (cnt == NULL)
+ old_ctx = prof_ctx_get(p);
+ if ((cnt = prof_alloc_prep(max_usize)) == NULL)
goto OOM;
- /*
- * Use minimum usize to determine whether promotion may happen.
- */
- if (prof_promote && (uintptr_t)cnt != (uintptr_t)1U
- && ((alignment == 0) ? s2u(size) : sa2u(size,
- alignment, NULL)) <= small_maxclass) {
+ if (prof_promote && (uintptr_t)cnt != (uintptr_t)1U && max_usize
+ <= small_maxclass) {
q = iralloc(p, small_maxclass+1, (small_maxclass+1 >=
size+extra) ? 0 : size+extra - (small_maxclass+1),
alignment, zero, no_move);
if (q == NULL)
goto ERR;
- if (max_usize < PAGE_SIZE) {
- usize = max_usize;
- arena_prof_promoted(q, usize);
- } else
- usize = isalloc(q);
+ usize = isalloc(q);
+ arena_prof_promoted(q, usize);
} else {
q = iralloc(p, size, extra, alignment, zero, no_move);
if (q == NULL)
@@ -1720,8 +1600,6 @@ JEMALLOC_P(rallocm)(void **ptr, size_t *rsize, size_t size, size_t extra,
usize = isalloc(q);
}
prof_realloc(q, usize, cnt, old_size, old_ctx);
- if (rsize != NULL)
- *rsize = usize;
} else
#endif
{
diff --git a/dep/jemalloc/src/mb.c b/dep/jemalloc/src/mb.c
index dc2c0a256fd..30a1a2e997a 100644
--- a/dep/jemalloc/src/mb.c
+++ b/dep/jemalloc/src/mb.c
@@ -1,2 +1,2 @@
-#define JEMALLOC_MB_C_
+#define MB_C_
#include "jemalloc/internal/jemalloc_internal.h"
diff --git a/dep/jemalloc/src/mutex.c b/dep/jemalloc/src/mutex.c
index ca89ef1c962..3ecb18a340e 100644
--- a/dep/jemalloc/src/mutex.c
+++ b/dep/jemalloc/src/mutex.c
@@ -55,9 +55,6 @@ pthread_create(pthread_t *__restrict thread,
bool
malloc_mutex_init(malloc_mutex_t *mutex)
{
-#ifdef JEMALLOC_OSSPIN
- *mutex = 0;
-#else
pthread_mutexattr_t attr;
if (pthread_mutexattr_init(&attr) != 0)
@@ -73,7 +70,6 @@ malloc_mutex_init(malloc_mutex_t *mutex)
}
pthread_mutexattr_destroy(&attr);
-#endif
return (false);
}
@@ -81,10 +77,8 @@ void
malloc_mutex_destroy(malloc_mutex_t *mutex)
{
-#ifndef JEMALLOC_OSSPIN
if (pthread_mutex_destroy(mutex) != 0) {
malloc_write("<jemalloc>: Error in pthread_mutex_destroy()\n");
abort();
}
-#endif
}
diff --git a/dep/jemalloc/src/prof.c b/dep/jemalloc/src/prof.c
index 8a144b4e46c..636cccef52a 100644
--- a/dep/jemalloc/src/prof.c
+++ b/dep/jemalloc/src/prof.c
@@ -3,15 +3,15 @@
#ifdef JEMALLOC_PROF
/******************************************************************************/
+#ifdef JEMALLOC_PROF_LIBGCC
+#include <unwind.h>
+#endif
+
#ifdef JEMALLOC_PROF_LIBUNWIND
#define UNW_LOCAL_ONLY
#include <libunwind.h>
#endif
-#ifdef JEMALLOC_PROF_LIBGCC
-#include <unwind.h>
-#endif
-
/******************************************************************************/
/* Data. */
@@ -169,7 +169,39 @@ prof_leave(void)
prof_gdump();
}
-#ifdef JEMALLOC_PROF_LIBUNWIND
+#ifdef JEMALLOC_PROF_LIBGCC
+static _Unwind_Reason_Code
+prof_unwind_init_callback(struct _Unwind_Context *context, void *arg)
+{
+
+ return (_URC_NO_REASON);
+}
+
+static _Unwind_Reason_Code
+prof_unwind_callback(struct _Unwind_Context *context, void *arg)
+{
+ prof_unwind_data_t *data = (prof_unwind_data_t *)arg;
+
+ if (data->nignore > 0)
+ data->nignore--;
+ else {
+ data->bt->vec[data->bt->len] = (void *)_Unwind_GetIP(context);
+ data->bt->len++;
+ if (data->bt->len == data->max)
+ return (_URC_END_OF_STACK);
+ }
+
+ return (_URC_NO_REASON);
+}
+
+void
+prof_backtrace(prof_bt_t *bt, unsigned nignore, unsigned max)
+{
+ prof_unwind_data_t data = {bt, nignore, max};
+
+ _Unwind_Backtrace(prof_unwind_callback, &data);
+}
+#elif defined(JEMALLOC_PROF_LIBUNWIND)
void
prof_backtrace(prof_bt_t *bt, unsigned nignore, unsigned max)
{
@@ -204,41 +236,7 @@ prof_backtrace(prof_bt_t *bt, unsigned nignore, unsigned max)
break;
}
}
-#endif
-#ifdef JEMALLOC_PROF_LIBGCC
-static _Unwind_Reason_Code
-prof_unwind_init_callback(struct _Unwind_Context *context, void *arg)
-{
-
- return (_URC_NO_REASON);
-}
-
-static _Unwind_Reason_Code
-prof_unwind_callback(struct _Unwind_Context *context, void *arg)
-{
- prof_unwind_data_t *data = (prof_unwind_data_t *)arg;
-
- if (data->nignore > 0)
- data->nignore--;
- else {
- data->bt->vec[data->bt->len] = (void *)_Unwind_GetIP(context);
- data->bt->len++;
- if (data->bt->len == data->max)
- return (_URC_END_OF_STACK);
- }
-
- return (_URC_NO_REASON);
-}
-
-void
-prof_backtrace(prof_bt_t *bt, unsigned nignore, unsigned max)
-{
- prof_unwind_data_t data = {bt, nignore, max};
-
- _Unwind_Backtrace(prof_unwind_callback, &data);
-}
-#endif
-#ifdef JEMALLOC_PROF_GCC
+#else
void
prof_backtrace(prof_bt_t *bt, unsigned nignore, unsigned max)
{
@@ -434,7 +432,6 @@ prof_lookup(prof_bt_t *bt)
prof_ctx_t *p;
void *v;
} ctx;
- bool new_ctx;
/*
* This thread's cache lacks bt. Look for it in the global
@@ -471,26 +468,12 @@ prof_lookup(prof_bt_t *bt)
idalloc(ctx.v);
return (NULL);
}
- /*
- * Artificially raise curobjs, in order to avoid a race
- * condition with prof_ctx_merge()/prof_ctx_destroy().
- *
- * No locking is necessary for ctx here because no other
- * threads have had the opportunity to fetch it from
- * bt2ctx yet.
- */
- ctx.p->cnt_merged.curobjs++;
- new_ctx = true;
- } else {
- /*
- * Artificially raise curobjs, in order to avoid a race
- * condition with prof_ctx_merge()/prof_ctx_destroy().
- */
- malloc_mutex_lock(&ctx.p->lock);
- ctx.p->cnt_merged.curobjs++;
- malloc_mutex_unlock(&ctx.p->lock);
- new_ctx = false;
}
+ /*
+ * Acquire ctx's lock before releasing bt2ctx_mtx, in order to
+ * avoid a race condition with prof_ctx_destroy().
+ */
+ malloc_mutex_lock(&ctx.p->lock);
prof_leave();
/* Link a prof_thd_cnt_t into ctx for this thread. */
@@ -503,9 +486,8 @@ prof_lookup(prof_bt_t *bt)
*/
ret.p = ql_last(&prof_tdata->lru_ql, lru_link);
assert(ret.v != NULL);
- if (ckh_remove(&prof_tdata->bt2cnt, ret.p->ctx->bt,
- NULL, NULL))
- assert(false);
+ ckh_remove(&prof_tdata->bt2cnt, ret.p->ctx->bt, NULL,
+ NULL);
ql_remove(&prof_tdata->lru_ql, ret.p, lru_link);
prof_ctx_merge(ret.p->ctx, ret.p);
/* ret can now be re-used. */
@@ -516,8 +498,7 @@ prof_lookup(prof_bt_t *bt)
/* Allocate and partially initialize a new cnt. */
ret.v = imalloc(sizeof(prof_thr_cnt_t));
if (ret.p == NULL) {
- if (new_ctx)
- prof_ctx_destroy(ctx.p);
+ malloc_mutex_unlock(&ctx.p->lock);
return (NULL);
}
ql_elm_new(ret.p, cnts_link);
@@ -528,15 +509,12 @@ prof_lookup(prof_bt_t *bt)
ret.p->epoch = 0;
memset(&ret.p->cnts, 0, sizeof(prof_cnt_t));
if (ckh_insert(&prof_tdata->bt2cnt, btkey.v, ret.v)) {
- if (new_ctx)
- prof_ctx_destroy(ctx.p);
+ malloc_mutex_unlock(&ctx.p->lock);
idalloc(ret.v);
return (NULL);
}
ql_head_insert(&prof_tdata->lru_ql, ret.p, lru_link);
- malloc_mutex_lock(&ctx.p->lock);
ql_tail_insert(&ctx.p->cnts_ql, ret.p, cnts_link);
- ctx.p->cnt_merged.curobjs--;
malloc_mutex_unlock(&ctx.p->lock);
} else {
/* Move ret to the front of the LRU. */
@@ -650,10 +628,11 @@ prof_ctx_destroy(prof_ctx_t *ctx)
/*
* Check that ctx is still unused by any thread cache before destroying
- * it. prof_lookup() artificially raises ctx->cnt_merge.curobjs in
- * order to avoid a race condition with this function, as does
- * prof_ctx_merge() in order to avoid a race between the main body of
- * prof_ctx_merge() and entry into this function.
+ * it. prof_lookup() interlocks bt2ctx_mtx and ctx->lock in order to
+ * avoid a race condition with this function, and prof_ctx_merge()
+ * artificially raises ctx->cnt_merged.curobjs in order to avoid a race
+ * between the main body of prof_ctx_merge() and entry into this
+ * function.
*/
prof_enter();
malloc_mutex_lock(&ctx->lock);
@@ -662,8 +641,7 @@ prof_ctx_destroy(prof_ctx_t *ctx)
assert(ctx->cnt_merged.accumobjs == 0);
assert(ctx->cnt_merged.accumbytes == 0);
/* Remove ctx from bt2ctx. */
- if (ckh_remove(&bt2ctx, ctx->bt, NULL, NULL))
- assert(false);
+ ckh_remove(&bt2ctx, ctx->bt, NULL, NULL);
prof_leave();
/* Destroy ctx. */
malloc_mutex_unlock(&ctx->lock);
@@ -671,10 +649,7 @@ prof_ctx_destroy(prof_ctx_t *ctx)
malloc_mutex_destroy(&ctx->lock);
idalloc(ctx);
} else {
- /*
- * Compensate for increment in prof_ctx_merge() or
- * prof_lookup().
- */
+ /* Compensate for increment in prof_ctx_merge(). */
ctx->cnt_merged.curobjs--;
malloc_mutex_unlock(&ctx->lock);
prof_leave();
@@ -1081,7 +1056,7 @@ prof_bt_hash(const void *key, unsigned minbits, size_t *hash1, size_t *hash2)
} else {
ret1 = h;
ret2 = hash(bt->vec, bt->len * sizeof(void *),
- 0x8432a476666bbc13LLU);
+ 0x8432a476666bbc13U);
}
*hash1 = ret1;
@@ -1118,6 +1093,7 @@ prof_tdata_init(void)
prof_tdata->vec = imalloc(sizeof(void *) * prof_bt_max);
if (prof_tdata->vec == NULL) {
+
ckh_delete(&prof_tdata->bt2cnt);
idalloc(prof_tdata);
return (NULL);
@@ -1135,26 +1111,33 @@ prof_tdata_init(void)
static void
prof_tdata_cleanup(void *arg)
{
- prof_thr_cnt_t *cnt;
- prof_tdata_t *prof_tdata = (prof_tdata_t *)arg;
+ prof_tdata_t *prof_tdata;
- /*
- * Delete the hash table. All of its contents can still be iterated
- * over via the LRU.
- */
- ckh_delete(&prof_tdata->bt2cnt);
+ prof_tdata = PROF_TCACHE_GET();
+ if (prof_tdata != NULL) {
+ prof_thr_cnt_t *cnt;
- /* Iteratively merge cnt's into the global stats and delete them. */
- while ((cnt = ql_last(&prof_tdata->lru_ql, lru_link)) != NULL) {
- ql_remove(&prof_tdata->lru_ql, cnt, lru_link);
- prof_ctx_merge(cnt->ctx, cnt);
- idalloc(cnt);
- }
+ /*
+ * Delete the hash table. All of its contents can still be
+ * iterated over via the LRU.
+ */
+ ckh_delete(&prof_tdata->bt2cnt);
- idalloc(prof_tdata->vec);
+ /*
+ * Iteratively merge cnt's into the global stats and delete
+ * them.
+ */
+ while ((cnt = ql_last(&prof_tdata->lru_ql, lru_link)) != NULL) {
+ prof_ctx_merge(cnt->ctx, cnt);
+ ql_remove(&prof_tdata->lru_ql, cnt, lru_link);
+ idalloc(cnt);
+ }
- idalloc(prof_tdata);
- PROF_TCACHE_SET(NULL);
+ idalloc(prof_tdata->vec);
+
+ idalloc(prof_tdata);
+ PROF_TCACHE_SET(NULL);
+ }
}
void
diff --git a/dep/jemalloc/src/rtree.c b/dep/jemalloc/src/rtree.c
index eb0ff1e24af..7753743c5e6 100644
--- a/dep/jemalloc/src/rtree.c
+++ b/dep/jemalloc/src/rtree.c
@@ -1,4 +1,4 @@
-#define JEMALLOC_RTREE_C_
+#define RTREE_C_
#include "jemalloc/internal/jemalloc_internal.h"
rtree_t *
@@ -20,10 +20,7 @@ rtree_new(unsigned bits)
memset(ret, 0, offsetof(rtree_t, level2bits) + (sizeof(unsigned) *
height));
- if (malloc_mutex_init(&ret->mutex)) {
- /* Leak the rtree. */
- return (NULL);
- }
+ malloc_mutex_init(&ret->mutex);
ret->height = height;
if (bits_per_level * height > bits)
ret->level2bits[0] = bits % bits_per_level;
diff --git a/dep/jemalloc/src/stats.c b/dep/jemalloc/src/stats.c
index dc172e425c0..3dfe0d232a6 100644
--- a/dep/jemalloc/src/stats.c
+++ b/dep/jemalloc/src/stats.c
@@ -39,10 +39,6 @@
bool opt_stats_print = false;
-#ifdef JEMALLOC_STATS
-size_t stats_cactive = 0;
-#endif
-
/******************************************************************************/
/* Function prototypes for non-inline static functions. */
@@ -323,7 +319,6 @@ static void
stats_arena_print(void (*write_cb)(void *, const char *), void *cbopaque,
unsigned i)
{
- unsigned nthreads;
size_t pagesize, pactive, pdirty, mapped;
uint64_t npurge, nmadvise, purged;
size_t small_allocated;
@@ -333,9 +328,6 @@ stats_arena_print(void (*write_cb)(void *, const char *), void *cbopaque,
CTL_GET("arenas.pagesize", &pagesize, size_t);
- CTL_I_GET("stats.arenas.0.nthreads", &nthreads, unsigned);
- malloc_cprintf(write_cb, cbopaque,
- "assigned threads: %u\n", nthreads);
CTL_I_GET("stats.arenas.0.pactive", &pactive, size_t);
CTL_I_GET("stats.arenas.0.pdirty", &pdirty, size_t);
CTL_I_GET("stats.arenas.0.npurge", &npurge, uint64_t);
@@ -677,26 +669,21 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
#ifdef JEMALLOC_STATS
{
int err;
- size_t sszp, ssz;
- size_t *cactive;
+ size_t ssz;
size_t allocated, active, mapped;
size_t chunks_current, chunks_high, swap_avail;
uint64_t chunks_total;
size_t huge_allocated;
uint64_t huge_nmalloc, huge_ndalloc;
- sszp = sizeof(size_t *);
ssz = sizeof(size_t);
- CTL_GET("stats.cactive", &cactive, size_t *);
CTL_GET("stats.allocated", &allocated, size_t);
CTL_GET("stats.active", &active, size_t);
CTL_GET("stats.mapped", &mapped, size_t);
malloc_cprintf(write_cb, cbopaque,
- "Allocated: %zu, active: %zu, mapped: %zu\n",
- allocated, active, mapped);
- malloc_cprintf(write_cb, cbopaque,
- "Current active ceiling: %zu\n", atomic_read_z(cactive));
+ "Allocated: %zu, active: %zu, mapped: %zu\n", allocated,
+ active, mapped);
/* Print chunk stats. */
CTL_GET("stats.chunks.total", &chunks_total, uint64_t);
@@ -748,7 +735,7 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
ninitialized++;
}
- if (ninitialized > 1 || unmerged == false) {
+ if (ninitialized > 1) {
/* Print merged arena stats. */
malloc_cprintf(write_cb, cbopaque,
"\nMerged arenas stats:\n");
diff --git a/dep/jemalloc/src/tcache.c b/dep/jemalloc/src/tcache.c
index 31c329e1613..cbbe7a113a9 100644
--- a/dep/jemalloc/src/tcache.c
+++ b/dep/jemalloc/src/tcache.c
@@ -8,9 +8,6 @@ bool opt_tcache = true;
ssize_t opt_lg_tcache_max = LG_TCACHE_MAXCLASS_DEFAULT;
ssize_t opt_lg_tcache_gc_sweep = LG_TCACHE_GC_SWEEP_DEFAULT;
-tcache_bin_info_t *tcache_bin_info;
-static unsigned stack_nelms; /* Total stack elms per tcache. */
-
/* Map of thread-specific caches. */
#ifndef NO_TLS
__thread tcache_t *tcache_tls JEMALLOC_ATTR(tls_model("initial-exec"));
@@ -58,19 +55,18 @@ tcache_bin_flush_small(tcache_bin_t *tbin, size_t binind, unsigned rem
#endif
)
{
- void *ptr;
+ void *flush, *deferred, *ptr;
unsigned i, nflush, ndeferred;
-#ifdef JEMALLOC_STATS
- bool merged_stats = false;
-#endif
+ bool first_pass;
assert(binind < nbins);
assert(rem <= tbin->ncached);
+ assert(tbin->ncached > 0 || tbin->avail == NULL);
- for (nflush = tbin->ncached - rem; nflush > 0; nflush = ndeferred) {
+ for (flush = tbin->avail, nflush = tbin->ncached - rem, first_pass =
+ true; flush != NULL; flush = deferred, nflush = ndeferred) {
/* Lock the arena bin associated with the first object. */
- arena_chunk_t *chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(
- tbin->avail[0]);
+ arena_chunk_t *chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(flush);
arena_t *arena = chunk->arena;
arena_bin_t *bin = &arena->bins[binind];
@@ -86,17 +82,17 @@ tcache_bin_flush_small(tcache_bin_t *tbin, size_t binind, unsigned rem
malloc_mutex_lock(&bin->lock);
#ifdef JEMALLOC_STATS
if (arena == tcache->arena) {
- assert(merged_stats == false);
- merged_stats = true;
bin->stats.nflushes++;
bin->stats.nrequests += tbin->tstats.nrequests;
tbin->tstats.nrequests = 0;
}
#endif
+ deferred = NULL;
ndeferred = 0;
for (i = 0; i < nflush; i++) {
- ptr = tbin->avail[i];
+ ptr = flush;
assert(ptr != NULL);
+ flush = *(void **)ptr;
chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr);
if (chunk->arena == arena) {
size_t pageind = ((uintptr_t)ptr -
@@ -111,31 +107,21 @@ tcache_bin_flush_small(tcache_bin_t *tbin, size_t binind, unsigned rem
* locked. Stash the object, so that it can be
* handled in a future pass.
*/
- tbin->avail[ndeferred] = ptr;
+ *(void **)ptr = deferred;
+ deferred = ptr;
ndeferred++;
}
}
malloc_mutex_unlock(&bin->lock);
+
+ if (first_pass) {
+ tbin->avail = flush;
+ first_pass = false;
+ }
}
-#ifdef JEMALLOC_STATS
- if (merged_stats == false) {
- /*
- * The flush loop didn't happen to flush to this thread's
- * arena, so the stats didn't get merged. Manually do so now.
- */
- arena_bin_t *bin = &tcache->arena->bins[binind];
- malloc_mutex_lock(&bin->lock);
- bin->stats.nflushes++;
- bin->stats.nrequests += tbin->tstats.nrequests;
- tbin->tstats.nrequests = 0;
- malloc_mutex_unlock(&bin->lock);
- }
-#endif
- memmove(tbin->avail, &tbin->avail[tbin->ncached - rem],
- rem * sizeof(void *));
tbin->ncached = rem;
- if ((int)tbin->ncached < tbin->low_water)
+ if (tbin->ncached < tbin->low_water)
tbin->low_water = tbin->ncached;
}
@@ -146,19 +132,18 @@ tcache_bin_flush_large(tcache_bin_t *tbin, size_t binind, unsigned rem
#endif
)
{
- void *ptr;
+ void *flush, *deferred, *ptr;
unsigned i, nflush, ndeferred;
-#ifdef JEMALLOC_STATS
- bool merged_stats = false;
-#endif
+ bool first_pass;
assert(binind < nhbins);
assert(rem <= tbin->ncached);
+ assert(tbin->ncached > 0 || tbin->avail == NULL);
- for (nflush = tbin->ncached - rem; nflush > 0; nflush = ndeferred) {
+ for (flush = tbin->avail, nflush = tbin->ncached - rem, first_pass =
+ true; flush != NULL; flush = deferred, nflush = ndeferred) {
/* Lock the arena associated with the first object. */
- arena_chunk_t *chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(
- tbin->avail[0]);
+ arena_chunk_t *chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(flush);
arena_t *arena = chunk->arena;
malloc_mutex_lock(&arena->lock);
@@ -170,7 +155,6 @@ tcache_bin_flush_large(tcache_bin_t *tbin, size_t binind, unsigned rem
tcache->prof_accumbytes = 0;
#endif
#ifdef JEMALLOC_STATS
- merged_stats = true;
arena->stats.nrequests_large += tbin->tstats.nrequests;
arena->stats.lstats[binind - nbins].nrequests +=
tbin->tstats.nrequests;
@@ -179,10 +163,12 @@ tcache_bin_flush_large(tcache_bin_t *tbin, size_t binind, unsigned rem
#if (defined(JEMALLOC_PROF) || defined(JEMALLOC_STATS))
}
#endif
+ deferred = NULL;
ndeferred = 0;
for (i = 0; i < nflush; i++) {
- ptr = tbin->avail[i];
+ ptr = flush;
assert(ptr != NULL);
+ flush = *(void **)ptr;
chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr);
if (chunk->arena == arena)
arena_dalloc_large(arena, chunk, ptr);
@@ -193,32 +179,21 @@ tcache_bin_flush_large(tcache_bin_t *tbin, size_t binind, unsigned rem
* Stash the object, so that it can be handled
* in a future pass.
*/
- tbin->avail[ndeferred] = ptr;
+ *(void **)ptr = deferred;
+ deferred = ptr;
ndeferred++;
}
}
malloc_mutex_unlock(&arena->lock);
+
+ if (first_pass) {
+ tbin->avail = flush;
+ first_pass = false;
+ }
}
-#ifdef JEMALLOC_STATS
- if (merged_stats == false) {
- /*
- * The flush loop didn't happen to flush to this thread's
- * arena, so the stats didn't get merged. Manually do so now.
- */
- arena_t *arena = tcache->arena;
- malloc_mutex_lock(&arena->lock);
- arena->stats.nrequests_large += tbin->tstats.nrequests;
- arena->stats.lstats[binind - nbins].nrequests +=
- tbin->tstats.nrequests;
- tbin->tstats.nrequests = 0;
- malloc_mutex_unlock(&arena->lock);
- }
-#endif
- memmove(tbin->avail, &tbin->avail[tbin->ncached - rem],
- rem * sizeof(void *));
tbin->ncached = rem;
- if ((int)tbin->ncached < tbin->low_water)
+ if (tbin->ncached < tbin->low_water)
tbin->low_water = tbin->ncached;
}
@@ -226,14 +201,10 @@ tcache_t *
tcache_create(arena_t *arena)
{
tcache_t *tcache;
- size_t size, stack_offset;
+ size_t size;
unsigned i;
size = offsetof(tcache_t, tbins) + (sizeof(tcache_bin_t) * nhbins);
- /* Naturally align the pointer stacks. */
- size = PTR_CEILING(size);
- stack_offset = size;
- size += stack_nelms * sizeof(void *);
/*
* Round up to the nearest multiple of the cacheline size, in order to
* avoid the possibility of false cacheline sharing.
@@ -246,8 +217,6 @@ tcache_create(arena_t *arena)
if (size <= small_maxclass)
tcache = (tcache_t *)arena_malloc_small(arena, size, true);
- else if (size <= tcache_maxclass)
- tcache = (tcache_t *)arena_malloc_large(arena, size, true);
else
tcache = (tcache_t *)icalloc(size);
@@ -264,12 +233,15 @@ tcache_create(arena_t *arena)
tcache->arena = arena;
assert((TCACHE_NSLOTS_SMALL_MAX & 1U) == 0);
- for (i = 0; i < nhbins; i++) {
- tcache->tbins[i].lg_fill_div = 1;
- tcache->tbins[i].avail = (void **)((uintptr_t)tcache +
- (uintptr_t)stack_offset);
- stack_offset += tcache_bin_info[i].ncached_max * sizeof(void *);
+ for (i = 0; i < nbins; i++) {
+ if ((arena->bins[i].nregs << 1) <= TCACHE_NSLOTS_SMALL_MAX) {
+ tcache->tbins[i].ncached_max = (arena->bins[i].nregs <<
+ 1);
+ } else
+ tcache->tbins[i].ncached_max = TCACHE_NSLOTS_SMALL_MAX;
}
+ for (; i < nhbins; i++)
+ tcache->tbins[i].ncached_max = TCACHE_NSLOTS_LARGE;
TCACHE_SET(tcache);
@@ -280,7 +252,6 @@ void
tcache_destroy(tcache_t *tcache)
{
unsigned i;
- size_t tcache_size;
#ifdef JEMALLOC_STATS
/* Unlink from list of extant tcaches. */
@@ -337,8 +308,7 @@ tcache_destroy(tcache_t *tcache)
}
#endif
- tcache_size = arena_salloc(tcache);
- if (tcache_size <= small_maxclass) {
+ if (arena_salloc(tcache) <= small_maxclass) {
arena_chunk_t *chunk = CHUNK_ADDR2BASE(tcache);
arena_t *arena = chunk->arena;
size_t pageind = ((uintptr_t)tcache - (uintptr_t)chunk) >>
@@ -352,13 +322,6 @@ tcache_destroy(tcache_t *tcache)
malloc_mutex_lock(&bin->lock);
arena_dalloc_bin(arena, chunk, tcache, mapelm);
malloc_mutex_unlock(&bin->lock);
- } else if (tcache_size <= tcache_maxclass) {
- arena_chunk_t *chunk = CHUNK_ADDR2BASE(tcache);
- arena_t *arena = chunk->arena;
-
- malloc_mutex_lock(&arena->lock);
- arena_dalloc_large(arena, chunk, tcache);
- malloc_mutex_unlock(&arena->lock);
} else
idalloc(tcache);
}
@@ -415,13 +378,11 @@ tcache_stats_merge(tcache_t *tcache, arena_t *arena)
}
#endif
-bool
+void
tcache_boot(void)
{
if (opt_tcache) {
- unsigned i;
-
/*
* If necessary, clamp opt_lg_tcache_max, now that
* small_maxclass and arena_maxclass are known.
@@ -436,28 +397,6 @@ tcache_boot(void)
nhbins = nbins + (tcache_maxclass >> PAGE_SHIFT);
- /* Initialize tcache_bin_info. */
- tcache_bin_info = (tcache_bin_info_t *)base_alloc(nhbins *
- sizeof(tcache_bin_info_t));
- if (tcache_bin_info == NULL)
- return (true);
- stack_nelms = 0;
- for (i = 0; i < nbins; i++) {
- if ((arena_bin_info[i].nregs << 1) <=
- TCACHE_NSLOTS_SMALL_MAX) {
- tcache_bin_info[i].ncached_max =
- (arena_bin_info[i].nregs << 1);
- } else {
- tcache_bin_info[i].ncached_max =
- TCACHE_NSLOTS_SMALL_MAX;
- }
- stack_nelms += tcache_bin_info[i].ncached_max;
- }
- for (; i < nhbins; i++) {
- tcache_bin_info[i].ncached_max = TCACHE_NSLOTS_LARGE;
- stack_nelms += tcache_bin_info[i].ncached_max;
- }
-
/* Compute incremental GC event threshold. */
if (opt_lg_tcache_gc_sweep >= 0) {
tcache_gc_incr = ((1U << opt_lg_tcache_gc_sweep) /
@@ -473,8 +412,6 @@ tcache_boot(void)
abort();
}
}
-
- return (false);
}
/******************************************************************************/
#endif /* JEMALLOC_TCACHE */
diff --git a/sql/updates/world/2012_04_17_00_world_creature.sql b/sql/updates/world/2012_04_17_00_world_creature.sql
new file mode 100644
index 00000000000..ebf0fb42a59
--- /dev/null
+++ b/sql/updates/world/2012_04_17_00_world_creature.sql
@@ -0,0 +1,28 @@
+SET @GUID1 := 41781;
+SET @GUID2 := 41783;
+
+DELETE FROM creature WHERE guid IN (@GUID1,@GUID2);
+INSERT INTO `creature`
+(`guid`,`id`,`map`,`spawnMask`,`phaseMask`,`position_x`,`position_y`,`position_z`,`orientation`)
+VALUES
+(@GUID1 ,38453,571,1,1,3561.821,-2736.367,136.0317,0), -- Arcturis in Grizzly Hills
+(@GUID2,35189,571,1,1,7101.845,-1443.734,924.2609,0.178631); -- Skoll in The Storm Peaks
+
+UPDATE `creature_template` SET `faction_A` = 190, `faction_H`=190 WHERE `entry` IN (38453,35189);
+
+SET @NPC= @GUID1*10;
+-- Add pathing for Arcturis
+DELETE FROM `creature_addon` WHERE `guid` = @GUID1;
+INSERT INTO `creature_addon` (`guid`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES
+(@GUID1,@NPC,0,0,0,0,''); -- Add path for Acturis
+-- Add waypoint data for the path:
+DELETE FROM `waypoint_data` WHERE `id`=@NPC;
+INSERT INTO `waypoint_data` (`id`,`point`,`position_x`,`position_y`,`position_z`) VALUES
+(@NPC,1,3563.499,-2737.698,137.1898),
+(@NPC,2,3565.249,-2738.698,138.4398),
+(@NPC,3,3566.749,-2739.948,139.9398),
+(@NPC,4,3568.249,-2740.698,140.6898),
+(@NPC,5,3567.839,-2741.380,141.9256),
+(@NPC,6,3569.999,-2741.948,142.1898),
+(@NPC,7,3570.749,-2742.448,143.1898),
+(@NPC,8,3572.676,-2743.528,144.8479);
diff --git a/sql/updates/world/2012_04_18_00_world_npc_spellclick_spells.sql b/sql/updates/world/2012_04_18_00_world_npc_spellclick_spells.sql
new file mode 100644
index 00000000000..3bad860290b
--- /dev/null
+++ b/sql/updates/world/2012_04_18_00_world_npc_spellclick_spells.sql
@@ -0,0 +1,2 @@
+UPDATE `npc_spellclick_spells` SET `spell_id`=57053 WHERE `npc_entry`=30066 AND `spell_id`=56678;
+UPDATE `creature_template` SET `spell1`=55812 WHERE `entry`=30066;
diff --git a/sql/updates/world/2012_04_18_01_world_creature.sql b/sql/updates/world/2012_04_18_01_world_creature.sql
new file mode 100644
index 00000000000..e2d6bdac95b
--- /dev/null
+++ b/sql/updates/world/2012_04_18_01_world_creature.sql
@@ -0,0 +1 @@
+UPDATE `creature` SET `spawntimesecs`=39600 WHERE `guid` IN (41781,41783); -- Set the spawntime to 11 hours for Arcturis & Skoll
diff --git a/sql/updates/world/2012_04_18_02_world_reference_loot_template.sql b/sql/updates/world/2012_04_18_02_world_reference_loot_template.sql
new file mode 100644
index 00000000000..4ed922060d9
--- /dev/null
+++ b/sql/updates/world/2012_04_18_02_world_reference_loot_template.sql
@@ -0,0 +1,377 @@
+-- ----------------------
+-- -- Various Cleanups --
+-- ----------------------
+DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=10 AND `SourceGroup`=34105;
+DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=4 AND `SourceGroup` IN (27081,27085,27073,26963,26955);
+DELETE FROM `reference_loot_template` WHERE `entry` IN (12020,12021,12022,34105,34125,34126,34127,34128,34129,34130);
+DELETE FROM `gameobject_loot_template` WHERE `entry`=10961; -- Bad Bogblossom fix was bad
+UPDATE `gameobject_template` SET `data1`=26956 WHERE `entry`=194315;
+-- -------------------------------
+-- -- Variables and definitions --
+-- -------------------------------
+-- Freya 10 man
+SET @Freya10k0ID := 194324; -- Freyas Gift 10man ALL elders alive
+SET @Freya10k1ID := 194326; -- Freyas Gift 10man killed 1 elder
+SET @Freya10k2ID := 194328; -- Freyas Gift 10man killed 2 elder
+SET @Freya10k3ID := 194330; -- Freyas Gift 10man killed 3 elder
+-- Freya 25 man
+SET @Freya25k0ID := 194325; -- Freyas Gift 25man ALL elders alive
+SET @Freya25k1ID := 194327; -- Freyas Gift 25man killed 1 elder
+SET @Freya25k2ID := 194329; -- Freyas Gift 25man killed 2 elder
+SET @Freya25k3ID := 194331; -- Freyas Gift 25man killed 3 elder
+-- Hodir
+SET @Hodir10nID := 194307; -- Cache of Winter 10man
+SET @Hodir10hID := 194200; -- Rare Cache of Winter 10man
+SET @Hodir25nID := 194308; -- Cache of Winter 25man
+SET @Hodir25hID := 194201; -- Rare Cache of Winter 25man
+-- Mimiron
+SET @Mimiron10nID := 194789; -- Cache of Innovations 10man
+SET @Mimiron25nID := 194956; -- Cache of Innovations 25man
+SET @Mimiron10hID := 194957; -- Cache of Innovation 10 man Hardmode
+SET @Mimiron25hID := 194958; -- Cache of Innovation 25 man Hardmode
+-- Thorim
+SET @Thorim10nID := 194312; -- Cache of Storms 10man
+SET @Thorim10hID := 194313; -- Cache of Storms 10 man Hardmode
+SET @Thorim25nID := 194314; -- Cache of Storms 25man
+SET @Thorim25hID := 194315; -- Cache of Storms 25 man Hardmode
+
+-- Use procedure to get Lootid from data1 field and assign it to a variable
+-- Freya 10
+CALL `sp_get_go_lootid`(@Freya10k0ID,@Freya10k0);
+CALL `sp_get_go_lootid`(@Freya10k1ID,@Freya10k1);
+CALL `sp_get_go_lootid`(@Freya10k2ID,@Freya10k2);
+CALL `sp_get_go_lootid`(@Freya10k3ID,@Freya10k3);
+-- Freya 25
+CALL `sp_get_go_lootid`(@Freya25k0ID,@Freya25k0);
+CALL `sp_get_go_lootid`(@Freya25k1ID,@Freya25k1);
+CALL `sp_get_go_lootid`(@Freya25k2ID,@Freya25k2);
+CALL `sp_get_go_lootid`(@Freya25k3ID,@Freya25k3);
+-- Hodir 10
+CALL `sp_get_go_lootid`(@Hodir10nID,@Hodir10n);
+CALL `sp_get_go_lootid`(@Hodir10hID,@Hodir10h);
+-- Hodir 25
+CALL `sp_get_go_lootid`(@Hodir25nID,@Hodir25n);
+CALL `sp_get_go_lootid`(@Hodir25hID,@Hodir25h);
+-- Mimiron
+CALL `sp_get_go_lootid`(@Mimiron10nID,@Mimiron10n);
+CALL `sp_get_go_lootid`(@Mimiron10hID,@Mimiron10h);
+CALL `sp_get_go_lootid`(@Mimiron25nID,@Mimiron25n);
+CALL `sp_get_go_lootid`(@Mimiron25hID,@Mimiron25h);
+-- Thorim
+CALL `sp_get_go_lootid`(@Thorim10nID,@Thorim10n);
+CALL `sp_get_go_lootid`(@Thorim10hID,@Thorim10h);
+CALL `sp_get_go_lootid`(@Thorim25nID,@Thorim25n);
+CALL `sp_get_go_lootid`(@Thorim25hID,@Thorim25h);
+-- Set References
+SET @Freya10Ref := 34365;
+SET @Freya25Ref := @Freya10Ref+1;
+SET @Hodir10Ref := @Freya10Ref+2;
+SET @Hodir25Ref := @Freya10Ref+3;
+SET @Mimiron10Ref := @Freya10Ref+4;
+SET @Mimiron25Ref := @Freya10Ref+5;
+SET @Thorim10Ref := @Freya10Ref+6;
+SET @Thorim25Ref := @Freya10Ref+7;
+SET @HandToken := 12026;
+SET @LegToken := @HandToken+1;
+SET @LegsToken := @HandToken+2;
+SET @ChestToken := @HandToken+3;
+SET @HeadToken := @HandToken+4;
+SET @GloveToken := @HandToken+5;
+SET @ShoulderToken := @HandToken+6;
+SET @HelmToken := @HandToken+7;
+SET @Recipe := 34154;
+-- -------------------------
+-- -- Reference Templates --
+-- -------------------------
+-- Delete previous templates if existing
+DELETE FROM `reference_loot_template` WHERE `entry` BETWEEN @Freya10Ref AND @Freya10Ref+7;
+DELETE FROM `reference_loot_template` WHERE `entry` BETWEEN @HandToken AND @HandToken+7;
+INSERT INTO `reference_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+-- Freya 10 man
+(@Freya10Ref,45934,0,1,1,1,1), -- Unraveling Reach
+(@Freya10Ref,45935,0,1,1,1,1), -- Ironbark Faceguard
+(@Freya10Ref,45941,0,1,1,1,1), -- Chestguard of the Lasher
+(@Freya10Ref,45936,0,1,1,1,1), -- Legplates of Flourishing Resolve
+(@Freya10Ref,45940,0,1,1,1,1), -- Tunic of the Limber Stalker
+-- Freya 25 man
+(@Freya25Ref,45483,0,1,1,1,1), -- Boots of the Servant
+(@Freya25Ref,45482,0,1,1,1,1), -- Leggings of the Lifetender
+(@Freya25Ref,45481,0,1,1,1,1), -- Gauntlets of Ruthless Reprisal
+(@Freya25Ref,45480,0,1,1,1,1), -- Nymph Heart Charm
+(@Freya25Ref,45479,0,1,1,1,1), -- The Lifebinder
+-- Freya Tokens
+(@HandToken,45644,0,1,1,1,1), -- Gloves of the Wayward Conqueror
+(@HandToken,45645,0,1,1,1,1), -- Gloves of the Wayward Protector
+(@HandToken,45646,0,1,1,1,1), -- Gloves of the Wayward Vanquisher
+(@LegToken,45653,0,1,1,1,1), -- Legplates of the Wayward Conqueror
+(@LegToken,45654,0,1,1,1,1), -- Legplates of the Wayward Protector
+(@LegToken,45655,0,1,1,1,1), -- Legplates of the Wayward Vanquisher
+-- Hodir 10 man
+(@Hodir10Ref,45874,0,1,1,1,1), -- Signet of Winter
+(@Hodir10Ref,45458,0,1,1,1,1), -- Stormedge
+(@Hodir10Ref,45873,0,1,1,1,1), -- Winter's Frigid Embrace
+(@Hodir10Ref,45872,0,1,1,1,1), -- Avalanche
+(@Hodir10Ref,45454,0,1,1,1,1), -- Cowl of Icy Breaths
+-- Hodir 25 man
+(@Hodir25Ref,45452,0,1,1,1,1), -- Frostplate Greaves
+(@Hodir25Ref,45454,0,1,1,1,1), -- Frost-Bound Chain Bracers
+(@Hodir25Ref,45453,0,1,1,1,1), -- Winter's Icy Embrace
+(@Hodir25Ref,45450,0,1,1,1,1), -- Northern Barrier
+(@Hodir25Ref,45451,0,1,1,1,1), -- Frozen Loop
+-- Hodir Tokens
+(@LegsToken,45650,0,1,1,1,1), -- Leggings of the Wayward Conqueror
+(@LegsToken,45651,0,1,1,1,1), -- Leggings of the Wayward Protector
+(@LegsToken,45652,0,1,1,1,1), -- Leggings of the Wayward Vanquisher
+(@ChestToken,45632,0,1,1,1,1), -- Breastplate of the Wayward Conqueror
+(@ChestToken,45633,0,1,1,1,1), -- Breastplate of the Wayward Protector
+(@ChestToken,45634,0,1,1,1,1), -- Breastplate of the Wayward Vanquisher
+-- Mimiron 10 man
+(@Mimiron10Ref,45974,0,1,1,1,1), -- Shoulderguards of Assimilation
+(@Mimiron10Ref,45976,0,1,1,1,1), -- Static Charge Handwraps
+(@Mimiron10Ref,45972,0,1,1,1,1), -- Pulse Baton
+(@Mimiron10Ref,45973,0,1,1,1,1), -- Stylish Power Cape
+(@Mimiron10Ref,45975,0,1,1,1,1), -- Cable of the Metrognome
+-- Mimiron 25 man
+(@Mimiron25Ref,45492,0,1,1,1,1), -- Malleable Steelweave Mantle
+(@Mimiron25Ref,45493,0,1,1,1,1), -- Asimov's Drape
+(@Mimiron25Ref,45490,0,1,1,1,1), -- Pandora's Plea
+(@Mimiron25Ref,45491,0,1,1,1,1), -- Waistguard of the Creator
+(@Mimiron25Ref,45489,0,1,1,1,1), -- Insanity's Grip
+-- Mimiron Tokens
+(@HeadToken,45647,0,1,1,1,1), -- Helm of the Wayward Conqueror
+(@HeadToken,45648,0,1,1,1,1), -- Helm of the Wayward Protector
+(@HeadToken,45649,0,1,1,1,1), -- Helm of the Wayward Vanquisher
+(@GloveToken,45641,0,1,1,1,1), -- Gauntlets of the Wayward Conqueror
+(@GloveToken,45642,0,1,1,1,1), -- Gauntlets of the Wayward Protector
+(@GloveToken,45643,0,1,1,1,1), -- Gauntlets of the Wayward Vanquisher
+-- Thorim 10 man
+(@Thorim10Ref,45927,0,1,1,1,1), -- Handwraps of Resonance
+(@Thorim10Ref,45894,0,1,1,1,1), -- Leggings of Unstable Discharge
+(@Thorim10Ref,45895,0,1,1,1,1), -- Belt of the Blood Pit
+(@Thorim10Ref,45893,0,1,1,1,1), -- Guise of the Midgard Serpent
+(@Thorim10Ref,45892,0,1,1,1,1), -- Legacy of Thunder
+-- Throim 25 man
+(@Thorim25Ref,45468,0,1,1,1,1), -- Leggings of Lost Love
+(@Thorim25Ref,45466,0,1,1,1,1), -- Scale of Fates
+(@Thorim25Ref,45467,0,1,1,1,1), -- Belt of the Betrayed
+(@Thorim25Ref,45469,0,1,1,1,1), -- Sif's Promise
+(@Thorim25Ref,45463,0,1,1,1,1), -- Vulmir, the Northern Tempest
+-- Thorim Tokens
+(@ShoulderToken,45659,0,1,1,1,1), -- Spaulders of the Wayward Conqueror
+(@ShoulderToken,45660,0,1,1,1,1), -- Spaulders of the Wayward Protector
+(@ShoulderToken,45661,0,1,1,1,1), -- Spaulders of the Wayward Vanquisher
+(@HelmToken,45638,0,1,1,1,1), -- Crown of the Wayward Conqueror
+(@HelmToken,45639,0,1,1,1,1), -- Crown of the Wayward Protector
+(@HelmToken,45640,0,1,1,1,1); -- Crown of the Wayward Vanquisher
+-- -------------------------------
+-- -- Gameobject Loot Templates --
+-- -------------------------------
+-- Delete previous templates if existing
+DELETE FROM `gameobject_loot_template` WHERE `entry` IN (@Freya10k3,@Freya10k2,@Freya10k1,@Freya10k0,@Freya25k3,@Freya25k2,@Freya25k1,@Freya25k0,@Hodir10n,@Hodir10h,@Hodir25n,@Hodir25h,@Mimiron10n,@Mimiron10h,@Mimiron25n,@Mimiron25h,@Thorim10n,@Thorim10h,@Thorim25n,@Thorim25h);
+INSERT INTO `gameobject_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+-- ------------------
+-- -- Freya 10 man --
+-- ------------------
+-- Normal Mode:
+(@Freya10k3,1,100,1,0,-@Freya10Ref,1), -- 1 from normal loot
+(@Freya10k3,2,100,1,0,-@HandToken,1), -- 1 from tokens
+(@Freya10k3,46110,100,1,0,1,1), -- Alchemist's Cache
+(@Freya10k3,47241,100,1,0,1,1), -- 1x Emblem of Triumph
+-- Hard Mode: 1 elder alive
+(@Freya10k2,1,100,1,0,-@Freya10Ref,1), -- 1 from normal loot
+(@Freya10k2,2,100,1,0,-@HandToken,1), -- 1 from tokens
+(@Freya10k2,46110,100,1,0,1,1), -- Alchemist's Cache
+(@Freya10k2,47241,100,1,0,2,2), -- 2x Emblem of Triumph
+(@Freya10k2,45087,100,1,0,1,1), -- Runed Orb
+(@Freya10k2,3,100,1,0,-34349,1), -- 1x Emblem of Triumph for Alive Elders
+-- Hard Mode: 2 elders alive
+(@Freya10k1,1,100,1,0,-@Freya10Ref,1), -- 1 from normal loot
+(@Freya10k1,2,100,1,0,-@HandToken,1), -- 1 from tokens
+(@Freya10k1,46110,100,1,0,1,1), -- Alchemist's Cache
+(@Freya10k1,47241,100,1,0,3,3), -- 3x Emblem of Triumph
+(@Freya10k1,45087,100,1,0,1,1), -- Runed Orb
+(@Freya10k1,3,100,1,0,-@Recipe,1), -- 1 from Recipe
+(@Freya10k1,4,100,1,0,-34349,2), -- 2x Emblem of Triumph for Alive Elders
+-- Hard Mode: 3 elders alive
+(@Freya10k0,1,100,1,0,-@Freya10Ref,1), -- 1 from normal loot
+(@Freya10k0,2,100,1,0,-@HandToken,1), -- 1 from tokens
+(@Freya10k0,46110,100,1,0,1,1), -- Alchemist's Cache
+(@Freya10k0,47241,100,1,0,3,3), -- 3x Emblem of Triumph (self)
+(@Freya10k0,45087,100,1,0,1,1), -- Runed Orb
+(@Freya10k0,3,100,1,0,-@Recipe,1), -- 1 from Recipe
+(@Freya10k0,45788,-100,1,0,1,1), -- Freya's Sigil 10 man QUEST ONLY
+(@Freya10k0,4,100,1,0,-34349,1), -- 3x Emblem of Triumph for Alive Elders
+-- 1 from Hardmode items:
+(@Freya10k0,45943,0,1,1,1,1), -- Gloves of Whispering Winds
+(@Freya10k0,45946,0,1,1,1,1), -- Fire Orchid Signet
+(@Freya10k0,45945,0,1,1,1,1), -- Seed of Budding Carnage
+(@Freya10k0,45947,0,1,1,1,1), -- Serilas, Blood Blade of Invar One-Arm
+(@Freya10k0,45294,0,1,1,1,1), -- Petrified Ivy Sprig
+-- ------------------
+-- -- Freya 25 man --
+-- ------------------
+-- Normal Mode:
+(@Freya25k3,1,100,1,0,-@Freya25Ref,1), -- 1 from normal loot
+(@Freya25k3,2,100,1,0,-@LegToken,2), -- 2 from tokens
+(@Freya25k3,47241,100,1,0,1,1), -- 1x Emblem of Triumph
+(@Freya25k3,46110,100,1,0,1,1), -- Alchemist's Cache
+(@Freya25k3,3,10,1,0,-@Recipe,1), -- Chance on Recipe
+(@Freya25k3,45087,10,1,0,1,1), -- Chance on Runed Orb
+(@Freya25k3,45083,5,1,0,1,1), -- Fragment of Val'anyr
+-- Hard Mode: 1 elder alive
+(@Freya25k2,1,100,1,0,-@Freya25Ref,1), -- 1 from normal loot
+(@Freya25k2,2,100,1,0,-@LegToken,2), -- 2 from tokens
+(@Freya25k2,47241,100,1,0,2,2), -- 2x Emblem of Triumph
+(@Freya25k2,46110,100,1,0,1,1), -- Alchemist's Cache
+(@Freya25k2,3,10,1,0,-@Recipe,1), -- Chance on Recipe
+(@Freya25k2,4,10,1,0,-34350,1), -- Chance on Runed Orb
+(@Freya25k2,45087,100,1,0,2,2), -- 2x Runed Orb
+(@Freya25k2,45083,7,1,0,1,1), -- Fragment of Val'anyr
+(@Freya25k2,5,100,1,0,-34349,1), -- 1x Emblem of Triumph for Alive Elder
+-- Hard Mode: 2 elders alive
+(@Freya25k1,1,100,1,0,-@Freya25Ref,1), -- 1 from normal loot
+(@Freya25k1,2,100,1,0,-@LegToken,2), -- 2 from tokens
+(@Freya25k1,47241,100,1,0,3,3), -- 3x Emblem of Triumph
+(@Freya25k1,46110,100,1,0,1,1), -- Alchemist's Cache
+(@Freya25k1,3,10,1,0,-34350,1), -- Chance on Runed Orb
+(@Freya25k1,45087,100,1,0,2,2), -- 2x Runed Orb
+(@Freya25k1,4,100,1,0,-@Recipe,1), -- Recipe
+(@Freya25k1,5,10,1,0,-@Recipe,1), -- Chance on Recipe
+(@Freya25k1,45083,9,1,0,1,1), -- Fragment of Val'anyr
+(@Freya25k1,6,100,1,0,-34349,2), -- 2x Emblem of Triumph for Alive Elder
+-- Hard Mode: 3 elders alive
+(@Freya25k0,1,100,1,0,-@Freya25Ref,1), -- 1 from normal loot
+(@Freya25k0,2,100,1,0,-@LegToken,2), -- 2 from tokens
+(@Freya25k0,47241,100,1,0,3,3), -- 3x Emblem of Triumph
+(@Freya25k0,46110,100,1,0,1,1), -- Alchemist's Cache
+(@Freya25k0,3,10,1,0,-34350,1), -- Chance on Runed Orb
+(@Freya25k0,45087,100,1,0,2,2), -- 2x Runed Orb
+(@Freya25k0,4,100,1,0,-@Recipe,1), -- Recipe
+(@Freya25k0,5,10,1,0,-@Recipe,1), -- Chance on Recipe
+(@Freya25k0,45814,-100,1,0,1,1), -- Freya's Sigil 25 man QUEST ONLY
+(@Freya25k0,45083,20,1,0,1,1), -- Fragment of Val'anyr
+(@Freya25k2,6,100,1,0,-34349,3), -- 3x Emblem of Triumph for Alive Elder
+-- 1 from Hardmode items
+(@Freya25k0,45484,0,1,1,1,1), -- Bladetwister
+(@Freya25k0,45486,0,1,1,1,1), -- Drape of the Sullen Goddess
+(@Freya25k0,45487,0,1,1,1,1), -- Handguards of Revitalization
+(@Freya25k0,45488,0,1,1,1,1), -- Leggings of the Enslaved Idol
+(@Freya25k0,45613,0,1,1,1,1), -- Dreambinder
+(@Freya25k0,45485,0,1,1,1,1), -- Bronze Pendant of the Vanir
+-- ------------------
+-- -- Hodir 10 man --
+-- ------------------
+(@Hodir10n,1,100,1,0,-@Hodir10Ref,1), -- 1x Normal Loot Item
+(@Hodir10n,2,100,1,0,-@LegsToken,1), -- 1x Token
+(@Hodir10n,47241,100,1,0,1,1), -- Emblem of Triumph
+-- Hard mode:
+(@Hodir10h,1,100,1,0,-@Hodir10Ref,1), -- 1x Normal Loot Item
+(@Hodir10h,2,100,1,0,-@LegsToken,1), -- 1x Token
+(@Hodir10h,47241,100,1,0,1,1), -- Emblem of Triumph
+(@Hodir10h,45786,-100,1,0,1,1), -- Hodir's Sigil
+-- 1 from Hardmode items
+(@Hodir10h,45887,0,1,1,1,1), -- Ice Layered Barrier
+(@Hodir10h,45888,0,1,1,1,1), -- Bitter Cold Armguards
+(@Hodir10h,45886,0,1,1,1,1), -- Icecore Staff
+(@Hodir10h,45876,0,1,1,1,1), -- Shiver
+(@Hodir10h,45877,0,1,1,1,1), -- The Boreal Guard
+-- ------------------
+-- -- Hodir 25 man --
+-- ------------------
+(@Hodir25n,1,100,1,0,-@Hodir25Ref,1), -- 1x Normal Loot Item
+(@Hodir25n,2,100,1,0,-@ChestToken,1), -- 1x Token
+(@Hodir25n,47241,100,1,0,1,1), -- Emblem of Triumph
+(@Hodir25n,3,10,1,0,-@Recipe,1), -- Chance on Recipe
+(@Hodir25n,45087,10,1,0,1,1), -- Chance on Runed Orb
+(@Hodir25n,45083,10,1,0,1,1), -- Fragment of Val'anyr
+-- Hard mode:
+(@Hodir25h,1,100,1,0,-@Hodir25Ref,1), -- 1x Normal Loot Item
+(@Hodir25h,2,100,1,0,-@ChestToken,2), -- 2x Token
+(@Hodir25h,47241,100,1,0,1,1), -- Emblem of Triumph
+(@Hodir25h,45815,-100,1,0,1,1), -- Hodir's Sigil
+(@Hodir25h,3,10,1,0,-@Recipe,1), -- Chance on Recipe
+(@Hodir25h,45087,10,1,0,1,1), -- Chance on Runed Orb
+(@Hodir25h,45083,20,1,0,1,1), -- Fragment of Val'anyr
+-- --------------------
+-- -- Mimiron 10 man --
+-- --------------------
+(@Mimiron10n,1,100,1,0,-@Mimiron10Ref,1), -- 1x Normal Loot Item
+(@Mimiron10n,2,100,1,0,-@HeadToken,1), -- 1x Token
+(@Mimiron10n,47241,100,1,0,1,1), -- 1x Emblem of Triumph
+-- Hardmode 10 man
+(@Mimiron10h,1,100,1,0,-@Mimiron10Ref,1), -- 1x Normal Loot Item
+(@Mimiron10h,2,100,1,0,-@HeadToken,1), -- 1x Token
+(@Mimiron10h,47241,100,1,0,1,1), -- 1x Emblem of Triumph
+(@Mimiron10h,45787,-100,1,0,1,1), -- Mimiron's Sigel (QUEST ONLY, HARDMODE ONLY)
+-- 1 from Hardmode items
+(@Mimiron10h,45989,0,1,1,1,1), -- Tempered Mercury Greaves
+(@Mimiron10h,45982,0,1,1,1,1), -- Fused Alloy Legplates
+(@Mimiron10h,45993,0,1,1,1,1), -- Mimiron's Flight Goggles
+(@Mimiron10h,45988,0,1,1,1,1), -- Greaves of the Iron Army
+(@Mimiron10h,45990,0,1,1,1,1), -- Fusion Blade
+-- --------------------
+-- -- Mimiron 25 man --
+-- --------------------
+(@Mimiron25n,1,100,1,0,-@Mimiron25Ref,1), -- 1x Normal Loot Item
+(@Mimiron25n,2,100,1,0,-@GloveToken,2), -- 2x Token
+(@Mimiron25n,47241,100,1,0,1,1), -- 1x Emblem of Triumph
+(@Mimiron25n,3,10,1,0,-@Recipe,1), -- Chance on Recipe
+(@Mimiron25n,45087,10,1,0,1,1), -- Chance on Runed Orb
+(@Mimiron25n,45083,8,1,0,1,1), -- Fragment of Val'anyr Normal
+-- Hard Mode 25 man
+(@Mimiron25h,1,100,1,0,-@Mimiron25Ref,1), -- 1x Normal Loot Item
+(@Mimiron25h,2,100,1,0,-@GloveToken,2), -- 2x Token
+(@Mimiron25h,47241,100,1,0,1,1), -- 1x Emblem of Triumph
+(@Mimiron25h,3,10,1,0,-@Recipe,1), -- Chance on Recipe
+(@Mimiron25h,45087,10,1,0,1,1), -- Chance on Runed Orb
+(@Mimiron25h,45816,-100,1,0,1,1), -- Mimiron's Sigel (QUEST ONLY, HARDMODE ONLY)
+(@Mimiron25h,45083,18,1,0,1,1), -- Fragment of Val'anyr Hardmode
+-- 1 from Hardmode items
+(@Mimiron25h,45496,0,1,1,1,1), -- Titanskin Cloak
+(@Mimiron25h,45494,0,1,1,1,1), -- Delirium's Touch
+(@Mimiron25h,45663,0,1,1,1,1), -- Armbands of Bedlam
+(@Mimiron25h,45620,0,1,1,1,1), -- Starshard Edge
+(@Mimiron25h,45495,0,1,1,1,1), -- Conductive Seal
+(@Mimiron25h,45497,0,1,1,1,1), -- Crown of Luminescence
+-- -------------------
+-- -- Thorim 10 man --
+-- -------------------
+(@Thorim10n,1,100,1,0,-@Thorim10Ref,1), -- 1x Normal Loot Item
+(@Thorim10n,2,100,1,0,-@ShoulderToken,1), -- 1x Token
+(@Thorim10n,47241,100,1,0,1,1), -- 1x Emblem of Triumph
+-- Hardmode 10 man
+(@Thorim10h,1,100,1,0,-@Thorim10Ref,1), -- 1x Normal Loot Item
+(@Thorim10h,2,100,1,0,-@ShoulderToken,1), -- 1x Token
+(@Thorim10h,47241,100,1,0,1,1), -- 1x Emblem of Triumph
+(@Thorim10h,45784,-100,2,0,1,1), -- Thorim's Sigil (QUEST ONLY, HARDMODE ONLY)
+-- 1 from Hardmode items
+(@Thorim10h,45933,0,2,1,1,1), -- Pendant of the Shallow Grave
+(@Thorim10h,45929,0,2,1,1,1), -- Sif's Remembrance
+(@Thorim10h,45928,0,2,1,1,1), -- Gauntlets of the Thunder God
+(@Thorim10h,45931,0,2,1,1,1), -- Mjolnir Runestone
+(@Thorim10h,45930,0,2,1,1,1), -- Combatant's Bootblade
+-- -------------------
+-- -- Thorim 25 man --
+-- -------------------
+(@Thorim25n,1,100,3,0,-@Thorim25Ref,1), -- 1x Normal Loot Item
+(@Thorim25n,2,100,3,0,-@HelmToken,2), -- 2x Token
+(@Thorim25n,47241,100,3,0,1,1), -- 1x Emblem of Triumph
+(@Thorim25n,3,10,3,0,-@Recipe,1), -- Chance on Recipe
+(@Thorim25n,45087,10,3,0,1,1), -- Chance on Runed Orb
+(@Thorim25n,45083,8,1,0,1,1), -- Fragment of Val'anyr Normal
+-- Hardmode 25 man
+(@Thorim25h,1,100,3,0,-@Thorim25Ref,1), -- 1x Normal Loot Item
+(@Thorim25h,2,100,3,0,-@HelmToken,2), -- 2x Token
+(@Thorim25h,47241,100,3,0,1,1), -- 1x Emblem of Triumph
+(@Thorim25h,3,10,3,0,-@Recipe,1), -- Chance on Recipe
+(@Thorim25h,45087,10,3,0,1,1), -- Chance on Runed Orb
+(@Thorim25h,45817,-100,1,0,1,1), -- Thorim's Sigil (QUEST ONLY, HARDMODE ONLY)
+(@Thorim25h,45083,18,1,0,1,1), -- Fragment of Val'anyr Hardmode
+-- 1 from Hardmode items
+(@Thorim25h,45471,0,1,1,1,1), -- Fate's Clutch
+(@Thorim25h,45570,0,1,1,1,1), -- Skyforge Crossbow
+(@Thorim25h,45472,0,1,1,1,1), -- Warhelm of the Champion
+(@Thorim25h,45474,0,1,1,1,1), -- Pauldrons of the Combatant
+(@Thorim25h,45470,0,1,1,1,1), -- Wisdom's Hold
+(@Thorim25h,45473,0,1,1,1,1); -- Embrace of the Gladiator
+
diff --git a/sql/updates/world/2012_04_18_03_world_creature_loot_template.sql b/sql/updates/world/2012_04_18_03_world_creature_loot_template.sql
new file mode 100644
index 00000000000..5ad26809cdf
--- /dev/null
+++ b/sql/updates/world/2012_04_18_03_world_creature_loot_template.sql
@@ -0,0 +1,2 @@
+-- Increase dropchance for Venture Co. Explosives
+UPDATE `creature_loot_template` SET `ChanceOrQuestChance`=-10 WHERE `entry` IN(28123,28124) AND `item`=39651;
diff --git a/sql/updates/world/2012_04_18_04_world_pickpocketing_loot_template.sql b/sql/updates/world/2012_04_18_04_world_pickpocketing_loot_template.sql
new file mode 100644
index 00000000000..ab1c562f7dd
--- /dev/null
+++ b/sql/updates/world/2012_04_18_04_world_pickpocketing_loot_template.sql
@@ -0,0 +1,501 @@
+-- implement missing Northrend pickpocket loot
+-- reference IDs
+SET @NEWREF0 := 10026;
+SET @NEWREF1 := @NEWREF0+1;
+SET @NEWREF2 := @NEWREF0+2;
+SET @NEWREF3 := @NEWREF0+3;
+SET @NEWREF4 := @NEWREF0+4;
+SET @NEWREF5 := @NEWREF0+5;
+SET @NEWREF6 := @NEWREF0+6;
+SET @NEWREF7 := @NEWREF0+7;
+SET @NEWREF8 := @NEWREF0+8;
+SET @NEWREF9 := @NEWREF0+9;
+-- new references
+DELETE FROM `reference_loot_template` WHERE entry IN (@NEWREF0, @NEWREF1, @NEWREF2, @NEWREF3, @NEWREF4, @NEWREF5, @NEWREF6, @NEWREF7, @NEWREF8, @NEWREF9);
+INSERT INTO `reference_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`mincountOrRef`,`maxcount`) VALUES
+(@NEWREF0,33447,25,1,1),-- Runic Healing Potion
+(@NEWREF0,35953,30,1,1),-- Mead Basted Caribou
+(@NEWREF0,38260,50,1,1),-- Empty Tobacco Pouch
+(@NEWREF0,43575,80,1,1),-- Reinforced Junkbox
+(@NEWREF1,36862,4,1,1),-- Wrogn Troll Dice
+(@NEWREF1,40202,20,1,1),-- Sizzling Grizzly Flank
+(@NEWREF2,33452,30,1,1),-- Honey-Spiced Lichen
+(@NEWREF2,38269,35,1,1),-- Soggy Handkerchief
+(@NEWREF3,33454,15,1,1),-- Salted Venison
+(@NEWREF3,38261,13,1,1),-- Ben House Key
+(@NEWREF4,38263,19,1,1),-- Too-Small Amband
+(@NEWREF4,38264,18,1,1),-- A Very Pretty Rock
+(@NEWREF5,29448,9,1,1),-- Mag'har Mild Cheese
+(@NEWREF5,29450,13,1,1),-- Telaari Grapes
+(@NEWREF5,37467,40,1,1),-- A Steamy Romance Novel: Forbidden Love
+(@NEWREF6,35947,25,1,1),-- Sparkling Frostcap
+(@NEWREF6,38269,40,1,1),-- Soggy Handkerchief
+(@NEWREF7,33447,25,1,1),-- Runic Healing Potion
+(@NEWREF7,35947,25,1,1),-- Sparkling Frostcap
+(@NEWREF7,38269,40,1,1),-- Soggy Handkerchief
+(@NEWREF7,43575,80,1,1),-- Reinforced Junkbox
+(@NEWREF8,35948,11,1,1),-- Savory Snowplum
+(@NEWREF8,35950,9,1,1),-- Sweet Potato Bread
+(@NEWREF8,35952,8,1,1),-- Briny Hardcheese
+(@NEWREF9,33447,25,1,1),-- Runic Healing Potion
+(@NEWREF9,38260,50,1,1),-- Empty Tobacco Pouch
+(@NEWREF9,43575,80,1,1); -- Reinforced Junkbox
+-- implement pickpokect loot
+UPDATE `creature_template` SET `pickpocketloot`=entry WHERE `entry` IN (25800,23667,23674,23760,23796,23865,23875,23963,24069,24262,24400,24460,25351,25427,25428,25429,25430,25601,25801,26073,26202,26334,26413,26447,26480,26481,26620,26621,26624,26626,26635,26636,26637,26639,26658,26681,26696,26727,26729,26800,26802,26836,26948,27105,27210,27211,/**/27234,27235,27247,27278,27289,27334,27342,27431,27533,27580,27639,27640,27699,27800,27859,27860,27961,27964,27965,28494,28496,28565,28803,28837,28838,28848,28961,28965,29369,29407,29553,29554,29656,29793,29820,29822,29836,29874,29875,29885,29920,30283,30319,30856,30868,31396,31554,32263);
+UPDATE `creature_template` SET `pickpocketloot`=25430 WHERE `entry` IN (23654,23656,23663,23665,25434,26728,26827,26926,27554,32572);
+UPDATE `creature_template` SET `pickpocketloot`=26481 WHERE `entry` IN (23662,23940,24016,24161,26493,26655,27007,27009);
+UPDATE `creature_template` SET `pickpocketloot`=25351 WHERE `entry` IN (23993,24540,25224,25383,26343,26492,26891,26946,27224,27226,27283,27360,27552,27799,27823,27826,28564,28750);
+UPDATE `creature_template` SET `pickpocketloot`=27533 WHERE `entry` IN (26555,26669,26670,26694,26830,27871,28022,28108,28242,28268,28419,29123,29133,29722,29738,30701,30894,30922,30949,31139,31150,31779,31847,32278,32505);
+UPDATE `creature_template` SET `pickpocketloot`=30319 WHERE `entry` IN (30111,30179);
+DELETE FROM `pickpocketing_loot_template` WHERE entry IN (25800,23656,23662,23663,23665,23667,23674,23760,23796,23865,23875,23940,23963,23993,24016,24069,24161,24262,24400,24460,24540,25224,25351,25383,25427,25428,25429,25430,25434,25601,25801,26073,26202,26334,26343,26413,26447,26480,26481,26492,26493,26555,26620,26621,26624,26626,26635,26636,26637,26639,26655,26658,26669,26670,26681,26694,26696,26727,26728,26729,26800,26802,26827,26830,26836,26891,26926,26946,26948,27007,27009,27105,27210,27211,27224,27226,27234,27235,27247,27278,27283,27289,27334,27342,27360,27431,27533,27552,27554,27580,27639,27640,27699,27799,27800,27823,27826,27859,27860,27871,27961,27964,27965,28022,28108,28242,28268,28419,28494,28496,28564,28565,28750,28803,28837,28838,28848,28961,28965,29123,29133,29369,29407,29553,29554,29656,29722,29738,29793,29820,29822,29836,29874,29875,29885,29920,30111,30179,30283,30319,30701,30856,30868,30894,30922,30949,31139,31150,31396,31554,31779,31847,32263,32278,32505,32572);
+INSERT INTO `pickpocketing_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+-- Plague Walker
+(30283,43575,100,0,1,1),-- Reinforced Junkbox
+(30283,0,100,0,-@NEWREF6,1),
+-- Twilight Darkcaster
+(30319,0,100,0,-@NEWREF0,1),
+(30319,33449,11,0,1,1),-- Crusty Flatbread
+(30319,1,100,0,-@NEWREF1,1),
+(30319,2,100,0,-@NEWREF3,1),
+-- High Priest Talet-Kha
+(26073,43575,58,0,1,1),-- Reinforced Junkbox
+(26073,0,100,0,-@NEWREF5,1),
+(26073,33449,8,0,1,1),-- Crusty Flatbread
+(26073,33447,8,0,1,1),-- Runic Healing Potion
+-- Nedar, Lord of Rhinos
+(25801,0,100,0,-@NEWREF5,1),
+(25801,33447,6,0,1,1),-- Runic Healing Potion
+(25801,38261,6,0,1,1),-- Bent House Key
+-- Clam Master K
+(25800,43575,47,0,1,1),-- Reinforced Junkbox
+(25800,0,100,0,-@NEWREF5,1),
+(25800,38261,15,0,1,1),-- Bent House Key
+(25800,33449,5,0,1,1),-- Crusty Flatbread
+(25800,33447,5,0,1,1),-- Runic Healing Potion
+-- Magmothregar
+(25430,0,100,0,-@NEWREF3,1),
+(25430,1,100,0,-@NEWREF9,1),
+(25430,33449,7,0,1,1),-- Crusty Flatbread
+(25430,36862,4,0,1,1),-- Wrogn Troll Dice
+-- Kaganishu
+(25427,43575,43,0,1,1),-- Reinforced Junkbox
+(25427,33454,35,0,1,1),-- Salted Venison
+(25427,0,100,0,-@NEWREF4,1),
+(25427,33447,8,0,1,1),-- Runic Healing Potion
+-- Prince Valanar
+(25601,43575,43,0,1,1),-- Reinforced Junkbox
+(25601,37467,39,0,1,1),-- A Steamy Romance Novel: Forbidden Love
+(25601,33447,9,0,1,1),-- Runic Healing Potion
+(25601,38261,9,0,1,1),-- Bent House Key
+(25601,33449,4,0,1,1),-- Crusty Flatbread
+(25601,29450,4,0,1,1),-- Telaari Grapes
+-- Ghostly Sage
+(25351,43575,42,0,1,1),-- Reinforced Junkbox
+(25351,0,100,0,-@NEWREF2,1),
+(25351,33447,10,0,1,1),-- Runic Healing Potion
+-- Luthion the Vile
+(27860,43575,42,0,1,1),-- Reinforced Junkbox
+(27860,0,100,0,-@NEWREF5,1),
+(27860,38261,13,0,1,1),-- Bent House Key
+(27860,33449,6,0,1,1),-- Crusty Flatbread
+(27860,33447,6,0,1,1),-- Runic Healing Potion
+-- Reckless Scavenger
+(26658,0,100,0,-@NEWREF2,1),
+(26658,43575,40,0,1,1),-- Reinforced Junkbox
+-- Ziggurat Defender
+(26202,43575,40,0,1,1),-- Reinforced Junkbox
+(26202,0,100,0,-@NEWREF2,1),
+(26202,33447,7,0,1,1),-- Runic Healing Potion
+(26202,29569,3,0,1,1),-- Strong Junkbox
+-- Magmoth Forager
+(25429,43575,39,0,1,1),-- Reinforced Junkbox
+(25429,33454,27,0,1,1),-- Salted Venison
+(25429,0,100,0,-@NEWREF4,1),
+(25429,33447,10,0,1,1),-- Runic Healing Potion
+(25429,38266,0.5,0,1,1),-- Rotund Relic
+-- Magmoth Shaman
+(25428,43575,39,0,1,1),-- Reinforced Junkbox
+(25428,33454,28,0,1,1),-- Salted Venison
+(25428,0,100,0,-@NEWREF4,1),
+(25428,33447,9,0,1,1),-- Runic Healing Potion
+(25428,38266,0.5,0,1,1),-- Rotund Relic
+-- Vanthryn the Merciless
+(27859,43575,39,0,1,1),-- Reinforced Junkbox
+(27859,0,100,0,-@NEWREF5,1),
+(27859,33449,12,0,1,1),-- Crusty Flatbread
+(27859,38261,12,0,1,1),-- Bent House Key
+(27859,33447,3,0,1,1),-- Runic Healing Potion
+-- Unbound Corrupter
+(30868,43575,47,0,1,1),-- Reinforced Junkbox
+(30868,40202,18,0,1,1),-- Sizzling Grizzly Flank
+(30868,33447,16,0,1,1),-- Runic Healing Potion
+(30868,0,100,0,-@NEWREF4,1),
+-- Unbound Trickster
+(30856,43575,38,0,1,1),-- Reinforced Junkbox
+(30856,0,100,0,-@NEWREF4,1),
+(30856,33447,19,0,1,1),-- Runic Healing Potion
+(30856,40202,14,0,1,1),-- Sizzling Grizzly Flank
+-- Kreug Oathbreaker
+(27105,43575,63,0,1,1),-- Reinforced Junkbox
+(27105,33447,25,0,1,1),-- Runic Healing Potion
+(27105,38269,13,0,1,1),-- Soggy Handkerchief
+-- Lead Cannoneer Zierhut
+(27235,43575,53,0,1,1),-- Reinforced Junkbox
+(27235,0,100,0,-@NEWREF5,1),
+(27235,33447,8,0,1,1),-- Runic Healing Potion
+(27235,38261,8,0,1,1),-- Bent House Key
+-- Devout Bodyguard
+(27247,43575,50,0,1,1),-- Reinforced Junkbox
+(27247,37467,42,0,1,1),-- A Steamy Romance Novel: Forbidden Love
+(27247,33447,8,0,1,1),-- Runic Healing Potion
+(27247,29450,8,0,1,1),-- Telaari Grapes
+(27247,38261,8,0,1,1),-- Bent House Key
+-- Magnataur Alpha
+(26481,0,100,0,-@NEWREF9,1),
+(26481,1,100,0,-@NEWREF3,1),
+(26481,33449,5,0,1,1),-- Crusty Flatbread
+-- High General Abbendis
+(27210,43575,48,0,1,1),-- Reinforced Junkbox
+(27210,0,100,0,-@NEWREF5,1),
+(27210,33449,10,0,1,1),-- Crusty Flatbread
+(27210,33447,10,0,1,1),-- Runic Healing Potion
+(27210,38261,8,0,1,1),-- Bent House Key
+-- Anub'ar Dreadweaver
+(26413,43575,44,0,1,1),-- Reinforced Junkbox
+(26413,43576,22,0,1,1),-- Chitin Polish
+(26413,33452,11,0,1,1),-- Honey-Spiced Lichen
+(26413,33447,11,0,1,1),-- Runic Healing Potion
+(26413,43577,11,0,1,1),-- Carapace Cleanser
+-- Naxxramas Necrolord
+(27289,33452,44,0,1,1),-- Honey-Spiced Lichen
+(27289,43575,44,0,1,1),-- Reinforced Junkbox
+(27289,33447,11,0,1,1),-- Runic Healing Potion
+-- Onslaught Commander Iustus
+(27334,37467,50,0,1,1),-- A Steamy Romance Novel: Forbidden Love
+(27334,43575,44,0,1,1),-- Reinforced Junkbox
+(27334,29448,13,0,1,1),-- Mag'har Mild Cheese
+(27334,38261,6,0,1,1),-- Bent House Key
+-- Blacksmith Goodman
+(27234,43575,41,0,1,1),-- Reinforced Junkbox
+(27234,0,100,0,-@NEWREF5,1),
+(27234,38261,13,0,1,1),-- Bent House Key
+(27234,33447,9,0,1,1),-- Runic Healing Potion
+(27234,33449,7,0,1,1),-- Crusty Flatbread
+-- Magnataur Youngling
+(26480,33449,19,0,1,1),-- Crusty Flatbread
+(26480,0,100,0,-@NEWREF3,1),
+(26480,1,100,0,-@NEWREF9,1),
+-- Bloodpaw Warrior
+(27342,43575,40,0,1,1),-- Reinforced Junkbox
+(27342,33454,26,0,1,1),-- Salted Venison
+(27342,0,100,0,-@NEWREF4,1),
+(27342,33447,11,0,1,1),-- Runic Healing Potion
+(27342,38266,0.6,0,1,1),-- Rotund Relic
+-- Frigid Geist
+(27533,0,100,0,-@NEWREF7,1),
+-- Snowplain Zealot
+(27278,43575,40,0,1,1),-- Reinforced Junkbox
+(27278,33454,22,0,1,1),-- Salted Venison
+(27278,0,100,0,-@NEWREF4,1),
+(27278,33447,12,0,1,1),-- Runic Healing Potion
+(27278,38266,0.3,0,1,1),-- Rotund Relic
+-- Hulking Atrocity
+(26948,43575,39,0,1,1),-- Reinforced Junkbox
+(26948,0,100,0,-@NEWREF2,1),
+(26948,33447,9,0,1,1),-- Runic Healing Potion
+(26948,29569,0.3,0,1,1),-- Strong Junkbox
+(26948,38268,0.3,0,1,1),-- Spare Hand
+-- Onslaught Executioner
+(27211,43575,39,0,1,1),-- Reinforced Junkbox
+(27211,0,100,0,-@NEWREF5,1),
+(27211,33449,12,0,1,1),-- Crusty Flatbread
+(27211,38261,11,0,1,1),-- Bent House Key
+(27211,33447,5,0,1,1),-- Runic Healing Potion
+-- Gigantaur
+(26836,0,100,0,-@NEWREF9,1),
+(26836,1,100,0,-@NEWREF3,1),
+(26836,33449,12,0,1,1),-- Crusty Flatbread
+-- Leprous Servant
+(27800,43575,38,0,1,1),-- Reinforced Junkbox
+(27800,0,100,0,-@NEWREF2,1),
+(27800,33447,7,0,1,1),-- Runic Healing Potion
+(27800,38268,2,0,1,1),-- Spare Hand
+-- Wretched Belcher
+(26624,43575,100,0,1,1),-- Reinforced Junkbox
+(26624,0,100,0,-@NEWREF2,1),
+(26624,33447,25,0,1,1),-- Runic Healing Potion
+(26624,35947,25,0,1,1),-- Sparkling Frostcap
+-- Drakkari Commander
+(27431,43575,90,0,1,1),-- Reinforced Junkbox
+(27431,0,100,0,-@NEWREF2,1),
+(27431,33447,26,0,1,1),-- Runic Healing Potion
+(27431,35947,10,0,1,1),-- Sparkling Frostcap
+-- Drakkari Guardian
+(26620,0,100,0,-@NEWREF0,1),
+(26620,33454,17,0,1,1),-- Salted Venison
+(26620,33449,9,0,1,1),-- Crusty Flatbread
+(26620,38261,9,0,1,1),-- Bent House Key
+(26620,1,100,0,-@NEWREF1,1),
+-- Risen Drakkari Soulmage
+(26636,43575,85,0,1,1),-- Reinforced Junkbox
+(26636,0,100,0,-@NEWREF2,1),
+(26636,35947,21,0,1,1),-- Sparkling Frostcap
+(26636,33447,16,0,1,1),-- Runic Healing Potion
+-- Ghoul Tormentor
+(26621,43575,81,0,1,1),-- Reinforced Junkbox
+(26621,0,100,0,-@NEWREF2,1),
+(26621,35947,24,0,1,1),-- Sparkling Frostcap
+(26621,33447,14,0,1,1),-- Runic Healing Potion
+-- Risen Drakkari Warrior
+(26635,43575,71,0,1,1),-- Reinforced Junkbox
+(26635,0,100,0,-@NEWREF2,1),
+(26635,33447,29,0,1,1),-- Runic Healing Potion
+(26635,35947,18,0,1,1),-- Sparkling Frostcap
+(26635,38268,0.8,0,1,1),-- Spare Hand
+-- Risen Drakkari Handler
+(26637,0,100,0,-@NEWREF2,1),
+(26637,43575,67,0,1,1),-- Reinforced Junkbox
+(26637,33447,30,0,1,1),-- Runic Healing Potion
+(26637,35947,18,0,1,1),-- Sparkling Frostcap
+-- Scourge Reanimator
+(26626,0,100,0,-@NEWREF2,1),
+(26626,43575,67,0,1,1),-- Reinforced Junkbox
+(26626,33447,21,0,1,1),-- Runic Healing Potion
+(26626,35947,21,0,1,1),-- Sparkling Frostcap
+-- Drakkari Shaman
+(26639,0,100,0,-@NEWREF0,1),
+(26639,33449,18,0,1,1),-- Crusty Flatbread
+(26639,1,100,0,-@NEWREF3,1),
+(26639,40202,11,0,1,1),-- Sizzling Grizzly Flank
+-- Selas
+(27580,43575,50,0,1,1),-- Reinforced Junkbox
+(27580,0,100,0,-@NEWREF3,1),
+(27580,38260,20,0,1,1),-- Empty Tobacco Pouch
+-- Forgemaster Damrath
+(26334,43575,48,0,1,1),-- Reinforced Junkbox
+(26334,0,100,0,-@NEWREF5,1),
+(26334,33447,9,0,1,1),-- Runic Healing Potion
+(26334,38261,9,0,1,1),-- Bent House Key
+-- Grumbald One-Eye
+(26681,43575,39,0,1,1),-- Reinforced Junkbox
+(26681,33454,28,0,1,1),-- Salted Venison
+(26681,0,100,0,-@NEWREF4,1),
+(26681,33447,9,0,1,1),-- Runic Healing Potion
+-- Drakkari Shaman
+(26447,0,100,0,-@NEWREF9,1),
+(26447,1,100,0,-@NEWREF3,1),
+(26447,33449,10,0,1,1),-- Crusty Flatbread
+(26447,35799,0.2,0,1,1),-- Frozen Mojo
+(26447,36862,0.2,0,1,1),-- Wrogn Troll Dice
+-- Drakkari God Hunter
+(29820,0,100,0,-@NEWREF0,1),
+(29820,1,100,0,-@NEWREF1,1),
+-- Drakkari Battle Rider
+(29836,0,100,0,-@NEWREF0,1),
+(29836,40202,18,0,1,1),-- Sizzling Grizzly Flank
+-- Ruins Dweller
+(29920,43575,71,0,1,1),-- Reinforced Junkbox
+(29920,37452,69,0,1,1),-- Fatty Bluefin
+(29920,38274,58,0,1,1),-- Large Snail Shell
+(29920,38273,35,0,1,1),-- Brain Coral
+(29920,33447,16,0,1,1),-- Runic Healing Potion
+-- Drakkari Fire Weaver
+(29822,0,100,0,-@NEWREF0,1),
+(29822,40202,24,0,1,1),-- Sizzling Grizzly Flank
+-- Drakkari Inciter
+(29874,0,100,0,-@NEWREF0,1),
+(29874,36862,16,0,1,1),-- Wrogn Troll Dice
+(29874,40202,12,0,1,1),-- Sizzling Grizzly Flank
+-- Titanium Siegebreaker
+(28961,0,100,0,-@NEWREF0,1),
+(28961,40202,35,0,1,1),-- Sizzling Grizzly Flank
+-- Stormforged Sentinel
+(28837,0,100,0,-@NEWREF0,1),
+(28837,40202,16,0,1,1),-- Sizzling Grizzly Flank
+-- Titanium Thunderer
+(28965,0,100,0,-@NEWREF0,1),
+(28965,40202,44,0,1,1),-- Sizzling Grizzly Flank
+-- Titanium Vanguard
+(28838,0,100,0,-@NEWREF0,1),
+(28838,40202,27,0,1,1),-- Sizzling Grizzly Flank
+-- Dark Rune Scholar
+(27964,0,100,0,-@NEWREF9,1),
+(27964,1,100,0,-@NEWREF1,1),
+-- Dark Rune Worker
+(27961,0,100,0,-@NEWREF0,1),
+(27961,40202,29,0,1,1),-- Sizzling Grizzly Flank
+(27961,36862,4,0,1,1),-- Wrogn Troll Dice
+-- Dark Rune Shaper
+(27965,0,100,0,-@NEWREF0,1),
+(27965,40202,28,0,1,1),-- Sizzling Grizzly Flank
+-- Steel Gate Archaeologist
+(24400,0,100,0,-@NEWREF0,1),
+(24400,1,100,0,-@NEWREF5,1),
+(24400,33449,7,0,1,1),-- Crusty Flatbread
+(24400,38261,9,0,1,1),-- Bent House Key
+-- Blacksouled Keeper
+(23875,0,100,0,-@NEWREF0,1),
+(23875,1,100,0,-@NEWREF3,1),
+(23875,33449,14,0,1,1),-- Crusty Flatbread
+-- Winterskorn Rune-Seer
+(23667,0,100,0,-@NEWREF0,1),
+(23667,33449,7,0,1,1),-- Crusty Flatbread
+(23667,33454,7,0,1,1),-- Salted Venison
+-- Sergeant Lorric
+(23963,43575,45,0,1,1),-- Reinforced Junkbox
+(23963,0,100,0,-@NEWREF5,1),
+(23963,33447,13,0,1,1),-- Runic Healing Potion
+(23963,38261,11,0,1,1),-- Bent House Key
+(23963,33449,7,0,1,1),-- Crusty Flatbread
+-- Gjalerhorn Scavenger
+(27699,0,100,0,-@NEWREF4,1),
+(27699,43575,43,0,1,1),-- Reinforced Junkbox
+(27699,33454,22,0,1,1),-- Salted Venison
+(27699,33447,7,0,1,1),-- Runic Healing Potion
+(27699,29569,0.8,0,1,1),-- Strong Junkbox
+-- Iron Rune Binder
+(23796,0,100,0,-@NEWREF5,1),
+(23796,43575,42,0,1,1),-- Reinforced Junkbox
+(23796,38261,12,0,1,1),-- Bent House Key
+(23796,33449,11,0,1,1),-- Crusty Flatbread
+(23796,33447,9,0,1,1),-- Runic Healing Potion
+(23796,29569,0.5,0,1,1),-- Strong Junkbox
+-- Forsaken Plaguebringer
+(23760,0,100,0,-@NEWREF2,1),
+(23760,43575,41,0,1,1),-- Reinforced Junkbox
+(23760,33447,10,0,1,1),-- Runic Healing Potion
+(23760,38268,0.3,0,1,1),-- Spare Hand
+-- Chillmere Tidehunter
+(24460,43575,40,0,1,1),-- Reinforced Junkbox
+(24460,38274,33,0,1,1),-- Large Snail Shell
+(24460,37452,18,0,1,1),-- Fatty Bluefin
+(24460,38273,15,0,1,1),-- Brain Coral
+(24460,33447,7,0,1,1),-- Runic Healing Potion
+-- Vrykul Soul
+(24262,0,100,0,-@NEWREF2,1),
+(24262,43575,40,0,1,1),-- Reinforced Junkbox
+(24262,33447,3,0,1,1),-- Runic Healing Potion
+-- Iron Rune Sage
+(23674,0,100,0,-@NEWREF5,1),
+(23674,43575,39,0,1,1),-- Reinforced Junkbox
+(23674,38261,13,0,1,1),-- Bent House Key
+(23674,33449,9,0,1,1),-- Crusty Flatbread
+(23674,33447,6,0,1,1),-- Runic Healing Potion
+-- Vengeance Bringer
+(23865,43575,39,0,1,1),-- Reinforced Junkbox
+(23865,0,100,0,-@NEWREF2,1),
+-- Restless Lookout
+(31554,43575,80,0,1,1),-- Reinforced Junkbox
+(31554,35947,40,0,1,1),-- Sparkling Frostcap
+-- Val'kyr Taskmistress
+(31396,43575,56,0,1,1),-- Reinforced Junkbox
+(31396,35947,38,0,1,1),-- Sparkling Frostcap
+(31396,33447,15,0,1,1),-- Runic Healing Potion
+-- Overseer Veraj
+(32263,43575,42,0,1,1),-- Reinforced Junkbox
+(32263,37467,28,0,1,1),-- A Steamy Romance Novel: Forbidden Love
+(32263,38261,15,0,1,1),-- Bent House Key
+(32263,33447,13,0,1,1),-- Runic Healing Potion
+(32263,0,100,0,-@NEWREF8,1),
+-- Steward
+(26729,0,100,0,-@NEWREF0,1),
+(26729,1,100,0,-@NEWREF3,1),
+(26729,33449,31,0,1,1),-- Crusty Flatbread
+(26729,29569,0.5,0,1,1),-- Strong Junkbox
+-- Alliance Berserker
+(26800,43575,62,0,1,1),-- Reinforced Junkbox
+(26800,33449,19,0,1,1),-- Crusty Flatbread
+(26800,38261,16,0,1,1),-- Bent House Key
+(26800,33447,10,0,1,1),-- Runic Healing Potion
+(26800,0,100,0,-@NEWREF5,1),
+-- Alliance Ranger
+(26802,0,100,0,-@NEWREF5,1),
+(26802,43575,60,0,1,1),-- Reinforced Junkbox
+(26802,38261,34,0,1,1),-- Bent House Key
+(26802,33449,24,0,1,1),-- Crusty Flatbread
+(26802,33447,12,0,1,1),-- Runic Healing Potion
+-- Mage Hunter Ascendant
+(26727,0,100,0,-@NEWREF0,1),
+(26727,1,100,0,-@NEWREF3,1),
+(26727,33449,29,0,1,1),-- Crusty Flatbread
+-- Ring-Lord Sorceress
+(27639,43575,87,0,1,1),-- Reinforced Junkbox
+(27639,37467,46,0,1,1),-- A Steamy Romance Novel: Forbidden Love
+(27639,38261,28,0,1,1),-- Bent House Key
+(27639,33447,19,0,1,1),-- Runic Healing Potion
+(27639,0,100,0,-@NEWREF8,1),
+(27639,36863,1.6,0,1,1),-- Decahedral Dwarven Dice
+-- Ring-Lord Conjurer
+(27640,37467,67,0,1,1),-- A Steamy Romance Novel: Forbidden Love
+(27640,43575,64,0,1,1),-- Reinforced Junkbox
+(27640,33447,30,0,1,1),-- Runic Healing Potion
+(27640,38261,26,0,1,1),-- Bent House Key
+(27640,0,100,0,-@NEWREF8,1),
+-- Mildred the Cruel
+(29885,0,100,0,-@NEWREF0,1),
+(29885,40202,13,0,1,1),-- Sizzling Grizzly Flank
+-- Snowblind Devotee
+(29407,43575,42,0,1,1),-- Reinforced Junkbox
+(29407,40202,29,0,1,1),-- Sizzling Grizzly Flank
+(29407,0,100,0,-@NEWREF4,1),
+(29407,33447,12,0,1,1),-- Runic Healing Potion
+-- Snowblind Devotee
+(29554,43575,43,0,1,1),-- Reinforced Junkbox
+(29554,40202,27,0,1,1),-- Sizzling Grizzly Flank
+(29554,0,100,0,-@NEWREF4,1),
+(29554,33447,12,0,1,1),-- Runic Healing Potion
+(29554,38266,0.2,0,1,1),-- Rotund Relic
+-- Frostfeather Witch
+(29793,43575,40,0,1,1),-- Reinforced Junkbox
+(29793,40202,21,0,1,1),-- Sizzling Grizzly Flank
+(29793,0,100,0,-@NEWREF4,1),
+(29793,33447,16,0,1,1),-- Runic Healing Potion
+-- Icemane Yeti
+(29875,43575,39,0,1,1),-- Reinforced Junkbox
+(29875,40202,23,0,1,1),-- Sizzling Grizzly Flank
+(29875,0,100,0,-@NEWREF4,1),
+(29875,33447,15,0,1,1),-- Runic Healing Potion
+(29875,38266,0.3,0,1,1),-- Rotund Relic
+-- Garm Watcher
+(29553,0,100,0,-@NEWREF0,1),
+(29553,1,100,0,-@NEWREF1,1),
+(29553,24231,0.3,0,2,2),-- Coarse Snuff
+-- Stormforged Taskmaster
+(29369,43575,38,0,1,1),-- Reinforced Junkbox
+(29369,37467,34,0,1,1),-- A Steamy Romance Novel: Forbidden Love
+(29369,33447,13,0,1,1),-- Runic Healing Potion
+(29369,38261,6,0,1,1),-- Bent House Key
+(29369,0,100,0,-@NEWREF8,1),
+-- Dragonflayer Bonecrusher
+(24069,0,100,0,-@NEWREF0,1),
+(24069,1,100,0,-@NEWREF1,1),
+(24069,29569,47,0,1,1),-- Strong Junkbox
+(24069,29570,34,0,1,1),-- A Gnome Effigy
+(24069,27855,22,0,1,1),-- Mag'har Grainbread
+(24069,27854,19,0,1,1),-- Smoked Talbuk Venison
+(24069,22829,10,0,1,1),-- Super Healing Potion
+(24069,23438,1.2,0,1,1),-- Star of Elune
+-- Ymirjar Berserker
+(26696,0,100,0,-@NEWREF7,1),
+(26696,29569,1.1,0,1,1),-- Strong Junkbox
+-- Kutube'sa
+(28494,0,100,0,-@NEWREF0,1),
+(28494,1,100,0,-@NEWREF1,1),
+-- Chulo the Mad
+(28496,0,100,0,-@NEWREF0,1),
+(28496,40202,6,0,1,1),-- Sizzling Grizzly Flank
+-- Drakuru's Guard
+(28803,43575,50,0,1,1),-- Reinforced Junkbox
+(28803,33447,33,0,1,1),-- Runic Healing Potion
+(28803,38269,17,0,1,1),-- Soggy Handkerchief
+-- Prophet of Har'koa
+(28848,0,100,0,-@NEWREF0,1),
+(28848,40202,3,0,1,1),-- Sizzling Grizzly Flank
+-- Decaying Ghoul
+(28565,0,100,0,-@NEWREF7,1),
+(28565,22829,0.9,0,1,1),-- Super Healing Potion
+-- Drakuru Berserker
+(29656,0,100,0,-@NEWREF0,1),
+(29656,1,100,0,-@NEWREF3,1),
+(29656,33449,11,0,1,1),-- Crusty Flatbread
+(29656,29569,0.9,0,1,1); -- Strong Junkbox
diff --git a/sql/updates/world/2012_04_18_05_world_conditions.sql b/sql/updates/world/2012_04_18_05_world_conditions.sql
new file mode 100644
index 00000000000..ecf80f270a3
--- /dev/null
+++ b/sql/updates/world/2012_04_18_05_world_conditions.sql
@@ -0,0 +1,4 @@
+-- Add condition to the Lovely Charm aura
+DELETE FROM conditions WHERE `SourceTypeOrReferenceId`=17 AND `SourceEntry`= 69511;
+INSERT INTO conditions (SourceTypeOrReferenceId, SourceGroup, SourceEntry, ElseGroup, ConditionTypeOrReference, ConditionValue1, ConditionValue2, ConditionValue3, ErrorTextId, ScriptName, COMMENT) VALUES
+(17,0,69511,0,12,8,0,0,0, '', 'Lovely Charm - Only during event');
diff --git a/sql/updates/world/2012_04_18_06_world_creature_template.sql b/sql/updates/world/2012_04_18_06_world_creature_template.sql
new file mode 100644
index 00000000000..8c167c2ffa1
--- /dev/null
+++ b/sql/updates/world/2012_04_18_06_world_creature_template.sql
@@ -0,0 +1,2 @@
+-- Remove Skinning loot from Blackwing Spellbinder
+UPDATE `creature_template` SET `skinloot`=0 WHERE `entry`=12457;
diff --git a/sql/updates/world/2012_04_18_07_world_fishing_loot_template.sql b/sql/updates/world/2012_04_18_07_world_fishing_loot_template.sql
new file mode 100644
index 00000000000..6c39cc95b48
--- /dev/null
+++ b/sql/updates/world/2012_04_18_07_world_fishing_loot_template.sql
@@ -0,0 +1,2 @@
+-- update wrong area.
+UPDATE `fishing_loot_template` SET `entry`=4560 WHERE `entry`=4395 AND `item`=11026;
diff --git a/sql/updates/world/2012_04_18_08_world_creature_loot_template.sql b/sql/updates/world/2012_04_18_08_world_creature_loot_template.sql
new file mode 100644
index 00000000000..4b00685ed55
--- /dev/null
+++ b/sql/updates/world/2012_04_18_08_world_creature_loot_template.sql
@@ -0,0 +1,22 @@
+-- Add loot for Hrothgar's Landing
+DELETE FROM `creature_loot_template` WHERE `entry` IN (34980,34838,34839,34965);
+INSERT INTO `creature_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+-- AURIAYA 10-man
+-- Drottinn Hrothgar - http://old.wowhead.com/npc=34980
+(34980,46859,-100,1,0,1,1), -- Stolen Tallstrider Leg
+-- Kvaldir Reaver
+(34838,46859,-100,1,0,1,1), -- Stolen Tallstrider Leg
+(34838,49676,5,1,0,1,1), -- Kvaldir Attack Plans
+(34838,33470,35,1,0,1,4), -- 1-4x Frostweave Cloth
+(34838,1,10,1,0,-24727,1), -- 1 of Northrend scrolls
+(34838,2,10,1,0,-26002,1), -- Northrend Grey Item Reference1
+(34838,3,2,1,0,-35080,1), -- Northrend Green Item Reference
+-- Kvaldir Mist Binder
+(34839,46859,-100,1,0,1,1), -- Stolen Tallstrider Leg
+(34839,49676,5,1,0,1,1), -- Kvaldir Attack Plans
+(34839,33470,35,1,0,1,4), -- 1-4x Frostweave Cloth
+(34839,1,10,1,0,-24727,1), -- 1 of Northrend scrolls
+(34839,2,10,1,0,-26002,1), -- Northrend Grey Item Reference1
+(34839,3, 2,1,0,-35080,1), -- Northrend Green Item Reference
+-- Mistcaller Yngvar
+(34965,46859,-100,1,0,1,1); -- Stolen Tallstrider Leg
diff --git a/sql/updates/world/2012_04_19_00_world_creature_template.sql b/sql/updates/world/2012_04_19_00_world_creature_template.sql
new file mode 100644
index 00000000000..e9abd40095e
--- /dev/null
+++ b/sql/updates/world/2012_04_19_00_world_creature_template.sql
@@ -0,0 +1,7 @@
+-- update Plague Slime & Marauding Geist to naxx25 trash lootid
+UPDATE `creature_template` SET `lootid`=100005 WHERE `entry` IN(29575,30424);
+-- update Plague Slime & Marauding Geist to naxx10 trash lootid
+UPDATE `creature_template` SET `lootid`=100003 WHERE `entry` IN(16243,30083);
+DELETE FROM `creature_loot_template` WHERE `entry` IN(30424,29575,16243,30083);
+-- Remove scraps for naxx10 from creature creature_loot_template
+DELETE FROM `creature_loot_template` WHERE `item` IN (22373,22374,22375,22376);
diff --git a/sql/updates/world/2012_04_19_01_world_pickpocketing_loot_template.sql b/sql/updates/world/2012_04_19_01_world_pickpocketing_loot_template.sql
new file mode 100644
index 00000000000..997b16ff65d
--- /dev/null
+++ b/sql/updates/world/2012_04_19_01_world_pickpocketing_loot_template.sql
@@ -0,0 +1,202 @@
+-- Fix to add pickpocketing loot for humoniods in borean tundra
+SET @GORLOCREF := 25100;
+SET @BERYLREF := @GORLOCREF+1;
+SET @BLOODREF := @GORLOCREF+2;
+SET @CHIEFREF := @GORLOCREF+3;
+SET @CULTREF := @GORLOCREF+4;
+SET @KVALDIRREF := @GORLOCREF+5;
+SET @CLAXREF := @GORLOCREF+6;
+SET @MAGMOTHREF := @GORLOCREF+7;
+-- Create reference templates
+DELETE FROM `reference_loot_template` WHERE `entry` BETWEEN @GORLOCREF AND @GORLOCREF+7;
+INSERT INTO `reference_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+(@GORLOCREF,29576,57,1,0,1,1), -- Shark Bait
+(@GORLOCREF,29569,30,1,0,1,1), -- Strong Junkbox
+(@GORLOCREF,27858,8,1,0,1,1), -- Sunspring Carp
+(@GORLOCREF,22829,3,1,0,1,1), -- Super Healing Potion
+(@GORLOCREF,23436,0.5,1,0,1,1), -- Living Ruby
+(@GORLOCREF,23437,0.5,1,0,1,1), -- Talasite
+(@GORLOCREF,23440,0.5,1,0,1,1), -- Dawnstone
+(@GORLOCREF,23438,0.5,1,0,1,1), -- Star of Elune
+(@GORLOCREF,23439,0.5,1,0,1,1), -- Noble Topaz
+-- --------------------------------------------------
+(@BERYLREF,37467,32.5,1,0,1,1), -- A Steamy Romance Novel: Forbidden Love
+(@BERYLREF,43575,31,1,0,1,1), -- Reinforced Junkbox
+(@BERYLREF,38261,10,1,0,1,1), -- Bent House Key
+(@BERYLREF,29448,7,1,0,1,1), -- Mag'har Mild Cheese
+(@BERYLREF,29450,7,1,0,1,1), -- Telaari Grapes
+(@BERYLREF,33447,6,1,0,1,1), -- Runic Healing Potion
+(@BERYLREF,33449,6,1,0,1,1), -- Crusty Flatbread
+(@BERYLREF,36863,0.5,1,0,1,1), -- Decahedral Dwarven Dice
+-- --------------------------------------------------
+(@BLOODREF,29572,37,1,0,1,1), -- Aboriginal Carvings
+(@BLOODREF,29569,33,1,0,1,1), -- Strong Junkbox
+(@BLOODREF,8952,20,1,0,1,1), -- Roasted Quail
+(@BLOODREF,22829,8,1,0,1,1), -- Super Healing Potion
+(@BLOODREF,23438,0.5,1,0,1,1), -- Star of Elune
+(@BLOODREF,23436,0.5,1,0,1,1), -- Living Ruby
+(@BLOODREF,23441,0.5,1,0,1,1), -- Nightseye
+(@BLOODREF,23437,0.5,1,0,1,1), -- Talasite
+(@BLOODREF,23440,0.5,1,0,1,1), -- Dawnstone
+-- --------------------------------------------------
+(@CHIEFREF,29569,50,1,0,1,1), -- Strong Junkbox
+(@CHIEFREF,27858,20,1,0,1,1), -- Sunspring Carp
+(@CHIEFREF,29576,20,1,0,1,1), -- Shark Bait
+(@CHIEFREF,22829,10,1,0,1,1), -- Super Healing Potion
+-- --------------------------------------------------
+(@CULTREF,29569,40,1,0,1,1), -- Strong Junkbox
+(@CULTREF,29571,37,1,0,1,1), -- A Steamy Romance Novel
+(@CULTREF,30458,8,1,0,1,1), -- Stromgarde Muenster
+(@CULTREF,27855,7,1,0,1,1), -- Mag'har Grainbread
+(@CULTREF,27856,6,1,0,1,1), -- Skethyl Berries
+(@CULTREF,22829,2,1,0,1,1), -- Super Healing Potion
+(@CULTREF,36863,0.5,1,0,1,1), -- Decahedral Dwarven Dice
+-- --------------------------------------------------
+(@KVALDIRREF,29569,39,1,0,1,1), -- Strong Junkbox
+(@KVALDIRREF,29570,28,1,0,1,1), -- A Gnome Effigy
+(@KVALDIRREF,27855,12,1,0,1,1), -- Mag'har Grainbread
+(@KVALDIRREF,27854,12,1,0,1,1), -- Smoked Talbuk Venison
+(@KVALDIRREF,22829,7,1,0,1,1), -- Super Healing Potion
+(@KVALDIRREF,23436,0.5,1,0,1,1), -- Living Ruby
+(@KVALDIRREF,23441,0.5,1,0,1,1), -- Nightseye
+(@KVALDIRREF,23440,0.5,1,0,1,1), -- Dawnstone
+(@KVALDIRREF,23439,0.5,1,0,1,1), -- Noble Topaz
+(@KVALDIRREF,23437,0.5,1,0,1,1), -- Talasite
+-- --------------------------------------------------
+(@CLAXREF,43575,28,1,0,1,1), -- Reinforced Junkbox
+(@CLAXREF,38273,26,1,0,1,1), -- Brain Coral
+(@CLAXREF,38274,23,1,0,1,1), -- Large Snail Shell
+(@CLAXREF,37452,17,1,0,1,1), -- Fatty Bluefin
+(@CLAXREF,33447,6,1,0,1,1), -- Runic Healing Potion
+-- --------------------------------------------------
+(@MAGMOTHREF,38260,33,1,0,1,1), -- Empty Tobacco Pouch
+(@MAGMOTHREF,38261,21,1,0,1,1), -- Bent House Key
+(@MAGMOTHREF,33449,16,1,0,1,1), -- Crusty Flatbread
+(@MAGMOTHREF,43575,16,1,0,1,1), -- Reinforced Junkbox
+(@MAGMOTHREF,33454,9,1,0,1,1), -- Salted Venison
+(@MAGMOTHREF,33447,5,1,0,1,1), -- Runic Healing Potion
+(@MAGMOTHREF,36862,1,1,0,1,1); -- Worn Troll Dice
+-- -------------------
+-- -- NPC Variables --
+-- -------------------
+SET @NPC := 25686;
+SET @NPC1 := 25700;
+SET @NPC2 := 25687;
+SET @NPC3 := 25685;
+SET @NPC4 := 25449;
+SET @NPC5 := 25316;
+SET @NPC6 := 25353;
+SET @NPC7 := 25719;
+SET @NPC8 := 25804;
+SET @NPC9 := 25392;
+SET @NPC10 := 25651;
+SET @NPC11 := 25836;
+SET @NPC12 := 25979;
+SET @NPC13 := 25806;
+SET @NPC14 := 25720;
+SET @NPC15 := 25803;
+SET @NPC16 := 25880;
+SET @NPC17 := 25618;
+SET @NPC18 := 25839;
+SET @NPC19 := 25470;
+SET @NPC20 := 24567;
+SET @NPC21 := 25467;
+SET @NPC22 := 25468;
+SET @NPC23 := 25501;
+SET @NPC24 := 25726;
+SET @NPC25 := 25701;
+SET @NPC26 := 25725;
+SET @NPC27 := 25699;
+SET @NPC28 := 24576;
+SET @NPC29 := 25605;
+SET @NPC30 := 25609;
+SET @NPC31 := 25378;
+SET @NPC32 := 25843;
+SET @NPC33 := 25496;
+SET @NPC34 := 25479;
+SET @NPC35 := 25760;
+SET @NPC36 := 26266;
+SET @NPC37 := 26451;
+SET @NPC38 := 25521;
+SET @NPC39 := 25613;
+SET @NPC40 := 25522;
+SET @NPC41 := 25520;
+SET @NPC42 := 25209;
+SET @NPC43 := 25210;
+SET @NPC44 := 25216;
+SET @NPC45 := 25215;
+SET @NPC46 := 25217;
+SET @NPC47 := 25789;
+SET @NPC48 := 24469;
+SET @NPC49 := 25432;
+SET @NPC50 := 25433;
+SET @NPC51 := 25615;
+SET @NPC52 := 25523;
+-- ----------------------
+-- -- Assign the loots --
+-- ----------------------
+UPDATE `creature_template` SET `pickpocketloot`=`entry` WHERE `entry` IN (@NPC,@NPC1,@NPC2,@NPC3,@NPC4,@NPC5,@NPC6,@NPC7,@NPC8,@NPC9,@NPC10,@NPC11,@NPC12,@NPC13,@NPC14,@NPC15,@NPC16,@NPC17,@NPC18,@NPC19,@NPC20,@NPC21,@NPC22,@NPC23,@NPC24,@NPC25,@NPC26,@NPC27,@NPC28,@NPC29,@NPC30,@NPC31,@NPC32,@NPC33,@NPC34,@NPC35,@NPC36,@NPC37,@NPC38,@NPC39,@NPC40,@NPC41,@NPC42,@NPC43,@NPC44,@NPC45,@NPC46,@NPC47,@NPC48,@NPC49,@NPC50,@NPC51,@NPC52);
+DELETE FROM `pickpocketing_loot_template` WHERE `entry` IN (@NPC,@NPC1,@NPC2,@NPC3,@NPC4,@NPC5,@NPC6,@NPC7,@NPC8,@NPC9,@NPC10,@NPC11,@NPC12,@NPC13,@NPC14,@NPC15,@NPC16,@NPC17,@NPC18,@NPC19,@NPC20,@NPC21,@NPC22,@NPC23,@NPC24,@NPC25,@NPC26,@NPC27,@NPC28,@NPC29,@NPC30,@NPC31,@NPC32,@NPC33,@NPC34,@NPC35,@NPC36,@NPC37,@NPC38,@NPC39,@NPC40,@NPC41,@NPC42,@NPC43,@NPC44,@NPC45,@NPC46,@NPC47,@NPC48,@NPC49,@NPC50,@NPC51,@NPC52);
+INSERT INTO `pickpocketing_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+-- -----------------------------------------------------------------------------------------------
+(@NPC,1,100,1,0,-@GORLOCREF,1), -- Gorloc ref loot template on Gorloc Gibberer
+(@NPC1,1,100,1,0,-@GORLOCREF,1), -- Gorloc ref loot template on Gorloc Hunter
+(@NPC2,1,100,1,0,-@GORLOCREF,1), -- Gorloc ref loot template on Gorloc Steam Belcher
+(@NPC3,1,100,1,0,-@GORLOCREF,1), -- Gorloc ref loot template on Gorloc Waddler
+-- -----------------------------------------------------------------------------------------------
+(@NPC4,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Beryl Reclaimer
+(@NPC5,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Beryl Sorcerer
+(@NPC6,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Beryl Treasure Hunter
+(@NPC7,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Coldarra Spellbinder
+(@NPC8,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Harold Lane <The Fur Baron>
+(@NPC9,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on High Priest Andorath
+(@NPC10,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Cultist Necrolyte
+(@NPC11,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Loot Crazed Diver
+(@NPC12,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Loot Crazed Hunter
+(@NPC13,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Loot Crazed Poacher
+(@NPC14,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Inquisitor Caleras
+(@NPC15,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Karen "I Don't Caribou" the Culler
+(@NPC16,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Minion of Kaw
+(@NPC17,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Varidus the Flenser
+(@NPC18,1,100,1,0,-@BERYLREF,1), -- Beryl ref loot template on Northsea Mercenary
+-- -----------------------------------------------------------------------------------------------
+(@NPC19,1,100,1,0,-@BLOODREF,1), -- Bloodspore ref loot template on Bloodspore Firestarter
+(@NPC20,1,100,1,0,-@BLOODREF,1), -- Bloodspore ref loot template on Den Vermin
+(@NPC21,1,100,1,0,-@BLOODREF,1), -- Bloodspore ref loot template on Bloodspore Harvester
+(@NPC22,1,100,1,0,-@BLOODREF,1), -- Bloodspore ref loot template on Bloodspore Roaster
+(@NPC23,1,100,1,0,-@BLOODREF,1), -- Bloodspore ref loot template on Gammoth Tender
+-- -----------------------------------------------------------------------------------------------
+(@NPC24,1,100,1,0,-@CHIEFREF,1), -- Chieftian ref loot template on Chieftain Burblegobble
+(@NPC25,1,100,1,0,-@CHIEFREF,1), -- Chieftian ref loot template on Gorloc Dredger
+(@NPC26,1,100,1,0,-@CHIEFREF,1), -- Chieftian ref loot template on Chieftain GurgleBoggle
+(@NPC27,1,100,1,0,-@CHIEFREF,1), -- Chieftian ref loot template on Gorloc Mud Splasher
+(@NPC28,1,100,1,0,-@CHIEFREF,1), -- Chieftian ref loot template on Riplash Myrmidon
+-- -----------------------------------------------------------------------------------------------
+(@NPC29,1,100,1,0,-@CULTREF,1), -- Cultist ref loot template on Clandestine Cultist <Cult of the Damned>
+(@NPC30,1,100,1,0,-@CULTREF,1), -- Cultist ref loot template on En'kilah Necrolord <Cult of the Damned>
+(@NPC31,1,100,1,0,-@CULTREF,1), -- Cultist ref loot template on En'kilah Necromancer <Cult of the Damned>
+(@NPC32,1,100,1,0,-@CULTREF,1), -- Cultist ref loot template on Northsea Thug
+-- -----------------------------------------------------------------------------------------------
+(@NPC33,1,100,1,0,-@KVALDIRREF,1), -- Kvaldir ref loot template on Kvaldir Mist Lord
+(@NPC34,1,100,1,0,-@KVALDIRREF,1), -- Kvaldir ref loot template on Kvaldir Mistweaver
+(@NPC35,1,100,1,0,-@KVALDIRREF,1), -- Kvaldir ref loot template on Kvaldir Raider
+(@NPC36,1,100,1,0,-@KVALDIRREF,1), -- Kvaldir ref loot template on Heigarr the Horrible
+(@NPC37,1,100,1,0,-@KVALDIRREF,1), -- Kvaldir ref loot template on Ragnar Drakkarlund
+(@NPC37,35774,-100,1,0,1,1), -- Trident of Naz'jan on Ragnar Drakkarlund
+(@NPC38,1,100,1,0,-@KVALDIRREF,1), -- Kvaldir ref loot template on Skadir Longboatsman
+(@NPC39,1,100,1,0,-@KVALDIRREF,1), -- Kvaldir ref loot template on Skadir Mistweaver
+(@NPC40,1,100,1,0,-@KVALDIRREF,1), -- Kvaldir ref loot template on Skadir Raider
+(@NPC41,1,100,1,0,-@KVALDIRREF,1), -- Kvaldir ref loot template on Skadir Runecaster
+-- -----------------------------------------------------------------------------------------------
+(@NPC42,1,100,1,0,-@CLAXREF,1), -- Clax ref loot template on Claximus
+(@NPC43,1,100,1,0,-@CLAXREF,1), -- Clax ref loot template on Keymaster Urmgrgl
+(@NPC44,1,100,1,0,-@CLAXREF,1), -- Clax ref loot template on Winterfin Oracle
+(@NPC45,1,100,1,0,-@CLAXREF,1), -- Clax ref loot template on Winterfin Shorestriker
+(@NPC46,1,100,1,0,-@CLAXREF,1), -- Clax ref loot template on Winterfin Warrior
+-- -----------------------------------------------------------------------------------------------
+(@NPC47,1,100,1,0,-@MAGMOTHREF,1), -- Magmoth2 ref loot template on Gammothra the Tormentor
+(@NPC48,1,100,1,0,-@MAGMOTHREF,1), -- Magmoth ref loot template on Magnataur Huntress <Mate of Gammothra>
+(@NPC49,1,100,1,0,-@MAGMOTHREF,1), -- Magmoth ref loot template on Mate of Magmothregar
+(@NPC50,1,100,1,0,-@MAGMOTHREF,1), -- Magmoth ref loot template on Offspring of Magmothregar
+(@NPC51,1,100,1,0,-@MAGMOTHREF,1), -- Magmoth ref loot template on Plagued Magnataur
+(@NPC52,1,100,1,0,-@MAGMOTHREF,1); -- Magmoth ref loot template on Skadir Mariner
diff --git a/sql/updates/world/2012_04_19_02_world_creature_loot_template.sql b/sql/updates/world/2012_04_19_02_world_creature_loot_template.sql
new file mode 100644
index 00000000000..336cd61c0eb
--- /dev/null
+++ b/sql/updates/world/2012_04_19_02_world_creature_loot_template.sql
@@ -0,0 +1,2 @@
+-- fix DB-error on startup
+DELETE FROM `creature_loot_template` WHERE `entry` IN (34965,34980);
diff --git a/sql/updates/world/2012_04_19_03_world_instance_ulduar.sql b/sql/updates/world/2012_04_19_03_world_instance_ulduar.sql
new file mode 100644
index 00000000000..a39ed9c01d5
--- /dev/null
+++ b/sql/updates/world/2012_04_19_03_world_instance_ulduar.sql
@@ -0,0 +1,174 @@
+DELETE FROM `script_texts` WHERE `entry` BETWEEN -1603019 AND -1603000;
+UPDATE `creature_template` SET `ScriptName`='' WHERE `ScriptName` IN ('boss_algalon','mob_collapsing_star');
+
+-- Difficulty linking
+UPDATE `creature_template` SET `difficulty_entry_1`=34296 WHERE `entry`=32953; -- Black Hole
+
+UPDATE `creature_template` SET `minlevel`=80,`maxlevel`=80,`faction_A`=35,`faction_H`=35,`unit_flags`=0x8300,`equipment_id`=2478 WHERE `entry`=34064; -- Brann Bronzebeard
+UPDATE `creature_template` SET `speed_walk`=4,`speed_run`=2.14286,`exp`=2,`minlevel`=83,`maxlevel`=83,`faction_A`=190,`faction_H`=190,`unit_flags`=0x8100,`BaseAttackTime`=1000,`equipment_id`=2479 WHERE `entry` IN (32871,33070); -- Algalon the Observer
+UPDATE `creature_template` SET `faction_A`=190,`faction_H`=190,`exp`=2,`minlevel`=83,`maxlevel`=83,`unit_flags`=0x2000000,`speed_run`=1,`InhabitType`=4 WHERE `entry`=34246; -- Azeroth
+UPDATE `creature_template` SET `faction_A`=14,`faction_H`=14,`exp`=2,`minlevel`=74,`maxlevel`=74,`unit_flags`=0x2000000,`flags_extra`=0x80,`InhabitType`=4 WHERE `entry`=33086; -- Algalon Stalker
+UPDATE `creature_template` SET `faction_A`=14,`faction_H`=14,`unit_flags`=0x2008000,`speed_run`=1,`equipment_id`=2480,`InhabitType`=4 WHERE `entry` IN (33052,33116); -- Living Constellation
+UPDATE `creature_template` SET `faction_A`=14,`faction_H`=14,`speed_run`=1,`RegenHealth`=0 WHERE `entry` IN (32955,34215); -- Collapsing Star
+UPDATE `creature_template` SET `faction_A`=14,`faction_H`=14,`exp`=2,`minlevel`=80,`maxlevel`=80,`unit_flags`=0x2000000,`speed_run`=1,`InhabitType`=4 WHERE `entry` IN (32953,34296); -- Black Hole
+UPDATE `creature_template` SET `faction_A`=14,`faction_H`=14,`minlevel`=81,`maxlevel`=81,`unit_flags`=0x8000,`speed_walk`=4,`speed_run`=1.42857,`InhabitType`=4 WHERE `entry` IN(33089,34097,34221,34222); -- Dark Matter
+UPDATE `creature_template` SET `faction_A`=14,`faction_H`=14,`unit_flags`=0x2000000,`flags_extra`=0x80 WHERE `entry`=34100; -- Algalon Void Zone Visual Stalker
+UPDATE `creature_template` SET `faction_A`=14,`faction_H`=14,`unit_flags`=0x2000000,`speed_run`=1,`InhabitType`=4 WHERE `entry`=34099; -- Worm Hole
+UPDATE `creature_template` SET `faction_A`=14,`faction_H`=14,`exp`=2,`minlevel`=74,`maxlevel`=74,`unit_flags`=0x2000000,`flags_extra`=0x80,`InhabitType`=4 WHERE `entry`=33104; -- Algalon Stalker Asteroid Target 01
+UPDATE `creature_template` SET `faction_A`=14,`faction_H`=14,`exp`=2,`minlevel`=74,`maxlevel`=74,`unit_flags`=0x2000000,`flags_extra`=0x80,`InhabitType`=4 WHERE `entry`=33105; -- Algalon Stalker Asteroid Target 02
+
+UPDATE `creature_model_info` SET `bounding_radius`=0.93,`combat_reach`=9,`gender`=0 WHERE `modelid`=28641; -- Algalon the Observer
+UPDATE `creature_model_info` SET `bounding_radius`=0.02,`combat_reach`=0.2,`gender`=2 WHERE `modelid`=29133; -- Azeroth
+UPDATE `creature_model_info` SET `bounding_radius`=0.62,`combat_reach`=0,`gender`=2 WHERE `modelid`=28741; -- Living Constellation
+UPDATE `creature_model_info` SET `bounding_radius`=1,`combat_reach`=1,`gender`=2 WHERE `modelid`=28988; -- Collapsing Star
+UPDATE `creature_model_info` SET `bounding_radius`=1,`combat_reach`=1,`gender`=2 WHERE `modelid`=28460; -- Black Hole
+
+UPDATE `gameobject_template` SET `faction`=114,`flags`=32 WHERE `entry`=194910; -- Doodad_UL_SigilDoor_03
+UPDATE `gameobject_template` SET `data0`=579 WHERE `entry`=194628; -- Celestial Planetarium Access
+
+UPDATE `creature_template` SET `ScriptName`='boss_algalon_the_observer' WHERE `entry`=32871; -- Algalon the Observer
+UPDATE `creature_template` SET `ScriptName`='npc_living_constellation' WHERE `entry`=33052; -- Living Constellation
+UPDATE `creature_template` SET `ScriptName`='npc_collapsing_star' WHERE `entry`=32955; -- Collapsing Star
+UPDATE `creature_template` SET `ScriptName`='npc_brann_bronzebeard_algalon' WHERE `entry`=34064; -- Brann Bronzebeard
+UPDATE `gameobject_template` SET `ScriptName`='go_celestial_planetarium_access' WHERE `entry` IN (194628,194752); -- Celestial Planetarium Access
+UPDATE `creature_template` SET `AIName`='NullCreatureAI' WHERE `entry` IN (32953,34099); -- Black Hole
+
+DELETE FROM `creature` WHERE `guid` IN (41781,41783,41790,41811,41812,41814,41819,41820,41821,41822,41823,41875);
+INSERT INTO `creature` (`guid`,`id`,`map`,`spawnMask`,`phaseMask`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`,`spawndist`,`MovementType`) VALUES
+(41781,33086,603,3,1,1627.400,-339.4133,417.4044,1.378810,7200,0,0), -- Algalon Stalker
+(41783,33086,603,3,1,1622.681,-344.2576,417.3955,1.378810,7200,0,0), -- Algalon Stalker
+(41790,33086,603,3,1,1629.984,-271.4798,417.4045,4.782202,7200,0,0), -- Algalon Stalker
+(41811,33086,603,3,1,1630.005,-345.5189,417.3955,1.378810,7200,0,0), -- Algalon Stalker
+(41812,33089,603,3,16,1622.451,-321.1563,417.6188,4.677482,7200,20,1), -- Dark Matter
+(41814,33089,603,3,16,1649.438,-319.8127,418.3941,1.082104,7200,20,1), -- Dark Matter
+(41819,33089,603,3,16,1615.060,-291.6816,417.7796,3.490659,7200,20,1), -- Dark Matter
+(41820,33089,603,3,16,1647.005,-288.6790,417.3955,3.490659,7200,20,1), -- Dark Matter
+(41821,33089,603,3,16,1622.451,-321.1563,417.6188,4.677482,7200,20,1), -- Dark Matter
+(41822,33089,603,3,16,1649.438,-319.8127,418.3941,1.082104,7200,20,1), -- Dark Matter
+(41823,33089,603,3,16,1615.060,-291.6816,417.7796,3.490659,7200,20,1), -- Dark Matter
+(41875,33089,603,3,16,1647.005,-288.6790,417.3955,3.490659,7200,20,1); -- Dark Matter
+
+SET @OGUID := 252;
+DELETE FROM `gameobject` WHERE `id` IN (194767,194910,194911,194715,194716,194148,194253,194628,194752,194821,194822);
+INSERT INTO `gameobject` (`guid`,`id`,`map`,`spawnMask`,`phaseMask`,`position_x`,`position_y`,`position_z`,`orientation`,`rotation0`,`rotation1`,`rotation2`,`rotation3`,`spawntimesecs`,`animprogress`,`state`) VALUES
+(@OGUID+00,194767,603,3,17,1632.024,-182.9211,427.6681,0.000000,0,0,8.742278E-08,1, 604800,255,1), -- Doodad_UL_SigilDoor_01
+(@OGUID+04,194911,603,3,17,1632.024,-182.9211,408.4224,3.141593,0,0,8.742278E-08,1, 604800,255,1), -- Doodad_UL_SigilDoor_02
+(@OGUID+10,194910,603,3,17,1632.053,-266.1495,438.5608,0.000000,0,0,8.742278E-08,1, 604800,255,0), -- Doodad_UL_SigilDoor_03
+(@OGUID+12,194715,603,3,17,1632.053,-307.6541,417.3211,0.000000,0,0,8.742278E-08,1, 604800,255,0), -- Doodad_UL_UniverseFloor_01
+(@OGUID+19,194716,603,3,17,1632.251,-307.5483,416.2641,0.000000,0,0,8.742278E-08,1, 604800,255,1), -- Doodad_UL_UniverseFloor_02
+(@OGUID+22,194148,603,3,17,1632.053,-307.6541,417.3211,0.000000,0,0,8.742278E-08,1, 604800,255,1), -- Doodad_UL_UniverseGlobe01
+(@OGUID+24,194253,603,3,17,1631.908,-246.4970,417.3211,0.000000,0,0,8.742278E-08,1, 604800,255,1), -- Doodad_UL_Ulduar_Trapdoor_03
+(@OGUID+29,194628,603,1, 1,1646.182,-174.6881,427.2536,1.553341,0,0,0.000000E-00,1, 604800,255,1), -- Celestial Planetarium Access
+(@OGUID+33,194752,603,2, 1,1646.182,-174.6881,427.2536,1.553341,0,0,0.000000E-00,1, 604800,255,1), -- Celestial Planetarium Access
+(@OGUID+37,194821,603,1, 1,1632.099,-306.5609,417.3210,4.694937,0,0,0.000000E-00,1,-604800,255,1), -- Gift of the Observer (10 man)
+(@OGUID+46,194822,603,2, 1,1632.099,-306.5609,417.3210,4.694937,0,0,0.000000E-00,1,-604800,255,1); -- Gift of the Observer (25 man)
+
+DELETE FROM `creature_equip_template` WHERE `entry` IN (2478,2479,2480);
+INSERT INTO `creature_equip_template` (`entry`,`itemEntry1`,`itemEntry2`,`itemEntry3`) VALUES
+(2478,1903,25972,0),
+(2479,45985,45985,0),
+(2480,44952,0,0);
+
+DELETE FROM `creature_template_addon` WHERE `entry` IN (32871,33070,33052,33116,33089,34221,34097,34222,33105);
+INSERT INTO `creature_template_addon` (`entry`,`mount`,`bytes1`,`bytes2`,`auras`) VALUES
+(32871,0,0x0000000,0x0,NULL), -- Algalon the Observer
+(33070,0,0x0000000,0x0,NULL), -- Algalon the Observer
+(33052,0,0x3000000,0x1,NULL), -- Living Constellation
+(33116,0,0x3000000,0x1,NULL), -- Living Constellation
+(33089,0,0x3000000,0x1,NULL), -- Dark Matter
+(34221,0,0x3000000,0x1,NULL), -- Dark Matter
+(34097,0,0x3000000,0x1,NULL), -- Unleashed Dark Matter
+(34222,0,0x3000000,0x1,NULL), -- Unleashed Dark Matter
+(33105,0,0x3000000,0x1,NULL); -- Algalon Stalker Asteroid Target 02
+
+DELETE FROM `creature_text` WHERE `entry` IN (32871,34064);
+INSERT INTO `creature_text` (`entry`,`groupid`,`id`,`text`,`type`,`sound`,`emote`,`comment`) VALUES
+(34064,0,0,'We did it, lads! We got here before Algalon''s arrival. Maybe we can rig the systems to interfere with his analysis--',14,15824,0,'Brann Bronzebeard - SAY_BRANN_ALGALON_INTRO_1'),
+(34064,1,0,'I''ll head back to the Archivum and see if I can jam his signal. I might be able to buy us some time while you take care of him.',12,15825,0,'Brann Bronzebeard - SAY_BRANN_ALGALON_INTRO_2'),
+(34064,2,0,'I know just the place. Will you be all right?',14,15823,6,'Brann Bronzebeard - SAY_BRANN_ALGALON_OUTRO'),
+(32871,0,0,'Translocation complete. Commencing planetary analysis of Azeroth.',12,15405,0,'Algalon the Observer - SAY_ALGALON_INTRO_1'),
+(32871,1,0,'Stand back, mortals. I''m not here to fight you.',12,15406,0,'Algalon the Observer - SAY_ALGALON_INTRO_2'),
+(32871,2,0,'It is in the universe''s best interest to re-originate this planet should my analysis find systemic corruption. Do not interfere.',12,15407,0,'Algalon the Observer - SAY_ALGALON_INTRO_3'),
+(32871,3,0,'Your actions are illogical. All possible results for this encounter have been calculated. The Pantheon will receive the Observer''s message regardless of outcome.',14,15386,0,'Algalon the Observer - SAY_ALGALON_START_TIMER'),
+(32871,4,0,'See your world through my eyes: A universe so vast as to be immeasurable - incomprehensible even to your greatest minds.',14,15390,1,'Algalon the Observer - SAY_ALGALON_AGGRO'),
+(32871,5,0,'The stars come to my aid!',14,15392,0,'Algalon the Observer - SAY_ALGALON_COLLAPSING_STAR'),
+(32871,6,0,'%s begins to Summon Collapsing Stars!',41,0,0,'Algalon the Observer - EMOTE_ALGALON_COLLAPSING_STAR'),
+(32871,7,0,'Witness the fury of the cosmos!',14,15396,0,'Algalon the Observer - SAY_ALGALONG_BIG_BANG'),
+(32871,8,0,'%s begins to cast Big Bang!',41,0,0,'Algalon the Observer - EMOTE_ALGALON_BIG_BANG'),
+(32871,9,0,'You are out of time.',14,15394,0,'Algalon the Observer - SAY_ALGALON_ASCEND'),
+(32871,10,0,'%s begins to cast Cosmic Smash!',41,0,0,'Algalon the Observer - EMOTE_ALGALON_COSMIC_SMASH'),
+(32871,11,0,'Behold the tools of creation!',14,15397,0,'Algalon the Observer - SAY_ALGALON_PHASE_TWO'),
+(32871,12,0,'I have seen worlds bathed in the Makers'' flames, their denizens fading without as much as a whimper. Entire planetary systems born and razed in the time that it takes your mortal hearts to beat once. Yet all throughout, my own heart devoid of emotion... of empathy. I. Have. Felt. Nothing. A million-million lives wasted. Had they all held within them your tenacity? Had they all loved life as you do?',14,15393,1,'Algalon the Observer - SAY_ALGALON_OUTRO_1'),
+(32871,13,0,'Perhaps it is your imperfections... that which grants you free will... that allows you to persevere against all cosmically calculated odds. You prevail where the Titan''s own perfect creations have failed.',14,15401,1,'Algalon the Observer - SAY_ALGALON_OUTRO_2'),
+(32871,14,0,'I''ve rearranged the reply code - your planet will be spared. I cannot be certain of my own calculations anymore.',14,15402,1,'Algalon the Observer - SAY_ALGALON_OUTRO_3'),
+(32871,15,0,'I lack the strength to transmit the signal. You must... hurry... find a place of power... close to the skies.',14,15403,1,'Algalon the Observer - SAY_ALGALON_OUTRO_4'),
+(32871,16,0,'Do not worry about my fate, Bronzen. If the signal is not transmitted in time, re-origination will proceed regardless. Save... your world...',14,15404,1,'Algalon the Observer - SAY_ALGALON_OUTRO_5'),
+(32871,17,0,'Analysis complete. There is partial corruption in the planet''s life-support systems as well as complete corruption in most of the planet''s defense mechanisms.',12,15398,0,'Algalon the Observer - SAY_ALGALON_DESPAWN_1'),
+(32871,18,0,'Begin uplink: Reply Code: ''Omega''. Planetary re-origination requested.',12,15399,0,'Algalon the Observer - SAY_ALGALON_DESPAWN_2'),
+(32871,19,0,'Farewell, mortals. Your bravery is admirable, for such flawed creatures.',12,15400,0,'Algalon the Observer - SAY_ALGALON_DESPAWN_3'),
+(32871,20,0,'Loss of life unavoidable.',14,15387,0,'Algalon the Observer - SAY_ALGALON_KILL'),
+(32871,20,1,'I do what I must.',14,15388,0,'Algalon the Observer - SAY_ALGALON_KILL');
+
+DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=13 AND `SourceEntry` IN (64996,62266,65509,62304,64597);
+INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`Comment`) VALUES
+(13,1,64996,31,3,34246,'Algalon the Observer - Reorigination on Azeroth'),
+(13,1,62266,31,3,33052,'Algalon Stalker - target Living Constellation'),
+(13,1,65509,31,3,33052,'Black Hole - target Living Constellation'),
+(13,1,62304,31,3,33104,'Cosmic Smash - target trigger'),
+(13,1,64597,31,3,33104,'Cosmic Smash - target trigger');
+
+DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_algalon_phase_punch';
+DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_algalon_arcane_barrage';
+DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_algalon_trigger_3_adds';
+DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_algalon_collapse';
+DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_algalon_big_bang';
+DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_algalon_remove_phase';
+DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_algalon_cosmic_smash';
+DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_algalon_cosmic_smash_damage';
+DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_algalon_supermassive_fail';
+INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
+(64412,'spell_algalon_phase_punch'),
+(64599,'spell_algalon_arcane_barrage'),
+(64607,'spell_algalon_arcane_barrage'),
+(62266,'spell_algalon_trigger_3_adds'),
+(62018,'spell_algalon_collapse'),
+(64443,'spell_algalon_big_bang'),
+(64584,'spell_algalon_big_bang'),
+(64445,'spell_algalon_remove_phase'),
+(62295,'spell_algalon_cosmic_smash'),
+(62311,'spell_algalon_cosmic_smash_damage'),
+(64596,'spell_algalon_cosmic_smash_damage'),
+(65311,'spell_algalon_supermassive_fail');
+
+SET @DIFF_ID := 3262;
+DELETE FROM `spelldifficulty_dbc` WHERE `id` BETWEEN @DIFF_ID AND @DIFF_ID+5;
+INSERT INTO `spelldifficulty_dbc` (`id`,`spellid0`,`spellid1`) VALUES
+(@DIFF_ID+0,64395,64592),
+(@DIFF_ID+1,64599,64607),
+(@DIFF_ID+2,64443,64584),
+(@DIFF_ID+3,64122,65108),
+(@DIFF_ID+4,62301,64598),
+(@DIFF_ID+5,62304,64597);
+
+UPDATE `instance_encounters` SET `creditType`=1,`creditEntry`=65184 WHERE `entry` IN (757,771); -- Algalon the Observer
+
+DELETE FROM `disables` WHERE `sourceType`=4 AND `entry` IN (10565,10566,10678,9990,9991,10567,10569,10698,10780,10781,10782,10783,10568,10570);
+DELETE FROM `achievement_criteria_data` WHERE `criteria_id` IN (10565,10566,10678,9990,9991,10567,10569,10698,10780,10781,10782,10783,10568,10570);
+INSERT INTO `achievement_criteria_data` (`criteria_id`,`type`,`value1`,`value2`,`ScriptName`) VALUES
+(10565,12,0,0,''), -- Algalon the Observer kills (Ulduar 10 player)
+(10566,12,1,0,''), -- Algalon the Observer kills (Ulduar 25 player)
+(10678,12,0,0,''), -- Herald of the Titans
+(10678,18,0,0,''), -- Herald of the Titans
+(9990,12,0,0,''), -- Lich King 10-player bosses killed
+(9991,12,1,0,''), -- Lich King 25-player bosses killed
+(10567,12,0,0,''), -- Observed (10 player)
+(10569,12,1,0,''), -- Observed (25 player)
+(10698,12,1,0,''), -- Realm First! Celestial Defender
+(10780,12,0,0,''), -- Supermassive (10 player)
+(10781,12,0,0,''), -- Supermassive (10 player)
+(10782,12,1,0,''), -- Supermassive (25 player)
+(10783,12,1,0,''), -- Supermassive (25 player)
+(10568,11,0,0,'achievement_he_feeds_on_your_tears'), -- He Feeds On Your Tears (10 player)
+(10568,12,0,0,''), -- He Feeds On Your Tears (10 player)
+(10570,11,0,0,'achievement_he_feeds_on_your_tears'), -- He Feeds On Your Tears (25 player)
+(10570,12,1,0,''); -- He Feeds On Your Tears (25 player)
diff --git a/sql/updates/world/2012_04_20_00_world_gameobject_loot_template.sql b/sql/updates/world/2012_04_20_00_world_gameobject_loot_template.sql
new file mode 100644
index 00000000000..47a22d519d0
--- /dev/null
+++ b/sql/updates/world/2012_04_20_00_world_gameobject_loot_template.sql
@@ -0,0 +1,15 @@
+SET @Ref := 12002;
+DELETE FROM `reference_loot_template` WHERE `entry`=@Ref;
+INSERT INTO `reference_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+(@Ref,47242,100,1,0,1,1);
+DELETE FROM `gameobject_loot_template` WHERE `entry` IN (195668,195667,195666,195665,195672,195671,195670,195669) AND `item`=47242;
+DELETE FROM `gameobject_loot_template` WHERE `entry` IN (195668,195667,195666,195665,195672,195671,195670,195669) AND `mincountOrRef` = -@Ref;
+INSERT INTO gameobject_loot_template (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+(195665,5,100,1,0,-@Ref,4), -- 10 man,50 attempts
+(195666,3,100,1,0,-@Ref,4), -- 10 man,45+ attempts
+(195667,3,100,1,0,-@Ref,2), -- 10 man,25+ attempts
+(195668,1,100,1,0,-@Ref,2), -- 10 man,0+ attempts
+(195669,6,100,1,0,-@Ref,4), -- 25 man,50 attempts
+(195670,4,100,1,0,-@Ref,4), -- 25 man,45+ attempts
+(195671,4,100,1,0,-@Ref,2), -- 25 man,25+ attempts
+(195672,2,100,1,0,-@Ref,2); -- 25 man,0+ attempts
diff --git a/sql/updates/world/2012_04_20_01_world_item_loot_template.sql b/sql/updates/world/2012_04_20_01_world_item_loot_template.sql
new file mode 100644
index 00000000000..af52ade0b25
--- /dev/null
+++ b/sql/updates/world/2012_04_20_01_world_item_loot_template.sql
@@ -0,0 +1,10 @@
+SET @Bag := 52676;
+DELETE FROM `item_loot_template` WHERE `entry`=@Bag;
+INSERT INTO `item_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+(@Bag,36933,0,1,1,1,3),-- Forest Emerald
+(@Bag,36918,0,1,1,1,3),-- Scarlet Ruby
+(@Bag,36921,0,1,1,1,3),-- Autumn's Glow
+(@Bag,36930,0,1,1,1,3),-- Monarch Topaz
+(@Bag,36924,0,1,1,1,3),-- Sky Sapphire
+(@Bag,36927,0,1,1,1,3),-- Twilight Opal
+(@Bag,43953,5,1,0,1,1); -- Reins of the Blue Drake
diff --git a/sql/updates/world/2012_04_20_02_world_creature_loot_template.sql b/sql/updates/world/2012_04_20_02_world_creature_loot_template.sql
new file mode 100644
index 00000000000..09b5beee75c
--- /dev/null
+++ b/sql/updates/world/2012_04_20_02_world_creature_loot_template.sql
@@ -0,0 +1,4 @@
+DELETE FROM `creature_loot_template` WHERE `entry` IN (31702,32297) AND `item`=44564;
+INSERT INTO `creature_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+(31702,44564,0.5,1,0,1,1), -- Recipe: Mighty Arcane Protection Potion on Frostbrood Spawn
+(32297,44564,0.5,1,0,1,1); -- Recipe: Mighty Arcane Protection Potion on Cult Researcher
diff --git a/sql/updates/world/2012_04_20_03_world_creature_loot_template.sql b/sql/updates/world/2012_04_20_03_world_creature_loot_template.sql
new file mode 100644
index 00000000000..a0b586ee0d9
--- /dev/null
+++ b/sql/updates/world/2012_04_20_03_world_creature_loot_template.sql
@@ -0,0 +1,7 @@
+SET @ITEM := 50406; -- Formula: Enchant Gloves - Angler
+UPDATE `creature_template` SET `lootid` = `entry` WHERE `entry` IN(26343,26344,26336);
+DELETE FROM `creature_loot_template` WHERE `item`=@ITEM;
+INSERT INTO `creature_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+(26343, @ITEM, 1.1, 1, 0, 1, 1), -- Indu'Le Fisherman
+(26336, @ITEM, 0.9, 1, 0, 1, 1), -- Indu'Le Mystic
+(26344, @ITEM, 1, 1, 0, 1, 1); -- Indu'Le Warrior
diff --git a/sql/updates/world/2012_04_20_04_world_creature_loot_template.sql b/sql/updates/world/2012_04_20_04_world_creature_loot_template.sql
new file mode 100644
index 00000000000..73e01efa23e
--- /dev/null
+++ b/sql/updates/world/2012_04_20_04_world_creature_loot_template.sql
@@ -0,0 +1,3 @@
+-- Make Grimscale Murlocs drop their heads faster...
+UPDATE `creature_loot_template` SET `ChanceOrQuestChance`=-66 WHERE `item`=21757;
+
diff --git a/sql/updates/world/2012_04_20_05_gameobject_template.sql b/sql/updates/world/2012_04_20_05_gameobject_template.sql
new file mode 100644
index 00000000000..24400b16a5c
--- /dev/null
+++ b/sql/updates/world/2012_04_20_05_gameobject_template.sql
@@ -0,0 +1,8 @@
+-- Restore horrible mistake in UP34 from myself
+UPDATE `gameobject_template` SET `data1`=27512 WHERE `entry`=195669;
+UPDATE `gameobject_template` SET `data1`=27517 WHERE `entry`=195670;
+UPDATE `gameobject_template` SET `data1`=27518 WHERE `entry`=195671;
+-- Fix loottemplates along with it
+UPDATE `gameobject_loot_template` SET `entry`=27512 WHERE `entry`=195669;
+UPDATE `gameobject_loot_template` SET `entry`=27517 WHERE `entry`=195670;
+UPDATE `gameobject_loot_template` SET `entry`=27518 WHERE `entry`=195671;
diff --git a/sql/updates/world/2012_04_21_00_world_spell_script_names.sql b/sql/updates/world/2012_04_21_00_world_spell_script_names.sql
new file mode 100644
index 00000000000..e61ef4aec74
--- /dev/null
+++ b/sql/updates/world/2012_04_21_00_world_spell_script_names.sql
@@ -0,0 +1,14 @@
+DELETE FROM `spell_script_names` WHERE `spell_id` IN (20625,29142,35139,42393,49882,55269,56578,38441,66316,67100,67101,67102);
+INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
+(20625,'spell_gen_default_count_pct_from_max_hp'), -- Ritual of Doom Sacrifice
+(29142,'spell_gen_default_count_pct_from_max_hp'), -- Eyesore Blaster
+(35139,'spell_gen_default_count_pct_from_max_hp'), -- Throw Boom's Doom
+(42393,'spell_gen_default_count_pct_from_max_hp'), -- Brewfest - Attack Keg
+(49882,'spell_gen_default_count_pct_from_max_hp'), -- Leviroth Self-Impale
+(55269,'spell_gen_default_count_pct_from_max_hp'), -- Deathly Stare
+(56578,'spell_gen_default_count_pct_from_max_hp'), -- Rapid-Fire Harpoon
+(38441,'spell_gen_50pct_count_pct_from_max_hp'), -- Cataclysmic Bolt
+(66316,'spell_gen_50pct_count_pct_from_max_hp'), -- Spinning Pain Spike 10m
+(67100,'spell_gen_50pct_count_pct_from_max_hp'), -- Spinning Pain Spike 25m
+(67101,'spell_gen_50pct_count_pct_from_max_hp'), -- Spinning Pain Spike 10m heroic
+(67102,'spell_gen_50pct_count_pct_from_max_hp'); -- Spinning Pain Spike 25m heroic
diff --git a/sql/updates/world/2012_04_22_00_world_sai.sql b/sql/updates/world/2012_04_22_00_world_sai.sql
new file mode 100644
index 00000000000..f223883c8a7
--- /dev/null
+++ b/sql/updates/world/2012_04_22_00_world_sai.sql
@@ -0,0 +1,63 @@
+-- SAI for Tabard Vendor Elizabeth Ross
+SET @ROSS := 28776;
+SET @GOSSIP := 9832;
+
+UPDATE `creature_template` SET `AIName`='SmartAI', `ScriptName`='' WHERE `entry`=@ROSS;
+
+DELETE FROM `gossip_menu_option` WHERE `menu_id`=@GOSSIP AND `id`>0 AND `id`<11;
+INSERT INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `option_id`, `npc_option_npcflag`, `action_menu_id`, `action_poi_id`, `box_coded`, `box_money`, `box_text`) VALUES
+(@GOSSIP, 1, 0, 'I''ve lost my Blood Knight Tabard.', 1, 1, 0, 0, 0, 0, ''),
+(@GOSSIP, 2, 0, 'I''ve lost my Tabard of the Hand.', 1, 1, 0, 0, 0, 0, ''),
+(@GOSSIP, 3, 0, 'I''ve lost my Tabard of the Protector.', 1, 1, 0, 0, 0, 0, ''),
+(@GOSSIP, 4, 0, 'I''ve lost my Green Trophy Tabard of the Illidari.', 1, 1, 0, 0, 0, 0, ''),
+(@GOSSIP, 5, 0, 'I''ve lost my Purple Trophy Tabard of the Illidari.', 1, 1, 0, 0, 0, 0, ''),
+(@GOSSIP, 6, 0, 'I''ve lost my Tabard of Summer Skies.', 1, 1, 0, 0, 0, 0, ''),
+(@GOSSIP, 7, 0, 'I''ve lost my Tabard of Summer Flames.', 1, 1, 0, 0, 0, 0, ''),
+(@GOSSIP, 8, 0, 'I''ve lost my Loremaster''s Colors.', 1, 1, 0, 0, 0, 0, ''),
+(@GOSSIP, 9, 0, 'I''ve lost my Tabard of the Explorer.', 1, 1, 0, 0, 0, 0, ''),
+(@GOSSIP, 10, 0, 'I''ve lost my Tabard of the Achiever.', 1, 1, 0, 0, 0, 0, '');
+
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ROSS AND `source_type`=0;
+INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ROSS, 0, 0, 10, 62, 0, 100, 0, @GOSSIP, 1, 0, 0, 11, 54974, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Elizabeth Ross - On Gossip Select - Cast Spell Create Blood Knight Tabard'),
+(@ROSS, 0, 1, 10, 62, 0, 100, 0, @GOSSIP, 2, 0, 0, 11, 54976, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Elizabeth Ross - On Gossip Select - Cast Spell Create Tabard of the Hand'),
+(@ROSS, 0, 2, 10, 62, 0, 100, 0, @GOSSIP, 3, 0, 0, 11, 55008, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Elizabeth Ross - On Gossip Select - Cast Spell Create Tabard of the Protector'),
+(@ROSS, 0, 3, 10, 62, 0, 100, 0, @GOSSIP, 4, 0, 0, 11, 54977, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Elizabeth Ross - On Gossip Select - Cast Spell Create Green Trophy Tabard of the Illidari'),
+(@ROSS, 0, 4, 10, 62, 0, 100, 0, @GOSSIP, 5, 0, 0, 11, 54982, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Elizabeth Ross - On Gossip Select - Cast Spell Create Purple Trophy Tabard of the Illidari'),
+(@ROSS, 0, 5, 10, 62, 0, 100, 0, @GOSSIP, 6, 0, 0, 11, 62768, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Elizabeth Ross - On Gossip Select - Cast Spell Create Tabard of Summer Skies'),
+(@ROSS, 0, 6, 10, 62, 0, 100, 0, @GOSSIP, 7, 0, 0, 11, 62769, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Elizabeth Ross - On Gossip Select - Cast Spell Create Tabard of Summer Flames'),
+(@ROSS, 0, 7, 10, 62, 0, 100, 0, @GOSSIP, 8, 0, 0, 11, 58194, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Elizabeth Ross - On Gossip Select - Cast Spell Create Loremaster''s Colors'),
+(@ROSS, 0, 8, 10, 62, 0, 100, 0, @GOSSIP, 9, 0, 0, 11, 58224, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Elizabeth Ross - On Gossip Select - Cast Spell Create Tabard of the Explorer'),
+(@ROSS, 0, 9, 10, 62, 0, 100, 0, @GOSSIP, 10, 0, 0, 11, 55006, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Elizabeth Ross - On Gossip Select - Cast Spell Create Tabard of the Achiever'),
+(@ROSS, 0, 10, 0, 61, 0, 100, 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Elizabeth Ross - On Gossip Select - Close Gossip');
+
+DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup`=@GOSSIP;
+INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
+(15,@GOSSIP,1,0,2,25549,1,1,1,0,'','Only show gossip if player doesn''t have Blood Knight Tabard'),
+(15,@GOSSIP,1,0,8,9737,0,0,0,0,'','Only show gossip if player already finished quest True Masters of Light'),
+(15,@GOSSIP,2,0,2,24344,1,1,1,0,'','Only show gossip if player doesn''t have Tabard of the Hand'),
+(15,@GOSSIP,2,0,8,9762,0,0,0,0,'','Only show gossip if player already finished quest The Unwritten Prophecy'),
+(15,@GOSSIP,3,0,2,28788,1,1,1,0,'','Only show gossip if player doesn''t have Tabard of the protector'),
+(15,@GOSSIP,3,0,8,10259,0,0,0,0,'','Only show gossip if player already finished quest Into the Breach'),
+(15,@GOSSIP,4,0,2,31404,1,1,1,0,'','Only show gossip if player doesn''t have Green Trophy Tabard of Illidari'),
+(15,@GOSSIP,4,0,2,31405,1,1,1,0,'','Only show gossip if player doesn''t have Purple Trophy Tabard of Illidari'),
+(15,@GOSSIP,4,0,2,31408,1,1,1,0,'','Only show gossip if player doesn''t have Offering of the Sha''tar'),
+(15,@GOSSIP,4,0,8,10781,0,0,0,0,'','Only show gossip if player already finished quest Battle of the Crimson Watch'),
+(15,@GOSSIP,5,0,2,31404,1,1,1,0,'','Only show gossip if player doesn''t have Green Trophy Tabard of Illidari'),
+(15,@GOSSIP,5,0,2,31405,1,1,1,0,'','Only show gossip if player doesn''t have Purple Trophy Tabard of Illidari'),
+(15,@GOSSIP,5,0,2,31408,1,1,1,0,'','Only show gossip if player doesn''t have Offering of the Sha''tar'),
+(15,@GOSSIP,5,0,8,10781,0,0,0,0,'','Only show gossip if player already finished quest Battle of the Crimson Watch'),
+(15,@GOSSIP,6,0,2,35279,1,1,1,0,'','Only show gossip if player doesn''t have Tabard of Summer Skies'),
+(15,@GOSSIP,6,0,2,35280,1,1,1,0,'','Only show gossip if player doesn''t have Tabard of Summer Flames'),
+(15,@GOSSIP,6,0,8,11972,0,0,0,0,'','Only show gossip if player already finished quest Shards of Ahune'),
+(15,@GOSSIP,7,0,2,35279,1,1,1,0,'','Only show gossip if player doesn''t have Tabard of Summer Skies'),
+(15,@GOSSIP,7,0,2,35280,1,1,1,0,'','Only show gossip if player doesn''t have Tabard of Summer Flames'),
+(15,@GOSSIP,7,0,8,11972,0,0,0,0,'','Only show gossip if player already finished quest Shards of Ahune'),
+(15,@GOSSIP,8,0,2,43300,1,1,1,0,'','Only show gossip if player doesn''t have Loremaster''s Colors'),
+(15,@GOSSIP,8,0,17,1681,0,0,0,0,'','Only show gossip if player have achievement Loremaster (A)'),
+(15,@GOSSIP,8,1,2,43300,1,1,1,0,'','Only show gossip if player doesn''t have Loremaster''s Colors'),
+(15,@GOSSIP,8,1,17,1682,0,0,0,0,'','Only show gossip if player have achievement Loremaster (H)'),
+(15,@GOSSIP,9,0,2,43348,1,1,1,0,'','Only show gossip if player doesn''t have Tabard of the Explorer'),
+(15,@GOSSIP,9,0,17,45,0,0,0,0,'','Only show gossip if player have achievement Explore Northrend'),
+(15,@GOSSIP,10,0,2,40643,1,1,1,0,'','Only show gossip if player doesn''t have Tabard of the Explorer'),
+(15,@GOSSIP,10,0,17,1021,0,0,0,0,'','Only show gossip if player have achievement Twenty-Five Tabards');
diff --git a/sql/updates/world/2012_04_23_00_world_creatures.sql b/sql/updates/world/2012_04_23_00_world_creatures.sql
new file mode 100644
index 00000000000..3730fabf552
--- /dev/null
+++ b/sql/updates/world/2012_04_23_00_world_creatures.sql
@@ -0,0 +1,12 @@
+UPDATE `creature_template` SET `flags_extra`=0x82,`ModelId1`=1126,`ModelId2`=16925 WHERE `entry` IN (38008,38641,38773,38774); -- Blood Orb Controller
+UPDATE `creature_template` SET `flags_extra`=0x80,`ModelId1`=19725,`ModelId2`=31095,`baseattacktime`=2000,`speed_walk`=0.8,`speed_run`=0.28571 WHERE `entry` IN (38454,38775,38776,38777); -- Kinetic Bomb
+UPDATE `creature_template` SET `exp`=2,`baseattacktime`=2000,`ModelId1`=19725,`ModelId2`=21342 WHERE `entry`=38458; -- Kinetic Bomb Target
+UPDATE `creature_template` SET `baseattacktime`=2000,`speed_walk`=4.4,`ModelId1`=19725,`ModelId2`=26767 WHERE `entry` IN (38332,38451); -- Ball of Flame
+UPDATE `creature_template` SET `flags_extra`=0x80 WHERE `entry`=37950; -- Valithria Dreamwalker
+UPDATE `creature_template` SET `InhabitType`=4 WHERE `InhabitType`&4 AND `flags_extra`&0x80; -- make flying triggers fly
+UPDATE `creature_template` SET `InhabitType`=4,`HoverHeight`=12 WHERE `entry`=37126; -- Sister Svalna
+UPDATE `creature_template` SET `InhabitType`=4 WHERE `entry`=37950; -- Valithria Dreamwalker
+UPDATE `creature_model_info` SET `bounding_radius`=1,`combat_reach`=0,`gender`=0 WHERE `modelid`=31095; -- Kinetic Bomb
+UPDATE `creature_model_info` SET `bounding_radius`=0.5,`combat_reach`=1,`gender`=0 WHERE `modelid`=21342; -- Kinetic Bomb Target
+UPDATE `creature_model_info` SET `bounding_radius`=0.5,`combat_reach`=1,`gender`=0 WHERE `modelid`=26767; -- Ball of Flame
+UPDATE `creature_template_addon` SET `bytes1`=50331648,`bytes2`=1,`mount`=0,`emote`=0,`auras`=NULL WHERE `entry`=38454; -- Kinetic Bomb
diff --git a/sql/updates/world/2012_04_23_01_world_conditions.sql b/sql/updates/world/2012_04_23_01_world_conditions.sql
new file mode 100644
index 00000000000..c731426aa3f
--- /dev/null
+++ b/sql/updates/world/2012_04_23_01_world_conditions.sql
@@ -0,0 +1,5 @@
+-- setup alternate conditions for spell 46488
+DELETE FROM `conditions` WHERE `SourceEntry` = 46488 AND `ElseGroup` = 1;
+INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
+(13,1,46488,0,1,31,1,3,26817,0,0,0,'',''),
+(13,1,46488,0,1,36,1,0,0,0,1,0,'','');
diff --git a/sql/updates/world/2012_04_23_02_world_prospecting_loot_template.sql b/sql/updates/world/2012_04_23_02_world_prospecting_loot_template.sql
new file mode 100644
index 00000000000..6ea44d92722
--- /dev/null
+++ b/sql/updates/world/2012_04_23_02_world_prospecting_loot_template.sql
@@ -0,0 +1,112 @@
+SET @TinRef := 13000;
+SET @TBC1 := @TinRef+1;
+SET @TBC2 := @TinRef+2;
+SET @WOTLK1 := @TinRef+3;
+SET @WOTLK2 := @TinRef+4;
+SET @WOTLK3 := @TinRef+5;
+
+SET @Copper := 2770;
+SET @Tin := 2771;
+SET @Iron := 2772;
+SET @Mithril := 3858;
+SET @Thorium := 10620;
+SET @FelIron := 23424;
+SET @Adamantite := 23425;
+SET @Cobalt := 36909;
+SET @Saronite := 36912;
+SET @Titanium := 36910;
+
+-- Reference Loot Templates
+DELETE FROM `reference_loot_template` WHERE `entry` BETWEEN @TinRef AND @TinRef+5;
+INSERT INTO `reference_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+-- Stupid Tin
+(@TinRef,1529,0,1,1,1,1), -- Jade
+(@TinRef,3864,0,1,1,1,1), -- Citrine
+(@TinRef,7909,0,1,1,1,1), -- Aquamarine
+-- TBC Greens
+(@TBC1,21929,0,1,1,1,2), -- Flame Spessarite
+(@TBC1,23077,0,1,1,1,2), -- Blood Garnet
+(@TBC1,23079,0,1,1,1,2), -- Deep Peridot
+(@TBC1,23107,0,1,1,1,2), -- Shadow Draenite
+(@TBC1,23112,0,1,1,1,2), -- Golden Draenite
+(@TBC1,23117,0,1,1,1,2), -- Azure Moonstone
+-- TBC Blues
+(@TBC2,23436,0,1,1,1,1), -- Living Ruby
+(@TBC2,23437,0,1,1,1,1), -- Talasite
+(@TBC2,23438,0,1,1,1,1), -- Star of Elune
+(@TBC2,23439,0,1,1,1,1), -- Noble Topaz
+(@TBC2,23440,0,1,1,1,1), -- Dawnstone
+(@TBC2,23441,0,1,1,1,1), -- Nightseye
+-- WOTLK Greens
+(@WOTLK1,36917,0,1,1,1,2), -- Bloodstone
+(@WOTLK1,36920,0,1,1,1,2), -- Sun Crystal
+(@WOTLK1,36923,0,1,1,1,2), -- Chalcedony
+(@WOTLK1,36926,0,1,1,1,2), -- Shadow Crystal
+(@WOTLK1,36929,0,1,1,1,2), -- Huge Citrine
+(@WOTLK1,36932,0,1,1,1,2), -- Dark Jade
+-- WOTLK Blues
+(@WOTLK2,36918,0,1,1,1,2), -- Scarlet Ruby
+(@WOTLK2,36921,0,1,1,1,2), -- Autumn's Glow
+(@WOTLK2,36924,0,1,1,1,2), -- Sky Sapphire
+(@WOTLK2,36927,0,1,1,1,2), -- Twilight Opal
+(@WOTLK2,36930,0,1,1,1,2), -- Monarch Topaz
+(@WOTLK2,36933,0,1,1,1,2), -- Forest Emerald
+-- WOTLK Epics
+(@WOTLK3,36919,0,1,1,1,1), -- Cardinal Ruby
+(@WOTLK3,36922,0,1,1,1,1), -- King's Amber
+(@WOTLK3,36925,0,1,1,1,1), -- Majestic Zircon
+(@WOTLK3,36928,0,1,1,1,1), -- Dreadstone
+(@WOTLK3,36931,0,1,1,1,1), -- Ametrine
+(@WOTLK3,36934,0,1,1,1,1); -- Eye of Zul
+-- --------------------------------------------------------
+-- Prospecting Loot Templates
+DELETE FROM `prospecting_loot_template` WHERE `entry` IN (@Copper,@Tin,@Iron,@Mithril,@Thorium,@FelIron,@Adamantite,@Cobalt,@Saronite,@Titanium);
+INSERT INTO `prospecting_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+-- Copper Ore
+(@Copper,774,0,1,1,1,1), -- Malachite
+(@Copper,818,0,1,1,1,1), -- Tigerseye
+(@Copper,1210,10,1,0,1,1), -- Shadowgem
+-- Tin Ore
+(@Tin,1210,0,1,1,1,2), -- Shadowgem
+(@Tin,1705,0,1,1,1,2), -- Lesser Moonstone
+(@Tin,1206,0,1,1,1,2), -- Moss Agate
+(@Tin,1,10,1,0,-@TinRef,1), -- One Rare gem chance
+-- Iron Ore
+(@Iron,1529,30,1,1,1,2), -- Jade
+(@Iron,1705,30,1,1,1,2), -- Lesser Moonstone
+(@Iron,3864,30,1,1,1,2), -- Citrine
+(@Iron,7909,5,1,1,1,1), -- Aquamarine
+(@Iron,7910,5,1,1,1,1), -- Star Ruby
+-- Mithril Ore
+(@Mithril,3864,30,1,1,1,2), -- Citrine
+(@Mithril,7909,30,1,1,1,2), -- Aquamarine
+(@Mithril,7910,30,1,1,1,2), -- Star Ruby
+(@Mithril,12361,2.5,1,1,1,1), -- Blue Sapphire
+(@Mithril,12364,2.5,1,1,1,1), -- Huge Emerald
+(@Mithril,12799,2.5,1,1,1,1), -- Large Opal
+(@Mithril,12800,2.5,1,1,1,1), -- Azerothian Diamond
+-- Thorium Ore
+(@Thorium,7910,30,1,1,1,2), -- Star Ruby
+(@Thorium,12361,15,1,1,1,2), -- Blue Sapphire
+(@Thorium,12364,15,1,1,1,2), -- Huge Emerald
+(@Thorium,12799,15,1,1,1,2), -- Large Opal
+(@Thorium,12800,15,1,1,1,2), -- Azerothian Diamond
+(@Thorium,1,10,1,1,-@TBC1,1), -- one from TBC Greens
+-- Fel Iron Ore
+(@FelIron,1,95,1,1,-@TBC1,1), -- One from TBC Greens
+(@FelIron,2,05,1,1,-@TBC2,1), -- One from TBC Blues
+-- Adamantite Ore
+(@Adamantite,24243,100,1,0,1,1), -- Adamantite Powder
+(@Adamantite,1,100,1,1,-@TBC1,1), -- One from TBC Greens
+(@Adamantite,2, 10,1,1,-@TBC2,1), -- One from TBC Blues
+-- Cobalt Ore
+(@Cobalt,1,95,1,1,-@WOTLK1,1), -- One from WOTLK Greens
+(@Cobalt,2,05,1,1,-@WOTLK2,1), -- One from WOTLK Blues
+-- Saronite Ore
+(@Saronite,1,85,1,1,-@WOTLK1,2), -- One from WOTLK Greens
+(@Saronite,2,15,1,1,-@WOTLK2,1), -- One from WOTLK Blues
+-- Titanium Ore
+(@Titanium,46849,75,1,0,1,1), -- Titanium Powder
+(@Titanium,1,75,1,1,-@WOTLK1,2), -- Two from WOTLK Greens
+(@Titanium,2,25,1,1,-@WOTLK2,1), -- One from WOTLK Blues
+(@Titanium,3,20,1,0,-@WOTLK3,1); -- One from WOTLK Epics
diff --git a/sql/updates/world/2012_04_23_03_world_skinning_loot_template.sql b/sql/updates/world/2012_04_23_03_world_skinning_loot_template.sql
new file mode 100644
index 00000000000..a1aa9e070f2
--- /dev/null
+++ b/sql/updates/world/2012_04_23_03_world_skinning_loot_template.sql
@@ -0,0 +1,44 @@
+UPDATE `creature_template` SET `skinloot`=entry WHERE `entry` IN (30260, 32517, 27641, 28860);
+UPDATE `creature_template` SET `skinloot`=70202 WHERE `entry` IN (25774,29693);
+UPDATE `creature_template` SET `skinloot`=70203 WHERE `entry`=28257;
+UPDATE `creature_template` SET `skinloot`=70207 WHERE `entry`=34137;
+UPDATE `creature_template` SET `skinloot`=70208 WHERE `entry` IN (32572,25448,25716,25713);
+UPDATE `creature_template` SET `skinloot`=70210 WHERE `entry` IN (33528,40419,26723,31134,36891);
+UPDATE `creature_template` SET `skinloot`=70211 WHERE `entry` IN (28847,30206,29875,29931,28203,30432);
+UPDATE `creature_template` SET `skinloot`=70212 WHERE `entry` IN (27645,32377,29838,26628,26622,32490,38453,32485,26633,32400,32361,29768,29735,26641,27644,27642,26735,26730,26722,33776,35189,26716,26672,29664,29774);
+UPDATE `creature_template` SET `skinloot`=70213 WHERE `entry` IN (27483,29312);
+UPDATE `creature_template` SET `skinloot`=70214 WHERE `entry` IN (37217,34564);
+UPDATE `creature_template` SET `skinloot`=27641 WHERE `entry` IN (31385,34269,34270,27641,30905,30353);
+
+DELETE FROM `skinning_loot_template` WHERE entry IN (30260,32517,70212,70213,70214,28860,27641);
+INSERT INTO `skinning_loot_template` (`entry`, `item`, `ChanceOrQuestChance`, `groupid`, `mincountOrRef`, `maxcount`) VALUES
+-- Stoic Mammoth
+(30260,33568,100,0,1,3), -- Borean Leather
+(30260,42542,-50,0,1,1), -- Stoic Mammoth Hide
+-- Loque'nahak
+(32517,33568,0,1,1,3), -- Borean Leather
+(32517,44128,2,1,1,1), -- Arctic Fur
+(32517,44687,100,0,1,1), -- Loque'Nahak's Pelt
+-- skinloot 70212
+(70212,33568,0,1,1,3), -- Borean Leather
+(70212,44128,1,1,1,1), -- Arctic Fur
+-- skinloot 70213
+(70213,33568,0,1,5,12), -- Borean Leather
+(70213,44128,1,1,1,1), -- Arctic Fur
+-- skinloot 70214
+(70214,33568,0,1,12,16), -- Borean Leather
+(70214,44128,25,1,1,1), -- Arctic Fur
+-- Sartharion
+(28860,33568,0,1,8,12), -- Borean Leather
+(28860,38557,0,1,8,12),-- Icy Dragonscale
+(28860,44128,1,1,1,1), -- Arctic Fur
+-- Centrifuge Construct
+(27641,41337,85,0,1,3), -- Whizzed-Out Gizmo
+(27641,41338,80,0,1,3), -- Sprung Whirlygig
+(27641,39690,15,0,1,3), -- Volatile Blasting Trigger
+(27641,39684,8,0,1,1), -- Hair Trigger
+(27641,36813,8,0,1,3), -- Sprung Sprocket
+(27641,39681,8,0,2,4), -- Handful of Cobalt Bolts
+(27641,49050,2,0,1,1), -- Schematic: Jeeves
+(27641,39682,1,0,1,1), -- Overcharged Capacitor
+(27641,39685,1,0,1,1); -- Indestructible Frame
diff --git a/sql/updates/world/2012_04_23_04_world_creature_loot_template.sql b/sql/updates/world/2012_04_23_04_world_creature_loot_template.sql
new file mode 100644
index 00000000000..94d2b092d12
--- /dev/null
+++ b/sql/updates/world/2012_04_23_04_world_creature_loot_template.sql
@@ -0,0 +1,2 @@
+-- Correct dropchance for Mote of Life, wowhead was wrong (as usual)
+UPDATE `creature_loot_template` SET `ChanceOrQuestChance`=18.5307 WHERE `entry`=22307 AND `item`=22575;
diff --git a/sql/updates/world/2012_04_23_05_world_creature_loot_template.sql b/sql/updates/world/2012_04_23_05_world_creature_loot_template.sql
new file mode 100644
index 00000000000..ddf0780d362
--- /dev/null
+++ b/sql/updates/world/2012_04_23_05_world_creature_loot_template.sql
@@ -0,0 +1,3 @@
+-- Update the dropchance to 100% if on quest
+UPDATE `creature_loot_template` SET `ChanceOrQuestChance`=-100 WHERE `entry`=21477 AND `item`=31372; -- Rocknail Flayer Carcass
+UPDATE `creature_loot_template` SET `ChanceOrQuestChance`=-100 WHERE `entry`=21478 AND `item`=31373; -- Rocknail Flayer Giblets
diff --git a/sql/updates/world/2012_04_24_00_world_command.sql b/sql/updates/world/2012_04_24_00_world_command.sql
new file mode 100644
index 00000000000..25912392347
--- /dev/null
+++ b/sql/updates/world/2012_04_24_00_world_command.sql
@@ -0,0 +1,10 @@
+DELETE FROM `command` WHERE `name` IN ('modify tp','modify bwalk','modify swim','modify fly','modify arena','modify aspeed','modify morph');
+INSERT INTO `command` (`name`, `security`, `help`) VALUES ('modify speed all', 1, 'Syntax: .modify aspeed #rate\r\n\r\nModify all speeds -run,swim,run back,swim back- of the selected player to "normalbase speed for this move type"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 50.'),
+('modify speed backwalk', 1, 'Syntax: .modify speed backwalk #rate\r\n\r\nModify the speed of the selected player while running backwards to "normal walk back speed"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 50.'),
+('modify speed fly', 1, '.modify speed fly #rate\nModify the flying speed of the selected player to "normal flying speed"*rate. If no player is selected, modify your speed.\n #rate may range from 0.1 to 50.'),
+('modify speed swim', 1, 'Syntax: .modify speed swim #rate\r\n\r\nModify the swim speed of the selected player to "normal swim speed"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 50.'),
+('modify speed walk', 1, 'Syntax: .modify speed bwalk #rate\r\n\r\nModify the speed of the selected player while running to "normal walk speed"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 50.'),
+('modify talentpoints', 1, 'Syntax: .modify talentpoints #amount\r\n\r\nSet free talent points for selected character or character\'s pet. It will be reset to default expected at next levelup/login/quest reward.'),
+('morph', 2, 'Syntax: .morph #displayid\r\n\r\nChange your current model id to #displayid.'),
+('modify arenapoints', 1, 'Syntax: .modify arenapoints #value\r\nAdd $amount arena points to the selected player.');
+UPDATE `command` SET `help`='Syntax: .modify speed $speedtype #rate\r\n\r\nModify the running speed of the selected player to "normal base run speed"= 1. If no player is selected, modify your speed.\r\n\r\n$speedtypes may be fly, all, walk, backwalk, or swim.\r\n\r\n #rate may range from 0.1 to 50.' WHERE `name`='modify speed' LIMIT 1;
diff --git a/sql/updates/world/2012_04_24_01_world_spell_proc_event.sql b/sql/updates/world/2012_04_24_01_world_spell_proc_event.sql
new file mode 100644
index 00000000000..6e997931bb5
--- /dev/null
+++ b/sql/updates/world/2012_04_24_01_world_spell_proc_event.sql
@@ -0,0 +1,4 @@
+-- Honor Among Thieves proc chance
+UPDATE `spell_proc_event` SET `CustomChance`=33 WHERE `entry`=51698; -- Rank 1
+UPDATE `spell_proc_event` SET `CustomChance`=66 WHERE `entry`=51700; -- Rank 2
+UPDATE `spell_proc_event` SET `CustomChance`=100 WHERE `entry`=51701; -- Rank 3
diff --git a/sql/updates/world/2012_04_24_02_world_warden_checks.sql b/sql/updates/world/2012_04_24_02_world_warden_checks.sql
new file mode 100644
index 00000000000..74539f99fb3
--- /dev/null
+++ b/sql/updates/world/2012_04_24_02_world_warden_checks.sql
@@ -0,0 +1,8 @@
+UPDATE `warden_checks` SET `comment`='Swimming_FallCalc - movement state' WHERE `id`=15;
+UPDATE `warden_checks` SET `comment`='CreateMovementStatus' WHERE `id`=72;
+UPDATE `warden_checks` SET `comment`='OnStartSwim OnSplineStartSwim - movement state' WHERE `id`=170;
+UPDATE `warden_checks` SET `comment`='DefaultServerLogin - account name' WHERE `id`=198;
+UPDATE `warden_checks` SET `comment`='Login Checksum - authentication process' WHERE `id`=320;
+UPDATE `warden_checks` SET `comment`='CalcFallStartElevation - (some kind of wall climb)' WHERE `id`=329;
+UPDATE `warden_checks` SET `comment`='Code injection at 0x40100A' WHERE `id`=381;
+UPDATE `warden_checks` SET `comment`='Login State - (May be false positive)' WHERE `id`=437;
diff --git a/sql/updates/world/2012_04_24_03_world_spell_script_names.sql b/sql/updates/world/2012_04_24_03_world_spell_script_names.sql
new file mode 100644
index 00000000000..a53d8bd585c
--- /dev/null
+++ b/sql/updates/world/2012_04_24_03_world_spell_script_names.sql
@@ -0,0 +1,4 @@
+-- Earthen Power
+DELETE FROM `spell_script_names` WHERE `spell_id`=59566;
+INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
+(59566,'spell_sha_earthen_power');
diff --git a/sql/updates/world/2012_04_24_04_world_spell_proc_event.sql b/sql/updates/world/2012_04_24_04_world_spell_proc_event.sql
new file mode 100644
index 00000000000..5ba6f24ccf8
--- /dev/null
+++ b/sql/updates/world/2012_04_24_04_world_spell_proc_event.sql
@@ -0,0 +1,4 @@
+ -- Rogue T9 2P - Should proc only from Rupture ticks.
+DELETE FROM `spell_proc_event` WHERE `entry` IN(67209);
+INSERT INTO `spell_proc_event` (`entry`, `SchoolMask`, `SpellFamilyName`, `SpellFamilyMask0`, `procFlags`) VALUES
+(67209, 0x01, 8, 0x100000, 0x50000);
diff --git a/sql/updates/world/2012_04_24_05_world_creature_loot_template.sql b/sql/updates/world/2012_04_24_05_world_creature_loot_template.sql
new file mode 100644
index 00000000000..c524999b492
--- /dev/null
+++ b/sql/updates/world/2012_04_24_05_world_creature_loot_template.sql
@@ -0,0 +1,9 @@
+-- Apply same loot template to below mentioned Bloodsail NPCs as that of Bloodsail Raider 1561
+-- (Mage 1562, Swashbuckler 1563, Warlock 1564, Sea Dog 1565)
+UPDATE `creature_template` SET `lootid`=1561 WHERE `entry` IN (1562,1563,1564,1565);
+-- Remove Loot from `creature_loot_template` for above mentioned NPCs because it contains only 2 items.
+-- Those 2 items, along with complete loot template for these mobs is applied in query above.
+DELETE FROM `creature_loot_template` WHERE `entry` IN (1562,1563,1564,1565);
+-- Remove loot and gold drop from Bloodsail Warlock's Minions
+UPDATE `creature_template` SET `lootid`=0, `mingold`=0 AND `maxgold`=0 WHERE `entry` IN (10928,12922);
+DELETE FROM `creature_loot_template` WHERE `entry` IN (10928,12922);
diff --git a/sql/updates/world/2012_04_24_06_world_misc.sql b/sql/updates/world/2012_04_24_06_world_misc.sql
new file mode 100644
index 00000000000..2e095a76cd9
--- /dev/null
+++ b/sql/updates/world/2012_04_24_06_world_misc.sql
@@ -0,0 +1,31 @@
+DELETE FROM `spell_script_names` WHERE `spell_id` = 46485;
+INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
+(46485,'spell_item_greatmothers_soulcatcher');
+
+DELETE FROM `conditions` WHERE `SourceEntry` IN (46485,46488);
+INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
+(13,1,46485,0,1,31,1,3,26817,0,0,0,'',''),
+(13,1,46485,0,1,36,1,0,0,0,1,0,'',''),
+(13,1,46488,0,1,31,1,3,26817,0,0,0,'',''),
+(13,1,46488,0,1,36,1,0,0,0,1,0,'','');
+
+-- Gnome Soul SAI
+SET @ENTRY := 26096;
+SET @SPELL_ARCANE_EXPLOSION := 35426;
+UPDATE creature_template SET AIName="SmartAI" WHERE entry=@ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES
+(@ENTRY,0,0,1,54,0,100,0,0,0,0,0,33,@ENTRY,0,0,0,0,0,7,0,0,0,0,0,0,0,"Gnome Soul - On Just Summoned - Quest Credit"),
+(@ENTRY,0,1,2,61,0,100,0,0,0,0,0,45,1,1,0,0,0,0,19,25814,10,1,0,0,0,0,"Gnome Soul - On Just Summoned - Set Data Fizzcrank Mechagnome"),
+(@ENTRY,0,2,0,61,0,100,0,0,0,0,0,69,1,0,0,0,0,0,7,0,0,0,0,0,0,0,"Gnome Soul - On Just Summoned - Move to Summoner"),
+
+(@ENTRY,0,3,4,34,0,100,0,1,0,0,0,11,@SPELL_ARCANE_EXPLOSION,0,0,0,0,0,1,0,0,0,0,0,0,0,"Gnome Soul - Reached Summoner - Cast Arcane Explosion Visual"),
+(@ENTRY,0,4,0,61,0,100,0,0,0,0,0,41,1000,0,0,0,0,0,1,0,0,0,0,0,0,0,"Gnome Soul - Reached Summoner - Forced Despawn");
+
+-- Fizzcrank Mechagnome SAI
+SET @ENTRY := 25814;
+UPDATE creature_template SET AIName="SmartAI" WHERE entry=@ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES
+(@ENTRY,0,0,0,4,0,100,0,0,0,0,0,1,1,10000,0,0,0,0,0,0,0,0,0,0,0,0,"Fizzcrank Mechagnome - Chance Say on Aggro"),
+(@ENTRY,1,0,0,38,0,100,0,1,1,0,0,41,0,0,0,0,0,0,1,0,0,0,0,0,0,0,"Fizzcrank Mechagnome - On Data Set - Forced Despawn");
diff --git a/sql/updates/world/2012_04_25_00_world_misc.sql b/sql/updates/world/2012_04_25_00_world_misc.sql
new file mode 100644
index 00000000000..3d2f20fdc8c
--- /dev/null
+++ b/sql/updates/world/2012_04_25_00_world_misc.sql
@@ -0,0 +1,3 @@
+UPDATE `smart_scripts` SET `source_type`=0,`id`=1 WHERE `entryorguid`=24814 AND `source_type`=1 AND `event_type`=38;
+UPDATE `conditions` SET `SourceTypeOrReferenceId`=17 WHERE `SourceEntry` IN (46485,46488);
+UPDATE `conditions` SET `ElseGroup`=0 WHERE `SourceEntry` IN (46485,46488) AND `ConditionValue1`=26817;
diff --git a/sql/updates/world/2012_04_25_01_world_spell_script_names.sql b/sql/updates/world/2012_04_25_01_world_spell_script_names.sql
new file mode 100644
index 00000000000..e42f1979229
--- /dev/null
+++ b/sql/updates/world/2012_04_25_01_world_spell_script_names.sql
@@ -0,0 +1,3 @@
+DELETE FROM `spell_script_names` WHERE `spell_id` = 33110;
+INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
+(33110,'spell_pri_prayer_of_mending_heal'); \ No newline at end of file
diff --git a/sql/updates/world/2012_04_25_02_world_spell_script_names.sql b/sql/updates/world/2012_04_25_02_world_spell_script_names.sql
new file mode 100644
index 00000000000..ea6b95559c6
--- /dev/null
+++ b/sql/updates/world/2012_04_25_02_world_spell_script_names.sql
@@ -0,0 +1,11 @@
+DELETE FROM `spell_scripts` WHERE `id` IN (15998,25952,29435,45980,51592,51910,52267,54420);
+DELETE FROM `spell_script_names` WHERE `spell_id` IN (15998,25952,29435,45980,51592,51910,52267,54420);
+INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
+(15998, 'spell_gen_despawn_self'),
+(25952, 'spell_gen_despawn_self'),
+(29435, 'spell_gen_despawn_self'),
+(45980, 'spell_gen_despawn_self'),
+(51592, 'spell_gen_despawn_self'),
+(51910, 'spell_gen_despawn_self'),
+(52267, 'spell_gen_despawn_self'),
+(54420, 'spell_gen_despawn_self'); \ No newline at end of file
diff --git a/sql/updates/world/2012_04_25_03_world_spell_group.sql b/sql/updates/world/2012_04_25_03_world_spell_group.sql
new file mode 100644
index 00000000000..a6fa90ad41d
--- /dev/null
+++ b/sql/updates/world/2012_04_25_03_world_spell_group.sql
@@ -0,0 +1,11 @@
+DELETE FROM `spell_group` WHERE `id` IN (1117,1118);
+INSERT INTO `spell_group` (`id`,`spell_id`) VALUES
+(1117,25898),
+(1117,25899),
+(1118,20911),
+(1118,20217);
+
+DELETE FROM `spell_group_stack_rules` WHERE `group_id` in (1117,1118);
+INSERT INTO `spell_group_stack_rules` (`group_id`,`stack_rule`) VALUES
+(1117,3),
+(1118,3);
diff --git a/sql/updates/world/2012_04_26_00_world_conditions.sql b/sql/updates/world/2012_04_26_00_world_conditions.sql
new file mode 100644
index 00000000000..8d525cad057
--- /dev/null
+++ b/sql/updates/world/2012_04_26_00_world_conditions.sql
@@ -0,0 +1 @@
+UPDATE `conditions` SET `ElseGroup` = 0, `SourceGroup` = 0 WHERE `SourceEntry` IN (46485,46488);
diff --git a/sql/updates/world/2012_04_26_01_world_smart_scripts.sql b/sql/updates/world/2012_04_26_01_world_smart_scripts.sql
new file mode 100644
index 00000000000..e90e7b58433
--- /dev/null
+++ b/sql/updates/world/2012_04_26_01_world_smart_scripts.sql
@@ -0,0 +1 @@
+UPDATE `smart_scripts` SET `source_type` = 0, `id` = 1 WHERE `entryorguid` = 25814 AND `source_type` = 1 AND `id` = 0;
diff --git a/sql/updates/world/2012_04_27_00_world_instance_icc.sql b/sql/updates/world/2012_04_27_00_world_instance_icc.sql
new file mode 100644
index 00000000000..6738e4904ab
--- /dev/null
+++ b/sql/updates/world/2012_04_27_00_world_instance_icc.sql
@@ -0,0 +1,5 @@
+DELETE FROM `creature_text` WHERE `entry`=37813 AND `groupid`=14;
+INSERT INTO `creature_text` (`entry`,`groupid`,`text`,`type`,`comment`) VALUES (37813,14,'%s''s Blood Beasts gain the scent of blood!',41,'Deathbringer Saurfang - EMOTE_SCENT_OF_BLOOD');
+DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=13 AND `SourceEntry`=72771;
+INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`Comment`) VALUES
+(13,3,72771,31,3,38508,'Deathbringer Saurfang - Scent of Blood on Blood Beast');
diff --git a/sql/updates/world/2012_04_28_00_world_reference_loot_template.sql b/sql/updates/world/2012_04_28_00_world_reference_loot_template.sql
new file mode 100644
index 00000000000..b59ba90fdbc
--- /dev/null
+++ b/sql/updates/world/2012_04_28_00_world_reference_loot_template.sql
@@ -0,0 +1,158 @@
+-- The Descent into Madness
+-- References
+-- -------------------------------
+-- -- Variables and definitions --
+-- -------------------------------
+-- Set References
+SET @Vezax10Ref := 34373;
+SET @Vezax25Ref := @Vezax10Ref+1;
+SET @Yogg10Ref := @Vezax10Ref+2;
+SET @Yogg25Ref := @Vezax10Ref+3;
+SET @Chest := 12034;
+SET @Shoulder := 12035;
+SET @EmblemRef := 34349;
+SET @Recipe := 34154;
+SET @Vezax10 := 33271;
+SET @Vezax25 := 33449;
+SET @Yogg10 := 33288;
+SET @Yogg25 := 33955;
+
+-- -------------------------
+-- -- Reference Templates --
+-- -------------------------
+-- Delete previous templates if existing
+DELETE FROM `reference_loot_template` WHERE `entry` IN (34131,34132,34133,34164,34165);
+DELETE FROM `reference_loot_template` WHERE `entry` IN (@Vezax10Ref,@Vezax25Ref,@Yogg10Ref,@Yogg25Ref,@Chest,@Shoulder);
+INSERT INTO `reference_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+-- Vezax 10 man
+(@Vezax10Ref,46014,0,1,1,1,1), -- Saronite Animus Cloak
+(@Vezax10Ref,46008,0,1,1,1,1), -- Choker of the Abyss
+(@Vezax10Ref,46010,0,1,1,1,1), -- Darkstone Ring
+(@Vezax10Ref,45996,0,1,1,1,1), -- Hoperender
+(@Vezax10Ref,46015,0,1,1,1,1), -- Pendant of Endless Despair
+(@Vezax10Ref,46013,0,1,1,1,1), -- Underworld Mantle
+(@Vezax10Ref,46012,0,1,1,1,1), -- Vestments of the Piercing Light
+(@Vezax10Ref,46009,0,1,1,1,1), -- Bindings of the Depths
+(@Vezax10Ref,45997,0,1,1,1,1), -- Gauntlets of the Wretched
+(@Vezax10Ref,46011,0,1,1,1,1), -- Shadowbite
+-- Vezax 25 man
+(@Vezax25Ref,45513,0,1,1,1,1), -- Boots of the Forgotten Dephts
+(@Vezax25Ref,45509,0,1,1,1,1), -- Idol of the Corruptor
+(@Vezax25Ref,45501,0,1,1,1,1), -- Boots of the Underdweller
+(@Vezax25Ref,45512,0,1,1,1,1), -- Grips of the Unbroken
+(@Vezax25Ref,45503,0,1,1,1,1), -- Metallic Loop of the Sufferer
+(@Vezax25Ref,45505,0,1,1,1,1), -- Belt of Clinging Hope
+(@Vezax25Ref,45502,0,1,1,1,1), -- Helm of the Faceless
+(@Vezax25Ref,45145,0,1,1,1,1), -- Libram of the Sacred Shield
+(@Vezax25Ref,45508,0,1,1,1,1), -- Belt of the Darkspeaker
+(@Vezax25Ref,45504,0,1,1,1,1), -- Darkcore Leggings
+(@Vezax25Ref,45514,0,1,1,1,1), -- Mantle of the Unknowing
+(@Vezax25Ref,45515,0,1,1,1,1), -- Ring of the Vacant Eye
+(@Vezax25Ref,45507,0,1,1,1,1), -- The General's Heart
+-- Yogg 10 man
+(@Yogg10Ref,46016,0,1,1,1,1), -- Abaddon
+(@Yogg10Ref,46018,0,1,1,1,1), -- Deliverance
+(@Yogg10Ref,46019,0,1,1,1,1), -- Leggings of the Insatiable
+(@Yogg10Ref,46021,0,1,1,1,1), -- Royal Seal of King Llane
+(@Yogg10Ref,46022,0,1,1,1,1), -- Pendant of a Thousand Maws
+(@Yogg10Ref,46024,0,1,1,1,1), -- Kingsbane
+(@Yogg10Ref,46025,0,1,1,1,1), -- Devotion
+(@Yogg10Ref,46028,0,1,1,1,1), -- Faceguard of the Eyeless Horror
+(@Yogg10Ref,46030,0,1,1,1,1), -- Threads of the Dragon Council
+(@Yogg10Ref,46031,0,1,1,1,1), -- Touch of Madness
+-- Yogg 25 man
+(@Yogg25Ref,45521,0,1,1,1,1), -- Earthshaper
+(@Yogg25Ref,45522,0,1,1,1,1), -- Blood of the Old God
+(@Yogg25Ref,45523,0,1,1,1,1), -- Garona's Guise
+(@Yogg25Ref,45524,0,1,1,1,1), -- Chestguard of Insidious Intent
+(@Yogg25Ref,45525,0,1,1,1,1), -- Godbane Signet
+(@Yogg25Ref,45527,0,1,1,1,1), -- Soulscribe
+(@Yogg25Ref,45529,0,1,1,1,1), -- Shawl of Haunted Memories
+(@Yogg25Ref,45530,0,1,1,1,1), -- Sanity's Bond
+(@Yogg25Ref,45531,0,1,1,1,1), -- Chestguard of the Fallen God
+(@Yogg25Ref,45532,0,1,1,1,1), -- Cowl of Dark Whispers
+-- Chest for Yogg
+(@Chest,45635,0,1,1,1,1), -- Chestguard of the Wayward Conqueror
+(@Chest,45636,0,1,1,1,1), -- Chestguard of the Wayward Protector
+(@Chest,45637,0,1,1,1,1), -- Chestguard of the Wayward Vanquisher
+(@Shoulder,45656,0,1,1,1,1), -- Mantle of the Wayward Conqueror
+(@Shoulder,45657,0,1,1,1,1), -- Mantle of the Wayward Protector
+(@Shoulder,45658,0,1,1,1,1); -- Mantle of the Wayward Vanquisher
+
+DELETE FROM `creature_loot_template` WHERE `entry` IN(@Vezax10,@Vezax25,@Yogg10,@Yogg25);
+INSERT INTO `creature_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+-- ----------------------------------------------------------
+-- General Vezax
+-- ----------------------------------------------------------
+-- 10 man mode
+(@Vezax10,1,100,3,0,-@Vezax10Ref,2), -- 2x Normal Loot Item
+(@Vezax10,47241,100,3,0,1,1), -- 1x Emblem of Triumph
+-- hardmode loot 10
+(@Vezax10,46032,0,2,1,1,1), -- Drape of the Faceless General
+(@Vezax10,46034,0,2,1,1,1), -- Leggings of Profound Darkness
+(@Vezax10,46033,0,2,1,1,1), -- Tortured Earth
+(@Vezax10,46035,0,2,1,1,1), -- Aesuga, Hand of the Ardent Champion
+(@Vezax10,46036,0,2,1,1,1), -- Void Sabre
+-- 25 man mode
+(@Vezax25,1,100,3,0,-@Vezax25Ref,3), -- 3x Normal Loot Item
+(@Vezax25,47241,100,3,0,1,1), -- 1x Emblem of Triumph
+(@Vezax25,2,10,1,0,-@Recipe,1), -- Chance on Recipe
+(@Vezax25,3,10,1,0,-34350,1), -- Chance on Runed Orb
+-- hardmode loot 25
+(@Vezax25,45498,0,2,1,1,1), -- Lotrafen, Spear of the Damned
+(@Vezax25,45511,0,2,1,1,1), -- Scepter of Lost Souls
+(@Vezax25,45516,0,2,1,1,1), -- Voldrethar, Dark Blade of Oblivion
+(@Vezax25,45517,0,2,1,1,1), -- Pendulum of Infinity
+(@Vezax25,45519,0,2,1,1,1), -- Vestments of the Blind Denizen
+(@Vezax25,45518,0,2,1,1,1), -- Flare of the Heavens
+(@Vezax25,45520,0,2,1,1,1), -- Handwraps of the Vigilant
+-- ----------------------------------------------------------
+-- Yogg Saron
+-- ----------------------------------------------------------
+-- 10 man
+-- All modes
+(@Yogg10,1,100,31,0,-@Yogg10Ref,1), -- 1x Normal Loot item for modes 0&1&2&3&4
+(@Yogg10,2,100,31,0,-@Chest,1), -- 1x Tier token for modes 0&1&2&3&4
+(@Yogg10,47241,100,31,0,1,1), -- 1x Emblem of Triumph for modes 0&1&2&3&4
+-- Extra for <3 watchers
+(@Yogg10,3,100,30,0,-@EmblemRef,1), -- additional Emblem for modes2&3
+-- Extra for <2 watchers
+(@Yogg10,4,100,28,0,-34350,1), -- Runed Orb for 0&1&2
+(@Yogg10,5,10,28,0,-@Recipe,1), -- Chance on Recipe for 0&1&2
+-- Extra for <1 watchers
+(@Yogg10,6,100,24,0,-@EmblemRef,1), -- additional Emblem for 0&1
+(@Yogg10,7,100,24,0,-@Recipe,1), -- Garanteed Recipe for 0&1
+-- Hardmode 10 loot
+(@Yogg10,46067,0,24,1,1,1), -- Hammer of Crushing Whispers
+(@Yogg10,46068,0,24,1,1,1), -- Amice of Inconceivable Horror
+(@Yogg10,46095,0,24,1,1,1), -- Soul-Devouring Cinch
+(@Yogg10,46096,0,24,1,1,1), -- Signet of Soft Lament
+(@Yogg10,46097,0,24,1,1,1), -- Caress of Insanity
+-- Extra for 0 watchers
+(@Yogg10,46312,100,16,0,1,1), -- Vanquished Clutches of Yogg-Saron
+-- 25 man mode
+-- All modes
+(@Yogg25,1,100,31,0,-@Yogg25Ref,2), -- 2x Normal Loot item for modes 0&1&2&3&4
+(@Yogg25,2,100,31,0,-@Shoulder,2), -- 2x Tier token for modes 0&1&2&3&4
+(@Yogg25,47241,100,31,0,1,1), -- 1x Emblem of Triumph for modes 0&1&2&3&4
+(@Yogg25,3,10,31,0,-34350,1), -- Chance on Runed Orb for modes 0&1&2&3&4
+(@Yogg25,4,10,31,0,-@Recipe,1), -- Chance on Recipe for 0&1&2&3&4
+(@Yogg25,45897,100,31,0,1,1), -- Fragment of Val'anyr
+-- Extra for <3 watchers
+(@Yogg25,5,100,30,0,-@EmblemRef,1), -- additional Emblem for modes2&3
+-- Extra for <2 watchers
+(@Yogg25,6,100,28,0,-34350,1), -- Runed Orb for 0&1&2
+-- Extra for <1 watchers
+(@Yogg25,7,100,24,0,-@EmblemRef,1), -- additional Emblem for 0&1
+(@Yogg25,8,100,24,0,-@Recipe,1), -- Garanteed Recipe for 0&1
+-- Hardmode 25 loot
+(@Yogg25,45533,0,24,1,1,1), -- Dark Edge of Depravity
+(@Yogg25,45534,0,24,1,1,1), -- Seal of the Betrayed King
+(@Yogg25,45535,0,24,1,1,1), -- Show of Faith
+(@Yogg25,45536,0,24,1,1,1), -- Legguards of Cunning Deception
+(@Yogg25,45537,0,24,1,1,1), -- Threads of the False Oracle
+-- Extra for 0 watchers
+(@Yogg25,45693,100,16,0,1,1); -- Mimiron's Head
+
+-- Cleanups
+DELETE FROM `conditions` WHERE `SourceEntry`=45897 AND `SourceGroup`=33955; \ No newline at end of file
diff --git a/sql/updates/world/2012_04_28_01_world_reference_loot_template.sql b/sql/updates/world/2012_04_28_01_world_reference_loot_template.sql
new file mode 100644
index 00000000000..e46c45e497a
--- /dev/null
+++ b/sql/updates/world/2012_04_28_01_world_reference_loot_template.sql
@@ -0,0 +1,22 @@
+SET @Triumph :=47241;
+-- Cleanup some unneeded references
+DELETE FROM `reference_loot_template` WHERE `entry` IN (34167,34168,34169);
+UPDATE `creature_loot_template` SET `mincountOrRef`=-34349 WHERE `mincountOrRef` IN (-34167,-34168,-34169);
+-- Fix this weird defined reference for ulduar
+UPDATE `reference_loot_template` SET `ChanceOrQuestChance`=100,`groupid`=0 WHERE `entry`=34349;
+-- Remove Emblem of Triumph from reference_loot
+DELETE FROM `reference_loot_template` WHERE `item`=@Triumph AND `entry`IN (12025,35034,35040,35049);
+-- Actual Emblem on creature as it should be
+DELETE FROM `creature_loot_template` WHERE `entry` IN (30397,30398,31365,31367,31656,31679) AND `item`=@Triumph;
+INSERT INTO `creature_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+(30397,@Triumph,100,1,0,1,1), -- Commander Kolurg (1)
+(30398,@Triumph,100,1,0,1,1), -- Commander Stoutbeard (1)
+(31365,@Triumph,100,1,0,1,1), -- Drakkari Colossus (1)
+(31367,@Triumph,100,1,0,1,1), -- Drakkari Elemental (1)
+(31656,@Triumph,100,1,0,1,1), -- Dalronn the Controller (1)
+(31679,@Triumph,100,1,0,1,1); -- Skarvald the Constructor (1)
+-- Similar action for gameobjects
+DELETE FROM `gameobject_loot_template` WHERE `entry` IN (27416,27417) AND `item`=@Triumph;
+INSERT INTO `gameobject_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) VALUES
+(27417,@Triumph,100,1,0,1,1), -- Confessor's Cache
+(27416,@Triumph,100,1,0,1,1); -- Eadric's Cache
diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h
index 98b0afdefc9..d097adf38ec 100755
--- a/src/server/game/AI/CreatureAIImpl.h
+++ b/src/server/game/AI/CreatureAIImpl.h
@@ -326,11 +326,15 @@ class EventMap : private std::map<uint32, uint32>
uint32 GetPhaseMask() const { return (_phase >> 24) & 0xFF; }
+ bool Empty() const { return empty(); }
+
// Sets event phase, must be in range 1 - 8
void SetPhase(uint32 phase)
{
if (phase && phase < 8)
_phase = (1 << (phase + 24));
+ else if (!phase)
+ _phase = 0;
}
// Creates new event entry in map with given id, time, group if given (1 - 8) and phase if given (1 - 8)
diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp
index 7a2b83273c9..835705a0d7c 100755
--- a/src/server/game/AI/EventAI/CreatureEventAI.cpp
+++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp
@@ -1107,7 +1107,7 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
break;
case EVENT_T_RANGE:
if (me->getVictim())
- if (me->IsInMap(me->getVictim()))
+ if (me->IsInMap(me->getVictim()) && me->InSamePhase(me->getVictim()))
if (me->IsInRange(me->getVictim(), (float)(*i).Event.range.minDist, (float)(*i).Event.range.maxDist))
ProcessEvent(*i);
break;
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 209eb38e13a..893c8f4580e 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -1119,12 +1119,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
{
- if (!IsUnit(*itr))
- continue;
-
(*itr)->GetPosition(x, y, z, o);
+ x += e.target.x;
+ y += e.target.y;
+ z += e.target.z;
+ o += e.target.o;
if (Creature* summon = GetBaseObject()->SummonCreature(e.action.summonCreature.creature, x, y, z, o, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration))
- if (unit && e.action.summonCreature.attackInvoker)
+ if (e.action.summonCreature.attackInvoker)
summon->AI()->AttackStart((*itr)->ToUnit());
}
@@ -1154,6 +1155,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
continue;
(*itr)->GetPosition(x, y, z, o);
+ x += e.target.x;
+ y += e.target.y;
+ z += e.target.z;
+ o += e.target.o;
GetBaseObject()->SummonGameObject(e.action.summonGO.entry, x, y, z, o, 0, 0, 0, 0, e.action.summonGO.despawnTime);
}
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp
index 8a11edf85e6..ccc6a2305b4 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp
@@ -86,11 +86,8 @@ void BattlegroundDS::PostUpdateImpl(uint32 diff)
setWaterFallTimer(BG_DS_WATERFALL_WARNING_DURATION);
setWaterFallStatus(BG_DS_WATERFALL_STATUS_WARNING);
}
- else if (getWaterFallStatus() == BG_DS_WATERFALL_STATUS_WARNING) // Active collision and perform knockback
+ else if (getWaterFallStatus() == BG_DS_WATERFALL_STATUS_WARNING) // Active collision and start knockback timer
{
- if (Creature* waterSpout = GetBgMap()->GetCreature(BgCreatures[BG_DS_NPC_WATERFALL_KNOCKBACK]))
- waterSpout->CastSpell(waterSpout, BG_DS_SPELL_WATER_SPOUT, true);
-
if (GameObject* gob = GetBgMap()->GetGameObject(BgObjects[BG_DS_OBJECT_WATER_1]))
gob->SetGoState(GO_STATE_READY);
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h
index 12ed91fc922..aaf08ba1313 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h
@@ -66,9 +66,9 @@ enum BattlegroundDSData
{ // These values are NOT blizzlike... need the correct data!
BG_DS_WATERFALL_TIMER_MIN = 30000,
BG_DS_WATERFALL_TIMER_MAX = 60000,
- BG_DS_WATERFALL_WARNING_DURATION = 7000,
- BG_DS_WATERFALL_DURATION = 10000,
- BG_DS_WATERFALL_KNOCKBACK_TIMER = 500,
+ BG_DS_WATERFALL_WARNING_DURATION = 5000,
+ BG_DS_WATERFALL_DURATION = 30000,
+ BG_DS_WATERFALL_KNOCKBACK_TIMER = 1500,
BG_DS_PIPE_KNOCKBACK_FIRST_DELAY = 5000,
BG_DS_PIPE_KNOCKBACK_DELAY = 3000,
@@ -118,7 +118,7 @@ class BattlegroundDS : public Battleground
void setWaterFallStatus(uint8 status) { _waterfallStatus = status; };
uint32 getWaterFallTimer() { return _waterfallTimer; };
void setWaterFallTimer(uint32 timer) { _waterfallTimer = timer; };
- uint32 getWaterFallKnockbackTimer() { return _waterfallTimer; };
+ uint32 getWaterFallKnockbackTimer() { return _waterfallKnockbackTimer; };
void setWaterFallKnockbackTimer(uint32 timer) { _waterfallKnockbackTimer = timer; };
uint8 getPipeKnockBackCount() { return _pipeKnockBackCount; };
void setPipeKnockBackCount(uint8 count) { _pipeKnockBackCount = count; };
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
index 6d784488aad..977897b8d48 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
@@ -534,16 +534,16 @@ void BattlegroundSA::EventPlayerDamagedGO(Player* /*player*/, GameObject* go, ui
if (eventType == go->GetGOInfo()->building.damagedEvent)
{
- uint32 i = GetGateIDFromDestroyEventID(eventType);
+ uint32 i = getGateIdFromDamagedOrDestroyEventId(eventType);
GateStatus[i] = BG_SA_GATE_DAMAGED;
- uint32 uws = GetWorldStateFromGateID(i);
+ uint32 uws = getWorldStateFromGateId(i);
if (uws)
UpdateWorldState(uws, GateStatus[i]);
}
if (eventType == go->GetGOInfo()->building.destroyedEvent)
{
- if (go->GetGOInfo()->building.destroyedEvent == 19837)
+ if (go->GetGOInfo()->building.destroyedEvent == BG_SA_EVENT_ANCIENT_GATE_DESTROYED)
SendWarningToAll(LANG_BG_SA_CHAMBER_BREACHED);
else
SendWarningToAll(LANG_BG_SA_WAS_DESTROYED, go->GetGOInfo()->name.c_str());
@@ -603,7 +603,7 @@ void BattlegroundSA::DemolisherStartState(bool start)
void BattlegroundSA::DestroyGate(Player* player, GameObject* go)
{
- uint32 i = GetGateIDFromDestroyEventID(go->GetGOInfo()->building.destroyedEvent);
+ uint32 i = getGateIdFromDamagedOrDestroyEventId(go->GetGOInfo()->building.destroyedEvent);
if (!GateStatus[i])
return;
@@ -612,7 +612,7 @@ void BattlegroundSA::DestroyGate(Player* player, GameObject* go)
if (g->GetGOValue()->Building.Health == 0)
{
GateStatus[i] = BG_SA_GATE_DESTROYED;
- uint32 uws = GetWorldStateFromGateID(i);
+ uint32 uws = getWorldStateFromGateId(i);
if (uws)
UpdateWorldState(uws, GateStatus[i]);
bool rewardHonor = true;
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h
index 76a772ff978..c18806490f2 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h
@@ -30,8 +30,8 @@ class BattlegroundSAScore : public BattlegroundScore
uint8 gates_destroyed;
};
-#define BG_SA_FLAG_AMOUNT 3
-#define BG_SA_DEMOLISHER_AMOUNT 4
+#define BG_SA_FLAG_AMOUNT 3
+#define BG_SA_DEMOLISHER_AMOUNT 4
enum BG_SA_Status
{
@@ -45,45 +45,66 @@ enum BG_SA_Status
enum BG_SA_GateState
{
- BG_SA_GATE_OK = 1,
- BG_SA_GATE_DAMAGED = 2,
- BG_SA_GATE_DESTROYED = 3
+ BG_SA_GATE_OK = 1,
+ BG_SA_GATE_DAMAGED = 2,
+ BG_SA_GATE_DESTROYED = 3
+};
+
+enum BG_SA_EventIdGate
+{
+ BG_SA_EVENT_BLUE_GATE_DAMAGED = 19040,
+ BG_SA_EVENT_BLUE_GATE_DESTROYED = 19045,
+
+ BG_SA_EVENT_GREEN_GATE_DAMAGED = 19041,
+ BG_SA_EVENT_GREEN_GATE_DESTROYED = 19046,
+
+ BG_SA_EVENT_RED_GATE_DAMAGED = 19042,
+ BG_SA_EVENT_RED_GATE_DESTROYED = 19047,
+
+ BG_SA_EVENT_PURPLE_GATE_DAMAGED = 19043,
+ BG_SA_EVENT_PURPLE_GATE_DESTROYED = 19048,
+
+ BG_SA_EVENT_YELLOW_GATE_DAMAGED = 19044,
+ BG_SA_EVENT_YELLOW_GATE_DESTROYED = 19049,
+
+ BG_SA_EVENT_ANCIENT_GATE_DAMAGED = 19836,
+ BG_SA_EVENT_ANCIENT_GATE_DESTROYED = 19837
};
enum BG_SA_Timers
{
- BG_SA_BOAT_START = 60*IN_MILLISECONDS,
- BG_SA_WARMUPLENGTH = 120*IN_MILLISECONDS,
- BG_SA_ROUNDLENGTH = 600*IN_MILLISECONDS
+ BG_SA_BOAT_START = 60 * IN_MILLISECONDS,
+ BG_SA_WARMUPLENGTH = 120 * IN_MILLISECONDS,
+ BG_SA_ROUNDLENGTH = 600 * IN_MILLISECONDS
};
enum BG_SA_WorldStates
{
- BG_SA_TIMER_MINS = 3559,
- BG_SA_TIMER_SEC_TENS = 3560,
- BG_SA_TIMER_SEC_DECS = 3561,
- BG_SA_ALLY_ATTACKS = 4352,
- BG_SA_HORDE_ATTACKS = 4353,
- BG_SA_PURPLE_GATEWS = 3614,
- BG_SA_RED_GATEWS = 3617,
- BG_SA_BLUE_GATEWS = 3620,
- BG_SA_GREEN_GATEWS = 3623,
- BG_SA_YELLOW_GATEWS = 3638,
- BG_SA_ANCIENT_GATEWS = 3849,
- BG_SA_LEFT_GY_ALLIANCE = 3635,
- BG_SA_RIGHT_GY_ALLIANCE = 3636,
- BG_SA_CENTER_GY_ALLIANCE = 3637,
- BG_SA_RIGHT_ATT_TOKEN_ALL = 3627,
- BG_SA_LEFT_ATT_TOKEN_ALL = 3626,
- BG_SA_LEFT_ATT_TOKEN_HRD = 3629,
- BG_SA_RIGHT_ATT_TOKEN_HRD = 3628,
- BG_SA_HORDE_DEFENCE_TOKEN = 3631,
- BG_SA_ALLIANCE_DEFENCE_TOKEN = 3630,
- BG_SA_RIGHT_GY_HORDE = 3632,
- BG_SA_LEFT_GY_HORDE = 3633,
- BG_SA_CENTER_GY_HORDE = 3634,
- BG_SA_BONUS_TIMER = 0xdf3,
- BG_SA_ENABLE_TIMER = 3564,
+ BG_SA_TIMER_MINS = 3559,
+ BG_SA_TIMER_SEC_TENS = 3560,
+ BG_SA_TIMER_SEC_DECS = 3561,
+ BG_SA_ALLY_ATTACKS = 4352,
+ BG_SA_HORDE_ATTACKS = 4353,
+ BG_SA_PURPLE_GATEWS = 3614,
+ BG_SA_RED_GATEWS = 3617,
+ BG_SA_BLUE_GATEWS = 3620,
+ BG_SA_GREEN_GATEWS = 3623,
+ BG_SA_YELLOW_GATEWS = 3638,
+ BG_SA_ANCIENT_GATEWS = 3849,
+ BG_SA_LEFT_GY_ALLIANCE = 3635,
+ BG_SA_RIGHT_GY_ALLIANCE = 3636,
+ BG_SA_CENTER_GY_ALLIANCE = 3637,
+ BG_SA_RIGHT_ATT_TOKEN_ALL = 3627,
+ BG_SA_LEFT_ATT_TOKEN_ALL = 3626,
+ BG_SA_LEFT_ATT_TOKEN_HRD = 3629,
+ BG_SA_RIGHT_ATT_TOKEN_HRD = 3628,
+ BG_SA_HORDE_DEFENCE_TOKEN = 3631,
+ BG_SA_ALLIANCE_DEFENCE_TOKEN = 3630,
+ BG_SA_RIGHT_GY_HORDE = 3632,
+ BG_SA_LEFT_GY_HORDE = 3633,
+ BG_SA_CENTER_GY_HORDE = 3634,
+ BG_SA_BONUS_TIMER = 0xdf3,
+ BG_SA_ENABLE_TIMER = 3564,
};
enum npc
@@ -122,14 +143,14 @@ enum BG_SA_NPCs
enum BG_SA_Boat
{
- BG_SA_BOAT_ONE_A =193182,
- BG_SA_BOAT_TWO_H =193183,
- BG_SA_BOAT_ONE_H =193184,
- BG_SA_BOAT_TWO_A =193185,
+ BG_SA_BOAT_ONE_A = 193182,
+ BG_SA_BOAT_TWO_H = 193183,
+ BG_SA_BOAT_ONE_H = 193184,
+ BG_SA_BOAT_TWO_A = 193185,
};
-const uint32 BG_SA_NpcEntries[BG_SA_MAXNPC] =
- {
+uint32 const BG_SA_NpcEntries[BG_SA_MAXNPC] =
+{
NPC_ANTI_PERSONNAL_CANNON,
NPC_ANTI_PERSONNAL_CANNON,
NPC_ANTI_PERSONNAL_CANNON,
@@ -140,25 +161,25 @@ const uint32 BG_SA_NpcEntries[BG_SA_MAXNPC] =
NPC_ANTI_PERSONNAL_CANNON,
NPC_ANTI_PERSONNAL_CANNON,
NPC_ANTI_PERSONNAL_CANNON,
- //4 beach demolishers
+ // 4 beach demolishers
NPC_DEMOLISHER_SA,
NPC_DEMOLISHER_SA,
NPC_DEMOLISHER_SA,
NPC_DEMOLISHER_SA,
- //Triggers
+ // Triggers
23472,
23472,
23472,
23472,
23472,
- //Used Demolisher Salesman
+ // Used Demolisher Salesman
NPC_RIGGER_SPARKLIGHT,
NPC_GORGRIL_RIGSPARK
- };
+};
-const float BG_SA_NpcSpawnlocs[BG_SA_MAXNPC + BG_SA_DEMOLISHER_AMOUNT][4] =
+float const BG_SA_NpcSpawnlocs[BG_SA_MAXNPC + BG_SA_DEMOLISHER_AMOUNT][4] =
{
- //Cannons
+ // Cannons
{ 1436.429f, 110.05f, 41.407f, 5.4f },
{ 1404.9023f, 84.758f, 41.183f, 5.46f },
{ 1068.693f, -86.951f, 93.81f, 0.02f },
@@ -169,21 +190,21 @@ const float BG_SA_NpcSpawnlocs[BG_SA_MAXNPC + BG_SA_DEMOLISHER_AMOUNT][4] =
{ 1249.634f, -224.189f, 66.72f, 0.635f },
{ 1236.213f, 92.287f, 64.965f, 5.751f },
{ 1215.11f, 57.772f, 64.739f, 5.78f },
- //Demolishers
+ // Demolishers
{ 1611.597656f, -117.270073f, 8.719355f, 2.513274f},
{ 1575.562500f, -158.421875f, 5.024450f, 2.129302f},
{ 1618.047729f, 61.424641f, 7.248210f, 3.979351f},
{ 1575.103149f, 98.873344f, 2.830360f, 3.752458f},
- //trigger
+ // Triggers
{ 1453.49f, -250.453f, 30.896f, 4.2883f},
{ 1377.05f, 97.036f, 30.8605f, 2.46539f},
{ 1186.05f, 58.8048f, 56.5491f, 2.75992f},
{ 1042.83f, -72.839f, 84.8145f, 3.58615f},
{ 1233.62f, -250.49f, 55.4036f, 3.7016f},
- //Npcs
+ // Npcs
{ 1348.644165f, -298.786469f, 31.080130f, 1.710423f},
{ 1358.191040f, 195.527786f, 31.018187f, 4.171337f},
- //Demolishers2
+ // Demolishers 2
{ 1371.055786f, -317.071136f, 35.007359f, 1.947460f},
{ 1424.034912f, -260.195190f, 31.084425f, 2.820013f},
{ 1353.139893f, 223.745438f, 35.265411f, 4.343684f},
@@ -221,7 +242,7 @@ enum BG_SA_Objects
BG_SA_MAXOBJ = BG_SA_BOMB+68
};
-const float BG_SA_ObjSpawnlocs[BG_SA_MAXOBJ][4] =
+float const BG_SA_ObjSpawnlocs[BG_SA_MAXOBJ][4] =
{
{ 1411.57f, 108.163f, 28.692f, 5.441f },
{ 1055.452f, -108.1f, 82.134f, 0.034f },
@@ -230,30 +251,30 @@ const float BG_SA_ObjSpawnlocs[BG_SA_MAXOBJ][4] =
{ 1214.681f, 81.21f, 53.413f, 5.745f },
{ 878.555f, -108.2f, 117.845f, 0.0f },
{ 836.5f, -108.8f, 120.219f, 0.0f },
- //Ships
+ // Ships
{ 2679.696777f, -826.891235f, 3.712860f, 5.78367f}, //rot2 1 rot3 0.0002f
{ 2574.003662f, 981.261475f, 2.603424f, 0.807696f},
- //Sigils
+ // Sigils
{ 1414.054f, 106.72f, 41.442f, 5.441f },
{ 1060.63f, -107.8f, 94.7f, 0.034f },
{ 1433.383f, -216.4f, 43.642f, 0.9736f },
{ 1230.75f, -210.724f, 67.611f, 0.5023f },
{ 1217.8f, 79.532f, 66.58f, 5.745f },
- //Flagpoles
+ // Flagpoles
{ 1215.114258f, -65.711861f, 70.084267f, -3.124123f},
{1338.863892f, -153.336533f, 30.895121f, -2.530723f},
{1309.124268f, 9.410645f, 30.893402f, -1.623156f},
- //Flags
+ // Flags
{ 1215.108032f, -65.715767f, 70.084267f, -3.124123f},
{ 1338.859253f, -153.327316f, 30.895077f, -2.530723f},
{ 1309.192017f, 9.416233f, 30.893402f, 1.518436f},
- //Portal
+ // Portal
{1468.380005f, -225.798996f, 30.896200f, 0.0f}, //blue
{1394.270020f, 72.551399f, 31.054300f, 0.0f}, //green
{1065.260010f, -89.79501f, 81.073402f, 0.0f}, //yellow
{1216.069946f, 47.904301f, 54.278198f, 0.0f}, //purple
{1255.569946f, -233.548996f, 56.43699f, 0.0f}, //red
- //Bombs
+ // Bombs
{1333.45f, 211.354f, 31.0538f, 5.03666f},
{1334.29f, 209.582f, 31.0532f, 1.28088f},
{1332.72f, 210.049f, 31.0532f, 1.28088f},
@@ -337,7 +358,7 @@ const float BG_SA_ObjSpawnlocs[BG_SA_MAXOBJ][4] =
* to get horde ones.
*/
-const uint32 BG_SA_ObjEntries[BG_SA_MAXOBJ + BG_SA_FLAG_AMOUNT] =
+uint32 const BG_SA_ObjEntries[BG_SA_MAXOBJ + BG_SA_FLAG_AMOUNT] =
{
190722,
190727,
@@ -367,7 +388,7 @@ const uint32 BG_SA_ObjEntries[BG_SA_MAXOBJ + BG_SA_FLAG_AMOUNT] =
190753
};
-const uint32 BG_SA_Factions[2] =
+uint32 const BG_SA_Factions[2] =
{
1732,
1735,
@@ -392,13 +413,13 @@ const uint32 BG_SA_GYEntries[BG_SA_MAX_GY] =
1348,
};
-const float BG_SA_GYOrientation[BG_SA_MAX_GY] =
+float const BG_SA_GYOrientation[BG_SA_MAX_GY] =
{
6.202f,
- 1.926f, //right capturable GY
- 3.917f, //left capturable GY
- 3.104f, //center, capturable
- 6.148f, //defender last GY
+ 1.926f, // right capturable GY
+ 3.917f, // left capturable GY
+ 3.104f, // center, capturable
+ 6.148f, // defender last GY
};
struct BG_SA_RoundScore
@@ -443,34 +464,60 @@ class BattlegroundSA : public Battleground
/// Called when a player use a gamobject (relic)
virtual void EventPlayerUsedGO(Player* Source, GameObject* object);
/// Return gate id, relative to bg data, according to gameobject id
- uint32 GetGateIDFromDestroyEventID(uint32 id)
+ uint32 getGateIdFromDamagedOrDestroyEventId(uint32 id)
{
- uint32 i = 0;
switch (id)
{
- case 19046: i = BG_SA_GREEN_GATE; break; //Green gate destroyed
- case 19045: i = BG_SA_BLUE_GATE; break; //blue gate
- case 19047: i = BG_SA_RED_GATE; break; //red gate
- case 19048: i = BG_SA_PURPLE_GATE; break; //purple gate
- case 19049: i = BG_SA_YELLOW_GATE; break; //yellow gate
- case 19837: i = BG_SA_ANCIENT_GATE; break; //ancient gate
+ // Green gate
+ case BG_SA_EVENT_GREEN_GATE_DAMAGED:
+ case BG_SA_EVENT_GREEN_GATE_DESTROYED:
+ return BG_SA_GREEN_GATE;
+ // Blue gate
+ case BG_SA_EVENT_BLUE_GATE_DAMAGED:
+ case BG_SA_EVENT_BLUE_GATE_DESTROYED:
+ return BG_SA_BLUE_GATE;
+ // Red gate
+ case BG_SA_EVENT_RED_GATE_DAMAGED:
+ case BG_SA_EVENT_RED_GATE_DESTROYED:
+ return BG_SA_RED_GATE;
+ // Purple gate
+ case BG_SA_EVENT_PURPLE_GATE_DAMAGED:
+ case BG_SA_EVENT_PURPLE_GATE_DESTROYED:
+ return BG_SA_PURPLE_GATE;
+ // Yellow gate
+ case BG_SA_EVENT_YELLOW_GATE_DAMAGED:
+ case BG_SA_EVENT_YELLOW_GATE_DESTROYED:
+ return BG_SA_YELLOW_GATE;
+ // Ancient gate
+ case BG_SA_EVENT_ANCIENT_GATE_DAMAGED:
+ case BG_SA_EVENT_ANCIENT_GATE_DESTROYED:
+ return BG_SA_ANCIENT_GATE;
+ default:
+ break;
}
- return i;
+ return 0;
}
/// Return worldstate id, according to door id
- uint32 GetWorldStateFromGateID(uint32 id)
+ uint32 getWorldStateFromGateId(uint32 id)
{
- uint32 uws = 0;
switch (id)
{
- case BG_SA_GREEN_GATE: uws = BG_SA_GREEN_GATEWS; break;
- case BG_SA_YELLOW_GATE: uws = BG_SA_YELLOW_GATEWS; break;
- case BG_SA_BLUE_GATE: uws = BG_SA_BLUE_GATEWS; break;
- case BG_SA_RED_GATE: uws = BG_SA_RED_GATEWS; break;
- case BG_SA_PURPLE_GATE: uws = BG_SA_PURPLE_GATEWS; break;
- case BG_SA_ANCIENT_GATE: uws = BG_SA_ANCIENT_GATEWS; break;
+ case BG_SA_GREEN_GATE:
+ return BG_SA_GREEN_GATEWS;
+ case BG_SA_YELLOW_GATE:
+ return BG_SA_YELLOW_GATEWS;
+ case BG_SA_BLUE_GATE:
+ return BG_SA_BLUE_GATEWS;
+ case BG_SA_RED_GATE:
+ return BG_SA_RED_GATEWS;
+ case BG_SA_PURPLE_GATE:
+ return BG_SA_PURPLE_GATEWS;
+ case BG_SA_ANCIENT_GATE:
+ return BG_SA_ANCIENT_GATEWS;
+ default:
+ break;
}
- return uws;
+ return 0;
}
/// Called on battleground ending
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
index 495178f18dd..d100dc645a2 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
@@ -476,7 +476,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
}
//Alliance flag on ground(not in base) (returned or picked up again from ground!)
- if (GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) && BgObjects[BG_WS_OBJECT_A_FLAG] == target_obj->GetGUID())
+ if (GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) && target_obj->GetGOInfo()->entry == BG_OBJECT_A_FLAG_GROUND_WS_ENTRY)
{
if (Source->GetTeam() == ALLIANCE)
{
@@ -510,7 +510,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
}
//Horde flag on ground(not in base) (returned or picked up again)
- if (GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) && BgObjects[BG_WS_OBJECT_H_FLAG] == target_obj->GetGUID())
+ if (GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) && target_obj->GetGOInfo()->entry == BG_OBJECT_H_FLAG_GROUND_WS_ENTRY)
{
if (Source->GetTeam() == HORDE)
{
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index 042f16be3cc..cc64a8e22dd 100755
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -359,7 +359,6 @@ ChatCommand* ChatHandler::getCommandTable()
{ "summon", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleSummonCommand>, "", NULL },
{ "groupsummon", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGroupSummonCommand>, "", NULL },
{ "commands", SEC_PLAYER, true, OldHandler<&ChatHandler::HandleCommandsCommand>, "", NULL },
- { "demorph", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleDeMorphCommand>, "", NULL },
{ "die", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDieCommand>, "", NULL },
{ "revive", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReviveCommand>, "", NULL },
{ "dismount", SEC_PLAYER, false, OldHandler<&ChatHandler::HandleDismountCommand>, "", NULL },
diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp
index cc638193b5a..52bdcd15163 100755
--- a/src/server/game/Chat/Commands/Level2.cpp
+++ b/src/server/game/Chat/Commands/Level2.cpp
@@ -205,22 +205,6 @@ bool ChatHandler::HandleItemMoveCommand(const char* args)
return true;
}
-//demorph player or unit
-bool ChatHandler::HandleDeMorphCommand(const char* /*args*/)
-{
- Unit* target = getSelectedUnit();
- if (!target)
- target = m_session->GetPlayer();
-
- // check online security
- else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target, 0))
- return false;
-
- target->DeMorph();
-
- return true;
-}
-
//kick player
bool ChatHandler::HandleKickPlayerCommand(const char *args)
{
diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp
index d82e43ba83b..e604eaf9024 100755
--- a/src/server/game/Combat/ThreatManager.cpp
+++ b/src/server/game/Combat/ThreatManager.cpp
@@ -75,7 +75,7 @@ bool ThreatCalcHelper::isValidProcess(Unit* hatedUnit, Unit* hatingUnit, SpellIn
return false;
// not in same map or phase
- if (!hatedUnit->IsInMap(hatingUnit))
+ if (!hatedUnit->IsInMap(hatingUnit) || !hatedUnit->InSamePhase(hatingUnit))
return false;
// spell not causing threat
@@ -182,6 +182,7 @@ void HostileReference::updateOnlineStatus()
&& (getTarget()->GetTypeId() != TYPEID_PLAYER || !getTarget()->ToPlayer()->isGameMaster())
&& !getTarget()->HasUnitState(UNIT_STATE_IN_FLIGHT)
&& getTarget()->IsInMap(getSourceUnit())
+ && getTarget()->InSamePhase(getSourceUnit())
)
{
Creature* creature = getSourceUnit()->ToCreature();
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 6a8ae07291a..fde85feb8d9 100755
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -135,7 +135,7 @@ CreatureBaseStats const* CreatureBaseStats::GetBaseStats(uint8 level, uint8 unit
bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
- m_owner.ForcedDespawn();
+ m_owner.DespawnOrUnsummon(); // since we are here, we are not TempSummon as object type cannot change during runtime
return true;
}
@@ -357,8 +357,9 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData* data)
m_regenHealth = cInfo->RegenHealth;
- // creatures always have melee weapon ready if any
- SetSheath(SHEATH_STATE_MELEE);
+ // creatures always have melee weapon ready if any unless specified otherwise
+ if (!GetCreatureAddon())
+ SetSheath(SHEATH_STATE_MELEE);
SelectLevel(GetCreatureTemplate());
if (team == HORDE)
@@ -795,10 +796,12 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry,
//! Need to be called after LoadCreaturesAddon - MOVEMENTFLAG_HOVER is set there
if (HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
+ {
z += GetFloatValue(UNIT_FIELD_HOVERHEIGHT);
- //! Relocate again with updated Z coord
- Relocate(x, y, z, ang);
+ //! Relocate again with updated Z coord
+ Relocate(x, y, z, ang);
+ }
uint32 displayID = GetNativeDisplayId();
CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID);
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 4b5b07fd8a5..f6021a7d7ec 100755
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -507,7 +507,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
if (isPet())
return false;
- return GetCreatureTemplate()->rank == CREATURE_ELITE_WORLDBOSS;
+ return GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_BOSS;
}
bool IsDungeonBoss() const;
@@ -635,7 +635,6 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
void RemoveCorpse(bool setSpawnTime = true);
- void ForcedDespawn(uint32 timeMSToDespawn = 0);
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0);
time_t const& GetRespawnTime() const { return m_respawnTime; }
@@ -763,6 +762,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
bool IsInvisibleDueToDespawn() const;
bool CanAlwaysSee(WorldObject const* obj) const;
private:
+ void ForcedDespawn(uint32 timeMSToDespawn = 0);
+
//WaypointMovementGenerator vars
uint32 m_waypointID;
uint32 m_path_id;
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index d96c9052b7a..f58dd6b2e4d 100755
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -1825,6 +1825,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
m_goValue->Building.Health = m_goValue->Building.MaxHealth;
SetGoAnimProgress(255);
}
+ EnableCollision(true);
break;
case GO_DESTRUCTIBLE_DAMAGED:
{
@@ -1881,6 +1882,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
m_goValue->Building.Health = 0;
SetGoAnimProgress(0);
}
+ EnableCollision(false);
break;
}
case GO_DESTRUCTIBLE_REBUILDING:
@@ -1900,6 +1902,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
m_goValue->Building.Health = m_goValue->Building.MaxHealth;
SetGoAnimProgress(255);
}
+ EnableCollision(true);
break;
}
}
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index 39be4d4f529..3693f683b24 100755
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -685,7 +685,7 @@ class WorldObject : public Object, public WorldLocation
bool IsInMap(const WorldObject* obj) const
{
if (obj)
- return IsInWorld() && obj->IsInWorld() && (GetMap() == obj->GetMap()) && InSamePhase(obj);
+ return IsInWorld() && obj->IsInWorld() && (GetMap() == obj->GetMap());
return false;
}
bool IsWithinDist3d(float x, float y, float z, float dist) const
@@ -703,7 +703,7 @@ class WorldObject : public Object, public WorldLocation
}
bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true) const
{
- return obj && IsInMap(obj) && _IsWithinDist(obj, dist2compare, is3D);
+ return obj && IsInMap(obj) && InSamePhase(obj) && _IsWithinDist(obj, dist2compare, is3D);
}
bool IsWithinLOS(float x, float y, float z) const;
bool IsWithinLOSInMap(const WorldObject* obj) const;
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 141902fbbdc..7c70fe9358e 100755
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -9217,6 +9217,9 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid)
case 4100: // The Culling of Stratholme
NumberOfFields = 13;
break;
+ case 4273: // Ulduar
+ NumberOfFields = 10;
+ break;
default:
NumberOfFields = 12;
break;
@@ -9761,6 +9764,16 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid)
data << uint32(3932) << uint32(0); // 13 WORLDSTATE_TIME_GUARDIAN_SHOW
}
break;
+ // Ulduar
+ case 4273:
+ if (instance && mapid == 603)
+ instance->FillInitialWorldStates(data);
+ else
+ {
+ data << uint32(4132) << uint32(0); // 9 WORLDSTATE_SHOW_CRATES
+ data << uint32(4131) << uint32(0); // 10 WORLDSTATE_CRATES_REVEALED
+ }
+ break;
default:
data << uint32(0x914) << uint32(0x0); // 7
data << uint32(0x913) << uint32(0x0); // 8
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index da23a7ba010..fb91c3fc9f1 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -460,7 +460,7 @@ void Unit::resetAttackTimer(WeaponAttackType type)
bool Unit::IsWithinCombatRange(const Unit* obj, float dist2compare) const
{
- if (!obj || !IsInMap(obj))
+ if (!obj || !IsInMap(obj) || !InSamePhase(obj))
return false;
float dx = GetPositionX() - obj->GetPositionX();
@@ -476,7 +476,7 @@ bool Unit::IsWithinCombatRange(const Unit* obj, float dist2compare) const
bool Unit::IsWithinMeleeRange(const Unit* obj, float dist) const
{
- if (!obj || !IsInMap(obj))
+ if (!obj || !IsInMap(obj) || !InSamePhase(obj))
return false;
float dx = GetPositionX() - obj->GetPositionX();
diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp
index 4ce05ff40d3..c297ce1e792 100755
--- a/src/server/game/Entities/Vehicle/Vehicle.cpp
+++ b/src/server/game/Entities/Vehicle/Vehicle.cpp
@@ -285,9 +285,6 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 typ
// return; // Something went wrong in the spellsystem
//}
- // This is not good, we have to send update twice
- accessory->SendMovementFlagUpdate();
-
if (GetBase()->GetTypeId() == TYPEID_UNIT)
sScriptMgr->OnInstallAccessory(this, accessory);
}
@@ -352,6 +349,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
unit->m_movementInfo.t_pos.m_orientation = 0;
unit->m_movementInfo.t_time = 0; // 1 for player
unit->m_movementInfo.t_seat = seat->first;
+ unit->m_movementInfo.t_guid = _me->GetGUID();
if (_me->GetTypeId() == TYPEID_UNIT
&& unit->GetTypeId() == TYPEID_PLAYER
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h
index ec79db769da..e81822e72be 100755
--- a/src/server/game/Grids/Notifiers/GridNotifiers.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.h
@@ -1287,7 +1287,7 @@ namespace Trinity
AllWorldObjectsInRange(const WorldObject* object, float maxRange) : m_pObject(object), m_fRange(maxRange) {}
bool operator() (WorldObject* go)
{
- return m_pObject->IsWithinDist(go, m_fRange, false);
+ return m_pObject->IsWithinDist(go, m_fRange, false) && m_pObject->InSamePhase(go);
}
private:
const WorldObject* m_pObject;
diff --git a/src/server/game/Grids/Notifiers/GridNotifiersImpl.h b/src/server/game/Grids/Notifiers/GridNotifiersImpl.h
index 40b3863679b..e3cda4dd76d 100755
--- a/src/server/game/Grids/Notifiers/GridNotifiersImpl.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiersImpl.h
@@ -251,9 +251,8 @@ void Trinity::WorldObjectListSearcher<Check>::Visit(PlayerMapType &m)
return;
for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
- if (itr->getSource()->InSamePhase(i_phaseMask))
- if (i_check(itr->getSource()))
- i_objects.push_back(itr->getSource());
+ if (i_check(itr->getSource()))
+ i_objects.push_back(itr->getSource());
}
template<class Check>
@@ -263,9 +262,8 @@ void Trinity::WorldObjectListSearcher<Check>::Visit(CreatureMapType &m)
return;
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
- if (itr->getSource()->InSamePhase(i_phaseMask))
- if (i_check(itr->getSource()))
- i_objects.push_back(itr->getSource());
+ if (i_check(itr->getSource()))
+ i_objects.push_back(itr->getSource());
}
template<class Check>
@@ -275,9 +273,8 @@ void Trinity::WorldObjectListSearcher<Check>::Visit(CorpseMapType &m)
return;
for (CorpseMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
- if (itr->getSource()->InSamePhase(i_phaseMask))
- if (i_check(itr->getSource()))
- i_objects.push_back(itr->getSource());
+ if (i_check(itr->getSource()))
+ i_objects.push_back(itr->getSource());
}
template<class Check>
@@ -287,9 +284,8 @@ void Trinity::WorldObjectListSearcher<Check>::Visit(GameObjectMapType &m)
return;
for (GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
- if (itr->getSource()->InSamePhase(i_phaseMask))
- if (i_check(itr->getSource()))
- i_objects.push_back(itr->getSource());
+ if (i_check(itr->getSource()))
+ i_objects.push_back(itr->getSource());
}
template<class Check>
@@ -299,9 +295,8 @@ void Trinity::WorldObjectListSearcher<Check>::Visit(DynamicObjectMapType &m)
return;
for (DynamicObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
- if (itr->getSource()->InSamePhase(i_phaseMask))
- if (i_check(itr->getSource()))
- i_objects.push_back(itr->getSource());
+ if (i_check(itr->getSource()))
+ i_objects.push_back(itr->getSource());
}
// Gameobject searchers
diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp
index f1217e58b3f..b3d663e1850 100755
--- a/src/server/game/Handlers/MovementHandler.cpp
+++ b/src/server/game/Handlers/MovementHandler.cpp
@@ -46,7 +46,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
GetPlayer()->SetSemaphoreTeleportFar(false);
// get the teleport destination
- WorldLocation &loc = GetPlayer()->GetTeleportDest();
+ WorldLocation const loc = GetPlayer()->GetTeleportDest();
// possible errors in the coordinate validity check
if (!MapManager::IsValidMapCoord(loc))
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h
index 766e3d23f93..6ba08646f25 100755
--- a/src/server/game/Maps/Map.h
+++ b/src/server/game/Maps/Map.h
@@ -228,7 +228,7 @@ enum LevelRequirementVsMode
#define MAX_HEIGHT 100000.0f // can be use for find ground height at surface
#define INVALID_HEIGHT -100000.0f // for check, must be equal to VMAP_INVALID_HEIGHT, real value for unknown height is VMAP_INVALID_HEIGHT_VALUE
#define MAX_FALL_DISTANCE 250000.0f // "unlimited fall" to find VMap ground if it is available, just larger than MAX_HEIGHT - INVALID_HEIGHT
-#define DEFAULT_HEIGHT_SEARCH 10.0f // default search distance to find height at nearby locations
+#define DEFAULT_HEIGHT_SEARCH 50.0f // default search distance to find height at nearby locations
#define MIN_UNLOAD_DELAY 1 // immediate unload
typedef std::map<uint32/*leaderDBGUID*/, CreatureGroup*> CreatureGroupHolderType;
diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h
index 0386e6b4214..06aca10879d 100755
--- a/src/server/game/Miscellaneous/SharedDefines.h
+++ b/src/server/game/Miscellaneous/SharedDefines.h
@@ -2566,7 +2566,7 @@ enum CreatureTypeFlags
{
CREATURE_TYPEFLAGS_TAMEABLE = 0x00000001, // Tameable by any hunter
CREATURE_TYPEFLAGS_GHOST = 0x00000002, // Creature are also visible for not alive player. Allow gossip interaction if npcflag allow?
- CREATURE_TYPEFLAGS_UNK2 = 0x00000004,
+ CREATURE_TYPEFLAGS_BOSS = 0x00000004,
CREATURE_TYPEFLAGS_UNK3 = 0x00000008,
CREATURE_TYPEFLAGS_UNK4 = 0x00000010,
CREATURE_TYPEFLAGS_UNK5 = 0x00000020,
diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp
index 76c3f1c073c..f64d0953e86 100755
--- a/src/server/game/Scripting/ScriptLoader.cpp
+++ b/src/server/game/Scripting/ScriptLoader.cpp
@@ -61,7 +61,6 @@ void AddSC_reload_commandscript();
void AddSC_tele_commandscript();
void AddSC_titles_commandscript();
void AddSC_wp_commandscript();
-void AddSC_gps_commandscript();
#ifdef SCRIPTS
//world
@@ -425,6 +424,7 @@ void AddSC_ulduar_teleporter();
void AddSC_boss_mimiron();
void AddSC_boss_hodir();
void AddSC_boss_freya();
+void AddSC_boss_algalon_the_observer();
void AddSC_instance_ulduar();
void AddSC_boss_keleseth(); //Utgarde Keep
void AddSC_boss_skarvald_dalronn();
@@ -663,7 +663,6 @@ void AddCommandScripts()
AddSC_tele_commandscript();
AddSC_titles_commandscript();
AddSC_wp_commandscript();
- AddSC_gps_commandscript();
}
void AddWorldScripts()
@@ -1129,6 +1128,7 @@ void AddNorthrendScripts()
AddSC_boss_mimiron();
AddSC_boss_hodir();
AddSC_boss_freya();
+ AddSC_boss_algalon_the_observer();
AddSC_instance_ulduar();
AddSC_boss_keleseth(); //Utgarde Keep
AddSC_boss_skarvald_dalronn();
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index dbbd89c7533..31a8e57825c 100755
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -1616,7 +1616,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
{
// Use the new aura to see on what stance the target will be
uint32 newStance = (1<<((newAura ? newAura->GetMiscValue() : 0)-1));
-
+
// If the stances are not compatible with the spell, remove it
if (itr->second->GetBase()->IsRemovedOnShapeLost(target) && !(itr->second->GetBase()->GetSpellInfo()->Stances & newStance))
target->RemoveAura(itr);
@@ -6473,7 +6473,7 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
// damage caster for heal amount
if (target != caster && GetSpellInfo()->AttributesEx2 & SPELL_ATTR2_HEALTH_FUNNEL)
{
- uint32 funnelDamage = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); // damage is not affected by spell power
+ uint32 funnelDamage = GetSpellInfo()->ManaPerSecond; // damage is not affected by spell power
if ((int32)funnelDamage > gain)
funnelDamage = gain;
uint32 funnelAbsorb = 0;
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index df2b9c35320..f055d669925 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -3107,13 +3107,13 @@ void Spell::cast(bool skipCheck)
// should be done before the spell is actually executed
sScriptMgr->OnPlayerSpellCast(playerCaster, this, skipCheck);
- // Let any pets know we've attacked something. As of 3.0.2 pets begin
- // attacking their owner's target immediately
- if (Pet* playerPet = playerCaster->GetPet())
- {
- if (playerPet->isAlive() && playerPet->isControlled() && (m_targets.GetTargetMask() & TARGET_FLAG_UNIT))
- playerPet->AI()->OwnerAttacked(m_targets.GetObjectTarget()->ToUnit());
- }
+ // As of 3.0.2 pets begin attacking their owner's target immediately
+ // Let any pets know we've attacked something. Check DmgClass for harmful spells only
+ // This prevents spells such as Hunter's Mark from triggering pet attack
+ if (this->GetSpellInfo()->DmgClass != SPELL_DAMAGE_CLASS_NONE)
+ if (Pet* playerPet = playerCaster->GetPet())
+ if (playerPet->isAlive() && playerPet->isControlled() && (m_targets.GetTargetMask() & TARGET_FLAG_UNIT))
+ playerPet->AI()->OwnerAttacked(m_targets.GetObjectTarget()->ToUnit());
}
SetExecutedCurrently(true);
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 5078391348f..d3566c24a48 100755
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -390,23 +390,6 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
if (!unitTarget->HasAura(27825))
return;
break;
- // Cataclysmic Bolt
- case 38441:
- {
- damage = unitTarget->CountPctFromMaxHealth(50);
- break;
- }
- case 20625: // Ritual of Doom Sacrifice
- case 29142: // Eyesore Blaster
- case 35139: // Throw Boom's Doom
- case 42393: // Brewfest - Attack Keg
- case 55269: // Deathly Stare
- case 56578: // Rapid-Fire Harpoon
- case 62775: // Tympanic Tantrum
- {
- damage = unitTarget->CountPctFromMaxHealth(damage);
- break;
- }
// Gargoyle Strike
case 51963:
{
@@ -666,19 +649,19 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
if (found)
damage += m_spellInfo->Effects[EFFECT_1].CalcValue();
- if (m_caster->GetTypeId() == TYPEID_PLAYER)
+ if (Player* caster = m_caster->ToPlayer())
{
// Add Ammo and Weapon damage plus RAP * 0.1
- Item* item = m_caster->ToPlayer()->GetWeaponForAttack(RANGED_ATTACK);
- if (item)
+ if (Item* item = caster->GetWeaponForAttack(RANGED_ATTACK))
{
- float dmg_min = item->GetTemplate()->Damage->DamageMin;
- float dmg_max = item->GetTemplate()->Damage->DamageMax;
+ ItemTemplate const* weaponTemplate = item->GetTemplate();
+ float dmg_min = weaponTemplate->Damage[0].DamageMin;
+ float dmg_max = weaponTemplate->Damage[0].DamageMax;
if (dmg_max == 0.0f && dmg_min > dmg_max)
damage += int32(dmg_min);
else
damage += irand(int32(dmg_min), int32(dmg_max));
- damage += int32(m_caster->ToPlayer()->GetAmmoDPS()*item->GetTemplate()->Delay*0.001f);
+ damage += int32(caster->GetAmmoDPS() * weaponTemplate->Delay * 0.001f);
}
}
}
@@ -1102,10 +1085,6 @@ void Spell::EffectForceCast(SpellEffIndex effIndex)
case 52349: // Overtake
unitTarget->CastCustomSpell(unitTarget, spellInfo->Id, &damage, NULL, NULL, true, NULL, NULL, m_originalCasterGUID);
return;
- case 72378: // Blood Nova
- case 73058: // Blood Nova
- m_caster->CastSpell(unitTarget, damage, true); // additional spell cast
- break;
}
}
@@ -5727,9 +5706,9 @@ void Spell::EffectSummonDeadPet(SpellEffIndex /*effIndex*/)
}
if (!pet)
return;
-
+
player->GetMap()->CreatureRelocation(pet, x, y, z, player->GetOrientation());
-
+
pet->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE);
pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
pet->setDeathState(ALIVE);
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index 05431ef0a16..64e1527b8d3 100755
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -3298,6 +3298,19 @@ void SpellMgr::LoadDbcDataCorrections()
spellInfo->EffectImplicitTargetB[1] = TARGET_UNIT_NEARBY_ENTRY;
spellInfo->EffectImplicitTargetB[2] = TARGET_UNIT_NEARBY_ENTRY;
break;
+ case 62301: // Cosmic Smash (Algalon the Observer)
+ spellInfo->MaxAffectedTargets = 1;
+ break;
+ case 64598: // Cosmic Smash (Algalon the Observer)
+ spellInfo->MaxAffectedTargets = 3;
+ break;
+ case 62293: // Cosmic Smash (Algalon the Observer)
+ spellInfo->EffectImplicitTargetB[0] = TARGET_DEST_CASTER;
+ break;
+ case 62311: // Cosmic Smash (Algalon the Observer)
+ case 64596: // Cosmic Smash (Algalon the Observer)
+ spellInfo->rangeIndex = 6; // 100yd
+ break;
// ENDOF ULDUAR SPELLS
//
// TRIAL OF THE CRUSADER SPELLS
@@ -3333,13 +3346,22 @@ void SpellMgr::LoadDbcDataCorrections()
case 70835: // Bone Storm (Lord Marrowgar)
case 70836: // Bone Storm (Lord Marrowgar)
case 72864: // Death Plague (Rotting Frost Giant)
- case 72378: // Blood Nova (Deathbringer Saurfang)
- case 73058: // Blood Nova (Deathbringer Saurfang)
case 71160: // Plague Stench (Stinky)
case 71161: // Plague Stench (Stinky)
case 71123: // Decimate (Stinky & Precious)
spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_100_YARDS; // 100yd
break;
+ case 72378: // Blood Nova (Deathbringer Saurfang)
+ case 73058: // Blood Nova (Deathbringer Saurfang)
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS;
+ spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_200_YARDS;
+ break;
+ case 72769: // Scent of Blood (Deathbringer Saurfang)
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS;
+ // no break
+ case 72771: // Scent of Blood (Deathbringer Saurfang)
+ spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_200_YARDS;
+ break;
case 72723: // Resistant Skin (Deathbringer Saurfang adds)
// this spell initially granted Shadow damage immunity, however it was removed but the data was left in client
spellInfo->Effect[2] = 0;
diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp
index df1640df1b7..44a2dd4dedb 100755
--- a/src/server/game/Spells/SpellScript.cpp
+++ b/src/server/game/Spells/SpellScript.cpp
@@ -403,7 +403,7 @@ GameObject* SpellScript::GetHitGObj()
return m_spell->gameObjTarget;
}
-WorldLocation const* SpellScript::GetHitDest()
+WorldLocation* SpellScript::GetHitDest()
{
if (!IsInEffectHook())
{
diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h
index e84a56c8dbb..26393040a1e 100755
--- a/src/server/game/Spells/SpellScript.h
+++ b/src/server/game/Spells/SpellScript.h
@@ -325,7 +325,7 @@ class SpellScript : public _SpellScript
// returns: target of current effect if it was GameObject otherwise NULL
GameObject* GetHitGObj();
// returns: destination of current effect
- WorldLocation const* GetHitDest();
+ WorldLocation* GetHitDest();
// setter/getter for for damage done by spell to target of spell hit
// returns damage calculated before hit, and real dmg done after hit
int32 GetHitDamage();
diff --git a/src/server/scripts/CMakeLists.txt b/src/server/scripts/CMakeLists.txt
index f0136b065e8..792fdeb3e7b 100644
--- a/src/server/scripts/CMakeLists.txt
+++ b/src/server/scripts/CMakeLists.txt
@@ -119,6 +119,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/server/game/Maps
${CMAKE_SOURCE_DIR}/src/server/game/Movement
${CMAKE_SOURCE_DIR}/src/server/game/Movement/MovementGenerators
+ ${CMAKE_SOURCE_DIR}/src/server/game/Movement/Spline
${CMAKE_SOURCE_DIR}/src/server/game/Movement/Waypoints
${CMAKE_SOURCE_DIR}/src/server/game/Opcodes
${CMAKE_SOURCE_DIR}/src/server/game/OutdoorPvP
diff --git a/src/server/scripts/Commands/CMakeLists.txt b/src/server/scripts/Commands/CMakeLists.txt
index d14e71aac4a..86fe984e197 100644
--- a/src/server/scripts/Commands/CMakeLists.txt
+++ b/src/server/scripts/Commands/CMakeLists.txt
@@ -17,7 +17,6 @@ set(scripts_STAT_SRCS
Commands/cs_gm.cpp
Commands/cs_go.cpp
Commands/cs_gobject.cpp
- Commands/cs_gps.cpp
Commands/cs_honor.cpp
Commands/cs_learn.cpp
Commands/cs_misc.cpp
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index 679bb450800..c7bcde01e9b 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -95,6 +95,7 @@ public:
static ChatCommand commandTable[] =
{
{ "debug", SEC_MODERATOR, true, NULL, "", debugCommandTable },
+ { "wpgps", SEC_ADMINISTRATOR, false, &HandleWPGPSCommand, "", NULL },
{ NULL, SEC_PLAYER, false, NULL, "", NULL }
};
return commandTable;
@@ -1319,6 +1320,16 @@ public:
return true;
}
+
+ static bool HandleWPGPSCommand(ChatHandler* handler, char const* /*args*/)
+ {
+ Player* player = handler->GetSession()->GetPlayer();
+
+ sLog->outSQLDev("(@PATH, XX, %.3f, %.3f, %.5f, 0,0, 0,100, 0),", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
+
+ handler->PSendSysMessage("Waypoint SQL written to SQL Developer log");
+ return true;
+ }
};
void AddSC_debug_commandscript()
diff --git a/src/server/scripts/Commands/cs_gps.cpp b/src/server/scripts/Commands/cs_gps.cpp
deleted file mode 100644
index 59e2ec90905..00000000000
--- a/src/server/scripts/Commands/cs_gps.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* ScriptData
-Name: gps_commandscript
-%Complete: 100
-Comment: GPS/WPGPS commands
-Category: commandscripts
-EndScriptData */
-
-#include "ObjectAccessor.h"
-#include "ScriptMgr.h"
-#include "Chat.h"
-#include "CellImpl.h"
-
-class gps_commandscript : public CommandScript
-{
-public:
- gps_commandscript() : CommandScript("gps_commandscript") { }
-
- ChatCommand* GetCommands() const
- {
- static ChatCommand commandTable[] =
- {
- { "gps", SEC_ADMINISTRATOR, false, &HandleGPSCommand, "", NULL },
- { "wpgps", SEC_ADMINISTRATOR, false, &HandleWPGPSCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
- };
- return commandTable;
- }
-
- static bool HandleGPSCommand(ChatHandler* handler, char const* args)
- {
- WorldObject* object = NULL;
- if (*args)
- {
- uint64 guid = handler->extractGuidFromLink((char*)args);
- if (guid)
- object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT);
-
- if (!object)
- {
- handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
- handler->SetSentErrorMessage(true);
- return false;
- }
- }
- else
- {
- object = handler->getSelectedUnit();
-
- if (!object)
- {
- handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
- }
-
- CellCoord cellCoord = Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY());
- Cell cell(cellCoord);
-
- uint32 zoneId, areaId;
- object->GetZoneAndAreaId(zoneId, areaId);
-
- MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId());
- AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zoneId);
- AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId);
-
- float zoneX = object->GetPositionX();
- float zoneY = object->GetPositionY();
-
- Map2ZoneCoordinates(zoneX, zoneY, zoneId);
-
- Map const* map = object->GetMap();
- float groundZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), MAX_HEIGHT);
- float floorZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ());
-
- GridCoord gridCoord = Trinity::ComputeGridCoord(object->GetPositionX(), object->GetPositionY());
-
- // 63? WHY?
- int gridX = 63 - gridCoord.x_coord;
- int gridY = 63 - gridCoord.y_coord;
-
- uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
- uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
-
- if (haveVMap)
- {
- if (map->IsOutdoors(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ()))
- handler->PSendSysMessage("You are outdoors");
- else
- handler->PSendSysMessage("You are indoors");
- }
- else
- handler->PSendSysMessage("no VMAP available for area info");
-
- handler->PSendSysMessage(LANG_MAP_POSITION,
- object->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"),
- zoneId, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
- areaId, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
- object->GetPhaseMask(),
- object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(),
- cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(),
- zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap);
-
- LiquidData liquidStatus;
- ZLiquidStatus status = map->getLiquidStatus(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus);
-
- if (status)
- handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidStatus.level, liquidStatus.depth_level, liquidStatus.entry, liquidStatus.type_flags, status);
-
- return true;
- }
-
- static bool HandleWPGPSCommand(ChatHandler* handler, char const* /*args*/)
- {
- Player* player = handler->GetSession()->GetPlayer();
-
- sLog->outSQLDev("(@PATH, XX, %.3f, %.3f, %.5f, 0,0, 0,100, 0),", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
-
- handler->PSendSysMessage("Waypoint SQL written to SQL Developer log");
- return true;
- }
-};
-
-void AddSC_gps_commandscript()
-{
- new gps_commandscript();
-}
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 5f0434e5c55..7c431566f52 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -17,6 +17,9 @@
#include "ScriptPCH.h"
#include "Chat.h"
+#include "ObjectAccessor.h"
+#include "ScriptMgr.h"
+#include "CellImpl.h"
class misc_commandscript : public CommandScript
{
@@ -27,7 +30,8 @@ public:
{
static ChatCommand commandTable[] =
{
- { "dev", SEC_ADMINISTRATOR, false, &HandleDevCommand, "", NULL },
+ { "dev", SEC_ADMINISTRATOR, false, &HandleDevCommand, "", NULL },
+ { "gps", SEC_ADMINISTRATOR, false, &HandleGPSCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
@@ -64,6 +68,90 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
+
+ static bool HandleGPSCommand(ChatHandler* handler, char const* args)
+ {
+ WorldObject* object = NULL;
+ if (*args)
+ {
+ uint64 guid = handler->extractGuidFromLink((char*)args);
+ if (guid)
+ object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT);
+
+ if (!object)
+ {
+ handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+ }
+ else
+ {
+ object = handler->getSelectedUnit();
+
+ if (!object)
+ {
+ handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+ }
+
+ CellCoord cellCoord = Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY());
+ Cell cell(cellCoord);
+
+ uint32 zoneId, areaId;
+ object->GetZoneAndAreaId(zoneId, areaId);
+
+ MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId());
+ AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zoneId);
+ AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId);
+
+ float zoneX = object->GetPositionX();
+ float zoneY = object->GetPositionY();
+
+ Map2ZoneCoordinates(zoneX, zoneY, zoneId);
+
+ Map const* map = object->GetMap();
+ float groundZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), MAX_HEIGHT);
+ float floorZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ());
+
+ GridCoord gridCoord = Trinity::ComputeGridCoord(object->GetPositionX(), object->GetPositionY());
+
+ // 63? WHY?
+ int gridX = 63 - gridCoord.x_coord;
+ int gridY = 63 - gridCoord.y_coord;
+
+ uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
+ uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
+
+ if (haveVMap)
+ {
+ if (map->IsOutdoors(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ()))
+ handler->PSendSysMessage("You are outdoors");
+ else
+ handler->PSendSysMessage("You are indoors");
+ }
+ else
+ handler->PSendSysMessage("no VMAP available for area info");
+
+ handler->PSendSysMessage(LANG_MAP_POSITION,
+ object->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"),
+ zoneId, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
+ areaId, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
+ object->GetPhaseMask(),
+ object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(),
+ cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(),
+ zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap);
+
+ LiquidData liquidStatus;
+ ZLiquidStatus status = map->getLiquidStatus(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus);
+
+ if (status)
+ handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidStatus.level, liquidStatus.depth_level, liquidStatus.entry, liquidStatus.type_flags, status);
+
+ return true;
+ }
};
void AddSC_misc_commandscript()
diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp
index bb3a4d65b76..b6feccc10c6 100644
--- a/src/server/scripts/Commands/cs_modify.cpp
+++ b/src/server/scripts/Commands/cs_modify.cpp
@@ -33,6 +33,16 @@ public:
ChatCommand* GetCommands() const
{
+ static ChatCommand modifyspeedCommandTable[] =
+ {
+ { "fly", SEC_MODERATOR, false, &HandleModifyFlyCommand, "", NULL },
+ { "all", SEC_MODERATOR, false, &HandleModifyASpeedCommand, "", NULL },
+ { "walk", SEC_MODERATOR, false, &HandleModifySpeedCommand, "", NULL },
+ { "backwalk", SEC_MODERATOR, false, &HandleModifyBWalkCommand, "", NULL },
+ { "swim", SEC_MODERATOR, false, &HandleModifySwimCommand, "", NULL },
+ { "", SEC_MODERATOR, false, &HandleModifyASpeedCommand, "", NULL },
+ { NULL, 0, false, NULL, "", NULL }
+ };
static ChatCommand modifyCommandTable[] =
{
{ "hp", SEC_MODERATOR, false, &HandleModifyHPCommand, "", NULL },
@@ -41,29 +51,26 @@ public:
{ "runicpower", SEC_MODERATOR, false, &HandleModifyRunicPowerCommand, "", NULL },
{ "energy", SEC_MODERATOR, false, &HandleModifyEnergyCommand, "", NULL },
{ "money", SEC_MODERATOR, false, &HandleModifyMoneyCommand, "", NULL },
- { "speed", SEC_MODERATOR, false, &HandleModifySpeedCommand, "", NULL },
- { "swim", SEC_MODERATOR, false, &HandleModifySwimCommand, "", NULL },
{ "scale", SEC_MODERATOR, false, &HandleModifyScaleCommand, "", NULL },
{ "bit", SEC_MODERATOR, false, &HandleModifyBitCommand, "", NULL },
- { "bwalk", SEC_MODERATOR, false, &HandleModifyBWalkCommand, "", NULL },
- { "fly", SEC_MODERATOR, false, &HandleModifyFlyCommand, "", NULL },
- { "aspeed", SEC_MODERATOR, false, &HandleModifyASpeedCommand, "", NULL },
{ "faction", SEC_MODERATOR, false, &HandleModifyFactionCommand, "", NULL },
{ "spell", SEC_MODERATOR, false, &HandleModifySpellCommand, "", NULL },
- { "tp", SEC_MODERATOR, false, &HandleModifyTalentCommand, "", NULL },
+ { "talentpoints", SEC_MODERATOR, false, &HandleModifyTalentCommand, "", NULL },
{ "mount", SEC_MODERATOR, false, &HandleModifyMountCommand, "", NULL },
{ "honor", SEC_MODERATOR, false, &HandleModifyHonorCommand, "", NULL },
- { "rep", SEC_GAMEMASTER, false, &HandleModifyRepCommand, "", NULL },
- { "arena", SEC_MODERATOR, false, &HandleModifyArenaCommand, "", NULL },
+ { "reputation", SEC_GAMEMASTER, false, &HandleModifyRepCommand, "", NULL },
+ { "arenapoints", SEC_MODERATOR, false, &HandleModifyArenaCommand, "", NULL },
{ "drunk", SEC_MODERATOR, false, &HandleModifyDrunkCommand, "", NULL },
{ "standstate", SEC_GAMEMASTER, false, &HandleModifyStandStateCommand, "", NULL },
- { "morph", SEC_GAMEMASTER, false, &HandleModifyMorphCommand, "", NULL },
{ "phase", SEC_ADMINISTRATOR, false, &HandleModifyPhaseCommand, "", NULL },
{ "gender", SEC_GAMEMASTER, false, &HandleModifyGenderCommand, "", NULL },
+ { "speed", SEC_MODERATOR, false, NULL, "", modifyspeedCommandTable },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
{
+ { "morph", SEC_GAMEMASTER, false, &HandleModifyMorphCommand, "", NULL },
+ { "demorph", SEC_GAMEMASTER, false, &HandleDeMorphCommand, "", NULL },
{ "modify", SEC_MODERATOR, false, NULL, "", modifyCommandTable },
{ NULL, 0, false, NULL, "", NULL }
};
@@ -1376,6 +1383,21 @@ public:
return true;
}
+//demorph player or unit
+ static bool HandleDeMorphCommand(ChatHandler* handler, const char* /*args*/)
+ {
+ Unit* target = handler->getSelectedUnit();
+ if (!target)
+ target = handler->GetSession()->GetPlayer();
+
+ // check online security
+ else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0))
+ return false;
+
+ target->DeMorph();
+
+ return true;
+ }
};
void AddSC_modify_commandscript()
diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
index 37808e2b924..bf887bec164 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
@@ -664,7 +664,7 @@ public:
{
CAST_PLR(charmer)->GroupEventHappens(12687, me);
charmer->RemoveAurasDueToSpell(SPELL_EFFECT_OVERTAKE);
- CAST_CRE(who)->ForcedDespawn();
+ CAST_CRE(who)->DespawnOrUnsummon();
//CAST_CRE(who)->Respawn(true);
}
@@ -767,7 +767,7 @@ public:
//Todo: Creatures must not be removed, but, must instead
// stand next to Gothik and be commanded into the pit
// and dig into the ground.
- CAST_CRE(who)->ForcedDespawn();
+ CAST_CRE(who)->DespawnOrUnsummon();
if (CAST_PLR(owner)->GetQuestStatus(12698) == QUEST_STATUS_COMPLETE)
owner->RemoveAllMinionsByEntry(GHOULS);
diff --git a/src/server/scripts/Kalimdor/bloodmyst_isle.cpp b/src/server/scripts/Kalimdor/bloodmyst_isle.cpp
index ffc2fb3fb61..6c692a6738b 100644
--- a/src/server/scripts/Kalimdor/bloodmyst_isle.cpp
+++ b/src/server/scripts/Kalimdor/bloodmyst_isle.cpp
@@ -193,7 +193,7 @@ public:
if (type == POINT_MOTION_TYPE && id == 1)
{
DoScriptText(SAY_DIRECTION, me);
- me->ForcedDespawn();
+ me->DespawnOrUnsummon();
}
}
};
diff --git a/src/server/scripts/Kalimdor/durotar.cpp b/src/server/scripts/Kalimdor/durotar.cpp
index 88bc3352ea1..fe5bedf4c98 100644
--- a/src/server/scripts/Kalimdor/durotar.cpp
+++ b/src/server/scripts/Kalimdor/durotar.cpp
@@ -264,7 +264,7 @@ class npc_tiger_matriarch : public CreatureScript
vehSummoner->RemoveAurasDueToSpell(SPELL_SPIRIT_OF_THE_TIGER_RIDER);
vehSummoner->RemoveAurasDueToSpell(SPELL_SUMMON_ZENTABRA_TRIGGER);
}
- me->ForcedDespawn();
+ me->DespawnOrUnsummon();
}
void DamageTaken(Unit* attacker, uint32& damage)
@@ -287,7 +287,7 @@ class npc_tiger_matriarch : public CreatureScript
vehSummoner->RemoveAurasDueToSpell(SPELL_SUMMON_ZENTABRA_TRIGGER);
}
- me->ForcedDespawn();
+ me->DespawnOrUnsummon();
}
}
diff --git a/src/server/scripts/Kalimdor/dustwallow_marsh.cpp b/src/server/scripts/Kalimdor/dustwallow_marsh.cpp
index 4a1b67ba477..cbacc4fdf66 100644
--- a/src/server/scripts/Kalimdor/dustwallow_marsh.cpp
+++ b/src/server/scripts/Kalimdor/dustwallow_marsh.cpp
@@ -847,7 +847,7 @@ public:
player->KilledMonsterCredit(NPC_THERAMORE_PRISONER, 0);
prisoner->AI()->Talk(SAY_FREE); // We also emote cry here (handled in creature_text.emote)
- prisoner->ForcedDespawn(6000);
+ prisoner->DespawnOrUnsummon(6000);
}
return true;
}
diff --git a/src/server/scripts/Northrend/CMakeLists.txt b/src/server/scripts/Northrend/CMakeLists.txt
index 31aa924365d..3502e7fb104 100644
--- a/src/server/scripts/Northrend/CMakeLists.txt
+++ b/src/server/scripts/Northrend/CMakeLists.txt
@@ -22,7 +22,7 @@ set(scripts_STAT_SRCS
Northrend/Ulduar/Ulduar/ulduar_teleporter.cpp
Northrend/Ulduar/Ulduar/boss_thorim.cpp
Northrend/Ulduar/Ulduar/boss_ignis.cpp
- Northrend/Ulduar/Ulduar/boss_algalon.cpp
+ Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp
Northrend/Ulduar/Ulduar/instance_ulduar.cpp
Northrend/Ulduar/Ulduar/boss_auriaya.cpp
Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp
index c718c0cee5f..f329b940e1f 100755
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp
@@ -104,7 +104,7 @@ enum BossSpells
SPELL_SPIKE_TELE = 66170,
};
-#define SPELL_PERMAFROST_HELPER RAID_MODE<uint32>(66193, 67856, 67855, 67857)
+#define SPELL_PERMAFROST_HELPER RAID_MODE<uint32>(66193, 67855, 67856, 67857)
enum SummonActions
{
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp
index 6f817a6d0eb..a7328b43826 100755
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp
@@ -515,36 +515,6 @@ public:
};
-class spell_spinning_pain_spike : public SpellScriptLoader
-{
- public:
- spell_spinning_pain_spike() : SpellScriptLoader("spell_spinning_pain_spike") {}
-
- class spell_spinning_pain_spike_SpellScript : public SpellScript
- {
- PrepareSpellScript(spell_spinning_pain_spike_SpellScript);
-
- void HandleScript(SpellEffIndex /*eff*/)
- {
- Unit* target = GetHitUnit();
- if (!target)
- return;
-
- if (target->isAlive())
- SetHitDamage(target->CountPctFromMaxHealth(50));
- }
- void Register()
- {
- OnEffectHitTarget += SpellEffectFn(spell_spinning_pain_spike_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
- }
- };
-
- SpellScript* GetSpellScript() const
- {
- return new spell_spinning_pain_spike_SpellScript();
- }
-};
-
void AddSC_boss_jaraxxus()
{
new boss_jaraxxus();
@@ -553,5 +523,4 @@ void AddSC_boss_jaraxxus()
new mob_fel_infernal();
new mob_nether_portal();
new mob_mistress_of_pain();
- new spell_spinning_pain_spike();
}
diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp
index 88e9bedcd07..8d015adf4a4 100644
--- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp
+++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp
@@ -387,8 +387,7 @@ class player_overlord_brandAI : public PlayerAI
void SetGUID(uint64 guid, int32 /*type*/)
{
tyrannus = ObjectAccessor::GetCreature(*me, guid);
- if (!tyrannus)
- me->IsAIEnabled = false;
+ me->IsAIEnabled = tyrannus != NULL;
}
void DamageDealt(Unit* /*victim*/, uint32& damage, DamageEffectType /*damageType*/)
@@ -423,10 +422,9 @@ class spell_tyrannus_overlord_brand : public SpellScriptLoader
return;
oldAI = GetTarget()->GetAI();
+ oldAIState = GetTarget()->IsAIEnabled;
GetTarget()->SetAI(new player_overlord_brandAI(GetTarget()->ToPlayer()));
GetTarget()->GetAI()->SetGUID(GetCasterGUID());
- oldAIState = GetTarget()->IsAIEnabled;
- GetTarget()->IsAIEnabled = true;
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp
index de104a78e43..8090fc98101 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp
@@ -103,6 +103,7 @@ enum Spells
SPELL_UNSTABLE = 72059,
SPELL_KINETIC_BOMB_VISUAL = 72054,
SPELL_KINETIC_BOMB_EXPLOSION = 72052,
+ SPELL_KINETIC_BOMB_KNOCKBACK = 72087,
// Shock Vortex
SPELL_SHOCK_VORTEX_PERIODIC = 71945,
@@ -443,20 +444,12 @@ class boss_prince_keleseth_icc : public CreatureScript
{
summons.Summon(summon);
Position pos;
- pos.Relocate(summon);
+ me->GetPosition(&pos);
float maxRange = me->GetDistance2d(summon);
float angle = me->GetAngle(summon);
- // prevent spawning outside of room
- while (!me->IsWithinLOS(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()))
- {
- maxRange -= 5.0f;
- if (maxRange < 5.0f)
- break;
-
- summon->MovePosition(pos, float(rand_norm() * maxRange), angle);
- }
-
+ me->MovePositionToFirstCollision(pos, maxRange, angle);
summon->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation());
+ summon->ToTempSummon()->SetTempSummonType(TEMPSUMMON_CORPSE_DESPAWN);
}
void DamageDealt(Unit* /*target*/, uint32& damage, DamageEffectType damageType)
@@ -894,6 +887,7 @@ class boss_prince_valanar_icc : public CreatureScript
summon->GetPosition(x, y, z);
float ground_Z = summon->GetMap()->GetHeight(summon->GetPhaseMask(), x, y, z, true, 500.0f);
summon->GetMotionMaster()->MovePoint(POINT_KINETIC_BOMB_IMPACT, x, y, ground_Z);
+ summon->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
break;
}
case NPC_SHOCK_VORTEX:
@@ -1073,7 +1067,7 @@ class npc_blood_queen_lana_thel : public CreatureScript
if (_introDone)
return;
- if (!me->IsWithinDistInMap(who, 35.0f))
+ if (!me->IsWithinDistInMap(who, 35.0f, false))
return;
_introDone = true;
@@ -1232,12 +1226,12 @@ class npc_kinetic_bomb : public CreatureScript
void Reset()
{
_events.Reset();
- me->SetDisplayId(DISPLAY_KINETIC_BOMB);
+ me->SetWalk(true);
me->CastSpell(me, SPELL_UNSTABLE, true);
me->CastSpell(me, SPELL_KINETIC_BOMB_VISUAL, true);
me->SetReactState(REACT_PASSIVE);
- me->SetSpeed(MOVE_FLIGHT, IsHeroic() ? 0.3f : 0.15f, true);
me->GetPosition(_x, _y, _groundZ);
+ me->DespawnOrUnsummon(60000);
_groundZ = me->GetMap()->GetHeight(me->GetPhaseMask(), _x, _y, _groundZ, true, 500.0f);
}
@@ -1247,9 +1241,9 @@ class npc_kinetic_bomb : public CreatureScript
_events.ScheduleEvent(EVENT_BOMB_DESPAWN, 1000);
else if (action == ACTION_KINETIC_BOMB_JUMP)
{
- me->GetMotionMaster()->Clear();
- me->GetMotionMaster()->MoveJump(_x, _y, me->GetPositionZ() + 7.0f, 1.0f, 7.0f);
- _events.ScheduleEvent(EVENT_CONTINUE_FALLING, 700);
+ if (!me->HasAura(SPELL_KINETIC_BOMB_KNOCKBACK))
+ me->GetMotionMaster()->MoveCharge(_x, _y, me->GetPositionZ() + 100.0f, me->GetSpeed(MOVE_RUN), 0);
+ _events.RescheduleEvent(EVENT_CONTINUE_FALLING, 3000);
}
}
@@ -1263,10 +1257,10 @@ class npc_kinetic_bomb : public CreatureScript
{
case EVENT_BOMB_DESPAWN:
me->SetVisible(false);
+ me->DespawnOrUnsummon(5000);
break;
case EVENT_CONTINUE_FALLING:
- me->GetMotionMaster()->Clear();
- me->GetMotionMaster()->MovePoint(POINT_KINETIC_BOMB_IMPACT, _x, _y, _groundZ);
+ me->GetMotionMaster()->MoveCharge(_x, _y, _groundZ, me->GetSpeed(MOVE_WALK), POINT_KINETIC_BOMB_IMPACT);
break;
default:
break;
@@ -1329,17 +1323,16 @@ class npc_dark_nucleus : public CreatureScript
void DamageTaken(Unit* attacker, uint32& /*damage*/)
{
- if (attacker == me)
+ if (attacker == me || attacker == me->getVictim())
return;
- if (!_lockedTarget)
- if (me->getVictim() == attacker)
- _lockedTarget = true;
+ me->DeleteThreatList();
+ me->AddThreat(attacker, 500000000.0f);
}
- void UpdateAI(const uint32 diff)
+ void UpdateAI(uint32 const diff)
{
- if (!me->isInCombat())
+ if (!UpdateVictim())
return;
if (_targetAuraCheck <= diff)
@@ -1355,23 +1348,6 @@ class npc_dark_nucleus : public CreatureScript
}
else
_targetAuraCheck -= diff;
-
- if (!_lockedTarget)
- {
- if (Unit* victim = me->SelectVictim())
- {
- if (me->getVictim() && me->getVictim() != victim)
- {
- me->getVictim()->RemoveAurasDueToSpell(SPELL_SHADOW_RESONANCE_RESIST, me->GetGUID());
- _lockedTarget = true;
- }
-
- _lockedTarget = true;
- AttackStart(victim);
- DoCast(victim, SPELL_SHADOW_RESONANCE_RESIST);
- me->ClearUnitState(UNIT_STATE_CASTING);
- }
- }
}
private:
@@ -1525,6 +1501,7 @@ class spell_valanar_kinetic_bomb : public SpellScriptLoader
Position offset = {0.0f, 0.0f, 20.0f, 0.0f};
summonPos.RelocateOffset(offset);
SetTargetDest(summonPos);
+ GetHitDest()->RelocateOffset(offset);
}
void Register()
@@ -1586,7 +1563,7 @@ class spell_valanar_kinetic_bomb_knockback : public SpellScriptLoader
void Register()
{
- AfterHit += SpellHitFn(spell_valanar_kinetic_bomb_knockback_SpellScript::KnockIntoAir);
+ BeforeHit += SpellHitFn(spell_valanar_kinetic_bomb_knockback_SpellScript::KnockIntoAir);
}
};
@@ -1663,7 +1640,7 @@ class spell_blood_council_shadow_prison_damage : public SpellScriptLoader
void AddExtraDamage()
{
if (Aura* aur = GetHitUnit()->GetAura(GetSpellInfo()->Id))
- if (AuraEffect const* eff = aur->GetEffect(1))
+ if (AuraEffect const* eff = aur->GetEffect(EFFECT_1))
SetHitDamage(GetHitDamage() + eff->GetAmount());
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp
index 249eed01643..afc7c503bee 100755
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp
@@ -39,6 +39,7 @@ enum ScriptTexts
SAY_FRENZY = 11,
SAY_BERSERK = 12,
SAY_DEATH = 13,
+ EMOTE_SCENT_OF_BLOOD = 14,
// High Overlord Saurfang
SAY_INTRO_HORDE_1 = 0,
@@ -145,6 +146,7 @@ enum EventTypes
EVENT_BOILING_BLOOD = 20,
EVENT_BLOOD_NOVA = 21,
EVENT_RUNE_OF_BLOOD = 22,
+ EVENT_SCENT_OF_BLOOD = 52,
EVENT_OUTRO_ALLIANCE_1 = 23,
EVENT_OUTRO_ALLIANCE_2 = 24,
@@ -297,7 +299,7 @@ class boss_deathbringer_saurfang : public CreatureScript
Talk(SAY_AGGRO);
events.ScheduleEvent(EVENT_SUMMON_BLOOD_BEAST, 30000, 0, PHASE_COMBAT);
- events.ScheduleEvent(EVENT_BERSERK, 480000, 0, PHASE_COMBAT);
+ events.ScheduleEvent(EVENT_BERSERK, IsHeroic() ? 360000 : 480000, 0, PHASE_COMBAT);
events.ScheduleEvent(EVENT_BOILING_BLOOD, 15500, 0, PHASE_COMBAT);
events.ScheduleEvent(EVENT_BLOOD_NOVA, 17000, 0, PHASE_COMBAT);
events.ScheduleEvent(EVENT_RUNE_OF_BLOOD, 20000, 0, PHASE_COMBAT);
@@ -374,16 +376,13 @@ class boss_deathbringer_saurfang : public CreatureScript
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true))
summon->AI()->AttackStart(target);
- if (IsHeroic())
- DoCast(summon, SPELL_SCENT_OF_BLOOD);
-
- summon->AI()->DoCast(summon, SPELL_BLOOD_LINK_BEAST, true);
- summon->AI()->DoCast(summon, SPELL_RESISTANT_SKIN, true);
+ summon->CastSpell(summon, SPELL_BLOOD_LINK_BEAST, true);
+ summon->CastSpell(summon, SPELL_RESISTANT_SKIN, true);
summons.Summon(summon);
DoZoneInCombat(summon);
}
- void SummonedCreatureDespawn(Creature* summon)
+ void SummonedCreatureDies(Creature* summon, Unit* /*killer*/)
{
summons.Despawn(summon);
}
@@ -463,18 +462,13 @@ class boss_deathbringer_saurfang : public CreatureScript
DoCast(me, SPELL_SUMMON_BLOOD_BEAST_25_MAN+i25);
Talk(SAY_BLOOD_BEASTS);
events.ScheduleEvent(EVENT_SUMMON_BLOOD_BEAST, 40000, 0, PHASE_COMBAT);
+ if (IsHeroic())
+ events.ScheduleEvent(EVENT_SCENT_OF_BLOOD, 10000, 0, PHASE_COMBAT);
break;
case EVENT_BLOOD_NOVA:
- {
- // select at range only
- Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, -10.0f, true);
- if (!target)
- target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true); // noone? select melee
- if (target)
- DoCast(target, SPELL_BLOOD_NOVA_TRIGGER);
+ DoCastAOE(SPELL_BLOOD_NOVA_TRIGGER);
events.ScheduleEvent(EVENT_BLOOD_NOVA, urand(20000, 25000), 0, PHASE_COMBAT);
break;
- }
case EVENT_RUNE_OF_BLOOD:
DoCastVictim(SPELL_RUNE_OF_BLOOD);
events.ScheduleEvent(EVENT_RUNE_OF_BLOOD, urand(20000, 25000), 0, PHASE_COMBAT);
@@ -487,6 +481,13 @@ class boss_deathbringer_saurfang : public CreatureScript
DoCast(me, SPELL_BERSERK);
Talk(SAY_BERSERK);
break;
+ case EVENT_SCENT_OF_BLOOD:
+ if (!summons.empty())
+ {
+ Talk(EMOTE_SCENT_OF_BLOOD);
+ DoCastAOE(SPELL_SCENT_OF_BLOOD);
+ }
+ break;
default:
break;
}
@@ -1237,10 +1238,16 @@ class spell_deathbringer_blood_nova_targeting : public SpellScriptLoader
unitList.push_back(target);
}
+ void HandleForceCast(SpellEffIndex /*effIndex*/)
+ {
+ GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), TRIGGERED_FULL_MASK);
+ }
+
void Register()
{
OnUnitTargetSelect += SpellUnitTargetFn(spell_deathbringer_blood_nova_targeting_SpellScript::FilterTargetsInitial, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
OnUnitTargetSelect += SpellUnitTargetFn(spell_deathbringer_blood_nova_targeting_SpellScript::FilterTargetsSubsequent, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY);
+ OnEffectHitTarget += SpellEffectFn(spell_deathbringer_blood_nova_targeting_SpellScript::HandleForceCast, EFFECT_0, SPELL_EFFECT_FORCE_CAST);
}
Unit* target;
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
index 273f2a20b4b..c043cb27c7c 100755
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
@@ -544,7 +544,7 @@ class boss_professor_putricide : public CreatureScript
void UpdateAI(uint32 const diff)
{
- if ((!UpdateVictim() && !(events.GetPhaseMask() & PHASE_MASK_NOT_SELF)) || !CheckInRoom())
+ if ((!(events.GetPhaseMask() & PHASE_MASK_NOT_SELF) && !UpdateVictim()) || !CheckInRoom())
return;
events.Update(diff);
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
index ab924d1b543..ebf9ae02a95 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
@@ -713,6 +713,7 @@ class npc_spinestalker : public CreatureScript
me->SetDisableGravity(false);
me->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER);
me->SetHomePosition(SpinestalkerLandPos);
+ me->SetFacingTo(SpinestalkerLandPos.GetOrientation());
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
}
@@ -839,6 +840,7 @@ class npc_rimefang : public CreatureScript
me->SetDisableGravity(false);
me->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER);
me->SetHomePosition(RimefangLandPos);
+ me->SetFacingTo(RimefangLandPos.GetOrientation());
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp
index ed1ca4d20fb..c40a521c794 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp
@@ -262,7 +262,7 @@ class ValithriaDespawner : public BasicEvent
if (CreatureData const* data = creature->GetCreatureData())
creature->SetPosition(data->posX, data->posY, data->posZ, data->orientation);
- creature->ForcedDespawn();
+ creature->DespawnOrUnsummon();
creature->SetCorpseDelay(corpseDelay);
creature->SetRespawnDelay(respawnDelay);
@@ -1087,7 +1087,7 @@ class npc_dream_cloud : public CreatureScript
me->GetMotionMaster()->MoveIdle();
// must use originalCaster the same for all clouds to allow stacking
me->CastSpell(me, EMERALD_VIGOR, false, NULL, NULL, _instance->GetData64(DATA_VALITHRIA_DREAMWALKER));
- me->ForcedDespawn(100);
+ me->DespawnOrUnsummon(100);
break;
default:
break;
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp
index c99fde1739c..5b208768b0c 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp
@@ -346,7 +346,7 @@ class FrostwingGauntletRespawner
if (CreatureData const* data = creature->GetCreatureData())
creature->SetPosition(data->posX, data->posY, data->posZ, data->orientation);
- creature->ForcedDespawn();
+ creature->DespawnOrUnsummon();
creature->SetCorpseDelay(corpseDelay);
creature->SetRespawnDelay(respawnDelay);
@@ -796,7 +796,8 @@ class boss_sister_svalna : public CreatureScript
{
_JustReachedHome();
me->SetReactState(REACT_PASSIVE);
- me->SetCanFly(false);
+ me->SetDisableGravity(false);
+ me->SetHover(false);
}
void DoAction(int32 const action)
@@ -838,13 +839,14 @@ class boss_sister_svalna : public CreatureScript
void MovementInform(uint32 type, uint32 id)
{
- if (type != POINT_MOTION_TYPE || id != POINT_LAND)
+ if (type != EFFECT_MOTION_TYPE || id != POINT_LAND)
return;
_isEventInProgress = false;
me->setActive(false);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
- me->SetCanFly(false);
+ me->SetDisableGravity(false);
+ me->SetHover(false);
}
void SpellHitTarget(Unit* target, SpellInfo const* spell)
@@ -1921,10 +1923,10 @@ class spell_svalna_revive_champion : public SpellScriptLoader
Position pos;
caster->GetPosition(&pos);
caster->GetNearPosition(pos, 5.0f, 0.0f);
- pos.m_positionZ = caster->GetBaseMap()->GetHeight(caster->GetPhaseMask(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), true, 20.0f);
- pos.m_positionZ += 0.05f;
+ //pos.m_positionZ = caster->GetBaseMap()->GetHeight(caster->GetPhaseMask(), pos.GetPositionX(), pos.GetPositionY(), caster->GetPositionZ(), true, 50.0f);
+ //pos.m_positionZ += 0.05f;
caster->SetHomePosition(pos);
- caster->GetMotionMaster()->MovePoint(POINT_LAND, pos);
+ caster->GetMotionMaster()->MoveLand(POINT_LAND, pos, caster->GetSpeed(MOVE_FLIGHT));
}
void Register()
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon.cpp
deleted file mode 100644
index 2dd13e7ce07..00000000000
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon.cpp
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "ScriptMgr.h"
-#include "ScriptedCreature.h"
-#include "ulduar.h"
-
-#define GAMEOBJECT_GIVE_OF_THE_OBSERVER 194821
-
-enum Spells
-{
- SPELL_ASCEND = 64487,
- SPELL_BERSERK = 47008,
- SPELL_BIG_BANG = 64443,
- H_SPELL_BIG_BANG = 64584,
- SPELL_COSMIC_SMASH = 62301,
- H_SPELL_COSMIC_SMASH = 64598,
- SPELL_PHASE_PUNCH = 64412,
- SPELL_QUANTUM_STRIKE = 64395,
- H_SPELL_QUANTUM_STRIKE = 64592,
- SPELL_BLACK_HOLE_EXPLOSION = 64122,
- SPELL_ARCANE_BARAGE = 64599,
- H_SPELL_ARCANE_BARAGE = 64607
-};
-
-enum Creatures
-{
- CREATURE_COLLAPSING_STAR = 32955,
- CREATURE_BLACK_HOLE = 32953,
- CREATURE_LIVING_CONSTELLATION = 33052,
- CREATURE_DARK_MATTER = 33089
-};
-
-enum Yells
-{
- SAY_AGGRO = -1603000,
- SAY_SLAY_1 = -1603001,
- SAY_SLAY_2 = -1603002,
- SAY_ENGADED_FOR_FIRTS_TIME = -1603003,
- SAY_PHASE_2 = -1603004,
- SAY_SUMMON_COLLAPSING_STAR = -1603005,
- SAY_DEATH_1 = -1603006,
- SAY_DEATH_2 = -1603007,
- SAY_DEATH_3 = -1603008,
- SAY_DEATH_4 = -1603009,
- SAY_DEATH_5 = -1603010,
- SAY_BERSERK = -1603011,
- SAY_BIG_BANG_1 = -1603012,
- SAY_BIG_BANG_2 = -1603013,
- SAY_TIMER_1 = -1603014,
- SAY_TIMER_2 = -1603015,
- SAY_TIMER_3 = -1603016,
- SAY_SUMMON_1 = -1603017,
- SAY_SUMMON_2 = -1603018,
- SAY_SUMMON_3 = -1603019,
-};
-
-class boss_algalon : public CreatureScript
-{
-public:
- boss_algalon() : CreatureScript("boss_algalon") { }
-
- CreatureAI* GetAI(Creature* creature) const
- {
- return GetUlduarAI<boss_algalonAI>(creature);
- }
-
- struct boss_algalonAI : public ScriptedAI
- {
- boss_algalonAI(Creature* creature) : ScriptedAI(creature)
- {
- instance = creature->GetInstanceScript();
- Summon = false; // not in reset. intro speech done only once.
- }
-
- InstanceScript* instance;
-
- std::list<uint64> m_lCollapsingStarGUIDList;
-
- uint32 Phase;
- uint32 Ascend_Timer;
- uint32 Berserk_Timer;
- uint32 BigBang_Timer;
- uint32 CosmicSmash_Timer;
- uint32 PhasePunch_Timer;
- uint32 QuantumStrike_Timer;
- uint32 CollapsingStar_Timer;
- uint32 uiPhase_timer;
- uint32 uiStep;
-
- uint64 BlackHoleGUID;
-
- bool Enrage;
- bool Summon;
-
- void EnterCombat(Unit* who)
- {
- if (Summon)
- {
- DoScriptText(SAY_AGGRO, me);
- me->InterruptSpell(CURRENT_CHANNELED_SPELL);
- DoZoneInCombat(who->ToCreature());
- }
- else
- {
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- me->SetReactState(REACT_PASSIVE);
- uiStep = 1;
- }
-
- if (instance)
- instance->SetData(BOSS_ALGALON, IN_PROGRESS);
- }
-
- void KilledUnit(Unit* /*victim*/)
- {
- DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), me);
- }
-
- void Reset()
- {
- Phase = 1;
-
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- if (instance)
- instance->SetData(BOSS_ALGALON, NOT_STARTED);
-
- BlackHoleGUID = 0;
-
- uiPhase_timer = 0;
- Ascend_Timer = 480000; //8 minutes
- QuantumStrike_Timer = urand(4000, 14000);
- Berserk_Timer = 360000; //6 minutes
- CollapsingStar_Timer = urand(15000, 20000); //Spawns between 15 to 20 seconds
- BigBang_Timer = 90000;
- PhasePunch_Timer = 8000;
- CosmicSmash_Timer = urand(30000, 60000);
- Enrage = false;
- }
-
- void JumpToNextStep(uint32 uiTimer)
- {
- uiPhase_timer = uiTimer;
- ++uiStep;
- }
-
- void DespawnCollapsingStar()
- {
- if (m_lCollapsingStarGUIDList.empty())
- return;
-
- for (std::list<uint64>::const_iterator itr = m_lCollapsingStarGUIDList.begin(); itr != m_lCollapsingStarGUIDList.end(); ++itr)
- {
- if (Creature* temp = Unit::GetCreature(*me, *itr))
- {
- if (temp->isAlive())
- temp->DespawnOrUnsummon();
- }
- }
- m_lCollapsingStarGUIDList.clear();
- }
-
- void JustSummoned(Creature* summoned)
- {
- if (summoned->GetEntry() == CREATURE_COLLAPSING_STAR)
- {
- Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);
- if (me->getVictim())
- summoned->AI()->AttackStart(target ? target : me->getVictim());
- m_lCollapsingStarGUIDList.push_back(summoned->GetGUID());
- }
- }
-
- void SummonCollapsingStar(Unit* target)
- {
- DoScriptText(SAY_SUMMON_COLLAPSING_STAR, me);
- me->SummonCreature(CREATURE_COLLAPSING_STAR, target->GetPositionX()+15.0f, target->GetPositionY()+15.0f, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 100000);
- me->SummonCreature(CREATURE_BLACK_HOLE, target->GetPositionX()+15.0f, target->GetPositionY()+15.0f, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 27000);
- }
-
- void UpdateAI(const uint32 diff)
- {
- //Return since we have no target
- if (!UpdateVictim())
- return;
-
- if (Phase == 1 && HealthBelowPct(20))
- {
- Phase = 2;
- DoScriptText(SAY_PHASE_2, me);
- }
-
- if (HealthBelowPct(2))
- {
- me->SummonGameObject(GAMEOBJECT_GIVE_OF_THE_OBSERVER, 1634.258667f, -295.101166f, 417.321381f, 0, 0, 0, 0, 0, 0);
-
- // All of them. or random?
- DoScriptText(SAY_DEATH_1, me);
- DoScriptText(SAY_DEATH_2, me);
- DoScriptText(SAY_DEATH_3, me);
- DoScriptText(SAY_DEATH_4, me);
- DoScriptText(SAY_DEATH_5, me);
-
- me->DisappearAndDie();
-
- if (instance)
- instance->SetData(BOSS_ALGALON, DONE);
-
- return;
- }
-
- if (Phase == 1)
- {
- if (!Summon)
- {
- if (uiPhase_timer <= diff)
- {
- switch (uiStep)
- {
- case 1:
- DoScriptText(SAY_SUMMON_1, me);
- JumpToNextStep(3000);
- break;
- case 2:
- DoScriptText(SAY_SUMMON_2, me);
- JumpToNextStep(3000);
- break;
- case 3:
- DoScriptText(SAY_SUMMON_3, me);
- JumpToNextStep(3000);
- break;
- case 4:
- DoScriptText(SAY_ENGADED_FOR_FIRTS_TIME, me);
- JumpToNextStep(3000);
- break;
- case 5:
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- me->SetReactState(REACT_AGGRESSIVE);
- Summon = true;
- break;
- }
- } else uiPhase_timer -= diff;
-
- return;
- }
-
- if (QuantumStrike_Timer <= diff)
- {
- DoCast(me->getVictim(), RAID_MODE(SPELL_QUANTUM_STRIKE, H_SPELL_QUANTUM_STRIKE), true);
-
- QuantumStrike_Timer = urand(4000, 14000);
- } else QuantumStrike_Timer -= diff;
-
- if (BigBang_Timer <= diff)
- {
- DoScriptText(RAND(SAY_BIG_BANG_1, SAY_BIG_BANG_2), me);
- DoCast(me->getVictim(), RAID_MODE(SPELL_BIG_BANG, H_SPELL_BIG_BANG), true);
-
- BigBang_Timer = 90000;
- } else BigBang_Timer -= diff;
-
- if (Ascend_Timer <= diff)
- {
- DoCast(me->getVictim(), SPELL_ASCEND, true);
-
- Ascend_Timer = 480000;
- } else Ascend_Timer -= diff;
-
- if (PhasePunch_Timer <= diff)
- {
- DoCast(me->getVictim(), SPELL_PHASE_PUNCH, true);
-
- PhasePunch_Timer = 8000;
- } else PhasePunch_Timer -= diff;
-
- if (CosmicSmash_Timer <= diff)
- {
- DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0), RAID_MODE(SPELL_COSMIC_SMASH, H_SPELL_COSMIC_SMASH), true);
-
- CosmicSmash_Timer = urand(30000, 60000);
- } else CosmicSmash_Timer -= diff;
-
- if (Berserk_Timer <= diff)
- {
- DoScriptText(SAY_BERSERK, me);
- DoCast(me->getVictim(), SPELL_BERSERK, true);
-
- Berserk_Timer = 360000;
- } else Berserk_Timer -= diff;
-
- DoMeleeAttackIfReady();
-
- EnterEvadeIfOutOfCombatArea(diff);
- }
-
- if (Phase == 2)
- {
- if (Enrage)
- {
- if (Ascend_Timer <= diff)
- {
- DoCast(me, SPELL_ASCEND);
- DoScriptText(SAY_BERSERK, me);
- Ascend_Timer = urand(360000, 365000);
- Enrage = false;
- } else Ascend_Timer -= diff;
- }
- }
-
- DoMeleeAttackIfReady();
- }
- };
-
-};
-
-//Collapsing Star
-class mob_collapsing_star : public CreatureScript
-{
-public:
- mob_collapsing_star() : CreatureScript("mob_collapsing_star") { }
-
- CreatureAI* GetAI(Creature* creature) const
- {
- return new mob_collapsing_starAI(creature);
- }
-
- struct mob_collapsing_starAI : public ScriptedAI
- {
- mob_collapsing_starAI(Creature* creature) : ScriptedAI(creature)
- {
- instance = creature->GetInstanceScript();
- }
-
- InstanceScript* instance;
-
- uint32 BlackHoleExplosion_Timer;
-
- void Reset()
- {
- BlackHoleExplosion_Timer = 0;
- }
-
- void UpdateAI(const uint32 diff)
- {
- if (!UpdateVictim())
- return;
-
- if (BlackHoleExplosion_Timer <= diff)
- {
- me->CastSpell(me, SPELL_BLACK_HOLE_EXPLOSION, false);
- BlackHoleExplosion_Timer = 0;
- } else BlackHoleExplosion_Timer -= diff;
- }
- };
-
-};
-
-void AddSC_boss_Algalon()
-{
- new boss_algalon();
- new mob_collapsing_star();
-}
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp
new file mode 100644
index 00000000000..6f87d7fcd2a
--- /dev/null
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp
@@ -0,0 +1,1374 @@
+/*
+ * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ObjectMgr.h"
+#include "ScriptMgr.h"
+#include "ScriptedCreature.h"
+#include "SpellScript.h"
+#include "PassiveAI.h"
+#include "GameObjectAI.h"
+#include "MapManager.h"
+#include "MoveSplineInit.h"
+#include "ulduar.h"
+
+enum Texts
+{
+ SAY_BRANN_ALGALON_INTRO_1 = 0,
+ SAY_BRANN_ALGALON_INTRO_2 = 1,
+ SAY_BRANN_ALGALON_OUTRO = 2,
+
+ SAY_ALGALON_INTRO_1 = 0,
+ SAY_ALGALON_INTRO_2 = 1,
+ SAY_ALGALON_INTRO_3 = 2,
+ SAY_ALGALON_START_TIMER = 3,
+ SAY_ALGALON_AGGRO = 4,
+ SAY_ALGALON_COLLAPSING_STAR = 5,
+ EMOTE_ALGALON_COLLAPSING_STAR = 6,
+ SAY_ALGALON_BIG_BANG = 7,
+ EMOTE_ALGALON_BIG_BANG = 8,
+ SAY_ALGALON_ASCEND = 9,
+ EMOTE_ALGALON_COSMIC_SMASH = 10,
+ SAY_ALGALON_PHASE_TWO = 11,
+ SAY_ALGALON_OUTRO_1 = 12,
+ SAY_ALGALON_OUTRO_2 = 13,
+ SAY_ALGALON_OUTRO_3 = 14,
+ SAY_ALGALON_OUTRO_4 = 15,
+ SAY_ALGALON_OUTRO_5 = 16,
+ SAY_ALGALON_DESPAWN_1 = 17,
+ SAY_ALGALON_DESPAWN_2 = 18,
+ SAY_ALGALON_DESPAWN_3 = 19,
+ SAY_ALGALON_KILL = 20,
+};
+
+enum Spells
+{
+ // Algalon the Observer
+ SPELL_ARRIVAL = 64997,
+ SPELL_RIDE_THE_LIGHTNING = 64986,
+ SPELL_SUMMON_AZEROTH = 64994,
+ SPELL_REORIGINATION = 64996,
+ SPELL_SUPERMASSIVE_FAIL = 65311,
+ SPELL_QUANTUM_STRIKE = 64395,
+ SPELL_PHASE_PUNCH = 64412,
+ SPELL_BIG_BANG = 64443,
+ SPELL_ASCEND_TO_THE_HEAVENS = 64487,
+ SPELL_COSMIC_SMASH = 62301,
+ SPELL_COSMIC_SMASH_TRIGGERED = 62304,
+ SPELL_COSMIC_SMASH_VISUAL_STATE = 62300,
+ SPELL_SELF_STUN = 65256,
+ SPELL_KILL_CREDIT = 65184,
+ SPELL_TELEPORT = 62940,
+
+ // Algalon Stalker
+ SPELL_TRIGGER_3_ADDS = 62266, // Triggers Living Constellation
+
+ // Living Constellation
+ SPELL_ARCANE_BARRAGE = 64599,
+
+ // Collapsing Star
+ SPELL_COLLAPSE = 62018,
+ SPELL_BLACK_HOLE_SPAWN_VISUAL = 62003,
+ SPELL_SUMMON_BLACK_HOLE = 62189,
+
+ // Black Hole
+ SPELL_BLACK_HOLE_TRIGGER = 62185,
+ SPELL_CONSTELLATION_PHASE_TRIGGER = 65508,
+ SPELL_CONSTELLATION_PHASE_EFFECT = 65509,
+ SPELL_BLACK_HOLE_EXPLOSION = 64122,
+ SPELL_SUMMON_VOID_ZONE_VISUAL = 64470,
+ SPELL_VOID_ZONE_VISUAL = 64469,
+ SPELL_BLACK_HOLE_CREDIT = 65312,
+
+ // Worm Hole
+ SPELL_WORM_HOLE_TRIGGER = 65251,
+ SPELL_SUMMON_UNLEASHED_DARK_MATTER = 64450,
+};
+
+uint32 const PhasePunchAlphaId[5] = {64435, 64434, 64428, 64421, 64417};
+
+enum Events
+{
+ // Celestial Planetarium Access
+ EVENT_DESPAWN_CONSOLE = 1,
+
+ // Brann Bronzebeard
+ EVENT_BRANN_MOVE_INTRO = 2,
+ EVENT_SUMMON_ALGALON = 3,
+ EVENT_BRANN_OUTRO_1 = 4,
+ EVENT_BRANN_OUTRO_2 = 5,
+
+ // Algalon the Observer
+ EVENT_INTRO_1 = 6,
+ EVENT_INTRO_2 = 7,
+ EVENT_INTRO_3 = 8,
+ EVENT_INTRO_FINISH = 9,
+ EVENT_START_COMBAT = 10,
+ EVENT_INTRO_TIMER_DONE = 11,
+ EVENT_QUANTUM_STRIKE = 12,
+ EVENT_PHASE_PUNCH = 13,
+ EVENT_SUMMON_COLLAPSING_STAR = 14,
+ EVENT_BIG_BANG = 15,
+ EVENT_RESUME_UPDATING = 16,
+ EVENT_ASCEND_TO_THE_HEAVENS = 17,
+ EVENT_EVADE = 18,
+ EVENT_COSMIC_SMASH = 19,
+ EVENT_UNLOCK_YELL = 20,
+ EVENT_OUTRO_START = 21,
+ EVENT_OUTRO_1 = 22,
+ EVENT_OUTRO_2 = 23,
+ EVENT_OUTRO_3 = 24,
+ EVENT_OUTRO_4 = 25,
+ EVENT_OUTRO_5 = 26,
+ EVENT_OUTRO_6 = 27,
+ EVENT_OUTRO_7 = 28,
+ EVENT_OUTRO_8 = 29,
+ EVENT_OUTRO_9 = 30,
+ EVENT_OUTRO_10 = 31,
+ EVENT_OUTRO_11 = 32,
+ EVENT_OUTRO_12 = 33,
+ EVENT_OUTRO_13 = 34,
+ EVENT_OUTRO_14 = 35,
+ EVENT_DESPAWN_ALGALON_1 = 36,
+ EVENT_DESPAWN_ALGALON_2 = 37,
+ EVENT_DESPAWN_ALGALON_3 = 38,
+
+ // Living Constellation
+ EVENT_ARCANE_BARRAGE = 39,
+};
+
+enum Actions
+{
+ ACTION_START_INTRO = 0,
+ ACTION_FINISH_INTRO = 1,
+ ACTION_ACTIVATE_STAR = 2,
+ ACTION_BIG_BANG = 3,
+ ACTION_ASCEND = 4,
+ ACTION_OUTRO = 5,
+};
+
+enum Points
+{
+ POINT_BRANN_INTRO = 0,
+ MAX_BRANN_WAYPOINTS_INTRO = 10,
+ POINT_BRANN_OUTRO = 10,
+ POINT_BRANN_OUTRO_END = 11,
+
+ POINT_ALGALON_LAND = 1,
+ POINT_ALGALON_OUTRO = 2,
+};
+
+enum EncounterPhases
+{
+ PHASE_NORMAL = 0,
+ PHASE_ROLE_PLAY = 1,
+ PHASE_BIG_BANG = 2,
+
+ PHASE_MASK_NO_UPDATE = (1 << PHASE_ROLE_PLAY) | (1 << PHASE_BIG_BANG),
+ PHASE_MASK_NO_CAST_CHECK = 1 << PHASE_ROLE_PLAY,
+};
+
+enum AchievmentInfo
+{
+ EVENT_ID_SUPERMASSIVE_START = 21697,
+ DATA_HAS_FED_ON_TEARS = 30043005,
+};
+
+
+Position const BrannIntroSpawnPos = {1676.277f, -162.5308f, 427.3326f, 3.235537f};
+Position const BrannIntroWaypoint[MAX_BRANN_WAYPOINTS_INTRO] =
+{
+ {1642.482f, -164.0812f, 427.2602f, 0.0f},
+ {1635.000f, -169.5145f, 427.2523f, 0.0f},
+ {1632.814f, -173.9334f, 427.2621f, 0.0f},
+ {1632.676f, -190.5927f, 425.8831f, 0.0f},
+ {1631.497f, -214.2221f, 418.1152f, 0.0f},
+ {1624.717f, -224.6876f, 418.1152f, 0.0f},
+ {1631.497f, -214.2221f, 418.1152f, 0.0f},
+ {1632.676f, -190.5927f, 425.8831f, 0.0f},
+ {1632.814f, -173.9334f, 427.2621f, 0.0f},
+ {1635.000f, -169.5145f, 427.2523f, 0.0f},
+};
+Position const AlgalonSummonPos = {1632.531f, -304.8516f, 450.1123f, 1.530165f};
+Position const AlgalonLandPos = {1632.668f, -302.7656f, 417.3211f, 1.530165f};
+
+#define LIVING_CONSTELLATION_COUNT 11
+Position const ConstellationPos[LIVING_CONSTELLATION_COUNT] =
+{
+ {1625.208f, -267.2771f, 446.4296f, 5.044002f},
+ {1658.279f, -262.5490f, 441.9073f, 4.188790f},
+ {1678.677f, -276.3280f, 427.7531f, 3.979351f},
+ {1593.389f, -299.4325f, 432.4636f, 6.073746f},
+ {1685.613f, -300.1219f, 443.2366f, 3.385939f},
+ {1591.706f, -263.8201f, 441.4153f, 5.253441f},
+ {1668.317f, -324.7676f, 457.9394f, 3.211406f},
+ {1592.242f, -325.5323f, 446.9508f, 0.226893f},
+ {1635.821f, -363.3442f, 424.3459f, 1.466077f},
+ {1672.188f, -357.2484f, 436.7337f, 2.338741f},
+ {1615.800f, -348.0065f, 442.9586f, 1.134464f},
+};
+
+#define COLLAPSING_STAR_COUNT 4
+Position const CollapsingStarPos[COLLAPSING_STAR_COUNT] =
+{
+ {1649.438f, -319.8127f, 418.3941f, 1.082104f},
+ {1647.005f, -288.6790f, 417.3955f, 3.490659f},
+ {1622.451f, -321.1563f, 417.6188f, 4.677482f},
+ {1615.060f, -291.6816f, 417.7796f, 3.490659f},
+};
+Position const AlgalonOutroPos = {1633.64f, -317.78f, 417.3211f, 0.0f};
+Position const BrannOutroPos[3] =
+{
+ {1632.023f, -243.7434f, 417.9118f, 0.0f},
+ {1631.986f, -297.7831f, 417.3210f, 0.0f},
+ {1633.832f, -216.2948f, 417.0463f, 0.0f},
+};
+
+class ActivateLivingConstellation : public BasicEvent
+{
+ public:
+ ActivateLivingConstellation(Unit* owner) : _owner(owner), _instance(owner->GetInstanceScript())
+ {
+ }
+
+ bool Execute(uint64 execTime, uint32 /*diff*/)
+ {
+ if (!_instance || _instance->GetBossState(BOSS_ALGALON) != IN_PROGRESS)
+ return true; // delete event
+
+ _owner->CastSpell((Unit*)NULL, SPELL_TRIGGER_3_ADDS, TRIGGERED_FULL_MASK);
+ _owner->m_Events.AddEvent(this, execTime + urand(45000, 50000));
+ return false;
+ }
+
+ private:
+ Unit* _owner;
+ InstanceScript* _instance;
+};
+
+class CosmicSmashDamageEvent : public BasicEvent
+{
+ public:
+ CosmicSmashDamageEvent(Unit* caster) : _caster(caster)
+ {
+ }
+
+ bool Execute(uint64 /*execTime*/, uint32 /*diff*/)
+ {
+ _caster->CastSpell((Unit*)NULL, SPELL_COSMIC_SMASH_TRIGGERED, TRIGGERED_FULL_MASK);
+ return true;
+ }
+
+ private:
+ Unit* _caster;
+};
+
+class SummonUnleashedDarkMatter : public BasicEvent
+{
+ public:
+ SummonUnleashedDarkMatter(Unit* caster) : _caster(caster)
+ {
+ }
+
+ bool Execute(uint64 execTime, uint32 /*diff*/)
+ {
+ _caster->CastSpell((Unit*)NULL, SPELL_SUMMON_UNLEASHED_DARK_MATTER, TRIGGERED_FULL_MASK);
+ _caster->m_Events.AddEvent(this, execTime + 30000);
+ return false;
+ }
+
+ private:
+ Unit* _caster;
+};
+
+class boss_algalon_the_observer : public CreatureScript
+{
+ public:
+ boss_algalon_the_observer() : CreatureScript("boss_algalon_the_observer") {}
+
+ struct boss_algalon_the_observerAI : public BossAI
+ {
+ boss_algalon_the_observerAI(Creature* creature) : BossAI(creature, BOSS_ALGALON)
+ {
+ _firstPull = true;
+ _fedOnTears = false;
+ }
+
+ void Reset()
+ {
+ _Reset();
+ me->SetReactState(REACT_PASSIVE);
+ _phaseTwo = false;
+ _fightWon = false;
+ _hasYelled = false;
+ }
+
+ void KilledUnit(Unit* victim)
+ {
+ if (victim->GetTypeId() == TYPEID_UNIT)
+ {
+ _fedOnTears = true;
+ if (!_hasYelled)
+ {
+ _hasYelled = true;
+ events.ScheduleEvent(EVENT_UNLOCK_YELL, 1000);
+ Talk(SAY_ALGALON_KILL);
+ }
+ }
+ }
+
+ void DoAction(int32 const action)
+ {
+ switch (action)
+ {
+ case ACTION_START_INTRO:
+ {
+ me->SetFlag(UNIT_FIELD_FLAGS_2, 0x20);
+ me->SetDisableGravity(true);
+ DoCast(me, SPELL_ARRIVAL, true);
+ DoCast(me, SPELL_RIDE_THE_LIGHTNING, true);
+ me->GetMotionMaster()->MovePoint(POINT_ALGALON_LAND, AlgalonLandPos);
+ me->SetHomePosition(AlgalonLandPos);
+ Movement::MoveSplineInit init(*me);
+ init.MoveTo(AlgalonLandPos.GetPositionX(), AlgalonLandPos.GetPositionY(), AlgalonLandPos.GetPositionZ());
+ init.SetOrientationFixed(true);
+ init.Launch();
+ events.Reset();
+ events.SetPhase(PHASE_ROLE_PLAY);
+ events.ScheduleEvent(EVENT_INTRO_1, 5000, 0, PHASE_ROLE_PLAY);
+ events.ScheduleEvent(EVENT_INTRO_2, 15000, 0, PHASE_ROLE_PLAY);
+ events.ScheduleEvent(EVENT_INTRO_3, 23000, 0, PHASE_ROLE_PLAY);
+ events.ScheduleEvent(EVENT_INTRO_FINISH, 36000, 0, PHASE_ROLE_PLAY);
+ break;
+ }
+ case ACTION_ASCEND:
+ events.SetPhase(PHASE_BIG_BANG);
+ events.CancelEvent(EVENT_RESUME_UPDATING);
+ events.ScheduleEvent(EVENT_ASCEND_TO_THE_HEAVENS, 1500);
+ break;
+ case EVENT_DESPAWN_ALGALON:
+ events.Reset();
+ events.SetPhase(PHASE_ROLE_PLAY);
+ if (me->isInCombat())
+ events.ScheduleEvent(EVENT_ASCEND_TO_THE_HEAVENS, 1);
+ events.ScheduleEvent(EVENT_DESPAWN_ALGALON_1, 5000);
+ events.ScheduleEvent(EVENT_DESPAWN_ALGALON_2, 17000);
+ events.ScheduleEvent(EVENT_DESPAWN_ALGALON_3, 26000);
+ me->DespawnOrUnsummon(34000);
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_IMMUNE_TO_NPC);
+ break;
+ case ACTION_INIT_ALGALON:
+ _firstPull = false;
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ break;;
+ }
+ }
+
+ uint32 GetData(uint32 type)
+ {
+ return type == DATA_HAS_FED_ON_TEARS ? _fedOnTears : 1;
+ }
+
+ void EnterCombat(Unit* /*target*/)
+ {
+ uint32 introDelay = 0;
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_IMMUNE_TO_NPC);
+ events.Reset();
+ events.SetPhase(PHASE_ROLE_PLAY);
+
+ if (!_firstPull)
+ {
+ Talk(SAY_ALGALON_AGGRO);
+ _EnterCombat();
+ introDelay = 8000;
+ }
+ else
+ {
+ _firstPull = false;
+ Talk(SAY_ALGALON_START_TIMER);
+ if (Creature* brann = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_BRANN_BRONZEBEARD_ALG)))
+ brann->AI()->DoAction(ACTION_FINISH_INTRO);
+
+ me->setActive(true);
+ DoZoneInCombat();
+ introDelay = 26000;
+ summons.DespawnEntry(NPC_AZEROTH);
+ instance->SetData(EVENT_DESPAWN_ALGALON, 0);
+ events.ScheduleEvent(EVENT_START_COMBAT, 18000);
+ }
+
+ events.ScheduleEvent(EVENT_INTRO_TIMER_DONE, introDelay);
+ events.ScheduleEvent(EVENT_QUANTUM_STRIKE, 3500 + introDelay);
+ events.ScheduleEvent(EVENT_PHASE_PUNCH, 15500 + introDelay);
+ events.ScheduleEvent(EVENT_SUMMON_COLLAPSING_STAR, 18000 + introDelay);
+ events.ScheduleEvent(EVENT_BIG_BANG, 90000 + introDelay);
+ events.ScheduleEvent(EVENT_ASCEND_TO_THE_HEAVENS, 360000 + introDelay);
+ events.ScheduleEvent(EVENT_COSMIC_SMASH, 25000 + introDelay);
+
+ std::list<Creature*> stalkers;
+ me->GetCreatureListWithEntryInGrid(stalkers, NPC_ALGALON_STALKER, 200.0f);
+ for (std::list<Creature*>::iterator itr = stalkers.begin(); itr != stalkers.end(); ++itr)
+ (*itr)->m_Events.KillAllEvents(true);
+ }
+
+ void MovementInform(uint32 movementType, uint32 pointId)
+ {
+ if (movementType != POINT_MOTION_TYPE)
+ return;
+
+ if (pointId == POINT_ALGALON_LAND)
+ me->SetDisableGravity(false);
+ else if (pointId == POINT_ALGALON_OUTRO)
+ {
+ me->SetFacingTo(1.605703f);
+ events.ScheduleEvent(EVENT_OUTRO_3, 1200);
+ events.ScheduleEvent(EVENT_OUTRO_4, 2400);
+ events.ScheduleEvent(EVENT_OUTRO_5, 8500);
+ events.ScheduleEvent(EVENT_OUTRO_6, 15500);
+ events.ScheduleEvent(EVENT_OUTRO_7, 55500);
+ events.ScheduleEvent(EVENT_OUTRO_8, 73500);
+ events.ScheduleEvent(EVENT_OUTRO_9, 85500);
+ events.ScheduleEvent(EVENT_OUTRO_10, 108500);
+ events.ScheduleEvent(EVENT_OUTRO_11, 123500);
+ }
+ }
+
+ void JustSummoned(Creature* summon)
+ {
+ summons.Summon(summon);
+ switch (summon->GetEntry())
+ {
+ case NPC_AZEROTH:
+ DoCastAOE(SPELL_REORIGINATION, true);
+ break;
+ case NPC_COLLAPSING_STAR:
+ summon->SetReactState(REACT_PASSIVE);
+ summon->GetMotionMaster()->MoveRandom(20.0f);
+ summon->CastSpell(summon, SPELL_COLLAPSE, TRIGGERED_FULL_MASK);
+ break;
+ case NPC_BLACK_HOLE:
+ summon->SetReactState(REACT_PASSIVE);
+ summon->CastSpell((Unit*)NULL, SPELL_BLACK_HOLE_TRIGGER, TRIGGERED_FULL_MASK);
+ summon->CastSpell(summon, SPELL_CONSTELLATION_PHASE_TRIGGER, TRIGGERED_FULL_MASK);
+ summon->CastSpell((Unit*)NULL, SPELL_BLACK_HOLE_EXPLOSION);
+ summon->CastSpell(summon, SPELL_SUMMON_VOID_ZONE_VISUAL, TRIGGERED_FULL_MASK);
+ break;
+ case NPC_ALGALON_VOID_ZONE_VISUAL_STALKER:
+ summon->CastSpell(summon, SPELL_VOID_ZONE_VISUAL, TRIGGERED_FULL_MASK);
+ break;
+ case NPC_ALGALON_STALKER_ASTEROID_TARGET_01:
+ summon->CastSpell(summon, SPELL_COSMIC_SMASH_VISUAL_STATE, TRIGGERED_FULL_MASK);
+ break;
+ case NPC_ALGALON_STALKER_ASTEROID_TARGET_02:
+ summon->m_Events.AddEvent(new CosmicSmashDamageEvent(summon), summon->m_Events.CalculateTime(3250));
+ break;
+ case NPC_WORM_HOLE:
+ summon->SetReactState(REACT_PASSIVE);
+ summon->CastSpell(summon, SPELL_WORM_HOLE_TRIGGER, TRIGGERED_FULL_MASK);
+ summon->CastSpell(summon, SPELL_SUMMON_VOID_ZONE_VISUAL, TRIGGERED_FULL_MASK);
+ break;
+ case NPC_UNLEASHED_DARK_MATTER:
+ if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me)))
+ if (summon->Attack(target, true))
+ summon->GetMotionMaster()->MoveChase(target);
+ break;
+ }
+ }
+
+ void EnterEvadeMode()
+ {
+ instance->SetBossState(BOSS_ALGALON, FAIL);
+ BossAI::EnterEvadeMode();
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ me->SetSheath(SHEATH_STATE_UNARMED);
+ }
+
+ void DamageTaken(Unit* /*attacker*/, uint32& damage)
+ {
+ if (_fightWon)
+ {
+ damage = 0;
+ return;
+ }
+
+ if (!_phaseTwo && me->HealthBelowPctDamaged(20, damage))
+ {
+ _phaseTwo = true;
+ Talk(SAY_ALGALON_PHASE_TWO);
+ summons.DespawnEntry(NPC_LIVING_CONSTELLATION);
+ summons.DespawnEntry(NPC_COLLAPSING_STAR);
+ summons.DespawnEntry(NPC_BLACK_HOLE);
+ summons.DespawnEntry(NPC_ALGALON_VOID_ZONE_VISUAL_STALKER);
+ events.CancelEvent(EVENT_SUMMON_COLLAPSING_STAR);
+ std::list<Creature*> stalkers;
+ me->GetCreatureListWithEntryInGrid(stalkers, NPC_ALGALON_STALKER, 200.0f);
+ for (std::list<Creature*>::iterator itr = stalkers.begin(); itr != stalkers.end(); ++itr)
+ (*itr)->m_Events.KillAllEvents(true);
+ for (uint32 i = 0; i < COLLAPSING_STAR_COUNT; ++i)
+ if (Creature* wormHole = DoSummon(NPC_WORM_HOLE, CollapsingStarPos[i], TEMPSUMMON_MANUAL_DESPAWN))
+ wormHole->m_Events.AddEvent(new SummonUnleashedDarkMatter(wormHole), wormHole->m_Events.CalculateTime(i >= 2 ? 8000 : 6000));
+ }
+ else if ((int32(me->GetHealth()) - int32(damage)) < CalculatePctF<int32>(int32(me->GetMaxHealth()), 2.5f) && !_fightWon)
+ {
+ _fightWon = true;
+ damage = 0;
+ me->SetReactState(REACT_PASSIVE);
+ me->AttackStop();
+ me->setFaction(35);
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ DoCast(me, SPELL_SELF_STUN);
+ events.Reset();
+ summons.DespawnAll();
+ events.SetPhase(PHASE_ROLE_PLAY);
+ events.ScheduleEvent(EVENT_OUTRO_START, 1500);
+ events.ScheduleEvent(EVENT_OUTRO_1, 7200);
+ events.ScheduleEvent(EVENT_OUTRO_2, 8700);
+ }
+ }
+
+ void UpdateAI(uint32 const diff)
+ {
+ if ((!(events.GetPhaseMask() & PHASE_MASK_NO_UPDATE) && !UpdateVictim()) || !CheckInRoom())
+ return;
+
+ events.Update(diff);
+
+ if (!(events.GetPhaseMask() & PHASE_MASK_NO_CAST_CHECK))
+ if (me->HasUnitState(UNIT_STATE_CASTING))
+ return;
+
+ while (uint32 eventId = events.ExecuteEvent())
+ {
+ switch (eventId)
+ {
+ case EVENT_INTRO_1:
+ me->RemoveAurasDueToSpell(SPELL_RIDE_THE_LIGHTNING);
+ Talk(SAY_ALGALON_INTRO_1);
+ break;
+ case EVENT_INTRO_2:
+ DoCastAOE(SPELL_SUMMON_AZEROTH, true);
+ Talk(SAY_ALGALON_INTRO_2);
+ break;
+ case EVENT_INTRO_3:
+ Talk(SAY_ALGALON_INTRO_3);
+ break;
+ case EVENT_INTRO_FINISH:
+ events.Reset();
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ break;
+ case EVENT_START_COMBAT:
+ instance->SetBossState(BOSS_ALGALON, IN_PROGRESS);
+ break;
+ case EVENT_INTRO_TIMER_DONE:
+ {
+ events.SetPhase(PHASE_NORMAL);
+ me->SetSheath(SHEATH_STATE_MELEE);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_IMMUNE_TO_NPC);
+ me->SetReactState(REACT_DEFENSIVE);
+ DoCastAOE(SPELL_SUPERMASSIVE_FAIL, true);
+ //! Workaround for Creature::_IsTargetAcceptable returning false
+ //! for creatures that start combat in REACT_PASSIVE and UNIT_FLAG_NOT_SELECTABLE
+ //! causing them to immediately evade
+ if (!me->getThreatManager().isThreatListEmpty())
+ AttackStart(me->getThreatManager().getHostilTarget());
+ for (uint32 i = 0; i < LIVING_CONSTELLATION_COUNT; ++i)
+ if (Creature* summon = DoSummon(NPC_LIVING_CONSTELLATION, ConstellationPos[i], 0, TEMPSUMMON_DEAD_DESPAWN))
+ summon->SetReactState(REACT_PASSIVE);
+
+ std::list<Creature*> stalkers;
+ me->GetCreatureListWithEntryInGrid(stalkers, NPC_ALGALON_STALKER, 200.0f);
+ if (!stalkers.empty())
+ {
+ Unit* stalker = Trinity::Containers::SelectRandomContainerElement(stalkers);
+ stalker->m_Events.AddEvent(new ActivateLivingConstellation(stalker), stalker->m_Events.CalculateTime(urand(45000, 50000)));
+ }
+ break;
+ }
+ case EVENT_QUANTUM_STRIKE:
+ DoCastVictim(SPELL_QUANTUM_STRIKE);
+ events.ScheduleEvent(EVENT_QUANTUM_STRIKE, urand(3000, 5000));
+ break;
+ case EVENT_PHASE_PUNCH:
+ DoCastVictim(SPELL_PHASE_PUNCH);
+ events.ScheduleEvent(EVENT_PHASE_PUNCH, 15500);
+ break;
+ case EVENT_SUMMON_COLLAPSING_STAR:
+ Talk(SAY_ALGALON_COLLAPSING_STAR);
+ Talk(EMOTE_ALGALON_COLLAPSING_STAR);
+ for (uint32 i = 0; i < COLLAPSING_STAR_COUNT; ++i)
+ me->SummonCreature(NPC_COLLAPSING_STAR, CollapsingStarPos[i], TEMPSUMMON_CORPSE_DESPAWN);
+ events.ScheduleEvent(EVENT_SUMMON_COLLAPSING_STAR, 60000);
+ break;
+ case EVENT_BIG_BANG:
+ {
+ Talk(SAY_ALGALON_BIG_BANG);
+ Talk(EMOTE_ALGALON_BIG_BANG);
+ events.SetPhase(PHASE_BIG_BANG);
+ std::list<Creature*> constellations;
+ me->GetCreatureListWithEntryInGrid(constellations, NPC_LIVING_CONSTELLATION, 200.0f);
+ for (std::list<Creature*>::iterator itr = constellations.begin(); itr != constellations.end(); ++itr)
+ (*itr)->AI()->DoAction(ACTION_BIG_BANG);
+ DoCastAOE(SPELL_BIG_BANG);
+ events.ScheduleEvent(EVENT_BIG_BANG, 90500);
+ events.ScheduleEvent(EVENT_RESUME_UPDATING, 9500);
+ break;
+ }
+ case EVENT_RESUME_UPDATING:
+ events.SetPhase(0);
+ break;
+ case EVENT_ASCEND_TO_THE_HEAVENS:
+ Talk(SAY_ALGALON_ASCEND);
+ DoCastAOE(SPELL_ASCEND_TO_THE_HEAVENS);
+ events.ScheduleEvent(EVENT_EVADE, 2500);
+ break;
+ case EVENT_EVADE:
+ EnterEvadeMode();
+ break;
+ case EVENT_COSMIC_SMASH:
+ Talk(EMOTE_ALGALON_COSMIC_SMASH);
+ DoCastAOE(SPELL_COSMIC_SMASH);
+ events.ScheduleEvent(EVENT_COSMIC_SMASH, 25500);
+ break;
+ case EVENT_UNLOCK_YELL:
+ _hasYelled = false;
+ break;
+ case EVENT_OUTRO_START:
+ instance->SetBossState(BOSS_ALGALON, DONE);
+ break;
+ case EVENT_OUTRO_1:
+ me->RemoveAllAuras();
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_RENAME);
+ break;
+ case EVENT_OUTRO_2:
+ _EnterEvadeMode();
+ me->AddUnitState(UNIT_STATE_EVADE);
+ me->GetMotionMaster()->MovePoint(POINT_ALGALON_OUTRO, AlgalonOutroPos);
+ break;
+ case EVENT_OUTRO_3:
+ DoCastAOE(SPELL_KILL_CREDIT);
+ break;
+ case EVENT_OUTRO_4:
+ DoCastAOE(SPELL_SUPERMASSIVE_FAIL);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ break;
+ case EVENT_OUTRO_5:
+ if (Creature* brann = DoSummon(NPC_BRANN_BRONZBEARD_ALG, BrannOutroPos[0], 131500, TEMPSUMMON_TIMED_DESPAWN))
+ brann->AI()->DoAction(ACTION_OUTRO);
+ break;
+ case EVENT_OUTRO_6:
+ Talk(SAY_ALGALON_OUTRO_1);
+ me->SetStandState(UNIT_STAND_STATE_KNEEL);
+ break;
+ case EVENT_OUTRO_7:
+ Talk(SAY_ALGALON_OUTRO_2);
+ break;
+ case EVENT_OUTRO_8:
+ Talk(SAY_ALGALON_OUTRO_3);
+ break;
+ case EVENT_OUTRO_9:
+ Talk(SAY_ALGALON_OUTRO_4);
+ break;
+ case EVENT_OUTRO_10:
+ Talk(SAY_ALGALON_OUTRO_5);
+ break;
+ case EVENT_OUTRO_11:
+ me->SetStandState(UNIT_STAND_STATE_STAND);
+ DoCast(me, SPELL_TELEPORT);
+ me->DespawnOrUnsummon(1500);
+ break;
+ }
+ }
+
+ DoMeleeAttackIfReady();
+ }
+
+ private:
+ bool _firstPull;
+ bool _fedOnTears;
+ bool _phaseTwo;
+ bool _fightWon;
+ bool _hasYelled;
+ };
+
+ CreatureAI* GetAI(Creature* creature) const
+ {
+ return GetUlduarAI<boss_algalon_the_observerAI>(creature);
+ }
+};
+
+class npc_living_constellation : public CreatureScript
+{
+ public:
+ npc_living_constellation() : CreatureScript("npc_living_constellation") { }
+
+ struct npc_living_constellationAI : public CreatureAI
+ {
+ npc_living_constellationAI(Creature* creature) : CreatureAI(creature)
+ {
+ }
+
+ void Reset()
+ {
+ _events.Reset();
+ _events.ScheduleEvent(EVENT_ARCANE_BARRAGE, 2500);
+ _isActive = false;
+ }
+
+ uint32 GetData(uint32 /*type*/)
+ {
+ return _isActive ? 1 : 0;
+ }
+
+ void DoAction(int32 const action)
+ {
+ switch (action)
+ {
+ case ACTION_ACTIVATE_STAR:
+ if (Creature* algalon = me->FindNearestCreature(NPC_ALGALON, 200.0f))
+ {
+ if (Unit* target = algalon->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(algalon)))
+ {
+ me->SetReactState(REACT_AGGRESSIVE);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ AttackStart(target);
+ DoZoneInCombat();
+ _isActive = true;
+ }
+ }
+ break;
+ case ACTION_BIG_BANG:
+ _events.SetPhase(PHASE_BIG_BANG);
+ _events.DelayEvents(9500);
+ _events.ScheduleEvent(EVENT_RESUME_UPDATING, 9500);
+ break;
+ }
+ }
+
+ void SpellHit(Unit* caster, SpellInfo const* spell)
+ {
+ if (spell->Id != SPELL_CONSTELLATION_PHASE_EFFECT || caster->GetTypeId() != TYPEID_UNIT)
+ return;
+
+ me->DespawnOrUnsummon(1);
+ if (InstanceScript* instance = me->GetInstanceScript())
+ instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EVENT_ID_SUPERMASSIVE_START);
+ caster->CastSpell((Unit*)NULL, SPELL_BLACK_HOLE_CREDIT, TRIGGERED_FULL_MASK);
+ caster->ToCreature()->DespawnOrUnsummon(1);
+ }
+
+ void UpdateAI(uint32 const diff)
+ {
+ if (!(_events.GetPhaseMask() & PHASE_MASK_NO_UPDATE) && !UpdateVictim())
+ return;
+
+ _events.Update(diff);
+
+ while (uint32 eventId = _events.ExecuteEvent())
+ {
+ switch (eventId)
+ {
+ case EVENT_ARCANE_BARRAGE:
+ DoCastAOE(SPELL_ARCANE_BARRAGE);
+ _events.ScheduleEvent(EVENT_ARCANE_BARRAGE, 2500);
+ break;
+ case EVENT_RESUME_UPDATING:
+ _events.SetPhase(0);
+ break;
+ }
+ }
+ }
+
+ private:
+ EventMap _events;
+ bool _isActive;
+ };
+
+ CreatureAI* GetAI(Creature* creature) const
+ {
+ return GetUlduarAI<npc_living_constellationAI>(creature);
+ }
+};
+
+class npc_collapsing_star : public CreatureScript
+{
+ public:
+ npc_collapsing_star() : CreatureScript("npc_collapsing_star") { }
+
+ struct npc_collapsing_starAI : public PassiveAI
+ {
+ npc_collapsing_starAI(Creature* creature) : PassiveAI(creature)
+ {
+ _dying = false;
+ }
+
+ void JustSummoned(Creature* summon)
+ {
+ if (summon->GetEntry() != NPC_BLACK_HOLE)
+ return;
+
+ if (TempSummon* summ = me->ToTempSummon())
+ if (Creature* algalon = ObjectAccessor::GetCreature(*me, summ->GetSummonerGUID()))
+ algalon->AI()->JustSummoned(summon);
+
+ me->DespawnOrUnsummon(1);
+ }
+
+ void DamageTaken(Unit* /*attacker*/, uint32& damage)
+ {
+ if (_dying)
+ {
+ damage = 0;
+ return;
+ }
+
+ if (damage >= me->GetHealth())
+ {
+ _dying = true;
+ damage = 0;
+ DoCast(me, SPELL_BLACK_HOLE_SPAWN_VISUAL, true);
+ DoCast(me, SPELL_SUMMON_BLACK_HOLE, true);
+ }
+ }
+
+ bool _dying;
+ };
+
+ CreatureAI* GetAI(Creature* creature) const
+ {
+ return GetUlduarAI<npc_collapsing_starAI>(creature);
+ }
+};
+
+class npc_brann_bronzebeard_algalon : public CreatureScript
+{
+ public:
+ npc_brann_bronzebeard_algalon() : CreatureScript("npc_brann_bronzebeard_algalon") { }
+
+ struct npc_brann_bronzebeard_algalonAI : public CreatureAI
+ {
+ npc_brann_bronzebeard_algalonAI(Creature* creature) : CreatureAI(creature)
+ {
+ }
+
+ void DoAction(int32 const action)
+ {
+ switch (action)
+ {
+ case ACTION_START_INTRO:
+ _currentPoint = 0;
+ _events.Reset();
+ me->SetWalk(false);
+ _events.ScheduleEvent(EVENT_BRANN_MOVE_INTRO, 1);
+ break;
+ case ACTION_FINISH_INTRO:
+ Talk(SAY_BRANN_ALGALON_INTRO_2);
+ _events.ScheduleEvent(EVENT_BRANN_MOVE_INTRO, 1);
+ break;
+ case ACTION_OUTRO:
+ me->GetMotionMaster()->MovePoint(POINT_BRANN_OUTRO, BrannOutroPos[1]);
+ _events.ScheduleEvent(EVENT_BRANN_OUTRO_1, 89500);
+ _events.ScheduleEvent(EVENT_BRANN_OUTRO_2, 116500);
+ break;
+ }
+ }
+
+ void MovementInform(uint32 movementType, uint32 pointId)
+ {
+ if (movementType != POINT_MOTION_TYPE)
+ return;
+
+ uint32 delay = 1;
+ _currentPoint = pointId + 1;
+ switch (pointId)
+ {
+ case 2:
+ delay = 8000;
+ me->SetWalk(true);
+ break;
+ case 5:
+ me->SetWalk(false);
+ Talk(SAY_BRANN_ALGALON_INTRO_1);
+ _events.ScheduleEvent(EVENT_SUMMON_ALGALON, 7500);
+ return;
+ case 9:
+ me->DespawnOrUnsummon(1);
+ return;
+ case POINT_BRANN_OUTRO:
+ case POINT_BRANN_OUTRO_END:
+ return;
+ }
+
+ _events.ScheduleEvent(EVENT_BRANN_MOVE_INTRO, delay);
+ }
+
+ void UpdateAI(uint32 const diff)
+ {
+ UpdateVictim();
+
+ if (_events.Empty())
+ return;
+
+ _events.Update(diff);
+
+ while (uint32 eventId = _events.ExecuteEvent())
+ {
+ switch (eventId)
+ {
+ case EVENT_BRANN_MOVE_INTRO:
+ if (_currentPoint < MAX_BRANN_WAYPOINTS_INTRO)
+ me->GetMotionMaster()->MovePoint(_currentPoint, BrannIntroWaypoint[_currentPoint]);
+ break;
+ case EVENT_SUMMON_ALGALON:
+ if (Creature* algalon = me->GetMap()->SummonCreature(NPC_ALGALON, AlgalonSummonPos))
+ algalon->AI()->DoAction(ACTION_START_INTRO);
+ break;
+ case EVENT_BRANN_OUTRO_1:
+ Talk(SAY_BRANN_ALGALON_OUTRO);
+ break;
+ case EVENT_BRANN_OUTRO_2:
+ me->GetMotionMaster()->MovePoint(POINT_BRANN_OUTRO_END, BrannOutroPos[2]);
+ break;
+ }
+ }
+ }
+
+ private:
+ EventMap _events;
+ uint32 _currentPoint;
+ };
+
+ CreatureAI* GetAI(Creature* creature) const
+ {
+ return GetUlduarAI<npc_brann_bronzebeard_algalonAI>(creature);
+ }
+};
+
+class go_celestial_planetarium_access : public GameObjectScript
+{
+ public:
+ go_celestial_planetarium_access() : GameObjectScript("go_celestial_planetarium_access") {}
+
+ struct go_celestial_planetarium_accessAI : public GameObjectAI
+ {
+ go_celestial_planetarium_accessAI(GameObject* go) : GameObjectAI(go)
+ {
+ }
+
+ bool GossipHello(Player* player)
+ {
+ bool hasKey = true;
+ if (LockEntry const* lock = sLockStore.LookupEntry(go->GetGOInfo()->goober.lockId))
+ {
+ hasKey = false;
+ for (uint32 i = 0; i < MAX_LOCK_CASE; ++i)
+ {
+ if (!lock->Index[i])
+ continue;
+
+ if (player->HasItemCount(lock->Index[i], 1))
+ {
+ hasKey = true;
+ break;
+ }
+ }
+ }
+
+ if (!hasKey)
+ return false;
+
+ // Start Algalon event
+ go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
+ _events.ScheduleEvent(EVENT_DESPAWN_CONSOLE, 5000);
+ if (Creature* brann = go->SummonCreature(NPC_BRANN_BRONZBEARD_ALG, BrannIntroSpawnPos))
+ brann->AI()->DoAction(ACTION_START_INTRO);
+
+ if (InstanceScript* instance = go->GetInstanceScript())
+ {
+ instance->SetData(DATA_ALGALON_SUMMON_STATE, 1);
+ if (GameObject* sigil = ObjectAccessor::GetGameObject(*go, instance->GetData64(DATA_SIGILDOOR_01)))
+ sigil->SetGoState(GO_STATE_ACTIVE);
+
+ if (GameObject* sigil = ObjectAccessor::GetGameObject(*go, instance->GetData64(DATA_SIGILDOOR_02)))
+ sigil->SetGoState(GO_STATE_ACTIVE);
+ }
+
+ return false;
+ }
+
+ void UpdateAI(uint32 diff)
+ {
+ if (_events.Empty())
+ return;
+
+ _events.Update(diff);
+
+ while (uint32 eventId = _events.ExecuteEvent())
+ {
+ switch (eventId)
+ {
+ case EVENT_DESPAWN_CONSOLE:
+ go->Delete();
+ break;
+ }
+ }
+ }
+
+ EventMap _events;
+ };
+
+ GameObjectAI* GetAI(GameObject* go) const
+ {
+ return GetUlduarAI<go_celestial_planetarium_accessAI>(go);
+ }
+};
+
+class spell_algalon_phase_punch : public SpellScriptLoader
+{
+ public:
+ spell_algalon_phase_punch() : SpellScriptLoader("spell_algalon_phase_punch") { }
+
+ class spell_algalon_phase_punch_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_algalon_phase_punch_AuraScript);
+
+ void HandlePeriodic(AuraEffect const* aurEff)
+ {
+ PreventDefaultAction();
+ if (GetStackAmount() != 1)
+ GetTarget()->RemoveAurasDueToSpell(PhasePunchAlphaId[GetStackAmount() - 2]);
+ GetTarget()->CastSpell(GetTarget(), PhasePunchAlphaId[GetStackAmount() - 1], TRIGGERED_FULL_MASK);
+ if (GetStackAmount() == 5)
+ Remove(AURA_REMOVE_BY_DEFAULT);
+ }
+
+ void OnRemove(AuraEffect const*, AuraEffectHandleModes)
+ {
+ if (GetStackAmount() != 5)
+ GetTarget()->RemoveAurasDueToSpell(PhasePunchAlphaId[GetStackAmount() - 1]);
+ }
+
+ void Register()
+ {
+ OnEffectPeriodic += AuraEffectPeriodicFn(spell_algalon_phase_punch_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
+ OnEffectRemove += AuraEffectRemoveFn(spell_algalon_phase_punch_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
+ }
+ };
+
+ AuraScript* GetAuraScript() const
+ {
+ return new spell_algalon_phase_punch_AuraScript();
+ }
+};
+
+class NotVictimFilter
+{
+ public:
+ NotVictimFilter(Unit* caster) : _victim(caster->getVictim())
+ {
+ }
+
+ bool operator()(Unit* target)
+ {
+ return target != _victim;
+ }
+
+ private:
+ Unit* _victim;
+};
+
+class spell_algalon_arcane_barrage : public SpellScriptLoader
+{
+ public:
+ spell_algalon_arcane_barrage() : SpellScriptLoader("spell_algalon_arcane_barrage") { }
+
+ class spell_algalon_arcane_barrage_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_algalon_arcane_barrage_SpellScript);
+
+ void SelectTarget(std::list<Unit*>& targets)
+ {
+ targets.remove_if(NotVictimFilter(GetCaster()));
+ }
+
+ void Register()
+ {
+ OnUnitTargetSelect += SpellUnitTargetFn(spell_algalon_arcane_barrage_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_algalon_arcane_barrage_SpellScript();
+ }
+};
+
+class ActiveConstellationFilter
+{
+ public:
+ bool operator()(Unit* target) const
+ {
+ return target->GetAI()->GetData(0);
+ }
+};
+
+class spell_algalon_trigger_3_adds : public SpellScriptLoader
+{
+ public:
+ spell_algalon_trigger_3_adds() : SpellScriptLoader("spell_algalon_trigger_3_adds") { }
+
+ class spell_algalon_trigger_3_adds_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_algalon_trigger_3_adds_SpellScript);
+
+ void SelectTarget(std::list<Unit*>& targets)
+ {
+ targets.remove_if(ActiveConstellationFilter());
+ }
+
+ void HandleDummy(SpellEffIndex effIndex)
+ {
+ PreventHitDefaultEffect(effIndex);
+ Creature* target = GetHitCreature();
+ if (!target)
+ return;
+
+ target->AI()->DoAction(ACTION_ACTIVATE_STAR);
+ }
+
+ void Register()
+ {
+ OnUnitTargetSelect += SpellUnitTargetFn(spell_algalon_trigger_3_adds_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_algalon_trigger_3_adds_SpellScript();
+ }
+};
+
+class spell_algalon_collapse : public SpellScriptLoader
+{
+ public:
+ spell_algalon_collapse() : SpellScriptLoader("spell_algalon_collapse") { }
+
+ class spell_algalon_collapse_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_algalon_collapse_AuraScript);
+
+ void HandlePeriodic(AuraEffect const* /*aurEff*/)
+ {
+ PreventDefaultAction();
+ GetTarget()->DealDamage(GetTarget(), GetTarget()->CountPctFromMaxHealth(1), NULL, NODAMAGE);
+ }
+
+ void Register()
+ {
+ OnEffectPeriodic += AuraEffectPeriodicFn(spell_algalon_collapse_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
+ }
+ };
+
+ AuraScript* GetAuraScript() const
+ {
+ return new spell_algalon_collapse_AuraScript();
+ }
+};
+
+class spell_algalon_big_bang : public SpellScriptLoader
+{
+ public:
+ spell_algalon_big_bang() : SpellScriptLoader("spell_algalon_big_bang") { }
+
+ class spell_algalon_big_bang_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_algalon_big_bang_SpellScript);
+
+ bool Load()
+ {
+ _targetCount = 0;
+ return true;
+ }
+
+ void CountTargets(std::list<Unit*>& targets)
+ {
+ _targetCount = targets.size();
+ }
+
+ void CheckTargets()
+ {
+ if (!_targetCount)
+ GetCaster()->GetAI()->DoAction(ACTION_ASCEND);
+ }
+
+ void Register()
+ {
+ OnUnitTargetSelect += SpellUnitTargetFn(spell_algalon_big_bang_SpellScript::CountTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
+ AfterCast += SpellCastFn(spell_algalon_big_bang_SpellScript::CheckTargets);
+ }
+
+ uint32 _targetCount;
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_algalon_big_bang_SpellScript();
+ }
+};
+
+class spell_algalon_remove_phase : public SpellScriptLoader
+{
+ public:
+ spell_algalon_remove_phase() : SpellScriptLoader("spell_algalon_remove_phase") { }
+
+ class spell_algalon_remove_phase_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_algalon_remove_phase_AuraScript);
+
+ void HandlePeriodic(AuraEffect const* /*aurEff*/)
+ {
+ PreventDefaultAction();
+ GetTarget()->RemoveAurasByType(SPELL_AURA_PHASE);
+ }
+
+ void Register()
+ {
+ OnEffectPeriodic += AuraEffectPeriodicFn(spell_algalon_remove_phase_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
+ }
+ };
+
+ AuraScript* GetAuraScript() const
+ {
+ return new spell_algalon_remove_phase_AuraScript();
+ }
+};
+
+class spell_algalon_cosmic_smash : public SpellScriptLoader
+{
+ public:
+ spell_algalon_cosmic_smash() : SpellScriptLoader("spell_algalon_cosmic_smash") { }
+
+ class spell_algalon_cosmic_smash_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_algalon_cosmic_smash_SpellScript);
+
+ void ModDestHeight(SpellEffIndex /*effIndex*/)
+ {
+ Position offset = {0.0f, 0.0f, 65.0f, 0.0f};
+ const_cast<WorldLocation*>(GetTargetDest())->RelocateOffset(offset);
+ GetHitDest()->RelocateOffset(offset);
+ }
+
+ void Register()
+ {
+ OnEffectLaunch += SpellEffectFn(spell_algalon_cosmic_smash_SpellScript::ModDestHeight, EFFECT_0, SPELL_EFFECT_SUMMON);
+ }
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_algalon_cosmic_smash_SpellScript();
+ }
+};
+
+class spell_algalon_cosmic_smash_damage : public SpellScriptLoader
+{
+ public:
+ spell_algalon_cosmic_smash_damage() : SpellScriptLoader("spell_algalon_cosmic_smash_damage") { }
+
+ class spell_algalon_cosmic_smash_damage_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_algalon_cosmic_smash_damage_SpellScript);
+
+ void RecalculateDamage()
+ {
+ if (!GetTargetDest() || !GetHitUnit())
+ return;
+
+ float distance = GetHitUnit()->GetDistance2d(GetTargetDest()->GetPositionX(), GetTargetDest()->GetPositionY());
+ if (distance > 6.0f)
+ SetHitDamage(int32(float(GetHitDamage()) / distance) * 2);
+ }
+
+ void Register()
+ {
+ OnHit += SpellHitFn(spell_algalon_cosmic_smash_damage_SpellScript::RecalculateDamage);
+ }
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_algalon_cosmic_smash_damage_SpellScript();
+ }
+};
+
+class spell_algalon_supermassive_fail : public SpellScriptLoader
+{
+ public:
+ spell_algalon_supermassive_fail() : SpellScriptLoader("spell_algalon_supermassive_fail") { }
+
+ class spell_algalon_supermassive_fail_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_algalon_supermassive_fail_SpellScript);
+
+ void RecalculateDamage()
+ {
+ if (!GetHitPlayer())
+ return;
+
+ GetHitPlayer()->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_CONDITION_NO_SPELL_HIT, GetSpellInfo()->Id, true);
+ }
+
+ void Register()
+ {
+ OnHit += SpellHitFn(spell_algalon_supermassive_fail_SpellScript::RecalculateDamage);
+ }
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_algalon_supermassive_fail_SpellScript();
+ }
+};
+
+class achievement_he_feeds_on_your_tears : public AchievementCriteriaScript
+{
+ public:
+ achievement_he_feeds_on_your_tears() : AchievementCriteriaScript("achievement_he_feeds_on_your_tears") { }
+
+ bool OnCheck(Player* /*source*/, Unit* target)
+ {
+ return !target->GetAI()->GetData(DATA_HAS_FED_ON_TEARS);
+ }
+};
+
+void AddSC_boss_algalon_the_observer()
+{
+ new boss_algalon_the_observer();
+ new npc_living_constellation();
+ new npc_collapsing_star();
+ new npc_brann_bronzebeard_algalon();
+ new go_celestial_planetarium_access();
+ new spell_algalon_phase_punch();
+ new spell_algalon_arcane_barrage();
+ new spell_algalon_trigger_3_adds();
+ new spell_algalon_collapse();
+ new spell_algalon_big_bang();
+ new spell_algalon_remove_phase();
+ new spell_algalon_cosmic_smash();
+ new spell_algalon_cosmic_smash_damage();
+ new spell_algalon_supermassive_fail();
+ new achievement_he_feeds_on_your_tears();
+}
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp
index 6c2c08f07a0..472ff153d73 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp
@@ -298,14 +298,14 @@ class npc_auriaya_seeping_trigger : public CreatureScript
void Reset()
{
- me->ForcedDespawn(600000);
+ me->DespawnOrUnsummon(600000);
DoCast(me, SPELL_SEEPING_ESSENCE);
}
void UpdateAI(uint32 const /*diff*/)
{
if (instance->GetBossState(BOSS_AURIAYA) != IN_PROGRESS)
- me->ForcedDespawn();
+ me->DespawnOrUnsummon();
}
private:
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp
index 4ea38a7642d..a3c9cb847e5 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp
@@ -507,7 +507,7 @@ class boss_freya : public CreatureScript
for (uint8 n = 0; n < 3; ++n)
{
summons.remove(Elemental[n][i]->GetGUID());
- Elemental[n][i]->ForcedDespawn(5000);
+ Elemental[n][i]->DespawnOrUnsummon(5000);
trioDefeated[i] = true;
Elemental[n][i]->CastSpell(me, SPELL_REMOVE_10STACK, true);
}
@@ -664,12 +664,12 @@ class boss_freya : public CreatureScript
case NPC_DETONATING_LASHER:
summoned->CastSpell(me, SPELL_REMOVE_2STACK, true);
summoned->CastSpell(who, SPELL_DETONATE, true);
- summoned->ForcedDespawn(5000);
+ summoned->DespawnOrUnsummon(5000);
summons.remove(summoned->GetGUID());
break;
case NPC_ANCIENT_CONSERVATOR:
summoned->CastSpell(me, SPELL_REMOVE_25STACK, true);
- summoned->ForcedDespawn(5000);
+ summoned->DespawnOrUnsummon(5000);
summons.remove(summoned->GetGUID());
break;
}
@@ -1385,7 +1385,7 @@ class npc_healthy_spore : public CreatureScript
if (lifeTimer <= diff)
{
me->RemoveAurasDueToSpell(SPELL_GROW);
- me->ForcedDespawn(2200);
+ me->DespawnOrUnsummon(2200);
lifeTimer = urand(22000, 30000);
}
else
@@ -1423,7 +1423,7 @@ class npc_eonars_gift : public CreatureScript
{
me->RemoveAurasDueToSpell(SPELL_GROW);
DoCast(SPELL_LIFEBINDERS_GIFT);
- me->ForcedDespawn(2500);
+ me->DespawnOrUnsummon(2500);
lifeBindersGiftTimer = 12000;
}
else
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp
index 727f40aef81..c7091b42c5a 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp
@@ -947,13 +947,19 @@ class spell_xt002_tympanic_tantrum : public SpellScriptLoader
void FilterTargets(std::list<Unit*>& unitList)
{
- unitList.remove_if (PlayerOrPetCheck());
+ unitList.remove_if(PlayerOrPetCheck());
+ }
+
+ void RecalculateDamage()
+ {
+ SetHitDamage(GetHitUnit()->CountPctFromMaxHealth(GetHitDamage()));
}
void Register()
{
OnUnitTargetSelect += SpellUnitTargetFn(spell_xt002_tympanic_tantrum_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
OnUnitTargetSelect += SpellUnitTargetFn(spell_xt002_tympanic_tantrum_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY);
+ OnHit += SpellHitFn(spell_xt002_tympanic_tantrum_SpellScript::RecalculateDamage);
}
};
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp
index 22858cf69e5..654d763ddbc 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp
@@ -22,9 +22,14 @@
static DoorData const doorData[] =
{
- { GO_LEVIATHAN_DOOR, BOSS_LEVIATHAN, DOOR_TYPE_ROOM, BOUNDARY_S },
- { GO_XT_002_DOOR, BOSS_XT002, DOOR_TYPE_ROOM, BOUNDARY_S },
- { 0, 0, DOOR_TYPE_ROOM, BOUNDARY_NONE },
+ {GO_LEVIATHAN_DOOR, BOSS_LEVIATHAN, DOOR_TYPE_ROOM, BOUNDARY_S },
+ {GO_XT_002_DOOR, BOSS_XT002, DOOR_TYPE_ROOM, BOUNDARY_S },
+ {GO_DOODAD_UL_SIGILDOOR_03, BOSS_ALGALON, DOOR_TYPE_ROOM, BOUNDARY_W },
+ {GO_DOODAD_UL_UNIVERSEFLOOR_01, BOSS_ALGALON, DOOR_TYPE_ROOM, BOUNDARY_NONE },
+ {GO_DOODAD_UL_UNIVERSEFLOOR_02, BOSS_ALGALON, DOOR_TYPE_SPAWN_HOLE, BOUNDARY_NONE },
+ {GO_DOODAD_UL_UNIVERSEGLOBE01, BOSS_ALGALON, DOOR_TYPE_SPAWN_HOLE, BOUNDARY_NONE },
+ {GO_DOODAD_UL_ULDUAR_TRAPDOOR_03, BOSS_ALGALON, DOOR_TYPE_SPAWN_HOLE, BOUNDARY_NONE },
+ {0, 0, DOOR_TYPE_ROOM, BOUNDARY_NONE },
};
class instance_ulduar : public InstanceMapScript
@@ -36,7 +41,6 @@ class instance_ulduar : public InstanceMapScript
{
instance_ulduar_InstanceMapScript(InstanceMap* map) : InstanceScript(map) { }
- uint32 Encounter[MAX_ENCOUNTER];
std::string m_strInstData;
// Creatures
@@ -72,6 +76,12 @@ class instance_ulduar : public InstanceMapScript
uint64 HodirDoorGUID;
uint64 HodirIceDoorGUID;
uint64 ArchivumDoorGUID;
+ uint64 AlgalonSigilDoorGUID[3];
+ uint64 AlgalonFloorGUID[2];
+ uint64 AlgalonUniverseGUID;
+ uint64 AlgalonTrapdoorGUID;
+ uint64 BrannBronzebeardAlgGUID;
+ uint64 GiftOfTheObserverGUID;
// Miscellaneous
uint32 TeamInInstance;
@@ -111,35 +121,49 @@ class instance_ulduar : public InstanceMapScript
HodirDoorGUID = 0;
HodirIceDoorGUID = 0;
ArchivumDoorGUID = 0;
+ AlgalonUniverseGUID = 0;
+ AlgalonTrapdoorGUID = 0;
+ BrannBronzebeardAlgGUID = 0;
+ GiftOfTheObserverGUID = 0;
+ _algalonTimer = 61;
+ _maxArmorItemLevel = 0;
+ _maxWeaponItemLevel = 0;
TeamInInstance = 0;
HodirRareCacheData = 0;
ColossusData = 0;
elderCount = 0;
conSpeedAtory = false;
Unbroken = true;
+ _summonAlgalon = false;
- memset(Encounter, 0, sizeof(Encounter));
+ memset(AlgalonSigilDoorGUID, 0, sizeof(AlgalonSigilDoorGUID));
+ memset(AlgalonFloorGUID, 0, sizeof(AlgalonFloorGUID));
memset(XTToyPileGUIDs, 0, sizeof(XTToyPileGUIDs));
memset(AssemblyGUIDs, 0, sizeof(AssemblyGUIDs));
memset(RazorHarpoonGUIDs, 0, sizeof(RazorHarpoonGUIDs));
memset(KeeperGUIDs, 0, sizeof(KeeperGUIDs));
}
- bool IsEncounterInProgress() const
+ void FillInitialWorldStates(WorldPacket& packet)
{
- for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
- {
- if (Encounter[i] == IN_PROGRESS)
- return true;
- }
-
- return false;
+ packet << uint32(WORLD_STATE_ALGALON_TIMER_ENABLED) << uint32(_algalonTimer && _algalonTimer <= 60);
+ packet << uint32(WORLD_STATE_ALGALON_DESPAWN_TIMER) << uint32(std::min<uint32>(_algalonTimer, 60));
}
void OnPlayerEnter(Player* player)
{
if (!TeamInInstance)
TeamInInstance = player->GetTeam();
+
+ if (_summonAlgalon)
+ {
+ _summonAlgalon = false;
+ TempSummon* algalon = instance->SummonCreature(NPC_ALGALON, AlgalonLandPos);
+ if (_algalonTimer && _algalonTimer <= 60)
+ algalon->AI()->DoAction(ACTION_INIT_ALGALON);
+ else
+ algalon->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ }
}
void OnCreatureCreate(Creature* creature)
@@ -267,9 +291,32 @@ class instance_ulduar : public InstanceMapScript
if (TeamInInstance == HORDE)
creature->UpdateEntry(NPC_BATTLE_PRIEST_GINA, HORDE);
break;
+ case NPC_BRANN_BRONZBEARD_ALG:
+ BrannBronzebeardAlgGUID = creature->GetGUID();
+ break;
+ //! These creatures are summoned by something else than Algalon
+ //! but need to be controlled/despawned by him - so they need to be
+ //! registered in his summon list
+ case NPC_ALGALON_VOID_ZONE_VISUAL_STALKER:
+ case NPC_ALGALON_STALKER_ASTEROID_TARGET_01:
+ case NPC_ALGALON_STALKER_ASTEROID_TARGET_02:
+ case NPC_UNLEASHED_DARK_MATTER:
+ if (Creature* algalon = instance->GetCreature(AlgalonGUID))
+ algalon->AI()->JustSummoned(creature);
+ break;
}
+ }
- }
+ void OnCreatureRemove(Creature* creature)
+ {
+ switch (creature->GetEntry())
+ {
+ case NPC_BRANN_BRONZBEARD_ALG:
+ if (BrannBronzebeardAlgGUID == creature->GetGUID())
+ BrannBronzebeardAlgGUID = 0;
+ break;
+ }
+ }
void OnGameObjectCreate(GameObject* gameObject)
{
@@ -340,6 +387,45 @@ class instance_ulduar : public InstanceMapScript
if (GetBossState(BOSS_ASSEMBLY_OF_IRON) != DONE)
HandleGameObject(ArchivumDoorGUID, false);
break;
+ case GO_CELESTIAL_PLANETARIUM_ACCESS_10:
+ case GO_CELESTIAL_PLANETARIUM_ACCESS_25:
+ if (_algalonSummoned)
+ gameObject->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
+ break;
+ case GO_DOODAD_UL_SIGILDOOR_01:
+ AlgalonSigilDoorGUID[0] = gameObject->GetGUID();
+ if (_algalonSummoned)
+ gameObject->SetGoState(GO_STATE_ACTIVE);
+ break;
+ case GO_DOODAD_UL_SIGILDOOR_02:
+ AlgalonSigilDoorGUID[1] = gameObject->GetGUID();
+ if (_algalonSummoned)
+ gameObject->SetGoState(GO_STATE_ACTIVE);
+ break;
+ case GO_DOODAD_UL_SIGILDOOR_03:
+ AlgalonSigilDoorGUID[2] = gameObject->GetGUID();
+ AddDoor(gameObject, true);
+ break;
+ case GO_DOODAD_UL_UNIVERSEFLOOR_01:
+ AlgalonFloorGUID[0] = gameObject->GetGUID();
+ AddDoor(gameObject, true);
+ break;
+ case GO_DOODAD_UL_UNIVERSEFLOOR_02:
+ AlgalonFloorGUID[1] = gameObject->GetGUID();
+ AddDoor(gameObject, true);
+ break;
+ case GO_DOODAD_UL_UNIVERSEGLOBE01:
+ AlgalonUniverseGUID = gameObject->GetGUID();
+ AddDoor(gameObject, true);
+ break;
+ case GO_DOODAD_UL_ULDUAR_TRAPDOOR_03:
+ AlgalonTrapdoorGUID = gameObject->GetGUID();
+ AddDoor(gameObject, true);
+ break;
+ case GO_GIFT_OF_THE_OBSERVER_10:
+ case GO_GIFT_OF_THE_OBSERVER_25:
+ GiftOfTheObserverGUID = gameObject->GetGUID();
+ break;
}
}
@@ -348,10 +434,14 @@ class instance_ulduar : public InstanceMapScript
switch (gameObject->GetEntry())
{
case GO_LEVIATHAN_DOOR:
- AddDoor(gameObject, false);
- break;
case GO_XT_002_DOOR:
+ case GO_DOODAD_UL_SIGILDOOR_03:
+ case GO_DOODAD_UL_UNIVERSEFLOOR_01:
+ case GO_DOODAD_UL_UNIVERSEFLOOR_02:
+ case GO_DOODAD_UL_UNIVERSEGLOBE01:
+ case GO_DOODAD_UL_ULDUAR_TRAPDOOR_03:
AddDoor(gameObject, false);
+ break;
default:
break;
}
@@ -389,6 +479,7 @@ class instance_ulduar : public InstanceMapScript
// Flame Leviathan's Tower Event triggers
Creature* FlameLeviathan = instance->GetCreature(LeviathanGUID);
if (FlameLeviathan && FlameLeviathan->isAlive()) // No leviathan, no event triggering ;)
+ {
switch (eventId)
{
case EVENT_TOWER_OF_STORM_DESTROYED:
@@ -404,6 +495,7 @@ class instance_ulduar : public InstanceMapScript
FlameLeviathan->AI()->DoAction(ACTION_TOWER_OF_LIFE_DESTROYED);
break;
}
+ }
}
@@ -464,6 +556,52 @@ class instance_ulduar : public InstanceMapScript
if (GameObject* gameObject = instance->GetGameObject(ThorimChestGUID))
gameObject->SetRespawnTime(gameObject->GetRespawnDelay());
break;
+ case BOSS_ALGALON:
+ if (state == DONE)
+ {
+ _events.CancelEvent(EVENT_UPDATE_ALGALON_TIMER);
+ _events.CancelEvent(EVENT_DESPAWN_ALGALON);
+ DoUpdateWorldState(WORLD_STATE_ALGALON_TIMER_ENABLED, 0);
+ _algalonTimer = 61;
+ if (GameObject* gameObject = instance->GetGameObject(GiftOfTheObserverGUID))
+ gameObject->SetRespawnTime(gameObject->GetRespawnDelay());
+ // get item level (recheck weapons)
+ Map::PlayerList const& players = instance->GetPlayers();
+ for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+ if (Player* player = itr->getSource())
+ for (uint8 slot = EQUIPMENT_SLOT_MAINHAND; slot <= EQUIPMENT_SLOT_RANGED; ++slot)
+ if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
+ if (item->GetTemplate()->ItemLevel > _maxWeaponItemLevel)
+ _maxWeaponItemLevel = item->GetTemplate()->ItemLevel;
+ }
+ else if (state == IN_PROGRESS)
+ {
+ // get item level (armor cannot be swapped in combat)
+ Map::PlayerList const& players = instance->GetPlayers();
+ for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+ {
+ if (Player* player = itr->getSource())
+ {
+ for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
+ {
+ if (slot == EQUIPMENT_SLOT_TABARD || slot == EQUIPMENT_SLOT_BODY)
+ continue;
+
+ if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
+ {
+ if (slot >= EQUIPMENT_SLOT_MAINHAND && slot <= EQUIPMENT_SLOT_RANGED)
+ {
+ if (item->GetTemplate()->ItemLevel > _maxWeaponItemLevel)
+ _maxWeaponItemLevel = item->GetTemplate()->ItemLevel;
+ }
+ else if (item->GetTemplate()->ItemLevel > _maxArmorItemLevel)
+ _maxArmorItemLevel = item->GetTemplate()->ItemLevel;
+ }
+ }
+ }
+ }
+ }
+ break;
}
return true;
@@ -496,6 +634,16 @@ class instance_ulduar : public InstanceMapScript
case DATA_UNBROKEN:
Unbroken = bool(data);
break;
+ case EVENT_DESPAWN_ALGALON:
+ DoUpdateWorldState(WORLD_STATE_ALGALON_TIMER_ENABLED, 1);
+ DoUpdateWorldState(WORLD_STATE_ALGALON_DESPAWN_TIMER, 60);
+ _algalonTimer = 60;
+ _events.ScheduleEvent(EVENT_DESPAWN_ALGALON, 3600000);
+ _events.ScheduleEvent(EVENT_UPDATE_ALGALON_TIMER, 60000);
+ break;
+ case DATA_ALGALON_SUMMON_STATE:
+ _algalonSummoned = true;
+ break;
default:
break;
}
@@ -570,6 +718,22 @@ class instance_ulduar : public InstanceMapScript
return KeeperGUIDs[1];
case BOSS_STONEBARK:
return KeeperGUIDs[2];
+ case DATA_SIGILDOOR_01:
+ return AlgalonSigilDoorGUID[0];
+ case DATA_SIGILDOOR_02:
+ return AlgalonSigilDoorGUID[1];
+ case DATA_SIGILDOOR_03:
+ return AlgalonSigilDoorGUID[2];
+ case DATA_UNIVERSE_FLOOR_01:
+ return AlgalonFloorGUID[0];
+ case DATA_UNIVERSE_FLOOR_02:
+ return AlgalonFloorGUID[1];
+ case DATA_UNIVERSE_GLOBE:
+ return AlgalonUniverseGUID;
+ case DATA_ALGALON_TRAPDOOR:
+ return AlgalonTrapdoorGUID;
+ case DATA_BRANN_BRONZEBEARD_ALG:
+ return BrannBronzebeardAlgGUID;
}
return 0;
@@ -592,12 +756,23 @@ class instance_ulduar : public InstanceMapScript
return 0;
}
+ bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* , Unit const* /* = NULL */, uint32 /* = 0 */)
+ {
+ switch (criteriaId)
+ {
+ case CRITERIA_HERALD_OF_TITANS:
+ return _maxArmorItemLevel <= MAX_HERALD_ARMOR_ITEMLEVEL && _maxWeaponItemLevel <= MAX_HERALD_WEAPON_ITEMLEVEL;
+ }
+
+ return false;
+ }
+
std::string GetSaveData()
{
OUT_SAVE_INST_DATA;
std::ostringstream saveStream;
- saveStream << "U U " << GetBossSaveData() << GetData(DATA_COLOSSUS);
+ saveStream << "U U " << GetBossSaveData() << GetData(DATA_COLOSSUS) << ' ' << _algalonTimer << ' ' << (_algalonSummoned ? 1 : 0);
OUT_SAVE_INST_DATA_COMPLETE;
return saveStream.str();
@@ -627,15 +802,68 @@ class instance_ulduar : public InstanceMapScript
if (tmpState == IN_PROGRESS || tmpState > SPECIAL)
tmpState = NOT_STARTED;
- if (i == DATA_COLOSSUS)
- SetData(i, tmpState);
- else
- SetBossState(i, EncounterState(tmpState));
+ SetBossState(i, EncounterState(tmpState));
+ }
+
+ uint32 tempState;
+ loadStream >> tempState;
+ if (tempState == IN_PROGRESS || tempState > SPECIAL)
+ tempState = NOT_STARTED;
+ SetData(DATA_COLOSSUS, tempState);
+
+ loadStream >> _algalonTimer;
+ loadStream >> tempState;
+ _algalonSummoned = tempState != 0;
+ if (_algalonSummoned && GetBossState(BOSS_ALGALON) != DONE)
+ {
+ _summonAlgalon = true;
+ if (_algalonTimer && _algalonTimer <= 60)
+ {
+ _events.ScheduleEvent(EVENT_UPDATE_ALGALON_TIMER, 60000);
+ DoUpdateWorldState(WORLD_STATE_ALGALON_TIMER_ENABLED, 1);
+ DoUpdateWorldState(WORLD_STATE_ALGALON_DESPAWN_TIMER, _algalonTimer);
+ }
}
}
OUT_LOAD_INST_DATA_COMPLETE;
}
+
+ void Update(uint32 diff)
+ {
+ if (_events.Empty())
+ return;
+
+ _events.Update(diff);
+
+ while (uint32 eventId = _events.ExecuteEvent())
+ {
+ switch (eventId)
+ {
+ case EVENT_UPDATE_ALGALON_TIMER:
+ SaveToDB();
+ DoUpdateWorldState(WORLD_STATE_ALGALON_DESPAWN_TIMER, --_algalonTimer);
+ if (_algalonTimer)
+ _events.ScheduleEvent(EVENT_UPDATE_ALGALON_TIMER, 60000);
+ else
+ {
+ DoUpdateWorldState(WORLD_STATE_ALGALON_TIMER_ENABLED, 0);
+ _events.CancelEvent(EVENT_UPDATE_ALGALON_TIMER);
+ if (Creature* algalon = instance->GetCreature(AlgalonGUID))
+ algalon->AI()->DoAction(EVENT_DESPAWN_ALGALON);
+ }
+ break;
+ }
+ }
+ }
+
+ private:
+ EventMap _events;
+ uint32 _algalonTimer;
+ bool _summonAlgalon;
+ bool _algalonSummoned;
+ uint32 _maxArmorItemLevel;
+ uint32 _maxWeaponItemLevel;
};
InstanceScript* GetInstanceScript(InstanceMap* map) const
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h
index a31954b8a16..d35f0559080 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h
@@ -21,6 +21,8 @@
#include "ObjectMgr.h"
#define UlduarScriptName "instance_ulduar"
+extern Position const AlgalonLandPos;
+
enum UlduarBosses
{
MAX_ENCOUNTER = 20,
@@ -50,98 +52,124 @@ enum UlduarBosses
enum UlduarNPCs
{
// General
- NPC_LEVIATHAN = 33113,
- NPC_SALVAGED_DEMOLISHER = 33109,
- NPC_SALVAGED_SIEGE_ENGINE = 33060,
- NPC_IGNIS = 33118,
- NPC_RAZORSCALE = 33186,
- NPC_RAZORSCALE_CONTROLLER = 33233,
- NPC_STEELFORGED_DEFFENDER = 33236,
- NPC_EXPEDITION_COMMANDER = 33210,
- NPC_XT002 = 33293,
- NPC_XT_TOY_PILE = 33337,
- NPC_STEELBREAKER = 32867,
- NPC_MOLGEIM = 32927,
- NPC_BRUNDIR = 32857,
- NPC_KOLOGARN = 32930,
- NPC_FOCUSED_EYEBEAM = 33632,
- NPC_FOCUSED_EYEBEAM_RIGHT = 33802,
- NPC_LEFT_ARM = 32933,
- NPC_RIGHT_ARM = 32934,
- NPC_RUBBLE = 33768,
- NPC_AURIAYA = 33515,
- NPC_MIMIRON = 33350,
- NPC_HODIR = 32845,
- NPC_THORIM = 32865,
- NPC_FREYA = 32906,
- NPC_VEZAX = 33271,
- NPC_YOGGSARON = 33288,
- NPC_ALGALON = 32871,
+ NPC_LEVIATHAN = 33113,
+ NPC_SALVAGED_DEMOLISHER = 33109,
+ NPC_SALVAGED_SIEGE_ENGINE = 33060,
+ NPC_IGNIS = 33118,
+ NPC_RAZORSCALE = 33186,
+ NPC_RAZORSCALE_CONTROLLER = 33233,
+ NPC_STEELFORGED_DEFFENDER = 33236,
+ NPC_EXPEDITION_COMMANDER = 33210,
+ NPC_XT002 = 33293,
+ NPC_XT_TOY_PILE = 33337,
+ NPC_STEELBREAKER = 32867,
+ NPC_MOLGEIM = 32927,
+ NPC_BRUNDIR = 32857,
+ NPC_KOLOGARN = 32930,
+ NPC_FOCUSED_EYEBEAM = 33632,
+ NPC_FOCUSED_EYEBEAM_RIGHT = 33802,
+ NPC_LEFT_ARM = 32933,
+ NPC_RIGHT_ARM = 32934,
+ NPC_RUBBLE = 33768,
+ NPC_AURIAYA = 33515,
+ NPC_MIMIRON = 33350,
+ NPC_HODIR = 32845,
+ NPC_THORIM = 32865,
+ NPC_FREYA = 32906,
+ NPC_VEZAX = 33271,
+ NPC_YOGGSARON = 33288,
+ NPC_ALGALON = 32871,
// Mimiron
- NPC_LEVIATHAN_MKII = 33432,
- NPC_VX_001 = 33651,
- NPC_AERIAL_COMMAND_UNIT = 33670,
+ NPC_LEVIATHAN_MKII = 33432,
+ NPC_VX_001 = 33651,
+ NPC_AERIAL_COMMAND_UNIT = 33670,
// Freya's Keepers
- NPC_IRONBRANCH = 32913,
- NPC_BRIGHTLEAF = 32915,
- NPC_STONEBARK = 32914,
+ NPC_IRONBRANCH = 32913,
+ NPC_BRIGHTLEAF = 32915,
+ NPC_STONEBARK = 32914,
// Hodir's Helper NPCs
- NPC_TOR_GREYCLOUD = 32941,
- NPC_KAR_GREYCLOUD = 33333,
- NPC_EIVI_NIGHTFEATHER = 33325,
- NPC_ELLIE_NIGHTFEATHER = 32901,
- NPC_SPIRITWALKER_TARA = 33332,
- NPC_SPIRITWALKER_YONA = 32950,
- NPC_ELEMENTALIST_MAHFUUN = 33328,
- NPC_ELEMENTALIST_AVUUN = 32900,
- NPC_AMIRA_BLAZEWEAVER = 33331,
- NPC_VEESHA_BLAZEWEAVER = 32946,
- NPC_MISSY_FLAMECUFFS = 32893,
- NPC_SISSY_FLAMECUFFS = 33327,
- NPC_BATTLE_PRIEST_ELIZA = 32948,
- NPC_BATTLE_PRIEST_GINA = 33330,
- NPC_FIELD_MEDIC_PENNY = 32897,
- NPC_FIELD_MEDIC_JESSI = 33326,
+ NPC_TOR_GREYCLOUD = 32941,
+ NPC_KAR_GREYCLOUD = 33333,
+ NPC_EIVI_NIGHTFEATHER = 33325,
+ NPC_ELLIE_NIGHTFEATHER = 32901,
+ NPC_SPIRITWALKER_TARA = 33332,
+ NPC_SPIRITWALKER_YONA = 32950,
+ NPC_ELEMENTALIST_MAHFUUN = 33328,
+ NPC_ELEMENTALIST_AVUUN = 32900,
+ NPC_AMIRA_BLAZEWEAVER = 33331,
+ NPC_VEESHA_BLAZEWEAVER = 32946,
+ NPC_MISSY_FLAMECUFFS = 32893,
+ NPC_SISSY_FLAMECUFFS = 33327,
+ NPC_BATTLE_PRIEST_ELIZA = 32948,
+ NPC_BATTLE_PRIEST_GINA = 33330,
+ NPC_FIELD_MEDIC_PENNY = 32897,
+ NPC_FIELD_MEDIC_JESSI = 33326,
// Freya's trash NPCs
- NPC_CORRUPTED_SERVITOR = 33354,
- NPC_MISGUIDED_NYMPH = 33355,
- NPC_GUARDIAN_LASHER = 33430,
- NPC_FOREST_SWARMER = 33431,
- NPC_MANGROVE_ENT = 33525,
- NPC_IRONROOT_LASHER = 33526,
- NPC_NATURES_BLADE = 33527,
- NPC_GUARDIAN_OF_LIFE = 33528,
+ NPC_CORRUPTED_SERVITOR = 33354,
+ NPC_MISGUIDED_NYMPH = 33355,
+ NPC_GUARDIAN_LASHER = 33430,
+ NPC_FOREST_SWARMER = 33431,
+ NPC_MANGROVE_ENT = 33525,
+ NPC_IRONROOT_LASHER = 33526,
+ NPC_NATURES_BLADE = 33527,
+ NPC_GUARDIAN_OF_LIFE = 33528,
+
+ // Algalon the Observer
+ NPC_BRANN_BRONZBEARD_ALG = 34064,
+ NPC_AZEROTH = 34246,
+ NPC_LIVING_CONSTELLATION = 33052,
+ NPC_ALGALON_STALKER = 33086,
+ NPC_COLLAPSING_STAR = 32955,
+ NPC_BLACK_HOLE = 32953,
+ NPC_WORM_HOLE = 34099,
+ NPC_ALGALON_VOID_ZONE_VISUAL_STALKER = 34100,
+ NPC_ALGALON_STALKER_ASTEROID_TARGET_01 = 33104,
+ NPC_ALGALON_STALKER_ASTEROID_TARGET_02 = 33105,
+ NPC_UNLEASHED_DARK_MATTER = 34097,
};
enum UlduarGameObjects
{
- GO_KOLOGARN_CHEST_HERO = 195047,
- GO_KOLOGARN_CHEST = 195046,
- GO_KOLOGARN_BRIDGE = 194232,
- GO_KOLOGARN_DOOR = 194553,
- GO_THORIM_CHEST_HERO = 194315,
- GO_THORIM_CHEST = 194314,
- GO_HODIR_RARE_CACHE_OF_WINTER = 194200,
- GO_HODIR_RARE_CACHE_OF_WINTER_HERO = 194201,
- GO_HODIR_CHEST_HERO = 194308,
- GO_HODIR_CHEST = 194307,
- GO_LEVIATHAN_DOOR = 194905,
- GO_LEVIATHAN_GATE = 194630,
- GO_XT_002_DOOR = 194631,
- GO_VEZAX_DOOR = 194750,
- GO_MOLE_MACHINE = 194316,
- GO_RAZOR_HARPOON_1 = 194542,
- GO_RAZOR_HARPOON_2 = 194541,
- GO_RAZOR_HARPOON_3 = 194543,
- GO_RAZOR_HARPOON_4 = 194519,
- GO_RAZOR_BROKEN_HARPOON = 194565,
- GO_HODIR_DOOR = 194634,
- GO_HODIR_ICE_DOOR = 194441,
- GO_ARCHIVUM_DOOR = 194556,
+ GO_KOLOGARN_CHEST_HERO = 195047,
+ GO_KOLOGARN_CHEST = 195046,
+ GO_KOLOGARN_BRIDGE = 194232,
+ GO_KOLOGARN_DOOR = 194553,
+ GO_THORIM_CHEST_HERO = 194315,
+ GO_THORIM_CHEST = 194314,
+ GO_HODIR_RARE_CACHE_OF_WINTER = 194200,
+ GO_HODIR_RARE_CACHE_OF_WINTER_HERO = 194201,
+ GO_HODIR_CHEST_HERO = 194308,
+ GO_HODIR_CHEST = 194307,
+ GO_LEVIATHAN_DOOR = 194905,
+ GO_LEVIATHAN_GATE = 194630,
+ GO_XT_002_DOOR = 194631,
+ GO_VEZAX_DOOR = 194750,
+ GO_MOLE_MACHINE = 194316,
+ GO_RAZOR_HARPOON_1 = 194542,
+ GO_RAZOR_HARPOON_2 = 194541,
+ GO_RAZOR_HARPOON_3 = 194543,
+ GO_RAZOR_HARPOON_4 = 194519,
+ GO_RAZOR_BROKEN_HARPOON = 194565,
+ GO_HODIR_DOOR = 194634,
+ GO_HODIR_ICE_DOOR = 194441,
+ GO_ARCHIVUM_DOOR = 194556,
+
+ // Algalon the Observer
+ GO_CELESTIAL_PLANETARIUM_ACCESS_10 = 194628,
+ GO_CELESTIAL_PLANETARIUM_ACCESS_25 = 194752,
+ GO_DOODAD_UL_SIGILDOOR_01 = 194767,
+ GO_DOODAD_UL_SIGILDOOR_02 = 194911,
+ GO_DOODAD_UL_SIGILDOOR_03 = 194910,
+ GO_DOODAD_UL_UNIVERSEFLOOR_01 = 194715,
+ GO_DOODAD_UL_UNIVERSEFLOOR_02 = 194716,
+ GO_DOODAD_UL_UNIVERSEGLOBE01 = 194148,
+ GO_DOODAD_UL_ULDUAR_TRAPDOOR_03 = 194253,
+ GO_GIFT_OF_THE_OBSERVER_10 = 194821,
+ GO_GIFT_OF_THE_OBSERVER_25 = 194822,
};
enum LeviathanData
@@ -161,6 +189,7 @@ enum UlduarAchievementCriteriaIds
{
CRITERIA_CON_SPEED_ATORY = 21597,
CRITERIA_DISARMED = 21687,
+ CRITERIA_HERALD_OF_TITANS = 10678,
};
enum UlduarData
@@ -180,12 +209,38 @@ enum UlduarData
// Hodir
DATA_HODIR_RARE_CACHE,
+
+ // Algalon the Observer
+ DATA_ALGALON_SUMMON_STATE,
+ DATA_SIGILDOOR_01,
+ DATA_SIGILDOOR_02,
+ DATA_SIGILDOOR_03,
+ DATA_UNIVERSE_FLOOR_01,
+ DATA_UNIVERSE_FLOOR_02,
+ DATA_UNIVERSE_GLOBE,
+ DATA_ALGALON_TRAPDOOR,
+ DATA_BRANN_BRONZEBEARD_ALG,
+};
+
+enum UlduarWorldStates
+{
+ WORLD_STATE_ALGALON_DESPAWN_TIMER = 4131,
+ WORLD_STATE_ALGALON_TIMER_ENABLED = 4132,
};
enum UlduarAchievementData
{
// FL Achievement boolean
DATA_UNBROKEN = 29052906, // 2905, 2906 are achievement IDs,
+ MAX_HERALD_ARMOR_ITEMLEVEL = 226,
+ MAX_HERALD_WEAPON_ITEMLEVEL = 232,
+};
+
+enum UlduarEvents
+{
+ EVENT_DESPAWN_ALGALON = 1,
+ EVENT_UPDATE_ALGALON_TIMER = 2,
+ ACTION_INIT_ALGALON = 6,
};
template<class AI>
@@ -199,6 +254,17 @@ CreatureAI* GetUlduarAI(Creature* creature)
return NULL;
}
+template<class AI>
+GameObjectAI* GetUlduarAI(GameObject* go)
+{
+ if (InstanceMap* instance = go->GetMap()->ToInstanceMap())
+ if (instance->GetInstanceScript())
+ if (instance->GetScriptId() == sObjectMgr->GetScriptId(UlduarScriptName))
+ return new AI(go);
+
+ return NULL;
+}
+
class PlayerOrPetCheck
{
public:
diff --git a/src/server/scripts/Northrend/borean_tundra.cpp b/src/server/scripts/Northrend/borean_tundra.cpp
index f83538b344c..8b51618eedd 100644
--- a/src/server/scripts/Northrend/borean_tundra.cpp
+++ b/src/server/scripts/Northrend/borean_tundra.cpp
@@ -186,7 +186,7 @@ public:
if (owner->GetTypeId() == TYPEID_PLAYER)
{
owner->CastSpell(owner, 46231, true);
- CAST_CRE(who)->ForcedDespawn();
+ CAST_CRE(who)->DespawnOrUnsummon();
}
}
}
diff --git a/src/server/scripts/Northrend/storm_peaks.cpp b/src/server/scripts/Northrend/storm_peaks.cpp
index 251bdb8278a..15239e9f836 100644
--- a/src/server/scripts/Northrend/storm_peaks.cpp
+++ b/src/server/scripts/Northrend/storm_peaks.cpp
@@ -550,7 +550,7 @@ public:
// drake unsummoned, passengers dropped
if (!me->IsOnVehicle(drake) && !hasEmptySeats)
- me->ForcedDespawn(3000);
+ me->DespawnOrUnsummon(3000);
if (enter_timer <= 0)
return;
@@ -605,7 +605,7 @@ public:
me->ExitVehicle();
me->CastSpell(me, SPELL_SUMMON_LIBERATED, true);
- me->ForcedDespawn(500);
+ me->DespawnOrUnsummon(500);
// drake is empty now, deliver credit for drake and despawn him
if (drake->GetVehicleKit()->HasEmptySeat(1) &&
@@ -616,7 +616,7 @@ public:
if (rider->ToPlayer())
rider->ToPlayer()->KilledMonsterCredit(29709, 0);
- drake->ForcedDespawn(0);
+ drake->DespawnOrUnsummon(0);
}
}
}
diff --git a/src/server/scripts/Outland/blades_edge_mountains.cpp b/src/server/scripts/Outland/blades_edge_mountains.cpp
index 7a371170d7d..cf0955ed89c 100644
--- a/src/server/scripts/Outland/blades_edge_mountains.cpp
+++ b/src/server/scripts/Outland/blades_edge_mountains.cpp
@@ -855,7 +855,7 @@ class npc_simon_bunny : public CreatureScript
if (GameObject* relic = me->FindNearestGameObject(large ? GO_APEXIS_MONUMENT : GO_APEXIS_RELIC, searchDistance))
relic->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
- me->ForcedDespawn(1000);
+ me->DespawnOrUnsummon(1000);
}
/*
diff --git a/src/server/scripts/Outland/boss_doomlord_kazzak.cpp b/src/server/scripts/Outland/boss_doomlord_kazzak.cpp
index 147d2d60359..a213713ae1a 100644
--- a/src/server/scripts/Outland/boss_doomlord_kazzak.cpp
+++ b/src/server/scripts/Outland/boss_doomlord_kazzak.cpp
@@ -31,15 +31,15 @@ enum Texts
enum Spells
{
- SPELL_SHADOWVOLLEY = 32963,
+ SPELL_SHADOW_VOLLEY = 32963,
SPELL_CLEAVE = 31779,
SPELL_THUNDERCLAP = 36706,
- SPELL_VOIDBOLT = 39329,
- SPELL_MARKOFKAZZAK = 32960,
- SPELL_MARKOFKAZZAK_DAMAGE = 32961,
+ SPELL_VOID_BOLT = 39329,
+ SPELL_MARK_OF_KAZZAK = 32960,
SPELL_ENRAGE = 32964,
- SPELL_CAPTURESOUL = 32966,
- SPELL_TWISTEDREFLECTION = 21063
+ SPELL_CAPTURE_SOUL = 32966,
+ SPELL_TWISTED_REFLECTION = 21063,
+ SPELL_BERSERK = 32965,
};
enum Events
@@ -47,10 +47,11 @@ enum Events
EVENT_SHADOW_VOLLEY = 1,
EVENT_CLEAVE = 2,
EVENT_THUNDERCLAP = 3,
- EVENT_VOIDBOLT = 4,
+ EVENT_VOID_BOLT = 4,
EVENT_MARK_OF_KAZZAK = 5,
EVENT_ENRAGE = 6,
- EVENT_TWISTED_REFLECTION = 7
+ EVENT_TWISTED_REFLECTION = 7,
+ EVENT_BERSERK = 8
};
class boss_doomlord_kazzak : public CreatureScript
@@ -70,10 +71,11 @@ class boss_doomlord_kazzak : public CreatureScript
_events.ScheduleEvent(EVENT_SHADOW_VOLLEY, urand(6000, 10000));
_events.ScheduleEvent(EVENT_CLEAVE, 7000);
_events.ScheduleEvent(EVENT_THUNDERCLAP, urand(14000, 18000));
- _events.ScheduleEvent(EVENT_VOIDBOLT, 30000);
+ _events.ScheduleEvent(EVENT_VOID_BOLT, 30000);
_events.ScheduleEvent(EVENT_MARK_OF_KAZZAK, 25000);
_events.ScheduleEvent(EVENT_ENRAGE, 60000);
_events.ScheduleEvent(EVENT_TWISTED_REFLECTION, 33000);
+ _events.ScheduleEvent(EVENT_BERSERK, 180000);
}
void JustRespawned()
@@ -92,7 +94,7 @@ class boss_doomlord_kazzak : public CreatureScript
if (victim->GetTypeId() != TYPEID_PLAYER)
return;
- DoCast(me, SPELL_CAPTURESOUL);
+ DoCast(me, SPELL_CAPTURE_SOUL);
Talk(SAY_KILL);
}
@@ -118,7 +120,7 @@ class boss_doomlord_kazzak : public CreatureScript
switch (eventId)
{
case EVENT_SHADOW_VOLLEY:
- DoCastVictim(SPELL_SHADOWVOLLEY);
+ DoCastVictim(SPELL_SHADOW_VOLLEY);
_events.ScheduleEvent(EVENT_SHADOW_VOLLEY, urand(4000, 6000));
break;
case EVENT_CLEAVE:
@@ -129,13 +131,13 @@ class boss_doomlord_kazzak : public CreatureScript
DoCastVictim(SPELL_THUNDERCLAP);
_events.ScheduleEvent(EVENT_THUNDERCLAP, urand(10000, 14000));
break;
- case EVENT_VOIDBOLT:
- DoCastVictim(SPELL_VOIDBOLT);
- _events.ScheduleEvent(EVENT_VOIDBOLT, urand(15000, 18000));
+ case EVENT_VOID_BOLT:
+ DoCastVictim(SPELL_VOID_BOLT);
+ _events.ScheduleEvent(EVENT_VOID_BOLT, urand(15000, 18000));
break;
case EVENT_MARK_OF_KAZZAK:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
- DoCast(target, SPELL_MARKOFKAZZAK);
+ DoCast(target, SPELL_MARK_OF_KAZZAK);
_events.ScheduleEvent(EVENT_MARK_OF_KAZZAK, 20000);
break;
case EVENT_ENRAGE:
@@ -145,9 +147,12 @@ class boss_doomlord_kazzak : public CreatureScript
break;
case EVENT_TWISTED_REFLECTION:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
- DoCast(target, SPELL_TWISTEDREFLECTION);
+ DoCast(target, SPELL_TWISTED_REFLECTION);
_events.ScheduleEvent(EVENT_TWISTED_REFLECTION, 15000);
break;
+ case EVENT_BERSERK:
+ DoCast(me, SPELL_BERSERK);
+ break;
default:
break;
}
diff --git a/src/server/scripts/Outland/nagrand.cpp b/src/server/scripts/Outland/nagrand.cpp
index 8080a1402af..871a2f200bb 100644
--- a/src/server/scripts/Outland/nagrand.cpp
+++ b/src/server/scripts/Outland/nagrand.cpp
@@ -450,7 +450,7 @@ public:
{
if (Say_Timer <= diff)
{
- me->ForcedDespawn();
+ me->DespawnOrUnsummon();
ReleasedFromCage = false;
}
else
@@ -689,7 +689,7 @@ class go_warmaul_prison : public GameObjectScript
player->KilledMonsterCredit(NPC_MAGHAR_PRISONER, 0);
prisoner->AI()->Talk(SAY_FREE, player->GetGUID());
- prisoner->ForcedDespawn(6000);
+ prisoner->DespawnOrUnsummon(6000);
}
return true;
}
diff --git a/src/server/scripts/Outland/netherstorm.cpp b/src/server/scripts/Outland/netherstorm.cpp
index 388d18697b9..afc18c71b92 100644
--- a/src/server/scripts/Outland/netherstorm.cpp
+++ b/src/server/scripts/Outland/netherstorm.cpp
@@ -1057,7 +1057,7 @@ class go_captain_tyralius_prison : public GameObjectScript
player->KilledMonsterCredit(NPC_CAPTAIN_TYRALIUS, 0);
tyralius->AI()->Talk(SAY_FREE);
- tyralius->ForcedDespawn(8000);
+ tyralius->DespawnOrUnsummon(8000);
}
return true;
}
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index 035f9ec98b2..7fd37ede316 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -169,7 +169,7 @@ class spell_gen_burn_brutallus : public SpellScriptLoader
}
};
-enum eCannibalizeSpells
+enum CannibalizeSpells
{
SPELL_CANNIBALIZE_TRIGGERED = 20578,
};
@@ -224,7 +224,7 @@ class spell_gen_cannibalize : public SpellScriptLoader
};
// 45472 Parachute
-enum eParachuteSpells
+enum ParachuteSpells
{
SPELL_PARACHUTE = 45472,
SPELL_PARACHUTE_BUFF = 44795,
@@ -365,7 +365,7 @@ class spell_gen_remove_flight_auras : public SpellScriptLoader
};
// 66118 Leeching Swarm
-enum eLeechingSwarmSpells
+enum LeechingSwarmSpells
{
SPELL_LEECHING_SWARM_DMG = 66240,
SPELL_LEECHING_SWARM_HEAL = 66125,
@@ -481,7 +481,7 @@ class spell_gen_elune_candle : public SpellScriptLoader
};
// 24750 Trick
-enum eTrickSpells
+enum TrickSpells
{
SPELL_PIRATE_COSTUME_MALE = 24708,
SPELL_PIRATE_COSTUME_FEMALE = 24709,
@@ -557,7 +557,7 @@ class spell_gen_trick : public SpellScriptLoader
};
// 24751 Trick or Treat
-enum eTrickOrTreatSpells
+enum TrickOrTreatSpells
{
SPELL_TRICK = 24714,
SPELL_TREAT = 24715,
@@ -2618,6 +2618,76 @@ class spell_gen_wg_water : public SpellScriptLoader
}
};
+class spell_gen_count_pct_from_max_hp : public SpellScriptLoader
+{
+ public:
+ spell_gen_count_pct_from_max_hp(char const* name, int32 damagePct = 0) : SpellScriptLoader(name), _damagePct(damagePct) { }
+
+ class spell_gen_count_pct_from_max_hp_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_gen_count_pct_from_max_hp_SpellScript)
+
+ public:
+ spell_gen_count_pct_from_max_hp_SpellScript(int32 damagePct) : SpellScript(), _damagePct(damagePct) { }
+
+ void RecalculateDamage()
+ {
+ if (!_damagePct)
+ _damagePct = GetHitDamage();
+
+ SetHitDamage(GetHitUnit()->CountPctFromMaxHealth(_damagePct));
+ }
+
+ void Register()
+ {
+ OnHit += SpellHitFn(spell_gen_count_pct_from_max_hp_SpellScript::RecalculateDamage);
+ }
+
+ private:
+ int32 _damagePct;
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_gen_count_pct_from_max_hp_SpellScript(_damagePct);
+ }
+
+ private:
+ int32 _damagePct;
+};
+
+class spell_gen_despawn_self : public SpellScriptLoader
+{
+public:
+ spell_gen_despawn_self() : SpellScriptLoader("spell_gen_despawn_self") { }
+
+ class spell_gen_despawn_self_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_gen_despawn_self_SpellScript);
+
+ bool Load()
+ {
+ return GetCaster()->GetTypeId() == TYPEID_UNIT;
+ }
+
+ void HandleDummy(SpellEffIndex effIndex)
+ {
+ if (GetSpellInfo()->Effects[effIndex].Effect == SPELL_EFFECT_DUMMY || GetSpellInfo()->Effects[effIndex].Effect == SPELL_EFFECT_SCRIPT_EFFECT)
+ GetCaster()->ToCreature()->DespawnOrUnsummon();
+ }
+
+ void Register()
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_gen_despawn_self_SpellScript::HandleDummy, EFFECT_ALL, SPELL_EFFECT_ANY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_gen_despawn_self_SpellScript();
+ }
+};
+
void AddSC_generic_spell_scripts()
{
new spell_gen_absorb0_hitlimit1();
@@ -2669,4 +2739,7 @@ void AddSC_generic_spell_scripts()
new spell_gen_chaos_blast();
new spell_gen_ds_flush_knockback();
new spell_gen_wg_water();
+ new spell_gen_count_pct_from_max_hp("spell_gen_default_count_pct_from_max_hp");
+ new spell_gen_count_pct_from_max_hp("spell_gen_50pct_count_pct_from_max_hp", 50);
+ new spell_gen_despawn_self();
}
diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp
index 666477e68e7..eb2d3187636 100644
--- a/src/server/scripts/Spells/spell_item.cpp
+++ b/src/server/scripts/Spells/spell_item.cpp
@@ -1744,6 +1744,7 @@ class spell_item_rocket_boots : public SpellScriptLoader
if (Battleground* bg = caster->GetBattleground())
bg->EventPlayerDroppedFlag(caster);
+ caster->RemoveSpellCooldown(SPELL_ROCKET_BOOTS_PROC);
caster->CastSpell(caster, SPELL_ROCKET_BOOTS_PROC, true, NULL);
}
@@ -2005,7 +2006,7 @@ class spell_item_muisek_vessel : public SpellScriptLoader
{
if (Creature* target = GetHitCreature())
if (target->isDead())
- target->ForcedDespawn();
+ target->DespawnOrUnsummon();
}
void Register()
@@ -2020,6 +2021,37 @@ class spell_item_muisek_vessel : public SpellScriptLoader
}
};
+enum GreatmothersSoulcather
+{
+ SPELL_FORCE_CAST_SUMMON_GNOME_SOUL = 46486,
+};
+class spell_item_greatmothers_soulcatcher : public SpellScriptLoader
+{
+public:
+ spell_item_greatmothers_soulcatcher() : SpellScriptLoader("spell_item_greatmothers_soulcatcher") { }
+
+ class spell_item_greatmothers_soulcatcher_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_item_greatmothers_soulcatcher_SpellScript);
+
+ void HandleDummy(SpellEffIndex /*effIndex*/)
+ {
+ if (Unit* target = GetHitUnit())
+ GetCaster()->CastSpell(GetCaster(),SPELL_FORCE_CAST_SUMMON_GNOME_SOUL);
+ }
+
+ void Register()
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_item_greatmothers_soulcatcher_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_item_greatmothers_soulcatcher_SpellScript();
+ }
+};
+
void AddSC_item_spell_scripts()
{
// 23074 Arcanite Dragonling
@@ -2072,4 +2104,5 @@ void AddSC_item_spell_scripts()
new spell_item_uded();
new spell_item_chicken_cover();
new spell_item_muisek_vessel();
+ new spell_item_greatmothers_soulcatcher();
}
diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp
index d823c629d4b..c8c563d3d5d 100644
--- a/src/server/scripts/Spells/spell_paladin.cpp
+++ b/src/server/scripts/Spells/spell_paladin.cpp
@@ -285,9 +285,20 @@ class spell_pal_holy_shock : public SpellScriptLoader
}
}
+ SpellCastResult CheckCast()
+ {
+ Player* caster = GetCaster()->ToPlayer();
+ if (GetTargetUnit())
+ if (Unit* target = GetTargetUnit())
+ if (!caster->IsFriendlyTo(target) && !caster->IsValidAttackTarget(target))
+ return SPELL_FAILED_BAD_TARGETS;
+ return SPELL_CAST_OK;
+ }
+
void Register()
{
// add dummy effect spell handler to Holy Shock
+ OnCheckCast += SpellCheckCastFn(spell_pal_holy_shock_SpellScript::CheckCast);
OnEffectHitTarget += SpellEffectFn(spell_pal_holy_shock_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp
index d2bba2b8bc3..47cec6ce516 100644
--- a/src/server/scripts/Spells/spell_priest.cpp
+++ b/src/server/scripts/Spells/spell_priest.cpp
@@ -228,8 +228,8 @@ class spell_pri_penance : public SpellScriptLoader
{
Player* caster = GetCaster()->ToPlayer();
if (GetTargetUnit())
- if (Player* target = GetTargetUnit()->ToPlayer())
- if (caster->GetTeam() != target->GetTeam() && !caster->IsValidAttackTarget(target))
+ if (Unit* target = GetTargetUnit())
+ if (!caster->IsFriendlyTo(target) && !caster->IsValidAttackTarget(target))
return SPELL_FAILED_BAD_TARGETS;
return SPELL_CAST_OK;
}
@@ -291,12 +291,53 @@ class spell_pri_reflective_shield_trigger : public SpellScriptLoader
}
};
+enum PrayerOfMending
+{
+ SPELL_T9_HEALING_2_PIECE = 67201,
+};
+// Prayer of Mending Heal
+class spell_pri_prayer_of_mending_heal : public SpellScriptLoader
+{
+public:
+ spell_pri_prayer_of_mending_heal() : SpellScriptLoader("spell_pri_prayer_of_mending_heal") { }
+
+ class spell_pri_prayer_of_mending_heal_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_pri_prayer_of_mending_heal_SpellScript);
+
+ void HandleHeal(SpellEffIndex /*effIndex*/)
+ {
+ if (Unit* caster = GetOriginalCaster())
+ {
+ if (AuraEffect* aurEff = caster->GetAuraEffect(SPELL_T9_HEALING_2_PIECE,EFFECT_0))
+ {
+ int32 heal = GetHitHeal();
+ AddPctN(heal, aurEff->GetAmount());
+ SetHitHeal(heal);
+ }
+ }
+
+ }
+
+ void Register()
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_pri_prayer_of_mending_heal_SpellScript::HandleHeal, EFFECT_0, SPELL_EFFECT_HEAL);
+ }
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_pri_prayer_of_mending_heal_SpellScript();
+ }
+};
+
void AddSC_priest_spell_scripts()
{
new spell_pri_guardian_spirit();
- new spell_pri_mana_burn;
- new spell_pri_pain_and_suffering_proc;
- new spell_pri_penance;
+ new spell_pri_mana_burn();
+ new spell_pri_pain_and_suffering_proc();
+ new spell_pri_penance();
new spell_pri_reflective_shield_trigger();
new spell_pri_mind_sear();
+ new spell_pri_prayer_of_mending_heal();
}
diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp
index 48faf83cd2f..06678407b93 100644
--- a/src/server/scripts/Spells/spell_quest.cpp
+++ b/src/server/scripts/Spells/spell_quest.cpp
@@ -837,7 +837,7 @@ class spell_q12659_ahunaes_knife : public SpellScriptLoader
Player* caster = GetCaster()->ToPlayer();
if (Creature* target = GetHitCreature())
{
- target->ForcedDespawn();
+ target->DespawnOrUnsummon();
caster->KilledMonsterCredit(NPC_SCALPS_KC_BUNNY, 0);
}
}
diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp
index 84e3bd8d604..f16f663ae2d 100644
--- a/src/server/scripts/Spells/spell_shaman.cpp
+++ b/src/server/scripts/Spells/spell_shaman.cpp
@@ -215,13 +215,12 @@ class spell_sha_earthbind_totem : public SpellScriptLoader
void HandleEffectPeriodic(AuraEffect const* aurEff)
{
- if (Unit* target = GetTarget())
- if (Unit* caster = aurEff->GetBase()->GetCaster())
- if (TempSummon* summon = caster->ToTempSummon())
- if (Unit* owner = summon->GetOwner())
- if (AuraEffect* aur = owner->GetDummyAuraEffect(SPELLFAMILY_SHAMAN, 2289, 0))
- if (roll_chance_i(aur->GetBaseAmount()) && target->HasAuraWithMechanic(1 << MECHANIC_SNARE))
- caster->CastSpell(caster, SHAMAN_TOTEM_SPELL_EARTHEN_POWER, true, NULL, aurEff);
+ if (!GetCaster())
+ return;
+ if (Player* owner = GetCaster()->GetCharmerOrOwnerPlayerOrPlayerItself())
+ if (AuraEffect* aur = owner->GetDummyAuraEffect(SPELLFAMILY_SHAMAN, 2289, 0))
+ if (roll_chance_i(aur->GetBaseAmount()))
+ GetTarget()->CastSpell((Unit*)NULL, SHAMAN_TOTEM_SPELL_EARTHEN_POWER, true);
}
void Apply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
@@ -252,6 +251,46 @@ class spell_sha_earthbind_totem : public SpellScriptLoader
}
};
+class EarthenPowerTargetSelector
+{
+ public:
+ EarthenPowerTargetSelector() { }
+
+ bool operator() (Unit* target)
+ {
+ if (!target->HasAuraWithMechanic(1 << MECHANIC_SNARE))
+ return true;
+
+ return false;
+ }
+};
+
+class spell_sha_earthen_power : public SpellScriptLoader
+{
+ public:
+ spell_sha_earthen_power() : SpellScriptLoader("spell_sha_earthen_power") { }
+
+ class spell_sha_earthen_power_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_sha_earthen_power_SpellScript);
+
+ void FilterTargets(std::list<Unit*>& unitList)
+ {
+ unitList.remove_if(EarthenPowerTargetSelector());
+ }
+
+ void Register()
+ {
+ OnUnitTargetSelect += SpellUnitTargetFn(spell_sha_earthen_power_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_sha_earthen_power_SpellScript();
+ }
+};
+
class spell_sha_bloodlust : public SpellScriptLoader
{
public:
@@ -270,7 +309,7 @@ class spell_sha_bloodlust : public SpellScriptLoader
void RemoveInvalidTargets(std::list<Unit*>& targets)
{
- targets.remove_if (Trinity::UnitAuraCheck(true, SHAMAN_SPELL_SATED));
+ targets.remove_if(Trinity::UnitAuraCheck(true, SHAMAN_SPELL_SATED));
}
void ApplyDebuff()
@@ -617,6 +656,7 @@ void AddSC_shaman_spell_scripts()
new spell_sha_fire_nova();
new spell_sha_mana_tide_totem();
new spell_sha_earthbind_totem();
+ new spell_sha_earthen_power();
new spell_sha_bloodlust();
new spell_sha_heroism();
new spell_sha_ancestral_awakening_proc();
diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp
index 3e4c043ae47..3b683eb5795 100644
--- a/src/server/scripts/Spells/spell_warrior.cpp
+++ b/src/server/scripts/Spells/spell_warrior.cpp
@@ -397,8 +397,7 @@ class spell_warr_bloodthirst : public SpellScriptLoader
void HandleDummy(SpellEffIndex /* effIndex */)
{
int32 damage = GetEffectValue();
- if (GetHitUnit())
- GetCaster()->CastCustomSpell(GetHitUnit(), SPELL_BLOODTHIRST, &damage, NULL, NULL, true, NULL);
+ GetCaster()->CastCustomSpell(GetCaster(), SPELL_BLOODTHIRST, &damage, NULL, NULL, true, NULL);
}
void Register()
diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp
index 60ddf8990a7..790a9d0f814 100644
--- a/src/server/scripts/World/go_scripts.cpp
+++ b/src/server/scripts/World/go_scripts.cpp
@@ -1174,7 +1174,7 @@ class go_gjalerbron_cage : public GameObjectScript
player->KilledMonsterCredit(NPC_GJALERBRON_PRISONER, 0);
prisoner->AI()->Talk(SAY_FREE);
- prisoner->ForcedDespawn(6000);
+ prisoner->DespawnOrUnsummon(6000);
}
}
return true;
@@ -1201,7 +1201,7 @@ class go_large_gjalerbron_cage : public GameObjectScript
{
go->UseDoorOrButton();
player->KilledMonsterCredit(NPC_GJALERBRON_PRISONER, (*itr)->GetGUID());
- (*itr)->ForcedDespawn(6000);
+ (*itr)->DespawnOrUnsummon(6000);
(*itr)->AI()->Talk(SAY_FREE);
}
}
@@ -1235,7 +1235,7 @@ class go_veil_skith_cage : public GameObjectScript
{
go->UseDoorOrButton();
player->KilledMonsterCredit(NPC_CAPTIVE_CHILD, (*itr)->GetGUID());
- (*itr)->ForcedDespawn(5000);
+ (*itr)->DespawnOrUnsummon(5000);
(*itr)->GetMotionMaster()->MovePoint(1, go->GetPositionX()+5, go->GetPositionY(), go->GetPositionZ());
(*itr)->AI()->Talk(SAY_FREE_0);
(*itr)->GetMotionMaster()->Clear();
diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp
index 61b997bba35..e1cfd077444 100644
--- a/src/server/scripts/World/npcs_special.cpp
+++ b/src/server/scripts/World/npcs_special.cpp
@@ -2530,172 +2530,6 @@ public:
};
/*######
-## npc_tabard_vendor
-######*/
-
-enum
-{
- QUEST_TRUE_MASTERS_OF_LIGHT = 9737,
- QUEST_THE_UNWRITTEN_PROPHECY = 9762,
- QUEST_INTO_THE_BREACH = 10259,
- QUEST_BATTLE_OF_THE_CRIMSON_WATCH = 10781,
- QUEST_SHARDS_OF_AHUNE = 11972,
-
- ACHIEVEMENT_EXPLORE_NORTHREND = 45,
- ACHIEVEMENT_TWENTYFIVE_TABARDS = 1021,
- ACHIEVEMENT_THE_LOREMASTER_A = 1681,
- ACHIEVEMENT_THE_LOREMASTER_H = 1682,
-
- ITEM_TABARD_OF_THE_HAND = 24344,
- ITEM_TABARD_OF_THE_BLOOD_KNIGHT = 25549,
- ITEM_TABARD_OF_THE_PROTECTOR = 28788,
- ITEM_OFFERING_OF_THE_SHATAR = 31408,
- ITEM_GREEN_TROPHY_TABARD_OF_THE_ILLIDARI = 31404,
- ITEM_PURPLE_TROPHY_TABARD_OF_THE_ILLIDARI = 31405,
- ITEM_TABARD_OF_THE_SUMMER_SKIES = 35279,
- ITEM_TABARD_OF_THE_SUMMER_FLAMES = 35280,
- ITEM_TABARD_OF_THE_ACHIEVER = 40643,
- ITEM_LOREMASTERS_COLORS = 43300,
- ITEM_TABARD_OF_THE_EXPLORER = 43348,
-
- SPELL_TABARD_OF_THE_BLOOD_KNIGHT = 54974,
- SPELL_TABARD_OF_THE_HAND = 54976,
- SPELL_GREEN_TROPHY_TABARD_OF_THE_ILLIDARI = 54977,
- SPELL_PURPLE_TROPHY_TABARD_OF_THE_ILLIDARI = 54982,
- SPELL_TABARD_OF_THE_ACHIEVER = 55006,
- SPELL_TABARD_OF_THE_PROTECTOR = 55008,
- SPELL_LOREMASTERS_COLORS = 58194,
- SPELL_TABARD_OF_THE_EXPLORER = 58224,
- SPELL_TABARD_OF_SUMMER_SKIES = 62768,
- SPELL_TABARD_OF_SUMMER_FLAMES = 62769
-};
-
-#define GOSSIP_LOST_TABARD_OF_BLOOD_KNIGHT "I've lost my Tabard of Blood Knight."
-#define GOSSIP_LOST_TABARD_OF_THE_HAND "I've lost my Tabard of the Hand."
-#define GOSSIP_LOST_TABARD_OF_THE_PROTECTOR "I've lost my Tabard of the Protector."
-#define GOSSIP_LOST_GREEN_TROPHY_TABARD_OF_THE_ILLIDARI "I've lost my Green Trophy Tabard of the Illidari."
-#define GOSSIP_LOST_PURPLE_TROPHY_TABARD_OF_THE_ILLIDARI "I've lost my Purple Trophy Tabard of the Illidari."
-#define GOSSIP_LOST_TABARD_OF_SUMMER_SKIES "I've lost my Tabard of Summer Skies."
-#define GOSSIP_LOST_TABARD_OF_SUMMER_FLAMES "I've lost my Tabard of Summer Flames."
-#define GOSSIP_LOST_LOREMASTERS_COLORS "I've lost my Loremaster's Colors."
-#define GOSSIP_LOST_TABARD_OF_THE_EXPLORER "I've lost my Tabard of the Explorer."
-#define GOSSIP_LOST_TABARD_OF_THE_ACHIEVER "I've lost my Tabard of the Achiever."
-
-class npc_tabard_vendor : public CreatureScript
-{
-public:
- npc_tabard_vendor() : CreatureScript("npc_tabard_vendor") { }
-
- bool OnGossipHello(Player* player, Creature* creature)
- {
- bool lostBloodKnight = false;
- bool lostHand = false;
- bool lostProtector = false;
- bool lostIllidari = false;
- bool lostSummer = false;
-
- //Tabard of the Blood Knight
- if (player->GetQuestRewardStatus(QUEST_TRUE_MASTERS_OF_LIGHT) && !player->HasItemCount(ITEM_TABARD_OF_THE_BLOOD_KNIGHT, 1, true))
- lostBloodKnight = true;
-
- //Tabard of the Hand
- if (player->GetQuestRewardStatus(QUEST_THE_UNWRITTEN_PROPHECY) && !player->HasItemCount(ITEM_TABARD_OF_THE_HAND, 1, true))
- lostHand = true;
-
- //Tabard of the Protector
- if (player->GetQuestRewardStatus(QUEST_INTO_THE_BREACH) && !player->HasItemCount(ITEM_TABARD_OF_THE_PROTECTOR, 1, true))
- lostProtector = true;
-
- //Green Trophy Tabard of the Illidari
- //Purple Trophy Tabard of the Illidari
- if (player->GetQuestRewardStatus(QUEST_BATTLE_OF_THE_CRIMSON_WATCH) &&
- (!player->HasItemCount(ITEM_GREEN_TROPHY_TABARD_OF_THE_ILLIDARI, 1, true) &&
- !player->HasItemCount(ITEM_PURPLE_TROPHY_TABARD_OF_THE_ILLIDARI, 1, true) &&
- !player->HasItemCount(ITEM_OFFERING_OF_THE_SHATAR, 1, true)))
- lostIllidari = true;
-
- //Tabard of Summer Skies
- //Tabard of Summer Flames
- if (player->GetQuestRewardStatus(QUEST_SHARDS_OF_AHUNE) &&
- !player->HasItemCount(ITEM_TABARD_OF_THE_SUMMER_SKIES, 1, true) &&
- !player->HasItemCount(ITEM_TABARD_OF_THE_SUMMER_FLAMES, 1, true))
- lostSummer = true;
-
- if (lostBloodKnight || lostHand || lostProtector || lostIllidari || lostSummer)
- {
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
-
- if (lostBloodKnight)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOST_TABARD_OF_BLOOD_KNIGHT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
-
- if (lostHand)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOST_TABARD_OF_THE_HAND, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
-
- if (lostProtector)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOST_TABARD_OF_THE_PROTECTOR, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
-
- if (lostIllidari)
- {
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOST_GREEN_TROPHY_TABARD_OF_THE_ILLIDARI, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOST_PURPLE_TROPHY_TABARD_OF_THE_ILLIDARI, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
- }
-
- if (lostSummer)
- {
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOST_TABARD_OF_SUMMER_SKIES, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOST_TABARD_OF_SUMMER_FLAMES, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7);
- }
-
- player->SEND_GOSSIP_MENU(13583, creature->GetGUID());
- }
- else
- player->GetSession()->SendListInventory(creature->GetGUID());
-
- return true;
- }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
- {
- player->PlayerTalkClass->ClearMenus();
- switch (action)
- {
- case GOSSIP_ACTION_TRADE:
- player->GetSession()->SendListInventory(creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF + 1:
- player->CLOSE_GOSSIP_MENU();
- player->CastSpell(player, SPELL_TABARD_OF_THE_BLOOD_KNIGHT, false);
- break;
- case GOSSIP_ACTION_INFO_DEF + 2:
- player->CLOSE_GOSSIP_MENU();
- player->CastSpell(player, SPELL_TABARD_OF_THE_HAND, false);
- break;
- case GOSSIP_ACTION_INFO_DEF + 3:
- player->CLOSE_GOSSIP_MENU();
- player->CastSpell(player, SPELL_TABARD_OF_THE_PROTECTOR, false);
- break;
- case GOSSIP_ACTION_INFO_DEF + 4:
- player->CLOSE_GOSSIP_MENU();
- player->CastSpell(player, SPELL_GREEN_TROPHY_TABARD_OF_THE_ILLIDARI, false);
- break;
- case GOSSIP_ACTION_INFO_DEF + 5:
- player->CLOSE_GOSSIP_MENU();
- player->CastSpell(player, SPELL_PURPLE_TROPHY_TABARD_OF_THE_ILLIDARI, false);
- break;
- case GOSSIP_ACTION_INFO_DEF + 6:
- player->CLOSE_GOSSIP_MENU();
- player->CastSpell(player, SPELL_TABARD_OF_SUMMER_SKIES, false);
- break;
- case GOSSIP_ACTION_INFO_DEF + 7:
- player->CLOSE_GOSSIP_MENU();
- player->CastSpell(player, SPELL_TABARD_OF_SUMMER_FLAMES, false);
- break;
- }
- return true;
- }
-};
-
-/*######
## npc_experience
######*/
@@ -3158,7 +2992,6 @@ void AddSC_npcs_special()
new npc_wormhole();
new npc_pet_trainer();
new npc_locksmith();
- new npc_tabard_vendor();
new npc_experience();
new npc_fire_elemental();
new npc_earth_elemental();
diff --git a/src/server/shared/Debugging/WheatyExceptionReport.cpp b/src/server/shared/Debugging/WheatyExceptionReport.cpp
index 63648f66e29..febc5ef3573 100644
--- a/src/server/shared/Debugging/WheatyExceptionReport.cpp
+++ b/src/server/shared/Debugging/WheatyExceptionReport.cpp
@@ -195,7 +195,23 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
case VER_PLATFORM_WIN32_NT:
// Test for the specific product family.
if (osvi.dwMajorVersion == 6)
- _tcsncat(szVersion, _T("Windows Vista or Windows Server 2008 "), cntMax);
+ {
+ #if WINVER < 0x0500
+ if (osvi.wReserved[1] == VER_NT_WORKSTATION)
+ #else
+ if (osvi.wProductType == VER_NT_WORKSTATION)
+ #endif // WINVER < 0x0500
+ {
+ if (osvi.dwMinorVersion == 1)
+ _tcsncat(szVersion, _T("Windows 7 "), cntMax);
+ else
+ _tcsncat(szVersion, _T("Windows Vista "), cntMax);
+ }
+ else if (osvi.dwMinorVersion == 1)
+ _tcsncat(szVersion, _T("Windows Server 2008 R2 "), cntMax);
+ else
+ _tcsncat(szVersion, _T("Windows Server 2008 "), cntMax);
+ }
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
_tcsncat(szVersion, _T("Microsoft Windows Server 2003 "), cntMax);
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)