Fixes mob and item atcommand sorting issues (#7058)

* Fixes #7055.
* Fixes several atcommands used for mob and item information were not properly accounting for order.
* Resolves an issue where YAML databases were not properly utilizing the cache feature.
* Increased MAX_SEARCH to 10 by default as in renewal there are many more items with duplicated names.
Thanks to @Playtester!
Co-authored-by: Playtester <Kenji.Ito@gmx.de>
This commit is contained in:
Aleos
2022-06-24 09:53:31 -04:00
committed by GitHub
parent 563a7012ff
commit 256735a136
12 changed files with 62 additions and 22 deletions

View File

@@ -315,14 +315,17 @@ std::shared_ptr<s_mob_db> mobdb_search_aegisname( const char* str ){
/*==========================================
* Founds up to N matches. Returns number of matches [Skotlex]
*------------------------------------------*/
int mobdb_searchname_array_(const char *str, uint16 * out, int size, bool full_cmp)
uint16 mobdb_searchname_array_(const char *str, uint16 * out, uint16 size, bool full_cmp)
{
unsigned short count = 0;
for( auto const &mobdb_pair : mob_db ) {
const uint16 mob_id = mobdb_pair.first;
if( mobdb_searchname_sub(mob_id, str, full_cmp) ) {
uint16 count = 0;
const auto &mob_list = mob_db.getCache();
for( const auto &mob : mob_list ) {
if (mob == nullptr)
continue;
if( mobdb_searchname_sub(mob->id, str, full_cmp) ) {
if( count < size )
out[count] = mob_id;
out[count] = mob->id;
count++;
}
}
@@ -330,7 +333,7 @@ int mobdb_searchname_array_(const char *str, uint16 * out, int size, bool full_c
return count;
}
int mobdb_searchname_array(const char *str, uint16 * out, int size)
uint16 mobdb_searchname_array(const char *str, uint16 * out, uint16 size)
{
return mobdb_searchname_array_(str, out, size, false);
}
@@ -4974,6 +4977,8 @@ void MobDatabase::loadingFinished() {
mob->status.hp = mob->status.max_hp;
mob->status.sp = mob->status.max_sp;
}
TypesafeCachedYamlDatabase::loadingFinished();
}
MobDatabase mob_db;