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/src/resources/encodables/ProsePackage.java b/src/resources/encodables/ProsePackage.java index 0d59d33d9..d53060774 100644 --- a/src/resources/encodables/ProsePackage.java +++ b/src/resources/encodables/ProsePackage.java @@ -110,7 +110,6 @@ public class ProsePackage implements OutOfBandData, Serializable { setTO(prose); break; case "DI": - System.out.println(prose.getClass().getSimpleName()); if (prose instanceof Integer) setDI((Integer) prose); else { System.err.println("DI can only be a Integer!"); } diff --git a/src/resources/objects/group/GroupObject.java b/src/resources/objects/group/GroupObject.java index ad3b244e5..c95ebc37c 100644 --- a/src/resources/objects/group/GroupObject.java +++ b/src/resources/objects/group/GroupObject.java @@ -113,6 +113,12 @@ public class GroupObject extends SWGObject { // Extends INTO or TANO? } } + public void updateMember(CreatureObject object) { + if (groupMembers.contains(new GroupMember(object.getObjectId(), object.getName()))) + awarenessInRange(object); + else awarenessOutOfRange(object); + } + public long getLeader() { return leader; } diff --git a/src/services/group/GroupService.java b/src/services/group/GroupService.java index 70def18ae..c288897a2 100644 --- a/src/services/group/GroupService.java +++ b/src/services/group/GroupService.java @@ -89,12 +89,8 @@ public class GroupService extends Service { reservedIds.addAll(((ObjectIdResponseIntent)i).getReservedIds()); break; case PlayerEventIntent.TYPE: - if (i instanceof PlayerEventIntent) { - PlayerEventIntent pei = (PlayerEventIntent) i; - if (pei.getEvent() == PlayerEvent.PE_FIRST_ZONE) { - pei.getPlayer().getCreatureObject().setGroupId(0); - } - } + if (i instanceof PlayerEventIntent) + handlePlayerEventIntent((PlayerEventIntent) i); break; default: break; } @@ -114,6 +110,32 @@ public class GroupService extends Service { } } + private void handlePlayerEventIntent(PlayerEventIntent intent) { + switch(intent.getEvent()) { + case PE_FIRST_ZONE: + handleMemberRezoned(intent.getPlayer()); + break; + default: break; + } + } + + private void handleMemberRezoned(Player player) { + CreatureObject creatureObject = player.getCreatureObject(); + long groupId = creatureObject.getGroupId(); + + if (groupId == 0) + return; + + GroupObject groupObject = getGroup(creatureObject.getGroupId()); + if (groupObject == null) { + // Group was destroyed while logged out + creatureObject.setGroupId(0); + return; + } + + groupObject.updateMember(creatureObject); + } + private void handleGroupDisband(Player player, CreatureObject target) { CreatureObject creo = player.getCreatureObject(); 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)); - } - -}