Skip to content

Commit 00695fc

Browse files
committed
Update to new db structure.
1 parent c251cc5 commit 00695fc

8 files changed

+124
-44
lines changed

SniffScripter/Defines/SniffDatabase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class SniffDatabase
4545
static void LoadCreatureEmote(char const* whereClause);
4646
static void LoadCreatureAttackStart(char const* whereClause);
4747
static void LoadCreatureAttackStop(char const* whereClause);
48+
static void LoadCreatureDeath(char const* whereClause);
4849
static void LoadCreatureDestroy(char const* whereClause);
4950
static void LoadCreatureCreate2(char const* whereClause);
5051
static void LoadCreatureCreate1(char const* whereClause);

SniffScripter/Defines/SniffedEvents.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ enum SniffedEventType : uint8
7676
SE_CREATURE_CREATE1,
7777
SE_CREATURE_CREATE2,
7878
SE_CREATURE_DESTROY,
79+
SE_CREATURE_DEATH,
7980
SE_CREATURE_TEXT,
8081
SE_CREATURE_EMOTE,
8182
SE_CREATURE_ATTACK_START,
@@ -195,6 +196,27 @@ struct SniffedEvent_CreatureDestroy : SniffedEvent
195196
}
196197
};
197198

199+
struct SniffedEvent_CreatureDeath : SniffedEvent
200+
{
201+
SniffedEvent_CreatureDeath(uint32 guid, uint32 entry) : m_guid(guid), m_entry(entry) {};
202+
uint32 m_guid = 0;
203+
uint32 m_entry = 0;
204+
std::string ToString(bool /*singleLine*/) const final
205+
{
206+
std::string txt = "Creature " + WorldDatabase::GetCreatureName(m_entry) + " (Guid: " + std::to_string(m_guid) + " Entry: " + std::to_string(m_entry) + ") dies.";
207+
return txt;
208+
}
209+
SniffedEventType GetType() const final
210+
{
211+
return SE_CREATURE_DEATH;
212+
}
213+
KnownObject GetSourceObject() const final
214+
{
215+
return KnownObject(m_guid, m_entry, "Creature");
216+
}
217+
};
218+
219+
198220
struct SniffedEvent_CreatureText : SniffedEvent
199221
{
200222
SniffedEvent_CreatureText(uint32 guid, uint32 entry, std::string text, uint32 chatType, std::string comment) :

SniffScripter/Defines/TimelineMaker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class TimelineMaker
1414
static void PrintTimelineToScreen(uint32 startTime);
1515
static void SaveTimelineToFile(uint32 startTime);
1616
static void PromptTimelineSaveMethod(uint32 startTime);
17-
static void CreateTimelineForGuids(uint32 uiStartTime, std::vector<uint32>& vCreatureGuids, std::vector<uint32> vGameObjectGuids, bool showReclaimCorpse, bool showReleaseSpirit, bool showQuests, bool showCreatureInteract, bool showGameObjectUse, bool showItemUse, bool showAttacks, bool showTexts, bool showEmotes, bool showMoves, bool showUpdates, bool showCasts, bool showSounds);
18-
static void CreateTimelineForAll(uint32 uiStartTime, uint32 uiEndTime, bool showReclaimCorpse, bool showReleaseSpirit, bool showQuests, bool showUseItem, bool showCreatures, bool showCreatureInteract, bool showCreatureAttacks, bool showCreatureTexts, bool showCreatureEmotes, bool showCreatureMoves, bool showCreatureCasts, bool showCreatureUpdates, bool showGameObjects, bool showGameObjectUse, bool showGameObjectCasts, bool showGameObjectUpdates, bool showSounds);
17+
static void CreateTimelineForGuids(uint32 uiStartTime, std::vector<uint32>& vCreatureGuids, std::vector<uint32> vGameObjectGuids, bool showReclaimCorpse, bool showReleaseSpirit, bool showQuests, bool showCreatureInteract, bool showGameObjectUse, bool showItemUse, bool showDeaths, bool showAttacks, bool showTexts, bool showEmotes, bool showMoves, bool showUpdates, bool showCasts, bool showSounds);
18+
static void CreateTimelineForAll(uint32 uiStartTime, uint32 uiEndTime, bool showReclaimCorpse, bool showReleaseSpirit, bool showQuests, bool showUseItem, bool showCreatures, bool showCreatureInteract, bool showCreatureDeaths, bool showCreatureAttacks, bool showCreatureTexts, bool showCreatureEmotes, bool showCreatureMoves, bool showCreatureCasts, bool showCreatureUpdates, bool showGameObjects, bool showGameObjectUse, bool showGameObjectCasts, bool showGameObjectUpdates, bool showSounds);
1919

2020
static uint32 SaveWaypointsToFile();
2121
static void CreateWaypoints(uint32 guid, bool useStartPosition);

SniffScripter/Defines/WorldDatabase.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ class WorldDatabase
8787
}
8888
static uint32 GetBroadcastTextId(std::string text)
8989
{
90+
auto index = text.find("$N", 0);
91+
if (index != std::string::npos)
92+
text.replace(index, 2, "$n");
93+
9094
for (auto const& itr : m_broadcastTexts)
9195
{
9296
if (itr.second.m_maleText == text || itr.second.m_femaleText == text)

SniffScripter/SniffDatabase.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void SniffDatabase::LoadCreatureText(char const* whereClause)
266266

267267
void SniffDatabase::LoadCreatureMovement(char const* whereClause)
268268
{
269-
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `id`, `point`, `move_time`, `start_position_x`, `start_position_y`, `start_position_z`, `end_position_x`, `end_position_y`, `end_position_z`, `orientation`, `unixtime` FROM `%s`.`creature_movement` WHERE %s ORDER BY `unixtime`", SniffDatabase::m_databaseName.c_str(), whereClause))
269+
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `guid`, `point`, `move_time`, `start_position_x`, `start_position_y`, `start_position_z`, `end_position_x`, `end_position_y`, `end_position_z`, `orientation`, `unixtime` FROM `%s`.`creature_movement_server` WHERE %s ORDER BY `unixtime`", SniffDatabase::m_databaseName.c_str(), whereClause))
270270
{
271271
do
272272
{
@@ -357,6 +357,25 @@ void SniffDatabase::LoadCreatureAttackStop(char const* whereClause)
357357
}
358358
}
359359

360+
void SniffDatabase::LoadCreatureDeath(char const* whereClause)
361+
{
362+
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `unixtimems`, `guid` FROM `%s`.`creature_values_update` WHERE (`current_health`=0) && %s ORDER BY `unixtimems`", SniffDatabase::m_databaseName.c_str(), whereClause))
363+
{
364+
do
365+
{
366+
DbField* pFields = result->fetchCurrentRow();
367+
368+
uint64 unixtimems = pFields[0].getUInt64();
369+
uint32 guid = pFields[1].getUInt32();
370+
uint32 creatureId = GetCreatureEntryFromGuid(guid);
371+
372+
std::shared_ptr<SniffedEvent_CreatureDeath> newEvent = std::make_shared<SniffedEvent_CreatureDeath>(guid, creatureId);
373+
TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent));
374+
375+
} while (result->NextRow());
376+
}
377+
}
378+
360379
void SniffDatabase::LoadCreatureDestroy(char const* whereClause)
361380
{
362381
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `guid`, `unixtimems` FROM `%s`.`creature_destroy_time` WHERE %s ORDER BY `unixtimems`", SniffDatabase::m_databaseName.c_str(), whereClause))
@@ -513,7 +532,7 @@ void SniffDatabase::LoadGameObjectUpdate(char const* fieldName, char const* wher
513532

514533
void SniffDatabase::LoadQuestAcceptTimes(char const* whereClause)
515534
{
516-
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `unixtimems`, `object_guid`, `object_id`, `object_type`, `quest_id` FROM `%s`.`quest_client_accept` WHERE %s ORDER BY `unixtimems`", SniffDatabase::m_databaseName.c_str(), whereClause))
535+
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `unixtimems`, `object_guid`, `object_id`, `object_type`, `quest_id` FROM `%s`.`client_quest_accept` WHERE %s ORDER BY `unixtimems`", SniffDatabase::m_databaseName.c_str(), whereClause))
517536
{
518537
do
519538
{
@@ -534,7 +553,7 @@ void SniffDatabase::LoadQuestAcceptTimes(char const* whereClause)
534553

535554
void SniffDatabase::LoadQuestCompleteTimes(char const* whereClause)
536555
{
537-
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `unixtimems`, `object_guid`, `object_id`, `object_type`, `quest_id` FROM `%s`.`quest_client_complete` WHERE %s ORDER BY `unixtimems`", SniffDatabase::m_databaseName.c_str(), whereClause))
556+
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `unixtimems`, `object_guid`, `object_id`, `object_type`, `quest_id` FROM `%s`.`client_quest_complete` WHERE %s ORDER BY `unixtimems`", SniffDatabase::m_databaseName.c_str(), whereClause))
538557
{
539558
do
540559
{
@@ -555,7 +574,7 @@ void SniffDatabase::LoadQuestCompleteTimes(char const* whereClause)
555574

556575
void SniffDatabase::LoadCreatureInteractTimes(char const* whereClause)
557576
{
558-
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `unixtimems`, `guid` FROM `%s`.`creature_client_interact` WHERE %s ORDER BY `unixtimems`", SniffDatabase::m_databaseName.c_str(), whereClause))
577+
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `unixtimems`, `guid` FROM `%s`.`client_creature_interact` WHERE %s ORDER BY `unixtimems`", SniffDatabase::m_databaseName.c_str(), whereClause))
559578
{
560579
do
561580
{
@@ -574,7 +593,7 @@ void SniffDatabase::LoadCreatureInteractTimes(char const* whereClause)
574593

575594
void SniffDatabase::LoadGameObjectUseTimes(char const* whereClause)
576595
{
577-
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `unixtimems`, `guid` FROM `%s`.`gameobject_client_use` WHERE %s ORDER BY `unixtimems`", SniffDatabase::m_databaseName.c_str(), whereClause))
596+
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `unixtimems`, `guid` FROM `%s`.`client_gameobject_use` WHERE %s ORDER BY `unixtimems`", SniffDatabase::m_databaseName.c_str(), whereClause))
578597
{
579598
do
580599
{
@@ -593,7 +612,7 @@ void SniffDatabase::LoadGameObjectUseTimes(char const* whereClause)
593612

594613
void SniffDatabase::LoadItemUseTimes(char const* whereClause)
595614
{
596-
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `unixtimems`, `entry` FROM `%s`.`item_client_use` WHERE %s ORDER BY `unixtimems`", SniffDatabase::m_databaseName.c_str(), whereClause))
615+
if (std::shared_ptr<QueryResult> result = GameDb.Query("SELECT `unixtimems`, `entry` FROM `%s`.`client_item_use` WHERE %s ORDER BY `unixtimems`", SniffDatabase::m_databaseName.c_str(), whereClause))
597616
{
598617
do
599618
{

0 commit comments

Comments
 (0)