Merge pull request #271 from P0nk/fix/global-drop-concurrency #patch
Fix global drops thread issue
This commit is contained in:
@@ -58,7 +58,7 @@ public class MonsterInformationProvider {
|
||||
|
||||
private final Map<Integer, List<MonsterDropEntry>> drops = new HashMap<>();
|
||||
private final List<MonsterGlobalDropEntry> globaldrops = new ArrayList<>();
|
||||
private final Map<Integer, List<MonsterGlobalDropEntry>> continentdrops = new HashMap<>();
|
||||
private final Map<Integer, List<MonsterGlobalDropEntry>> continentDrops = new HashMap<>();
|
||||
|
||||
private final Map<Integer, List<Integer>> dropsChancePool = new HashMap<>(); // thanks to ronan
|
||||
private final Set<Integer> hasNoMultiEquipDrops = new HashSet<>();
|
||||
@@ -76,23 +76,15 @@ public class MonsterInformationProvider {
|
||||
retrieveGlobal();
|
||||
}
|
||||
|
||||
public final List<MonsterGlobalDropEntry> getRelevantGlobalDrops(int mapid) {
|
||||
int continentid = mapid / 100000000;
|
||||
public final List<MonsterGlobalDropEntry> getRelevantGlobalDrops(int mapId) {
|
||||
final int continentId = mapId / 100000000;
|
||||
return continentDrops.computeIfAbsent(continentId, this::loadContinentDrops);
|
||||
}
|
||||
|
||||
List<MonsterGlobalDropEntry> contiItems = continentdrops.get(continentid);
|
||||
if (contiItems == null) { // continent separated global drops found thanks to marcuswoon
|
||||
contiItems = new ArrayList<>();
|
||||
|
||||
for (MonsterGlobalDropEntry e : globaldrops) {
|
||||
if (e.continentid < 0 || e.continentid == continentid) {
|
||||
contiItems.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
continentdrops.put(continentid, contiItems);
|
||||
}
|
||||
|
||||
return contiItems;
|
||||
private List<MonsterGlobalDropEntry> loadContinentDrops(int continentId) {
|
||||
return globaldrops.stream()
|
||||
.filter(dropEntry -> dropEntry.continentid < 0 || dropEntry.continentid == continentId)
|
||||
.toList();
|
||||
}
|
||||
|
||||
private void retrieveGlobal() {
|
||||
@@ -291,7 +283,7 @@ public class MonsterInformationProvider {
|
||||
extraMultiEquipDrops.clear();
|
||||
dropsChancePool.clear();
|
||||
globaldrops.clear();
|
||||
continentdrops.clear();
|
||||
continentDrops.clear();
|
||||
retrieveGlobal();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -751,7 +751,7 @@ public class MapleMap {
|
||||
}
|
||||
|
||||
final MonsterInformationProvider mi = MonsterInformationProvider.getInstance();
|
||||
final List<MonsterGlobalDropEntry> globalEntry = mi.getRelevantGlobalDrops(this.getId());
|
||||
final List<MonsterGlobalDropEntry> globalEntry = new ArrayList<>(mi.getRelevantGlobalDrops(mapid));
|
||||
|
||||
final List<MonsterDropEntry> dropEntry = new ArrayList<>();
|
||||
final List<MonsterDropEntry> visibleQuestEntry = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user