[s0642] Cleanups in ThreatManager.h

Signed-off-by: VladimirMangos <vladimir@getmangos.com>

(based on commit 4133018)
Add peeking support to LockedQueue.

Also make DB code thread-safe. Original patch by Machiavelli and Kero99.

(based on commit ea13ac3)
(based on commit 6bc7e97)
[s0643] More safe for use PET_FOLLOW_ANGLE define.

(based on commit 9ccbdbf)
[s0644] Avoid use StopMoving when creature is already stopped.

Some additional code cleanup in related code.

(based on commit 14b21d8)
[s0645] Battleground queue related backports

(based on commit 4601ed3)
(based on commit 877e963)
(based on commit 6dd33ca)

New attempt backport bg related commits. Please report stability porblems if its showup after this commit.
[s0646] Team related cleanups in generic code and battlegrounds code.

Use BattleGround(AV)TeamIndex enum types in AV battleground code.

* Added BattleGroundAVTeamIndex enum type for 3-case special team list fo AV.
* Rename BattleGroundTeamId -> BattleGroundTeamIndex for clarify
* Some safe checks added and dropped bogus call RewardReputationToTeam in BattleGroundAV::HandleQuestComplete
  for BattleGroundTeamIndex as faction. Unclear for what it expected used so dropped.

Use Team enum types in all appropriate cases and catches bug in result fix.

* Fixed wrong arenaid use at leave arena queue.
* Fixed memory lost and etc at not virtual EndBattleground call
* Fixed crash at arena join with fake data from client.
* Code cleanups.

(based on commit 83e7f13)
(based on commit 8fcfddf)
(based on commit 3faa764)
(based on commit 17693a6)
(based on commit 9373719)

Thanks to mns for research code and help  for this and prev. backport commits.
[s0647] Fixed linking porblem for scripting library.

Visual Studio have known porblems with make public (in DLL access meaning)
for private fields accessed by public inline functions.

(based on commit b74660e)
[s0648] Remove unused aura caster get.
[s0649] Prevent deleting reflect source aura ebfore reflected spell cast.

(based on commit 419774c)
[s0650] Sort Unit::HandleDummyAuraProc generic family spells in case.

(based on commit 80ea28d)
[s0651] Some comments from not backportable commit.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>

(based on commit 140f3f1)
[s0652] Proper sort spel 27681 and ranks in mangos.sql.

(based on commit 9d98bec)
[s0653] Sort some spell handelrs by spell ids.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>

(based on commit b8823de)
[s0654] Propertly note for not loaded script library version.

* Better support localization in case built-in version notes.
* Move script library version functions to ScriptMgr

(based on commit 8076ef5)
[s0655] Implement reflect chance with telent 11189

In 2.x it work in diff. way from 3.x version

Also fixed generic not expected limitation in pre-auraholder code
for not calling aura boost code at remove for auras without visible slot.
In aura holder version it already fixed but it too big problem for wait
auraholder backporting.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>

(based on commit a3d3fe4)
[s0656] Missing sql update from backport. :/

This will fix crashes from arena announcer.

(based on commit 6dd33ca)
[s0657] Fixed spell stacking problem for somr sprlls with spell icon 240.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>

(based on commit e12a38b)
[s0658] Prevent apply spell power bonuses to some item heals.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>

(based on commit 2038573)

Thanks to mns for find this important for backport commit.
[s0659] Fix wrong threat assignment in Spell::EffectHealPct when m_caster and m_originalCaster differ.

(based on commit 2381845)
[s0660] Implement optional support post-3.1 and later fishing changes.

* Fishing now prowide junk loot at fail skill check.
  This can be enabled for post-3.1.x way work using SkillFail.Loot.Fishing option.
  Junk loot expected to be listed in fishing_loot_template entry 0.

* Fishing can gain skill grow at skill fail check case.
  Controlled by SkillFail.Gain.Fishing option.

* Fishing from fishing pool gameobject can't be fail.
  Controlled by SkillFail.Possible.FishingPool

(based on commit 902c3df)
(based on commit 74fe338)
(based on commit f43c272)