[z2559] Implement Battleground scores storage system

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [12756] - 9b7bb67)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2204] - 4c31c37)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2560] Extend pvp team indexes to global use

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [12760] - 5c3b410)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2205] - 33cb564)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2561] Reverse pvp team indexes for score statistics storage

This updates [s2204] and makes @ShinDarth happy

(based on commit [12769] - fab75fc)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2206] - 7df0ef6)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2562] Fix winner team for bg scores storage

(based on commit [12770] - df8a125)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2207] - c419282)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2563] Fix rooted player continue their movement while rooted for other clients.

http://cmangos.net/thread-6756.html
Thank to Moh for pointing.

(based on commit [12762] - c1af307)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2209] - cbc7050)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2564] Improve EventAI code engine a little bit to be more effective with EVENT_T_RANGE

(based on commit [12765] - f676018)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2210] - 3028f75)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2565] EventAI - CodeStyle

(based on commit [12766] - 1c1fb83)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2211] - 1cbeda7)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2566] EventAI - SpeedUp OOC-LoS Event handling

Reorder checks such that range and LoS checks are handled after the faster faction checks.
Also introduce a bool variable to prevent iterating all events every MovementAction

(based on commit [12767] - 86fa6da)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2212] - 38f0ba1)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2567] EventAI - Some random changes

(based on commit [12768] - 6525c80)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2213] - 877e494)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2568] Rewrite rest management.

Fix Rest when logged in not working in some case.
Also fix rest bonus according to wowwiki.

This need to be backported in all core.
Thank to @TheTrueAnimal for pointing.
Fix cmangos/issues#494

(based on commit [12771] - e804879)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2214] - 0386b46)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2569] Fix logic bug in SelectAuraRankForLevel

(based on commit [12773] - bf80378)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2215] - f9c7c3b)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2570] Fix bug that cause AreaAura reaply because the code doesn't search the correct rank of it.

(based on commit [12774] - 215b4b9)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2216] - 66d56aa)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2571] Fix AreaAura bug when low level grouped with high level Player. Thank to @tarwyn for his precious help and proposed patch.

http://cmangos.net/thread-6773.html

(based on commit [12776] - 43caf20)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2217] - cf236f7)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2572] Fix issue with afk playerin duel logout request from client after 30 mins. We can logout during duel. Btw during duel we must be in combat for some timer without any action. Also change message from "duel cancel" to "duel  FLED"

(based on commit [12777] - cc542de)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2218] - cd9bb00)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2573] Fix skinning loot bug.

Thank to @TheTrueAnimal for pointing.

Fix cmangos/issues#472

(based on commit [12778] - d4cdfb5)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2219] - 054ba03)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2574] Allow creating Non-Instance Maps without player

(based on commit [12780] - 06472b0)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2220] - 5fb6557)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2575] Move unused Map::LoadGrid function to function Map::ForceLoadGrid

(based on commit [12781] - d193f83)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2221] - 94c6002)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2576] Add new config setting LoadAllGridsOnMaps

With this setting one can store a list of maps that are automatically
loaded with all grids and all creatures.
Continents will be loaded on server-startup, instances when a player
enters.

NOTE: Using maps with this setting will cost huge amount of cpu and ram
power, and hence it must only be used for development purposes

(based on commit [12782] - e5182a3)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2222] - 3a571b9)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2577] Create function to load active entities.

Note this function is considered WIP, and will require further work pending more features

Ideas and loop to load all grids on a map by Neo2003.

(based on commit [12783] - aaf514c)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2223] - 3a82e9c)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>
[z2578] Implement CREATURE_FLAG_EXTRA_ACTIVE

Setting this flag 0x1000 to creature_template.ExtraFlags will result in
the npc being loaded and set to active when the map is created.

In case of continents this will happen on server startup.

Note to DB-Devs: Use this flag with care, it will create more memory and
cpu usage for users.

Note to users: If you have a bottleneck and do not care about i.e. mobs
with huge paths, just remove this flag from the npcs

(based on commit [12784] - 00d86f0)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>

(based on commit [s2224] - 02a1afa)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>