Skip to content

Commit 368ce1e

Browse files
committed
Some more changes to make tool more usable for CMaNGOS DB
1 parent cc8d1a1 commit 368ce1e

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
Debug/
22
.vs/
33
SniffScripter/*.sql
4+
enc_temp_folder/

SniffScripter/Defines/SniffedEvents.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ struct SniffedEvent_CreatureMovement : SniffedEvent
363363
}
364364
};
365365

366-
struct SniffedEvent_VmangosWaypoints : SniffedEvent
366+
struct SniffedEvent_mangosWaypoints : SniffedEvent
367367
{
368-
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) :
368+
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) :
369369
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) {};
370370
uint32 m_guid = 0;
371371
uint32 m_point = 0;
@@ -379,7 +379,7 @@ struct SniffedEvent_VmangosWaypoints : SniffedEvent
379379
std::string m_comment;
380380
std::string ToString(bool /*singleLine*/) const final
381381
{
382-
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) + ")";
382+
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) + ")";
383383
return txt;
384384
}
385385
SniffedEventType GetType() const final

SniffScripter/Defines/WorldDatabase.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#include <string>
66
#include "Common.h"
77

8+
#define CURRENT_PATCH 10
9+
#define CURRENT_BUILD 8606 // 2.4.3 (5875 - 1.12.1)
10+
#define TBC_START_BUILD 5610 // 2.0.0
11+
812
struct BroadcastText
913
{
1014
BroadcastText(std::string maleText, std::string femaleText) : m_maleText(maleText), m_femaleText(femaleText) {};

SniffScripter/TimelineMaker.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "Defines\TimelineMaker.h"
1111
#include "Defines\ScriptCommands.h"
1212
#include "Defines\Helpers.h"
13+
#include "Defines\WorldDatabase.h"
1314
#include "Database\Database.h"
1415

1516
extern Database GameDb;
@@ -634,7 +635,7 @@ std::string GetListOfPointsWithSamePosition(float posX, float posY, float posZ,
634635
std::string points;
635636
for (const auto& itr : TimelineMaker::m_eventsMap)
636637
{
637-
if (auto ptr = std::dynamic_pointer_cast<SniffedEvent_VmangosWaypoints>(itr.second))
638+
if (auto ptr = std::dynamic_pointer_cast<SniffedEvent_mangosWaypoints>(itr.second))
638639
{
639640
if (ptr->m_position_x == posX && ptr->m_position_y == posY && ptr->m_position_z == posZ && (ptr->m_point != point - 1))
640641
{
@@ -690,7 +691,7 @@ void TimelineMaker::CreateWaypoints(uint32 guid, bool useStartPosition)
690691
if (std::shared_ptr<QueryResult> 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))
691692
{
692693
uint32 pointCounter = 1;
693-
std::shared_ptr<SniffedEvent_VmangosWaypoints> lastPoint = nullptr;
694+
std::shared_ptr<SniffedEvent_mangosWaypoints> lastPoint = nullptr;
694695
uint32 lastMoveTime = 0;
695696
uint32 lastUnixTime = 0;
696697
float lastOrientation = 100.0f;
@@ -746,7 +747,7 @@ void TimelineMaker::CreateWaypoints(uint32 guid, bool useStartPosition)
746747
std::string comment = GetListOfPointsWithSamePosition(start_position_x, start_position_y, start_position_z, point);
747748
if (!comment.empty())
748749
comment = "position seen before in points: " + comment;
749-
std::shared_ptr<SniffedEvent_VmangosWaypoints> newEvent = std::make_shared<SniffedEvent_VmangosWaypoints>(id, pointCounter, start_position_x, start_position_y, start_position_z, orientation, waittime, 0.0f, 0, comment);
750+
std::shared_ptr<SniffedEvent_mangosWaypoints> newEvent = std::make_shared<SniffedEvent_mangosWaypoints>(id, pointCounter, start_position_x, start_position_y, start_position_z, orientation, waittime, 0.0f, 0, comment);
750751
m_eventsMap.insert(std::make_pair(uint64(unixtime) * 1000, newEvent));
751752

752753
lastPoint = newEvent;
@@ -763,7 +764,7 @@ void TimelineMaker::CreateWaypoints(uint32 guid, bool useStartPosition)
763764
uint32 splinesCount = (splines.size() - 1);
764765
float orientation = (i == splinesCount) ? final_orientation : 100.0f;
765766
std::string comment = "spline " + std::to_string(i) + "/" + std::to_string(splinesCount);
766-
std::shared_ptr<SniffedEvent_VmangosWaypoints> newEvent = std::make_shared<SniffedEvent_VmangosWaypoints>(id, pointCounter, spline.position_x, spline.position_y, spline.position_z, orientation, 0, 0.0f, 0, comment);
767+
std::shared_ptr<SniffedEvent_mangosWaypoints> newEvent = std::make_shared<SniffedEvent_mangosWaypoints>(id, pointCounter, spline.position_x, spline.position_y, spline.position_z, orientation, 0, 0.0f, 0, comment);
767768
m_eventsMap.insert(std::make_pair(uint64(unixtime) * 1000, newEvent));
768769

769770
lastPoint = newEvent;
@@ -788,7 +789,7 @@ void TimelineMaker::CreateWaypoints(uint32 guid, bool useStartPosition)
788789
comment = "position seen before in points: " + samePointsList;
789790
}
790791

791-
std::shared_ptr<SniffedEvent_VmangosWaypoints> newEvent = std::make_shared<SniffedEvent_VmangosWaypoints>(id, pointCounter, posX, posY, posZ, final_orientation, 0, 0.0f, 0, comment);
792+
std::shared_ptr<SniffedEvent_mangosWaypoints> newEvent = std::make_shared<SniffedEvent_mangosWaypoints>(id, pointCounter, posX, posY, posZ, final_orientation, 0, 0.0f, 0, comment);
792793
m_eventsMap.insert(std::make_pair(uint64(unixtime) * 1000, newEvent));
793794

794795
lastPoint = newEvent;
@@ -905,7 +906,7 @@ uint32 TimelineMaker::SaveWaypointsToFile()
905906
if (!log.is_open())
906907
return 0;
907908

908-
log << "INSERT INTO `creature_movement` (`id`, `point`, `position_x`, `position_y`, `position_z`, `orientation`, `waittime`, `wander_distance`, `script_id`) VALUES\n";
909+
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");
909910

910911
uint32 totalWaypointRows = 0;
911912
for (const auto& itr : m_eventsMap)
@@ -918,7 +919,7 @@ uint32 TimelineMaker::SaveWaypointsToFile()
918919
uint32 waypointRows = 0;
919920
for (const auto& itr : m_eventsMap)
920921
{
921-
if (auto ptr = std::dynamic_pointer_cast<SniffedEvent_VmangosWaypoints>(itr.second))
922+
if (auto ptr = std::dynamic_pointer_cast<SniffedEvent_mangosWaypoints>(itr.second))
922923
{
923924
log << ptr->ToString(true);
924925
waypointRows++;
@@ -1434,14 +1435,14 @@ void TimelineMaker::SaveScriptToFile(std::ofstream& log, uint32 scriptId, std::s
14341435
{
14351436
uint32 count = 0;
14361437
log << "DELETE FROM `" << tableName << "` WHERE `id`=" << scriptId << ";\n";
1437-
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";
1438+
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";
14381439
for (const auto& script : vScripts)
14391440
{
14401441
if (count > 0)
14411442
log << ",\n";
14421443
log << "(" << script.id << ", " << script.delay - delayOffset << ", " << script.command << ", "
1443-
<< script.raw.data[0] << ", " << script.raw.data[1] << ", " << script.raw.data[2] << ", " << script.raw.data[3] << ", "
1444-
<< script.target_param1 << ", " << script.target_param2 << ", " << script.target_type << ", "
1444+
<< script.raw.data[0] << ", " << script.raw.data[1] << ", " << script.raw.data[2] << ", " << (CURRENT_BUILD >= TBC_START_BUILD ? "" : script.raw.data[3] + ", ")
1445+
<< script.target_param1 << ", " << script.target_param2 << ", " << (CURRENT_BUILD >= TBC_START_BUILD ? "" : script.target_type + ", ")
14451446
<< script.raw.data[4] << ", " << script.raw.data[5] << ", " << script.raw.data[6] << ", " << script.raw.data[7] << ", "
14461447
<< script.raw.data[8] << ", " << script.x << ", " << script.y << ", " << script.z << ", " << script.o << ", "
14471448
<< script.condition << ", '" << script.comment << "')";

SniffScripter/WorldDatabase.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55

66
extern Database GameDb;
77

8-
#define CURRENT_PATCH 10
9-
#define CURRENT_BUILD 8606 // 2.4.3 (5875 - 1.12.1)
10-
#define TBC_START_BUILD 5610 // 2.0.0
11-
128
std::map<uint32, std::string> WorldDatabase::m_creatureNames;
139

1410
void WorldDatabase::LoadCreatures()

0 commit comments

Comments
 (0)