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