From 994d1723b694404f688f5f1bc6068a3f25f23638 Mon Sep 17 00:00:00 2001 From: P0nk Date: Sat, 17 Aug 2024 19:11:53 +0200 Subject: [PATCH] Remove unnecessary "spawn loot on animation" feature No longer needed since item drop timing is now dictated by the client since two commits back. --- config.yaml | 1 - src/main/java/config/ServerConfig.java | 1 - src/main/java/server/maps/MapleMap.java | 111 ++++-------------------- 3 files changed, 17 insertions(+), 96 deletions(-) diff --git a/config.yaml b/config.yaml index 49c4572dca..980401a0cb 100644 --- a/config.yaml +++ b/config.yaml @@ -249,7 +249,6 @@ server: USE_ENFORCE_MERCHANT_SAVE: true #Forces automatic DB save on merchant owners, at every item movement on shop. USE_ENFORCE_MDOOR_POSITION: false #Forces mystic door to be spawned near spawnpoints. USE_SPAWN_CLEAN_MDOOR: false #Makes mystic doors to be spawned without deploy animation. This clears disconnecting issues that may happen when trying to cancel doors a couple seconds after deployment. - USE_SPAWN_LOOT_ON_ANIMATION: false #Makes loot appear some time after the mob has been killed (following the mob death animation, instead of instantly). USE_SPAWN_RELEVANT_LOOT: true #Forces to only spawn loots that are collectable by the player or any of their party members. USE_ERASE_PERMIT_ON_OPENSHOP: true #Forces "shop permit" item to be consumed when player deploy his/her player shop. USE_ERASE_UNTRADEABLE_DROP: true #Forces flagged untradeable items to disappear when dropped. diff --git a/src/main/java/config/ServerConfig.java b/src/main/java/config/ServerConfig.java index 3aef4172d9..fff7bca8da 100644 --- a/src/main/java/config/ServerConfig.java +++ b/src/main/java/config/ServerConfig.java @@ -97,7 +97,6 @@ public class ServerConfig { public boolean USE_ENFORCE_MERCHANT_SAVE; public boolean USE_ENFORCE_MDOOR_POSITION; public boolean USE_SPAWN_CLEAN_MDOOR; - public boolean USE_SPAWN_LOOT_ON_ANIMATION; public boolean USE_SPAWN_RELEVANT_LOOT; public boolean USE_ERASE_PERMIT_ON_OPENSHOP; public boolean USE_ERASE_UNTRADEABLE_DROP; diff --git a/src/main/java/server/maps/MapleMap.java b/src/main/java/server/maps/MapleMap.java index 32b3d7cea1..fc421c1a49 100644 --- a/src/main/java/server/maps/MapleMap.java +++ b/src/main/java/server/maps/MapleMap.java @@ -82,7 +82,6 @@ import java.util.Calendar; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -121,7 +120,6 @@ public class MapleMap { private final Map environment = new LinkedHashMap<>(); private final Map droppedItems = new LinkedHashMap<>(); private final LinkedList> registeredDrops = new LinkedList<>(); - private final Map mobLootEntries = new HashMap(20); private final List statUpdateRunnables = new ArrayList(50); private final List areas = new ArrayList<>(); private FootholdTree footholds = null; @@ -160,7 +158,6 @@ public class MapleMap { private MonsterAggroCoordinator aggroMonitor = null; // aggroMonitor activity in sync with itemMonitor private ScheduledFuture itemMonitor = null; private ScheduledFuture expireItemsTask = null; - private ScheduledFuture mobSpawnLootTask = null; private ScheduledFuture characterStatUpdateTask = null; private short itemMonitorTimeout; private Pair timeMob = null; @@ -654,10 +651,10 @@ public class MapleMap { } } - private byte dropItemsFromMonsterOnMap(List dropEntry, Point pos, byte d, int chRate, + private byte dropItemsFromMonsterOnMap(List dropEntry, Point pos, byte index, int chRate, byte droptype, int mobpos, Character chr, Monster mob, short delay) { if (dropEntry.isEmpty()) { - return d; + return index; } Collections.shuffle(dropEntry); @@ -671,9 +668,9 @@ public class MapleMap { if (Randomizer.nextInt(999999) < dropChance) { if (droptype == 3) { - pos.x = mobpos + ((d % 2 == 0) ? (40 * ((d + 1) / 2)) : -(40 * (d / 2))); + pos.x = mobpos + ((index % 2 == 0) ? (40 * ((index + 1) / 2)) : -(40 * (index / 2))); } else { - pos.x = mobpos + ((d % 2 == 0) ? (25 * ((d + 1) / 2)) : -(25 * (d / 2))); + pos.x = mobpos + ((index % 2 == 0) ? (25 * ((index + 1) / 2)) : -(25 * (index / 2))); } if (de.itemId == 0) { // meso int mesos = Randomizer.nextInt(de.Maximum - de.Minimum) + de.Minimum; @@ -698,11 +695,11 @@ public class MapleMap { } spawnDrop(idrop, calcDropPos(pos, mob.getPosition()), mob, chr, droptype, de.questid, delay); } - d++; + index++; } } - return d; + return index; } private byte dropGlobalItemsFromMonsterOnMap(List globalEntry, Point pos, byte d, @@ -742,7 +739,6 @@ public class MapleMap { final byte droptype = (byte) (mob.getStats().isExplosiveReward() ? 3 : mob.getStats().isFfaLoot() ? 2 : chr.getParty() != null ? 1 : 0); final int mobpos = mob.getPosition().x; int chRate = !mob.isBoss() ? chr.getDropRate() : chr.getBossDropRate(); - byte d = 1; Point pos = new Point(0, mob.getPosition().y); MonsterStatusEffect stati = mob.getStati(MonsterStatus.SHOWDOWN); @@ -768,8 +764,17 @@ public class MapleMap { return; } - registerMobItemDrops(droptype, mobpos, chRate, pos, dropEntry, visibleQuestEntry, otherQuestEntry, globalEntry, - chr, mob, delay); + + byte index = 1; + // Normal Drops + index = dropItemsFromMonsterOnMap(dropEntry, pos, index, chRate, droptype, mobpos, chr, mob, delay); + + // Global Drops + index = dropGlobalItemsFromMonsterOnMap(globalEntry, pos, index, droptype, mobpos, chr, mob, delay); + + // Quest Drops + index = dropItemsFromMonsterOnMap(visibleQuestEntry, pos, index, chRate, droptype, mobpos, chr, mob, delay); + dropItemsFromMonsterOnMap(otherQuestEntry, pos, index, chRate, droptype, mobpos, chr, mob, delay); } public void dropItemsFromMonster(List list, final Character chr, final Monster mob, short delay) { @@ -802,11 +807,6 @@ public class MapleMap { expireItemsTask.cancel(false); expireItemsTask = null; - if (YamlConfig.config.server.USE_SPAWN_LOOT_ON_ANIMATION) { - mobSpawnLootTask.cancel(false); - mobSpawnLootTask = null; - } - characterStatUpdateTask.cancel(false); characterStatUpdateTask = null; } @@ -863,17 +863,6 @@ public class MapleMap { expireItemsTask = TimerManager.getInstance().register(() -> makeDisappearExpiredItemDrops(), YamlConfig.config.server.ITEM_EXPIRE_CHECK, YamlConfig.config.server.ITEM_EXPIRE_CHECK); - if (YamlConfig.config.server.USE_SPAWN_LOOT_ON_ANIMATION) { - lootLock.lock(); - try { - mobLootEntries.clear(); - } finally { - lootLock.unlock(); - } - - mobSpawnLootTask = TimerManager.getInstance().register(() -> spawnMobItemDrops(), 200, 200); - } - characterStatUpdateTask = TimerManager.getInstance().register(() -> runCharacterStatUpdate(), 200, 200); itemMonitorTimeout = 1; @@ -970,67 +959,6 @@ public class MapleMap { } } - private void registerMobItemDrops(byte droptype, int mobpos, int chRate, Point pos, - List dropEntry, List visibleQuestEntry, - List otherQuestEntry, List globalEntry, - Character chr, Monster mob, short delay) { - MobLootEntry mle = new MobLootEntry(droptype, mobpos, chRate, pos, delay, dropEntry, visibleQuestEntry, - otherQuestEntry, globalEntry, chr, mob); - - if (YamlConfig.config.server.USE_SPAWN_LOOT_ON_ANIMATION) { - int animationTime = mob.getAnimationTime("die1"); - - lootLock.lock(); - try { - long timeNow = Server.getInstance().getCurrentTime(); - mobLootEntries.put(mle, timeNow + ((long) (0.42 * animationTime))); - } finally { - lootLock.unlock(); - } - } else { - mle.run(); - } - } - - private void spawnMobItemDrops() { - Set> mleList; - - lootLock.lock(); - try { - mleList = new HashSet<>(mobLootEntries.entrySet()); - } finally { - lootLock.unlock(); - } - - long timeNow = Server.getInstance().getCurrentTime(); - List toRemove = new LinkedList<>(); - for (Entry mlee : mleList) { - if (mlee.getValue() < timeNow) { - toRemove.add(mlee.getKey()); - } - } - - if (!toRemove.isEmpty()) { - List toSpawnLoot = new LinkedList<>(); - - lootLock.lock(); - try { - for (MobLootEntry mle : toRemove) { - Long mler = mobLootEntries.remove(mle); - if (mler != null) { - toSpawnLoot.add(mle); - } - } - } finally { - lootLock.unlock(); - } - - for (MobLootEntry mle : toSpawnLoot) { - mle.run(); - } - } - } - private List getDroppedItems() { objectRLock.lock(); try { @@ -4450,11 +4378,6 @@ public class MapleMap { expireItemsTask = null; } - if (mobSpawnLootTask != null) { - mobSpawnLootTask.cancel(false); - mobSpawnLootTask = null; - } - if (characterStatUpdateTask != null) { characterStatUpdateTask.cancel(false); characterStatUpdateTask = null;