Subv's changes to mesh extractor V2

Signed-off-by: Tomatoes <diredarknil@gmail.com>
Merge pull request #10963 from Tomatodev/master

Tools/MeshExtractor: Fixed an infinite loop when reading the liquid information
Tools/MeshExtractor: Cleanup using static analyzing tool
*printf format fixed
*method arguments changed to const where needed
*removed not needed strlen() from cycles
*other minor changes
DB/Update: Spawndist for creature with random movement
DB/Update: Pet spells
Merge pull request #10966 from Chaplain/Mesh

Tools/MeshExtractor: Cleanup using static analyzing tool
Core/Scripts: Fix uninitialized values in The Black Morass

Valgrind log:
 Conditional jump or move depends on uninitialised value(s)
  at 0x1798C2C: npc_medivh_bm::npc_medivh_bmAI::UpdateAI(unsigned int) (the_black_morass.cpp:192)
  by 0x11AEFC0: Creature::Update(unsigned int) (Creature.cpp:542)
  by 0x12E96F8: Trinity::ObjectUpdater::Visit(GridRefManager<Creature>&) (GridNotifiersImpl.h:45)

 Conditional jump or move depends on uninitialised value(s)
  at 0x1798C7E: npc_medivh_bm::npc_medivh_bmAI::UpdateAI(unsigned int) (the_black_morass.cpp:200)
  by 0x11AEFC0: Creature::Update(unsigned int) (Creature.cpp:542)
  by 0x12E96F8: Trinity::ObjectUpdater::Visit(GridRefManager<Creature>&) (GridNotifiersImpl.h:45)

 Conditional jump or move depends on uninitialised value(s)
  at 0x1798CB0: npc_medivh_bm::npc_medivh_bmAI::UpdateAI(unsigned int) (the_black_morass.cpp:205)
  by 0x11AEFC0: Creature::Update(unsigned int) (Creature.cpp:542)
  by 0x12E96F8: Trinity::ObjectUpdater::Visit(GridRefManager<Creature>&) (GridNotifiersImpl.h:45)

 Conditional jump or move depends on uninitialised value(s)
  at 0x1798CE2: npc_medivh_bm::npc_medivh_bmAI::UpdateAI(unsigned int) (the_black_morass.cpp:210)
  by 0x11AEFC0: Creature::Update(unsigned int) (Creature.cpp:542)
  by 0x12E96F8: Trinity::ObjectUpdater::Visit(GridRefManager<Creature>&) (GridNotifiersImpl.h:45)
Tools/MapExtractor: Fix string-related memory issues

Fix not-NULL terminated char buffers and char[] to string conversion.

Valgrind logs:
 Invalid read of size 1
  at 0x4C2D7D4: __GI_strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  by 0x5318BAF: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.17)
  by 0x409471: ReadBuild(int) (System.cpp:189)
  by 0x40CEC6: main (System.cpp:1108)
  Address 0x5f851ee is 0 bytes after a block of size 94 alloc'd
  at 0x4C2C037: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  by 0x40F63A: MPQFile::MPQFile(char const*) (mpq_libmpq.cpp:65)
  by 0x409408: ReadBuild(int) (System.cpp:182)
  by 0x40CEC6: main (System.cpp:1108)

 Invalid read of size 1
  at 0x57FFCAC: strtok (strtok.S:165)
  by 0x40D279: MPQArchive::GetFileListTo(std::vector<std::string, std::allocator<std::string> >&) (mpq_libmpq04.h:45)
  by 0x40C5CF: ExtractDBCFiles(int, bool) (System.cpp:1001)
  by 0x40CEF5: main (System.cpp:1110)
  Address 0x5f91e27 is 0 bytes after a block of size 44,391 alloc'd
  at 0x4C2C037: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  by 0x40D1A5: MPQArchive::GetFileListTo(std::vector<std::string, std::allocator<std::string> >&) (mpq_libmpq04.h:30)
  by 0x40C5CF: ExtractDBCFiles(int, bool) (System.cpp:1001)
  by 0x40CEF5: main (System.cpp:1110)
Tools/MeshExtractor: Fixed a lot of stuff, finally made the Doodads render, the WMO's have been disabled for now.
ToDo:
* Fix the doodads positions.
* Review and re-implement some code.

P.D: Help me please.
Tools/VMAP Extractor: Fix memory issues

Fix not-NULL terminated char buffer and uninitialized memory written to vmaps due to WMOLiquidHeader struct padding bytes left uninitialized. The padding bytes should be ignored anyway by VMAP Assembler so no re-extraction is required.

Valgrind log:
 Syscall param write(buf) points to uninitialised byte(s)
  at 0x585FB50: __write_nocancel (syscall-template.S:81)
  by 0x57EE2F2: _IO_file_write@@GLIBC_2.2.5 (fileops.c:1270)
  by 0x57EE1D1: new_do_write (fileops.c:546)
  by 0x57EF904: _IO_do_write@@GLIBC_2.2.5 (fileops.c:519)
  by 0x57EEB70: _IO_file_xsputn@@GLIBC_2.2.5 (fileops.c:1341)
  by 0x57E3EC4: fwrite (iofwrite.c:43)
  by 0x41161B: WMOGroup::ConvertToVMAPGroupWmo(_IO_FILE*, WMORoot*, bool) (wmo.cpp:386)
  by 0x407FA9: ExtractSingleWmo(std::string&) (vmapexport.cpp:215)
  by 0x407B16: ExtractWmo() (vmapexport.cpp:138)
  by 0x409D50: main (vmapexport.cpp:497)
 Address 0x40398e2 is not stack'd, malloc'd or (recently) free'd
 Uninitialised value was created by a heap allocation
  at 0x4C2C7A7: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  by 0x410ADA: WMOGroup::open() (wmo.cpp:224)
  by 0x407F54: ExtractSingleWmo(std::string&) (vmapexport.cpp:208)
  by 0x407B16: ExtractWmo() (vmapexport.cpp:138)
  by 0x409D50: main (vmapexport.cpp:497)
Core/RBAC: Simplify RBAC implementation
- Drop groups (roles than can have inherited roles) and roles (set of
  permissions)
- Permissions can now have inherited permissions (those act as roles)

RBAC DB structure is now limited to four tables
- rbac_permissions: Contains permissions and roles
- rbac_linked_permissions: Contains the relation between permissions and
  linked permissions (those permissions that have linked permissions are
  called roles)
- rbac_default_permissions: Contains the list of permissions to be granted
  to each security level [Added to maintain compatibility in an easy way]
- rbac_account_permissions: Contains the list of permissions granted or
  denied for a particular account.

NOTE: IF YOU ARE USING CUSTOM PERMISSIONS, ROLES OR GROUPS CHECK THE SQL
BEFORE APPLYING...
Fix compile under linux and update auth db with latest changes
DB/SAI: Leading the Ancestors Home

By @dr-j fixes #10783
DB/SAI: Neltharion's Flame (12267)

By @dr-j fixes #10965
DB/SAI: Finding the Source

By @dr-j fixes #10943
DB/Update: Gibblewilt fear spam

By @Vincent-Michael fixes #10627
DB/Update: Plan B

By @untaught fixes #10787
DB/SAI: Hampering their Escape

By @untaught fixes #10780
DB/SAI: Destroying the Alters

By @untaught fixes #10841
Tools/MeshExtractor: Fixed(??????) Doodads in the terrain.
Semi-fixed WMOs in the terrain, they are wrongly rotated.
P.D: HALP
P.P.D: Entered "I don't know what i'm doing" mode.