Moved many packets into PSWGCommon

This commit is contained in:
Obique
2017-08-22 16:39:34 -05:00
parent f5c9e09dd5
commit 5a9f59e6a3
248 changed files with 21226 additions and 560 deletions

View File

@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<accessrules>
<accessrule kind="accessible" pattern="javafx/**"/>
</accessrules>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin"/>
</classpath>

2
.gitignore vendored
View File

@@ -1,2 +1,4 @@
.settings
.gradle
bin
build

View File

@@ -10,8 +10,14 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>

View File

@@ -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<T> {
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<T> {
public boolean callOnEach(CallCallback<T> 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();

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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];
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
package com.projectswg.common.data.combat;
public enum CombatStatus {
UNKNOWN,
INVALID_TARGET,
NO_WEAPON,
NO_TARGET,
TOO_FAR,
SUCCESS
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<DamageType> getDamageTypes(int num) {
Set<DamageType> types = EnumSet.noneOf(DamageType.class);
for (DamageType type : VALUES) {
if ((num & type.getNum()) != 0)
types.add(type);
}
return types;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<Integer, DelayAttackEggPosition> 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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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];
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<Integer, HitType> 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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<TrailLocation> getTrailLocations(int num) {
Set<TrailLocation> types = EnumSet.noneOf(TrailLocation.class);
for (TrailLocation type : VALUES) {
if ((num & type.getNum()) != 0)
types.add(type);
}
return types;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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];
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
******************************************************************************/
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<String> 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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
******************************************************************************/
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<Integer, ChatResult> 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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
******************************************************************************/
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<ChatAvatar> moderators;
private List<ChatAvatar> invited;
private boolean moderated; // No one but moderators can talk
private List<ChatAvatar> 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<ChatAvatar> 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<ChatAvatar> getModerators() {
return moderators;
}
public List<ChatAvatar> getInvited() {
return invited;
}
public boolean isModerated() {
return moderated;
}
public void setModerated(boolean moderated) {
this.cache.clearCached();
this.moderated = moderated;
}
public List<ChatAvatar> getMembers() {
return members;
}
public boolean isPublic() {
return type == 0;
}
public void setIsPublic(boolean isPublic) {
this.cache.clearCached();
this.type = (isPublic ? 0 : 1);
}
public List<ChatAvatar> 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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
******************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
******************************************************************************/
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();
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<OutOfBandData> packages;
public OutOfBandPackage() {
packages = new ArrayList<>();
}
public OutOfBandPackage(OutOfBandData ... outOfBandData) {
this();
Collections.addAll(packages, outOfBandData);
}
public List<OutOfBandData> 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<Byte, Type> 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);
}
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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 <br>
* <br>
* Example: <br>
* &nbsp&nbsp&nbsp&nbsp 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. <br>
* <br>
* Example: <br>
* &nbsp&nbsp&nbsp&nbsp 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 + "']";
}
}
}

View File

@@ -25,85 +25,116 @@
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<ChangeListener<? super String>> listeners;
private final Set<InvalidationListener> invalidationListeners;
private final Set<Property<?>> 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<? super String> 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<? super String> listener) {
super.removeListener(listener);
listeners.remove(listener);
public int getLength() {
return 8 + key.length() + file.length();
}
public void removeAllListeners() {
for (ChangeListener<? super String> 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<String> 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 <T> void bindBidirectional(Property<T> property, StringConverter<T> 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();
}
}

View File

@@ -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<String, WaypointColor> NAME_LOOKUP = new EnumLookup<>(WaypointColor.class, WaypointColor::getName);
private static final EnumLookup<Integer, WaypointColor> 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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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();
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<Byte, Posture> 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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<Integer, PvpFaction> 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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<PvpFlag> getFlags(int bits) {
EnumSet <PvpFlag> states = EnumSet.noneOf(PvpFlag.class);
for (PvpFlag state : values()) {
if ((state.getBitmask() & bits) != 0)
states.add(state);
}
return states;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<Integer, PvpStatus> 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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<Integer, Race> CRC_TO_RACE = new EnumLookup<>(Race.class, Race::getCrc);
private static final EnumLookup<String, Race> SPECIES_TO_RACE = new EnumLookup<>(Race.class, r -> r.species);
private static final EnumLookup<String, Race> 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);
}
}

View File

