diff --git a/.classpath b/.classpath index cfabda2..2ebdd55 100644 --- a/.classpath +++ b/.classpath @@ -1,10 +1,7 @@ - - - - - + + diff --git a/.gitignore b/.gitignore index 543ab98..548dc14 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .settings +.gradle bin +build diff --git a/.project b/.project index 69d73dc..461ed31 100644 --- a/.project +++ b/.project @@ -10,8 +10,14 @@ + + org.eclipse.buildship.core.gradleprojectbuilder + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature diff --git a/src/com/projectswg/common/callback/CallbackManager.java b/src/com/projectswg/common/callback/CallbackManager.java index 0d952b9..3af93bc 100644 --- a/src/com/projectswg/common/callback/CallbackManager.java +++ b/src/com/projectswg/common/callback/CallbackManager.java @@ -27,8 +27,8 @@ ***********************************************************************************/ package com.projectswg.common.callback; -import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -48,33 +48,25 @@ public class CallbackManager { public CallbackManager(String name, int threadCount) { this.executor = new PswgThreadPool(threadCount, name); - this.callbacks = new ArrayList<>(); + this.callbacks = new CopyOnWriteArrayList<>(); this.runningTasks = new AtomicInteger(0); } public void addCallback(T callback) { - synchronized (callbacks) { - callbacks.add(callback); - } + callbacks.add(callback); } public void removeCallback(T callback) { - synchronized (callbacks) { - callbacks.remove(callback); - } + callbacks.remove(callback); } public void setCallback(T callback) { - synchronized (callbacks) { - callbacks.clear(); - callbacks.add(callback); - } + callbacks.clear(); + callbacks.add(callback); } public void clearCallbacks() { - synchronized (callbacks) { - callbacks.clear(); - } + callbacks.clear(); } public void start() { @@ -100,13 +92,11 @@ public class CallbackManager { public boolean callOnEach(CallCallback call) { runningTasks.incrementAndGet(); return executor.execute(() -> { - synchronized (callbacks) { - for (T callback : callbacks) { - try { - call.run(callback); - } catch (Throwable t) { - Log.e(t); - } + for (T callback : callbacks) { + try { + call.run(callback); + } catch (Throwable t) { + Log.e(t); } } runningTasks.decrementAndGet(); diff --git a/src/com/projectswg/common/data/HologramColour.java b/src/com/projectswg/common/data/HologramColour.java new file mode 100644 index 0000000..9579fc3 --- /dev/null +++ b/src/com/projectswg/common/data/HologramColour.java @@ -0,0 +1,52 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.data; + +public enum HologramColour { + DEFAULT (-1), + BLUE (0), + PURPLE (4), + ORANGE (8); + + private int value; + + HologramColour(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + public static final HologramColour getForValue(int value) { + for (HologramColour d : values()) + if (d.getValue() == value) + return d; + return DEFAULT; + } +} diff --git a/src/com/projectswg/common/data/WeatherType.java b/src/com/projectswg/common/data/WeatherType.java new file mode 100644 index 0000000..f2934ff --- /dev/null +++ b/src/com/projectswg/common/data/WeatherType.java @@ -0,0 +1,57 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.data; + +/** + * Make sure that the chances for each weather type add up to 1.0 (100%). + * @author Ziggy + * + */ +public enum WeatherType { + CLEAR (0, .70f), // 70% chance + LIGHT (1, .15f), // 15% chance + MEDIUM (2, .10f), // 10% chance + HEAVY (3, .05f); // 5% chance + + private int value; + private float chance; + + WeatherType(int value, float chance) { + this.value = value; + this.chance = chance; + } + + public int getValue() { + return value; + } + + public float getChance() { + return chance; + } + +} diff --git a/src/com/projectswg/common/data/combat/AttackInfo.java b/src/com/projectswg/common/data/combat/AttackInfo.java new file mode 100644 index 0000000..da5a194 --- /dev/null +++ b/src/com/projectswg/common/data/combat/AttackInfo.java @@ -0,0 +1,239 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.combat; + +public class AttackInfo { + + private boolean success = true; + private long armor = 0; + private int rawDamage = 0; + private DamageType damageType = DamageType.KINETIC; + private int elementalDamage = 0; + private DamageType elementalDamageType = DamageType.KINETIC; + private int bleedDamage = 0; + private int criticalDamage = 0; + private int blockedDamage = 0; + private int finalDamage = 0; + private HitLocation hitLocation = HitLocation.HIT_LOCATION_BODY; + private boolean crushing = false; + private boolean strikethrough = false; + private double strikethroughAmount = 0; + private boolean evadeResult = false; + private double evadeAmount = 0; + private boolean blockResult = false; + private int block = 0; + private boolean dodge = false; + private boolean parry = false; + private boolean critical = false; + private boolean glancing = false; + private boolean proc = false; + + public boolean isSuccess() { + return success; + } + + public long getArmor() { + return armor; + } + + public int getRawDamage() { + return rawDamage; + } + + public DamageType getDamageType() { + return damageType; + } + + public int getElementalDamage() { + return elementalDamage; + } + + public DamageType getElementalDamageType() { + return elementalDamageType; + } + + public int getBleedDamage() { + return bleedDamage; + } + + public int getCriticalDamage() { + return criticalDamage; + } + + public int getBlockedDamage() { + return blockedDamage; + } + + public int getFinalDamage() { + return finalDamage; + } + + public HitLocation getHitLocation() { + return hitLocation; + } + + public boolean isCrushing() { + return crushing; + } + + public boolean isStrikethrough() { + return strikethrough; + } + + public double getStrikethroughAmount() { + return strikethroughAmount; + } + + public boolean isEvadeResult() { + return evadeResult; + } + + public double getEvadeAmount() { + return evadeAmount; + } + + public boolean isBlockResult() { + return blockResult; + } + + public int getBlock() { + return block; + } + + public boolean isDodge() { + return dodge; + } + + public boolean isParry() { + return parry; + } + + public boolean isCritical() { + return critical; + } + + public boolean isGlancing() { + return glancing; + } + + public boolean isProc() { + return proc; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public void setArmor(long armor) { + this.armor = armor; + } + + public void setRawDamage(int rawDamage) { + this.rawDamage = rawDamage; + } + + public void setDamageType(DamageType damageType) { + this.damageType = damageType; + } + + public void setElementalDamage(int elementalDamage) { + this.elementalDamage = elementalDamage; + } + + public void setElementalDamageType(DamageType elementalDamageType) { + this.elementalDamageType = elementalDamageType; + } + + public void setBleedDamage(int bleedDamage) { + this.bleedDamage = bleedDamage; + } + + public void setCriticalDamage(int criticalDamage) { + this.criticalDamage = criticalDamage; + } + + public void setBlockedDamage(int blockedDamage) { + this.blockedDamage = blockedDamage; + } + + public void setFinalDamage(int finalDamage) { + this.finalDamage = finalDamage; + } + + public void setHitLocation(HitLocation hitLocation) { + this.hitLocation = hitLocation; + } + + public void setCrushing(boolean crushing) { + this.crushing = crushing; + } + + public void setStrikethrough(boolean strikethrough) { + this.strikethrough = strikethrough; + } + + public void setStrikethroughAmount(double strikethroughAmount) { + this.strikethroughAmount = strikethroughAmount; + } + + public void setEvadeResult(boolean evadeResult) { + this.evadeResult = evadeResult; + } + + public void setEvadeAmount(double evadeAmount) { + this.evadeAmount = evadeAmount; + } + + public void setBlockResult(boolean blockResult) { + this.blockResult = blockResult; + } + + public void setBlock(int block) { + this.block = block; + } + + public void setDodge(boolean dodge) { + this.dodge = dodge; + } + + public void setParry(boolean parry) { + this.parry = parry; + } + + public void setCritical(boolean critical) { + this.critical = critical; + } + + public void setGlancing(boolean glancing) { + this.glancing = glancing; + } + + public void setProc(boolean proc) { + this.proc = proc; + } +} diff --git a/src/com/projectswg/common/data/combat/AttackType.java b/src/com/projectswg/common/data/combat/AttackType.java new file mode 100644 index 0000000..bb2c3b2 --- /dev/null +++ b/src/com/projectswg/common/data/combat/AttackType.java @@ -0,0 +1,63 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.combat; + +public enum AttackType { + CONE (0), + SINGLE_TARGET (1), + AREA (2), + TARGET_AREA (3), + DUAL_WIELD (4), + RAMPAGE (5), + RANDOM_HATE_TARGET (6), + RANDOM_HATE_TARGET_CONE (7), + RANDOM_HATE_TARGET_CONE_TERMINUS (8), + HATE_LIST (9), + RANDOM_HATE_MULTI (10), + AREA_PROGRESSIVE (11), + SPLIT_DAMAGE_TARGET_AREA (12), + DISTANCE_FARTHEST (13); + + private static final AttackType [] VALUES = values(); + + private int num; + + AttackType(int num) { + this.num = num; + } + + public int getNum() { + return num; + } + + public static AttackType getAttackType(int num) { + if (num < 0 || num >= VALUES.length) + return AttackType.SINGLE_TARGET; + return VALUES[num]; + } +} diff --git a/src/com/projectswg/common/data/combat/CombatStatus.java b/src/com/projectswg/common/data/combat/CombatStatus.java new file mode 100644 index 0000000..5621a9a --- /dev/null +++ b/src/com/projectswg/common/data/combat/CombatStatus.java @@ -0,0 +1,37 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.combat; + +public enum CombatStatus { + UNKNOWN, + INVALID_TARGET, + NO_WEAPON, + NO_TARGET, + TOO_FAR, + SUCCESS +} diff --git a/src/com/projectswg/common/data/combat/DamageType.java b/src/com/projectswg/common/data/combat/DamageType.java new file mode 100644 index 0000000..c1dc2ed --- /dev/null +++ b/src/com/projectswg/common/data/combat/DamageType.java @@ -0,0 +1,72 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.combat; + +import java.util.EnumSet; +import java.util.Set; + +public enum DamageType { + KINETIC (1), + ENERGY (2), + BLAST (4), + STUN (8), + RESTAINT (16), + ELEMENTAL_HEAT (32), + ELEMENTAL_COLD (64), + ELEMENTAL_ACID (128), + ELEMENTAL_ELECTRICAL (256); + + private static final DamageType [] VALUES = values(); + + private int num; + + DamageType(int num) { + this.num = num; + } + + public int getNum() { + return num; + } + + public static DamageType getDamageType(int num) { + for (DamageType type : VALUES) { + if ((num & type.getNum()) != 0) + return type; + } + return KINETIC; + } + + public static Set getDamageTypes(int num) { + Set types = EnumSet.noneOf(DamageType.class); + for (DamageType type : VALUES) { + if ((num & type.getNum()) != 0) + types.add(type); + } + return types; + } +} diff --git a/src/com/projectswg/common/data/combat/DelayAttackEggPosition.java b/src/com/projectswg/common/data/combat/DelayAttackEggPosition.java new file mode 100644 index 0000000..3827f55 --- /dev/null +++ b/src/com/projectswg/common/data/combat/DelayAttackEggPosition.java @@ -0,0 +1,52 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.combat; + +import com.projectswg.common.data.EnumLookup; + +public enum DelayAttackEggPosition { + LOCATION (1), + TARGET (2), + SELF (3); + + private static final EnumLookup LOOKUP = new EnumLookup<>(DelayAttackEggPosition.class, DelayAttackEggPosition::getNum); + + private final int num; + + DelayAttackEggPosition(int num) { + this.num = num; + } + + public int getNum() { + return num; + } + + public static DelayAttackEggPosition getEggPosition(int num) { + return LOOKUP.getEnum(num, SELF); + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/data/combat/HitLocation.java b/src/com/projectswg/common/data/combat/HitLocation.java new file mode 100644 index 0000000..b4e2a4a --- /dev/null +++ b/src/com/projectswg/common/data/combat/HitLocation.java @@ -0,0 +1,56 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.combat; + +public enum HitLocation { + HIT_LOCATION_BODY (0), + HIT_LOCATION_HEAD (1), + HIT_LOCATION_R_ARM (2), + HIT_LOCATION_L_ARM (3), + HIT_LOCATION_R_LEG (4), + HIT_LOCATION_L_LEG (5), + HIT_LOCATION_NUM_LOCATIONS (6); + + private static final HitLocation [] VALUES = values(); + + private int num; + + HitLocation(int num) { + this.num = num; + } + + public int getNum() { + return num; + } + + public static HitLocation getHitLocation(int num) { + if (num < 0 || num >= VALUES.length) + return HIT_LOCATION_BODY; + return VALUES[num]; + } +} diff --git a/src/com/projectswg/common/data/combat/HitType.java b/src/com/projectswg/common/data/combat/HitType.java new file mode 100644 index 0000000..e38c169 --- /dev/null +++ b/src/com/projectswg/common/data/combat/HitType.java @@ -0,0 +1,62 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.combat; + +import java.util.HashMap; +import java.util.Map; + +public enum HitType { + ATTACK (-1), + BUFF (0), + DEBUFF (4), + HEAL (5), + DELAY_ATTACK (6), + REVIVE (7); + + private static final Map HIT_TYPES = new HashMap<>(); + + static { + for(HitType hitType : values()) { + HIT_TYPES.put(hitType.getNum(), hitType); + } + } + + private final int num; + + HitType(int num) { + this.num = num; + } + + public int getNum() { + return num; + } + + public static HitType getHitType(int num) { + return HIT_TYPES.getOrDefault(num, ATTACK); + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/data/combat/TrailLocation.java b/src/com/projectswg/common/data/combat/TrailLocation.java new file mode 100644 index 0000000..872bdee --- /dev/null +++ b/src/com/projectswg/common/data/combat/TrailLocation.java @@ -0,0 +1,69 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.combat; + +import java.util.EnumSet; +import java.util.Set; + +public enum TrailLocation { + LEFT_FOOT (0x01), + RIGHT_FOOT (0x02), + LEFT_HAND (0x04), + RIGHT_HAND (0x08), + WEAPON (0x10); + + private static final TrailLocation [] VALUES = values(); + + private int num; + + TrailLocation(int num) { + this.num = num; + } + + public int getNum() { + return num; + } + + public static TrailLocation getTrailLocation(int num) { + for (TrailLocation type : VALUES) { + if ((num & type.getNum()) != 0) + return type; + } + return WEAPON; + } + + public static Set getTrailLocations(int num) { + Set types = EnumSet.noneOf(TrailLocation.class); + for (TrailLocation type : VALUES) { + if ((num & type.getNum()) != 0) + types.add(type); + } + return types; + } + +} diff --git a/src/com/projectswg/common/data/combat/ValidTarget.java b/src/com/projectswg/common/data/combat/ValidTarget.java new file mode 100644 index 0000000..12dfba6 --- /dev/null +++ b/src/com/projectswg/common/data/combat/ValidTarget.java @@ -0,0 +1,61 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.combat; + +public enum ValidTarget { + NONE (-1), + STANDARD(0), + MOB (1), + CREATURE(2), + NPC (3), + DROID (4), + PVP (5), + JEDI (6), + DEAD (7), + FRIEND (8); + + private static final ValidTarget [] VALUES = values(); + + private int num; + + ValidTarget(int num) { + this.num = num; + } + + public int getNum() { + return num; + } + + public static ValidTarget getValidTarget(int num) { + ++num; + if (num < 0 || num >= VALUES.length) + return STANDARD; + return VALUES[num]; + } + +} diff --git a/src/com/projectswg/common/data/encodables/chat/ChatAvatar.java b/src/com/projectswg/common/data/encodables/chat/ChatAvatar.java new file mode 100644 index 0000000..5fec2e4 --- /dev/null +++ b/src/com/projectswg/common/data/encodables/chat/ChatAvatar.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ +package com.projectswg.common.data.encodables.chat; + +import java.util.Locale; +import java.util.concurrent.atomic.AtomicReference; + +import com.projectswg.common.encoding.Encodable; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.NetBufferStream; +import com.projectswg.common.persistable.Persistable; + +public class ChatAvatar implements Encodable, Persistable { + + private static final AtomicReference GALAXY = new AtomicReference<>(""); + private static final ChatAvatar SYSTEM_AVATAR = new ChatAvatar("system"); + + private String name; + + public ChatAvatar() { + this(null); + } + + public ChatAvatar(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public String getGalaxy() { + return GALAXY.get(); + } + + @Override + public int getLength() { + return 9 + name.length() + GALAXY.get().length(); + } + + @Override + public byte[] encode() { + NetBuffer buffer = NetBuffer.allocate(getLength()); + buffer.addAscii("SWG"); + buffer.addAscii(GALAXY.get()); + buffer.addAscii(name); + return buffer.array(); + } + + @Override + public void decode(NetBuffer data) { + data.getAscii(); // SWG + data.getAscii(); + name = data.getAscii().toLowerCase(Locale.US); + } + + @Override + public void save(NetBufferStream stream) { + stream.addByte(1); + stream.addAscii(name); + } + + @Override + public void read(NetBufferStream stream) { + byte ver = stream.getByte(); + if (ver == 0) + stream.getAscii(); + name = stream.getAscii(); + } + + @Override + public String toString() { + return String.format("ChatAvatar[name='%s']", name); + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof ChatAvatar)) + return false; + return ((ChatAvatar) o).getName().equals(getName()); + } + + @Override + public int hashCode() { + return name.hashCode(); + } + + public static ChatAvatar getSystemAvatar() { + return SYSTEM_AVATAR; + } + + public static void setGalaxy(String galaxy) { + GALAXY.set(galaxy); + } + +} diff --git a/src/com/projectswg/common/data/encodables/chat/ChatResult.java b/src/com/projectswg/common/data/encodables/chat/ChatResult.java new file mode 100644 index 0000000..e93f54b --- /dev/null +++ b/src/com/projectswg/common/data/encodables/chat/ChatResult.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ +package com.projectswg.common.data.encodables.chat; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Waverunner + */ +public enum ChatResult { + NONE (-1), // The client will just display an "unknown error code" if this is used. + SUCCESS (0), + TARGET_AVATAR_DOESNT_EXIST (4), + ROOM_INVALID_ID (5), + ROOM_INVALID_NAME (6), + CUSTOM_FAILURE (9), + ROOM_AVATAR_BANNED (12), + ROOM_PRIVATE (13), + ROOM_AVATAR_NO_PERMISSION (16), + IGNORED (23), + ROOM_ALREADY_EXISTS (24), + ROOM_ALREADY_JOINED (36), + CHAT_SERVER_UNAVAILABLE (1000000), + ROOM_DIFFERENT_FACTION (1000001), + ROOM_NOT_GCW_DEFENDER_FACTION (1000005); + + private static final Map RESULT_MAP = new HashMap<>(); + + static { + for (ChatResult result : values()) { + RESULT_MAP.put(result.getCode(), result); + } + } + + private final int code; + + ChatResult(int code) { + this.code = code; + } + + public int getCode() { + return code; + } + + public static ChatResult fromInteger(int code) { + ChatResult result = RESULT_MAP.get(code); + if (result == null) + return NONE; + return result; + } +} diff --git a/src/com/projectswg/common/data/encodables/chat/ChatRoom.java b/src/com/projectswg/common/data/encodables/chat/ChatRoom.java new file mode 100644 index 0000000..1aac9c5 --- /dev/null +++ b/src/com/projectswg/common/data/encodables/chat/ChatRoom.java @@ -0,0 +1,326 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ +package com.projectswg.common.data.encodables.chat; + +import java.util.ArrayList; +import java.util.List; + +import com.projectswg.common.encoding.CachedEncode; +import com.projectswg.common.encoding.Encodable; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.NetBufferStream; +import com.projectswg.common.persistable.Persistable; + +public class ChatRoom implements Encodable, Persistable { + + private final CachedEncode cache; + + private int id; + private int type; + private String path; + private ChatAvatar owner; + private ChatAvatar creator; + private String title; + private List moderators; + private List invited; + private boolean moderated; // No one but moderators can talk + private List banned; + // Members are only actually apart of a room when they're "in the room", so we don't need to save this info + // as each player will automatically re-join the room based on their joined channels list + private transient List members; + + public ChatRoom() { + this.cache = new CachedEncode(() -> encodeImpl()); + owner = new ChatAvatar(); + creator = new ChatAvatar(); + moderators = new ArrayList<>(); + invited = new ArrayList<>(); + members = new ArrayList<>(); + banned = new ArrayList<>(); + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.cache.clearCached(); + this.id = id; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.cache.clearCached(); + this.type = type; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.cache.clearCached(); + this.path = path; + } + + public ChatAvatar getOwner() { + return owner; + } + + public void setOwner(ChatAvatar owner) { + this.cache.clearCached(); + this.owner = owner; + } + + public ChatAvatar getCreator() { + return creator; + } + + public void setCreator(ChatAvatar creator) { + this.cache.clearCached(); + this.creator = creator; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.cache.clearCached(); + this.title = title; + } + + public List getModerators() { + return moderators; + } + + public List getInvited() { + return invited; + } + + public boolean isModerated() { + return moderated; + } + + public void setModerated(boolean moderated) { + this.cache.clearCached(); + this.moderated = moderated; + } + + public List getMembers() { + return members; + } + + public boolean isPublic() { + return type == 0; + } + + public void setIsPublic(boolean isPublic) { + this.cache.clearCached(); + this.type = (isPublic ? 0 : 1); + } + + public List getBanned() { + return banned; + } + + public ChatResult canJoinRoom(ChatAvatar avatar, boolean ignoreInvitation) { + if (banned.contains(avatar)) + return ChatResult.ROOM_AVATAR_BANNED; + + if (members.contains(avatar)) + return ChatResult.ROOM_ALREADY_JOINED; + + if (isPublic() || ignoreInvitation || invited.contains(avatar) || moderators.contains(avatar)) + return ChatResult.SUCCESS; + + return ChatResult.ROOM_AVATAR_NO_PERMISSION; + } + + public ChatResult canSendMessage(ChatAvatar avatar) { + if (banned.contains(avatar)) + return ChatResult.ROOM_AVATAR_BANNED; + + if (moderated && !moderators.contains(avatar)) + return ChatResult.CUSTOM_FAILURE; + + return ChatResult.SUCCESS; + } + + public boolean isModerator(ChatAvatar avatar) { + return avatar.equals(owner) || moderators.contains(avatar); + } + + public boolean isMember(ChatAvatar avatar) { + return members.contains(avatar); + } + + public boolean isBanned(ChatAvatar avatar) { + return banned.contains(avatar); + } + + public boolean isInvited(ChatAvatar avatar) { + return invited.contains(avatar); + } + + public boolean addMember(ChatAvatar avatar) { + this.cache.clearCached(); + return members.add(avatar); + } + + public boolean removeMember(ChatAvatar avatar) { + this.cache.clearCached(); + return members.remove(avatar); + } + + public boolean addModerator(ChatAvatar avatar) { + this.cache.clearCached(); + return moderators.add(avatar); + } + + public boolean removeModerator(ChatAvatar avatar) { + this.cache.clearCached(); + return moderators.remove(avatar); + } + + public boolean addInvited(ChatAvatar avatar) { + this.cache.clearCached(); + return invited.add(avatar); + } + + public boolean removeInvited(ChatAvatar avatar) { + this.cache.clearCached(); + return invited.remove(avatar); + } + + public boolean addBanned(ChatAvatar avatar) { + this.cache.clearCached(); + return banned.add(avatar); + } + + public boolean removeBanned(ChatAvatar avatar) { + this.cache.clearCached(); + return banned.remove(avatar); + } + + @Override + public void decode(NetBuffer data) { + id = data.getInt(); + type = data.getInt(); + moderated = data.getBoolean(); + path = data.getAscii(); + owner = data.getEncodable(ChatAvatar.class); + creator = data.getEncodable(ChatAvatar.class); + title = data.getUnicode(); + moderators = data.getList(ChatAvatar.class); + invited = data.getList(ChatAvatar.class); + } + + @Override + public byte[] encode() { + return cache.encode(); + } + + private byte[] encodeImpl() { + NetBuffer data = NetBuffer.allocate(getLength()); + data.addInt(id); + data.addInt(type); + data.addBoolean(moderated); + data.addAscii(path); + data.addEncodable(owner); + data.addEncodable(creator); + data.addUnicode(title); + data.addList(moderators); + data.addList(invited); + return data.array(); + } + + @Override + public int getLength() { + int avatarIdSize = 0; // The encode method for ChatAvatar saves the encode result if the class was modified/null data + + for (ChatAvatar moderator : moderators) { + avatarIdSize += moderator.getLength(); + } + for (ChatAvatar invitee : invited) { + avatarIdSize += invitee.getLength(); + } + + avatarIdSize += owner.getLength() + creator.getLength(); + return 23 + path.length() + (title.length() * 2) + avatarIdSize; + } + + @Override + public void save(NetBufferStream stream) { + stream.addByte(0); + owner.save(stream); + creator.save(stream); + stream.addInt(id); + stream.addInt(type); + stream.addAscii(path); + stream.addUnicode(title); + stream.addBoolean(moderated); + stream.addList(moderators, (a) -> a.save(stream)); + stream.addList(invited, (a) -> a.save(stream)); + stream.addList(banned, (a) -> a.save(stream)); + } + + @Override + public void read(NetBufferStream stream) { + stream.getByte(); + owner.read(stream); + creator.read(stream); + id = stream.getInt(); + type = stream.getInt(); + path = stream.getAscii(); + title = stream.getUnicode(); + moderated = stream.getBoolean(); + stream.getList((i) -> moderators.add(inflateAvatar(stream))); + stream.getList((i) -> invited.add(inflateAvatar(stream))); + stream.getList((i) -> banned.add(inflateAvatar(stream))); + } + + private ChatAvatar inflateAvatar(NetBufferStream stream) { + ChatAvatar avatar = new ChatAvatar(); + avatar.read(stream); + return avatar; + } + + @Override + public String toString() { + return "ChatRoom[id=" + id + ", type=" + type + ", path='" + path + "', title='" + title + '\'' + ", creator=" + creator + ", moderated=" + moderated + ", isPublic=" + isPublic() + "]"; + } + + public static ChatRoom create(NetBufferStream stream) { + ChatRoom room = new ChatRoom(); + room.read(stream); + return room; + } +} diff --git a/src/com/projectswg/common/data/encodables/galaxy/Galaxy.java b/src/com/projectswg/common/data/encodables/galaxy/Galaxy.java new file mode 100644 index 0000000..c10e074 --- /dev/null +++ b/src/com/projectswg/common/data/encodables/galaxy/Galaxy.java @@ -0,0 +1,144 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.data.encodables.galaxy; + +import java.time.ZoneOffset; +import java.util.TimeZone; +import java.util.concurrent.TimeUnit; + + +public class Galaxy { + + // Population status values. Values are in percent. + private static final double VERY_LIGHT = 10; + private static final double LIGHT = 20; + private static final double MEDIUM = 30; + private static final double HEAVY = 40; + private static final double VERY_HEAVY = 50; + private static final double EXTREMELY_HEAVY = 100; + + private int id = 0; + private String name = ""; + private String address = ""; + private int zonePort = 44463; + private int pingPort = 44462; + private int population = 0; + private GalaxyStatus status = GalaxyStatus.DOWN; + private ZoneOffset zoneOffset; + private int maxCharacters = 0; + private int onlinePlayerLimit = 0; + private int onlineFreeTrialLimit = 0; + private int adminServerPort = 0; + private boolean recommended = true; + + public Galaxy() { + + } + + public synchronized int getId() { return id; } + public synchronized String getName() { return name; } + public synchronized String getAddress() { return address; } + public synchronized int getZonePort() { return zonePort; } + public synchronized int getPingPort() { return pingPort; } + public synchronized int getPopulation() { return population; } + public synchronized GalaxyStatus getStatus() { return status; } + public synchronized int getDistance() { return zoneOffset.getTotalSeconds() - (int) TimeUnit.SECONDS.convert(TimeZone.getDefault().getDSTSavings(), TimeUnit.MILLISECONDS); } + public synchronized int getMaxCharacters() { return maxCharacters; } + public synchronized int getOnlinePlayerLimit() { return onlinePlayerLimit; } + public synchronized int getOnlineFreeTrialLimit() { return onlineFreeTrialLimit; } + public synchronized int getAdminServerPort() { return adminServerPort; } + public synchronized boolean isRecommended() { return recommended; } + + public synchronized int getPopulationStatus() { + + if (population < VERY_LIGHT) + return 0; + else if(population < LIGHT) + return 1; + else if(population < MEDIUM) + return 2; + else if(population < HEAVY) + return 3; + else if(population < VERY_HEAVY) + return 4; + else if(population < EXTREMELY_HEAVY) + return 5; + return 6; + } + + public synchronized void setId(int id) { this.id = id; } + public synchronized void setName(String name) { this.name = name; } + public synchronized void setAddress(String addr) { this.address = addr; } + public synchronized void setZonePort(int port) { this.zonePort = port; } + public synchronized void setPingPort(int port) { this.pingPort = port; } + public synchronized void setPopulation(int population) { this.population = population; } + public synchronized void setStatus(GalaxyStatus status) { this.status = status; } + public synchronized void setZoneOffset(ZoneOffset zoneOffset) { this.zoneOffset = zoneOffset; } + public synchronized void setMaxCharacters(int max) { this.maxCharacters = max; } + public synchronized void setOnlinePlayerLimit(int max) { this.onlinePlayerLimit = max; } + public synchronized void setOnlineFreeTrialLimit(int max) { this.onlineFreeTrialLimit = max; } + public synchronized void setAdminServerPort(int port) { this.adminServerPort = port; } + public synchronized void setRecommended(boolean r) { this.recommended = r; } + public synchronized void incrementPopulationCount() { population++; } + public synchronized void decrementPopulationCount() { population--; } + + @Override + public String toString() { + return String.format("Galaxy[ID=%d Name=%s Address=%s Zone=%d Ping=%d Pop=%d PopStat=%d Status=%s Time=%s Max=%d Rec=%b]", + id, name, address, zonePort, pingPort, population, getPopulationStatus(), status, zoneOffset.getId(), maxCharacters, recommended); + } + + public void setStatus(int status) { + for (GalaxyStatus gs : GalaxyStatus.values()) { + if (gs.getStatus() == status) { + setStatus(gs); + return; + } + } + } + + public enum GalaxyStatus { + DOWN (0x00), + LOADING (0x01), + UP (0x02), + LOCKED (0x03), + RESTRICTED (0x04), + FULL (0x05); + + private byte status; + + GalaxyStatus(int status) { + this.status = (byte) status; + } + + public byte getStatus() { + return status; + } + } + +} diff --git a/src/com/projectswg/common/data/encodables/map/MapLocation.java b/src/com/projectswg/common/data/encodables/map/MapLocation.java new file mode 100644 index 0000000..469889e --- /dev/null +++ b/src/com/projectswg/common/data/encodables/map/MapLocation.java @@ -0,0 +1,160 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ +package com.projectswg.common.data.encodables.map; + +import com.projectswg.common.encoding.CachedEncode; +import com.projectswg.common.encoding.Encodable; +import com.projectswg.common.network.NetBuffer; + +public class MapLocation implements Encodable { + + private long id; + private String name; + private float x; + private float y; + private byte category; + private byte subcategory; + private boolean isActive; + + private final CachedEncode cache; + + public MapLocation() { + this.cache = new CachedEncode(() -> encodeImpl()); + } + + public MapLocation(long id, String name, float x, float y, byte category, byte subcategory, boolean isActive) { + this(); + this.id = id; + this.name = name; + this.x = x; + this.y = y; + this.category = category; + this.subcategory = subcategory; + this.isActive = isActive; + } + + public long getId() { + return id; + } + + public void setId(long id) { + cache.clearCached(); + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + cache.clearCached(); + this.name = name; + } + + public float getX() { + return x; + } + + public void setX(float x) { + cache.clearCached(); + this.x = x; + } + + public float getY() { + return y; + } + + public void setY(float y) { + cache.clearCached(); + this.y = y; + } + + public byte getCategory() { + return category; + } + + public void setCategory(byte category) { + cache.clearCached(); + this.category = category; + } + + public byte getSubcategory() { + return subcategory; + } + + public void setSubcategory(byte subcategory) { + cache.clearCached(); + this.subcategory = subcategory; + } + + public boolean isActive() { + return isActive; + } + + public void setIsActive(boolean isActive) { + cache.clearCached(); + this.isActive = isActive; + } + + @Override + public byte[] encode() { + return cache.encode(); + } + + @Override + public void decode(NetBuffer data) { + id = data.getLong(); + name = data.getUnicode(); + x = data.getFloat(); + y = data.getFloat(); + category = data.getByte(); + subcategory = data.getByte(); + isActive = data.getBoolean(); + } + + private byte [] encodeImpl() { + NetBuffer data = NetBuffer.allocate(getLength()); + data.addLong(id); + data.addUnicode(name); + data.addFloat(x); + data.addFloat(y); + data.addByte(category); + data.addByte(subcategory); + data.addBoolean(isActive); + return data.array(); + } + + @Override + public int getLength() { + return name.length() * 2 + 23; + } + + @Override + public String toString() { + return name + " x: " + x + "y: " + y; + } +} diff --git a/src/com/projectswg/common/data/encodables/oob/OutOfBandData.java b/src/com/projectswg/common/data/encodables/oob/OutOfBandData.java new file mode 100644 index 0000000..9989732 --- /dev/null +++ b/src/com/projectswg/common/data/encodables/oob/OutOfBandData.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ +package com.projectswg.common.data.encodables.oob; + +import com.projectswg.common.encoding.Encodable; +import com.projectswg.common.persistable.Persistable; + +public interface OutOfBandData extends Encodable, Persistable { + + OutOfBandPackage.Type getOobType(); + int getOobPosition(); + +} diff --git a/src/com/projectswg/common/data/encodables/oob/OutOfBandFactory.java b/src/com/projectswg/common/data/encodables/oob/OutOfBandFactory.java new file mode 100644 index 0000000..88dbea7 --- /dev/null +++ b/src/com/projectswg/common/data/encodables/oob/OutOfBandFactory.java @@ -0,0 +1,67 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.encodables.oob; + +import com.projectswg.common.data.encodables.oob.waypoint.WaypointPackage; +import com.projectswg.common.network.NetBufferStream; + +public class OutOfBandFactory { + + public static void save(OutOfBandData oob, NetBufferStream stream) { + if (oob instanceof StringId) + stream.addByte(1); + else if (oob instanceof ProsePackage) + stream.addByte(2); + else if (oob instanceof WaypointPackage) { + stream.addByte(4); + } else + throw new IllegalArgumentException("Unknown OOB data!"); + oob.save(stream); + } + + public static OutOfBandData create(NetBufferStream stream) { + OutOfBandData oob; + byte type = stream.getByte(); + switch (type) { + case 1: + oob = new StringId(); + break; + case 2: + oob = new ProsePackage(); + break; + case 4: + oob = new WaypointPackage(); + break; + default: + throw new IllegalStateException("Unknown type byte! Type: " + type); + } + oob.read(stream); + return oob; + } + +} diff --git a/src/com/projectswg/common/data/encodables/oob/OutOfBandPackage.java b/src/com/projectswg/common/data/encodables/oob/OutOfBandPackage.java new file mode 100644 index 0000000..959d399 --- /dev/null +++ b/src/com/projectswg/common/data/encodables/oob/OutOfBandPackage.java @@ -0,0 +1,183 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.data.encodables.oob; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import com.projectswg.common.data.EnumLookup; +import com.projectswg.common.data.encodables.oob.waypoint.WaypointPackage; +import com.projectswg.common.debug.Log; +import com.projectswg.common.encoding.Encodable; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.NetBufferStream; +import com.projectswg.common.persistable.Persistable; + +public class OutOfBandPackage implements Encodable, Persistable { + + private final List packages; + + public OutOfBandPackage() { + packages = new ArrayList<>(); + } + + public OutOfBandPackage(OutOfBandData ... outOfBandData) { + this(); + Collections.addAll(packages, outOfBandData); + } + + public List getPackages() { + return packages; + } + + @Override + public byte[] encode() { + if (packages.isEmpty()) + return new byte[4]; + + int length = getLength(); + NetBuffer data = NetBuffer.allocate(length); + data.addInt((length-4) / 2); // Client treats this like a unicode string, so it's half the actual size of the array + for (OutOfBandData oob : packages) { + data.addRawArray(packOutOfBandData(oob)); + } + return data.array(); + } + + @Override + public void decode(NetBuffer data) { + int remaining = data.getInt() * 2; + while (remaining > 0) { + int start = data.position(); + int padding = data.getShort(); + Type type = Type.getTypeForByte(data.getByte()); + unpackOutOfBandData(data, type); + data.seek(padding); + remaining -= data.position() - start; + } + } + + @Override + public int getLength() { + int size = 4; + for (OutOfBandData oob : packages) { + size += getOOBLength(oob); + } + return size; + } + + @Override + public void save(NetBufferStream stream) { + stream.addList(packages, (p) -> OutOfBandFactory.save(p, stream)); + } + + @Override + public void read(NetBufferStream stream) { + stream.getList((i) -> packages.add(OutOfBandFactory.create(stream))); + } + + private void unpackOutOfBandData(NetBuffer data, Type type) { + // Position doesn't seem to be reflective of it's spot in the package list, not sure if this can be automated + // as the client will send -3 for multiple waypoints in a mail, so could be static for each OutOfBandData + // If that's the case, then we can move the position variable to the Type enum instead of a method return statement + data.getInt(); // position + OutOfBandData oob; + switch (type) { + case PROSE_PACKAGE: + oob = data.getEncodable(ProsePackage.class); + break; + case WAYPOINT: + oob = data.getEncodable(WaypointPackage.class); + break; + case STRING_ID: + oob = data.getEncodable(StringId.class); + break; + default: + Log.e("Tried to decode an unsupported OutOfBandData Type: " + type); + return; + } + packages.add(oob); + } + + private byte[] packOutOfBandData(OutOfBandData oob) { + // Type and position is included in the padding size + int paddingSize = getOOBPaddingSize(oob); + NetBuffer data = NetBuffer.allocate(getOOBLength(oob)); + data.addShort(paddingSize); // Number of bytes for decoding to skip over when reading + data.addByte(oob.getOobType().getType()); + data.addInt(oob.getOobPosition()); + data.addEncodable(oob); + for (int i = 0; i < paddingSize; i++) { + data.addByte(0); + } + + return data.array(); + } + + private int getOOBLength(OutOfBandData oob) { + return 7 + oob.getLength() + getOOBPaddingSize(oob); + } + + private int getOOBPaddingSize(OutOfBandData oob) { + return (oob.getLength() + 5) % 2; + } + + @Override + public String toString() { + return "OutOfBandPackage[packages=" + packages + "]"; + } + + public enum Type { + UNDEFINED (Byte.MIN_VALUE), + OBJECT (0), + PROSE_PACKAGE (1), + AUCTION_TOKEN (2), + OBJECT_ATTRIBUTES (3), + WAYPOINT (4), + STRING_ID (5), + STRING (6), + NUM_TYPES (7); + + private static final EnumLookup LOOKUP = new EnumLookup<>(Type.class, t -> t.getType()); + + private byte type; + + Type(int type) { + this.type = (byte) type; + } + + public byte getType() { + return type; + } + + public static Type getTypeForByte(byte typeByte) { + return LOOKUP.getEnum(typeByte, UNDEFINED); + } + } +} diff --git a/src/com/projectswg/common/data/encodables/oob/ProsePackage.java b/src/com/projectswg/common/data/encodables/oob/ProsePackage.java new file mode 100644 index 0000000..efe264a --- /dev/null +++ b/src/com/projectswg/common/data/encodables/oob/ProsePackage.java @@ -0,0 +1,359 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.data.encodables.oob; + +import java.math.BigInteger; + +import com.projectswg.common.debug.Assert; +import com.projectswg.common.debug.Log; +import com.projectswg.common.encoding.Encodable; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.NetBufferStream; +import com.projectswg.common.persistable.Persistable; + +public class ProsePackage implements OutOfBandData { + + private StringId base; + private Prose actor; + private Prose target; + private Prose other; + private int di; // decimal integer + private float df; // decimal float + private boolean grammarFlag; + + public ProsePackage() { + this.base = new StringId("", ""); + this.actor = new Prose(); + this.target = new Prose(); + this.other = new Prose(); + this.di = 0; + this.df = 0; + this.grammarFlag = false; + } + + /** + * Creates a new ProsePackage that only specifies a StringId + * + * @param table Base stf table for this ProsePackage + * @param key The key for the provided table to use + */ + public ProsePackage(String table, String key) { + this(); + setStringId(new StringId(table, key)); + } + + /** + * Creates a new ProsePackage that contains only 1 parameter for the specified StringId object
+ *
+ * Example:
+ *      ProsePackage("@base_player:prose_deposit_success", "DI", 500) + * + * @param stringId The base stringId for this ProsePackage + * @param proseKey The key in the message, can either be TU, TT, TO, or DI. + * @param prose Value to set for this key, instance depends on the key. + */ + public ProsePackage(StringId stringId, String proseKey, Object prose) { + this(); + setStringId(stringId); + setProse(proseKey, prose); + } + + /** + * Creates a new ProsePackage with multiple defined parameters. The first Object must be the prose key, followed by the keys value, and so on. If you're only setting 1 parameter, you should use the ProsePackage(key, prose) constructor instead.
+ *
+ * Example:
+ *      ProsePackage("StringId", new StringId("base_player", "prose_deposit_success"), "DI", 500) + * + * @param objects Key followed by the value. Can either be STF, TU, TT, TO, or DI. + */ + public ProsePackage(Object ... objects) { + this(); + int length = objects.length; + for (int i = 0; i < length - 1; i++) { + if (!(objects[i] instanceof String)) // Make sure that it's a key, chance of it being a customString though + continue; + + setProse((String) objects[i], objects[i + 1]); + } + } + + private void setProse(String key, Object prose) { + switch (key) { + case "StringId": + setStringId(prose); + break; + case "TU": + setTU(prose); + break; + case "TT": + setTT(prose); + break; + case "TO": + setTO(prose); + break; + case "DI": + if (prose instanceof Integer) + setDI((Integer) prose); + else { + Log.w("DI can only be a Integer!"); + } + break; + case "DF": + if (prose instanceof Float) + setDF((Float) prose); + else { + Log.w("DF can only be a Float!"); + } + break; + default: + break; + + } + } + + public void setStringId(Object prose) { + if (prose instanceof StringId) { + base = (StringId) prose; + } else if (prose instanceof String) { + if (((String) prose).startsWith("@")) { + base = new StringId((String) prose); + } else { + Log.w("The base STF cannot be a custom string!"); + } + } else { + Log.w("The base STF must be either a Stf or a String! Received class: " + prose.getClass().getName()); + } + } + + public void setTU(Object prose) { + setProse(actor, prose); + } + + public void setTT(Object prose) { + setProse(target, prose); + } + + public void setTO(Object prose) { + setProse(other, prose); + } + + public void setDI(Integer prose) { + di = prose; + } + + public void setDF(Float prose) { + df = prose; + } + + public void setGrammarFlag(boolean useGrammar) { + grammarFlag = useGrammar; + } + + private void setProse(Prose prose, Object obj) { + if (obj instanceof StringId) { + prose.setStringId((StringId) obj); + } else if (obj instanceof String) { + if (((String) obj).startsWith("@")) { + prose.setStringId(new StringId((String) obj)); + } else { + prose.setText((String) obj); + } + } else if (obj instanceof Long) { + prose.setObjectId((Long) obj); + } else if (obj instanceof BigInteger) { + prose.setObjectId(((BigInteger) obj).longValue()); + } else { + Log.w("Proses can only be Strings or Longs! Received class: " + prose.getClass().getName()); + } + } + + @Override + public byte[] encode() { + Assert.notNull(base, "There must be a StringId base!"); + NetBuffer data = NetBuffer.allocate(getLength()); + data.addEncodable(base); + data.addEncodable(actor); + data.addEncodable(target); + data.addEncodable(other); + data.addInt(di); + data.addFloat(df); + data.addBoolean(grammarFlag); + return data.array(); + } + + @Override + public void decode(NetBuffer data) { + base = data.getEncodable(StringId.class); + actor = data.getEncodable(Prose.class); + target = data.getEncodable(Prose.class); + other = data.getEncodable(Prose.class); + di = data.getInt(); + df = data.getInt(); + grammarFlag = data.getBoolean(); + } + + @Override + public int getLength() { + return 9 + base.getLength() + actor.getLength() + target.getLength() + other.getLength(); + } + + @Override + public void save(NetBufferStream stream) { + stream.addByte(0); + base.save(stream); + actor.save(stream); + target.save(stream); + other.save(stream); + stream.addBoolean(grammarFlag); + stream.addInt(di); + stream.addFloat(df); + } + + @Override + public void read(NetBufferStream stream) { + stream.getByte(); + base.read(stream); + actor.read(stream); + target.read(stream); + other.read(stream); + grammarFlag = stream.getBoolean(); + di = stream.getInt(); + df = stream.getFloat(); + } + + @Override + public OutOfBandPackage.Type getOobType() { + return OutOfBandPackage.Type.PROSE_PACKAGE; + } + + @Override + public int getOobPosition() { + return -1; + } + + @Override + public String toString() { + return "ProsePackage[base=" + base + ", grammarFlag=" + grammarFlag + ", actor=" + actor + ", target=" + target + ", other=" + other + ", di=" + di + ", df=" + df + "]"; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof ProsePackage)) + return false; + ProsePackage pp = (ProsePackage) o; + return base.equals(pp.base) && actor.equals(pp.actor) && target.equals(pp.target) && other.equals(pp.other) && grammarFlag == pp.grammarFlag && di == pp.di && df == pp.df; + } + + @Override + public int hashCode() { + return base.hashCode() * 3 + actor.hashCode() * 7 + target.hashCode() * 13 + other.hashCode() * 17 + (grammarFlag ? 1 : 0) + di * 19 + ((int) (df * 23)); + } + + public static class Prose implements Encodable, Persistable { + + private long objectId; + private StringId stringId; + private String text; + + public Prose() { + this.objectId = 0; + this.stringId = new StringId("", ""); + this.text = ""; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + + public void setStringId(StringId stringId) { + Assert.notNull(stringId, "StringId cannot be null!"); + this.stringId = stringId; + } + + public void setText(String text) { + Assert.notNull(text, "Text cannot be null!"); + this.text = text; + } + + @Override + public byte[] encode() { + NetBuffer data = NetBuffer.allocate(getLength()); + data.addLong(objectId); + data.addEncodable(stringId); + data.addUnicode(text); + return data.array(); + } + + @Override + public void decode(NetBuffer data) { + objectId = data.getLong(); + stringId = data.getEncodable(StringId.class); + text = data.getUnicode(); + } + + @Override + public int getLength() { + return 12 + stringId.getLength() + text.length()*2; + } + + @Override + public void save(NetBufferStream stream) { + stream.addByte(0); + stringId.save(stream); + stream.addLong(objectId); + stream.addUnicode(text); + } + + @Override + public void read(NetBufferStream stream) { + stream.getByte(); + stringId.read(stream); + objectId = stream.getLong(); + text = stream.getUnicode(); + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Prose)) + return false; + Prose p = (Prose) o; + return stringId.equals(p.stringId) && objectId == p.objectId && text.equals(p.text); + } + + @Override + public int hashCode() { + return stringId.hashCode() * 3 + Long.hashCode(objectId) * 7 + text.hashCode() * 13; + } + + @Override + public String toString() { + return "Prose[objectId=" + objectId + ", stringId=" + stringId + ", text='" + text + "']"; + } + } + +} diff --git a/src/com/projectswg/common/javafx/PSWGStringProperty.java b/src/com/projectswg/common/data/encodables/oob/StringId.java similarity index 53% rename from src/com/projectswg/common/javafx/PSWGStringProperty.java rename to src/com/projectswg/common/data/encodables/oob/StringId.java index 44f73f5..8328ffc 100644 --- a/src/com/projectswg/common/javafx/PSWGStringProperty.java +++ b/src/com/projectswg/common/data/encodables/oob/StringId.java @@ -25,85 +25,116 @@ * along with Holocore. If not, see . * * * ***********************************************************************************/ -package com.projectswg.common.javafx; +package com.projectswg.common.data.encodables.oob; -import java.text.Format; -import java.util.HashSet; -import java.util.Set; +import com.projectswg.common.debug.Log; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.NetBufferStream; +import com.projectswg.common.persistable.Persistable; -import javafx.beans.InvalidationListener; -import javafx.beans.property.Property; -import javafx.beans.property.SimpleStringProperty; -import javafx.beans.value.ChangeListener; -import javafx.util.StringConverter; - -public class PSWGStringProperty extends SimpleStringProperty { +public class StringId implements OutOfBandData, Persistable { - private final Set> listeners; - private final Set invalidationListeners; - private final Set> properties; + private String key = ""; + private String file = ""; - public PSWGStringProperty() { - super(); - listeners = new HashSet<>(); - invalidationListeners = new HashSet<>(); - properties = new HashSet<>(); + public StringId() { + } - public PSWGStringProperty(String initialValue) { - super(initialValue); - listeners = new HashSet<>(); - invalidationListeners = new HashSet<>(); - properties = new HashSet<>(); + public StringId(String file, String key) { + this.file = file; + this.key = key; + } + + public StringId(String stf) { + if (!stf.contains(":")) { + Log.e("Invalid stf format! Expected a semi-colon for " + stf); + return; + } + + if (stf.startsWith("@")) + stf = stf.substring(1); + + String[] split = stf.split(":", 2); + file = split[0]; + + if (split.length == 2) + key = split[1]; } @Override - public void addListener(ChangeListener listener) { - super.addListener(listener); - listeners.add(listener); + public byte[] encode() { + NetBuffer buffer = NetBuffer.allocate(getLength()); + buffer.addAscii(file); + buffer.addInt(0); + buffer.addAscii(key); + return buffer.array(); } @Override - public void addListener(InvalidationListener listener) { - super.addListener(listener); - invalidationListeners.add(listener); + public void decode(NetBuffer data) { + file = data.getAscii(); + data.getInt(); + key = data.getAscii(); } @Override - public void removeListener(ChangeListener listener) { - super.removeListener(listener); - listeners.remove(listener); + public int getLength() { + return 8 + key.length() + file.length(); } - public void removeAllListeners() { - for (ChangeListener listener : listeners) { - super.removeListener(listener); - } - for (InvalidationListener listener : invalidationListeners) { - super.removeListener(listener); - } + @Override + public void save(NetBufferStream stream) { + stream.addAscii(file); + stream.addAscii(key); } - public void bindBidirectional(Property property) { - super.bindBidirectional(property); - properties.add(property); + @Override + public void read(NetBufferStream stream) { + file = stream.getAscii(); + key = stream.getAscii(); } - public void bindBidirectional(Property property, Format format) { - super.bindBidirectional(property, format); - properties.add(property); + @Override + public OutOfBandPackage.Type getOobType() { + return OutOfBandPackage.Type.STRING_ID; } - public void bindBidirectional(Property property, StringConverter converter) { - super.bindBidirectional(property, converter); - properties.add(property); + @Override + public int getOobPosition() { + return -1; } - public void unbindAll() { - unbind(); - for (Property property : properties) { - super.unbindBidirectional(property); - } + public String getKey() { + return key; } + public void setKey(String key) { + this.key = key; + } + + public String getFile() { + return file; + } + + public void setFile(String file) { + this.file = file; + } + + @Override + public String toString() { + return "@" + file + ":" + key; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof StringId)) + return false; + return ((StringId) o).getKey().equals(getKey()) && ((StringId) o).getFile().equals(getFile()); + } + + @Override + public int hashCode() { + return key.hashCode() * 67 + file.hashCode(); + } } diff --git a/src/com/projectswg/common/data/encodables/oob/waypoint/WaypointColor.java b/src/com/projectswg/common/data/encodables/oob/waypoint/WaypointColor.java new file mode 100644 index 0000000..63c80a8 --- /dev/null +++ b/src/com/projectswg/common/data/encodables/oob/waypoint/WaypointColor.java @@ -0,0 +1,41 @@ +package com.projectswg.common.data.encodables.oob.waypoint; + +import com.projectswg.common.data.EnumLookup; + +public enum WaypointColor { + BLUE (1, "blue"), + GREEN (2, "green"), + ORANGE (3, "orange"), + YELLOW (4, "yellow"), + PURPLE (5, "purple"), + WHITE (6, "white"), + MULTICOLOR (7, "multicolor"); + + private static final EnumLookup NAME_LOOKUP = new EnumLookup<>(WaypointColor.class, WaypointColor::getName); + private static final EnumLookup VALUE_LOOKUP = new EnumLookup<>(WaypointColor.class, WaypointColor::getValue); + + private final String name; + private final int i; + + WaypointColor(int i, String name) { + this.name = name; + this.i = i; + } + + public String getName() { + return name; + } + + public int getValue() { + return i; + } + + public static WaypointColor valueOf(int colorId) { + return VALUE_LOOKUP.getEnum(colorId, WaypointColor.BLUE); + } + + public static WaypointColor fromString(String str) { + return NAME_LOOKUP.getEnum(str, WaypointColor.BLUE); + } + +} diff --git a/src/com/projectswg/common/data/encodables/oob/waypoint/WaypointPackage.java b/src/com/projectswg/common/data/encodables/oob/waypoint/WaypointPackage.java new file mode 100644 index 0000000..aa6d75a --- /dev/null +++ b/src/com/projectswg/common/data/encodables/oob/waypoint/WaypointPackage.java @@ -0,0 +1,194 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.data.encodables.oob.waypoint; + +import com.projectswg.common.data.encodables.oob.OutOfBandData; +import com.projectswg.common.data.encodables.oob.OutOfBandPackage; +import com.projectswg.common.data.encodables.oob.OutOfBandPackage.Type; +import com.projectswg.common.data.location.Point3D; +import com.projectswg.common.data.location.Terrain; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.NetBufferStream; + +public class WaypointPackage implements OutOfBandData { + + private final Point3D position; + + private long objectId; + private Terrain terrain; + private long cellId; + private String name; + private WaypointColor color; + private boolean active; + + public WaypointPackage() { + this.position = new Point3D(); + this.objectId = 0; + this.terrain = Terrain.GONE; + this.cellId = 0; + this.name = "New Waypoint"; + this.color = WaypointColor.BLUE; + this.active = true; + } + + public WaypointPackage(NetBuffer data) { + this.position = new Point3D(); + decode(data); + } + + public Point3D getPosition() { + return position; + } + + public long getObjectId() { + return objectId; + } + + public Terrain getTerrain() { + return terrain; + } + + public long getCellId() { + return cellId; + } + + public String getName() { + return name; + } + + public WaypointColor getColor() { + return color; + } + + public boolean isActive() { + return active; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + + public void setTerrain(Terrain terrain) { + this.terrain = terrain; + } + + public void setCellId(long cellId) { + this.cellId = cellId; + } + + public void setName(String name) { + this.name = name; + } + + public void setColor(WaypointColor color) { + this.color = color; + } + + public void setActive(boolean active) { + this.active = active; + } + + @Override + public byte[] encode() { + NetBuffer data = NetBuffer.allocate(getLength()); + data.addInt(0); + data.addEncodable(position); + data.addLong(cellId); + data.addInt(terrain.getCrc()); + data.addUnicode(name); + data.addLong(objectId); + data.addByte(color.getValue()); + data.addBoolean(active); + return data.array(); + } + + @Override + public void decode(NetBuffer data) { + data.getInt(); + position.decode(data); + cellId = data.getLong(); + terrain = Terrain.getTerrainFromCrc(data.getInt()); + name = data.getUnicode(); + objectId = data.getLong(); + color = WaypointColor.valueOf(data.getByte()); + active = data.getBoolean(); + } + + @Override + public int getLength() { + return 42 + name.length() * 2; + } + + @Override + public void save(NetBufferStream stream) { + stream.addByte(0); + stream.addLong(objectId); + stream.addLong(cellId); + position.save(stream); + stream.addAscii(terrain.name()); + stream.addUnicode(name); + stream.addInt(color.getValue()); + stream.addBoolean(active); + } + + @Override + public void read(NetBufferStream stream) { + stream.getByte(); + objectId = stream.getLong(); + cellId = stream.getLong(); + position.read(stream); + terrain = Terrain.valueOf(stream.getAscii()); + name = stream.getUnicode(); + color = WaypointColor.valueOf(stream.getInt()); + active = stream.getBoolean(); + } + + @Override + public Type getOobType() { + return OutOfBandPackage.Type.WAYPOINT; + } + + @Override + public int getOobPosition() { + return -3; + } + + @Override + public int hashCode() { + return Long.hashCode(objectId); + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof WaypointPackage)) + return false; + WaypointPackage wp = (WaypointPackage) o; + return wp.getObjectId() == getObjectId(); + } + +} diff --git a/src/com/projectswg/common/data/encodables/player/Mail.java b/src/com/projectswg/common/data/encodables/player/Mail.java new file mode 100644 index 0000000..f1ff7bd --- /dev/null +++ b/src/com/projectswg/common/data/encodables/player/Mail.java @@ -0,0 +1,199 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.data.encodables.player; + +import com.projectswg.common.data.encodables.oob.OutOfBandPackage; +import com.projectswg.common.encoding.Encodable; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.NetBufferStream; +import com.projectswg.common.persistable.Persistable; + +public class Mail implements Encodable, Persistable { + + private int id; + private String sender; + private long receiverId; + private String subject; + private String message; + private OutOfBandPackage outOfBandPackage; + private byte status; + private int timestamp; + + public static final byte NEW = 0x4E; + public static final byte READ = 0x52; + public static final byte UNREAD = 0x55; + + public Mail(String sender, String subject, String message, long receiverId) { + this.sender = sender; + this.subject = subject; + this.message = message; + this.receiverId = receiverId; + this.status = NEW; + this.outOfBandPackage = null; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getSender() { + return sender; + } + + public void setSender(String sender) { + this.sender = sender; + } + + public long getReceiverId() { + return receiverId; + } + + public String getSubject() { + return subject; + } + + public String getMessage() { + return message; + } + + public byte getStatus() { + return status; + } + + public void setStatus(byte status) { + this.status = status; + } + + public int getTimestamp() { + return timestamp; + } + + public void setTimestamp(int timestamp) { + this.timestamp = timestamp; + } + + public OutOfBandPackage getOutOfBandPackage() { + return outOfBandPackage; + } + + public void setOutOfBandPackage(OutOfBandPackage outOfBandPackage) { + this.outOfBandPackage = outOfBandPackage; + } + + @Override + public byte[] encode() { + NetBuffer data = NetBuffer.allocate(getLength()); + data.addUnicode(message); + data.addUnicode(subject); + data.addEncodable(outOfBandPackage); + return data.array(); + } + + @Override + public void decode(NetBuffer data) { + message = data.getUnicode(); + subject = data.getUnicode(); + outOfBandPackage = data.getEncodable(OutOfBandPackage.class); + } + + @Override + public int getLength() { + return 8 + message.length()*2 + subject.length()*2 + outOfBandPackage.getLength(); + } + + @Override + public void save(NetBufferStream stream) { + stream.addByte(0); + stream.addByte(status); + stream.addInt(id); + stream.addInt(timestamp); + stream.addLong(receiverId); + stream.addUnicode(sender); + stream.addUnicode(subject); + stream.addUnicode(message); + stream.addBoolean(outOfBandPackage != null); + if (outOfBandPackage != null) + outOfBandPackage.save(stream); + } + + @Override + public void read(NetBufferStream stream) { + stream.getByte(); + status = stream.getByte(); + id = stream.getInt(); + timestamp = stream.getInt(); + receiverId = stream.getLong(); + sender = stream.getUnicode(); + subject = stream.getUnicode(); + message = stream.getUnicode(); + if (stream.getBoolean()) { + outOfBandPackage = new OutOfBandPackage(); + outOfBandPackage.read(stream); + } + } + + @Override + public int hashCode() { + return id; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Mail)) + return false; + return ((Mail) o).id == id; + } + + public byte[] encodeHeader() { + NetBuffer data = NetBuffer.allocate(12 + subject.length() * 2); + data.addInt(0); + data.addUnicode(subject); + data.addInt(0); + return data.array(); + } + + public void decodeHeader(NetBuffer data) { + data.getInt(); + subject = data.getUnicode(); + data.getInt(); + } + + public static Mail create(NetBufferStream stream) { + Mail m = new Mail("", "", "", 0); + m.read(stream); + return m; + } + + public static void saveMail(Mail m, NetBufferStream stream) { + m.save(stream); + } +} diff --git a/src/com/projectswg/common/data/encodables/tangible/Posture.java b/src/com/projectswg/common/data/encodables/tangible/Posture.java new file mode 100644 index 0000000..1bda6a0 --- /dev/null +++ b/src/com/projectswg/common/data/encodables/tangible/Posture.java @@ -0,0 +1,65 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.data.encodables.tangible; + +import com.projectswg.common.data.EnumLookup; + +public enum Posture { + UPRIGHT (0x00), + CROUCHED (0x01), + PRONE (0x02), + SNEAKING (0x03), + BLOCKING (0x04), + CLIMBING (0x05), + FLYING (0x06), + LYING_DOWN (0x07), + SITTING (0x08), + SKILL_ANIMATING (0x09), + DRIVING_VEHICLE (0x0A), + RIDING_CREATURE (0x0B), + KNOCKED_DOWN (0x0C), + INCAPACITATED (0x0D), + DEAD (0x0E), + INVALID (0xFF); + + private static final EnumLookup LOOKUP = new EnumLookup<>(Posture.class, Posture::getId); + private byte id; + + Posture(int id) { + this.id = (byte)id; + } + + public byte getId() { + return id; + } + + public static final Posture getFromId(byte id) { + return LOOKUP.getEnum(id, INVALID); + } + +} \ No newline at end of file diff --git a/src/com/projectswg/common/data/encodables/tangible/PvpFaction.java b/src/com/projectswg/common/data/encodables/tangible/PvpFaction.java new file mode 100644 index 0000000..9390121 --- /dev/null +++ b/src/com/projectswg/common/data/encodables/tangible/PvpFaction.java @@ -0,0 +1,55 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.encodables.tangible; + +import com.projectswg.common.data.CRC; +import com.projectswg.common.data.EnumLookup; + + +public enum PvpFaction { + NEUTRAL (0), + IMPERIAL(CRC.getCrc("imperial")), + REBEL (CRC.getCrc("rebel")); + + private static final EnumLookup LOOKUP = new EnumLookup<>(PvpFaction.class, PvpFaction::getCrc); + + private int crc; + + PvpFaction(int crc) { + this.crc = crc; + } + + public int getCrc() { + return crc; + } + + public static PvpFaction getFactionForCrc(int crc) { + return LOOKUP.getEnum(crc, null); + } + +} diff --git a/src/com/projectswg/common/data/encodables/tangible/PvpFlag.java b/src/com/projectswg/common/data/encodables/tangible/PvpFlag.java new file mode 100644 index 0000000..28c15a4 --- /dev/null +++ b/src/com/projectswg/common/data/encodables/tangible/PvpFlag.java @@ -0,0 +1,62 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.encodables.tangible; + +import java.util.EnumSet; + +public enum PvpFlag { + ATTACKABLE (1 << 0), + AGGRESSIVE (1 << 1), + OVERT (1 << 2), + TEF (1 << 3), + PLAYER (1 << 4), + ENEMY (1 << 5), + GOING_OVERT (1 << 6), + GOING_COVERT (1 << 7), + DUEL (1 << 8); + + private int bitmask; + + PvpFlag(int bitmask) { + this.bitmask = bitmask; + } + + public int getBitmask() { + return bitmask; + } + + public static EnumSet getFlags(int bits) { + EnumSet states = EnumSet.noneOf(PvpFlag.class); + for (PvpFlag state : values()) { + if ((state.getBitmask() & bits) != 0) + states.add(state); + } + return states; + } + +} \ No newline at end of file diff --git a/src/com/projectswg/common/data/encodables/tangible/PvpStatus.java b/src/com/projectswg/common/data/encodables/tangible/PvpStatus.java new file mode 100644 index 0000000..4f55932 --- /dev/null +++ b/src/com/projectswg/common/data/encodables/tangible/PvpStatus.java @@ -0,0 +1,53 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.encodables.tangible; + +import com.projectswg.common.data.EnumLookup; + +public enum PvpStatus { + ONLEAVE (0), + COMBATANT (1), + SPECIALFORCES (2); + + private static final EnumLookup LOOKUP = new EnumLookup<>(PvpStatus.class, PvpStatus::getValue); + + private int value; + + PvpStatus(int crc) { + this.value = crc; + } + + public int getValue() { + return value; + } + + public static PvpStatus getStatusForValue(int crc) { + return LOOKUP.getEnum(crc, null); + } + +} \ No newline at end of file diff --git a/src/com/projectswg/common/data/encodables/tangible/Race.java b/src/com/projectswg/common/data/encodables/tangible/Race.java new file mode 100644 index 0000000..5e28b02 --- /dev/null +++ b/src/com/projectswg/common/data/encodables/tangible/Race.java @@ -0,0 +1,106 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.data.encodables.tangible; + +import com.projectswg.common.data.CRC; +import com.projectswg.common.data.EnumLookup; +import com.projectswg.common.data.swgfile.ClientFactory; + +public enum Race { + HUMAN_MALE ("human_male", 50, 0, 0, 50, 50, 50), + HUMAN_FEMALE ("human_female", 50, 0, 0, 50, 50, 50), + TRANDOSHAN_MALE ("trandoshan_male", 20, 65, 0, 0, 65, 50), + TRANDOSHAN_FEMALE ("trandoshan_female", 20, 65, 0, 0, 65, 50), + TWILEK_MALE ("twilek_male", 60, 0, 40, 40, 60, 0), + TWILEK_FEMALE ("twilek_female", 60, 0, 40, 40, 60, 0), + BOTHAN_MALE ("bothan_male", 50, 25, 60, 65, 0, 0), + BOTHAN_FEMALE ("bothan_female", 50, 25, 60, 65, 0, 0), + ZABRAK_MALE ("zabrak_male", 50, 50, 0, 50, 0, 50), + ZABRAK_FEMALE ("zabrak_female", 50, 50, 0, 50, 0, 50), + RODIAN_MALE ("rodian_male", 80, 0, 20, 80, 20, 0), + RODIAN_FEMALE ("rodian_female", 80, 0, 20, 80, 20, 0), + MONCAL_MALE ("moncal_male", 0, 40, 40, 60, 60, 0), + MONCAL_FEMALE ("moncal_female", 0, 40, 40, 60, 60, 0), + WOOKIEE_MALE ("wookiee_male", 0, 85, 0, 10, 40, 85), + WOOKIEE_FEMALE ("wookiee_female", 0, 85, 0, 10, 40, 85), + SULLUSTAN_MALE ("sullustan_male", 60, 60, 40, 0, 0, 40), + SULLUSTAN_FEMALE ("sullustan_female", 60, 60, 40, 0, 0, 40), + ITHORIAN_MALE ("ithorian_male", 0, 0, 30, 40, 70, 60), + ITHORIAN_FEMALE ("ithorian_female", 0, 0, 30, 40, 70, 60); + + private static final EnumLookup CRC_TO_RACE = new EnumLookup<>(Race.class, Race::getCrc); + private static final EnumLookup SPECIES_TO_RACE = new EnumLookup<>(Race.class, r -> r.species); + private static final EnumLookup FILE_TO_RACE = new EnumLookup<>(Race.class, Race::getFilename); + + private final boolean male; + private final int crc; + private final String species; + private final int agility; + private final int constitution; + private final int luck; + private final int precision; + private final int stamina; + private final int strength; + + Race(String species, int agility, int constitution, int luck, int precision, int stamina, int strength) { + this.male = !species.endsWith("female"); + this.crc = CRC.getCrc("object/creature/player/"+species+".iff"); + this.species = species; + this.agility = agility; + this.constitution = constitution; + this.luck = luck; + this.precision = precision; + this.stamina = stamina; + this.strength = strength; + } + + public boolean isMale() { return male; } + public boolean isFemale() { return !male; } + public int getCrc() { return crc; } + public int getAgility() { return agility; } + public int getConstitution() { return constitution; } + public int getLuck() { return luck; } + public int getPrecision() { return precision; } + public int getStamina() { return stamina; } + public int getStrength() { return strength; } + public String getFilename() { return "object/creature/player/shared_"+species+".iff"; } + public String getSpecies() { return species.substring(0, species.indexOf('_')); } + + public static final Race getRace(int crc) { + return CRC_TO_RACE.getEnum(crc, null); + } + + public static final Race getRace(String species) { + return SPECIES_TO_RACE.getEnum(species, HUMAN_MALE); + } + + public static final Race getRaceByFile(String iffFile) { + return FILE_TO_RACE.getEnum(ClientFactory.formatToSharedFile(iffFile), HUMAN_MALE); + } + +} diff --git a/src/com/projectswg/common/javafx/PSWGBooleanProperty.java b/src/com/projectswg/common/data/encodables/tangible/SkillMod.java similarity index 64% rename from src/com/projectswg/common/javafx/PSWGBooleanProperty.java rename to src/com/projectswg/common/data/encodables/tangible/SkillMod.java index 4bb794e..33f35d5 100644 --- a/src/com/projectswg/common/javafx/PSWGBooleanProperty.java +++ b/src/com/projectswg/common/data/encodables/tangible/SkillMod.java @@ -25,61 +25,74 @@ * along with Holocore. If not, see . * * * ***********************************************************************************/ -package com.projectswg.common.javafx; +package com.projectswg.common.data.encodables.tangible; -import java.util.HashSet; -import java.util.Set; +import com.projectswg.common.encoding.Encodable; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.NetBufferStream; +import com.projectswg.common.persistable.Persistable; -import javafx.beans.property.Property; -import javafx.beans.property.SimpleBooleanProperty; -import javafx.beans.value.ChangeListener; - -public class PSWGBooleanProperty extends SimpleBooleanProperty { +public class SkillMod implements Encodable, Persistable { - private final Set> listeners; - private final Set> properties; + private int base, modifier; - public PSWGBooleanProperty() { - super(); - listeners = new HashSet<>(); - properties = new HashSet<>(); + public SkillMod() { + this(0, 0); } - public PSWGBooleanProperty(boolean initialValue) { - super(initialValue); - listeners = new HashSet<>(); - properties = new HashSet<>(); + public SkillMod(int base, int modifier) { + this.base = base; + this.modifier = modifier; } @Override - public void addListener(ChangeListener listener) { - listeners.add(listener); - super.addListener(listener); + public byte[] encode() { + NetBuffer data = NetBuffer.allocate(8); + + data.addInt(base); + data.addInt(modifier); + + return data.array(); + } + + @Override + public void decode(NetBuffer data) { + base = data.getInt(); + modifier = data.getInt(); } @Override - public void removeListener(ChangeListener listener) { - listeners.remove(listener); - super.removeListener(listener); - } - - public void removeAllListeners() { - for (ChangeListener listener : listeners) { - super.removeListener(listener); - } + public int getLength() { + return 8; } @Override - public void bindBidirectional(Property property) { - super.bindBidirectional(property); - properties.add(property); + public void save(NetBufferStream stream) { + stream.addInt(base); + stream.addInt(modifier); } - public void unbindAll() { - unbind(); - for (Property property : properties) { - super.unbindBidirectional(property); - } + @Override + public void read(NetBufferStream stream) { + base = stream.getInt(); + modifier = stream.getInt(); + } + + public void adjustBase(int adjustment) { + base += adjustment; } + public void adjustModifier(int adjustment) { + modifier += adjustment; + } + + public int getValue() { + return base + modifier; + } + + @Override + public String toString() { + return "SkillMod[Base="+base+", Modifier="+modifier+"]"; + } + } diff --git a/src/com/projectswg/common/data/location/Location.java b/src/com/projectswg/common/data/location/Location.java index 479563d..10db275 100644 --- a/src/com/projectswg/common/data/location/Location.java +++ b/src/com/projectswg/common/data/location/Location.java @@ -53,51 +53,12 @@ public class Location implements Encodable, Persistable { this.terrain = terrain; } - public void setTerrain(Terrain terrain) { + private Location(Point3D point, Quaternion orientation, Terrain terrain) { + this.point = point; + this.orientation = orientation; this.terrain = terrain; } - public void setX(double x) { - point.setX(x); - } - - public void setY(double y) { - point.setY(y); - } - - public void setZ(double z) { - point.setZ(z); - } - - public void setOrientationX(double oX) { - orientation.setX(oX); - } - - public void setOrientationY(double oY) { - orientation.setY(oY); - } - - public void setOrientationZ(double oZ) { - orientation.setZ(oZ); - } - - public void setOrientationW(double oW) { - orientation.setW(oW); - } - - public void setPosition(double x, double y, double z) { - setX(x); - setY(y); - setZ(z); - } - - public void setOrientation(double oX, double oY, double oZ, double oW) { - setOrientationX(oX); - setOrientationY(oY); - setOrientationZ(oZ); - setOrientationW(oW); - } - public Terrain getTerrain() { return terrain; } @@ -168,59 +129,6 @@ public class Location implements Encodable, Persistable { return square(getX() - target.getX()) + square(getZ() - target.getZ()) <= square(radius); } - public void translatePosition(double x, double y, double z) { - setX(getX() + x); - setY(getY() + y); - setZ(getZ() + z); - } - - public void translateLocation(Location l) { - point.rotateAround(l.getX(), l.getY(), l.getZ(), l.orientation); - orientation.rotateByQuaternion(l.orientation); - } - - public Location translate(Location l) { - Location ret = new Location(this); - ret.translateLocation(l); - return ret; - } - - /** - * Sets the orientation to be facing the specified heading - * - * @param heading the heading to face, in degrees - */ - public void setHeading(double heading) { - orientation.setHeading(heading); - } - - /** - * Rotates the orientation by the specified angle along the Y-axis - * - * @param angle the angle to rotate by in degrees - */ - public void rotateHeading(double angle) { - orientation.rotateHeading(angle); - } - - /** - * Rotates the orientation by the specified angle along the specified axises - * - * @param angle the angle to rotate by in degrees - * @param axisX the amount of rotation about the x-axis - * @param axisY the amount of rotation about the x-axis - * @param axisZ the amount of rotation about the x-axis - */ - public void rotate(double angle, double axisX, double axisY, double axisZ) { - orientation.rotateDegrees(angle, axisX, axisY, axisZ); - } - - public void mergeWith(Location l) { - this.terrain = l.getTerrain(); - this.point.set(l.getX(), l.getY(), l.getZ()); - this.orientation.set(l.getOrientationX(), l.getOrientationY(), l.getOrientationZ(), l.getOrientationW()); - } - public double getSpeed(Location l, double deltaTime) { double dist = Math.sqrt(square(getX() - l.getX()) + square(getY() - l.getY()) + square(getZ() - l.getZ())); return dist / deltaTime; @@ -230,7 +138,7 @@ public class Location implements Encodable, Persistable { return orientation.getYaw(); } - private double square(double x) { + private static double square(double x) { return x * x; } @@ -347,4 +255,208 @@ public class Location implements Encodable, Persistable { return Math.sqrt(square(dstX - getX()) + square(dstZ - getZ())); } + public static LocationBuilder builder() { + return new LocationBuilder(); + } + + public static LocationBuilder builder(Location location) { + return new LocationBuilder(location); + } + + public static class LocationBuilder { + + private final Point3D point; + private final Quaternion orientation; + private Terrain terrain; + + public LocationBuilder() { + this.point = new Point3D(Double.NaN, Double.NaN, Double.NaN); + this.orientation = new Quaternion(0, 0, 0, 1); + this.terrain = null; + } + + public LocationBuilder(Location location) { + this.point = location.getPosition(); + this.orientation = location.getOrientation(); + this.terrain = location.getTerrain(); + } + + public Terrain getTerrain() { + return terrain; + } + + public double getX() { + return point.getX(); + } + + public double getY() { + return point.getY(); + } + + public double getZ() { + return point.getZ(); + } + + public double getOrientationX() { + return orientation.getX(); + } + + public double getOrientationY() { + return orientation.getY(); + } + + public double getOrientationZ() { + return orientation.getZ(); + } + + public double getOrientationW() { + return orientation.getW(); + } + + public double getYaw() { + return orientation.getYaw(); + } + + public boolean isWithinDistance(Location l, double x, double y, double z) { + if (getTerrain() != l.getTerrain()) + return false; + if (Math.abs(getX() - l.getX()) > x) + return false; + if (Math.abs(getY() - l.getY()) > y) + return false; + if (Math.abs(getZ() - l.getZ()) > z) + return false; + return true; + } + + public boolean isWithinDistance(Location l, double radius) { + return isWithinDistance(l.getTerrain(), l.getX(), l.getY(), l.getZ(), radius); + } + + public boolean isWithinDistance(Terrain t, double x, double y, double z, double radius) { + if (getTerrain() != t) + return false; + return square(getX() - x) + square(getY() - y) + square(getZ() - z) <= square(radius); + } + + public boolean isWithinFlatDistance(Location l, double radius) { + return isWithinFlatDistance(l.point, radius); + } + + public boolean isWithinFlatDistance(Point3D target, double radius) { + return square(getX() - target.getX()) + square(getZ() - target.getZ()) <= square(radius); + } + + public double getSpeed(Location l, double deltaTime) { + double dist = Math.sqrt(square(getX() - l.getX()) + square(getY() - l.getY()) + square(getZ() - l.getZ())); + return dist / deltaTime; + } + + public LocationBuilder setTerrain(Terrain terrain) { + this.terrain = terrain; + return this; + } + + public LocationBuilder setX(double x) { + point.setX(x); + return this; + } + + public LocationBuilder setY(double y) { + point.setY(y); + return this; + } + + public LocationBuilder setZ(double z) { + point.setZ(z); + return this; + } + + public LocationBuilder setOrientationX(double oX) { + orientation.setX(oX); + return this; + } + + public LocationBuilder setOrientationY(double oY) { + orientation.setY(oY); + return this; + } + + public LocationBuilder setOrientationZ(double oZ) { + orientation.setZ(oZ); + return this; + } + + public LocationBuilder setOrientationW(double oW) { + orientation.setW(oW); + return this; + } + + public LocationBuilder setPosition(double x, double y, double z) { + setX(x); + setY(y); + setZ(z); + return this; + } + + public LocationBuilder setOrientation(double oX, double oY, double oZ, double oW) { + setOrientationX(oX); + setOrientationY(oY); + setOrientationZ(oZ); + setOrientationW(oW); + return this; + } + + public LocationBuilder translatePosition(double x, double y, double z) { + setX(point.getX() + x); + setY(point.getY() + y); + setZ(point.getZ() + z); + return this; + } + + public LocationBuilder translateLocation(Location l) { + point.rotateAround(l.getX(), l.getY(), l.getZ(), l.orientation); + orientation.rotateByQuaternion(l.orientation); + return this; + } + + /** + * Sets the orientation to be facing the specified heading + * + * @param heading the heading to face, in degrees + */ + public LocationBuilder setHeading(double heading) { + orientation.setHeading(heading); + return this; + } + + /** + * Rotates the orientation by the specified angle along the Y-axis + * + * @param angle the angle to rotate by in degrees + */ + public LocationBuilder rotateHeading(double angle) { + orientation.rotateHeading(angle); + return this; + } + + /** + * Rotates the orientation by the specified angle along the specified axises + * + * @param angle the angle to rotate by in degrees + * @param axisX the amount of rotation about the x-axis + * @param axisY the amount of rotation about the x-axis + * @param axisZ the amount of rotation about the x-axis + */ + public LocationBuilder rotate(double angle, double axisX, double axisY, double axisZ) { + orientation.rotateDegrees(angle, axisX, axisY, axisZ); + return this; + } + + public Location build() { + return new Location(new Point3D(point), new Quaternion(orientation), terrain); + } + + } + } diff --git a/src/com/projectswg/common/data/location/Terrain.java b/src/com/projectswg/common/data/location/Terrain.java index e97378c..666c938 100644 --- a/src/com/projectswg/common/data/location/Terrain.java +++ b/src/com/projectswg/common/data/location/Terrain.java @@ -32,6 +32,7 @@ import java.util.Random; import com.projectswg.common.data.CRC; import com.projectswg.common.data.EnumLookup; +import com.projectswg.common.data.location.Location.LocationBuilder; public enum Terrain { ADVENTURE1 ("terrain/adventure1.trn"), @@ -132,18 +133,14 @@ public enum Terrain { } public Location getStartLocation() { - Location l = new Location(); + LocationBuilder l = Location.builder(); Random r = new Random(); if (this == TATOOINE) { - l.setOrientationX(0); - l.setOrientationY(0); - l.setOrientationZ(0); - l.setOrientationW(1); l.setX(3828 + r.nextInt(100) / 10 - 5); l.setY(4); l.setZ(-4804 + r.nextInt(100) / 10 - 5); } - return l; + return l.build(); } public static int getTerrainCount() { diff --git a/src/com/projectswg/common/data/radial/RadialItem.java b/src/com/projectswg/common/data/radial/RadialItem.java new file mode 100644 index 0000000..6445ad2 --- /dev/null +++ b/src/com/projectswg/common/data/radial/RadialItem.java @@ -0,0 +1,389 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.radial; + +import com.projectswg.common.data.EnumLookup; + +public enum RadialItem { + UNKNOWN (""), + COMBAT_TARGET (""), + COMBAT_UNTARGET (""), + COMBAT_ATTACK (""), + COMBAT_PEACE (""), + COMBAT_DUEL (""), + COMBAT_DEATH_BLOW (""), + EXAMINE (""), + EXAMINE_CHARACTERSHEET (""), + TRADE_START (""), + TRADE_ACCEPT (""), + ITEM_PICKUP (""), + ITEM_EQUIP (""), + ITEM_UNEQUIP (""), + ITEM_DROP (""), + ITEM_DESTROY (""), + ITEM_TOKEN (""), + ITEM_OPEN (""), + ITEM_OPEN_NEW_WINDOW (""), + ITEM_ACTIVATE (""), + ITEM_DEACTIVATE (""), + ITEM_USE (""), + ITEM_USE_SELF (""), + ITEM_USE_OTHER (""), + ITEM_SIT (""), + ITEM_MAIL (""), + CONVERSE_START (""), + CONVERSE_RESPOND (""), + CONVERSE_RESPONSE (""), + CONVERSE_STOP (""), + CRAFT_OPTIONS (""), + CRAFT_START (""), + CRAFT_HOPPER_INPUT (""), + CRAFT_HOPPER_OUTPUT (""), + MISSION_TERMINAL_LIST (""), + MISSION_DETAILS (""), + LOOT (""), + LOOT_ALL (""), + GROUP_INVITE (""), + GROUP_JOIN (""), + GROUP_LEAVE (""), + GROUP_KICK (""), + GROUP_DISBAND (""), + GROUP_DECLINE (""), + EXTRACT_OBJECT (""), + PET_CALL (""), + TERMINAL_AUCTION_USE (""), + CREATURE_FOLLOW (""), + CREATURE_STOP_FOLLOW (""), + SPLIT (""), + IMAGEDESIGN (""), + SET_NAME (""), + ITEM_ROTATE (""), + ITEM_ROTATE_LEFT (""), + ITEM_MOVE (""), + ITEM_MOVE_FORWARD (""), + ITEM_MOVE_BACK (""), + ITEM_MOVE_UP (""), + ITEM_MOVE_DOWN (""), + PET_STORE (""), + VEHICLE_GENERATE (""), + VEHICLE_STORE (""), + MISSION_ABORT (""), + MISSION_END_DUTY (""), + SHIP_MANAGE_COMPONENTS (""), + WAYPOINT_AUTOPILOT (""), + PROGRAM_DROID (""), + VEHICLE_OFFER_RIDE (""), + ITEM_PUBLIC_CONTAINER_USE1 (""), + COLLECTIONS (""), + GROUP_MASTER_LOOTER (""), + GROUP_MAKE_LEADER (""), + GROUP_LOOT (""), + ITEM_ROTATE_BACKWARD (""), + ITEM_ROTATE_COUNTERCLOCKWISE (""), + ITEM_ROTATE_RANDOM (""), + ITEM_ROTATE_RANDOM_YAW (""), + ITEM_ROTATE_RANDOM_PITCH (""), + ITEM_ROTATE_RANDOM_ROLL (""), + ITEM_ROTATE_RESET (""), + ITEM_ROTATE_COPY (""), + ITEM_MOVE_COPY_LOCATION (""), + ITEM_MOVE_COPY_HEIGHT (""), + GROUP_TELL (""), + ITEM_WP_SETCOLOR (""), + ITEM_WP_SETCOLOR_BLUE (""), + ITEM_WP_SETCOLOR_GREEN (""), + ITEM_WP_SETCOLOR_ORANGE (""), + ITEM_WP_SETCOLOR_YELLOW (""), + ITEM_WP_SETCOLOR_PURPLE (""), + ITEM_WP_SETCOLOR_WHITE (""), + ITEM_MOVE_LEFT (""), + ITEM_MOVE_RIGHT (""), + ROTATE_APPLY (""), + ROTATE_RESET (""), + WINDOW_LOCK (""), + WINDOW_UNLOCK (""), + GROUP_CREATE_PICKUP_POINT (""), + GROUP_USE_PICKUP_POINT (""), + GROUP_USE_PICKUP_POINT_NOCAMP (""), + VOICE_SHORTLIST_REMOVE (""), + VOICE_INVITE (""), + VOICE_KICK (""), + ITEM_EQUIP_APPEARANCE (""), + ITEM_UNEQUIP_APPEARANCE (""), + OPEN_STORYTELLER_RECIPE (""), + ITEM_WP_MAKE_CITY_WAYPOINT (""), + ITEM_WP_MAKE_GUILD_WAYPOINT (""), + ATMOSPHERIC_FLIGHT_FLY (""), + ATMOSPHERIC_FLIGHT_LAND (""), + SERVER_DIVIDER (""), + SERVER_MENU1 (""), + SERVER_MENU2 (""), + SERVER_MENU3 (""), + SERVER_MENU4 (""), + SERVER_MENU5 (""), + SERVER_MENU6 (""), + SERVER_MENU7 (""), + SERVER_MENU8 (""), + SERVER_MENU9 (""), + SERVER_MENU10 (""), + SERVER_MENU11 (""), + SERVER_MENU12 (""), + SERVER_MENU13 (""), + SERVER_MENU14 (""), + SERVER_MENU15 (""), + SERVER_MENU16 (""), + SERVER_MENU17 (""), + SERVER_MENU18 (""), + SERVER_MENU19 (""), + SERVER_MENU20 (""), + SERVER_MENU21 (""), + SERVER_MENU22 (""), + SERVER_MENU23 (""), + SERVER_MENU24 (""), + SERVER_MENU25 (""), + SERVER_MENU26 (""), + SERVER_MENU27 (""), + SERVER_MENU28 (""), + SERVER_MENU29 (""), + SERVER_MENU30 (""), + SERVER_MENU31 (""), + SERVER_MENU32 (""), + SERVER_MENU33 (""), + SERVER_MENU34 (""), + SERVER_MENU35 (""), + SERVER_MENU36 (""), + SERVER_MENU37 (""), + SERVER_MENU38 (""), + SERVER_MENU39 (""), + SERVER_MENU40 (""), + SERVER_MENU41 (""), + SERVER_MENU42 (""), + SERVER_MENU43 (""), + SERVER_MENU44 (""), + SERVER_MENU45 (""), + SERVER_MENU46 (""), + SERVER_MENU47 (""), + SERVER_MENU48 (""), + SERVER_MENU49 (""), + SERVER_MENU50 (""), + SERVER_HARVESTER_MANAGE (""), + SERVER_HOUSE_MANAGE (""), + SERVER_FACTION_HALL_MANAGE (""), + SERVER_HUE (""), + SERVER_OBSERVE (""), + SERVER_STOP_OBSERVING (""), + SERVER_TRAVEL_OPTIONS (""), + SERVER_BAZAAR_OPTIONS (""), + SERVER_SHIPPING_OPTIONS (""), + SERVER_HEAL_WOUND (""), + SERVER_HEAL_WOUND_HEALTH (""), + SERVER_HEAL_WOUND_ACTION (""), + SERVER_HEAL_WOUND_STRENGTH (""), + SERVER_HEAL_WOUND_CONSTITUTION (""), + SERVER_HEAL_WOUND_QUICKNESS (""), + SERVER_HEAL_WOUND_STAMINA (""), + SERVER_HEAL_DAMAGE (""), + SERVER_HEAL_STATE (""), + SERVER_HEAL_STATE_STUNNED (""), + SERVER_HEAL_STATE_BLINDED (""), + SERVER_HEAL_STATE_DIZZY (""), + SERVER_HEAL_STATE_INTIMIDATED (""), + SERVER_HEAL_ENHANCE (""), + SERVER_HEAL_ENHANCE_HEALTH (""), + SERVER_HEAL_ENHANCE_ACTION (""), + SERVER_HEAL_ENHANCE_STRENGTH (""), + SERVER_HEAL_ENHANCE_CONSTITUTION (""), + SERVER_HEAL_ENHANCE_QUICKNESS (""), + SERVER_HEAL_ENHANCE_STAMINA (""), + SERVER_HEAL_FIRSTAID (""), + SERVER_HEAL_CURE_POISON (""), + SERVER_HEAL_CURE_DISEASE (""), + SERVER_HEAL_APPLY_POISON (""), + SERVER_HEAL_APPLY_DISEASE (""), + SERVER_HARVEST_CORPSE (""), + SERVER_PERFORMANCE_LISTEN (""), + SERVER_PERFORMANCE_WATCH (""), + SERVER_PERFORMANCE_LISTEN_STOP (""), + SERVER_PERFORMANCE_WATCH_STOP (""), + SERVER_TERMINAL_PERMISSIONS (""), + SERVER_TERMINAL_MANAGEMENT (""), + SERVER_TERMINAL_PERMISSIONS_ENTER (""), + SERVER_TERMINAL_PERMISSIONS_BANNED (""), + SERVER_TERMINAL_PERMISSIONS_ADMIN (""), + SERVER_TERMINAL_PERMISSIONS_VENDOR (""), + SERVER_TERMINAL_PERMISSIONS_HOPPER (""), + SERVER_TERMINAL_MANAGEMENT_STATUS (""), + SERVER_TERMINAL_MANAGEMENT_PRIVACY (""), + SERVER_TERMINAL_MANAGEMENT_TRANSFER (""), + SERVER_TERMINAL_MANAGEMENT_RESIDENCE (""), + SERVER_TERMINAL_MANAGEMENT_DESTROY (""), + SERVER_TERMINAL_MANAGEMENT_PAY (""), + SERVER_TERMINAL_CREATE_VENDOR (""), + SERVER_GIVE_VENDOR_MAINTENANCE (""), + SERVER_ITEM_OPTIONS (""), + SERVER_SURVEY_TOOL_RANGE (""), + SERVER_SURVEY_TOOL_RESOLUTION (""), + SERVER_SURVEY_TOOL_CLASS (""), + SERVER_PROBE_DROID_TRACK_TARGET (""), + SERVER_PROBE_DROID_FIND_TARGET (""), + SERVER_PROBE_DROID_ACTIVATE (""), + SERVER_PROBE_DROID_BUY (""), + SERVER_TEACH (""), + PET_COMMAND (""), + PET_FOLLOW (""), + PET_STAY (""), + PET_GUARD (""), + PET_FRIEND (""), + PET_ATTACK (""), + PET_PATROL (""), + PET_GET_PATROL_POINT (""), + PET_CLEAR_PATROL_POINTS (""), + PET_ASSUME_FORMATION_1 (""), + PET_ASSUME_FORMATION_2 (""), + PET_TRANSFER (""), + PET_RELEASE (""), + PET_TRICK_1 (""), + PET_TRICK_2 (""), + PET_TRICK_3 (""), + PET_TRICK_4 (""), + PET_GROUP (""), + PET_TAME (""), + PET_FEED (""), + PET_SPECIAL_ATTACK_ONE (""), + PET_SPECIAL_ATTACK_TWO (""), + PET_RANGED_ATTACK (""), + DICE_ROLL (""), + DICE_TWO_FACE (""), + DICE_THREE_FACE (""), + DICE_FOUR_FACE (""), + DICE_FIVE_FACE (""), + DICE_SIX_FACE (""), + DICE_SEVEN_FACE (""), + DICE_EIGHT_FACE (""), + DICE_COUNT_ONE (""), + DICE_COUNT_TWO (""), + DICE_COUNT_THREE (""), + DICE_COUNT_FOUR (""), + CREATE_BALLOT (""), + VOTE (""), + BOMBING_RUN (""), + SELF_DESTRUCT (""), + THIRTY_SEC (""), + FIFTEEN_SEC (""), + SERVER_CAMP_DISBAND (""), + SERVER_CAMP_ASSUME_OWNERSHIP (""), + SERVER_PROBE_DROID_PROGRAM (""), + SERVER_GUILD_CREATE ("@guild:menu_create"), + SERVER_GUILD_INFO (""), + SERVER_GUILD_MEMBERS (""), + SERVER_GUILD_SPONSORED (""), + SERVER_GUILD_ENEMIES (""), + SERVER_GUILD_SPONSOR (""), + SERVER_GUILD_DISBAND (""), + SERVER_GUILD_NAMECHANGE (""), + SERVER_GUILD_GUILD_MANAGEMENT (""), + SERVER_GUILD_MEMBER_MANAGEMENT (""), + SERVER_MANF_HOPPER_INPUT (""), + SERVER_MANF_HOPPER_OUTPUT (""), + SERVER_MANF_STATION_SCHEMATIC (""), + ELEVATOR_UP (""), + ELEVATOR_DOWN (""), + SERVER_PET_OPEN (""), + SERVER_PET_DPAD (""), + SERVER_MED_TOOL_DIAGNOSE (""), + SERVER_MED_TOOL_TENDWOUND (""), + SERVER_MED_TOOL_TENDDAMAGE (""), + SERVER_PET_DISMOUNT (""), + SERVER_PET_TRAIN_MOUNT (""), + SERVER_VEHICLE_ENTER (""), + SERVER_VEHICLE_EXIT (""), + OPEN_NAVICOMP_DPAD (""), + INIT_NAVICOMP_DPAD (""), + CITY_STATUS (""), + CITY_CITIZENS (""), + CITY_STRUCTURES (""), + CITY_TREASURY (""), + CITY_MANAGEMENT (""), + CITY_NAME (""), + CITY_MILITIA (""), + CITY_TAXES (""), + CITY_TREASURY_DEPOSIT (""), + CITY_TREASURY_WITHDRAW (""), + CITY_REGISTER (""), + CITY_RANK (""), + CITY_ADMIN_1 (""), + CITY_ADMIN_2 (""), + CITY_ADMIN_3 (""), + CITY_ADMIN_4 (""), + CITY_ADMIN_5 (""), + CITY_ADMIN_6 (""), + MEMORY_CHIP_PROGRAM (""), + MEMORY_CHIP_TRANSFER (""), + MEMORY_CHIP_ANALYZE (""), + EQUIP_DROID_ON_SHIP (""), + BIO_LINK (""), + LANDMINE_DISARM (""), + LANDMINE_REVERSE_TRIGGER (""), + REWARD_TRADE_IN (""); + + private static final EnumLookup LOOKUP = new EnumLookup<>(RadialItem.class, RadialItem::getId); + + private final int id; + private final int optionType; + private final String text; + + RadialItem(String text) { + this.id = RadialItemInit.getNextItemId(); + this.optionType = 3; + this.text = text; + } + + public int getId() { + return id; + } + + public int getOptionType() { + return optionType; + } + + public String getText() { + return text; + } + + /** + * Gets the RadialItem from the selection id. If the item is undefined, + * then NULL is returned + * @param id the selection id that maps to a RadialItem + * @return the RadialItem represented by the selection, or NULL if it does + * not exist + */ + public static RadialItem getFromId(int id) { + return LOOKUP.getEnum(id, null); + } + +} diff --git a/src/com/projectswg/common/data/radial/RadialItemInit.java b/src/com/projectswg/common/data/radial/RadialItemInit.java new file mode 100644 index 0000000..f0a14a6 --- /dev/null +++ b/src/com/projectswg/common/data/radial/RadialItemInit.java @@ -0,0 +1,40 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.radial; + +import java.util.concurrent.atomic.AtomicInteger; + +class RadialItemInit { + + private static final AtomicInteger ID = new AtomicInteger(0); + + public static int getNextItemId() { + return ID.getAndIncrement(); + } + +} diff --git a/src/com/projectswg/common/data/radial/RadialOption.java b/src/com/projectswg/common/data/radial/RadialOption.java new file mode 100644 index 0000000..9acf940 --- /dev/null +++ b/src/com/projectswg/common/data/radial/RadialOption.java @@ -0,0 +1,69 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.data.radial; + +import java.util.ArrayList; +import java.util.List; + +public class RadialOption { + + private RadialItem item; + private List children; + private String overriddenText; + + public RadialOption() { + this.children = new ArrayList<>(); + } + + public RadialOption(RadialItem item) { + this.item = item; + this.children = new ArrayList<>(); + } + + public void setItem(RadialItem item) { this.item = item; } + public void addChild(RadialOption option) { this.children.add(option); } + public void addChild(RadialItem item) { addChild(new RadialOption(item)); } + public void addChildWithOverriddenText(RadialItem item, String overriddenText) { + RadialOption childOption = new RadialOption(item); + childOption.setOverriddenText(overriddenText); + addChild(childOption); + } + public void setOverriddenText(String overridenText) { this.overriddenText = overridenText; } + + public int getId() { return item.getId(); } + public int getOptionType() { return item.getOptionType(); } + public String getText() { return overriddenText != null ? overriddenText : item.getText(); } + + public List getChildren() { return children; } + + @Override + public String toString() { + return String.format("ID=%d Option=%d Text=%s", getId(), getOptionType(), getText()); + } + +} diff --git a/src/com/projectswg/common/data/radial/RadialOptionList.java b/src/com/projectswg/common/data/radial/RadialOptionList.java new file mode 100644 index 0000000..d687990 --- /dev/null +++ b/src/com/projectswg/common/data/radial/RadialOptionList.java @@ -0,0 +1,171 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.data.radial; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.projectswg.common.debug.Log; +import com.projectswg.common.encoding.Encodable; +import com.projectswg.common.network.NetBuffer; + +public class RadialOptionList implements Encodable { + + private final List options; + + public RadialOptionList() { + options = new ArrayList<>(); + } + + public RadialOptionList(List options) { + this(); + this.options.addAll(options); + } + + public void addOption(RadialOption option) { + options.add(option); + } + + public void setOptions(List options) { + this.options.clear(); + this.options.addAll(options); + } + + public List getOptions() { + return Collections.unmodifiableList(options); + } + + @Override + public void decode(NetBuffer data) { + int optionsCount = data.getInt(); + Map optionMap = new HashMap<>(); + for (int i = 0; i < optionsCount; i++) { + RadialOption option = new RadialOption(); + int opt = data.getByte(); // option number + int parent = data.getByte(); // parentId + int radialType = data.getShort(); // radialType + data.getByte(); // optionType + data.getUnicode(); // text + RadialItem item = RadialItem.getFromId(radialType); + if (item == null) { + Log.e("No radial item found for: %04X"); + continue; + } + option.setItem(item); + optionMap.put(opt, option); + if (parent == 0) { + options.add(option); + } else { + RadialOption parentOpt = optionMap.get(parent); + if (parentOpt == null) { + Log.e("Parent not found! Parent=%d Option=%s", parent, option); + } else { + parentOpt.addChild(option); + } + } + } + } + + @Override + public byte [] encode() { + NetBuffer data = NetBuffer.allocate(4 + getOptionSize()); + data.addInt(getOptionCount()); + addOptions(data); + return data.array(); + } + + @Override + public int getLength() { + return 4 + getOptionSize(); + } + + public int getSize() { + return 4 + getOptionSize(); + } + + private int getOptionCount() { + int count = 0; + for (RadialOption option : options) { + count += getOptionCount(option); + } + return count; + } + + private int getOptionSize() { + int size = 0; + for (RadialOption option : options) { + size += getOptionSize(option); + } + return size; + } + + private void addOptions(NetBuffer data) { + int index = 1; + for (RadialOption option : options) { + index = addOption(data, option, 0, index); + } + } + + private int getOptionCount(RadialOption parent) { + int count = 1; + for (RadialOption child : parent.getChildren()) { + count += getOptionCount(child); + } + return count; + } + + private int getOptionSize(RadialOption parent) { + int size = 9; + if (parent.getText() != null && !parent.getText().isEmpty()) + size += parent.getText().length()*2; + for (RadialOption child : parent.getChildren()) { + size += getOptionSize(child); + } + return size; + } + + private int addOption(NetBuffer data, RadialOption parent, int parentIndex, int index) { + int myIndex = index++; + data.addByte(myIndex); + data.addByte(parentIndex); + data.addShort(parent.getId()); + data.addByte(parent.getOptionType()); + if (parent.getText() != null || !parent.getText().isEmpty()) + data.addUnicode(parent.getText()); + else + data.addInt(0); + for (RadialOption option : parent.getChildren()) { + index = addOption(data, option, myIndex, index); + } + return index; + } + +} diff --git a/src/com/projectswg/common/javafx/FXMLController.java b/src/com/projectswg/common/data/sui/ISuiCallback.java similarity index 91% rename from src/com/projectswg/common/javafx/FXMLController.java rename to src/com/projectswg/common/data/sui/ISuiCallback.java index c3b5911..a3049dc 100644 --- a/src/com/projectswg/common/javafx/FXMLController.java +++ b/src/com/projectswg/common/data/sui/ISuiCallback.java @@ -25,16 +25,10 @@ * along with Holocore. If not, see . * * * ***********************************************************************************/ -package com.projectswg.common.javafx; +package com.projectswg.common.data.sui; -import javafx.fxml.Initializable; -import javafx.scene.Parent; +import java.util.Map; -public interface FXMLController extends Initializable { - - Parent getRoot(); - default void terminate() { - - } - +public interface ISuiCallback { + void handleEvent(SuiEvent event, Map parameters); } diff --git a/src/com/projectswg/common/data/sui/SuiBaseWindow.java b/src/com/projectswg/common/data/sui/SuiBaseWindow.java new file mode 100644 index 0000000..5d2aa92 --- /dev/null +++ b/src/com/projectswg/common/data/sui/SuiBaseWindow.java @@ -0,0 +1,324 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.data.sui; + +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.projectswg.common.debug.Log; +import com.projectswg.common.encoding.Encodable; +import com.projectswg.common.network.NetBuffer; + +public class SuiBaseWindow implements Encodable { + + private int id; + private String suiScript; + private long rangeObjId; + private float maxDistance = 0; + private List components = new ArrayList<>(); + private Map callbacks; + private Map scriptCallbacks; + private boolean hasSubscriptionComponent = false; + + public SuiBaseWindow() { + } + + public SuiBaseWindow(String suiScript) { + this.suiScript = suiScript; + } + + public final void clearDataSource(String dataSource) { + SuiComponent component = new SuiComponent(SuiComponent.Type.CLEAR_DATA_SOURCE, dataSource); + components.add(component); + } + + public final void addChildWidget(String type, String childWidget, String parentWidget) { + SuiComponent component = new SuiComponent(SuiComponent.Type.ADD_CHILD_WIDGET, parentWidget); + + component.addNarrowParam(type); + component.addNarrowParam(childWidget); + + components.add(component); + } + + public final void setProperty(String widget, String property, String value) { + SuiComponent component = new SuiComponent(SuiComponent.Type.SET_PROPERTY, widget); + + component.addNarrowParam(property); + component.addWideParam(value); + + components.add(component); + } + + public final void addDataItem(String dataSource, String name, String value) { + SuiComponent component = new SuiComponent(SuiComponent.Type.ADD_DATA_ITEM, dataSource); + + component.addNarrowParam(name); + component.addWideParam(value); + + components.add(component); + } + + protected void subscribeToEvent(int event, String widgetSource, String callback) { + SuiComponent component = getSubscriptionForEvent(event, widgetSource); + if (component != null) { + Log.i("Added event callback %d to %s when the event is already subscribed to, replacing callback to %s", event, widgetSource, callback); + component.getNarrowParams().set(2, callback); + } else { + component = new SuiComponent(SuiComponent.Type.SUBSCRIBE_TO_EVENT, widgetSource); + component.addNarrowParam(getWrappedEventString(event)); + component.addNarrowParam(callback); + + components.add(component); + } + if (!hasSubscriptionComponent()) + hasSubscriptionComponent = true; + } + + protected void subscribeToPropertyEvent(int event, String widgetSource, String propertyWidget, String propertyName) { + SuiComponent component = getSubscriptionForEvent(event, widgetSource); + if (component != null) { + // This component already has the trigger and source param, just need to add the widget and property + // for client to return the value to the server + component.addNarrowParam(propertyWidget); + component.addNarrowParam(propertyName); + } else { + component = new SuiComponent(SuiComponent.Type.SUBSCRIBE_TO_EVENT, widgetSource); + component.addNarrowParam(getWrappedEventString(event)); + component.addNarrowParam(""); + component.addNarrowParam(propertyWidget); + component.addNarrowParam(propertyName); + components.add(component); + } + if (!hasSubscriptionComponent()) + hasSubscriptionComponent = true; + } + + public final void addDataSourceContainer(String dataSourceContainer, String name, String value) { + SuiComponent component = new SuiComponent(SuiComponent.Type.ADD_DATA_SOURCE_CONTAINER, dataSourceContainer); + + component.addNarrowParam(name); + component.addWideParam(value); + + components.add(component); + } + + public final void clearDataSourceContainer(String dataSourceContainer) { + SuiComponent component = new SuiComponent(SuiComponent.Type.CLEAR_DATA_SOURCE_CONTAINER, dataSourceContainer); + components.add(component); + } + + public final void addDataSource(String dataSource, String name, String value) { + SuiComponent component = new SuiComponent(SuiComponent.Type.ADD_DATA_SOURCE, dataSource); + + component.addNarrowParam(name); + component.addWideParam(value); + + components.add(component); + } + + public final void addReturnableProperty(SuiEvent event, String source, String widget, String property) { + subscribeToPropertyEvent(event.getValue(), source, widget, property); + } + + public final void addReturnableProperty(SuiEvent event, String widget, String property) { + addReturnableProperty(event, "", widget, property); + } + + public final void addReturnableProperty(String widget, String property) { + subscribeToPropertyEvent(SuiEvent.OK_PRESSED.getValue(), "", widget, property); + subscribeToPropertyEvent(SuiEvent.CANCEL_PRESSED.getValue(), "", widget, property); + } + + public final void addCallback(SuiEvent event, String source, String name, ISuiCallback callback) { + subscribeToEvent(event.getValue(), source, name); + addJavaCallback(name, callback); + } + + public final void addCallback(SuiEvent event, String name, ISuiCallback callback) { + addCallback(event, "", name, callback); + } + + public final void addCallback(SuiEvent event, String source, String script, String function) { + subscribeToEvent(event.getValue(), source, function); + addScriptCallback(function, script); + } + + public final void addCallback(SuiEvent event, String script, String function) { + addCallback(event, "", script, function); + } + + public final void addCallback(String source, String script, String function) { + subscribeToEvent(SuiEvent.OK_PRESSED.getValue(), source, function); + subscribeToEvent(SuiEvent.CANCEL_PRESSED.getValue(), source, function); + addScriptCallback(function, script); + } + + public final void addCallback(String script, String function) { + addCallback("", script, function); + } + + public final void addCallback(String source, String name, ISuiCallback callback) { + subscribeToEvent(SuiEvent.OK_PRESSED.getValue(), source, name); + subscribeToEvent(SuiEvent.CANCEL_PRESSED.getValue(), source, name); + addJavaCallback(name, callback); + } + + public final void addCallback(String name, ISuiCallback callback) { + addCallback("", name, callback); + } + + public final SuiComponent getSubscriptionForEvent(int event, String widget) { + for (SuiComponent component : components) { + if (component.getType() != SuiComponent.Type.SUBSCRIBE_TO_EVENT) + continue; + + int eventType = component.getSubscribedToEventType(); + + if (eventType == event && component.getTarget().equals(widget)) + return component; + } + return null; + } + + public final SuiComponent getSubscriptionByIndex(int index) { + int count = 0; + for (SuiComponent component : components) { + if (component.getType() == SuiComponent.Type.SUBSCRIBE_TO_EVENT) { + if (index == count) return component; + else count++; + } + } + return null; + } + + public final long getRangeObjId() { + return rangeObjId; + } + + public final void setRangeObjId(long rangeObjId) { + this.rangeObjId = rangeObjId; + } + + public final int getId() { + return id; + } + + public final void setId(int id) { + this.id = id; + } + + public final String getSuiScript() { + return suiScript; + } + + public final float getMaxDistance() { + return maxDistance; + } + + public final void setMaxDistance(float maxDistance) { + this.maxDistance = maxDistance; + } + + public final List getComponents() { + return components; + } + + public final ISuiCallback getJavaCallback(String name) { + return callbacks != null ? callbacks.get(name) : null; + } + + public final String getCallbackScript(String function) { + return scriptCallbacks != null ? scriptCallbacks.get(function) : null; + } + + public final boolean hasCallbackFunction(String function) { + return scriptCallbacks != null && scriptCallbacks.containsKey(function); + } + + public final boolean hasJavaCallback(String name) { + return callbacks != null && callbacks.containsKey(name); + } + + public final boolean hasSubscriptionComponent() { + return hasSubscriptionComponent; + } + + private void addJavaCallback(String name, ISuiCallback callback) { + if (callbacks == null) callbacks = new HashMap<>(); + + callbacks.put(name, callback); + } + + private void addScriptCallback(String function, String script) { + if (scriptCallbacks == null) scriptCallbacks = new HashMap<>(); + + scriptCallbacks.put(function, script); + } + + private String getWrappedEventString(int event) { + return new String(new byte[]{(byte) event}, StandardCharsets.UTF_8); + } + + @Override + public byte[] encode() { + NetBuffer data = NetBuffer.allocate(getLength()); + data.addInt(id); + data.addAscii(suiScript); + data.addList(components); + data.addLong(rangeObjId); + data.addFloat(maxDistance); + data.addLong(0); // Window Location? + data.addInt(0); + return data.array(); + } + + @Override + public void decode(NetBuffer data) { + id = data.getInt(); + suiScript = data.getAscii(); + components = data.getList(SuiComponent.class); + rangeObjId = data.getLong(); + maxDistance = data.getFloat(); + // unk long + // unk int + } + + @Override + public int getLength() { + int listSize = 0; + for (SuiComponent component : components) { + listSize += component.getLength(); + } + return 34 + suiScript.length() + listSize; + } + +} diff --git a/src/com/projectswg/common/data/sui/SuiComponent.java b/src/com/projectswg/common/data/sui/SuiComponent.java new file mode 100644 index 0000000..92642f8 --- /dev/null +++ b/src/com/projectswg/common/data/sui/SuiComponent.java @@ -0,0 +1,199 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ +package com.projectswg.common.data.sui; + +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + +import com.projectswg.common.debug.Log; +import com.projectswg.common.encoding.Encodable; +import com.projectswg.common.encoding.StringType; +import com.projectswg.common.network.NetBuffer; + +/** + * @author Waverunner + */ +public class SuiComponent implements Encodable { + + private Type type; + private List wideParams; + private List narrowParams; + + public SuiComponent() { + type = Type.NONE; + wideParams = new ArrayList<>(); + narrowParams = new ArrayList<>(); + } + + public SuiComponent(Type type, String widget) { + this.type = type; + this.wideParams = new ArrayList<>(3); + this.narrowParams = new ArrayList<>(3); + + narrowParams.add(widget); + } + + public Type getType() { + return type; + } + public List getNarrowParams() { + return narrowParams; + } + public List getWideParams() { + return wideParams; + } + + /** + * Retrieve the base widget that this component targets + * @return Base widget this component targets + */ + public String getTarget() { + return narrowParams.get(0); + } + + public void addNarrowParam(String param) { + narrowParams.add(param); + } + + public void addWideParam(String param) { + wideParams.add(param); + } + + public List getSubscribedProperties() { + if (type != Type.SUBSCRIBE_TO_EVENT) + return null; + + int size = narrowParams.size(); + if (size < 3) { + Log.w("Tried to get subscribed properties when there are none for target %s", getTarget()); + } else { + List subscribedProperties = new ArrayList<>(); + + for (int i = 3; i < size;) { + String property = narrowParams.get(i++) + "." + narrowParams.get(i++); + subscribedProperties.add(property); + } + + return subscribedProperties; + } + return null; + } + + public String getSubscribeToEventCallback() { + if (type != Type.SUBSCRIBE_TO_EVENT) + return null; + + int size = narrowParams.size(); + if (size < 3) { + Log.w("Tried to get subscribed callback when there is none for target %s", getTarget()); + } else { + + return narrowParams.get(2); + } + return null; + } + + public int getSubscribedToEventType() { + if (type != Type.SUBSCRIBE_TO_EVENT) + return -1; + + int size = narrowParams.size(); + if (size < 3) { + Log.w("Tried to get subscribed event type when there is none for target %s", getTarget()); + } else { + byte[] bytes = narrowParams.get(1).getBytes(StandardCharsets.UTF_8); + if (bytes.length > 1) { + Log.w("Tried to get eventType but narrowparams string byte array length is more than 1"); + return -1; + } + + return bytes[0]; + } + return -1; + } + + @Override + public byte[] encode() { + NetBuffer data = NetBuffer.allocate(getLength()); + data.addByte(type.getValue()); + data.addList(wideParams, StringType.UNICODE); + data.addList(narrowParams, StringType.ASCII); + return data.array(); + } + + @Override + public void decode(NetBuffer data) { + type = Type.valueOf(data.getByte()); + wideParams = data.getList(StringType.UNICODE); + narrowParams = data.getList(StringType.ASCII); + } + + @Override + public int getLength() { + int size = 9; + + for (String param : wideParams) { + size += 4 + (param.length() * 2); + } + for (String param : narrowParams) { + size += 2 + param.length(); + } + + return size; + } + + public enum Type { + NONE(0), + CLEAR_DATA_SOURCE(1), + ADD_CHILD_WIDGET(2), + SET_PROPERTY(3), + ADD_DATA_ITEM(4), + SUBSCRIBE_TO_EVENT(5), + ADD_DATA_SOURCE_CONTAINER(6), + CLEAR_DATA_SOURCE_CONTAINER(7), + ADD_DATA_SOURCE(8); + + private byte value; + + Type(int value) { + this.value = (byte) value; + } + + public byte getValue() { + return value; + } + + public static Type valueOf(byte value) { + for (Type type : Type.values()) { + if (type.getValue() == value) + return type; + } + return NONE; + } + } +} diff --git a/src/com/projectswg/common/data/sui/SuiEvent.java b/src/com/projectswg/common/data/sui/SuiEvent.java new file mode 100644 index 0000000..221b5ab --- /dev/null +++ b/src/com/projectswg/common/data/sui/SuiEvent.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ +package com.projectswg.common.data.sui; + +/** + * Created by Waverunner on 8/14/2015 + */ +public enum SuiEvent { + NONE (0), + BUTTON (1), + CHECKBOX (2), + ENABLE_DISABLE (3), + GENERIC (4), + SLIDER (5), + TAB_PANE (6), + TEXTBOX (7), + VISIBILITY_CHANGED (8), + OK_PRESSED (9), + CANCEL_PRESSED (10); + + private int value; + + SuiEvent(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + public static SuiEvent valueOf(int value) { + switch(value) { + case 0: return NONE; + case 1: return BUTTON; + case 2: return CHECKBOX; + case 3: return ENABLE_DISABLE; + case 4: return GENERIC; + case 5: return SLIDER; + case 6: return TAB_PANE; + case 7: return TEXTBOX; + case 8: return VISIBILITY_CHANGED; + case 9: return OK_PRESSED; + case 10: return CANCEL_PRESSED; + default: return NONE; + } + } +} diff --git a/src/com/projectswg/common/data/swgfile/visitors/DatatableData.java b/src/com/projectswg/common/data/swgfile/visitors/DatatableData.java index a874ba6..1f59594 100644 --- a/src/com/projectswg/common/data/swgfile/visitors/DatatableData.java +++ b/src/com/projectswg/common/data/swgfile/visitors/DatatableData.java @@ -31,10 +31,10 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import com.projectswg.common.debug.Log; import com.projectswg.common.data.swgfile.ClientData; import com.projectswg.common.data.swgfile.IffNode; import com.projectswg.common.data.swgfile.SWGFile; +import com.projectswg.common.debug.Log; public class DatatableData extends ClientData { diff --git a/src/com/projectswg/common/data/swgfile/visitors/WorldSnapshotData.java b/src/com/projectswg/common/data/swgfile/visitors/WorldSnapshotData.java index 8bee7f4..600f487 100644 --- a/src/com/projectswg/common/data/swgfile/visitors/WorldSnapshotData.java +++ b/src/com/projectswg/common/data/swgfile/visitors/WorldSnapshotData.java @@ -121,14 +121,15 @@ public class WorldSnapshotData extends ClientData { objectTemplateNameIndex = chunk.readInt(); cellIndex = chunk.readInt(); - location = new Location(); - location.setOrientationW(chunk.readFloat()); - location.setOrientationX(chunk.readFloat()); - location.setOrientationY(chunk.readFloat()); - location.setOrientationZ(chunk.readFloat()); - location.setX(chunk.readFloat()); - location.setY(chunk.readFloat()); - location.setZ(chunk.readFloat()); + location = Location.builder() + .setOrientationW(chunk.readFloat()) + .setOrientationX(chunk.readFloat()) + .setOrientationY(chunk.readFloat()) + .setOrientationZ(chunk.readFloat()) + .setX(chunk.readFloat()) + .setY(chunk.readFloat()) + .setZ(chunk.readFloat()) + .build(); radius = chunk.readFloat(); portalLayoutCrc = chunk.readUInt(); diff --git a/src/com/projectswg/common/data/swgfile/visitors/appearance/AppearanceTemplateList.java b/src/com/projectswg/common/data/swgfile/visitors/appearance/AppearanceTemplateList.java index b673d6c..011b58a 100644 --- a/src/com/projectswg/common/data/swgfile/visitors/appearance/AppearanceTemplateList.java +++ b/src/com/projectswg/common/data/swgfile/visitors/appearance/AppearanceTemplateList.java @@ -29,13 +29,13 @@ package com.projectswg.common.data.swgfile.visitors.appearance; import java.util.List; -import com.projectswg.common.debug.Log; import com.projectswg.common.data.swgfile.ClientData; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.IffNode; import com.projectswg.common.data.swgfile.SWGFile; import com.projectswg.common.data.swgfile.visitors.appearance.render.RenderData; import com.projectswg.common.data.swgfile.visitors.appearance.render.RenderableData; +import com.projectswg.common.debug.Log; public class AppearanceTemplateList extends ClientData implements RenderableData { diff --git a/src/com/projectswg/common/data/swgfile/visitors/appearance/DetailedAppearanceTemplateData.java b/src/com/projectswg/common/data/swgfile/visitors/appearance/DetailedAppearanceTemplateData.java index 04d93bd..c4eb067 100644 --- a/src/com/projectswg/common/data/swgfile/visitors/appearance/DetailedAppearanceTemplateData.java +++ b/src/com/projectswg/common/data/swgfile/visitors/appearance/DetailedAppearanceTemplateData.java @@ -30,7 +30,6 @@ package com.projectswg.common.data.swgfile.visitors.appearance; import java.util.ArrayList; import java.util.List; -import com.projectswg.common.debug.Log; import com.projectswg.common.data.swgfile.ClientData; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.IffNode; @@ -38,6 +37,7 @@ import com.projectswg.common.data.swgfile.SWGFile; import com.projectswg.common.data.swgfile.visitors.appearance.render.RenderData; import com.projectswg.common.data.swgfile.visitors.appearance.render.RenderableData; import com.projectswg.common.data.swgfile.visitors.appearance.render.RenderableDataChild; +import com.projectswg.common.debug.Log; public class DetailedAppearanceTemplateData extends ClientData implements RenderableData { diff --git a/src/com/projectswg/common/data/swgfile/visitors/appearance/SkeletalMeshGeneratorTemplateData.java b/src/com/projectswg/common/data/swgfile/visitors/appearance/SkeletalMeshGeneratorTemplateData.java index 530d118..62a9dc4 100644 --- a/src/com/projectswg/common/data/swgfile/visitors/appearance/SkeletalMeshGeneratorTemplateData.java +++ b/src/com/projectswg/common/data/swgfile/visitors/appearance/SkeletalMeshGeneratorTemplateData.java @@ -32,13 +32,13 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javafx.geometry.Point3D; - import com.projectswg.common.data.swgfile.ClientData; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.IffNode; import com.projectswg.common.data.swgfile.SWGFile; +import javafx.geometry.Point3D; + public class SkeletalMeshGeneratorTemplateData extends ClientData { private final Map skeletonTemplateNames; diff --git a/src/com/projectswg/common/debug/log_wrapper/FileLogWrapper.java b/src/com/projectswg/common/debug/log_wrapper/FileLogWrapper.java index c762927..2869a5b 100644 --- a/src/com/projectswg/common/debug/log_wrapper/FileLogWrapper.java +++ b/src/com/projectswg/common/debug/log_wrapper/FileLogWrapper.java @@ -7,8 +7,8 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; -import com.projectswg.common.debug.LogWrapper; import com.projectswg.common.debug.Log.LogLevel; +import com.projectswg.common.debug.LogWrapper; public class FileLogWrapper implements LogWrapper { diff --git a/src/com/projectswg/common/encoding/Encoder.java b/src/com/projectswg/common/encoding/Encoder.java index ffff290..eb1263c 100644 --- a/src/com/projectswg/common/encoding/Encoder.java +++ b/src/com/projectswg/common/encoding/Encoder.java @@ -31,7 +31,6 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.Charset; - import com.projectswg.common.debug.Log; public class Encoder { diff --git a/src/com/projectswg/common/javafx/FXMLUtilities.java b/src/com/projectswg/common/javafx/FXMLUtilities.java deleted file mode 100644 index 9e32cd0..0000000 --- a/src/com/projectswg/common/javafx/FXMLUtilities.java +++ /dev/null @@ -1,125 +0,0 @@ -/*********************************************************************************** -* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * -* * -* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * -* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * -* Our goal is to create an emulator which will provide a server for players to * -* continue playing a game similar to the one they used to play. We are basing * -* it on the final publish of the game prior to end-game events. * -* * -* This file is part of Holocore. * -* * -* -------------------------------------------------------------------------------- * -* * -* Holocore is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Affero General Public License as * -* published by the Free Software Foundation, either version 3 of the * -* License, or (at your option) any later version. * -* * -* Holocore is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Affero General Public License for more details. * -* * -* You should have received a copy of the GNU Affero General Public License * -* along with Holocore. If not, see . * -* * -***********************************************************************************/ -package com.projectswg.common.javafx; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.HashSet; -import java.util.Locale; -import java.util.ResourceBundle; -import java.util.Set; - -import com.projectswg.common.debug.Log; - -import javafx.fxml.FXMLLoader; - -public class FXMLUtilities { - - private static final Set CONTROLLERS = new HashSet<>(); - - public static void terminate() { - synchronized (CONTROLLERS) { - Log.i("Terminating FXML controllers"); - for (FXMLController controller : CONTROLLERS) { - controller.terminate(); - } - CONTROLLERS.clear(); - } - } - - public static ResourceBundle getResourceBundle(Locale locale) { - return ResourceBundle.getBundle("bundles.strings.strings", locale); - } - - public static void onFxmlLoaded(FXMLController controller) { - synchronized (CONTROLLERS) { - CONTROLLERS.add(controller); - } - } - - public static FXMLController loadFxml(String fxml, Locale locale) { - try { - File file = ResourceUtilities.getResource("fxml/" + fxml); - if (file == null || !file.isFile()) { - Log.e("Unable to load fxml - doesn't exist: %s", file); - return null; - } - Log.i("Loading fxml: %s", file); - FXMLLoader fxmlLoader = new FXMLLoader(file.toURI().toURL()); - return processFxml(fxmlLoader, locale); - } catch (IOException e) { - Log.e("Error loading fmxl: %s", fxml); - Log.e(e); - return null; - } - } - - /** - * Loads the FXML through the Class getResource implementation - - * @param fxml - * @param locale - * @return - */ - public static FXMLController loadFxmlAsClassResource(String fxml, Locale locale) { - try { - Log.i("Loading fxml: %s", fxml); - URL url = ResourceUtilities.getClassResource(fxml); - if (url == null || !canOpen(url)) { - Log.e("Unable to load fxml - doesn't exist: %s", fxml); - return null; - } - FXMLLoader fxmlLoader = new FXMLLoader(url); - return processFxml(fxmlLoader, locale); - } catch (IOException e) { - Log.e("Error loading fmxl: %s", fxml); - Log.e(e); - return null; - } - } - - private static FXMLController processFxml(FXMLLoader fxmlLoader, Locale locale) throws IOException { - fxmlLoader.setResources(getResourceBundle(locale)); - fxmlLoader.load(); - onFxmlLoaded(fxmlLoader.getController()); - synchronized (CONTROLLERS) { - CONTROLLERS.add(fxmlLoader.getController()); - } - return fxmlLoader.getController(); - } - - private static boolean canOpen(URL url) { - try { - url.openStream().close(); - return true; - } catch (IOException e) { - return false; - } - } - -} diff --git a/src/com/projectswg/common/network/packets/PacketType.java b/src/com/projectswg/common/network/packets/PacketType.java new file mode 100644 index 0000000..00148eb --- /dev/null +++ b/src/com/projectswg/common/network/packets/PacketType.java @@ -0,0 +1,381 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets; + +import com.projectswg.common.data.EnumLookup; +import com.projectswg.common.debug.Log; +import com.projectswg.common.network.packets.swg.ErrorMessage; +import com.projectswg.common.network.packets.swg.ServerUnixEpochTime; +import com.projectswg.common.network.packets.swg.admin.AdminShutdownServer; +import com.projectswg.common.network.packets.swg.holo.HoloConnectionStarted; +import com.projectswg.common.network.packets.swg.holo.HoloConnectionStopped; +import com.projectswg.common.network.packets.swg.holo.HoloSetProtocolVersion; +import com.projectswg.common.network.packets.swg.login.AccountFeatureBits; +import com.projectswg.common.network.packets.swg.login.CharacterCreationDisabled; +import com.projectswg.common.network.packets.swg.login.ClientIdMsg; +import com.projectswg.common.network.packets.swg.login.ClientPermissionsMessage; +import com.projectswg.common.network.packets.swg.login.ConnectionServerLagResponse; +import com.projectswg.common.network.packets.swg.login.EnumerateCharacterId; +import com.projectswg.common.network.packets.swg.login.LoginClientId; +import com.projectswg.common.network.packets.swg.login.LoginClientToken; +import com.projectswg.common.network.packets.swg.login.LoginClusterStatus; +import com.projectswg.common.network.packets.swg.login.LoginEnumCluster; +import com.projectswg.common.network.packets.swg.login.LoginIncorrectClientId; +import com.projectswg.common.network.packets.swg.login.OfflineServersMessage; +import com.projectswg.common.network.packets.swg.login.RequestExtendedClusters; +import com.projectswg.common.network.packets.swg.login.ServerId; +import com.projectswg.common.network.packets.swg.login.ServerString; +import com.projectswg.common.network.packets.swg.login.StationIdHasJediSlot; +import com.projectswg.common.network.packets.swg.login.creation.ClientCreateCharacter; +import com.projectswg.common.network.packets.swg.login.creation.ClientVerifyAndLockNameRequest; +import com.projectswg.common.network.packets.swg.login.creation.ClientVerifyAndLockNameResponse; +import com.projectswg.common.network.packets.swg.login.creation.CreateCharacterFailure; +import com.projectswg.common.network.packets.swg.login.creation.CreateCharacterSuccess; +import com.projectswg.common.network.packets.swg.login.creation.DeleteCharacterRequest; +import com.projectswg.common.network.packets.swg.login.creation.DeleteCharacterResponse; +import com.projectswg.common.network.packets.swg.login.creation.RandomNameRequest; +import com.projectswg.common.network.packets.swg.login.creation.RandomNameResponse; +import com.projectswg.common.network.packets.swg.zone.ClientOpenContainerMessage; +import com.projectswg.common.network.packets.swg.zone.CmdSceneReady; +import com.projectswg.common.network.packets.swg.zone.ConnectPlayerResponseMessage; +import com.projectswg.common.network.packets.swg.zone.EnterTicketPurchaseModeMessage; +import com.projectswg.common.network.packets.swg.zone.ExpertiseRequestMessage; +import com.projectswg.common.network.packets.swg.zone.GalaxyLoopTimesResponse; +import com.projectswg.common.network.packets.swg.zone.GameServerLagResponse; +import com.projectswg.common.network.packets.swg.zone.HeartBeat; +import com.projectswg.common.network.packets.swg.zone.LagRequest; +import com.projectswg.common.network.packets.swg.zone.ObjectMenuSelect; +import com.projectswg.common.network.packets.swg.zone.ParametersMessage; +import com.projectswg.common.network.packets.swg.zone.PlanetTravelPointListRequest; +import com.projectswg.common.network.packets.swg.zone.PlanetTravelPointListResponse; +import com.projectswg.common.network.packets.swg.zone.PlayClientEffectObjectMessage; +import com.projectswg.common.network.packets.swg.zone.PlayMusicMessage; +import com.projectswg.common.network.packets.swg.zone.RequestGalaxyLoopTimes; +import com.projectswg.common.network.packets.swg.zone.SceneCreateObjectByCrc; +import com.projectswg.common.network.packets.swg.zone.SceneDestroyObject; +import com.projectswg.common.network.packets.swg.zone.SceneEndBaselines; +import com.projectswg.common.network.packets.swg.zone.ServerNowEpochTime; +import com.projectswg.common.network.packets.swg.zone.ServerTimeMessage; +import com.projectswg.common.network.packets.swg.zone.ServerWeatherMessage; +import com.projectswg.common.network.packets.swg.zone.SetWaypointColor; +import com.projectswg.common.network.packets.swg.zone.ShowBackpack; +import com.projectswg.common.network.packets.swg.zone.ShowHelmet; +import com.projectswg.common.network.packets.swg.zone.StopClientEffectObjectByLabelMessage; +import com.projectswg.common.network.packets.swg.zone.UpdateContainmentMessage; +import com.projectswg.common.network.packets.swg.zone.UpdatePostureMessage; +import com.projectswg.common.network.packets.swg.zone.UpdatePvpStatusMessage; +import com.projectswg.common.network.packets.swg.zone.UpdateTransformMessage; +import com.projectswg.common.network.packets.swg.zone.UpdateTransformWithParentMessage; +import com.projectswg.common.network.packets.swg.zone.auction.AuctionQueryHeadersMessage; +import com.projectswg.common.network.packets.swg.zone.auction.AuctionQueryHeadersResponseMessage; +import com.projectswg.common.network.packets.swg.zone.auction.CancelLiveAuctionMessage; +import com.projectswg.common.network.packets.swg.zone.auction.CancelLiveAuctionResponseMessage; +import com.projectswg.common.network.packets.swg.zone.auction.CommoditiesItemTypeListRequest; +import com.projectswg.common.network.packets.swg.zone.auction.CommoditiesItemTypeListResponse; +import com.projectswg.common.network.packets.swg.zone.auction.GetAuctionDetails; +import com.projectswg.common.network.packets.swg.zone.auction.GetAuctionDetailsResponse; +import com.projectswg.common.network.packets.swg.zone.auction.IsVendorOwnerMessage; +import com.projectswg.common.network.packets.swg.zone.auction.IsVendorOwnerResponseMessage; +import com.projectswg.common.network.packets.swg.zone.auction.RetrieveAuctionItemMessage; +import com.projectswg.common.network.packets.swg.zone.auction.RetrieveAuctionItemResponseMessage; +import com.projectswg.common.network.packets.swg.zone.baselines.Baseline; +import com.projectswg.common.network.packets.swg.zone.building.UpdateCellPermissionMessage; +import com.projectswg.common.network.packets.swg.zone.chat.ChatAddModeratorToRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatBanAvatarFromRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatCreateRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatDeletePersistentMessage; +import com.projectswg.common.network.packets.swg.zone.chat.ChatDestroyRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatEnterRoomById; +import com.projectswg.common.network.packets.swg.zone.chat.ChatFriendsListUpdate; +import com.projectswg.common.network.packets.swg.zone.chat.ChatIgnoreList; +import com.projectswg.common.network.packets.swg.zone.chat.ChatInstantMessageToCharacter; +import com.projectswg.common.network.packets.swg.zone.chat.ChatInstantMessageToClient; +import com.projectswg.common.network.packets.swg.zone.chat.ChatInviteAvatarToRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatKickAvatarFromRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatOnConnectAvatar; +import com.projectswg.common.network.packets.swg.zone.chat.ChatOnCreateRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatOnDestroyRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatOnEnteredRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatOnLeaveRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatOnReceiveRoomInvitation; +import com.projectswg.common.network.packets.swg.zone.chat.ChatOnSendInstantMessage; +import com.projectswg.common.network.packets.swg.zone.chat.ChatOnSendRoomMessage; +import com.projectswg.common.network.packets.swg.zone.chat.ChatPersistentMessageToClient; +import com.projectswg.common.network.packets.swg.zone.chat.ChatPersistentMessageToServer; +import com.projectswg.common.network.packets.swg.zone.chat.ChatQueryRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatRemoveAvatarFromRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatRemoveModeratorFromRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatRequestPersistentMessage; +import com.projectswg.common.network.packets.swg.zone.chat.ChatRequestRoomList; +import com.projectswg.common.network.packets.swg.zone.chat.ChatRoomMessage; +import com.projectswg.common.network.packets.swg.zone.chat.ChatSendToRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatSystemMessage; +import com.projectswg.common.network.packets.swg.zone.chat.ChatUnbanAvatarFromRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ChatUninviteFromRoom; +import com.projectswg.common.network.packets.swg.zone.chat.ConGenericMessage; +import com.projectswg.common.network.packets.swg.zone.chat.VoiceChatStatus; +import com.projectswg.common.network.packets.swg.zone.combat.GrantCommandMessage; +import com.projectswg.common.network.packets.swg.zone.deltas.DeltasMessage; +import com.projectswg.common.network.packets.swg.zone.insertion.ChatRoomList; +import com.projectswg.common.network.packets.swg.zone.insertion.ChatServerStatus; +import com.projectswg.common.network.packets.swg.zone.insertion.CmdStartScene; +import com.projectswg.common.network.packets.swg.zone.insertion.ConnectPlayerMessage; +import com.projectswg.common.network.packets.swg.zone.insertion.SelectCharacter; +import com.projectswg.common.network.packets.swg.zone.object_controller.ChangeRoleIconChoice; +import com.projectswg.common.network.packets.swg.zone.object_controller.ObjectController; +import com.projectswg.common.network.packets.swg.zone.object_controller.ShowLootBox; +import com.projectswg.common.network.packets.swg.zone.server_ui.SuiCreatePageMessage; +import com.projectswg.common.network.packets.swg.zone.server_ui.SuiEventNotification; +import com.projectswg.common.network.packets.swg.zone.spatial.AttributeListMessage; +import com.projectswg.common.network.packets.swg.zone.spatial.GetMapLocationsMessage; +import com.projectswg.common.network.packets.swg.zone.spatial.GetMapLocationsResponseMessage; +import com.projectswg.common.network.packets.swg.zone.spatial.NewTicketActivityResponseMessage; +import com.projectswg.common.network.packets.swg.zone.trade.AbortTradeMessage; +import com.projectswg.common.network.packets.swg.zone.trade.AcceptTransactionMessage; +import com.projectswg.common.network.packets.swg.zone.trade.AddItemFailedMessage; +import com.projectswg.common.network.packets.swg.zone.trade.AddItemMessage; +import com.projectswg.common.network.packets.swg.zone.trade.BeginTradeMessage; +import com.projectswg.common.network.packets.swg.zone.trade.BeginVerificationMessage; +import com.projectswg.common.network.packets.swg.zone.trade.DenyTradeMessage; +import com.projectswg.common.network.packets.swg.zone.trade.GiveMoneyMessage; +import com.projectswg.common.network.packets.swg.zone.trade.RemoveItemMessage; +import com.projectswg.common.network.packets.swg.zone.trade.TradeCompleteMessage; +import com.projectswg.common.network.packets.swg.zone.trade.UnAcceptTransactionMessage; +import com.projectswg.common.network.packets.swg.zone.trade.VerifyTradeMessage; + +public enum PacketType { + + // Holocore + HOLO_SET_PROTOCOL_VERSION (HoloSetProtocolVersion.CRC, HoloSetProtocolVersion.class), + HOLO_CONNECTION_STARTED (HoloConnectionStarted.CRC, HoloConnectionStarted.class), + HOLO_CONNECTION_STOPPED (HoloConnectionStopped.CRC, HoloConnectionStopped.class), + + // Admin + ADMIN_SHUTDOWN_SERVER (AdminShutdownServer.CRC, AdminShutdownServer.class), + + // Both + SERVER_UNIX_EPOCH_TIME (ServerUnixEpochTime.CRC, ServerUnixEpochTime.class), + SERVER_ID (ServerId.CRC, ServerId.class), + SERVER_STRING (ServerString.CRC, ServerString.class), + LAG_REQUEST (LagRequest.CRC, LagRequest.class), + + // Login + CLIENT_ID_MSG (ClientIdMsg.CRC, ClientIdMsg.class), + ERROR_MESSAGE (ErrorMessage.CRC, ErrorMessage.class), + ACCOUNT_FEATURE_BITS (AccountFeatureBits.CRC, AccountFeatureBits.class), + CLIENT_PERMISSIONS_MESSAGE (ClientPermissionsMessage.CRC, ClientPermissionsMessage.class), + REQUEST_EXTENDED_CLUSTERS (RequestExtendedClusters.CRC, RequestExtendedClusters.class), + OFFLINE_SERVERS_MESSAGE (OfflineServersMessage.CRC, OfflineServersMessage.class), + SERVER_NOW_EPOCH_TIME (ServerNowEpochTime.CRC, ServerNowEpochTime.class), + GAME_SERVER_LAG_RESPONSE (GameServerLagResponse.CRC, GameServerLagResponse.class), + + // Post-Login + LOGIN_CLIENT_ID (LoginClientId.CRC, LoginClientId.class), + LOGIN_INCORRECT_CLIENT_ID (LoginIncorrectClientId.CRC, LoginIncorrectClientId.class), + LOGIN_CLIENT_TOKEN (LoginClientToken.CRC, LoginClientToken.class), + LOGIN_ENUM_CLUSTER (LoginEnumCluster.CRC, LoginEnumCluster.class), + LOGIN_CLUSTER_STATUS (LoginClusterStatus.CRC, LoginClusterStatus.class), + ENUMERATE_CHARACTER_ID (EnumerateCharacterId.CRC, EnumerateCharacterId.class), + STATION_ID_HAS_JEDI_SLOT (StationIdHasJediSlot.CRC, StationIdHasJediSlot.class), + CHARACTER_CREATION_DISABLED (CharacterCreationDisabled.CRC, CharacterCreationDisabled.class), + + // Character Creation + CLIENT_CREATE_CHARACTER (ClientCreateCharacter.CRC, ClientCreateCharacter.class), + CREATE_CHARACTER_SUCCESS (CreateCharacterSuccess.CRC, CreateCharacterSuccess.class), + CREATE_CHARACTER_FAILURE (CreateCharacterFailure.CRC, CreateCharacterFailure.class), + APPROVE_NAME_REQUEST (ClientVerifyAndLockNameRequest.CRC, ClientVerifyAndLockNameRequest.class), + APPROVE_NAME_RESPONSE (ClientVerifyAndLockNameResponse.CRC, ClientVerifyAndLockNameResponse.class), + RANDOM_NAME_REQUEST (RandomNameRequest.CRC, RandomNameRequest.class), + RANDOM_NAME_RESPONSE (RandomNameResponse.CRC, RandomNameResponse.class), + + // Character Deletion + DELETE_CHARACTER_RESPONSE (DeleteCharacterResponse.CRC, DeleteCharacterResponse.class), + DELETE_CHARACTER_REQUEST (DeleteCharacterRequest.CRC, DeleteCharacterRequest.class), + + // Zone + CONNECTION_SERVER_LAG_RESPONSE (ConnectionServerLagResponse.CRC, ConnectionServerLagResponse.class), + SELECT_CHARACTER (SelectCharacter.CRC, SelectCharacter.class), + CMD_SCENE_READY (CmdSceneReady.CRC, CmdSceneReady.class), + CMD_START_SCENE (CmdStartScene.CRC, CmdStartScene.class), + HEART_BEAT_MESSAGE (HeartBeat.CRC, HeartBeat.class), + OBJECT_CONTROLLER (ObjectController.CRC, ObjectController.class), + BASELINE (Baseline.CRC, Baseline.class), + CONNECT_PLAYER_MESSAGE (ConnectPlayerMessage.CRC, ConnectPlayerMessage.class), + CONNECT_PLAYER_RESPONSE_MESSAGE (ConnectPlayerResponseMessage.CRC, ConnectPlayerResponseMessage.class), + GALAXY_LOOP_TIMES_REQUEST (RequestGalaxyLoopTimes.CRC, RequestGalaxyLoopTimes.class), + GALAXY_LOOP_TIMES_RESPONSE (GalaxyLoopTimesResponse.CRC, GalaxyLoopTimesResponse.class), + PARAMETERS_MESSAGE (ParametersMessage.CRC, ParametersMessage.class), + DELTA (DeltasMessage.CRC, DeltasMessage.class), + SERVER_TIME_MESSAGE (ServerTimeMessage.CRC, ServerTimeMessage.class), + SET_WAYPOINT_COLOR (SetWaypointColor.CRC, SetWaypointColor.class), + SHOW_BACKPACK (ShowBackpack.CRC, ShowBackpack.class), + SHOW_HELMET (ShowHelmet.CRC, ShowHelmet.class), + SERVER_WEATHER_MESSAGE (ServerWeatherMessage.CRC, ServerWeatherMessage.class), + PLAY_MUSIC_MESSAGE (PlayMusicMessage.CRC, PlayMusicMessage.class), + PLAY_CLIENT_EFFECT_OBJECT_MESSAGE (PlayClientEffectObjectMessage.CRC, PlayClientEffectObjectMessage.class), + STOP_CLIENT_EFFECT_OBJECT_BY_LABEL (StopClientEffectObjectByLabelMessage.CRC, StopClientEffectObjectByLabelMessage.class), + EXPERTISE_REQUEST_MESSAGE (ExpertiseRequestMessage.CRC, ExpertiseRequestMessage.class), + CHANGE_ROLE_ICON_CHOICE (ChangeRoleIconChoice.CRC, ChangeRoleIconChoice.class), + SHOW_LOOT_BOX (ShowLootBox.CRC, ShowLootBox.class), + + // Chat + CHAT_CREATE_ROOM (ChatCreateRoom.CRC, ChatCreateRoom.class), + CHAT_DESTROY_ROOM (ChatDestroyRoom.CRC, ChatDestroyRoom.class), + CHAT_ON_CREATE_ROOM (ChatOnCreateRoom.CRC, ChatOnCreateRoom.class), + CHAT_FRIENDS_LIST_UPDATE (ChatFriendsListUpdate.CRC, ChatFriendsListUpdate.class), + CHAT_IGNORE_LIST (ChatIgnoreList.CRC, ChatIgnoreList.class), + CHAT_INSTANT_MESSAGE_TO_CLIENT (ChatInstantMessageToClient.CRC, ChatInstantMessageToClient.class), + CHAT_INSTANT_MESSAGE_TO_CHARACTER (ChatInstantMessageToCharacter.CRC, ChatInstantMessageToCharacter.class), + CHAT_ON_CONNECT_AVATAR (ChatOnConnectAvatar.CRC, ChatOnConnectAvatar.class), + CHAT_ON_DESTROY_ROOM (ChatOnDestroyRoom.CRC, ChatOnDestroyRoom.class), + CHAT_ON_ENTERED_ROOM (ChatOnEnteredRoom.CRC, ChatOnEnteredRoom.class), + CHAT_ON_LEAVE_ROOM (ChatOnLeaveRoom.CRC, ChatOnLeaveRoom.class), + CHAT_ON_RECEIVE_ROOM_INVITATION (ChatOnReceiveRoomInvitation.CRC, ChatOnReceiveRoomInvitation.class), + CHAT_ON_SEND_INSTANT_MESSAGE (ChatOnSendInstantMessage.CRC, ChatOnSendInstantMessage.class), + CHAT_ON_SEND_ROOM_MESSAGE (ChatOnSendRoomMessage.CRC, ChatOnSendRoomMessage.class), + CHAT_PERSISTENT_MESSAGE_TO_CLIENT (ChatPersistentMessageToClient.CRC, ChatPersistentMessageToClient.class), + CHAT_PERSISTENT_MESSAGE_TO_SERVER (ChatPersistentMessageToServer.CRC, ChatPersistentMessageToServer.class), + CHAT_DELETE_PERSISTENT_MESSAGE (ChatDeletePersistentMessage.CRC, ChatDeletePersistentMessage.class), + CHAT_REQUEST_PERSISTENT_MESSAGE (ChatRequestPersistentMessage.CRC, ChatRequestPersistentMessage.class), + CHAT_REQUEST_ROOM_LIST (ChatRequestRoomList.CRC, ChatRequestRoomList.class), + CHAT_ENTER_ROOM_BY_ID (ChatEnterRoomById.CRC, ChatEnterRoomById.class), + CHAT_QUERY_ROOM (ChatQueryRoom.CRC, ChatQueryRoom.class), + CHAT_ROOM_LIST (ChatRoomList.CRC, ChatRoomList.class), + CHAT_ROOM_MESSAGE (ChatRoomMessage.CRC, ChatRoomMessage.class), + CHAT_SEND_TO_ROOM (ChatSendToRoom.CRC, ChatSendToRoom.class), + CHAT_REMOVE_AVATAR_FROM_ROOM (ChatRemoveAvatarFromRoom.CRC, ChatRemoveAvatarFromRoom.class), + CHAT_SERVER_STATUS (ChatServerStatus.CRC, ChatServerStatus.class), + CHAT_SYSTEM_MESSAGE (ChatSystemMessage.CRC, ChatSystemMessage.class), + CHAT_INVITE_AVATAR_TO_ROOM (ChatInviteAvatarToRoom.CRC, ChatInviteAvatarToRoom.class), + CHAT_UNINVITE_FROM_ROOM (ChatUninviteFromRoom.CRC, ChatUninviteFromRoom.class), + CHAT_KICK_AVATAR_FROM_ROOM (ChatKickAvatarFromRoom.CRC, ChatKickAvatarFromRoom.class), + CHAT_BAN_AVATAR_FROM_ROOM (ChatBanAvatarFromRoom.CRC, ChatBanAvatarFromRoom.class), + CHAT_UNBAN_AVATAR_FROM_ROOM (ChatUnbanAvatarFromRoom.CRC, ChatUnbanAvatarFromRoom.class), + CHAT_ADD_MODERATOR_TO_ROOM (ChatAddModeratorToRoom.CRC, ChatAddModeratorToRoom.class), + CHAT_REMOVE_MODERATOR_FROM_ROOM (ChatRemoveModeratorFromRoom.CRC, ChatRemoveModeratorFromRoom.class), + CON_GENERIC_MESSAGE (ConGenericMessage.CRC, ConGenericMessage.class), + VOICE_CHAT_STATUS (VoiceChatStatus.CRC, VoiceChatStatus.class), + + // Scene + SCENE_END_BASELINES (SceneEndBaselines.CRC, SceneEndBaselines.class), + SCENE_CREATE_OBJECT_BY_CRC (SceneCreateObjectByCrc.CRC, SceneCreateObjectByCrc.class), + SCENE_DESTROY_OBJECT (SceneDestroyObject.CRC, SceneDestroyObject.class), + UPDATE_CONTAINMENT_MESSAGE (UpdateContainmentMessage.CRC, UpdateContainmentMessage.class), + UPDATE_CELL_PERMISSIONS_MESSAGE (UpdateCellPermissionMessage.CRC, UpdateCellPermissionMessage.class), + GET_MAP_LOCATIONS_MESSAGE (GetMapLocationsMessage.CRC, GetMapLocationsMessage.class), + GET_MAP_LOCATIONS_RESPONSE_MESSAGE (GetMapLocationsResponseMessage.CRC, GetMapLocationsResponseMessage.class), + + // Spatial + UPDATE_POSTURE_MESSAGE (UpdatePostureMessage.CRC, UpdatePostureMessage.class), + UPDATE_TRANSFORMS_MESSAGE (UpdateTransformMessage.CRC, UpdateTransformMessage.class), + UPDATE_TRANSFORM_WITH_PARENT_MESSAGE (UpdateTransformWithParentMessage.CRC, UpdateTransformWithParentMessage.class), + NEW_TICKET_ACTIVITY_RESPONSE_MESSAGE (NewTicketActivityResponseMessage.CRC, NewTicketActivityResponseMessage.class), + ATTRIBUTE_LIST_MESSAGE (AttributeListMessage.CRC, AttributeListMessage.class), + OPENED_CONTAINER_MESSAGE (ClientOpenContainerMessage.CRC, ClientOpenContainerMessage.class), + + // Combat + UPDATE_PVP_STATUS_MESSAGE (UpdatePvpStatusMessage.CRC, UpdatePvpStatusMessage.class), + GRANT_COMMAND_MESSAGE (GrantCommandMessage.CRC, GrantCommandMessage.class), + + // Server UI + OBJECT_MENU_SELECT (ObjectMenuSelect.CRC, ObjectMenuSelect.class), + SUI_CREATE_PAGE_MESSAGE (SuiCreatePageMessage.CRC, SuiCreatePageMessage.class), + SUI_EVENT_NOTIFICATION (SuiEventNotification.CRC, SuiEventNotification.class), + + // Auction + IS_VENDOR_OWNER_RESPONSE_MESSAGE (IsVendorOwnerResponseMessage.CRC, IsVendorOwnerResponseMessage.class), + AUCTION_QUERY_HEADERS_MESSAGE (AuctionQueryHeadersMessage.CRC, AuctionQueryHeadersMessage.class), + GET_AUCTION_DETAILS (GetAuctionDetails.CRC, GetAuctionDetails.class), + GET_AUCTION_DETAILS_RESPONSE (GetAuctionDetailsResponse.CRC, GetAuctionDetailsResponse.class), + CANCEL_LIVE_AUCTION_MESSAGE (CancelLiveAuctionMessage.CRC, CancelLiveAuctionMessage.class), + CANCEL_LIVE_AUCTION_RESPONSE_MESSAGE (CancelLiveAuctionResponseMessage.CRC, CancelLiveAuctionResponseMessage.class), + AUCTION_QUERY_HEADERS_RESPONSE_MESSAGE (AuctionQueryHeadersResponseMessage.CRC, AuctionQueryHeadersResponseMessage.class), + RETRIEVE_AUCTION_ITEM_MESSAGE (RetrieveAuctionItemMessage.CRC, RetrieveAuctionItemMessage.class), + RETRIEVE_AUCTION_ITEM_RESPONSE_MESSAGE (RetrieveAuctionItemResponseMessage.CRC, RetrieveAuctionItemResponseMessage.class), + IS_VENDOR_OWNER_MESSAGE (IsVendorOwnerMessage.CRC, IsVendorOwnerMessage.class), + COMMODITIES_ITEM_TYPE_LIST_REPSONSE (CommoditiesItemTypeListResponse.CRC, CommoditiesItemTypeListResponse.class), + COMMODITIES_ITEM_TYPE_LIST_REQUEST (CommoditiesItemTypeListRequest.CRC, CommoditiesItemTypeListRequest.class), + + // Travel + ENTER_TICKET_PURCHASE_MODE_MESSAGE (EnterTicketPurchaseModeMessage.CRC, EnterTicketPurchaseModeMessage.class), + PLANET_TRAVEL_POINT_LIST_REQUEST (PlanetTravelPointListRequest.CRC, PlanetTravelPointListRequest.class), + PLANET_TRAVEL_POINT_LIST_RESPONSE (PlanetTravelPointListResponse.CRC, PlanetTravelPointListResponse.class), + + //Trade + ABORT_TRADE_MESSAGE (AbortTradeMessage.CRC, AbortTradeMessage.class), + ACCEPT_TRANSACTION_MESSAGE (AcceptTransactionMessage.CRC, AcceptTransactionMessage.class), + ADD_ITEM_FAILED_MESSAGE (AddItemFailedMessage.CRC, AddItemFailedMessage.class), + ADD_ITEM_MESSAGE (AddItemMessage.CRC, AddItemMessage.class), + BEGIN_TRADE_MESSAGE (BeginTradeMessage.CRC, BeginTradeMessage.class), + BEGIN_VERIFICATION_MESSAGE (BeginVerificationMessage.CRC, BeginVerificationMessage.class), + DENY_TRADE_MESSAGE (DenyTradeMessage.CRC, DenyTradeMessage.class), + GIVE_MONEY_MESSAGE (GiveMoneyMessage.CRC, GiveMoneyMessage.class), + REMOVE_ITEM_MESSAGE (RemoveItemMessage.CRC, RemoveItemMessage.class), + TRADE_COMPLETE_MESSAGE (TradeCompleteMessage.CRC, TradeCompleteMessage.class), + UNACCEPT_TRANSACTION_MESSAGE (UnAcceptTransactionMessage.CRC, UnAcceptTransactionMessage.class), + VERIFY_TRADE_MESSAGE (VerifyTradeMessage.CRC, VerifyTradeMessage.class), + + UNKNOWN (0xFFFFFFFF, SWGPacket.class); + + private static final EnumLookup LOOKUP = new EnumLookup<>(PacketType.class, PacketType::getCrc); + + private final int crc; + private final Class c; + + PacketType(int crc, Class c) { + this.crc = crc; + this.c = c; + } + + public int getCrc() { + return crc; + } + + public Class getSwgClass() { + return c; + } + + public static PacketType fromCrc(int crc) { + return LOOKUP.getEnum(crc, PacketType.UNKNOWN); + } + + public static SWGPacket getForCrc(int crc) { + PacketType type = LOOKUP.getEnum(crc, PacketType.UNKNOWN); + if (type == UNKNOWN) + return null; + Class c = type.c; + try { + return c.newInstance(); + } catch (Exception e) { + Log.e("Packet: [%08X] %s", crc, c.getName()); + Log.e(e); + } + return null; + } + +} diff --git a/src/com/projectswg/common/network/packets/SOEPacket.java b/src/com/projectswg/common/network/packets/SOEPacket.java new file mode 100644 index 0000000..ebebe70 --- /dev/null +++ b/src/com/projectswg/common/network/packets/SOEPacket.java @@ -0,0 +1,69 @@ +package com.projectswg.common.network.packets; + +import java.net.SocketAddress; +import java.time.Instant; + +import com.projectswg.common.network.NetBuffer; + +public abstract class SOEPacket { + + private SocketAddress address; + private NetBuffer data; + private Instant time; + private int opcode; + + public SOEPacket() { + this.address = null; + this.data = null; + this.time = null; + this.opcode = 0; + } + + public void decode(NetBuffer data) { + data.position(0); + this.data = NetBuffer.allocate(data.limit()); + this.data.addRawArray(data.getArray(this.data.limit())); + + data.position(0); + opcode = data.getNetShort(); + } + + public void encode(NetBuffer data, int opcode) { + data.addNetShort(opcode); + } + + public abstract NetBuffer encode(); + + public SocketAddress getAddress() { + return address; + } + + public NetBuffer getData() { + return data; + } + + public Instant getTime() { + return time; + } + + public int getOpcode() { + return opcode; + } + + public void setAddress(SocketAddress address) { + this.address = address; + } + + public void setData(NetBuffer data) { + this.data = data; + } + + public void setTime(Instant time) { + this.time = time; + } + + public void setOpcode(int opcode) { + this.opcode = opcode; + } + +} diff --git a/src/com/projectswg/common/network/packets/SWGPacket.java b/src/com/projectswg/common/network/packets/SWGPacket.java new file mode 100644 index 0000000..eec62fb --- /dev/null +++ b/src/com/projectswg/common/network/packets/SWGPacket.java @@ -0,0 +1,59 @@ +package com.projectswg.common.network.packets; + +import java.net.SocketAddress; + +import com.projectswg.common.data.CRC; +import com.projectswg.common.debug.Log; +import com.projectswg.common.network.NetBuffer; + +public abstract class SWGPacket { + + private SocketAddress socketAddress; + private PacketType type; + private int crc; + + public SWGPacket() { + this.socketAddress = null; + this.type = PacketType.UNKNOWN; + this.crc = 0; + } + + /** + * Sets the socket address that this packet was sent to or received from. Setting this value after it's received, or before it's sent has no effect + * + * @param socketAddress the socket address + */ + public void setSocketAddress(SocketAddress socketAddress) { + this.socketAddress = socketAddress; + } + + public SocketAddress getSocketAddress() { + return socketAddress; + } + + public int getSWGOpcode() { + return crc; + } + + public PacketType getPacketType() { + return type; + } + + public boolean checkDecode(NetBuffer data, int crc) { + data.getShort(); + this.crc = data.getInt(); + this.type = PacketType.fromCrc(crc); + if (this.crc == crc) + return true; + Log.w("SWG Opcode does not match actual! Expected: 0x%08X Actual: 0x%08X", crc, getSWGOpcode()); + return false; + } + + public abstract void decode(NetBuffer data); + public abstract NetBuffer encode(); + + public static int getCrc(String string) { + return CRC.getCrc(string); + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/ErrorMessage.java b/src/com/projectswg/common/network/packets/swg/ErrorMessage.java new file mode 100644 index 0000000..a642d34 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/ErrorMessage.java @@ -0,0 +1,70 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class ErrorMessage extends SWGPacket { + public static final int CRC = getCrc("ErrorMessage"); + + private String type; + private String message; + private boolean fatal; + + public ErrorMessage() { + + } + + public ErrorMessage(String type, String message, boolean fatal) { + this.type = type; + this.message = message; + this.fatal = fatal; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + type = data.getAscii(); + message = data.getAscii(); + fatal = data.getBoolean(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(11 + type.length() + message.length()); + data.addShort(3); + data.addInt(CRC); + data.addAscii(type); + data.addAscii(message); + data.addBoolean(fatal); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/ServerUnixEpochTime.java b/src/com/projectswg/common/network/packets/swg/ServerUnixEpochTime.java new file mode 100644 index 0000000..283b23d --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/ServerUnixEpochTime.java @@ -0,0 +1,64 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class ServerUnixEpochTime extends SWGPacket { + public static final int CRC = getCrc("ServerUnixEpochTime"); + + private int time = 0; + + public ServerUnixEpochTime() { + + } + + public ServerUnixEpochTime(int time) { + this.time = time; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + time = data.getInt(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10); + data.addShort(2); + data.addInt(CRC); + data.addInt(time); + return data; + } + + public int getTime() { + return time; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/admin/AdminPacket.java b/src/com/projectswg/common/network/packets/swg/admin/AdminPacket.java new file mode 100644 index 0000000..5184c5a --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/admin/AdminPacket.java @@ -0,0 +1,34 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.admin; + +import com.projectswg.common.network.packets.swg.holo.HoloPacket; + +public abstract class AdminPacket extends HoloPacket { + +} diff --git a/src/com/projectswg/common/network/packets/swg/admin/AdminShutdownServer.java b/src/com/projectswg/common/network/packets/swg/admin/AdminShutdownServer.java new file mode 100644 index 0000000..b23bf13 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/admin/AdminShutdownServer.java @@ -0,0 +1,70 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.admin; + +import com.projectswg.common.network.NetBuffer; + +public class AdminShutdownServer extends AdminPacket { + + public static final int CRC = getCrc("AdminShutdownServer"); + + private int shutdownTime; + + public AdminShutdownServer() { + + } + + public AdminShutdownServer(int shutdownTime) { + setShutdownTime(shutdownTime); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + shutdownTime = data.getShort(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(8); + data.addShort(1); + data.addInt(CRC); + data.addShort(shutdownTime); + return data; + } + + public int getShutdownTime() { + return shutdownTime; + } + + public void setShutdownTime(int shutdownTime) { + this.shutdownTime = shutdownTime; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/holo/HoloConnectionStarted.java b/src/com/projectswg/common/network/packets/swg/holo/HoloConnectionStarted.java new file mode 100644 index 0000000..1e59f2a --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/holo/HoloConnectionStarted.java @@ -0,0 +1,54 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.holo; + +import com.projectswg.common.network.NetBuffer; + +public class HoloConnectionStarted extends HoloPacket { + + public static final int CRC = getCrc("HoloConnectionStarted"); + + public HoloConnectionStarted() { + + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(1); + data.addInt(CRC); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/holo/HoloConnectionStopped.java b/src/com/projectswg/common/network/packets/swg/holo/HoloConnectionStopped.java new file mode 100644 index 0000000..c9129f0 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/holo/HoloConnectionStopped.java @@ -0,0 +1,83 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.holo; + +import com.projectswg.common.network.NetBuffer; + +public class HoloConnectionStopped extends HoloPacket { + + public static final int CRC = getCrc("HoloConnectionStopped"); + + private ConnectionStoppedReason reason; + + public HoloConnectionStopped() { + this(ConnectionStoppedReason.UNKNOWN); + } + + public HoloConnectionStopped(ConnectionStoppedReason reason) { + this.reason = reason; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + try { + reason = ConnectionStoppedReason.valueOf(data.getAscii()); + } catch (IllegalArgumentException e) { + reason = ConnectionStoppedReason.UNKNOWN; + } + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(8+reason.name().length()); + data.addShort(1); + data.addInt(CRC); + data.addAscii(reason.name()); + return data; + } + + public void setReason(ConnectionStoppedReason reason) { + this.reason = reason; + } + + public ConnectionStoppedReason getReason() { + return reason; + } + + public static enum ConnectionStoppedReason { + APPLICATION, + INVALID_PROTOCOL, + OTHER_SIDE_TERMINATED, + NETWORK, + SERVER_ERROR, + UNKNOWN + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/holo/HoloPacket.java b/src/com/projectswg/common/network/packets/swg/holo/HoloPacket.java new file mode 100644 index 0000000..dfb9a7f --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/holo/HoloPacket.java @@ -0,0 +1,38 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.holo; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public abstract class HoloPacket extends SWGPacket { + + public abstract void decode(NetBuffer data); + public abstract NetBuffer encode(); + +} diff --git a/src/com/projectswg/common/network/packets/swg/holo/HoloSetProtocolVersion.java b/src/com/projectswg/common/network/packets/swg/holo/HoloSetProtocolVersion.java new file mode 100644 index 0000000..b5f6ad5 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/holo/HoloSetProtocolVersion.java @@ -0,0 +1,70 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.holo; + +import com.projectswg.common.network.NetBuffer; + +public class HoloSetProtocolVersion extends HoloPacket { + + public static final int CRC = getCrc("HoloSetProtocolVersion"); + + private String protocol; + + public HoloSetProtocolVersion() { + this(""); + } + + public HoloSetProtocolVersion(String protocol) { + this.protocol = protocol; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + protocol = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(8 + protocol.length()); + data.addShort(2); + data.addInt(CRC); + data.addAscii(protocol); + return data; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/login/AccountFeatureBits.java b/src/com/projectswg/common/network/packets/swg/login/AccountFeatureBits.java new file mode 100644 index 0000000..ebb7ec7 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/AccountFeatureBits.java @@ -0,0 +1,59 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class AccountFeatureBits extends SWGPacket { + + public static final int CRC = 0x979F0279; + + public AccountFeatureBits() { + + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + // Not sure how to decode this.. still a mystery + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(22); + data.addShort(2); + data.addInt(CRC); + data.addInt(0x025C8231); + data.addInt(1); + data.addInt(6); + data.addInt(0x4EEAC08A); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/login/CharacterCreationDisabled.java b/src/com/projectswg/common/network/packets/swg/login/CharacterCreationDisabled.java new file mode 100644 index 0000000..5eeef9e --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/CharacterCreationDisabled.java @@ -0,0 +1,76 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class CharacterCreationDisabled extends SWGPacket { + + public static final int CRC = 0xF4A15265; + + private String [] serverNames = new String[0]; + + public CharacterCreationDisabled() { + this(new String[0]); + } + + public CharacterCreationDisabled(String [] serverNames) { + this.serverNames = serverNames; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + int listSize = data.getInt(); + serverNames = new String[listSize]; + for (int i = 0; i < listSize; i++) { + serverNames[i] = data.getAscii(); + } + } + + public NetBuffer encode() { + int length = 10; + for (int i = 0; i < serverNames.length; i++) + length += 2 + serverNames[i].length(); + NetBuffer data = NetBuffer.allocate(length); + data.addShort(2); + data.addInt(CRC); + data.addInt(serverNames.length); + for (int i = 0; i < serverNames.length; i++) { + data.addAscii(serverNames[i]); + } + return data; + } + + public String [] getServerNames() { + return serverNames; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/login/ClientIdMsg.java b/src/com/projectswg/common/network/packets/swg/login/ClientIdMsg.java new file mode 100644 index 0000000..fbad207 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/ClientIdMsg.java @@ -0,0 +1,79 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class ClientIdMsg extends SWGPacket { + + public static final int CRC = getCrc("ClientIdMsg"); + + private int gameBitsToClear; + private byte [] sessionToken; + private String version; + + public ClientIdMsg() { + this(0, new byte[0], ""); + } + + public ClientIdMsg(NetBuffer data) { + decode(data); + } + + public ClientIdMsg(int gameBitsToClear, byte [] sessionKey, String version) { + this.gameBitsToClear = gameBitsToClear; + this.sessionToken = sessionKey; + this.version = version; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + gameBitsToClear = data.getInt(); + sessionToken = data.getArrayLarge(); + version = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(16 + sessionToken.length + version.length()); + data.addShort(4); + data.addInt(CRC); + data.addInt(gameBitsToClear); + data.addArrayLarge(sessionToken); + data.addAscii(version); + return data; + } + + public int getGameBitsToClear() { return gameBitsToClear; } + public byte [] getSessionToken() { return sessionToken; } + public String getVersion() { return version; } +} diff --git a/src/com/projectswg/common/network/packets/swg/login/ClientPermissionsMessage.java b/src/com/projectswg/common/network/packets/swg/login/ClientPermissionsMessage.java new file mode 100644 index 0000000..6591431 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/ClientPermissionsMessage.java @@ -0,0 +1,78 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class ClientPermissionsMessage extends SWGPacket { + public static final int CRC = getCrc("ClientPermissionsMessage"); + + private boolean canLogin; + private boolean canCreateRegularCharacter; + private boolean canCreateJediCharacter; + private boolean canSkipTutorial; + + public ClientPermissionsMessage() { + canLogin = true; + canCreateRegularCharacter = true; + canCreateJediCharacter = true; + canSkipTutorial = true; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + canLogin = data.getBoolean(); + canCreateRegularCharacter = data.getBoolean(); + canCreateJediCharacter = data.getBoolean(); + canSkipTutorial = data.getBoolean(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10); + data.addShort(5); + data.addInt(CRC); + data.addBoolean(canLogin); + data.addBoolean(canCreateRegularCharacter); + data.addBoolean(canCreateJediCharacter); + data.addBoolean(canSkipTutorial); + return data; + } + + public void setCanLogin(boolean can) { this.canLogin = can; } + public void setCanCreateRegularCharacter(boolean can) { this.canCreateRegularCharacter = can; } + public void setCanCreateJediCharacter(boolean can) { this.canCreateJediCharacter = can; } + public void setCanSkipTutorial(boolean can) { this.canSkipTutorial = can; } + + public boolean canLogin() { return canLogin; } + public boolean canCreateRegularCharacter() { return canCreateRegularCharacter; } + public boolean canCreateJediCharacter() { return canCreateJediCharacter; } + public boolean canSkipTutorial() { return canSkipTutorial; } +} diff --git a/src/com/projectswg/common/network/packets/swg/login/ConnectionServerLagResponse.java b/src/com/projectswg/common/network/packets/swg/login/ConnectionServerLagResponse.java new file mode 100644 index 0000000..df20086 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/ConnectionServerLagResponse.java @@ -0,0 +1,54 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class ConnectionServerLagResponse extends SWGPacket { + + public static final int CRC = getCrc("ConnectionServerLagResponse"); + + public ConnectionServerLagResponse() { + + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(1); + data.addInt(CRC); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/login/EnumerateCharacterId.java b/src/com/projectswg/common/network/packets/swg/login/EnumerateCharacterId.java new file mode 100644 index 0000000..180ebe1 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/EnumerateCharacterId.java @@ -0,0 +1,137 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import java.util.ArrayList; +import java.util.List; + +import com.projectswg.common.encoding.Encodable; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class EnumerateCharacterId extends SWGPacket { + public static final int CRC = getCrc("EnumerateCharacterId"); + + private List characters; + + public EnumerateCharacterId() { + this.characters = new ArrayList<>(); + } + + public EnumerateCharacterId(List characters) { + this.characters = new ArrayList<>(characters); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + characters = data.getList(SWGCharacter.class); + } + + @Override + public NetBuffer encode() { + int length = 10; + for (SWGCharacter c : characters) { + length += c.getLength(); + } + NetBuffer data = NetBuffer.allocate(length); + data.addShort(2); + data.addInt(CRC); + data.addList(characters); + return data; + } + + public List getCharacters() { + return characters; + } + + public static class SWGCharacter implements Encodable { + + private String name; + private int raceCrc; + private long id; + private int galaxyId; + private int type; + + public SWGCharacter() { + + } + + public SWGCharacter(String name, int raceCrc, long id, int galaxyId, int status) { + this.name = name; + this.raceCrc = raceCrc; + this.id = id; + this.galaxyId = galaxyId; + this.type = status; + } + + public int getLength() { + return 24 + name.length() * 2; + } + + @Override + public void decode(NetBuffer data) { + name = data.getUnicode(); + raceCrc = data.getInt(); + id = data.getLong(); + galaxyId = data.getInt(); + type = data.getInt(); + } + + @Override + public byte [] encode() { + NetBuffer data = NetBuffer.allocate(getLength()); + data.addUnicode(name); + data.addInt(raceCrc); + data.addLong(id); + data.addInt(galaxyId); + data.addInt(type); + return data.array(); + } + + public void setId(long id) { this.id = id; } + public void setName(String name) { this.name = name; } + public void setRaceCrc(int crc) { this.raceCrc = crc; } + public void setGalaxyId(int id) { this.galaxyId = id; } + public void setType(int type) { this.type = type; } + + public long getId() { return id; } + public String getName() { return name; } + public int getRaceCrc() { return raceCrc; } + public int getGalaxyId() { return galaxyId; } + public int getType() { return type; } + + @Override + public String toString() { + return String.format("SWGCharacter[id=%d name=%s race=%d galaxy=%d type=%d", id, name, raceCrc, galaxyId, type); + } + + } +} diff --git a/src/com/projectswg/common/network/packets/swg/login/LoginClientId.java b/src/com/projectswg/common/network/packets/swg/login/LoginClientId.java new file mode 100644 index 0000000..cf5cd4b --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/LoginClientId.java @@ -0,0 +1,79 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class LoginClientId extends SWGPacket { + public static final int CRC = getCrc("LoginClientId"); + + private String username; + private String password; + private String version; + + public LoginClientId() { + this("", "", ""); + } + + public LoginClientId(NetBuffer data) { + decode(data); + } + + public LoginClientId(String username, String password, String version) { + this.username = username; + this.password = password; + this.version = version; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + username = data.getAscii(); + password = data.getAscii(); + version = data.getAscii(); + } + + public NetBuffer encode() { + int length = 6 + 6 + username.length() * 2 + password.length() * 2 + version.length() * 2; + NetBuffer data = NetBuffer.allocate(length); + data.addShort(4); + data.addInt(CRC); + data.addAscii(username); + data.addAscii(password); + data.addAscii(version); + return data; + } + + public String getUsername() { return username; } + public void setUsername(String str) { this.username = str; } + public String getPassword() { return password; } + public void setPassword(String str) { this.password = str; } + public String getVersion() { return version; } +} diff --git a/src/com/projectswg/common/network/packets/swg/login/LoginClientToken.java b/src/com/projectswg/common/network/packets/swg/login/LoginClientToken.java new file mode 100644 index 0000000..8243697 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/LoginClientToken.java @@ -0,0 +1,88 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class LoginClientToken extends SWGPacket { + public static final int CRC = getCrc("LoginClientToken"); + + private byte [] sessionKey; + private int userId; + private String username; + + public LoginClientToken() { + + } + + public LoginClientToken(NetBuffer data) { + decode(data); + } + + public LoginClientToken(byte [] sessionKey, int userId, String username) { + this.sessionKey = sessionKey; + this.userId = userId; + this.username = username; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + sessionKey = data.getArrayLarge(); + userId = data.getInt(); + username = data.getAscii(); + } + + @Override + public NetBuffer encode() { + int length = 16 + sessionKey.length + username.length(); + NetBuffer data = NetBuffer.allocate(length); + data.addShort(4); + data.addInt(CRC); + data.addArrayLarge(sessionKey); + data.addInt(userId); + data.addAscii(username); + return data; + } + + public byte [] getSessionKey() { + return sessionKey; + } + + public int getUserId() { + return userId; + } + + public String getUsername() { + return username; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/login/LoginClusterStatus.java b/src/com/projectswg/common/network/packets/swg/login/LoginClusterStatus.java new file mode 100644 index 0000000..b002c60 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/LoginClusterStatus.java @@ -0,0 +1,104 @@ +/*********************************************************************************** + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import java.time.ZoneOffset; +import java.util.List; +import java.util.Vector; + +import com.projectswg.common.data.encodables.galaxy.Galaxy; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class LoginClusterStatus extends SWGPacket { + + public static final int CRC = getCrc("LoginClusterStatus"); + + private Vector galaxies; + + public LoginClusterStatus() { + galaxies = new Vector(); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + int serverCount = data.getInt(); + for (int i = 0; i < serverCount; i++) { + Galaxy g = new Galaxy(); + g.setId(data.getInt()); + g.setAddress(data.getAscii()); + g.setZonePort(data.getShort()); + g.setPingPort(data.getShort()); + g.setPopulation(data.getInt()); + data.getInt(); // population status + g.setMaxCharacters(data.getInt()); + g.setZoneOffset(ZoneOffset.ofTotalSeconds(data.getInt())); + g.setStatus(data.getInt()); + g.setRecommended(data.getBoolean()); + g.setOnlinePlayerLimit(data.getInt()); + g.setOnlineFreeTrialLimit(data.getInt()); + galaxies.add(g); + } + } + + public NetBuffer encode() { + int length = 10; + for (Galaxy g : galaxies) + length += 39 + g.getAddress().length(); + NetBuffer data = NetBuffer.allocate(length); + data.addShort(2); + data.addInt(CRC); + data.addInt(galaxies.size()); + for (Galaxy g : galaxies) { + data.addInt(g.getId()); + data.addAscii(g.getAddress()); + data.addShort(g.getZonePort()); + data.addShort(g.getPingPort()); + data.addInt(g.getPopulation()); + data.addInt(g.getPopulationStatus()); + data.addInt(g.getMaxCharacters()); + data.addInt(g.getDistance()); + data.addInt(g.getStatus().getStatus()); + data.addBoolean(g.isRecommended()); + data.addInt(g.getOnlinePlayerLimit()); + data.addInt(g.getOnlineFreeTrialLimit()); + } + return data; + } + + public void addGalaxy(Galaxy g) { + galaxies.add(g); + } + + public List getGalaxies() { + return galaxies; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/login/LoginEnumCluster.java b/src/com/projectswg/common/network/packets/swg/login/LoginEnumCluster.java new file mode 100644 index 0000000..c885846 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/LoginEnumCluster.java @@ -0,0 +1,101 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import java.time.ZoneOffset; +import java.util.List; +import java.util.Vector; + +import com.projectswg.common.data.encodables.galaxy.Galaxy; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class LoginEnumCluster extends SWGPacket { + + public static final int CRC = 0xC11C63B9; + + private Vector galaxies; + private int maxCharacters; + + public LoginEnumCluster() { + galaxies = new Vector(); + } + + public LoginEnumCluster(int maxCharacters) { + galaxies = new Vector(); + this.maxCharacters = maxCharacters; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + int serverCount = data.getInt(); + for (int i = 0; i < serverCount; i++) { + Galaxy g = new Galaxy(); + g.setId(data.getInt()); + g.setName(data.getAscii()); + g.setZoneOffset(ZoneOffset.ofTotalSeconds(data.getInt())); + galaxies.add(g); + } + maxCharacters = data.getInt(); + } + + public NetBuffer encode() { + int length = 14; + for (Galaxy g : galaxies) + length += 10 + g.getName().length(); + NetBuffer data = NetBuffer.allocate(length); + data.addShort(3); + data.addInt(CRC); + data.addInt(galaxies.size()); + for (Galaxy g : galaxies) { + data.addInt(g.getId()); + data.addAscii(g.getName()); + data.addInt(g.getDistance()); + } + data.addInt(maxCharacters); + return data; + } + + public void addGalaxy(Galaxy g) { + galaxies.add(g); + } + + public void setMaxCharacters(int max) { + this.maxCharacters = max; + } + + public int getMaxCharacters() { + return maxCharacters; + } + + public List getGalaxies() { + return galaxies; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/login/LoginIncorrectClientId.java b/src/com/projectswg/common/network/packets/swg/login/LoginIncorrectClientId.java new file mode 100644 index 0000000..6a5d8ab --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/LoginIncorrectClientId.java @@ -0,0 +1,68 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class LoginIncorrectClientId extends SWGPacket { + public static final int CRC = getCrc("LoginIncorrectClientId"); + + private String serverId; + private String serverAppVersion; + + public LoginIncorrectClientId() { + this("", ""); + } + + public LoginIncorrectClientId(NetBuffer data) { + decode(data); + } + + public LoginIncorrectClientId(String serverId, String serverAppVersion) { + this.serverId = serverId; + this.serverAppVersion = serverAppVersion; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + serverId = data.getAscii(); + serverAppVersion = data.getAscii(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10 + serverId.length() + serverAppVersion.length()); + data.addShort(4); + data.addInt(CRC); + data.addAscii(serverId); + data.addAscii(serverAppVersion); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/login/OfflineServersMessage.java b/src/com/projectswg/common/network/packets/swg/login/OfflineServersMessage.java new file mode 100644 index 0000000..ba7d4c2 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/OfflineServersMessage.java @@ -0,0 +1,88 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import java.util.ArrayList; +import java.util.List; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class OfflineServersMessage extends SWGPacket { + + public static final int CRC = 0xF41A5265; + + private List offlineServers; + + public OfflineServersMessage() { + offlineServers = new ArrayList(); + } + + public OfflineServersMessage(List offline) { + this.offlineServers = offline; + } + + public OfflineServersMessage(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + int listCount = data.getInt(); + offlineServers = new ArrayList(listCount); + for (int i = 0 ; i < listCount; i++) + offlineServers.add(data.getAscii()); + } + + public NetBuffer encode() { + int strLength = 0; + for (String str : offlineServers) + strLength += 2 + str.length(); + NetBuffer data = NetBuffer.allocate(10 + strLength); + data.addShort(2); + data.addInt(CRC); + data.addInt(offlineServers.size()); + for (String str : offlineServers) + data.addAscii(str); + return data; + } + + public List getOfflineServers() { + return offlineServers; + } + + public void setOfflineServers(List offline) { + offlineServers = offline; + } + + public void addOflineServer(String offline) { + offlineServers.add(offline); + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/login/RequestExtendedClusters.java b/src/com/projectswg/common/network/packets/swg/login/RequestExtendedClusters.java new file mode 100644 index 0000000..0e1d425 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/RequestExtendedClusters.java @@ -0,0 +1,54 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class RequestExtendedClusters extends SWGPacket { + + public static final int CRC = getCrc("RequestExtendedClusterInfo"); + + public RequestExtendedClusters() { + + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10); + data.addShort(2); + data.addInt(CRC); + data.addInt(0); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/login/ServerId.java b/src/com/projectswg/common/network/packets/swg/login/ServerId.java new file mode 100644 index 0000000..29d2ae2 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/ServerId.java @@ -0,0 +1,65 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class ServerId extends SWGPacket { + + public static final int CRC = 0x58C07F21; + private int serverId = 0; + + public ServerId() { + + } + + public ServerId(int id) { + this.serverId = id; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + serverId = data.getInt(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10); + data.addShort(2); + data.addInt(CRC); + data.addInt(serverId); + return data; + } + + public int getServerId() { + return serverId; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/login/ServerString.java b/src/com/projectswg/common/network/packets/swg/login/ServerString.java new file mode 100644 index 0000000..c6ba820 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/ServerString.java @@ -0,0 +1,65 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class ServerString extends SWGPacket { + + public static final int CRC = 0x0E20D7E9; + private String serverName = ""; + + public ServerString() { + + } + + public ServerString(String name) { + this.serverName = name; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + serverName = data.getAscii(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(8 + serverName.length()); + data.addShort(2); + data.addInt(CRC); + data.addAscii(serverName); + return data; + } + + public String getServerString() { + return serverName; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/login/StationIdHasJediSlot.java b/src/com/projectswg/common/network/packets/swg/login/StationIdHasJediSlot.java new file mode 100644 index 0000000..0f4e429 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/StationIdHasJediSlot.java @@ -0,0 +1,66 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class StationIdHasJediSlot extends SWGPacket { + + public static final int CRC = 0xCC9FCCF8; + + private int jedi; + + public StationIdHasJediSlot() { + this.jedi = 1; + } + + public StationIdHasJediSlot(int jedi) { + this.jedi = jedi; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + jedi = data.getInt(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10); + data.addShort(2); + data.addInt(CRC); + data.addInt(jedi); + return data; + } + + public int getJediSlot() { + return jedi; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/login/creation/ClientCreateCharacter.java b/src/com/projectswg/common/network/packets/swg/login/creation/ClientCreateCharacter.java new file mode 100644 index 0000000..fb49fec --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/creation/ClientCreateCharacter.java @@ -0,0 +1,124 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login.creation; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class ClientCreateCharacter extends SWGPacket { + public static final int CRC = getCrc("ClientCreateCharacter"); + + private byte [] charCustomization = new byte[0]; + private String name = ""; + private String race = ""; + private String start = ""; + private String hair = ""; + private byte [] hairCustomization = new byte[0]; + private String clothes = ""; + private boolean jedi = false; + private float height = 0; + private String biography = ""; + private boolean tutorial = false; + private String profession = ""; + private String startingPhase = ""; + + public ClientCreateCharacter() { + + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + charCustomization = data.getArray(); + name = data.getUnicode(); + race = data.getAscii(); + start = data.getAscii(); + hair = data.getAscii(); + hairCustomization = data.getArray(); + clothes = data.getAscii(); + jedi = data.getBoolean(); + height = data.getFloat(); + biography = data.getUnicode(); + tutorial = data.getBoolean(); + profession = data.getAscii(); + startingPhase = data.getAscii(); + } + + public NetBuffer encode() { + int extraSize = charCustomization.length; + extraSize += name.length()*2; + extraSize += race.length() + start.length(); + extraSize += hair.length() + hairCustomization.length; + extraSize += clothes.length() + profession.length(); + extraSize += startingPhase.length(); + NetBuffer data = NetBuffer.allocate(36+extraSize); + data.addShort(2); + data.addInt(CRC); + data.addArray(charCustomization); + data.addUnicode(name); + data.addAscii(race); + data.addAscii(start); + data.addAscii(hair); + data.addArray(hairCustomization); + data.addAscii(clothes); + data.addBoolean(jedi); + data.addFloat(height); + data.addUnicode(biography); + data.addBoolean(tutorial); + data.addAscii(profession); + data.addAscii(startingPhase); + return data; + } + + public byte [] getCharCustomization() { return charCustomization; } + public String getName() { return name; } + public String getRace() { return race; } + public String getStartLocation() { return start; } + public String getHair() { return hair; } + public byte [] getHairCustomization() { return hairCustomization; } + public String getClothes() { return clothes; } + public float getHeight() { return height; } + public boolean isTutorial() { return tutorial; } + public String getProfession() { return profession; } + public String getStartingPhase() { return startingPhase; } + + public void setCharCustomization(byte [] data) { this.charCustomization = data; } + public void setName(String name) { this.name = name; } + public String getStart() { return start; } + public void setStart(String start) { this.start = start; } + public void setRace(String race) { this.race = race; } + public void setHair(String hair) { this.hair = hair; } + public void setHairCustomization(byte [] hairCustomization) { this.hairCustomization = hairCustomization; } + public void setClothes(String clothes) { this.clothes = clothes; } + public void setHeight(float height) { this.height = height; } + public void setTutorial(boolean tutorial) { this.tutorial = tutorial; } + public void setProfession(String profession) { this.profession = profession; } + public void setStartingPhase(String startingPhase) { this.startingPhase = startingPhase; } + +} diff --git a/src/com/projectswg/common/network/packets/swg/login/creation/ClientVerifyAndLockNameRequest.java b/src/com/projectswg/common/network/packets/swg/login/creation/ClientVerifyAndLockNameRequest.java new file mode 100644 index 0000000..f47d0d4 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/creation/ClientVerifyAndLockNameRequest.java @@ -0,0 +1,67 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login.creation; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class ClientVerifyAndLockNameRequest extends SWGPacket { + public static final int CRC = getCrc("ClientVerifyAndLockNameRequest"); + + private String race = ""; + private String name = ""; + + public ClientVerifyAndLockNameRequest() { + + } + + public ClientVerifyAndLockNameRequest(String race, String name) { + this.race = race; + this.name = name; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + race = data.getAscii(); + name = data.getUnicode(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10 + race.length() + name.length() * 2); + data.addShort(4); + data.addInt(CRC); + data.addAscii(race); + data.addUnicode(name); + return data; + } + + public String getRace() { return race; } + public String getName() { return name; } +} diff --git a/src/com/projectswg/common/network/packets/swg/login/creation/ClientVerifyAndLockNameResponse.java b/src/com/projectswg/common/network/packets/swg/login/creation/ClientVerifyAndLockNameResponse.java new file mode 100644 index 0000000..487c0e5 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/creation/ClientVerifyAndLockNameResponse.java @@ -0,0 +1,93 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login.creation; + +import java.util.Locale; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class ClientVerifyAndLockNameResponse extends SWGPacket { + public static final int CRC = getCrc("ClientVerifyAndLockNameResponse"); + + private String name = ""; + private ErrorMessage error = ErrorMessage.NAME_APPROVED; + + public ClientVerifyAndLockNameResponse() { + + } + + public ClientVerifyAndLockNameResponse(String name, ErrorMessage error) { + this.name = name; + this.error = error; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + name = data.getUnicode(); + data.getAscii(); // ui + data.getInt(); + error = ErrorMessage.valueOf(data.getAscii().toUpperCase(Locale.US)); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(20 + error.name().length() + name.length() * 2); + data.addShort(9); + data.addInt(CRC); + data.addUnicode(name); + data.addAscii("ui"); + data.addInt(0); + data.addAscii(error.name().toLowerCase(Locale.US)); + return data; + } + + public enum ErrorMessage { + NAME_APPROVED, + NAME_APPROVED_MODIFIED, + NAME_DECLINED_SYNTAX, + NAME_DECLINED_EMPTY, + NAME_DECLINED_RACIALLY_INAPPROPRIATE, + NAME_DECLINED_FICTIONALLY_INAPPROPRIATE, + NAME_DECLINED_PROFANE, + NAME_DECLINED_IN_USE, + NAME_DECLINED_RESERVED, + NAME_DECLINED_NO_TEMPLATE, + NAME_DECLINED_NOT_CREATURE_TEMPLATE, + NAME_DECLINED_NO_NAME_GENERATOR, + NAME_DECLINED_CANT_CREATE_AVATAR, + NAME_DECLINED_INTERNAL_ERROR, + NAME_DECLINED_RETRY, + NAME_DECLINED_TOO_FAST, + NAME_DECLINED_NOT_AUTHORIZED_FOR_SPECIES, + NAME_DECLINED_FICTIONALLY_RESERVED, + SERVER_CHARACTER_CREATION_MAX_CHARS; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/login/creation/CreateCharacterFailure.java b/src/com/projectswg/common/network/packets/swg/login/creation/CreateCharacterFailure.java new file mode 100644 index 0000000..507fbaa --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/creation/CreateCharacterFailure.java @@ -0,0 +1,95 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login.creation; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class CreateCharacterFailure extends SWGPacket { + public static final int CRC = getCrc("ClientCreateCharacterFailed"); + + private NameFailureReason reason; + + public CreateCharacterFailure() { + reason = NameFailureReason.NAME_RETRY; + } + + public CreateCharacterFailure(NameFailureReason reason) { + this.reason = reason; + } + + public void decode(NetBuffer data) { + + } + + public NetBuffer encode() { + String errorString = nameFailureTranslation(reason); + NetBuffer data = NetBuffer.allocate(20 + errorString.length()); + data.addShort(3); + data.addInt(CRC); + data.addUnicode(""); + data.addAscii("ui"); + data.addInt(0); + data.addAscii(errorString); + return data; + } + + private String nameFailureTranslation(NameFailureReason reason) { + switch (reason) { + case NAME_DECLINED_EMPTY: + return "name_declined_empty"; + case NAME_IN_USE: + return "name_declined_in_use"; + case NAME_RETRY: + return "name_declined_retry"; + case NAME_FICTIONALLY_INAPPRORIATE: + return "name_declined_syntax"; + case NAME_SYNTAX: + return "name_declined_syntax"; + case NAME_TOO_FAST: + return "name_declined_too_fast"; + case NAME_DEV_RESERVED: + return "name_declined_developer"; + case TOO_MANY_CHARACTERS: + return "server_character_creation_max_chars"; + } + return "name_declined_retry"; + } + + public enum NameFailureReason { + NAME_DECLINED_EMPTY, + NAME_TOO_FAST, + NAME_RETRY, + NAME_SYNTAX, + NAME_IN_USE, + NAME_FICTIONALLY_INAPPRORIATE, + NAME_DEV_RESERVED, + TOO_MANY_CHARACTERS; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/login/creation/CreateCharacterSuccess.java b/src/com/projectswg/common/network/packets/swg/login/creation/CreateCharacterSuccess.java new file mode 100644 index 0000000..9f22de0 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/creation/CreateCharacterSuccess.java @@ -0,0 +1,63 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login.creation; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class CreateCharacterSuccess extends SWGPacket { + public static final int CRC = getCrc("ClientCreateCharacterSuccess"); + + private long id = 0; + + public CreateCharacterSuccess() { + + } + + public CreateCharacterSuccess(long charId) { + this.id = charId; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + id = data.getLong(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(2); + data.addInt(CRC); + data.addLong(id); + return data; + } + + public long getId() { return id; } + public void setId(long id) { this.id = id; } +} diff --git a/src/com/projectswg/common/network/packets/swg/login/creation/DeleteCharacterRequest.java b/src/com/projectswg/common/network/packets/swg/login/creation/DeleteCharacterRequest.java new file mode 100644 index 0000000..0c96f97 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/creation/DeleteCharacterRequest.java @@ -0,0 +1,67 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login.creation; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class DeleteCharacterRequest extends SWGPacket { + public static final int CRC = getCrc("DeleteCharacterMessage"); + + private int serverId = 0; + private long playerId = 0; + + public DeleteCharacterRequest() { + + } + + public DeleteCharacterRequest(int serverId, long playerId) { + this.serverId = serverId; + this.playerId = playerId; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + serverId = data.getInt(); + playerId = data.getLong(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(18); + data.addShort(3); + data.addInt(CRC); + data.addInt(serverId); + data.addLong(playerId); + return data; + } + + public int getServerId() { return serverId; } + public long getPlayerId() { return playerId; } +} diff --git a/src/com/projectswg/common/network/packets/swg/login/creation/DeleteCharacterResponse.java b/src/com/projectswg/common/network/packets/swg/login/creation/DeleteCharacterResponse.java new file mode 100644 index 0000000..2f7ea48 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/creation/DeleteCharacterResponse.java @@ -0,0 +1,60 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login.creation; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class DeleteCharacterResponse extends SWGPacket { + public static final int CRC = getCrc("DeleteCharacterReplyMessage"); + + private boolean deleted = true; + + public DeleteCharacterResponse() { + + } + + public DeleteCharacterResponse(boolean deleted) { + this.deleted = deleted; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + deleted = data.getInt() == 0; + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10); + data.addShort(2); + data.addInt(CRC); + data.addInt(deleted ? 0 : 1); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/login/creation/RandomNameRequest.java b/src/com/projectswg/common/network/packets/swg/login/creation/RandomNameRequest.java new file mode 100644 index 0000000..84eb5d3 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/creation/RandomNameRequest.java @@ -0,0 +1,59 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login.creation; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class RandomNameRequest extends SWGPacket { + public static final int CRC = getCrc("ClientRandomNameRequest"); + + private String raceCrc = "object/creature/player/human_male.iff"; + + public RandomNameRequest() { + + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + raceCrc = data.getAscii(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(8 + raceCrc.length()); + data.addShort(2); + data.addInt(CRC); + data.addAscii(raceCrc); + return data; + } + + public String getRace() { return raceCrc; } + public void setRace(String race) { this.raceCrc = race; } +} diff --git a/src/com/projectswg/common/network/packets/swg/login/creation/RandomNameResponse.java b/src/com/projectswg/common/network/packets/swg/login/creation/RandomNameResponse.java new file mode 100644 index 0000000..9d8c409 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/login/creation/RandomNameResponse.java @@ -0,0 +1,78 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.login.creation; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class RandomNameResponse extends SWGPacket { + public static final int CRC = getCrc("ClientRandomNameResponse"); + + private String race; + private String randomName; + + public RandomNameResponse() { + this.race = "object/creature/player/human_male.iff"; + this.randomName = ""; + } + + public RandomNameResponse(String race, String randomName) { + this.race = race; + this.randomName = randomName; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + race = data.getAscii(); + randomName = data.getUnicode(); + data.getAscii(); + data.getInt(); + data.getAscii(); + } + + public NetBuffer encode() { + int length = 35 + race.length() + randomName.length() * 2; + NetBuffer data = NetBuffer.allocate(length); + data.addShort(4); + data.addInt(CRC); + data.addAscii(race); + data.addUnicode(randomName); + data.addAscii("ui"); + data.addInt(0); + data.addAscii("name_approved"); + return data; + } + + public void setRace(String race) { this.race = race; } + public void setRandomName(String randomName) { this.randomName = randomName; } + + public String getRace() { return race; } + public String getRandomName() { return randomName; } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/ClientOpenContainerMessage.java b/src/com/projectswg/common/network/packets/swg/zone/ClientOpenContainerMessage.java new file mode 100644 index 0000000..f23a61c --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/ClientOpenContainerMessage.java @@ -0,0 +1,70 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ClientOpenContainerMessage extends SWGPacket { + public static final int CRC = getCrc("ClientOpenContainerMessage"); + + private long containerId; + private String slot; + + public ClientOpenContainerMessage() { + this(0, ""); + } + + public ClientOpenContainerMessage(long containerId, String slot) { + this.containerId = containerId; + this.slot = slot; + } + + public ClientOpenContainerMessage(NetBuffer data) { + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + containerId = data.getLong(); + slot = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(16 + slot.length()); + data.addShort(2); + data.addInt(CRC); + data.addLong(containerId); + data.addAscii(slot); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/CmdSceneReady.java b/src/com/projectswg/common/network/packets/swg/zone/CmdSceneReady.java new file mode 100644 index 0000000..18c3b51 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/CmdSceneReady.java @@ -0,0 +1,54 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class CmdSceneReady extends SWGPacket { + public static final int CRC = getCrc("CmdSceneReady"); + + public CmdSceneReady() { + + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + int length = 6; + NetBuffer data = NetBuffer.allocate(length); + data.addShort(1); + data.addInt(CRC); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/ConnectPlayerResponseMessage.java b/src/com/projectswg/common/network/packets/swg/zone/ConnectPlayerResponseMessage.java new file mode 100644 index 0000000..3d9ddeb --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/ConnectPlayerResponseMessage.java @@ -0,0 +1,60 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ConnectPlayerResponseMessage extends SWGPacket { + public static final int CRC = getCrc("ConnectPlayerResponseMessage"); + + public ConnectPlayerResponseMessage() { + + } + + public ConnectPlayerResponseMessage(NetBuffer data) { + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10); + data.addShort(2); + data.addInt(CRC); + data.addInt(0); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/EnterTicketPurchaseModeMessage.java b/src/com/projectswg/common/network/packets/swg/zone/EnterTicketPurchaseModeMessage.java new file mode 100644 index 0000000..1f08ee2 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/EnterTicketPurchaseModeMessage.java @@ -0,0 +1,71 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class EnterTicketPurchaseModeMessage extends SWGPacket { + public static final int CRC = getCrc("EnterTicketPurchaseModeMessage"); + + private String planetName; + private String nearestPointName; + private boolean instant; + + public EnterTicketPurchaseModeMessage() { + + } + + public EnterTicketPurchaseModeMessage(String planetName, String nearestPointName, boolean instant) { + this.planetName = planetName; + this.nearestPointName = nearestPointName; + this.instant = instant; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + planetName = data.getAscii(); + nearestPointName = data.getAscii(); + instant = data.getBoolean(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(11 + planetName.length() + nearestPointName.length()); // 2x ascii length shorts, 1x opcount short, 1x boolean, int CRC = 11 + data.addShort(3); // Operand count of 3 + data.addInt(CRC); + data.addAscii(planetName); + data.addAscii(nearestPointName); + data.addBoolean(instant); + return data; + } + + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/ExpertiseRequestMessage.java b/src/com/projectswg/common/network/packets/swg/zone/ExpertiseRequestMessage.java new file mode 100644 index 0000000..d48a586 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/ExpertiseRequestMessage.java @@ -0,0 +1,90 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public final class ExpertiseRequestMessage extends SWGPacket { + + public static final int CRC = getCrc("ExpertiseRequestMessage"); + + private String[] requestedSkills; + private boolean clearAllExpertisesFirst; + + public ExpertiseRequestMessage() { + + } + + public ExpertiseRequestMessage(NetBuffer data) { + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + requestedSkills = new String[data.getInt()]; + + for (int i = 0; i < requestedSkills.length; i++) { + requestedSkills[i] = data.getAscii(); + } + + clearAllExpertisesFirst = data.getBoolean(); + } + + @Override + public NetBuffer encode() { + int skillNamesLength = 0; + + for (String skillName : requestedSkills) + skillNamesLength += 2 + skillName.length(); + + NetBuffer data = NetBuffer.allocate(11 + skillNamesLength); + data.addShort(3); + data.addInt(CRC); + data.addInt(requestedSkills.length); + + for (String requestedSkill : requestedSkills) { + data.addAscii(requestedSkill); + } + + data.addBoolean(clearAllExpertisesFirst); + + return data; + } + + public String[] getRequestedSkills() { + return requestedSkills; + } + + public boolean isClearAllExpertisesFirst() { + return clearAllExpertisesFirst; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/GalaxyLoopTimesResponse.java b/src/com/projectswg/common/network/packets/swg/zone/GalaxyLoopTimesResponse.java new file mode 100644 index 0000000..e766d3d --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/GalaxyLoopTimesResponse.java @@ -0,0 +1,62 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class GalaxyLoopTimesResponse extends SWGPacket { + public static final int CRC = getCrc("GalaxyLoopTimesResponse"); + + private long time = 0; + + public GalaxyLoopTimesResponse() { + + } + + public GalaxyLoopTimesResponse(long time) { + this.time = time; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + time = data.getLong(); + } + + @Override + public NetBuffer encode() { + int length = 14; + NetBuffer data = NetBuffer.allocate(length); + data.addShort(3); + data.addInt(CRC); + data.addLong(time); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/GameServerLagResponse.java b/src/com/projectswg/common/network/packets/swg/zone/GameServerLagResponse.java new file mode 100644 index 0000000..57b0b6a --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/GameServerLagResponse.java @@ -0,0 +1,56 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class GameServerLagResponse extends SWGPacket { + + public static final int CRC = getCrc("GameServerLagResponse"); + + public GameServerLagResponse() { + + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(1); + data.addInt(CRC); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/HeartBeat.java b/src/com/projectswg/common/network/packets/swg/zone/HeartBeat.java new file mode 100644 index 0000000..fe0d5bd --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/HeartBeat.java @@ -0,0 +1,53 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class HeartBeat extends SWGPacket { + public static final int CRC = getCrc("HeartBeat"); + + public HeartBeat() { + + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(1); + data.addInt(CRC); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/LagRequest.java b/src/com/projectswg/common/network/packets/swg/zone/LagRequest.java new file mode 100644 index 0000000..1c9da58 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/LagRequest.java @@ -0,0 +1,56 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + + +public class LagRequest extends SWGPacket { + + public static final int CRC = getCrc("LagRequest"); + + public LagRequest() { + + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(2); + data.addInt(CRC); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/ObjectMenuSelect.java b/src/com/projectswg/common/network/packets/swg/zone/ObjectMenuSelect.java new file mode 100644 index 0000000..977b30f --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/ObjectMenuSelect.java @@ -0,0 +1,83 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ObjectMenuSelect extends SWGPacket { + + public static final int CRC = getCrc("ObjectMenuSelectMessage::MESSAGE_TYPE"); + + private long objectId; + private short selection; + + public ObjectMenuSelect() { + this(0, (short) 0); + } + + public ObjectMenuSelect(long objectId, short selection) { + this.objectId = objectId; + this.selection = selection; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objectId = data.getLong(); + selection = data.getShort(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(16); + data.addShort(3); + data.addInt(CRC); + data.addLong(objectId); + data.addShort(selection); + return data; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + + public void setSelection(short selection) { + this.selection = selection; + } + + public long getObjectId() { + return objectId; + } + + public short getSelection() { + return selection; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/ParametersMessage.java b/src/com/projectswg/common/network/packets/swg/zone/ParametersMessage.java new file mode 100644 index 0000000..70ad00a --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/ParametersMessage.java @@ -0,0 +1,57 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ParametersMessage extends SWGPacket { + public static final int CRC = getCrc("ParametersMessage"); + + private int weatherInterval = 900; + + public ParametersMessage() { + + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + weatherInterval = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10); + data.addShort(2); + data.addInt(CRC); + data.addInt(weatherInterval); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/PlanetTravelPointListRequest.java b/src/com/projectswg/common/network/packets/swg/zone/PlanetTravelPointListRequest.java new file mode 100644 index 0000000..8152013 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/PlanetTravelPointListRequest.java @@ -0,0 +1,62 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class PlanetTravelPointListRequest extends SWGPacket { + + public static final int CRC = getCrc("PlanetTravelPointListRequest"); + + private long requesterObjId; // The object ID of the CreatureObject belonging to the player clicking the travel terminal + private String planetName; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + requesterObjId = data.getLong(); + planetName = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(16 + planetName.length()); // ascii length short + opcount short + long + int = 16 + data.addShort(3); // Operand count of 3 + data.addInt(CRC); + data.addLong(requesterObjId); + data.addAscii(planetName); + return data; + } + + public String getPlanetName() { + return planetName; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/PlanetTravelPointListResponse.java b/src/com/projectswg/common/network/packets/swg/zone/PlanetTravelPointListResponse.java new file mode 100644 index 0000000..d80f8c3 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/PlanetTravelPointListResponse.java @@ -0,0 +1,145 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import java.util.ArrayList; +import java.util.List; + +import com.projectswg.common.data.location.Point3D; +import com.projectswg.common.encoding.StringType; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class PlanetTravelPointListResponse extends SWGPacket { + + public static final int CRC = getCrc("PlanetTravelPointListResponse"); + + private final List travelPoints; + private String planetName; + + public PlanetTravelPointListResponse() { + this("", new ArrayList<>()); + } + + public PlanetTravelPointListResponse(String planetName, List travelPoints) { + this.planetName = planetName; + this.travelPoints = travelPoints; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(getLength()); + + data.addShort(6); // Operand count + data.addInt(CRC); // CRC + data.addAscii(planetName); // ASCII planet name + + data.addInt(travelPoints.size()); // List size + for (PlanetTravelPoint tp : travelPoints) // Point names + data.addAscii(tp.getName()); + + data.addInt(travelPoints.size()); // List size + for (PlanetTravelPoint tp : travelPoints) { // Point coordinates + data.addFloat((float) tp.getLocation().getX()); + data.addFloat((float) tp.getLocation().getY()); + data.addFloat((float) tp.getLocation().getZ()); + } + + data.addInt(travelPoints.size()); // List size + for (PlanetTravelPoint tp : travelPoints) { // additional costs + data.addInt(tp.getAdditionalCost()); + } + + data.addInt(travelPoints.size()); // List size + for (PlanetTravelPoint tp : travelPoints) { // reachable + data.addBoolean(tp.isReachable()); + } + + return data; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + planetName = data.getAscii(); + List pointNames = data.getList(StringType.ASCII); + List points = data.getList(Point3D.class); + int[] additionalCosts = data.getIntArray(); + boolean [] reachable = data.getBooleanArray(); // reachable + + for (int i = 0; i < pointNames.size(); i++) { + travelPoints.add(new PlanetTravelPoint(pointNames.get(i), points.get(i), additionalCosts[i]*2, reachable[i])); + } + } + + public int getLength() { + int size = 24 + planetName.length(); + + for (PlanetTravelPoint tp : travelPoints) { + size += 19 + tp.getName().length(); + } + + return size; + } + + public static class PlanetTravelPoint { + + private final String name; + private final Point3D location; + private final int additionalCost; + private final boolean reachable; + + public PlanetTravelPoint(String name, Point3D location, int additionalCost, boolean reachable) { + this.name = name; + this.location = new Point3D(); + this.additionalCost = additionalCost; + this.reachable = reachable; + + this.location.set(location.getX(), location.getY(), location.getZ()); + } + + public String getName() { + return name; + } + + public Point3D getLocation() { + return location; + } + + public int getAdditionalCost() { + return additionalCost; + } + + public boolean isReachable() { + return reachable; + } + + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/PlayClientEffectObjectMessage.java b/src/com/projectswg/common/network/packets/swg/zone/PlayClientEffectObjectMessage.java new file mode 100644 index 0000000..2f8f251 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/PlayClientEffectObjectMessage.java @@ -0,0 +1,73 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class PlayClientEffectObjectMessage extends SWGPacket { + public static final int CRC = getCrc("PlayClientEffectObjectMessage"); + + private String effectFile; + private String effectLocation; + private long objectId; + private String commandString; + + public PlayClientEffectObjectMessage() { + + } + + public PlayClientEffectObjectMessage(String effectFile, String effectLocation, long objectId, String commandString) { + this.effectFile = effectFile; + this.effectLocation = effectLocation; + this.objectId = objectId; + this.commandString = commandString; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + effectFile = data.getAscii(); + effectLocation = data.getAscii(); + objectId = data.getLong(); + commandString = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(20 + effectFile.length() + effectLocation.length() + commandString.length()); + data.addShort(4); + data.addInt(CRC); + data.addAscii(effectFile); + data.addAscii(effectLocation); + data.addLong(objectId); + data.addAscii(commandString); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/PlayClientEffectObjectTransformMessage.java b/src/com/projectswg/common/network/packets/swg/zone/PlayClientEffectObjectTransformMessage.java new file mode 100644 index 0000000..8121e3c --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/PlayClientEffectObjectTransformMessage.java @@ -0,0 +1,75 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.data.location.Location; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class PlayClientEffectObjectTransformMessage extends SWGPacket { + public static final int CRC = getCrc("PlayClientEffectObjectTransformMessage"); + + private long objectId; + private String effectFile; + private Location location; + private String commandString; + + public PlayClientEffectObjectTransformMessage() { + + } + + public PlayClientEffectObjectTransformMessage(long objectId, String effectFile, Location location, String commandString) { + this.objectId = objectId; + this.effectFile = effectFile; + this.location = location; + this.commandString = commandString; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + + effectFile = data.getAscii(); + location = data.getEncodable(Location.class); + objectId = data.getLong(); + commandString = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(46 + effectFile.length() + commandString.length()); + data.addShort(5); + data.addInt(CRC); + data.addAscii(effectFile); + data.addEncodable(location); + data.addLong(objectId); + data.addAscii(commandString); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/PlayMusicMessage.java b/src/com/projectswg/common/network/packets/swg/zone/PlayMusicMessage.java new file mode 100644 index 0000000..77347bf --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/PlayMusicMessage.java @@ -0,0 +1,77 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class PlayMusicMessage extends SWGPacket { + public static final int CRC = getCrc("PlayMusicMessage"); + + private long objectId; + private String soundFile; + private int repititions; // playType? + private boolean loop; + + /** + * + * @param objectId is the ID for the object where this sound originates from. + * Use an object ID of 0 if the sound doesn't originate from anywhere. + * @param soundFile is the full path to the .snd file to play + * @param repititions TODO + * @param loop can be set to true if this sound should keep looping (TODO ?) + */ + public PlayMusicMessage(long objectId, String soundFile, int repititions, boolean loop) { + this.objectId = objectId; + this.soundFile = soundFile; + this.repititions = repititions; + this.loop = loop; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + soundFile = data.getAscii(); + objectId = data.getLong(); + repititions = data.getInt(); + loop = data.getBoolean(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(21 + soundFile.length()); + data.addShort(5); + data.addInt(CRC); + data.addAscii(soundFile); + data.addLong(objectId); + data.addInt(repititions); + data.addBoolean(loop); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/RequestGalaxyLoopTimes.java b/src/com/projectswg/common/network/packets/swg/zone/RequestGalaxyLoopTimes.java new file mode 100644 index 0000000..2524e5e --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/RequestGalaxyLoopTimes.java @@ -0,0 +1,54 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class RequestGalaxyLoopTimes extends SWGPacket { + public static final int CRC = getCrc("RequestGalaxyLoopTimes"); + + public RequestGalaxyLoopTimes() { + + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + int length = 6; + NetBuffer data = NetBuffer.allocate(length); + data.addShort(1); + data.addInt(CRC); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/SceneCreateObjectByCrc.java b/src/com/projectswg/common/network/packets/swg/zone/SceneCreateObjectByCrc.java new file mode 100644 index 0000000..06d1ee7 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/SceneCreateObjectByCrc.java @@ -0,0 +1,128 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.data.location.Location; +import com.projectswg.common.debug.Assert; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class SceneCreateObjectByCrc extends SWGPacket { + + public static final int CRC = getCrc("SceneCreateObjectByCrc"); + + private Location location; + private boolean hyperspace; + private long objId; + private int objCrc; + + public SceneCreateObjectByCrc() { + + } + + public SceneCreateObjectByCrc(long objId, Location l, int objCrc, boolean hyperspace) { + setObjectId(objId); + setLocation(l); + setObjectCrc(objCrc); + setHyperspace(hyperspace); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objId = data.getLong(); + location = data.getEncodable(Location.class); + objCrc = data.getInt(); + hyperspace = data.getBoolean(); + } + + @Override + public NetBuffer encode() { + verifyObjectId(); + verifyLocation(); + NetBuffer data = NetBuffer.allocate(47); + data.addShort(5); + data.addInt(CRC); + data.addLong(objId); + data.addEncodable(location); + data.addInt(objCrc); + data.addBoolean(hyperspace); + return data; + } + + public void setObjectId(long objId) { + this.objId = objId; + verifyObjectId(); + } + + public void setLocation(Location l) { + this.location = new Location(l); + verifyLocation(); + } + + public void setObjectCrc(int objCrc) { + this.objCrc = objCrc; + } + + public void setHyperspace(boolean hyperspace) { + this.hyperspace = hyperspace; + } + + public long getObjectId() { + return objId; + } + + public Location getLocation() { + return location; + } + + public int getObjectCrc() { + return objCrc; + } + + public boolean isHyperspace() { + return hyperspace; + } + + private void verifyObjectId() { + Assert.test(objId != 0, "Object ID cannot be 0!"); + } + + private void verifyLocation() { + Assert.notNull(location); + Assert.test(!Double.isNaN(location.getX()), "X Coordinate is NaN!"); + Assert.test(!Double.isNaN(location.getY()), "Y Coordinate is NaN!"); + Assert.test(!Double.isNaN(location.getZ()), "Z Coordinate is NaN!"); + Assert.test(!Double.isNaN(location.getOrientationX()), "X Orientation is NaN!"); + Assert.test(!Double.isNaN(location.getOrientationY()), "Y Orientation is NaN!"); + Assert.test(!Double.isNaN(location.getOrientationZ()), "Z Orientation is NaN!"); + Assert.test(!Double.isNaN(location.getOrientationW()), "W Orientation is NaN!"); + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/SceneDestroyObject.java b/src/com/projectswg/common/network/packets/swg/zone/SceneDestroyObject.java new file mode 100644 index 0000000..e2eb9dc --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/SceneDestroyObject.java @@ -0,0 +1,69 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class SceneDestroyObject extends SWGPacket { + public static final int CRC = getCrc("SceneDestroyObject"); + + private long objId; + + public SceneDestroyObject() { + this(0); + } + + public SceneDestroyObject(long objId) { + this.objId = objId; + } + + public SceneDestroyObject(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objId = data.getLong(); + data.getByte(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(15); + data.addShort(3); + data.addInt(CRC); + data.addLong(objId); + data.addByte(0); + return data; + } + + public long getObjectId() { return objId; } + public void setObjectId(long objId) { this.objId = objId; } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/SceneEndBaselines.java b/src/com/projectswg/common/network/packets/swg/zone/SceneEndBaselines.java new file mode 100644 index 0000000..713d3cb --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/SceneEndBaselines.java @@ -0,0 +1,63 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class SceneEndBaselines extends SWGPacket { + public static final int CRC = getCrc("SceneEndBaselines"); + + private long objId = 0; + + public SceneEndBaselines() { + + } + + public SceneEndBaselines(long objId) { + this.objId = objId; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objId = data.getLong(); + } + + public NetBuffer encode() { + int length = 14; + NetBuffer data = NetBuffer.allocate(length); + data.addShort(2); + data.addInt(CRC); + data.addLong(objId); + return data; + } + + public long getObjectId() { return objId; } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/ServerNowEpochTime.java b/src/com/projectswg/common/network/packets/swg/zone/ServerNowEpochTime.java new file mode 100644 index 0000000..640d7ef --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/ServerNowEpochTime.java @@ -0,0 +1,63 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ServerNowEpochTime extends SWGPacket { + public static final int CRC = getCrc("ServerNowEpochTime"); + + private int time = 0; + + public ServerNowEpochTime() { + + } + + public ServerNowEpochTime(int time) { + this.time = time; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + time = data.getInt(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10); + data.addShort(2); + data.addInt(CRC); + data.addInt(time); + return data; + } + + public int getTime() { + return time; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/ServerTimeMessage.java b/src/com/projectswg/common/network/packets/swg/zone/ServerTimeMessage.java new file mode 100644 index 0000000..c792e23 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/ServerTimeMessage.java @@ -0,0 +1,67 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ServerTimeMessage extends SWGPacket { + public static final int CRC = getCrc("ServerTimeMessage"); + + private long time = 0; + + public ServerTimeMessage() { + + } + + public ServerTimeMessage(long time) { + this.time = time; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + time = data.getLong(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(2); + data.addInt(CRC); + data.addLong(time); + return data; + } + + public long getTime() { + return time; + } + + public void setTime(long time) { + this.time = time; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/ServerWeatherMessage.java b/src/com/projectswg/common/network/packets/swg/zone/ServerWeatherMessage.java new file mode 100644 index 0000000..a13536f --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/ServerWeatherMessage.java @@ -0,0 +1,115 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.data.WeatherType; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ServerWeatherMessage extends SWGPacket { + public static final int CRC = getCrc("ServerWeatherMessage"); + + private WeatherType type; + private float cloudVectorX; + private float cloudVectorZ; + private float cloudVectorY; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + + switch (data.getInt()) { + case 0: + default: + type = WeatherType.CLEAR; + break; + case 1: + type = WeatherType.LIGHT; + break; + case 2: + type = WeatherType.MEDIUM; + break; + case 3: + type = WeatherType.HEAVY; + break; + } + + cloudVectorX = data.getFloat(); + cloudVectorZ = data.getFloat(); + cloudVectorY = data.getFloat(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(22); + + data.addShort(3); + data.addInt(CRC); + data.addInt(type.getValue()); + + data.addFloat(cloudVectorX); + data.addFloat(cloudVectorZ); + data.addFloat(cloudVectorY); + + return data; + } + + public WeatherType getType() { + return type; + } + + public void setType(WeatherType type) { + this.type = type; + } + + public float getCloudVectorX() { + return cloudVectorX; + } + + public void setCloudVectorX(float cloudVectorX) { + this.cloudVectorX = cloudVectorX; + } + + public float getCloudVectorZ() { + return cloudVectorZ; + } + + public void setCloudVectorZ(float cloudVectorZ) { + this.cloudVectorZ = cloudVectorZ; + } + + public float getCloudVectorY() { + return cloudVectorY; + } + + public void setCloudVectorY(float cloudVectorY) { + this.cloudVectorY = cloudVectorY; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/SetWaypointColor.java b/src/com/projectswg/common/network/packets/swg/zone/SetWaypointColor.java new file mode 100644 index 0000000..9d9decc --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/SetWaypointColor.java @@ -0,0 +1,67 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class SetWaypointColor extends SWGPacket { + public static final int CRC = getCrc("SetWaypointColor"); + + private long objId; + private String color; + + public SetWaypointColor() { } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + + objId = data.getLong(); + color = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(16 + color.length()); + data.addShort(3); + data.addInt(CRC); + data.addLong(objId); + data.addAscii(color); + return data; + } + + public long getObjId() { + return objId; + } + + public String getColor() { + return color; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/ShowBackpack.java b/src/com/projectswg/common/network/packets/swg/zone/ShowBackpack.java new file mode 100644 index 0000000..dcb4cec --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/ShowBackpack.java @@ -0,0 +1,66 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ShowBackpack extends SWGPacket { + public static final int CRC = getCrc("ShowBackpack"); + + private long objectId; + private boolean showBackpack; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + + objectId = data.getLong(); + showBackpack = data.getBoolean(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(15); + data.addShort(3); + data.addInt(CRC); + data.addLong(objectId); + data.addBoolean(showBackpack); + return data; + } + + public boolean showingBackpack() { + return showBackpack; + } + + public long getObjectId() { + return objectId; + } + +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/ShowHelmet.java b/src/com/projectswg/common/network/packets/swg/zone/ShowHelmet.java new file mode 100644 index 0000000..ccb55ff --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/ShowHelmet.java @@ -0,0 +1,66 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ShowHelmet extends SWGPacket { + public static final int CRC = getCrc("ShowHelmet"); + + private long objectId; + private boolean showHelmet; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + + objectId = data.getLong(); + showHelmet = data.getBoolean(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(15); + data.addShort(3); + data.addInt(CRC); + data.addLong(objectId); + data.addBoolean(showHelmet); + return data; + } + + public boolean showingHelmet() { + return showHelmet; + } + + public long getObjectId() { + return objectId; + } + +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/StopClientEffectObjectByLabelMessage.java b/src/com/projectswg/common/network/packets/swg/zone/StopClientEffectObjectByLabelMessage.java new file mode 100644 index 0000000..748a944 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/StopClientEffectObjectByLabelMessage.java @@ -0,0 +1,74 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class StopClientEffectObjectByLabelMessage extends SWGPacket { + public static final int CRC = getCrc("StopClientEffectObjectByLabelMessage"); + + private long objectId; + private String label; + private boolean softStop; + + public StopClientEffectObjectByLabelMessage() { + + } + + public StopClientEffectObjectByLabelMessage(long objectId, String label, boolean softStop) { + this.objectId = objectId; + this.label = label; + this.softStop = softStop; + } + + public StopClientEffectObjectByLabelMessage(NetBuffer data) { + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objectId = data.getLong(); + label = data.getAscii(); + softStop = data.getBoolean(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(Short.BYTES * 2 + Integer.BYTES + Long.BYTES + Byte.BYTES + label.length()); + data.addShort(4); + data.addInt(CRC); + data.addLong(objectId); + data.addAscii(label); + data.addBoolean(softStop); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/UpdateContainmentMessage.java b/src/com/projectswg/common/network/packets/swg/zone/UpdateContainmentMessage.java new file mode 100644 index 0000000..f09b8ee --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/UpdateContainmentMessage.java @@ -0,0 +1,71 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class UpdateContainmentMessage extends SWGPacket { + public static final int CRC = getCrc("UpdateContainmentMessage"); + + private long containerId = 0; + private long objectId = 0; + private int slotIndex = 0; + + public UpdateContainmentMessage() { + + } + + public UpdateContainmentMessage(long objectId, long containerId, int slotIndex) { + this.objectId = objectId; + this.containerId = containerId; + this.slotIndex = slotIndex; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objectId = data.getLong(); + containerId = data.getLong(); + slotIndex = data.getInt(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(26); + data.addShort(4); + data.addInt(CRC); + data.addLong(objectId); + data.addLong(containerId); + data.addInt(slotIndex); + return data; + } + + public long getObjectId() { return objectId; } + public long getContainerId() { return containerId; } + public int getSlotIndex() { return slotIndex; } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/UpdatePostureMessage.java b/src/com/projectswg/common/network/packets/swg/zone/UpdatePostureMessage.java new file mode 100644 index 0000000..71aa39d --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/UpdatePostureMessage.java @@ -0,0 +1,87 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.data.encodables.tangible.Posture; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class UpdatePostureMessage extends SWGPacket { + public static final int CRC = getCrc("UpdatePostureMessage"); + + private int posture = 0; + private long objId = 0; + + public UpdatePostureMessage() { + + } + + public UpdatePostureMessage(Posture posture, long objId) { + this.posture = posture.getId(); + this.objId = objId; + } + + public UpdatePostureMessage(int posture, long objId) { + this.posture = posture; + this.objId = objId; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + posture = data.getByte(); + objId = data.getLong(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(15); + data.addShort(3); + data.addInt(CRC); + data.addByte(posture); + data.addLong(objId); + return data; + } + + public int getPosture() { + return posture; + } + + public long getObjectId() { + return objId; + } + + public void setPosture(int posture) { + this.posture = posture; + } + + public void setObjId(long objId) { + this.objId = objId; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/UpdatePvpStatusMessage.java b/src/com/projectswg/common/network/packets/swg/zone/UpdatePvpStatusMessage.java new file mode 100644 index 0000000..84d5370 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/UpdatePvpStatusMessage.java @@ -0,0 +1,86 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import java.util.EnumSet; + +import com.projectswg.common.data.encodables.tangible.PvpFaction; +import com.projectswg.common.data.encodables.tangible.PvpFlag; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class UpdatePvpStatusMessage extends SWGPacket { + public static final int CRC = getCrc("UpdatePvpStatusMessage"); + + private PvpFlag[] pvpFlags; + private PvpFaction pvpFaction; + private long objId; + + public UpdatePvpStatusMessage() { + pvpFlags = new PvpFlag[]{PvpFlag.PLAYER}; + pvpFaction = PvpFaction.NEUTRAL; + objId = 0; + } + + public UpdatePvpStatusMessage(PvpFaction pvpFaction, long objId, PvpFlag... pvpFlags) { + this.pvpFlags = pvpFlags; + this.pvpFaction = pvpFaction; + this.objId = objId; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + EnumSet enumFlags = PvpFlag.getFlags(data.getInt()); + + pvpFlags = enumFlags.toArray(new PvpFlag[enumFlags.size()]); + pvpFaction = PvpFaction.getFactionForCrc(data.getInt()); + objId = data.getLong(); + } + + public NetBuffer encode() { + int length = 22; + int flagBitmask = 0; + NetBuffer data = NetBuffer.allocate(length); + + for(PvpFlag pvpFlag : pvpFlags) + flagBitmask |= pvpFlag.getBitmask(); + + data.addShort(4); + data.addInt(CRC); + data.addInt(flagBitmask); + data.addInt(pvpFaction.getCrc()); + data.addLong(objId); + return data; + } + + public long getObjectId() { return objId; } + public PvpFaction getPlayerFaction() { return pvpFaction; } + public PvpFlag[] getPvpFlags() { return pvpFlags; } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/UpdateTransformMessage.java b/src/com/projectswg/common/network/packets/swg/zone/UpdateTransformMessage.java new file mode 100644 index 0000000..a5e628e --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/UpdateTransformMessage.java @@ -0,0 +1,121 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class UpdateTransformMessage extends SWGPacket { + public static final int CRC = getCrc("UpdateTransformMessage"); + + private long objId; + private short posX; + private short posY; + private short posZ; + private int updateCounter; + private byte direction; + private float speed; + private byte lookAtYaw; + private boolean useLookAtYaw; + + public UpdateTransformMessage() { + this.objId = 0; + this.posX = 0; + this.posY = 0; + this.posZ = 0; + this.updateCounter = 0; + this.direction = 0; + this.speed = 0; + } + + public UpdateTransformMessage(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objId = data.getLong(); + posX = data.getShort(); + posY = data.getShort(); + posZ = data.getShort(); + updateCounter = data.getInt(); + speed = data.getByte(); + direction = data.getByte(); + lookAtYaw = data.getByte(); + useLookAtYaw = data.getBoolean(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(28); + data.addShort(10); + data.addInt(CRC); + data.addLong(objId); + data.addShort(posX); + data.addShort(posY); + data.addShort(posZ); + data.addInt(updateCounter); + data.addByte((byte) speed); + data.addByte(direction); + data.addByte(lookAtYaw); // lookAtYaw + data.addBoolean(useLookAtYaw); // useLookAtYaw + return data; + } + + public void setObjectId(long objId) { this.objId = objId; } + public void setX(short x) { this.posX = x; } + public void setY(short y) { this.posY = y; } + public void setZ(short z) { this.posZ = z; } + public void setUpdateCounter(int count) { this.updateCounter = count; } + public void setDirection(byte d) { this.direction = d; } + public void setSpeed(float speed) { this.speed = speed; } + + public long getObjectId() { return objId; } + public short getX() { return posX; } + public short getY() { return posY; } + public short getZ() { return posZ; } + public int getUpdateCounter() { return updateCounter; } + public byte getDirection() { return direction; } + public float getSpeed() { return speed; } + + public boolean isUseLookAtYaw() { + return useLookAtYaw; + } + + public void setUseLookAtYaw(boolean useLookAtYaw) { + this.useLookAtYaw = useLookAtYaw; + } + + public byte getLookAtYaw() { + return lookAtYaw; + } + + public void setLookAtYaw(byte lookAtYaw) { + this.lookAtYaw = lookAtYaw; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/UpdateTransformWithParentMessage.java b/src/com/projectswg/common/network/packets/swg/zone/UpdateTransformWithParentMessage.java new file mode 100644 index 0000000..4a6b122 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/UpdateTransformWithParentMessage.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone; + +import com.projectswg.common.data.location.Location; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class UpdateTransformWithParentMessage extends SWGPacket { + public static final int CRC = getCrc("UpdateTransformWithParentMessage"); + + private long cellId; + private long objectId; + private short x; + private short y; + private short z; + private int updateCounter; + private byte speed; + private byte direction; + private byte lookDirection; + private boolean useLookDirection; + + public UpdateTransformWithParentMessage() { + + } + + public UpdateTransformWithParentMessage(long cellId, long objectId) { + this.cellId = cellId; + this.objectId = objectId; + } + + public UpdateTransformWithParentMessage(long cellId, long objectId, Location location, int updateCounter, byte speed, byte direction, byte lookDirection, boolean useLookDirection) { + this.cellId = cellId; + this.objectId = objectId; + this.updateCounter = updateCounter; + this.speed = speed; + this.direction = direction; + this.lookDirection = lookDirection; + this.useLookDirection = useLookDirection; + setLocation(location); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + cellId = data.getLong(); + objectId = data.getLong(); + x = data.getShort(); + y = data.getShort(); + z = data.getShort(); + updateCounter = data.getInt(); + speed = data.getByte(); + direction = data.getByte(); + lookDirection = data.getByte(); + useLookDirection= data.getBoolean(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(36); + data.addShort(11); + data.addInt(CRC); + data.addLong(cellId); + data.addLong(objectId); + data.addShort(x); + data.addShort(y); + data.addShort(z); + data.addInt(updateCounter); + data.addByte(speed); + data.addByte(direction); + data.addByte(lookDirection); + data.addBoolean(useLookDirection); + return data; + } + + public void setCellId(long cellId) { + this.cellId = cellId; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + + public void setUpdateCounter(int updateCounter) { + this.updateCounter = updateCounter; + } + + public void setSpeed(byte speed) { + this.speed = speed; + } + + public void setDirection(byte direction) { + this.direction = direction; + } + + public void setLookDirection(byte lookDirection) { + this.lookDirection = lookDirection; + } + + public void setUseLookDirection(boolean useLookDirection) { + this.useLookDirection = useLookDirection; + } + + public long getCellId() { + return cellId; + } + + public long getObjectId() { + return objectId; + } + + public int getUpdateCounter() { + return updateCounter; + } + + public byte getSpeed() { + return speed; + } + + public byte getDirection() { + return direction; + } + + public byte getLookDirection() { + return lookDirection; + } + + public boolean isUseLookDirection() { + return useLookDirection; + } + + public void setLocation(Location location) { + this.x = (short) (location.getX() * 8 + 0.5); + this.y = (short) (location.getY() * 8 + 0.5); + this.z = (short) (location.getZ() * 8 + 0.5); + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/auction/AuctionQueryHeadersMessage.java b/src/com/projectswg/common/network/packets/swg/zone/auction/AuctionQueryHeadersMessage.java new file mode 100644 index 0000000..2f392bb --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/auction/AuctionQueryHeadersMessage.java @@ -0,0 +1,61 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.auction; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class AuctionQueryHeadersMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("AuctionQueryHeadersMessage"); + + public AuctionQueryHeadersMessage() { + + } + + public AuctionQueryHeadersMessage(String command) { + + } + + public AuctionQueryHeadersMessage(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(2); + data.addInt(CRC); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/auction/AuctionQueryHeadersResponseMessage.java b/src/com/projectswg/common/network/packets/swg/zone/auction/AuctionQueryHeadersResponseMessage.java new file mode 100644 index 0000000..db0b821 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/auction/AuctionQueryHeadersResponseMessage.java @@ -0,0 +1,251 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.auction; + +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class AuctionQueryHeadersResponseMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("AuctionQueryHeadersResponseMessage"); + + private int counter; + private int screen; + private List items; + + public AuctionQueryHeadersResponseMessage() { + items = new ArrayList(); + } + + public AuctionQueryHeadersResponseMessage(NetBuffer data) { + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + counter = data.getInt(); + screen = data.getInt(); + String [] locations = new String[data.getInt()]; + for (int i = 0; i < locations.length; i++) + locations[i] = data.getAscii(); + int itemCount = data.getInt(); + AuctionItem [] items = new AuctionItem[itemCount]; + for (int itemI = 0; itemI < itemCount; itemI++) { + AuctionItem item = new AuctionItem(); + item.setItemName(data.getUnicode()); + items[itemI] = item; + } + itemCount = data.getInt(); + if (itemCount != items.length) + throw new IllegalStateException("I WAS LIED TO!"); + for (int itemI = 0; itemI < itemCount; itemI++) { + AuctionItem item = items[itemI]; + item.setObjectId(data.getLong()); + data.getByte(); + item.setPrice(data.getInt()); + item.setExpireTime(data.getInt()*1000L+System.currentTimeMillis()); + if (data.getInt() != item.getPrice()) + throw new IllegalStateException("I WAS LIED TO AT INDEX " + itemI); + item.setVuid(locations[data.getShort()]); + item.setOwnerId(data.getLong()); + item.setOwnerName(locations[data.getShort()]); + data.getLong(); + data.getInt(); + data.getInt(); + data.getShort(); + item.setItemType(data.getInt()); + data.getInt(); + item.setAuctionOptions(data.getInt()); + data.getInt(); + } + data.getShort(); + data.getByte(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(8); + data.addInt(CRC); + data.addInt(counter); + data.addInt(screen); + + Set locations = new LinkedHashSet(); + for (AuctionItem item : items) { + locations.add(item.getVuid()); + locations.add(item.getOwnerName()); + } + data.addInt(items.size()); + for (String item : locations) { + data.addAscii(item); + } + + data.addInt(items.size()); + for (AuctionItem item : items) + data.addUnicode(item.getItemName()); + + data.addInt(items.size()); + + int i = 0; + for(AuctionItem item : items) { + data.addLong(item.getObjectId()); + data.addByte(i); + data.addInt(item.getPrice()); + data.addInt((int) ((item.getExpireTime() - System.currentTimeMillis()) / 1000)); + data.addInt(item.getPrice()); // if != price then auction instead of instant sale + //data.addInt(0); + data.addShort(getString(locations, item.getVuid())); + data.addLong(item.getOwnerId()); + data.addShort(getString(locations, item.getOwnerName())); + data.addLong(0); + data.addInt(0); // unk seen as 2 mostly, doesnt seem to have any effect + data.addInt(0); + data.addShort((short) 0); + data.addInt(item.getItemType()); // gameObjectType/category bitmask + + data.addInt(0); + int options = 0; + + if (item.getStatus() == AuctionState.OFFERED || item.getStatus() == AuctionState.FORSALE) + options |= 0x800; + + data.addInt(item.getAuctionOptions() | options); + data.addInt(0); + i++; + } + + data.addShort(0); + + data.addByte((byte) 0); + return data; + } + + private int getString(Set strings, String str) { + int index = 0; + for (String s : strings) { + if (s.equals(str)) + return index; + index++; + } + return index; + } + + public static enum AuctionState { + PREMIUM (0x400), + WITHDRAW (0x800), + FORSALE (1), + SOLD (2), + EXPIRED (4), + OFFERED (5), + RETRIEVED (6); + + private int id; + + AuctionState(int id) { + this.id = id; + } + + public int getId() { return id; } + } + + public static class AuctionItem { + private long objectId; + private long ownerId; + private long vendorId; + private long buyerId; + private long offerToId; + private int itemType; + private int itemTypeCRC; + private String ownerName; + private String bidderName; + private String itemName; + private String itemDescription; + private String planet; + private String location; + private int price; + private int proxyBid; + private boolean auction; + private String vuid; + private boolean onBazaar = false; + private long expireTime; + private int auctionOptions; + private AuctionState state; + + public long getObjectId() { return objectId; } + public long getOwnerId() { return ownerId; } + public long getVendorId() { return vendorId; } + public long getBuyerId() { return buyerId; } + public long getOfferToId() { return offerToId; } + public int getItemType() { return itemType; } + public String getOwnerName() { return ownerName; } + public String getBidderName() { return bidderName; } + public String getItemName() { return itemName; } + public String getLocation() { return location; } + public int getPrice() { return price; } + public int getProxyBid() { return proxyBid; } + public boolean isAuction() { return auction; } + public String getVuid() { return vuid; } + public AuctionState getStatus() { return state; } + public boolean isOnBazaar() { return onBazaar; } + public int getAuctionOptions() { return auctionOptions; } + public String getPlanet() { return planet; } + public int getItemTypeCRC() { return itemTypeCRC; } + + public String getItemDescription() { return itemDescription; } + public void setObjectId(long objectId) { this.objectId = objectId; } + public void setOwnerId(long ownerId) { this.ownerId = ownerId; } + public void setVendorId(long vendorId) { this.vendorId = vendorId; } + public void setBuyerId(long buyerId) { this.buyerId = buyerId; } + public void setOfferToId(long offerToId) { this.offerToId = offerToId; } + public void setItemType(int itemType) { this.itemType = itemType; } + public void setOwnerName(String ownerName) { this.ownerName = ownerName; } + public void setBidderName(String bidderName) { this.bidderName = bidderName; } + public void setItemName(String itemName) { this.itemName = itemName; } + public void setLocation(String location) { this.location = location; } + public void setItemDescription(String itemDescription) { this.itemDescription = itemDescription; } + public void setPrice(int price) { this.price = price; } + public void setProxyBid(int proxyBid) { this.proxyBid = proxyBid; } + public void setAuction(boolean auction) { this.auction = auction; } + public void setVuid(String vuid) { this.vuid = vuid; } + public void setStatus(AuctionState state) { this.state = state; } + public void setOnBazaar(boolean onBazaar) { this.onBazaar = onBazaar; } + public long getExpireTime() { return expireTime; } + public void setExpireTime(long expireTime) { this.expireTime = expireTime; } + public void setAuctionOptions(int auctionOptions) { this.auctionOptions = auctionOptions; } + public void setPlanet(String planet) { this.planet = planet; } + public void setItemTypeCRC(int itemTypeCRC) { this.itemTypeCRC = itemTypeCRC; } + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/auction/CancelLiveAuctionMessage.java b/src/com/projectswg/common/network/packets/swg/zone/auction/CancelLiveAuctionMessage.java new file mode 100644 index 0000000..2d95d39 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/auction/CancelLiveAuctionMessage.java @@ -0,0 +1,61 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.auction; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class CancelLiveAuctionMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("CancelLiveAuctionMessage"); + + public CancelLiveAuctionMessage() { + + } + + public CancelLiveAuctionMessage(String command) { + + } + + public CancelLiveAuctionMessage(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(2); + data.addInt(CRC); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/auction/CancelLiveAuctionResponseMessage.java b/src/com/projectswg/common/network/packets/swg/zone/auction/CancelLiveAuctionResponseMessage.java new file mode 100644 index 0000000..e8d365e --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/auction/CancelLiveAuctionResponseMessage.java @@ -0,0 +1,61 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.auction; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class CancelLiveAuctionResponseMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("CancelLiveAuctionResponseMessage"); + + public CancelLiveAuctionResponseMessage() { + + } + + public CancelLiveAuctionResponseMessage(String command) { + + } + + public CancelLiveAuctionResponseMessage(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(2); + data.addInt(CRC); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/auction/CommoditiesItemTypeListRequest.java b/src/com/projectswg/common/network/packets/swg/zone/auction/CommoditiesItemTypeListRequest.java new file mode 100644 index 0000000..d5a35f0 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/auction/CommoditiesItemTypeListRequest.java @@ -0,0 +1,58 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.auction; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class CommoditiesItemTypeListRequest extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("CommoditiesItemTypeListRequest"); + + private String from; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + from = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(8 + from.length()); + data.addShort(2); + data.addInt(CRC); + data.addAscii(from); + return data; + } + + public String getFrom() { + return from; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/auction/CommoditiesItemTypeListResponse.java b/src/com/projectswg/common/network/packets/swg/zone/auction/CommoditiesItemTypeListResponse.java new file mode 100644 index 0000000..3aba888 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/auction/CommoditiesItemTypeListResponse.java @@ -0,0 +1,110 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.auction; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class CommoditiesItemTypeListResponse extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("CommoditiesItemTypeListResponse"); + + private String serverName; + private int subCategoryCounter; + private int subCatagory; + private int itemsInSubCategory; + private String categoryName; + private int placeholder; + private String type; + + public CommoditiesItemTypeListResponse(String serverName, int subCategoryCounter, int subCatagory, int itemsInSubCategory, String categoryName, int placeholder, String type) { + this.serverName = serverName; + this.subCategoryCounter = subCategoryCounter; + this.subCatagory = subCatagory; + this.itemsInSubCategory = itemsInSubCategory; + this.categoryName = categoryName; + this.placeholder = placeholder; + this.type = type; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + serverName = data.getAscii(); + subCategoryCounter = data.getInt(); + subCatagory = data.getInt(); + itemsInSubCategory = data.getInt(); + categoryName = data.getAscii(); + placeholder = data.getInt(); + type = data.getUnicode(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(30 + serverName.length() + categoryName.length() + type.length()*2); + data.addShort(8); + data.addInt(CRC); + data.addAscii(serverName); + data.addInt(subCategoryCounter); + data.addInt(subCatagory); + data.addInt(itemsInSubCategory); + data.addAscii(categoryName); + data.addInt(placeholder); + data.addUnicode(type); + return data; + } + + public String getServerName() { + return serverName; + } + + public int getSubCategoryCounter() { + return subCategoryCounter; + } + + public int getSubCatagory() { + return subCatagory; + } + + public int getItemsInSubCategory() { + return itemsInSubCategory; + } + + public String getCategoryName() { + return categoryName; + } + + public int getPlaceholder() { + return placeholder; + } + + public String getType() { + return type; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/auction/GetAuctionDetails.java b/src/com/projectswg/common/network/packets/swg/zone/auction/GetAuctionDetails.java new file mode 100644 index 0000000..8470283 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/auction/GetAuctionDetails.java @@ -0,0 +1,65 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.auction; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class GetAuctionDetails extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("GetAuctionDetails"); + + private long auctionId; + + public GetAuctionDetails() { + this(0); + } + + public GetAuctionDetails(long auctionId) { + this.auctionId = auctionId; + } + + public GetAuctionDetails(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + auctionId = data.getLong(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(2); + data.addInt(CRC); + data.addLong(auctionId); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/auction/GetAuctionDetailsResponse.java b/src/com/projectswg/common/network/packets/swg/zone/auction/GetAuctionDetailsResponse.java new file mode 100644 index 0000000..1e6e408 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/auction/GetAuctionDetailsResponse.java @@ -0,0 +1,92 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.auction; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class GetAuctionDetailsResponse extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("GetAuctionDetailsResponse"); + + private long itemId; + private Map properties; + private String itemName; + + public GetAuctionDetailsResponse() { + this(0, new HashMap(), ""); + } + + public GetAuctionDetailsResponse(long itemId, Map properties, String itemName) { + this.itemId = itemId; + this.properties = properties; + this.itemName = itemName; + } + + public GetAuctionDetailsResponse(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + itemId = data.getLong(); + data.getInt(); + int count = data.getInt(); + for (int i = 0; i < count; i++) { + String key = data.getAscii(); + String val = data.getUnicode(); + properties.put(key, val); + } + itemName = data.getAscii(); + data.getShort(); // 0 + } + + public NetBuffer encode() { + int strSize = 0; + for (Entry e : properties.entrySet()) + strSize += 6 + e.getKey().length() + e.getValue().length()*2; + NetBuffer data = NetBuffer.allocate(18 + strSize); + data.addShort(9); + data.addInt(CRC); + data.addLong(itemId); + data.addInt(properties.size()); + for (Entry e : properties.entrySet()) { + data.addAscii(e.getKey()); + data.addUnicode(e.getValue()); + } + data.addAscii(itemName); + data.addShort(0); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/auction/IsVendorOwnerMessage.java b/src/com/projectswg/common/network/packets/swg/zone/auction/IsVendorOwnerMessage.java new file mode 100644 index 0000000..fd06625 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/auction/IsVendorOwnerMessage.java @@ -0,0 +1,31 @@ +package com.projectswg.common.network.packets.swg.zone.auction; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class IsVendorOwnerMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("IsVendorOwnerMessage"); + + private long terminalId; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + terminalId = data.getLong(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(2); + data.addInt(CRC); + data.addLong(terminalId); + return data; + } + + public long getTerminalId() { + return terminalId; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/auction/IsVendorOwnerResponseMessage.java b/src/com/projectswg/common/network/packets/swg/zone/auction/IsVendorOwnerResponseMessage.java new file mode 100644 index 0000000..a08e35b --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/auction/IsVendorOwnerResponseMessage.java @@ -0,0 +1,120 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.auction; + +import com.projectswg.common.data.EnumLookup; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class IsVendorOwnerResponseMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("IsVendorOwnerResponseMessage"); + + private int ownerResult; + private int auctionResult; + private long containerId; + private String marketName; + private short maxPageSize; + + public IsVendorOwnerResponseMessage(long containerId, String marketName, int auctionResult, int ownerResult, short maxPageSize) { + super(); + this.containerId = containerId; + this.marketName = marketName; + this.auctionResult = auctionResult; + this.ownerResult = ownerResult; + this.maxPageSize = maxPageSize; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + containerId = data.getLong(); + auctionResult = data.getInt(); + marketName = data.getAscii(); + ownerResult = data.getInt(); + maxPageSize = data.getShort(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(26 + marketName.length()); + data.addShort(5); + data.addInt(CRC); + data.addLong(containerId); + data.addInt(auctionResult); + data.addAscii(marketName); + data.addInt(ownerResult); + data.addShort(maxPageSize); + return data; + } + + public int getOwnerResult() { + return ownerResult; + } + + public int getAuctionResult() { + return auctionResult; + } + + public long getContainerId() { + return containerId; + } + + public String getMarketName() { + return marketName; + } + + public short getMaxPageSize() { + return maxPageSize; + } + + public enum VendorOwnerResult { + UNDEFINED (Integer.MIN_VALUE), + IS_OWNER (0), + IS_NOT_OWNER (1), + IS_BAZAAR (2); + + + private static final EnumLookup LOOKUP = new EnumLookup<>(VendorOwnerResult.class, t -> t.getId()); + + private int id; + + VendorOwnerResult(int id) { + this.id = id; + } + + public int getId() { + return id; + } + + public static VendorOwnerResult getTypeForInt(int id) { + return LOOKUP.getEnum(id, UNDEFINED); + } + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/auction/RetrieveAuctionItemMessage.java b/src/com/projectswg/common/network/packets/swg/zone/auction/RetrieveAuctionItemMessage.java new file mode 100644 index 0000000..131a4a4 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/auction/RetrieveAuctionItemMessage.java @@ -0,0 +1,61 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.auction; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class RetrieveAuctionItemMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("RetrieveAuctionItemMessage"); + + public RetrieveAuctionItemMessage() { + + } + + public RetrieveAuctionItemMessage(String command) { + + } + + public RetrieveAuctionItemMessage(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(2); + data.addInt(CRC); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/auction/RetrieveAuctionItemResponseMessage.java b/src/com/projectswg/common/network/packets/swg/zone/auction/RetrieveAuctionItemResponseMessage.java new file mode 100644 index 0000000..af2332f --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/auction/RetrieveAuctionItemResponseMessage.java @@ -0,0 +1,61 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.auction; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class RetrieveAuctionItemResponseMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("RetrieveAuctionItemResponseMessage"); + + public RetrieveAuctionItemResponseMessage() { + + } + + public RetrieveAuctionItemResponseMessage(String command) { + + } + + public RetrieveAuctionItemResponseMessage(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(2); + data.addInt(CRC); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/baselines/Baseline.java b/src/com/projectswg/common/network/packets/swg/zone/baselines/Baseline.java new file mode 100644 index 0000000..9a376a0 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/baselines/Baseline.java @@ -0,0 +1,103 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.baselines; + +import java.nio.charset.StandardCharsets; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class Baseline extends SWGPacket { + public static final int CRC = getCrc("BaselinesMessage"); + + private BaselineType type; + private int num; + private short opCount; + private long objId; + private byte [] baseData; + + public Baseline() { + + } + + public Baseline(long objId, Baseline subData) { + this.objId = objId; + type = subData.getType(); + num = subData.getNum(); + baseData = subData.encodeBaseline().array(); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objId = data.getLong(); + type = BaselineType.valueOf(new StringBuffer(new String(data.getArray(4), StandardCharsets.UTF_8)).reverse().toString()); + num = data.getByte(); + baseData = data.getArrayLarge(); + if (baseData.length >= 2) + opCount = NetBuffer.wrap(baseData).getShort(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(25 + baseData.length); + data.addShort(5); + data.addInt(CRC); + data.addLong(objId); + data.addRawArray(new StringBuffer(type.toString()).reverse().toString().getBytes(StandardCharsets.UTF_8)); + data.addByte(num); + data.addInt(baseData.length + 2); + data.addShort((opCount == 0 ? 5 : opCount)); + data.addRawArray(baseData); + return data; + } + + public NetBuffer encodeBaseline() { return NetBuffer.allocate(0); } + + public long getObjectId() { return objId; } + + public void setType(BaselineType type) { this.type = type; } + public void setNum(int num) { this.num = num; } + public void setId(long id) { this.objId = id; } + public void setBaselineData(byte [] data) { this.baseData = data; } + public void setOperandCount(int count) { this.opCount = (short) count;} + + public BaselineType getType() { return type; } + public int getNum() { return num; } + public long getId() { return objId; } + public byte [] getBaselineData() { return baseData; } + + public enum BaselineType { + BMRK, BUIO, CREO, FCYT, + GILD, GRUP, HINO, INSO, + ITNO, MINO, MISO, MSCO, + PLAY, RCNO, SCLT, STAO, + SHIP, TANO, WAYP, WEAO + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/building/UpdateCellPermissionMessage.java b/src/com/projectswg/common/network/packets/swg/zone/building/UpdateCellPermissionMessage.java new file mode 100644 index 0000000..5b3ddca --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/building/UpdateCellPermissionMessage.java @@ -0,0 +1,72 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.building; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class UpdateCellPermissionMessage extends SWGPacket { + public static final int CRC = getCrc("UpdateCellPermissionMessage"); + + private byte permissionFlag; + private long cellId; + + public UpdateCellPermissionMessage() { + permissionFlag = 0; + cellId = 0; + } + + public UpdateCellPermissionMessage(byte permissionFlag, long cellId) { + this.permissionFlag = permissionFlag; + this.cellId = cellId; + } + + public UpdateCellPermissionMessage(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + permissionFlag = data.getByte(); + cellId = data.getLong(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(15); + data.addShort(2); + data.addInt(CRC); + data.addByte(permissionFlag); + data.addLong(cellId); + return data; + } + + public long getCellId() { return cellId; } + public byte getPermissions() { return permissionFlag; } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatAddModeratorToRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatAddModeratorToRoom.java new file mode 100644 index 0000000..06a0f84 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatAddModeratorToRoom.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatAddModeratorToRoom extends SWGPacket { + + public static final int CRC = getCrc("ChatAddModeratorToRoom"); + + private ChatAvatar avatar; + private String room; + private int sequence; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + avatar = data.getEncodable(ChatAvatar.class); + room = data.getAscii(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(12 + room.length() + avatar.encode().length); + data.addShort(4); + data.addInt(CRC); + data.addEncodable(avatar); + data.addAscii(room); + data.addInt(sequence); + return data; + } + + public ChatAvatar getAvatar() { + return avatar; + } + + public String getRoom() { + return room; + } + + public int getSequence() { + return sequence; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatBanAvatarFromRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatBanAvatarFromRoom.java new file mode 100644 index 0000000..e4f7327 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatBanAvatarFromRoom.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatBanAvatarFromRoom extends SWGPacket { + + public static final int CRC = getCrc("ChatBanAvatarFromRoom"); + + private ChatAvatar avatar; + private String room; + private int sequence; + + public ChatBanAvatarFromRoom() { + + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + avatar = data.getEncodable(ChatAvatar.class); + room = data.getAscii(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(12 + avatar.encode().length + room.length()); + data.addShort(4); + data.addInt(CRC); + data.addEncodable(avatar); + data.addAscii(room); + data.addInt(sequence); + return data; + } + + public ChatAvatar getAvatar() { + return avatar; + } + + public String getRoom() { + return room; + } + + public int getSequence() { + return sequence; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatCreateRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatCreateRoom.java new file mode 100644 index 0000000..f7c1bf7 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatCreateRoom.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatCreateRoom extends SWGPacket { + public static final int CRC = getCrc("ChatCreateRoom"); + + private boolean isPublic; + private boolean isModerated; + private String owner; + private String roomName; + private String roomTitle; + private int sequence; + + public ChatCreateRoom() {} + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + isPublic = data.getBoolean(); + isModerated = data.getBoolean(); + owner = data.getAscii(); + roomName = data.getAscii(); + roomTitle = data.getAscii(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(18 + owner.length() + roomName.length() + roomTitle.length()); + data.addShort(7); + data.addInt(CRC); + data.addBoolean(isPublic); + data.addBoolean(isModerated); + data.addAscii(owner); + data.addAscii(roomName); + data.addAscii(roomTitle); + data.addInt(sequence); + return data; + } + + public boolean isPublic() { + return isPublic; + } + + public boolean isModerated() { + return isModerated; + } + + public String getOwner() { + return owner; + } + + public String getRoomName() { + return roomName; + } + + public String getRoomTitle() { + return roomTitle; + } + + public int getSequence() { + return sequence; + } + + @Override + public String toString() { + return "ChatCreateRoom[isPublic=" + isPublic + ", isModerated=" + isModerated + + ", owner='" + owner + "'," + "roomName='" + roomName + "'," + "roomTitle='" + roomTitle + '\'' + + ", sequence=" + sequence + "]"; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatDeletePersistentMessage.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatDeletePersistentMessage.java new file mode 100644 index 0000000..851afdc --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatDeletePersistentMessage.java @@ -0,0 +1,56 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatDeletePersistentMessage extends SWGPacket { + public static final int CRC = getCrc("ChatDeletePersistentMessage"); + + private int mailId; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + + mailId = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10); + data.addShort(2); + data.addInt(CRC); + data.addInt(mailId); + return data; + } + + public int getMailId() { return mailId; } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatDestroyRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatDestroyRoom.java new file mode 100644 index 0000000..7c241de --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatDestroyRoom.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatDestroyRoom extends SWGPacket { + public static final int CRC = getCrc("ChatDestroyRoom"); + + private int roomId; + private int sequence; + + public ChatDestroyRoom() {} + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + roomId = data.getInt(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(3); + data.addInt(CRC); + data.addInt(roomId); + data.addInt(sequence); + return data; + } + + public int getRoomId() { + return roomId; + } + + public int getSequence() { + return sequence; + } + + @Override + public String toString() { + return "ChatDestroyRoom[roomId=" + roomId + ", sequence=" + sequence + "]"; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatEnterRoomById.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatEnterRoomById.java new file mode 100644 index 0000000..efef64c --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatEnterRoomById.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatEnterRoomById extends SWGPacket { + public static final int CRC = getCrc("ChatEnterRoomById"); + + private int sequence; + private int roomId; + private String roomPath; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + + sequence = data.getInt(); + roomId = data.getInt(); + roomPath = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10 + roomPath.length()); + data.addShort(4); + data.addInt(sequence); + data.addInt(roomId); + data.addAscii(roomPath); + return data; + } + + public int getSequence() { + return sequence; + } + + public int getRoomId() { + return roomId; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatFriendsListUpdate.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatFriendsListUpdate.java new file mode 100644 index 0000000..0f91387 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatFriendsListUpdate.java @@ -0,0 +1,70 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatFriendsListUpdate extends SWGPacket { + public static final int CRC = getCrc("ChatFriendsListUpdate"); + + private ChatAvatar friend; + private boolean online; + + public ChatFriendsListUpdate() {} + + public ChatFriendsListUpdate(ChatAvatar friend, boolean online) { + this.friend = friend; + this.online = online; + } + + public ChatFriendsListUpdate(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + friend = data.getEncodable(ChatAvatar.class); + online = data.getBoolean(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(7 + friend.encode().length); + data.addShort(3); + data.addInt(CRC); + data.addEncodable(friend); + data.addBoolean(online); + return data; + } + + public ChatAvatar getFriend() { + return friend; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatIgnoreList.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatIgnoreList.java new file mode 100644 index 0000000..cab812b --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatIgnoreList.java @@ -0,0 +1,113 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import java.util.ArrayList; +import java.util.List; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatIgnoreList extends SWGPacket { + + public static final int CRC = 0xF8C275B0; + + private long objectId; + private List ignoreList; + + public ChatIgnoreList() { + objectId = 0; + ignoreList = new ArrayList(); + } + + public ChatIgnoreList(NetBuffer data) { + decode(data); + } + + public void addName(String game, String galaxy, String name) { + addName(new IgnoreListItem(game, galaxy, name)); + } + + public void addName(IgnoreListItem name) { + ignoreList.add(name); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objectId = data.getLong(); + int listCount = data.getInt(); + for (int i = 0; i < listCount; i++) { + String game = data.getAscii(); + String galaxy = data.getAscii(); + String name = data.getAscii(); + addName(game, galaxy, name); + } + } + + public NetBuffer encode() { + int extraSize = 0; + for (IgnoreListItem item : ignoreList) + extraSize += 6 + item.getGame().length() + item.getGalaxy().length() + item.getName().length(); + NetBuffer data = NetBuffer.allocate(18 + extraSize); + data.addShort(3); + data.addInt(CRC); + data.addLong(objectId); + data.addInt(ignoreList.size()); + for (IgnoreListItem item : ignoreList) { + data.addAscii(item.getGame()); + data.addAscii(item.getGalaxy()); + data.addAscii(item.getName()); + } + return data; + } + + public static class IgnoreListItem { + private String game; + private String galaxy; + private String name; + + public IgnoreListItem() { + this("SWG", "", ""); + } + + public IgnoreListItem(String game, String galaxy, String name) { + this.game = game; + this.galaxy = galaxy; + this.name = name; + } + + public String getGame() { return game; } + public String getGalaxy() { return galaxy; } + public String getName() { return name; } + public void setGame(String game) { this.game = game; } + public void setGalaxy(String galaxy) { this.galaxy = galaxy; } + public void setName(String name) { this.name = name; } + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatInstantMessageToCharacter.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatInstantMessageToCharacter.java new file mode 100644 index 0000000..86aaddd --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatInstantMessageToCharacter.java @@ -0,0 +1,98 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatInstantMessageToCharacter extends SWGPacket { + public static final int CRC = getCrc("ChatInstantMessageToCharacter"); + + private String galaxy; + private String character; + private String message; + private String outOfBand; + private int sequence; + + public ChatInstantMessageToCharacter() { + this("", "", "", "", 0); + } + + public ChatInstantMessageToCharacter(String galaxy, String character, String message, int sequence) { + this(galaxy, character, message, "", sequence); + } + + public ChatInstantMessageToCharacter(String galaxy, String character, String message, String outOfBand, int sequence) { + this.galaxy = galaxy; + this.character = character; + this.message = message; + this.outOfBand = outOfBand; + this.sequence = sequence; + } + + public ChatInstantMessageToCharacter(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + data.getAscii(); + galaxy = data.getAscii(); + character = data.getAscii(); + message = data.getUnicode(); + outOfBand = data.getUnicode(); + sequence = data.getInt(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(27 + galaxy.length() + character.length() + message.length()*2); + data.addShort(2); + data.addInt(CRC); + data.addAscii("SWG"); + data.addAscii(galaxy); + data.addAscii(character); + data.addUnicode(message); + data.addUnicode(outOfBand); + data.addInt(sequence); + return data; + } + + public String getGalaxy() { return galaxy; } + public String getCharacter() { return character; } + public String getMessage() { return message; } + public String getOutOfBand() { return outOfBand; } + public int getSequence() { return sequence; } + + public void setGalaxy(String galaxy) { this.galaxy = galaxy; } + public void setCharacter(String character) { this.character = character; } + public void setMessage(String message) { this.message = message; } + public void setOutOfBand(String outOfBand) { this.outOfBand = outOfBand; } + public void setSequence(int sequence) { this.sequence = sequence; } + +} diff --git a/src/com/projectswg/common/javafx/ResourceUtilities.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatInstantMessageToClient.java similarity index 54% rename from src/com/projectswg/common/javafx/ResourceUtilities.java rename to src/com/projectswg/common/network/packets/swg/zone/chat/ChatInstantMessageToClient.java index 6dcb5b8..55c7cb9 100644 --- a/src/com/projectswg/common/javafx/ResourceUtilities.java +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatInstantMessageToClient.java @@ -25,74 +25,68 @@ * along with Holocore. If not, see . * * * ***********************************************************************************/ -package com.projectswg.common.javafx; +package com.projectswg.common.network.packets.swg.zone.chat; -import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.concurrent.atomic.AtomicReference; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; -public class ResourceUtilities { - - private static final AtomicReference THEME = new AtomicReference<>("."); - private static final AtomicReference> SRC = new AtomicReference<>(ResourceUtilities.class); - private static final String RESOURCES_PATH = "/res/"; +public class ChatInstantMessageToClient extends SWGPacket { + public static final int CRC = getCrc("ChatInstantMessageToClient"); - public static void setTheme(String theme) { - THEME.set(theme); + private String galaxy; + private String character; + private String message; + private String outOfBand; + + public ChatInstantMessageToClient() { + this("", "", "", ""); } - public static void setPrimarySource(Class c) { - SRC.set(c); + public ChatInstantMessageToClient(String galaxy, String character, String message) { + this(galaxy, character, message, ""); } - public static File getSourceDirectory() { - try { - return new File(SRC.get().getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile(); - } catch (URISyntaxException e) { - return null; - } + public ChatInstantMessageToClient(String galaxy, String character, String message, String outOfBand) { + this.galaxy = galaxy; + this.character = character; + this.message = message; + this.outOfBand = outOfBand; } - public static File getResourcesDirectory() { - File source = getSourceDirectory(); - if (source == null) - return null; - return new File(source, RESOURCES_PATH); + public ChatInstantMessageToClient(NetBuffer data) { + decode(data); } - public static URI getResourceURI(String path) { - File file = getResource(path); - if (file == null) - return null; - return file.toURI(); + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + data.getAscii(); // "SWG" + galaxy = data.getAscii(); + character = data.getAscii(); + message = data.getUnicode(); + outOfBand = data.getUnicode(); } - public static File getResource(String path) { - try { - String parent = new File(SRC.get().getProtectionDomain().getCodeSource().getLocation().toURI()).getParent(); - return new File(parent, cleanupPath(RESOURCES_PATH + THEME.get() + '/' + path)); - } catch (URISyntaxException e) { - return null; - } + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(23 + galaxy.length() + character.length() + message.length()*2 + outOfBand.length()*2); + data.addShort(2); + data.addInt(CRC); + data.addAscii("SWG"); + data.addAscii(galaxy); + data.addAscii(character); + data.addUnicode(message); + data.addUnicode(outOfBand); + return data; } - public static URL getClassResource(String path) { - return SRC.get().getClassLoader().getResource(path); - } + public String getGalaxy() { return galaxy; } + public String getCharacter() { return character; } + public String getMessage() { return message; } + public String getOutOfBand() { return outOfBand; } - public static File getGeneralResource(String path) { - try { - String parent = new File(SRC.get().getProtectionDomain().getCodeSource().getLocation().toURI()).getParent(); - return new File(parent, cleanupPath(RESOURCES_PATH + "common/" + path)); - } catch (URISyntaxException e) { - return null; - } - } - - private static String cleanupPath(String path) { - return path.replace('/', File.separatorChar); - } + public void setGalaxy(String galaxy) { this.galaxy = galaxy; } + public void setCharacter(String character) { this.character = character; } + public void setMessage(String message) { this.message = message; } + public void setOutOfBand(String outOfBand) { this.outOfBand = outOfBand; } } diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatInviteAvatarToRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatInviteAvatarToRoom.java new file mode 100644 index 0000000..f6daea1 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatInviteAvatarToRoom.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatInviteAvatarToRoom extends SWGPacket { + public static final int CRC = getCrc("ChatInviteAvatarToRoom"); + + private ChatAvatar avatar; + private String room; + + public ChatInviteAvatarToRoom() {} + + public ChatInviteAvatarToRoom(ChatAvatar avatar, String room) { + this.avatar = avatar; + this.room = room; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + avatar = data.getEncodable(ChatAvatar.class); + room = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(8 + avatar.getLength() + room.length()); + data.addShort(3); + data.addInt(CRC); + data.addEncodable(avatar); + data.addAscii(room); + return data; + } + + public ChatAvatar getAvatar() { + return avatar; + } + + public String getRoom() { + return room; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatKickAvatarFromRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatKickAvatarFromRoom.java new file mode 100644 index 0000000..55a2513 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatKickAvatarFromRoom.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatKickAvatarFromRoom extends SWGPacket { + public static final int CRC = getCrc("ChatKickAvatarFromRoom"); + + private ChatAvatar avatar; + private String room; + + public ChatKickAvatarFromRoom() {} + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + avatar = data.getEncodable(ChatAvatar.class); + room = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(8 + avatar.encode().length); + data.addShort(3); + data.addInt(CRC); + data.addEncodable(avatar); + data.addAscii(room); + return data; + } + + public ChatAvatar getAvatar() { + return avatar; + } + + public String getRoom() { + return room; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnAddModeratorToRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnAddModeratorToRoom.java new file mode 100644 index 0000000..9720694 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnAddModeratorToRoom.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatOnAddModeratorToRoom extends SWGPacket { + public static final int CRC = getCrc("ChatOnAddModeratorToRoom"); + + private ChatAvatar target; + private ChatAvatar moderator; + private int result; + private String room; + private int sequence; + + public ChatOnAddModeratorToRoom(ChatAvatar target, ChatAvatar moderator, int result, String room, int sequence) { + this.target = target; + this.moderator = moderator; + this.result = result; + this.room = room; + this.sequence = sequence; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + target = data.getEncodable(ChatAvatar.class); + moderator = data.getEncodable(ChatAvatar.class); + result = data.getInt(); + room = data.getAscii(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(16 + target.encode().length + moderator.encode().length + room.length()); + data.addShort(1); + data.addInt(CRC); + data.addEncodable(target); + data.addEncodable(moderator); + data.addInt(result); + data.addAscii(room); + data.addInt(sequence); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnBanAvatarFromRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnBanAvatarFromRoom.java new file mode 100644 index 0000000..1f22b79 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnBanAvatarFromRoom.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatOnBanAvatarFromRoom extends SWGPacket { + public static final int CRC = getCrc("ChatOnBanAvatarFromRoom"); + + private String room; + private ChatAvatar moderator; + private ChatAvatar target; + private int result; + private int sequence; + + public ChatOnBanAvatarFromRoom(String room, ChatAvatar moderator, ChatAvatar target, int result, int sequence) { + this.room = room; + this.moderator = moderator; + this.target = target; + this.result = result; + this.sequence = sequence; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + room = data.getAscii(); + moderator = data.getEncodable(ChatAvatar.class); + target = data.getEncodable(ChatAvatar.class); + result = data.getInt(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(16 + moderator.encode().length + target.encode().length + room.length()); + data.addShort(6); + data.addInt(CRC); + data.addAscii(room); + data.addEncodable(moderator); + data.addEncodable(target); + data.addInt(result); + data.addInt(sequence); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnConnectAvatar.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnConnectAvatar.java new file mode 100644 index 0000000..62b5878 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnConnectAvatar.java @@ -0,0 +1,62 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatOnConnectAvatar extends SWGPacket { + public static final int CRC = getCrc("ChatOnConnectAvatar"); + + public ChatOnConnectAvatar() { + + } + + public ChatOnConnectAvatar(String command) { + + } + + public ChatOnConnectAvatar(NetBuffer data) { + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(2); + data.addInt(CRC); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnCreateRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnCreateRoom.java new file mode 100644 index 0000000..d8fc66f --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnCreateRoom.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatRoom; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatOnCreateRoom extends SWGPacket { + public static final int CRC = getCrc("ChatOnCreateRoom"); + + private int result; + private ChatRoom room; + private int sequence; + + public ChatOnCreateRoom() {} + + public ChatOnCreateRoom(int result, ChatRoom room, int sequence) { + this.result = result; + this.room = room; + this.sequence = sequence; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + result = data.getInt(); + room = data.getEncodable(ChatRoom.class); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14 + room.encode().length); + data.addShort(1); + data.addInt(CRC); + data.addInt(result); + data.addEncodable(room); + data.addInt(sequence); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnDestroyRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnDestroyRoom.java new file mode 100644 index 0000000..a09800c --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnDestroyRoom.java @@ -0,0 +1,80 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatOnDestroyRoom extends SWGPacket { + public static final int CRC = getCrc("ChatOnDestroyRoom"); + + private ChatAvatar owner; + private int result; + private int roomId; + private int sequence; + + public ChatOnDestroyRoom() { + this(null, 0, 0, 0); + } + + public ChatOnDestroyRoom(ChatAvatar owner, int result, int roomId, int sequence) { + this.owner = owner; + this.result = result; + this.roomId = roomId; + this.sequence = sequence; + } + + public ChatOnDestroyRoom(NetBuffer data) { + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + owner = data.getEncodable(ChatAvatar.class); + result = data.getInt(); + roomId = data.getInt(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(18 + owner.getLength()); + data.addShort(5); + data.addInt(CRC); + data.addEncodable(owner); + data.addInt(result); + data.addInt(roomId); + data.addInt(sequence); + return data; + } + +} + diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnEnteredRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnEnteredRoom.java new file mode 100644 index 0000000..cd3d5c1 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnEnteredRoom.java @@ -0,0 +1,85 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.data.encodables.chat.ChatResult; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatOnEnteredRoom extends SWGPacket { + + public static final int CRC = getCrc("ChatOnEnteredRoom"); + + private ChatAvatar avatar; + private ChatResult result; + private int chatRoomId; + private int sequence; + + public ChatOnEnteredRoom() { + + } + + public ChatOnEnteredRoom(ChatAvatar avatar, int chatRoomId, int sequence) { + this(avatar, ChatResult.NONE, chatRoomId, sequence); + } + + public ChatOnEnteredRoom(ChatAvatar avatar, ChatResult result, int chatRoomId, int sequence) { + this.avatar = avatar; + this.result = result; + this.chatRoomId = chatRoomId; + this.sequence = sequence; + } + + public ChatOnEnteredRoom(NetBuffer data) { + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + avatar = data.getEncodable(ChatAvatar.class); + result = ChatResult.fromInteger(data.getInt()); + chatRoomId = data.getInt(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(avatar.getLength() + 18); + data.addShort(5); + data.addInt(CRC); + data.addEncodable(avatar); + data.addInt(result.getCode()); + data.addInt(chatRoomId); + data.addInt(sequence); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnInviteToRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnInviteToRoom.java new file mode 100644 index 0000000..3b8ea2a --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnInviteToRoom.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatOnInviteToRoom extends SWGPacket { + public static final int CRC = getCrc("ChatOnInviteToRoom"); + + private String room; + private ChatAvatar sender; + private ChatAvatar invited; + private int result; + + public ChatOnInviteToRoom() {} + + public ChatOnInviteToRoom(String room, ChatAvatar sender, ChatAvatar invited, int result) { + this.room = room; + this.sender = sender; + this.invited = invited; + this.result = result; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + room = data.getAscii(); + sender = data.getEncodable(ChatAvatar.class); + invited = data.getEncodable(ChatAvatar.class); + result = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(12 + sender.getLength() + invited.getLength() + room.length()); + data.addShort(5); + data.addInt(CRC); + data.addAscii(room); + data.addEncodable(sender); + data.addEncodable(invited); + data.addInt(result); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnKickAvatarFromRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnKickAvatarFromRoom.java new file mode 100644 index 0000000..acfe2e5 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnKickAvatarFromRoom.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatOnKickAvatarFromRoom extends SWGPacket { + public static final int CRC = getCrc("ChatOnKickAvatarFromRoom"); + + private ChatAvatar target; + private ChatAvatar moderator; + private int result; + private String room; + + public ChatOnKickAvatarFromRoom(ChatAvatar target, ChatAvatar moderator, int result, String room) { + this.target = target; + this.moderator = moderator; + this.result = result; + this.room = room; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + target = data.getEncodable(ChatAvatar.class); + moderator = data.getEncodable(ChatAvatar.class); + result = data.getInt(); + room = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(16 + target.encode().length + moderator.encode().length + room.length()); + data.addShort(6); + data.addInt(CRC); + data.addEncodable(target); + data.addEncodable(moderator); + data.addInt(result); + data.addAscii(room); + return data; + } +} diff --git a/src/com/projectswg/common/javafx/PSWGDoubleProperty.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnLeaveRoom.java similarity index 64% rename from src/com/projectswg/common/javafx/PSWGDoubleProperty.java rename to src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnLeaveRoom.java index dbeb51c..66d50f2 100644 --- a/src/com/projectswg/common/javafx/PSWGDoubleProperty.java +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnLeaveRoom.java @@ -25,61 +25,53 @@ * along with Holocore. If not, see . * * * ***********************************************************************************/ -package com.projectswg.common.javafx; +package com.projectswg.common.network.packets.swg.zone.chat; -import java.util.HashSet; -import java.util.Set; +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; -import javafx.beans.property.Property; -import javafx.beans.property.SimpleDoubleProperty; -import javafx.beans.value.ChangeListener; - -public class PSWGDoubleProperty extends SimpleDoubleProperty { +public class ChatOnLeaveRoom extends SWGPacket { + public static final int CRC = getCrc("ChatOnLeaveRoom"); - private final Set> listeners; - private final Set> properties; + private ChatAvatar avatar; + private int result; + private int chatRoomId; + private int sequence; - public PSWGDoubleProperty() { - super(); - listeners = new HashSet<>(); - properties = new HashSet<>(); + public ChatOnLeaveRoom() { + } - public PSWGDoubleProperty(double initialValue) { - super(initialValue); - listeners = new HashSet<>(); - properties = new HashSet<>(); + public ChatOnLeaveRoom(ChatAvatar avatar, int result, int chatRoomId, int sequence) { + this.avatar = avatar; + this.result = result; + this.chatRoomId = chatRoomId; + this.sequence = sequence; } - @Override - public void addListener(ChangeListener listener) { - listeners.add(listener); - super.addListener(listener); + public ChatOnLeaveRoom(NetBuffer data) { + decode(data); } - @Override - public void removeListener(ChangeListener listener) { - listeners.remove(listener); - super.removeListener(listener); + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + avatar = data.getEncodable(ChatAvatar.class); + result = data.getInt(); + chatRoomId = data.getInt(); + sequence = data.getInt(); } - public void removeAllListeners() { - for (ChangeListener listener : listeners) { - super.removeListener(listener); - } - } - - @Override - public void bindBidirectional(Property property) { - super.bindBidirectional(property); - properties.add(property); - } - - public void unbindAll() { - unbind(); - for (Property property : properties) { - super.unbindBidirectional(property); - } + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(18 + avatar.getLength()); + data.addShort(5); + data.addInt(CRC); + data.addEncodable(avatar); + data.addInt(result); + data.addInt(chatRoomId); + data.addInt(sequence); + return data; } } diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnReceiveRoomInvitation.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnReceiveRoomInvitation.java new file mode 100644 index 0000000..eee2bac --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnReceiveRoomInvitation.java @@ -0,0 +1,62 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatOnReceiveRoomInvitation extends SWGPacket { + public static final int CRC = getCrc("ChatOnReceiveRoomInvitation"); + + private ChatAvatar avatar; + private String room; + + public ChatOnReceiveRoomInvitation() {} + + public ChatOnReceiveRoomInvitation(ChatAvatar avatar, String room) { + this.avatar = avatar; + this.room = room; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + avatar = data.getEncodable(ChatAvatar.class); + room = data.getAscii(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(8 + avatar.getLength() + room.length()); + data.addShort(3); + data.addInt(CRC); + data.addEncodable(avatar); + data.addAscii(room); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnRemoveModeratorFromRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnRemoveModeratorFromRoom.java new file mode 100644 index 0000000..f4ba8e0 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnRemoveModeratorFromRoom.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatOnRemoveModeratorFromRoom extends SWGPacket { + public static final int CRC = getCrc("ChatOnRemoveModeratorFromRoom"); + + private ChatAvatar target; + private ChatAvatar moderator; + private int result; + private String room; + private int sequence; + + public ChatOnRemoveModeratorFromRoom(ChatAvatar target, ChatAvatar moderator, int result, String room, int sequence) { + this.target = target; + this.moderator = moderator; + this.result = result; + this.room = room; + this.sequence = sequence; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + target = data.getEncodable(ChatAvatar.class); + moderator = data.getEncodable(ChatAvatar.class); + result = data.getInt(); + room = data.getAscii(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(16 + target.encode().length + moderator.encode().length + room.length()); + data.addShort(1); + data.addInt(CRC); + data.addEncodable(target); + data.addEncodable(moderator); + data.addInt(result); + data.addAscii(room); + data.addInt(sequence); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnSendInstantMessage.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnSendInstantMessage.java new file mode 100644 index 0000000..3fdae44 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnSendInstantMessage.java @@ -0,0 +1,84 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatOnSendInstantMessage extends SWGPacket { + public static final int CRC = getCrc("ChatOnSendInstantMessage"); + + private int result; + private int sequence; + + public ChatOnSendInstantMessage() { + this(0, 0); + } + + public ChatOnSendInstantMessage(int result, int sequence) { + this.result = result; + this.sequence = sequence; + } + + public ChatOnSendInstantMessage(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + result = data.getInt(); + sequence = data.getInt(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(2); + data.addInt(CRC); + data.addInt(result); + data.addInt(sequence); + return data; + } + + public void setResult(int result) { + this.result = result; + } + + public void setSequence(int sequence) { + this.sequence = sequence; + } + + public int getResult() { + return result; + } + + public int getSequence() { + return sequence; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnSendPersistentMessage.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnSendPersistentMessage.java new file mode 100644 index 0000000..24c6b69 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnSendPersistentMessage.java @@ -0,0 +1,62 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatResult; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatOnSendPersistentMessage extends SWGPacket { + public static final int CRC = getCrc("ChatOnSendPersistentMessage"); + + private ChatResult result; + private int count; + + public ChatOnSendPersistentMessage(ChatResult result, int count) { + this.result = result; + this.count = count; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + result = ChatResult.fromInteger(data.getInt()); + count = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(3); + data.addInt(CRC); + data.addInt(result.getCode()); + data.addInt(count); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnSendRoomMessage.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnSendRoomMessage.java new file mode 100644 index 0000000..be5a54b --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnSendRoomMessage.java @@ -0,0 +1,59 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatOnSendRoomMessage extends SWGPacket { + public static final int CRC = getCrc("ChatOnSendRoomMessage"); + + private int result = 0; + private int sequence = 0; + + public ChatOnSendRoomMessage(int result, int sequence) { + this.result = result; + this.sequence = sequence; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + result = data.getInt(); + sequence = data.getInt(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(3); + data.addInt(CRC); + data.addInt(result); + data.addInt(sequence); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnUnbanAvatarFromRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnUnbanAvatarFromRoom.java new file mode 100644 index 0000000..c9c6939 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnUnbanAvatarFromRoom.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatOnUnbanAvatarFromRoom extends SWGPacket { + public static final int CRC = getCrc("ChatOnUnbanAvatarFromRoom"); + + private String room; + private ChatAvatar moderator; + private ChatAvatar target; + private int result; + private int sequence; + + public ChatOnUnbanAvatarFromRoom(String room, ChatAvatar moderator, ChatAvatar target, int result, int sequence) { + this.room = room; + this.moderator = moderator; + this.target = target; + this.result = result; + this.sequence = sequence; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + room = data.getAscii(); + moderator = data.getEncodable(ChatAvatar.class); + target = data.getEncodable(ChatAvatar.class); + result = data.getInt(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(16 + moderator.encode().length + target.encode().length + room.length()); + data.addShort(6); + data.addInt(CRC); + data.addAscii(room); + data.addEncodable(moderator); + data.addEncodable(target); + data.addInt(result); + data.addInt(sequence); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnUninviteFromRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnUninviteFromRoom.java new file mode 100644 index 0000000..e248494 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatOnUninviteFromRoom.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatOnUninviteFromRoom extends SWGPacket { + public static final int CRC = getCrc("ChatOnUninviteFromRoom"); + + private String room; + private ChatAvatar sender; + private ChatAvatar invitee; + private int result; + private int sequence; + + public ChatOnUninviteFromRoom() {} + + public ChatOnUninviteFromRoom(String room, ChatAvatar sender, ChatAvatar invitee, int result, int sequence) { + this.room = room; + this.sender = sender; + this.invitee = invitee; + this.result = result; + this.sequence = sequence; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + + room = data.getAscii(); + sender = data.getEncodable(ChatAvatar.class); + invitee = data.getEncodable(ChatAvatar.class); + result = data.getInt(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(16 + room.length() + sender.encode().length + invitee.encode().length); + data.addShort(6); + data.addInt(CRC); + data.addAscii(room); + data.addEncodable(sender); + data.addEncodable(invitee); + data.addInt(result); + data.addInt(sequence); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatPersistentMessageToClient.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatPersistentMessageToClient.java new file mode 100644 index 0000000..01db265 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatPersistentMessageToClient.java @@ -0,0 +1,89 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.player.Mail; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatPersistentMessageToClient extends SWGPacket { + + public static final int CRC = getCrc("ChatPersistentMessageToClient"); + + private Mail mail; + private String galaxy; + private boolean header; + + public ChatPersistentMessageToClient() { + this(null, null, false); + } + + public ChatPersistentMessageToClient(Mail mail, String galaxy, boolean header) { + this.mail = mail; + this.galaxy = galaxy; + this.header = header; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + mail = new Mail(null, null, null, 0); + mail.setSender(data.getAscii()); + data.getAscii(); // SWG + galaxy = data.getAscii(); + mail.setId(data.getInt()); + header = data.getBoolean(); + if (header) + mail.decodeHeader(data); + else + mail.decode(data); + mail.setStatus(data.getByte()); + mail.setTimestamp(data.getInt()); + } + + @Override + public NetBuffer encode() { + byte[] mailData = (header ? mail.encodeHeader() : mail.encode()); + + NetBuffer data = NetBuffer.allocate(25 + galaxy.length() + mailData.length + mail.getSender().length()); + data.addShort(2); + data.addInt(CRC); + + data.addAscii(mail.getSender()); + data.addAscii("SWG"); + data.addAscii(galaxy); + data.addInt(mail.getId()); + data.addBoolean(header); + data.addRawArray(mailData); + data.addByte(mail.getStatus()); + data.addInt(mail.getTimestamp()); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatPersistentMessageToServer.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatPersistentMessageToServer.java new file mode 100644 index 0000000..9bdee55 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatPersistentMessageToServer.java @@ -0,0 +1,127 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.oob.OutOfBandPackage; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatPersistentMessageToServer extends SWGPacket { + public static final int CRC = getCrc("ChatPersistentMessageToServer"); + + private String message; + private OutOfBandPackage outOfBandPackage; + private int counter; + private String subject; + private String galaxy; + private String recipient; + + public ChatPersistentMessageToServer() { + message = ""; + outOfBandPackage = new OutOfBandPackage(); + subject = ""; + galaxy = ""; + recipient = ""; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + message = data.getUnicode(); + outOfBandPackage = data.getEncodable(OutOfBandPackage.class); + counter = data.getInt(); + subject = data.getUnicode(); + data.getAscii(); // "SWG" + galaxy = data.getAscii(); + recipient = data.getAscii(); + } + + @Override + public NetBuffer encode() { + int dataLength = 31 + message.length() * 2 + outOfBandPackage.getLength() + subject.length() * 2 + galaxy.length() + recipient.length(); + NetBuffer data = NetBuffer.allocate(dataLength); + data.addUnicode(message); + data.addEncodable(outOfBandPackage); + data.addInt(counter); + data.addUnicode(subject); + data.addAscii("SWG"); + data.addAscii(galaxy); + data.addAscii(recipient); + return data; + } + + public String getMessage() { + return message; + } + + public OutOfBandPackage getOutOfBandPackage() { + return outOfBandPackage; + } + + public int getCounter() { + return counter; + } + + public String getSubject() { + return subject; + } + + public String getCluster() { + return galaxy; + } + + public String getRecipient() { + return recipient; + } + + public void setMessage(String message) { + this.message = message; + } + + public void setOutOfBandPackage(OutOfBandPackage outOfBandPackage) { + this.outOfBandPackage = outOfBandPackage; + } + + public void setCounter(int counter) { + this.counter = counter; + } + + public void setSubject(String subject) { + this.subject = subject; + } + + public void setCluster(String cluster) { + this.galaxy = cluster; + } + + public void setRecipient(String recipient) { + this.recipient = recipient; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatQueryRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatQueryRoom.java new file mode 100644 index 0000000..69c8464 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatQueryRoom.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatQueryRoom extends SWGPacket { + public static final int CRC = getCrc("ChatQueryRoom"); + + private int sequence; + private String roomPath; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + sequence = data.getInt(); + roomPath = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(12 + roomPath.length()); + data.addShort(3); + data.addInt(CRC); + data.addInt(sequence); + data.addAscii(roomPath); + return data; + } + + public int getSequence() { + return sequence; + } + + public String getRoomPath() { + return roomPath; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatQueryRoomResults.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatQueryRoomResults.java new file mode 100644 index 0000000..910605a --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatQueryRoomResults.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.data.encodables.chat.ChatRoom; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatQueryRoomResults extends SWGPacket { + + public static final int CRC = getCrc("ChatQueryRoomResults"); + + private ChatRoom room; + private int sequence; + + public ChatQueryRoomResults(ChatRoom room, int sequence) { + this.room = room; + this.sequence = sequence; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(getLength()); + data.addList(room.getMembers()); + data.addList(room.getInvited()); + data.addList(room.getModerators()); + data.addList(room.getBanned()); + data.addInt(sequence); + data.addEncodable(room); + return data; + } + + private int getLength() { + int size = 20 + room.getLength(); + + for (ChatAvatar avatar : room.getMembers()) { + size += avatar.getLength(); + } + for (ChatAvatar avatar : room.getInvited()) { + size += avatar.getLength(); + } + for (ChatAvatar avatar : room.getModerators()) { + size += avatar.getLength(); + } + for (ChatAvatar avatar : room.getBanned()) { + size += avatar.getLength(); + } + + return size; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRemoveAvatarFromRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRemoveAvatarFromRoom.java new file mode 100644 index 0000000..a41d436 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRemoveAvatarFromRoom.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatRemoveAvatarFromRoom extends SWGPacket { + public static final int CRC = getCrc("ChatRemoveAvatarFromRoom"); + + private ChatAvatar avatar; + private String path; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + + avatar = data.getEncodable(ChatAvatar.class); + path = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6 + path.length() + avatar.getLength()); + data.addShort(3); + data.addInt(CRC); + data.addEncodable(avatar); + data.addAscii(path); + return data; + } + + public ChatAvatar getAvatar() { + return avatar; + } + + public String getPath() { + return path; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRemoveModeratorFromRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRemoveModeratorFromRoom.java new file mode 100644 index 0000000..9bf1892 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRemoveModeratorFromRoom.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatRemoveModeratorFromRoom extends SWGPacket { + public static final int CRC = getCrc("ChatRemoveModeratorFromRoom"); + + private ChatAvatar avatar; + private String room; + private int sequence; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + avatar = data.getEncodable(ChatAvatar.class); + room = data.getAscii(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(12 + room.length() + avatar.encode().length); + data.addShort(4); + data.addInt(CRC); + data.addEncodable(avatar); + data.addAscii(room); + data.addInt(sequence); + return data; + } + + public ChatAvatar getAvatar() { + return avatar; + } + + public String getRoom() { + return room; + } + + public int getSequence() { + return sequence; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRequestPersistentMessage.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRequestPersistentMessage.java new file mode 100644 index 0000000..a0afaa5 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRequestPersistentMessage.java @@ -0,0 +1,59 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatRequestPersistentMessage extends SWGPacket { + public static final int CRC = getCrc("ChatRequestPersistentMessage"); + + private int sequence; + private int mailId; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + sequence = data.getInt(); + mailId = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(3); + data.addInt(CRC); + data.addInt(sequence); + data.addInt(mailId); + + return data; + } + + public int getMailId() { return this.mailId; } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRequestRoomList.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRequestRoomList.java new file mode 100644 index 0000000..4f4d54a --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRequestRoomList.java @@ -0,0 +1,53 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatRequestRoomList extends SWGPacket { + + public static final int CRC = getCrc("ChatRequestRoomList"); + + public ChatRequestRoomList() { + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(1); + data.addInt(CRC); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRoomMessage.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRoomMessage.java new file mode 100644 index 0000000..0bd8a54 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatRoomMessage.java @@ -0,0 +1,73 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.data.encodables.oob.OutOfBandPackage; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatRoomMessage extends SWGPacket { + public static final int CRC = getCrc("ChatRoomMessage"); + + private ChatAvatar avatar; + private int roomId = 0; + private String message = ""; + private OutOfBandPackage outOfBandPackage; + + public ChatRoomMessage(ChatAvatar avatar, int roomId, String message, OutOfBandPackage oob) { + this.avatar = avatar; + this.roomId = roomId; + this.message = message; + this.outOfBandPackage = oob; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + avatar = data.getEncodable(ChatAvatar.class); + roomId = data.getInt(); + message = data.getUnicode(); + outOfBandPackage = data.getEncodable(OutOfBandPackage.class); + } + + @Override + public NetBuffer encode() { + byte[] oob = outOfBandPackage.encode(); + int length = 14 + avatar.getLength() + oob.length + message.length() * 2; + NetBuffer data = NetBuffer.allocate(length); + data.addShort(5); + data.addInt(CRC); + data.addEncodable(avatar); + data.addInt(roomId); + data.addUnicode(message); + data.addRawArray(oob); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatSendToRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatSendToRoom.java new file mode 100644 index 0000000..ff5b475 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatSendToRoom.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.oob.OutOfBandPackage; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatSendToRoom extends SWGPacket { + public static final int CRC = getCrc("ChatSendToRoom"); + + private String message; + private OutOfBandPackage outOfBandPackage; + private int roomId; + private int sequence; // This seems to vary from room to room, client keeps track individually for each room? + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + + message = data.getUnicode(); + outOfBandPackage = data.getEncodable(OutOfBandPackage.class); + roomId = data.getInt(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + byte [] oobRaw = outOfBandPackage.encode(); + NetBuffer data = NetBuffer.allocate(12 + message.length()*2 + oobRaw.length); + data.addUnicode(message); + data.addRawArray(oobRaw); + data.addInt(roomId); + data.addInt(sequence); + return data; + } + + public String getMessage() { + return message; + } + + public OutOfBandPackage getOutOfBandPackage() { + return outOfBandPackage; + } + + public int getRoomId() { + return roomId; + } + + public int getSequence() { + return sequence; + } +} diff --git a/src/com/projectswg/common/javafx/PSWGObjectProperty.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatSystemMessage.java similarity index 55% rename from src/com/projectswg/common/javafx/PSWGObjectProperty.java rename to src/com/projectswg/common/network/packets/swg/zone/chat/ChatSystemMessage.java index 6128268..2a26deb 100644 --- a/src/com/projectswg/common/javafx/PSWGObjectProperty.java +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatSystemMessage.java @@ -25,79 +25,92 @@ * along with Holocore. If not, see . * * * ***********************************************************************************/ -package com.projectswg.common.javafx; +package com.projectswg.common.network.packets.swg.zone.chat; -import java.util.HashSet; -import java.util.Set; +import com.projectswg.common.data.encodables.oob.OutOfBandPackage; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; -import javafx.beans.InvalidationListener; -import javafx.beans.property.Property; -import javafx.beans.property.SimpleObjectProperty; -import javafx.beans.value.ChangeListener; - -public class PSWGObjectProperty extends SimpleObjectProperty { +public class ChatSystemMessage extends SWGPacket { - private final Set> listeners; - private final Set invalidationListeners; - private final Set> properties; + public static final int CRC = getCrc("ChatSystemMessage"); - public PSWGObjectProperty() { - super(); - listeners = new HashSet<>(); - invalidationListeners = new HashSet<>(); - properties = new HashSet<>(); + private OutOfBandPackage oob; + private String message; + private SystemChatType type; + + public ChatSystemMessage() { + this(SystemChatType.PERSONAL, "", null); } - public PSWGObjectProperty(T initialValue) { - super(initialValue); - listeners = new HashSet<>(); - invalidationListeners = new HashSet<>(); - properties = new HashSet<>(); + public ChatSystemMessage(SystemChatType type, String message) { + this(type, message, null); + } + + public ChatSystemMessage(SystemChatType type, OutOfBandPackage oob) { + this(type, "", oob); + } + + public ChatSystemMessage(SystemChatType type, String message, OutOfBandPackage oob) { + this.type = type; + this.message = message; + this.oob = oob; } @Override - public void addListener(ChangeListener listener) { - super.addListener(listener); - listeners.add(listener); + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + type = SystemChatType.getType(data.getByte()); + message = data.getUnicode(); + data.getUnicode(); } @Override - public void addListener(InvalidationListener listener) { - super.addListener(listener); - invalidationListeners.add(listener); + public NetBuffer encode() { + boolean oobExists = (oob != null); + NetBuffer data = NetBuffer.allocate(11 + message.length()*2 + (oobExists ? oob.getLength() : 4)); + data.addShort(4); + data.addInt(CRC); + data.addByte(type.getType()); + data.addUnicode(message); + if (oobExists) + data.addEncodable(oob); + else + data.addInt(0); + return data; } - @Override - public void removeListener(ChangeListener listener) { - super.removeListener(listener); - listeners.remove(listener); + public String getMessage() { + return message; } - @Override - public void removeListener(InvalidationListener listener) { - super.removeListener(listener); - invalidationListeners.remove(listener); - } - - public void removeAllListeners() { - for (ChangeListener listener : listeners) { - super.removeListener(listener); + public enum SystemChatType { + PERSONAL (0x00), + BROADCAST (0x01), + CHAT_BOX (0x02), + QUEST (0x04); + + int type; + + SystemChatType(int type) { + this.type = type; } - for (InvalidationListener listener : invalidationListeners) { - super.removeListener(listener); + + public int getType() { + return type; } - } - - @Override - public void bindBidirectional(Property property) { - super.bindBidirectional(property); - properties.add(property); - } - - public void unbindAll() { - unbind(); - for (Property property : properties) { - super.unbindBidirectional(property); + + public static SystemChatType getType(int type) { + switch (type) { + case 0: + default: + return SystemChatType.PERSONAL; + case 1: + return SystemChatType.BROADCAST; + case 2: + return SystemChatType.CHAT_BOX; + } } } diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatUnbanAvatarFromRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatUnbanAvatarFromRoom.java new file mode 100644 index 0000000..8d922f3 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatUnbanAvatarFromRoom.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatUnbanAvatarFromRoom extends SWGPacket { + public static final int CRC = getCrc("ChatUnbanAvatarFromRoom"); + + private ChatAvatar avatar; + private String room; + private int sequence; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + avatar = data.getEncodable(ChatAvatar.class); + room = data.getAscii(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(12 + avatar.encode().length + room.length()); + data.addShort(4); + data.addInt(CRC); + data.addEncodable(avatar); + data.addAscii(room); + data.addInt(sequence); + return data; + } + + public ChatAvatar getAvatar() { + return avatar; + } + + public String getRoom() { + return room; + } + + public int getSequence() { + return sequence; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ChatUninviteFromRoom.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatUninviteFromRoom.java new file mode 100644 index 0000000..c9f4f89 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ChatUninviteFromRoom.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * @author Waverunner + */ +public class ChatUninviteFromRoom extends SWGPacket { + public static final int CRC = getCrc("ChatUninviteFromRoom"); + + private ChatAvatar avatar; + private String room; + private int sequence; + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + avatar = data.getEncodable(ChatAvatar.class); + room = data.getAscii(); + sequence = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(12 + avatar.encode().length + room.length()); + data.addShort(4); + data.addInt(CRC); + data.addEncodable(avatar); + data.addAscii(room); + data.addInt(sequence); + return data; + } + + public ChatAvatar getAvatar() { + return avatar; + } + + public String getRoom() { + return room; + } + + public int getSequence() { + return sequence; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/ConGenericMessage.java b/src/com/projectswg/common/network/packets/swg/zone/chat/ConGenericMessage.java new file mode 100644 index 0000000..ef2699f --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/ConGenericMessage.java @@ -0,0 +1,68 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ConGenericMessage extends SWGPacket { + public static final int CRC = getCrc("ConGenericMessage"); + + private String message; + + public ConGenericMessage() { + this(""); + } + + public ConGenericMessage(String message) { + this.message = message; + } + + public ConGenericMessage(NetBuffer data) { + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + message = data.getAscii(); + data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(8 + message.length()); + data.addShort(3); + data.addInt(CRC); + data.addAscii(message); + data.addInt(0); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/chat/VoiceChatStatus.java b/src/com/projectswg/common/network/packets/swg/zone/chat/VoiceChatStatus.java new file mode 100644 index 0000000..a90967d --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/chat/VoiceChatStatus.java @@ -0,0 +1,59 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.chat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class VoiceChatStatus extends SWGPacket { + + public static final int CRC = 0x9E601905; + + public VoiceChatStatus() { + + } + + public VoiceChatStatus(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + data.getInt(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10); + data.addShort(2); + data.addInt(CRC); + data.addInt(1); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/combat/GrantCommandMessage.java b/src/com/projectswg/common/network/packets/swg/zone/combat/GrantCommandMessage.java new file mode 100644 index 0000000..4940aff --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/combat/GrantCommandMessage.java @@ -0,0 +1,73 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.combat; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class GrantCommandMessage extends SWGPacket { + + public static final int CRC = 0xE67E3875; + + private String command; + + public GrantCommandMessage() { + command = ""; + } + + public GrantCommandMessage(String command) { + this.command = command; + } + + public GrantCommandMessage(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + this.command = data.getAscii(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(8 + command.length()); + data.addShort(2); + data.addInt(CRC); + data.addAscii(command); + return data; + } + + public String getCommand() { + return command; + } + + public void setCommand(String command) { + this.command = command; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/crafting/resources/ResourceListForSurveyMessage.java b/src/com/projectswg/common/network/packets/swg/zone/crafting/resources/ResourceListForSurveyMessage.java new file mode 100644 index 0000000..be56480 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/crafting/resources/ResourceListForSurveyMessage.java @@ -0,0 +1,173 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.crafting.resources; + +import java.util.ArrayList; +import java.util.List; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ResourceListForSurveyMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("ResourceListForSurveyMessage"); + + private final List resources; + + private String resourceType; + private long creatureId; + + public ResourceListForSurveyMessage(long creatureId, String resourceType) { + this.resources = new ArrayList<>(); + this.creatureId = creatureId; + this.resourceType = resourceType; + } + + public ResourceListForSurveyMessage(NetBuffer data) { + this.resources = new ArrayList<>(); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + int resourceSize = data.getInt(); + for (int i = 0; i < resourceSize; i++) { + resources.add(ResourceItem.decode(data)); + } + resourceType = data.getAscii(); + creatureId = data.getLong(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(getLength()); + data.addShort(4); + data.addInt(CRC); + data.addInt(resources.size()); + for (ResourceItem item : resources) { + ResourceItem.encode(data, item); + } + data.addAscii(resourceType); + data.addLong(creatureId); + return data; + } + + public List getResources() { + return resources; + } + + public String getResourceType() { + return resourceType; + } + + public long getCreatureId() { + return creatureId; + } + + public void addResource(ResourceItem item) { + resources.add(item); + } + + public void removeResource(ResourceItem item) { + resources.remove(item); + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public void setCreatureId(long creatureId) { + this.creatureId = creatureId; + } + + private int getLength() { + int length = 20 + resourceType.length(); + for (ResourceItem item : resources) + length += item.getLength(); + return length; + } + + public static class ResourceItem { + + private final String resourceName; + private final String resourceClass; + private final long resourceId; + + public ResourceItem(String resourceName, String resourceClass, long resourceId) { + this.resourceName = resourceName; + this.resourceClass = resourceClass; + this.resourceId = resourceId; + } + + public String getResourceName() { + return resourceName; + } + + public String getResourceClass() { + return resourceClass; + } + + public long getResourceId() { + return resourceId; + } + + public int getLength() { + return 12 + resourceName.length() + resourceClass.length(); + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof ResourceItem)) + return false; + ResourceItem item = (ResourceItem) o; + return item.resourceName.equals(resourceName) && item.resourceClass.equals(resourceClass) && item.resourceId == resourceId; + } + + @Override + public int hashCode() { + return Long.hashCode(resourceId) * 7 + resourceName.hashCode() * 3 + resourceClass.hashCode(); + } + + public static void encode(NetBuffer buffer, ResourceItem item) { + buffer.addAscii(item.getResourceName()); + buffer.addLong(item.getResourceId()); + buffer.addAscii(item.getResourceClass()); + } + + public static ResourceItem decode(NetBuffer buffer) { + String resourceName = buffer.getAscii(); + long resourceId = buffer.getLong(); + String resourceClass = buffer.getAscii(); + return new ResourceItem(resourceName, resourceClass, resourceId); + } + + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/crafting/surveying/SurveyMessage.java b/src/com/projectswg/common/network/packets/swg/zone/crafting/surveying/SurveyMessage.java new file mode 100644 index 0000000..a187a99 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/crafting/surveying/SurveyMessage.java @@ -0,0 +1,130 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.crafting.surveying; + +import java.util.ArrayList; +import java.util.List; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class SurveyMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("SurveyMessage"); + + private final List concentrations; + + public SurveyMessage() { + this.concentrations = new ArrayList<>(); + } + + public SurveyMessage(NetBuffer data) { + this.concentrations = new ArrayList<>(); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + int pointAmounts = data.getInt(); + for (int i = 0; i < pointAmounts; i++) { + float x = data.getFloat(); + data.getFloat(); + float z = data.getFloat(); + float concentration = data.getFloat(); + concentrations.add(new ResourceConcentration(x, z, concentration)); + } + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(getLength()); + data.addShort(2); + data.addInt(CRC); + data.addInt(concentrations.size()); + for (ResourceConcentration rc : concentrations) { + data.addFloat((float) rc.getX()); + data.addFloat(0); + data.addFloat((float) rc.getZ()); + data.addFloat((float) rc.getConcentration()); + } + return data; + } + + private int getLength() { + return 10 + concentrations.size() * 16; + } + + public List getConcentrations() { + return concentrations; + } + + public void addConcentration(ResourceConcentration rc) { + concentrations.add(rc); + } + + public void removeConcentration(ResourceConcentration rc) { + concentrations.remove(rc); + } + + public static class ResourceConcentration { + + private final double x; + private final double z; + private final double concentration; + + public ResourceConcentration(double x, double z, double concentration) { + this.x = x; + this.z = z; + this.concentration = concentration; + } + + public double getX() { + return x; + } + + public double getZ() { + return z; + } + + public double getConcentration() { + return concentration; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof ResourceConcentration)) + return false; + ResourceConcentration rc = (ResourceConcentration) o; + return rc.x == x && rc.z == z && rc.concentration == concentration; + } + + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/deltas/DeltasMessage.java b/src/com/projectswg/common/network/packets/swg/zone/deltas/DeltasMessage.java new file mode 100644 index 0000000..e3c3272 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/deltas/DeltasMessage.java @@ -0,0 +1,133 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.deltas; + +import java.nio.charset.StandardCharsets; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; +import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; + +public class DeltasMessage extends SWGPacket { + + public static final int CRC = getCrc("DeltasMessage"); + + private long objId; + private BaselineType type; + private int num; + private byte[] deltaData; + private int update; + + public DeltasMessage() { + + } + + public DeltasMessage(long objId, BaselineType type, int typeNumber, int update, byte[] data) { + this.objId = objId; + this.type = type; + this.update = update; + this.num = typeNumber; + this.deltaData = data; + } + + public DeltasMessage(NetBuffer data) { + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objId = data.getLong(); + type = BaselineType.valueOf(reverse(new String(data.getArray(4), StandardCharsets.UTF_8))); + num = data.getByte(); + NetBuffer deltaDataBuffer = NetBuffer.wrap(data.getArrayLarge()); + deltaDataBuffer.getShort(); + update = deltaDataBuffer.getShort(); + deltaData = deltaDataBuffer.getArray(deltaDataBuffer.remaining()); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(27 + deltaData.length); + data.addShort(5); + data.addInt(CRC); + data.addLong(objId); + data.addRawArray(reverse(type.toString()).getBytes(StandardCharsets.UTF_8)); + data.addByte(num); + data.addInt(deltaData.length + 4); + data.addShort(1); // updates - only 1 cause we're boring + data.addShort(update); + data.addRawArray(deltaData); + return data; + } + + public long getObjectId() { + return objId; + } + + public BaselineType getType() { + return type; + } + + public int getNum() { + return num; + } + + public int getUpdate() { + return update; + } + + public byte[] getDeltaData() { + return deltaData; + } + + public void setType(BaselineType type) { + this.type = type; + } + + public void setNum(int num) { + this.num = num; + } + + public void setId(long id) { + this.objId = id; + } + + public void setData(byte[] data) { + this.deltaData = data; + } + + public void setUpdate(int update) { + this.update = update; + } + + private String reverse(String str) { + return new StringBuffer(str).reverse().toString(); + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/harvesters/ResourceHarvesterActivatePageMessage.java b/src/com/projectswg/common/network/packets/swg/zone/harvesters/ResourceHarvesterActivatePageMessage.java new file mode 100644 index 0000000..c0813a2 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/harvesters/ResourceHarvesterActivatePageMessage.java @@ -0,0 +1,38 @@ +package com.projectswg.common.network.packets.swg.zone.harvesters; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ResourceHarvesterActivatePageMessage extends SWGPacket { + public static final int CRC = getCrc("ResourceHarvesterActivatePageMessage"); + + private long harvesterId; + + public ResourceHarvesterActivatePageMessage(long harvesterId) { + this.harvesterId = harvesterId; + } + + public ResourceHarvesterActivatePageMessage(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + harvesterId = data.getLong(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(8); + data.addLong(harvesterId); + return data; + } + + public long getHarvesterId() { + return harvesterId; + } + + public void setHarvesterId(long harvesterId) { + this.harvesterId = harvesterId; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/javafx/PSWGIntegerProperty.java b/src/com/projectswg/common/network/packets/swg/zone/insertion/ChatRoomList.java similarity index 64% rename from src/com/projectswg/common/javafx/PSWGIntegerProperty.java rename to src/com/projectswg/common/network/packets/swg/zone/insertion/ChatRoomList.java index cd19e11..492d598 100644 --- a/src/com/projectswg/common/javafx/PSWGIntegerProperty.java +++ b/src/com/projectswg/common/network/packets/swg/zone/insertion/ChatRoomList.java @@ -25,61 +25,61 @@ * along with Holocore. If not, see . * * * ***********************************************************************************/ -package com.projectswg.common.javafx; +package com.projectswg.common.network.packets.swg.zone.insertion; -import java.util.HashSet; -import java.util.Set; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; -import javafx.beans.property.Property; -import javafx.beans.property.SimpleIntegerProperty; -import javafx.beans.value.ChangeListener; +import com.projectswg.common.data.encodables.chat.ChatRoom; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; -public class PSWGIntegerProperty extends SimpleIntegerProperty { +public class ChatRoomList extends SWGPacket { - private final Set> listeners; - private final Set> properties; + public static final int CRC = getCrc("ChatRoomList"); - public PSWGIntegerProperty() { - super(); - listeners = new HashSet<>(); - properties = new HashSet<>(); + private Collection rooms; + + public ChatRoomList() { + this.rooms = new ArrayList<>(); } - public PSWGIntegerProperty(int initialValue) { - super(initialValue); - listeners = new HashSet<>(); - properties = new HashSet<>(); + public ChatRoomList(ChatRoom... rooms) { + this.rooms = Arrays.asList(rooms); + } + + public ChatRoomList(Collection rooms) { + this.rooms = rooms; } @Override - public void addListener(ChangeListener listener) { - listeners.add(listener); - super.addListener(listener); + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + rooms = data.getList(ChatRoom.class); } @Override - public void removeListener(ChangeListener listener) { - listeners.remove(listener); - super.removeListener(listener); - } - - public void removeAllListeners() { - for (ChangeListener listener : listeners) { - super.removeListener(listener); + public NetBuffer encode() { + int length = 10; + for (ChatRoom r : rooms) { + length += r.getLength(); } + NetBuffer data = NetBuffer.allocate(length); + data.addShort(2); + data.addInt(CRC); + data.addList(rooms); + return data; + } + + public Collection getRooms() { + return rooms; } @Override - public void bindBidirectional(Property property) { - super.bindBidirectional(property); - properties.add(property); - } - - public void unbindAll() { - unbind(); - for (Property property : properties) { - super.unbindBidirectional(property); - } + public String toString() { + return "ChatRoomList[roomSize=" + rooms.size() + "]"; } } diff --git a/src/com/projectswg/common/network/packets/swg/zone/insertion/ChatServerStatus.java b/src/com/projectswg/common/network/packets/swg/zone/insertion/ChatServerStatus.java new file mode 100644 index 0000000..1c33a6b --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/insertion/ChatServerStatus.java @@ -0,0 +1,60 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.insertion; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ChatServerStatus extends SWGPacket { + public static final int CRC = getCrc("ChatServerStatus"); + + private boolean online = false; + + public ChatServerStatus() { + + } + + public ChatServerStatus(boolean online) { + this.online = online; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + online = data.getBoolean(); + } + + public NetBuffer encode() { + int length = 7; + NetBuffer data = NetBuffer.allocate(length); + data.addShort(2); + data.addInt(CRC); + data.addBoolean(online); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/insertion/CmdStartScene.java b/src/com/projectswg/common/network/packets/swg/zone/insertion/CmdStartScene.java new file mode 100644 index 0000000..6c5ddf1 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/insertion/CmdStartScene.java @@ -0,0 +1,121 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.insertion; + +import com.projectswg.common.data.encodables.tangible.Race; +import com.projectswg.common.data.location.Location; +import com.projectswg.common.data.location.Terrain; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class CmdStartScene extends SWGPacket { + public static final int CRC = getCrc("CmdStartScene"); + + private boolean ignoreLayoutFiles; + private long charId; + private Race race; + private Location l; + private long galacticTime; + private int serverEpoch; + + public CmdStartScene() { + ignoreLayoutFiles = false; + charId = 0; + race = Race.HUMAN_MALE; + l = new Location(); + galacticTime = 0; + serverEpoch = 0; + } + + public CmdStartScene(boolean ignoreLayoutFiles, long charId, Race race, Location l, long galacticTime, int serverEpoch) { + this.ignoreLayoutFiles = ignoreLayoutFiles; + this.charId = charId; + this.race = race; + this.l = l; + this.galacticTime = galacticTime; + this.serverEpoch = serverEpoch; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + ignoreLayoutFiles = data.getBoolean(); + charId = data.getLong(); + String ter = data.getAscii(); + Terrain terrain = null; + for (Terrain t : Terrain.values()) { + if (t.getFile().equals(ter)) { + terrain = t; + break; + } + } + l = Location.builder() + .setTerrain(terrain) + .setX(data.getFloat()) + .setY(data.getFloat()) + .setZ(data.getFloat()) + .setHeading(data.getFloat()) + .build(); + race = Race.getRaceByFile(data.getAscii()); + galacticTime = data.getLong(); + serverEpoch = data.getInt(); + } + + @Override + public NetBuffer encode() { + int length = 47 + l.getTerrain().getFile().length() + race.getFilename().length(); + NetBuffer data = NetBuffer.allocate(length); + data.addShort(2); + data.addInt(CRC); + data.addBoolean(ignoreLayoutFiles); + data.addLong(charId); + data.addAscii(l.getTerrain().getFile()); + data.addFloat((float) l.getX()); + data.addFloat((float) l.getY()); + data.addFloat((float) l.getZ()); + data.addFloat((float) l.getYaw()); + data.addAscii(race.getFilename()); + data.addLong(galacticTime); + data.addInt(serverEpoch); + return data; + } + + public long getCharacterId() { return charId; } + public Location getLocation() { return l; } + public Race getRace() { return race; } + public long getGalacticTime() { return galacticTime; } + public int getServerEpoch() { return serverEpoch; } + + public void setCharacterId(long id) { this.charId = id; } + public void setLocation(Location l) { this.l = l; } + public void setRace(Race r) { this.race = r; } + public void setGalacticTime(long time) { this.galacticTime = time; } + public void setServerEpoch(int epoch) { this.serverEpoch = epoch; } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/insertion/ConnectPlayerMessage.java b/src/com/projectswg/common/network/packets/swg/zone/insertion/ConnectPlayerMessage.java new file mode 100644 index 0000000..14845d1 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/insertion/ConnectPlayerMessage.java @@ -0,0 +1,56 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.insertion; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class ConnectPlayerMessage extends SWGPacket { + public static final int CRC = getCrc("ConnectPlayerMessage"); + + private int stationId = 0; + + public ConnectPlayerMessage() { + + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + stationId = data.getInt(); + } + + public NetBuffer encode() { + int length = 10; + NetBuffer data = NetBuffer.allocate(length); + data.addShort(2); + data.addInt(CRC); + data.addInt(stationId); // stationId that's sent when using auto-login + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/insertion/SelectCharacter.java b/src/com/projectswg/common/network/packets/swg/zone/insertion/SelectCharacter.java new file mode 100644 index 0000000..830beca --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/insertion/SelectCharacter.java @@ -0,0 +1,61 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.insertion; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class SelectCharacter extends SWGPacket { + public static final int CRC = getCrc("SelectCharacter"); + + private long charId = 0; + + public SelectCharacter() { + + } + + public SelectCharacter(long id) { + this.charId = id; + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + charId = data.getLong(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(2); + data.addInt(CRC); + data.addLong(charId); + return data; + } + + public long getCharacterId() { return charId; } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/Animation.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/Animation.java new file mode 100644 index 0000000..46f214a --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/Animation.java @@ -0,0 +1,62 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class Animation extends ObjectController { + + public static final int CRC = 0x00F2; + + private String animation; + + public Animation(long objectId, String animation) { + super(objectId, CRC); + this.animation = animation; + } + + public Animation(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + animation = data.getAscii(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 2 + animation.length()); + encodeHeader(data); + data.addAscii(animation); + return data; + } +} + diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/BiographyUpdate.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/BiographyUpdate.java new file mode 100644 index 0000000..45355e8 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/BiographyUpdate.java @@ -0,0 +1,76 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class BiographyUpdate extends ObjectController { + + public static final int CRC = 0x01DB; + + private long targetId; + private String biography; + + public BiographyUpdate(long objectId, long targetId, String biography) { + super(objectId, CRC); + setTargetId(targetId); + setBiography(biography); + } + + public BiographyUpdate(NetBuffer data) { + super(CRC); + decode(data); + } + + public void decode(NetBuffer data) { + decodeHeader(data); + targetId = data.getLong(); + biography = data.getUnicode(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + Long.BYTES + Integer.BYTES + biography.length() * 2); + encodeHeader(data); + data.addLong(targetId); + data.addUnicode(biography); + return data; + } + + public long getTargetId() { return targetId; } + + public void setTargetId(long targetId) { this.targetId = targetId; } + + public String getBiography() { + return biography; + } + + public void setBiography(String biography) { + this.biography = biography; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/ChangeRoleIconChoice.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/ChangeRoleIconChoice.java new file mode 100644 index 0000000..ac6c3d1 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/ChangeRoleIconChoice.java @@ -0,0 +1,70 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class ChangeRoleIconChoice extends ObjectController { + + public static final int CRC = 0x044D; + + private int iconChoice; + + public ChangeRoleIconChoice(long objectId) { + super(objectId, CRC); + } + + public ChangeRoleIconChoice(NetBuffer data) { + super(CRC); + decode(data); + } + + public ChangeRoleIconChoice(long objectId, int iconChoice) { + super(objectId, CRC); + this.iconChoice = iconChoice; + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + iconChoice = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + Integer.BYTES); + encodeHeader(data); + data.addInt(iconChoice); + return data; + } + + public int getIconChoice() { + return iconChoice; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/CommandQueueDequeue.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/CommandQueueDequeue.java new file mode 100644 index 0000000..4b887ff --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/CommandQueueDequeue.java @@ -0,0 +1,79 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + + +public class CommandQueueDequeue extends ObjectController { + + public static final int CRC = 0x0117; + + private int counter; + private float timer; + private int error; + private int action; + + public CommandQueueDequeue(long objectId) { + super(objectId, CRC); + } + + public CommandQueueDequeue(NetBuffer data) { + super(CRC); + decode(data); + } + + public void decode(NetBuffer data) { + decodeHeader(data); + counter = data.getInt(); + timer = data.getFloat(); + error = data.getInt(); + action = data.getInt(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 16); + encodeHeader(data); + data.addInt(counter); + data.addFloat(timer); + data.addInt(error); + data.addInt(action); + return data; + } + + public int getCounter() { return counter; } + public float getTimer() { return timer; } + public int getError() { return error; } + public int getAction() { return action; } + + public void setCounter(int counter) { this.counter = counter; } + public void setTimer(float timer) { this.timer = timer; } + public void setError(int error) { this.error = error; } + public void setAction(int action) { this.action = action; } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/CommandQueueEnqueue.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/CommandQueueEnqueue.java new file mode 100644 index 0000000..ad8ce0d --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/CommandQueueEnqueue.java @@ -0,0 +1,83 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + + +public class CommandQueueEnqueue extends ObjectController { + + public static final int CRC = 0x0116; + + private int counter = 0; + private int crc = 0; + private long targetId = 0; + private String arguments = ""; + + public CommandQueueEnqueue(long objectId, int counter, int crc, long targetId, String arguments) { + super(objectId, CRC); + this.counter = counter; + this.crc = crc; + this.targetId = targetId; + this.arguments = arguments; + } + + public CommandQueueEnqueue(NetBuffer data) { + super(CRC); + decode(data); + } + + public void decode(NetBuffer data) { + decodeHeader(data); + counter = data.getInt(); + crc = data.getInt(); + targetId = data.getLong(); + arguments = data.getUnicode(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 20 + arguments.length()*2); + encodeHeader(data); + data.addInt(counter); + data.addInt(crc); + data.addLong(targetId); + data.addUnicode(arguments); + return data; + } + + public int getCounter() { return counter; } + public int getCommandCrc() { return crc; } + public String getArguments() { return arguments; } + public long getTargetId() { return targetId; } + + public void setCounter(int counter) { this.counter = counter; } + public void setCommandCrc(int crc) { this.crc = crc; } + public void setArguments(String args) { this.arguments = args; } + public void setTargetId(long targetId) { this.targetId = targetId; } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/CommandTimer.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/CommandTimer.java new file mode 100644 index 0000000..5abb7aa --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/CommandTimer.java @@ -0,0 +1,110 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + + +public class CommandTimer extends ObjectController { + + public static final int CRC = 0x0448; + + private int sequenceId; + private int commandNameCrc; + private int cooldownGroupCrc; + private float cooldownMin; + private float cooldownMax; + + public CommandTimer(long objectId) { + super(objectId, CRC); + } + + public CommandTimer(NetBuffer data) { + super(CRC); + decode(data); + } + + public void decode(NetBuffer data) { + decodeHeader(data); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 29); + encodeHeader(data); + data.addByte(4); // 0 for no cooldown, 0x26 to add defaultTime (usually 0.25) + data.addInt(sequenceId); + data.addInt(0); // Unknown + data.addInt(0); // Unknown + data.addInt(commandNameCrc); + data.addInt(cooldownGroupCrc); + data.addFloat(cooldownMin); + data.addFloat(cooldownMax); + return data; + } + + public int getSequenceId() { + return sequenceId; + } + + public void setSequenceId(int sequenceId) { + this.sequenceId = sequenceId; + } + + public int getCommandNameCrc() { + return commandNameCrc; + } + + public void setCommandNameCrc(int commandNameCrc) { + this.commandNameCrc = commandNameCrc; + } + + public int getCooldownGroupCrc() { + return cooldownGroupCrc; + } + + public void setCooldownGroupCrc(int cooldownGroupCrc) { + this.cooldownGroupCrc = cooldownGroupCrc; + } + + public float getCooldownMin() { + return cooldownMin; + } + + public void setCooldownMin(float cooldownMin) { + this.cooldownMin = cooldownMin; + } + + public float getCooldownMax() { + return cooldownMax; + } + + public void setCooldownMax(float cooldownMax) { + this.cooldownMax = cooldownMax; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/CraftAcknowledge.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/CraftAcknowledge.java new file mode 100644 index 0000000..e3ece08 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/CraftAcknowledge.java @@ -0,0 +1,93 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class CraftAcknowledge extends ObjectController { + + public static final int CRC = 0x010C; + + private int acknowledgeId; + private int errorId; + private byte updateCounter; + + public CraftAcknowledge(int acknowledgeId, int errorId, byte updateCounter) { + super(CRC); + this.acknowledgeId = acknowledgeId; + this.errorId = errorId; + this.updateCounter = updateCounter; + } + + public CraftAcknowledge(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + acknowledgeId = data.getInt(); + errorId = data.getInt(); + updateCounter = data.getByte(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 9); + encodeHeader(data); + data.addInt(acknowledgeId); + data.addInt(errorId); + data.addByte(updateCounter); + return data; + } + + public int getAcknowledgeId() { + return acknowledgeId; + } + + public void setAcknowledgeId(int acknowledgeId) { + this.acknowledgeId = acknowledgeId; + } + + public int getErrorId() { + return errorId; + } + + public void setErrorId(int errorId) { + this.errorId = errorId; + } + + public byte getUpdateCounter() { + return updateCounter; + } + + public void setUpdateCounter(byte updateCounter) { + this.updateCounter = updateCounter; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/CraftExperimentationResponse.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/CraftExperimentationResponse.java new file mode 100644 index 0000000..7bd1bbd --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/CraftExperimentationResponse.java @@ -0,0 +1,93 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class CraftExperimentationResponse extends ObjectController{ + + public static final int CRC = 0x0113; + + private int acknowledgeId; + private int stringId; + private byte staleFlag; + + public CraftExperimentationResponse(int acknowledgeId, int stringId, byte staleFlag) { + super(CRC); + this.acknowledgeId = acknowledgeId; + this.stringId = stringId; + this.staleFlag = staleFlag; + } + + public CraftExperimentationResponse(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + acknowledgeId = data.getInt(); + stringId = data.getInt(); + staleFlag = data.getByte(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 9); + encodeHeader(data); + data.addInt(acknowledgeId); + data.addInt(stringId); + data.addByte(staleFlag); + return data; + } + + public int getAcknowledgeId() { + return acknowledgeId; + } + + public void setAcknowledgeId(int acknowledgeId) { + this.acknowledgeId = acknowledgeId; + } + + public int getStringId() { + return stringId; + } + + public void setStringId(int stringId) { + this.stringId = stringId; + } + + public byte getStaleFlag() { + return staleFlag; + } + + public void setStaleFlag(byte staleFlag) { + this.staleFlag = staleFlag; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/CraftingSessionEnded.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/CraftingSessionEnded.java new file mode 100644 index 0000000..6e357a8 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/CraftingSessionEnded.java @@ -0,0 +1,93 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class CraftingSessionEnded extends ObjectController{ + + public static final int CRC = 0x01C2; + + private long playerId; //crafterId + private int sessionId; //sessionId, must be 0 after the Craftingsession + private byte count; //Itemcount created in that Session + + public CraftingSessionEnded(long playerId, int sessionId, byte count) { + super(CRC); + this.playerId = playerId; + this.sessionId = sessionId; + this.count = count; + } + + public CraftingSessionEnded(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + playerId = data.getLong(); + sessionId = data.getInt(); + count = data.getByte(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 13); + encodeHeader(data); + data.addLong(playerId); + data.addInt(sessionId); + data.addByte(count); + return data; + } + + public long getPlayerId() { + return playerId; + } + + public void setPlayerId(long playerId) { + this.playerId = playerId; + } + + public int getSessionId() { + return sessionId; + } + + public void setSessionId(int sessionId) { + this.sessionId = sessionId; + } + + public byte getCount() { + return count; + } + + public void setCount(byte count) { + this.count = count; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/DataTransform.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/DataTransform.java new file mode 100644 index 0000000..0d43ed1 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/DataTransform.java @@ -0,0 +1,162 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.data.location.Location; +import com.projectswg.common.network.NetBuffer; + +public class DataTransform extends ObjectController { + + public static final int CRC = 0x0071; + + private int timestamp; + private int updateCounter = 0; + private Location l; + private float speed = 0; + private float lookAtYaw = 0; + private boolean useLookAtYaw; + + public DataTransform(long objectId) { + super(objectId, CRC); + } + + public DataTransform(DataTransform transform) { + super(transform.getObjectId(), CRC); + timestamp = transform.getTimestamp(); + updateCounter = transform.getUpdateCounter(); + l = new Location(transform.getLocation()); + speed = transform.getSpeed(); + lookAtYaw = transform.getLookAtYaw(); + useLookAtYaw = transform.isUseLookAtYaw(); + } + + public DataTransform(long objectId, int counter, Location l, float speed) { + super(objectId, CRC); + if (l == null) + l = new Location(); + this.l = l; + this.speed = speed; + this.updateCounter = counter; + } + + public DataTransform(NetBuffer data) { + super(CRC); + this.l = new Location(); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + timestamp = data.getInt(); + updateCounter = data.getInt(); + l = data.getEncodable(Location.class); + speed = data.getFloat(); + lookAtYaw = data.getFloat(); + useLookAtYaw = data.getBoolean(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 45); + encodeHeader(data); + data.addInt(timestamp); + data.addInt(updateCounter); + data.addEncodable(l); + data.addFloat(speed); + data.addFloat(lookAtYaw); + data.addBoolean(useLookAtYaw); + return data; + } + + public void setTimestamp(int timestamp) { + this.timestamp = timestamp; + } + + public void setUpdateCounter(int counter) { + this.updateCounter = counter; + } + + public void setLocation(Location l) { + this.l = l; + } + + public void setSpeed(float speed) { + this.speed = speed; + } + + public int getUpdateCounter() { + return updateCounter; + } + + public Location getLocation() { + return l; + } + + public float getSpeed() { + return speed; + } + + public boolean isUseLookAtYaw() { + return useLookAtYaw; + } + + public void setUseLookAtYaw(boolean useLookAtYaw) { + this.useLookAtYaw = useLookAtYaw; + } + + public float getLookAtYaw() { + return lookAtYaw; + } + + public void setLookAtYaw(float lookAtYaw) { + this.lookAtYaw = lookAtYaw; + } + + public int getTimestamp() { + return timestamp; + } + + public byte getMovementAngle() { + byte movementAngle = (byte) 0.0f; + double wOrient = l.getOrientationW(); + double yOrient = l.getOrientationY(); + double sq = Math.sqrt(1 - (wOrient * wOrient)); + + if (sq != 0) { + if (l.getOrientationW() > 0 && l.getOrientationY() < 0) { + wOrient *= -1; + yOrient *= -1; + } + movementAngle = (byte) ((yOrient / sq) * (2 * Math.acos(wOrient) / 0.06283f)); + } + + return movementAngle; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/DataTransformWithParent.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/DataTransformWithParent.java new file mode 100644 index 0000000..ce9d961 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/DataTransformWithParent.java @@ -0,0 +1,144 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + + +import com.projectswg.common.data.location.Location; +import com.projectswg.common.network.NetBuffer; + +public class DataTransformWithParent extends ObjectController { + + public static final int CRC = 0x00F1; + + private int timestamp; + private int counter; + private long cellId; + private Location l; + private float speed; + private float lookAtYaw; + private boolean useLookAtYaw; + + public DataTransformWithParent(long objectId) { + super(objectId, CRC); + } + + public DataTransformWithParent(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + timestamp = data.getInt(); // Timestamp + counter = data.getInt(); + cellId = data.getLong(); + l = data.getEncodable(Location.class); + speed = data.getFloat(); + lookAtYaw = data.getFloat(); + useLookAtYaw = data.getBoolean(); + } + + @Override + public NetBuffer encode() { + return null; + } + + public void setUpdateCounter(int counter) { + this.counter = counter; + } + + public void setTimestamp(int timestamp) { + this.timestamp = timestamp; + } + + public void setCellId(long cellId) { + this.cellId = cellId; + } + + public void setLocation(Location l) { + this.l = l; + } + + public void setSpeed(float speed) { + this.speed = speed; + } + + public void setLookAtYaw(float lookAtYaw) { + this.lookAtYaw = lookAtYaw; + } + + public void setUseLookAtYaw(boolean useLookAtYaw) { + this.useLookAtYaw = useLookAtYaw; + } + + public int getUpdateCounter() { + return counter; + } + + public long getCellId() { + return cellId; + } + + public Location getLocation() { + return l; + } + + public float getSpeed() { + return speed; + } + + public float getLookAtYaw() { + return lookAtYaw; + } + + public boolean isUseLookAtYaw() { + return useLookAtYaw; + } + + public int getTimestamp() { + return timestamp; + } + + public byte getMovementAngle() { + byte movementAngle = (byte) 0.0f; + double wOrient = l.getOrientationW(); + double yOrient = l.getOrientationY(); + double sq = Math.sqrt(1 - (wOrient * wOrient)); + + if (sq != 0) { + if (l.getOrientationW() > 0 && l.getOrientationY() < 0) { + wOrient *= -1; + yOrient *= -1; + } + movementAngle = (byte) ((yOrient / sq) * (2 * Math.acos(wOrient) / 0.06283f)); + } + + return movementAngle; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/IntendedTarget.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/IntendedTarget.java new file mode 100644 index 0000000..4db17a6 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/IntendedTarget.java @@ -0,0 +1,64 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class IntendedTarget extends ObjectController { + + public static final int CRC = 0x04C5; + + private long targetId; + + public IntendedTarget(long objectId, long targetId) { + super(objectId, CRC); + setTargetId(targetId); + } + + public IntendedTarget(NetBuffer data) { + super(CRC); + decode(data); + } + + public void decode(NetBuffer data) { + decodeHeader(data); + targetId = data.getLong(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 2); + encodeHeader(data); + data.addLong(targetId); + return data; + } + + public long getTargetId() { return targetId; } + + public void setTargetId(long targetId) { this.targetId = targetId; } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/JTLTerminalSharedMessage.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/JTLTerminalSharedMessage.java new file mode 100644 index 0000000..0142655 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/JTLTerminalSharedMessage.java @@ -0,0 +1,48 @@ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class JTLTerminalSharedMessage extends ObjectController { + + public static final int CRC = 0x041C; + + private int tickCount; + private long terminalId; + + public JTLTerminalSharedMessage(NetBuffer data) { + super(CRC); + } + + public int getTickCount() { + return tickCount; + } + + public void setTickCount(int tickCount) { + this.tickCount = tickCount; + } + + public long getTerminalId() { + return terminalId; + } + + public void setTerminalId(long terminalId) { + this.terminalId = terminalId; + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + setTickCount(data.getInt()); + setTerminalId(data.getLong()); + + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 12); + encodeHeader(data); + data.addInt(getTickCount()); + data.addLong(getTerminalId()); + return data; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/JumpUpdate.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/JumpUpdate.java new file mode 100644 index 0000000..de4382d --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/JumpUpdate.java @@ -0,0 +1,54 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class JumpUpdate extends ObjectController { + + public static final int CRC = 0x04BF; + + public JumpUpdate(long objectId) { + super(objectId, CRC); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH); + encodeHeader(data); + + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/LookAtTarget.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/LookAtTarget.java new file mode 100644 index 0000000..e244bf1 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/LookAtTarget.java @@ -0,0 +1,64 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class LookAtTarget extends ObjectController { + + public static final int CRC = 0x0126; + + private long targetId; + + public LookAtTarget(long objectId, long targetId) { + super(objectId, CRC); + setTargetId(targetId); + } + + public LookAtTarget(NetBuffer data) { + super(CRC); + decode(data); + } + + public void decode(NetBuffer data) { + decodeHeader(data); + targetId = data.getLong(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 2); + encodeHeader(data); + data.addLong(targetId); + return data; + } + + public long getTargetId() { return targetId; } + + public void setTargetId(long targetId) { this.targetId = targetId; } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftCustomization.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftCustomization.java new file mode 100644 index 0000000..33914a6 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftCustomization.java @@ -0,0 +1,135 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class MessageQueueCraftCustomization extends ObjectController { + + public static final int CRC = 0x015A; + + private String itemName; + private byte appearenceTemplate; + private int itemAmount; + private byte count; + private int[] property; + private int[] value; + + public MessageQueueCraftCustomization(String itemName, byte appearenceTemplate, int itemAmount, byte count, int[] property, int[] value) { + super(CRC); + this.itemName = itemName; + this.appearenceTemplate = appearenceTemplate; + this.itemAmount = itemAmount; + this.count = count; + this.property = property; + this.value = value; + } + + public MessageQueueCraftCustomization(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + itemName = data.getUnicode(); + appearenceTemplate = data.getByte(); + itemAmount = data.getInt(); + count = data.getByte(); + + for(int i = 0; i < count; i++){ + property[i] = data.getInt(); + value[i] = data.getInt(); + } + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 10 + itemName.length()*2 + count * 8); + encodeHeader(data); + data.addUnicode(itemName); + data.addByte(appearenceTemplate); + data.addInt(itemAmount); + data.addByte(count); + + for(int i = 0; i < count; i++){ + data.addInt(property[i] ); + data.addInt(value[i]); + } + return data; + } + + public String getItemName() { + return itemName; + } + + public void setItemName(String itemName) { + this.itemName = itemName; + } + + public byte getAppearenceTemplate() { + return appearenceTemplate; + } + + public void setAppearenceTemplate(byte appearenceTemplate) { + this.appearenceTemplate = appearenceTemplate; + } + + public int getItemAmount() { + return itemAmount; + } + + public void setItemAmount(int itemAmount) { + this.itemAmount = itemAmount; + } + + public byte getCount() { + return count; + } + + public void setCount(byte count) { + this.count = count; + } + + public int[] getProperty() { + return property; + } + + public void setProperty(int[] property) { + this.property = property; + } + + public int[] getValue() { + return value; + } + + public void setValue(int[] value) { + this.value = value; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftEmptySlot.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftEmptySlot.java new file mode 100644 index 0000000..5ecb5e2 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftEmptySlot.java @@ -0,0 +1,93 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class MessageQueueCraftEmptySlot extends ObjectController{ + + public static final int CRC = 0x0108; + + private int slot; + private long containerId; + private byte staleFlag; + + public MessageQueueCraftEmptySlot(int slot, long containerId, byte staleFlag) { + super(CRC); + this.slot = slot; + this.containerId = containerId; + this.staleFlag = staleFlag; + } + + public MessageQueueCraftEmptySlot(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + slot = data.getInt(); + containerId = data.getLong(); + staleFlag = data.getByte(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 13); + encodeHeader(data); + data.addInt(slot); + data.addLong(containerId); + data.addByte(staleFlag); + return data; + } + + public int getSlot() { + return slot; + } + + public void setSlot(int slot) { + this.slot = slot; + } + + public long getContainerId() { + return containerId; + } + + public void setContainerId(long containerId) { + this.containerId = containerId; + } + + public byte getStaleFlag() { + return staleFlag; + } + + public void setStaleFlag(byte staleFlag) { + this.staleFlag = staleFlag; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftExperiment.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftExperiment.java new file mode 100644 index 0000000..04afc14 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftExperiment.java @@ -0,0 +1,101 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class MessageQueueCraftExperiment extends ObjectController { + + public static final int CRC = 0x0106; + + private byte actionCounter; //total of points, should increase by 2 during experimentation each roll + private int statCount; //counter of stats we can eperiment on + private int[] statExperimentationAmount; //amount of Stats we will experiment on in this roll + private int[] spentPoints; //amount of spentpoints + + public MessageQueueCraftExperiment(byte actionCounter, int statCount, int[] statExperimentationAmount, int[] spentPoints) { + super(CRC); + this.actionCounter = actionCounter; + this.statCount = statCount; + this.statExperimentationAmount = statExperimentationAmount; + this.spentPoints = spentPoints; + } + public MessageQueueCraftExperiment(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + actionCounter = data.getByte(); + statCount = data.getInt(); + for(int i = 0; i < statCount; i++){ + statExperimentationAmount[i] = data.getInt(); + spentPoints[i] = data.getInt(); + } + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 5 + statCount * 8); + encodeHeader(data); + data.addByte(actionCounter); + data.addInt(statCount); + for(int i = 0; i < statCount; i++){ + data.addInt(statExperimentationAmount[i]); + data.addInt(spentPoints[i]); + } + return data; + } + + public byte getActionCounter() { + return actionCounter; + } + public void setActionCounter(byte actionCounter) { + this.actionCounter = actionCounter; + } + public int getStatCount() { + return statCount; + } + public void setStatCount(int statCount) { + this.statCount = statCount; + } + public int[] getStatExperimentationAmount() { + return statExperimentationAmount; + } + public void setStatExperimentationAmount(int[] statExperimentationAmount) { + this.statExperimentationAmount = statExperimentationAmount; + } + public int[] getSpentPoints() { + return spentPoints; + } + public void setSpentPoints(int[] spentPoints) { + this.spentPoints = spentPoints; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftFillSlot.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftFillSlot.java new file mode 100644 index 0000000..d2d0c31 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftFillSlot.java @@ -0,0 +1,105 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class MessageQueueCraftFillSlot extends ObjectController{ + + public static final int CRC = 0x0107; + + private long resourceId; + private int slotId; + private int option; + private byte sequenceId; + + public MessageQueueCraftFillSlot(long resourceId, int slotId, int option, byte sequenceId) { + super(CRC); + this.resourceId = resourceId; + this.slotId = slotId; + this.option = option; + this.sequenceId = sequenceId; + } + + public MessageQueueCraftFillSlot(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + resourceId = data.getLong(); + slotId = data.getInt(); + option = data.getInt(); + sequenceId = data.getByte(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 17 ); + encodeHeader(data); + data.addLong(resourceId); + data.addInt(slotId); + data.addInt(option); + data.addByte(sequenceId); + return data; + } + + public long getResourceId() { + return resourceId; + } + + public void setResourceId(long resourceId) { + this.resourceId = resourceId; + } + + public int getSlotId() { + return slotId; + } + + public void setSlotId(int slotId) { + this.slotId = slotId; + } + + public int getOption() { + return option; + } + + public void setOption(int option) { + this.option = option; + } + + public byte getSequenceId() { + return sequenceId; + } + + public void setSequenceId(byte sequenceId) { + this.sequenceId = sequenceId; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftIngredients.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftIngredients.java new file mode 100644 index 0000000..5f4da15 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftIngredients.java @@ -0,0 +1,112 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class MessageQueueCraftIngredients extends ObjectController { + + public static final int CRC = 0x0105; + + private int count; + private String[] resourceName; + private byte[] type; + private int[] quantity; + + public MessageQueueCraftIngredients(int count, String[] resourceName, byte[] type, int[] quantity) { + super(); + this.count = count; + this.resourceName = resourceName; + this.type = type; + this.quantity = quantity; + } + + public MessageQueueCraftIngredients(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + count = data.getInt(); + for(int i = 0; i < count; i++){ + resourceName[i] = data.getUnicode(); + type[i] = data.getByte(); + quantity[i] = data.getInt(); + } + } + + @Override + public NetBuffer encode() { + int len = 4; + for (int i = 0; i < count; i++) + len += 9 + resourceName[i].length(); + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 4 + len); + encodeHeader(data); + data.addInt(count); + for(int i = 0; i < count; i++){ + data.addUnicode(resourceName[i] ); + data.addByte(type[i]); + data.addInt(quantity[i]); + } + return data; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public String[] getResourceName() { + return resourceName; + } + + public void setResourceName(String[] resourceName) { + this.resourceName = resourceName; + } + + public byte[] getType() { + return type; + } + + public void setType(byte[] type) { + this.type = type; + } + + public int[] getQuantity() { + return quantity; + } + + public void setQuantity(int[] quantity) { + this.quantity = quantity; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftRequestSession.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftRequestSession.java new file mode 100644 index 0000000..21bc494 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftRequestSession.java @@ -0,0 +1,81 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class MessageQueueCraftRequestSession extends ObjectController{ + + private final static int CRC = 0x010F; + + private long sessionId; //wants to create a session for this particular craftingsession + private int sequenceId; + + public MessageQueueCraftRequestSession(long sessionId, int sequenceId) { + super(CRC); + this.sessionId = sessionId; + this.sequenceId = sequenceId; + } + + public MessageQueueCraftRequestSession(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + sessionId = data.getLong(); + sequenceId = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 12); + encodeHeader(data); + data.addLong(sessionId); + data.addInt(sequenceId); + return data; + } + + public long getSessionId() { + return sessionId; + } + + public void setSessionId(long sessionId) { + this.sessionId = sessionId; + } + + public int getSequenceId() { + return sequenceId; + } + + public void setSequenceId(int sequenceId) { + this.sequenceId = sequenceId; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftSelectSchematic.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftSelectSchematic.java new file mode 100644 index 0000000..e8c4526 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueCraftSelectSchematic.java @@ -0,0 +1,61 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class MessageQueueCraftSelectSchematic extends ObjectController { + + public static final int CRC = 0x010E; + + private int schematicId; + + public MessageQueueCraftSelectSchematic(int schematicId) { + super(CRC); + this.schematicId = schematicId; + } + + public MessageQueueCraftSelectSchematic(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + schematicId = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 4 ); + encodeHeader(data); + data.addInt(schematicId); + return data; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueDraftSchematics.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueDraftSchematics.java new file mode 100644 index 0000000..41e855b --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueDraftSchematics.java @@ -0,0 +1,133 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class MessageQueueDraftSchematics extends ObjectController { + + private final static int CRC = 0x0102; + + private long toolId; + private long craftingStationId; + private int schematicsCounter; + private int[] schematicsId; + private int[] schematicsCrc; + private byte [][] schematicSubcategories = new byte[schematicsCounter][4]; + + public MessageQueueDraftSchematics(long toolId, long craftingStationId, int schematicsCounter, int[] schematicsId, int[] schematicsCrc, byte[][] schematicSubcategories) { + super(); + this.toolId = toolId; + this.craftingStationId = craftingStationId; + this.schematicsCounter = schematicsCounter; + this.schematicsId = schematicsId; + this.schematicsCrc = schematicsCrc; + System.arraycopy(schematicSubcategories, 0, this.schematicSubcategories, 0, 4); + } + + public MessageQueueDraftSchematics(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + toolId = data.getLong(); + craftingStationId = data.getLong(); + schematicsCounter = data.getInt(); + for(int i = 0; i < schematicsCounter; i++){ + schematicsId[i] = data.getInt(); + schematicsCrc[i] = data.getInt(); + schematicSubcategories[i] = data.getArray(4); + } + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 20 + schematicsCounter * 12 + schematicSubcategories.length); + encodeHeader(data); + data.addLong(toolId); + data.addLong(craftingStationId); + data.addInt(schematicsCounter); + for(int i = 0; i< schematicsCounter; i++){ + data.addInt(schematicsId[i]); + data.addInt(schematicsCrc[i]); + data.addRawArray(schematicSubcategories[i]); + } + return data; + } + + public long getToolId() { + return toolId; + } + + public void setToolId(long toolId) { + this.toolId = toolId; + } + + public long getCraftingStationId() { + return craftingStationId; + } + + public void setCraftingStationId(long craftingStationId) { + this.craftingStationId = craftingStationId; + } + + public int getSchematicsCounter() { + return schematicsCounter; + } + + public void setSchematicsCounter(int schematicsCounter) { + this.schematicsCounter = schematicsCounter; + } + + public int[] getSchematicsId() { + return schematicsId; + } + + public void setSchematicsId(int[] schematicsId) { + this.schematicsId = schematicsId; + } + + public int[] getSchematicsCrc() { + return schematicsCrc; + } + + public void setSchematicsCrc(int[] schematicsCrc) { + this.schematicsCrc = schematicsCrc; + } + + public byte[][] getSchematicSubcategories() { + return schematicSubcategories; + } + + public void setSchematicSubcategories(byte[][] schematicSubcategories) { + this.schematicSubcategories = schematicSubcategories; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueHarvesterResourceData.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueHarvesterResourceData.java new file mode 100644 index 0000000..6eb8da0 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueHarvesterResourceData.java @@ -0,0 +1,138 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class MessageQueueHarvesterResourceData extends ObjectController { + + public static final int CRC = 0x00EA; + + private long harvesterId; + private int resourceListSize; + private long[] resourceId; + private String[] resourceName; + private String[] resourceType; + private byte[] resourceDensity; + + public MessageQueueHarvesterResourceData(long harvesterId, int resourceListSize, long[] resourceId, String[] resourceName, String[] resourceType, byte[] resourceDensity) { + super(CRC); + this.harvesterId = harvesterId; + this.resourceListSize = resourceListSize; + this.resourceId = resourceId; + this.resourceName = resourceName; + this.resourceType = resourceType; + this.resourceDensity = resourceDensity; + } + + public MessageQueueHarvesterResourceData(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + harvesterId = data.getLong(); + resourceListSize = data.getInt(); + for(int i = 0; i < resourceListSize; i++){ + resourceId[i] = data.getLong(); + resourceName[i] = data.getUnicode(); + resourceType[i] = data.getUnicode(); + resourceDensity[i] = data.getByte(); + } + + } + + @Override + public NetBuffer encode() { + int len = HEADER_LENGTH + 12; + for (int i = 0; i < resourceListSize; i++) + len += 17 + resourceName[i].length() * 2 + resourceType[i].length() * 2; + NetBuffer data = NetBuffer.allocate(len); + encodeHeader(data); + data.addLong(harvesterId); + data.addInt(resourceListSize); + for(int i = 0; i < resourceListSize; i++){ + data.addLong(resourceId[i]); + data.addUnicode(resourceName[i]); + data.addUnicode(resourceType[i]); + data.addByte(resourceDensity[i]); + } + + return data; + } + + public long getHarvesterId() { + return harvesterId; + } + + public void setHarvesterId(long harvesterId) { + this.harvesterId = harvesterId; + } + + public int getResourceListSize() { + return resourceListSize; + } + + public void setResourceListSize(int resourceListSize) { + this.resourceListSize = resourceListSize; + } + + public long[] getResourceId() { + return resourceId; + } + + public void setResourceId(long[] resourceId) { + this.resourceId = resourceId; + } + + public String[] getResourceName() { + return resourceName; + } + + public void setResourceName(String[] resourceName) { + this.resourceName = resourceName; + } + + public String[] getResourceType() { + return resourceType; + } + + public void setResourceTypo(String[] resourceType) { + this.resourceType = resourceType; + } + + public byte[] getResourceDensity() { + return resourceDensity; + } + + public void setResourceDensity(byte[] resourceDensity) { + this.resourceDensity = resourceDensity; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueResourceEmptyHopper.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueResourceEmptyHopper.java new file mode 100644 index 0000000..2445371 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueResourceEmptyHopper.java @@ -0,0 +1,117 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class MessageQueueResourceEmptyHopper extends ObjectController { + + public static final int CRC = 0x00ED; + + private long playerId; + private long harvesterId; + private int amount; + private boolean discard; + private int sequenceId; + + public MessageQueueResourceEmptyHopper(long playerId, long harvesterId, int amount, boolean discard, int sequenceId) { + super(CRC); + this.playerId = playerId; + this.harvesterId = harvesterId; + this.amount = amount; + this.discard = discard; + this.sequenceId = sequenceId; + } + + public MessageQueueResourceEmptyHopper(NetBuffer data){ + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + playerId = data.getLong(); + harvesterId = data.getLong(); + amount = data.getInt(); + discard = data.getBoolean(); + sequenceId = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 25 ); + encodeHeader(data); + data.addLong(playerId); + data.addLong(harvesterId); + data.addInt(amount); + data.addBoolean(discard); + data.addInt(sequenceId); + return data; + } + + public long getPlayerId() { + return playerId; + } + + public void setPlayerId(long playerId) { + this.playerId = playerId; + } + + public long getHarvesterId() { + return harvesterId; + } + + public void setHarvesterId(long harvesterId) { + this.harvesterId = harvesterId; + } + + public int getAmount() { + return amount; + } + + public void setAmount(int amount) { + this.amount = amount; + } + + public boolean isDiscard() { + return discard; + } + + public void setDiscard(boolean discard) { + this.discard = discard; + } + + public int getSequenceId() { + return sequenceId; + } + + public void setSequenceId(int sequenceId) { + this.sequenceId = sequenceId; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueSpaceMiningSellResource.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueSpaceMiningSellResource.java new file mode 100644 index 0000000..dad6cb9 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MessageQueueSpaceMiningSellResource.java @@ -0,0 +1,105 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class MessageQueueSpaceMiningSellResource extends ObjectController{ + + public static final int CRC = 0x04B6; + + private long shipId; + private long spaceStationId; + private long resourceId; + private int amount; + + public MessageQueueSpaceMiningSellResource(long shipId, long spaceStationId, long resourceId, int amount) { + super(CRC); + this.shipId = shipId; + this.spaceStationId = spaceStationId; + this.resourceId = resourceId; + this.amount = amount; + } + + public MessageQueueSpaceMiningSellResource(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + shipId = data.getLong(); + spaceStationId = data.getLong(); + resourceId = data.getLong(); + amount = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 28 ); + encodeHeader(data); + data.addLong(shipId); + data.addLong(spaceStationId); + data.addLong(resourceId); + data.addInt(amount); + return data; + } + + public long getShipId() { + return shipId; + } + + public void setShipId(long shipId) { + this.shipId = shipId; + } + + public long getSpaceStationId() { + return spaceStationId; + } + + public void setSpaceStationId(long spaceStationId) { + this.spaceStationId = spaceStationId; + } + + public long getResourceId() { + return resourceId; + } + + public void setResourceId(long resourceId) { + this.resourceId = resourceId; + } + + public int getAmount() { + return amount; + } + + public void setAmount(int amount) { + this.amount = amount; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/MissionListRequest.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MissionListRequest.java new file mode 100644 index 0000000..89257b9 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/MissionListRequest.java @@ -0,0 +1,49 @@ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class MissionListRequest extends ObjectController{ + + public static final int CRC = 0x00F5; + + private long terminalId; + private byte tickCount; + + public MissionListRequest(NetBuffer data) { + super(CRC); + } + + public long getTerminalId() { + return terminalId; + } + + public void setTerminalId(long terminalId) { + this.terminalId = terminalId; + } + + public byte getTickCount() { + return tickCount; + } + + public void setTickCount(byte tickCount) { + this.tickCount = tickCount; + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + data.getByte(); + setTickCount(data.getByte()); + setTerminalId(data.getLong()); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 10); + encodeHeader(data); + data.addByte(0); + data.addByte(getTickCount()); + data.addLong(getTerminalId()); + return data; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/NextCraftingStage.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/NextCraftingStage.java new file mode 100644 index 0000000..f046fdd --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/NextCraftingStage.java @@ -0,0 +1,93 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class NextCraftingStage extends ObjectController{ + + public static final int CRC = 0x0109; + + private int requestId; + private int response; + private byte sequenceId; + + public NextCraftingStage(int requestId, int response, byte sequenceId) { + super(CRC); + this.requestId = requestId; + this.response = response; + this.sequenceId = sequenceId; + } + + public NextCraftingStage(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + requestId = data.getInt(); + response = data.getInt(); + sequenceId = data.getByte(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 9); + encodeHeader(data); + data.addInt(requestId); + data.addInt(response); + data.addByte(sequenceId); + return data; + } + + public int getRequestId() { + return requestId; + } + + public void setRequestId(int requestId) { + this.requestId = requestId; + } + + public int getResponse() { + return response; + } + + public void setResponse(int response) { + this.response = response; + } + + public byte getSequenceId() { + return sequenceId; + } + + public void setSequenceId(byte sequenceId) { + this.sequenceId = sequenceId; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/NextCraftingStageResult.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/NextCraftingStageResult.java new file mode 100644 index 0000000..adafffe --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/NextCraftingStageResult.java @@ -0,0 +1,93 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class NextCraftingStageResult extends ObjectController { + + public static final int CRC = 0x01BE; + + private int requestId; + private int response; + private byte sequenceId; + + public NextCraftingStageResult(int requestId, int response, byte sequenceId) { + super(CRC); + this.requestId = requestId; + this.response = response; + this.sequenceId = sequenceId; + } + + public NextCraftingStageResult(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + requestId = data.getInt(); + response = data.getInt(); + sequenceId = data.getByte(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 9); + encodeHeader(data); + data.addInt(requestId); + data.addInt(response); + data.addByte(sequenceId); + return data; + } + + public int getRequestId() { + return requestId; + } + + public void setRequestId(int requestId) { + this.requestId = requestId; + } + + public int getResponse() { + return response; + } + + public void setResponse(int response) { + this.response = response; + } + + public byte getSequenceId() { + return sequenceId; + } + + public void setSequenceId(byte sequenceId) { + this.sequenceId = sequenceId; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/ObjectController.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/ObjectController.java new file mode 100644 index 0000000..d4e2567 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/ObjectController.java @@ -0,0 +1,142 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.debug.Log; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; +import com.projectswg.common.network.packets.swg.zone.object_controller.combat.CombatAction; +import com.projectswg.common.network.packets.swg.zone.object_controller.combat.CombatSpam; + +public abstract class ObjectController extends SWGPacket { + + public static final int CRC = 0x80CE5E46; + protected static final int HEADER_LENGTH = 26; + + private final int controllerCrc; + private int update = 0; + private long objectId = 0; + + public ObjectController() { + this(0, 0); + } + + public ObjectController(int controllerCrc) { + this(0, controllerCrc); + } + + public ObjectController(long objectId, int controllerCrc) { + this.objectId = objectId; + this.controllerCrc = controllerCrc; + this.update = 0x1B; + } + + protected final void decodeHeader(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + update = data.getInt(); + if (data.getInt() != controllerCrc) + Log.e("Attempting to process invalid controller"); + objectId = data.getLong(); + data.getInt(); + return; + } + + protected final void encodeHeader(NetBuffer data) { + data.addShort(5); + data.addInt(CRC); + data.addInt(update); + data.addInt(controllerCrc); + data.addLong(objectId); + data.addInt(0); + } + + @Override + public abstract void decode(NetBuffer data); + @Override + public abstract NetBuffer encode(); + + public long getObjectId() { return objectId; } + public int getUpdate() { return update; } + public int getControllerCrc() { return controllerCrc; } + + public void setUpdate(int update) { this.update = update; } + + public static final ObjectController decodeController(NetBuffer data) { + if (data.array().length < 14) + return null; + int pos = data.position(); + data.position(pos+10); + int crc = data.getInt(); + data.position(pos); + switch (crc) { + case 0x0071: return new DataTransform(data); + case 0x00CC: return new CombatAction(data); + case 0x00F1: return new DataTransformWithParent(data); + case 0x0116: return new CommandQueueEnqueue(data); + case 0x0117: return new CommandQueueDequeue(data); + case 0x0126: return new LookAtTarget(data); + case 0x012E: return new PlayerEmote(data); + case 0x0131: return new PostureUpdate(data); + case 0x0134: return new CombatSpam(data); + case 0x0146: return new ObjectMenuRequest(data); + case 0x01BD: return new ShowFlyText(data); + case 0x01DB: return new BiographyUpdate(data); + case 0x0448: return new CommandTimer(data); + case 0x044D: return new ChangeRoleIconChoice(data); + case 0x04BC: return new ShowLootBox(data); + case 0x04C5: return new IntendedTarget(data); + case 0x00F5: return new MissionListRequest(data); + case 0x041C: return new JTLTerminalSharedMessage(data); + case 0x0115: return new SecureTrade(data); + } + Log.w("Unknown object controller: %08X", crc); + return new GenericObjectController(crc, data); + } + + private static class GenericObjectController extends ObjectController { + + public GenericObjectController(int crc, NetBuffer data) { + super(0, crc); + decode(data); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH); + encodeHeader(data); + return data; + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + } + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/ObjectMenuRequest.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/ObjectMenuRequest.java new file mode 100644 index 0000000..b185aa3 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/ObjectMenuRequest.java @@ -0,0 +1,84 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import java.util.List; + +import com.projectswg.common.data.radial.RadialOption; +import com.projectswg.common.data.radial.RadialOptionList; +import com.projectswg.common.network.NetBuffer; + +public class ObjectMenuRequest extends ObjectController { + + public static final int CRC = 0x0146; + + private long targetId; + private long requestorId; + private RadialOptionList options; + private byte counter; + + public ObjectMenuRequest(long objectId) { + super(objectId, CRC); + options = new RadialOptionList(); + } + + public ObjectMenuRequest(NetBuffer data) { + super(CRC); + options = new RadialOptionList(); + decode(data); + } + + public void decode(NetBuffer data) { + decodeHeader(data); + targetId = data.getLong(); + requestorId = data.getLong(); + options = data.getEncodable(RadialOptionList.class); + counter = data.getByte(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + options.getSize() + 17); + encodeHeader(data); + data.addLong(targetId); + data.addLong(requestorId); + data.addEncodable(options); + data.addByte(counter); + return data; + } + + public long getTargetId() { return targetId; } + public long getRequestorId() { return requestorId; } + public int getCounter() { return counter; } + public List getOptions() { return options.getOptions(); } + + public void setTargetId(long targetId) { this.targetId = targetId; } + public void setRequestorId(long requesterId) { this.requestorId = requesterId; } + public void setCounter(byte counter) { this.counter = counter; } + public void addOption(RadialOption opt) { options.addOption(opt); } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/ObjectMenuResponse.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/ObjectMenuResponse.java new file mode 100644 index 0000000..4ab3f08 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/ObjectMenuResponse.java @@ -0,0 +1,120 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import java.util.List; + +import com.projectswg.common.data.radial.RadialOption; +import com.projectswg.common.data.radial.RadialOptionList; +import com.projectswg.common.network.NetBuffer; + +public class ObjectMenuResponse extends ObjectController { + + public static final int CRC = 0x0147; + + private RadialOptionList options; + private long targetId; + private long requestorId; + private int counter; + + public ObjectMenuResponse(long objectId) { + super(objectId, CRC); + this.options = new RadialOptionList(); + } + + public ObjectMenuResponse(long objectId, long targetId, long requestorId, List options, int counter) { + super(objectId, CRC); + this.targetId = targetId; + this.requestorId = requestorId; + this.options = new RadialOptionList(options); + this.counter = counter; + setTargetId(targetId); + setRequestorId(requestorId); + setRadialOptions(options); + setCounter(counter); + } + + public ObjectMenuResponse(NetBuffer data) { + super(CRC); + this.options = new RadialOptionList(); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + targetId = data.getLong(); + requestorId = data.getLong(); + options = data.getEncodable(RadialOptionList.class); + counter = data.getByte(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + options.getSize() + 17); + encodeHeader(data); + data.addLong(targetId); + data.addLong(requestorId); + data.addEncodable(options); + data.addByte(counter); + return data; + } + + public void setTargetId(long targetId) { + this.targetId = targetId; + } + + public void setRequestorId(long requestorId) { + this.requestorId = requestorId; + } + + public void setRadialOptions(List options) { + this.options.setOptions(options); + } + + public void setCounter(int counter) { + this.counter = counter; + } + + public long getTargetId() { + return targetId; + } + + public long getRequestorId() { + return requestorId; + } + + public List getOptions() { + return options.getOptions(); + } + + public int getCounter() { + return counter; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/PlayerEmote.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/PlayerEmote.java new file mode 100644 index 0000000..c6bcdba --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/PlayerEmote.java @@ -0,0 +1,83 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class PlayerEmote extends ObjectController { + + public static final int CRC = 0x012E; + + private long sourceId; + private long targetId; + private short emoteId; + + public PlayerEmote(long objectId) { + super(objectId, CRC); + } + + public PlayerEmote(NetBuffer data) { + super(CRC); + decode(data); + } + + public PlayerEmote(long objectId, long sourceId, long targetId, short emoteId) { + super(objectId, CRC); + this.sourceId = sourceId; + this.targetId = targetId; + this.emoteId = emoteId; + } + + public PlayerEmote(long objectId, PlayerEmote emote) { + super(objectId, CRC); + this.sourceId = emote.sourceId; + this.targetId = emote.targetId; + this.emoteId = emote.emoteId; + } + + public void decode(NetBuffer data) { + decodeHeader(data); + sourceId = data.getLong(); + targetId = data.getLong(); + emoteId = data.getShort(); + data.getShort(); // Should be 0 + data.getByte(); // Should be 3 + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 21); + encodeHeader(data); + data.addLong(sourceId); + data.addLong(targetId); + data.addShort(emoteId); + data.addShort((short) 0); + data.addByte((byte) 3); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/PostureUpdate.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/PostureUpdate.java new file mode 100644 index 0000000..28b422a --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/PostureUpdate.java @@ -0,0 +1,67 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.data.encodables.tangible.Posture; +import com.projectswg.common.network.NetBuffer; + +public class PostureUpdate extends ObjectController { + + public static final int CRC = 0x0131; + + private Posture posture; + + public PostureUpdate(long objectId, Posture posture) { + super(objectId, CRC); + this.posture = posture; + } + + public PostureUpdate(NetBuffer data) { + super(CRC); + decode(data); + } + + public void decode(NetBuffer data) { + decodeHeader(data); + posture = Posture.getFromId(data.getByte()); + data.getBoolean(); // isClientImmediate + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 2); + encodeHeader(data); + data.addByte(posture.getId()); + data.addBoolean(true); // isClientImmediate + return data; + } + + public Posture getPosture() { return posture; } + + public void setPosture(Posture posture) { this.posture = posture; } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/SecureTrade.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/SecureTrade.java new file mode 100644 index 0000000..e7c8184 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/SecureTrade.java @@ -0,0 +1,87 @@ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.data.EnumLookup; +import com.projectswg.common.network.NetBuffer; + +public class SecureTrade extends ObjectController { + + public static final int CRC = 0x0115; + + private TradeMessageType type; + private long starterId; + private long accepterId; + + public SecureTrade(TradeMessageType type, long starterId, long accepterId) { + super(CRC); + this.type = type; + this.starterId = starterId; + this.accepterId = accepterId; + } + + public SecureTrade(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + type = TradeMessageType.getTypeForInt(data.getInt()); + starterId = data.getLong(); + accepterId = data.getLong(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 20); + encodeHeader(data); + data.addInt(type.getId()); + data.addLong(starterId); + data.addLong(accepterId); + return data; + } + + public TradeMessageType getType() { + return type; + } + + public void setType(TradeMessageType type) { + this.type = type; + } + + public long getStarterId() { + return starterId; + } + + public long getAccepterId() { + return accepterId; + } + + public static enum TradeMessageType { + UNDEFINED (Integer.MIN_VALUE), + REQUEST_TRADE (0), + TRADE_REQUESTED (1), + ACCEPT_TRADE (2), + DENIED_TRADE (3), + DENIED_PLAYER_BUSY (4), + DENIED_PLAYER_UNREACHABLE (5), + REQUEST_TRADE_REVERSED (6), + LAST_TRADE_MESSAGE (7); + + private static final EnumLookup LOOKUP = new EnumLookup<>(TradeMessageType.class, t -> t.getId()); + + private int id; + + TradeMessageType(int id) { + this.id = id; + } + + public int getId() { + return id; + } + + public static TradeMessageType getTypeForInt(int id) { + return LOOKUP.getEnum(id, UNDEFINED); + } + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/ShowFlyText.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/ShowFlyText.java new file mode 100644 index 0000000..37eb24e --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/ShowFlyText.java @@ -0,0 +1,209 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import java.util.EnumSet; +import java.util.Set; + +import com.projectswg.common.data.RGB; +import com.projectswg.common.data.encodables.oob.OutOfBandPackage; +import com.projectswg.common.data.encodables.oob.StringId; +import com.projectswg.common.network.NetBuffer; + +public class ShowFlyText extends ObjectController { + + public static final int CRC = 0x01BD; + + private StringId text; + private OutOfBandPackage oob; + private double scale; + private RGB rgb; + private Set display; + + public ShowFlyText(long objectId, String text, Scale scale, RGB rgb, Flag ... flags) { + this(objectId, new StringId(text), scale, rgb, flags); + } + + public ShowFlyText(long objectId, StringId text, Scale scale, RGB rgb, Flag ... flags) { + this(objectId, text, new OutOfBandPackage(), scale, rgb, flags); + } + + public ShowFlyText(long objectId, OutOfBandPackage oob, Scale scale, RGB rgb, Flag ... flags) { + this(objectId, new StringId(), oob, scale, rgb, flags); + } + + public ShowFlyText(long objectId, StringId text, OutOfBandPackage oob, Scale scale, RGB rgb, Flag ... flags) { + this(objectId, text, oob, scale.getSize(), rgb, flags); + } + + public ShowFlyText(long objectId, StringId text, OutOfBandPackage oob, double scale, RGB rgb, Flag ... flags) { + super(objectId, CRC); + this.text = text; + this.oob = oob; + this.scale = scale; + this.rgb = rgb; + this.display = EnumSet.noneOf(Flag.class); + setDisplayFlag(flags); + } + + public ShowFlyText(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + data.getLong(); + text = data.getEncodable(StringId.class); + oob = data.getEncodable(OutOfBandPackage.class); + scale = data.getFloat(); + rgb = data.getEncodable(RGB.class); + display = Flag.getFlyFlags(data.getInt()); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 27 + text.getFile().length() + text.getKey().length() + oob.getLength()); + encodeHeader(data); + data.addLong(getObjectId()); + data.addEncodable(text); + data.addEncodable(oob); + data.addFloat((float) scale); + data.addEncodable(rgb); + data.addInt(getDisplayBitmask()); + return data; + } + + public StringId getText() { + return text; + } + + public void setText(StringId text) { + this.text = text; + } + + public OutOfBandPackage getOob() { + return oob; + } + + public void setOob(OutOfBandPackage oob) { + this.oob = oob; + } + + public double getScale() { + return scale; + } + + public void setScale(double scale) { + this.scale = scale; + } + + public RGB getRgb() { + return rgb; + } + + public void setRgb(RGB rgb) { + this.rgb = rgb; + } + + public Set getDisplayFlags() { + return display; + } + + public void setDisplayFlag(ShowFlyText.Flag ... flags) { + for (Flag f : flags) + display.add(f); + } + + public void removeDisplayFlag(ShowFlyText.Flag ... flags) { + for (Flag f : flags) + display.remove(f); + } + + private int getDisplayBitmask() { + int bitmask = 0; + for (Flag f : display) + bitmask |= f.getMask(); + return bitmask; + } + + public enum Scale { + SMALLEST(1.0), + SMALL (1.2), + MEDIUM (1.5), + LARGE (2.0), + LARGEST (2.5); + + private double size; + + Scale(double size) { + this.size = size; + } + + public double getSize() { + return size; + } + } + + public enum Flag { + PRIVATE (0x0001), + SHOW_IN_CHAT_BOX (0x0002), + IS_DAMAGE_FROM_PLAYER (0x0004), + IS_SNARE (0x0008), + IS_GLANCING_BLOW (0x0010), + IS_CRITICAL_HIT (0x0020), + IS_LUCKY (0x0040), + IS_DOT (0x0080), + IS_BLEED (0x0100), + IS_HEAL (0x0200), + IS_FREESHOT (0x0400); + + private static final Flag [] VALUES = values(); + + private int num; + + Flag(int num) { + this.num = num; + } + + public int getMask() { + return num; + } + + public static Set getFlyFlags(int num) { + Set flags = EnumSet.noneOf(Flag.class); + for (Flag flag : VALUES) { + if ((num & flag.getMask()) != 0) + flags.add(flag); + } + return flags; + } + } +} + diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/ShowLootBox.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/ShowLootBox.java new file mode 100644 index 0000000..1de2da1 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/ShowLootBox.java @@ -0,0 +1,75 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class ShowLootBox extends ObjectController { + + public static final int CRC = 0x04BC; + + private long[] items; + + public ShowLootBox(long objectId, long[] items) { + super(objectId, CRC); + this.items = items; + } + + public ShowLootBox(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + + int itemCount = data.getInt(); + items = new long[itemCount]; + + for(int i = 0; i < itemCount; i++ ) { + items[i] = data.getLong(); + } + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 4 + items.length * 8); + encodeHeader(data); + + + data.addInt(items.length); + for (long objectId : items) { + data.addLong(objectId); + } + + return data; + } + +} + diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/SitOnObject.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/SitOnObject.java new file mode 100644 index 0000000..684162b --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/SitOnObject.java @@ -0,0 +1,86 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + +public class SitOnObject extends ObjectController { + + public static final int CRC = 0x013B; + + private long cellId; + private float x; + private float y; + private float z; + + public SitOnObject(long objectId) { + super(objectId, CRC); + } + + public SitOnObject(NetBuffer data) { + super(CRC); + decode(data); + } + + public SitOnObject(long objectId, long cellId, float x, float y, float z ) { + super(objectId, CRC); + this.cellId = cellId; + this.x = x; + this.y = y; + this.z = z; + } + + public SitOnObject(long objectId, SitOnObject sit) { + super(objectId, CRC); + this.cellId = sit.cellId; + this.x = sit.x; + this.y = sit.y; + this.z = sit.z; + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + cellId = data.getLong(); + x = data.getFloat(); + z = data.getFloat(); + y = data.getFloat(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 20); + encodeHeader(data); + data.addLong(cellId); + data.addFloat(x); + data.addFloat(z); + data.addFloat(y); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/SpatialChat.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/SpatialChat.java new file mode 100644 index 0000000..23fe163 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/SpatialChat.java @@ -0,0 +1,129 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller; + +import com.projectswg.common.network.NetBuffer; + + +public class SpatialChat extends ObjectController { + + public static final int CRC = 0x00F4; + + private long sourceId = 0; + private long targetId = 0; + private String text = ""; + private short balloonSize = 5; + private short balloonType = 0; + private short moodId = 0; + private byte languageId = 0; + private String outOfBand = ""; + private String sourceName = ""; + + public SpatialChat(long objectId) { + super(objectId, CRC); + } + + public SpatialChat(long objectId, long sourceId, long targetId, String text, short balloonType, short moodId) { + super(objectId, CRC); + this.sourceId = sourceId; + this.targetId = targetId; + this.text = text; + this.balloonType = balloonType; + this.moodId = moodId; + } + + public SpatialChat(long objectId, SpatialChat chat) { + super(objectId, CRC); + this.sourceId = chat.sourceId; + this.targetId = chat.targetId; + this.text = chat.text; + this.balloonSize = chat.balloonSize; + this.balloonType = chat.balloonType; + this.moodId = chat.moodId; + this.languageId = chat.languageId; + this.outOfBand = chat.outOfBand; + this.sourceName = chat.sourceName; + } + + public SpatialChat(NetBuffer data) { + super(CRC); + decode(data); + } + + public void decode(NetBuffer data) { + decodeHeader(data); + sourceId = data.getLong(); + targetId = data.getLong(); + text = data.getUnicode(); + data.getInt(); + balloonSize = data.getShort(); + balloonType = data.getShort(); + moodId = data.getShort(); + languageId = data.getByte(); + outOfBand = data.getUnicode(); + sourceName = data.getUnicode(); + } + + public NetBuffer encode() { + int length = 39 + text.length()*2 + outOfBand.length()*2 + sourceName.length()*2; + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + length); + encodeHeader(data); + data.addLong(sourceId); + data.addLong(targetId); + data.addUnicode(text); + data.addInt(0); // flags + data.addShort(balloonSize); + data.addShort(balloonType); + data.addShort(moodId); + data.addByte(languageId); // languageId + data.addUnicode(outOfBand); + data.addUnicode(sourceName); + return data; + } + + public void setSourceId(long sourceId) { this.sourceId = sourceId; } + public void setTargetId(long targetId) { this.targetId = targetId; } + public void setText(String text) { this.text = text; } + public void setBalloonSize(short size) { this.balloonSize = size; } + public void setBalloonType(short type) { this.balloonType = type; } + public void setMoodId(short moodId) { this.moodId = moodId; } + public void setLanguageId(byte id) { this.languageId = id; } + public void setOutOfBand(String oob) { this.outOfBand = oob; } + public void setSourceName(String name) { this.sourceName = name; } + + public long getSourceId() { return sourceId; } + public long getTargetId() { return targetId; } + public String getText() { return text; } + public short getBalloonSize() { return balloonSize; } + public short getBalloonType() { return balloonType; } + public short getMoodId() { return moodId; } + public byte getLanguageId() { return languageId; } + public String getOutOfBand() { return outOfBand; } + public String getSourceName() { return sourceName; } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/combat/CombatAction.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/combat/CombatAction.java new file mode 100644 index 0000000..2ddd047 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/combat/CombatAction.java @@ -0,0 +1,297 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller.combat; + +import java.util.HashSet; +import java.util.Set; + +import com.projectswg.common.data.combat.HitLocation; +import com.projectswg.common.data.combat.TrailLocation; +import com.projectswg.common.data.encodables.tangible.Posture; +import com.projectswg.common.data.location.Point3D; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.swg.zone.object_controller.ObjectController; + +public class CombatAction extends ObjectController { + + public static final int CRC = 0x00CC; + + private int actionCrc; + private long attackerId; + private long weaponId; + private Posture posture; + private Point3D position; + private long cell; + private TrailLocation trail; + private byte clientEffectId; + private int commandCrc; + private boolean useLocation; + private Set defenders; + + public CombatAction(long objectId) { + super(objectId, CRC); + defenders = new HashSet<>(); + } + + public CombatAction(NetBuffer data) { + super(CRC); + defenders = new HashSet<>(); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + actionCrc = data.getInt(); + attackerId = data.getLong(); + weaponId = data.getLong(); + posture = Posture.getFromId(data.getByte()); + trail = TrailLocation.getTrailLocation(data.getByte()); + clientEffectId = data.getByte(); + commandCrc = data.getInt(); + useLocation = data.getBoolean(); + if (useLocation) { + position = data.getEncodable(Point3D.class); + cell = data.getLong(); + } + int count = data.getShort(); + for (int i = 0; i < count; i++) { + Defender d = new Defender(); + d.setCreatureId(data.getLong()); + d.setPosture(Posture.getFromId(data.getByte())); + d.setDefense(data.getBoolean()); + d.setClientEffectId(data.getByte()); + d.setHitLocation(HitLocation.getHitLocation(data.getByte())); + d.setDamage(data.getShort()); + defenders.add(d); + } + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 30 + defenders.size() * 14 + (useLocation ? 20 : 0)); + encodeHeader(data); + data.addInt(actionCrc); + data.addLong(attackerId); + data.addLong(weaponId); + data.addByte(posture.getId()); + data.addByte(trail.getNum()); + data.addByte(clientEffectId); + data.addInt(commandCrc); + data.addBoolean(useLocation); + if (useLocation) { + data.addEncodable(position); + data.addLong(cell); + } + data.addShort(defenders.size()); + for (Defender d : defenders) { + data.addLong(d.getCreatureId()); + data.addByte(d.getPosture().getId()); + data.addBoolean(d.isDefense()); + data.addByte(d.getClientEffectId()); + data.addByte(d.getHitLocation().getNum()); + data.addShort(d.getDamage()); + } + return data; + } + + public int getActionCrc() { + return actionCrc; + } + + public long getAttackerId() { + return attackerId; + } + + public long getWeaponId() { + return weaponId; + } + + public Posture getPosture() { + return posture; + } + + public Point3D getPosition() { + return position; + } + + public long getCell() { + return cell; + } + + public TrailLocation getTrail() { + return trail; + } + + public byte getClientEffectId() { + return clientEffectId; + } + + public int getCommandCrc() { + return commandCrc; + } + + public boolean isUseLocation() { + return useLocation; + } + + public Set getDefenders() { + return defenders; + } + + public void setActionCrc(int actionCrc) { + this.actionCrc = actionCrc; + } + + public void setAttackerId(long attackerId) { + this.attackerId = attackerId; + } + + public void setWeaponId(long weaponId) { + this.weaponId = weaponId; + } + + public void setPosture(Posture posture) { + this.posture = posture; + } + + public void setPosition(Point3D position) { + this.position = position; + } + + public void setCell(long cell) { + this.cell = cell; + } + + public void setTrail(TrailLocation trail) { + this.trail = trail; + } + + public void setClientEffectId(byte clientEffectId) { + this.clientEffectId = clientEffectId; + } + + public void setCommandCrc(int commandCrc) { + this.commandCrc = commandCrc; + } + + public void setUseLocation(boolean useLocation) { + this.useLocation = useLocation; + } + + public void addDefender(Defender defender) { + defenders.add(defender); + } + + public static class Defender { + + private long creatureId; + private Posture posture; + private boolean defense; + private byte clientEffectId; + private HitLocation hitLocation; + private short damage; + + public Defender() { + this(0, Posture.UPRIGHT, false, (byte) 0, HitLocation.HIT_LOCATION_BODY, (short) 0); + } + + public Defender(long creatureId, Posture p, boolean defense, byte clientEffectId, HitLocation location, short damage) { + setCreatureId(creatureId); + setPosture(p); + setDefense(defense); + setClientEffectId(clientEffectId); + setHitLocation(location); + setDamage(damage); + } + + public long getCreatureId() { + return creatureId; + } + + public Posture getPosture() { + return posture; + } + + public boolean isDefense() { + return defense; + } + + public byte getClientEffectId() { + return clientEffectId; + } + + public HitLocation getHitLocation() { + return hitLocation; + } + + public short getDamage() { + return damage; + } + + public void setCreatureId(long creatureId) { + this.creatureId = creatureId; + } + + public void setPosture(Posture p) { + this.posture = p; + } + + public void setDefense(boolean defense) { + this.defense = defense; + } + + public void setClientEffectId(byte clientEffectId) { + this.clientEffectId = clientEffectId; + } + + public void setHitLocation(HitLocation hitLocation) { + this.hitLocation = hitLocation; + } + + public void setDamage(short damage) { + this.damage = damage; + } + + @Override + public int hashCode() { + return Long.hashCode(creatureId); + } + + public boolean equals(Defender d) { + return creatureId == d.getCreatureId(); + } + + @Override + public String toString() { + return String.format("CREO=%d:%s Defense=%b EffectId=%d HitLoc=%s Damage=%d", creatureId, posture, defense, clientEffectId, hitLocation, damage); + } + } + +} + diff --git a/src/com/projectswg/common/network/packets/swg/zone/object_controller/combat/CombatSpam.java b/src/com/projectswg/common/network/packets/swg/zone/object_controller/combat/CombatSpam.java new file mode 100644 index 0000000..3ceebf9 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/object_controller/combat/CombatSpam.java @@ -0,0 +1,274 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.object_controller.combat; + +import com.projectswg.common.data.combat.AttackInfo; +import com.projectswg.common.data.combat.DamageType; +import com.projectswg.common.data.combat.HitLocation; +import com.projectswg.common.data.encodables.oob.StringId; +import com.projectswg.common.data.location.Point3D; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.swg.zone.object_controller.ObjectController; + +public class CombatSpam extends ObjectController { + + public static final int CRC = 0x0134; + + private byte dataType; + private long attacker; + private Point3D attackerPosition; + private long defender; + private Point3D defenderPosition; + private long weapon; + private StringId weaponName; + private StringId attackName; + private AttackInfo info; + private String spamMessage; + private int spamType; + + public CombatSpam(long objectId) { + super(objectId, CRC); + } + + public CombatSpam(NetBuffer data) { + super(CRC); + decode(data); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + info = new AttackInfo(); + dataType = data.getByte(); + attacker = data.getLong(); + attackerPosition = data.getEncodable(Point3D.class); + defender = data.getLong(); + defenderPosition = data.getEncodable(Point3D.class); + if (isAttackDataWeaponObject(dataType) || isAttackWeaponName(dataType)) { + if (isAttackDataWeaponObject(dataType)) + weapon = data.getLong(); + else + weaponName = data.getEncodable(StringId.class); + attackName = data.getEncodable(StringId.class); + info.setSuccess(data.getBoolean()); + if (info.isSuccess()) { + info.setArmor(data.getLong()); + info.setRawDamage(data.getInt()); + info.setDamageType(DamageType.getDamageType(data.getInt())); + info.setElementalDamage(data.getInt()); + info.setElementalDamageType(DamageType.getDamageType(data.getInt())); + info.setBleedDamage(data.getInt()); + info.setCriticalDamage(data.getInt()); + info.setBlockedDamage(data.getInt()); + info.setFinalDamage(data.getInt()); + info.setHitLocation(HitLocation.getHitLocation(data.getInt())); + info.setCrushing(data.getBoolean()); + info.setStrikethrough(data.getBoolean()); + info.setStrikethroughAmount(data.getFloat()); + info.setEvadeResult(data.getBoolean()); + info.setEvadeAmount(data.getFloat()); + info.setBlockResult(data.getBoolean()); + info.setBlock(data.getInt()); + } else { + info.setDodge(data.getBoolean()); + info.setParry(data.getBoolean()); + } + } else { + // spamMessage = data.getUnicode(); + data.getInt(); + } + info.setCritical(data.getBoolean()); + info.setGlancing(data.getBoolean()); + info.setProc(data.getBoolean()); + spamType = data.getInt(); + if (isMessageData(dataType)) { + // Extra stuff? + } + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(getEncodeSize()); + encodeHeader(data); + data.addByte(dataType); + data.addLong(attacker); + data.addEncodable(attackerPosition); + data.addLong(defender); + data.addEncodable(defenderPosition); + if (isAttackDataWeaponObject(dataType) || isAttackWeaponName(dataType)) { + if (isAttackDataWeaponObject(dataType)) + data.addLong(weapon); + else + data.addEncodable(weaponName); + data.addEncodable(attackName); + data.addBoolean(info.isSuccess()); + if (info.isSuccess()) { + data.addLong(info.getArmor()); + data.addInt(info.getRawDamage()); + data.addInt(info.getDamageType().getNum()); + data.addInt(info.getElementalDamage()); + data.addInt(info.getElementalDamageType().getNum()); + data.addInt(info.getBleedDamage());; + data.addInt(info.getCriticalDamage()); + data.addInt(info.getBlockedDamage()); + data.addInt(info.getFinalDamage()); + data.addInt(info.getHitLocation().getNum()); + data.addBoolean(info.isCrushing()); + data.addBoolean(info.isStrikethrough()); + data.addFloat((float) info.getStrikethroughAmount()); + data.addBoolean(info.isEvadeResult()); + data.addFloat((float) info.getEvadeAmount()); + data.addBoolean(info.isBlockResult()); + data.addInt(info.getBlock()); + } else { + data.addBoolean(info.isDodge()); + data.addBoolean(info.isParry()); + } + } else { + data.addInt(0); // ihnfk + } + data.addBoolean(info.isCritical()); + data.addBoolean(info.isGlancing()); + data.addBoolean(info.isProc()); + data.addInt(spamType); + return data; + } + + private int getEncodeSize() { + int size = HEADER_LENGTH + 24 + attackerPosition.getLength() + defenderPosition.getLength(); + if (isAttackDataWeaponObject(dataType)) + size += 9 + attackName.getLength() + (info.isSuccess() ? 60 : 2); + else if (isAttackWeaponName(dataType)) + size += 1 + attackName.getLength() + weaponName.getLength() + (info.isSuccess() ? 60 : 2); + else + size += 4; // I have no idea what's in this struct + return size; + } + + public byte getDataType() { + return dataType; + } + + public long getAttacker() { + return attacker; + } + + public Point3D getAttackerPosition() { + return attackerPosition; + } + + public long getDefender() { + return defender; + } + + public Point3D getDefenderPosition() { + return defenderPosition; + } + + public long getWeapon() { + return weapon; + } + + public StringId getWeaponName() { + return weaponName; + } + + public StringId getAttackName() { + return attackName; + } + + public AttackInfo getInfo() { + return info; + } + + public String getSpamMessage() { + return spamMessage; + } + + public int getSpamType() { + return spamType; + } + + public void setDataType(byte dataType) { + this.dataType = dataType; + } + + public void setAttacker(long attacker) { + this.attacker = attacker; + } + + public void setAttackerPosition(Point3D attackerPosition) { + this.attackerPosition = attackerPosition; + } + + public void setDefender(long defender) { + this.defender = defender; + } + + public void setDefenderPosition(Point3D defenderPosition) { + this.defenderPosition = defenderPosition; + } + + public void setWeapon(long weapon) { + this.weapon = weapon; + } + + public void setWeaponName(StringId weaponName) { + this.weaponName = weaponName; + } + + public void setAttackName(StringId attackName) { + this.attackName = attackName; + } + + public void setInfo(AttackInfo info) { + this.info = info; + } + + public void setSpamMessage(String spamMessage) { + this.spamMessage = spamMessage; + } + + public void setSpamType(int spamType) { + this.spamType = spamType; + } + + private boolean isAttackDataWeaponObject(byte b) { + return b == 0; + } + + private boolean isAttackWeaponName(byte b) { + return b == 1; + } + + private boolean isMessageData(byte b) { + return b == 2; + } + +} + diff --git a/src/com/projectswg/common/network/packets/swg/zone/resource/ResourceWeight.java b/src/com/projectswg/common/network/packets/swg/zone/resource/ResourceWeight.java new file mode 100644 index 0000000..f82ee3b --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/resource/ResourceWeight.java @@ -0,0 +1,157 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.resource; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import com.projectswg.common.debug.Assert; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.swg.zone.object_controller.ObjectController; + +public class ResourceWeight extends ObjectController { + + public static final int CRC = 0x0207; + + private final Map> attributes; + private final Map> resourceMaxWeights; + private int schematicId; + private int schematicCrc; + + public ResourceWeight() { + super(CRC); + attributes = new HashMap<>(); + resourceMaxWeights = new HashMap<>(); + } + + @Override + public void decode(NetBuffer data) { + decodeHeader(data); + schematicId = data.getInt(); + schematicCrc = data.getInt(); + int count = data.getByte(); + decodeWeights(data, attributes, count); + decodeWeights(data, resourceMaxWeights, count); + Assert.test(attributes.size() == resourceMaxWeights.size()); + } + + @Override + public NetBuffer encode() { + int len = HEADER_LENGTH + 9; + for (List weights : attributes.values()) + len += 3 + weights.size(); + for (List weights : resourceMaxWeights.values()) + len += 3 + weights.size(); + Assert.test(attributes.size() == resourceMaxWeights.size()); + NetBuffer data = NetBuffer.allocate(len); + encodeHeader(data); + encodeWeights(data, attributes); + encodeWeights(data, resourceMaxWeights); + data.addInt(attributes.size()); + return data; + } + + private void decodeWeights(NetBuffer data, Map> map, int count) { + for (int i = 0; i < count; i++) { + data.getByte(); // index + int slot = data.getByte(); + int weightCount = data.getByte(); + List weights = new ArrayList<>(); + map.put(slot, weights); + for (int j = 0; j < weightCount; j++) { + byte b = data.getByte(); + weights.add(new Weight((b & 0xF0) >>> 4, b & 0x0F)); + } + } + } + + private void encodeWeights(NetBuffer data, Map> map) { + int i = 0; + for (Entry> e : map.entrySet()) { + List weights = e.getValue(); + data.addByte(i++); + data.addByte(e.getKey()); + data.addByte(weights.size()); + for (Weight w : weights) { + data.addByte((w.getResourceId() << 4) | w.getWeight()); + } + } + } + + public Map> getAttributes() { + return attributes; + } + + public Map> getResourceMaxWeights() { + return resourceMaxWeights; + } + + public int getSchematicId() { + return schematicId; + } + + public int getSchematicCrc() { + return schematicCrc; + } + + public void setSchematicId(int schematicId) { + this.schematicId = schematicId; + } + + public void setSchematicCrc(int schematicCrc) { + this.schematicCrc = schematicCrc; + } + + public static class Weight { + + private int resourceId; + private int weight; + + public Weight() { + this(-1, 0); + } + + public Weight(int resourceId, int weight) { + this.resourceId = resourceId; + this.weight = weight; + } + + public int getResourceId() { + return resourceId; + } + + public int getWeight() { + return weight; + } + + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/server_ui/SuiCreatePageMessage.java b/src/com/projectswg/common/network/packets/swg/zone/server_ui/SuiCreatePageMessage.java new file mode 100644 index 0000000..af8cdcb --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/server_ui/SuiCreatePageMessage.java @@ -0,0 +1,69 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.server_ui; + +import com.projectswg.common.data.sui.SuiBaseWindow; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class SuiCreatePageMessage extends SWGPacket { + + public static final int CRC = getCrc("SuiCreatePageMessage"); + + private SuiBaseWindow window; + + public SuiCreatePageMessage() {} + + public SuiCreatePageMessage(SuiBaseWindow window) { + this.window = window; + } + + public SuiCreatePageMessage(NetBuffer data) { + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + window = data.getEncodable(SuiBaseWindow.class); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6 + window.getLength()); + data.addShort(2); + data.addInt(CRC); + data.addEncodable(window); + return data; + } + + public SuiBaseWindow getWindow() { + return window; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/server_ui/SuiEventNotification.java b/src/com/projectswg/common/network/packets/swg/zone/server_ui/SuiEventNotification.java new file mode 100644 index 0000000..1c20fc2 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/server_ui/SuiEventNotification.java @@ -0,0 +1,86 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.server_ui; + +import java.util.ArrayList; +import java.util.List; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class SuiEventNotification extends SWGPacket { + public static final int CRC = getCrc("SuiEventNotification"); + + private int windowId; + private int eventIndex; + private int updateCount; + private List subscribedToProperties; + + public SuiEventNotification() { + subscribedToProperties = new ArrayList<>(); + } + + public SuiEventNotification(NetBuffer data) { + this(); + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + windowId = data.getInt(); + eventIndex = data.getInt(); + int size = data.getInt(); + updateCount = data.getInt(); + for (int i = 0; i < size; i++) { + subscribedToProperties.add(data.getUnicode()); + } + } + + public NetBuffer encode() { + int size = 0; + for (String property : subscribedToProperties) { + size += 4 + (property.length() * 2); + } + + NetBuffer data = NetBuffer.allocate(size + 16); + data.addInt(windowId); + data.addInt(eventIndex); + data.addInt(subscribedToProperties.size()); + data.addInt(updateCount); + for (String property : subscribedToProperties) { + data.addUnicode(property); + } + return data; + } + + public int getWindowId() { return this.windowId; } + public List getSubscribedToProperties() { return this.subscribedToProperties; } + public int getEventIndex() { return this.eventIndex; } + public int getUpdateCount() { return this.updateCount; } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/server_ui/SuiForceClosePage.java b/src/com/projectswg/common/network/packets/swg/zone/server_ui/SuiForceClosePage.java new file mode 100644 index 0000000..e8998f7 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/server_ui/SuiForceClosePage.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone.server_ui; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +/** + * Created by Waverunner on 8/17/2015 + */ +public class SuiForceClosePage extends SWGPacket { + public static final int CRC = getCrc("SuiForceClosePage"); + + private int windowId; + + public SuiForceClosePage(int windowId) { + this.windowId = windowId; + } + + public SuiForceClosePage() {} + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + windowId = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10); + data.addShort(1); + data.addInt(CRC); + data.addInt(windowId); + return data; + } + + public int getWindowId() { + return windowId; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/spatial/AttributeListMessage.java b/src/com/projectswg/common/network/packets/swg/zone/spatial/AttributeListMessage.java new file mode 100644 index 0000000..36c9242 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/spatial/AttributeListMessage.java @@ -0,0 +1,92 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.spatial; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class AttributeListMessage extends SWGPacket { + public static final int CRC = getCrc("AttributeListMessage"); + + private long objectId; + private Map attributes; + + public AttributeListMessage() { + this(0, new HashMap<>()); + } + + public AttributeListMessage(long objectId, Map attributes) { + this.objectId = objectId; + this.attributes = attributes; + } + + public AttributeListMessage(NetBuffer data) { + decode(data); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objectId = data.getLong(); + data.getAscii(); // static item name + int count = data.getInt(); + for (int i = 0; i < count; i++) { + String name = data.getAscii(); + String attr = data.getUnicode(); + attributes.put(name, attr); + } + data.getInt(); + } + + @Override + public NetBuffer encode() { + int size = 0; + for (Entry e : attributes.entrySet()) { + size += 6 + e.getKey().length() + (e.getValue().length() * 2); + } + NetBuffer data = NetBuffer.allocate(24 + size); + data.addShort(3); + data.addInt(CRC); + data.addLong(objectId); + data.addShort(0); + data.addInt(attributes.size()); + for (Entry e : attributes.entrySet()) { + data.addAscii(e.getKey()); + data.addUnicode(e.getValue()); + } + data.addInt(0); + return data; + } + +} + diff --git a/src/com/projectswg/common/network/packets/swg/zone/spatial/GetMapLocationsMessage.java b/src/com/projectswg/common/network/packets/swg/zone/spatial/GetMapLocationsMessage.java new file mode 100644 index 0000000..4518c1a --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/spatial/GetMapLocationsMessage.java @@ -0,0 +1,84 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.spatial; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class GetMapLocationsMessage extends SWGPacket { + public static final int CRC = getCrc("GetMapLocationsMessage"); + + private String planet; + private int versionStatic; + private int versionDynamic; + private int versionPersist; + + public GetMapLocationsMessage() { + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + planet = data.getAscii(); + versionStatic = data.getInt(); + versionDynamic = data.getInt(); + versionPersist = data.getInt(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(19 + planet.length()); + data.addShort(28); + data.addInt(CRC); + data.addAscii(planet); + data.addInt(versionStatic); + data.addInt(versionDynamic); + data.addInt(versionPersist); + return data; + } + + public String getPlanet() { return planet; } + + public int getVersionDynamic() { + return versionDynamic; + } + + public int getVersionStatic() { + return versionStatic; + } + + public int getVersionPersist() { + return versionPersist; + } + + @Override + public String toString() { + return String.format("[GetMapLocationsMessage] planet=%s static=%d dynamic=%d persist=%d", + planet, versionStatic, versionDynamic, versionPersist); + } +} + diff --git a/src/com/projectswg/common/network/packets/swg/zone/spatial/GetMapLocationsResponseMessage.java b/src/com/projectswg/common/network/packets/swg/zone/spatial/GetMapLocationsResponseMessage.java new file mode 100644 index 0000000..fb97387 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/spatial/GetMapLocationsResponseMessage.java @@ -0,0 +1,124 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.spatial; + +import java.util.List; + +import com.projectswg.common.data.encodables.map.MapLocation; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class GetMapLocationsResponseMessage extends SWGPacket { + public static final int CRC = getCrc("GetMapLocationsResponseMessage"); + + private String planet; + private List updatedStaticLocations; + private List updatedDynamicLocations; + private List updatedPersistLocations; + private int staticLocVersion; + private int dynamicLocVersion; + private int persistentLocVersion; + + public GetMapLocationsResponseMessage() { + + } + + public GetMapLocationsResponseMessage(String planet, + List staticLocs, List dynamicLocs, List persistLocs, + int staticLocVersion, int dynamicLocVersion, int persistLocVersion) { + this.planet = planet; + this.updatedStaticLocations = staticLocs; + this.updatedDynamicLocations = dynamicLocs; + this.updatedPersistLocations = persistLocs; + this.staticLocVersion = staticLocVersion; + this.dynamicLocVersion = dynamicLocVersion; + this.persistentLocVersion = persistLocVersion; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + planet = data.getAscii(); + updatedStaticLocations = data.getList(MapLocation.class); + updatedDynamicLocations = data.getList(MapLocation.class); + updatedPersistLocations = data.getList(MapLocation.class); + staticLocVersion = data.getInt(); + dynamicLocVersion = data.getInt(); + persistentLocVersion = data.getInt(); + } + + @Override + public NetBuffer encode() { + int size = planet.length() + 32; + + // Get size of data + if (updatedStaticLocations != null) { + for (MapLocation location : updatedStaticLocations) { + byte[] data = location.encode(); + size += data.length; + } + } + + if (updatedDynamicLocations != null) { + for (MapLocation location : updatedDynamicLocations) { + byte[] data = location.encode(); + size += data.length; + } + } + + if (updatedPersistLocations != null) { + for (MapLocation location : updatedPersistLocations) { + byte[] data = location.encode(); + size += data.length; + } + } + + // Create the packet + NetBuffer data = NetBuffer.allocate(size); + data.addShort(8); + data.addInt(CRC); + + data.addAscii(planet); + + data.addList(updatedStaticLocations); + data.addList(updatedDynamicLocations); + data.addList(updatedPersistLocations); + + data.addInt(staticLocVersion); + data.addInt(dynamicLocVersion); + data.addInt(persistentLocVersion); + return data; + } + + @Override + public String toString() { + return "[GetMapLocationsResponseMessage] " + + "staticVersion=" + staticLocVersion + "dynamicVersion=" + dynamicLocVersion + "persistVersion=" + persistentLocVersion; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/spatial/NewTicketActivityResponseMessage.java b/src/com/projectswg/common/network/packets/swg/zone/spatial/NewTicketActivityResponseMessage.java new file mode 100644 index 0000000..e62a085 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/spatial/NewTicketActivityResponseMessage.java @@ -0,0 +1,60 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.spatial; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class NewTicketActivityResponseMessage extends SWGPacket { + public static final int CRC = getCrc("NewTicketActivityResponseMessage"); + + public NewTicketActivityResponseMessage() { + + } + + public NewTicketActivityResponseMessage(NetBuffer data) { + decode(data); + } + + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + data.getByte(); + data.getInt(); + } + + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(11); + data.addShort(2); + data.addInt(CRC); + data.addByte(0); + data.addInt(1); + return data; + } + +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/trade/AbortTradeMessage.java b/src/com/projectswg/common/network/packets/swg/zone/trade/AbortTradeMessage.java new file mode 100644 index 0000000..45e44bd --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/trade/AbortTradeMessage.java @@ -0,0 +1,50 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.trade; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class AbortTradeMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("AbortTradeMessage"); + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(1); + data.addInt(CRC); + return data; + } +} diff --git a/src/com/projectswg/common/network/packets/swg/zone/trade/AcceptTransactionMessage.java b/src/com/projectswg/common/network/packets/swg/zone/trade/AcceptTransactionMessage.java new file mode 100644 index 0000000..0705fbe --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/trade/AcceptTransactionMessage.java @@ -0,0 +1,50 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.trade; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class AcceptTransactionMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("AcceptTransactionMessage"); + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(1); + data.addInt(CRC); + return data; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/trade/AddItemFailedMessage.java b/src/com/projectswg/common/network/packets/swg/zone/trade/AddItemFailedMessage.java new file mode 100644 index 0000000..70157f5 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/trade/AddItemFailedMessage.java @@ -0,0 +1,62 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.trade; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class AddItemFailedMessage extends SWGPacket{ + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("AddItemFailedMessage"); + + private long objectId; + + public AddItemFailedMessage(long objectId) { + this.objectId = objectId; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objectId = data.getLong(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(2); + data.addInt(CRC); + data.addLong(objectId); + return data; + } + + public long getObjectId() { + return objectId; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/trade/AddItemMessage.java b/src/com/projectswg/common/network/packets/swg/zone/trade/AddItemMessage.java new file mode 100644 index 0000000..d341e67 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/trade/AddItemMessage.java @@ -0,0 +1,65 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.trade; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class AddItemMessage extends SWGPacket{ + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("AddItemMessage"); + + private long objectId; + + public AddItemMessage(long objectId) { + this.objectId = objectId; + } + + public AddItemMessage() { + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objectId = data.getLong(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(2); + data.addInt(CRC); + data.addLong(objectId); + return data; + } + + public long getObjectId() { + return objectId; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/trade/BeginTradeMessage.java b/src/com/projectswg/common/network/packets/swg/zone/trade/BeginTradeMessage.java new file mode 100644 index 0000000..b5a47d4 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/trade/BeginTradeMessage.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.trade; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class BeginTradeMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("BeginTradeMessage"); + + private long playerId; + + public BeginTradeMessage(long playerId) { + super(); + this.playerId = playerId; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + playerId = data.getLong(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(2); + data.addInt(CRC); + data.addLong(playerId); + return data; + } + + public long getPlayerId() { + return playerId; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/trade/BeginVerificationMessage.java b/src/com/projectswg/common/network/packets/swg/zone/trade/BeginVerificationMessage.java new file mode 100644 index 0000000..0da963d --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/trade/BeginVerificationMessage.java @@ -0,0 +1,50 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.trade; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class BeginVerificationMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("BeginVerificationMessage"); + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(1); + data.addInt(CRC); + return data; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/trade/DenyTradeMessage.java b/src/com/projectswg/common/network/packets/swg/zone/trade/DenyTradeMessage.java new file mode 100644 index 0000000..2319db8 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/trade/DenyTradeMessage.java @@ -0,0 +1,50 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.trade; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class DenyTradeMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("DenyTradeMessage"); + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(1); + data.addInt(CRC); + return data; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/trade/GiveMoneyMessage.java b/src/com/projectswg/common/network/packets/swg/zone/trade/GiveMoneyMessage.java new file mode 100644 index 0000000..cbef03e --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/trade/GiveMoneyMessage.java @@ -0,0 +1,67 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.trade; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class GiveMoneyMessage extends SWGPacket{ + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("GiveMoneyMessage"); + + private int moneyAmount; + + public GiveMoneyMessage(int moneyAmount) { + super(); + this.moneyAmount = moneyAmount; + } + + public GiveMoneyMessage() { + super(); + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + moneyAmount = data.getInt(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(10); + data.addShort(2); + data.addInt(CRC); + data.addInt(moneyAmount); + return data; + } + + public int getMoneyAmount() { + return moneyAmount; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/trade/RemoveItemMessage.java b/src/com/projectswg/common/network/packets/swg/zone/trade/RemoveItemMessage.java new file mode 100644 index 0000000..6728d5c --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/trade/RemoveItemMessage.java @@ -0,0 +1,63 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.trade; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class RemoveItemMessage extends SWGPacket{ + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("RemoveItemMessage"); + + private long objectId; + + public RemoveItemMessage(long objectId) { + super(); + this.objectId = objectId; + } + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + objectId = data.getLong(); + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(14); + data.addShort(2); + data.addInt(CRC); + data.addLong(objectId); + return data; + } + + public long getObjectId() { + return objectId; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/trade/TradeCompleteMessage.java b/src/com/projectswg/common/network/packets/swg/zone/trade/TradeCompleteMessage.java new file mode 100644 index 0000000..edbd4a1 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/trade/TradeCompleteMessage.java @@ -0,0 +1,50 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.trade; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class TradeCompleteMessage extends SWGPacket{ + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("TradeCompleteMessage"); + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(1); + data.addInt(CRC); + return data; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/trade/UnAcceptTransactionMessage.java b/src/com/projectswg/common/network/packets/swg/zone/trade/UnAcceptTransactionMessage.java new file mode 100644 index 0000000..cc78342 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/trade/UnAcceptTransactionMessage.java @@ -0,0 +1,50 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.trade; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class UnAcceptTransactionMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("UnAcceptTransactionMessage"); + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(1); + data.addInt(CRC); + return data; + } +} \ No newline at end of file diff --git a/src/com/projectswg/common/network/packets/swg/zone/trade/VerifyTradeMessage.java b/src/com/projectswg/common/network/packets/swg/zone/trade/VerifyTradeMessage.java new file mode 100644 index 0000000..e01ede1 --- /dev/null +++ b/src/com/projectswg/common/network/packets/swg/zone/trade/VerifyTradeMessage.java @@ -0,0 +1,50 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package com.projectswg.common.network.packets.swg.zone.trade; + +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.SWGPacket; + +public class VerifyTradeMessage extends SWGPacket { + + public static final int CRC = com.projectswg.common.data.CRC.getCrc("VerifyTradeMessage"); + + @Override + public void decode(NetBuffer data) { + if (!super.checkDecode(data, CRC)) + return; + } + + @Override + public NetBuffer encode() { + NetBuffer data = NetBuffer.allocate(6); + data.addShort(1); + data.addInt(CRC); + return data; + } +} \ No newline at end of file