From 2fde9edb41617ec117c078650c10428ed446167c Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Tue, 26 Apr 2016 16:06:24 -0400 Subject: [PATCH] Fix null bind issues --- common/database.cpp | 8 +++++++- world/client.cpp | 20 +++++++++++++++++++- world/worlddb.cpp | 28 +++++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/common/database.cpp b/common/database.cpp index a54de2bd5..f223418ab 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -641,10 +641,16 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe /* Save Bind Points */ query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, slot)" " VALUES (%u, %u, %u, %f, %f, %f, %f, %i), " + "(%u, %u, %u, %f, %f, %f, %f, %i), ", + "(%u, %u, %u, %f, %f, %f, %f, %i), ", + "(%u, %u, %u, %f, %f, %f, %f, %i), ", "(%u, %u, %u, %f, %f, %f, %f, %i)", character_id, pp->binds[0].zoneId, 0, pp->binds[0].x, pp->binds[0].y, pp->binds[0].z, pp->binds[0].heading, 0, + character_id, pp->binds[1].zoneId, 0, pp->binds[1].x, pp->binds[1].y, pp->binds[1].z, pp->binds[1].heading, 1, + character_id, pp->binds[2].zoneId, 0, pp->binds[2].x, pp->binds[2].y, pp->binds[2].z, pp->binds[2].heading, 2, + character_id, pp->binds[3].zoneId, 0, pp->binds[3].x, pp->binds[3].y, pp->binds[3].z, pp->binds[3].heading, 3, character_id, pp->binds[4].zoneId, 0, pp->binds[4].x, pp->binds[4].y, pp->binds[4].z, pp->binds[4].heading, 4 - ); results = QueryDatabase(query); + ); results = QueryDatabase(query); /* Save Skills */ int firstquery = 0; diff --git a/world/client.cpp b/world/client.cpp index 7137d785e..91c8cffb5 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -1511,7 +1511,25 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) pp.x = pp.y = pp.z = -1; } - /* Set Home Binds */ + /* Set Home Binds -- yep, all of them */ + pp.binds[1].zoneId = pp.zone_id; + pp.binds[1].x = pp.x; + pp.binds[1].y = pp.y; + pp.binds[1].z = pp.z; + pp.binds[1].heading = pp.heading; + + pp.binds[2].zoneId = pp.zone_id; + pp.binds[2].x = pp.x; + pp.binds[2].y = pp.y; + pp.binds[2].z = pp.z; + pp.binds[2].heading = pp.heading; + + pp.binds[3].zoneId = pp.zone_id; + pp.binds[3].x = pp.x; + pp.binds[3].y = pp.y; + pp.binds[3].z = pp.z; + pp.binds[3].heading = pp.heading; + pp.binds[4].zoneId = pp.zone_id; pp.binds[4].x = pp.x; pp.binds[4].y = pp.y; diff --git a/world/worlddb.cpp b/world/worlddb.cpp index 346f3a2e6..50513af1e 100644 --- a/world/worlddb.cpp +++ b/world/worlddb.cpp @@ -161,8 +161,20 @@ void WorldDatabase::GetCharSelectInfo(uint32 accountID, EQApplicationPacket **ou /* Set Bind Point Data for any character that may possibly be missing it for any reason */ cquery = StringFormat("SELECT `zone_id`, `instance_id`, `x`, `y`, `z`, `heading`, `slot` FROM `character_bind` WHERE `id` = %i LIMIT 5", character_id); auto results_bind = database.QueryDatabase(cquery); + auto bind_count = results_bind.RowCount(); for (auto row_b = results_bind.begin(); row_b != results_bind.end(); ++row_b) { - if (row_b[6] && atoi(row_b[6]) == 4){ has_home = 1; } + if (row_b[6] && atoi(row_b[6]) == 4) { + has_home = 1; + // If our bind count is less than 5, we need to actually make use of this data so lets parse it + if (bind_count < 5) { + pp.binds[4].zoneId = atoi(row_b[0]); + pp.binds[4].instance_id = atoi(row_b[1]); + pp.binds[4].x = atof(row_b[2]); + pp.binds[4].y = atof(row_b[3]); + pp.binds[4].z = atof(row_b[4]); + pp.binds[4].heading = atof(row_b[5]); + } + } if (row_b[6] && atoi(row_b[6]) == 0){ has_bind = 1; } } @@ -202,6 +214,20 @@ void WorldDatabase::GetCharSelectInfo(uint32 accountID, EQApplicationPacket **ou auto results_bset = QueryDatabase(query); } } + /* If our bind count is less than 5, then we have null data that needs to be filled in. */ + if (bind_count < 5) { + // we know that home and main bind must be valid here, so we don't check those + // we also use home to fill in the null data like live does. + for (int i = 1; i < 4; i++) { + if (pp.binds[i].zoneId != 0) // we assume 0 is the only invalid one ... + continue; + + std::string query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, slot)" + " VALUES (%u, %u, %u, %f, %f, %f, %f, %i)", + character_id, pp.binds[4].zoneId, 0, pp.binds[4].x, pp.binds[4].y, pp.binds[4].z, pp.binds[4].heading, i); + auto results_bset = QueryDatabase(query); + } + } /* Bind End */ /* Load Character Material Data for Char Select */