mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-20 17:31:30 +00:00
Updated GetUnusedInstanceID to not recycle instance ID's unless it has reached max (65535)
This commit is contained in:
parent
60c280a521
commit
d887c77a1b
@ -1,5 +1,8 @@
|
|||||||
EQEMu Changelog (Started on Sept 24, 2003 15:50)
|
EQEMu Changelog (Started on Sept 24, 2003 15:50)
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
|
== 02/24/2014 ==
|
||||||
|
Sorvani: Updated GetUnusedInstanceID to not recycle instance ID's unless it has reached max (65535)
|
||||||
|
|
||||||
== 02/23/2014 ==
|
== 02/23/2014 ==
|
||||||
Secrets: Exported the client object SendTargetCommand to Perl.
|
Secrets: Exported the client object SendTargetCommand to Perl.
|
||||||
|
|
||||||
|
|||||||
@ -2516,30 +2516,53 @@ bool Database::GetUnusedInstanceID(uint16 &instance_id)
|
|||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
uint32 count = RuleI(Zone, ReservedInstances) + 1;
|
uint32 count = RuleI(Zone, ReservedInstances);
|
||||||
uint32 max = 65535;
|
uint32 max = 65535;
|
||||||
|
if (RunQuery(query, MakeAnyLenString(&query, "SELECT IFNULL(MAX(id),%u)+1 FROM instance_list WHERE id > %u", count,count), errbuf, &result)) {
|
||||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM instance_list where id >= %i ORDER BY id", count), errbuf, &result)) {
|
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
if (mysql_num_rows(result) != 0) {
|
if (mysql_num_rows(result) != 0) {
|
||||||
while((row = mysql_fetch_row(result))) {
|
row = mysql_fetch_row(result);
|
||||||
if(count < atoi(row[0])) {
|
mysql_free_result(result);
|
||||||
instance_id = count;
|
if(atoi(row[0]) <= max) {
|
||||||
mysql_free_result(result);
|
count = atoi(row[0]);
|
||||||
return true;
|
} else {
|
||||||
} else if(count > max) {
|
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM instance_list where id > %u ORDER BY id", count), errbuf, &result)) {
|
||||||
instance_id = 0;
|
safe_delete_array(query);
|
||||||
mysql_free_result(result);
|
if (mysql_num_rows(result) != 0) {
|
||||||
return false;
|
count++;
|
||||||
|
while((row = mysql_fetch_row(result))) {
|
||||||
|
if(count < atoi(row[0])) {
|
||||||
|
instance_id = count;
|
||||||
|
mysql_free_result(result);
|
||||||
|
return true;
|
||||||
|
} else if(count > max) {
|
||||||
|
instance_id = 0;
|
||||||
|
mysql_free_result(result);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
instance_id = 0;
|
||||||
|
mysql_free_result(result);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
count++;
|
safe_delete_array(query);
|
||||||
|
instance_id = 0;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
instance_id = 0;
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
|
instance_id = 0;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
instance_id = count;
|
instance_id = count;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user