@@ -25,61 +25,74 @@
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<ChangeListener<? super Boolean>> listeners;
private final Set<Property<Boolean>> 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<? super Boolean> 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<? super Boolean> listener) {
listeners.remove(listener);
super.removeListener(listener);
}
public void removeAllListeners() {
for (ChangeListener<? super Boolean> listener : listeners) {
super.removeListener(listener);
}
public int getLength() {
return 8;
}
@Override
public void bindBidirectional(Property<Boolean> property) {
super.bindBidirectional(property);
properties.add(property);
public void save(NetBufferStream stream) {
stream.addInt(base);
stream.addInt(modifier);
}
public void unbindAll() {
unbind();
for (Property<Boolean> 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+"]";
}
}

View File

@@ -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);
}
}
}

View File

@@ -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() {

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<Integer, RadialItem> 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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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();
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
package com.projectswg.common.data.radial;
import java.util.ArrayList;
import java.util.List;
public class RadialOption {
private RadialItem item;
private List<RadialOption> 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<RadialOption> getChildren() { return children; }
@Override
public String toString() {
return String.format("ID=%d Option=%d Text=%s", getId(), getOptionType(), getText());
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<RadialOption> options;
public RadialOptionList() {
options = new ArrayList<>();
}
public RadialOptionList(List<RadialOption> options) {
this();
this.options.addAll(options);
}
public void addOption(RadialOption option) {
options.add(option);
}
public void setOptions(List<RadialOption> options) {
this.options.clear();
this.options.addAll(options);
}
public List<RadialOption> getOptions() {
return Collections.unmodifiableList(options);
}
@Override
public void decode(NetBuffer data) {
int optionsCount = data.getInt();
Map<Integer, RadialOption> 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;
}
}

View File

@@ -25,16 +25,10 @@
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<String, String> parameters);
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<SuiComponent> components = new ArrayList<>();
private Map<String, ISuiCallback> callbacks;
private Map<String, String> 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<SuiComponent> 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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
******************************************************************************/
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 <String> wideParams;
private List<String> 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 <String> getNarrowParams() {
return narrowParams;
}
public List <String> 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<String> 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<String> 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;
}
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
******************************************************************************/
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;
}
}
}

View File

@@ -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 {

View File

@@ -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();

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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<String, ClientData> skeletonTemplateNames;

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<FXMLController> 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;
}
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<Integer, PacketType> LOOKUP = new EnumLookup<>(PacketType.class, PacketType::getCrc);
private final int crc;
private final Class <? extends SWGPacket> c;
PacketType(int crc, Class <? extends SWGPacket> c) {
this.crc = crc;
this.c = c;
}
public int getCrc() {
return crc;
}
public Class<? extends SWGPacket> 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 <? extends SWGPacket> c = type.c;
try {
return c.newInstance();
} catch (Exception e) {
Log.e("Packet: [%08X] %s", crc, c.getName());
Log.e(e);
}
return null;
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
package com.projectswg.common.network.packets.swg.admin;
import com.projectswg.common.network.packets.swg.holo.HoloPacket;
public abstract class AdminPacket extends HoloPacket {
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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();
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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; }
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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; }
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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<SWGCharacter> characters;
public EnumerateCharacterId() {
this.characters = new ArrayList<>();
}
public EnumerateCharacterId(List<SWGCharacter> 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<SWGCharacter> 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);
}
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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; }
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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 <Galaxy> galaxies;
public LoginClusterStatus() {
galaxies = new Vector<Galaxy>();
}
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 <Galaxy> getGalaxies() {
return galaxies;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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 <Galaxy> galaxies;
private int maxCharacters;
public LoginEnumCluster() {
galaxies = new Vector<Galaxy>();
}
public LoginEnumCluster(int maxCharacters) {
galaxies = new Vector<Galaxy>();
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 <Galaxy> getGalaxies() {
return galaxies;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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 <String> offlineServers;
public OfflineServersMessage() {
offlineServers = new ArrayList<String>();
}
public OfflineServersMessage(List <String> 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<String>(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 <String> getOfflineServers() {
return offlineServers;
}
public void setOfflineServers(List <String> offline) {
offlineServers = offline;
}
public void addOflineServer(String offline) {
offlineServers.add(offline);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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; }
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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; }
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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; }
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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; }
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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; }
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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; }
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}

Some files were not shown because too many files have changed in this diff Show More