diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a1459ba --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +Debug/ +.vs/ +SniffScripter/*.sql +enc_temp_folder/ \ No newline at end of file diff --git a/SniffScripter/Database/Database.cpp b/SniffScripter/Database/Database.cpp index 95c4f42..c8c016e 100644 --- a/SniffScripter/Database/Database.cpp +++ b/SniffScripter/Database/Database.cpp @@ -9,16 +9,15 @@ #include #include -// Keep track of how many database connections the +// Keep track of how many database connections size_t Database::m_stDatabaseCount = 0; -Database::Database() : +Database::Database() : m_pMYSQL(nullptr), m_bQueriesTransaction(false), m_bCancelToken(false), m_bInit(false) { - } Database::~Database() @@ -73,7 +72,7 @@ bool Database::Initialize(const char* infoString) printf("Database::Initialize - Could not initialize Mysql connection"); return false; } - + std::string strHost; std::string strPortOrSocket; std::string strUser; @@ -94,11 +93,11 @@ bool Database::Initialize(const char* infoString) } mysql_options(pMyqlInit, MYSQL_SET_CHARSET_NAME, "utf8"); - + int32 port = 0; // Named pipe use option (Windows) - if (strHost == ".") + if (strHost == ".") { uint32 opt = MYSQL_PROTOCOL_PIPE; mysql_options(pMyqlInit, MYSQL_OPT_PROTOCOL, (char const*)&opt); @@ -134,7 +133,7 @@ bool Database::Initialize(const char* infoString) } else { - printf("Database::Initialize - Could not connect to MySQL database %s at %s\n", strDbName.c_str(),strHost.c_str()); + printf("Database::Initialize - Could not connect to MySQL database %s at %s\n", strDbName.c_str(), strHost.c_str()); mysql_close(pMyqlInit); return false; } @@ -143,7 +142,7 @@ bool Database::Initialize(const char* infoString) void Database::WorkerThread() { // Cycle until m_bCancelToken variable is set to false. - // However, we will also wait until we've finished emptying m_queueQueries. + // However, we will also wait until we've finished emptying m_queueQueries. // Anything in that queue expected itself to be finished. while (true) @@ -207,13 +206,13 @@ int32 Database::QueryInt32(const char* format, ...) std::shared_ptr Database::LockedPerformQuery(const std::string strQuery) { std::lock_guard lock(m_mutexMysql); - return PerformQuery(strQuery); + return PerformQuery(strQuery); } std::shared_ptr Database::PerformQuery(const std::string strQuery) { ASSERT(m_pMYSQL); - + if (!RawMysqlQueryCall(strQuery)) return nullptr; @@ -254,7 +253,7 @@ void Database::CommitManyQueries() for (size_t i = 0; i < m_vTransactionQueries.size(); ++i) result.push_back(std::make_shared(m_vTransactionQueries[i])); - // We anticipate that + // We anticipate that m_queueQueries.pushMany(result); m_vTransactionQueries.clear(); @@ -271,7 +270,7 @@ bool Database::ExecuteQueryInstant(const char* format, ...) { if (!format || !m_pMYSQL) return false; - + std::string strQuery; FORMAT_STRING_ARGS(format, strQuery, MAX_QUERY_LEN); @@ -279,11 +278,11 @@ bool Database::ExecuteQueryInstant(const char* format, ...) return RawMysqlQueryCall(strQuery, true); } -bool Database::QueueExecuteQuery(const char* format,...) +bool Database::QueueExecuteQuery(const char* format, ...) { if (!format || !m_pMYSQL) return false; - + std::string strQuery; FORMAT_STRING_ARGS(format, strQuery, MAX_QUERY_LEN); @@ -301,7 +300,7 @@ bool Database::QueueExecuteQuery(const char* format,...) } bool Database::RawMysqlQueryCall(const std::string strQuery, const bool bDeleteGatheredData) -{ +{ ASSERT(m_pMYSQL); if (mysql_query(m_pMYSQL, strQuery.c_str())) @@ -332,9 +331,9 @@ void Database::EscapeString(std::string& str) char strResult[MAX_QUERY_LEN]; ASSERT(str.size() < MAX_QUERY_LEN); - + mysql_real_escape_string(m_pMYSQL, strResult, str.c_str(), str.size()); - + // Copy result. str = strResult; } @@ -342,7 +341,7 @@ void Database::EscapeString(std::string& str) void Database::CallbackResult(const uint64 id, std::shared_ptr result) { std::lock_guard lock(m_mutexCallbackQueries); - + auto itr = m_uoCallbackQueries.find(id); if (itr != m_uoCallbackQueries.end()) diff --git a/SniffScripter/Database/DbField.cpp b/SniffScripter/Database/DbField.cpp index 127411a..de20f23 100644 --- a/SniffScripter/Database/DbField.cpp +++ b/SniffScripter/Database/DbField.cpp @@ -5,13 +5,12 @@ #include "DbField.h" #include "Database.h" -DbField::DbField() : +DbField::DbField() : m_pData(nullptr) { - } -DbField::DbField(DbField &f) +DbField::DbField(DbField& f) { const char* value = nullptr; value = f.getString(); @@ -22,7 +21,7 @@ DbField::DbField(DbField &f) m_pData = nullptr; } -DbField::DbField(const char* value) +DbField::DbField(const char* value) { if (value && (m_pData = new char[strlen(value) + 1])) strcpy(m_pData, value); @@ -33,13 +32,13 @@ DbField::DbField(const char* value) DbField::~DbField() { if (m_pData) - delete [] m_pData; + delete[] m_pData; } void DbField::SetValue(const char* value) { if (m_pData) - delete [] m_pData; + delete[] m_pData; if (value) { @@ -50,6 +49,4 @@ void DbField::SetValue(const char* value) { m_pData = nullptr; } -} - - +} \ No newline at end of file diff --git a/SniffScripter/Database/QueryObject.cpp b/SniffScripter/Database/QueryObject.cpp index 98816b1..5a3ab7c 100644 --- a/SniffScripter/Database/QueryObject.cpp +++ b/SniffScripter/Database/QueryObject.cpp @@ -21,7 +21,7 @@ void QueryObj::RunQuery(Database& db) void CallbackQueryObj::RunQuery(Database& db) { std::shared_ptr result(new ResultQueryHolder(m_strMsgToSelf)); - + // Would be nonsensical for this to be empty. ASSERT(!m_uoQueries.empty()); diff --git a/SniffScripter/Database/QueryResult.cpp b/SniffScripter/Database/QueryResult.cpp index bf7ebba..f04b670 100644 --- a/SniffScripter/Database/QueryResult.cpp +++ b/SniffScripter/Database/QueryResult.cpp @@ -5,9 +5,9 @@ #include "Database.h" #include "QueryResult.h" -QueryResult::QueryResult(MYSQL_RES* result, MYSQL_FIELD* fields, uint64 rowCount, uint32 fieldCount) : - m_pResult(result), - m_uiFieldCount(fieldCount), +QueryResult::QueryResult(MYSQL_RES* result, MYSQL_FIELD* fields, uint64 rowCount, uint32 fieldCount) : + m_pResult(result), + m_uiFieldCount(fieldCount), m_uiRowCount(rowCount) { m_pCurrentRow = new DbField[m_uiFieldCount]; @@ -46,7 +46,7 @@ void QueryResult::EndQuery() { if (m_pCurrentRow) { - delete [] m_pCurrentRow; + delete[] m_pCurrentRow; m_pCurrentRow = 0; } @@ -55,6 +55,4 @@ void QueryResult::EndQuery() mysql_free_result(m_pResult); m_pResult = 0; } -} - - +} \ No newline at end of file diff --git a/SniffScripter/Defines/SniffedEvents.h b/SniffScripter/Defines/SniffedEvents.h index 3936862..a870f37 100644 --- a/SniffScripter/Defines/SniffedEvents.h +++ b/SniffScripter/Defines/SniffedEvents.h @@ -19,14 +19,14 @@ struct KnownObject bool operator==(KnownObject const& other) const { return m_guid == other.m_guid && - m_entry == other.m_entry && - m_type == other.m_type; + m_entry == other.m_entry && + m_type == other.m_type; } bool operator!=(KnownObject const& other) const { return !(m_guid == other.m_guid && - m_entry == other.m_entry && - m_type == other.m_type); + m_entry == other.m_entry && + m_type == other.m_type); } bool operator<(KnownObject const& other) const { @@ -216,10 +216,9 @@ struct SniffedEvent_CreatureDeath : SniffedEvent } }; - struct SniffedEvent_CreatureText : SniffedEvent { - SniffedEvent_CreatureText(uint32 guid, uint32 entry, std::string text, uint32 chatType, std::string comment) : + SniffedEvent_CreatureText(uint32 guid, uint32 entry, std::string text, uint32 chatType, std::string comment) : m_guid(guid), m_entry(entry), m_chatType(chatType), m_text(text), m_comment(comment) {}; uint32 m_guid = 0; uint32 m_entry = 0; @@ -239,7 +238,7 @@ struct SniffedEvent_CreatureText : SniffedEvent txt += "Chat Type: " + GetGetChatTypeName(ConvertChatTypeToVmangosFormat(m_chatType)) + "\n"; txt += "Comment: " + m_comment; } - + return txt; } SniffedEventType GetType() const final @@ -347,7 +346,7 @@ struct SniffedEvent_CreatureMovement : SniffedEvent float m_orientation = 0.0f; std::string ToString(bool /*singleLine*/) const final { - std::string txt = "Creature " + WorldDatabase::GetCreatureName(m_entry) + " (Guid: " + std::to_string(m_guid) + " Entry: " + std::to_string(m_entry) + ") moves to point " + std::to_string(m_point) + " in " + std::to_string(m_moveTime) +" ms.\n"; + std::string txt = "Creature " + WorldDatabase::GetCreatureName(m_entry) + " (Guid: " + std::to_string(m_guid) + " Entry: " + std::to_string(m_entry) + ") moves to point " + std::to_string(m_point) + " in " + std::to_string(m_moveTime) + " ms.\n"; txt += "Start Position: " + std::to_string(m_startX) + " " + std::to_string(m_startY) + " " + std::to_string(m_startZ) + "\n"; txt += "End Position: " + std::to_string(m_endX) + " " + std::to_string(m_endY) + " " + std::to_string(m_endZ) + "\n"; txt += "Final Orientation: " + std::to_string(m_orientation); @@ -364,9 +363,9 @@ struct SniffedEvent_CreatureMovement : SniffedEvent } }; -struct SniffedEvent_VmangosWaypoints : SniffedEvent +struct SniffedEvent_mangosWaypoints : SniffedEvent { - SniffedEvent_VmangosWaypoints(uint32 guid, uint32 point, float position_x, float position_y, float position_z, float orientation, uint32 waittime, float wander_distance, uint32 script_id, std::string comment) : + SniffedEvent_mangosWaypoints(uint32 guid, uint32 point, float position_x, float position_y, float position_z, float orientation, uint32 waittime, float wander_distance, uint32 script_id, std::string comment) : m_guid(guid), m_point(point), m_position_x(position_x), m_position_y(position_y), m_position_z(position_z), m_orientation(orientation), m_waittime(waittime), m_wander_distance(wander_distance), m_script_id(script_id), m_comment(comment) {}; uint32 m_guid = 0; uint32 m_point = 0; @@ -380,7 +379,7 @@ struct SniffedEvent_VmangosWaypoints : SniffedEvent std::string m_comment; std::string ToString(bool /*singleLine*/) const final { - std::string txt = "(" + std::to_string(m_guid) + ", " + std::to_string(m_point) + ", " + std::to_string(m_position_x) + ", " + std::to_string(m_position_y) + ", " + std::to_string(m_position_z) + ", " + std::to_string(m_orientation) + ", " + std::to_string(m_waittime) + ", " + std::to_string(m_wander_distance) + ", " + std::to_string(m_script_id) + ")"; + std::string txt = "(" + std::to_string(m_guid) + ", " + std::to_string(m_point) + ", " + std::to_string(m_position_x) + ", " + std::to_string(m_position_y) + ", " + std::to_string(m_position_z) + ", " + std::to_string(m_orientation) + ", " + std::to_string(m_waittime) + (CURRENT_BUILD >= TBC_START_BUILD ? "" : ", " + std::to_string(m_wander_distance)) + ", " + std::to_string(m_script_id) + ")"; return txt; } SniffedEventType GetType() const final @@ -442,7 +441,7 @@ struct SniffedEvent_CreatureUpdate_faction : SniffedEvent uint32 m_value = 0; std::string ToString(bool /*singleLine*/) const final { - std::string txt = "Creature " + WorldDatabase::GetCreatureName(m_entry) + " (Guid: " + std::to_string(m_guid) + " Entry: " + std::to_string(m_entry) + ") updates faction to " + std::to_string(m_value) + + " (" + WorldDatabase::GetFactionName(m_value) + ")."; + std::string txt = "Creature " + WorldDatabase::GetCreatureName(m_entry) + " (Guid: " + std::to_string(m_guid) + " Entry: " + std::to_string(m_entry) + ") updates faction to " + std::to_string(m_value) + +" (" + WorldDatabase::GetFactionName(m_value) + ")."; return txt; } SniffedEventType GetType() const final @@ -707,7 +706,7 @@ struct SniffedEvent_PlaySound : SniffedEvent if (m_sourceId != 0) txt += " Source is " + FormatObjectName(m_sourceGuid, m_sourceId, m_sourceType) + "."; } - + return txt; } SniffedEventType GetType() const final @@ -754,7 +753,7 @@ struct SniffedEvent_SpellCastStart : SniffedEvent } }; -struct SniffedEvent_SpellCastGo: SniffedEvent +struct SniffedEvent_SpellCastGo : SniffedEvent { SniffedEvent_SpellCastGo(uint32 spellId, uint32 casterGuid, uint32 casterId, std::string casterType, uint32 targetGuid, uint32 targetId, std::string targetType, uint32 hitTargetsCount, uint32 hitTargetsListId) : m_spellId(spellId), m_casterGuid(casterGuid), m_casterId(casterId), m_casterType(casterType), m_targetGuid(targetGuid), m_targetId(targetId), m_targetType(targetType), m_hitTargetsCount(hitTargetsCount), m_hitTargetsListId(hitTargetsListId) {}; @@ -788,7 +787,7 @@ struct SniffedEvent_SpellCastGo: SniffedEvent } } } - + return txt; } SniffedEventType GetType() const final diff --git a/SniffScripter/Defines/TimelineMaker.h b/SniffScripter/Defines/TimelineMaker.h index 9c0523d..0d3a262 100644 --- a/SniffScripter/Defines/TimelineMaker.h +++ b/SniffScripter/Defines/TimelineMaker.h @@ -16,7 +16,7 @@ class TimelineMaker static void PromptTimelineSaveMethod(uint32 startTime); static void CreateTimelineForGuids(uint32 uiStartTime, std::vector& vCreatureGuids, std::vector 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); 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); - + static uint32 SaveWaypointsToFile(); static void CreateWaypoints(uint32 guid, bool useStartPosition); diff --git a/SniffScripter/Defines/WorldDatabase.h b/SniffScripter/Defines/WorldDatabase.h index a6a40db..b18abed 100644 --- a/SniffScripter/Defines/WorldDatabase.h +++ b/SniffScripter/Defines/WorldDatabase.h @@ -5,6 +5,10 @@ #include #include "Common.h" +#define CURRENT_PATCH 10 +#define CURRENT_BUILD 8606 // 2.4.3 (5875 - 1.12.1) +#define TBC_START_BUILD 5610 // 2.0.0 + struct BroadcastText { BroadcastText(std::string maleText, std::string femaleText) : m_maleText(maleText), m_femaleText(femaleText) {}; diff --git a/SniffScripter/SniffDatabase.cpp b/SniffScripter/SniffDatabase.cpp index 54ebab4..dfa22da 100644 --- a/SniffScripter/SniffDatabase.cpp +++ b/SniffScripter/SniffDatabase.cpp @@ -53,7 +53,6 @@ void SniffDatabase::LoadCreatureSpawns() } } - std::map SniffDatabase::m_gameObjectGuidToEntry; void SniffDatabase::LoadGameObjectSpawns() @@ -113,7 +112,6 @@ void SniffDatabase::LoadSpellCastStart(char const* whereClause) std::shared_ptr newEvent = std::make_shared(spellId, casterGuid, casterId, casterType, targetGuid, targetId, targetType); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -134,7 +132,6 @@ void SniffDatabase::LoadSpellCastGoHitTargets() target.m_entry = pFields[2].getUInt32(); target.m_type = pFields[3].getCppString(); m_spellGoHitTargets[listId].push_back(target); - } while (result->NextRow()); } } @@ -166,7 +163,6 @@ void SniffDatabase::LoadSpellCastGo(char const* whereClause) std::shared_ptr newEvent = std::make_shared(spellId, casterGuid, casterId, casterType, targetGuid, targetId, targetType, hitTargetsCount, hitTargetsListId); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -187,7 +183,6 @@ void SniffDatabase::LoadPlaySound(char const* whereClause) std::shared_ptr newEvent = std::make_shared(soundId, sourceGuid, sourceId, sourceType); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -205,7 +200,6 @@ void SniffDatabase::LoadPlayMusic(char const* whereClause) std::shared_ptr newEvent = std::make_shared(musicId); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -234,7 +228,6 @@ void SniffDatabase::LoadCreatureUpdate(char const* fieldName, char const* whereC std::shared_ptr newEvent = std::make_shared(guid, creatureId, value); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -259,7 +252,6 @@ void SniffDatabase::LoadCreatureText(char const* whereClause) std::shared_ptr newEvent = std::make_shared(creatureGuid, creatureId, text, chatType, comment); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -286,8 +278,7 @@ void SniffDatabase::LoadCreatureMovement(char const* whereClause) uint64 unixtime = pFields[10].getUInt32(); std::shared_ptr newEvent = std::make_shared(guid, creatureId, point, moveTime, startX, startY, startZ, endX, endY, endZ, orientation); - TimelineMaker::m_eventsMap.insert(std::make_pair(unixtime*1000, newEvent)); - + TimelineMaker::m_eventsMap.insert(std::make_pair(unixtime * 1000, newEvent)); } while (result->NextRow()); } } @@ -308,7 +299,6 @@ void SniffDatabase::LoadCreatureEmote(char const* whereClause) std::shared_ptr newEvent = std::make_shared(guid, creatureId, emoteId, emoteName); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -330,7 +320,6 @@ void SniffDatabase::LoadCreatureAttackStart(char const* whereClause) std::shared_ptr newEvent = std::make_shared(guid, creatureId, victimGuid, victimId, victimType); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -352,7 +341,6 @@ void SniffDatabase::LoadCreatureAttackStop(char const* whereClause) std::shared_ptr newEvent = std::make_shared(guid, creatureId, victimGuid, victimId, victimType); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -371,7 +359,6 @@ void SniffDatabase::LoadCreatureDeath(char const* whereClause) std::shared_ptr newEvent = std::make_shared(guid, creatureId); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -390,7 +377,6 @@ void SniffDatabase::LoadCreatureDestroy(char const* whereClause) std::shared_ptr newEvent = std::make_shared(guid, creatureId); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -413,7 +399,6 @@ void SniffDatabase::LoadCreatureCreate2(char const* whereClause) std::shared_ptr newEvent = std::make_shared(guid, creatureId, position_x, position_y, position_z, orientation); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -436,7 +421,6 @@ void SniffDatabase::LoadCreatureCreate1(char const* whereClause) std::shared_ptr newEvent = std::make_shared(guid, creatureId, position_x, position_y, position_z, orientation); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -455,7 +439,6 @@ void SniffDatabase::LoadGameObjectDestroy(char const* whereClause) std::shared_ptr newEvent = std::make_shared(guid, entry); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -478,7 +461,6 @@ void SniffDatabase::LoadGameObjectCreate2(char const* whereClause) std::shared_ptr newEvent = std::make_shared(guid, entry, position_x, position_y, position_z, orientation); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -501,7 +483,6 @@ void SniffDatabase::LoadGameObjectCreate1(char const* whereClause) std::shared_ptr newEvent = std::make_shared(guid, entry, position_x, position_y, position_z, orientation); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -525,7 +506,6 @@ void SniffDatabase::LoadGameObjectUpdate(char const* fieldName, char const* wher std::shared_ptr newEvent = std::make_shared(guid, entry, value); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -546,7 +526,6 @@ void SniffDatabase::LoadQuestAcceptTimes(char const* whereClause) std::shared_ptr newEvent = std::make_shared(questId, objectGuid, objectId, objectType); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -567,7 +546,6 @@ void SniffDatabase::LoadQuestCompleteTimes(char const* whereClause) std::shared_ptr newEvent = std::make_shared(questId, objectGuid, objectId, objectType); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -586,7 +564,6 @@ void SniffDatabase::LoadCreatureInteractTimes(char const* whereClause) std::shared_ptr newEvent = std::make_shared(guid, entry); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -605,7 +582,6 @@ void SniffDatabase::LoadGameObjectUseTimes(char const* whereClause) std::shared_ptr newEvent = std::make_shared(guid, entry); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -623,7 +599,6 @@ void SniffDatabase::LoadItemUseTimes(char const* whereClause) std::shared_ptr newEvent = std::make_shared(entry); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -640,7 +615,6 @@ void SniffDatabase::LoadClientReclaimCorpse(char const* whereClause) std::shared_ptr newEvent = std::make_shared(); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -657,7 +631,6 @@ void SniffDatabase::LoadClientReleaseSpirit(char const* whereClause) std::shared_ptr newEvent = std::make_shared(); TimelineMaker::m_eventsMap.insert(std::make_pair(unixtimems, newEvent)); - } while (result->NextRow()); } } @@ -672,7 +645,6 @@ uint32 SniffDatabase::GetCreatureFieldValueBeforeTime(uint32 guid, uint64 unixti DbField* pFields = result->fetchCurrentRow(); field = pFields[0].getUInt32(); - } while (result->NextRow()); } @@ -683,7 +655,6 @@ uint32 SniffDatabase::GetCreatureFieldValueBeforeTime(uint32 guid, uint64 unixti DbField* pFields = result->fetchCurrentRow(); field = pFields[0].getUInt32(); - } while (result->NextRow()); } return field; diff --git a/SniffScripter/TimelineMaker.cpp b/SniffScripter/TimelineMaker.cpp index 7430555..a65583b 100644 --- a/SniffScripter/TimelineMaker.cpp +++ b/SniffScripter/TimelineMaker.cpp @@ -3,11 +3,14 @@ #include #include #include +#include +#include #include "Defines\SniffedEvents.h" #include "Defines\SniffDatabase.h" #include "Defines\TimelineMaker.h" #include "Defines\ScriptCommands.h" #include "Defines\Helpers.h" +#include "Defines\WorldDatabase.h" #include "Database\Database.h" extern Database GameDb; @@ -197,7 +200,7 @@ void TimelineMaker::CreateTimelineForGuids(uint32 uiStartTime, std::vector("state", whereClause); } } - + if (showCasts) { { @@ -479,7 +482,6 @@ void TimelineMaker::CreateTimelineForAll(uint32 uiStartTime, uint32 uiEndTime, b SniffDatabase::LoadCreatureDestroy(whereClause); } } - // GameObjects @@ -531,7 +533,7 @@ void TimelineMaker::CreateTimelineForAll(uint32 uiStartTime, uint32 uiEndTime, b SniffDatabase::LoadGameObjectDestroy(whereClause); } } - + // Sounds and Music if (showSounds) @@ -565,7 +567,7 @@ void TimelineMaker::PromptTimelineSaveMethod(uint32 startTime) void TimelineMaker::PrintTimelineToScreen(uint32 startTime) { - uint64 lastEventTime = uint64(startTime)*1000; + uint64 lastEventTime = uint64(startTime) * 1000; for (const auto& itr : m_eventsMap) { uint64 timeDiff = itr.first - lastEventTime; @@ -633,7 +635,7 @@ std::string GetListOfPointsWithSamePosition(float posX, float posY, float posZ, std::string points; for (const auto& itr : TimelineMaker::m_eventsMap) { - if (auto ptr = std::dynamic_pointer_cast(itr.second)) + if (auto ptr = std::dynamic_pointer_cast(itr.second)) { if (ptr->m_position_x == posX && ptr->m_position_y == posY && ptr->m_position_z == posZ && (ptr->m_point != point - 1)) { @@ -689,7 +691,7 @@ void TimelineMaker::CreateWaypoints(uint32 guid, bool useStartPosition) if (std::shared_ptr result = GameDb.Query("SELECT `guid`, `point`, `move_time`, `spline_flags`, `spline_count`, `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 `guid`=%u", SniffDatabase::m_databaseName.c_str(), guid)) { uint32 pointCounter = 1; - std::shared_ptr lastPoint = nullptr; + std::shared_ptr lastPoint = nullptr; uint32 lastMoveTime = 0; uint32 lastUnixTime = 0; float lastOrientation = 100.0f; @@ -727,14 +729,14 @@ void TimelineMaker::CreateWaypoints(uint32 guid, bool useStartPosition) fMoveTime = ceilf(fMoveTime); uint32 roundedUpMoveTime = (uint32)fMoveTime; uint32 timeDiff = unixtime - lastUnixTime; - + if (timeDiff > (roundedUpMoveTime * 2)) { if (useStartPosition) waittime = (timeDiff - roundedUpMoveTime) * 1000; else lastPoint->m_waittime = (timeDiff - roundedUpMoveTime) * 1000; - } + } } if (useStartPosition) @@ -745,7 +747,7 @@ void TimelineMaker::CreateWaypoints(uint32 guid, bool useStartPosition) std::string comment = GetListOfPointsWithSamePosition(start_position_x, start_position_y, start_position_z, point); if (!comment.empty()) comment = "position seen before in points: " + comment; - std::shared_ptr newEvent = std::make_shared(id, pointCounter, start_position_x, start_position_y, start_position_z, orientation, waittime, 0.0f, 0, comment); + std::shared_ptr newEvent = std::make_shared(id, pointCounter, start_position_x, start_position_y, start_position_z, orientation, waittime, 0.0f, 0, comment); m_eventsMap.insert(std::make_pair(uint64(unixtime) * 1000, newEvent)); lastPoint = newEvent; @@ -762,7 +764,7 @@ void TimelineMaker::CreateWaypoints(uint32 guid, bool useStartPosition) uint32 splinesCount = (splines.size() - 1); float orientation = (i == splinesCount) ? final_orientation : 100.0f; std::string comment = "spline " + std::to_string(i) + "/" + std::to_string(splinesCount); - std::shared_ptr newEvent = std::make_shared(id, pointCounter, spline.position_x, spline.position_y, spline.position_z, orientation, 0, 0.0f, 0, comment); + std::shared_ptr newEvent = std::make_shared(id, pointCounter, spline.position_x, spline.position_y, spline.position_z, orientation, 0, 0.0f, 0, comment); m_eventsMap.insert(std::make_pair(uint64(unixtime) * 1000, newEvent)); lastPoint = newEvent; @@ -786,8 +788,8 @@ void TimelineMaker::CreateWaypoints(uint32 guid, bool useStartPosition) if (!samePointsList.empty()) comment = "position seen before in points: " + samePointsList; } - - std::shared_ptr newEvent = std::make_shared(id, pointCounter, posX, posY, posZ, final_orientation, 0, 0.0f, 0, comment); + + std::shared_ptr newEvent = std::make_shared(id, pointCounter, posX, posY, posZ, final_orientation, 0, 0.0f, 0, comment); m_eventsMap.insert(std::make_pair(uint64(unixtime) * 1000, newEvent)); lastPoint = newEvent; @@ -797,7 +799,6 @@ void TimelineMaker::CreateWaypoints(uint32 guid, bool useStartPosition) lastMoveTime = move_time; lastUnixTime = unixtime; - } while (result->NextRow()); } @@ -897,11 +898,15 @@ uint32 TimelineMaker::SaveWaypointsToFile() if (m_eventsMap.empty()) return 0; - std::ofstream log("waypoints.sql"); + std::time_t result = std::time(nullptr); + std::stringstream ss; + ss << result; + std::string ts = ss.str(); + std::ofstream log("waypoints_" + ts + ".sql"); if (!log.is_open()) return 0; - log << "INSERT INTO `creature_movement` (`id`, `point`, `position_x`, `position_y`, `position_z`, `orientation`, `waittime`, `wander_distance`, `script_id`) VALUES\n"; + log << (CURRENT_BUILD >= TBC_START_BUILD ? "INSERT INTO `creature_movement` (`id`, `point`, `position_x`, `position_y`, `position_z`, `orientation`, `waittime`, `script_id`) VALUES\n" : "INSERT INTO `creature_movement` (`id`, `point`, `position_x`, `position_y`, `position_z`, `orientation`, `waittime`, `wander_distance`, `script_id`) VALUES\n"); uint32 totalWaypointRows = 0; for (const auto& itr : m_eventsMap) @@ -914,7 +919,7 @@ uint32 TimelineMaker::SaveWaypointsToFile() uint32 waypointRows = 0; for (const auto& itr : m_eventsMap) { - if (auto ptr = std::dynamic_pointer_cast(itr.second)) + if (auto ptr = std::dynamic_pointer_cast(itr.second)) { log << ptr->ToString(true); waypointRows++; @@ -1064,13 +1069,13 @@ bool TimelineMaker::FindQuestsWithRpEvents(uint32 const duration) SniffDatabase::LoadGameObjectUpdate("state", whereClause); } } - + { char whereClause[128] = {}; snprintf(whereClause, 127, "(`caster_guid` = %u) && (`unixtimems` >= (%u * 1000)) && (`unixtimems` <= (%u * 1000))", itr.objectGuid, startTime, endTime); SniffDatabase::LoadSpellCastStart(whereClause); } - + { char whereClause[128] = {}; snprintf(whereClause, 127, "(`caster_guid` = %u) && (`unixtimems` >= (%u * 1000)) && (`unixtimems` <= (%u * 1000))", itr.objectGuid, startTime, endTime); @@ -1093,11 +1098,11 @@ bool TimelineMaker::FindQuestsWithRpEvents(uint32 const duration) else if (sniffedEvent.second->GetType() == SE_CREATURE_MOVEMENT) eventTypes.insert(std::string("Movement")); else if (sniffedEvent.second->GetType() == SE_SPELL_CAST_START || - sniffedEvent.second->GetType() == SE_SPELL_CAST_GO) + sniffedEvent.second->GetType() == SE_SPELL_CAST_GO) eventTypes.insert(std::string("Spell Cast")); - else if (sniffedEvent.second->GetType() == SE_CREATURE_UPDATE_NPC_FLAGS || - sniffedEvent.second->GetType() == SE_GAMEOBJECT_UPDATE_FLAGS || - sniffedEvent.second->GetType() == SE_GAMEOBJECT_UPDATE_STATE) + else if (sniffedEvent.second->GetType() == SE_CREATURE_UPDATE_NPC_FLAGS || + sniffedEvent.second->GetType() == SE_GAMEOBJECT_UPDATE_FLAGS || + sniffedEvent.second->GetType() == SE_GAMEOBJECT_UPDATE_STATE) eventTypes.insert(std::string("Values Update")); } std::string eventTypesList; @@ -1222,7 +1227,7 @@ void TimelineMaker::CreateScriptFromEvents(uint32 uiStartTime, uint32 uiEndTime) } log << "\n"; } - + if (!m_unknownScriptTexts.empty()) { log << "Texts with placeholder broadcast ids:\n"; @@ -1232,7 +1237,7 @@ void TimelineMaker::CreateScriptFromEvents(uint32 uiStartTime, uint32 uiEndTime) } log << "\n"; } - + log << "*/\n\n"; } @@ -1384,7 +1389,7 @@ void TimelineMaker::CreateScriptFromEvents(uint32 uiStartTime, uint32 uiEndTime) script.id = mainScriptId; // Swap targets so that the correct source executes the command. - if (mainActor != source && + if (mainActor != source && script.command != SCRIPT_COMMAND_TEMP_SUMMON_CREATURE && script.command != SCRIPT_COMMAND_SUMMON_OBJECT) { @@ -1413,7 +1418,7 @@ void TimelineMaker::CreateScriptFromEvents(uint32 uiStartTime, uint32 uiEndTime) } } } - + log << "-- Script for " << FormatObjectName(itr.first) << "\n"; SaveScriptToFile(log, GENERIC_SCRIPTS_START + itr.second.first, "generic_scripts", itr.second.second, delayOffset); } @@ -1430,14 +1435,14 @@ void TimelineMaker::SaveScriptToFile(std::ofstream& log, uint32 scriptId, std::s { uint32 count = 0; log << "DELETE FROM `" << tableName << "` WHERE `id`=" << scriptId << ";\n"; - log << "INSERT INTO `" << tableName << "` (`id`, `delay`, `command`, `datalong`, `datalong2`, `datalong3`, `datalong4`, `target_param1`, `target_param2`, `target_type`, `data_flags`, `dataint`, `dataint2`, `dataint3`, `dataint4`, `x`, `y`, `z`, `o`, `condition_id`, `comments`) VALUES\n"; + log << "INSERT INTO `" << tableName << (CURRENT_BUILD >= TBC_START_BUILD) ? "` (`id`, `delay`, `command`, `datalong`, `datalong2`, `datalong3`, `buddy_entry`, `search_radius`, `data_flags`, `dataint`, `dataint2`, `dataint3`, `dataint4`, `x`, `y`, `z`, `o`, `condition_id`, `comments`) VALUES\n" : "` (`id`, `delay`, `command`, `datalong`, `datalong2`, `datalong3`, `datalong4`, `target_param1`, `target_param2`, `target_type`, `data_flags`, `dataint`, `dataint2`, `dataint3`, `dataint4`, `x`, `y`, `z`, `o`, `condition_id`, `comments`) VALUES\n"; for (const auto& script : vScripts) { if (count > 0) log << ",\n"; log << "(" << script.id << ", " << script.delay - delayOffset << ", " << script.command << ", " - << script.raw.data[0] << ", " << script.raw.data[1] << ", " << script.raw.data[2] << ", " << script.raw.data[3] << ", " - << script.target_param1 << ", " << script.target_param2 << ", " << script.target_type << ", " + << script.raw.data[0] << ", " << script.raw.data[1] << ", " << script.raw.data[2] << ", " << (CURRENT_BUILD >= TBC_START_BUILD ? "" : script.raw.data[3] + ", ") + << script.target_param1 << ", " << script.target_param2 << ", " << (CURRENT_BUILD >= TBC_START_BUILD ? "" : script.target_type + ", ") << script.raw.data[4] << ", " << script.raw.data[5] << ", " << script.raw.data[6] << ", " << script.raw.data[7] << ", " << script.raw.data[8] << ", " << script.x << ", " << script.y << ", " << script.z << ", " << script.o << ", " << script.condition << ", '" << script.comment << "')"; @@ -1710,4 +1715,4 @@ void TimelineMaker::GetScriptInfoFromSniffedEvent(uint64 unixtimems, std::shared script.comment = "Cast Spell " + WorldDatabase::GetSpellName(ptr->m_spellId); scriptActions.push_back(script); } -} +} \ No newline at end of file diff --git a/SniffScripter/WorldDatabase.cpp b/SniffScripter/WorldDatabase.cpp index 71605e0..3575479 100644 --- a/SniffScripter/WorldDatabase.cpp +++ b/SniffScripter/WorldDatabase.cpp @@ -5,16 +5,14 @@ extern Database GameDb; -#define CURRENT_PATCH 10 -#define CURRENT_BUILD 5875 - std::map WorldDatabase::m_creatureNames; void WorldDatabase::LoadCreatures() { printf("Loading creature database.\n"); - // 0 1 - if (std::shared_ptr result = GameDb.Query("SELECT `entry`, `name` FROM `creature_template` t1 WHERE `patch`=(SELECT max(`patch`) FROM `creature_template` t2 WHERE t1.`entry`=t2.`entry` && `patch` <= %u)", CURRENT_PATCH)) + // 0 1 + std::shared_ptr result = CURRENT_BUILD >= TBC_START_BUILD ? GameDb.Query("SELECT `entry`, `name` FROM `creature_template`") : GameDb.Query("SELECT `entry`, `name` FROM `creature_template` t1 WHERE `patch`=(SELECT max(`patch`) FROM `creature_template` t2 WHERE t1.`entry`=t2.`entry` && `patch` <= %u)", CURRENT_PATCH); + if (result) { do { @@ -33,8 +31,9 @@ std::map WorldDatabase::m_gameObjectNames; void WorldDatabase::LoadGameObjects() { printf("Loading gameobject database.\n"); - // 0 1 - if (std::shared_ptr result = GameDb.Query("SELECT `entry`, `name` FROM `gameobject_template` t1 WHERE `patch`=(SELECT max(`patch`) FROM `gameobject_template` t2 WHERE t1.`entry`=t2.`entry` && `patch` <= %u)", CURRENT_PATCH)) + // 0 1 + std::shared_ptr result = CURRENT_BUILD >= TBC_START_BUILD ? GameDb.Query("SELECT `entry`, `name` FROM `gameobject_template`") : GameDb.Query("SELECT `entry`, `name` FROM `gameobject_template` t1 WHERE `patch`=(SELECT max(`patch`) FROM `gameobject_template` t2 WHERE t1.`entry`=t2.`entry` && `patch` <= %u)", CURRENT_PATCH); + if (result) { do { @@ -53,8 +52,9 @@ std::map WorldDatabase::m_itemNames; void WorldDatabase::LoadItems() { printf("Loading item database.\n"); - // 0 1 - if (std::shared_ptr result = GameDb.Query("SELECT `entry`, `name` FROM `item_template` t1 WHERE `patch`=(SELECT max(`patch`) FROM `item_template` t2 WHERE t1.`entry`=t2.`entry` && `patch` <= %u)", CURRENT_PATCH)) + // 0 1 + std::shared_ptr result = CURRENT_BUILD >= TBC_START_BUILD ? GameDb.Query("SELECT `entry`, `name` FROM `item_template`") : GameDb.Query("SELECT `entry`, `name` FROM `item_template` t1 WHERE `patch`=(SELECT max(`patch`) FROM `item_template` t2 WHERE t1.`entry`=t2.`entry` && `patch` <= %u)", CURRENT_PATCH); + if (result) { do { @@ -73,8 +73,9 @@ std::map WorldDatabase::m_questNames; void WorldDatabase::LoadQuests() { printf("Loading quest database.\n"); - // 0 1 - if (std::shared_ptr result = GameDb.Query("SELECT `entry`, `Title` FROM `quest_template` t1 WHERE `patch`=(SELECT max(`patch`) FROM `quest_template` t2 WHERE t1.`entry`=t2.`entry` && `patch` <= %u)", CURRENT_PATCH)) + // 0 1 + std::shared_ptr result = CURRENT_BUILD >= TBC_START_BUILD ? GameDb.Query("SELECT `entry`, `Title` FROM `quest_template`") : GameDb.Query("SELECT `entry`, `Title` FROM `quest_template` t1 WHERE `patch`=(SELECT max(`patch`) FROM `quest_template` t2 WHERE t1.`entry`=t2.`entry` && `patch` <= %u)", CURRENT_PATCH); + if (result) { do { @@ -93,8 +94,9 @@ std::map WorldDatabase::m_spellNames; void WorldDatabase::LoadSpells() { printf("Loading spell database.\n"); - // 0 1 - if (std::shared_ptr result = GameDb.Query("SELECT `entry`, `name` FROM `spell_template` t1 WHERE `build`=(SELECT max(`build`) FROM `spell_template` t2 WHERE t1.`entry`=t2.`entry` && `build` <= %u)", CURRENT_BUILD)) + // 0 1 + std::shared_ptr result = CURRENT_BUILD >= TBC_START_BUILD ? GameDb.Query("SELECT `Id`, `SpellName` FROM `spell_template`") : GameDb.Query("SELECT `entry`, `name` FROM `spell_template` t1 WHERE `build`=(SELECT max(`build`) FROM `spell_template` t2 WHERE t1.`entry`=t2.`entry` && `build` <= %u)", CURRENT_BUILD); + if (result) { do { @@ -112,8 +114,15 @@ std::map WorldDatabase::m_factionNames; void WorldDatabase::LoadFactions() { + if (CURRENT_BUILD >= TBC_START_BUILD) + { + printf("Skipped loading faction database due to non-Classic CURRENT_BUILD setting.\n"); + return; + } + else + printf("Loading faction database.\n"); + std::map factionNames; - printf("Loading faction database.\n"); // 0 1 if (std::shared_ptr result = GameDb.Query("SELECT `id`, `name` FROM `faction` t1 WHERE `build`=(SELECT max(`build`) FROM `faction` t2 WHERE t1.`id`=t2.`id` && `build` <= %u)", CURRENT_BUILD)) { @@ -128,7 +137,8 @@ void WorldDatabase::LoadFactions() } while (result->NextRow()); } printf("Loading faction template database.\n"); - // 0 1 + + // 0 1 if (std::shared_ptr result = GameDb.Query("SELECT `id`, `faction_id` FROM `faction_template` t1 WHERE `build`=(SELECT max(`build`) FROM `faction_template` t2 WHERE t1.`id`=t2.`id` && `build` <= %u)", CURRENT_BUILD)) { do @@ -147,8 +157,15 @@ std::map WorldDatabase::m_soundNames; void WorldDatabase::LoadSounds() { - printf("Loading sound database.\n"); - // 0 1 + if (CURRENT_BUILD >= TBC_START_BUILD) + { + printf("Skipped loading sound database due to non-Classic CURRENT_BUILD setting.\n"); + return; + } + else + printf("Loading sound database.\n"); + + // 0 1 if (std::shared_ptr result = GameDb.Query("SELECT `id`, `name` FROM `sound_entries`")) { do @@ -168,8 +185,9 @@ std::map WorldDatabase::m_broadcastTexts; void WorldDatabase::LoadBroadcastTexts() { printf("Loading broadcast text database.\n"); - // 0 1 2 - if (std::shared_ptr result = GameDb.Query("SELECT `entry`, `male_text`, `female_text` FROM `broadcast_text`")) + // 0 1 2 + std::shared_ptr result = CURRENT_BUILD >= TBC_START_BUILD ? GameDb.Query("SELECT `Id`, `text`, `text1` FROM `broadcast_text`") : GameDb.Query("SELECT `entry`, `male_text`, `female_text` FROM `broadcast_text`"); + if (result) { do { diff --git a/SniffScripter/main.cpp b/SniffScripter/main.cpp index 808eadb..07b2a4e 100644 --- a/SniffScripter/main.cpp +++ b/SniffScripter/main.cpp @@ -14,6 +14,12 @@ #include "Defines\\Helpers.h" Database GameDb; +std::string mysql_host_default = "localhost"; +std::string mysql_port_default = "3306"; +std::string mysql_user_default = "root"; +std::string mysql_pass_default = "password"; +std::string mysql_world_db_default = "voamangos"; +std::string mysql_sniff_db_default = "nost2"; std::string MakeConnectionString() { @@ -25,30 +31,37 @@ std::string MakeConnectionString() fseek(stdin, 0, SEEK_END); - printf("Host: "); + printf("Host (or press Enter to use all defaults): "); getline(std::cin, mysql_host); if (mysql_host.empty()) - mysql_host = "127.0.0.1"; + { + mysql_host = mysql_host_default; + mysql_port = mysql_port_default; + mysql_user = mysql_user_default; + mysql_pass = mysql_pass_default; + mysql_db = mysql_world_db_default; + return mysql_host + ";" + mysql_port + ";" + mysql_user + ";" + mysql_pass + ";" + mysql_db; + } printf("Port: "); getline(std::cin, mysql_port); if (mysql_port.empty()) - mysql_port = "3306"; + mysql_port = mysql_port_default; printf("User: "); getline(std::cin, mysql_user); if (mysql_user.empty()) - mysql_user = "root"; + mysql_user = mysql_user_default; printf("Password: "); getline(std::cin, mysql_pass); if (mysql_pass.empty()) - mysql_pass = "root"; + mysql_pass = mysql_pass_default; printf("World db: "); getline(std::cin, mysql_db); if (mysql_db.empty()) - mysql_db = "mangos"; + mysql_db = mysql_world_db_default; fseek(stdin, 0, SEEK_END); @@ -64,47 +77,17 @@ enum OPTION_QUESTS_WITH_RP_EVENTS = 5, OPTION_BREAKDOWN_NPC_FLAGS = 6, OPTION_BREAKDOWN_UNIT_FLAGS = 7, + OPTION_QUIT = 8, }; -int main() +int runOnce(uint32 option) { - printf("Options:\n"); - printf("1. Create timeline for specific guids\n"); - printf("2. Create timeline for all in time period\n"); - printf("3. Create waypoints and show events as comments\n"); - printf("4. Create database script from selected events\n"); - printf("5. List quests with RP events\n"); - printf("6. Breakdown NPC Flags\n"); - printf("7. Breakdown Unit Flags\n"); - printf("> "); - - uint32 option = GetUInt32(); - if (option == OPTION_TIMELINE_SPECIFIC_GUIDS || option == OPTION_TIMELINE_ALL_EVENTS || option == OPTION_TIMELINE_WAYPOINTS || option == OPTION_QUESTS_WITH_RP_EVENTS || option == OPTION_GENERATE_SCRIPT) { - printf("\nEnter your database connection info.\n"); - std::string const connection_string = MakeConnectionString(); - - printf("\nConnecting to database.\n"); - if (!GameDb.Initialize(connection_string.c_str())) - { - printf("\nError: Cannot connect to world database!\n"); - GetChar(); - return 1; - } - - WorldDatabase::LoadWorldDatabase(); - printf("\n"); - - printf("Enter sniff database name: "); - SniffDatabase::m_databaseName = GetString("sniffs_new_test"); - SniffDatabase::LoadSniffDatabase(); - printf("\n"); - if (option == OPTION_TIMELINE_SPECIFIC_GUIDS) { std::vector vCreatureGuids; @@ -176,7 +159,7 @@ int main() printf("Show when sounds or music played? (y/n)\n> "); bool showSounds = GetChar() == 'y'; - + printf("Start time: "); uint32 uiStartTime = GetUInt32(); @@ -234,7 +217,7 @@ int main() printf("Show changes to creature update fields? (y/n)\n> "); showCreatureUpdates = GetChar() == 'y'; } - + printf("Show gameobject related events? (y/n)\n> "); bool showGameObjects = GetChar() == 'y'; bool showGameObjectUse = false; @@ -345,9 +328,48 @@ int main() repeat = GetChar() == 'y'; } } - - GetChar(); - GameDb.Uninitialise(); return 0; } +int main() +{ + printf("Enter your database connection info.\n"); + std::string const connection_string = MakeConnectionString(); + + printf("\nConnecting to database.\n"); + if (!GameDb.Initialize(connection_string.c_str())) + { + printf("\nError: Cannot connect to world database!\n"); + GetChar(); + return 1; + } + WorldDatabase::LoadWorldDatabase(); + + printf("\n"); + printf("Enter sniff database name (or press Enter to use default): "); + SniffDatabase::m_databaseName = GetString(mysql_sniff_db_default); + SniffDatabase::LoadSniffDatabase(); + printf("\n"); + + uint32 option = OPTION_TIMELINE_WAYPOINTS; + while (option != OPTION_QUIT) + { + printf("Options:\n"); + printf("1. Create timeline for specific guids\n"); + printf("2. Create timeline for all in time period\n"); + printf("3. Create waypoints and show events as comments\n"); + printf("4. Create database script from selected events\n"); + printf("5. List quests with RP events\n"); + printf("6. Breakdown NPC Flags\n"); + printf("7. Breakdown Unit Flags\n"); + printf("8. Exit\n"); + printf("> "); + option = GetUInt32(); + runOnce(option); + } + + GameDb.Uninitialise(); + printf("Exited - press any key to close window."); + GetChar(); + return 0; +} \ No newline at end of file