mirror of
https://github.com/ProjectSWGCore/pswgcommon.git
synced 2026-01-15 23:04:19 -05:00
Merge branch 'master' of https://github.com/ProjectSWGCore/pswgcommon
This commit is contained in:
@@ -31,7 +31,8 @@ sourceSets {
|
||||
implementation(group="org.jetbrains", name="annotations", version="20.1.0")
|
||||
api(group="me.joshlarson", name="jlcommon", version="1.9.2")
|
||||
api(group="org.bouncycastle", name="bcprov-jdk15on", version="1.60")
|
||||
api(group="org.mongodb", name="mongodb-driver-sync", version="3.10.2")
|
||||
implementation(kotlin("stdlib"))
|
||||
implementation(group="org.mongodb", name="mongodb-driver-sync", version="3.12.2")
|
||||
}
|
||||
}
|
||||
test {
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import me.joshlarson.jlcommon.log.Log;
|
||||
|
||||
@@ -53,7 +54,7 @@ public class CrcDatabase {
|
||||
}
|
||||
|
||||
public void saveStrings(OutputStream os) throws IOException {
|
||||
for (Entry<Integer, String> e : crcTable.entrySet()) {
|
||||
for (Entry<Integer, String> e : new TreeMap<>(crcTable).entrySet()) {
|
||||
os.write((Integer.toString(e.getKey(), 16) + ',' + e.getValue() + '\n').getBytes(StandardCharsets.US_ASCII));
|
||||
}
|
||||
os.flush();
|
||||
|
||||
@@ -28,17 +28,33 @@ package com.projectswg.common.data.combat;
|
||||
|
||||
import com.projectswg.common.data.EnumLookup;
|
||||
|
||||
public enum CombatSpamFilterType {
|
||||
ALL(0),
|
||||
SELF(1),
|
||||
GROUP(2),
|
||||
NONE(3);
|
||||
/**
|
||||
* Determines color for entries in the combat log client-side
|
||||
*/
|
||||
public enum CombatSpamType {
|
||||
MISS(0),
|
||||
HIT(1),
|
||||
BLOCK(2),
|
||||
EVADE(3),
|
||||
REDIRECT(4),
|
||||
COUNTER(5),
|
||||
FUMBLE(6),
|
||||
LIGHTSABER_BLOCK(7),
|
||||
LIGHTSABER_COUNTER(8),
|
||||
LIGHTSABER_COUNTER_TARGET(9),
|
||||
GENERIC(10),
|
||||
OUT_OF_RANGE(11),
|
||||
POSTURE_CHANGE(12),
|
||||
TETHERED(13), // AI was forced to return to original location
|
||||
MEDICAL(14),
|
||||
BUFF(15),
|
||||
DEBUFF(16);
|
||||
|
||||
private static final EnumLookup<Integer, CombatSpamFilterType> LOOKUP = new EnumLookup<>(CombatSpamFilterType.class, CombatSpamFilterType::getNum);
|
||||
private static final EnumLookup<Integer, CombatSpamType> LOOKUP = new EnumLookup<>(CombatSpamType.class, CombatSpamType::getNum);
|
||||
|
||||
private int num;
|
||||
|
||||
CombatSpamFilterType(int num) {
|
||||
CombatSpamType(int num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
@@ -46,7 +62,8 @@ public enum CombatSpamFilterType {
|
||||
return num;
|
||||
}
|
||||
|
||||
public static CombatSpamFilterType getCombatSpamFilterType(int num) {
|
||||
return LOOKUP.getEnum(num, NONE);
|
||||
public static CombatSpamType getCombatSpamType(int num) {
|
||||
return LOOKUP.getEnum(num, HIT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2018 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of Holocore. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* Holocore is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* Holocore is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General 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.gcw;
|
||||
|
||||
import com.projectswg.common.encoding.Encodable;
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class GcwGroup implements Encodable {
|
||||
|
||||
private final String planetName;
|
||||
private final Collection<GcwGroupZone> zones;
|
||||
|
||||
public GcwGroup(String planetName, Collection<GcwGroupZone> zones) {
|
||||
this.planetName = planetName;
|
||||
this.zones = zones;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode() {
|
||||
NetBuffer buffer = NetBuffer.allocate(getLength());
|
||||
|
||||
buffer.addAscii(planetName);
|
||||
buffer.addList(zones);
|
||||
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLength() {
|
||||
int nameLength = 2 + planetName.length();
|
||||
int zonesLength = 4 + zones.stream().mapToInt(GcwGroupZone::getLength).sum();
|
||||
|
||||
return nameLength + zonesLength;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2018 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of Holocore. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* Holocore is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* Holocore is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General 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.gcw;
|
||||
|
||||
import com.projectswg.common.encoding.Encodable;
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
|
||||
public class GcwGroupZone implements Encodable {
|
||||
|
||||
private final String name;
|
||||
private final int weight;
|
||||
|
||||
public GcwGroupZone(String name, int weight) {
|
||||
this.name = name;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode() {
|
||||
NetBuffer buffer = NetBuffer.allocate(getLength());
|
||||
|
||||
buffer.addAscii(name);
|
||||
buffer.addInt(weight);
|
||||
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLength() {
|
||||
return 2 + name.length() + Integer.BYTES;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2018 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of Holocore. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* Holocore is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* Holocore is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General 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.gcw;
|
||||
|
||||
import com.projectswg.common.encoding.Encodable;
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class GcwRegion implements Encodable {
|
||||
|
||||
private final String planetName;
|
||||
private final Collection<GcwRegionZone> zones;
|
||||
|
||||
public GcwRegion(String planetName, Collection<GcwRegionZone> zones) {
|
||||
this.planetName = planetName;
|
||||
this.zones = zones;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode() {
|
||||
NetBuffer buffer = NetBuffer.allocate(getLength());
|
||||
|
||||
buffer.addAscii(planetName);
|
||||
buffer.addList(zones);
|
||||
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLength() {
|
||||
int nameLength = 2 + planetName.length();
|
||||
int zonesLength = 4 + zones.stream().mapToInt(GcwRegionZone::getLength).sum();
|
||||
|
||||
return nameLength + zonesLength;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2018 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of Holocore. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* Holocore is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* Holocore is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General 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.gcw;
|
||||
|
||||
import com.projectswg.common.encoding.Encodable;
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
|
||||
public class GcwRegionZone implements Encodable {
|
||||
|
||||
private final String name;
|
||||
private final float x;
|
||||
private final float z;
|
||||
private final float radius;
|
||||
|
||||
public GcwRegionZone(String name, float x, float z, float radius) {
|
||||
this.name = name;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode() {
|
||||
NetBuffer buffer = NetBuffer.allocate(getLength());
|
||||
|
||||
buffer.addAscii(name);
|
||||
buffer.addFloat(x);
|
||||
buffer.addFloat(z);
|
||||
buffer.addFloat(radius);
|
||||
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLength() {
|
||||
return 2 + name.length() + Float.BYTES * 3;
|
||||
}
|
||||
}
|
||||
@@ -210,6 +210,11 @@ public class MongoData implements Map<String, Object> {
|
||||
|
||||
@NotNull
|
||||
public MongoData getDocument(String key) {
|
||||
if (!doc.containsKey(key)) {
|
||||
var mongoDoc = new Document();
|
||||
doc.put(key, mongoDoc);
|
||||
return new MongoData(mongoDoc);
|
||||
}
|
||||
return new MongoData(doc.get(key, Document.class));
|
||||
}
|
||||
|
||||
@@ -261,7 +266,7 @@ public class MongoData implements Map<String, Object> {
|
||||
|
||||
@NotNull
|
||||
public <T, V> Map<T, V> getMap(String key, Class<T> keyClass, Class<V> valueClass) {
|
||||
Map<T, V> ret = new HashMap<>();
|
||||
Map<T, V> ret = new LinkedHashMap<>();
|
||||
for (MongoData val : getArray(key, MongoData.class)) {
|
||||
ret.put(translateGet(val.get("key"), keyClass), translateGet(val.get("val"), valueClass));
|
||||
}
|
||||
@@ -270,7 +275,7 @@ public class MongoData implements Map<String, Object> {
|
||||
|
||||
@NotNull
|
||||
public <T extends MongoPersistable, V> Map<T, V> getMap(String key, Supplier<T> keyGen, Class<V> valueClass) {
|
||||
Map<T, V> ret = new HashMap<>();
|
||||
Map<T, V> ret = new LinkedHashMap<>();
|
||||
for (MongoData val : getArray(key, MongoData.class)) {
|
||||
ret.put(translateGet(val.get("key"), keyGen), translateGet(val.get("val"), valueClass));
|
||||
}
|
||||
@@ -279,7 +284,7 @@ public class MongoData implements Map<String, Object> {
|
||||
|
||||
@NotNull
|
||||
public <T extends MongoPersistable, V> Map<T, V> getMap(String key, Function<MongoData, T> keyGen, Class<V> valueClass) {
|
||||
Map<T, V> ret = new HashMap<>();
|
||||
Map<T, V> ret = new LinkedHashMap<>();
|
||||
for (MongoData val : getArray(key, MongoData.class)) {
|
||||
ret.put(translateGet(val.get("key"), keyGen), translateGet(val.get("val"), valueClass));
|
||||
}
|
||||
@@ -288,7 +293,7 @@ public class MongoData implements Map<String, Object> {
|
||||
|
||||
@NotNull
|
||||
public <T, V extends MongoPersistable> Map<T, V> getMap(String key, Class<T> keyClass, Supplier<V> valueGen) {
|
||||
Map<T, V> ret = new HashMap<>();
|
||||
Map<T, V> ret = new LinkedHashMap<>();
|
||||
for (MongoData val : getArray(key, MongoData.class)) {
|
||||
ret.put(translateGet(val.get("key"), keyClass), translateGet(val.get("val"), valueGen));
|
||||
}
|
||||
@@ -297,7 +302,7 @@ public class MongoData implements Map<String, Object> {
|
||||
|
||||
@NotNull
|
||||
public <T, V extends MongoPersistable> Map<T, V> getMap(String key, Class<T> keyClass, Function<MongoData, V> valueGen) {
|
||||
Map<T, V> ret = new HashMap<>();
|
||||
Map<T, V> ret = new LinkedHashMap<>();
|
||||
for (MongoData val : getArray(key, MongoData.class)) {
|
||||
ret.put(translateGet(val.get("key"), keyClass), translateGet(val.get("val"), valueGen));
|
||||
}
|
||||
@@ -306,7 +311,7 @@ public class MongoData implements Map<String, Object> {
|
||||
|
||||
@NotNull
|
||||
public <T extends MongoPersistable, V extends MongoPersistable> Map<T, V> getMap(String key, Supplier<T> keyGen, Supplier<V> valueGen) {
|
||||
Map<T, V> ret = new HashMap<>();
|
||||
Map<T, V> ret = new LinkedHashMap<>();
|
||||
for (MongoData val : getArray(key, MongoData.class)) {
|
||||
ret.put(translateGet(val.get("key"), keyGen), translateGet(val.get("val"), valueGen));
|
||||
}
|
||||
@@ -315,7 +320,7 @@ public class MongoData implements Map<String, Object> {
|
||||
|
||||
@NotNull
|
||||
public <T extends MongoPersistable, V extends MongoPersistable> Map<T, V> getMap(String key, Function<MongoData, T> keyGen, Supplier<V> valueGen) {
|
||||
Map<T, V> ret = new HashMap<>();
|
||||
Map<T, V> ret = new LinkedHashMap<>();
|
||||
for (MongoData val : getArray(key, MongoData.class)) {
|
||||
ret.put(translateGet(val.get("key"), keyGen), translateGet(val.get("val"), valueGen));
|
||||
}
|
||||
@@ -324,7 +329,7 @@ public class MongoData implements Map<String, Object> {
|
||||
|
||||
@NotNull
|
||||
public <T extends MongoPersistable, V extends MongoPersistable> Map<T, V> getMap(String key, Supplier<T> keyGen, Function<MongoData, V> valueGen) {
|
||||
Map<T, V> ret = new HashMap<>();
|
||||
Map<T, V> ret = new LinkedHashMap<>();
|
||||
for (MongoData val : getArray(key, MongoData.class)) {
|
||||
ret.put(translateGet(val.get("key"), keyGen), translateGet(val.get("val"), valueGen));
|
||||
}
|
||||
@@ -333,7 +338,7 @@ public class MongoData implements Map<String, Object> {
|
||||
|
||||
@NotNull
|
||||
public <T extends MongoPersistable, V extends MongoPersistable> Map<T, V> getMap(String key, Function<MongoData, T> keyGen, Function<MongoData, V> valueGen) {
|
||||
Map<T, V> ret = new HashMap<>();
|
||||
Map<T, V> ret = new LinkedHashMap<>();
|
||||
for (MongoData val : getArray(key, MongoData.class)) {
|
||||
ret.put(translateGet(val.get("key"), keyGen), translateGet(val.get("val"), valueGen));
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.projectswg.common.persistable.Persistable;
|
||||
public class OutOfBandPackage implements Encodable, Persistable, MongoPersistable {
|
||||
|
||||
private final List<OutOfBandData> packages;
|
||||
private boolean conversation;
|
||||
|
||||
public OutOfBandPackage() {
|
||||
packages = new ArrayList<>();
|
||||
@@ -57,6 +58,14 @@ public class OutOfBandPackage implements Encodable, Persistable, MongoPersistabl
|
||||
return packages;
|
||||
}
|
||||
|
||||
public boolean isConversation() {
|
||||
return conversation;
|
||||
}
|
||||
|
||||
public void setConversation(boolean conversation) {
|
||||
this.conversation = conversation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode() {
|
||||
if (packages.isEmpty())
|
||||
@@ -65,6 +74,12 @@ public class OutOfBandPackage implements Encodable, Persistable, MongoPersistabl
|
||||
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
|
||||
|
||||
if (isConversation()) {
|
||||
// Unfortunately conversations specifically require this to be present. If not, texts aren't displayed properly.
|
||||
data.addShort(0);
|
||||
}
|
||||
|
||||
for (OutOfBandData oob : packages) {
|
||||
data.addRawArray(packOutOfBandData(oob));
|
||||
}
|
||||
@@ -87,6 +102,11 @@ public class OutOfBandPackage implements Encodable, Persistable, MongoPersistabl
|
||||
@Override
|
||||
public int getLength() {
|
||||
int size = 4;
|
||||
|
||||
if (isConversation()) {
|
||||
size += Short.BYTES;
|
||||
}
|
||||
|
||||
for (OutOfBandData oob : packages) {
|
||||
size += getOOBLength(oob);
|
||||
}
|
||||
|
||||
@@ -311,6 +311,10 @@ public class ProsePackage implements OutOfBandData {
|
||||
return base.hashCode() * 3 + actor.hashCode() * 7 + target.hashCode() * 13 + other.hashCode() * 17 + (grammarFlag ? 1 : 0) + di * 19 + ((int) (df * 23));
|
||||
}
|
||||
|
||||
public StringId getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
public static class Prose implements Encodable, Persistable, MongoPersistable {
|
||||
|
||||
private long objectId;
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.projectswg.common.data.swgfile.ClientData;
|
||||
import com.projectswg.common.data.swgfile.IffNode;
|
||||
import com.projectswg.common.data.swgfile.SWGFile;
|
||||
import me.joshlarson.jlcommon.log.Log;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class DatatableData extends ClientData {
|
||||
|
||||
@@ -199,22 +200,36 @@ public class DatatableData extends ClientData {
|
||||
return table[row][column];
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getCell(int row, String columnName) {
|
||||
return getCell(row, nameToIndex.get(columnName).intValue());
|
||||
if (nameToIndex.containsKey(columnName)) {
|
||||
return getCell(row, nameToIndex.get(columnName));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getString(int row, String columnName) {
|
||||
return (String) getCell(row, nameToIndex.get(columnName).intValue());
|
||||
return (String) getCell(row, columnName);
|
||||
}
|
||||
|
||||
public float getFloat(int row, String columnName) {
|
||||
return (float) getCell(row, nameToIndex.get(columnName).intValue());
|
||||
@Nullable
|
||||
public Float getFloat(int row, String columnName) {
|
||||
return (Float) getCell(row, columnName);
|
||||
}
|
||||
|
||||
public int getInt(int row, String columnName) {
|
||||
return (int) getCell(row, nameToIndex.get(columnName).intValue());
|
||||
@Nullable
|
||||
public Integer getInt(int row, String columnName) {
|
||||
return (Integer) getCell(row, columnName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Boolean getBoolean(int row, String columnName) {
|
||||
return (Boolean) getCell(row, columnName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getColumnName(int column) {
|
||||
if (column < 0 || column >= getColumnCount())
|
||||
return null;
|
||||
@@ -227,6 +242,7 @@ public class DatatableData extends ClientData {
|
||||
return columnTypes[column];
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public int getColumnFromName(String columnName) {
|
||||
Integer column = nameToIndex.get(columnName);
|
||||
return column == null ? -1 : column;
|
||||
|
||||
@@ -191,6 +191,18 @@ public class NetBuffer {
|
||||
data.put(b);
|
||||
}
|
||||
|
||||
public void addByteSizedList(Collection<? extends Encodable> list) {
|
||||
if (list == null) {
|
||||
addByte(0);
|
||||
return;
|
||||
}
|
||||
|
||||
addByte(list.size());
|
||||
for (Encodable encodable : list) {
|
||||
addEncodable(encodable);
|
||||
}
|
||||
}
|
||||
|
||||
public void addList(Collection<? extends Encodable> list) {
|
||||
if (list == null) {
|
||||
addInt(0);
|
||||
@@ -342,9 +354,7 @@ public class NetBuffer {
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T extends Encodable> List<T> getList(Class<T> type) {
|
||||
int size = getInt();
|
||||
|
||||
public <T extends Encodable> List<T> getList(Class<T> type, int size) {
|
||||
if (size < 0) {
|
||||
Log.e("Read list with size less than zero!");
|
||||
return null;
|
||||
@@ -369,6 +379,12 @@ public class NetBuffer {
|
||||
return list;
|
||||
}
|
||||
|
||||
public <T extends Encodable> List<T> getList(Class<T> type) {
|
||||
int size = getInt();
|
||||
|
||||
return getList(type, size);
|
||||
}
|
||||
|
||||
public List<String> getList(StringType type) {
|
||||
int size = getInt();
|
||||
|
||||
|
||||
@@ -112,6 +112,8 @@ 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.guild.GuildRequestMessage;
|
||||
import com.projectswg.common.network.packets.swg.zone.guild.GuildResponseMessage;
|
||||
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;
|
||||
@@ -212,11 +214,15 @@ public enum PacketType {
|
||||
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),
|
||||
PLAY_CLIENT_EFFECT_LOC_MESSAGE (PlayClientEffectLocMessage.CRC, PlayClientEffectLocMessage.class),
|
||||
EXPERTISE_REQUEST_MESSAGE (ExpertiseRequestMessage.CRC, ExpertiseRequestMessage.class),
|
||||
CHANGE_ROLE_ICON_CHOICE (ChangeRoleIconChoice.CRC, ChangeRoleIconChoice.class),
|
||||
SHOW_LOOT_BOX (ShowLootBox.CRC, ShowLootBox.class),
|
||||
CREATE_CLIENT_PATH_MESSAGE (CreateClientPathMessage.CRC, CreateClientPathMessage.class),
|
||||
DESTROY_CLIENT_PATH_MESSAGE (DestroyClientPathMessage.CRC, DestroyClientPathMessage.class),
|
||||
GUILD_REQUEST_MESSAGE (GuildRequestMessage.CRC, GuildRequestMessage.class),
|
||||
GUILD_RESPONSE_MESSAGE (GuildResponseMessage.CRC, GuildResponseMessage.class),
|
||||
COMM_PLAYER_MESSAGE (CommPlayerMessage.CRC, CommPlayerMessage.class),
|
||||
|
||||
// Chat
|
||||
CHAT_CREATE_ROOM (ChatCreateRoom.CRC, ChatCreateRoom.class),
|
||||
@@ -316,6 +322,11 @@ public enum PacketType {
|
||||
UNACCEPT_TRANSACTION_MESSAGE (UnAcceptTransactionMessage.CRC, UnAcceptTransactionMessage.class),
|
||||
VERIFY_TRADE_MESSAGE (VerifyTradeMessage.CRC, VerifyTradeMessage.class),
|
||||
|
||||
// GCW
|
||||
GCW_REGIONS_REQUEST_MESSAGE (GcwRegionsReq.CRC, GcwRegionsReq.class),
|
||||
GCW_REGIONS_RESPONSE_MESSAGE (GcwRegionsRsp.CRC, GcwRegionsRsp.class),
|
||||
GCW_GROUPS_RESPONSE_MESSAGE (GcwGroupsRsp.CRC, GcwGroupsRsp.class),
|
||||
|
||||
UNKNOWN (0xFFFFFFFF, SWGPacket.class);
|
||||
|
||||
private static final EnumLookup<Integer, PacketType> LOOKUP = new EnumLookup<>(PacketType.class, PacketType::getCrc);
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2021 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of PSWGCommon. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* PSWGCommon is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* PSWGCommon is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with PSWGCommon. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.network.packets.swg.zone;
|
||||
|
||||
import com.projectswg.common.data.CRC;
|
||||
import com.projectswg.common.data.encodables.oob.OutOfBandPackage;
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.common.network.packets.SWGPacket;
|
||||
|
||||
/**
|
||||
* Makes the client display a comm message with a given text and a given sender.
|
||||
*/
|
||||
public class CommPlayerMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = getCrc("CommPlayerMessage");
|
||||
|
||||
private boolean chronicles;
|
||||
private long objectId;
|
||||
private OutOfBandPackage message;
|
||||
private CRC modelCrc;
|
||||
private String soundFile;
|
||||
private float displayTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param chronicles displays the comm window with Chronicles styling.
|
||||
* @param objectId ID for object to show. Can be overridden by {@code modelCrc} param.
|
||||
* @param message text that is displayed.
|
||||
* @param modelCrc override displayed object from {@code objectId} param with CRC for a shared template to display instead.
|
||||
* @param soundFile plays specified sound to the receiver.
|
||||
* @param displayTime amount of time the comm message is displayed before automatically closing. Time unit is seconds.
|
||||
* If 0, the client tries to automatically determine an appropriate amount of time based on the amount of text shown.
|
||||
* If be
|
||||
*/
|
||||
public CommPlayerMessage(boolean chronicles, long objectId, OutOfBandPackage message, CRC modelCrc, String soundFile, float displayTime) {
|
||||
this.chronicles = chronicles;
|
||||
this.objectId = objectId;
|
||||
this.message = message;
|
||||
this.modelCrc = modelCrc;
|
||||
this.soundFile = soundFile;
|
||||
this.displayTime = displayTime;
|
||||
}
|
||||
|
||||
public CommPlayerMessage(NetBuffer data) {
|
||||
decode(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
if (!super.checkDecode(data, CRC))
|
||||
return;
|
||||
|
||||
chronicles = data.getBoolean();
|
||||
objectId = data.getLong();
|
||||
message = data.getEncodable(OutOfBandPackage.class);
|
||||
modelCrc = data.getEncodable(CRC.class);
|
||||
soundFile = data.getAscii();
|
||||
displayTime = data.getFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
int length = 0;
|
||||
|
||||
length += Short.BYTES;
|
||||
length += Integer.BYTES;
|
||||
length += Byte.BYTES;
|
||||
length += Long.BYTES;
|
||||
length += message.getLength();
|
||||
length += Integer.BYTES;
|
||||
length += Short.BYTES + soundFile.length();
|
||||
length += Float.BYTES;
|
||||
|
||||
NetBuffer data = NetBuffer.allocate(length);
|
||||
data.addShort(2);
|
||||
data.addInt(CRC);
|
||||
data.addBoolean(chronicles);
|
||||
data.addLong(objectId);
|
||||
data.addEncodable(message);
|
||||
data.addEncodable(modelCrc);
|
||||
data.addAscii(soundFile);
|
||||
data.addFloat(displayTime);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPacketData() {
|
||||
return createPacketInformation(
|
||||
"chronicles", chronicles,
|
||||
"objectId", objectId,
|
||||
"message", message,
|
||||
"modelCrc", modelCrc,
|
||||
"soundFile", soundFile,
|
||||
"displayTime", displayTime
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2018 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of Holocore. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* Holocore is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* Holocore is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General 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.data.encodables.gcw.GcwGroup;
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.common.network.packets.SWGPacket;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Shows given locations as Galactic Civil War Contested Zones on the map of the planetary map
|
||||
*/
|
||||
public class GcwGroupsRsp extends SWGPacket {
|
||||
|
||||
public static final int CRC = getCrc("GcwGroupsRsp");
|
||||
|
||||
private final Collection<GcwGroup> groups;
|
||||
|
||||
public GcwGroupsRsp(Collection<GcwGroup> groups) {
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
int regionsLength = groups.stream().mapToInt(GcwGroup::getLength).sum();
|
||||
NetBuffer buffer = NetBuffer.allocate(Short.BYTES + Integer.BYTES + 4 + regionsLength); // 4 is list size variable
|
||||
|
||||
buffer.addShort(2);
|
||||
buffer.addInt(CRC);
|
||||
buffer.addList(groups);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2018 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of Holocore. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* Holocore is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* Holocore is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General 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 GcwRegionsReq extends SWGPacket {
|
||||
|
||||
public static final int CRC = getCrc("GcwRegionsReq");
|
||||
|
||||
public GcwRegionsReq() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
return NetBuffer.allocate(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2018 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of Holocore. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* Holocore is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* Holocore is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General 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.data.encodables.gcw.GcwRegion;
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.common.network.packets.SWGPacket;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Showws given locations in "Galactic Civil War Contested Zone"
|
||||
*/
|
||||
public class GcwRegionsRsp extends SWGPacket {
|
||||
|
||||
public static final int CRC = getCrc("GcwRegionsRsp");
|
||||
|
||||
private final Collection<GcwRegion> regions;
|
||||
|
||||
public GcwRegionsRsp(Collection<GcwRegion> regions) {
|
||||
this.regions = regions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
int regionsLength = regions.stream().mapToInt(GcwRegion::getLength).sum();
|
||||
NetBuffer buffer = NetBuffer.allocate(Short.BYTES + Integer.BYTES + 4 + regionsLength); // 4 is list size variable
|
||||
|
||||
buffer.addShort(2);
|
||||
buffer.addInt(CRC);
|
||||
buffer.addList(regions);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.projectswg.common.network.packets.swg.zone;
|
||||
|
||||
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.packets.SWGPacket;
|
||||
|
||||
/**
|
||||
* Plays an effect at a specified location.
|
||||
*/
|
||||
public class PlayClientEffectLocMessage extends SWGPacket {
|
||||
public static final int CRC = getCrc("PlayClientEffectLocMessage");
|
||||
|
||||
private String effectFile;
|
||||
private Terrain terrain;
|
||||
private Point3D point;
|
||||
private long cellId;
|
||||
private float terrainDelta;
|
||||
private String commandString;
|
||||
|
||||
public PlayClientEffectLocMessage() {
|
||||
}
|
||||
|
||||
public PlayClientEffectLocMessage(String effectFile, Terrain terrain, Point3D point, long cellId, float terrainDelta, String commandString) {
|
||||
this.effectFile = effectFile;
|
||||
this.terrain = terrain;
|
||||
this.point = point;
|
||||
this.cellId = cellId;
|
||||
this.terrainDelta = terrainDelta;
|
||||
this.commandString = commandString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
if (!super.checkDecode(data, CRC))
|
||||
return;
|
||||
|
||||
effectFile = data.getAscii();
|
||||
terrain = Terrain.getTerrainFromName(data.getAscii());
|
||||
point = data.getEncodable(Point3D.class);
|
||||
cellId = data.getLong();
|
||||
terrainDelta = data.getFloat();
|
||||
commandString = data.getAscii();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
NetBuffer data = NetBuffer.allocate(2 + 4 + 2 + effectFile.length() + 2 + terrain.getName().length() + point.getLength() + 8 + 4 + 2 + commandString.length());
|
||||
|
||||
data.addShort(6);
|
||||
data.addInt(CRC);
|
||||
data.addAscii(effectFile);
|
||||
data.addAscii(terrain.getName());
|
||||
data.addEncodable(point);
|
||||
data.addLong(cellId);
|
||||
data.addFloat(terrainDelta);
|
||||
data.addAscii(commandString);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getEffectFile() {
|
||||
return effectFile;
|
||||
}
|
||||
|
||||
public Terrain getTerrain() {
|
||||
return terrain;
|
||||
}
|
||||
|
||||
public Point3D getPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
public long getCellId() {
|
||||
return cellId;
|
||||
}
|
||||
|
||||
public float getTerrainDelta() {
|
||||
return terrainDelta;
|
||||
}
|
||||
|
||||
public String getCommandString() {
|
||||
return commandString;
|
||||
}
|
||||
}
|
||||
@@ -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.zone.guild;
|
||||
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.common.network.packets.SWGPacket;
|
||||
|
||||
public class GuildRequestMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = getCrc("GuildRequestMessage");
|
||||
|
||||
private long objectId;
|
||||
|
||||
public GuildRequestMessage() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
if (!super.checkDecode(data, CRC))
|
||||
return;
|
||||
|
||||
objectId = data.getLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
int length = 14;
|
||||
NetBuffer data = NetBuffer.allocate(length);
|
||||
data.addShort(2);
|
||||
data.addInt(CRC);
|
||||
data.addLong(objectId);
|
||||
return data;
|
||||
}
|
||||
|
||||
public long getObjectId() {
|
||||
return objectId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2015 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of Holocore. *
|
||||
* *
|
||||
* -------------------------------------------------------------------------------- *
|
||||
* *
|
||||
* Holocore is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* Holocore is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.network.packets.swg.zone.guild;
|
||||
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.common.network.packets.SWGPacket;
|
||||
|
||||
public class GuildResponseMessage extends SWGPacket {
|
||||
|
||||
public static final int CRC = getCrc("GuildResponseMessage");
|
||||
|
||||
private long objectId;
|
||||
private String guildName;
|
||||
private String memberTitle;
|
||||
|
||||
public GuildResponseMessage() {
|
||||
|
||||
}
|
||||
|
||||
public GuildResponseMessage(long objectId, String guildName, String memberTitle) {
|
||||
this.objectId = objectId;
|
||||
this.guildName = guildName;
|
||||
this.memberTitle = memberTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
if (!super.checkDecode(data, CRC))
|
||||
return;
|
||||
|
||||
objectId = data.getLong();
|
||||
guildName = data.getAscii();
|
||||
memberTitle = data.getAscii();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
int length = 18 + guildName.length() + memberTitle.length();
|
||||
NetBuffer data = NetBuffer.allocate(length);
|
||||
data.addShort(3);
|
||||
data.addInt(CRC);
|
||||
data.addLong(objectId);
|
||||
data.addAscii(guildName);
|
||||
data.addAscii(memberTitle);
|
||||
return data;
|
||||
}
|
||||
|
||||
public long getObjectId() {
|
||||
return objectId;
|
||||
}
|
||||
|
||||
public String getGuildName() {
|
||||
return guildName;
|
||||
}
|
||||
|
||||
public String getMemberTitle() {
|
||||
return memberTitle;
|
||||
}
|
||||
}
|
||||
@@ -28,11 +28,14 @@ package com.projectswg.common.network.packets.swg.zone.object_controller;
|
||||
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
|
||||
public class CommandTimer extends ObjectController {
|
||||
|
||||
public static final int CRC = 0x0448;
|
||||
|
||||
private EnumSet<CommandTimerFlag> flags;
|
||||
private int sequenceId;
|
||||
private int commandNameCrc;
|
||||
private int cooldownGroupCrc;
|
||||
@@ -41,10 +44,12 @@ public class CommandTimer extends ObjectController {
|
||||
|
||||
public CommandTimer(long objectId) {
|
||||
super(objectId, CRC);
|
||||
this.flags = EnumSet.noneOf(CommandTimerFlag.class);
|
||||
}
|
||||
|
||||
public CommandTimer(NetBuffer data) {
|
||||
super(CRC);
|
||||
this.flags = EnumSet.noneOf(CommandTimerFlag.class);
|
||||
decode(data);
|
||||
}
|
||||
|
||||
@@ -55,7 +60,7 @@ public class CommandTimer extends ObjectController {
|
||||
public NetBuffer encode() {
|
||||
NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 29);
|
||||
encodeHeader(data);
|
||||
data.addByte(4); // 0 for no cooldown, 0x26 to add defaultTime (usually 0.25)
|
||||
data.addByte(flagsToByte()); // 0 for no cooldown, 0x26 to add defaultTime (usually 0.25)
|
||||
data.addInt(sequenceId);
|
||||
data.addInt(0); // Unknown
|
||||
data.addInt(0); // Unknown
|
||||
@@ -65,6 +70,18 @@ public class CommandTimer extends ObjectController {
|
||||
data.addFloat(cooldownMax);
|
||||
return data;
|
||||
}
|
||||
|
||||
public EnumSet<CommandTimerFlag> getFlags() {
|
||||
return flags.clone();
|
||||
}
|
||||
|
||||
public void addFlag(CommandTimerFlag flag) {
|
||||
this.flags.add(flag);
|
||||
}
|
||||
|
||||
public void clearFlag(CommandTimerFlag flag) {
|
||||
this.flags.remove(flag);
|
||||
}
|
||||
|
||||
public int getSequenceId() {
|
||||
return sequenceId;
|
||||
@@ -106,4 +123,51 @@ public class CommandTimer extends ObjectController {
|
||||
this.cooldownMax = cooldownMax;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPacketData() {
|
||||
return createPacketInformation(
|
||||
"objId", getObjectId(),
|
||||
"sequence", sequenceId,
|
||||
"name", com.projectswg.common.data.CRC.getString(commandNameCrc),
|
||||
"cooldownGroup", com.projectswg.common.data.CRC.getString(cooldownGroupCrc),
|
||||
"cooldownMin", cooldownMin,
|
||||
"cooldownMax", cooldownMax
|
||||
);
|
||||
}
|
||||
|
||||
private byte flagsToByte() {
|
||||
int b = 0;
|
||||
for (CommandTimerFlag flag : flags) {
|
||||
b |= flag.getBitmask();
|
||||
}
|
||||
return (byte) b;
|
||||
}
|
||||
|
||||
public enum CommandTimerFlag {
|
||||
WARMUP (0x01), // 1
|
||||
EXECUTE (0x02), // 2
|
||||
COOLDOWN (0x04), // 4
|
||||
FAILED (0x08), // 8
|
||||
FAILED_RETRY (0x10), // 16
|
||||
COOLDOWN2 (0x20); // 32
|
||||
|
||||
private final int bitmask;
|
||||
|
||||
CommandTimerFlag(int bitmask) {
|
||||
this.bitmask = bitmask;
|
||||
}
|
||||
|
||||
public int getBitmask() {
|
||||
return bitmask;
|
||||
}
|
||||
|
||||
public static EnumSet<CommandTimerFlag> getFlags(int bits) {
|
||||
EnumSet<CommandTimerFlag> states = EnumSet.noneOf(CommandTimerFlag.class);
|
||||
for (CommandTimerFlag state : values()) {
|
||||
if ((state.getBitmask() & bits) != 0)
|
||||
states.add(state);
|
||||
}
|
||||
return states;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2018 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of PSWGCommon. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* PSWGCommon is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* PSWGCommon is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with PSWGCommon. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************************/
|
||||
|
||||
package com.projectswg.common.network.packets.swg.zone.object_controller;
|
||||
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
|
||||
public class MissionAcceptRequest extends ObjectController{
|
||||
|
||||
public static final int CRC = 0x00F9;
|
||||
|
||||
private long missionId;
|
||||
private long terminalId;
|
||||
|
||||
public MissionAcceptRequest(NetBuffer data) {
|
||||
super(CRC);
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public long getTerminalId() {
|
||||
return terminalId;
|
||||
}
|
||||
|
||||
public void setTerminalId(long terminalId) {
|
||||
this.terminalId = terminalId;
|
||||
}
|
||||
|
||||
public long getMissionId() {
|
||||
return missionId;
|
||||
}
|
||||
|
||||
public void setMissionId(long missionId) {
|
||||
this.missionId = missionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
decodeHeader(data);
|
||||
setMissionId(data.getLong());
|
||||
setTerminalId(data.getLong());
|
||||
data.getByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 17);
|
||||
encodeHeader(data);
|
||||
data.addLong(getMissionId());
|
||||
data.addLong(getTerminalId());
|
||||
data.addByte(0);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ public class MissionListRequest extends ObjectController{
|
||||
|
||||
public MissionListRequest(NetBuffer data) {
|
||||
super(CRC);
|
||||
decode(data);
|
||||
}
|
||||
|
||||
public long getTerminalId() {
|
||||
|
||||
@@ -26,9 +26,15 @@
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.network.packets.swg.zone.object_controller;
|
||||
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.conversation.NpcConversationMessage;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.conversation.NpcConversationOptions;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.conversation.StartNpcConversation;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.conversation.StopNpcConversation;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.loot.GroupCloseLotteryWindow;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.loot.GroupOpenLotteryWindow;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.loot.GroupRequestLotteryItems;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.quest.QuestCompletedMessage;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.quest.QuestTaskCounterMessage;
|
||||
import me.joshlarson.jlcommon.log.Log;
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.common.network.packets.SWGPacket;
|
||||
@@ -107,6 +113,10 @@ public abstract class ObjectController extends SWGPacket {
|
||||
switch (crc) {
|
||||
case 0x0071: return new DataTransform(data);
|
||||
case 0x00CC: return new CombatAction(data);
|
||||
case StartNpcConversation.CRC: return new StartNpcConversation(data);
|
||||
case NpcConversationMessage.CRC: return new NpcConversationMessage(data);
|
||||
case NpcConversationOptions.CRC: return new NpcConversationOptions(data);
|
||||
case StopNpcConversation.CRC: return new StopNpcConversation(data);
|
||||
case 0x00F1: return new DataTransformWithParent(data);
|
||||
case 0x0116: return new CommandQueueEnqueue(data);
|
||||
case 0x0117: return new CommandQueueDequeue(data);
|
||||
@@ -130,8 +140,11 @@ public abstract class ObjectController extends SWGPacket {
|
||||
case 0x04BC: return new ShowLootBox(data);
|
||||
case 0x04C5: return new IntendedTarget(data);
|
||||
case 0x00F5: return new MissionListRequest(data);
|
||||
case 0x00F9: return new MissionAcceptRequest(data);
|
||||
case 0x041C: return new JTLTerminalSharedMessage(data);
|
||||
case 0x0115: return new SecureTrade(data);
|
||||
case QuestTaskCounterMessage.CRC: return new QuestTaskCounterMessage(data);
|
||||
case QuestCompletedMessage.CRC: return new QuestCompletedMessage(data);
|
||||
}
|
||||
Log.w("Unknown object controller: %08X", crc);
|
||||
return new GenericObjectController(crc, data);
|
||||
|
||||
@@ -47,13 +47,14 @@ public class SpatialChat extends ObjectController {
|
||||
super(objectId, CRC);
|
||||
}
|
||||
|
||||
public SpatialChat(long objectId, long sourceId, long targetId, String text, short balloonType, short moodId) {
|
||||
public SpatialChat(long objectId, long sourceId, long targetId, String text, short balloonType, short moodId, byte languageId) {
|
||||
super(objectId, CRC);
|
||||
this.sourceId = sourceId;
|
||||
this.targetId = targetId;
|
||||
this.text = text;
|
||||
this.balloonType = balloonType;
|
||||
this.moodId = moodId;
|
||||
this.languageId = languageId;
|
||||
}
|
||||
|
||||
public SpatialChat(long objectId, SpatialChat chat) {
|
||||
|
||||
@@ -26,10 +26,8 @@
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.network.packets.swg.zone.object_controller.combat;
|
||||
|
||||
import com.projectswg.common.data.combat.AttackInfo;
|
||||
import com.projectswg.common.data.combat.CombatSpamFilterType;
|
||||
import com.projectswg.common.data.combat.DamageType;
|
||||
import com.projectswg.common.data.combat.HitLocation;
|
||||
import com.projectswg.common.data.combat.*;
|
||||
import com.projectswg.common.data.encodables.oob.OutOfBandPackage;
|
||||
import com.projectswg.common.data.encodables.oob.StringId;
|
||||
import com.projectswg.common.data.location.Point3D;
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
@@ -48,8 +46,8 @@ public class CombatSpam extends ObjectController {
|
||||
private StringId weaponName;
|
||||
private StringId attackName;
|
||||
private AttackInfo info;
|
||||
private String spamMessage;
|
||||
private CombatSpamFilterType spamType;
|
||||
private OutOfBandPackage spamMessage;
|
||||
private CombatSpamType spamType;
|
||||
|
||||
public CombatSpam(long objectId) {
|
||||
super(objectId, CRC);
|
||||
@@ -99,12 +97,12 @@ public class CombatSpam extends ObjectController {
|
||||
info.setParry(data.getBoolean());
|
||||
}
|
||||
} else if (isMessageData(dataType)) {
|
||||
spamMessage = data.getUnicode();
|
||||
spamMessage = data.getEncodable(OutOfBandPackage.class);
|
||||
}
|
||||
info.setCritical(data.getBoolean());
|
||||
info.setGlancing(data.getBoolean());
|
||||
info.setProc(data.getBoolean());
|
||||
spamType = CombatSpamFilterType.getCombatSpamFilterType(data.getInt());
|
||||
spamType = CombatSpamType.getCombatSpamType(data.getInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -146,7 +144,7 @@ public class CombatSpam extends ObjectController {
|
||||
data.addBoolean(info.isParry());
|
||||
}
|
||||
} else if (isMessageData(dataType)) {
|
||||
data.addUnicode(spamMessage);
|
||||
data.addEncodable(spamMessage);
|
||||
}
|
||||
data.addBoolean(info.isCritical());
|
||||
data.addBoolean(info.isGlancing());
|
||||
@@ -162,7 +160,7 @@ public class CombatSpam extends ObjectController {
|
||||
else if (isAttackWeaponName(dataType))
|
||||
size += 1 + attackName.getLength() + weaponName.getLength() + (info.isSuccess() ? 60 : 2);
|
||||
else if (isMessageData(dataType))
|
||||
size += 4 + spamMessage.length() * 2; // I have no idea what's in this struct
|
||||
size += spamMessage.getLength();
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -202,11 +200,11 @@ public class CombatSpam extends ObjectController {
|
||||
return info;
|
||||
}
|
||||
|
||||
public String getSpamMessage() {
|
||||
public OutOfBandPackage getSpamMessage() {
|
||||
return spamMessage;
|
||||
}
|
||||
|
||||
public CombatSpamFilterType getSpamType() {
|
||||
public CombatSpamType getSpamType() {
|
||||
return spamType;
|
||||
}
|
||||
|
||||
@@ -246,11 +244,15 @@ public class CombatSpam extends ObjectController {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void setSpamMessage(String spamMessage) {
|
||||
public void setSpamMessage(OutOfBandPackage spamMessage) {
|
||||
this.spamMessage = spamMessage;
|
||||
}
|
||||
|
||||
public void setSpamType(CombatSpamFilterType spamType) {
|
||||
/**
|
||||
* Controls the color of the combat log entry shown in the client
|
||||
* @param spamType color to show this entry in
|
||||
*/
|
||||
public void setSpamType(CombatSpamType spamType) {
|
||||
this.spamType = spamType;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2021 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of PSWGCommon. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* PSWGCommon is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* PSWGCommon is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with PSWGCommon. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.network.packets.swg.zone.object_controller.conversation;
|
||||
|
||||
import com.projectswg.common.data.encodables.oob.OutOfBandPackage;
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.ObjectController;
|
||||
|
||||
public class NpcConversationMessage extends ObjectController {
|
||||
|
||||
public static final int CRC = 0x00DF;
|
||||
|
||||
private OutOfBandPackage outOfBandPackage;
|
||||
|
||||
public NpcConversationMessage(long objectId, OutOfBandPackage outOfBandPackage) {
|
||||
super(objectId, CRC);
|
||||
this.outOfBandPackage = outOfBandPackage;
|
||||
}
|
||||
|
||||
public NpcConversationMessage(NetBuffer data) {
|
||||
super(CRC);
|
||||
decode(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
decodeHeader(data);
|
||||
|
||||
outOfBandPackage = data.getEncodable(OutOfBandPackage.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + outOfBandPackage.getLength());
|
||||
|
||||
encodeHeader(data);
|
||||
|
||||
data.addEncodable(outOfBandPackage);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2021 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of PSWGCommon. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* PSWGCommon is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* PSWGCommon is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with PSWGCommon. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.network.packets.swg.zone.object_controller.conversation;
|
||||
|
||||
import com.projectswg.common.data.encodables.oob.OutOfBandPackage;
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.ObjectController;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class NpcConversationOptions extends ObjectController {
|
||||
|
||||
public static final int CRC = 0x00E0;
|
||||
|
||||
private Collection<OutOfBandPackage> playerReplies;
|
||||
|
||||
public NpcConversationOptions(long objectId, Collection<OutOfBandPackage> playerReplies) {
|
||||
super(objectId, CRC);
|
||||
this.playerReplies = playerReplies;
|
||||
}
|
||||
|
||||
public NpcConversationOptions(NetBuffer data) {
|
||||
super(CRC);
|
||||
decode(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
decodeHeader(data);
|
||||
byte replyCount = data.getByte();
|
||||
playerReplies = data.getList(OutOfBandPackage.class, replyCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
int length = 0;
|
||||
|
||||
length += HEADER_LENGTH;
|
||||
length += Byte.BYTES;
|
||||
|
||||
for (OutOfBandPackage playerReply : playerReplies) {
|
||||
length += playerReply.getLength();
|
||||
}
|
||||
|
||||
NetBuffer data = NetBuffer.allocate(length);
|
||||
encodeHeader(data);
|
||||
|
||||
data.addByteSizedList(playerReplies);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public Collection<OutOfBandPackage> getPlayerReplies() {
|
||||
return playerReplies;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2021 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of PSWGCommon. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* PSWGCommon is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* PSWGCommon is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with PSWGCommon. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.network.packets.swg.zone.object_controller.conversation;
|
||||
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.ObjectController;
|
||||
|
||||
public class StartNpcConversation extends ObjectController {
|
||||
|
||||
public static final int CRC = 0x00DD;
|
||||
|
||||
private long npcId;
|
||||
|
||||
public StartNpcConversation(long npcId, long objectId) {
|
||||
super(objectId, CRC);
|
||||
this.npcId = npcId;
|
||||
}
|
||||
|
||||
public StartNpcConversation(NetBuffer data) {
|
||||
super(CRC);
|
||||
decode(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
decodeHeader(data);
|
||||
npcId = data.getLong();
|
||||
data.getInt();
|
||||
data.getShort();
|
||||
data.getByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 15);
|
||||
encodeHeader(data);
|
||||
|
||||
data.addLong(npcId);
|
||||
data.addInt(0);
|
||||
data.addShort((short) 0);
|
||||
data.addByte(0);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public long getNpcId() {
|
||||
return npcId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2021 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of PSWGCommon. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* PSWGCommon is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* PSWGCommon is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with PSWGCommon. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.network.packets.swg.zone.object_controller.conversation;
|
||||
|
||||
import com.projectswg.common.data.encodables.oob.StringId;
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.ObjectController;
|
||||
|
||||
public class StopNpcConversation extends ObjectController {
|
||||
|
||||
public static final int CRC = 0x00DE;
|
||||
|
||||
private StringId stringId;
|
||||
private long npcId;
|
||||
|
||||
public StopNpcConversation(long objectId, long npcId, StringId stringId) {
|
||||
super(objectId, CRC);
|
||||
this.npcId = npcId;
|
||||
this.stringId = stringId;
|
||||
}
|
||||
|
||||
public StopNpcConversation(NetBuffer data) {
|
||||
super(CRC);
|
||||
decode(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
decodeHeader(data);
|
||||
|
||||
npcId = data.getLong();
|
||||
stringId = data.getEncodable(StringId.class);
|
||||
data.getLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + Long.BYTES + stringId.getLength() + Long.BYTES);
|
||||
|
||||
encodeHeader(data);
|
||||
|
||||
data.addLong(npcId);
|
||||
data.addEncodable(stringId);
|
||||
data.addLong(0);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2021 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of PSWGCommon. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* PSWGCommon is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* PSWGCommon is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with PSWGCommon. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.network.packets.swg.zone.object_controller.quest;
|
||||
|
||||
import com.projectswg.common.data.CRC;
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.ObjectController;
|
||||
|
||||
public class QuestCompletedMessage extends ObjectController {
|
||||
|
||||
public static final int CRC = 0x04B8;
|
||||
|
||||
private CRC questCrc;
|
||||
|
||||
public QuestCompletedMessage(long objectId, CRC questCrc) {
|
||||
super(objectId, CRC);
|
||||
this.questCrc = questCrc;
|
||||
}
|
||||
|
||||
public QuestCompletedMessage(NetBuffer data) {
|
||||
super(CRC);
|
||||
decode(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
decodeHeader(data);
|
||||
questCrc = data.getEncodable(CRC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + questCrc.getLength());
|
||||
|
||||
encodeHeader(data);
|
||||
data.addEncodable(questCrc);
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2021 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of PSWGCommon. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* PSWGCommon is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* PSWGCommon is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with PSWGCommon. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.network.packets.swg.zone.object_controller.quest;
|
||||
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.ObjectController;
|
||||
|
||||
public class QuestTaskCounterMessage extends ObjectController {
|
||||
|
||||
public static final int CRC = 0x0441;
|
||||
|
||||
private String questName;
|
||||
private String counterText;
|
||||
private int current;
|
||||
private int max;
|
||||
|
||||
public QuestTaskCounterMessage(long objectId, String questName, String counterText, int current, int max) {
|
||||
super(objectId, CRC);
|
||||
this.questName = questName;
|
||||
this.counterText = counterText;
|
||||
this.current = current;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public QuestTaskCounterMessage(NetBuffer data) {
|
||||
super(CRC);
|
||||
decode(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(NetBuffer data) {
|
||||
decodeHeader(data);
|
||||
questName = data.getAscii();
|
||||
max = data.getInt();
|
||||
counterText = data.getUnicode();
|
||||
data.getInt();
|
||||
current = data.getInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetBuffer encode() {
|
||||
NetBuffer data = NetBuffer.allocate(HEADER_LENGTH + 18 + questName.length() + counterText.length() * 2);
|
||||
encodeHeader(data);
|
||||
|
||||
data.addAscii(questName);
|
||||
data.addInt(max);
|
||||
data.addUnicode(counterText);
|
||||
data.addInt(0);
|
||||
data.addInt(current);
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,14 @@ module com.projectswg.common {
|
||||
requires org.mongodb.bson;
|
||||
requires org.jetbrains.annotations;
|
||||
requires org.bouncycastle.provider;
|
||||
requires kotlin.stdlib;
|
||||
|
||||
exports com.projectswg.common.data;
|
||||
exports com.projectswg.common.data.combat;
|
||||
exports com.projectswg.common.data.customization;
|
||||
exports com.projectswg.common.data.encodables.chat;
|
||||
exports com.projectswg.common.data.encodables.galaxy;
|
||||
exports com.projectswg.common.data.encodables.gcw;
|
||||
exports com.projectswg.common.data.encodables.map;
|
||||
exports com.projectswg.common.data.encodables.mongo;
|
||||
exports com.projectswg.common.data.encodables.oob;
|
||||
@@ -57,11 +59,14 @@ module com.projectswg.common {
|
||||
exports com.projectswg.common.network.packets.swg.zone.crafting.resources;
|
||||
exports com.projectswg.common.network.packets.swg.zone.crafting.surveying;
|
||||
exports com.projectswg.common.network.packets.swg.zone.deltas;
|
||||
exports com.projectswg.common.network.packets.swg.zone.guild;
|
||||
exports com.projectswg.common.network.packets.swg.zone.harvesters;
|
||||
exports com.projectswg.common.network.packets.swg.zone.insertion;
|
||||
exports com.projectswg.common.network.packets.swg.zone.object_controller;
|
||||
exports com.projectswg.common.network.packets.swg.zone.object_controller.combat;
|
||||
exports com.projectswg.common.network.packets.swg.zone.object_controller.conversation;
|
||||
exports com.projectswg.common.network.packets.swg.zone.object_controller.loot;
|
||||
exports com.projectswg.common.network.packets.swg.zone.object_controller.quest;
|
||||
exports com.projectswg.common.network.packets.swg.zone.resource;
|
||||
exports com.projectswg.common.network.packets.swg.zone.server_ui;
|
||||
exports com.projectswg.common.network.packets.swg.zone.spatial;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2018 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of Holocore. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* Holocore is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* Holocore is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General 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.location;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TestLocation {
|
||||
|
||||
@Test
|
||||
public void testHeadingConsistent() {
|
||||
Location origin = Location.builder().setPosition(0, 0, 0).build();
|
||||
Location pointNorth = Location.builder().setPosition(0, 0, 10).build();
|
||||
Location pointEast = Location.builder().setPosition(10, 0, 0).build();
|
||||
Location pointWest = Location.builder().setPosition(-10, 0, 0).build();
|
||||
Location pointSouth = Location.builder().setPosition(0, 0, -10).build();
|
||||
|
||||
assertEquals(0, origin.getHeadingTo(pointNorth), 1E-7);
|
||||
assertEquals(0, pointSouth.getHeadingTo(pointNorth), 1E-7);
|
||||
assertEquals(270, origin.getHeadingTo(pointEast), 1E-7);
|
||||
assertEquals(180, origin.getHeadingTo(pointSouth), 1E-7);
|
||||
assertEquals(90, origin.getHeadingTo(pointWest), 1E-7);
|
||||
|
||||
assertEquals(0, Location.builder(origin).setHeading(0).build().getYaw(), 1E-7);
|
||||
assertEquals(90, Location.builder(origin).setHeading(90).build().getYaw(), 1E-7);
|
||||
assertEquals(180, Location.builder(origin).setHeading(180).build().getYaw(), 1E-7);
|
||||
assertEquals(270, Location.builder(origin).setHeading(270).build().getYaw(), 1E-7);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user