Implemented new monster range (#2604)

With this the internal static array was changed to a std::map which manages it's memory dynamically when needed.

Dropped mob_dummy since it was useless to have it in the first place.

Replaced a lot of direct accesses to the mob db by the "get" function.

With this you can now use 20021-31998 for monsters and also 4000-20020 will be used for player clones whenever needed.

Dropped mobdb_exists
Replaced almost all references to MAX_MOB_DB

Moved MAX_MOB_DB from the header directly into the source file to make it only visible to the .cpp file itself and not to any other.

Moved the mob drop calculation function from itemdb.cpp into mob.cpp, because it needs to iterate over the whole mob db.

Added a few missing clone checks.

Thanks to @lighta, @Jeybla and @aleos89.
This commit is contained in:
Lemongrass3110
2017-11-19 01:22:29 +01:00
committed by GitHub
parent 34817c9715
commit b2ab9724fe
7 changed files with 212 additions and 267 deletions

View File

@@ -1913,40 +1913,6 @@ static int itemdb_randomopt_free(DBKey key, DBData *data, va_list ap) {
return 1;
}
/**
* Re-link monster drop data with item data
* Fixes the need of a @reloadmobdb after a @reloaditemdb
* @author Epoque
*/
void itemdb_reload_itemmob_data(void) {
int i;
for( i = 0; i < MAX_MOB_DB; i++ ) {
struct mob_db *entry = mob_db(i);
int d, k;
for(d = 0; d < MAX_MOB_DROP_TOTAL; d++) {
struct item_data *id;
if( !entry->dropitem[d].nameid )
continue;
id = itemdb_search(entry->dropitem[d].nameid);
for (k = 0; k < MAX_SEARCH; k++) {
if (id->mob[k].chance <= entry->dropitem[d].p)
break;
}
if (k == MAX_SEARCH)
continue;
if (id->mob[k].id != i)
memmove(&id->mob[k+1], &id->mob[k], (MAX_SEARCH-k-1)*sizeof(id->mob[0]));
id->mob[k].chance = entry->dropitem[d].p;
id->mob[k].id = i;
}
}
}
/**
* Reload Item DB
*/
@@ -1969,7 +1935,7 @@ void itemdb_reload(void) {
if (battle_config.feature_roulette)
itemdb_parse_roulette_db();
itemdb_reload_itemmob_data();
mob_reload_itemmob_data();
// readjust itemdb pointer cache for each player
iter = mapit_geteachpc();