Rename MapleMatchCheckingElement

This commit is contained in:
P0nk
2021-09-09 23:04:36 +02:00
parent 8f0bdb3c6d
commit 62d2e87d25

View File

@@ -34,7 +34,7 @@ import java.util.concurrent.Semaphore;
*/ */
public class MatchCheckerCoordinator { public class MatchCheckerCoordinator {
private final Map<Integer, MapleMatchCheckingElement> matchEntries = new HashMap<>(); private final Map<Integer, MatchCheckingElement> 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);
@@ -62,7 +62,7 @@ public class MatchCheckerCoordinator {
} }
} }
private class MapleMatchCheckingElement { private class MatchCheckingElement {
private final int leaderCid; private final int leaderCid;
private final int world; private final int world;
@@ -75,7 +75,7 @@ public class MatchCheckerCoordinator {
private final String message; private final String message;
private MapleMatchCheckingElement(MatchCheckerType matchType, int leaderCid, int world, AbstractMatchCheckerListener leaderListener, Set<Integer> matchPlayers, String message) { private MatchCheckingElement(MatchCheckerType matchType, int leaderCid, int world, AbstractMatchCheckerListener leaderListener, Set<Integer> matchPlayers, String message) {
this.leaderCid = leaderCid; this.leaderCid = leaderCid;
this.world = world; this.world = world;
this.listener = leaderListener; this.listener = leaderListener;
@@ -213,7 +213,7 @@ public class MatchCheckerCoordinator {
private void reenablePlayerMatching(Set<Integer> matchPlayers) { private void reenablePlayerMatching(Set<Integer> matchPlayers) {
for (Integer cid : matchPlayers) { for (Integer cid : matchPlayers) {
MapleMatchCheckingElement mmce = matchEntries.get(cid); MatchCheckingElement mmce = matchEntries.get(cid);
if (mmce != null) { if (mmce != null) {
synchronized (mmce) { synchronized (mmce) {
@@ -226,7 +226,7 @@ public class MatchCheckerCoordinator {
} }
public int getMatchConfirmationLeaderid(int cid) { public int getMatchConfirmationLeaderid(int cid) {
MapleMatchCheckingElement mmce = matchEntries.get(cid); MatchCheckingElement mmce = matchEntries.get(cid);
if (mmce != null) { if (mmce != null) {
return mmce.leaderCid; return mmce.leaderCid;
} else { } else {
@@ -235,7 +235,7 @@ public class MatchCheckerCoordinator {
} }
public MatchCheckerType getMatchConfirmationType(int cid) { public MatchCheckerType getMatchConfirmationType(int cid) {
MapleMatchCheckingElement mmce = matchEntries.get(cid); MatchCheckingElement mmce = matchEntries.get(cid);
if (mmce != null) { if (mmce != null) {
return mmce.matchType; return mmce.matchType;
} else { } else {
@@ -244,7 +244,7 @@ public class MatchCheckerCoordinator {
} }
public boolean isMatchConfirmationActive(int cid) { public boolean isMatchConfirmationActive(int cid) {
MapleMatchCheckingElement mmce = matchEntries.get(cid); MatchCheckingElement mmce = matchEntries.get(cid);
if (mmce != null) { if (mmce != null) {
return mmce.active; return mmce.active;
} else { } else {
@@ -252,8 +252,8 @@ public class MatchCheckerCoordinator {
} }
} }
private MapleMatchCheckingElement createMatchConfirmationInternal(MatchCheckerType matchType, int world, int leaderCid, AbstractMatchCheckerListener leaderListener, Set<Integer> players, String message) { private MatchCheckingElement createMatchConfirmationInternal(MatchCheckerType matchType, int world, int leaderCid, AbstractMatchCheckerListener leaderListener, Set<Integer> players, String message) {
MapleMatchCheckingElement mmce = new MapleMatchCheckingElement(matchType, leaderCid, world, leaderListener, players, message); MatchCheckingElement mmce = new MatchCheckingElement(matchType, leaderCid, world, leaderListener, players, message);
for (Integer cid : players) { for (Integer cid : players) {
matchEntries.put(cid, mmce); matchEntries.put(cid, mmce);
@@ -264,7 +264,7 @@ public class MatchCheckerCoordinator {
} }
public boolean createMatchConfirmation(MatchCheckerType matchType, int world, int leaderCid, Set<Integer> players, String message) { public boolean createMatchConfirmation(MatchCheckerType matchType, int world, int leaderCid, Set<Integer> players, String message) {
MapleMatchCheckingElement mmce = null; MatchCheckingElement mmce = null;
try { try {
semaphorePool.acquire(); semaphorePool.acquire();
try { try {
@@ -295,7 +295,7 @@ public class MatchCheckerCoordinator {
} }
} }
private void disposeMatchElement(MapleMatchCheckingElement mmce) { private void disposeMatchElement(MatchCheckingElement mmce) {
Set<Integer> matchPlayers = mmce.getMatchPlayers(); // thanks Ai for noticing players getting match-stuck on certain cases Set<Integer> matchPlayers = mmce.getMatchPlayers(); // thanks Ai for noticing players getting match-stuck on certain cases
while (!poolMatchPlayers(matchPlayers)) { while (!poolMatchPlayers(matchPlayers)) {
try { try {
@@ -313,7 +313,7 @@ public class MatchCheckerCoordinator {
} }
} }
private boolean acceptMatchElement(MapleMatchCheckingElement mmce, int cid) { private boolean acceptMatchElement(MatchCheckingElement mmce, int cid) {
if (mmce.acceptEntry(cid)) { if (mmce.acceptEntry(cid)) {
unpoolMatchPlayer(cid); unpoolMatchPlayer(cid);
disposeMatchElement(mmce); disposeMatchElement(mmce);
@@ -324,12 +324,12 @@ public class MatchCheckerCoordinator {
} }
} }
private void denyMatchElement(MapleMatchCheckingElement mmce, int cid) { private void denyMatchElement(MatchCheckingElement mmce, int cid) {
unpoolMatchPlayer(cid); unpoolMatchPlayer(cid);
disposeMatchElement(mmce); disposeMatchElement(mmce);
} }
private void dismissMatchElement(MapleMatchCheckingElement mmce, int cid) { private void dismissMatchElement(MatchCheckingElement mmce, int cid) {
mmce.setMatchActive(false); mmce.setMatchActive(false);
unpoolMatchPlayer(cid); unpoolMatchPlayer(cid);
@@ -337,7 +337,7 @@ public class MatchCheckerCoordinator {
} }
public boolean answerMatchConfirmation(int cid, boolean accept) { public boolean answerMatchConfirmation(int cid, boolean accept) {
MapleMatchCheckingElement mmce = null; MatchCheckingElement mmce = null;
try { try {
semaphorePool.acquire(); semaphorePool.acquire();
try { try {
@@ -385,7 +385,7 @@ public class MatchCheckerCoordinator {
} }
public boolean dismissMatchConfirmation(int cid) { public boolean dismissMatchConfirmation(int cid) {
MapleMatchCheckingElement mmce = null; MatchCheckingElement mmce = null;
try { try {
semaphorePool.acquire(); semaphorePool.acquire();
try { try {