Rename and clean up MapleMatchCheckerCoordinator
This commit is contained in:
@@ -30,21 +30,20 @@ import java.util.Map.Entry;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MapleMatchCheckerCoordinator {
|
||||
public class MatchCheckerCoordinator {
|
||||
|
||||
private final Map<Integer, MapleMatchCheckingElement> matchEntries = new HashMap<>();
|
||||
|
||||
private final Set<Integer> pooledCids = new HashSet<>();
|
||||
private final Semaphore semaphorePool = new Semaphore(7);
|
||||
|
||||
private class MapleMatchCheckingEntry {
|
||||
private class MatchCheckingEntry {
|
||||
private boolean accepted;
|
||||
private int cid;
|
||||
private final int cid;
|
||||
|
||||
private MapleMatchCheckingEntry(int cid) {
|
||||
private MatchCheckingEntry(int cid) {
|
||||
this.cid = cid;
|
||||
this.accepted = false;
|
||||
}
|
||||
@@ -64,17 +63,17 @@ public class MapleMatchCheckerCoordinator {
|
||||
}
|
||||
|
||||
private class MapleMatchCheckingElement {
|
||||
private int leaderCid;
|
||||
private int world;
|
||||
private final int leaderCid;
|
||||
private final int world;
|
||||
|
||||
private MatchCheckerType matchType;
|
||||
private AbstractMatchCheckerListener listener;
|
||||
private final MatchCheckerType matchType;
|
||||
private final AbstractMatchCheckerListener listener;
|
||||
|
||||
private Map<Integer, MapleMatchCheckingEntry> confirmingMembers = new HashMap<>();
|
||||
private final Map<Integer, MatchCheckingEntry> confirmingMembers = new HashMap<>();
|
||||
private int confirmCount;
|
||||
private boolean active = true;
|
||||
|
||||
private String message;
|
||||
private final String message;
|
||||
|
||||
private MapleMatchCheckingElement(MatchCheckerType matchType, int leaderCid, int world, AbstractMatchCheckerListener leaderListener, Set<Integer> matchPlayers, String message) {
|
||||
this.leaderCid = leaderCid;
|
||||
@@ -85,20 +84,18 @@ public class MapleMatchCheckerCoordinator {
|
||||
this.matchType = matchType;
|
||||
|
||||
for (Integer cid : matchPlayers) {
|
||||
MapleMatchCheckingEntry mmcEntry = new MapleMatchCheckingEntry(cid);
|
||||
MatchCheckingEntry mmcEntry = new MatchCheckingEntry(cid);
|
||||
confirmingMembers.put(cid, mmcEntry);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean acceptEntry(int cid) {
|
||||
MapleMatchCheckingEntry mmcEntry = confirmingMembers.get(cid);
|
||||
MatchCheckingEntry mmcEntry = confirmingMembers.get(cid);
|
||||
if (mmcEntry != null) {
|
||||
if (mmcEntry.setAccept()) {
|
||||
this.confirmCount++;
|
||||
|
||||
if (this.confirmCount == this.confirmingMembers.size()) {
|
||||
return true;
|
||||
}
|
||||
return this.confirmCount == this.confirmingMembers.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +117,7 @@ public class MapleMatchCheckerCoordinator {
|
||||
private Set<Integer> getAcceptedMatchPlayers() {
|
||||
Set<Integer> s = new HashSet<>();
|
||||
|
||||
for (Entry<Integer, MapleMatchCheckingEntry> e : confirmingMembers.entrySet()) {
|
||||
for (Entry<Integer, MatchCheckingEntry> e : confirmingMembers.entrySet()) {
|
||||
if (e.getValue().getAccept()) {
|
||||
s.add(e.getKey());
|
||||
}
|
||||
@@ -303,7 +300,8 @@ public class MapleMatchCheckerCoordinator {
|
||||
while (!poolMatchPlayers(matchPlayers)) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ie) {}
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -30,7 +30,7 @@ import net.server.Server;
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
import net.server.channel.Channel;
|
||||
import net.server.coordinator.matchchecker.MapleMatchCheckerCoordinator;
|
||||
import net.server.coordinator.matchchecker.MatchCheckerCoordinator;
|
||||
import net.server.coordinator.world.MapleInviteCoordinator;
|
||||
import net.server.coordinator.world.MapleInviteCoordinator.InviteType;
|
||||
import net.server.coordinator.world.MapleInviteCoordinator.MapleInviteResult;
|
||||
@@ -752,7 +752,7 @@ public class MapleGuild {
|
||||
Set<Character> guildMembers = new HashSet<>();
|
||||
guildMembers.add(guildLeader);
|
||||
|
||||
MapleMatchCheckerCoordinator mmce = guildLeader.getWorldServer().getMatchCheckerCoordinator();
|
||||
MatchCheckerCoordinator mmce = guildLeader.getWorldServer().getMatchCheckerCoordinator();
|
||||
for (Character chr : guildLeader.getMap().getAllPlayers()) {
|
||||
if (chr.getParty() == null && chr.getGuild() == null && mmce.getMatchConfirmationLeaderid(chr.getId()) == -1) {
|
||||
guildMembers.add(chr);
|
||||
|
||||
@@ -28,7 +28,7 @@ import net.server.audit.LockCollector;
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.MonitoredReentrantLock;
|
||||
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
import net.server.coordinator.matchchecker.MapleMatchCheckerCoordinator;
|
||||
import net.server.coordinator.matchchecker.MatchCheckerCoordinator;
|
||||
import net.server.coordinator.matchchecker.MatchCheckerListenerFactory.MatchCheckerType;
|
||||
import scripting.event.EventInstanceManager;
|
||||
import server.maps.MapleDoor;
|
||||
@@ -436,7 +436,7 @@ public class MapleParty {
|
||||
|
||||
player.setParty(null);
|
||||
|
||||
MapleMatchCheckerCoordinator mmce = c.getWorldServer().getMatchCheckerCoordinator();
|
||||
MatchCheckerCoordinator mmce = c.getWorldServer().getMatchCheckerCoordinator();
|
||||
if (mmce.getMatchConfirmationLeaderid(player.getId()) == player.getId() && mmce.getMatchConfirmationType(player.getId()) == MatchCheckerType.GUILD_CREATION) {
|
||||
mmce.dismissMatchConfirmation(player.getId());
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
import net.server.audit.locks.factory.MonitoredWriteLockFactory;
|
||||
import net.server.channel.Channel;
|
||||
import net.server.channel.CharacterIdChannelPair;
|
||||
import net.server.coordinator.matchchecker.MapleMatchCheckerCoordinator;
|
||||
import net.server.coordinator.matchchecker.MatchCheckerCoordinator;
|
||||
import net.server.coordinator.partysearch.MaplePartySearchCoordinator;
|
||||
import net.server.coordinator.world.MapleInviteCoordinator;
|
||||
import net.server.coordinator.world.MapleInviteCoordinator.InviteResult;
|
||||
@@ -88,7 +88,7 @@ public class World {
|
||||
private Map<Integer, MapleGuildSummary> gsStore = new HashMap<>();
|
||||
private PlayerStorage players = new PlayerStorage();
|
||||
private ServicesManager services = new ServicesManager(WorldServices.SAVE_CHARACTER);
|
||||
private MapleMatchCheckerCoordinator matchChecker = new MapleMatchCheckerCoordinator();
|
||||
private MatchCheckerCoordinator matchChecker = new MatchCheckerCoordinator();
|
||||
private MaplePartySearchCoordinator partySearch = new MaplePartySearchCoordinator();
|
||||
|
||||
private final MonitoredReentrantReadWriteLock chnLock = new MonitoredReentrantReadWriteLock(MonitoredLockType.WORLD_CHANNELS, true);
|
||||
@@ -513,7 +513,7 @@ public class World {
|
||||
return players;
|
||||
}
|
||||
|
||||
public MapleMatchCheckerCoordinator getMatchCheckerCoordinator() {
|
||||
public MatchCheckerCoordinator getMatchCheckerCoordinator() {
|
||||
return matchChecker;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user