diff --git a/src/network/OutboundNetworkHandler.java b/src/network/OutboundNetworkHandler.java index cfad5a4e3..7ab784c46 100644 --- a/src/network/OutboundNetworkHandler.java +++ b/src/network/OutboundNetworkHandler.java @@ -29,10 +29,10 @@ package network; import java.util.Iterator; import java.util.LinkedList; +import java.util.PriorityQueue; import java.util.Queue; import java.util.concurrent.TimeUnit; -import resources.SortedLinkedList; import network.encryption.Encryption; import network.packets.Packet; import network.packets.soe.DataChannelA; @@ -47,13 +47,13 @@ public class OutboundNetworkHandler { private static final long RESEND_TIMEOUT = TimeUnit.MILLISECONDS.toMillis(3000); private final Queue assembleQueue; - private final SortedLinkedList sequenced; + private final Queue sequenced; private short sendSequence; private int crc; public OutboundNetworkHandler() { assembleQueue = new LinkedList(); - sequenced = new SortedLinkedList(); + sequenced = new PriorityQueue(); sendSequence = 0; crc = 0; } @@ -79,8 +79,8 @@ public class OutboundNetworkHandler { public synchronized void onAcknowledge(short sequence) { synchronized (sequenced) { - Iterator it = sequenced.listIterator(); - while (it.hasNext()) { + Iterator it = sequenced.iterator(); + while(it.hasNext()) { SequencedPacket sp = it.next(); if (sp.getSequence() <= sequence) { it.remove(); @@ -96,7 +96,7 @@ public class OutboundNetworkHandler { public synchronized void onOutOfOrder(short sequence) { synchronized (sequenced) { - Iterator it = sequenced.listIterator(); + Iterator it = sequenced.iterator(); while (it.hasNext()) { SequencedPacket sp = it.next(); if (sp.getSequence() > sequence) { diff --git a/src/resources/SortedLinkedList.java b/src/resources/SortedLinkedList.java deleted file mode 100644 index a1e335240..000000000 --- a/src/resources/SortedLinkedList.java +++ /dev/null @@ -1,77 +0,0 @@ -/*********************************************************************************** -* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * -* * -* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * -* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * -* Our goal is to create an emulator which will provide a server for players to * -* continue playing a game similar to the one they used to play. We are basing * -* it on the final publish of the game prior to end-game events. * -* * -* This file is part of Holocore. * -* * -* -------------------------------------------------------------------------------- * -* * -* Holocore is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Affero General Public License as * -* published by the Free Software Foundation, either version 3 of the * -* License, or (at your option) any later version. * -* * -* Holocore is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Affero General Public License for more details. * -* * -* You should have received a copy of the GNU Affero General Public License * -* along with Holocore. If not, see . * -* * -***********************************************************************************/ -package resources; - -import java.util.Collection; -import java.util.LinkedList; -import java.util.ListIterator; - -public class SortedLinkedList> extends LinkedList { - - private static final long serialVersionUID = -6776628467181994889L; - - @Override - public boolean add(E e) { - ListIterator iter = super.listIterator(); - - while (iter.hasNext()) { - if (e.compareTo(iter.next()) <= 0) { - iter.previous(); - iter.add(e); - return true; - } - } - super.addLast(e); - return true; - } - - @Override - public void add(int index, E element) { - throw new UnsupportedOperationException("The sorted nature of the list prohibits this action."); - } - - @Override - public boolean addAll(Collection c) { - for (E item : c) { - add(item); - } - - return true; - } - - @Override - public boolean addAll(int index, Collection c) { - throw new UnsupportedOperationException("The sorted nature of the list prohibits this action."); - } - - @Override - public E set(int index, E element) { - throw new UnsupportedOperationException("The sorted nature of the list prohibits this action."); - } - -} diff --git a/test/resources/TestResources.java b/test/resources/TestResources.java index 0b46df777..b232be990 100644 --- a/test/resources/TestResources.java +++ b/test/resources/TestResources.java @@ -39,7 +39,6 @@ import resources.services.TestConfig; @RunWith(Suite.class) @SuiteClasses({ SWGListTest.class, - TestSortedLinkedList.class, TestWeatherType.class, TestQuadTree.class, TestObjectDatabase.class, diff --git a/test/resources/TestSortedLinkedList.java b/test/resources/TestSortedLinkedList.java deleted file mode 100644 index 143b49995..000000000 --- a/test/resources/TestSortedLinkedList.java +++ /dev/null @@ -1,59 +0,0 @@ -/*********************************************************************************** -* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * -* * -* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * -* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * -* Our goal is to create an emulator which will provide a server for players to * -* continue playing a game similar to the one they used to play. We are basing * -* it on the final publish of the game prior to end-game events. * -* * -* This file is part of Holocore. * -* * -* -------------------------------------------------------------------------------- * -* * -* Holocore is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Affero General Public License as * -* published by the Free Software Foundation, either version 3 of the * -* License, or (at your option) any later version. * -* * -* Holocore is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Affero General Public License for more details. * -* * -* You should have received a copy of the GNU Affero General Public License * -* along with Holocore. If not, see . * -* * -***********************************************************************************/ -package resources; - -import static org.junit.Assert.assertTrue; -import java.util.Iterator; -import org.junit.Test; - -public class TestSortedLinkedList { - - /** - * Characters are compared by numerical value and they - * should therefore be stored in such order within the list. - */ - @Test - public void testSorting() { - SortedLinkedList list = new SortedLinkedList<>(); - final char testchar1 = 'a'; - final char testchar2 = 'b'; - final char testchar3 = 'c'; - Iterator it; - - list.add(testchar2); - list.add(testchar3); - list.add(testchar1); - - it = list.listIterator(); - - assertTrue(it.next().equals(testchar1)); - assertTrue(it.next().equals(testchar2)); - assertTrue(it.next().equals(testchar3)); - } - -}