Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- common/database.cpp | 74 +++++++++++++++--------------------------------------
- 1 file changed, 20 insertions(+), 54 deletions(-)
- diff --git a/common/database.cpp b/common/database.cpp
- index ace5bf4..e94df75 100644
- --- a/common/database.cpp
- +++ b/common/database.cpp
- @@ -2516,68 +2516,34 @@ bool Database::GetUnusedInstanceID(uint16 &instance_id)
- MYSQL_RES *result;
- MYSQL_ROW row;
- - if (RunQuery(query, MakeAnyLenString(&query, "SELECT COUNT(*) FROM instance_lockout"), errbuf, &result))
- - {
- - safe_delete_array(query);
- - if (mysql_num_rows(result) != 0)
- - {
- - row = mysql_fetch_row(result);
- - int count = atoi(row[0]);
- - if(count == 0)
- - {
- - mysql_free_result(result);
- - instance_id = RuleI(Zone, ReservedInstances) + 1;
- - return true;
- - }
- - }
- - else
- - {
- - mysql_free_result(result);
- - }
- - mysql_free_result(result);
- - }
- - else
- - {
- - safe_delete_array(query);
- - instance_id = 0;
- - return false;
- - }
- -
- - int32 count = RuleI(Zone, ReservedInstances) + 1;
- - int32 max = 65535;
- -
- - if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM instance_lockout where id >= %i ORDER BY id", count), errbuf, &result))
- - {
- - safe_delete_array(query);
- - if (mysql_num_rows(result) != 0)
- - {
- - while((row = mysql_fetch_row(result)))
- - {
- - if(count < atoi(row[0]))
- - {
- - instance_id = count;
- - mysql_free_result(result);
- - return true;
- - }
- - else if(count > max)
- - {
- + uint32 count = RuleI(Zone, ReservedInstances) + 1;
- + uint32 max = 65535;
- +
- + if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM instance_lockout where id >= %i ORDER BY id", count), errbuf, &result)) {
- + safe_delete_array(query);
- + if (mysql_num_rows(result) != 0) {
- + while((row = mysql_fetch_row(result))) {
- + if(count < atoi(row[0])) {
- + if(world_check_for_zone up_returns_true) {
- + // zone still running this id is not available
- + count++;
- + } else {
- + instance_id = count;
- + mysql_free_result(result);
- + return true;
- + }
- + } else if(count > max) {
- instance_id = 0;
- mysql_free_result(result);
- return false;
- - }
- - else
- - {
- + } else {
- count++;
- }
- }
- - }
- - else
- - {
- + } else {
- mysql_free_result(result);
- }
- - }
- - else
- - {
- + } else {
- safe_delete_array(query);
- }
- instance_id = count;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement