11/*
22 * Copyright (C) 20??-2008 Wilibald09
3- * Copyright (C) 2011-2015 ArkCORE <http://www.arkania.net/>
4- * Copyright (C) 2008-2019 TrinityCore <http ://www.trinitycore.org/>
3+ * Copyright (C) 2011-2015 ArkCORE (webpage dead)
4+ * Copyright (C) 2008-2016 TrinityCore <https ://www.trinitycore.org/>
55 *
66 * This program is free software; you can redistribute it and/or modify it
77 * under the terms of the GNU General Public License as published by the
1818 */
1919
2020#include " Player.h"
21- #include " Log.h"
2221#include " sc_npc_teleport.h"
2322#include " WorldSession.h"
2423#include " DatabaseEnv.h"
24+ #include " Log.h"
25+
2526#define TELE nsNpcTel::CatDest
2627#define PAGE nsNpcTel::Page
2728#define PAGEI PAGE ::Instance
@@ -126,7 +127,6 @@ bool TELE::IsAllowedToTeleport(Player * const player) const
126127 case TEAM_HORDE : return player->GetTeam () == HORDE ;
127128 case TEAM_ALLIANCE : return player->GetTeam () == ALLIANCE ;
128129 case TEAM_ALL : return true ;
129- default : TC_LOG_ERROR (" misc" , " Invalid m_catvalue.data0 . Important problem..." ); return false ;
130130 }
131131
132132 case FLAG_GUILD :
@@ -167,19 +167,29 @@ bool TELE::IsAllowedToTeleport(Player * const player) const
167167 case FLAG_PLAYER :
168168 return player->GetGUID ().GetCounter () == m_catvalue.data0 ;
169169
170- default : TC_LOG_ERROR (" misc" , " Invalid flag (category: %u ). Important problem..." , GetCatID ()); return false ;
170+ default : TC_LOG_ERROR (" misc" , " Invalid flag (category: {} ). Important problem..." , GetCatID ());
171171 }
172172
173- TC_LOG_ERROR (" misc" , " Invalid flag (category: %u ). Important problem..." , GetCatID ());
173+ TC_LOG_ERROR (" misc" , " Invalid flag (category: {} ). Important problem..." , GetCatID ());
174174 return false ;
175175}
176176
177- uint32 TELE::CountOfCategoryAllowedBy (Player * const player)
177+ bool TELE::HasSubCategories (void ) const
178+ {
179+ for (VCatDest_t i (0 ); i < TabCatDest.size (); ++i)
180+ {
181+ if (TabCatDest[i].GetSuperCatID () == m_catvalue.catid )
182+ return true ;
183+ }
184+ return false ;
185+ }
186+
187+ uint32 TELE::CountOfCategoryAllowedBy (Player * const player, uint32 supercatid /* = 0 */ )
178188{
179189 uint32 count (0 );
180190 for (VCatDest_t i (0 ); i < TabCatDest.size (); ++i)
181191 {
182- if (TabCatDest[i].IsAllowedToTeleport (player))
192+ if (TabCatDest[i].GetSuperCatID () == supercatid && TabCatDest[i]. IsAllowedToTeleport (player))
183193 ++count;
184194 }
185195 return count;
@@ -317,20 +327,17 @@ void LoadNpcTele(void)
317327 " custom_npc_tele_association" ,
318328 };
319329
330+
320331 QueryResult result = WorldDatabase.PQuery (
321- " SELECT `flag`, `data0`, `data1`, `cat_id`, C.`icon` `iconcat`, C.`size` `iconsize`, C.`colour` `colourcat`, C.`name` `namecat`, "
322- // 0 1 2 3 4 5 6 7
332+ " SELECT C.`flag`, C.`data0`, C.`data1`, C.`id`, C.`supercat_id`, C.`icon` `iconcat`, C.`size` `iconsize`, C.`colour` `colourcat`, C.`name` `namecat`, "
323333 " C.`name_loc1`, C.`name_loc2`, C.`name_loc3`, C.`name_loc4`, C.`name_loc5`, C.`name_loc6`, C.`name_loc7`, C.`name_loc8`, "
324- // 8 9 10 11 12 13 14 15
325334 " D.`icon` `icondest`, D.`size` `sizedest`, D.`colour` `colourdest`, D.`name` `namedest`, "
326- // 16 17 18 19
327335 " D.`name_loc1`, D.`name_loc2`, D.`name_loc3`, D.`name_loc4`, D.`name_loc5`, D.`name_loc6`, D.`name_loc7`, D.`name_loc8`, "
328- // 20 21 22 23 24 25 26 27
329- " `pos_X`, `pos_Y`, `pos_Z`, `orientation`, `map`, `level`, `cost` "
330- // 28 29 30 31 32 33 34
331- " FROM `{}` C, `{}` D, `{}` A "
332- " WHERE C.`id` = `cat_id` AND D.`id` = `dest_id` "
333- " ORDER BY `namecat`, `cat_id`, `namedest`" , Table[0 ], Table[1 ], Table[2 ]);
336+ " D.`pos_X`, D.`pos_Y`, D.`pos_Z`, D.`orientation`, D.`map`, D.`level`, D.`cost`, A.`dest_id` "
337+ " FROM `{}` C "
338+ " LEFT JOIN `{}` A ON C.`id` = A.`cat_id` "
339+ " LEFT JOIN `{}` D ON D.`id` = A.`dest_id` "
340+ " ORDER BY C.`supercat_id`, `namecat`, C.`id`, `namedest`" , Table[0 ], Table[2 ], Table[1 ]);
334341
335342 nsNpcTel::TabCatDest.clear ();
336343
@@ -356,6 +363,7 @@ void LoadNpcTele(void)
356363 nsNpcTel::CatValue catvalue =
357364 {
358365 fields[3 ].GetUInt32 (),
366+ fields[4 ].GetUInt32 (),
359367 (nsNpcTel::Flag)fields[0 ].GetUInt8 (),
360368 fields[1 ].GetUInt64 (),
361369 fields[2 ].GetUInt32 ()
@@ -373,53 +381,56 @@ void LoadNpcTele(void)
373381 catid = catvalue.catid ;
374382 nsNpcTel::CatName catname =
375383 {
376- fields[4 ].GetString (), // Cat icon
377- fields[5 ].GetString (), // Cat size
378- fields[6 ].GetString (), // Cat colour
384+ fields[5 ].GetString (), // Cat icon
385+ fields[6 ].GetString (), // Cat size
386+ fields[7 ].GetString (), // Cat colour
379387 {
380- fields[7 ].GetString (), // Cat Name
381- fields[8 ].GetString (), // Cat Name Loc1
382- fields[9 ].GetString (), // Cat Name Loc2
383- fields[10 ].GetString (), // Cat Name Loc3
384- fields[11 ].GetString (), // Cat Name Loc4
385- fields[12 ].GetString (), // Cat Name Loc5
386- fields[13 ].GetString (), // Cat Name Loc6
387- fields[14 ].GetString (), // Cat Name Loc7
388- fields[15 ].GetString () // Cat Name Loc8
388+ fields[8 ].GetString (), // Cat Name
389+ fields[9 ].GetString (), // Cat Name Loc1
390+ fields[10 ].GetString (), // Cat Name Loc2
391+ fields[11 ].GetString (), // Cat Name Loc3
392+ fields[12 ].GetString (), // Cat Name Loc4
393+ fields[13 ].GetString (), // Cat Name Loc5
394+ fields[14 ].GetString (), // Cat Name Loc6
395+ fields[15 ].GetString (), // Cat Name Loc7
396+ fields[16 ].GetString () // Cat Name Loc8
389397 }
390398 };
391399
392400 nsNpcTel::CatDest categorie (catvalue, catname);
393401 nsNpcTel::TabCatDest.push_back (categorie);
394402 }
395403
396- nsNpcTel::Dest item =
404+ if (!fields[ 36 ]. IsNull ())
397405 {
398- fields[16 ].GetString (), // Dest icon
399- fields[17 ].GetString (), // Dest size
400- fields[18 ].GetString (), // Dest colour
406+ nsNpcTel::Dest item =
401407 {
402- fields[19 ].GetString (), // Dest Name
403- fields[20 ].GetString (), // Dest Name_loc1
404- fields[21 ].GetString (), // Dest Name_loc2
405- fields[22 ].GetString (), // Dest Name_loc3
406- fields[23 ].GetString (), // Dest Name_loc4
407- fields[24 ].GetString (), // Dest Name_loc5
408- fields[25 ].GetString (), // Dest Name_loc6
409- fields[26 ].GetString (), // Dest Name_loc7
410- fields[27 ].GetString () // Dest Name_loc8
411- },
412- fields[28 ].GetFloat (), // X
413- fields[29 ].GetFloat (), // Y
414- fields[30 ].GetFloat (), // Z
415- fields[31 ].GetFloat (), // Orientation
416- fields[32 ].GetUInt16 (), // Map
417- fields[33 ].GetUInt8 (), // Level
418- fields[34 ].GetUInt32 () // Cost
419- };
408+ fields[17 ].GetString (), // Dest icon
409+ fields[18 ].GetString (), // Dest size
410+ fields[19 ].GetString (), // Dest colour
411+ {
412+ fields[20 ].GetString (), // Dest Name
413+ fields[21 ].GetString (), // Dest Name_loc1
414+ fields[22 ].GetString (), // Dest Name_loc2
415+ fields[23 ].GetString (), // Dest Name_loc3
416+ fields[24 ].GetString (), // Dest Name_loc4
417+ fields[25 ].GetString (), // Dest Name_loc5
418+ fields[26 ].GetString (), // Dest Name_loc6
419+ fields[27 ].GetString (), // Dest Name_loc7
420+ fields[28 ].GetString () // Dest Name_loc8
421+ },
422+ fields[29 ].GetFloat (), // X
423+ fields[30 ].GetFloat (), // Y
424+ fields[31 ].GetFloat (), // Z
425+ fields[32 ].GetFloat (), // Orientation
426+ fields[33 ].GetUInt16 (), // Map
427+ fields[34 ].GetUInt8 (), // Level
428+ fields[35 ].GetUInt32 () // Cost
429+ };
420430
421- nsNpcTel::TabCatDest.back ().AddDest (item);
422- ++nbDest;
431+ nsNpcTel::TabCatDest.back ().AddDest (item);
432+ ++nbDest;
433+ }
423434 } while (result->NextRow ());
424435
425436 TC_LOG_INFO (" server.loading" , " " );
@@ -429,4 +440,5 @@ void LoadNpcTele(void)
429440 TC_LOG_ERROR (" misc" , " WARNING >> Loaded 0 npc_teleport." );
430441}
431442
443+
432444#undef TELE
0 commit comments