Skip to content

Commit 3362223

Browse files
committed
fix missing parts of mixing branches to test and push
1 parent 03945e5 commit 3362223

2 files changed

Lines changed: 73 additions & 58 deletions

File tree

src/server/game/AI/ScriptedAI/sc_npc_teleport.cpp renamed to src/server/scripts/Custom/sc_npc_teleport.cpp

Lines changed: 66 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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
@@ -18,10 +18,11 @@
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

src/server/game/AI/ScriptedAI/sc_npc_teleport.h renamed to src/server/scripts/Custom/sc_npc_teleport.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ namespace nsNpcTel
6868
struct CatValue
6969
{
7070
uint32 catid;
71+
uint32 supercatid;
7172
nsNpcTel::Flag flag;
7273
uint64 data0;
7374
uint32 data1;
@@ -94,12 +95,14 @@ namespace nsNpcTel
9495
void AddDest(const Dest &item) { m_TabDest.push_back(item); }
9596
Dest GetDest(const uint32 &id) const { return m_TabDest[id]; }
9697
uint32 GetCatID(void) const { return m_catvalue.catid; }
98+
uint32 GetSuperCatID(void) const { return m_catvalue.supercatid; }
99+
bool HasSubCategories(void) const;
97100
uint32 size(void) const { return m_TabDest.size(); }
98101

99102
std::string GetName(const uint8 loc /* = 0 */, const bool IsGM = false) const;
100103
bool IsAllowedToTeleport(Player * const player) const;
101104

102-
static uint32 CountOfCategoryAllowedBy(Player * const player);
105+
static uint32 CountOfCategoryAllowedBy(Player * const player, uint32 supercatid = 0);
103106

104107
private:
105108

@@ -114,7 +117,7 @@ namespace nsNpcTel
114117
protected:
115118

116119
// Class instance for current player
117-
class TC_GAME_API Instance
120+
class Instance
118121
{
119122
public:
120123

@@ -157,11 +160,11 @@ namespace nsNpcTel
157160
// Verification of data integrity
158161
bool IsValidData(const CatValue cat);
159162

160-
extern TC_GAME_API VCatDest TabCatDest;
163+
TC_GAME_API extern VCatDest TabCatDest;
161164
}
162165

163166
// Loading contents of database
164-
void TC_GAME_API LoadNpcTele(void);
167+
void LoadNpcTele(void);
165168

166169
//extern WorldDatabaseWorkerPool WorldDatabase;
167170

0 commit comments

Comments
 (0)