Stability fixes

This commit is contained in:
Stephen Seo 2018-09-19 15:00:38 +09:00
parent 24749b8ccc
commit 74abaa76c0

View file

@ -502,8 +502,7 @@ public class Battle
} }
} }
boolean didRemove = !removeQueue.isEmpty(); boolean didRemove = !removeQueue.isEmpty();
Integer toRemove = removeQueue.poll(); for(Integer toRemove = removeQueue.poll(); toRemove != null; toRemove = removeQueue.poll())
while(toRemove != null)
{ {
sideA.remove(toRemove); sideA.remove(toRemove);
sideB.remove(toRemove); sideB.remove(toRemove);
@ -511,7 +510,6 @@ public class Battle
{ {
playerCount.decrementAndGet(); playerCount.decrementAndGet();
} }
toRemove = removeQueue.poll();
} }
if(players.isEmpty() || sideA.isEmpty() || sideB.isEmpty()) if(players.isEmpty() || sideA.isEmpty() || sideB.isEmpty())
{ {
@ -521,12 +519,13 @@ public class Battle
else if(didRemove) else if(didRemove)
{ {
notifyPlayersBattleInfo(); notifyPlayersBattleInfo();
resetUndecidedCount();
} }
return didRemove; return didRemove;
} }
private void isCreativeCheck() private boolean isCreativeCheck()
{ {
Queue<Integer> removeQueue = new ArrayDeque<Integer>(); Queue<Integer> removeQueue = new ArrayDeque<Integer>();
for(Combatant c : players.values()) for(Combatant c : players.values())
@ -537,15 +536,38 @@ public class Battle
removeQueue.add(c.entity.getEntityId()); removeQueue.add(c.entity.getEntityId());
} }
} }
Integer toRemove = removeQueue.poll(); boolean didRemove = false;
while(toRemove != null) for(Integer toRemove = removeQueue.poll(); toRemove != null; toRemove = removeQueue.poll())
{ {
didRemove = true;
sideA.remove(toRemove); sideA.remove(toRemove);
sideB.remove(toRemove); sideB.remove(toRemove);
players.remove(toRemove); players.remove(toRemove);
playerCount.decrementAndGet(); playerCount.decrementAndGet();
sendMessageToAllPlayers(PacketBattleMessage.MessageType.BECAME_CREATIVE, toRemove, 0, 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.BECAME_CREATIVE, toRemove, 0, 0);
} }
if(didRemove)
{
notifyPlayersBattleInfo();
resetUndecidedCount();
}
return didRemove;
}
private void resetUndecidedCount()
{
if(state == State.DECISION)
{
undecidedCount.set(0);
for(Combatant p : players.values())
{
if(p.decision == Decision.UNDECIDED)
{
undecidedCount.incrementAndGet();
}
}
}
} }
private void enforceFreezePositions() private void enforceFreezePositions()