mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-16 01:01: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)
|
||||
-------------------------------------------------------
|
||||
== 02/24/2014 ==
|
||||
Sorvani: Updated GetUnusedInstanceID to not recycle instance ID's unless it has reached max (65535)
|
||||
|
||||
== 02/23/2014 ==
|
||||
Secrets: Exported the client object SendTargetCommand to Perl.
|
||||
|
||||
|
||||
@ -2516,30 +2516,53 @@ bool Database::GetUnusedInstanceID(uint16 &instance_id)
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
uint32 count = RuleI(Zone, ReservedInstances) + 1;
|
||||
uint32 count = RuleI(Zone, ReservedInstances);
|
||||
uint32 max = 65535;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM instance_list where id >= %i ORDER BY id", count), errbuf, &result)) {
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT IFNULL(MAX(id),%u)+1 FROM instance_list WHERE id > %u", count,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) {
|
||||
instance_id = 0;
|
||||
mysql_free_result(result);
|
||||
return false;
|
||||
row = mysql_fetch_row(result);
|
||||
mysql_free_result(result);
|
||||
if(atoi(row[0]) <= max) {
|
||||
count = atoi(row[0]);
|
||||
} else {
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM instance_list where id > %u ORDER BY id", count), errbuf, &result)) {
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) != 0) {
|
||||
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 {
|
||||
count++;
|
||||
safe_delete_array(query);
|
||||
instance_id = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
instance_id = 0;
|
||||
mysql_free_result(result);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
safe_delete_array(query);
|
||||
instance_id = 0;
|
||||
return false;
|
||||
}
|
||||
instance_id = count;
|
||||
return true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user