diff --git a/README.md b/README.md index 02525e8..a45dc01 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,15 @@ This is a Java client for [Artemis Space Bridge Simulator](http://artemis.eochu. More information on specific functionality will be available as development progresses. +## Acknowledgments +This is a client for Artemis Space Bridge Simulator created by Thom Robertson. You must have a legally purchased version of Artemis +in order to play this game. Artemis is an awesome game and Thom has been kind enough to be supportive of third party clients. Please +do not pirate Artemis - thank him by buying a copy of the game! + +In order to talk to the Artemis server, this client uses IAN (Interface for Artemis Networking), created by Robert J. Walker (rjwut) +on top of the original ArtClientLib created by Daniel Leong (dhleong). None of this would be possible without their hard work! + + ## Persistent Custom Presets TODO: document me! @@ -89,7 +98,7 @@ First, clone this repository into the root of your Eclipse workspace. Open Eclipse and choose `File -> New Java Project`. Enter the name of this repository exactly as the name of the project. You'll see text on the bottom of the window explaining that the wizard will automatically configure the JRE etc. Make sure Java SE 8 or later is selected (we're currently using 1.8.0_51). Click `Finish`. -Then, right click on the project and select `Build Path -> Configure Build Path`. Under the `Libraries` tab, you should see `artclientlib-2.6.0.jar`; if you don't, click `Add JARs` and locate it under `lib`. On the entry for that JAR, expand the triangle to see more details. Double-click the `Source Attachment` entry and navigate to `lib/ArtClientLib-2.6.0`. You should now be able to click on library classes such as `ShipSystem` and see their source and JavaDoc comments. +Then, right click on the project and select `Build Path -> Configure Build Path`. Under the `Libraries` tab, you should see `ian-UNRELEASED.jar`; if you don't, click `Add JARs` and locate it under `lib`. #### IntelliJ IDEA @@ -100,13 +109,10 @@ These instructions assume you are using IntelliJ IDEA 14.1.4. 1. Select `Create project from existing sources`. 1. Continue selecting defaults until the project loads. 1. In the project window's tree, locate the lib directory under `ArtemisEngineeringClient`. -1. Right click on artclientlib-2.6.0.jar, select `Add as source...`, and select `Build -> Rebuild Project`. +1. Right click on ian-UNRELEASED.jar, select `Add as source...`, and select `Build -> Rebuild Project`. - You should now have no compilation errors. -1. Right click on `ArtemisEngineeringClient`, select `Open module settings...`, and navigate to `Project Settings -> Libraries` -1. Select `artclientlib-2.6.0`. Select the `+` in the bottom of the UI (not the one at the top to add a new library) and select the `lib/ArtClientLib-2.6.0` directory. - - You should now be able to navigate directly to the ArtClientLib source code from within your source files and see no compilation errors in the `ArtClientLib` directory. -1. In the project window's tree, right click on `lib` and select `Mark Directory As -> Excluded`. This will cause any compilation errors in ArtClientLib to go away (you only need that directory for code navigation, not compilation). - - If you do wish to actually compile (or run the tests) for ArtClientLib, you'll probably have to do something like this: select the `+` at the top of the UI (to add a new library), select `Java`, and select `ArtemisEngineeringClient/lib/ArtClientLib-2.6.0/junitlib/junit-4.11.jar`. Do the same for `hamcrest-core-1.3.jar` as well. + - You should now be able to navigate directly to the IAN source code from within your source files +1. In the project window's tree, right click on `lib` and select `Mark Directory As -> Excluded`. This will cause any compilation errors in any dependencies to go away (you only need that directory for code navigation, not compilation). ### 3D DAMCON Models diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/dat/artemis-3.snt b/artemisData/dat/artemis-3.snt similarity index 100% rename from lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/dat/artemis-3.snt rename to artemisData/dat/artemis-3.snt diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/dat/artemis-4.snt b/artemisData/dat/artemis-4.snt similarity index 100% rename from lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/dat/artemis-4.snt rename to artemisData/dat/artemis-4.snt diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/dat/artemis-5.snt b/artemisData/dat/artemis-5.snt similarity index 100% rename from lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/dat/artemis-5.snt rename to artemisData/dat/artemis-5.snt diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/dat/artemis-scout.snt b/artemisData/dat/artemis-scout.snt similarity index 100% rename from lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/dat/artemis-scout.snt rename to artemisData/dat/artemis-scout.snt diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/dat/artemis.snt b/artemisData/dat/artemis.snt similarity index 100% rename from lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/dat/artemis.snt rename to artemisData/dat/artemis.snt diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/dat/vesselData.xml b/artemisData/dat/vesselData.xml similarity index 100% rename from lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/dat/vesselData.xml rename to artemisData/dat/vesselData.xml diff --git a/lib/.DS_Store b/lib/.DS_Store deleted file mode 100644 index 0621cc1..0000000 Binary files a/lib/.DS_Store and /dev/null differ diff --git a/lib/ArtClientLib-2.6.0/.gitignore b/lib/ArtClientLib-2.6.0/.gitignore deleted file mode 100644 index d163863..0000000 --- a/lib/ArtClientLib-2.6.0/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build/ \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/.travis.yml b/lib/ArtClientLib-2.6.0/.travis.yml deleted file mode 100644 index 2ead906..0000000 --- a/lib/ArtClientLib-2.6.0/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: java -sudo: false -jdk: - - oraclejdk8 - - oraclejdk7 - - openjdk7 - - openjdk6 diff --git a/lib/ArtClientLib-2.6.0/build.xml b/lib/ArtClientLib-2.6.0/build.xml deleted file mode 100644 index c158604..0000000 --- a/lib/ArtClientLib-2.6.0/build.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lib/ArtClientLib-2.6.0/junitlib/hamcrest-core-1.3.jar b/lib/ArtClientLib-2.6.0/junitlib/hamcrest-core-1.3.jar deleted file mode 100644 index 9d5fe16..0000000 Binary files a/lib/ArtClientLib-2.6.0/junitlib/hamcrest-core-1.3.jar and /dev/null differ diff --git a/lib/ArtClientLib-2.6.0/junitlib/junit-4.11.jar b/lib/ArtClientLib-2.6.0/junitlib/junit-4.11.jar deleted file mode 100644 index aaf7444..0000000 Binary files a/lib/ArtClientLib-2.6.0/junitlib/junit-4.11.jar and /dev/null differ diff --git a/lib/ArtClientLib-2.6.0/readme.md b/lib/ArtClientLib-2.6.0/readme.md deleted file mode 100644 index cb84317..0000000 --- a/lib/ArtClientLib-2.6.0/readme.md +++ /dev/null @@ -1,15 +0,0 @@ -ArtClientLib -============ -[![Build Status](https://secure.travis-ci.org/rjwut/ArtClientLib.svg)](http://travis-ci.org/rjwut/ArtClientLib) - -**ArtClientLib** is an _unofficial_ Java library for communicating with [Artemis Spaceship Bridge Simulator](http://www.artemis.eochu.com/) servers and clients. - -Documentation for the project is found on the [wiki](https://github.com/rjwut/ArtClientLib/wiki). Please also read the [disclaimer](https://github.com/rjwut/ArtClientLib/wiki/Disclaimer) before using ArtClientLib. - -ArtClientLib does not maintain backwards compatibility when updating for new versions of Artemis. The current release supports version 2.1.1. The list below provides links to the latest release of ArtClientLib to support various previous versions. Keep in mind that current documentation will differ significantly from these past versions. - -* Artemis v2.1: [ArtClientLib v2.4.0](https://github.com/rjwut/ArtClientLib/releases/tag/v2.4.0) -* Artemis v2.0: [ArtClientLib v2.3.0](https://github.com/rjwut/ArtClientLib/releases/tag/v2.3.0) -* Artemis v1.x: [ArtClientLib v1.x](https://github.com/dhleong/ArtClientLib) (by Daniel Leong) - -ArtClientLib was originally developed by Daniel Leong and released on GitHub with permission of the developer of Artemis, Thom Robertson. diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/AlertStatus.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/AlertStatus.java deleted file mode 100644 index 00a9cbc..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/AlertStatus.java +++ /dev/null @@ -1,6 +0,0 @@ -package net.dhleong.acl.enums; - -public enum AlertStatus { - NORMAL, - RED -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/AudioCommand.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/AudioCommand.java deleted file mode 100644 index 23ebb7c..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/AudioCommand.java +++ /dev/null @@ -1,6 +0,0 @@ -package net.dhleong.acl.enums; - -public enum AudioCommand { - PLAY, - DISMISS -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/AudioMode.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/AudioMode.java deleted file mode 100644 index 95947a9..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/AudioMode.java +++ /dev/null @@ -1,6 +0,0 @@ -package net.dhleong.acl.enums; - -public enum AudioMode { - PLAYING, - INCOMING -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/BaseMessage.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/BaseMessage.java deleted file mode 100644 index bf3b362..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/BaseMessage.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * Messages that can be sent to bases. - * @author rjwut - */ -public enum BaseMessage implements CommsMessage { - STAND_BY_FOR_DOCKING("Stand by for docking."), - PLEASE_REPORT_STATUS("Please report status."), - BUILD_HOMING_MISSILES("Please build type 1 homing ordnance for us."), - BUILD_NUKES("Please build type 4 nuke ordnance for us."), - BUILD_MINES("Please build type 6 mine ordnance for us."), - BUILD_EMPS("Please build type 9 EMP ordnance for us."); - - private String label; - - BaseMessage(String label) { - this.label = label; - } - - @Override - public String toString() { - return label; - } - - @Override - public boolean hasArgument() { - return false; - } - - @Override - public int getId() { - return ordinal(); - } - - @Override - public CommsRecipientType getRecipientType() { - return CommsRecipientType.BASE; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/BeamFrequency.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/BeamFrequency.java deleted file mode 100644 index 9b99a34..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/BeamFrequency.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * The available frequencies to which beams can be tuned. - * @author rjwut - */ -public enum BeamFrequency { - A, B, C, D, E -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/CommsMessage.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/CommsMessage.java deleted file mode 100644 index 1a41afd..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/CommsMessage.java +++ /dev/null @@ -1,23 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * All messages that can be sent over COMMs implement this interface. - * @author rjwut - */ -public interface CommsMessage { - /** - * Returns the ID of this CommsMessage. IDs are unique per - * CommsRecipientType. - */ - public int getId(); - - /** - * Returns the CommsTargetType that can recieve this CommsMessage. - */ - public CommsRecipientType getRecipientType(); - - /** - * Returns whether or not this message has an argument. - */ - public boolean hasArgument(); -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/CommsRecipientType.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/CommsRecipientType.java deleted file mode 100644 index 94acd9b..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/CommsRecipientType.java +++ /dev/null @@ -1,84 +0,0 @@ -package net.dhleong.acl.enums; - -import net.dhleong.acl.util.BoolState; -import net.dhleong.acl.vesseldata.Vessel; -import net.dhleong.acl.world.ArtemisNpc; -import net.dhleong.acl.world.ArtemisObject; - -/** - * The types of ArtemisObjects to which players can send COMMs messages. - * @author rjwut - */ -public enum CommsRecipientType { - /** - * Other player ships - */ - PLAYER { - @Override - public CommsMessage messageFromId(int id) { - return PlayerMessage.values()[id]; - } - }, - /** - * NCP enemy ships - */ - ENEMY { - @Override - public CommsMessage messageFromId(int id) { - return EnemyMessage.values()[id]; - } - }, - /** - * Bases - */ - BASE { - @Override - public CommsMessage messageFromId(int id) { - return BaseMessage.values()[id]; - } - }, - /** - * Other (civilian NPCs) - */ - OTHER { - @Override - public CommsMessage messageFromId(int id) { - return OtherMessage.fromId(id); - } - }; - - /** - * Returns the CommsRecipientType that corresponds to the given - * ArtemisObject; or null if the object in question cannot receive COMMs - * messages. - */ - public static CommsRecipientType fromObject(ArtemisObject obj) { - ObjectType type = obj.getType(); - - switch (type) { - case PLAYER_SHIP: - return PLAYER; - case BASE: - return BASE; - case NPC_SHIP: - ArtemisNpc npc = (ArtemisNpc) obj; - Vessel vessel = npc.getVessel(); - boolean enemy; - - if (vessel != null) { - enemy = vessel.getFaction().is(FactionAttribute.ENEMY); - } else { - enemy = BoolState.safeValue(npc.isEnemy()); - } - - return enemy ? ENEMY : OTHER; - default: - return null; - } - } - - /** - * Returns the CommsMessage value that corresponds to the given message ID. - */ - public abstract CommsMessage messageFromId(int id); -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/ConnectionType.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/ConnectionType.java deleted file mode 100644 index e0e1e53..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/ConnectionType.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * Represents the type of the machine found at the opposite end of a connection. - * @author rjwut - */ -public enum ConnectionType { - SERVER, CLIENT; - - /** - * Returns the ConnectionType that corresponds to the given int value. - */ - public static final ConnectionType fromInt(int value) { - return value == 1 ? SERVER : (value == 2 ? CLIENT : null); - } - - private int val; - - ConnectionType() { - val = ordinal() + 1; - } - - /** - * Returns the int value for this ConnectionType. - */ - public int toInt() { - return val; - } - - /** - * Returns the opposite ConnectionType to this one: SERVER.opposite() - * returns CLIENT and vice-versa. - */ - public ConnectionType opposite() { - return this == SERVER ? CLIENT : SERVER; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/Console.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/Console.java deleted file mode 100644 index 42f74b9..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/Console.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * The bridge conoles. - * @author rjwut - */ -public enum Console { - MAIN_SCREEN("Main screen"), - HELM("Helm"), - WEAPONS("Weapons"), - ENGINEERING("Engineering"), - SCIENCE("Science"), - COMMUNICATIONS("Communications"), - DATA("Data"), - OBSERVER("Observer"), - CAPTAINS_MAP("Captain's map"), - GAME_MASTER("Game master"); - - private String label; - - Console(String label) { - this.label = label; - } - - @Override - public String toString() { - return label; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/ConsoleStatus.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/ConsoleStatus.java deleted file mode 100644 index df2b967..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/ConsoleStatus.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * Availability status for the various bridge consoles. - * @author rjwut - */ -public enum ConsoleStatus { - AVAILABLE, // you can claim this station - YOURS, // you have already claimed this station - UNAVAILABLE; // you cannot claim this station -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/CreatureType.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/CreatureType.java deleted file mode 100644 index 628bd95..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/CreatureType.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.dhleong.acl.enums; - -public enum CreatureType { - CLASSIC, - WHALE, - SHARK, - DRAGON, - PIRANHA, - CHARYBDIS, - NSECT, - WRECK -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/DriveType.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/DriveType.java deleted file mode 100644 index df49c08..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/DriveType.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * The two types of ship drives. - * @author rjwut - */ -public enum DriveType { - WARP, JUMP -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/EliteAbility.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/EliteAbility.java deleted file mode 100644 index cf5b4a5..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/EliteAbility.java +++ /dev/null @@ -1,52 +0,0 @@ -package net.dhleong.acl.enums; - -import java.util.HashSet; -import java.util.Set; - -/** - * Elite abilities that enemy ships may have. - * @author rjwut - */ -public enum EliteAbility { - STEALTH, // invisible on long range or tactical views - LOW_VIS, // invisible on helm or weapons views until within 3k - CLOAK, // invisible on all views - HET, // high energy turn - WARP, // warp drive - TELEPORT, // jump drive - TRACTOR, // tractor beam - DRONES, // Torgoth drone launcher - ANTI_MINE, // can shoot mines - ANTI_TORP, // can shoot torpedoes - SHIELD_DRAIN; // can drain your shields - - /** - * Returns a set containing the EliteAbility values that correspond to the - * given bit field value. - */ - public static Set fromValue(int value) { - Set set = new HashSet(); - - for (EliteAbility ability : values()) { - if ((value & ability.bit) != 0) { - set.add(ability); - } - } - - return set; - } - - private int bit; - - EliteAbility() { - bit = 0x01 << ordinal(); - } - - /** - * Given a bit field value, returns true if the bit corresponding to this - * EliteAbility is turned on; false otherwise. - */ - public boolean on(int value) { - return (value & bit) != 0; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/EnemyMessage.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/EnemyMessage.java deleted file mode 100644 index 41c9c45..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/EnemyMessage.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * Messages that can be sent to enemy NPCs. - * @author rjwut - */ -public enum EnemyMessage implements CommsMessage { - WILL_YOU_SURRENDER("Will you surrender?"), - TAUNT_1("[Taunt #1]"), - TAUNT_2("[Taunt #2]"), - TAUNT_3("[Taunt #3]"); - - private String label; - - EnemyMessage(String label) { - this.label = label; - } - - @Override - public String toString() { - return label; - } - - @Override - public boolean hasArgument() { - return false; - } - - @Override - public int getId() { - return ordinal(); - } - - @Override - public CommsRecipientType getRecipientType() { - return CommsRecipientType.ENEMY; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/FactionAttribute.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/FactionAttribute.java deleted file mode 100644 index 37e2b4f..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/FactionAttribute.java +++ /dev/null @@ -1,44 +0,0 @@ -package net.dhleong.acl.enums; - -import java.util.HashSet; -import java.util.Set; - -/** - * A list of attributes for Factions. Corresponds to the - * attribute in vesselData.xml. - * @author rjwut - */ -public enum FactionAttribute { - // stance - PLAYER, - FRIENDLY, - ENEMY, - BIOMECH, - - // fleet behavior - STANDARD, - SUPPORT, - LONER, - - // whale behavior - WHALELOVER, - WHALEHATER, - - // elite - ELITE; - - /** - * Returns a Set containing the FactionAttributes that correspond to the - * space-delimited list of attribute names in the given String. - */ - public static Set build(String keys) { - String[] tokens = keys.split(" "); - Set attrs = new HashSet(); - - for (String token : tokens) { - attrs.add(FactionAttribute.valueOf(token.toUpperCase())); - } - - return attrs; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/GameType.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/GameType.java deleted file mode 100644 index 82ecd3d..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/GameType.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * Game types for solo and co-op games. - * @author rjwut - */ -public enum GameType { - SIEGE, - SINGLE_FRONT, - DOUBLE_FRONT, - DEEP_STRIKE, - PEACETIME, - BORDER_WAR -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/MainScreenView.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/MainScreenView.java deleted file mode 100644 index 568eab7..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/MainScreenView.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * The available views for the main screen. - * @author rjwut - */ -public enum MainScreenView { - FORE, PORT, STARBOARD, AFT, TACTICAL, LONG_RANGE, STATUS -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/ObjectType.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/ObjectType.java deleted file mode 100644 index e2e9d55..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/ObjectType.java +++ /dev/null @@ -1,87 +0,0 @@ -package net.dhleong.acl.enums; - -import net.dhleong.acl.world.ArtemisAnomaly; -import net.dhleong.acl.world.ArtemisBase; -import net.dhleong.acl.world.ArtemisCreature; -import net.dhleong.acl.world.ArtemisDrone; -import net.dhleong.acl.world.ArtemisGenericObject; -import net.dhleong.acl.world.ArtemisMesh; -import net.dhleong.acl.world.ArtemisNebula; -import net.dhleong.acl.world.ArtemisNpc; -import net.dhleong.acl.world.ArtemisObject; -import net.dhleong.acl.world.ArtemisPlayer; - -/** - * World object types. - * @author rjwut - */ -public enum ObjectType { - PLAYER_SHIP(1, true, ArtemisPlayer.class), - WEAPONS_CONSOLE(2, false, ArtemisPlayer.class), - ENGINEERING_CONSOLE(3, false, ArtemisPlayer.class), - UPGRADES(4, false, ArtemisPlayer.class), - NPC_SHIP(5, true, ArtemisNpc.class), - BASE(6, true, ArtemisBase.class), - MINE(7, false, ArtemisGenericObject.class), - ANOMALY(8, true, ArtemisAnomaly.class), - // 9 is unused - NEBULA(10, false, ArtemisNebula.class), - TORPEDO(11, false, ArtemisGenericObject.class), - BLACK_HOLE(12, false, ArtemisGenericObject.class), - ASTEROID(13, false, ArtemisGenericObject.class), - GENERIC_MESH(14, true, ArtemisMesh.class), - CREATURE(15, true, ArtemisCreature.class), - DRONE(16, false, ArtemisDrone.class); - - public static ObjectType fromId(int id) { - if (id == 0) { - return null; - } - - for (ObjectType objectType : values()) { - if (objectType.id == id) { - return objectType; - } - } - - throw new IllegalArgumentException("No ObjectType with this ID: " + id); - } - - private byte id; - private boolean named; - private Class objectClass; - - ObjectType(int id, boolean named, Class objectClass) { - this.id = (byte) id; - this.named = named; - this.objectClass = objectClass; - } - - /** - * Returns the ID of this type. - */ - public byte getId() { - return id; - } - - /** - * Returns true if objects of this type can have a name; false otherwise. - */ - public boolean isNamed() { - return named; - } - - /** - * Returns true if the given object is compatible with this ObjectType. - */ - public boolean isCompatible(ArtemisObject obj) { - return objectClass.equals(obj.getClass()); - } - - /** - * Returns the class of object represented by this ObjectType. - */ - public Class getObjectClass() { - return objectClass; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/OrdnanceType.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/OrdnanceType.java deleted file mode 100644 index f0a072d..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/OrdnanceType.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * The four types of ordnance that player ships can fire. - * @author rjwut - */ -public enum OrdnanceType { - HOMING("Homing"), - NUKE("Nuke"), - MINE("Mine"), - EMP("EMP"), - PSHOCK("PlasmaShock"); - - public static final int COUNT = values().length; - - private String label; - - OrdnanceType(String label) { - this.label = label; - } - - @Override - public String toString() { - return label; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/OtherMessage.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/OtherMessage.java deleted file mode 100644 index ce7dfe7..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/OtherMessage.java +++ /dev/null @@ -1,66 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * Messages that can be sent to civilian NPCs. - * @author rjwut - */ -public enum OtherMessage implements CommsMessage { - HAIL(0, "Hail."), - TURN_TO_HEADING_0(1, "Turn to heading 0."), - TURN_TO_HEADING_90(2, "Turn to heading 90."), - TURN_TO_HEADING_180(3, "Turn to heading 180."), - TURN_TO_HEADING_270(4, "Turn to heading 270."), - TURN_LEFT_10_DEGREES(5, "Turn left 10 degrees."), - TURN_RIGHT_10_DEGREES(6, "Turn right 10 degrees."), - TURN_LEFT_25_DEGREES(15, "Turn left 25 degrees."), - TURN_RIGHT_25_DEGREES(16, "Turn right 25 degrees."), - ATTACK_NEAREST_ENEMY(7, "Attack nearest enemy."), - PROCEED_TO_YOUR_DESTINATION(8, "Proceed to you destination."), - GO_DEFEND(9, "Go defend:") { - @Override - public boolean hasArgument() { - return true; - } - }; - - /** - * Returns the AllyMessage that corresponds to the given ID. - */ - public static OtherMessage fromId(int id) { - for (OtherMessage message : values()) { - if (message.id == id) { - return message; - } - } - - return null; - } - - private int id; - private String label; - - OtherMessage(int id, String label) { - this.id = id; - this.label = label; - } - - @Override - public String toString() { - return label; - } - - @Override - public boolean hasArgument() { - return false; - } - - @Override - public int getId() { - return id; - } - - @Override - public CommsRecipientType getRecipientType() { - return CommsRecipientType.OTHER; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/Perspective.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/Perspective.java deleted file mode 100644 index 415f4e5..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/Perspective.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * Main screen perspective - * @author rjwut - */ -public enum Perspective { - FIRST_PERSON, - THIRD_PERSON -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/PlayerMessage.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/PlayerMessage.java deleted file mode 100644 index 752b3e1..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/PlayerMessage.java +++ /dev/null @@ -1,46 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * Messages that can be sent to other players. - * @author rjwut - */ -public enum PlayerMessage implements CommsMessage { - YES("Yes."), - NO("No."), - HELP("Help!"), - GREETINGS("Greetings."), - DIE("Die!"), - WERE_LEAVING_THE_SECTOR_BYE("We're leaving the sector. Bye."), - READY_TO_GO("Ready to go."), - PLEASE_FOLLOW_US("Please follow us."), - WELL_FOLLOW_YOU("We'll follow you."), - WERE_BADLY_DAMAGED("We're badly damaged."), - WERE_HEADED_BACK_TO_THE_STATION("We're headed back to the station."), - SORRY_PLEASE_DISREGARD("Sorry, please disregard."); - - private String label; - - PlayerMessage(String label) { - this.label = label; - } - - @Override - public String toString() { - return label; - } - - @Override - public boolean hasArgument() { - return false; - } - - @Override - public int getId() { - return ordinal(); - } - - @Override - public CommsRecipientType getRecipientType() { - return CommsRecipientType.PLAYER; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/ShipSystem.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/ShipSystem.java deleted file mode 100644 index 21faefb..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/ShipSystem.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * The eight ship systems. - * @author rjwut - */ -public enum ShipSystem { - BEAMS("Beams"), - TORPEDOES("Torpedoes"), - SENSORS("Sensors"), - MANEUVERING("Maneuvering"), - IMPULSE("Impulse"), - WARP_JUMP_DRIVE("Warp/Jump Drive"), - FORE_SHIELDS("Fore shields"), - AFT_SHIELDS("Aft shields"); - - private String label; - - ShipSystem(String label) { - this.label = label; - } - - @Override - public String toString() { - return label; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/TargetingMode.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/TargetingMode.java deleted file mode 100644 index ffe9cf9..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/TargetingMode.java +++ /dev/null @@ -1,6 +0,0 @@ -package net.dhleong.acl.enums; - -public enum TargetingMode { - AUTO, - MANUAL -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/TubeState.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/TubeState.java deleted file mode 100644 index 7a808ad..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/TubeState.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.dhleong.acl.enums; - -/** - * The four possible torpedo tube states. - * @author rjwut - */ -public enum TubeState { - UNLOADED, // the tube is ready to load - LOADED, // the tube is ready to fire or unload - LOADING, // wait for the tube to finish loading - UNLOADING // wait for the tube to finish unloading -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/Upgrade.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/Upgrade.java deleted file mode 100644 index 9f6ef13..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/Upgrade.java +++ /dev/null @@ -1,64 +0,0 @@ -package net.dhleong.acl.enums; - -import java.util.Arrays; - -/** - * Upgrade types - * @author rjwut - */ -public enum Upgrade { - HIDENS_POWER_CELL(null), // +500 energy (on pickup) - VIGORANIUM_NODULE(null), // resurrects 1 DAMCON (on pickup) - CETROCITE_CRYSTAL(Console.ENGINEERING), // coolant buff - LATERAL_ARRAY(Console.SCIENCE), // scanning is instantaneous - TAURON_FOCUSER(Console.WEAPONS), // +10% beam damage and cooldown buff - INFUSION_P_COIL(Console.HELM), // +10% warp and impulse speed - CARPACTION_COIL(Console.WEAPONS), // +10% shield recharge rate - SECRET_CODE_CASE(Console.COMMUNICATIONS); // force 1 enemy to accept surrender - /* - * Unknown types: - * HYDROGEN_RAM - * POLYPHASIC_CAPACITORS - * COOLANT_RESERVES - * ECM_STARPULSE - * WARTIME_PRODUCTION - * PROTONIC_VERNIERS - * REGENERATIVE_PAU_GRIDS - * VETERAN_DAMCON_TEAMS - * TACHYON_SCANNERS - * GRIDSCAN_OVERLOAD - * OVERRIDE_AUTHORIZATION - * RESUPPLY_IMPERATIVES - * PATROL_GROUP - * FAST_SUPPLY - * VANGUARD_REFIT (x6) - */ - - public static final int STORABLE_UPGRADE_COUNT; - - static { - STORABLE_UPGRADE_COUNT = getStorableUpgrades().length; - } - - /** - * Returns an array containing the Upgrade values that players can store on - * the ship and use later. - */ - public static Upgrade[] getStorableUpgrades() { - return Arrays.copyOfRange(values(), 2, 8); - } - - private Console activatedBy; - - private Upgrade(Console activatedBy) { - this.activatedBy = activatedBy; - } - - /** - * Returns the Console that can activate this Upgrade, or null if the - * Upgrade is used immediately when picked up. - */ - public Console getActivatedby() { - return activatedBy; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/VesselAttribute.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/VesselAttribute.java deleted file mode 100644 index 3555302..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/enums/VesselAttribute.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.dhleong.acl.enums; - -import java.util.HashSet; -import java.util.Set; - -/** - * A list of attributes for Vessels. Corresponds to the - * attribute in vesselData.xml. - * @author rjwut - */ -public enum VesselAttribute { - // vessel class - PLAYER, - BASE, - FIGHTER, - SMALL, - MEDIUM, - LARGE, - - // civilian type - WARSHIP, - SCIENCE, - CARGO, - LUXURY, - TRANSPORT, - - // behavior - CARRIER, - ASTEROIDEATER, - ANOMALYEATER, - SENTIENT; - - /** - * Returns a Set containing the VesselAttributes that correspond to the - * space-delimited list of attribute names in the given String. - */ - public static Set build(String broadType) { - String[] tokens = broadType.split(" "); - Set attrs = new HashSet(); - - for (String token : tokens) { - attrs.add(VesselAttribute.valueOf(token.toUpperCase())); - } - - return attrs; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ArtemisNetworkInterface.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ArtemisNetworkInterface.java deleted file mode 100644 index e5611b5..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ArtemisNetworkInterface.java +++ /dev/null @@ -1,69 +0,0 @@ -package net.dhleong.acl.iface; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.Protocol; -import net.dhleong.acl.protocol.core.CoreArtemisProtocol; -import net.dhleong.acl.util.Version; - -/** - * Interface for objects which can connect to an Artemis server and send and - * receive packets. - */ -public interface ArtemisNetworkInterface { - public static final Version MIN_VERSION = new Version("2.0"); - - /** - * Returns the ConnectionType of the packets this interface can receive. An - * ArtemisProtocolException will be thrown if it receives a packet of the - * wrong type. - */ - public ConnectionType getRecvType(); - - /** - * Returns the ConnectionType of the packets this interface can send. An - * ArtemisProtocolException will be thrown if it is asked to send a packet - * of the wrong type. - */ - public ConnectionType getSendType(); - - /** - * Registers the packet types defined by the given Protocol with this - * object. The {@link CoreArtemisProtocol} is registered automatically. - */ - public void registerProtocol(Protocol protocol); - - /** - * Registers an object as a listener. It must have one or more qualifying - * methods annotated with {@link Listener}. - */ - public void addListener(Object listener); - - /** - * Opens the send/receive streams to the remote machine. - */ - public void start(); - - /** - * Returns true if currently connected to the remote machine; false - * otherwise. - */ - public boolean isConnected(); - - /** - * Enqueues a packet to be transmitted to the remote machine. - */ - public void send(ArtemisPacket pkt); - - /** - * Closes the connection to the remote machine. - */ - public void stop(); - - /** - * Attaches the given debugger to the interface. Any previously attached - * debugger is removed. If debugger is null, the previous debugger, if any, - * is removed, with no new debugger attached. - */ - public void attachDebugger(Debugger debugger); -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/BaseDebugger.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/BaseDebugger.java deleted file mode 100644 index 51b2415..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/BaseDebugger.java +++ /dev/null @@ -1,44 +0,0 @@ -package net.dhleong.acl.iface; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.RawPacket; - -/** - * A no-op implementation of the Debugger interface. You can extend this class - * so as to not have to implement all the methods. - * @author rjwut - */ -public class BaseDebugger implements Debugger { - @Override - public void onRecvPacketBytes(ConnectionType connType, int pktType, - byte[] payload) { - // do nothing - } - - @Override - public void onRecvParsedPacket(ArtemisPacket pkt) { - // do nothing - } - - @Override - public void onRecvUnparsedPacket(RawPacket pkt) { - // do nothing - } - - @Override - public void onSendPacket(ArtemisPacket pkt) { - // do nothing - } - - @Override - public void onSendPacketBytes(ConnectionType connType, int pktType, - byte[] payload) { - // do nothing - } - - @Override - public void warn(String msg) { - // do nothing - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ConnectionEvent.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ConnectionEvent.java deleted file mode 100644 index 07ee280..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ConnectionEvent.java +++ /dev/null @@ -1,19 +0,0 @@ -package net.dhleong.acl.iface; - -import java.util.Date; - -/** - * An event regarding the connection to a remote machine. Typically, you would - * work with a subclass, not this class. - * @author rjwut - */ -public abstract class ConnectionEvent { - private long timestamp = System.currentTimeMillis(); - - /** - * The time this event occurred. - */ - public Date getTime() { - return new Date(timestamp); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ConnectionSuccessEvent.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ConnectionSuccessEvent.java deleted file mode 100644 index 764073d..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ConnectionSuccessEvent.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.dhleong.acl.iface; - -/** - * An event that gets thrown when ArtClientLib successfully connects to a remote - * machine. - * @author rjwut - */ -public class ConnectionSuccessEvent extends ConnectionEvent { - // no additional members -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/Debugger.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/Debugger.java deleted file mode 100644 index 17a3cfb..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/Debugger.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.dhleong.acl.iface; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.RawPacket; - -/** - * Interface for objects which can be attached to an ArtemisNetworkInterface to - * get notified of debugging-related events. - * @author rjwut - */ -public interface Debugger { - /** - * Invoked when a packet has been received, but before it is parsed. - */ - public void onRecvPacketBytes(ConnectionType connType, int pktType, - byte[] payload); - - /** - * Invoked when a packet is successfully parsed. Packets which are not - * parsed (because they are unknown or because no listener is interested in - * them) do not trigger this listener. - */ - public void onRecvParsedPacket(ArtemisPacket pkt); - - /** - * Invoked when a packet is received and not parsed. This may occur because - * the packet type is unknown (UnknownPacket), or because no listener is - * interested in it (UnparsedPacket). - */ - public void onRecvUnparsedPacket(RawPacket pkt); - - /** - * Invoked just before a packet is written to the PacketWriter. - */ - public void onSendPacket(ArtemisPacket pkt); - - /** - * Invoked just after a packet is written to the PacketWriter and just - * before it is flushed to the OutputStream. - */ - public void onSendPacketBytes(ConnectionType connType, int pktType, - byte[] payload); - - /** - * Invoked when the interface wishes to report a warning. - */ - public void warn(String msg); -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/DisconnectEvent.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/DisconnectEvent.java deleted file mode 100644 index b4fdbee..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/DisconnectEvent.java +++ /dev/null @@ -1,76 +0,0 @@ -package net.dhleong.acl.iface; - -/** - * An event that gets thrown when an existing connection to a remote machine is - * lost. (A failure to connect in the first place is a - * {@link ConnectionFailureEvent}.) The {@link #cause} property indicates why - * the connection was lost. If there is an exception that further explains the - * event, it is provided in the {@link #exception} property; otherwise, it will - * be null. - * @author rjwut - */ -public class DisconnectEvent extends ConnectionEvent { - /** - * Indicates the reason that the connection was terminated. - */ - public enum Cause { - /** - * The connection was closed from this side; in other words, the user - * terminated the connection intentionally. - */ - LOCAL_DISCONNECT, - - /** - * The connection was closed from the remote side. This could be because - * the remote machine terminated the connection intentionally, or a - * network problem caused the connection to drop. - */ - REMOTE_DISCONNECT, - - /** - * ArtClientLib received a packet with an unexpected format. This would - * typically be caused by a bug in ArtClientLib or in a protocol - * extension being used by a custom proxy. - */ - PACKET_PARSE_EXCEPTION, - - /** - * An I/O exception occurred. The {@link #exception} property may have - * more information, but this is generally an external problem that - * ArtClientLib can't do anything about. - */ - IO_EXCEPTION, - - /** - * The server version in use is not supported by ArtClientLib. This - * fork of ArtClientLib doesn't support Artemis versions earlier than - * 2.0, and there are no plans to do so. Future Artemis releases will - * require updates to ArtClientLib to support them. - */ - UNSUPPORTED_SERVER_VERSION - } - - private Cause cause; - private Exception exception; - - DisconnectEvent(Cause cause, Exception exception) { - this.cause = cause; - this.exception = exception; - } - - /** - * Returns a Cause value describing the reason the connection was - * terminated. - */ - public Cause getCause() { - return cause; - } - - /** - * Returns the Exception that was thrown as a result of the connection - * termination, if any. - */ - public Exception getException() { - return exception; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/Listener.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/Listener.java deleted file mode 100644 index 856927c..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/Listener.java +++ /dev/null @@ -1,30 +0,0 @@ -package net.dhleong.acl.iface; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation that marks methods which are to be invoked when a packet is - * received or an event fires. To be eligible to be a Listener, a method must: - * 1) be public, 2) have a void return type, and 3) have exactly one argument of - * an accepted type ({@link net.dhleong.acl.protocol.ArtemisPacket}, - * {@link net.dhleong.acl.iface.ConnectionEvent}, or any of their subtypes). The - * method will only be notified of packets or events that are assignable to the - * argument's type. - * - * Annotating the method alone is not enough to get notifications; you must - * register the object that has the annotated method with the - * ArtemisNetworkInterface implementation that will be receiving the packets or - * events. - * - * @author rjwut - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -@Inherited -public @interface Listener { - // no properties -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ListenerMethod.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ListenerMethod.java deleted file mode 100644 index 35f141e..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ListenerMethod.java +++ /dev/null @@ -1,106 +0,0 @@ -package net.dhleong.acl.iface; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; - -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.world.ArtemisObject; - -/** - * Contains all the information needed to invoke a listener Method (annotated - * with {@link Listener}). - * @author rjwut - */ -public class ListenerMethod { - private Object object; - private Method method; - private Class paramType; - - /** - * @param object The listener object - * @param method The annotated method - */ - ListenerMethod (Object object, Method method) { - validate(method); - this.object = object; - this.method = method; - paramType = method.getParameterTypes()[0]; - } - - /** - * Throws an IllegalArgumentException if the given method is not a valid - * listener method. - */ - private static void validate(Method method) { - if (!Modifier.isPublic(method.getModifiers())) { - throw new IllegalArgumentException( - "Method " + method.getName() + - " must be public to be a listener" - ); - } - - if (!Void.TYPE.equals(method.getReturnType())) { - throw new IllegalArgumentException( - "Method " + method.getName() + - " must return void to be a listener" - ); - } - - Class[] paramTypes = method.getParameterTypes(); - - if (paramTypes.length != 1) { - throw new IllegalArgumentException( - "Method " + method.getName() + - " must have exactly one argument to be a listener" - ); - } - - Class paramType = paramTypes[0]; - - if ( - ArtemisPacket.class.isAssignableFrom(paramType) || - ArtemisObject.class.isAssignableFrom(paramType) || - ConnectionEvent.class.isAssignableFrom(paramType) - ) { - return; - } - - throw new IllegalArgumentException( - "Method " + method.getName() + - " argument must be assignable to ArtemisPacket," + - " or ConnectionEvent" - ); - } - - /** - * Returns true if this ListenerMethod accepts events or packets of the - * given class; false otherwise. - */ - boolean accepts(Class clazz) { - return paramType.isAssignableFrom(clazz); - } - - /** - * Invokes the wrapped listener Method, passing in the indicated argument, - * if it is type-compatible with the Method's argument; otherwise, nothing - * happens. Since the listeners have been pre-validated, no exception should - * occur, so we wrap the ones thrown by Method.invoke() in a - * RuntimeException. - */ - void offer(Object arg) { - Class clazz = arg.getClass(); - - if (paramType.isAssignableFrom(clazz)) { - try { - method.invoke(object, arg); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex); - } catch (IllegalArgumentException ex) { - throw new RuntimeException(ex); - } catch (InvocationTargetException ex) { - throw new RuntimeException(ex); - } - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ListenerRegistry.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ListenerRegistry.java deleted file mode 100644 index 788dc8a..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ListenerRegistry.java +++ /dev/null @@ -1,58 +0,0 @@ -package net.dhleong.acl.iface; - -import java.lang.reflect.Method; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -/** - * Contains ListenerMethods to be invoked when a corresponding event occurs. - * @author rjwut - */ -public class ListenerRegistry { - private List listeners = new CopyOnWriteArrayList(); - - /** - * Registers all methods on the given Object which have the @Listener - * annotation with the registry. A listener method must be public, return - * void, and have exactly one argument which is assignable to ArtemisPacket, - * ArtemisObject or ConnectionEvent. - */ - public void register(Object object) { - synchronized (listeners) { - Method[] methods = object.getClass().getMethods(); - - for (Method method : methods) { - if (method.getAnnotation(Listener.class) != null) { - listeners.add(new ListenerMethod(object, method)); - } - } - } - } - - /** - * Returns true if any listeners are interested in objects of the given - * class; false otherwise. - */ - public boolean listeningFor(Class clazz) { - synchronized (listeners) { - for (ListenerMethod listener : listeners) { - if (listener.accepts(clazz)) { - return true; - } - } - - return false; - } - } - - /** - * Fires all listeners which are interested in the given object. - */ - void fire(Object obj) { - synchronized (listeners) { - for (ListenerMethod listener : listeners) { - listener.offer(obj); - } - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/OutputStreamDebugger.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/OutputStreamDebugger.java deleted file mode 100644 index 61c936f..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/OutputStreamDebugger.java +++ /dev/null @@ -1,98 +0,0 @@ -package net.dhleong.acl.iface; - -import java.io.OutputStream; -import java.io.PrintStream; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.RawPacket; -import net.dhleong.acl.util.TextUtil; - -/** - * Debugger implementation that simply writes all packets to an OutputStream. - * @author rjwut - */ -public class OutputStreamDebugger implements Debugger { - private String name; - private PrintStream out; - - /** - * Convenience constructor for new OutputStreamDebugger("", System.out); - */ - public OutputStreamDebugger() { - this("", System.out); - } - - /** - * Convenience constructor for new OutputStreamDebugger(name, System.out); - */ - public OutputStreamDebugger(String name) { - this(name, System.out); - } - - /** - * Convenience constructor for new OutputStreamDebugger("", out); - */ - public OutputStreamDebugger(OutputStream out) { - this("", out); - } - - /** - * Creates an OutputStreamDebugger with the indicated name that writes to - * the given OutputStream. The name is prefixed to each event that is - * written to the stream so you can tell which Debugger is reporting it. - */ - public OutputStreamDebugger(String name, OutputStream out) { - this.name = name; - this.out = out instanceof PrintStream ? (PrintStream) out : new PrintStream(out); - } - - @Override - public void onRecvPacketBytes(ConnectionType connType, int pktType, - byte[] payload) { - printPacketBytes(false, connType, pktType, payload); - } - - @Override - public void onRecvParsedPacket(ArtemisPacket pkt) { - out.println(name + "> " + pkt); - } - - @Override - public void onRecvUnparsedPacket(RawPacket pkt) { - out.println(name + "< " + pkt); - } - - @Override - public void onSendPacket(ArtemisPacket pkt) { - out.println(name + "< " + pkt); - } - - @Override - public void onSendPacketBytes(ConnectionType connType, int pktType, - byte[] payload) { - printPacketBytes(true, connType, pktType, payload); - } - - @Override - public void warn(String msg) { - out.println((name != "" ? (name + ": ") : "") + "WARNING: " + msg); - } - - /** - * Writes the bytes for the given packet to the OutputStream. - */ - private void printPacketBytes(boolean send, ConnectionType connType, - int pktType, byte[] payload) { - out.println( - name + (send ? "< " : "> ") + - TextUtil.intToHexLE(ArtemisPacket.HEADER) + " " + - TextUtil.intToHexLE(payload.length + 24) + " " + - TextUtil.intToHexLE(connType.toInt()) + " " + - TextUtil.intToHexLE(0) + " " + - TextUtil.intToHexLE(payload.length + 4) + " " + - TextUtil.intToHexLE(pktType) + " " + - TextUtil.byteArrayToHexString(payload) - ); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/PacketFactory.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/PacketFactory.java deleted file mode 100644 index d1051e3..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/PacketFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.dhleong.acl.iface; - -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; - -/** - * Interface for objects which can convert a byte array to a packet. - * @author rjwut - */ -public interface PacketFactory { - /** - * Returns the subclass of ArtemisPacket that this PacketFactory can - * produce. - */ - public Class getFactoryClass(); - - /** - * Returns a packet constructed with a payload read from the given - * PacketReader. (It is assumed that the preamble has already been read.) - * This method should throw an ArtemisPacketException if the payload is - * malformed. - */ - public ArtemisPacket build(PacketReader reader) throws ArtemisPacketException; -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/PacketFactoryRegistry.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/PacketFactoryRegistry.java deleted file mode 100644 index 57b04f6..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/PacketFactoryRegistry.java +++ /dev/null @@ -1,113 +0,0 @@ -package net.dhleong.acl.iface; - -import java.util.LinkedList; -import java.util.List; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.CoreArtemisProtocol; - -/** - * A registry of PacketFactories. This class handles the job of selecting the - * appropriate PacketFactory for a given type and subType. PacketFactories are - * checked in the order in which they were registered. Therefore, registering - * the most frequently-encountered PacketFactories first will result in better - * performance. - * - * Every PacketFactoryRegistry is pre-seeded with factories from - * {@link CoreArtemisProtocol}. - * - * @author rjwut - */ -public class PacketFactoryRegistry { - /** - * An entry in the PacketFactoryRegistry. - */ - private class Entry { - private int pktType; - private Byte pktSubtype; - private PacketFactory factory; - - private Entry(int pktType, PacketFactory factory) { - this.pktType = pktType; - this.factory = factory; - } - - private Entry(int pktType, byte pktSubtype, PacketFactory factory) { - this.pktType = pktType; - this.pktSubtype = Byte.valueOf(pktSubtype); - this.factory = factory; - } - - /** - * Returns true if this Entry corresponds to the offered type and - * subType; false otherwise. - */ - private boolean match(int offeredPktType, byte offeredPktSubtype) { - if (pktType != offeredPktType) { - return false; - } - - return pktSubtype == null || pktSubtype.byteValue() == offeredPktSubtype; - } - } - - private List serverEntries = new LinkedList(); - private List clientEntries = new LinkedList(); - - public PacketFactoryRegistry() { - new CoreArtemisProtocol().registerPacketFactories(this); - } - - /** - * Registers the given PacketFactory under the indicated type. - */ - public void register(ConnectionType connType, int pktType, PacketFactory factory) { - if (connType == null) { - throw new IllegalArgumentException("You must provide a ConnectionType"); - } - - if (factory == null) { - throw new IllegalArgumentException("You must provide a PacketFactory"); - } - - List list = connType == ConnectionType.SERVER ? serverEntries : clientEntries; - list.add(new Entry(pktType, factory)); - } - - /** - * Registers the given PacketFactory under the indicated packet type and - * subtype. - */ - public void register(ConnectionType connType, int pktType, byte pktSubtype, - PacketFactory factory) { - if (connType == null) { - throw new IllegalArgumentException("You must provide a ConnectionType"); - } - - if (factory == null) { - throw new IllegalArgumentException("You must provide a PacketFactory"); - } - - List list = connType == ConnectionType.SERVER ? serverEntries : clientEntries; - list.add(new Entry(pktType, pktSubtype, factory)); - } - - /** - * Returns the PacketFactory registered under the given ConnectionType, - * packet type and subtype, or null if no such PacketFactory has been - * registered. If a packetFactory was not registered under a subtype, the - * subtype will be ignored when matching on it. - */ - public PacketFactory get(ConnectionType connType, int pktType, - byte pktSubtype) { - List list = connType == ConnectionType.SERVER ? serverEntries : clientEntries; - - for (Entry entry : list) { - if (entry.match(pktType, pktSubtype)) { - return entry.factory; - } - } - - return null; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/PacketReader.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/PacketReader.java deleted file mode 100644 index eecd439..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/PacketReader.java +++ /dev/null @@ -1,511 +0,0 @@ -package net.dhleong.acl.iface; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.SortedMap; -import java.util.TreeMap; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.UnknownPacket; -import net.dhleong.acl.protocol.UnparsedPacket; -import net.dhleong.acl.protocol.core.setup.VersionPacket; -import net.dhleong.acl.protocol.core.world.ObjectUpdatePacket; -import net.dhleong.acl.util.ByteArrayReader; -import net.dhleong.acl.util.BitField; -import net.dhleong.acl.util.BoolState; -import net.dhleong.acl.util.TextUtil; -import net.dhleong.acl.util.Version; - -/** - * Facilitates reading packets from an InputStream. This object may be reused to - * read as many packets as desired from a single InputStream. Individual packet - * classes can read their properties by using the read*() methods on this class. - * @author rjwut - */ -public class PacketReader { - private ConnectionType connType; - private InputStream in; - private byte[] intBuffer = new byte[4]; - private boolean parse = true; - private PacketFactoryRegistry factoryRegistry; - private ListenerRegistry listenerRegistry; - private Version version; - private ByteArrayReader payload; - private SortedMap unknownProps; - private ObjectType objectType; - private int objectId; - private BitField bitField; - private SortedMap unknownObjectProps; - - /** - * Wraps the given InputStream with this PacketReader. - */ - public PacketReader(ConnectionType connType, InputStream in, - PacketFactoryRegistry factoryRegistry, - ListenerRegistry listenerRegistry) { - this.connType = connType; - this.in = in; - this.factoryRegistry = factoryRegistry; - this.listenerRegistry = listenerRegistry; - } - - /** - * If set to false, all packets will be returned as UnknownPackets. This is - * useful for testing purposes to easily capture packet payloads in their - * raw form without bothering to parse any of them. By default, this - * property is true, meaning that all known packets will be parsed. - */ - public void setParsePackets(boolean parse) { - this.parse = parse; - } - - /** - * Returns the server Version, or null if unknown. - */ - public Version getVersion() { - return version; - } - - /** - * Reads a single packet and returns it. The given Debugger will also be - * notified. - */ - public ArtemisPacket readPacket(Debugger debugger) throws ArtemisPacketException { - objectType = null; - objectId = 0; - bitField = null; - unknownProps = new TreeMap(); - unknownObjectProps = new TreeMap(); - - // header (0xdeadbeef) - final int header = readIntFromStream(); - - if (header != ArtemisPacket.HEADER) { - throw new ArtemisPacketException( - "Illegal packet header: " + Integer.toHexString(header) - ); - } - - // packet length - final int len = readIntFromStream(); - - if (len <= 8) { - throw new ArtemisPacketException( - "Illegal packet length: " + len - ); - } - - // connection type - final int connectionTypeValue = readIntFromStream(); - final ConnectionType connectionType = ConnectionType.fromInt(connectionTypeValue); - - if (connectionType == null) { - throw new ArtemisPacketException( - "Unknown connection type: " + connectionTypeValue - ); - } - - if (connectionType != connType) { - throw new ArtemisPacketException( - "Connection type mismatch: expected " + connType + - ", got " + connectionType - ); - } - - // padding - final int padding = readIntFromStream(); - - if (padding != 0) { - throw new ArtemisPacketException( - "No empty padding after connection type?", - connType - ); - } - - // remaining bytes - final int remainingBytes = readIntFromStream(); - final int expectedRemainingBytes = len - 20; - - if (remainingBytes != expectedRemainingBytes) { - throw new ArtemisPacketException( - "Packet length discrepancy: total length = " + len + - "; expected " + expectedRemainingBytes + - " for remaining bytes field, but got " + - remainingBytes, - connType - ); - } - - // packet type - final int packetType = readIntFromStream(); - - // payload - // The preamble was 24 bytes (6 ints), so the payload size is the size - // of the whole packet minus 24 bytes. - final int remaining = len - 24; - byte[] payloadBytes = new byte[remaining]; - - try { - ByteArrayReader.readBytes(in, remaining, payloadBytes); - } catch (InterruptedException ex) { - throw new ArtemisPacketException(ex, connType, packetType); - } catch (IOException ex) { - throw new ArtemisPacketException(ex, connType, packetType); - } - - debugger.onRecvPacketBytes(connType, packetType, payloadBytes); - - // Find the PacketFactory that knows how to handle this packet type - PacketFactory factory = null; - byte subtype = remaining > 0 ? payloadBytes[0] : 0x00; - - if (parse) { - factory = factoryRegistry.get(connType, packetType, subtype); - } - - if (factory == null) { - // No factory can handle this; return an UnknownPacket - UnknownPacket packet = new UnknownPacket(connType, packetType, payloadBytes); - debugger.onRecvUnparsedPacket(packet); - return packet; - } - - Class factoryClass = factory.getFactoryClass(); - boolean parsePacket = listenerRegistry.listeningFor(factoryClass); - - if (!parsePacket && factoryClass.isAssignableFrom(ObjectUpdatePacket.class)) { - ObjectType type = ObjectType.fromId(subtype); - - if (type != null) { - parsePacket = listenerRegistry.listeningFor(type.getObjectClass()); - } - } - - if (parsePacket) { - // We're interested in this packet; parse and build it - payload = new ByteArrayReader(payloadBytes); - ArtemisPacket packet; - - try { - packet = factory.build(this); - } catch (ArtemisPacketException ex) { - throw new ArtemisPacketException(ex, connType, packetType, payloadBytes); - } catch (RuntimeException ex) { - throw new ArtemisPacketException(ex, connType, packetType, payloadBytes); - } - - if (packet instanceof VersionPacket) { - // We got a VersionPacket; store the version - version = ((VersionPacket) packet).getVersion(); - } - - int unreadByteCount = payload.getBytesLeft(); - - if (unreadByteCount > 0) { - debugger.warn( - "Unread bytes [" + - packet.getClass().getSimpleName() + "]: " + - TextUtil.byteArrayToHexString(readBytes(unreadByteCount)) - ); - } - - debugger.onRecvParsedPacket(packet); - return packet; - } - - // We don't have any listeners for this packet - UnparsedPacket packet = new UnparsedPacket(connType, packetType, payloadBytes); - debugger.onRecvUnparsedPacket(packet); - return packet; - } - - public int getBytesLeft() { - return payload.getBytesLeft(); - } - - /** - * Returns true if the packet currently being read has more data; false - * otherwise. - */ - public boolean hasMore() { - return payload.getBytesLeft() > 0 && (bitField == null || payload.peek() != 0); - } - - /** - * Returns the next byte in the current packet's payload without moving the - * pointer. - */ - public byte peekByte() { - return payload.peek(); - } - - /** - * Reads a single byte from the current packet's payload. - */ - public byte readByte() { - return payload.readByte(); - } - - /** - * Convenience method for readByte(bit, 0). - */ - public byte readByte(Enum bit) { - return readByte(bit, (byte) 0); - } - - /** - * Reads a single byte from the current packet's payload if the indicated - * bit in the current BitField is on. Otherwise, the pointer is not moved, - * and the given default value is returned. - */ - public byte readByte(Enum bit, byte defaultValue) { - return bitField.get(bit) ? readByte() : defaultValue; - } - - /** - * Reads the indicated number of bytes from the current packet's payload, - * then coerces the zeroeth byte read into a BoolState. - */ - public BoolState readBool(int byteCount) { - return payload.readBoolState(byteCount); - } - - /** - * Reads the indicated number of bytes from the current packet's payload if - * the indicated bit in the current BitField is on, then coerces the zeroeth - * byte read into a BoolState. Otherwise, the pointer is not moved, and - * BoolState.UNKNOWN is returned. - */ - public BoolState readBool(Enum bit, int bytes) { - return bitField.get(bit) ? readBool(bytes) : BoolState.UNKNOWN; - } - - /** - * Reads a short from the current packet's payload. - */ - public int readShort() { - return payload.readShort(); - } - - /** - * Convenience method for readShort(bit, 0). - */ - public int readShort(Enum bit) { - return readShort(bit, 0); - } - - /** - * Reads a short from the current packet's payload if the indicated bit in - * the current BitField is on. Otherwise, the pointer is not moved, and the - * given default value is returned. - */ - public int readShort(Enum bit, int defaultValue) { - return bitField.get(bit) ? readShort() : defaultValue; - } - - /** - * Reads an int from the current packet's payload. - */ - public int readInt() { - return payload.readInt(); - } - - /** - * Convenience method for readInt(bit, -1). - */ - public int readInt(Enum bit) { - return readInt(bit, -1); - } - - /** - * Reads an int from the current packet's payload if the indicated bit in - * the current BitField is on. Otherwise, the pointer is not moved, and the - * given default value is returned. - */ - public int readInt(Enum bit, int defaultValue) { - return bitField.get(bit) ? readInt() : defaultValue; - } - - /** - * Reads a float from the current packet's payload. - */ - public float readFloat() { - return payload.readFloat(); - } - - /** - * Reads a float from the current packet's payload if the indicated bit in - * the current BitField is on. Otherwise, the pointer is not moved, and the - * given default value is returned. - */ - public float readFloat(Enum bit, float defaultValue) { - return bitField.get(bit) ? readFloat() : defaultValue; - } - - /** - * Reads a UTF-16LE String from the current packet's payload. - */ - public String readString() { - return payload.readUTF16LEString(); - } - - /** - * Reads a US ASCII String from the current packet's payload. - */ - public String readUSASCIIString() { - return payload.readUSASCIIString(); - } - - /** - * Reads a UTF-16LE String from the current packet's payload if the - * indicated bit in the current BitField is on. Otherwise, the pointer is - * not moved, and null is returned. - */ - public String readString(Enum bit) { - return bitField.get(bit) ? readString() : null; - } - - /** - * Reads the given number of bytes from the current packet's payload. - */ - public byte[] readBytes(int byteCount) { - return payload.readBytes(byteCount); - } - - /** - * Reads the given number of bytes from the current packet's payload if - * the indicated bit in the current BitField is on. Otherwise, the pointer - * is not moved, and null is returned. - */ - public byte[] readBytes(Enum bit, int byteCount) { - return bitField.get(bit) ? readBytes(byteCount) : null; - } - - /** - * Reads the given number of bytes from the current packet's payload and - * puts them in the unknown property map with the indicated name. - */ - public void readUnknown(String name, int byteCount) { - unknownProps.put(name, readBytes(byteCount)); - } - - /** - * Reads the given number of bytes from the current packet's payload and - * puts them in the unknown object property map with the indicated name. - */ - public void readObjectUnknown(String name, int byteCount) { - unknownObjectProps.put(name, readBytes(byteCount)); - } - - /** - * Reads bytes from the current packet's payload until the endByte value is - * encountered, then puts them in the unknown object property map with the - * indicated name. This method is needed for the UpgradesParser, as we do - * not know the sizes of some of the fields. If we discover the sizes of the - * remaining fields, this method could probably go away. - */ - public void readObjectUnknownUntil(String name, byte endByte) { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - - while (hasMore() && peekByte() != endByte) { - bytes.write(readByte()); - } - - unknownObjectProps.put(name, bytes.toByteArray()); - } - - /** - * if the indicated bit in the current BitField is off, this method returns - * without doing anything. Otherwise, it acts as a convenience method for - * readObjectUnknown(bit.name(), byteCount). - */ - public void readObjectUnknown(Enum bit, int byteCount) { - if (bitField.get(bit)) { - readObjectUnknown(bit.name(), byteCount); - } - } - - /** - * Skips the given number of bytes in the current packet's payload. - */ - public void skip(int byteCount) { - payload.skip(byteCount); - } - - /** - * Returns the unknown properties previously stored by readUnknown(). - */ - public SortedMap getUnknownProps() { - return unknownProps; - } - - /** - * Starts reading an object from an ObjectUpdatingPacket. This will read off - * an object ID (int) and (if a bits enum value array is given) a BitField - * from the current packet's payload. This also clears the - * unknownObjectProps property. The ObjectType is then returned. - */ - public ObjectType startObject(ObjectType type, Enum[] bits) { - objectType = type; - objectId = readInt(); - - if (bits != null) { - bitField = payload.readBitField(bits); - } else { - bitField = null; - } - - unknownObjectProps = new TreeMap(); - return objectType; - } - - /** - * Returns true if the current BitField has the indicated bit turned on. - */ - public boolean has(Enum bit) { - return bitField.get(bit); - } - - /** - * Returns the type of the current object being read from the payload. - */ - public ObjectType getObjectType() { - return objectType; - } - - /** - * Returns the ID of the current object being read from the payload. - */ - public int getObjectId() { - return objectId; - } - - /** - * Returns the unknown object properties previously stored by - * readObjectUnknown(). - */ - public SortedMap getUnknownObjectProps() { - return unknownObjectProps; - } - - /** - * Reads an int value directly from the InputStream wrapped by this object. - * This is used to read values for the preamble. This method blocks until - * four bytes are read or the stream closes. In the latter case, - * ArtemisPacketException will be thrown. - */ - private int readIntFromStream() throws ArtemisPacketException { - try { - ByteArrayReader.readBytes(in, 4, intBuffer); - return ByteArrayReader.readInt(intBuffer, 0); - } catch (InterruptedException ex) { - throw new ArtemisPacketException(ex); - } catch (IOException ex) { - throw new ArtemisPacketException(ex); - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/PacketWriter.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/PacketWriter.java deleted file mode 100644 index cc55927..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/PacketWriter.java +++ /dev/null @@ -1,463 +0,0 @@ -package net.dhleong.acl.iface; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.SortedMap; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.util.BitField; -import net.dhleong.acl.util.BoolState; -import net.dhleong.acl.util.Util; -import net.dhleong.acl.util.Version; -import net.dhleong.acl.world.ArtemisObject; - -/** - * Facilitates writing packets to an OutputStream. This object may be reused to - * write as many packets as desired to a single OutputStream. To write a packet, - * follow these steps: - * - * 1. Invoke start(). - * 2. Write the payload data using the write*() methods. Payload data is - * buffered by the PacketWriter, not written immediately to the OutputStream. - * 3. Invoke flush(). The proper values for the fields in the preamble will be - * automatically computed and written, followed by the payload. The entire - * packet is then flushed to the OutputStream. - * - * Once flush() has been called, you can start writing another packet by - * invoking start() again. - * - * @author rjwut - */ -public class PacketWriter { - private final OutputStream out; - private ConnectionType mConnType; - private Version version; - - private int mPacketType; - private ByteArrayOutputStream baos; - private ArtemisObject obj; - private ObjectType objType; - private BitField bitField; - private ByteArrayOutputStream baosObj; - private byte[] buffer = new byte[4]; - - /** - * Creates a PacketWriter that writes packets to the given OutputStream. - */ - public PacketWriter(OutputStream out) { - if (out == null) { - throw new IllegalArgumentException( - "The out argument cannot be null" - ); - } - - this.out = out; - } - - /** - * Returns the server version number, or null if unknown. - */ - public Version getVersion() { - return version; - } - - /** - * Sets the server version number. This is invoked by VersionPacket. - */ - public void setVersion(Version version) { - this.version = version; - } - - /** - * Starts a packet of the given type. - */ - public PacketWriter start(ConnectionType connType, int packetType) { - mConnType = connType; - mPacketType = packetType; - baos = new ByteArrayOutputStream(); - return this; - } - - /** - * Convenience method for startObject(object, object.getType(), bits). - */ - public PacketWriter startObject(ArtemisObject object, Enum[] bits) { - return startObject(object, object.getType(), bits); - } - - /** - * Starts writing a new entry into the packet for the given object, - * overriding the object's type with the specified ObjectType. If object - * entries for this packet have bit fields, an array of the possible enum - * values (not just the ones in this packet) should be provided; otherwise, - * the bits argument should be null. - */ - public PacketWriter startObject(ArtemisObject object, ObjectType type, - Enum[] bits) { - assertStarted(); - obj = object; - objType = type; - bitField = new BitField(bits); - baosObj = new ByteArrayOutputStream(); - return this; - } - - /** - * Writes a single byte. You must invoke start() before calling this method. - */ - public PacketWriter writeByte(byte v) { - assertStarted(); - baos.write(v); - return this; - } - - /** - * Writes a single byte for the current object. You must invoke - * startObject() before calling this method. - */ - public PacketWriter writeObjByte(byte v) { - assertObjectStarted(); - baosObj.write(v); - return this; - } - - /** - * If the given byte is different from defaultValue, the byte is written - * to the packet, and the corresponding bit in the object's bit field is set; - * otherwise, nothing happens. You must invoke startObject() before calling - * this method. - */ - public PacketWriter writeByte(Enum bit, byte v, byte defaultValue) { - assertObjectStarted(); - - if (v != defaultValue) { - bitField.set(bit, true); - baosObj.write(v); - } - - return this; - } - - /** - * If the given BoolState is known, it is written to the packet using the - * given number of bytes, and the corresponding bit in the object's bit - * field is set; otherwise, nothing happens. You must invoke startObject() - * before calling this method. - */ - public PacketWriter writeBool(Enum bit, BoolState v, int byteCount) { - assertObjectStarted(); - - if (!BoolState.isKnown(v)) { - return this; - } - - buffer[0] = (byte) (v.getBooleanValue() ? 1 : 0); - - for (int i = 1; i < byteCount; i++) { - buffer[i] = 0; - } - - baosObj.write(buffer, 0, byteCount); - return this; - } - - /** - * Writes a short (two bytes). You must invoke start() before calling this - * method. - */ - public PacketWriter writeShort(int v) { - assertStarted(); - writeShort(v, baos); - return this; - } - - /** - * If the given int is different from defaultValue, the int is coerced to a - * short and written to the packet, and the corresponding bit in the - * object's bit field is set; otherwise, nothing happens. You must invoke - * startObject() before calling this method. - */ - public PacketWriter writeShort(Enum bit, int v, int defaultValue) { - assertObjectStarted(); - - if (v != defaultValue) { - bitField.set(bit, true); - writeShort(v, baosObj); - } - - return this; - } - - /** - * Writes an int (four bytes). You must invoke start() before calling this - * method. - */ - public PacketWriter writeInt(int v) { - assertStarted(); - writeInt(v, baos); - return this; - } - - /** - * If the given int is different from defaultValue, the int is written to - * the packet, and the corresponding bit in the object's bit field is set; - * otherwise, nothing happens. You must invoke startObject() before calling - * this method. - */ - public PacketWriter writeInt(Enum bit, int v, int defaultValue) { - assertObjectStarted(); - - if (v != defaultValue) { - bitField.set(bit, true); - writeInt(v, baosObj); - } - - return this; - } - - /** - * Writes a float (four bytes). You must invoke start() before calling this - * method. - */ - public PacketWriter writeFloat(float v) { - return writeInt(Float.floatToRawIntBits(v)); - } - - /** - * If the given float is different from defaultValue, the float is written - * to the packet, and the corresponding bit in the object's bit field is - * set; otherwise, nothing happens. You must invoke startObject() before - * calling this method. - */ - public PacketWriter writeFloat(Enum bit, float v, float defaultValue) { - return writeInt( - bit, - Float.floatToRawIntBits(v), - Float.floatToRawIntBits(defaultValue) - ); - } - - /** - * Writes a UTF-16LE encoded String. This handles writing the string length - * and the terminating null character automatically. You must invoke start() - * before calling this method. - */ - public PacketWriter writeString(String str) { - writeString(str, baos); - return this; - } - - /** - * Writes a US-ASCII encoded String. This handles writing the string length - * and the terminating null character automatically. You must invoke start() - * before calling this method. - */ - public PacketWriter writeUSASCIIString(String str) { - writeUSASCIIString(str, baos); - return this; - } - - /** - * If the given String is not null, it is written to the packet, and the - * corresponding bit in the object's bit field is set; otherwise, nothing - * happens. You must invoke startObject() before calling this method. - */ - public PacketWriter writeString(Enum bit, String str) { - assertObjectStarted(); - - if (str != null) { - bitField.set(bit, true); - writeString(str, baosObj); - } - - return this; - } - - /** - * Writes a byte array. You must invoke start() before calling this method. - */ - public PacketWriter writeBytes(byte[] bytes) { - assertStarted(); - baos.write(bytes, 0, bytes.length); - return this; - } - - /** - * If the given byte array is not null, it is written to the packet, and the - * corresponding bit in the object's bit field is set; otherwise, nothing - * happens. You must invoke startObject() before calling this method. - */ - public PacketWriter writeBytes(Enum bit, byte[] bytes) { - assertObjectStarted(); - - if (bytes != null) { - bitField.set(bit, true); - baosObj.write(bytes, 0, bytes.length); - } - - return this; - } - - /** - * Retrieves the named unknown value as a byte array from the unknown - * properties map. If the retrieved value is not null, it is written to the - * packet; otherwise, the defaultValue byte array will be written. You must - * invoke startObject() before calling this method. - */ - public PacketWriter writeUnknown(String name, byte[] defaultValue) { - assertObjectStarted(); - SortedMap unknownProps = obj.getUnknownProps(); - byte[] bytes = unknownProps != null ? unknownProps.get(name) : null; - bytes = bytes != null ? bytes : defaultValue; - baosObj.write(bytes, 0, bytes.length); - return this; - } - - /** - * Retrieves the unknown value identified by the indicated bit as a byte - * array from the unknown properties map. If the retrieved value is not - * null, it is written to the packet and the corresponding bit in the - * object's bit field is set; otherwise, nothing happens. You must invoke - * startObject() before calling this method. - */ - public PacketWriter writeUnknown(Enum bit) { - assertObjectStarted(); - SortedMap unknownProps = obj.getUnknownProps(); - - if (unknownProps != null) { - byte[] bytes = unknownProps.get(bit.name()); - - if (bytes != null) { - bitField.set(bit, true); - baosObj.write(bytes, 0, bytes.length); - } - } - - return this; - } - - /** - * Flushes the current object's bytes to the packet, but not to the wrapped - * OutputStream. This prepares the packet for writing another byte. You must - * invoke startObject() before calling this method. When this method - * returns, you will have to call startObject() again before you can write - * another object. - */ - public void endObject() { - writeByte(objType.getId()); - writeInt(obj.getId()); - - try { - bitField.write(baos); - } catch (IOException ex) { - // ByteArrayOutputStream doesn't actually throw IOException; it - // just inherits the declaration from the OutputStream class. Since - // it won't ever actually happen, we wrap it in a RuntimeException. - throw new RuntimeException(ex); - } - - writeBytes(baosObj.toByteArray()); - obj = null; - objType = null; - bitField = null; - baosObj = null; - } - - /** - * Writes the completed packet to the OutputStream. You must invoke start() - * before calling this method. When this method returns, you will have to - * call start() again before you can write more data. The given Debugger - * will also be notified. - */ - public void flush(Debugger debugger) throws IOException { - assertStarted(); - byte[] payload = baos.toByteArray(); - baos = null; - writeInt(ArtemisPacket.HEADER, out); // header - writeInt(payload.length + 24, out); // packet length - writeInt(mConnType.toInt(), out); // connection type - writeInt(0, out); // padding - writeInt(payload.length + 4, out); // remaining bytes - writeInt(mPacketType, out); // packet type - out.write(payload); // payload - out.flush(); - debugger.onSendPacketBytes(mConnType, mPacketType, payload); - } - - /** - * Throws an IllegalStateException if start() has not been called since the - * time this object was constructed or since the last call to flush(). - */ - private void assertStarted() { - if (baos == null) { - throw new IllegalStateException("Must invoke start() first"); - } - } - - /** - * Throws an IllegalStateException if startObject() has not been called - * since the time this object was constructed or since the last call to - * endObject() or flush(). - */ - private void assertObjectStarted() { - if (baosObj == null) { - throw new IllegalStateException("Must invoke startObject() first"); - } - } - - /** - * Writes an int (coerced into a short) into the given ByteArrayOutputStream. - */ - private void writeShort(int value, ByteArrayOutputStream outStream) { - buffer[0] = (byte) (0xff & value); - buffer[1] = (byte) (0xff & (value >> 8)); - outStream.write(buffer, 0, 2); - } - - /** - * Writes an int into the given OutputStream. - */ - private void writeInt(int v, OutputStream outStream) throws IOException { - buffer[0] = (byte) (0xff & v); - buffer[1] = (byte) (0xff & (v >> 8)); - buffer[2] = (byte) (0xff & (v >> 16)); - buffer[3] = (byte) (0xff & (v >> 24)); - outStream.write(buffer, 0, 4); - } - - /** - * Writes an int into the given ByteArrayOutputStream. This is a useful override because it can - * avoid throwing IOException. - */ - private void writeInt(int v, ByteArrayOutputStream outStream) { - buffer[0] = (byte) (0xff & v); - buffer[1] = (byte) (0xff & (v >> 8)); - buffer[2] = (byte) (0xff & (v >> 16)); - buffer[3] = (byte) (0xff & (v >> 24)); - outStream.write(buffer, 0, 4); - } - - /** - * Writes a UTF-16LE encoded String into the given ByteArrayOutputStream. - */ - private void writeString(String v, ByteArrayOutputStream outStream) { - int charCount = v.length() + 1; - writeInt(charCount, outStream); - byte[] charBytes = v.getBytes(Util.UTF16LE); - outStream.write(charBytes, 0, charBytes.length); - writeShort(0, outStream); // terminating null - } - - /** - * Writes a US ASCII encoded String into the given ByteArrayOutputStream. - */ - private void writeUSASCIIString(String v, ByteArrayOutputStream outStream) { - int charCount = v.length(); - writeInt(charCount, outStream); - byte[] charBytes = v.getBytes(Util.US_ASCII); - outStream.write(charBytes, 0, charBytes.length); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ThreadedArtemisNetworkInterface.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ThreadedArtemisNetworkInterface.java deleted file mode 100644 index c26355a..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/iface/ThreadedArtemisNetworkInterface.java +++ /dev/null @@ -1,347 +0,0 @@ -package net.dhleong.acl.iface; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.net.SocketException; -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.Protocol; -import net.dhleong.acl.protocol.core.setup.VersionPacket; -import net.dhleong.acl.protocol.core.setup.WelcomePacket; -import net.dhleong.acl.protocol.core.world.ObjectUpdatePacket; -import net.dhleong.acl.util.Version; -import net.dhleong.acl.world.ArtemisObject; - -/** - * Default implementation of ArtemisNetworkInterface. Kicks off a thread for - * each stream. - */ -public class ThreadedArtemisNetworkInterface implements ArtemisNetworkInterface { - private ConnectionType recvType; - private ConnectionType sendType; - private PacketFactoryRegistry factoryRegistry = new PacketFactoryRegistry(); - private ListenerRegistry mListeners = new ListenerRegistry(); - private ReceiverThread mReceiveThread; - private SenderThread mSendThread; - - private DisconnectEvent.Cause disconnectCause = DisconnectEvent.Cause.LOCAL_DISCONNECT; - private Exception exception; - private Debugger mDebugger = new BaseDebugger(); - - /** - * Prepares an outgoing client connection to an Artemis server. The send and - * receive streams won't actually be opened until start() is called. This - * constructor causes ArtClientLib to wait forever for a connection; a - * separate constructor is provided for specifying a timeout. - */ - public ThreadedArtemisNetworkInterface(String host, int port) - throws IOException { - this(host, port, 0); - } - - /** - * Prepares an outgoing client connection to an Artemis server. The send and - * receive streams won't actually be opened until start() is called. The - * timeoutMs value indicates how long (in milliseconds) ArtClientLib will - * wait for the connection to be established before throwing an exception; 0 - * means "wait forever." - */ - public ThreadedArtemisNetworkInterface(String host, int port, int timeoutMs) - throws IOException { - Socket skt = new Socket(); - skt.connect(new InetSocketAddress(host, port), timeoutMs); - init(skt, ConnectionType.SERVER); - } - - /** - * Creates a ThreadedArtemisNetworkInterface instance which will communicate - * over the given Socket. - * - * The ConnectionType indicates the expected type of the remote machine; in - * other words, it corresponds to the type of packets that are expected to - * be received. If ArtClientLib is connecting as a client to a remote - * server, connType should be ConnectionType.SERVER. (The constructor which - * accepts a host and port number simplifies this setup.) If ArtClientLib is - * acting as a proxy server and has accepted a socket connection from a - * remote client, connType should be ConnectionType.CLIENT. - * - * The send/receive streams won't actually be opened until start() is - * called. - * - * @param socket The ServerSocket that has received a connection - */ - public ThreadedArtemisNetworkInterface(Socket skt, ConnectionType connType) - throws IOException { - init(skt, connType); - } - - private void init(Socket skt, ConnectionType connType) throws IOException { - recvType = connType; - sendType = connType.opposite(); - skt.setKeepAlive(true); - mSendThread = new SenderThread(this, skt); - mReceiveThread = new ReceiverThread(this, skt); - addListener(mSendThread); - } - - @Override - public ConnectionType getRecvType() { - return recvType; - } - - @Override - public ConnectionType getSendType() { - return sendType; - } - - @Override - public void registerProtocol(Protocol protocol) { - protocol.registerPacketFactories(factoryRegistry); - } - - @Override - public void addListener(final Object listener) { - mListeners.register(listener); - } - - /** - * By default, ArtClientLib will attempt to parse any packet it receives for - * which there is a registered interested listener. Known packet types that - * have no listeners will be discarded without being parsed, and unknown - * packet types will emit UnknownPackets. - * - * If this is set to false, ArtClientLib will treat all incoming packets as - * UnknownPackets. This is useful to simply capture the raw bytes for all - * packets, without attempting to parse them. - */ - public void setParsePackets(boolean parse) { - mReceiveThread.setParsePackets(parse); - } - - @Override - public void start() { - if (!mReceiveThread.mStarted) { - mReceiveThread.start(); - } - - if (!mSendThread.mStarted) { - mSendThread.start(); - } - } - - @Override - public boolean isConnected() { - return mSendThread.mConnected; - } - - @Override - public void send(final ArtemisPacket pkt) { - if (pkt.getConnectionType() != sendType) { - throw new IllegalArgumentException( - "Can only send " + sendType + " packets" - ); - } - - mSendThread.offer(pkt); - } - - @Override - public void stop() { - mReceiveThread.end(); - mSendThread.end(); - } - - - /** - * Manages sending packets to the OutputStream. - */ - private static class SenderThread extends Thread { - private final Socket mSkt; - private final Queue mQueue = new ConcurrentLinkedQueue(); - private boolean mRunning = true; - - private final PacketWriter mWriter; - private final ThreadedArtemisNetworkInterface mInterface; - - private boolean mConnected; - private boolean mStarted; - - public SenderThread(final ThreadedArtemisNetworkInterface net, final Socket skt) throws IOException { - mInterface = net; - mSkt = skt; - OutputStream output = new BufferedOutputStream(mSkt.getOutputStream()); - mWriter = new PacketWriter(output); - } - - /** - * Enqueues a packet to be sent. - */ - public boolean offer(final ArtemisPacket pkt) { - return mQueue.offer(pkt); - } - - @Override - public void run() { - mStarted = true; - - while (mRunning) { - try { - Thread.sleep(5); - } catch (final InterruptedException e) { - // TODO Supposed to bail if an InterruptedException is received - } - - ArtemisPacket pkt = mQueue.poll(); - - if (pkt == null) { - // empty queue; loop back to wait - continue; - } - - try { - mInterface.mDebugger.onSendPacket(pkt); - pkt.writeTo(mWriter, mInterface.mDebugger); - } catch (final IOException e) { - if (mRunning) { - mInterface.disconnectCause = DisconnectEvent.Cause.IO_EXCEPTION; - mInterface.exception = e; - } - - break; - } - } - - mConnected = false; - mInterface.stop(); - - // close the socket here; this will - // allow us to send any closing - // packets needed before shutting - // down the pipes - try { - mSkt.close(); - } catch (final IOException e) { - // DON'T CARE - } - - mInterface.mListeners.fire(new DisconnectEvent( - mInterface.disconnectCause, - mInterface.exception - )); - } - - public void end() { - mRunning = false; - } - - @Listener - public void onPacket(final WelcomePacket pkt) { - final boolean wasConnected = mConnected; - mConnected = true; - - if (!wasConnected) { - mInterface.mListeners.fire(new ConnectionSuccessEvent()); - } - } - - @Listener - public void onPacket(final VersionPacket pkt) { - final Version version = pkt.getVersion(); - - if (version.lt(ArtemisNetworkInterface.MIN_VERSION)) { - mInterface.mListeners.fire(new DisconnectEvent( - DisconnectEvent.Cause.UNSUPPORTED_SERVER_VERSION, - null - )); - - // go ahead and end the receive thread NOW - mInterface.mReceiveThread.end(); - end(); - } - } - } - - /** - * Manages receiving packets from the InputStream. - */ - private class ReceiverThread extends Thread { - private boolean mRunning = true; - private final ThreadedArtemisNetworkInterface mInterface; - private PacketReader mReader; - private boolean mStarted; - - public ReceiverThread(final ThreadedArtemisNetworkInterface net, final Socket skt) throws IOException { - mInterface = net; - InputStream input = new BufferedInputStream(skt.getInputStream()); - mReader = new PacketReader(net.getRecvType(), input, - factoryRegistry, mListeners); - } - - private void setParsePackets(boolean parse) { - mReader.setParsePackets(parse); - } - - @Override - public void run() { - mStarted = true; - - while (mRunning) { - try { - // read packet - final ArtemisPacket pkt = mReader.readPacket(mInterface.mDebugger); - - if (mRunning) { - mListeners.fire(pkt); - - if (pkt instanceof ObjectUpdatePacket) { - for (ArtemisObject obj : ((ObjectUpdatePacket) pkt).getObjects()) { - mListeners.fire(obj); - } - } - } - } catch (final ArtemisPacketException e) { - if (mRunning) { - Throwable cause = e.getCause(); - - if (cause instanceof SocketException) { - // Parse failed because the connection was lost - mInterface.disconnectCause = DisconnectEvent.Cause.REMOTE_DISCONNECT; - mInterface.exception = (SocketException) cause; - } else { - mInterface.disconnectCause = DisconnectEvent.Cause.PACKET_PARSE_EXCEPTION; - mInterface.exception = e; - } - - end(); - } - - break; - } - } - - mInterface.stop(); - } - - public void end() { - mRunning = false; - } - } - - @Override - public void attachDebugger(Debugger debugger) { - if (debugger == null) { - debugger = new BaseDebugger(); - } - - mDebugger = debugger; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/ArtemisPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/ArtemisPacket.java deleted file mode 100644 index 6bc411e..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/ArtemisPacket.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.dhleong.acl.protocol; - -import java.io.IOException; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.Debugger; -import net.dhleong.acl.iface.PacketWriter; - -/** - * Interface for all packets that can be received or sent. - */ -public interface ArtemisPacket { - /** - * The preamble of every packet starts with this value. - */ - public static final int HEADER = 0xdeadbeef; - - /** - * Returns a ConnectionType value indicating the type of connection from - * which this packet originates. SERVER means that this packet type is sent - * by the server; CLIENT means it's sent by the client. - */ - public ConnectionType getConnectionType(); - - /** - * Returns the type value for this packet, specified as the last field of - * the preamble. - */ - public int getType(); - - /** - * Writes this packet to the given PacketWriter, then returns the array of - * bytes that was sent. The given Debugger will be notified of the written - * packet. - */ - public void writeTo(PacketWriter writer, Debugger debugger) throws IOException; -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/ArtemisPacketException.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/ArtemisPacketException.java deleted file mode 100644 index 4059a61..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/ArtemisPacketException.java +++ /dev/null @@ -1,83 +0,0 @@ -package net.dhleong.acl.protocol; - -import net.dhleong.acl.enums.ConnectionType; - -/** - * Thrown when ArtClientLib encounters a problem while attempting to parse a - * packet of a known type. Unknown packets don't throw this exception; - * ArtClientLib creates UnknownPacket objects for them. - */ -public class ArtemisPacketException extends Exception { - private static final long serialVersionUID = 6305993950844264082L; - private ConnectionType connType; - private int packetType; - private byte[] payload; - - /** - * @param string A description of the problem - */ - public ArtemisPacketException(String string) { - super(string); - } - - /** - * @param t The exception that caused ArtemisPacketException to be thrown - */ - public ArtemisPacketException(Throwable t) { - super(t); - } - - /** - * @param string A description of the problem - * @param connType The packet's ConnectionType - */ - public ArtemisPacketException(String string, ConnectionType connType) { - super(string); - this.connType = connType; - } - - /** - * @param t The exception that caused ArtemisPacketException to be thrown - * @param connType The packet's ConnectionType - * @param packetType The packet's type value - */ - public ArtemisPacketException(Throwable t, ConnectionType connType, - int packetType) { - this(t, connType, packetType, null); - } - - /** - * @param t The exception that caused ArtemisPacketException to be thrown - * @param connType The packet's ConnectionType - * @param packetType The packet's type value - * @param payload The packet's payload bytes - */ - public ArtemisPacketException(Throwable t, ConnectionType connType, - int packetType, byte[] payload) { - super(t); - this.connType = connType; - this.packetType = packetType; - this.payload = payload; - } - - /** - * Returns the packet's ConnectionType, or null if unknown. - */ - public ConnectionType getConnectionType() { - return connType; - } - - /** - * Returns the type value for this packet, or 0 if unknown. - */ - public int getPacketType() { - return packetType; - } - - /** - * Returns the payload for this packet, or null if unknown. - */ - public byte[] getPayload() { - return payload; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/BaseArtemisPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/BaseArtemisPacket.java deleted file mode 100644 index 5e2a455..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/BaseArtemisPacket.java +++ /dev/null @@ -1,60 +0,0 @@ -package net.dhleong.acl.protocol; - -import java.io.IOException; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.Debugger; -import net.dhleong.acl.iface.PacketWriter; - -/** - * Implements common packet functionality. - */ -public abstract class BaseArtemisPacket implements ArtemisPacket { - /** - * Causes the packet's payload to be written to the given PacketWriter. - */ - protected abstract void writePayload(PacketWriter writer); - - /** - * Writes packet type-specific details (debug info) to be written to the - * given StringBuilder. - */ - protected abstract void appendPacketDetail(StringBuilder b); - - private final ConnectionType mConnectionType; - private final int mType; - - /** - * @param connectionType The packet's ConnectionType - * @param packetType The packet's type value - */ - public BaseArtemisPacket(ConnectionType connectionType, int packetType) { - mConnectionType = connectionType; - mType = packetType; - } - - @Override - public ConnectionType getConnectionType() { - return mConnectionType; - } - - @Override - public int getType() { - return mType; - } - - @Override - public final void writeTo(PacketWriter writer, Debugger debugger) throws IOException { - writer.start(mConnectionType, mType); - writePayload(writer); - writer.flush(debugger); - } - - @Override - public final String toString() { - StringBuilder b = new StringBuilder(); - b.append('[').append(getClass().getSimpleName()).append("] "); - appendPacketDetail(b); - return b.toString(); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/Protocol.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/Protocol.java deleted file mode 100644 index 8ee0202..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/Protocol.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.dhleong.acl.protocol; - -import net.dhleong.acl.iface.PacketFactoryRegistry; - -/** - * Registers a set of PacketFactories with a PacketFactoryRegistry. - * @author rjwut - */ -public interface Protocol { - /** - * Creates PacketFactory objects for each packet in the protocol and - * registers them with the given PacketFactoryRegistry. - */ - public void registerPacketFactories(PacketFactoryRegistry registry); -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/RawPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/RawPacket.java deleted file mode 100644 index 59a6041..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/RawPacket.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.dhleong.acl.protocol; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.util.TextUtil; - -/** - * Any packet that ArtClientLib has not parsed. This may be because it was not - * recognized by any registered protocol, or because there are no registered - * packet listeners that are interested in it. - * @author rjwut - */ -public abstract class RawPacket extends BaseArtemisPacket { - protected final byte[] mPayload; - - /** - * @param connectionType The type of connection over which this packet was - * received - * @param packetType The packet type value specified in the preamble - * @param payload The bytes from the payload (byte offset 24 onward) - */ - protected RawPacket(ConnectionType connectionType, int packetType, - byte[] payload) { - super(connectionType, packetType); - mPayload = payload; - } - - /** - * Returns the payload for this packet. - */ - public byte[] getPayload() { - return mPayload; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeBytes(mPayload); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append("0x").append(TextUtil.intToHex(getType())).append(' ') - .append(TextUtil.byteArrayToHexString(mPayload)); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/UnexpectedTypeException.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/UnexpectedTypeException.java deleted file mode 100644 index fd40712..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/UnexpectedTypeException.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.dhleong.acl.protocol; - -/** - * Thrown if ArtClientLib encounters a different packet type than it expected. - * This is almost certainly caused by a bug in the PacketFactory that - * constructed the packet. - * @author rjwut - */ -public class UnexpectedTypeException extends IllegalArgumentException { - private static final long serialVersionUID = -5961855010011595291L; - - public UnexpectedTypeException(int type, int expectedType) { - super("Expected type " + expectedType + ", got " + type); - } -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/UnknownPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/UnknownPacket.java deleted file mode 100644 index 23060d7..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/UnknownPacket.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.dhleong.acl.protocol; - -import net.dhleong.acl.enums.ConnectionType; - -/** - * Any packet received that isn't of a type recognized by a registered protocol - * will be returned as this class. If you disable packet parsing (by calling - * ThreadedArtemisNetworkInterface.setParsePackets(false)), all packets will be - * of this type. In most cases, you won't be interested in these: they're mainly - * intended for reverse-engineering of the protocol and debugging. However, if - * you are writing a server proxy, you will want to capture these so that you - * can pass them along. - * @author rjwut - */ -public class UnknownPacket extends RawPacket { - public UnknownPacket(ConnectionType connectionType, int packetType, - byte[] payload) { - super(connectionType, packetType, payload); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/UnparsedPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/UnparsedPacket.java deleted file mode 100644 index 1976bf6..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/UnparsedPacket.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.dhleong.acl.protocol; - -import net.dhleong.acl.enums.ConnectionType; - -/** - * Any packet received for which no packet listeners have been registered will - * be returned as this class. Only Debuggers are notified of these packets. - * @author rjwut - */ -public final class UnparsedPacket extends RawPacket { - public UnparsedPacket(ConnectionType connectionType, int packetType, - byte[] payload) { - super(connectionType, packetType, payload); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/CaptainSelectPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/CaptainSelectPacket.java deleted file mode 100644 index eee3fd4..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/CaptainSelectPacket.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.world.ArtemisObject; - -/** - * Selects (or deselects) a target on the captain's map. - * @author rjwut - */ -public class CaptainSelectPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_CAPTAIN_SELECT, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return CaptainSelectPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new CaptainSelectPacket(reader); - } - }); - } - - /** - * @param target The target to select, or null to deselect a target - */ - public CaptainSelectPacket(ArtemisObject target) { - super(TYPE_CAPTAIN_SELECT, target == null ? 1 : target.getId()); - } - - private CaptainSelectPacket(PacketReader reader) { - super(TYPE_CAPTAIN_SELECT, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append('#').append(mArg); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/CoreArtemisProtocol.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/CoreArtemisProtocol.java deleted file mode 100644 index aa0e265..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/CoreArtemisProtocol.java +++ /dev/null @@ -1,90 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.protocol.Protocol; -import net.dhleong.acl.protocol.core.comm.*; -import net.dhleong.acl.protocol.core.eng.*; -import net.dhleong.acl.protocol.core.helm.*; -import net.dhleong.acl.protocol.core.sci.*; -import net.dhleong.acl.protocol.core.setup.*; -import net.dhleong.acl.protocol.core.weap.*; -import net.dhleong.acl.protocol.core.world.*; - -/** - * Implements the core Artemis protocol. - * @author rjwut - */ -public class CoreArtemisProtocol implements Protocol { - @Override - public void registerPacketFactories(PacketFactoryRegistry registry) { - // server - // --- prioritized - ObjectUpdatePacket.register(registry); - BeamFiredPacket.register(registry); - EngGridUpdatePacket.register(registry); - IntelPacket.register(registry); - SoundEffectPacket.register(registry); - // --- rest - AllShipSettingsPacket.register(registry); - EngAutoDamconUpdatePacket.register(registry); - CommsIncomingPacket.register(registry); - ConsoleStatusPacket.register(registry); - DmxMessagePacket.register(registry); - DestroyObjectPacket.register(registry); - DifficultyPacket.register(registry); - GameMessagePacket.register(registry); - GameOverPacket.register(registry); - GameOverReasonPacket.register(registry); - GameOverStatsPacket.register(registry); - IncomingAudioPacket.register(registry); - JumpStatusPacket.register(registry); - KeyCaptureTogglePacket.register(registry); - PausePacket.register(registry); - PerspectivePacket.register(registry); - PlayerShipDamagePacket.register(registry); - SkyboxPacket.register(registry); - VersionPacket.register(registry); - WelcomePacket.register(registry); - - // client - // -- prioritized - ToggleShieldsPacket.register(registry); - FireBeamPacket.register(registry); - FireTubePacket.register(registry); - ToggleAutoBeamsPacket.register(registry); - SetWeaponsTargetPacket.register(registry); - LoadTubePacket.register(registry); - HelmSetSteeringPacket.register(registry); - HelmSetWarpPacket.register(registry); - HelmJumpPacket.register(registry); - EngSetCoolantPacket.register(registry); - EngSetEnergyPacket.register(registry); - HelmSetImpulsePacket.register(registry); - HelmRequestDockPacket.register(registry); - // --- rest - AudioCommandPacket.register(registry); - CaptainSelectPacket.register(registry); - ClimbDivePacket.register(registry); - CommsOutgoingPacket.register(registry); - ConvertTorpedoPacket.register(registry); - EngSendDamconPacket.register(registry); - EngSetAutoDamconPacket.register(registry); - GameMasterMessagePacket.register(registry); - GameMasterSelectPacket.register(registry); - HelmSetClimbDivePacket.register(registry); - HelmToggleReversePacket.register(registry); - KeystrokePacket.register(registry); - ReadyPacket.register(registry); - ReadyPacket2.register(registry); - SciScanPacket.register(registry); - SciSelectPacket.register(registry); - SetBeamFreqPacket.register(registry); - SetMainScreenPacket.register(registry); - SetShipPacket.register(registry); - SetShipSettingsPacket.register(registry); - SetConsolePacket.register(registry); - TogglePerspectivePacket.register(registry); - ToggleRedAlertPacket.register(registry); - UnloadTubePacket.register(registry); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/DmxMessagePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/DmxMessagePacket.java deleted file mode 100644 index a5c902e..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/DmxMessagePacket.java +++ /dev/null @@ -1,77 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -public class DmxMessagePacket extends BaseArtemisPacket { - private static final int TYPE = 0xf754c8fe; - private static final byte MSG_TYPE = 0x10; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return DmxMessagePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new DmxMessagePacket(reader); - } - }); - } - - private final String mName; - private final boolean mOn; - - private DmxMessagePacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - int subtype = reader.readInt(); - - if (subtype != MSG_TYPE) { - throw new UnexpectedTypeException(subtype, MSG_TYPE); - } - - mName = reader.readString(); - mOn = reader.readInt() == 1; - } - - public DmxMessagePacket(String name, boolean on) { - super(ConnectionType.SERVER, TYPE); - mName = name; - mOn = on; - } - - /** - * The name of the DMX flag. - */ - public String getMessage() { - return mName; - } - - /** - * Returns true if the DMX flag is on; false otherwise. - */ - public boolean isOn() { - return mOn; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(MSG_TYPE).writeString(mName).writeInt(mOn ? 1 : 0); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mName).append('=').append(mOn ? "ON" : "OFF"); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameMasterMessagePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameMasterMessagePacket.java deleted file mode 100644 index 4504e65..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameMasterMessagePacket.java +++ /dev/null @@ -1,115 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.Console; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; - -/** - * A packet sent by the game master console to the server which causes a message - * to be displayed on a client. - * @author rjwut - */ -public class GameMasterMessagePacket extends BaseArtemisPacket { - private static final int TYPE = 0x809305a7; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return GameMasterMessagePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new GameMasterMessagePacket(reader); - } - }); - } - - private final Console mConsole; - private final String mSender; - private final String mMessage; - - private GameMasterMessagePacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - byte console = reader.readByte(); - - if (console != 0) { - console--; - - if (console < 0 || console > Console.COMMUNICATIONS.ordinal()) { - throw new IllegalArgumentException("Invalid console value: " + console); - } - - mConsole = Console.values()[console]; - } else { - mConsole = null; - } - - mSender = reader.readString(); - mMessage = reader.readString(); - } - - /** - * A message from the game master that will be received as a normal COMMs - * message. - * Convenience constructor for GameMasterMessage(String, String, null). - */ - public GameMasterMessagePacket(String sender, String message) { - this(sender, message, null); - } - - /** - * A message from the game master that will be received by one of the - * consoles. If the console argument is null, it will be recieved as a - * normal COMMs message. Otherwise, it will be displayed as a popup on the - * named Console. Only the six main console types (MAIN_SCREEN, HELM, - * WEAPONS, ENGINEERING, SCIENCE, COMMUNICATIONS) are allowed. - */ - public GameMasterMessagePacket(String sender, String message, Console console) { - super(ConnectionType.CLIENT, TYPE); - - if (console != null && console.ordinal() > Console.COMMUNICATIONS.ordinal()) { - throw new IllegalArgumentException("Invalid console: " + console); - } - - mSender = sender; - mMessage = message; - mConsole = console; - } - - public String getSender() { - return mSender; - } - - public String getMessage() { - return mMessage; - } - - public Console getConsole() { - return mConsole; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeByte((byte) (mConsole == null ? 0 : mConsole.ordinal() - 1)); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - if (mConsole == null) { - b.append(" [COMMs message] "); - } else { - b.append(" [").append(mConsole).append(" popup] "); - } - - b.append(mSender).append(": ").append(mMessage); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameMasterSelectPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameMasterSelectPacket.java deleted file mode 100644 index fd2acc2..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameMasterSelectPacket.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.world.ArtemisObject; - -/** - * Selects (or deselects) a target on the game master's map. - * @author rjwut - */ -public class GameMasterSelectPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_CAPTAIN_SELECT, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return GameMasterSelectPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new GameMasterSelectPacket(reader); - } - }); - } - - /** - * @param target The target to select, or null to deselect a target - */ - public GameMasterSelectPacket(ArtemisObject target) { - super(TYPE_GAME_MASTER_SELECT, target == null ? 1 : target.getId()); - } - - private GameMasterSelectPacket(PacketReader reader) { - super(TYPE_GAME_MASTER_SELECT, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append('#').append(mArg); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameMessagePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameMessagePacket.java deleted file mode 100644 index c9354b4..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameMessagePacket.java +++ /dev/null @@ -1,70 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -/** - * "Toast" messages sent by the server. - */ -public class GameMessagePacket extends BaseArtemisPacket { - private static final int TYPE = 0xf754c8fe; - private static final byte MSG_TYPE = 0x0a; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return GameMessagePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new GameMessagePacket(reader); - } - }); - } - - private final String mMessage; - - private GameMessagePacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - int subtype = reader.readInt(); - - if (subtype != MSG_TYPE) { - throw new UnexpectedTypeException(subtype, MSG_TYPE); - } - - mMessage = reader.readString(); - } - - public GameMessagePacket(String message) { - super(ConnectionType.SERVER, TYPE); - mMessage = message; - } - - /** - * The contents of the "toast" message. - */ - public String getMessage() { - return mMessage; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(MSG_TYPE).writeString(mMessage); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mMessage); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameOverPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameOverPacket.java deleted file mode 100644 index d47ac68..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameOverPacket.java +++ /dev/null @@ -1,59 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -/** - * Sent by the server when the game ends. - * @author rjwut - */ -public class GameOverPacket extends BaseArtemisPacket { - private static final int TYPE = 0xf754c8fe; - private static final byte MSG_TYPE = 0x06; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return GameOverPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new GameOverPacket(reader); - } - }); - } - - private GameOverPacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - int subtype = reader.readInt(); - - if (subtype != MSG_TYPE) { - throw new UnexpectedTypeException(subtype, MSG_TYPE); - } - } - - public GameOverPacket() { - super(ConnectionType.SERVER, TYPE); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - // do nothing - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(MSG_TYPE); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameOverReasonPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameOverReasonPacket.java deleted file mode 100644 index 8e9f602..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameOverReasonPacket.java +++ /dev/null @@ -1,82 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -public class GameOverReasonPacket extends BaseArtemisPacket { - private static final int TYPE = 0xf754c8fe; - private static final byte MSG_TYPE = 0x14; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return GameOverReasonPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new GameOverReasonPacket(reader); - } - }); - } - - private List mText; - - private GameOverReasonPacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - int subtype = reader.readInt(); - - if (subtype != MSG_TYPE) { - throw new UnexpectedTypeException(subtype, MSG_TYPE); - } - - mText = new LinkedList(); - - while (reader.hasMore()) { - mText.add(reader.readString()); - } - } - - public GameOverReasonPacket(String... text) { - super(ConnectionType.SERVER, TYPE); - mText = Arrays.asList(text); - } - - /** - * The text describing why the game ended. Each String in the List is one - * line. - */ - public List getText() { - return new LinkedList(mText); - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(MSG_TYPE); - - for (String line : mText) { - writer.writeString(line); - } - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - for (String line : mText) { - b.append("\n\t").append(line); - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameOverStatsPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameOverStatsPacket.java deleted file mode 100644 index e133254..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/GameOverStatsPacket.java +++ /dev/null @@ -1,125 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -public class GameOverStatsPacket extends BaseArtemisPacket implements - Iterable { - private static final int TYPE = 0xf754c8fe; - private static final byte MSG_TYPE = 0x15; - private static final byte DELIMITER = 0x00; - private static final byte END_MARKER = (byte) 0xce; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return GameOverStatsPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new GameOverStatsPacket(reader); - } - }); - } - - private byte columnIndex; - private List rows = new LinkedList(); - - private GameOverStatsPacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - int subtype = reader.readInt(); - - if (subtype != MSG_TYPE) { - throw new UnexpectedTypeException(subtype, MSG_TYPE); - } - - columnIndex = reader.readByte(); - - do { - if (reader.readByte() == END_MARKER) { - break; - } - - int value = reader.readInt(); - String label = reader.readString(); - rows.add(new Row(label, value)); - } while (true); - } - - public GameOverStatsPacket(byte columnIndex) { - super(ConnectionType.SERVER, TYPE); - this.columnIndex = columnIndex; - } - - public byte getColumnIndex() { - return columnIndex; - } - - @Override - public Iterator iterator() { - return rows.iterator(); - } - - public void addRow(String label, int value) { - rows.add(new Row(label, value)); - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(MSG_TYPE); - writer.writeByte(columnIndex); - - for (Row row : rows) { - writer - .writeByte(DELIMITER) - .writeInt(row.getValue()) - .writeString(row.getLabel()); - } - - writer.writeByte(END_MARKER); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - for (Row row : rows) { - b .append("\n\t") - .append(row.getLabel()) - .append(": ") - .append(row.getValue()); - } - } - - - public static class Row { - private String label; - private int value; - - private Row(String label, int value) { - this.label = label; - this.value = value; - } - - public String getLabel() { - return label; - } - - public int getValue() { - return value; - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/KeyCaptureTogglePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/KeyCaptureTogglePacket.java deleted file mode 100644 index c3ebb46..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/KeyCaptureTogglePacket.java +++ /dev/null @@ -1,73 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -/** - * Enables/disables keystroke capture for this console. Note that the game - * master console always captures keystrokes; all others don't by default unless - * this packet enables it. - * @author rjwut - */ -public class KeyCaptureTogglePacket extends BaseArtemisPacket { - private static final int TYPE = 0xf754c8fe; - private static final byte MSG_TYPE = 0x11; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return KeyCaptureTogglePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new KeyCaptureTogglePacket(reader); - } - }); - } - - private boolean mEnabled; - - private KeyCaptureTogglePacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - byte subtype = reader.readByte(); - - if (subtype != MSG_TYPE) { - throw new UnexpectedTypeException(subtype, MSG_TYPE); - } - - mEnabled = reader.readInt() == 1; - } - - public KeyCaptureTogglePacket(boolean enabled) { - super(ConnectionType.SERVER, TYPE); - mEnabled = enabled; - } - - /** - * Returns true if this console should capture keystrokes; false otherwise. - */ - public boolean isEnabled() { - return mEnabled; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeByte(MSG_TYPE).writeInt(mEnabled ? 1 : 0); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mEnabled ? "ON" : "OFF"); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/KeystrokePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/KeystrokePacket.java deleted file mode 100644 index 29a022f..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/KeystrokePacket.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; - -/** - * Sends a keystroke to the server. This should only be done for the game master - * console, or if keystroke capture has been enabled via the - * KeyCaptureTogglePacket. - * @author rjwut - */ -public class KeystrokePacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_REVERSE_ENGINES, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return KeystrokePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new KeystrokePacket(reader); - } - }); - } - - /** - * @param keycode the key that was pressed - * @see {@link java.awt.event.KeyEvent} (for constants) - */ - public KeystrokePacket(int keycode) { - super(TYPE_KEYSTROKE, keycode); - } - - private KeystrokePacket(PacketReader reader) { - super(TYPE_KEYSTROKE, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mArg); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/PausePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/PausePacket.java deleted file mode 100644 index e5a16de..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/PausePacket.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; -import net.dhleong.acl.util.BoolState; - -public class PausePacket extends BaseArtemisPacket { - private static final int TYPE = 0xf754c8fe; - private static final byte MSG_TYPE = 0x04; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return PausePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new PausePacket(reader); - } - }); - } - - private final BoolState mPaused; - - private PausePacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - int subtype = reader.readInt(); - - if (subtype != MSG_TYPE) { - throw new UnexpectedTypeException(subtype, MSG_TYPE); - } - - mPaused = reader.readBool(4); - } - - public PausePacket(boolean paused) { - super(ConnectionType.SERVER, TYPE); - mPaused = BoolState.from(paused); - } - - public BoolState getPaused() { - return mPaused; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(MSG_TYPE).writeInt(BoolState.safeValue(mPaused) ? 1 : 0); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(BoolState.safeValue(mPaused) ? "PAUSED" : "RUNNING"); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/PerspectivePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/PerspectivePacket.java deleted file mode 100644 index 5ed36d5..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/PerspectivePacket.java +++ /dev/null @@ -1,77 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.Perspective; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -/** - * Notifies clients that the main screen perspective has changed. - * @author rjwut - */ -public class PerspectivePacket extends BaseArtemisPacket { - private static final int TYPE = 0xf754c8fe; - private static final byte MSG_TYPE = 0x12; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return PerspectivePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new PerspectivePacket(reader); - } - }); - } - - private Perspective mPerspective; - - private PerspectivePacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - int subtype = reader.readInt(); - - if (subtype != MSG_TYPE) { - throw new UnexpectedTypeException(subtype, MSG_TYPE); - } - - mPerspective = Perspective.values()[reader.readInt()]; - } - - public PerspectivePacket(Perspective perspective) { - super(ConnectionType.SERVER, TYPE); - - if (perspective == null) { - throw new IllegalArgumentException("You must provide a Perspective"); - } - - mPerspective = perspective; - } - - /** - * Returns the Perspective specified by this packet. - */ - public Perspective getPerspective() { - return mPerspective; - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mPerspective.name()); - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(MSG_TYPE).writeInt(mPerspective.ordinal()); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/PlayerShipDamagePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/PlayerShipDamagePacket.java deleted file mode 100644 index 2a1cef8..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/PlayerShipDamagePacket.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; - -public class PlayerShipDamagePacket extends BaseArtemisPacket { - private static final int TYPE = 0xf754c8fe; - - public static void register(PacketFactoryRegistry registry) { - PacketFactory factory = new PacketFactory() { - @Override - public Class getFactoryClass() { - return PlayerShipDamagePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new PlayerShipDamagePacket(reader); - } - }; - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE, factory); - } - - public static final byte MSG_TYPE = 0x05; - - private byte[] unknown0; - private byte[] unknown1; - - private PlayerShipDamagePacket(PacketReader reader) throws ArtemisPacketException { - super(ConnectionType.SERVER, TYPE); - int subtype = reader.readInt(); - - if (subtype != MSG_TYPE) { - throw new ArtemisPacketException( - "Expected subtype " + MSG_TYPE + ", got " + subtype - ); - } - - unknown0 = reader.readBytes(4); - unknown1 = reader.readBytes(4); - } - - public PlayerShipDamagePacket() { - super(ConnectionType.SERVER, TYPE); - unknown0 = new byte[] { 0, 0, 0, 0 }; - unknown1 = unknown0; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(MSG_TYPE).writeBytes(unknown0).writeBytes(unknown1); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - // do nothing - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/SetMainScreenPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/SetMainScreenPacket.java deleted file mode 100644 index 05d27f3..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/SetMainScreenPacket.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.MainScreenView; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; - -/** - * Set what to show on the MainScreen - * @author dhleong - */ -public class SetMainScreenPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_MAINSCREEN, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return SetMainScreenPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new SetMainScreenPacket(reader); - } - }); - } - - /** - * @param screen The enum value representing the desired view - */ - public SetMainScreenPacket(MainScreenView screen) { - super(TYPE_MAINSCREEN, screen != null ? screen.ordinal() : -1); - - if (screen == null) { - throw new IllegalArgumentException("You must specify a view"); - } - } - - private SetMainScreenPacket(PacketReader reader) { - super(TYPE_MAINSCREEN, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(MainScreenView.values()[mArg]); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/ShipActionPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/ShipActionPacket.java deleted file mode 100644 index 6b5565d..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/ShipActionPacket.java +++ /dev/null @@ -1,78 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.BaseArtemisPacket; - -/** - * A superclass for handling all type 0x4c821d3c client packets. - * @author rjwut - */ -public abstract class ShipActionPacket extends BaseArtemisPacket { - protected static final int TYPE = 0x4c821d3c; - - protected static final byte TYPE_WARPSPEED = 0x00; - protected static final byte TYPE_MAINSCREEN = 0x01; - protected static final byte TYPE_SET_TARGET = 0x02; - protected static final byte TYPE_TOGGLE_AUTO_BEAMS = 0x03; - protected static final byte TYPE_TOGGLE_SHIELDS = 0x04; - - protected static final byte TYPE_REQUEST_DOCK = 0x07; - protected static final byte TYPE_FIRE_TUBE = 0x08; - protected static final byte TYPE_UNLOAD_TUBE = 0x09; - protected static final byte TYPE_TOGGLE_REDALERT = 0x0a; - protected static final byte TYPE_SET_BEAMFREQ = 0x0b; - protected static final byte TYPE_AUTO_DAMCON = 0x0c; - protected static final byte TYPE_SET_SHIP = 0x0d; - protected static final byte TYPE_SET_CONSOLE = 0x0e; - protected static final byte TYPE_READY = 0x0f; - protected static final byte TYPE_SCI_SELECT = 0x10; - protected static final byte TYPE_CAPTAIN_SELECT = 0x11; - protected static final byte TYPE_GAME_MASTER_SELECT = 0x12; - protected static final byte TYPE_SCI_SCAN = 0x13; - protected static final byte TYPE_KEYSTROKE = 0x14; - - protected static final byte TYPE_SHIP_SETUP = 0x16; - - protected static final byte TYPE_REVERSE_ENGINES = 0x18; - protected static final byte TYPE_READY2 = 0x19; - protected static final byte TYPE_TOGGLE_PERSPECTIVE = 0x1a; - - private byte mSubType; - protected int mArg = -1; - - /** - * Use this constructor if you intend to override writePayload() with your - * own implementation and not call ShipActionPacket.writePayload(). - * @param subType The desired packet subtype - */ - public ShipActionPacket(byte subType) { - super(ConnectionType.CLIENT, TYPE); - mSubType = subType; - } - - /** - * Use this constructor if the packet has a single int argument that is - * written to the payload after the subtype. In this case, you will not need - * to override writePayload(). - * @param subType The desired packet subtype - * @param arg A single argument to write to the payload after the subtype - */ - public ShipActionPacket(byte subType, int arg) { - this(subType); - mArg = arg; - } - - protected ShipActionPacket(byte subType, PacketReader reader) { - this(subType); - reader.skip(4); // subtype - mArg = reader.readInt(); - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(mSubType); - writer.writeInt(mArg); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/SkyboxPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/SkyboxPacket.java deleted file mode 100644 index 4ddd258..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/SkyboxPacket.java +++ /dev/null @@ -1,59 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -public class SkyboxPacket extends BaseArtemisPacket { - private static final int TYPE = 0xf754c8fe; - private static final byte MSG_TYPE = 0x09; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return SkyboxPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new SkyboxPacket(reader); - } - }); - } - - private int mSkyboxId; - - private SkyboxPacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - int subtype = reader.readInt(); - - if (subtype != MSG_TYPE) { - throw new UnexpectedTypeException(subtype, MSG_TYPE); - } - - mSkyboxId = reader.readInt(); - } - - public SkyboxPacket(int offset) { - super(ConnectionType.SERVER, TYPE); - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(MSG_TYPE).writeInt(mSkyboxId); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mSkyboxId); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/TogglePerspectivePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/TogglePerspectivePacket.java deleted file mode 100644 index 433232a..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/TogglePerspectivePacket.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; - -/** - * Toggles between first- and third-person perspectives on the main screen. Note - * that you cannot specify which perspective you want; you can only indicate - * that you want to switch from the current one to the other. - * @author rjwut - */ -public class TogglePerspectivePacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_TOGGLE_PERSPECTIVE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return TogglePerspectivePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new TogglePerspectivePacket(reader); - } - }); - } - - public TogglePerspectivePacket() { - super(TYPE_TOGGLE_PERSPECTIVE, 0); - } - - private TogglePerspectivePacket(PacketReader reader) { - super(TYPE_TOGGLE_PERSPECTIVE, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - // do nothing - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/ToggleShieldsPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/ToggleShieldsPacket.java deleted file mode 100644 index 6dc5c02..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/ToggleShieldsPacket.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.dhleong.acl.protocol.core; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; - -/** - * Toggle shields - * @author dhleong - */ -public class ToggleShieldsPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_TOGGLE_SHIELDS, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return ToggleShieldsPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new ToggleShieldsPacket(reader); - } - }); - } - - public ToggleShieldsPacket() { - super(TYPE_TOGGLE_SHIELDS, 0); - } - - private ToggleShieldsPacket(PacketReader reader) { - super(TYPE_TOGGLE_SHIELDS, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - // do nothing - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/AudioCommandPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/AudioCommandPacket.java deleted file mode 100644 index 3d1f557..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/AudioCommandPacket.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.dhleong.acl.protocol.core.comm; - -import net.dhleong.acl.enums.AudioCommand; -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; - -/** - * Plays or deletes an audio message. - */ -public class AudioCommandPacket extends BaseArtemisPacket { - private static final int TYPE = 0x6aadc57f; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return AudioCommandPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new AudioCommandPacket(reader); - } - }); - } - - private int audioId; - private AudioCommand cmd; - - /** - * @param audioId The ID of the audio message to which the command applies - * @param cmd The command to issue (PLAY or DELETE) - */ - public AudioCommandPacket(int audioId, AudioCommand cmd) { - super(ConnectionType.CLIENT, TYPE); - - if (cmd == null) { - throw new IllegalArgumentException("You must provide a command"); - } - - this.audioId = audioId; - this.cmd = cmd; - } - - private AudioCommandPacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - audioId = reader.readInt(); - cmd = AudioCommand.values()[reader.readInt()]; - } - - public int getAudioId() { - return audioId; - } - - public AudioCommand getCommand() { - return cmd; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(audioId).writeInt(cmd.ordinal()); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(cmd).append(" msg #").append(audioId); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/CommsIncomingPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/CommsIncomingPacket.java deleted file mode 100644 index da40333..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/CommsIncomingPacket.java +++ /dev/null @@ -1,100 +0,0 @@ -package net.dhleong.acl.protocol.core.comm; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; - -/** - * Received when an incoming COMMs message arrives. - */ -public class CommsIncomingPacket extends BaseArtemisPacket { - private static final int TYPE = 0xD672C35F; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return CommsIncomingPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new CommsIncomingPacket(reader); - } - }); - } - - private final int mPriority; - private final String mFrom; - private final String mMessage; - - private CommsIncomingPacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - mPriority = reader.readInt(); - mFrom = reader.readString(); - mMessage = reader.readString().replace('^', '\n'); - } - - public CommsIncomingPacket(int priority, String from, String message) { - super(ConnectionType.SERVER, TYPE); - - if (priority < 0 || priority > 8) { - throw new IllegalArgumentException("Invalid priority: " + priority); - } - - if (from == null) { - throw new IllegalArgumentException("You must provide a sender name"); - } - - if (message == null) { - throw new IllegalArgumentException("You must provide a message"); - } - - mPriority = priority; - mFrom = from; - mMessage = message; - } - - /** - * Returns the message priority, with lower values having higher priority. - * @return An integer between 0 and 8, inclusive - */ - public int getPriority() { - return mPriority; - } - - /** - * A String identifying the sender. This may not correspond to the name of - * a game entity. For example, some messages from bases or friendly ships - * have additional detail after the entity's name ("DS3 TSN Base"). Messages - * in scripted scenarios can have any String for the sender. - */ - public String getFrom() { - return mFrom; - } - - /** - * The content of the message. - */ - public String getMessage() { - return mMessage; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(mPriority); - writer.writeString(mFrom); - writer.writeString(mMessage.replace('\n', '^')); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append("from ").append(mFrom).append(": ").append(mMessage); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/CommsOutgoingPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/CommsOutgoingPacket.java deleted file mode 100644 index 57ba934..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/CommsOutgoingPacket.java +++ /dev/null @@ -1,151 +0,0 @@ -package net.dhleong.acl.protocol.core.comm; - -import net.dhleong.acl.enums.CommsMessage; -import net.dhleong.acl.enums.CommsRecipientType; -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.world.ArtemisObject; - -/** - * Sends a message to another entity. - */ -public class CommsOutgoingPacket extends BaseArtemisPacket { - private static final int TYPE = 0x574C4C4b; - public static final int NO_ARG = 0x00730078; - private static final int NO_ARG_2 = 0x004f005e; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return CommsOutgoingPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new CommsOutgoingPacket(reader); - } - }); - } - - private CommsRecipientType mRecipientType; - private int mRecipientId; - private CommsMessage mMsg; - private int mArg; - - /** - * Use this constructor for messages which do not have an argument; - * otherwise, an IllegalArgumentException will be thrown. - * @param target The message recipient - * @param msg The message to be sent - */ - public CommsOutgoingPacket(ArtemisObject target, CommsMessage msg) { - super(ConnectionType.CLIENT, TYPE); - - if (msg.hasArgument()) { - throw new IllegalArgumentException( - "Message " + msg + " requires an argument" - ); - } - - init(target, msg, NO_ARG); - } - - /** - * Use this constructor for messages which have an argument; otherwise, an - * IllegalArgumentException will be thrown. At this writing only the - * {@link net.dhleong.acl.enums.OtherMessage#GO_DEFEND} - * message has an argument, which is the ID of the object to be defended. - */ - public CommsOutgoingPacket(ArtemisObject recipient, CommsMessage msg, - int arg) { - super(ConnectionType.CLIENT, TYPE); - - if (!msg.hasArgument()) { - throw new IllegalArgumentException( - "Message " + msg + " does not accept an argument" - ); - } - - init(recipient, msg, arg); - } - - private CommsOutgoingPacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - mRecipientType = CommsRecipientType.values()[reader.readInt()]; - mRecipientId = reader.readInt(); - mMsg = mRecipientType.messageFromId(reader.readInt()); - mArg = reader.readInt(); - reader.skip(4); // arg 2 placeholder - } - - private void init(ArtemisObject recipient, CommsMessage msg, int arg) { - if (recipient == null) { - throw new IllegalArgumentException("You must provide a recipient"); - } - - if (msg == null) { - throw new IllegalArgumentException("You must provide a message"); - } - - mRecipientType = CommsRecipientType.fromObject(recipient); - - if (mRecipientType == null) { - throw new IllegalArgumentException("Recipient cannot receive messages"); - } - - CommsRecipientType messageRecipientType = msg.getRecipientType(); - - if (mRecipientType != messageRecipientType) { - throw new IllegalArgumentException( - "Recipient type is " + mRecipientType + - ", but message recipient type is " + messageRecipientType - ); - } - - mRecipientId = recipient.getId(); - mMsg = msg; - mArg = arg; - } - - public CommsRecipientType getRecipientType() { - return mRecipientType; - } - - public int getRecipientId() { - return mRecipientId; - } - - public CommsMessage getMessage() { - return mMsg; - } - - public int getArgument() { - return mArg; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer .writeInt(mRecipientType.ordinal()) - .writeInt(mRecipientId) - .writeInt(mMsg.getId()) - .writeInt(mArg) - .writeInt(NO_ARG_2); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append("to obj #").append(mRecipientId).append(": ").append(mMsg); - - if (mArg != NO_ARG) { - b.append(" object #").append(mArg); - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/IncomingAudioPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/IncomingAudioPacket.java deleted file mode 100644 index 10b2a5b..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/IncomingAudioPacket.java +++ /dev/null @@ -1,134 +0,0 @@ -package net.dhleong.acl.protocol.core.comm; - -import net.dhleong.acl.enums.AudioMode; -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; - -/** - * Received when an incoming COMMs audio message arrives. - * @author dhleong - */ -public class IncomingAudioPacket extends BaseArtemisPacket { - private static final int TYPE = 0xae88e058; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return IncomingAudioPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new IncomingAudioPacket(reader); - } - }); - } - - private final int mId; - private final AudioMode mMode; - private final String mTitle; - private final String mFile; - - private IncomingAudioPacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - mId = reader.readInt(); - mMode = AudioMode.values()[reader.readInt() - 1]; - - if (mMode == AudioMode.INCOMING) { - mTitle = reader.readString(); - mFile = reader.readString(); - } else { - mTitle = null; - mFile = null; - } - } - - /** - * Indicates that the audio message with the given ID has started playing - * (Mode.PLAYING). - */ - public IncomingAudioPacket(int id) { - super(ConnectionType.SERVER, TYPE); - mId = id; - mMode = AudioMode.PLAYING; - mTitle = null; - mFile = null; - } - - /** - * Indicates that there is an incoming audio message (Mode.INCOMING). - */ - public IncomingAudioPacket(int id, String title, String file) { - super(ConnectionType.SERVER, TYPE); - mId = id; - mMode = AudioMode.INCOMING; - mTitle = title; - mFile = file; - } - - /** - * The ID assigned to this audio message. - */ - public int getAudioId() { - return mId; - } - - /** - * The file name for this audio message. This will only be populated if - * getAudioMode() returns IncomingAudioPacket.Mode.INCOMING; otherwise, it - * returns null. - */ - public String getFileName() { - return mFile; - } - - /** - * The title for this audio message. This will only be populated if - * getAudioMode() returns IncomingAudioPacket.Mode.INCOMING; otherwise, it - * returns null. - */ - public String getTitle() { - return mTitle; - } - - @Override - public ConnectionType getConnectionType() { - return ConnectionType.SERVER; - } - - /** - * Indicates whether this packet indicates that the message is available - * (INCOMING) or playing (PLAYING). - */ - public AudioMode getAudioMode() { - return mMode; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(mId); - writer.writeInt(mMode.ordinal() + 1); - - if (mMode == AudioMode.INCOMING) { - writer.writeString(mTitle); - writer.writeString(mFile); - } - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append('#').append(mId).append(' ').append(mMode); - - if (mMode == AudioMode.INCOMING) { - b.append(": ").append(mTitle); - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/ToggleRedAlertPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/ToggleRedAlertPacket.java deleted file mode 100644 index c1d0f0c..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/comm/ToggleRedAlertPacket.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.dhleong.acl.protocol.core.comm; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; - -/** - * Toggles red alert on and off. - */ -public class ToggleRedAlertPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_TOGGLE_REDALERT, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return ToggleRedAlertPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new ToggleRedAlertPacket(reader); - } - }); - } - - public ToggleRedAlertPacket() { - super(TYPE_TOGGLE_REDALERT, 0); - } - - private ToggleRedAlertPacket(PacketReader reader) { - super(TYPE_TOGGLE_REDALERT, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - // do nothing - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngAutoDamconUpdatePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngAutoDamconUpdatePacket.java deleted file mode 100644 index 6b181f5..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngAutoDamconUpdatePacket.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.dhleong.acl.protocol.core.eng; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -public class EngAutoDamconUpdatePacket extends BaseArtemisPacket { - private static final int TYPE = 0xf754c8fe; - private static final byte MSG_TYPE = 0x0b; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return EngAutoDamconUpdatePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new EngAutoDamconUpdatePacket(reader); - } - }); - } - - private final boolean mOn; - - private EngAutoDamconUpdatePacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - int subtype = reader.readInt(); - - if (subtype != MSG_TYPE) { - throw new UnexpectedTypeException(subtype, MSG_TYPE); - } - - mOn = reader.readInt() == 1; - } - - public EngAutoDamconUpdatePacket(String name, boolean on) { - super(ConnectionType.SERVER, TYPE); - mOn = on; - } - - /** - * Returns true if autonomous DAMCON was turned on; false if turned off. - */ - public boolean isOn() { - return mOn; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(MSG_TYPE).writeInt(mOn ? 1 : 0); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mOn ? "ON" : "OFF"); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngGridUpdatePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngGridUpdatePacket.java deleted file mode 100644 index e2af3ea..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngGridUpdatePacket.java +++ /dev/null @@ -1,300 +0,0 @@ -package net.dhleong.acl.protocol.core.eng; - -import java.util.ArrayList; -import java.util.List; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.util.GridCoord; - -/** - * Updates damage to the various system grids on the ship, as well as DamCon - * team status/location. - * @author dhleong - */ -public class EngGridUpdatePacket extends BaseArtemisPacket { - private static final int TYPE = 0x77e9f3c; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return EngGridUpdatePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new EngGridUpdatePacket(reader); - } - }); - } - - private static final byte END_GRID_MARKER = (byte) 0xff; - private static final byte END_DAMCON_MARKER = (byte) 0xfe; - private static final int TEAM_NUMBER_OFFSET = 0x0a; - private static final float PROGRESS_EPSILON = 0.001f; - - private List mDamage = new ArrayList(); - private List mDamconUpdates = new ArrayList(); - - /** - * Creates a new EngGridUpdatePacket with no updates. Use the - * addDamageUpdate() and addDamconUpdate() methods to add update information - * to this packet. - */ - public EngGridUpdatePacket() { - super(ConnectionType.SERVER, TYPE); - } - - private EngGridUpdatePacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - reader.readUnknown("Unknown", 1); - - while (reader.peekByte() != END_GRID_MARKER) { - GridCoord coord = GridCoord.getInstance( - reader.readByte(), - reader.readByte(), - reader.readByte() - ); - float damage = reader.readFloat(); - mDamage.add(new GridDamage(coord, damage)); - } - - reader.skip(1); // read the 0xff byte - - while (reader.peekByte() != END_DAMCON_MARKER) { - byte teamIndicator = reader.readByte(); - int teamNumber = teamIndicator - TEAM_NUMBER_OFFSET; - int xGoal = reader.readInt(); - int x = reader.readInt(); - int yGoal = reader.readInt(); - int y = reader.readInt(); - int zGoal = reader.readInt(); - int z = reader.readInt(); - float progress = reader.readFloat(); - int members = reader.readInt(); - addDamconUpdate(teamNumber, members, xGoal, yGoal, zGoal, x, y, z, - progress); - } - - reader.skip(1); // read the 0xfe byte - } - - /** - * Adds a damage update to this packet. - */ - public void addDamageUpdate(int x, int y, int z, float damage) { - mDamage.add(new GridDamage(GridCoord.getInstance(x, y, z), damage)); - } - - /** - * Adds a DAMCON team update to this packet. - */ - public void addDamconUpdate(int teamNumber, int members, int xGoal, - int yGoal, int zGoal, int x, int y, int z, float progress) { - mDamconUpdates.add(new DamconStatus(teamNumber, members, xGoal, yGoal, - zGoal, x, y, z, progress)); - } - - /** - * Returns a List of GridDamage objects that describe the damage data - * encoded in this packet. - */ - public List getDamage() { - return mDamage; - } - - /** - * Returns a List of DamconStatus objects that provide the DAMCON team - * updates encoded in this packet. - */ - public List getDamcons() { - return mDamconUpdates; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeByte((byte) 1); // unknown - - for (GridDamage damage : mDamage) { - GridCoord coord = damage.coord; - writer .writeByte((byte) coord.getX()) - .writeByte((byte) coord.getY()) - .writeByte((byte) coord.getZ()) - .writeFloat(damage.damage); - } - - writer.writeByte(END_GRID_MARKER); - - for (DamconStatus update : mDamconUpdates) { - writer .writeByte((byte) (update.teamNumber + TEAM_NUMBER_OFFSET)) - .writeInt(update.goal.getX()) - .writeInt(update.pos.getX()) - .writeInt(update.goal.getY()) - .writeInt(update.pos.getY()) - .writeInt(update.goal.getZ()) - .writeInt(update.pos.getZ()) - .writeFloat(update.progress) - .writeInt(update.members); - } - - writer.writeByte(END_DAMCON_MARKER); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append("\nDamage updates:"); - - if (mDamage.isEmpty()) { - b.append("\n\tnone"); - } else { - for (GridDamage damage : mDamage) { - b.append("\n\t").append(damage); - } - } - - b.append("\nDAMCON status updates:"); - - if (mDamconUpdates.isEmpty()) { - b.append("\n\tnone"); - } else { - for (DamconStatus status : mDamconUpdates) { - b.append("\n\t").append(status); - } - } - } - - - /** - * Updates the level of damage to a node in the system grid. - * @author dhleong - */ - public static final class GridDamage { - private final GridCoord coord; - private final float damage; - - private GridDamage(GridCoord coord, float damage) { - this.coord = coord; - this.damage = damage; - } - - public GridCoord getCoord() { - return coord; - } - - public float getDamage() { - return damage; - } - - @Override - public boolean equals(Object other) { - if (this == other) { - return true; - } - - if (!(other instanceof GridDamage)) { - return false; - } - - GridDamage cast = (GridDamage) other; - return coord.equals(cast.coord); - } - - @Override - public int hashCode() { - return coord.hashCode(); - } - - @Override - public String toString() { - return coord + ": " + damage; - } - } - - /** - * Updates the status of a DAMCON team. - * @author dhleong - */ - public static final class DamconStatus { - private int teamNumber, members; - private GridCoord goal; - private GridCoord pos; - private float progress; - - public DamconStatus(int teamNumber, int members, int xGoal, - int yGoal, int zGoal, int x, int y, int z, float progress) { - this.teamNumber = teamNumber; - this.members = members; - goal = GridCoord.getInstance(xGoal, yGoal, zGoal); - pos = GridCoord.getInstance(x, y, z); - this.progress = progress; - } - - /** - * The number assigned to this DAMCON team. - */ - public int getTeamNumber() { - return teamNumber; - } - - /** - * The number of people in this DAMCON team that are still alive. - */ - public int getMembers() { - return members; - } - - /** - * The coordinates of the DAMCON team's current location. - */ - public GridCoord getPosition() { - return pos; - } - - /** - * The coordinates of the DAMCON team's goal. - */ - public GridCoord getGoal() { - return goal; - } - - /** - * The DAMCON team's progress towards their destination. - */ - public float getProgress() { - return progress; - } - - public void updateFrom(DamconStatus other) { - this.members = other.members; - - if (other.progress < PROGRESS_EPSILON && progress > 0) { - this.pos = goal; - } else { - this.pos = other.pos; - } - - this.goal = other.goal; - this.progress = other.progress; - } - - @Override - public String toString() { - StringBuilder b = new StringBuilder(); - b.append("Team #").append(teamNumber) - .append(" (").append(members).append("): ") - .append(pos) - .append(" => ") - .append(goal) - .append(" (").append(progress).append(")"); - return b.toString(); - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngSendDamconPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngSendDamconPacket.java deleted file mode 100644 index 07b98ed..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngSendDamconPacket.java +++ /dev/null @@ -1,102 +0,0 @@ -package net.dhleong.acl.protocol.core.eng; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; -import net.dhleong.acl.util.GridCoord; - -/** - * Send a DAMCON team to a grid location. - * @author dhleong - */ -public class EngSendDamconPacket extends BaseArtemisPacket { - private static final int TYPE = 0x69CC01D9; - private static final byte SUBTYPE = 0x04; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, SUBTYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return EngSendDamconPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new EngSendDamconPacket(reader); - } - }); - } - - private int mTeamNumber; - private GridCoord mCoord; - - /** - * Send the team to grid node at x,y,z. - * @param teamNumber int [0, TEAMS) where TEAMS is probably 3 - * @param x Destination X-coordinate in the system grid - * @param y Destination Y-coordinate in the system grid - * @param z Destination Z-coordinate in the system grid - */ - public EngSendDamconPacket(int teamNumber, int x, int y, int z) { - super(ConnectionType.CLIENT, TYPE); - - if (teamNumber < 0) { - throw new IllegalArgumentException( - "DAMCON team number can't be less than 0" - ); - } - - mTeamNumber = teamNumber; - mCoord = GridCoord.getInstance(x, y, z); - } - - /** - * @param teamNumber int [0, TEAMS) where TEAMS is probably 3 - * @param coord Destination coordinates in the system grid - */ - public EngSendDamconPacket(int teamNumber, GridCoord coord) { - this(teamNumber, coord.getX(), coord.getY(), coord.getZ()); - } - - private EngSendDamconPacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - int subtype = reader.readInt(); - - if (subtype != SUBTYPE) { - throw new UnexpectedTypeException(subtype, SUBTYPE); - } - - mTeamNumber = reader.readInt(); - mCoord = GridCoord.getInstance(reader.readInt(), reader.readInt(), reader.readInt()); - } - - public int getTeamNumber() { - return mTeamNumber; - } - - public GridCoord getDestination() { - return mCoord; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer .writeInt(SUBTYPE) - .writeInt(mTeamNumber) - .writeInt(mCoord.getX()) - .writeInt(mCoord.getY()) - .writeInt(mCoord.getZ()); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append("Team #").append(mTeamNumber).append(" to ").append(mCoord); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngSetAutoDamconPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngSetAutoDamconPacket.java deleted file mode 100644 index 9909491..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngSetAutoDamconPacket.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.dhleong.acl.protocol.core.eng; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; - -/** - * Set whether DAMCON teams should be autonomous or not. - * @author dhleong - */ -public class EngSetAutoDamconPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_AUTO_DAMCON, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return EngSetAutoDamconPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new EngSetAutoDamconPacket(reader); - } - }); - } - - /** - * @param autonomous Whether DAMCON teams should be autonomous - */ - public EngSetAutoDamconPacket(boolean autonomous) { - super(TYPE_AUTO_DAMCON, autonomous ? 1 : 0); - } - - private EngSetAutoDamconPacket(PacketReader reader) { - super(TYPE_AUTO_DAMCON, reader); - } - - public boolean isAutonomous() { - return mArg == 1; - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mArg == 1 ? "on" : "off"); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngSetCoolantPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngSetCoolantPacket.java deleted file mode 100644 index a9ac6e8..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngSetCoolantPacket.java +++ /dev/null @@ -1,93 +0,0 @@ -package net.dhleong.acl.protocol.core.eng; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -/** - * Set the amount of coolant in a system. - * @author dhleong - */ -public class EngSetCoolantPacket extends BaseArtemisPacket { - private static final int TYPE = 0x69CC01D9; - private static final byte SUBTYPE = 0x00; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, SUBTYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return EngSetCoolantPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new EngSetCoolantPacket(reader); - } - }); - } - - private ShipSystem mSystem; - private int mCoolant; - - /** - * @param system The ShipSystem whose coolant level is to be set - * @param coolant The amount of coolant to allocate - */ - public EngSetCoolantPacket(ShipSystem system, int coolant) { - super(ConnectionType.CLIENT, TYPE); - - if (system == null) { - throw new IllegalArgumentException("You must provide a system"); - } - - if (coolant < 0) { - throw new IllegalArgumentException( - "You cannot allocate a negative amount of coolant" - ); - } - - mSystem = system; - mCoolant = coolant; - } - - private EngSetCoolantPacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - int subtype = reader.readInt(); - - if (subtype != SUBTYPE) { - throw new UnexpectedTypeException(subtype, SUBTYPE); - } - - mSystem = ShipSystem.values()[reader.readInt()]; - mCoolant = reader.readInt(); - } - - public ShipSystem getSystem() { - return mSystem; - } - - public int getCoolant() { - return mCoolant; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer .writeInt(SUBTYPE) - .writeInt(mSystem.ordinal()) - .writeInt(mCoolant); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mSystem).append(" = ").append(mCoolant); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngSetEnergyPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngSetEnergyPacket.java deleted file mode 100644 index 42c9ea4..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/eng/EngSetEnergyPacket.java +++ /dev/null @@ -1,115 +0,0 @@ -package net.dhleong.acl.protocol.core.eng; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; -import net.dhleong.acl.world.Artemis; - -/** - * Sets the amount of energy allocated to a system. - */ -public class EngSetEnergyPacket extends BaseArtemisPacket { - private static final int TYPE = 0x0351a5ac; - private static final byte SUBTYPE = 0x04; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, SUBTYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return EngSetEnergyPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new EngSetEnergyPacket(reader); - } - }); - } - - private ShipSystem mSystem; - private float mValue; - - /** - * Sets the given system's energy allocation. - * @param system The ShipSystem whose energy allocation is to be set - * @param value A number between 0 (no energy) and 1 (max possible energy), - * inclusive. A value of 0.333333... is the default allocation level. - */ - public EngSetEnergyPacket(ShipSystem system, float value) { - super(ConnectionType.CLIENT, TYPE); - - if (system == null) { - throw new IllegalArgumentException("You must provide a system"); - } - - if (value < 0) { - throw new IllegalArgumentException( - "You cannot allocate a negative amount of energy" - ); - } - - if (value > 1) { - throw new IllegalArgumentException( - "You cannot allocate more than " + - Artemis.MAX_ENERGY_ALLOCATION_PERCENT + "% energy" - ); - } - - mSystem = system; - mValue = value; - } - - /** - * Sets the given system's energy allocation. - * @param system The ShipSystem whose energy allocation is to be set - * @param percentage A number between 0 (no energy) and 300 (max possible - * energy), inclusive. This value corresponds to the energy allocation - * percentage as seen in the UI. A value of 100 (100%) is the default - * allocation level. - */ - public EngSetEnergyPacket(ShipSystem system, int percentage) { - this(system, percentage / (float) Artemis.MAX_ENERGY_ALLOCATION_PERCENT); - } - - private EngSetEnergyPacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - int subtype = reader.readInt(); - - if (subtype != SUBTYPE) { - throw new UnexpectedTypeException(subtype, SUBTYPE); - } - - mValue = reader.readFloat(); - mSystem = ShipSystem.values()[reader.readInt()]; - } - - public ShipSystem getSystem() { - return mSystem; - } - - public float getAllocation() { - return mValue; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer .writeInt(SUBTYPE) - .writeFloat(mValue) - .writeInt(mSystem.ordinal()); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b .append(mSystem).append(" = ") - .append(mValue * Artemis.MAX_ENERGY_ALLOCATION_PERCENT).append('%'); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/ClimbDivePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/ClimbDivePacket.java deleted file mode 100644 index 6e665ec..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/ClimbDivePacket.java +++ /dev/null @@ -1,76 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -/** - * Changes the ship's trim, causing it to climb, dive or level out. - * @author rjwut - */ -public class ClimbDivePacket extends BaseArtemisPacket { - private static final int TYPE = 0x4C821D3C; - private static final byte SUBTYPE = 0x1b; - private static final int UP = -1; - private static final int DOWN = 1; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, SUBTYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return ClimbDivePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new ClimbDivePacket(reader); - } - }); - } - - private boolean mUp; - - /** - * Giving an "up" command while diving causes the ship to level out; giving - * a second "up" command causes it to start climbing. The "down" command - * does the reverse. - * @param up True if you want to tilt the ship up, false to tilt it down. - */ - public ClimbDivePacket(boolean up) { - super(ConnectionType.CLIENT, TYPE); - this.mUp = up; - } - - private ClimbDivePacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - int subtype = reader.readInt(); - - if (subtype != SUBTYPE) { - throw new UnexpectedTypeException(subtype, SUBTYPE); - } - - mUp = reader.readInt() == UP; - } - - public boolean isUp() { - return mUp; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(SUBTYPE).writeInt(mUp ? UP : DOWN); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mUp ? "up" : "down"); - } -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmJumpPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmJumpPacket.java deleted file mode 100644 index 72538e9..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmJumpPacket.java +++ /dev/null @@ -1,93 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -/** - * Initiate a jump. There is no confirmation; that's all client-side. - * @author dhleong - */ -public class HelmJumpPacket extends BaseArtemisPacket { - private static final int TYPE = 0x0351A5AC; - private static final byte SUBTYPE = 0x05; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, SUBTYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return HelmJumpPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new HelmJumpPacket(reader); - } - }); - } - - private float mHeading; - private float mDistance; - - /** - * Initiates a jump for the indicated direction and distance. - * @param heading Heading as a percentage of 360 - * @param distance Distance as a percentage of the max possible jump - * distance, 50K - */ - public HelmJumpPacket(float heading, float distance) { - super(ConnectionType.CLIENT, TYPE); - - if (heading < 0 || heading > 1) { - throw new IllegalArgumentException("Heading out of range"); - } - - if (distance < 0 || distance > 1) { - throw new IllegalArgumentException("Distance out of range"); - } - - mHeading = heading; - mDistance = distance; - } - - private HelmJumpPacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - int subtype = reader.readInt(); - - if (subtype != SUBTYPE) { - throw new UnexpectedTypeException(subtype, SUBTYPE); - } - - mHeading = reader.readFloat(); - mDistance = reader.readFloat(); - } - - public float getHeading() { - return mHeading; - } - - public float getDistance() { - return mDistance; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer .writeInt(SUBTYPE) - .writeFloat(mHeading) - .writeFloat(mDistance); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append("heading = ").append(mHeading * 360) - .append(" deg; distance = ").append(mDistance * 50).append('k'); - } -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmRequestDockPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmRequestDockPacket.java deleted file mode 100644 index 926f889..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmRequestDockPacket.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; - -/** - * Request to dock. The request is automatically targeted at the nearest - * base. - * @author dhleong - */ -public class HelmRequestDockPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_REQUEST_DOCK, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return HelmRequestDockPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new HelmRequestDockPacket(reader); - } - }); - } - - public HelmRequestDockPacket() { - super(TYPE_REQUEST_DOCK, 0); - } - - private HelmRequestDockPacket(PacketReader reader) { - super(TYPE_REQUEST_DOCK, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - // do nothing - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmSetClimbDivePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmSetClimbDivePacket.java deleted file mode 100644 index 413a0ee..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmSetClimbDivePacket.java +++ /dev/null @@ -1,76 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -/** - * Set climb/dive. - */ -public class HelmSetClimbDivePacket extends BaseArtemisPacket { - private static final int TYPE = 0x0351A5AC; - private static final byte SUBTYPE = 0x02; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, SUBTYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return HelmSetClimbDivePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new HelmSetClimbDivePacket(reader); - } - }); - } - - private float mPitch; - - /** - * @param pitch steering float in [-1, 1], where 0.0 is "centered" (neither - * climbing nor diving, 1.0 is hard dive, -1.0 is hard climb - */ - public HelmSetClimbDivePacket(float pitch) { - super(ConnectionType.CLIENT, TYPE); - - if (pitch < -1 || pitch > 1) { - throw new IllegalArgumentException("Pitch out of range"); - } - - mPitch = pitch; - } - - private HelmSetClimbDivePacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - int subtype = reader.readInt(); - - if (subtype != SUBTYPE) { - throw new UnexpectedTypeException(subtype, SUBTYPE); - } - - mPitch = reader.readFloat(); - } - - public float getPitch() { - return mPitch; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(SUBTYPE).writeFloat(mPitch); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mPitch); - } -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmSetImpulsePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmSetImpulsePacket.java deleted file mode 100644 index c12de2d..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmSetImpulsePacket.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -/** - * Set impulse power. - * @author dhleong - */ -public class HelmSetImpulsePacket extends BaseArtemisPacket { - private static final int TYPE = 0x0351A5AC; - private static final byte SUBTYPE = 0x00; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, SUBTYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return HelmSetImpulsePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new HelmSetImpulsePacket(reader); - } - }); - } - - private float mPower; - - /** - * @param power Impulse power percentage (value between 0 and 1, inclusive) - */ - public HelmSetImpulsePacket(float power) { - super(ConnectionType.CLIENT, TYPE); - - if (power < 0 || power > 1) { - throw new IllegalArgumentException("Impulse power out of range"); - } - - mPower = power; - } - - private HelmSetImpulsePacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - int subtype = reader.readInt(); - - if (subtype != SUBTYPE) { - throw new UnexpectedTypeException(subtype, SUBTYPE); - } - - mPower = reader.readFloat(); - } - - public float getPower() { - return mPower; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(SUBTYPE).writeFloat(mPower); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mPower * 100).append('%'); - } -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmSetSteeringPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmSetSteeringPacket.java deleted file mode 100644 index 68708e5..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmSetSteeringPacket.java +++ /dev/null @@ -1,79 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -/** - * Set steering amount. Just like the actual console, you need to send one - * packet to start turning, then another to reset the steering angle to stop - * turning. - * @author dhleong - */ -public class HelmSetSteeringPacket extends BaseArtemisPacket { - private static final int TYPE = 0x0351A5AC; - private static final byte SUBTYPE = 0x01; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, SUBTYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return HelmSetSteeringPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new HelmSetSteeringPacket(reader); - } - }); - } - - private float mSteering; - - /** - * @param steering float in [0, 1], where 0.5 is "centered" (no turning), - * 0.0 is left (hard to port), 1.0 is right (hard to starboard) - */ - public HelmSetSteeringPacket(float steering) { - super(ConnectionType.CLIENT, TYPE); - - if (steering < 0 || steering > 1) { - throw new IllegalArgumentException("Steering out of range"); - } - - mSteering = steering; - } - - private HelmSetSteeringPacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - int subtype = reader.readInt(); - - if (subtype != SUBTYPE) { - throw new UnexpectedTypeException(subtype, SUBTYPE); - } - - mSteering = reader.readFloat(); - } - - public float getSteering() { - return mSteering; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(SUBTYPE).writeFloat(mSteering); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mSteering); - } -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmSetWarpPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmSetWarpPacket.java deleted file mode 100644 index 1d67da6..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmSetWarpPacket.java +++ /dev/null @@ -1,52 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; -import net.dhleong.acl.world.Artemis; - -/** - * Set warp speed. - * @author dhleong - */ -public class HelmSetWarpPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_WARPSPEED, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return HelmSetWarpPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new HelmSetWarpPacket(reader); - } - }); - } - - /** - * @param warp Value between 0 (no warp) and 4 (max warp) - */ - public HelmSetWarpPacket(int warp) { - super(TYPE_WARPSPEED, warp); - - if (warp < 0 || warp > Artemis.MAX_WARP) { - throw new IndexOutOfBoundsException("Warp speed out of range"); - } - } - - private HelmSetWarpPacket(PacketReader reader) { - super(TYPE_WARPSPEED, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mArg); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmToggleReversePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmToggleReversePacket.java deleted file mode 100644 index 8740fb7..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/HelmToggleReversePacket.java +++ /dev/null @@ -1,44 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; - -/** - * Toggles reverse engines. - * @author dhleong - */ -public class HelmToggleReversePacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_REVERSE_ENGINES, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return HelmToggleReversePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new HelmToggleReversePacket(reader); - } - }); - } - - public HelmToggleReversePacket() { - super(TYPE_REVERSE_ENGINES, 0); - } - - private HelmToggleReversePacket(PacketReader reader) { - super(TYPE_REVERSE_ENGINES, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - // do nothing - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/JumpStatusPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/JumpStatusPacket.java deleted file mode 100644 index 03caaa4..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/helm/JumpStatusPacket.java +++ /dev/null @@ -1,87 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; - -/** - * Indicates that a jump has begun or ended. - * @author dhleong - */ -public class JumpStatusPacket extends BaseArtemisPacket { - private static final int TYPE = 0xf754c8fe; - - public static void register(PacketFactoryRegistry registry) { - PacketFactory factory = new PacketFactory() { - @Override - public Class getFactoryClass() { - return JumpStatusPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new JumpStatusPacket(reader); - } - }; - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE_BEGIN, factory); - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE_END, factory); - } - - /** - * Jump "begin"; that is, the countdown has begun - */ - public static final byte MSG_TYPE_BEGIN = 0x0c; - - /** - * Jump "end"; there's still some cooldown (~5 seconds) - */ - public static final byte MSG_TYPE_END = 0x0d; - - private final boolean begin; - - private JumpStatusPacket(PacketReader reader) throws ArtemisPacketException { - super(ConnectionType.SERVER, TYPE); - int subtype = reader.readInt(); - - if (subtype == MSG_TYPE_BEGIN) { - begin = true; - } else if (subtype == MSG_TYPE_END) { - begin = false; - } else { - throw new ArtemisPacketException( - "Expected subtype " + MSG_TYPE_BEGIN + " or " + - MSG_TYPE_END + ", got " + subtype - ); - } - } - - public JumpStatusPacket(boolean countingDown) { - super(ConnectionType.SERVER, TYPE); - begin = countingDown; - } - - /** - * Returns true if the jump is starting (countdown has begun); false if the - * jump has ended. - * @return - */ - public boolean isCountdown() { - return begin; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(begin ? MSG_TYPE_BEGIN : MSG_TYPE_END); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(begin ? "begin" : "end"); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/sci/SciScanPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/sci/SciScanPacket.java deleted file mode 100644 index d4b19e0..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/sci/SciScanPacket.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.dhleong.acl.protocol.core.sci; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; -import net.dhleong.acl.world.ArtemisObject; - -/** - * Scans the indicated target. - */ -public class SciScanPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_SCI_SCAN, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return SciScanPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new SciScanPacket(reader); - } - }); - } - - /** - * @param target The target to scan - */ - public SciScanPacket(ArtemisObject target) { - super(TYPE_SCI_SCAN, target != null ? target.getId() : 0); - - if (target == null) { - throw new IllegalArgumentException("You must provide a target"); - } - } - - private SciScanPacket(PacketReader reader) { - super(TYPE_SCI_SCAN, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append('#').append(mArg); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/sci/SciSelectPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/sci/SciSelectPacket.java deleted file mode 100644 index 3447742..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/sci/SciSelectPacket.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.dhleong.acl.protocol.core.sci; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; -import net.dhleong.acl.world.ArtemisObject; - -/** - * Sets the science officer's current target. - */ -public class SciSelectPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_SCI_SELECT, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return SciSelectPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new SciSelectPacket(reader); - } - }); - } - - /** - * @param target The target to select (or null to clear the taregt) - */ - public SciSelectPacket(ArtemisObject target) { - super(TYPE_SCI_SELECT, target == null ? 1 : target.getId()); - } - - public SciSelectPacket(PacketReader reader) { - super(TYPE_SCI_SELECT, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append('#').append(mArg); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/AllShipSettingsPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/AllShipSettingsPacket.java deleted file mode 100644 index 65a0eb3..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/AllShipSettingsPacket.java +++ /dev/null @@ -1,149 +0,0 @@ -package net.dhleong.acl.protocol.core.setup; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.DriveType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; -import net.dhleong.acl.vesseldata.Vessel; -import net.dhleong.acl.vesseldata.VesselData; -import net.dhleong.acl.world.Artemis; - -/** - * Sent by the server to update the names, types and drives for each ship. - * @author dhleong - */ -public class AllShipSettingsPacket extends BaseArtemisPacket { - private static final int TYPE = 0xf754c8fe; - private static final byte MSG_TYPE = 0x0f; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return AllShipSettingsPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new AllShipSettingsPacket(reader); - } - }); - } - - public static class Ship { - private String mName; - private int mShipType; - private DriveType mDrive; - - public Ship(String name, int shipType, DriveType drive) { - mName = name; - mShipType = shipType; - mDrive = drive; - } - - public String getName() { - return mName; - } - - public int getShipType() { - return mShipType; - } - - public DriveType getDrive() { - return mDrive; - } - - @Override - public String toString() { - Vessel vessel = VesselData.get().getVessel(mShipType); - StringBuilder b = new StringBuilder(); - b .append(mName) - .append(" (") - .append(vessel != null ? vessel.getName() : "UNKNOWN TYPE") - .append(") [") - .append(mDrive) - .append(']'); - return b.toString(); - } - } - - private final Ship[] mShips; - - private AllShipSettingsPacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - mShips = new Ship[Artemis.SHIP_COUNT]; - int subtype = reader.readInt(); - - if (subtype != MSG_TYPE) { - throw new UnexpectedTypeException(subtype, MSG_TYPE); - } - - for (int i = 0; i < Artemis.SHIP_COUNT; i++) { - DriveType drive = DriveType.values()[reader.readInt()]; - int shipType = reader.readInt(); - reader.skip(4); // RJW: UNKNOWN INT (always seems to be 1 0 0 0) - String name = reader.readString(); - mShips[i] = new Ship(name, shipType, drive); - } - } - - public AllShipSettingsPacket(Ship[] ships) { - super(ConnectionType.SERVER, TYPE); - - if (ships.length != Artemis.SHIP_COUNT) { - throw new IllegalArgumentException( - "Must specify " + Artemis.SHIP_COUNT + " ships" - ); - } - - for (Ship ship : ships) { - if (ship == null) { - throw new IllegalArgumentException( - "Must specify " + Artemis.SHIP_COUNT + " ships" - ); - } - - if (ship.getDrive() == null) { - throw new IllegalArgumentException("Must specify ship drive"); - } - - String name = ship.getName(); - - if (name == null || name.trim().length() == 0) { - throw new IllegalArgumentException("Must specify ship name"); - } - } - - mShips = ships; - } - - public Ship getShip(int shipIndex) { - return mShips[shipIndex]; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(MSG_TYPE); - - for (Ship ship : mShips) { - writer.writeInt(ship.mDrive.ordinal()); - writer.writeInt(ship.mShipType); - writer.writeInt(1); // RJW: UNKNOWN INT (always seems to be 1 0 0 0) - writer.writeString(ship.mName); - } - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - for (int i = 0; i < Artemis.SHIP_COUNT; i++) { - b.append("\n\t").append(mShips[i]); - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/ConsoleStatusPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/ConsoleStatusPacket.java deleted file mode 100644 index 898af22..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/ConsoleStatusPacket.java +++ /dev/null @@ -1,118 +0,0 @@ -package net.dhleong.acl.protocol.core.setup; - -import net.dhleong.acl.enums.Console; -import net.dhleong.acl.enums.ConsoleStatus; -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.world.Artemis; - -/** - * Indicates which consoles are taken; received in response to a - * SetConsolePacket or SetShipPacket. - * @author dhleong - */ -public class ConsoleStatusPacket extends BaseArtemisPacket { - private static final int TYPE = 0x19c6e2d4; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return ConsoleStatusPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new ConsoleStatusPacket(reader); - } - }); - } - - private final int shipNumber; - private final ConsoleStatus[] statuses; - - private ConsoleStatusPacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - shipNumber = reader.readInt(); - final Console[] consoleValues = Console.values(); - final ConsoleStatus[] statusValues = ConsoleStatus.values(); - statuses = new ConsoleStatus[consoleValues.length]; - - for (Console console : consoleValues) { - statuses[console.ordinal()] = statusValues[reader.readByte()]; - } - } - - public ConsoleStatusPacket(int shipNumber, ConsoleStatus[] statuses) { - super(ConnectionType.SERVER, TYPE); - - if (shipNumber < 1 || shipNumber > Artemis.SHIP_COUNT) { - throw new IllegalArgumentException( - "Ship number must be between 1 and " + Artemis.SHIP_COUNT - ); - } - - if (statuses.length != ConsoleStatus.values().length) { - throw new IllegalArgumentException( - "Must provide a status for each bridge console" - ); - } - - for (ConsoleStatus status : statuses) { - if (status == null) { - throw new IllegalArgumentException( - "Must provide a status for each bridge console" - ); - } - } - - this.shipNumber = shipNumber; - this.statuses = statuses; - } - - /** - * Returns the ship number whose consoles this packet reports. - */ - public int getShipNumber() { - return shipNumber; - } - - /** - * Get the status for a specific Console - * @param console The desired Console - * @return ConsoleStatus The status of that console - */ - public ConsoleStatus get(Console console) { - if (console == null) { - throw new IllegalArgumentException("You must specify a console"); - } - - return statuses[console.ordinal()]; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(shipNumber); - - for (ConsoleStatus status : statuses) { - writer.writeByte((byte) status.ordinal()); - } - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append("Ship #").append(shipNumber); - - for (Console console : Console.values()) { - ConsoleStatus status = statuses[console.ordinal()]; - b.append("\n\t").append(console).append(": ").append(status); - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/DifficultyPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/DifficultyPacket.java deleted file mode 100644 index c4b887a..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/DifficultyPacket.java +++ /dev/null @@ -1,87 +0,0 @@ -package net.dhleong.acl.protocol.core.setup; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.GameType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; - -public class DifficultyPacket extends BaseArtemisPacket { - private static final int TYPE = 0x3de66711; - public static final int MIN = 1; - public static final int MAX = 11; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return DifficultyPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new DifficultyPacket(reader); - } - }); - } - - private int difficulty; - private GameType gameType; - - private DifficultyPacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - setDifficulty(reader.readInt()); - setGameType(GameType.values()[reader.readInt()]); - } - - public DifficultyPacket(int difficulty, GameType gameType) { - super(ConnectionType.SERVER, TYPE); - setDifficulty(difficulty); - setGameType(gameType); - } - - public int getDifficulty() { - return difficulty; - } - - public void setDifficulty(int difficulty) { - if (difficulty < MIN || difficulty > MAX) { - throw new IllegalArgumentException( - "Invalid difficulty level (" + - difficulty + - "); must be between " + - MIN + - " and " + - MAX - ); - } - - this.difficulty = difficulty; - } - - public GameType getGameType() { - return gameType; - } - - public void setGameType(GameType gameType) { - this.gameType = gameType; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(difficulty).writeInt(gameType.ordinal()); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b .append("difficulty = ") - .append(difficulty) - .append(", game type = ") - .append(gameType); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/ReadyPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/ReadyPacket.java deleted file mode 100644 index 5447051..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/ReadyPacket.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.dhleong.acl.protocol.core.setup; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; - -/** - * Signals to the server that this console is ready to join the game. If the - * ReadyPacket is sent before the game has started, the server will start - * sending updates when the game starts. If the ReadyPacket is sent after the - * game has started, the server sends updates immediately. Once a game has - * ended, the client must send another ReadyPacket before it will be sent - * updates again. - * @author dhleong - */ -public class ReadyPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_READY, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return ReadyPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new ReadyPacket(reader); - } - }); - } - - public ReadyPacket() { - super(TYPE_READY, 0); - } - - private ReadyPacket(PacketReader reader) { - super(TYPE_READY, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - // do nothing - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/ReadyPacket2.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/ReadyPacket2.java deleted file mode 100644 index 6ea6c12..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/ReadyPacket2.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.dhleong.acl.protocol.core.setup; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; - -/** - * The official client sends this sometimes. We currently don't know why. It - * seems to work fine without it. - * @author dhleong - */ -public class ReadyPacket2 extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_READY2, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return ReadyPacket2.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new ReadyPacket2(reader); - } - }); - } - - public ReadyPacket2() { - super(TYPE_READY2, 0); - } - - private ReadyPacket2(PacketReader reader) { - super(TYPE_READY2, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - // do nothing - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/SetConsolePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/SetConsolePacket.java deleted file mode 100644 index ff7068b..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/SetConsolePacket.java +++ /dev/null @@ -1,76 +0,0 @@ -package net.dhleong.acl.protocol.core.setup; - -import net.dhleong.acl.enums.Console; -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.UnexpectedTypeException; -import net.dhleong.acl.protocol.core.ShipActionPacket; - -/** - * Take or relinquish a bridge console. - * @author dhleong - */ -public class SetConsolePacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_SET_CONSOLE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return SetConsolePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new SetConsolePacket(reader); - } - }); - } - - private Console mConsole; - private boolean mSelected; - - /** - * @param console The Console being updated - * @param selected Whether the player is taking this console or not - */ - public SetConsolePacket(Console console, boolean selected) { - super(TYPE_SET_CONSOLE); - - if (console == null) { - throw new IllegalArgumentException("You must specify a console"); - } - - mConsole = console; - mSelected = selected; - } - - private SetConsolePacket(PacketReader reader) { - super(TYPE_SET_CONSOLE); - int subtype = reader.readInt(); - - if (subtype != TYPE_SET_CONSOLE) { - throw new UnexpectedTypeException(subtype, TYPE_SET_CONSOLE); - } - - mConsole = Console.values()[reader.readInt()]; - mSelected = reader.readInt() == 1; - } - - @Override - public void writePayload(PacketWriter writer) { - writer .writeInt(TYPE_SET_CONSOLE) - .writeInt(mConsole.ordinal()) - .writeInt(mSelected ? 1 : 0); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mConsole).append(' ').append(mSelected ? "selected" : "deselected"); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/SetShipPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/SetShipPacket.java deleted file mode 100644 index 96a3d6b..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/SetShipPacket.java +++ /dev/null @@ -1,59 +0,0 @@ -package net.dhleong.acl.protocol.core.setup; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; - -/** - * Set the ship you want to be on. You must send this packet before - * SetConsolePacket. - * @author dhleong - */ -public class SetShipPacket extends ShipActionPacket { - public static final int SHIP_1_ARTEMIS = 0; - public static final int SHIP_2_INTREPID = 1; - public static final int SHIP_3_AEGIS = 2; - public static final int SHIP_4_HORATIO = 3; - public static final int SHIP_5_EXCALIBUR= 4; - public static final int SHIP_6_HERA = 5; - public static final int SHIP_7_CERES = 6; - public static final int SHIP_8_DIANA = 7; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_SET_SHIP, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return SetShipPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new SetShipPacket(reader); - } - }); - } - - /** - * @param shipIndex Index [0,7] of the ship you want to be on. The SHIP_* - * constants are provided for reference, but the names can, of course, be - * changed. - */ - public SetShipPacket(int shipIndex) { - super(TYPE_SET_SHIP, shipIndex); - } - - private SetShipPacket(PacketReader reader) { - super(TYPE_SET_SHIP, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mArg); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/SetShipSettingsPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/SetShipSettingsPacket.java deleted file mode 100644 index cca5e59..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/SetShipSettingsPacket.java +++ /dev/null @@ -1,113 +0,0 @@ -package net.dhleong.acl.protocol.core.setup; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.DriveType; -import net.dhleong.acl.enums.VesselAttribute; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.UnexpectedTypeException; -import net.dhleong.acl.protocol.core.ShipActionPacket; -import net.dhleong.acl.vesseldata.Vessel; -import net.dhleong.acl.vesseldata.VesselData; - - -/** - * Set the name, type and drive of ship your console has selected. - * @author dhleong - */ -public class SetShipSettingsPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_SHIP_SETUP, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return SetShipSettingsPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new SetShipSettingsPacket(reader); - } - }); - } - - private DriveType mDrive; - private int mHullId; - private String mName; - - /** - * Use this constructor if you wish to use a Vessel instance from the - * VesselData class. - */ - public SetShipSettingsPacket(DriveType drive, Vessel vessel, String name) { - super(TYPE_SHIP_SETUP); - - if (vessel == null) { - throw new IllegalArgumentException("You must specify a Vessel"); - } - - if (!vessel.is(VesselAttribute.PLAYER)) { - throw new IllegalArgumentException("Must select a player vessel"); - } - - init(drive, vessel.getId(), name); - } - - /** - * Use this constructor if you wish to use a hull ID. - */ - public SetShipSettingsPacket(DriveType drive, int hullId, String name) { - super(TYPE_SHIP_SETUP); - init(drive, hullId, name); - } - - private SetShipSettingsPacket(PacketReader reader) { - super(TYPE_SHIP_SETUP); - int subtype = reader.readInt(); - - if (subtype != TYPE_SHIP_SETUP) { - throw new UnexpectedTypeException(subtype, TYPE_SHIP_SETUP); - } - - mDrive = DriveType.values()[reader.readInt()]; - mHullId = reader.readInt(); - reader.skip(4); // RJW: UNKNOWN INT (always seems to be 1 0 0 0) - mName = reader.readString(); - } - - private void init(DriveType drive, int hullId, String name) { - if (drive == null) { - throw new IllegalArgumentException("You must specify a drive type"); - } - - if (name == null) { - throw new IllegalArgumentException("You must specify a name"); - } - - mDrive = drive; - mHullId = hullId; - mName = name; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer .writeInt(TYPE_SHIP_SETUP) - .writeInt(mDrive.ordinal()) - .writeInt(mHullId) - .writeInt(1) // RJW: UNKNOWN INT (always seems to be 1 0 0 0) - .writeString(mName); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - Vessel vessel = VesselData.get().getVessel(mHullId); - b .append(mName).append(": ") - .append(vessel != null ? vessel.getName() : "UNKNOWN TYPE") - .append(" [").append(mDrive).append(']'); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/VersionPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/VersionPacket.java deleted file mode 100644 index b297ce0..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/VersionPacket.java +++ /dev/null @@ -1,78 +0,0 @@ -package net.dhleong.acl.protocol.core.setup; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.util.Version; - -/** - * Gives the Artemis server's version number. Send immediately after - * WelcomePacket. - * @author rjwut - */ -public class VersionPacket extends BaseArtemisPacket { - private static final int TYPE = 0xe548e74a; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return VersionPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new VersionPacket(reader); - } - }); - } - - private int mUnknown; - private Version mVersion; - - private VersionPacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - mUnknown = reader.readInt(); - float fVersion = reader.readFloat(); - - if (reader.hasMore()) { - mVersion = new Version( - reader.readInt(), - reader.readInt(), - reader.readInt() - ); - } else { - mVersion = new Version(fVersion); - } - } - - public VersionPacket(Version version) { - super(ConnectionType.SERVER, TYPE); - mVersion = version; - } - - /** - * @return The version number - */ - public Version getVersion() { - return mVersion; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(mUnknown); - mVersion.writeTo(writer); - writer.setVersion(mVersion); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mVersion); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/WelcomePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/WelcomePacket.java deleted file mode 100644 index 2126eb1..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/setup/WelcomePacket.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.dhleong.acl.protocol.core.setup; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; - -/** - * Sent by the server immediately on connection. The receipt of this packet - * indicates a successful connection to the server. - * @author rjwut - */ -public class WelcomePacket extends BaseArtemisPacket { - private static final int TYPE = 0x6d04b3da; - protected static final String MSG = "You have connected to Thom Robertson's Artemis Bridge Simulator. Please connect with an authorized game client."; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return WelcomePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new WelcomePacket(reader); - } - }); - } - - private String msg = MSG; - - private WelcomePacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - msg = reader.readUSASCIIString(); - } - - public WelcomePacket() { - super(ConnectionType.SERVER, TYPE); - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeUSASCIIString(msg); - } - - /** - * Returns the welcome message sent by the server. - */ - public String getMessage() { - return msg; - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(getMessage()); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/ConvertTorpedoPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/ConvertTorpedoPacket.java deleted file mode 100644 index e4bdcbe..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/ConvertTorpedoPacket.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.dhleong.acl.protocol.core.weap; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -/** - * Converts a homing torpedo to energy or vice-versa. - */ -public class ConvertTorpedoPacket extends BaseArtemisPacket { - private static final int TYPE = 0x69CC01D9; - private static final byte SUBTYPE = 0x03; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, SUBTYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return ConvertTorpedoPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new ConvertTorpedoPacket(reader); - } - }); - } - - public enum Direction { - TORPEDO_TO_ENERGY, ENERGY_TO_TORPEDO - } - - private Direction mDirection; - - /** - * @param direction The Direction value indicating the desired conversion type - */ - public ConvertTorpedoPacket(final Direction direction) { - super(ConnectionType.CLIENT, TYPE); - - if (direction == null) { - throw new IllegalArgumentException("You must specify a direction"); - } - - mDirection = direction; - } - - private ConvertTorpedoPacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - int subtype = reader.readInt(); - - if (subtype != SUBTYPE) { - throw new UnexpectedTypeException(subtype, SUBTYPE); - } - - mDirection = Direction.values()[(int)reader.readFloat()]; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(SUBTYPE).writeFloat(mDirection.ordinal()); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mDirection); - } -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/FireBeamPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/FireBeamPacket.java deleted file mode 100644 index 203740f..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/FireBeamPacket.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.dhleong.acl.protocol.core.weap; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.world.ArtemisObject; - -/** - * Manually fire beams. - */ -public class FireBeamPacket extends BaseArtemisPacket { - private static final int TYPE = 0xc2bee72e; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return FireBeamPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new FireBeamPacket(reader); - } - }); - } - - private int mId; - private float mX; - private float mY; - private float mZ; - - /** - * Fire at the given target. The x, y and z parameters indicate the - * coordinates on the target at which to fire. - */ - public FireBeamPacket(ArtemisObject target, float x, float y, float z) { - super(ConnectionType.CLIENT, TYPE); - mId = target.getId(); - mX = x; - mY = y; - mZ = z; - } - - private FireBeamPacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - mId = reader.readInt(); - mX = reader.readFloat(); - mY = reader.readFloat(); - mZ = reader.readFloat(); - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(mId).writeFloat(mX).writeFloat(mY).writeFloat(mZ); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append('#') - .append(mId) - .append(": ") - .append(mX) - .append(',') - .append(mY) - .append(',') - .append(mZ); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/FireTubePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/FireTubePacket.java deleted file mode 100644 index cf0db6b..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/FireTubePacket.java +++ /dev/null @@ -1,54 +0,0 @@ -package net.dhleong.acl.protocol.core.weap; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; -import net.dhleong.acl.world.Artemis; - -/** - * Fire whatever's in the given tube. - * @author dhleong - */ -public class FireTubePacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_FIRE_TUBE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return FireTubePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new FireTubePacket(reader); - } - }); - } - - /** - * @param tube The index of the tube to fire, [0 - Artemis.MAX_TUBES) - */ - public FireTubePacket(int tube) { - super(TYPE_FIRE_TUBE, tube); - - if (tube < 0 || tube >= Artemis.MAX_TUBES) { - throw new IndexOutOfBoundsException( - "Invalid tube index: " + tube - ); - } - } - - private FireTubePacket(PacketReader reader) { - super(TYPE_FIRE_TUBE, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mArg); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/LoadTubePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/LoadTubePacket.java deleted file mode 100644 index 93b7af3..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/LoadTubePacket.java +++ /dev/null @@ -1,95 +0,0 @@ -package net.dhleong.acl.protocol.core.weap; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.OrdnanceType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; -import net.dhleong.acl.world.Artemis; - -/** - * Load a type of torpedo into a tube. - * @author dhleong - */ -public class LoadTubePacket extends BaseArtemisPacket { - private static final int TYPE = 0x69CC01D9; - private static final byte SUBTYPE = 0x02; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, SUBTYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return LoadTubePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new LoadTubePacket(reader); - } - }); - } - - private int mTube; - private OrdnanceType mOrdnanceType; - private int mUnknown0; - private int mUnknown1; - - /** - * @param tube Index of tube to load, [0 - Artemis.MAX_TUBES) - * @param torpedoType OrdnanceType value indicating what to load - */ - public LoadTubePacket(int tube, OrdnanceType ordnanceType) { - super(ConnectionType.CLIENT, TYPE); - - if (tube < 0 || tube >= Artemis.MAX_TUBES) { - throw new IndexOutOfBoundsException( - "Invalid tube index: " + tube - ); - } - - if (ordnanceType == null) { - throw new IllegalArgumentException( - "You must specify an ordnance type" - ); - } - - mTube = tube; - mOrdnanceType = ordnanceType; - } - - private LoadTubePacket(PacketReader reader) { - super(ConnectionType.CLIENT, TYPE); - int subtype = reader.readInt(); - - if (subtype != SUBTYPE) { - throw new UnexpectedTypeException(subtype, SUBTYPE); - } - - mTube = reader.readInt(); - mOrdnanceType = OrdnanceType.values()[reader.readInt()]; - mUnknown0 = reader.readInt(); - mUnknown1 = reader.readInt(); - } - - @Override - protected void writePayload(PacketWriter writer) { - writer .writeInt(SUBTYPE) - .writeInt(mTube) - .writeInt(mOrdnanceType.ordinal()) - .writeInt(mUnknown0) - .writeInt(mUnknown1); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append("Tube #").append(mTube).append(": ").append(mOrdnanceType); - b.append("\nUnknown: ").append(mUnknown0).append("/").append(mUnknown1); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/SetBeamFreqPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/SetBeamFreqPacket.java deleted file mode 100644 index 29a4e1a..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/SetBeamFreqPacket.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.dhleong.acl.protocol.core.weap; - -import net.dhleong.acl.enums.BeamFrequency; -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; - -/** - * Sets the frequency at which to tune the beams. - */ -public class SetBeamFreqPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_SET_BEAMFREQ, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return SetBeamFreqPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new SetBeamFreqPacket(reader); - } - }); - } - - /** - * @param frequency The desired beam frequency - */ - public SetBeamFreqPacket(BeamFrequency frequency) { - super(TYPE_SET_BEAMFREQ, frequency != null ? frequency.ordinal(): -1); - - if (frequency == null) { - throw new IllegalArgumentException( - "You must specify a beam frequency" - ); - } - } - - private SetBeamFreqPacket(PacketReader reader) { - super(TYPE_SET_BEAMFREQ, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(BeamFrequency.values()[mArg]); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/SetWeaponsTargetPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/SetWeaponsTargetPacket.java deleted file mode 100644 index 0ce6b96..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/SetWeaponsTargetPacket.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.dhleong.acl.protocol.core.weap; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; -import net.dhleong.acl.world.ArtemisObject; - -/** - * Set the target for our weapons. - * @author dhleong - */ -public class SetWeaponsTargetPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_SET_TARGET, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return SetWeaponsTargetPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new SetWeaponsTargetPacket(reader); - } - }); - } - - /** - * @param target The desired target (or null to release target lock) - */ - public SetWeaponsTargetPacket(ArtemisObject target) { - super(TYPE_SET_TARGET, target == null ? 1 : target.getId()); - } - - private SetWeaponsTargetPacket(PacketReader reader) { - super(TYPE_SET_TARGET, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append('#').append(mArg); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/ToggleAutoBeamsPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/ToggleAutoBeamsPacket.java deleted file mode 100644 index 1e4d8ba..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/ToggleAutoBeamsPacket.java +++ /dev/null @@ -1,44 +0,0 @@ -package net.dhleong.acl.protocol.core.weap; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; - -/** - * Toggles auto beams on/off. - * @author rjwut - */ -public class ToggleAutoBeamsPacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_TOGGLE_AUTO_BEAMS, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return ToggleAutoBeamsPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new ToggleAutoBeamsPacket(reader); - } - }); - } - - public ToggleAutoBeamsPacket() { - super(TYPE_TOGGLE_AUTO_BEAMS, 0); - } - - private ToggleAutoBeamsPacket(PacketReader reader) { - super(TYPE_TOGGLE_AUTO_BEAMS, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - // do nothing - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/UnloadTubePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/UnloadTubePacket.java deleted file mode 100644 index 2b66294..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/weap/UnloadTubePacket.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.dhleong.acl.protocol.core.weap; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.core.ShipActionPacket; -import net.dhleong.acl.world.Artemis; - -/** - * Unloads the indicated tube. - */ -public class UnloadTubePacket extends ShipActionPacket { - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.CLIENT, TYPE, TYPE_UNLOAD_TUBE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return UnloadTubePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new UnloadTubePacket(reader); - } - }); - } - - /** - * @param tube Index of the tube to unload, [0 - Artemis.MAX_TUBES) - */ - public UnloadTubePacket(int tube) { - super(TYPE_UNLOAD_TUBE, tube); - - if (tube < 0 || tube >= Artemis.MAX_TUBES) { - throw new IndexOutOfBoundsException( - "Invalid tube index: " + tube - ); - } - } - - private UnloadTubePacket(PacketReader reader) { - super(TYPE_UNLOAD_TUBE, reader); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mArg); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/AbstractObjectParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/AbstractObjectParser.java deleted file mode 100644 index 32fb199..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/AbstractObjectParser.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.world.ArtemisObject; - -public abstract class AbstractObjectParser implements ObjectParser { - protected abstract ArtemisObject parseImpl(PacketReader reader); - - protected ObjectType objectType; - - protected AbstractObjectParser(ObjectType objectType) { - this.objectType = objectType; - } - - @Override - public final ArtemisObject parse(PacketReader reader) { - byte typeId = reader.hasMore() ? reader.readByte() : 0; - - if (typeId == 0) { - return null; // no more objects to parse - } - - ObjectType parsedObjectType = ObjectType.fromId(typeId); - - if (objectType != parsedObjectType) { - throw new IllegalStateException("Expected to parse " + objectType + - " but received " + parsedObjectType); - } - - reader.startObject(objectType, getBits()); - ArtemisObject obj = parseImpl(reader); - obj.setUnknownProps(reader.getUnknownObjectProps()); - return obj; - } - - @Override - public void appendDetail(ArtemisObject obj, StringBuilder b) { - b.append("\nObject #").append(obj.getId()).append(obj); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/AnomalyParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/AnomalyParser.java deleted file mode 100644 index 174802a..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/AnomalyParser.java +++ /dev/null @@ -1,55 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.enums.Upgrade; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.world.ArtemisAnomaly; -import net.dhleong.acl.world.ArtemisObject; - -public class AnomalyParser extends AbstractObjectParser { - private enum Bit { - X, - Y, - Z, - UPGRADE - } - private static final Bit[] BITS = Bit.values(); - - AnomalyParser() { - super(ObjectType.ANOMALY); - } - - @Override - public Bit[] getBits() { - return BITS; - } - - @Override - protected ArtemisAnomaly parseImpl(PacketReader reader) { - ArtemisAnomaly anomaly = new ArtemisAnomaly(reader.getObjectId()); - anomaly.setX(reader.readFloat(Bit.X, Float.MIN_VALUE)); - anomaly.setY(reader.readFloat(Bit.Y, Float.MIN_VALUE)); - anomaly.setZ(reader.readFloat(Bit.Z, Float.MIN_VALUE)); - - if (reader.has(Bit.UPGRADE)) { - anomaly.setUpgrade(Upgrade.values()[reader.readInt()]); - } - - return anomaly; - } - - @Override - public void write(ArtemisObject obj, PacketWriter writer) { - ArtemisAnomaly anomaly = (ArtemisAnomaly) obj; - writer.writeFloat(Bit.X, anomaly.getX(), Float.MIN_VALUE); - writer.writeFloat(Bit.Y, anomaly.getY(), Float.MIN_VALUE); - writer.writeFloat(Bit.Z, anomaly.getZ(), Float.MIN_VALUE); - - Upgrade upgrade = anomaly.getUpgrade(); - - if (upgrade != null) { - writer.writeInt(Bit.UPGRADE, upgrade.ordinal(), -1); - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/BaseParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/BaseParser.java deleted file mode 100644 index 5055709..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/BaseParser.java +++ /dev/null @@ -1,78 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.world.ArtemisBase; -import net.dhleong.acl.world.ArtemisObject; - -public class BaseParser extends AbstractObjectParser { - private enum Bit { - NAME, - FORE_SHIELDS, - AFT_SHIELDS, - INDEX, - HULL_ID, - X, - Y, - Z, - - UNK_2_1, - UNK_2_2, - UNK_2_3, - UNK_2_4, - UNK_2_5, - UNK_2_6 - } - private static final Bit[] BITS = Bit.values(); - - BaseParser() { - super(ObjectType.BASE); - } - - @Override - public Bit[] getBits() { - return BITS; - } - - @Override - protected ArtemisBase parseImpl(PacketReader reader) { - ArtemisBase base = new ArtemisBase(reader.getObjectId()); - base.setName(reader.readString(Bit.NAME)); - float shieldsFront = reader.readFloat(Bit.FORE_SHIELDS, Float.MIN_VALUE); - float shieldsRear = reader.readFloat(Bit.AFT_SHIELDS, Float.MIN_VALUE); - base.setIndex(reader.readInt(Bit.INDEX, -1)); - base.setHullId(reader.readInt(Bit.HULL_ID, -1)); - base.setShieldsFront(shieldsFront); - base.setShieldsRear(shieldsRear); - base.setX(reader.readFloat(Bit.X, Float.MIN_VALUE)); - base.setY(reader.readFloat(Bit.Y, Float.MIN_VALUE)); - base.setZ(reader.readFloat(Bit.Z, Float.MIN_VALUE)); - reader.readObjectUnknown(Bit.UNK_2_1, 4); - reader.readObjectUnknown(Bit.UNK_2_2, 4); - reader.readObjectUnknown(Bit.UNK_2_3, 4); - reader.readObjectUnknown(Bit.UNK_2_4, 4); - reader.readObjectUnknown(Bit.UNK_2_5, 1); - reader.readObjectUnknown(Bit.UNK_2_6, 1); - return base; - } - - @Override - public void write(ArtemisObject obj, PacketWriter writer) { - ArtemisBase base = (ArtemisBase) obj; - writer .writeString(Bit.NAME, base.getName()) - .writeFloat(Bit.FORE_SHIELDS, base.getShieldsFront(), Float.MIN_VALUE) - .writeFloat(Bit.AFT_SHIELDS, base.getShieldsRear(), Float.MIN_VALUE) - .writeInt(Bit.INDEX, base.getIndex(), -1) - .writeInt(Bit.HULL_ID, base.getHullId(), -1) - .writeFloat(Bit.X, base.getX(), Float.MIN_VALUE) - .writeFloat(Bit.Y, base.getY(), Float.MIN_VALUE) - .writeFloat(Bit.Z, base.getZ(), Float.MIN_VALUE) - .writeUnknown(Bit.UNK_2_1) - .writeUnknown(Bit.UNK_2_2) - .writeUnknown(Bit.UNK_2_3) - .writeUnknown(Bit.UNK_2_4) - .writeUnknown(Bit.UNK_2_5) - .writeUnknown(Bit.UNK_2_6); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/BeamFiredPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/BeamFiredPacket.java deleted file mode 100644 index 872ccae..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/BeamFiredPacket.java +++ /dev/null @@ -1,190 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; - -public class BeamFiredPacket extends BaseArtemisPacket { - private static final int TYPE = 0xb83fd2c4; - private static final byte[] DEFAULT_UNKNOWN_VALUE = { 0, 0, 0, 0 }; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return BeamFiredPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new BeamFiredPacket(reader); - } - }); - } - - private int mBeamId; - private int mBeamPortIndex; - private int mOriginId; - private int mTargetId; - private float mImpactX; - private float mImpactY; - private float mImpactZ; - private boolean mAutoFired; - private byte[] unknown1 = DEFAULT_UNKNOWN_VALUE; - private byte[] unknown2 = DEFAULT_UNKNOWN_VALUE; - private byte[] unknown3 = DEFAULT_UNKNOWN_VALUE; - private byte[] unknown4 = DEFAULT_UNKNOWN_VALUE; - - private BeamFiredPacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - mBeamId = reader.readInt(); - unknown1 = reader.readBytes(4); - unknown2 = reader.readBytes(4); - mBeamPortIndex = reader.readInt(); - unknown3 = reader.readBytes(4); - unknown4 = reader.readBytes(4); - mOriginId = reader.readInt(); - mTargetId = reader.readInt(); - mImpactX = reader.readFloat(); - mImpactY = reader.readFloat(); - mImpactZ = reader.readFloat(); - mAutoFired = reader.readInt() == 0; - } - - public BeamFiredPacket(int beamId) { - super(ConnectionType.SERVER, TYPE); - mBeamId = beamId; - } - - /** - * The beam's ID. - */ - public int getBeamId() { - return mBeamId; - } - - /** - * The index of the port from which this beam was fired, which is the same - * as the index of the corresponding <beam_port> entry in - * the shipData.xml file. (So 0 corresponds to the zeroeth - * <beam_port> entry for that ship in shipData.xml.) - */ - public int getBeamPortIndex() { - return mBeamPortIndex; - } - - public void setBeamPortIndex(int beamPortIndex) { - mBeamPortIndex = beamPortIndex; - } - - /** - * The ID of the object from which the beam was fired. - */ - public int getOriginId() { - return mOriginId; - } - - public void setOriginId(int originId) { - mOriginId = originId; - } - - /** - * The ID of the object being fired upon. - */ - public int getTargetId() { - return mTargetId; - } - - public void setTargetId(int targetId) { - mTargetId = targetId; - } - - /** - * The X-coordinate (relative to the center of the target) of the impact - * point. This is used to determine the endpoint for the beam. A negative - * value means an impact on the target's starboard; a positive value means - * an impact on the target's port. - */ - public float getImpactX() { - return mImpactX; - } - - public void setImpactX(float impactX) { - mImpactX = impactX; - } - - /** - * The Y-coordinate (relative to the center of the target) of the impact - * point. This is used to determine the endpoint for the beam. A negative - * value means an impact on the target's ventral (bottom) side; a positive - * value means an impact on the target's dorsal (top) side. - */ - public float getImpactY() { - return mImpactY; - } - - public void setImpactY(float impactY) { - mImpactY = impactY; - } - - /** - * The Z-coordinate (relative to the center of the target) of the impact - * point. This is used to determine the endpoint for the beam. A negative - * value means an impact on the target's aft; a positive value means an - * impact on the target's fore. - */ - public float getImpactZ() { - return mImpactZ; - } - - public void setImpactZ(float impactZ) { - mImpactZ = impactZ; - } - - /** - * Returns true if the beam was auto-fired; false if it was fired manually. - */ - public boolean isAutoFired() { - return mAutoFired; - } - - public void setAutoFired(boolean autoFired) { - mAutoFired = autoFired; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer - .writeInt(mBeamId) - .writeBytes(unknown1) - .writeBytes(unknown2) - .writeInt(mBeamPortIndex) - .writeBytes(unknown3) - .writeBytes(unknown4) - .writeInt(mOriginId) - .writeInt(mTargetId) - .writeFloat(mImpactX) - .writeFloat(mImpactY) - .writeFloat(mImpactZ) - .writeInt(mAutoFired ? 0 : 1); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b - .append("Beam #") - .append(mBeamId) - .append(" port ") - .append(mBeamPortIndex) - .append(" from ship #") - .append(mOriginId) - .append(" to ship #") - .append(mTargetId); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/CreatureParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/CreatureParser.java deleted file mode 100644 index 6b405bd..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/CreatureParser.java +++ /dev/null @@ -1,87 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.CreatureType; -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.world.ArtemisCreature; -import net.dhleong.acl.world.ArtemisObject; - -public class CreatureParser extends AbstractObjectParser { - private enum Bit { - X, - Y, - Z, - NAME, - HEADING, - PITCH, - ROLL, - CREATURE_TYPE, - - UNK_2_1, - UNK_2_2, - UNK_2_3, - UNK_2_4, - UNK_2_5, - UNK_2_6 - } - private static final Bit[] BITS = Bit.values(); - - CreatureParser() { - super(ObjectType.CREATURE); - } - - @Override - public Bit[] getBits() { - return BITS; - } - - @Override - protected ArtemisCreature parseImpl(PacketReader reader) { - final ArtemisCreature creature = new ArtemisCreature(reader.getObjectId()); - creature.setX(reader.readFloat(Bit.X, Float.MIN_VALUE)); - creature.setY(reader.readFloat(Bit.Y, Float.MIN_VALUE)); - creature.setZ(reader.readFloat(Bit.Z, Float.MIN_VALUE)); - creature.setName(reader.readString(Bit.NAME)); - creature.setHeading(reader.readFloat(Bit.HEADING, Float.MIN_VALUE)); - creature.setPitch(reader.readFloat(Bit.PITCH, Float.MIN_VALUE)); - creature.setRoll(reader.readFloat(Bit.ROLL, Float.MIN_VALUE)); - - if (reader.has(Bit.CREATURE_TYPE)) { - creature.setCreatureType(CreatureType.values()[reader.readInt()]); - } - - reader.readObjectUnknown(Bit.UNK_2_1, 4); - reader.readObjectUnknown(Bit.UNK_2_2, 4); - reader.readObjectUnknown(Bit.UNK_2_3, 4); - reader.readObjectUnknown(Bit.UNK_2_4, 4); - reader.readObjectUnknown(Bit.UNK_2_5, 4); - reader.readObjectUnknown(Bit.UNK_2_6, 4); - return creature; - } - - @Override - public void write(ArtemisObject obj, PacketWriter writer) { - ArtemisCreature creature = (ArtemisCreature) obj; - writer .writeFloat(Bit.X, creature.getX(), Float.MIN_VALUE) - .writeFloat(Bit.Y, creature.getY(), Float.MIN_VALUE) - .writeFloat(Bit.Z, creature.getZ(), Float.MIN_VALUE) - .writeString(Bit.NAME, creature.getName()) - .writeFloat(Bit.HEADING, creature.getHeading(), Float.MIN_VALUE) - .writeFloat(Bit.PITCH, creature.getPitch(), Float.MIN_VALUE) - .writeFloat(Bit.ROLL, creature.getRoll(), Float.MIN_VALUE); - - CreatureType creatureType = creature.getCreatureType(); - - if (creatureType != null) { - writer.writeInt(Bit.CREATURE_TYPE, creatureType.ordinal(), -1); - } - - writer .writeUnknown(Bit.UNK_2_1) - .writeUnknown(Bit.UNK_2_2) - .writeUnknown(Bit.UNK_2_3) - .writeUnknown(Bit.UNK_2_4) - .writeUnknown(Bit.UNK_2_5) - .writeUnknown(Bit.UNK_2_6); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/DestroyObjectPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/DestroyObjectPacket.java deleted file mode 100644 index 295e531..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/DestroyObjectPacket.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.world.ArtemisObject; - -/** - * Sent by the server when an object is destroyed. - */ -public class DestroyObjectPacket extends BaseArtemisPacket { - private static final int TYPE = 0xcc5a3e30; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return DestroyObjectPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new DestroyObjectPacket(reader); - } - }); - } - - private final ObjectType mTargetType; - private final int mTarget; - - private DestroyObjectPacket(PacketReader reader) { - this(ObjectType.fromId(reader.readByte()), reader.readInt()); - } - - public DestroyObjectPacket(ArtemisObject obj) { - this(obj.getType(), obj.getId()); - } - - public DestroyObjectPacket(ObjectType targetType, int id) { - super(ConnectionType.SERVER, TYPE); - mTargetType = targetType; - mTarget = id; - } - - /** - * The ObjectType of the destroyed object - */ - public ObjectType getTargetType() { - return mTargetType; - } - - /** - * The destroyed object's ID - */ - public int getTarget() { - return mTarget; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeByte(mTargetType.getId()).writeInt(mTarget); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append('#').append(mTarget).append(" (").append(mTargetType).append(')'); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/DroneParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/DroneParser.java deleted file mode 100644 index c908fb7..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/DroneParser.java +++ /dev/null @@ -1,60 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.world.ArtemisDrone; -import net.dhleong.acl.world.ArtemisObject; - -public class DroneParser extends AbstractObjectParser { - private enum Bit { - UNK_1_1, - X, - UNK_1_3, - Z, - UNK_1_5, - Y, - HEADING, - UNK_1_8 - } - private static final Bit[] BITS = Bit.values(); - private static final byte[] ZERO_ARR = { (byte) 0 }; - - DroneParser() { - super(ObjectType.DRONE); - } - - @Override - public Bit[] getBits() { - return BITS; - } - - @Override - protected ArtemisDrone parseImpl(PacketReader reader) { - final ArtemisDrone drone = new ArtemisDrone(reader.getObjectId()); - reader.readObjectUnknown("UNK", 1); - reader.readObjectUnknown(Bit.UNK_1_1, 4); - drone.setX(reader.readFloat(Bit.X, Float.MIN_VALUE)); - reader.readObjectUnknown(Bit.UNK_1_3, 4); - drone.setZ(reader.readFloat(Bit.Z, Float.MIN_VALUE)); - reader.readObjectUnknown(Bit.UNK_1_5, 4); - drone.setY(reader.readFloat(Bit.Y, Float.MIN_VALUE)); - drone.setHeading(reader.readFloat(Bit.HEADING, Float.MIN_VALUE)); - reader.readObjectUnknown(Bit.UNK_1_8, 4); - return drone; - } - - @Override - public void write(ArtemisObject obj, PacketWriter writer) { - ArtemisDrone drone = (ArtemisDrone) obj; - writer .writeUnknown("UNK", ZERO_ARR) - .writeUnknown(Bit.UNK_1_1) - .writeFloat(Bit.X, drone.getX(), Float.MIN_VALUE) - .writeUnknown(Bit.UNK_1_3) - .writeFloat(Bit.Z, drone.getZ(), Float.MIN_VALUE) - .writeUnknown(Bit.UNK_1_5) - .writeFloat(Bit.Y, drone.getY(), Float.MIN_VALUE) - .writeFloat(Bit.HEADING, drone.getHeading(), Float.MIN_VALUE) - .writeUnknown(Bit.UNK_1_8); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/EngParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/EngParser.java deleted file mode 100644 index 10fadb0..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/EngParser.java +++ /dev/null @@ -1,110 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import java.util.Arrays; - -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.world.Artemis; -import net.dhleong.acl.world.ArtemisObject; -import net.dhleong.acl.world.ArtemisPlayer; - -public class EngParser extends AbstractObjectParser { - private enum Bit { - HEAT_BEAMS, - HEAT_TORPEDOES, - HEAT_SENSORS, - HEAT_MANEUVERING, - HEAT_IMPULSE, - HEAT_WARP_OR_JUMP, - HEAT_FORE_SHIELDS, - HEAT_AFT_SHEILDS, - - ENERGY_BEAMS, - ENERGY_TORPEDOES, - ENERGY_SENSORS, - ENERGY_MANEUVERING, - ENERGY_IMPULSE, - ENERGY_WARP_OR_JUMP, - ENERGY_FORE_SHIELDS, - ENERGY_AFT_SHIELDS, - - COOLANT_BEAMS, - COOLANT_TORPEDOES, - COOLANT_SENSORS, - COOLANT_MANEUVERING, - COOLANT_IMPULSE, - COOLANT_WARP_OR_JUMP, - COOLANT_FORE_SHIELDS, - COOLANT_AFT_SHIELDS - } - private static final Bit[] BITS = Bit.values(); - private static final Bit[] HEAT; - private static final Bit[] ENERGY; - private static final Bit[] COOLANT; - - static { - HEAT = Arrays.copyOfRange(BITS, Bit.HEAT_BEAMS.ordinal(), Bit.ENERGY_BEAMS.ordinal()); - ENERGY = Arrays.copyOfRange(BITS, Bit.ENERGY_BEAMS.ordinal(), Bit.COOLANT_BEAMS.ordinal()); - COOLANT = Arrays.copyOfRange(BITS, Bit.COOLANT_BEAMS.ordinal(), Bit.values().length); - } - - EngParser() { - super(ObjectType.ENGINEERING_CONSOLE); - } - - @Override - public Bit[] getBits() { - return BITS; - } - - @Override - protected ArtemisPlayer parseImpl(PacketReader reader) { - float[] heat = new float[ Artemis.SYSTEM_COUNT ]; - float[] sysEnergy = new float[ Artemis.SYSTEM_COUNT ]; - int[] coolant = new int[ Artemis.SYSTEM_COUNT ]; - reader.skip(1); - - for (int i = 0; i < Artemis.SYSTEM_COUNT; i++) { - heat[i] = reader.readFloat(HEAT[i], -1); - } - - for (int i = 0; i < Artemis.SYSTEM_COUNT; i++) { - sysEnergy[i] = reader.readFloat(ENERGY[i], -1); - } - - for (int i = 0; i < Artemis.SYSTEM_COUNT; i++) { - coolant[i] = reader.readByte(COOLANT[i], (byte) -1); - } - - ArtemisPlayer player = new ArtemisPlayer(reader.getObjectId()); - - for (int i = 0; i < Artemis.SYSTEM_COUNT; i++) { - ShipSystem sys = ShipSystem.values()[i]; - player.setSystemHeat(sys, heat[i]); - player.setSystemEnergy(sys, sysEnergy[i]); - player.setSystemCoolant(sys, coolant[i]); - } - - return player; - } - - @Override - public void write(ArtemisObject obj, PacketWriter writer) { - ArtemisPlayer player = (ArtemisPlayer) obj; - writer.writeObjByte((byte) 0); - - for (ShipSystem sys : ShipSystem.values()) { - writer.writeFloat(HEAT[sys.ordinal()], player.getSystemHeat(sys), -1); - } - - for (ShipSystem sys : ShipSystem.values()) { - writer.writeFloat(ENERGY[sys.ordinal()], player.getSystemEnergy(sys), -1); - } - - for (ShipSystem sys : ShipSystem.values()) { - writer.writeByte(COOLANT[sys.ordinal()], (byte) player.getSystemCoolant(sys), (byte) -1); - } - } -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/GenericMeshParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/GenericMeshParser.java deleted file mode 100644 index b23d781..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/GenericMeshParser.java +++ /dev/null @@ -1,141 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.world.ArtemisMesh; -import net.dhleong.acl.world.ArtemisObject; - -public class GenericMeshParser extends AbstractObjectParser { - private enum Bit { - X, - Y, - Z, - UNK_1_4, - UNK_1_5, - UNK_1_6, - UNK_1_7, - UNK_1_8, - - UNK_2_1, - UNK_2_2, - NAME, - MESH_PATH, - TEXTURE_PATH, - UNK_2_6, - UNK_2_7, - UNK_2_8, - - UNK_3_1, - UNK_3_2, - COLOR, - FORE_SHIELDS, - AFT_SHIELDS, - UNK_3_6, - UNK_3_7, - UNK_3_8, - - UNK_4_1, - UNK_4_2 - } - private static final Bit[] BITS = Bit.values(); - - GenericMeshParser() { - super(ObjectType.GENERIC_MESH); - } - - @Override - public Bit[] getBits() { - return BITS; - } - - @Override - protected ArtemisMesh parseImpl(PacketReader reader) { - float x = reader.readFloat(Bit.X, Float.MIN_VALUE); - float y = reader.readFloat(Bit.Y, Float.MIN_VALUE); - float z = reader.readFloat(Bit.Z, Float.MIN_VALUE); - - reader.readObjectUnknown(Bit.UNK_1_4, 4); - reader.readObjectUnknown(Bit.UNK_1_5, 4); - reader.readObjectUnknown(Bit.UNK_1_6, 8); - reader.readObjectUnknown(Bit.UNK_1_7, 4); - reader.readObjectUnknown(Bit.UNK_1_8, 4); - reader.readObjectUnknown(Bit.UNK_2_1, 4); - reader.readObjectUnknown(Bit.UNK_2_2, 8); - - final ArtemisMesh mesh = new ArtemisMesh(reader.getObjectId()); - mesh.setName(reader.readString(Bit.NAME)); - mesh.setX(x); - mesh.setY(y); - mesh.setZ(z); - mesh.setMesh(reader.readString(Bit.TEXTURE_PATH)); // wtf?! - mesh.setTexture(reader.readString(Bit.TEXTURE_PATH)); - - reader.readObjectUnknown(Bit.UNK_2_6, 4); - reader.readObjectUnknown(Bit.UNK_2_7, 2); - reader.readObjectUnknown(Bit.UNK_2_8, 1); - reader.readObjectUnknown(Bit.UNK_3_1, 1); - reader.readObjectUnknown(Bit.UNK_3_2, 1); - - boolean hasColor = reader.has(Bit.COLOR); - - // color - if (hasColor) { - mesh.setARGB( - 1.0f, - reader.readFloat(), - reader.readFloat(), - reader.readFloat() - ); - } - - mesh.setFakeShields( - reader.readFloat(Bit.FORE_SHIELDS, Float.MIN_VALUE), - reader.readFloat(Bit.AFT_SHIELDS, Float.MIN_VALUE) - ); - - reader.readObjectUnknown(Bit.UNK_3_6, 1); - reader.readObjectUnknown(Bit.UNK_3_7, 4); - reader.readObjectUnknown(Bit.UNK_3_8, 4); - reader.readObjectUnknown(Bit.UNK_4_1, 4); - reader.readObjectUnknown(Bit.UNK_4_2, 4); - return mesh; - } - - @Override - public void write(ArtemisObject obj, PacketWriter writer) { - ArtemisMesh mesh = (ArtemisMesh) obj; - writer .writeFloat(Bit.X, mesh.getX(), Float.MIN_VALUE) - .writeFloat(Bit.Y, mesh.getY(), Float.MIN_VALUE) - .writeFloat(Bit.Z, mesh.getZ(), Float.MIN_VALUE) - .writeUnknown(Bit.UNK_1_4) - .writeUnknown(Bit.UNK_1_5) - .writeUnknown(Bit.UNK_1_6) - .writeUnknown(Bit.UNK_1_7) - .writeUnknown(Bit.UNK_1_8) - .writeUnknown(Bit.UNK_2_1) - .writeUnknown(Bit.UNK_2_2) - .writeString(Bit.NAME, mesh.getName()) - .writeString(Bit.TEXTURE_PATH, mesh.getMesh()) - .writeString(Bit.TEXTURE_PATH, mesh.getTexture()) - .writeUnknown(Bit.UNK_2_6) - .writeUnknown(Bit.UNK_2_7) - .writeUnknown(Bit.UNK_2_8) - .writeUnknown(Bit.UNK_3_1) - .writeUnknown(Bit.UNK_3_2); - - if (mesh.hasColor()) { - writer .writeFloat(((float) mesh.getRed()) / 255) - .writeFloat(((float) mesh.getGreen()) / 255) - .writeFloat(((float) mesh.getBlue()) / 255); - } - - writer .writeFloat(Bit.FORE_SHIELDS, mesh.getShieldsFront(), Float.MIN_VALUE) - .writeFloat(Bit.AFT_SHIELDS, mesh.getShieldsRear(), Float.MIN_VALUE) - .writeUnknown(Bit.UNK_3_6) - .writeUnknown(Bit.UNK_3_7) - .writeUnknown(Bit.UNK_3_8) - .writeUnknown(Bit.UNK_4_1) - .writeUnknown(Bit.UNK_4_2); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/IntelPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/IntelPacket.java deleted file mode 100644 index 87b2f51..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/IntelPacket.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; - -/** - * Provides intel on another vessel, typically as the result of a level 2 scan. - * @author rjwut - */ -public class IntelPacket extends BaseArtemisPacket { - private static final int TYPE = 0xee665279; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return IntelPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new IntelPacket(reader); - } - }); - } - - private final int mId; - private final String mIntel; - - private IntelPacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - mId = reader.readInt(); - reader.readUnknown("Unknown", 1); - mIntel = reader.readString(); - } - - /** - * The ID of the ship in question - */ - public int getId() { - return mId; - } - - /** - * The intel on that ship, as human-readable text - */ - public String getIntel() { - return mIntel; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(mId).writeByte((byte) 3).writeString(mIntel); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append("Obj #").append(mId).append(": ").append(mIntel); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/NebulaParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/NebulaParser.java deleted file mode 100644 index 5615ea8..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/NebulaParser.java +++ /dev/null @@ -1,60 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.world.ArtemisNebula; -import net.dhleong.acl.world.ArtemisObject; - -public class NebulaParser extends AbstractObjectParser { - private enum Bit { - X, - Y, - Z, - RED, - GREEN, - BLUE, - UNK_1_7, - UNK_1_8 - } - private static final Bit[] BITS = Bit.values(); - - NebulaParser() { - super(ObjectType.NEBULA); - } - - @Override - public Bit[] getBits() { - return BITS; - } - - @Override - protected ArtemisNebula parseImpl(PacketReader reader) { - final ArtemisNebula obj = new ArtemisNebula(reader.getObjectId()); - reader.readObjectUnknown(Bit.UNK_1_7, 4); - reader.readObjectUnknown(Bit.UNK_1_8, 4); - obj.setX(reader.readFloat(Bit.X, Float.MIN_VALUE)); - obj.setY(reader.readFloat(Bit.Y, Float.MIN_VALUE)); - obj.setZ(reader.readFloat(Bit.Z, Float.MIN_VALUE)); - obj.setARGB( - 0, - reader.readFloat(Bit.RED, Float.MIN_VALUE), - reader.readFloat(Bit.GREEN, Float.MIN_VALUE), - reader.readFloat(Bit.BLUE, Float.MIN_VALUE) - ); - return obj; - } - - @Override - public void write(ArtemisObject obj, PacketWriter writer) { - ArtemisNebula nObj = (ArtemisNebula) obj; - writer .writeFloat(Bit.X, nObj.getX(), Float.MIN_VALUE) - .writeFloat(Bit.Y, nObj.getY(), Float.MIN_VALUE) - .writeFloat(Bit.Z, nObj.getZ(), Float.MIN_VALUE) - .writeFloat(Bit.RED, nObj.getRed() / 255f, Float.MIN_VALUE) - .writeFloat(Bit.GREEN, nObj.getGreen() / 255f, Float.MIN_VALUE) - .writeFloat(Bit.BLUE, nObj.getBlue() / 255f, Float.MIN_VALUE) - .writeUnknown(Bit.UNK_1_7) - .writeUnknown(Bit.UNK_1_8); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/NpcShipParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/NpcShipParser.java deleted file mode 100644 index 77e3f7c..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/NpcShipParser.java +++ /dev/null @@ -1,217 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.BeamFrequency; -import net.dhleong.acl.enums.FactionAttribute; -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.vesseldata.Vessel; -import net.dhleong.acl.world.ArtemisNpc; -import net.dhleong.acl.world.ArtemisObject; - -public class NpcShipParser extends AbstractObjectParser { - private enum Bit { - NAME, - IMPULSE, - UNK_1_3, - MAX_IMPULSE, - MAX_TURN_RATE, - IS_ENEMY, - SHIP_TYPE, - X, - - Y, - Z, - PITCH, - ROLL, - HEADING, - VELOCITY, - SURRENDERED, - UNK_2_8, - - FORE_SHIELD, - FORE_SHIELD_MAX, - AFT_SHIELD, - AFT_SHIELD_MAX, - UNK_3_5, - FLEET_NUMBER, - ELITE_ABILITIES, - ELITE_STATE, - - UNK_4_1, - UNK_4_2, - UNK_4_3, - UNK_4_4, - UNK_4_5, - UNK_4_6, - UNK_4_7, - UNK_4_8, - - UNK_5_1, - UNK_5_2, - BEAM_SYSTEM_DAMAGE, - TORPEDO_SYSTEM_DAMAGE, - SENSOR_SYSTEM_DAMAGE, - MANEUVER_SYSTEM_DAMAGE, - IMPULSE_SYSTEM_DAMAGE, - WARP_SYSTEM_DAMAGE, - - FORE_SHIELD_SYSTEM_DAMAGE, - AFT_SHIELD_SYSTEM_DAMAGE, - SHIELD_FREQUENCY_A, - SHIELD_FREQUENCY_B, - SHIELD_FREQUENCY_C, - SHIELD_FREQUENCY_D, - SHIELD_FREQUENCY_E - } - private static final Bit[] BITS = Bit.values(); - - private static final Bit[] SYSTEM_DAMAGES = new Bit[] { - Bit.BEAM_SYSTEM_DAMAGE, - Bit.TORPEDO_SYSTEM_DAMAGE, - Bit.SENSOR_SYSTEM_DAMAGE, - Bit.MANEUVER_SYSTEM_DAMAGE, - Bit.IMPULSE_SYSTEM_DAMAGE, - Bit.WARP_SYSTEM_DAMAGE, - Bit.FORE_SHIELD_SYSTEM_DAMAGE, - Bit.AFT_SHIELD_SYSTEM_DAMAGE - }; - - private static final Bit[] SHLD_FREQS = new Bit[] { - Bit.SHIELD_FREQUENCY_A, - Bit.SHIELD_FREQUENCY_B, - Bit.SHIELD_FREQUENCY_C, - Bit.SHIELD_FREQUENCY_D, - Bit.SHIELD_FREQUENCY_E - }; - - NpcShipParser() { - super(ObjectType.NPC_SHIP); - } - - @Override - public Bit[] getBits() { - return BITS; - } - - @Override - protected ArtemisNpc parseImpl(PacketReader reader) { - ArtemisNpc obj = new ArtemisNpc(reader.getObjectId()); - obj.setName(reader.readString(Bit.NAME)); - obj.setImpulse(reader.readFloat(Bit.IMPULSE, -1)); - - reader.readObjectUnknown(Bit.UNK_1_3, 4); - - obj.setTopSpeed(reader.readFloat(Bit.MAX_IMPULSE, -1)); - obj.setTurnRate(reader.readFloat(Bit.MAX_TURN_RATE, -1)); - obj.setEnemy(reader.readBool(Bit.IS_ENEMY, 4)); - obj.setHullId(reader.readInt(Bit.SHIP_TYPE, -1)); - obj.setX(reader.readFloat(Bit.X, Float.MIN_VALUE)); - obj.setY(reader.readFloat(Bit.Y, Float.MIN_VALUE)); - obj.setZ(reader.readFloat(Bit.Z, Float.MIN_VALUE)); - obj.setPitch(reader.readFloat(Bit.PITCH, Float.MIN_VALUE)); - obj.setRoll(reader.readFloat(Bit.ROLL, Float.MIN_VALUE)); - obj.setHeading(reader.readFloat(Bit.HEADING, Float.MIN_VALUE)); - obj.setVelocity(reader.readFloat(Bit.VELOCITY, -1)); - obj.setSurrendered(reader.readBool(Bit.SURRENDERED, 1)); - - reader.readObjectUnknown(Bit.UNK_2_8, 2); - - obj.setShieldsFront(reader.readFloat(Bit.FORE_SHIELD, Float.MIN_VALUE)); - obj.setShieldsFrontMax(reader.readFloat(Bit.FORE_SHIELD_MAX, -1)); - obj.setShieldsRear(reader.readFloat(Bit.AFT_SHIELD, Float.MIN_VALUE)); - obj.setShieldsRearMax(reader.readFloat(Bit.AFT_SHIELD_MAX, -1)); - - reader.readObjectUnknown(Bit.UNK_3_5, 2); - - obj.setFleetNumber(reader.readByte(Bit.FLEET_NUMBER, (byte) -1)); - int elite = reader.readInt(Bit.ELITE_ABILITIES, -1); - int eliteState = reader.readInt(Bit.ELITE_STATE, -1); - Vessel vessel = obj.getVessel(); - - if (vessel != null && vessel.getFaction().is(FactionAttribute.ELITE)) { - obj.setEliteBits(elite); - obj.setEliteStateBits(eliteState); - } - - obj.setScanLevel((byte) reader.readInt(Bit.UNK_4_1)); - - reader.readObjectUnknown(Bit.UNK_4_2, 4); - - // TODO What are these? - reader.readObjectUnknown(Bit.UNK_4_3, 4); - reader.readObjectUnknown(Bit.UNK_4_4, 1); - reader.readObjectUnknown(Bit.UNK_4_5, 1); - reader.readObjectUnknown(Bit.UNK_4_6, 1); - reader.readObjectUnknown(Bit.UNK_4_7, 1); - reader.readObjectUnknown(Bit.UNK_4_8, 4); - reader.readObjectUnknown(Bit.UNK_5_1, 4); - reader.readObjectUnknown(Bit.UNK_5_2, 4); - - // system damage - ShipSystem[] systems = ShipSystem.values(); - - for (int i = 0; i < SYSTEM_DAMAGES.length; i++) { - obj.setSystemDamage(systems[i], reader.readFloat(SYSTEM_DAMAGES[i], -1)); - } - - // shield frequencies - BeamFrequency[] freqs = BeamFrequency.values(); - - for (int i = 0; i < SHLD_FREQS.length; i++) { - obj.setShieldFreq(freqs[i], reader.readFloat(SHLD_FREQS[i], -1)); - } - - return obj; - } - - @Override - public void write(ArtemisObject obj, PacketWriter writer) { - ArtemisNpc npc = (ArtemisNpc) obj; - writer .writeString(Bit.NAME, npc.getName()) - .writeFloat(Bit.IMPULSE, npc.getImpulse(), -1) - .writeUnknown(Bit.UNK_1_3) - .writeFloat(Bit.MAX_IMPULSE, npc.getTopSpeed(), -1) - .writeFloat(Bit.MAX_TURN_RATE, npc.getTurnRate(), -1) - .writeBool(Bit.IS_ENEMY, npc.isEnemy(), 4) - .writeInt(Bit.SHIP_TYPE, npc.getHullId(), -1) - .writeFloat(Bit.X, npc.getX(), Float.MIN_VALUE) - .writeFloat(Bit.Y, npc.getY(), Float.MIN_VALUE) - .writeFloat(Bit.Z, npc.getZ(), Float.MIN_VALUE) - .writeFloat(Bit.PITCH, npc.getPitch(), Float.MIN_VALUE) - .writeFloat(Bit.ROLL, npc.getRoll(), Float.MIN_VALUE) - .writeFloat(Bit.HEADING, npc.getHeading(), Float.MIN_VALUE) - .writeFloat(Bit.VELOCITY, npc.getVelocity(), -1) - .writeBool(Bit.SURRENDERED, npc.isSurrendered(), 1) - .writeUnknown(Bit.UNK_2_8) - .writeFloat(Bit.FORE_SHIELD, npc.getShieldsFront(), Float.MIN_VALUE) - .writeFloat(Bit.FORE_SHIELD_MAX, npc.getShieldsFrontMax(), -1) - .writeFloat(Bit.AFT_SHIELD, npc.getShieldsRear(), Float.MIN_VALUE) - .writeFloat(Bit.AFT_SHIELD_MAX, npc.getShieldsRearMax(), -1) - .writeUnknown(Bit.UNK_3_5) - .writeByte(Bit.FLEET_NUMBER, npc.getFleetNumber(), (byte) -1) - .writeInt(Bit.ELITE_ABILITIES, npc.getEliteBits(), -1) - .writeInt(Bit.ELITE_STATE, npc.getEliteStateBits(), -1) - .writeInt(Bit.UNK_4_1, npc.getScanLevel(), -1) - .writeUnknown(Bit.UNK_4_2) - .writeUnknown(Bit.UNK_4_3) - .writeUnknown(Bit.UNK_4_4) - .writeUnknown(Bit.UNK_4_5) - .writeUnknown(Bit.UNK_4_6) - .writeUnknown(Bit.UNK_4_7) - .writeUnknown(Bit.UNK_4_8) - .writeUnknown(Bit.UNK_5_1) - .writeUnknown(Bit.UNK_5_2); - - for (ShipSystem sys : ShipSystem.values()) { - Bit bit = SYSTEM_DAMAGES[sys.ordinal()]; - writer.writeFloat(bit, npc.getSystemDamage(sys), -1); - } - - for (BeamFrequency freq : BeamFrequency.values()) { - Bit bit = SHLD_FREQS[freq.ordinal()]; - writer.writeFloat(bit, npc.getShieldFreq(freq), -1); - } - } -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/ObjectParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/ObjectParser.java deleted file mode 100644 index b235c18..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/ObjectParser.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.world.ArtemisObject; - -public interface ObjectParser { - public Enum[] getBits(); - public ArtemisObject parse(PacketReader reader); - public void write(ArtemisObject obj, PacketWriter writer); - public void appendDetail(ArtemisObject obj, StringBuilder b); -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/ObjectUpdatePacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/ObjectUpdatePacket.java deleted file mode 100644 index 93a5880..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/ObjectUpdatePacket.java +++ /dev/null @@ -1,118 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.world.ArtemisObject; - -public class ObjectUpdatePacket extends BaseArtemisPacket { - public static final int TYPE = 0x80803df9; - - private static final Map PARSERS; - - static { - PARSERS = new HashMap(); - PARSERS.put(ObjectType.PLAYER_SHIP, new PlayerShipParser()); - PARSERS.put(ObjectType.WEAPONS_CONSOLE, new WeapParser()); - PARSERS.put(ObjectType.ENGINEERING_CONSOLE, new EngParser()); - PARSERS.put(ObjectType.UPGRADES, new UpgradesParser()); - PARSERS.put(ObjectType.BASE, new BaseParser()); - PARSERS.put(ObjectType.NPC_SHIP, new NpcShipParser()); - PARSERS.put(ObjectType.MINE, new OtherParser(ObjectType.MINE)); - PARSERS.put(ObjectType.ANOMALY, new AnomalyParser()); - PARSERS.put(ObjectType.NEBULA, new NebulaParser()); - PARSERS.put(ObjectType.TORPEDO, new TorpedoParser()); - PARSERS.put(ObjectType.BLACK_HOLE, new OtherParser(ObjectType.BLACK_HOLE)); - PARSERS.put(ObjectType.ASTEROID, new OtherParser(ObjectType.ASTEROID)); - PARSERS.put(ObjectType.GENERIC_MESH, new GenericMeshParser()); - PARSERS.put(ObjectType.CREATURE, new CreatureParser()); - PARSERS.put(ObjectType.DRONE, new DroneParser()); - } - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, new PacketFactory() { - @Override - public Class getFactoryClass() { - return ObjectUpdatePacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new ObjectUpdatePacket(reader); - } - }); - } - - private ObjectType objectType; - private ObjectParser parser; - private List objects = new LinkedList(); - - private ObjectUpdatePacket(PacketReader reader) { - this(ObjectType.fromId(reader.peekByte())); - - if (parser == null) { - return; - } - - do { - ArtemisObject obj = parser.parse(reader); - - if (obj == null) { - break; - } - - objects.add(obj); - } while (true); - - reader.skip(4); - } - - public ObjectUpdatePacket(ObjectType type) { - super(ConnectionType.SERVER, TYPE); - objectType = type; - parser = PARSERS.get(objectType); - } - - public void addObject(ArtemisObject obj) { - if (objectType.isCompatible(obj)) { - throw new IllegalArgumentException("Object is of type " + - obj.getType() + "; expected " + objectType); - } - - objects.add(obj); - } - - public List getObjects() { - return new LinkedList(objects); - } - - @Override - protected void writePayload(PacketWriter writer) { - for (ArtemisObject obj : objects) { - writer.startObject(obj, objectType, parser.getBits()); - parser.write(obj, writer); - writer.endObject(); - } - - writer.writeInt(0); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - for (ArtemisObject obj : objects) { - parser.appendDetail(obj, b); - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/OtherParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/OtherParser.java deleted file mode 100644 index 69019d8..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/OtherParser.java +++ /dev/null @@ -1,77 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.world.ArtemisGenericObject; -import net.dhleong.acl.world.ArtemisObject; - -public class OtherParser extends AbstractObjectParser { - private enum Bit { - X, - Y, - Z, - NAME, - UNK_1_5, - UNK_1_6, - UNK_1_7, - UNK_1_8 - } - private static final Bit[] BITS = Bit.values(); - - OtherParser(ObjectType objectType) { - super(objectType); - } - - @Override - public Bit[] getBits() { - return BITS; - } - - @Override - protected ArtemisGenericObject parseImpl(PacketReader reader) { - ObjectType type = reader.getObjectType(); - float x = reader.readFloat(Bit.X, Float.MIN_VALUE); - float y = reader.readFloat(Bit.Y, Float.MIN_VALUE); - float z = reader.readFloat(Bit.Z, Float.MIN_VALUE); - final ArtemisGenericObject obj = new ArtemisGenericObject(reader.getObjectId()); - String name; - - if (type.isNamed()) { - name = reader.readString(Bit.NAME); - } else { - name = null; - reader.readObjectUnknown(Bit.NAME, 4); - } - - obj.setName(name); - obj.setType(type); - obj.setX(x); - obj.setY(y); - obj.setZ(z); - reader.readObjectUnknown(Bit.UNK_1_5, 4); - reader.readObjectUnknown(Bit.UNK_1_6, 4); - reader.readObjectUnknown(Bit.UNK_1_7, 4); - reader.readObjectUnknown(Bit.UNK_1_8, 4); - return obj; - } - - @Override - public void write(ArtemisObject obj, PacketWriter writer) { - ArtemisGenericObject gObj = (ArtemisGenericObject) obj; - writer .writeFloat(Bit.X, gObj.getX(), Float.MIN_VALUE) - .writeFloat(Bit.Y, gObj.getY(), Float.MIN_VALUE) - .writeFloat(Bit.Z, gObj.getZ(), Float.MIN_VALUE); - - if (objectType.isNamed()) { - writer.writeString(Bit.NAME, gObj.getName()); - } else { - writer.writeUnknown(Bit.NAME); - } - - writer .writeUnknown(Bit.UNK_1_5) - .writeUnknown(Bit.UNK_1_6) - .writeUnknown(Bit.UNK_1_7) - .writeUnknown(Bit.UNK_1_8); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/PlayerShipParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/PlayerShipParser.java deleted file mode 100644 index c169f8f..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/PlayerShipParser.java +++ /dev/null @@ -1,217 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.AlertStatus; -import net.dhleong.acl.enums.BeamFrequency; -import net.dhleong.acl.enums.DriveType; -import net.dhleong.acl.enums.MainScreenView; -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.enums.TargetingMode; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.world.ArtemisObject; -import net.dhleong.acl.world.ArtemisPlayer; - -public class PlayerShipParser extends AbstractObjectParser { - private enum Bit { - WEAPONS_TARGET, - IMPULSE, - RUDDER, - TOP_SPEED, - TURN_RATE, - TARGETING_MODE, - WARP, - ENERGY, - - SHIELD_STATE, - SHIP_NUMBER, - SHIP_TYPE, - X, - Y, - Z, - PITCH, - ROLL, - - HEADING, - VELOCITY, - UNK_3_3, - NAME, - FORE_SHIELDS, - FORE_SHIELDS_MAX, - AFT_SHIELDS, - AFT_SHIELDS_MAX, - - DOCKING_BASE, - ALERT_STATUS, - UNK_4_3, - MAIN_SCREEN, - BEAM_FREQUENCY, - AVAILABLE_COOLANT, - SCIENCE_TARGET, - CAPTAIN_TARGET, - - DRIVE_TYPE, - SCAN_OBJECT_ID, - SCAN_PROGRESS, - REVERSE_STATE, - UNK_5_5, - UNK_5_6, - UNK_5_7 - } - private static final Bit[] BITS = Bit.values(); - - protected PlayerShipParser() { - super(ObjectType.PLAYER_SHIP); - } - - @Override - public Bit[] getBits() { - return BITS; - } - - @Override - protected ArtemisPlayer parseImpl(PacketReader reader) { - ArtemisPlayer player = new ArtemisPlayer(reader.getObjectId()); - player.setWeaponsTarget(reader.readInt(Bit.WEAPONS_TARGET, -1)); - player.setImpulse(reader.readFloat(Bit.IMPULSE, -1)); - player.setSteering(reader.readFloat(Bit.RUDDER, -1)); - player.setTopSpeed(reader.readFloat(Bit.TOP_SPEED, -1)); - player.setTurnRate(reader.readFloat(Bit.TURN_RATE, -1)); - - if (reader.has(Bit.TARGETING_MODE)) { - player.setTargetingMode(TargetingMode.values()[reader.readByte()]); - } - - player.setWarp(reader.readByte(Bit.WARP, (byte) -1)); - player.setEnergy(reader.readFloat(Bit.ENERGY, -1)); - - if (reader.has(Bit.SHIELD_STATE)) { - player.setShields(reader.readBool(Bit.SHIELD_STATE, 2).getBooleanValue()); - } - - player.setShipIndex(reader.readInt(Bit.SHIP_NUMBER) - 1); - player.setHullId(reader.readInt(Bit.SHIP_TYPE)); - player.setX(reader.readFloat(Bit.X, Float.MIN_VALUE)); - player.setY(reader.readFloat(Bit.Y, Float.MIN_VALUE)); - player.setZ(reader.readFloat(Bit.Z, Float.MIN_VALUE)); - player.setPitch(reader.readFloat(Bit.PITCH, Float.MIN_VALUE)); - player.setRoll(reader.readFloat(Bit.ROLL, Float.MIN_VALUE)); - player.setHeading(reader.readFloat(Bit.HEADING, Float.MIN_VALUE)); - player.setVelocity(reader.readFloat(Bit.VELOCITY, -1)); - - reader.readObjectUnknown(Bit.UNK_3_3, 2); - - player.setName(reader.readString(Bit.NAME)); - player.setShieldsFront(reader.readFloat(Bit.FORE_SHIELDS, Float.MIN_VALUE)); - player.setShieldsFrontMax(reader.readFloat(Bit.FORE_SHIELDS_MAX, -1)); - player.setShieldsRear(reader.readFloat(Bit.AFT_SHIELDS, Float.MIN_VALUE)); - player.setShieldsRearMax(reader.readFloat(Bit.AFT_SHIELDS_MAX, -1)); - player.setDockingBase(reader.readInt(Bit.DOCKING_BASE, -1)); - - if (reader.has(Bit.ALERT_STATUS)) { - player.setAlertStatus(AlertStatus.values()[reader.readByte()]); - } - - reader.readObjectUnknown(Bit.UNK_4_3, 4); - - if (reader.has(Bit.MAIN_SCREEN)) { - player.setMainScreen(MainScreenView.values()[reader.readByte()]); - } - - if (reader.has(Bit.BEAM_FREQUENCY)) { - player.setBeamFrequency(BeamFrequency.values()[reader.readByte()]); - } - - player.setAvailableCoolant(reader.readByte(Bit.AVAILABLE_COOLANT, (byte) -1)); - player.setScienceTarget(reader.readInt(Bit.SCIENCE_TARGET, -1)); - player.setCaptainTarget(reader.readInt(Bit.CAPTAIN_TARGET, -1)); - - if (reader.has(Bit.DRIVE_TYPE)) { - player.setDriveType(DriveType.values()[reader.readByte()]); - } - - player.setScanObjectId(reader.readInt(Bit.SCAN_OBJECT_ID, -1)); - player.setScanProgress(reader.readFloat(Bit.SCAN_PROGRESS, -1)); - player.setReverse(reader.readBool(Bit.REVERSE_STATE, 1)); - - reader.readObjectUnknown(Bit.UNK_5_5, 4); - reader.readObjectUnknown(Bit.UNK_5_6, 5); - reader.readObjectUnknown(Bit.UNK_5_7, 4); - - return player; - } - - @Override - public void write(ArtemisObject obj, PacketWriter writer) { - ArtemisPlayer player = (ArtemisPlayer) obj; - int shipIndex = player.getShipIndex(); - int shipNumber = shipIndex == -1 ? -1 : shipIndex + 1; - writer .writeInt(Bit.WEAPONS_TARGET, player.getWeaponsTarget(), -1) - .writeFloat(Bit.IMPULSE, player.getImpulse(), -1) - .writeFloat(Bit.RUDDER, player.getSteering(), -1) - .writeFloat(Bit.TOP_SPEED, player.getTopSpeed(), -1) - .writeFloat(Bit.TURN_RATE, player.getTurnRate(), -1); - - TargetingMode targetingMode = player.getTargetingMode(); - - if (targetingMode != null) { - writer.writeByte(Bit.TARGETING_MODE, (byte) targetingMode.ordinal(), (byte) -1); - } - - writer .writeByte(Bit.WARP, player.getWarp(), (byte) -1) - .writeFloat(Bit.ENERGY, player.getEnergy(), -1) - .writeBool(Bit.SHIELD_STATE, player.getShieldsState(), 2) - .writeInt(Bit.SHIP_NUMBER, shipNumber, -1) - .writeInt(Bit.SHIP_TYPE, player.getHullId(), -1) - .writeFloat(Bit.X, player.getX(), Float.MIN_VALUE) - .writeFloat(Bit.Y, player.getY(), Float.MIN_VALUE) - .writeFloat(Bit.Z, player.getZ(), Float.MIN_VALUE) - .writeFloat(Bit.PITCH, player.getPitch(), Float.MIN_VALUE) - .writeFloat(Bit.ROLL, player.getRoll(), Float.MIN_VALUE) - .writeFloat(Bit.HEADING, player.getHeading(), Float.MIN_VALUE) - .writeFloat(Bit.VELOCITY, player.getVelocity(), -1) - .writeUnknown(Bit.UNK_3_3) - .writeString(Bit.NAME, player.getName()) - .writeFloat(Bit.FORE_SHIELDS, player.getShieldsFront(), Float.MIN_VALUE) - .writeFloat(Bit.FORE_SHIELDS_MAX, player.getShieldsFrontMax(), -1) - .writeFloat(Bit.AFT_SHIELDS, player.getShieldsRear(), Float.MIN_VALUE) - .writeFloat(Bit.AFT_SHIELDS_MAX, player.getShieldsRearMax(), -1) - .writeInt(Bit.DOCKING_BASE, player.getDockingBase(), -1); - - AlertStatus alertStatus = player.getAlertStatus(); - - if (alertStatus != null) { - writer.writeByte(Bit.ALERT_STATUS, (byte) alertStatus.ordinal(), (byte) -1); - } - - writer.writeUnknown(Bit.UNK_4_3); - - MainScreenView screen = player.getMainScreen(); - - if (screen != null) { - writer.writeByte(Bit.MAIN_SCREEN, (byte) screen.ordinal(), (byte) -1); - } - - BeamFrequency beamFreq = player.getBeamFrequency(); - - if (beamFreq != null) { - writer.writeByte(Bit.BEAM_FREQUENCY, (byte) beamFreq.ordinal(), (byte) -1); - } - - writer .writeByte(Bit.AVAILABLE_COOLANT, (byte) player.getAvailableCoolant(), (byte) -1) - .writeInt(Bit.SCIENCE_TARGET, player.getScienceTarget(), -1) - .writeInt(Bit.CAPTAIN_TARGET, player.getCaptainTarget(), -1); - - DriveType drive = player.getDriveType(); - - if (drive != null) { - writer.writeByte(Bit.DRIVE_TYPE, (byte) drive.ordinal(), (byte) -1); - } - - writer .writeInt(Bit.SCAN_OBJECT_ID, player.getScanObjectId(), -1) - .writeFloat(Bit.SCAN_PROGRESS, player.getScanProgress(), -1) - .writeBool(Bit.REVERSE_STATE, player.getReverseState(), 1) - .writeUnknown(Bit.UNK_5_5) - .writeUnknown(Bit.UNK_5_6) - .writeUnknown(Bit.UNK_5_7); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/SoundEffectPacket.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/SoundEffectPacket.java deleted file mode 100644 index a0bb077..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/SoundEffectPacket.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.PacketFactory; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.BaseArtemisPacket; -import net.dhleong.acl.protocol.UnexpectedTypeException; - -/** - * Indicates that the client should play the indicated sound file. - * @author rjwut - */ -public class SoundEffectPacket extends BaseArtemisPacket { - private static final int TYPE = 0xf754c8fe; - private static final byte MSG_TYPE = 0x03; - - public static void register(PacketFactoryRegistry registry) { - registry.register(ConnectionType.SERVER, TYPE, MSG_TYPE, - new PacketFactory() { - @Override - public Class getFactoryClass() { - return SoundEffectPacket.class; - } - - @Override - public ArtemisPacket build(PacketReader reader) - throws ArtemisPacketException { - return new SoundEffectPacket(reader); - } - }); - } - - private String mFilename; - - private SoundEffectPacket(PacketReader reader) { - super(ConnectionType.SERVER, TYPE); - int subtype = reader.readInt(); - - if (subtype != MSG_TYPE) { - throw new UnexpectedTypeException(subtype, MSG_TYPE); - } - - mFilename = reader.readString(); - } - - /** - * Returns the path of the file to play, relative to the Artemis install - * directory. - */ - public String getFilename() { - return mFilename; - } - - @Override - protected void writePayload(PacketWriter writer) { - writer.writeInt(MSG_TYPE).writeString(mFilename); - } - - @Override - protected void appendPacketDetail(StringBuilder b) { - b.append(mFilename); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/TorpedoParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/TorpedoParser.java deleted file mode 100644 index da8896b..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/TorpedoParser.java +++ /dev/null @@ -1,64 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.world.ArtemisGenericObject; -import net.dhleong.acl.world.ArtemisObject; - -public class TorpedoParser extends AbstractObjectParser { - private enum Bit { - X, - Y, - Z, - NAME, - UNK_1_5, - UNK_1_6, - UNK_1_7, - UNK_1_8 - } - private static final Bit[] BITS = Bit.values(); - private static final byte[] UNK_TORPEDO = { 0 }; - - TorpedoParser() { - super(ObjectType.TORPEDO); - } - - @Override - public Bit[] getBits() { - return BITS; - } - - @Override - protected ArtemisGenericObject parseImpl(PacketReader reader) { - reader.readObjectUnknown("UNK_TORPEDO", 1); - float x = reader.readFloat(Bit.X, Float.MIN_VALUE); - float y = reader.readFloat(Bit.Y, Float.MIN_VALUE); - float z = reader.readFloat(Bit.Z, Float.MIN_VALUE); - reader.readObjectUnknown(Bit.NAME, 4); - final ArtemisGenericObject obj = new ArtemisGenericObject(reader.getObjectId()); - obj.setType(ObjectType.TORPEDO); - obj.setX(x); - obj.setY(y); - obj.setZ(z); - reader.readObjectUnknown(Bit.UNK_1_5, 4); - reader.readObjectUnknown(Bit.UNK_1_6, 4); - reader.readObjectUnknown(Bit.UNK_1_7, 4); - reader.readObjectUnknown(Bit.UNK_1_8, 4); - return obj; - } - - @Override - public void write(ArtemisObject obj, PacketWriter writer) { - ArtemisGenericObject gObj = (ArtemisGenericObject) obj; - writer.writeUnknown("UNK_TORPEDO", UNK_TORPEDO); - writer .writeFloat(Bit.X, gObj.getX(), Float.MIN_VALUE) - .writeFloat(Bit.Y, gObj.getY(), Float.MIN_VALUE) - .writeFloat(Bit.Z, gObj.getZ(), Float.MIN_VALUE); - writer .writeUnknown(Bit.NAME) - .writeUnknown(Bit.UNK_1_5) - .writeUnknown(Bit.UNK_1_6) - .writeUnknown(Bit.UNK_1_7) - .writeUnknown(Bit.UNK_1_8); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/UpgradesParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/UpgradesParser.java deleted file mode 100644 index e9cd1c0..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/UpgradesParser.java +++ /dev/null @@ -1,158 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.enums.Upgrade; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.world.ArtemisObject; -import net.dhleong.acl.world.ArtemisPlayer; - -public class UpgradesParser extends AbstractObjectParser { - private enum Bit { - UNKNOWN_1_1, - UNKNOWN_1_2, - UNKNOWN_1_3, - UNKNOWN_1_4, - UNKNOWN_1_5, - UNKNOWN_1_6, - UNKNOWN_1_7, - UNKNOWN_1_8, - UNKNOWN_2_1, - UNKNOWN_2_2, - UNKNOWN_2_3, - UNKNOWN_2_4, - UNKNOWN_2_5, - UNKNOWN_2_6, - UNKNOWN_2_7, - UNKNOWN_2_8, - UNKNOWN_3_1, - UNKNOWN_3_2, - UNKNOWN_3_3, - UNKNOWN_3_4, - UNKNOWN_3_5, - UNKNOWN_3_6, - UNKNOWN_3_7, - UNKNOWN_3_8, - UNKNOWN_4_1, - UNKNOWN_4_2, - UNKNOWN_4_3, - UNKNOWN_4_4, - INFUSION_P_COIL(Upgrade.INFUSION_P_COIL), - UNKNOWN_4_6, - TAURON_FOCUSER(Upgrade.TAURON_FOCUSER), - CARPACTION_COIL(Upgrade.CARPACTION_COIL), - UNKNOWN_5_1, - CETROCITE_CRYSTAL(Upgrade.CETROCITE_CRYSTAL), - LATERAL_ARRAY(Upgrade.LATERAL_ARRAY), - UNKNOWN_5_4, - SECRET_CODE_CASE(Upgrade.SECRET_CODE_CASE), - UNKNOWN_5_6, - UNKNOWN_5_7, - UNKNOWN_5_8, - UNKNOWN_6_1, - UNKNOWN_6_2, - UNKNOWN_6_3, - UNKNOWN_6_4, - UNKNOWN_6_5, - UNKNOWN_6_6, - UNKNOWN_6_7, - UNKNOWN_6_8, - UNKNOWN_7_1, - UNKNOWN_7_2, - UNKNOWN_7_3, - UNKNOWN_7_4, - UNKNOWN_7_5, - UNKNOWN_7_6, - UNKNOWN_7_7, - UNKNOWN_7_8, - UNKNOWN_8_1, - UNKNOWN_8_2, - UNKNOWN_8_3, - UNKNOWN_8_4, - UNKNOWN_8_5, - UNKNOWN_8_6, - UNKNOWN_8_7, - UNKNOWN_8_8, - UNKNOWN_9_1, - UNKNOWN_9_2, - UNKNOWN_9_3, - UNKNOWN_9_4, - UNKNOWN_9_5, - UNKNOWN_9_6, - UNKNOWN_9_7, - UNKNOWN_9_8, - UNKNOWN_10_1, - UNKNOWN_10_2, - UNKNOWN_10_3, - UNKNOWN_10_4, - UNKNOWN_10_5, - UNKNOWN_10_6, - UNKNOWN_10_7, - UNKNOWN_10_8, - UNKNOWN_11_1, - UNKNOWN_11_2, - UNKNOWN_11_3, - UNKNOWN_11_4; - - private Upgrade upgrade; - - Bit() { - } - - Bit(Upgrade upgrade) { - this.upgrade = upgrade; - } - - private Upgrade getUpgrade() { - return upgrade; - } - } - - private static final Bit[] BITS = Bit.values(); - - UpgradesParser() { - super(ObjectType.UPGRADES); - } - - @Override - public Bit[] getBits() { - return BITS; - } - - @Override - protected ArtemisPlayer parseImpl(PacketReader reader) { - ArtemisPlayer player = new ArtemisPlayer(reader.getObjectId()); - - for (Bit bit : BITS) { - if (reader.has(bit)) { - Upgrade upgrade = bit.getUpgrade(); - - if (upgrade != null) { - player.setUpgrades(upgrade, reader.readByte()); - } else { - reader.readObjectUnknown(bit, 1); - } - } - } - - reader.readObjectUnknownUntil("UNKNOWN", ObjectType.UPGRADES.getId()); - return player; - } - - @Override - public void write(ArtemisObject obj, PacketWriter writer) { - ArtemisPlayer player = (ArtemisPlayer) obj; - - for (Bit bit : BITS) { - Upgrade upgrade = bit.getUpgrade(); - - if (upgrade != null) { - writer.writeByte(bit, player.getUpgrades(upgrade), (byte) -1); - } else { - writer.writeUnknown(bit); - } - } - - writer.writeUnknown("UNKNOWN", null); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/WeapParser.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/WeapParser.java deleted file mode 100644 index ba1edef..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/protocol/core/world/WeapParser.java +++ /dev/null @@ -1,202 +0,0 @@ -package net.dhleong.acl.protocol.core.world; - -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.enums.OrdnanceType; -import net.dhleong.acl.enums.TubeState; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.world.Artemis; -import net.dhleong.acl.world.ArtemisObject; -import net.dhleong.acl.world.ArtemisPlayer; - -public class WeapParser extends AbstractObjectParser { - private enum Bit { - TORP_HOMING, - TORP_NUKE, - TORP_MINE, - TORP_EMP, - TORP_PSHOCK, - UNK_1_6, - TUBE_TIME_1, - TUBE_TIME_2, - - TUBE_TIME_3, - TUBE_TIME_4, - TUBE_TIME_5, - TUBE_TIME_6, - TUBE_STATE_1, - TUBE_STATE_2, - TUBE_STATE_3, - TUBE_STATE_4, - - TUBE_STATE_5, - TUBE_STATE_6, - TUBE_CONTENT_1, - TUBE_CONTENT_2, - TUBE_CONTENT_3, - TUBE_CONTENT_4, - TUBE_CONTENT_5, - TUBE_CONTENT_6, - - UNK_4_1, - UNK_4_2, - UNK_4_3, - UNK_4_4, - UNK_4_5, - UNK_4_6, - UNK_4_7, - UNK_4_8 - } - private static final Bit[] BITS = Bit.values(); - - private static final Bit[] TORPEDOS = { - Bit.TORP_HOMING, Bit.TORP_NUKE, Bit.TORP_MINE, Bit.TORP_EMP, - Bit.TORP_PSHOCK - }; - - private static final Bit[] TUBE_TIMES = { - Bit.TUBE_TIME_1, Bit.TUBE_TIME_2, Bit.TUBE_TIME_3, - Bit.TUBE_TIME_4, Bit.TUBE_TIME_5, Bit.TUBE_TIME_6 - }; - - private static final Bit[] TUBE_STATES = { - Bit.TUBE_STATE_1, Bit.TUBE_STATE_2, Bit.TUBE_STATE_3, - Bit.TUBE_STATE_4, Bit.TUBE_STATE_5, Bit.TUBE_STATE_6 - }; - - private static final Bit[] TUBE_CONTENTS = { - Bit.TUBE_CONTENT_1, Bit.TUBE_CONTENT_2, Bit.TUBE_CONTENT_3, - Bit.TUBE_CONTENT_4, Bit.TUBE_CONTENT_5, Bit.TUBE_CONTENT_6 - }; - - - protected WeapParser() { - super(ObjectType.WEAPONS_CONSOLE); - } - - @Override - public Bit[] getBits() { - return BITS; - } - - @Override - protected ArtemisPlayer parseImpl(PacketReader reader) { - int[] torps = new int[TORPEDOS.length]; - float[] tubeTimes = new float[Artemis.MAX_TUBES]; - TubeState[] tubeStates = new TubeState[Artemis.MAX_TUBES]; - byte[] tubeContents = new byte[Artemis.MAX_TUBES]; - - for (int i = 0; i < torps.length; i++) { - torps[i] = (reader.readByte(TORPEDOS[i], (byte) -1)); - } - - reader.readObjectUnknown(Bit.UNK_1_6, 1); - - for (int i = 0; i < Artemis.MAX_TUBES; i++) { - tubeTimes[i] = reader.readFloat(TUBE_TIMES[i], -1); - } - - for (int i = 0; i < Artemis.MAX_TUBES; i++) { - byte state = reader.readByte(TUBE_STATES[i], (byte) -1); - - if (state != -1) { - tubeStates[i] = TubeState.values()[state]; - } - } - - for (int i = 0; i < Artemis.MAX_TUBES; i++) { - tubeContents[i] = reader.readByte(TUBE_CONTENTS[i], (byte) -1); - } - - ArtemisPlayer player = new ArtemisPlayer(reader.getObjectId()); - - for (int i = 0; i < TORPEDOS.length; i++) { - player.setTorpedoCount(i, torps[i]); - } - - for (int i = 0; i < Artemis.MAX_TUBES; i++) { - player.setTubeCountdown(i, tubeTimes[i]); - player.setTubeState(i, tubeStates[i]); - player.setTubeContentsValue(i, tubeContents[i]); - } - - // last byte in bit field appears to be unused - return player; - } - - @Override - public void write(ArtemisObject obj, PacketWriter writer) { - ArtemisPlayer player = (ArtemisPlayer) obj; - OrdnanceType[] ordTypes = OrdnanceType.values(); - - for (int i = 0; i < TORPEDOS.length; i++) { - OrdnanceType type = ordTypes[i]; - writer.writeByte(TORPEDOS[i], (byte) player.getTorpedoCount(type), (byte) -1); - } - - writer.writeUnknown(Bit.UNK_1_6); - - for (int i = 0; i < Artemis.MAX_TUBES; i++) { - writer.writeFloat(TUBE_TIMES[i], player.getTubeCountdown(i), -1); - } - - for (int i = 0; i < Artemis.MAX_TUBES; i++) { - TubeState state = player.getTubeState(i); - byte stateByte = (byte) (state != null ? state.ordinal() : -1); - writer.writeByte(TUBE_STATES[i], stateByte, (byte) -1); - } - - for (int i = 0; i < Artemis.MAX_TUBES; i++) { - byte type = player.getTubeContentsValue(i); - writer.writeByte(TUBE_CONTENTS[i], type, (byte) -1); - } - - // last byte in bit field appears to be unused - } - - @Override - public void appendDetail(ArtemisObject obj, StringBuilder b) { - ArtemisPlayer player = (ArtemisPlayer) obj; - b.append("\nWEAP for player ship #").append(obj.getId()).append(": "); - - for (OrdnanceType type : OrdnanceType.values()) { - int count = player.getTorpedoCount(type); - - if (count != -1) { - b.append(type).append('=').append(count).append(' '); - } - } - - for (int i = 0; i < Artemis.MAX_TUBES; i++) { - TubeState state = player.getTubeState(i); - byte contents = player.getTubeContentsValue(i); - float time = player.getTubeCountdown(i); - - if (state == null && contents == -1 && time < 0) { - continue; - } - - b.append("\n\tTube #").append(i).append(":"); - - if (state != null) { - b.append(" state=").append(state); - } - - if (contents != -1) { - String contentsStr; - - if (state == TubeState.UNLOADED) { - contentsStr = "EMPTY"; - } else { - contentsStr = OrdnanceType.values()[contents].name(); - } - - b.append(" contents=").append(contentsStr); - } - - if (time >= 0) { - b.append(" time=").append(time); - } - } - } -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/BitField.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/BitField.java deleted file mode 100644 index 2e40ecc..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/BitField.java +++ /dev/null @@ -1,127 +0,0 @@ -package net.dhleong.acl.util; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.Arrays; - -/** - * Provides easy reading and writing of bits in a bit field. The bit places are - * identified by an enum. The bytes are little-endian, so in the event that the - * final byte is not completely utilized, it will be the most significant bits - * that are left unused. - * @author rjwut - */ -public class BitField { - private byte[] bytes; - - /** - * Creates a BitField large enough to accommodate the enumerated bits. All - * bits start at 0. - */ - public BitField(Enum[] bits) { - this(countBytes(bits)); - } - - /** - * Creates a BitField large enough to accommodate the enumerated bits, and - * stores the indicated bytes in it. - */ - public BitField(Enum[] bits, byte[] bytes, int offset) { - this.bytes = Arrays.copyOfRange(bytes, offset, offset + countBytes(bits)); - } - - /** - * Creates a BitField with the given number of bits. All bits start at 0. - */ - public BitField(int bitCount) { - this.bytes = new byte[countBytes(bitCount)]; - } - - /** - * Returns the number of bytes in this BitField. - */ - public int getByteCount() { - return bytes.length; - } - - /** - * Returns true if the indicated bit is 1, false if it's 0. - */ - public boolean get(Enum bit) { - int bitIndex = bit.ordinal(); - int byteIndex = bitIndex / 8; - int mask = 0x1 << (bitIndex % 8); - return (bytes[byteIndex] & mask) != 0; - } - - /** - * If value is true, the indicated bit is set to 1; otherwise, it's set to - * 0. - */ - public void set(Enum bit, boolean value) { - int ordinal = bit.ordinal(); - int byteIndex = ordinal / 8; - int bitIndex = ordinal % 8; - int mask = (0x1 << bitIndex) ^ 0xff; - int shiftedValue = (value ? 1 : 0) << bitIndex; - bytes[byteIndex] = (byte) ((bytes[byteIndex] & mask) | shiftedValue); - } - - /** - * Returns a hex encoded String of the bytes that comprise this BitField. - */ - @Override - public String toString() { - return TextUtil.byteArrayToHexString(bytes); - } - - /** - * Writes this BitField to the given OutputStream. - */ - public void write(OutputStream out) throws IOException { - out.write(bytes); - } - - /** - * Returns a space-delimited list of the names of the enum values that - * correspond to active bits in this BitField. This can be useful for - * debugging purposes. - */ - public String listActiveBits(Enum[] bits) { - StringBuilder list = new StringBuilder(); - - for (int i = 0; i < bytes.length; i++) { - byte b = bytes[i]; - - for (int j = 0; j < 8; j++) { - int bitIndex = i * 8 + j; - - if (bitIndex < bits.length) { - if ((b & (0x01 << j)) != 0) { - if (list.length() != 0) { - list.append(' '); - } - - list.append(bits[bitIndex].name()); - } - } - } - } - - return list.toString(); - } - - /** - * Returns the number of bytes required to store the given number of bits in a BitField. - */ - private static int countBytes(int bitCount) { - return (bitCount + 7) / 8; - } - - /** - * Returns the number of bytes required to store the enumerated bits. - */ - private static int countBytes(Enum[] bits) { - return countBytes(bits.length); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/BoolState.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/BoolState.java deleted file mode 100644 index 37d957e..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/BoolState.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.dhleong.acl.util; - -/** - * A tri-state enumeration representing the values TRUE, FALSE and UNKNOWN. - * @author rjwut - */ -public enum BoolState { - TRUE, FALSE, UNKNOWN; - - /** - * Returns true if this BoolState is .TRUE; false otherwise. - */ - public boolean getBooleanValue() { - return ordinal() == 0; - } - - /** - * Returns .TRUE if the given boolean is true; .FALSE otherwise. - */ - public static BoolState from(boolean isTrue) { - return isTrue ? TRUE : FALSE; - } - - /** - * Returns .FALSE if state is null or .UNKNOWN; .TRUE otherwise. - */ - public static boolean isKnown(BoolState state) { - return state == TRUE || state == FALSE; - } - - /** - * Returns true if the given value is .TRUE; otherwise. - */ - public static boolean safeValue(BoolState value) { - return value == TRUE; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/ByteArrayReader.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/ByteArrayReader.java deleted file mode 100644 index 5c365ec..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/ByteArrayReader.java +++ /dev/null @@ -1,215 +0,0 @@ -package net.dhleong.acl.util; - -import java.io.EOFException; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.Charset; -import java.util.Arrays; - -/** - * Handles reading various data types from a byte array and tracking the offset - * pointer. - */ -public class ByteArrayReader { - /** - * Reads the indicated number of bytes from the given InputStream wrapped by this object and - * stores them in the provided buffer. This method blocks until the desired number of bytes has - * been read or the stream closes. - */ - public static void readBytes(InputStream in, int byteCount, byte[] buffer) throws InterruptedException, IOException { - if (byteCount > buffer.length) { - throw new IllegalArgumentException("Requested " + byteCount + - " byte(s) but buffer is only " + buffer.length + " byte(s)"); - } - - int totalBytesRead = 0; - - while (true) { - int bytesRead = in.read(buffer, totalBytesRead, byteCount - totalBytesRead); - - if (bytesRead == -1) { - throw new EOFException("Stream is closed"); - } - - totalBytesRead += bytesRead; - - if (totalBytesRead < byteCount) { - Thread.sleep(1); - } else { - break; - } - } - } - - /** - * Reads a short (coerced to an int) from the indicated location in the - * given byte array. - */ - public static int readShort(byte[] bytes, int offset) { - return (0xff & (bytes[offset + 1] << 8)) | (0xff & bytes[offset]); - } - - /** - * Reads an int from the indicated location in the given byte array. - */ - public static int readInt(byte[] bytes, int offset) { - return ((0xff & bytes[offset + 3]) << 24) | - ((0xff & bytes[offset + 2]) << 16) | - ((0xff & bytes[offset + 1]) << 8) | - (0xff & bytes[offset]); - } - - /** - * Reads a float from the indicated location in the given byte array. - */ - public static float readFloat(byte[] bytes, int offset) { - return Float.intBitsToFloat(readInt(bytes, offset)); - } - - private byte[] bytes; - private int offset; - - /** - * Constructs a new ByteArrayReader that will read the bytes from the given - * array. - */ - public ByteArrayReader(byte[] bytes) { - this.bytes = bytes; - } - - /** - * Returns the number of unread bytes. - */ - public int getBytesLeft() { - return bytes.length - offset; - } - - /** - * Returns the next byte to be read from the array without moving the - * pointer. - */ - public byte peek() { - return bytes[offset]; - } - - /** - * Skips the indicated number of bytes. - */ - public void skip(int byteCount) { - offset += byteCount; - } - - /** - * Returns the next byte. - */ - public byte readByte() { - return bytes[offset++]; - } - - /** - * Returns the next given number of bytes. - */ - public byte[] readBytes(int byteCount) { - byte[] readBytes = Arrays.copyOfRange(bytes, offset, offset + byteCount); - offset += byteCount; - return readBytes; - } - - /** - * Reads the given number of bytes, then returns true if the first byte was - * 1 and false otherwise. - */ - public boolean readBoolean(int byteCount) { - return readBytes(byteCount)[0] == 1; - } - - /** - * Reads the given number of bytes, then returns BoolState.TRUE if the first - * byte was 1 and BoolState.FALSE otherwise. - */ - public BoolState readBoolState(int byteCount) { - return BoolState.from(readBoolean(byteCount)); - } - - /** - * Reads a short value (two bytes) and returns it coerced to an int. - */ - public int readShort() { - int value = readShort(bytes, offset); - offset += 2; - return value; - } - - /** - * Reads and returns an int value (four bytes). - */ - public int readInt() { - int value = readInt(bytes, offset); - offset += 4; - return value; - } - - /** - * Reads and returns a float value (four bytes). - */ - public float readFloat() { - return Float.intBitsToFloat(readInt()); - } - - /** - * Reads and returns a BitField, presuming that the given enum values - * represent the bits it stores. - */ - public BitField readBitField(Enum[] bits) { - BitField bitField = new BitField(bits, bytes, offset); - offset += bitField.getByteCount(); - return bitField; - } - - /** - * Reads and returns a US ASCII encoded String(). - */ - public String readUSASCIIString() { - return readString(Util.US_ASCII, 1, false); - } - - /** - * Reads and returns a UTF-16LE encoded String(). - */ - public String readUTF16LEString() { - return readString(Util.UTF16LE, 2, true); - } - - /** - * Reads a String in the given Charset, assuming the indicated number of - * bytes per character. - */ - private String readString(Charset charset, int bytesPerChar, boolean nullTerminated) { - int charCount = readInt(); - int byteCount = charCount * bytesPerChar; - int nullLength = nullTerminated ? bytesPerChar : 0; - int endOffset = offset + byteCount - nullLength; - byte[] readBytes = Arrays.copyOfRange(bytes, offset, endOffset); - offset += byteCount; - int i = 0; - - // check for "early" null - for ( ; i < readBytes.length; i += bytesPerChar) { - boolean isNull = true; - - for (int j = 0; isNull && j < bytesPerChar; j++) { - isNull = readBytes[i + j] == 0; - } - - if (isNull) { - break; - } - } - - if (i != readBytes.length) { - readBytes = Arrays.copyOfRange(readBytes, 0, i); - } - - return new String(readBytes, charset); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/GridCoord.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/GridCoord.java deleted file mode 100644 index 905a0bd..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/GridCoord.java +++ /dev/null @@ -1,136 +0,0 @@ -package net.dhleong.acl.util; - -import java.util.ArrayDeque; -import java.util.Iterator; -import java.util.Queue; - -/** - * A 3d grid coordinate, for referencing internal systems on the Player's ship. - * @author dhleong - */ -public final class GridCoord implements Comparable { - private static final int CACHE_SIZE = 50; - private static final Queue sCache = new ArrayDeque(CACHE_SIZE); - - private final int x, y, z; - - private GridCoord(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - public int getX() { - return x; - } - - public int getY() { - return y; - } - - public int getZ() { - return z; - } - - @Override - public final boolean equals(Object other) { - if (this == other) { - return true; - } - - if (!(other instanceof GridCoord)) { - return false; - } - - GridCoord cast = (GridCoord) other; - return equals(cast.x, cast.y, cast.z); - } - - public final boolean equals(int ox, int oy, int oz) { - return (x == ox && y == oy && z == oz); - } - - @Override - public int hashCode() { - int result = (x ^ (x >>> 32)); - result = 31 * result + (y ^ (y >>> 32)); - result = 31 * result + (z ^ (z >>> 32)); - return result; - } - - @Override - public String toString() { - return new StringBuilder() - .append('[') - .append(x) - .append(',') - .append(y) - .append(',') - .append(z) - .append(']') - .toString(); - } - - /** - * This factory method uses a very simple LRU queue to maintain a cache of - * GridCoords, since we will probably reuse just a handful but fairly often. - * This should keep our memory footprint to a minimum. - */ - public static final GridCoord getInstance(int x, int y, int z) { - synchronized(sCache) { - Iterator iter = sCache.iterator(); - - while (iter.hasNext()) { - GridCoord c = iter.next(); - - if (c.equals(x, y, z)) { - iter.remove(); // pop out so we can move it to the head - sCache.offer(c); - return c; - } - } - } - - GridCoord c = new GridCoord(x, y, z); - - // put it in the queue, if there's room. - int size = sCache.size(); - - if (size >= CACHE_SIZE) { - synchronized(sCache) { - sCache.poll(); // free up space - } - } - - synchronized(sCache) { - sCache.offer(c); - } - - return c; - } - - /** - * Return a unique long representing this coord. - * It's super simple, but should work since our - * coords tend to be 10 or less in any dimension - */ - public long getUniqueId() { - return (x * 10000L) + (y * 100) + z; - } - - /** - * Sorts in z order, then x, then y. - */ - @Override - public int compareTo(GridCoord other) { - if (z != other.z) { - return z - other.z; - } - - if (x != other.x) { - return x - other.x; - } - - return y - other.y; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/PlayerShipUpdateListener.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/PlayerShipUpdateListener.java deleted file mode 100644 index 557910b..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/PlayerShipUpdateListener.java +++ /dev/null @@ -1,71 +0,0 @@ -package net.dhleong.acl.util; - -import net.dhleong.acl.iface.DisconnectEvent; -import net.dhleong.acl.iface.Listener; -import net.dhleong.acl.protocol.core.GameOverPacket; -import net.dhleong.acl.world.ArtemisPlayer; - -/** - * Convenience class for listening for updates to a particular player ship, - * indicated by ship index. The ship index is usually omitted from updates, but - * the first update will always specify it. This class automates the tactic of - * noting the ID of the ship with the given index, and using that to identify - * the ship from then on. When an update for the specific ship is received, the - * onShipUpdate() method is invoked. - * - * To use, extend the class and implement onShipUpdate(), then pass an instance - * of your subclass into ArtemisNetworkInterface.addListener(). - * - * @author rjwut - */ -public abstract class PlayerShipUpdateListener { - public abstract void onShipUpdate(ArtemisPlayer player); - - private int index; - private int id; - private boolean found = false; - - public PlayerShipUpdateListener(int index) { - this.index = index; - } - - @Listener - public final void onPlayerObjectUpdated(ArtemisPlayer player) { - if (!found) { - synchronized (this) { - // We don't know the ship's ID yet - int curIndex = player.getShipIndex(); - - if (curIndex == -1 || curIndex != index) { - return; // this isn't the one we want - } - - // We found it; record the ID - id = player.getId(); - found = true; - } - } else { - // We know the ID, so just check for that - if (player.getId() != id) { - return; // this isn't the one we want - } - } - - // If we got here, this is the ship we want - onShipUpdate(player); - } - - @Listener - public void onGameOver(GameOverPacket pkt) { - found = false; // ship will probably have a different ID next game - } - - @Listener - public void onDisconnect(DisconnectEvent event) { - found = false; // ship will probably have a different ID next game - } - - public int getIndex() { - return index; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/ShipSystemGrid.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/ShipSystemGrid.java deleted file mode 100644 index cb15309..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/ShipSystemGrid.java +++ /dev/null @@ -1,84 +0,0 @@ -package net.dhleong.acl.util; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import net.dhleong.acl.enums.ShipSystem; - -/** - * Some basic management of the internal systems grid for a Player Ship. This is - * by no means comprehensive--we don't keep track of pixel coordinates, for - * example, just the "grid" coordinates--but is just enough so we can get the - * Engineering console to be more complete. - * @author dhleong - */ -public class ShipSystemGrid { - public static class GridEntry { - private final ShipSystem system; - private final int index; // index of this system among its types, [0,N) - - private GridEntry(ShipSystem system, int index) { - this.system = system; - this.index = index; - } - - public ShipSystem getSystem() { - return system; - } - - public int getIndex() { - return index; - } - } - - private final Map mSystems = new HashMap(); - private final int[] mSystemCounts = new int[ShipSystem.values().length]; - - /** - * Get the number of nodes we have of the given ShipSystem. - */ - public int getSystemCount(ShipSystem sys) { - return mSystemCounts[sys.ordinal()]; - } - - /** - * Returns the GridEntry found at the given coordinates. - */ - public GridEntry getGridAt(GridCoord coord) { - return mSystems.get(coord); - } - - /** - * Convenience method for getGridAt(coord).getSystem(). - */ - public ShipSystem getSystemTypeAt(GridCoord coord) { - return mSystems.get(coord).system; - } - - /** - * Get the set of GridCoords contained on this grid. - */ - public Set getCoords() { - return mSystems.keySet(); - } - - /** - * Returns all GridCoord objects that pertain to the given ShipSystem. - */ - public Collection getCoordsFor(ShipSystem sys) { - List coords = new ArrayList(); - - for (Entry e : mSystems.entrySet()) { - if (e.getValue().system == sys) { - coords.add(e.getKey()); - } - } - - return coords; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/TextUtil.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/TextUtil.java deleted file mode 100644 index 96800a5..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/TextUtil.java +++ /dev/null @@ -1,95 +0,0 @@ -package net.dhleong.acl.util; - -/** - * Various utility methods for coercing between hex values and other formats. - */ -public class TextUtil { - /** - * Converts the given byte to a hex String. - */ - public static String byteToHex(byte b) { - String hex = Integer.toHexString(b); - if (hex.length() >= 2) { - return hex.substring(hex.length()-2); - } - - return String.format("0%s", hex); - } - - /** - * Converts the given byte array to a hex String. - */ - public static String byteArrayToHexString(byte[] data) { - return byteArrayToHexString(data, 0, data.length); - } - - /** - * Converts a subset of the given byte array to a hex String. - */ - public static String byteArrayToHexString(byte[] data, int offset, int length) { - StringBuilder buf = new StringBuilder(); - final int end = offset + length; - - for (int i=offset; i < end; i++) { - byte b = data[i]; - - buf.append(byteToHex(b)); - } - - return buf.toString(); - } - - /** - * Converts an int to a hex String. - */ - public static String intToHex(int val) { - String hex = Integer.toHexString(val); - - if (hex.length() >= 8) { - return hex.substring(hex.length()-8); - } - - return String.format("%8s", hex).replace(' ', '0'); - } - - /** - * Converts an int to a little-endian hex String. - */ - public static String intToHexLE(int val) { - StringBuilder buf = new StringBuilder(); - - for (int i = 0; i < 32; i += 8) { - String hex = Integer.toHexString((0xff & (val >> i))); - - if (hex.length() == 1) { - buf.append('0'); - } - - buf.append(hex); - } - - return buf.toString(); - } - - /** - * Converts a hex String to a byte array. - */ - public static byte[] hexToByteArray(String hex) { - int len = hex.length(); - - if (len % 2 == 1) { - throw new IllegalArgumentException( - "Hex strings must contain two characters per byte: " + hex - ); - } - - byte[] bytes = new byte[len / 2]; - - for (int i = 0; i < len; i += 2) { - String hexByte = hex.substring(i, i + 2); - bytes[i / 2] = (byte) Integer.parseInt(hexByte, 16); - } - - return bytes; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/Util.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/Util.java deleted file mode 100644 index a25d831..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/Util.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.dhleong.acl.util; - -import java.nio.charset.Charset; -import java.util.Set; - -/** - * Miscellaneous unloved stuff that doesn't have a home right now. But don't - * worry, we love you and will find you a home. - */ -public class Util { - public static final Charset US_ASCII = Charset.forName("US-ASCII"); - public static final Charset UTF16LE = Charset.forName("UTF-16LE"); - - public static final String enumSetToString(Set> set) { - if (set.isEmpty()) { - return ""; - } - - StringBuilder b = new StringBuilder(); - - for (Enum val : set) { - if (b.length() != 0) { - b.append(' '); - } - - b.append(val); - } - - return b.toString(); - } -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/Version.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/Version.java deleted file mode 100644 index e6836f5..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/util/Version.java +++ /dev/null @@ -1,188 +0,0 @@ -package net.dhleong.acl.util; - -import java.util.Arrays; - -import net.dhleong.acl.iface.PacketWriter; - -/** - * Version number handling class. This handles semantic versioning - * (major.minor.patch), and can interpret float version numbers for backwards - * compatibility. For robustness and to avoid duplication of code, it can handle - * an arbitrary number of parts in the version number, not just three. - * @author rjwut - */ -public class Version implements Comparable { - public static final Version MODERN = new Version("2.1"); - - private int[] mParts; - private int hash; - - /** - * Constructs a Version from integer parts, with the most significant part - * first. This constructor can be used to create both modern and legacy - * version numbers. - */ - public Version(int... parts) { - mParts = parts; - hash = Arrays.hashCode(mParts); - } - - /** - * Interprets a float as a version number, with a check to ensure that - * versions prior to 1.41 are interpreted correctly according to the Artemis - * version history. This constructor can only be used to create legacy - * version numbers (earlier than version 2.1); later ones will throw an - * IllegalArgumentException. - * @see http://artemiswiki.pbworks.com/w/page/53699717/Version%20history - */ - public Version(float version) { - if (version >= 2.1) { - throw new IllegalArgumentException( - "Legacy version constructor is not valid for Artemis 2.1+" - ); - } - - int major = (int) Math.floor(version); - int minor = (int) Math.floor((version - major) * 100); - - if (minor < 40) { - minor /= 10; - } - - mParts = new int[] { major, minor, 0 }; - hash = Arrays.hashCode(mParts); - } - - /** - * Constructs a Version from a String. This constructor can be used to - * create both modern and legacy version numbers. - */ - public Version(String version) { - String[] strParts = version.split("\\."); - mParts = new int[strParts.length]; - - for (int i = 0; i < strParts.length; i++) { - mParts[i] = Integer.parseInt(strParts[i]); - } - - hash = Arrays.hashCode(mParts); - } - - /** - * Returns true if this is a legacy version number; false otherwise. Legacy - * versioning was deprecated as of Artemis 2.1, so this method will return - * true for all version numbers earlier than that. - */ - public boolean isLegacy() { - return lt(MODERN); - } - - /** - * Convenience method for compareTo(version) < 0. - */ - public boolean lt(Version version) { - return compareTo(version) < 0; - } - - /** - * Convenience method for compareTo(version) > 0. - */ - public boolean gt(Version version) { - return compareTo(version) > 0; - } - - /** - * Convenience method for compareTo(version) <= 0. - */ - public boolean le(Version version) { - return compareTo(version) <= 0; - } - - /** - * Convenience method for compareTo(version) >= 0. - */ - public boolean ge(Version version) { - return compareTo(version) >= 0; - } - - /** - * Writes this Version to the given PacketWriter. Writes both the legacy and - * (if applicable) modern version fields. Note that to ensure compatibility, - * modern version fields will always be written with exactly three parts. - */ - public void writeTo(PacketWriter writer) { - boolean legacy = isLegacy(); - writer.writeFloat(legacy ? mParts[0] + mParts[1] * 0.1f : 2.0f); - - if (!legacy) { - for (int i = 0; i < 3; i++) { - writer.writeInt(getPart(mParts, i)); - } - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof Version)) { - return false; - } - - return compareTo((Version) o) == 0; - } - - @Override - public int hashCode() { - return hash; - } - - @Override - public String toString() { - if (isLegacy()) { - return mParts[0] + "." + mParts[1]; - } - - StringBuilder b = new StringBuilder(); - - for (int part : mParts) { - if (b.length() != 0) { - b.append('.'); - } - - b.append(part); - } - - return b.toString(); - } - - /** - * Compares this Version against the given one. If the two Version objects - * don't have the same number of parts, the absent parts are treated as zero - * (e.g.: 2.1 is the same as 2.1.0). - */ - @Override - public int compareTo(Version o) { - int partCount = Math.max(mParts.length, o.mParts.length); - - for (int i = 0; i < partCount; i++) { - int c = getPart(mParts, i) - getPart(o.mParts, i); - - if (c != 0) { - return c; - } - } - - return 0; - } - - /** - * Returns the indicated part value for the given array of parts, or 0 if - * the index is greater than that of the last part. - */ - private static int getPart(int[] parts, int index) { - return parts.length > index ? parts[index] : 0; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/BeamPort.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/BeamPort.java deleted file mode 100644 index 4ff1ae2..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/BeamPort.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.dhleong.acl.vesseldata; - -/** - * Describes a single beam port on a vessel. Corresponds to the - * element in vesselData.xml. This class extends WeaponPort and adds an arcWidth - * property to define the beam weapon's firing arc. - * @author rjwut - */ -public class BeamPort extends WeaponPort { - float arcWidth; - - /** - * Returns the width of the beam arc in radians. - */ - public float getArcWidth() { - return arcWidth; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/ClasspathResolver.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/ClasspathResolver.java deleted file mode 100644 index d624f84..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/ClasspathResolver.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.dhleong.acl.vesseldata; - -import java.net.URI; -import java.net.URISyntaxException; - -class ClasspathResolver implements PathResolver { - @Override - public URI get(String path) throws URISyntaxException { - return getClass().getResource(path).toURI(); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/Faction.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/Faction.java deleted file mode 100644 index 79c921c..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/Faction.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.dhleong.acl.vesseldata; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import net.dhleong.acl.enums.FactionAttribute; - -/** - * Corresponds to the element in vesselData.xml. - * @author rjwut - */ -public class Faction { - private int id; - private String name; - private Set attributes; - List taunts = new ArrayList(3); - - Faction(int id, String name, String keys) { - this.id = id; - this.name = name; - attributes = FactionAttribute.build(keys); - } - - /** - * Returns the faction's ID. - */ - public int getId() { - return id; - } - - /** - * Returns the faction's name. - */ - public String getName() { - return name; - } - - /** - * Returns an array containing the FactionAttributes that correspond to this - * Faction. - */ - public FactionAttribute[] getAttributes() { - return attributes.toArray(new FactionAttribute[attributes.size()]); - } - - /** - * Returns true if this Faction has all the given FactionAttributes; false - * otherwise. - */ - public boolean is(FactionAttribute... attrs) { - for (FactionAttribute attr : attrs) { - if (!attributes.contains(attr)) { - return false; - } - } - - return true; - } - - /** - * Returns this Faction's Taunts. - */ - public Taunt[] getTaunts() { - return (Taunt[]) taunts.toArray(); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/FilePathResolver.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/FilePathResolver.java deleted file mode 100644 index f29c89b..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/FilePathResolver.java +++ /dev/null @@ -1,19 +0,0 @@ -package net.dhleong.acl.vesseldata; - -import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; - -class FilePathResolver implements PathResolver { - private File artemisInstallPath; - - FilePathResolver(File artemisInstallPath) { - this.artemisInstallPath = artemisInstallPath; - } - - @Override - public URI get(String path) throws URISyntaxException { - return new File(artemisInstallPath, path).toURI(); - } - -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/PathResolver.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/PathResolver.java deleted file mode 100644 index 4827270..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/PathResolver.java +++ /dev/null @@ -1,8 +0,0 @@ -package net.dhleong.acl.vesseldata; - -import java.net.URI; -import java.net.URISyntaxException; - -public interface PathResolver { - public URI get(String path) throws URISyntaxException; -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/SAXVesselDataHandler.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/SAXVesselDataHandler.java deleted file mode 100644 index e444f24..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/SAXVesselDataHandler.java +++ /dev/null @@ -1,353 +0,0 @@ -package net.dhleong.acl.vesseldata; - -import java.util.HashMap; -import java.util.Map; - -import net.dhleong.acl.enums.OrdnanceType; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -/** - * SAX ContentHandler implementation that can convert vesselData.xml to a - * VesselData object. - */ -public class SAXVesselDataHandler extends DefaultHandler { - /** - * Interface for classes which handle a specific element type in - * vesselData.xml. - */ - private interface Parser { - /** - * Invoked when the corresponding element is encountered by the SAX - * parser. - */ - void parse(Attributes attrs); - } - - VesselData vesselData; - private Map parsers = new HashMap(); - private Faction faction; - private Vessel vessel; - - SAXVesselDataHandler() { - parsers.put("art", new ArtParser()); - parsers.put("beam_port", new BeamPortParser()); - parsers.put("carrier", new CarrierParser()); - parsers.put("drone_port", new DronePortParser()); - parsers.put("engine_port", new EnginePortParser()); - parsers.put("fleet_ai", new FleetAiParser()); - parsers.put("hullRace", new HullRaceParser()); - parsers.put("impulse_point", new ImpulsePointParser()); - parsers.put("internal_data", new InternalDataParser()); - parsers.put("long_desc", new LongDescParser()); - parsers.put("maneuver_point", new ManeuverPointParser()); - parsers.put("performance", new PerformanceParser()); - parsers.put("production", new ProductionParser()); - parsers.put("shields", new ShieldsParser()); - parsers.put("taunt", new TauntParser()); - parsers.put("torpedo_station_port", new TorpedoStationPortParser()); - parsers.put("torpedo_storage", new TorpedoStorageParser()); - parsers.put("torpedo_tube", new TorpedoTubeParser()); - parsers.put("vessel", new VesselParser()); - parsers.put("vessel_data", new VesselDataParser()); - } - - @Override - public void startElement(String namespaceURI, String localName, - String qName, Attributes attrs) throws SAXException { - Parser parser = parsers.get(qName); - - if (parser != null) { - parser.parse(attrs); - } else { - System.err.println("Unknown element: " + qName); - } - } - - /** - * Converts an XML attribute to a float value, or 0.0f if the attribute is - * not found. - */ - private static float parseFloat(Attributes attrs, String name) { - String value = attrs.getValue(name); - return value != null ? Float.parseFloat(value) : 0.0f; - } - - /** - * Converts an XML attribute to an int value; or 0 if the attribute is not - * found. - */ - private static int parseInt(Attributes attrs, String name) { - String value = attrs.getValue(name); - return value != null ? Integer.parseInt(value) : 0; - } - - /** - * Extracts the x, y, and z attributes and writes them to the given - * VesselPoint object. - */ - private static void parseVesselPoint(VesselPoint point, Attributes attrs) { - point.x = Float.parseFloat(attrs.getValue("x")); - point.y = Float.parseFloat(attrs.getValue("y")); - point.z = Float.parseFloat(attrs.getValue("z")); - } - - /** - * Extracts weapon port attributes and writes them to the given WeaponPort - * object. - */ - public static void parseWeaponPort(WeaponPort port, Attributes attrs) { - parseVesselPoint(port, attrs); - port.damage = parseFloat(attrs, "damage"); - port.cycleTime = parseFloat(attrs, "cycletime"); - port.range = parseInt(attrs, "range"); - } - - /** - * Parser for elements. - */ - private class ArtParser implements Parser { - @Override - public void parse(Attributes attrs) { - vessel.meshFile = attrs.getValue("meshfile"); - vessel.diffuseFile = attrs.getValue("diffuseFile"); - vessel.glowFile = attrs.getValue("glowFile"); - vessel.specularFile = attrs.getValue("specularFile"); - vessel.scale = parseFloat(attrs, "scale"); - } - } - - /** - * Parser for elements. - */ - private class BeamPortParser implements Parser { - @Override - public void parse(Attributes attrs) { - BeamPort port = new BeamPort(); - parseWeaponPort(port, attrs); - port.arcWidth = parseFloat(attrs, "arcwidth"); - vessel.beamPorts.add(port); - } - } - - /** - * Parser for elements. - */ - private class CarrierParser implements Parser { - @Override - public void parse(Attributes attrs) { - vessel.fighterCount = parseInt(attrs, "complement"); - } - } - - /** - * Parser for elements. - */ - private class DronePortParser implements Parser { - @Override - public void parse(Attributes attrs) { - WeaponPort port = new WeaponPort(); - parseWeaponPort(port, attrs); - vessel.dronePorts.add(port); - } - } - - /** - * Parser for elements. - */ - private class EnginePortParser implements Parser { - @Override - public void parse(Attributes attrs) { - VesselPoint point = new VesselPoint(); - parseVesselPoint(point, attrs); - vessel.enginePorts.add(point); - } - } - - /** - * Parser for elements. - */ - private class FleetAiParser implements Parser { - @Override - public void parse(Attributes attrs) { - vessel.fleetAiCommonality = parseInt(attrs, "commonality"); - } - } - - /** - * Parser for elements. - */ - private class HullRaceParser implements Parser { - @Override - public void parse(Attributes attrs) { - int id = parseInt(attrs, "ID"); - faction = new Faction( - id, - attrs.getValue("name"), - attrs.getValue("keys") - ); - - while (vesselData.factions.size() <= id) { - vesselData.factions.add(null); - } - - vesselData.factions.set(id, faction); - } - } - - /** - * Parser for elements. - */ - private class ImpulsePointParser implements Parser { - @Override - public void parse(Attributes attrs) { - VesselPoint point = new VesselPoint(); - parseVesselPoint(point, attrs); - vessel.impulsePoints.add(point); - } - } - - /** - * Parser for elements. - */ - private class InternalDataParser implements Parser{ - @Override - public void parse(Attributes attrs) { - vessel.internals = new VesselInternals(attrs.getValue("file")); - } - } - - /** - * Parser for elements. - */ - private class LongDescParser implements Parser { - @Override - public void parse(Attributes attrs) { - vessel.description = attrs.getValue("text").replaceAll("\\^", "\n"); - } - } - - /** - * Parser for elements. - */ - private class ManeuverPointParser implements Parser { - @Override - public void parse(Attributes attrs) { - VesselPoint point = new VesselPoint(); - parseVesselPoint(point, attrs); - vessel.maneuverPoints.add(point); - } - } - - /** - * Parser for elements. - */ - private class PerformanceParser implements Parser { - @Override - public void parse(Attributes attrs) { - vessel.turnRate = parseFloat(attrs, "turnrate"); - vessel.topSpeed = parseFloat(attrs, "topspeed"); - vessel.efficiency = parseFloat(attrs, "efficiency"); - } - } - - /** - * Parser for elements. - */ - private class ProductionParser implements Parser { - @Override - public void parse(Attributes attrs) { - vessel.productionCoeff = parseFloat(attrs, "coeff"); - } - } - - /** - * Parser for elements. - */ - private class ShieldsParser implements Parser { - @Override - public void parse(Attributes attrs) { - vessel.foreShields = parseInt(attrs, "front"); - vessel.aftShields = parseInt(attrs, "back"); - } - } - - /** - * Parser for elements. - */ - private class TauntParser implements Parser { - @Override - public void parse(Attributes attrs) { - faction.taunts.add(new Taunt( - attrs.getValue("immunity"), - attrs.getValue("text") - )); - } - } - - /** - * Parser for elements. - */ - private class TorpedoStationPortParser implements Parser { - @Override - public void parse(Attributes attrs) { - WeaponPort port = new WeaponPort(); - parseWeaponPort(port, attrs); - vessel.baseTorpedoPorts.add(port); - } - } - - /** - * Parser for elements. - */ - private class TorpedoStorageParser implements Parser { - @Override - public void parse(Attributes attrs) { - OrdnanceType type = OrdnanceType.values()[parseInt(attrs, "type")]; - Integer amount = Integer.valueOf(attrs.getValue("amount")); - vessel.torpedoStorage.put(type, amount); - vessel.totalTorpedoStorage += amount.intValue(); - } - } - - /** - * Parser for elements. - */ - private class TorpedoTubeParser implements Parser { - @Override - public void parse(Attributes attrs) { - VesselPoint point = new VesselPoint(); - parseVesselPoint(point, attrs); - vessel.torpedoTubes.add(point); - } - } - - /** - * Parser for elements. - */ - private class VesselParser implements Parser { - @Override - public void parse(Attributes attrs) { - Integer id = Integer.valueOf(attrs.getValue("uniqueID")); - vessel = new Vessel( - id.intValue(), - parseInt(attrs, "side"), - attrs.getValue("classname"), - attrs.getValue("broadType") - ); - vesselData.vessels.put(id, vessel); - } - } - - /** - * Parser for the main element. - */ - private class VesselDataParser implements Parser { - @Override - public void parse(Attributes attrs) { - vesselData = new VesselData(attrs.getValue("version")); - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/Taunt.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/Taunt.java deleted file mode 100644 index 93aceb7..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/Taunt.java +++ /dev/null @@ -1,30 +0,0 @@ -package net.dhleong.acl.vesseldata; - -/** - * Faction-specific taunts. - * @author rjwut - */ -public class Taunt { - private String immunity; - private String text; - - Taunt(String immunity, String text) { - this.immunity = immunity; - this.text = text; - } - - /** - * The indicator in the captain's psychological profile that indicates that - * they are immune to this taunt. - */ - public String getImmunity() { - return immunity; - } - - /** - * The actual text of the taunt. - */ - public String getText() { - return text; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/Vessel.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/Vessel.java deleted file mode 100644 index bf0ca2e..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/Vessel.java +++ /dev/null @@ -1,309 +0,0 @@ -package net.dhleong.acl.vesseldata; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import net.dhleong.acl.enums.OrdnanceType; -import net.dhleong.acl.enums.VesselAttribute; - -/** - * Corresponds to the element in vesselData.xml. Note that this - * represents an entire class of ships, not an individual one. - * @author rjwut - */ -public class Vessel { - private int id; - private int side; - private String name; - String description; - private Set attributes; - String meshFile; - String diffuseFile; - String glowFile; - String specularFile; - VesselInternals internals; - float scale; - int pushRadius; - int foreShields; - int aftShields; - float turnRate; - float topSpeed; - float efficiency; - int fleetAiCommonality; - int fighterCount; - float productionCoeff; - List beamPorts = new ArrayList(); - List torpedoTubes = new ArrayList(); - Map torpedoStorage = new LinkedHashMap(); - int totalTorpedoStorage; - List dronePorts = new ArrayList(); - List baseTorpedoPorts = new ArrayList(); - List enginePorts = new ArrayList(); - List impulsePoints = new ArrayList(); - List maneuverPoints = new ArrayList(); - - Vessel(int uniqueID, int side, String className, String broadType) { - id = uniqueID; - this.side = side; - name = className; - attributes = VesselAttribute.build(broadType); - - for (OrdnanceType type : OrdnanceType.values()) { - torpedoStorage.put(type, Integer.valueOf(0)); - } - } - - /** - * Returns the Vessel's ID. - */ - public int getId() { - return id; - } - - /** - * Returns the Vessel's Faction ID. - */ - public int getSide() { - return side; - } - - /** - * Returns the Faction to which this Vessel belongs. - */ - public Faction getFaction() { - return VesselData.get().getFaction(side); - } - - /** - * Returns this Vessel's name. - */ - public String getName() { - return name; - } - - /** - * Returns a short description of this Vessel. - */ - public String getDescription() { - return description; - } - - /** - * Returns an array of this Vessel's VesselAttributes. - */ - public VesselAttribute[] getAttributes() { - return attributes.toArray(new VesselAttribute[attributes.size()]); - } - - /** - * Returns true if this Vessel has all the given VesselAttribute; false - * otherwise. - */ - public boolean is(VesselAttribute... attrs) { - for (VesselAttribute attr : attrs) { - if (!attributes.contains(attr)) { - return false; - } - } - - return true; - } - - /** - * Returns the 3D mesh filename. - */ - public String getMeshFile() { - return meshFile; - } - - /** - * Returns the diffuse image filename. - */ - public String getDiffuseFile() { - return diffuseFile; - } - - /** - * Returns the glow image filename. - */ - public String getGlowFile() { - return glowFile; - } - - /** - * Returns the specular image filename. - */ - public String getSpecularFile() { - return specularFile; - } - - /** - * Returns the VesselInternals object describing the system node structure - * for this Vessel, or null if there is none. (Only player ships will have - * a VesselInternals object.) - */ - public VesselInternals getInternals() { - return internals; - } - - /** - * Returns this Vessel's scale value. This presumably controls how large it - * is. - */ - public float getScale() { - return scale; - } - - /** - * Returns this Vessel's push radius. This presumably how close other - * objects can get before they are considered to have collided with this - * Vessel. - */ - public int getPushRadius() { - return pushRadius; - } - - /** - * Returns the initial strength of this Vessel's forward shields. - */ - public int getForeShields() { - return foreShields; - } - - /** - * Returns the initial strength of this Vessel's aft shields. - */ - public int getAftShields() { - return aftShields; - } - - /** - * Returns this Vessel's turn rate. - */ - public float getTurnRate() { - return turnRate; - } - - /** - * Returns this Vessel's top (impulse) speed. - */ - public float getTopSpeed() { - return topSpeed; - } - - /** - * Returns this Vessel's efficiency rating. - */ - public float getEfficiency() { - return efficiency; - } - - /** - * Returns this Vessel's fleet AI commonality value. It is unknown what - * exactly this value does. - */ - public int getFleetAiCommonality() { - return fleetAiCommonality; - } - - /** - * Returns the number of fighters this Vessel has. Only Vessels that were - * declared with the element will have fighters, and presumably - * only those with VesselAttribute.CARRIER. - */ - public int getFighterCount() { - return fighterCount; - } - - /** - * Returns the base production coefficient. This value affects how quickly - * the base produces new ordnance. - */ - public float getProductionCoeff() { - return productionCoeff; - } - - /** - * Returns an array of BeamPort objects describing the beams with which this - * Vessel is equipped. - */ - public BeamPort[] getBeamPorts() { - return beamPorts.toArray(new BeamPort[beamPorts.size()]); - } - - /** - * Returns an array of VesselPoint objects describing the locations of the - * Vessel's torpedo tubes. - */ - public VesselPoint[] getTorepedoTubes() { - return torpedoTubes.toArray(new BeamPort[torpedoTubes.size()]); - } - - /** - * Returns the number of units of the given OrdnanceType this Vessel can - * carry. - */ - public int getTorpedoStorage(OrdnanceType type) { - return torpedoStorage.get(type).intValue(); - } - - /** - * Returns true if this Vessel is capable of launching ordnance; false - * otherwise. To launch ordnance, a player Vessel must have at least one - * torpedo tube and storage space for at least one torpedo. Other Vessel - * types must have at least one drone port or base torpedo port. - */ - public boolean canLaunchOrdnance() { - if (is(VesselAttribute.PLAYER)) { - return !torpedoTubes.isEmpty() && totalTorpedoStorage > 0; - } - - return !dronePorts.isEmpty() || !baseTorpedoPorts.isEmpty(); - } - - /** - * Returns an array of WeaponPoint objects describing the locations of the - * Vessel's drone launchers. - */ - public WeaponPort[] getDronePorts() { - return dronePorts.toArray(new WeaponPort[dronePorts.size()]); - } - - /** - * Returns an array of WeaponPoint objects describing the locations of the - * Vessel's torpedo launchers. As of this writing, only the Command Station - * base has this port in the stock Artemis install; player vessels have - * torpedo tubes instead, and no other vessels launch torpedoes (although - * Torgoth drones are basically the same). - */ - public WeaponPort[] getBaseTorpedoPorts() { - return baseTorpedoPorts.toArray(new WeaponPort[baseTorpedoPorts.size()]); - } - - /** - * Returns an array of VesselPoint objects describing the locations of the - * Vessel's engine ports. - */ - public VesselPoint[] getEnginePorts() { - return enginePorts.toArray(new VesselPoint[enginePorts.size()]); - } - - /** - * Returns an array of VesselPoint objects describing the locations of the - * Vessel's impulse points. - */ - public VesselPoint[] getImpulsePoints() { - return impulsePoints.toArray(new VesselPoint[impulsePoints.size()]); - } - - /** - * Returns an array of VesselPoint objects describing the locations of the - * Vessel's maneuver points. - */ - public VesselPoint[] getManeuverPoints() { - return maneuverPoints.toArray(new VesselPoint[maneuverPoints.size()]); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselData.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselData.java deleted file mode 100644 index ccff389..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselData.java +++ /dev/null @@ -1,137 +0,0 @@ -package net.dhleong.acl.vesseldata; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -import net.dhleong.acl.util.Version; - -/** - * Contains all the information extracted from the vesselData.xml file. - * @author rjwut - */ -public class VesselData { - static PathResolver pathResolver; - private static VesselData instance; - - /** - * Loads the default vesselData.xml packaged with ArtClientLib. This is - * invoked when get() is called without calling load(File) first. - */ - private static void load() { - pathResolver = new ClasspathResolver(); - - try { - loadInternal(); - } catch (VesselDataException ex) { - throw new RuntimeException(ex); // shouldn't happen - } - } - - /** - * Loads the vesselData.xml file from the Artemis installation found at the - * given path. This allows ArtClientLib to handle modded Artemis installs. - * If get() is called without invoking this method, the default - * vesselData.xml file bundled with ArtClientLib is used instead. - */ - public static void load(File artemisInstallPath) throws VesselDataException { - pathResolver = new FilePathResolver(artemisInstallPath); - loadInternal(); - } - - /** - * Returns the VesselData instance. If load(File) has been invoked, the - * VesselData object will reflect whatever customizations have been made on - * that Artemis installation. Otherwise, it will contain the values for a - * stock Artemis install. - */ - public static VesselData get() { - if (instance == null) { - load(); - } - - return instance; - } - - /** - * Parses the vessel data XML file at the given URI and stores the result - * in the VesselData.instance static field. - */ - private static void loadInternal() throws VesselDataException { - try { - SAXParserFactory spf = SAXParserFactory.newInstance(); - SAXParser saxParser = spf.newSAXParser(); - XMLReader xmlReader = saxParser.getXMLReader(); - SAXVesselDataHandler handler = new SAXVesselDataHandler(); - xmlReader.setContentHandler(handler); - xmlReader.parse(pathResolver.get("dat/vesselData.xml").toString()); - instance = handler.vesselData; - } catch (URISyntaxException ex) { // shouldn't happen - throw new VesselDataException(ex); - } catch (SAXException ex) { - throw new VesselDataException(ex); - } catch (ParserConfigurationException ex) { - throw new VesselDataException(ex); - } catch (IOException ex) { - throw new VesselDataException(ex); - } - } - - Version version; - List factions = new ArrayList(); - Map vessels = new LinkedHashMap(); - - VesselData(String version) { - this.version = new Version(version); - } - - /** - * Returns the version of Artemis reported by vesselData.xml. Note that this - * does not neccessarily match the version reported by the protocol; the - * version in vesselData.xml is known to lag behind the actual version - * number. - */ - public Version getVersion() { - return version; - } - - /** - * Returns the Faction represented by the given ID. - */ - public Faction getFaction(int id) { - return factions.get(id); - } - - /** - * Returns the Vessel represented by the given ID. - */ - public Vessel getVessel(int id) { - return vessels.get(Integer.valueOf(id)); - } - - /** - * Iterates all the Factions in this object. - */ - public Iterator factionIterator() { - return factions.iterator(); - } - - /** - * Iterates all the Vessels in this object. - */ - public Iterator vesselIterator() { - return vessels.values().iterator(); - } -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselDataException.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselDataException.java deleted file mode 100644 index 2a84bc5..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselDataException.java +++ /dev/null @@ -1,13 +0,0 @@ -package net.dhleong.acl.vesseldata; - -/** - * Thrown when ArtClientLib fails to parse the vesselData.xml file. - * @author rjwut - */ -public class VesselDataException extends Exception { - private static final long serialVersionUID = -495427263065919450L; - - public VesselDataException(Exception ex) { - super(ex); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselInternals.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselInternals.java deleted file mode 100644 index aa76d92..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselInternals.java +++ /dev/null @@ -1,113 +0,0 @@ -package net.dhleong.acl.vesseldata; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -import net.dhleong.acl.util.GridCoord; - -/** - * An object which describes the internal system grid of a Vessel. Note that while the .snt file - * contains an entry for every coordinate in the internal grid, this object will only contain - * VesselNodes for coordinates that correspond to a ship system or a hallway. - * @author rjwut - */ -public class VesselInternals { - public static final int GRID_SIZE_X = 5; - public static final int GRID_SIZE_Y = 5; - public static final int GRID_SIZE_Z = 10; - - private Map map = new LinkedHashMap(); - private Set connections = new HashSet(); - private byte[] buffer = new byte[VesselNode.BLOCK_SIZE]; - - public VesselInternals(String sntPath) { - URI uri; - - try { - uri = VesselData.pathResolver.get(sntPath); - } catch (URISyntaxException ex) { - throw new RuntimeException(ex); - } - - InputStream in = null; - - try { - in = uri.toURL().openStream(); - load(new BufferedInputStream(in)); - } catch (MalformedURLException ex) { - throw new RuntimeException(ex); - } catch (IOException ex) { - throw new RuntimeException(ex); - } catch (InterruptedException ex) { - throw new RuntimeException(ex); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException ex) { - // don't care - } - } - } - } - - /** - * Builds a VesselInternals object from the .snt file read from the given InputStream. - */ - private void load(InputStream in) throws InterruptedException, IOException { - for (int x = 0; x < GRID_SIZE_X; x++) { - for (int y = 0; y < GRID_SIZE_Y; y++) { - for (int z = 0; z < GRID_SIZE_Z; z++) { - GridCoord coords = GridCoord.getInstance(x, y, z); - VesselNode node = new VesselNode(in, coords, buffer); - - if (node.isAccessible()) { - map.put(coords, node); - buildAdjacency(node, x - 1, y, z); - buildAdjacency(node, x, y - 1, z); - buildAdjacency(node, x, y, z - 1); - } - } - } - } - } - - private void buildAdjacency(VesselNode node, int x, int y, int z) { - VesselNode adjacentNode = map.get(GridCoord.getInstance(x, y, z)); - - if (adjacentNode != null) { - connections.add(new VesselNodeConnection(adjacentNode, node)); - } - } - - /** - * Returns the VesselNode located at the given internal grid coordinates, or null if there is - * no VesselNode at that location. - */ - public VesselNode get(int x, int y, int z) { - return map.get(GridCoord.getInstance(x, y, z)); - } - - /** - * Iterates all VesselNodes. - */ - public Iterator nodeIterator() { - return map.values().iterator(); - } - - /** - * Iterates all VesselNodeConnections. - */ - public Iterator connectionIterator() { - return connections.iterator(); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselNode.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselNode.java deleted file mode 100644 index 33c0db1..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselNode.java +++ /dev/null @@ -1,102 +0,0 @@ -package net.dhleong.acl.vesseldata; - -import java.io.IOException; -import java.io.InputStream; - -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.util.ByteArrayReader; -import net.dhleong.acl.util.GridCoord; - -public class VesselNode { - static final int BLOCK_SIZE = 32; - private static final int EMPTY_NODE_VALUE = -2; - private static final int HALLWAY_NODE_VALUE = -1; - - private GridCoord coords; - private float x; - private float y; - private float z; - private boolean accessible; - private ShipSystem system; - - VesselNode (InputStream in, GridCoord coords, byte[] buffer) throws InterruptedException, IOException { - ByteArrayReader.readBytes(in, BLOCK_SIZE, buffer); - ByteArrayReader reader = new ByteArrayReader(buffer); - this.coords = coords; - x = reader.readFloat(); - y = reader.readFloat(); - z = reader.readFloat(); - int typeValue = reader.readInt(); - accessible = typeValue != EMPTY_NODE_VALUE; - - if (accessible && typeValue != HALLWAY_NODE_VALUE) { - system = ShipSystem.values()[typeValue]; - } - } - - /** - * Returns the GridCoord for this node's location in the system grid. - */ - public GridCoord getGridCoord() { - return coords; - } - - /** - * Returns the X-coordinate of this node relative to the origin of the ship's model coordinates. - */ - public float getX() { - return x; - } - - /** - * Returns the Y-coordinate of this node relative to the origin of the ship's model coordinates. - */ - public float getY() { - return y; - } - - /** - * Returns the Z-coordinate of this node relative to the origin of the ship's model coordinates. - */ - public float getZ() { - return z; - } - - /** - * Returns true if it's possible for DAMCON teams to access this node; false otherwise. - */ - public boolean isAccessible() { - return accessible; - } - - /** - * Returns the ShipSystem found here, or null if there is none. - */ - public ShipSystem getSystem() { - return system; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (!(obj instanceof VesselNode)) { - return false; - } - - VesselNode that = (VesselNode) obj; - return coords.equals(that.coords); - } - - @Override - public int hashCode() { - return coords.hashCode(); - } - - @Override - public String toString() { - return coords.toString() + '=' + (accessible ? (system != null ? system : "hallway") : "empty"); - } -} diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselNodeConnection.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselNodeConnection.java deleted file mode 100644 index 0a104d3..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselNodeConnection.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.dhleong.acl.vesseldata; - -/** - * Represents a connection between two VesselNodes. - * @author rjwut - */ -public class VesselNodeConnection { - private VesselNode node1; - private VesselNode node2; - - VesselNodeConnection(VesselNode node1, VesselNode node2) { - this.node1 = node1; - this.node2 = node2; - } - - public VesselNode getNode1() { - return node1; - } - - public VesselNode getNode2() { - return node2; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (!(obj instanceof VesselNodeConnection)) { - return false; - } - - VesselNodeConnection that = (VesselNodeConnection) obj; - return node1.equals(that.node1) && node2.equals(that.node2); - } - - @Override - public int hashCode() { - int hash1 = node1.hashCode(); - int hash2 = node2.hashCode(); - return 31 * (hash1 ^ (hash1 >>> 32)) + (hash2 ^ (hash2 >>> 32)); - } - - @Override - public String toString() { - return node1 + " <=> " + node2; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselPoint.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselPoint.java deleted file mode 100644 index 5c5f07f..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/VesselPoint.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.dhleong.acl.vesseldata; - -/** - * A location on a Vessel's 3D mesh. - * @author rjwut - */ -public class VesselPoint { - float x; - float y; - float z; - - /** - * Returns the point's X coordinate. - */ - public float getX() { - return x; - } - - /** - * Returns the point's Y coordinate. - */ - public float getY() { - return y; - } - - /** - * Returns the point's Z coordinate. - */ - public float getZ() { - return z; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/WeaponPort.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/WeaponPort.java deleted file mode 100644 index 38263c7..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/vesseldata/WeaponPort.java +++ /dev/null @@ -1,35 +0,0 @@ -package net.dhleong.acl.vesseldata; - -/** - * A subclass of VesselPoint for weapon ports. In addition to their location on - * the Vessel's 3D mesh, WeaponPorts also have damage, cycle time and range - * values. Beam ports (subclassed as BeamPort), Torgoth drone launchers and - * base torpedo ports are WeaponPorts. Player ship torpedo tubes, while - * technically being weapon ports, are simply VesselPoints, since they don't - * have damage, cycle time and range properties; those properties are dictated - * by the ordnance loaded in them. - * @author rjwut - */ -public class WeaponPort extends VesselPoint { - float damage; - float cycleTime; - int range; - - /** - * The amount of damage that this weapon port can inflict. - */ - public float getDamage() { - return damage; - } - - /** - * The time (in seconds) this port requires to cool down between shots. - */ - public float getCycleTime() { - return cycleTime; - } - - public int getRange() { - return range; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/Artemis.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/Artemis.java deleted file mode 100644 index c313276..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/Artemis.java +++ /dev/null @@ -1,56 +0,0 @@ -package net.dhleong.acl.world; - -import net.dhleong.acl.enums.ShipSystem; - -/** - * Contains miscellaneous constants about the game world. - * @author rjwut - */ -public final class Artemis { - /** - * The default amount of coolant the player ship has at start. The amount of - * coolant may change due to side mission rewards or custom scripting. - */ - public static final int DEFAULT_COOLANT = 8; - - /** - * The maximum amount of coolant that can be applied to any one system. - */ - public static final int MAX_COOLANT_PER_SYSTEM = 8; - - /** - * The maximum energy allocation for a system, in percentage points. - */ - public static final int MAX_ENERGY_ALLOCATION_PERCENT = 300; - - /** - * The maximum number of tubes a ship can have. Note that none of the ships - * in the stock install of Artemis have this many tubes, but a custom ship - * might. - */ - public static final int MAX_TUBES = 6; - - /** - * The maximum warp factor player ships can achieve. - */ - public static final int MAX_WARP = 4; - - /** - * The number of available player ships. - */ - public static final int SHIP_COUNT = 8; - - /** - * The number of ship systems. - */ - public static final int SYSTEM_COUNT = ShipSystem.values().length; - - /** - * The length of the sides of the map (the X and Z dimensions). - */ - public static final int MAP_SIZE = 100000; - - private Artemis() { - // prevent instantiation of this class - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisAnomaly.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisAnomaly.java deleted file mode 100644 index 72e0356..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisAnomaly.java +++ /dev/null @@ -1,46 +0,0 @@ -package net.dhleong.acl.world; - -import java.util.SortedMap; - -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.enums.Upgrade; - -public class ArtemisAnomaly extends BaseArtemisObject { - private Upgrade mUpgrade; - - public ArtemisAnomaly(int objId) { - super(objId); - } - - @Override - public ObjectType getType() { - return ObjectType.ANOMALY; - } - - public Upgrade getUpgrade() { - return mUpgrade; - } - - public void setUpgrade(Upgrade upgrade) { - mUpgrade = upgrade; - } - - @Override - public void updateFrom(ArtemisObject obj) { - super.updateFrom(obj); - - if (obj instanceof ArtemisAnomaly) { - ArtemisAnomaly anomaly = (ArtemisAnomaly) obj; - - if (anomaly.mUpgrade != null) { - mUpgrade = anomaly.mUpgrade; - } - } - } - - @Override - public void appendObjectProps(SortedMap props, boolean includeUnspecified) { - super.appendObjectProps(props, includeUnspecified); - putProp(props, "Upgrade", mUpgrade, includeUnspecified); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisBase.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisBase.java deleted file mode 100644 index ef5dab4..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisBase.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.dhleong.acl.world; - -import java.util.SortedMap; - -import net.dhleong.acl.enums.ObjectType; - -/** - * Bases - */ -public class ArtemisBase extends BaseArtemisShielded { - private int mIndex = -1; - - public ArtemisBase(int objId) { - super(objId); - } - - @Override - public ObjectType getType() { - return ObjectType.BASE; - } - - /** - * This base's index value. In non-scripted scenarios, DS1's index is 0, - * DS2's index is 1, etc. This value is unique even if the names aren't. - * Unspecified: -1 - */ - public int getIndex() { - return mIndex; - } - - public void setIndex(int index) { - mIndex = index; - } - - @Override - public void updateFrom(ArtemisObject eng) { - super.updateFrom(eng); - - if (eng instanceof ArtemisBase) { - ArtemisBase base = (ArtemisBase) eng; - - if (base.mIndex != -1) { - mIndex = base.mIndex; - } - } - } - - @Override - public void appendObjectProps(SortedMap props, boolean includeUnspecified) { - super.appendObjectProps(props, includeUnspecified); - putProp(props, "Base index", mIndex, -1, includeUnspecified); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisCreature.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisCreature.java deleted file mode 100644 index 6518aab..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisCreature.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.dhleong.acl.world; - -import java.util.SortedMap; - -import net.dhleong.acl.enums.CreatureType; -import net.dhleong.acl.enums.ObjectType; - -/** - * Various spacefaring creatures (and... wrecks?) - */ -public class ArtemisCreature extends BaseArtemisOrientable { - private CreatureType mCreatureType; - - public ArtemisCreature(int objId) { - super(objId); - } - - @Override - public ObjectType getType() { - return ObjectType.CREATURE; - } - - @Override - public void updateFrom(ArtemisObject obj) { - super.updateFrom(obj); - - if (obj instanceof ArtemisCreature) { - ArtemisCreature cast = (ArtemisCreature) obj; - - CreatureType creatureType = cast.getCreatureType(); - - if (creatureType != null) { - setCreatureType(creatureType); - } - } - } - - public CreatureType getCreatureType() { - return mCreatureType; - } - - public void setCreatureType(CreatureType creatureType) { - mCreatureType = creatureType; - } - - @Override - public void appendObjectProps(SortedMap props, boolean includeUnspecified) { - super.appendObjectProps(props, includeUnspecified); - putProp(props, "Creature type", mCreatureType, includeUnspecified); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisDrone.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisDrone.java deleted file mode 100644 index 60423b9..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisDrone.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.dhleong.acl.world; - -import java.util.SortedMap; - -import net.dhleong.acl.enums.ObjectType; - -public class ArtemisDrone extends BaseArtemisOrientable { - private float mSteering = -1; - - public ArtemisDrone(int objId) { - super(objId); - } - - @Override - public ObjectType getType() { - return ObjectType.DRONE; - } - - public float getSteering() { - return mSteering; - } - - public void setSteering(float steering) { - this.mSteering = steering; - } - - @Override - public void updateFrom(ArtemisObject other) { - super.updateFrom(other); - - if (other instanceof ArtemisDrone) { - ArtemisDrone drone = (ArtemisDrone) other; - - if (drone.mSteering != -1) { - mSteering = drone.mSteering; - } - } - } - - @Override - public void appendObjectProps(SortedMap props, boolean includeUnspecified) { - super.appendObjectProps(props, includeUnspecified); - putProp(props, "Rudder", mSteering, -1, includeUnspecified); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisGenericObject.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisGenericObject.java deleted file mode 100644 index 4e77934..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisGenericObject.java +++ /dev/null @@ -1,33 +0,0 @@ -package net.dhleong.acl.world; - -import net.dhleong.acl.enums.ObjectType; - -/** - * There are many "generic" objects which are very similar in implementation. - * They are all handled by this class. Specifically, the objects implemented by - * this class are: mines, torpedoes, black holes and asteroids. - * @author dhleong - */ -public class ArtemisGenericObject extends BaseArtemisObject { - private ObjectType mType; - - public ArtemisGenericObject(int objId) { - super(objId); - } - - @Override - public ObjectType getType() { - return mType; - } - - public void setType(ObjectType type) { - if (type == null || !type.isCompatible(this)) { - throw new IllegalArgumentException( - "Invalid object type for " + getClass().getName() + ": " + - type - ); - } - - mType = type; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisMesh.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisMesh.java deleted file mode 100644 index 5870051..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisMesh.java +++ /dev/null @@ -1,159 +0,0 @@ -package net.dhleong.acl.world; - -import java.util.SortedMap; - -import net.dhleong.acl.enums.ObjectType; - -/** - * This is a custom-rendered mesh in the game world. These are typically - * inserted by scripts for non-interactive objects. - * @author dhleong - */ -public class ArtemisMesh extends BaseArtemisObject { - private String mMesh; - private String mTex; - private boolean hasColor; - private int mColor; - private float mShieldsFront = Float.MIN_VALUE; - private float mShieldsRear = Float.MIN_VALUE; - - public ArtemisMesh(int objId) { - super(objId); - } - - @Override - public ObjectType getType() { - return ObjectType.GENERIC_MESH; - } - - /** - * The 3D mesh filename - * Unspecified: null - */ - public String getMesh() { - return mMesh; - } - - public void setMesh(String path) { - mMesh = path; - } - - /** - * The texture filename - * Unspecified: null - */ - public String getTexture() { - return mTex; - } - - public void setTexture(String path) { - mTex = path; - } - - public boolean hasColor() { - return hasColor; - } - - /** - * The color that will be used to render this object on sensor views. This - * is specified as an ARGB int value. To specify each channel separately, - * use the setARGB() method. - * Unspecified: 0 - */ - public int getColor() { - return mColor; - } - - public int getAlpha() { - return (mColor >>> 24) & 0xff; - } - - public int getRed() { - return (mColor >>> 16) & 0xff; - } - - public int getGreen() { - return (mColor >>> 8) & 0xff; - } - - public int getBlue() { - return mColor & 0xff; - } - - /** - * Sets the color that will be used to render this object on sensor views, - * specifying each channel as a value between 0 and 255. - */ - public void setARGB(int a, int r, int g, int b) { - mColor = 0; - mColor |= ((a & 0xff) << 24); - mColor |= ((r & 0xff) << 16); - mColor |= ((g & 0xff) << 8); - mColor |= (b & 0xff); - hasColor = true; - } - - /** - * Sets the color that will be used to render this object on sensor views, - * specifying each channel as a value between 0 and 1. - */ - public void setARGB(float a, float r, float g, float b) { - setARGB( - (int)(255 * a), - (int)(255 * r), - (int)(255 * g), - (int)(255 * b) - ); - } - - /** - * Returns the strength of the mesh's forward shields. These are supposedly - * "fake" shields, since meshes can't actually be targeted. - * Unspecified: Float.MIN_VALUE - */ - public float getShieldsFront() { - return mShieldsFront; - } - - /** - * Returns the strength of the mesh's aft shields. These are supposedly - * "fake" shields, since meshes can't actually be targeted. - * Unspecified: Float.MIN_VALUE - */ - public float getShieldsRear() { - return mShieldsRear; - } - - /** - * Sets the strength of the front and aft shields. These are supposedly - * "fake" shields, since meshes can't actually be targeted. - */ - public void setFakeShields(float shieldsFront, float shieldsRear) { - mShieldsFront = shieldsFront; - mShieldsRear = shieldsRear; - } - - @Override - public void updateFrom(ArtemisObject other) { - super.updateFrom(other); - - ArtemisMesh m = (ArtemisMesh) other; - if (m.mShieldsFront != Float.MIN_VALUE) { - mShieldsFront = m.mShieldsFront; - } - - if (m.mShieldsRear != Float.MIN_VALUE) { - mShieldsRear = m.mShieldsRear; - } - } - - @Override - public void appendObjectProps(SortedMap props, boolean includeUnspecified) { - super.appendObjectProps(props, includeUnspecified); - putProp(props, "Mesh", mMesh, includeUnspecified); - putProp(props, "Texture", mTex, includeUnspecified); - putProp(props, "Color", mColor, 0, includeUnspecified); - putProp(props, "Shields: fore", mShieldsFront, Float.MIN_VALUE, includeUnspecified); - putProp(props, "Shields: aft", mShieldsRear, Float.MIN_VALUE, includeUnspecified); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisNebula.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisNebula.java deleted file mode 100644 index 3ad4f42..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisNebula.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.dhleong.acl.world; - -import net.dhleong.acl.enums.ObjectType; - -public class ArtemisNebula extends BaseArtemisObject { - private boolean hasColor; - private byte a; - private byte r; - private byte g; - private byte b; - - public ArtemisNebula(int objId) { - super(objId); - setName("NEBULA"); - } - - @Override - public ObjectType getType() { - return ObjectType.NEBULA; - } - - public boolean hasColor() { - return hasColor; - } - - /** - * The color of the nebula. This is specified as an ARGB int value. To - * specify each channel separately, use the setARGB() method. - * Unspecified: 0 - */ - public int getColor() { - return a << 24 | r << 16 | g << 8 | b; - } - - public byte getAlpha() { - return a; - } - - public byte getRed() { - return r; - } - - public byte getGreen() { - return g; - } - - public byte getBlue() { - return b; - } - - /** - * Sets the color of the nebula, specifying each channel as a value between - * 0 and 255. - */ - public void setARGB(byte a, byte r, byte g, byte b) { - this.a = a; - this.r = r; - this.g = g; - this.b = b; - hasColor = true; - } - - /** - * Sets the color that will be used to render this object on sensor views, - * specifying each channel as a value between 0 and 1. - */ - public void setARGB(float a, float r, float g, float b) { - setARGB( - (byte) (255 * a), - (byte) (255 * r), - (byte) (255 * g), - (byte) (255 * b) - ); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisNpc.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisNpc.java deleted file mode 100644 index 7cb16b7..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisNpc.java +++ /dev/null @@ -1,265 +0,0 @@ -package net.dhleong.acl.world; - -import java.util.Set; -import java.util.SortedMap; - -import net.dhleong.acl.enums.EliteAbility; -import net.dhleong.acl.enums.FactionAttribute; -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.util.BoolState; -import net.dhleong.acl.util.Util; -import net.dhleong.acl.vesseldata.Faction; -import net.dhleong.acl.vesseldata.Vessel; - -/** - * An NPC ship; they may have special abilities, and can be scanned. - * @author dhleong - */ -public class ArtemisNpc extends BaseArtemisShip { - // scan levels... only 2 for now - public static final byte SCAN_LEVEL_BASIC = 1; - public static final byte SCAN_LEVEL_FULL = 2; - - private byte mScanLevel = -1; - private int mElite = -1, mEliteState = -1; - private BoolState mEnemy = BoolState.UNKNOWN; - private BoolState mSurrendered = BoolState.UNKNOWN; - private byte mFleetNumber = (byte) -1; - private String mIntel; - private final float[] mSysDamage = new float[8]; - - public ArtemisNpc(int objId) { - super(objId); - - for (int i = 0; i < 8; i++) { - mSysDamage[i] = -1; - } - } - - @Override - public ObjectType getType() { - return ObjectType.NPC_SHIP; - } - - /** - * Returns BoolState.TRUE if this ship is an enemy, BoolState.FALSE if it's - * friendly. Note that this only works in Solo mode. - * Unspecified: BoolState.UNKNOWN - */ - public BoolState isEnemy() { - return mEnemy; - } - - public void setEnemy(BoolState enemy) { - mEnemy = enemy; - } - - /** - * Returns BoolState.TRUE if this ship has surrendered, and BoolState.FALSE - * if it hasn't. - * Unspecified: BoolState.UNKNOWN - */ - public BoolState isSurrendered() { - return mSurrendered; - } - - public void setSurrendered(BoolState surrendered) { - mSurrendered = surrendered; - } - - /** - * Returns the ship's fleet number. - * Unspecified: -1 - */ - public byte getFleetNumber() { - return mFleetNumber; - } - - public void setFleetNumber(byte fleetNumber) { - mFleetNumber = fleetNumber; - } - - /** - * Returns a Set containing the EliteAbility values that pertain to this - * ship. - * Unspecified: null - */ - public Set getEliteAbilities() { - return mElite != -1 ? EliteAbility.fromValue(mElite) : null; - } - - /** - * Returns true if this ship has the specified elite ability and false if it - * does not or if it is unknown whether it has it. - */ - public boolean hasEliteAbility(EliteAbility ability) { - return mElite != -1 && ability.on(mElite); - } - - /** - * Returns true if this ship is using the specified elite ability and false - * if it is not. - */ - public boolean isUsingEliteAbilty(EliteAbility ability) { - return mEliteState != -1 && ability.on(mEliteState); - } - - public int getEliteBits() { - return mElite; - } - - /** - * Sets the elite ability bit field. - * Unspecified: -1 - */ - public void setEliteBits(int elite) { - mElite = elite; - } - - public int getEliteStateBits() { - return mEliteState; - } - - /** - * Sets the elite state bit field (what abilities are being used). - * Unspecified: -1 - */ - public void setEliteStateBits(int elite) { - mEliteState = elite; - } - - /** - * The scan level for this ship. - * Unspecified: -1 - */ - public byte getScanLevel() { - return mScanLevel; - } - - public void setScanLevel(byte scanLevel) { - mScanLevel = scanLevel; - } - - /** - * Returns true if this ship has been scanned at the given level or higher; - * false otherwise. - */ - public boolean isScanned(byte scanLevel) { - return mScanLevel >= scanLevel; - } - - /** - * The intel String for this ship. - * Unspecified: null - */ - public String getIntel() { - return mIntel; - } - - public void setIntel(String intel) { - mIntel = intel; - } - - /** - * The percentage of damage sustained by a particular system, expressed as - * a value between 0 and 1. - * Unspecified: -1 - */ - public float getSystemDamage(ShipSystem sys) { - return mSysDamage[sys.ordinal()]; - } - - public void setSystemDamage(ShipSystem sys, float value) { - mSysDamage[sys.ordinal()] = value; - } - - @Override - public void updateFrom(ArtemisObject eng) { - super.updateFrom(eng); - - // it SHOULD be an ArtemisNpc - if (eng instanceof ArtemisNpc) { - ArtemisNpc cast = (ArtemisNpc) eng; - BoolState enemy = cast.isEnemy(); - - if (BoolState.isKnown(enemy)) { - mEnemy = enemy; - } - - BoolState surrendered = cast.isSurrendered(); - - if (BoolState.isKnown(surrendered)) { - mSurrendered = surrendered; - } - - if (cast.mFleetNumber != (byte) -1) { - setFleetNumber(cast.mFleetNumber); - } - - if (cast.mScanLevel != -1) { - setScanLevel(cast.mScanLevel); - } - - boolean elite = false; - Vessel vessel = getVessel(); - - if (vessel != null) { - Faction faction = vessel.getFaction(); - elite = faction.is(FactionAttribute.ELITE); - } - - if (cast.mElite != -1) { - setEliteBits(elite ? cast.mElite : 0); - } - - if (cast.mEliteState != -1) { - setEliteStateBits(elite ? cast.mEliteState : 0); - } - - if (cast.mIntel != null) { - setIntel(cast.mIntel); - } - - for (int i = 0; i < mSysDamage.length; i++) { - float value = cast.mSysDamage[i]; - - if (value != -1) { - mSysDamage[i] = value; - } - } - } - } - - @Override - public void appendObjectProps(SortedMap props, - boolean includeUnspecified) { - super.appendObjectProps(props, includeUnspecified); - putProp(props, "Scan level", mScanLevel, -1, includeUnspecified); - - if (mElite != -1) { - String str = Util.enumSetToString(EliteAbility.fromValue(mElite)); - props.put("Specials", str != "" ? str : "NONE"); - } else if (includeUnspecified) { - props.put("Specials", "UNKNOWN"); - } - - if (mEliteState != -1) { - String str = Util.enumSetToString(EliteAbility.fromValue(mEliteState)); - props.put("Specials active", str != "" ? str : "NONE"); - } else if (includeUnspecified) { - props.put("Specials active", "UNKNOWN"); - } - - putProp(props, "Is enemy", mEnemy, includeUnspecified); - putProp(props, "Surrendered", mSurrendered, includeUnspecified); - putProp(props, "Fleet number", mFleetNumber, -1, includeUnspecified); - putProp(props, "Intel", mIntel, includeUnspecified); - ShipSystem[] systems = ShipSystem.values(); - - for (int i = 0; i < mSysDamage.length; i++) { - putProp(props, "Damage: " + systems[i], mSysDamage[i], - -1, includeUnspecified); - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisObject.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisObject.java deleted file mode 100644 index 3d12724..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisObject.java +++ /dev/null @@ -1,125 +0,0 @@ -package net.dhleong.acl.world; - -import java.util.SortedMap; - -import net.dhleong.acl.enums.ObjectType; - -/** - * This interface represents information about an object in the game world. It - * may contain all the information known about that object, or just updates. - * Every object has the following properties: - * - * - an ID - * - a type - * - a position (x, y, z) - * - * Many objects also have a name, but not all of them do, and the name is not - * guaranteed to be unique. However, any one update is only guaranteed to - * specify the ID. - * - * - * Unspecified properties vs. unknown properties - * - * A property is unspecified if no value has been given for it. Since object - * update packets typically contain values for properties which have changed, - * other properties will be unspecified. To avoid instantiating a lot of - * objects, special values are used to indicate whether a primitive property is - * unspecified. The documentation for each property's accessor method will tell - * you what that value is. The "unspecified" value depends on the property's - * type and what its permissible values are: - * - * BoolState: BoolState.UNKNOWN - * Other Objects: null - * Numeric primitives: -1, or the type's MIN_VALUE if -1 is a permissible value - * for that property - * - * An unknown property is one whose purpose is currently unknown. It may have a - * specified value, but we don't know what that value means. ArtClientLib is - * capable of tracking unknown property values, but this capability is really - * only useful for people who are trying to determine what these properties - * mean. - * - * - * Updating objects - * - * Most packets which update object information produce objects which implement - * this interface. These objects will contain only the property values that were - * updated by that packet; all other values will be unspecified. You can use the - * updateFrom() method to transfer all specified properties from one object to - * another; this allows you to keep around a single instance that always has the - * latest known state for that world object. - * - * - * Object positions - * - * A sector is a three-dimentional rectangular prism. From the perspective of a - * ship with a heading of 0 degress, the X axis runs from port to starboard, the - * Y axis runs up and down, and the Z axis runs bow to stern. The boundaries of - * the sector are (0, 500, 0) [top northeast corner] to (100000, -500, 100000) - * [bottom southwest corner]. However, some objects, such as asteroids and - * nebulae, may lie outside these bounds. - * - * @author dhleong - */ -public interface ArtemisObject { - /** - * The object's unique identifier. This property should always be specified. - */ - public int getId(); - - /** - * The object's type. - * Unspecified: null - */ - public ObjectType getType(); - - /** - * The object's name. - * Unspecified: null - */ - public String getName(); - - /** - * The object's position along the X-axis. - * Unspecified: Float.MIN_VALUE - */ - public abstract float getX(); - public abstract void setX(float x); - - /** - * The object's position along the Y-axis - * Unspecified: Float.MIN_VALUE - */ - public abstract float getY(); - public abstract void setY(float y); - - /** - * The object's position along the Z-axis - * Unspecified: Float.MIN_VALUE - */ - public abstract float getZ(); - public abstract void setZ(float z); - - /** - * Returns a SortedMap containing the values for properties whose purpose is - * currently unknown. This is useful for debugging. - */ - public SortedMap getUnknownProps(); - public void setUnknownProps(SortedMap unknownProps); - - /** - * Updates this object's properties to match any updates provided by the - * given object. If any property of the given object is unspecified, this - * object's corresponding property will not be updated. - */ - public void updateFrom(ArtemisObject other); - - /** - * Returns a SortedMap containing this object's properties. If - * includeUnspecified is true, all properties will be included in the map, - * even if they're unspecified. Otherwise, only specified properties will be - * included. Note that unknown properties that have not been specified will - * never be included, even if includeUnspecified is true. - */ - public SortedMap getProps(boolean includeUnspecified); -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisOrientable.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisOrientable.java deleted file mode 100644 index a5f51f9..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisOrientable.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.dhleong.acl.world; - -/** - * An interface for objects which have an orientation: heading, pitch and roll. - * Technically, all objects have these properties, but only objects which - * implement this interface have them exposed in the Artemis protocol. - * @author rjwut - */ -public interface ArtemisOrientable { - /** - * The direction the object is facing on the X-Z plane. This is expressed as - * a value from negative pi to pi. A value of pi corresponds to a heading of - * 0 degrees. The ship turns to port as the value decreases. A value of 0 - * corresponds to a heading of 180 degrees. - * Unspecified: Float.MIN_VALUE - */ - public abstract float getHeading(); - public abstract void setHeading(float heading); - - /** - * The angle between the X-Z plane and the front of the object, in degrees. - * A positive value means the object is pointed "down", while a negative - * value means the object is pointed "up". - * Unspecified: Float.MIN_VALUE - */ - public abstract float getPitch(); - public abstract void setPitch(float pitch); - - /** - * The angle that the object has rolled towards the port (positive) or - * starboard (negative) side, in degrees. - * Unspecified: Float.MIN_VALUE - */ - public abstract float getRoll(); - public abstract void setRoll(float roll); - -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisPlayer.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisPlayer.java deleted file mode 100644 index 74ffd95..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisPlayer.java +++ /dev/null @@ -1,637 +0,0 @@ -package net.dhleong.acl.world; - -import java.util.Arrays; -import java.util.SortedMap; - -import net.dhleong.acl.enums.AlertStatus; -import net.dhleong.acl.enums.BeamFrequency; -import net.dhleong.acl.enums.DriveType; -import net.dhleong.acl.enums.MainScreenView; -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.enums.OrdnanceType; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.enums.TargetingMode; -import net.dhleong.acl.enums.TubeState; -import net.dhleong.acl.enums.Upgrade; -import net.dhleong.acl.util.BoolState; - -/** - * A player ship. - * @author dhleong - */ -public class ArtemisPlayer extends BaseArtemisShip { - private TargetingMode mTargetingMode; - private AlertStatus mAlertStatus; - private BoolState mShields; - private int mShipNumber = -1; - private final float[] mHeat = new float[Artemis.SYSTEM_COUNT]; - private final float[] mSystems = new float[Artemis.SYSTEM_COUNT]; - private final int[] mCoolant = new int[Artemis.SYSTEM_COUNT]; - private final int[] mTorpedos = new int[OrdnanceType.COUNT]; - private final float[] mTubeTimes = new float[Artemis.MAX_TUBES]; - private final TubeState[] mTubeState = new TubeState[Artemis.MAX_TUBES]; - private final byte[] mTubeContents = new byte[Artemis.MAX_TUBES]; - private float mEnergy = -1; - private int mDockingBase = -1; - private MainScreenView mMainScreen; - private int mAvailableCoolant = -1; - private int mWeaponsTarget = -1; - private byte mWarp = -1; - private BeamFrequency mBeamFreq; - private DriveType mDriveType; - private BoolState mReverse; - private int mScienceTarget = -1; - private float mScanProgress = -1; - private int mCaptainTarget = -1; - private int mScanningId = -1; - private final byte[] mUpgrades = new byte[Upgrade.STORABLE_UPGRADE_COUNT]; - - public ArtemisPlayer(int objId) { - super(objId); - - // pre-fill - Arrays.fill(mHeat, -1); - Arrays.fill(mSystems, -1); - Arrays.fill(mCoolant, -1); - Arrays.fill(mTorpedos, -1); - Arrays.fill(mTubeTimes, -1); - Arrays.fill(mTubeContents, (byte) -1); - Arrays.fill(mUpgrades, (byte) -1); - } - - @Override - public ObjectType getType() { - return ObjectType.PLAYER_SHIP; - } - - /** - * The ship's energy reserves. - * Unspecified: -1 - */ - public float getEnergy() { - return mEnergy; - } - - public void setEnergy(float energy) { - mEnergy = energy; - } - - /** - * Get this ship's player ship index. This is NOT the displayed number, but - * the INDEX (used in SystemManager#getPlayerShip). - * Unspecified: -1 - * @return int in [0,Artemis.SHIP_COUNT), or -1 if undefined - */ - public int getShipIndex() { - return mShipNumber == -1 ? -1 : mShipNumber - 1; - } - - public void setShipIndex(int shipIndex) { - mShipNumber = shipIndex + 1; - } - - /** - * The amount of coolant allocated to the given system. - * Unspecified: -1 - */ - public int getSystemCoolant(ShipSystem sys) { - return mCoolant[sys.ordinal()]; - } - - public void setSystemCoolant(ShipSystem sys, int coolant) { - mCoolant[sys.ordinal()] = coolant; - } - - /** - * The energy allocation level for a system, as a value between 0 (no energy - * allocated) and 1 (maximum energy allocated). - * Unspecified: -1 - */ - public float getSystemEnergy(ShipSystem sys) { - return mSystems[sys.ordinal()]; - } - - public void setSystemEnergy(ShipSystem sys, float energy) { - if (energy > 1f) { - throw new IllegalArgumentException("Illegal energy value: " + energy); - } - mSystems[sys.ordinal()] = energy; - } - - /** - * Convenience, set energy as an int percentage [0, 300] - */ - public void setSystemEnergy(ShipSystem sys, int energyPercentage) { - setSystemEnergy(sys, energyPercentage / (float) Artemis.MAX_ENERGY_ALLOCATION_PERCENT); - } - - /** - * The heat level for a system. - * Unspecified: -1 - */ - public float getSystemHeat(ShipSystem sys) { - return mHeat[sys.ordinal()]; - } - - public void setSystemHeat(ShipSystem sys, float heat) { - mHeat[sys.ordinal()] = heat; - } - - /** - * Whether the shields are up or not. - */ - public BoolState getShieldsState() { - return mShields; - } - - public void setShields(boolean newState) { - mShields = BoolState.from(newState); - } - - /** - * Current alert status. - */ - public AlertStatus getAlertStatus() { - return mAlertStatus; - } - - public void setAlertStatus(AlertStatus alertStatus) { - mAlertStatus = alertStatus; - } - - /** - * Get the ID of the base at which we're docking. Note that this property is - * only updated in a packet when the docking process commences; undocking - * does not update this property. However, if an existing ArtemisPlayer - * object is docked, is updated by another one, and the update has the ship - * engaging impulse or warp drive, this property will be set to 0 to - * indicate that the ship has undocked. - * Unspecified: -1 - */ - public int getDockingBase() { - return mDockingBase; - } - - public void setDockingBase(int baseId) { - mDockingBase = baseId; - } - - /** - * The number of torpedoes of the given type in the ship's stores. - * Unspecified: -1 - */ - public int getTorpedoCount(OrdnanceType type) { - return mTorpedos[type.ordinal()]; - } - - public void setTorpedoCount(int torpType, int count) { - mTorpedos[torpType] = count; - } - - /** - * Whether or not the ship's impulse drive is in reverse. - */ - public BoolState getReverseState() { - return mReverse; - } - - public void setReverse(BoolState reverse) { - mReverse = reverse; - } - - /** - * The loading state of the given tube. - * Unspecified: null - */ - public TubeState getTubeState(int tube) { - return mTubeState[tube]; - } - - public void setTubeState(int tube, TubeState state) { - mTubeState[tube] = state; - } - - /** - * Returns a value indicating the contents of the tube. If the tube's state - * is TubeState.UNLOADED, 0 means that the tube is empty. In any other - * state, the number will be the ordinal value of the OrdnanceType in the - * tube. - * Unspecified: any negative number - */ - public byte getTubeContentsValue(int tube) { - return mTubeContents[tube]; - } - - public void setTubeContentsValue(int tube, byte value) { - mTubeContents[tube] = value; - } - - /** - * Returns an OrdnanceType value indicating the contents of the tube. This - * method will return null if the tube contents are unspecified, or if the - * tube is empty. - */ - public OrdnanceType getTubeContents(int tube) { - TubeState state = mTubeState[tube]; - int contents = mTubeContents[tube]; - - if (state == null || contents < 0) { - return null; - } - - return state == TubeState.UNLOADED ? null : OrdnanceType.values()[contents]; - } - - /** - * Sets the contents of the given tube. The tube state must be set to a - * value other than TubeState.UNLOADED before invoking this method. - */ - public void setTubeContents(int tube, OrdnanceType type) { - TubeState state = mTubeState[tube]; - - if (state == null) { - throw new IllegalStateException("Tube state not set"); - } - - if (state == TubeState.UNLOADED) { - if (type != null) { - throw new IllegalArgumentException( - "Unloaded tubes cannot contain ordnance" - ); - } - - mTubeContents[tube] = 0; - } else { - if (type == null) { - throw new IllegalArgumentException( - "No OrdnanceType specified for " + state + " tube state" - ); - } - - mTubeContents[tube] = (byte) type.ordinal(); - } - } - - /** - * Returns the number of seconds until the current (un)load operation is - * complete. - * Unspecified: -1 - */ - public float getTubeCountdown(int tube) { - return mTubeTimes[tube]; - } - - public void setTubeCountdown(int tube, float seconds) { - mTubeTimes[tube] = seconds; - } - - /** - * Amount of coolant in the ship's reserves. - * Unspecified: -1 - */ - public int getAvailableCoolant() { - return mAvailableCoolant; - } - - public void setAvailableCoolant(int availableCoolant) { - mAvailableCoolant = availableCoolant; - } - - /** - * The view for the main screen. - * Unspecified: null - */ - public MainScreenView getMainScreen() { - return mMainScreen; - } - - public void setMainScreen(MainScreenView screen) { - mMainScreen = screen; - } - - /** - * The frequency at which beam weapons are to be tuned. - * Unspecified: null - */ - public BeamFrequency getBeamFrequency() { - return mBeamFreq; - } - - public void setBeamFrequency(BeamFrequency beamFreq) { - mBeamFreq = beamFreq; - } - - /** - * The type of drive system the ship has. - * Unspecified: null - */ - public DriveType getDriveType() { - return mDriveType; - } - - public void setDriveType(DriveType driveType) { - mDriveType = driveType; - } - - /** - * Returns the current targeting mode (auto vs. manual beams). - * Unspecified: null - */ - public TargetingMode getTargetingMode() { - return mTargetingMode; - } - - public void setTargetingMode(TargetingMode targetingMode) { - mTargetingMode = targetingMode; - } - - /** - * The ID of the object targeted by the science officer. If the target is - * cleared, this method returns 1. - * Unspecified: -1 - */ - public int getScienceTarget() { - return mScienceTarget; - } - - public void setScienceTarget(int scienceTarget) { - mScienceTarget = scienceTarget; - } - - /** - * The progress of the current scan, as a value between 0 and 1. - * Unspecified: -1 - */ - public float getScanProgress() { - return mScanProgress; - } - - public void setScanProgress(float scanProgress) { - mScanProgress = scanProgress; - } - - /** - * The ID of the object targeted by the captain officer. If the target is - * cleared, this method returns 1. - * Unspecified: -1 - */ - public int getCaptainTarget() { - return mCaptainTarget; - } - - public void setCaptainTarget(int captainTarget) { - mCaptainTarget = captainTarget; - } - - /** - * The ID of the object targeted by the weapons officer. If the target is - * cleared, this method returns 1. - * Unspecified: -1 - */ - public int getWeaponsTarget() { - return mWeaponsTarget; - } - - public void setWeaponsTarget(int weaponsTarget) { - mWeaponsTarget = weaponsTarget; - } - - /** - * The ID of the object being scanned. Note that this is distinct from the - * science target: science can start a scan then change targets, but the - * scan continues on the original target as long as science has not - * initiated a new scan. - * Unspecified: -1 - */ - public int getScanObjectId() { - return mScanningId; - } - - public void setScanObjectId(int scanningId) { - mScanningId = scanningId; - } - - /** - * Warp factor, between 0 (not at warp) and Artemis.MAX_WARP. - * Unspecified: -1 - */ - public byte getWarp() { - return mWarp; - } - - public void setWarp(byte warp) { - mWarp = warp; - } - - /** - * Returns the number of upgrades of the indicated type stored on the ship. - * Unspecified: -1 - */ - public byte getUpgrades(Upgrade upgrade) { - if (upgrade.getActivatedby() == null) { - throw new IllegalArgumentException(upgrade + " upgrades can't be stored on the ship"); - } - - return mUpgrades[upgrade.ordinal() - 2]; - } - - public void setUpgrades(Upgrade upgrade, byte count) { - if (upgrade.getActivatedby() == null) { - throw new IllegalArgumentException(upgrade + " upgrades can't be stored on the ship"); - } - - mUpgrades[upgrade.ordinal() - 2] = count; - } - - @Override - public void updateFrom(ArtemisObject eng) { - super.updateFrom(eng); - - // it should be! - if (eng instanceof ArtemisPlayer) { - ArtemisPlayer plr = (ArtemisPlayer) eng; - - if (mShipNumber == -1) { - mShipNumber = plr.mShipNumber; - } - - if (plr.mTargetingMode != null) { - mTargetingMode = plr.mTargetingMode; - } - - if (plr.mWeaponsTarget != -1) { - mWeaponsTarget = plr.mWeaponsTarget; - } - - if (plr.mWarp != -1) { - mWarp = plr.mWarp; - } - - if (plr.mDockingBase != -1) { - mDockingBase = plr.mDockingBase; - } else if (plr.getImpulse() != -1 || plr.mWarp != -1) { - mDockingBase = 0; - } - - if (plr.mBeamFreq != null) { - mBeamFreq = plr.mBeamFreq; - } - - if (plr.mAlertStatus != null) { - mAlertStatus = plr.mAlertStatus; - } - - if (BoolState.isKnown(plr.mShields)) { - mShields = plr.mShields; - } - - if (plr.mEnergy != -1) { - mEnergy = plr.mEnergy; - } - - if (plr.mAvailableCoolant != -1) { - mAvailableCoolant = plr.mAvailableCoolant; - } - - if (plr.mDriveType != null) { - mDriveType = plr.mDriveType; - } - - for (int i = 0; i < Artemis.SYSTEM_COUNT; i++) { - if (plr.mHeat[i] != -1) { - mHeat[i] = plr.mHeat[i]; - } - - if (plr.mSystems[i] != -1) { - mSystems[i] = plr.mSystems[i]; - } - - if (plr.mCoolant[i] != -1) { - mCoolant[i] = plr.mCoolant[i]; - } - } - - for (int i=0; i < OrdnanceType.COUNT; i++) { - if (plr.mTorpedos[i] != -1) { - mTorpedos[i] = plr.mTorpedos[i]; - } - } - - for (int i = 0; i < Artemis.MAX_TUBES; i++) { - float time = plr.mTubeTimes[i]; - - if (time >= 0) { - mTubeTimes[i] = time < 0.05f ? 0 : time; - } - - TubeState state = plr.mTubeState[i]; - - if (state != null) { - mTubeState[i] = state; - } - - byte contents = plr.mTubeContents[i]; - - if (contents != -1) { - mTubeContents[i] = contents; - } else if (state == TubeState.UNLOADED) { - mTubeContents[i] = 0; - } - } - - if (plr.mMainScreen != null) { - mMainScreen = plr.mMainScreen; - } - - if (BoolState.isKnown(plr.mReverse)) { - mReverse = plr.mReverse; - } - - if (plr.mScienceTarget != -1) { - mScienceTarget = plr.mScienceTarget; - } - - if (plr.mScanProgress != -1) { - mScanProgress = plr.mScanProgress; - } - - if (plr.mCaptainTarget != -1) { - mCaptainTarget = plr.mCaptainTarget; - } - - if (plr.mScanningId != -1) { - mScanningId = plr.mScanningId; - } - - for (int i = 0; i < mUpgrades.length; i++) { - byte upgrade = plr.mUpgrades[i]; - - if (upgrade >= 0) { - mUpgrades[i] = upgrade; - } - } - } - } - - @Override - public void appendObjectProps(SortedMap props, boolean includeUnspecified) { - super.appendObjectProps(props, includeUnspecified); - putProp(props, "Targeting mode", mTargetingMode, includeUnspecified); - putProp(props, "Alert status", mAlertStatus, includeUnspecified); - putProp(props, "Shield state", mShields, includeUnspecified); - putProp(props, "Player ship number", mShipNumber, -1, includeUnspecified); - - for (ShipSystem system : ShipSystem.values()) { - int i = system.ordinal(); - putProp(props, "System heat: " + system, mHeat[i], -1, includeUnspecified); - putProp(props, "System energy: " + system, mSystems[i], -1, includeUnspecified); - putProp(props, "System coolant: " + system, mCoolant[i], -1, includeUnspecified); - } - - OrdnanceType[] ordValues = OrdnanceType.values(); - - for (OrdnanceType ordnanceType : ordValues) { - int i = ordnanceType.ordinal(); - putProp(props, "Ordnance count: " + ordnanceType, mTorpedos[i], -1, includeUnspecified); - } - - for (int i = 0; i < Artemis.MAX_TUBES; i++) { - TubeState state = mTubeState[i]; - int contents = mTubeContents[i]; - putProp(props, "Tube " + i + " state", state, includeUnspecified); - String contentsStr; - - if (state != null && contents != -1) { - if (state == TubeState.UNLOADED) { - contentsStr = "EMPTY"; - } else { - contentsStr = ordValues[contents].name(); - } - - putProp(props, "Tube " + i + " contents", contentsStr, includeUnspecified); - } - - putProp(props, "Tube " + i + " countdown", mTubeTimes[i], -1, includeUnspecified); - } - - putProp(props, "Energy", mEnergy, -1, includeUnspecified); - putProp(props, "Docking base", mDockingBase, -1, includeUnspecified); - putProp(props, "Main screen view", mMainScreen, includeUnspecified); - putProp(props, "Coolant", mAvailableCoolant, -1, includeUnspecified); - putProp(props, "Warp", mWarp, -1, includeUnspecified); - putProp(props, "Beam frequency", mBeamFreq, includeUnspecified); - putProp(props, "Drive type", mDriveType, includeUnspecified); - putProp(props, "Reverse", mReverse, includeUnspecified); - putProp(props, "Scan target", mScienceTarget, -1, includeUnspecified); - putProp(props, "Scan progress", mScanProgress, -1, includeUnspecified); - putProp(props, "Scan object ID", mScanningId, -1, includeUnspecified); - putProp(props, "Weapons target", mWeaponsTarget, -1, includeUnspecified); - putProp(props, "Captain target", mCaptainTarget, -1, includeUnspecified); - Upgrade[] upgradeTypes = Upgrade.getStorableUpgrades(); - - for (int i = 0; i < mUpgrades.length; i++) { - Upgrade upgradeType = upgradeTypes[i]; - putProp(props, "Upgrades: " + upgradeType, mUpgrades[i], -1, includeUnspecified); - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisShielded.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisShielded.java deleted file mode 100644 index fc7d39c..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/ArtemisShielded.java +++ /dev/null @@ -1,39 +0,0 @@ -package net.dhleong.acl.world; - -import net.dhleong.acl.vesseldata.Vessel; - -/** - * An ArtemisObject which can have shields. Note that shield values can be - * negative. - * @author dhleong - */ -public interface ArtemisShielded extends ArtemisObject { - /** - * Identifies the type of ship this is. This corresponds to the uniqueID - * attribute of vessel elements in vesselData.xml. - * Unspecified: -1 - */ - public int getHullId(); - public void setHullId(int value); - - /** - * Returns the Vessel object corresponding to this object's hull ID. If the - * hull ID is unspecified or VesselData contains no Vessel with that ID, - * getVessel() returns null. - */ - public Vessel getVessel(); - - /** - * The strength of the forward shields. - * Unspecified: Float.MIN_VALUE - */ - public float getShieldsFront(); - public void setShieldsFront(float value); - - /** - * The strength of the aft shields. - * Unspecified: Float.MIN_VALUE - */ - public float getShieldsRear(); - public void setShieldsRear(float value); -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/BaseArtemisObject.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/BaseArtemisObject.java deleted file mode 100644 index c268aec..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/BaseArtemisObject.java +++ /dev/null @@ -1,238 +0,0 @@ -package net.dhleong.acl.world; - -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; - -import net.dhleong.acl.util.BoolState; -import net.dhleong.acl.util.TextUtil; - -/** - * Base implementation for all ArtemisObjects. - */ -public abstract class BaseArtemisObject implements ArtemisObject { - private static final String UNKNOWN = "UNKNOWN"; - - /** - * Puts the given int property into the indicated map. If the given value is - * equal to unspecifiedValue, then the includeUnspecified value dictates the - * behavor of this method. If it is true, the property is recorded in the - * map as "UNKNOWN". Otherwise, it is omitted. - */ - public static void putProp(SortedMap props, String label, - int value, int unspecifiedValue, boolean includeUnspecified) { - if (!includeUnspecified && value == unspecifiedValue) { - return; - } - - props.put(label, value != unspecifiedValue ? Integer.valueOf(value) : UNKNOWN); - } - - /** - * Puts the given float property into the indicated map. If the given value - * is equal to unspecifiedValue, then the includeUnspecified value dictates - * the behavor of this method. If it is true, the property is recorded in - * the map as "UNKNOWN". Otherwise, it is omitted. - */ - public static void putProp(SortedMap props, String label, - float value, float unspecifiedValue, boolean includeUnspecified) { - if (!includeUnspecified && value == unspecifiedValue) { - return; - } - - props.put(label, value != unspecifiedValue ? Float.valueOf(value) : UNKNOWN); - } - - /** - * Puts the given BoolState property into the indicated map. If the given - * value is null or BoolState.UNKNOWN, then the includeUnspecified value - * dictates the behavor of this method. If it is true, the property is - * recorded in the map as-is. Otherwise, it is omitted. - */ - public static void putProp(SortedMap props, String label, - BoolState value, boolean includeUnspecified) { - if (!includeUnspecified && !BoolState.isKnown(value)) { - return; - } - - props.put(label, value != null ? value : BoolState.UNKNOWN); - } - - /** - * Puts the given Object property into the indicated map. If the given value - * is null, then the includeUnspecified value dictates the behavor of this - * method. If it is true, the property is recorded in the map as "UNKNOWN". - * Otherwise, it is omitted. - */ - public static void putProp(SortedMap props, String label, - Object value, boolean includeUnspecified) { - if (!includeUnspecified && value == null) { - return; - } - - props.put(label, value != null ? value : UNKNOWN); - } - - protected final int mId; - public String mName; - private float mX = Float.MIN_VALUE; - private float mY = Float.MIN_VALUE; - private float mZ = Float.MIN_VALUE; - private SortedMap unknownProps; - - public BaseArtemisObject(int objId) { - mId = objId; - } - - @Override - public int getId() { - return mId; - } - - @Override - public String getName() { - return mName; - } - - public void setName(String name) { - mName = name; - } - - @Override - public float getX() { - return mX; - } - - @Override - public void setX(float mX) { - this.mX = mX; - } - - @Override - public float getY() { - return mY; - } - - @Override - public void setY(float y) { - mY = y; - } - - @Override - public float getZ() { - return mZ; - } - - @Override - public void setZ(float z) { - mZ = z; - } - - @Override - public void updateFrom(ArtemisObject eng) { - if (eng.getName() != null) { - mName = eng.getName(); - } - - float x = eng.getX(); - float y = eng.getY(); - float z = eng.getZ(); - - if (x != Float.MIN_VALUE) { - mX = x; - } - - if (y != Float.MIN_VALUE) { - mY = y; - } - - if (z != Float.MIN_VALUE) { - mZ = z; - } - - BaseArtemisObject cast = (BaseArtemisObject) eng; - SortedMap unknown = cast.getUnknownProps(); - - if (unknown != null && !unknown.isEmpty()) { - if (unknownProps == null) { - unknownProps = new TreeMap(); - } - - unknownProps.putAll(unknown); - } - } - - @Override - public final SortedMap getUnknownProps() { - return unknownProps; - } - - @Override - public final void setUnknownProps(SortedMap unknownProps) { - this.unknownProps = unknownProps; - } - - @Override - public final SortedMap getProps(boolean includeUnspecified) { - SortedMap props = new TreeMap(); - appendObjectProps(props, includeUnspecified); - return props; - } - - @Override - public final String toString() { - SortedMap props = getProps(false); - StringBuilder b = new StringBuilder(); - - for (Map.Entry entry : props.entrySet()) { - b.append("\n\t").append(entry.getKey()).append(": "); - Object value = entry.getValue(); - - if (value instanceof byte[]) { - b.append(TextUtil.byteArrayToHexString((byte[]) value)); - } else { - b.append(value); - } - } - - return b.toString(); - } - - /** - * Appends this object's properties to the given map. If includeUnspecified - * is true, unspecified properties area also included (unless they are also - * unknown properties). Subclasses must always call the superclass's - * implementation of this method. - */ - protected void appendObjectProps(SortedMap props, - boolean includeUnspecified) { - props.put("ID", Integer.valueOf(mId)); - putProp(props, "Name", mName, includeUnspecified); - putProp(props, "Object type", getType(), includeUnspecified); - putProp(props, "X", mX, Float.MIN_VALUE, includeUnspecified); - putProp(props, "Y", mY, Float.MIN_VALUE, includeUnspecified); - putProp(props, "Z", mZ, Float.MIN_VALUE, includeUnspecified); - - if (unknownProps != null) { - props.putAll(unknownProps); - } - } - - @Override - public boolean equals(Object other) { - if (this == other) { - return true; - } - - if (!(other instanceof ArtemisObject)) { - return false; - } - - return mId == ((ArtemisObject) other).getId(); - } - - @Override - public int hashCode() { - return mId; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/BaseArtemisOrientable.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/BaseArtemisOrientable.java deleted file mode 100644 index 2a63d1d..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/BaseArtemisOrientable.java +++ /dev/null @@ -1,81 +0,0 @@ -package net.dhleong.acl.world; - -import java.util.SortedMap; - -/** - * Base implementation for ArtemisOrientable objects. - * @author rjwut - */ -public abstract class BaseArtemisOrientable extends BaseArtemisObject - implements ArtemisOrientable { - public BaseArtemisOrientable(int objId) { - super(objId); - } - - private float mHeading = Float.MIN_VALUE; - private float mPitch = Float.MIN_VALUE; - private float mRoll = Float.MIN_VALUE; - - @Override - public float getHeading() { - return mHeading; - } - - @Override - public void setHeading(float heading) { - mHeading = heading; - } - - @Override - public float getPitch() { - return mPitch; - } - - @Override - public void setPitch(float pitch) { - mPitch = pitch; - } - - @Override - public float getRoll() { - return mRoll; - } - - @Override - public void setRoll(float roll) { - mRoll = roll; - } - - @Override - public void updateFrom(ArtemisObject obj) { - super.updateFrom(obj); - - if (obj instanceof ArtemisOrientable) { - ArtemisOrientable cast = (ArtemisOrientable) obj; - float heading = cast.getHeading(); - float pitch = cast.getPitch(); - float roll = cast.getRoll(); - - if (heading != Float.MIN_VALUE) { - mHeading = heading; - } - - if (pitch != Float.MIN_VALUE) { - mPitch = pitch; - } - - if (roll != Float.MIN_VALUE) { - mRoll = roll; - } - } - } - - @Override - protected void appendObjectProps(SortedMap props, - boolean includeUnspecified) { - super.appendObjectProps(props, includeUnspecified); - putProp(props, "Heading", mHeading, Float.MIN_VALUE, includeUnspecified); - putProp(props, "Pitch", mPitch, Float.MIN_VALUE, includeUnspecified); - putProp(props, "Roll", mRoll, Float.MIN_VALUE, includeUnspecified); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/BaseArtemisShielded.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/BaseArtemisShielded.java deleted file mode 100644 index 922b6ff..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/BaseArtemisShielded.java +++ /dev/null @@ -1,110 +0,0 @@ -package net.dhleong.acl.world; - -import java.util.SortedMap; - -import net.dhleong.acl.vesseldata.Vessel; -import net.dhleong.acl.vesseldata.VesselData; - -/** - * Base implementation of a shielded world object. - */ -public abstract class BaseArtemisShielded extends BaseArtemisOrientable - implements ArtemisShielded { - private int mHullId = -1; - private float mShieldsFront = Float.MIN_VALUE; - private float mShieldsRear = Float.MIN_VALUE; - - public BaseArtemisShielded(int objId) { - super(objId); - } - - @Override - public int getHullId() { - return mHullId; - } - - @Override - public Vessel getVessel() { - return mHullId != -1 ? VesselData.get().getVessel(mHullId) : null; - } - - @Override - public void setHullId(int hullId) { - mHullId = hullId; - } - - public void setVessel(Vessel vessel) { - mHullId = vessel.getId(); - } - - @Override - public float getShieldsFront() { - return mShieldsFront; - } - - @Override - public void setShieldsFront(float shieldsFront) { - mShieldsFront = shieldsFront; - } - @Override - public float getShieldsRear() { - return mShieldsRear; - } - - @Override - public void setShieldsRear(float shieldsRear) { - mShieldsRear = shieldsRear; - } - - @Override - public void updateFrom(ArtemisObject eng) { - super.updateFrom(eng); - - if (eng instanceof BaseArtemisShielded) { - ArtemisShielded ship = (ArtemisShielded) eng; - int hullId = ship.getHullId(); - - if (hullId != -1) { - mHullId = hullId; - } - - float shields = ship.getShieldsFront(); - - if (shields != Float.MIN_VALUE) { - mShieldsFront = shields; - } - - shields = ship.getShieldsRear(); - - if (shields != Float.MIN_VALUE) { - mShieldsRear = shields; - } - } - } - - @Override - public void appendObjectProps(SortedMap props, boolean includeUnspecified) { - super.appendObjectProps(props, includeUnspecified); - putProp(props, "Hull ID", mHullId, -1, includeUnspecified); - - if (includeUnspecified || mHullId != -1) { - Vessel vessel = getVessel(); - putProp( - props, - "Vessel type", - vessel != null ? vessel.getName() : Integer.toString(mHullId), - includeUnspecified - ); - - putProp( - props, - "Faction", - vessel != null ? vessel.getFaction().getName() : "UNKNOWN", - includeUnspecified - ); - } - - putProp(props, "Shields: fore", mShieldsFront, Float.MIN_VALUE, includeUnspecified); - putProp(props, "Shields: aft", mShieldsRear, Float.MIN_VALUE, includeUnspecified); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/BaseArtemisShip.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/BaseArtemisShip.java deleted file mode 100644 index 1dc4056..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/BaseArtemisShip.java +++ /dev/null @@ -1,181 +0,0 @@ -package net.dhleong.acl.world; - -import java.util.SortedMap; - -import net.dhleong.acl.enums.BeamFrequency; - -/** - * Base implementation for ships (player or NPC). - */ -public abstract class BaseArtemisShip extends BaseArtemisShielded { - private float mVelocity = -1; - private float mShieldsFrontMax = -1; - private float mShieldsRearMax = -1; - private final float[] mShieldFreqs = new float[5]; - private float mSteering = -1; - private float mTopSpeed = -1; - private float mTurnRate = -1; - private float mImpulse = -1; - - public BaseArtemisShip(int objId) { - super(objId); - - for (int i = 0; i < 5; i++) { - mShieldFreqs[i] = -1; - } - } - - public float getVelocity() { - return mVelocity; - } - - public void setVelocity(float velocity) { - mVelocity = velocity; - } - - public float getSteering() { - return mSteering; - } - - public void setSteering(float steeringSlider) { - mSteering = steeringSlider; - } - - /** - * The maximum speed of this ship, in ls (whatever that is). - * Unspecified: -1 - */ - public float getTopSpeed() { - return mTopSpeed; - } - - public void setTopSpeed(float topSpeed) { - mTopSpeed = topSpeed; - } - - /** - * The maximum turn rate of this ship. - * Unspecified: -1 - */ - public float getTurnRate() { - return mTurnRate; - } - - public void setTurnRate(float turnRate) { - mTurnRate = turnRate; - } - - /** - * The maximum strength of the forward shield. - * Unspecified: -1 - */ - public float getShieldsFrontMax() { - return mShieldsFrontMax; - } - - public void setShieldsFrontMax(float shieldsFrontMax) { - this.mShieldsFrontMax = shieldsFrontMax; - } - - /** - * The maximum strength of the aft shield. - * Unspecified: -1 - */ - public float getShieldsRearMax() { - return mShieldsRearMax; - } - - public void setShieldsRearMax(float shieldsRearMax) { - this.mShieldsRearMax = shieldsRearMax; - } - - /** - * A value between 0 and 1 indicating the shields' resistance to the given - * BeamFrequency. Higher values indicate that the shields are more resistant - * to that frequency. - * Unspecified: -1 - */ - public float getShieldFreq(BeamFrequency freq) { - return mShieldFreqs[freq.ordinal()]; - } - - public void setShieldFreq(BeamFrequency freq, float value) { - mShieldFreqs[freq.ordinal()] = value; - } - - /** - * Impulse setting, as a value from 0 (all stop) and 1 (full impulse). - * Unspecified: -1 - */ - public float getImpulse() { - return mImpulse; - } - - public void setImpulse(float impulseSlider) { - mImpulse = impulseSlider; - } - - @Override - public void updateFrom(ArtemisObject eng) { - super.updateFrom(eng); - - if (eng instanceof BaseArtemisShip) { - BaseArtemisShip ship = (BaseArtemisShip) eng; - - if (ship.mSteering != -1) { - mSteering = ship.mSteering; - } - - if (ship.mVelocity != -1) { - mVelocity = ship.mVelocity; - } - - if (ship.mTopSpeed != -1) { - mTopSpeed = ship.mTopSpeed; - } - - if (ship.mTurnRate != -1) { - mTurnRate = ship.mTurnRate; - } - - if (ship.mShieldsFrontMax != -1) { - mShieldsFrontMax = ship.mShieldsFrontMax; - } - - if (ship.mShieldsRearMax != -1) { - mShieldsRearMax = ship.mShieldsRearMax; - } - - if (ship.mImpulse != -1) { - mImpulse = ship.mImpulse; - } - - for (int i = 0; i < mShieldFreqs.length; i++) { - float value = ship.mShieldFreqs[i]; - - if (value != -1) { - mShieldFreqs[i] = value; - } - } - } - } - - @Override - public void appendObjectProps(SortedMap props, boolean includeUnspecified) { - super.appendObjectProps(props, includeUnspecified); - putProp(props, "Velocity", mVelocity, -1, includeUnspecified); - putProp(props, "Shields: fore max", mShieldsFrontMax, -1, includeUnspecified); - putProp(props, "Shields: aft max", mShieldsRearMax, -1, includeUnspecified); - BeamFrequency[] freqs = BeamFrequency.values(); - - for (int i = 0; i < mShieldFreqs.length; i++) { - putProp(props, "Shield frequency " + freqs[i], mShieldFreqs[i], - -1, includeUnspecified); - } - - putProp(props, "Rudder", mSteering, -1, includeUnspecified); - putProp(props, "Top speed", mTopSpeed, -1, includeUnspecified); - putProp(props, "Turn rate", mTurnRate, -1, includeUnspecified); - putProp(props, "Impulse", mImpulse, -1, includeUnspecified); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/SystemManager.java b/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/SystemManager.java deleted file mode 100644 index b6555ca..0000000 --- a/lib/ArtClientLib-2.6.0/src/net/dhleong/acl/world/SystemManager.java +++ /dev/null @@ -1,395 +0,0 @@ -package net.dhleong.acl.world; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; - -import net.dhleong.acl.enums.ObjectType; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.iface.Listener; -import net.dhleong.acl.protocol.core.eng.EngGridUpdatePacket; -import net.dhleong.acl.protocol.core.eng.EngGridUpdatePacket.DamconStatus; -import net.dhleong.acl.protocol.core.eng.EngGridUpdatePacket.GridDamage; -import net.dhleong.acl.protocol.core.world.DestroyObjectPacket; -import net.dhleong.acl.protocol.core.world.IntelPacket; -import net.dhleong.acl.protocol.core.world.ObjectUpdatePacket; -import net.dhleong.acl.util.GridCoord; -import net.dhleong.acl.util.ShipSystemGrid; -import net.dhleong.acl.util.ShipSystemGrid.GridEntry; - -/** - * A repository of Artemis world objects. Register an instance of SystemManager - * with the ArtemisNetworkInterface and it will keep track of all objects as - * they're created, updated and destroyed. - * @author dhleong - */ -public class SystemManager { - - public interface OnObjectCountChangeListener { - void onObjectCountChanged(int count); - } - - private static final OnObjectCountChangeListener sDummyListener = - new OnObjectCountChangeListener() { - @Override - public void onObjectCountChanged(int count) {/* nop */} - }; - - private static final boolean DEBUG = false; - - private final HashMap mObjects = - new HashMap(); - private OnObjectCountChangeListener mListener = sDummyListener; - - private HashMap mGridDamage; - private ShipSystemGrid mGrid; - - private final HashMap mDamcons = - new HashMap(); - - private final ArtemisPlayer[] mPlayers = new ArtemisPlayer[Artemis.SHIP_COUNT]; - - public SystemManager() { - clear(); - } - - /** Manually add an obj to the system */ - public void addObject(ArtemisObject obj) { - synchronized(this) { - mObjects.put(Integer.valueOf(obj.getId()), obj); - } - - mListener.onObjectCountChanged(mObjects.size()); - } - - @Listener - public void onPacket(DestroyObjectPacket pkt) { - synchronized(this) { - mObjects.remove(Integer.valueOf(pkt.getTarget())); - } - - // signal change - if (mObjects.size() == 1) { - ArtemisObject last = mObjects.values().iterator().next(); - - if ("Artemis".equals(last.getName())) { - // special (hack?) case; - // this is actually the end of the game - clear(); - mListener.onObjectCountChanged(0); - return; - } - } - - mListener.onObjectCountChanged(mObjects.size()); - return; - } - - @Listener - public void onPacket(EngGridUpdatePacket pkt) { - // this ONLY goes to the appropriate ship's engineer console - List damages = pkt.getDamage(); - - if (damages.size() > 0 && mGridDamage != null) { - for (GridDamage d : damages) { - mGridDamage.put(d.getCoord(), Float.valueOf(d.getDamage())); - } - } - - // update/init damcon teams - for (DamconStatus s : pkt.getDamcons()) { - final Integer team = Integer.valueOf(s.getTeamNumber()); - - if (mDamcons.containsKey(team)) { - DamconStatus old = mDamcons.get(team); - old.updateFrom(s); - } else { - mDamcons.put(team, s); - } - } - } - - @Listener - public void onPacket(ObjectUpdatePacket pkt) { - for (ArtemisObject p : pkt.getObjects()) { - updateOrCreate(p); - } - } - - @Listener - public void onPacket(IntelPacket pkt) { - ArtemisNpc npc = (ArtemisNpc) mObjects.get(Integer.valueOf(pkt.getId())); - - if (npc != null) { - npc.setIntel(pkt.getIntel()); - } - } - - @SuppressWarnings("unused") - private boolean updateOrCreate(ArtemisObject o) { - Integer id = Integer.valueOf(o.getId()); - ArtemisObject p = mObjects.get(id); - - if (p != null) { - p.updateFrom(o); - - if (o instanceof ArtemisPlayer) { - // just in case we get the ship number AFTER - // first creating the object, we store the - // updated ORIGINAL with the new ship number - ArtemisPlayer plr = (ArtemisPlayer) o; - - if (plr.getShipIndex() >= 0) { - mPlayers[plr.getShipIndex()] = (ArtemisPlayer) p; - } - } - - return false; - } - - synchronized(this) { - mObjects.put(id, o); - } - - if (o instanceof ArtemisPlayer) { - ArtemisPlayer plr = (ArtemisPlayer) o; - - if (plr.getShipIndex() >= 0) { - mPlayers[plr.getShipIndex()] = plr; - } - } - - if (DEBUG && o.getName() == null) { - throw new IllegalStateException("Creating " + p +" without name! " + - Integer.toHexString(o.getId())); - } - - mListener.onObjectCountChanged(mObjects.size()); - return true; - } - - public synchronized void getAll(List dest) { - dest.addAll(mObjects.values()); - } - - public synchronized void getAllSelectable(List dest) { - for (ArtemisObject obj : mObjects.values()) { - // tentative - if (!(obj instanceof ArtemisGenericObject)) { - dest.add(obj); - } - } - } - - /** - * Add objects of the given type to the given list - * - * @param dest - * @param type One of the ArtemisObject#TYPE_* constants - * @return The number of objects added to "dest" - */ - public synchronized int getObjects(List dest, ObjectType type) { - int count = 0; - - for (ArtemisObject obj : mObjects.values()) { - if (obj.getType() == type) { - dest.add(obj); - count++; - } - } - - return count; - } - - /** - * If you don't want/need to reuse a List, this - * will create a list for you - * - * @param type - * @return - * @see #getObjects(List, int) - */ - public List getObjects(ObjectType type) { - List objs = new ArrayList(); - getObjects(objs, type); - return objs; - } - - public ArtemisObject getObject(int objId) { - return mObjects.get(Integer.valueOf(objId)); - } - - /** - * Get the player ship by index. Possible values - * are the SetShipPacket#SHIP_* constants (that - * is, ints in range [0,5]) and NOT the - * {@link ArtemisPlayer#getShipIndex()} value - * - * @param shipIndex - * @return - */ - public ArtemisPlayer getPlayerShip(int shipIndex) { - if (shipIndex < 0 || shipIndex >= mPlayers.length) { - throw new IllegalArgumentException("Invalid ship index " + shipIndex); - } - - return mPlayers[shipIndex]; - } - - /** - * Get the status of the given Damcon Team - * if we have it, else null. It would be - * great to have a good first guess, but - * I can't seem to find any pattern, nor - * does there seem to be an init data---even - * the native client just uses a first guess - * on connect - * - * @param teamNumber - * @return - */ - public DamconStatus getDamcon(int teamNumber) { - return mDamcons.get(Integer.valueOf(teamNumber)); - } - - public GridEntry getGridAt(int x, int y, int z) { - return getGridAt(GridCoord.getInstance(x, y, z)); - } - - public GridEntry getGridAt(GridCoord key) { - if (mGrid == null) { - throw new IllegalStateException("SystemManager must have a ShipSystemGrid"); - } - - return mGrid.getGridAt(key); - } - - /** - * Get the type of System at the grid coordinates, - * or NULL if it's just a hallway - * @param x - * @param y - * @param z - * @return - */ - public ShipSystem getSystemTypeAt(int x, int y, int z) { - return mGrid.getSystemTypeAt(GridCoord.getInstance(x, y, z)); - } - - /** - * Get the overall health of the given system - * @param sys - * @return A float [0, 1] indicating percentage health - * @throws IllegalStateException if the SystemManager doesn't - * yet have a ShipSystemGrid - */ - public float getHealthOfSystem(ShipSystem sys) { - if (mGrid == null) { - throw new IllegalStateException("SystemManager must have a ShipSystemGrid"); - } - - final float total = mGrid.getSystemCount(sys); - float current = total; - - for (GridCoord c : mGrid.getCoordsFor(sys)) { - final float damage = getGridDamageAt(c); - - if (damage != -1) { - current -= damage; - } - } - - return current / total; - } - - /** - * Get the first object with the given name - * @param type - * @return null if no such object or if name is null - */ - public synchronized ArtemisObject getObjectByName(final String name) { - if (name == null) { - return null; - } - - for (ArtemisObject obj : mObjects.values()) { - if (name.equals(obj.getName())) { - return obj; - } - } - - return null; - } - - public boolean hasSystemGrid() { - return mGrid != null; - } - - public void setOnObjectCountChangedListener(OnObjectCountChangeListener listener) { - mListener = (listener == null) ? sDummyListener : listener; - } - - /** - * Get the damage at a specific grid coord - * @param coord - * @return The damage as a value [0, 1] or -1 - * if we don't have the any entry for the coord - */ - public float getGridDamageAt(GridCoord coord) { - if (mGridDamage == null) { - return -1f; - } - - Float value = mGridDamage.get(coord); - return value != null ? value.floatValue() : -1f; - } - - /** - * Convenience - * @param x - * @param y - * @param z - * @return - */ - public float getGridDamageAt(int x, int y, int z) { - return getGridDamageAt(GridCoord.getInstance(x, y, z)); - } - - public Set> getGridDamages() { - return mGridDamage.entrySet(); - } - - /** - * Set the current ship's (fully loaded) grid - * @param grid - */ - public void setSystemGrid(ShipSystemGrid grid) { - if (mGridDamage == null) { - mGridDamage = new HashMap(); - } else { - mGridDamage.clear(); // just in case - } - mGrid = grid; - - // fill some default values - for (GridCoord c : grid.getCoords()) { - mGridDamage.put(c, Float.valueOf(0f)); // default - } - } - - public synchronized void clear() { - mObjects.clear(); - Arrays.fill(mPlayers, null); - - mGrid = null; - - if (mGridDamage != null) { - mGridDamage.clear(); - } - - mDamcons.clear(); - } -} diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/TestPacketFile.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/TestPacketFile.java deleted file mode 100644 index 6c8a756..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/TestPacketFile.java +++ /dev/null @@ -1,333 +0,0 @@ -package net.dhleong.acl.protocol; - -import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.net.URL; -import java.nio.charset.Charset; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.BaseDebugger; -import net.dhleong.acl.iface.Listener; -import net.dhleong.acl.iface.ListenerRegistry; -import net.dhleong.acl.iface.PacketFactoryRegistry; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.util.TextUtil; - -/** - * Class that can read and write test packet files, and perform various - * operations useful for testing. - * - * The test files don't contain the raw binary data. Instead, they contain hex- - * encoded bytes for easier reading by humans. You can add white space for - * greater legibility. You can also add comments with double slashes (//); the - * slashes and all characters after them until the next newline character will - * be ignored. - * - * Example: - * // ToggleRedAlertPacket - * efbeadde // header - * 20000000 // packet length = 32 - * 02000000 // origin = client - * 00000000 // padding - * 0c000000 // remaining length = 12 - * 3c1d824c 0a000000 // ToggleRedAlertPacket - * 00000000 // unused - * - * @author rjwut - */ -public class TestPacketFile { - public enum Mode { - READ, WRITE - } - - private static final Charset UTF_8 = Charset.forName("UTF-8"); - - /** - * Reads a file name and a ConnectionType (SERVER or CLIENT) from the - * command line, then reads in the file, parses it, re-writes the packets, - * and confirms that the resulting output bytes exactly match the bytes that - * were originally read. - */ - public static void main(String[] args) { - String fileName = args[0]; - ConnectionType connType = ConnectionType.valueOf(args[1]); - - try { - new TestPacketFile(new File(fileName), Mode.READ).test(connType); - } catch (IOException ex) { - ex.printStackTrace(); - } - } - - private Mode mode; - private byte[] bytes; // bytes read in on read mode - private OutputStream os; // destination stream for write mode - private ByteArrayOutputStream baos; // buffer for write mode - - /** - * Reads test packet data from the given File. - */ - public TestPacketFile(File file, Mode mode) throws IOException { - if (mode == Mode.READ) { - initRead(new FileInputStream(file)); - } else if (mode == Mode.WRITE) { - initWrite(new FileOutputStream(file)); - } - } - - /** - * Reads test packet data from the given URL. - */ - public TestPacketFile(URL url) throws IOException { - initRead(url.openStream()); - } - - /** - * Reads test packet data from the given InputStream. - */ - public TestPacketFile(InputStream is) throws IOException { - initRead(is); - } - - public TestPacketFile(OutputStream os) { - initWrite(os); - } - - private void initRead(InputStream is) throws IOException { - mode = Mode.READ; - BufferedReader reader = new BufferedReader(new InputStreamReader(is, UTF_8)); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - String line; - - while ((line = reader.readLine()) != null) { - // strip out comments and whitespace - int commentIndex = line.indexOf("//"); - - if (commentIndex != -1) { - line = line.substring(0, commentIndex); - } - - line = line.replaceAll("\\s+", ""); - - if (line.isEmpty()) { - continue; // no actual data on this line - } - - out.write(TextUtil.hexToByteArray(line)); - } - - reader.close(); - bytes = out.toByteArray(); - } - - private void initWrite(OutputStream outputStream) { - mode = Mode.WRITE; - this.os = outputStream; - baos = new ByteArrayOutputStream(); - } - - /** - * Given a ConnectionType from which the data in this file originated, - * attempts to parse and re-write the data. If an error occurs, a stack - * trace will be written out to System.err. - */ - public void test(ConnectionType connType) { - if (mode != Mode.READ) { - throw new IllegalStateException("test() only valid for read mode"); - } - - // Set up PacketReader - ListenerRegistry listeners = new ListenerRegistry(); - listeners.register(this); - ByteArrayInputStream bais = new ByteArrayInputStream(bytes); - PacketReader reader = new PacketReader( - connType, - bais, - new PacketFactoryRegistry(), - listeners - ); - PacketTestDebugger debugger = new PacketTestDebugger(); - - // Read until there's no more data - while (bais.available() > 0) { - ArtemisPacket pkt; - - try { - // Parse a packet, then get the bytes from the Debugger - pkt = reader.readPacket(debugger); - System.out.println(pkt.getClass().getSimpleName()); - byte[] in = debugger.in; - - // Write the bytes out to a ByteArrayOutputStream - ByteArrayOutputStream baosOut = new ByteArrayOutputStream(); - PacketWriter writer = new PacketWriter(baosOut); - pkt.writeTo(writer, debugger); - byte[] out = baosOut.toByteArray(); - - // Compare against original bytes - if (!diff(pkt, in, out)) { - break; // diff already wrote out an error - } - } catch (ArtemisPacketException ex) { - ex.printStackTrace(); - } catch (IOException ex) { - ex.printStackTrace(); - } - } - } - - /** - * Returns a PacketReader of the given type that will consume the bytes from - * this file. - */ - public PacketReader toPacketReader(ConnectionType type) { - if (mode != Mode.READ) { - throw new IllegalStateException("toPacketReader() only valid for read mode"); - } - - ListenerRegistry listeners = new ListenerRegistry(); - listeners.register(this); - return new PacketReader( - type, - new ByteArrayInputStream(bytes), - new PacketFactoryRegistry(), - listeners - ); - } - - /** - * Returns a PacketWriter of the given type to write packets to the OutputStream. - */ - public PacketWriter toPacketWriter(ConnectionType type) { - if (mode != Mode.WRITE) { - throw new IllegalStateException("toPacketWriter() only valid for write mode"); - } - - return new PacketWriter(baos); - } - - /** - * Flushes the packets which have been written to the OutputStream and closes it. - */ - public void close() throws IOException { - if (mode != Mode.WRITE) { - throw new IllegalStateException("flush() only valid for read mode"); - } - - BufferedOutputStream bos = new BufferedOutputStream(os); - OutputStreamWriter writer = new OutputStreamWriter(bos); - writer.append(TextUtil.byteArrayToHexString(baos.toByteArray())); - writer.close(); - } - - /** - * Do nothing upon parsing a packet; this simply forces all packets to be - * read; the actual test work is handled by the PacketTestDebugger class. - */ - @Listener - public void onPacket(ArtemisPacket pkt) { - // do nothing - } - - /** - * Returns true if the bytes in the given ByteArrayOutputStream match those - * from this file; false otherwise. - */ - public boolean matches(ByteArrayOutputStream baosOut) { - if (mode != Mode.READ) { - throw new IllegalStateException("matches() only valid for read mode"); - } - - byte[] bytes2 = baosOut.toByteArray(); - - if (bytes.length != bytes2.length) { - return false; - } - - for (int i = 0; i < bytes.length; i++) { - if (bytes[i] != bytes2[i]) { - return false; - } - } - - return true; - } - - @Override - public String toString() { - return TextUtil.byteArrayToHexString(mode == Mode.READ ? bytes : baos.toByteArray()); - } - - - /** - * Used by TestPacketFile to capture the raw bytes from the file. This is - * used by test() method. It also ensures that any parse warnings get output - * to the console. - */ - private class PacketTestDebugger extends BaseDebugger { - private byte[] in; - - @Override - public void onRecvPacketBytes(ConnectionType connType, int pktType, - byte[] payload) { - int packetLength = payload.length + 24; - in = new byte[packetLength]; - int offset = 0; - offset = writeInt(ArtemisPacket.HEADER, in, offset); - offset = writeInt(packetLength, in, offset); - offset = writeInt(connType.toInt(), in, offset); - offset = writeInt(0, in, offset); - offset = writeInt(packetLength - 20, in, offset); - offset = writeInt(pktType, in, offset); - System.arraycopy(payload, 0, in, 24, payload.length); - } - - @Override - public void warn(String msg) { - System.out.println(msg); - } - } - - /** - * Writes an int to the given byte array at the indicated offset. - */ - private static int writeInt(int v, byte[] bytes, int offset) { - bytes[offset++] = (byte) (v & 0xff); - bytes[offset++] = (byte) ((v >> 8) & 0xff); - bytes[offset++] = (byte) ((v >> 16) & 0xff); - bytes[offset++] = (byte) ((v >> 24) & 0xff); - return offset; - } - - /** - * Returns true if the given byte arrays match. Otherwise, it prints out a - * description of the packet and the input and output byte arrays and - * returns false. - */ - private static boolean diff(ArtemisPacket pkt, byte[] in, byte[] out) { - boolean ok = in.length == out.length; - - for (int i = 0; ok && i < in.length; i++) { - ok = in[i] == out[i]; - } - - if (!ok) { - System.out.println(pkt); - System.out.println(" IN: " + TextUtil.byteArrayToHexString(in)); - System.out.println(" OUT: " + TextUtil.byteArrayToHexString(out)); - } - - return ok; - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/AudioCommandPacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/AudioCommandPacket.txt deleted file mode 100644 index 77d3191..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/AudioCommandPacket.txt +++ /dev/null @@ -1,17 +0,0 @@ -efbeadde // header -20000000 // packet length = 32 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 12 -7fc5ad6a // AudioCommandPacket -00000000 // ID = 0 -00000000 // command = play - -efbeadde // header -20000000 // packet length = 32 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 12 -7fc5ad6a // AudioCommandPacket -01000000 // ID = 1 -01000000 // command = delete \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/AudioCommandPacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/AudioCommandPacketTest.java deleted file mode 100644 index 14a152e..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/AudioCommandPacketTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.dhleong.acl.protocol.core.comm; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - -import net.dhleong.acl.enums.AudioCommand; -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class AudioCommandPacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/comm/AudioCommandPacket.txt", ConnectionType.CLIENT, 2); - } - - @Override - protected void testPackets(List packets) { - AudioCommandPacket pkt = packets.get(0); - Assert.assertEquals(0, pkt.getAudioId()); - Assert.assertEquals(AudioCommand.PLAY, pkt.getCommand()); - pkt = packets.get(1); - Assert.assertEquals(1, pkt.getAudioId()); - Assert.assertEquals(AudioCommand.DISMISS, pkt.getCommand()); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/CommsIncomingPacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/CommsIncomingPacket.txt deleted file mode 100644 index ebe164e..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/CommsIncomingPacket.txt +++ /dev/null @@ -1,14 +0,0 @@ -efbeadde // header -4e000000 // packet length = 76 -01000000 // origin = server -00000000 // padding -3a000000 // remaining length = 56 -5fc372d6 // CommsIncomingPacket - -00000000 // priority = 0 (high) - -// sender = DS1 -04000000 4400 5300 3100 0000 - -// message = Hi.^How are you? -11000000 4800 6900 2e00 5e00 4800 6f00 7700 2000 6100 7200 6500 2000 7900 6f00 7500 3f00 0000 \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/CommsIncomingPacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/CommsIncomingPacketTest.java deleted file mode 100644 index bf563f6..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/CommsIncomingPacketTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.dhleong.acl.protocol.core.comm; - -import java.util.List; - -import org.junit.Assert; - -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class CommsIncomingPacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/comm/CommsIncomingPacket.txt", ConnectionType.SERVER, 1); - } - - @Override - protected void testPackets(List packets) { - CommsIncomingPacket pkt = packets.get(0); - Assert.assertEquals(0, pkt.getPriority()); - Assert.assertEquals("DS1", pkt.getFrom()); - Assert.assertEquals("Hi.\nHow are you?", pkt.getMessage()); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/CommsOutgoingPacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/CommsOutgoingPacket.txt deleted file mode 100644 index db75d3c..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/CommsOutgoingPacket.txt +++ /dev/null @@ -1,47 +0,0 @@ -efbeadde // header -2c000000 // packet length = 44 -02000000 // origin = client -00000000 // padding -18000000 // remaining length = 24 -4b4c4c57 // CommsOutgoingPacket -00000000 // recipient type = player -00000000 // recipient ID = 0 -04000000 // message = Die! -78007300 // [no argument] -5e004f00 // [unknown] - -efbeadde // header -2c000000 // packet length = 44 -02000000 // origin = client -00000000 // padding -18000000 // remaining length = 24 -4b4c4c57 // CommsOutgoingPacket -01000000 // recipient type = enemy -01000000 // recipient ID = 1 -00000000 // message = Will you surrender? -78007300 // [no argument] -5e004f00 // [unknown] - -efbeadde // header -2c000000 // packet length = 44 -02000000 // origin = client -00000000 // padding -18000000 // remaining length = 24 -4b4c4c57 // CommsOutgoingPacket -02000000 // recipient type = base -02000000 // recipient ID = 2 -03000000 // message = Build nukes -78007300 // [no argument] -5e004f00 // [unknown] - -efbeadde // header -2c000000 // packet length = 44 -02000000 // origin = client -00000000 // padding -18000000 // remaining length = 24 -4b4c4c57 // CommsOutgoingPacket -03000000 // recipient type = other -03000000 // recipient ID = 3 -09000000 // message = Go defend [target] -2f000000 // target ID = 47 -5e004f00 // [unknown] \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/CommsOutgoingPacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/CommsOutgoingPacketTest.java deleted file mode 100644 index 4995d81..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/CommsOutgoingPacketTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.dhleong.acl.protocol.core.comm; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - -import net.dhleong.acl.enums.BaseMessage; -import net.dhleong.acl.enums.CommsRecipientType; -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.EnemyMessage; -import net.dhleong.acl.enums.OtherMessage; -import net.dhleong.acl.enums.PlayerMessage; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class CommsOutgoingPacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/comm/CommsOutgoingPacket.txt", ConnectionType.CLIENT, 4); - } - - @Override - protected void testPackets(List packets) { - CommsOutgoingPacket pkt = packets.get(0); - Assert.assertEquals(CommsRecipientType.PLAYER, pkt.getRecipientType()); - Assert.assertEquals(0, pkt.getRecipientId()); - Assert.assertEquals(PlayerMessage.DIE, pkt.getMessage()); - Assert.assertEquals(CommsOutgoingPacket.NO_ARG, pkt.getArgument()); - - pkt = packets.get(1); - Assert.assertEquals(CommsRecipientType.ENEMY, pkt.getRecipientType()); - Assert.assertEquals(1, pkt.getRecipientId()); - Assert.assertEquals(EnemyMessage.WILL_YOU_SURRENDER, pkt.getMessage()); - Assert.assertEquals(CommsOutgoingPacket.NO_ARG, pkt.getArgument()); - - pkt = packets.get(2); - Assert.assertEquals(CommsRecipientType.BASE, pkt.getRecipientType()); - Assert.assertEquals(2, pkt.getRecipientId()); - Assert.assertEquals(BaseMessage.BUILD_NUKES, pkt.getMessage()); - Assert.assertEquals(CommsOutgoingPacket.NO_ARG, pkt.getArgument()); - - pkt = packets.get(3); - Assert.assertEquals(CommsRecipientType.OTHER, pkt.getRecipientType()); - Assert.assertEquals(3, pkt.getRecipientId()); - Assert.assertEquals(OtherMessage.GO_DEFEND, pkt.getMessage()); - Assert.assertEquals(47, pkt.getArgument()); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/IncomingAudioPacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/IncomingAudioPacket.txt deleted file mode 100644 index 79961ad..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/IncomingAudioPacket.txt +++ /dev/null @@ -1,21 +0,0 @@ -efbeadde // header -48000000 // packet length = 72 -01000000 // origin = server -00000000 // padding -34000000 // remaining length = 52 -58e088ae // AudioCommandPacket -00000000 // ID = 0 -02000000 // mode = incoming -// title = Hello -06000000 4800 6500 6c00 6c00 6f00 0000 -// filename = hello.ogg -0a000000 6800 6500 6c00 6c00 6f00 2e00 6f00 6700 6700 0000 - -efbeadde // header -20000000 // packet length = 32 -01000000 // origin = server -00000000 // padding -0c000000 // remaining length = 12 -58e088ae // AudioCommandPacket -01000000 // ID = 1 -01000000 // mode = playing \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/IncomingAudioPacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/IncomingAudioPacketTest.java deleted file mode 100644 index be18291..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/IncomingAudioPacketTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.dhleong.acl.protocol.core.comm; - -import java.util.List; - -import org.junit.Assert; - -import org.junit.Test; - -import net.dhleong.acl.enums.AudioMode; -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class IncomingAudioPacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/comm/IncomingAudioPacket.txt", ConnectionType.SERVER, 2); - } - - @Override - protected void testPackets(List packets) { - IncomingAudioPacket pkt = packets.get(0); - Assert.assertEquals(0, pkt.getAudioId()); - Assert.assertEquals(AudioMode.INCOMING, pkt.getAudioMode()); - Assert.assertEquals("Hello", pkt.getTitle()); - Assert.assertEquals("hello.ogg", pkt.getFileName()); - pkt = packets.get(1); - Assert.assertEquals(1, pkt.getAudioId()); - Assert.assertEquals(AudioMode.PLAYING, pkt.getAudioMode()); - Assert.assertNull(pkt.getTitle()); - Assert.assertNull(pkt.getFileName()); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/ToggleRedAlertPacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/ToggleRedAlertPacket.txt deleted file mode 100644 index 64dd669..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/ToggleRedAlertPacket.txt +++ /dev/null @@ -1,7 +0,0 @@ -efbeadde // header -20000000 // packet length = 32 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 12 -3c1d824c 0a000000 // ToggleRedAlertPacket -00000000 // unused \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/ToggleRedAlertPacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/ToggleRedAlertPacketTest.java deleted file mode 100644 index ce285c6..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/comm/ToggleRedAlertPacketTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.dhleong.acl.protocol.core.comm; - -import java.util.List; - -import org.junit.Assert; - -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class ToggleRedAlertPacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/comm/ToggleRedAlertPacket.txt", ConnectionType.CLIENT, 1); - } - - @Override - protected void testPackets(List packets) { - Assert.assertNotNull(packets.get(0)); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngAutoDamconUpdatePacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngAutoDamconUpdatePacket.txt deleted file mode 100644 index 742540c..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngAutoDamconUpdatePacket.txt +++ /dev/null @@ -1,15 +0,0 @@ -efbeadde // header -20000000 // packet length = 32 -01000000 // origin = server -00000000 // padding -0c000000 // remaining length = 12 -fec854f7 0b000000 // EngAutoDamconUpdatePacket -00000000 // off - -efbeadde // header -20000000 // packet length = 32 -01000000 // origin = server -00000000 // padding -0c000000 // remaining length = 12 -fec854f7 0b000000 // EngAutoDamconUpdatePacket -01000000 // on diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngAutoDamconUpdatePacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngAutoDamconUpdatePacketTest.java deleted file mode 100644 index fe06a12..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngAutoDamconUpdatePacketTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.dhleong.acl.protocol.core.eng; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class EngAutoDamconUpdatePacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/eng/EngAutoDamconUpdatePacket.txt", ConnectionType.SERVER, 2); - } - - @Override - protected void testPackets(List packets) { - EngAutoDamconUpdatePacket pkt = packets.get(0); - Assert.assertFalse(pkt.isOn()); - pkt = packets.get(1); - Assert.assertTrue(pkt.isOn()); - } -} diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngGridUpdatePacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngGridUpdatePacket.txt deleted file mode 100644 index 94b4882..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngGridUpdatePacket.txt +++ /dev/null @@ -1,22 +0,0 @@ -efbeadde // header -4a000000 // packet length = 74 -01000000 // origin = server -00000000 // padding -36000000 // remaining length = 54 -3c9f7e07 // EngGridUpdatePacket -01 // unknown -000000 // 0,0,0 -00000000 // 0.0 damage -01ff01 // 1,-1,1 -3333333f // 0.7 damage -ff // end of grid marker -0a // team = 0 -04000000 // goal X = 4 -03000000 // current X = 3 -07000000 // goal Y = 7 -04000000 // current Y = 4 -ffffffff // goal Z = -1 -00000000 // current Z = 0 -9a99993e // progress = 0.3 -03000000 // team member count = 3 -fe // end of DAMCON status marker diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngGridUpdatePacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngGridUpdatePacketTest.java deleted file mode 100644 index 0044ed8..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngGridUpdatePacketTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package net.dhleong.acl.protocol.core.eng; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; -import net.dhleong.acl.util.GridCoord; - -public class EngGridUpdatePacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/eng/EngGridUpdatePacket.txt", ConnectionType.SERVER, 1); - } - - @Override - protected void testPackets(List packets) { - EngGridUpdatePacket pkt = packets.get(0); - List damages = pkt.getDamage(); - Assert.assertEquals(2, damages.size()); - EngGridUpdatePacket.GridDamage damage = damages.get(0); - GridCoord coord = damage.getCoord(); - Assert.assertEquals(0, coord.getX()); - Assert.assertEquals(0, coord.getY()); - Assert.assertEquals(0, coord.getZ()); - Assert.assertEquals(0.0f, damage.getDamage(), EPSILON); - damage = damages.get(1); - coord = damage.getCoord(); - Assert.assertEquals(1, coord.getX()); - Assert.assertEquals(-1, coord.getY()); - Assert.assertEquals(1, coord.getZ()); - Assert.assertEquals(0.7f, damage.getDamage(), EPSILON); - List statuses = pkt.getDamcons(); - Assert.assertEquals(1, statuses.size()); - EngGridUpdatePacket.DamconStatus status = statuses.get(0); - Assert.assertEquals(0, status.getTeamNumber()); - Assert.assertEquals(3, status.getMembers()); - Assert.assertEquals(0.3f, status.getProgress(), EPSILON); - coord = status.getPosition(); - Assert.assertEquals(3, coord.getX()); - Assert.assertEquals(4, coord.getY()); - Assert.assertEquals(0, coord.getZ()); - coord = status.getGoal(); - Assert.assertEquals(4, coord.getX()); - Assert.assertEquals(7, coord.getY()); - Assert.assertEquals(-1, coord.getZ()); - } -} diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSendDamconPacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSendDamconPacket.txt deleted file mode 100644 index 766e30d..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSendDamconPacket.txt +++ /dev/null @@ -1,17 +0,0 @@ -efbeadde // header -2c000000 // packet length = 44 -02000000 // origin = client -00000000 // padding -18000000 // remaining length = 24 -d901cc69 04000000 // EngSendDamconPacket -00000000 // damcon team #0 -00000000 00000000 00000000 // coords = (0, 0, 0) - -efbeadde // header -2c000000 // packet length = 44 -02000000 // origin = client -00000000 // padding -18000000 // remaining length = 24 -d901cc69 04000000 // EngSendDamconPacket -01000000 // damcon team #1 -02000000 03000000 04000000 // coords = (2, 3, 4) diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSendDamconPacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSendDamconPacketTest.java deleted file mode 100644 index 795baa9..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSendDamconPacketTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package net.dhleong.acl.protocol.core.eng; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; -import net.dhleong.acl.util.GridCoord; - -public class EngSendDamconPacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/eng/EngSendDamconPacket.txt", ConnectionType.CLIENT, 2); - } - - @Override - protected void testPackets(List packets) { - EngSendDamconPacket pkt = packets.get(0); - Assert.assertEquals(0, pkt.getTeamNumber()); - GridCoord coord = pkt.getDestination(); - Assert.assertEquals(0, coord.getX()); - Assert.assertEquals(0, coord.getY()); - Assert.assertEquals(0, coord.getZ()); - pkt = packets.get(1); - Assert.assertEquals(1, pkt.getTeamNumber()); - coord = pkt.getDestination(); - Assert.assertEquals(2, coord.getX()); - Assert.assertEquals(3, coord.getY()); - Assert.assertEquals(4, coord.getZ()); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetAutoDamconPacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetAutoDamconPacket.txt deleted file mode 100644 index 6d9e0ee..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetAutoDamconPacket.txt +++ /dev/null @@ -1,15 +0,0 @@ -efbeadde // header -20000000 // packet length = 44 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 24 -3c1d824c 0c000000 // EngSetAutoDamconPacket -00000000 // autonomous off - -efbeadde // header -20000000 // packet length = 44 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 24 -3c1d824c 0c000000 // EngSetAutoDamconPacket -01000000 // autonomous on diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetAutoDamconPacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetAutoDamconPacketTest.java deleted file mode 100644 index cdc892e..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetAutoDamconPacketTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.dhleong.acl.protocol.core.eng; - -import java.util.List; - -import org.junit.Assert; - -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class EngSetAutoDamconPacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/eng/EngSetAutoDamconPacket.txt", ConnectionType.CLIENT, 2); - } - - @Override - protected void testPackets(List packets) { - EngSetAutoDamconPacket pkt = packets.get(0); - Assert.assertFalse(pkt.isAutonomous()); - pkt = packets.get(1); - Assert.assertTrue(pkt.isAutonomous()); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetCoolantPacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetCoolantPacket.txt deleted file mode 100644 index ad337f7..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetCoolantPacket.txt +++ /dev/null @@ -1,17 +0,0 @@ -efbeadde // header -24000000 // packet length = 36 -02000000 // origin = client -00000000 // padding -10000000 // remaining length = 16 -d901cc69 00000000 // EngSetCoolantPacket -07000000 // system = aft shields -03000000 // coolant = 3 - -efbeadde // header -24000000 // packet length = 36 -02000000 // origin = client -00000000 // padding -10000000 // remaining length = 16 -d901cc69 00000000 // EngSetCoolantPacket -00000000 // system = beams -00000000 // coolant = 0 diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetCoolantPacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetCoolantPacketTest.java deleted file mode 100644 index 5eadaaa..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetCoolantPacketTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.dhleong.acl.protocol.core.eng; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class EngSetCoolantPacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/eng/EngSetCoolantPacket.txt", ConnectionType.CLIENT, 2); - } - - @Override - protected void testPackets(List packets) { - EngSetCoolantPacket pkt = packets.get(0); - Assert.assertEquals(ShipSystem.AFT_SHIELDS, pkt.getSystem()); - Assert.assertEquals(3, pkt.getCoolant()); - pkt = packets.get(1); - Assert.assertEquals(ShipSystem.BEAMS, pkt.getSystem()); - Assert.assertEquals(0, pkt.getCoolant()); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetEnergyPacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetEnergyPacket.txt deleted file mode 100644 index 1acd144..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetEnergyPacket.txt +++ /dev/null @@ -1,26 +0,0 @@ -efbeadde // header -24000000 // packet length = 36 -02000000 // origin = client -00000000 // padding -10000000 // remaining length = 16 -aca55103 04000000 // EngSetEnergyPacket -abaaaa3e // energy allocation = 100% (0.33333334) -00000000 // beams - -efbeadde // header -24000000 // packet length = 36 -02000000 // origin = client -00000000 // padding -10000000 // remaining length = 16 -aca55103 04000000 // EngSetEnergyPacket -00000000 // energy allocation = 0% (0.0) -07000000 // aft shields - -efbeadde // header -24000000 // packet length = 36 -02000000 // origin = client -00000000 // padding -10000000 // remaining length = 16 -aca55103 04000000 // EngSetEnergyPacket -0000803f // energy allocation = 300% (1.0) -05000000 // warp/jump drive \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetEnergyPacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetEnergyPacketTest.java deleted file mode 100644 index 689c3da..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/eng/EngSetEnergyPacketTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package net.dhleong.acl.protocol.core.eng; - -import java.util.List; - -import org.junit.Assert; - -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class EngSetEnergyPacketTest extends AbstractPacketTester { - private static final float DEFAULT_ENERGY_ALLOCATION = 1.0f / 3; - - @Test - public void test() { - execute("core/eng/EngSetEnergyPacket.txt", ConnectionType.CLIENT, 3); - } - - @Override - protected void testPackets(List packets) { - EngSetEnergyPacket pkt = packets.get(0); - Assert.assertEquals(pkt.getSystem(), ShipSystem.BEAMS); - Assert.assertEquals(DEFAULT_ENERGY_ALLOCATION, pkt.getAllocation(), EPSILON); - pkt = packets.get(1); - Assert.assertEquals(pkt.getSystem(), ShipSystem.AFT_SHIELDS); - Assert.assertEquals(0.0f, pkt.getAllocation(), EPSILON); - pkt = packets.get(2); - Assert.assertEquals(pkt.getSystem(), ShipSystem.WARP_JUMP_DRIVE); - Assert.assertEquals(1.0f, pkt.getAllocation(), EPSILON); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/ClimbDivePacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/ClimbDivePacket.txt deleted file mode 100644 index fee5534..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/ClimbDivePacket.txt +++ /dev/null @@ -1,15 +0,0 @@ -efbeadde // header -20000000 // packet length = 32 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 12 -3c1d824c 1b000000 // ClimbDivePacket -ffffffff // direction = up - -efbeadde // header -20000000 // packet length = 32 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 12 -3c1d824c 1b000000 // ClimbDivePacket -01000000 // direction = down diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/ClimbDivePacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/ClimbDivePacketTest.java deleted file mode 100644 index e90364c..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/ClimbDivePacketTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class ClimbDivePacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/helm/ClimbDivePacket.txt", ConnectionType.CLIENT, 2); - } - - @Override - protected void testPackets(List packets) { - Assert.assertTrue(packets.get(0).isUp()); - Assert.assertFalse(packets.get(1).isUp()); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmJumpPacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmJumpPacket.txt deleted file mode 100644 index 318ea6a..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmJumpPacket.txt +++ /dev/null @@ -1,8 +0,0 @@ -efbeadde // header -24000000 // packet size = 36 -02000000 // origin = client -00000000 // padding -10000000 // remaining size = 16 -aca55103 05000000 // HelmJumpPacket -cdcc4c3e // heading = 0.2 (72 degrees) -3333333f // distance = 0.7 (35 kls) diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmJumpPacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmJumpPacketTest.java deleted file mode 100644 index 3a93ae7..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmJumpPacketTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class HelmJumpPacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/helm/HelmJumpPacket.txt", ConnectionType.CLIENT, 1); - } - - @Override - protected void testPackets(List packets) { - HelmJumpPacket pkt = packets.get(0); - Assert.assertEquals(0.2f, pkt.getHeading(), EPSILON); - Assert.assertEquals(0.7f, pkt.getDistance(), EPSILON); - } -} diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmRequestDockPacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmRequestDockPacket.txt deleted file mode 100644 index 5307f2d..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmRequestDockPacket.txt +++ /dev/null @@ -1,7 +0,0 @@ -efbeadde // header -20000000 // packet length = 32 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 12 -3c1d824c 07000000 // HelmRequestDockPacket -00000000 // unused diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmRequestDockPacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmRequestDockPacketTest.java deleted file mode 100644 index e6249fd..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmRequestDockPacketTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class HelmRequestDockPacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/helm/HelmRequestDockPacket.txt", ConnectionType.CLIENT, 1); - } - - @Override - protected void testPackets(List packets) { - Assert.assertNotNull(packets.get(0)); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetClimbDivePacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetClimbDivePacket.txt deleted file mode 100644 index 5a7cb26..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetClimbDivePacket.txt +++ /dev/null @@ -1,23 +0,0 @@ -efbeadde // header -20000000 // packet length = 32 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 12 -aca55103 02000000 // SetClimbDivePacket -00000000 // level out - -efbeadde // header -20000000 // packet length = 32 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 12 -aca55103 02000000 // SetClimbDivePacket -000080bf // hard dive - -efbeadde // header -20000000 // packet length = 32 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 12 -aca55103 02000000 // SetClimbDivePacket -9a99993e // gentle climb diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetClimbDivePacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetClimbDivePacketTest.java deleted file mode 100644 index 760bffe..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetClimbDivePacketTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class HelmSetClimbDivePacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/helm/HelmSetClimbDivePacket.txt", ConnectionType.CLIENT, 3); - } - - @Override - protected void testPackets(List packets) { - HelmSetClimbDivePacket pkt = packets.get(0); - Assert.assertEquals(0.0f, pkt.getPitch(), EPSILON); - pkt = packets.get(1); - Assert.assertEquals(-1.0f, pkt.getPitch(), EPSILON); - pkt = packets.get(2); - Assert.assertEquals(0.3f, pkt.getPitch(), EPSILON); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetImpulsePacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetImpulsePacket.txt deleted file mode 100644 index 86f5942..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetImpulsePacket.txt +++ /dev/null @@ -1,15 +0,0 @@ -efbeadde // header -20000000 // packet length = 32 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 12 -aca55103 00000000 // HelmSetImpulsePacket -00000000 // all stop (0.0f) - -efbeadde // header -20000000 // packet length = 32 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 12 -aca55103 00000000 // HelmSetImpulsePacket -3333333f // 70% (0.7f) diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetImpulsePacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetImpulsePacketTest.java deleted file mode 100644 index f16c919..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetImpulsePacketTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import java.util.List; - -import junit.framework.Assert; - -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class HelmSetImpulsePacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/helm/HelmSetImpulsePacket.txt", ConnectionType.CLIENT, 2); - } - - @Override - protected void testPackets(List packets) { - HelmSetImpulsePacket pkt = packets.get(0); - Assert.assertEquals(0.0f, pkt.getPower(), EPSILON); - pkt = packets.get(1); - Assert.assertEquals(0.7f, pkt.getPower(), EPSILON); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetSteeringPacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetSteeringPacket.txt deleted file mode 100644 index 0a1be88..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetSteeringPacket.txt +++ /dev/null @@ -1,15 +0,0 @@ -efbeadde // header -20000000 // packet length = 32 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 12 -aca55103 01000000 // HelmSetSteeringPacket -00000000 // hard to port (0.0f) - -efbeadde // header -20000000 // packet length = 32 -02000000 // origin = client -00000000 // padding -0c000000 // remaining length = 12 -aca55103 01000000 // HelmSetSteeringPacket -3333333f // medium to starboard (0.7f) diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetSteeringPacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetSteeringPacketTest.java deleted file mode 100644 index a74630e..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/helm/HelmSetSteeringPacketTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.dhleong.acl.protocol.core.helm; - -import java.util.List; - -import junit.framework.Assert; - -import org.junit.Test; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.protocol.core.setup.AbstractPacketTester; - -public class HelmSetSteeringPacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/helm/HelmSetSteeringPacket.txt", ConnectionType.CLIENT, 2); - } - - @Override - protected void testPackets(List packets) { - HelmSetSteeringPacket pkt = packets.get(0); - Assert.assertEquals(0.0f, pkt.getSteering(), EPSILON); - pkt = packets.get(1); - Assert.assertEquals(0.7f, pkt.getSteering(), EPSILON); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/AbstractPacketTester.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/AbstractPacketTester.java deleted file mode 100644 index db2cc24..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/AbstractPacketTester.java +++ /dev/null @@ -1,98 +0,0 @@ -package net.dhleong.acl.protocol.core.setup; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.lang.management.ManagementFactory; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.BaseDebugger; -import net.dhleong.acl.iface.Debugger; -import net.dhleong.acl.iface.OutputStreamDebugger; -import net.dhleong.acl.iface.PacketReader; -import net.dhleong.acl.iface.PacketWriter; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.ArtemisPacketException; -import net.dhleong.acl.protocol.TestPacketFile; - -/** - * Abstract class that can be extended for testing individual packet types. - */ -public abstract class AbstractPacketTester { - // Are we running in debug mode? - private static final boolean DEBUG = ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("jdwp") >= 0; - - protected static final float EPSILON = 0.00000001f; // for float equality checks - - /** - * Invoked by AbstractPacketTester when it has successfully parsed the - * desired number of packets with no bytes left over. The resulting packets - * are passed in; subclasses should evaluate them to ensure that they - * contain the expected data and throw an assert if not. - */ - protected abstract void testPackets(List packets); - - private Debugger debugger = DEBUG ? new OutputStreamDebugger() : new BaseDebugger(); - - /** - * Loads the test packet file at the indicated path and reads the given - * number of packets from it. After building a human-readable description of - * each packet, they are then passed to testPackets(); subclasses will - * override this to perform type-specific tests for those packets. Finally, - * the packets will be written out to a stream, and the resulting bytes - * compared to the original file. - */ - protected void execute(String resourcePath, ConnectionType type, int packetCount) { - try { - // Load test packet file - URL url = TestPacketFile.class.getResource(resourcePath); - TestPacketFile file = new TestPacketFile(url); - - if (DEBUG) { - System.out.println("\n### " + resourcePath); - } - - // Parse the desired number of packets - PacketReader reader = file.toPacketReader(type); - List list = new ArrayList(packetCount); - - for (int i = 0; i < packetCount; i++) { - T pkt = (T) reader.readPacket(debugger); - Assert.assertNotNull(pkt); - list.add(pkt); - Assert.assertFalse(reader.hasMore()); // Any bytes left over? - pkt.toString(); - } - - // Delegate to subclass for type-specific tests - testPackets(list); - - // Write packets back out - if (DEBUG) { - System.out.println("Writing packets..."); - } - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PacketWriter writer = new PacketWriter(baos); - - for (T pkt : list) { - pkt.writeTo(writer, debugger); - } - - // Compare written bytes to originals - Assert.assertTrue(file.matches(baos)); - - if (DEBUG) { - System.out.println("Input and output bytes match"); - } - } catch (IOException ex) { - throw new RuntimeException(ex); - } catch (ArtemisPacketException ex) { - throw new RuntimeException(ex); - } - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/VersionPacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/VersionPacket.txt deleted file mode 100644 index c5707c7..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/VersionPacket.txt +++ /dev/null @@ -1,24 +0,0 @@ -// Legacy version (2.0) -efbeadde // header -20000000 // packet length = 32 -01000000 // origin = server -00000000 // padding -0c000000 // remaining length = 12 -4ae748e5 // VersionPacket - -00000000 // unknown -00000040 // version = 2.0 - -// Modern version (2.1.1) -efbeadde // header -2c000000 // packet length = 44 -01000000 // origin = server -00000000 // padding -18000000 // remaining length = 24 -4ae748e5 // VersionPacket - -00000000 // unknown -00000040 // version = 2.0 (legacy) -02000000 // major = 2 -01000000 // minor = 1 -01000000 // patch = 1 \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/VersionPacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/VersionPacketTest.java deleted file mode 100644 index fc76c9a..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/VersionPacketTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.dhleong.acl.protocol.core.setup; - -import java.util.List; - -import org.junit.Assert; - -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.util.Version; - -import org.junit.Test; - -public class VersionPacketTest extends AbstractPacketTester { - private static final Version VERSION_2_0 = new Version(2.0f); - private static final Version VERSION_2_1_1 = new Version("2.1.1"); - - @Test - public void test() { - execute("core/setup/VersionPacket.txt", ConnectionType.SERVER, 2); - } - - @Override - protected void testPackets(List packets) { - Assert.assertEquals(VERSION_2_0, packets.get(0).getVersion()); - Assert.assertEquals(VERSION_2_1_1, packets.get(1).getVersion()); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/WelcomePacket.txt b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/WelcomePacket.txt deleted file mode 100644 index 881b5e0..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/WelcomePacket.txt +++ /dev/null @@ -1,14 +0,0 @@ -efbeadde // header -8c000000 // packet length = 140 -01000000 // origin = server -00000000 // padding -78000000 // remaining length = 120 -dab3046d // WelcomePacket - -70000000 // string length = 112 -59 6f 75 20 68 61 76 65 20 63 6f 6e 6e 65 63 74 65 64 20 // You have connected -74 6f 20 54 68 6f 6d 20 52 6f 62 65 72 74 73 6f 6e 27 73 // to Thom Roberton's -20 41 72 74 65 6d 69 73 20 42 72 69 64 67 65 20 53 69 6d // Artemis Bridge Sim -75 6c 61 74 6f 72 2e 20 20 50 6c 65 61 73 65 20 63 6f 6e // ulator. Please con -6e 65 63 74 20 77 69 74 68 20 61 6e 20 61 75 74 68 6f 72 // nect with an author -69 7a 65 64 20 67 61 6d 65 20 63 6c 69 65 6e 74 2e // ized game client. \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/WelcomePacketTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/WelcomePacketTest.java deleted file mode 100644 index 2d83c14..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/protocol/core/setup/WelcomePacketTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package net.dhleong.acl.protocol.core.setup; - -import java.util.List; - -import org.junit.Assert; - -import net.dhleong.acl.enums.ConnectionType; - -import org.junit.Test; - -public class WelcomePacketTest extends AbstractPacketTester { - @Test - public void test() { - execute("core/setup/WelcomePacket.txt", ConnectionType.SERVER, 1); - } - - @Override - protected void testPackets(List packets) { - Assert.assertEquals(WelcomePacket.MSG, packets.get(0).getMessage()); - } -} \ No newline at end of file diff --git a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/vesseldata/VesselDataTest.java b/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/vesseldata/VesselDataTest.java deleted file mode 100644 index 9537558..0000000 --- a/lib/ArtClientLib-2.6.0/test/net/dhleong/acl/vesseldata/VesselDataTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package net.dhleong.acl.vesseldata; - -import static org.junit.Assert.*; -import net.dhleong.acl.enums.FactionAttribute; -import net.dhleong.acl.enums.VesselAttribute; - -import org.junit.BeforeClass; -import org.junit.Test; - -public class VesselDataTest { - private static VesselData vesselData; - - @BeforeClass - public static void beforeClass() { - vesselData = VesselData.get(); - } - - @Test - public void testFactions() { - testFaction(vesselData.getFaction(0), "TSN", FactionAttribute.PLAYER); - testFaction(vesselData.getFaction(1), "TSN", FactionAttribute.FRIENDLY); - testFaction(vesselData.getFaction(2), "Kralien", FactionAttribute.ENEMY, - FactionAttribute.STANDARD); - testFaction(vesselData.getFaction(3), "Arvonian", FactionAttribute.ENEMY, - FactionAttribute.SUPPORT, FactionAttribute.WHALELOVER); - testFaction(vesselData.getFaction(4), "Torgoth", FactionAttribute.ENEMY, - FactionAttribute.SUPPORT, FactionAttribute.WHALEHATER); - testFaction(vesselData.getFaction(5), "Skaraan", FactionAttribute.ENEMY, - FactionAttribute.LONER, FactionAttribute.ELITE); - testFaction(vesselData.getFaction(6), "BioMech", FactionAttribute.ENEMY, - FactionAttribute.LONER, FactionAttribute.BIOMECH); - } - - @Test - public void testVessels() { - testVessel(vesselData.getVessel(0), "Light Cruiser", 0, 80, 80, - VesselAttribute.PLAYER); - testVessel(vesselData.getVessel(1), "Scout", 0, 60, 60, - VesselAttribute.PLAYER); - testVessel(vesselData.getVessel(2), "Battleship", 0, 250, 150, - VesselAttribute.PLAYER); - testVessel(vesselData.getVessel(3), "Missile Cruiser", 0, 110, 80, - VesselAttribute.PLAYER); - testVessel(vesselData.getVessel(4), "Dreadnought", 0, 200, 200, - VesselAttribute.PLAYER); - } - - private static void testFaction(Faction faction, String name, - FactionAttribute... attrs) { - assertEquals(name, faction.getName()); - assertEquals(attrs.length, faction.getAttributes().length); - assertTrue(faction.is(attrs)); - } - - private static void testVessel(Vessel vessel, String name, int side, - int foreShield, int aftShield, VesselAttribute... attrs) { - assertEquals(name, vessel.getName()); - assertEquals(0, vessel.getSide()); - assertEquals(foreShield, vessel.getForeShields()); - assertEquals(aftShield, vessel.getAftShields()); - assertEquals(attrs.length, vessel.getAttributes().length); - assertTrue(vessel.is(attrs)); - } -} \ No newline at end of file diff --git a/lib/artclientlib-2.6.0.jar b/lib/artclientlib-2.6.0.jar deleted file mode 100644 index 782ea01..0000000 Binary files a/lib/artclientlib-2.6.0.jar and /dev/null differ diff --git a/lib/ian-UNRELEASED.jar b/lib/ian-UNRELEASED.jar new file mode 100644 index 0000000..99d7b0e Binary files /dev/null and b/lib/ian-UNRELEASED.jar differ diff --git a/src/com/brindyblitz/artemis/engconsole/BaseEngineeringConsoleManager.java b/src/com/brindyblitz/artemis/engconsole/BaseEngineeringConsoleManager.java index b931bfb..92983c3 100644 --- a/src/com/brindyblitz/artemis/engconsole/BaseEngineeringConsoleManager.java +++ b/src/com/brindyblitz/artemis/engconsole/BaseEngineeringConsoleManager.java @@ -1,5 +1,6 @@ package com.brindyblitz.artemis.engconsole; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -10,15 +11,15 @@ import com.brindyblitz.artemis.utils.newton.DerivedProperty; import com.brindyblitz.artemis.utils.newton.Property; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.protocol.core.eng.EngGridUpdatePacket.DamconStatus; -import net.dhleong.acl.util.GridCoord; -import net.dhleong.acl.util.ShipSystemGrid; -import net.dhleong.acl.vesseldata.Vessel; -import net.dhleong.acl.vesseldata.VesselData; -import net.dhleong.acl.vesseldata.VesselNode; -import net.dhleong.acl.vesseldata.VesselNodeConnection; -import net.dhleong.acl.world.Artemis; +import com.walkertribe.ian.enums.ShipSystem; +import com.walkertribe.ian.protocol.core.eng.EngGridUpdatePacket.DamconStatus; +import com.walkertribe.ian.util.GridCoord; +import com.walkertribe.ian.util.ShipSystemGrid; +import com.walkertribe.ian.vesseldata.Vessel; +import com.walkertribe.ian.vesseldata.VesselData; +import com.walkertribe.ian.vesseldata.VesselNode; +import com.walkertribe.ian.vesseldata.VesselNodeConnection; +import com.walkertribe.ian.world.Artemis; public abstract class BaseEngineeringConsoleManager implements EngineeringConsoleManager { @@ -30,6 +31,8 @@ public abstract class BaseEngineeringConsoleManager implements EngineeringConsol public BaseEngineeringConsoleManager() { + VesselData.setArtemisInstallPath(new File(System.getProperty("user.dir"), "artemisData")); + NonShittyShipSystemGrid shipSystemGrid = new NonShittyShipSystemGrid(); this.grid = new ArrayList<>(); this.gridIndex = new HashMap<>(); diff --git a/src/com/brindyblitz/artemis/engconsole/EngineeringConsoleManager.java b/src/com/brindyblitz/artemis/engconsole/EngineeringConsoleManager.java index f3309ad..2e69c6d 100644 --- a/src/com/brindyblitz/artemis/engconsole/EngineeringConsoleManager.java +++ b/src/com/brindyblitz/artemis/engconsole/EngineeringConsoleManager.java @@ -5,12 +5,12 @@ import com.brindyblitz.artemis.utils.newton.Property; -import net.dhleong.acl.enums.OrdnanceType; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.protocol.core.eng.EngGridUpdatePacket.DamconStatus; -import net.dhleong.acl.util.GridCoord; -import net.dhleong.acl.vesseldata.VesselNode; -import net.dhleong.acl.vesseldata.VesselNodeConnection; +import com.walkertribe.ian.enums.OrdnanceType; +import com.walkertribe.ian.enums.ShipSystem; +import com.walkertribe.ian.protocol.core.eng.EngGridUpdatePacket.DamconStatus; +import com.walkertribe.ian.util.GridCoord; +import com.walkertribe.ian.vesseldata.VesselNode; +import com.walkertribe.ian.vesseldata.VesselNodeConnection; public interface EngineeringConsoleManager { diff --git a/src/com/brindyblitz/artemis/engconsole/FakeEngineeringConsoleManager.java b/src/com/brindyblitz/artemis/engconsole/FakeEngineeringConsoleManager.java index 5d14a2a..28fa649 100644 --- a/src/com/brindyblitz/artemis/engconsole/FakeEngineeringConsoleManager.java +++ b/src/com/brindyblitz/artemis/engconsole/FakeEngineeringConsoleManager.java @@ -12,10 +12,10 @@ import com.brindyblitz.artemis.utils.newton.Property; import com.brindyblitz.artemis.utils.newton.SettableProperty; -import net.dhleong.acl.enums.OrdnanceType; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.protocol.core.eng.EngGridUpdatePacket.DamconStatus; -import net.dhleong.acl.util.GridCoord; +import com.walkertribe.ian.enums.OrdnanceType; +import com.walkertribe.ian.enums.ShipSystem; +import com.walkertribe.ian.protocol.core.eng.EngGridUpdatePacket.DamconStatus; +import com.walkertribe.ian.util.GridCoord; public class FakeEngineeringConsoleManager extends BaseEngineeringConsoleManager { private static final int MAX_COOLANT = 8; diff --git a/src/com/brindyblitz/artemis/engconsole/RealEngineeringConsoleManager.java b/src/com/brindyblitz/artemis/engconsole/RealEngineeringConsoleManager.java index 5aa719a..a30a2dd 100644 --- a/src/com/brindyblitz/artemis/engconsole/RealEngineeringConsoleManager.java +++ b/src/com/brindyblitz/artemis/engconsole/RealEngineeringConsoleManager.java @@ -16,14 +16,14 @@ import com.brindyblitz.artemis.utils.newton.ObservableAdapter; import com.brindyblitz.artemis.utils.newton.Property; -import net.dhleong.acl.enums.OrdnanceType; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.protocol.core.eng.EngGridUpdatePacket.DamconStatus; -import net.dhleong.acl.protocol.core.eng.EngSendDamconPacket; -import net.dhleong.acl.protocol.core.eng.EngSetCoolantPacket; -import net.dhleong.acl.protocol.core.eng.EngSetEnergyPacket; -import net.dhleong.acl.util.GridCoord; -import net.dhleong.acl.world.Artemis; +import com.walkertribe.ian.enums.OrdnanceType; +import com.walkertribe.ian.enums.ShipSystem; +import com.walkertribe.ian.protocol.core.eng.EngGridUpdatePacket.DamconStatus; +import com.walkertribe.ian.protocol.core.eng.EngSendDamconPacket; +import com.walkertribe.ian.protocol.core.eng.EngSetCoolantPacket; +import com.walkertribe.ian.protocol.core.eng.EngSetEnergyPacket; +import com.walkertribe.ian.util.GridCoord; +import com.walkertribe.ian.world.Artemis; public class RealEngineeringConsoleManager extends BaseEngineeringConsoleManager { @@ -67,7 +67,7 @@ public Property getGameState() { if (worldAwareServer == null || !worldAwareServer.isConnected()) { return GameState.DISCONNECTED; } - else if ( this.worldAwareServer.getSystemManager().getPlayerShip(0) != null) { + else if ( this.worldAwareServer.getSystemManager().getPlayerShip(1) != null) { return GameState.INGAME; } else { @@ -84,11 +84,11 @@ public Property> getSystemEnergyAllocated() { Map result = new HashMap<>(); for(ShipSystem system: ShipSystem.values()) { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { result.put(system, 100); } else { - result.put(system, (int)(this.worldAwareServer.getSystemManager().getPlayerShip(0).getSystemEnergy(system) * 300)); + result.put(system, (int)(this.worldAwareServer.getSystemManager().getPlayerShip(1).getSystemEnergy(system) * 300)); } } @@ -103,11 +103,11 @@ public Property> getSystemCoolantAllocated() { Map result = new HashMap<>(); for(ShipSystem system: ShipSystem.values()) { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { result.put(system, 0); } else { - result.put(system, this.worldAwareServer.getSystemManager().getPlayerShip(0).getSystemCoolant(system)); + result.put(system, this.worldAwareServer.getSystemManager().getPlayerShip(1).getSystemCoolant(system)); } } @@ -122,11 +122,11 @@ public Property> getSystemHeat() { Map result = new HashMap<>(); for(ShipSystem system: ShipSystem.values()) { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { result.put(system, 0); } else { - result.put(system, (int) (this.worldAwareServer.getSystemManager().getPlayerShip(0).getSystemHeat(system) * 100)); + result.put(system, (int) (this.worldAwareServer.getSystemManager().getPlayerShip(1).getSystemHeat(system) * 100)); } } @@ -142,7 +142,7 @@ public Property> getSystemHealth() { Map result = new HashMap<>(); for(ShipSystem system: ShipSystem.values()) { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { result.put(system, 100); } else { @@ -158,10 +158,10 @@ public Property getTotalShipCoolant() { return totalShipCoolant; } private final DerivedProperty totalShipCoolant = new DerivedProperty<>( () -> { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { return 8; } - return this.worldAwareServer.getSystemManager().getPlayerShip(0).getAvailableCoolant(); + return this.worldAwareServer.getSystemManager().getPlayerShip(1).getAvailableCoolant(); }, systemManagerChangeObservable); @@ -171,7 +171,7 @@ public Property getTotalCoolantRemaining() { } private final DerivedProperty totalCoolantRemaining = new DerivedProperty<>( () -> { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { return Artemis.DEFAULT_COOLANT; } Map systemCoolantAllocated = this.getSystemCoolantAllocated().get(); @@ -226,11 +226,11 @@ public Property getTotalEnergyRemaining() { return totalEnergyRemaining; } private final DerivedProperty totalEnergyRemaining = new DerivedProperty<>( () -> { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { return 0f; } - return this.worldAwareServer.getSystemManager().getPlayerShip(0).getEnergy(); + return this.worldAwareServer.getSystemManager().getPlayerShip(1).getEnergy(); }, systemManagerChangeObservable); @Override @@ -238,12 +238,12 @@ public Property getFrontShieldStrength() { return frontShieldStrength; } private final DerivedProperty frontShieldStrength = new DerivedProperty<>( () -> { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { return 0; } // When shields are knocked offline, they go to a negative value and come back online once they reach 1 again. - int strength = (int) this.worldAwareServer.getSystemManager().getPlayerShip(0).getShieldsFront(); + int strength = (int) this.worldAwareServer.getSystemManager().getPlayerShip(1).getShieldsFront(); return strength > 0 ? strength : 0; }, systemManagerChangeObservable); @@ -253,12 +253,12 @@ public Property getRearShieldStrength() { } private final DerivedProperty rearShieldStrength = new DerivedProperty<>( () -> { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { return 0; } // When shields are knocked offline, they go to a negative value and come back online once they reach 1 again. - int strength = (int) this.worldAwareServer.getSystemManager().getPlayerShip(0).getShieldsRear(); + int strength = (int) this.worldAwareServer.getSystemManager().getPlayerShip(1).getShieldsRear(); return strength > 0 ? strength : 0; }, systemManagerChangeObservable); @@ -267,11 +267,11 @@ public Property getFrontShieldMaxStrength() { return frontShieldMaxStrength; } private final DerivedProperty frontShieldMaxStrength = new DerivedProperty<>( () -> { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { return 0; } - return (int) this.worldAwareServer.getSystemManager().getPlayerShip(0).getShieldsFrontMax(); + return (int) this.worldAwareServer.getSystemManager().getPlayerShip(1).getShieldsFrontMax(); }, systemManagerChangeObservable); @@ -281,11 +281,11 @@ public Property getRearShieldMaxStrength() { } private final DerivedProperty rearShieldMaxStrength = new DerivedProperty<>( () -> { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { return 0; } - return (int) this.worldAwareServer.getSystemManager().getPlayerShip(0).getShieldsRearMax(); + return (int) this.worldAwareServer.getSystemManager().getPlayerShip(1).getShieldsRearMax(); }, systemManagerChangeObservable); @Override @@ -294,11 +294,11 @@ public Property getShieldsActive() { } private final DerivedProperty shieldsActive = new DerivedProperty<>( () -> { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { return false; } - return this.worldAwareServer.getSystemManager().getPlayerShip(0).getShieldsState().getBooleanValue(); + return this.worldAwareServer.getSystemManager().getPlayerShip(1).getShieldsState().getBooleanValue(); }, systemManagerChangeObservable); @Override @@ -309,11 +309,11 @@ public Property> getOrdnanceCount() { Map result = new HashMap<>(); for(OrdnanceType type: OrdnanceType.values()) { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { result.put(type, 0); } else { - result.put(type, this.worldAwareServer.getSystemManager().getPlayerShip(0).getTorpedoCount(type)); + result.put(type, this.worldAwareServer.getSystemManager().getPlayerShip(1).getTorpedoCount(type)); } } @@ -323,7 +323,7 @@ public Property> getOrdnanceCount() { @Override public void incrementSystemEnergyAllocated(ShipSystem system, int amount) { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { return; } super.incrementSystemEnergyAllocated(system, amount); @@ -331,7 +331,7 @@ public void incrementSystemEnergyAllocated(ShipSystem system, int amount) { @Override public void incrementSystemCoolantAllocated(ShipSystem system, int amount) { - if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(0) == null) { + if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) { return; } super.incrementSystemCoolantAllocated(system, amount); diff --git a/src/com/brindyblitz/artemis/engconsole/config/ConfigurationLoader.java b/src/com/brindyblitz/artemis/engconsole/config/ConfigurationLoader.java index 7487a22..d22a94c 100644 --- a/src/com/brindyblitz/artemis/engconsole/config/ConfigurationLoader.java +++ b/src/com/brindyblitz/artemis/engconsole/config/ConfigurationLoader.java @@ -10,7 +10,7 @@ import java.util.Map.Entry; import java.util.Properties; -import net.dhleong.acl.enums.ShipSystem; +import com.walkertribe.ian.enums.ShipSystem; public class ConfigurationLoader { diff --git a/src/com/brindyblitz/artemis/engconsole/config/EnergyCoolantPreset.java b/src/com/brindyblitz/artemis/engconsole/config/EnergyCoolantPreset.java index 267a2b1..22f5fa0 100644 --- a/src/com/brindyblitz/artemis/engconsole/config/EnergyCoolantPreset.java +++ b/src/com/brindyblitz/artemis/engconsole/config/EnergyCoolantPreset.java @@ -3,7 +3,7 @@ import java.util.HashMap; import java.util.Map; -import net.dhleong.acl.enums.ShipSystem; +import com.walkertribe.ian.enums.ShipSystem; public class EnergyCoolantPreset { public static final int SAFE_ENERGY = -999; diff --git a/src/com/brindyblitz/artemis/engconsole/config/InputMapping.java b/src/com/brindyblitz/artemis/engconsole/config/InputMapping.java index 074823e..1c02902 100644 --- a/src/com/brindyblitz/artemis/engconsole/config/InputMapping.java +++ b/src/com/brindyblitz/artemis/engconsole/config/InputMapping.java @@ -1,6 +1,6 @@ package com.brindyblitz.artemis.engconsole.config; -import net.dhleong.acl.enums.ShipSystem; +import com.walkertribe.ian.enums.ShipSystem; import java.awt.event.KeyEvent; import java.lang.reflect.Field; diff --git a/src/com/brindyblitz/artemis/engconsole/ui/InGamePanel.java b/src/com/brindyblitz/artemis/engconsole/ui/InGamePanel.java index b2bbfde..f1af76b 100644 --- a/src/com/brindyblitz/artemis/engconsole/ui/InGamePanel.java +++ b/src/com/brindyblitz/artemis/engconsole/ui/InGamePanel.java @@ -1,13 +1,13 @@ package com.brindyblitz.artemis.engconsole.ui; -import static net.dhleong.acl.enums.ShipSystem.AFT_SHIELDS; -import static net.dhleong.acl.enums.ShipSystem.BEAMS; -import static net.dhleong.acl.enums.ShipSystem.FORE_SHIELDS; -import static net.dhleong.acl.enums.ShipSystem.IMPULSE; -import static net.dhleong.acl.enums.ShipSystem.MANEUVERING; -import static net.dhleong.acl.enums.ShipSystem.SENSORS; -import static net.dhleong.acl.enums.ShipSystem.TORPEDOES; -import static net.dhleong.acl.enums.ShipSystem.WARP_JUMP_DRIVE; +import static com.walkertribe.ian.enums.ShipSystem.AFT_SHIELDS; +import static com.walkertribe.ian.enums.ShipSystem.BEAMS; +import static com.walkertribe.ian.enums.ShipSystem.FORE_SHIELDS; +import static com.walkertribe.ian.enums.ShipSystem.IMPULSE; +import static com.walkertribe.ian.enums.ShipSystem.MANEUVERING; +import static com.walkertribe.ian.enums.ShipSystem.SENSORS; +import static com.walkertribe.ian.enums.ShipSystem.TORPEDOES; +import static com.walkertribe.ian.enums.ShipSystem.WARP_JUMP_DRIVE; import java.awt.Color; import java.awt.event.KeyEvent; @@ -24,9 +24,9 @@ import com.brindyblitz.artemis.engconsole.ui.damcon.Damcon; import com.brindyblitz.artemis.utils.AudioManager; -import net.dhleong.acl.enums.OrdnanceType; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.util.GridCoord; +import com.walkertribe.ian.enums.OrdnanceType; +import com.walkertribe.ian.enums.ShipSystem; +import com.walkertribe.ian.util.GridCoord; public class InGamePanel extends JPanel { diff --git a/src/com/brindyblitz/artemis/engconsole/ui/InputManager.java b/src/com/brindyblitz/artemis/engconsole/ui/InputManager.java index 376a8d4..8e4cb5a 100644 --- a/src/com/brindyblitz/artemis/engconsole/ui/InputManager.java +++ b/src/com/brindyblitz/artemis/engconsole/ui/InputManager.java @@ -7,7 +7,7 @@ import com.brindyblitz.artemis.engconsole.config.ConfigurationLoader; import com.brindyblitz.artemis.engconsole.config.InputMapping; -import net.dhleong.acl.enums.ShipSystem; +import com.walkertribe.ian.enums.ShipSystem; public abstract class InputManager { public static Map mappings = new HashMap(); diff --git a/src/com/brindyblitz/artemis/engconsole/ui/PresetManager.java b/src/com/brindyblitz/artemis/engconsole/ui/PresetManager.java index 8f5bd44..d0ca078 100644 --- a/src/com/brindyblitz/artemis/engconsole/ui/PresetManager.java +++ b/src/com/brindyblitz/artemis/engconsole/ui/PresetManager.java @@ -4,7 +4,7 @@ import com.brindyblitz.artemis.engconsole.config.ConfigurationLoader; import com.brindyblitz.artemis.engconsole.config.EnergyCoolantPreset; -import net.dhleong.acl.enums.ShipSystem; +import com.walkertribe.ian.enums.ShipSystem; public class PresetManager { private EnergyCoolantPreset[] presets; diff --git a/src/com/brindyblitz/artemis/engconsole/ui/SystemHealthSlider.java b/src/com/brindyblitz/artemis/engconsole/ui/SystemHealthSlider.java index d19eb4f..c575417 100644 --- a/src/com/brindyblitz/artemis/engconsole/ui/SystemHealthSlider.java +++ b/src/com/brindyblitz/artemis/engconsole/ui/SystemHealthSlider.java @@ -1,7 +1,7 @@ package com.brindyblitz.artemis.engconsole.ui; import com.brindyblitz.artemis.engconsole.EngineeringConsoleManager; -import net.dhleong.acl.enums.ShipSystem; +import com.walkertribe.ian.enums.ShipSystem; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; diff --git a/src/com/brindyblitz/artemis/engconsole/ui/SystemHeatSlider.java b/src/com/brindyblitz/artemis/engconsole/ui/SystemHeatSlider.java index f064a19..c6b5200 100644 --- a/src/com/brindyblitz/artemis/engconsole/ui/SystemHeatSlider.java +++ b/src/com/brindyblitz/artemis/engconsole/ui/SystemHeatSlider.java @@ -1,7 +1,7 @@ package com.brindyblitz.artemis.engconsole.ui; import com.brindyblitz.artemis.engconsole.EngineeringConsoleManager; -import net.dhleong.acl.enums.ShipSystem; +import com.walkertribe.ian.enums.ShipSystem; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; diff --git a/src/com/brindyblitz/artemis/engconsole/ui/SystemSlider.java b/src/com/brindyblitz/artemis/engconsole/ui/SystemSlider.java index b1d3387..3bbcc6f 100644 --- a/src/com/brindyblitz/artemis/engconsole/ui/SystemSlider.java +++ b/src/com/brindyblitz/artemis/engconsole/ui/SystemSlider.java @@ -20,8 +20,8 @@ import com.brindyblitz.artemis.engconsole.ui.SystemStatusRenderer.IntervalType; import com.brindyblitz.artemis.utils.AudioManager; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.world.Artemis; +import com.walkertribe.ian.enums.ShipSystem; +import com.walkertribe.ian.world.Artemis; public class SystemSlider extends JPanel implements MouseListener, MouseMotionListener, MouseWheelListener { private static final long serialVersionUID = 1L; diff --git a/src/com/brindyblitz/artemis/engconsole/ui/SystemStatusRenderer.java b/src/com/brindyblitz/artemis/engconsole/ui/SystemStatusRenderer.java index bb5e3a3..823217a 100644 --- a/src/com/brindyblitz/artemis/engconsole/ui/SystemStatusRenderer.java +++ b/src/com/brindyblitz/artemis/engconsole/ui/SystemStatusRenderer.java @@ -5,7 +5,7 @@ import com.brindyblitz.artemis.engconsole.EngineeringConsoleManager; -import net.dhleong.acl.enums.ShipSystem; +import com.walkertribe.ian.enums.ShipSystem; public class SystemStatusRenderer { diff --git a/src/com/brindyblitz/artemis/engconsole/ui/SystemStatusSlider.java b/src/com/brindyblitz/artemis/engconsole/ui/SystemStatusSlider.java index bbf1a1b..ae1e642 100644 --- a/src/com/brindyblitz/artemis/engconsole/ui/SystemStatusSlider.java +++ b/src/com/brindyblitz/artemis/engconsole/ui/SystemStatusSlider.java @@ -14,7 +14,7 @@ import com.brindyblitz.artemis.engconsole.EngineeringConsoleManager; -import net.dhleong.acl.enums.ShipSystem; +import com.walkertribe.ian.enums.ShipSystem; public abstract class SystemStatusSlider extends JPanel { private static final long serialVersionUID = 1L; diff --git a/src/com/brindyblitz/artemis/engconsole/ui/damcon/Damcon.java b/src/com/brindyblitz/artemis/engconsole/ui/damcon/Damcon.java index 3d7e4fe..9004f07 100644 --- a/src/com/brindyblitz/artemis/engconsole/ui/damcon/Damcon.java +++ b/src/com/brindyblitz/artemis/engconsole/ui/damcon/Damcon.java @@ -47,9 +47,9 @@ import com.sun.j3d.utils.pickfast.PickCanvas; import com.sun.j3d.utils.universe.SimpleUniverse; -import net.dhleong.acl.util.GridCoord; -import net.dhleong.acl.vesseldata.VesselNode; -import net.dhleong.acl.vesseldata.VesselNodeConnection; +import com.walkertribe.ian.util.GridCoord; +import com.walkertribe.ian.vesseldata.VesselNode; +import com.walkertribe.ian.vesseldata.VesselNodeConnection; public class Damcon implements MouseListener, MouseMotionListener, MouseWheelListener { private static final int WIDTH = 400, HEIGHT = 300; diff --git a/src/com/brindyblitz/artemis/engconsole/ui/damcon/Internal.java b/src/com/brindyblitz/artemis/engconsole/ui/damcon/Internal.java index 54b2120..03bb0b3 100644 --- a/src/com/brindyblitz/artemis/engconsole/ui/damcon/Internal.java +++ b/src/com/brindyblitz/artemis/engconsole/ui/damcon/Internal.java @@ -2,7 +2,7 @@ import com.brindyblitz.artemis.utils.AudioManager; -import net.dhleong.acl.vesseldata.VesselNode; +import com.walkertribe.ian.vesseldata.VesselNode; import javax.media.j3d.Shape3D; import javax.vecmath.Point3f; diff --git a/src/com/brindyblitz/artemis/engconsole/ui/damcon/InternalConnection.java b/src/com/brindyblitz/artemis/engconsole/ui/damcon/InternalConnection.java index a18859a..a3a3b94 100644 --- a/src/com/brindyblitz/artemis/engconsole/ui/damcon/InternalConnection.java +++ b/src/com/brindyblitz/artemis/engconsole/ui/damcon/InternalConnection.java @@ -10,7 +10,7 @@ import com.brindyblitz.artemis.utils.AudioManager; -import net.dhleong.acl.vesseldata.VesselNodeConnection; +import com.walkertribe.ian.vesseldata.VesselNodeConnection; public class InternalConnection extends Internal { private VesselNodeConnection vesselNodeConnection; diff --git a/src/com/brindyblitz/artemis/engconsole/ui/damcon/InternalNode.java b/src/com/brindyblitz/artemis/engconsole/ui/damcon/InternalNode.java index f357d02..7c7a661 100644 --- a/src/com/brindyblitz/artemis/engconsole/ui/damcon/InternalNode.java +++ b/src/com/brindyblitz/artemis/engconsole/ui/damcon/InternalNode.java @@ -4,8 +4,8 @@ import com.brindyblitz.artemis.utils.AudioManager; -import net.dhleong.acl.util.GridCoord; -import net.dhleong.acl.vesseldata.VesselNode; +import com.walkertribe.ian.util.GridCoord; +import com.walkertribe.ian.vesseldata.VesselNode; public class InternalNode extends InternalSelectable { private VesselNode vesselNode; diff --git a/src/com/brindyblitz/artemis/protocol/NonShittyShipSystemGrid.java b/src/com/brindyblitz/artemis/protocol/NonShittyShipSystemGrid.java index ed70e63..1c38624 100644 --- a/src/com/brindyblitz/artemis/protocol/NonShittyShipSystemGrid.java +++ b/src/com/brindyblitz/artemis/protocol/NonShittyShipSystemGrid.java @@ -5,9 +5,9 @@ import java.lang.reflect.InvocationTargetException; import java.util.Map; -import net.dhleong.acl.enums.ShipSystem; -import net.dhleong.acl.util.GridCoord; -import net.dhleong.acl.util.ShipSystemGrid; +import com.walkertribe.ian.enums.ShipSystem; +import com.walkertribe.ian.util.GridCoord; +import com.walkertribe.ian.util.ShipSystemGrid; public class NonShittyShipSystemGrid extends ShipSystemGrid { diff --git a/src/com/brindyblitz/artemis/protocol/NotifyingSystemManager.java b/src/com/brindyblitz/artemis/protocol/NotifyingSystemManager.java index f1508f3..f2a497b 100644 --- a/src/com/brindyblitz/artemis/protocol/NotifyingSystemManager.java +++ b/src/com/brindyblitz/artemis/protocol/NotifyingSystemManager.java @@ -3,12 +3,12 @@ import com.brindyblitz.artemis.utils.EventEmitter; import com.brindyblitz.artemis.utils.EventSubscriber; -import net.dhleong.acl.iface.Listener; -import net.dhleong.acl.protocol.core.eng.EngGridUpdatePacket; -import net.dhleong.acl.protocol.core.world.DestroyObjectPacket; -import net.dhleong.acl.protocol.core.world.IntelPacket; -import net.dhleong.acl.protocol.core.world.ObjectUpdatePacket; -import net.dhleong.acl.world.SystemManager; +import com.walkertribe.ian.iface.Listener; +import com.walkertribe.ian.protocol.core.eng.EngGridUpdatePacket; +import com.walkertribe.ian.protocol.core.world.DestroyObjectPacket; +import com.walkertribe.ian.protocol.core.world.IntelPacket; +import com.walkertribe.ian.protocol.core.world.ObjectUpdatePacket; +import com.walkertribe.ian.world.SystemManager; public class NotifyingSystemManager extends SystemManager { diff --git a/src/com/brindyblitz/artemis/protocol/RobustProxyListener.java b/src/com/brindyblitz/artemis/protocol/RobustProxyListener.java index c9476aa..56ef5bc 100644 --- a/src/com/brindyblitz/artemis/protocol/RobustProxyListener.java +++ b/src/com/brindyblitz/artemis/protocol/RobustProxyListener.java @@ -5,15 +5,15 @@ import java.net.ServerSocket; import java.net.Socket; -import net.dhleong.acl.enums.ConnectionType; -import net.dhleong.acl.iface.ArtemisNetworkInterface; -import net.dhleong.acl.iface.BaseDebugger; -import net.dhleong.acl.iface.DisconnectEvent; -import net.dhleong.acl.iface.Listener; -import net.dhleong.acl.iface.ThreadedArtemisNetworkInterface; -import net.dhleong.acl.protocol.ArtemisPacket; -import net.dhleong.acl.protocol.RawPacket; -import net.dhleong.acl.protocol.UnparsedPacket; +import com.walkertribe.ian.enums.ConnectionType; +import com.walkertribe.ian.iface.ArtemisNetworkInterface; +import com.walkertribe.ian.iface.BaseDebugger; +import com.walkertribe.ian.iface.DisconnectEvent; +import com.walkertribe.ian.iface.Listener; +import com.walkertribe.ian.iface.ThreadedArtemisNetworkInterface; +import com.walkertribe.ian.protocol.ArtemisPacket; +import com.walkertribe.ian.protocol.RawPacket; +import com.walkertribe.ian.protocol.UnparsedPacket; public class RobustProxyListener implements Runnable { diff --git a/src/com/brindyblitz/artemis/protocol/WorldAwareRegularServer.java b/src/com/brindyblitz/artemis/protocol/WorldAwareRegularServer.java index 0a8783a..0d41806 100644 --- a/src/com/brindyblitz/artemis/protocol/WorldAwareRegularServer.java +++ b/src/com/brindyblitz/artemis/protocol/WorldAwareRegularServer.java @@ -4,14 +4,14 @@ import com.brindyblitz.artemis.utils.EventEmitter; -import net.dhleong.acl.enums.Console; -import net.dhleong.acl.iface.ArtemisNetworkInterface; -import net.dhleong.acl.iface.ConnectionSuccessEvent; -import net.dhleong.acl.iface.Listener; -import net.dhleong.acl.iface.ThreadedArtemisNetworkInterface; -import net.dhleong.acl.protocol.core.setup.ReadyPacket; -import net.dhleong.acl.protocol.core.setup.ReadyPacket2; -import net.dhleong.acl.protocol.core.setup.SetConsolePacket; +import com.walkertribe.ian.enums.Console; +import com.walkertribe.ian.iface.ArtemisNetworkInterface; +import com.walkertribe.ian.iface.ConnectionSuccessEvent; +import com.walkertribe.ian.iface.Listener; +import com.walkertribe.ian.iface.ThreadedArtemisNetworkInterface; +import com.walkertribe.ian.protocol.core.setup.ReadyPacket; +import com.walkertribe.ian.protocol.core.setup.ReadyPacket2; +import com.walkertribe.ian.protocol.core.setup.SetConsolePacket; public class WorldAwareRegularServer implements WorldAwareServer { diff --git a/src/com/brindyblitz/artemis/protocol/WorldAwareServer.java b/src/com/brindyblitz/artemis/protocol/WorldAwareServer.java index 89b3323..ce16787 100644 --- a/src/com/brindyblitz/artemis/protocol/WorldAwareServer.java +++ b/src/com/brindyblitz/artemis/protocol/WorldAwareServer.java @@ -1,6 +1,6 @@ package com.brindyblitz.artemis.protocol; -import net.dhleong.acl.iface.ArtemisNetworkInterface; +import com.walkertribe.ian.iface.ArtemisNetworkInterface; public interface WorldAwareServer {