mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-03 18:13:11 -04:00
Merge branch 'master' of https://github.com/ProjectSWGCore/NGECore2
Conflicts: src/protocol/swg/ObjControllerMessage.java src/resources/objects/player/PlayerMessageBuilder.java src/services/travel/TravelService.java
This commit is contained in:
@@ -22,19 +22,27 @@
|
||||
package resources.objects;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.buffer.SimpleBufferAllocator;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import resources.common.StringUtilities;
|
||||
|
||||
|
||||
@Persistent
|
||||
public abstract class Delta implements IDelta {
|
||||
|
||||
public Delta() { }
|
||||
|
||||
@NotPersistent
|
||||
protected final Object objectMutex = new Object();
|
||||
public SimpleBufferAllocator bufferPool = new SimpleBufferAllocator();
|
||||
@NotPersistent
|
||||
private static SimpleBufferAllocator bufferPool = new SimpleBufferAllocator();
|
||||
|
||||
public Delta() {
|
||||
|
||||
}
|
||||
|
||||
protected String getAsciiString(ByteBuffer buffer) {
|
||||
return StringUtilities.getAsciiString(buffer);
|
||||
@@ -56,4 +64,8 @@ public abstract class Delta implements IDelta {
|
||||
return ((byte) ((variable) ? 1 : 0));
|
||||
}
|
||||
|
||||
public static IoBuffer createBuffer(int size) {
|
||||
return bufferPool.allocate(size, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -346,14 +346,19 @@ public class SWGList<E> implements List<E> {
|
||||
|
||||
private byte[] item(int type, int index, byte[] data, boolean useIndex, boolean useData) {
|
||||
int size = 1 + ((useIndex) ? 2 : 0) + ((useData) ? data.length : 0);
|
||||
|
||||
|
||||
if (messageBuilder == null) {
|
||||
updateCounter++;
|
||||
return new byte[] { };
|
||||
}
|
||||
|
||||
IoBuffer buffer = messageBuilder.bufferPool.allocate((size), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.put((byte) type);
|
||||
if (useIndex) buffer.putShort((short) index);
|
||||
if (useData) buffer.put(data);
|
||||
|
||||
|
||||
updateCounter++;
|
||||
|
||||
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
|
||||
@@ -90,8 +90,8 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
private float slopeModAngle = 1;
|
||||
private float slopeModPercent = 1;
|
||||
private float turnRadius = 1;
|
||||
private float walkSpeed = (float) 2.75;
|
||||
private float waterModPercent = 1;
|
||||
private float walkSpeed = (float) 1.549;
|
||||
private float waterModPercent = (float) 0.75;
|
||||
private SWGList<String> abilities;
|
||||
private int abilitiesUpdateCounter = 0;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.Map.Entry;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import engine.resources.common.CRC;
|
||||
import resources.common.StringUtilities;
|
||||
import resources.objects.ObjectMessageBuilder;
|
||||
import resources.objects.waypoint.WaypointObject;
|
||||
|
||||
@@ -362,7 +363,7 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder {
|
||||
PlayerObject player = (PlayerObject) object;
|
||||
player.setXpListUpdateCounter(player.getXpListUpdateCounter() + 1);
|
||||
|
||||
IoBuffer result = bufferPool.allocate(17 + type.length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
IoBuffer result = bufferPool.allocate(15 + type.length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
result.putInt(1);
|
||||
result.putInt(player.getXpListUpdateCounter());
|
||||
@@ -372,12 +373,23 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
int size = result.position();
|
||||
result.flip();
|
||||
|
||||
result = createDelta("PLAY", (byte) 8, (short) 1, (short) 0, result, size + 4);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IoBuffer buildProfessionWheelPositionDelta(String professionWheelPosition) {
|
||||
IoBuffer buffer = bufferPool.allocate(2 + professionWheelPosition.length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.put(getAsciiString(professionWheelPosition));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
|
||||
buffer = createDelta("PLAY", (byte) 8, (short) 1, (short) 8, buffer, size + 4);
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildWaypointAddDelta(WaypointObject waypoint) {
|
||||
|
||||
PlayerObject player = (PlayerObject) object;
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import resources.common.Console;
|
||||
import resources.objects.intangible.IntangibleObject;
|
||||
import resources.objects.waypoint.WaypointObject;
|
||||
|
||||
@@ -41,7 +42,7 @@ import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=3)
|
||||
@Persistent(version=5)
|
||||
public class PlayerObject extends IntangibleObject {
|
||||
|
||||
// PLAY 3
|
||||
@@ -116,6 +117,9 @@ public class PlayerObject extends IntangibleObject {
|
||||
|
||||
private int jediState = 0; // unused in NGE
|
||||
|
||||
private String biography = "";
|
||||
private String spouse;
|
||||
|
||||
@NotPersistent
|
||||
private PlayerMessageBuilder messageBuilder;
|
||||
|
||||
@@ -228,6 +232,8 @@ public class PlayerObject extends IntangibleObject {
|
||||
synchronized(objectMutex) {
|
||||
xpExists = xpList.containsKey(type);
|
||||
xpList.put(type, amount);
|
||||
Console.println("Put " + type + " exp of " + amount + " in the map.");
|
||||
Console.println("Map is now: " + xpList.get(type).intValue());
|
||||
}
|
||||
|
||||
if (getContainer() != null && getContainer().getClient() != null && getContainer().getClient().getSession() != null) {
|
||||
@@ -342,6 +348,9 @@ public class PlayerObject extends IntangibleObject {
|
||||
synchronized(objectMutex) {
|
||||
this.professionWheelPosition = professionWheelPosition;
|
||||
}
|
||||
if (getContainer() != null && getContainer().getClient() != null && getContainer().getClient().getSession() != null) {
|
||||
getContainer().getClient().getSession().write(messageBuilder.buildProfessionWheelPositionDelta(professionWheelPosition));
|
||||
}
|
||||
}
|
||||
|
||||
public int getExperimentationFlag() {
|
||||
@@ -664,6 +673,26 @@ public class PlayerObject extends IntangibleObject {
|
||||
}
|
||||
}
|
||||
|
||||
public String getBiography() {
|
||||
return biography;
|
||||
}
|
||||
|
||||
public void setBiography(String biography) {
|
||||
synchronized(objectMutex) {
|
||||
this.biography = biography;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSpouseName() {
|
||||
return spouse;
|
||||
}
|
||||
|
||||
public void setSpouseName(String spouse) {
|
||||
synchronized(objectMutex) {
|
||||
this.spouse = spouse;
|
||||
}
|
||||
}
|
||||
|
||||
public int getFlagBitmask() {
|
||||
synchronized(objectMutex) {
|
||||
return flagBitmask;
|
||||
|
||||
@@ -140,6 +140,16 @@ public class TangibleMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildCustomNameDelta(String customName) {
|
||||
IoBuffer buffer = bufferPool.allocate(getUnicodeString(customName).length, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.put(getUnicodeString(customName));
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("TANO", (byte) 3, (short) 1, (short) 2, buffer, size + 4);
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@@ -87,6 +87,12 @@ public class TangibleObject extends SWGObject {
|
||||
super();
|
||||
messageBuilder = new TangibleMessageBuilder(this);
|
||||
}
|
||||
|
||||
public void setCustomName2(String customName) {
|
||||
setCustomName(customName);
|
||||
|
||||
notifyObservers(messageBuilder.buildCustomNameDelta(customName), true);
|
||||
}
|
||||
|
||||
public int getIncapTimer() {
|
||||
return incapTimer;
|
||||
|
||||
@@ -154,7 +154,10 @@ public class WeaponObject extends TangibleObject {
|
||||
}
|
||||
|
||||
public int getDamagePerSecond() {
|
||||
return (int) (((getMaxDamage() + getElementalDamage() + getMinDamage() + getElementalDamage()) / 2 + getElementalDamage()) * (1 / getAttackSpeed()));
|
||||
if (getElementalType() != null)
|
||||
return (int) (((getMaxDamage() + getElementalDamage() + getMinDamage() + getElementalDamage()) / 2 + getElementalDamage()) * (1 / getAttackSpeed()));
|
||||
else
|
||||
return (int) (((getMaxDamage() + getMinDamage()) / 2 ) * (1 / getAttackSpeed()));
|
||||
}
|
||||
|
||||
public int getWeaponType() {
|
||||
|
||||
Reference in New Issue
Block a user